Compare commits
4 Commits
feat/remov
...
aea2cbceba
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aea2cbceba
|
||
|
|
cb89b16dd8
|
||
|
|
4217621574
|
||
|
|
22f285eaff
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,4 +4,3 @@ node_modules/
|
|||||||
# Added by cargo
|
# Added by cargo
|
||||||
|
|
||||||
/target
|
/target
|
||||||
.direnv/
|
|
||||||
|
|||||||
357
Cargo.lock
generated
357
Cargo.lock
generated
@@ -1,80 +1,176 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 4
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.5.0"
|
version = "1.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "box"
|
name = "box"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"console_error_panic_hook",
|
||||||
"nodarium_macros",
|
"nodarium_macros",
|
||||||
"nodarium_utils",
|
"nodarium_utils",
|
||||||
|
"serde",
|
||||||
|
"serde-wasm-bindgen",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-test",
|
||||||
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "branch"
|
name = "branch"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"console_error_panic_hook",
|
||||||
|
"glam",
|
||||||
"nodarium_macros",
|
"nodarium_macros",
|
||||||
"nodarium_utils",
|
"nodarium_utils",
|
||||||
|
"serde",
|
||||||
|
"serde-wasm-bindgen",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-test",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bumpalo"
|
||||||
|
version = "3.16.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "console_error_panic_hook"
|
||||||
|
version = "0.1.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "float"
|
name = "float"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"console_error_panic_hook",
|
||||||
"nodarium_macros",
|
"nodarium_macros",
|
||||||
"nodarium_utils",
|
"nodarium_utils",
|
||||||
|
"serde",
|
||||||
|
"serde-wasm-bindgen",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-test",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glam"
|
name = "glam"
|
||||||
version = "0.30.10"
|
version = "0.27.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "19fc433e8437a212d1b6f1e68c7824af3aed907da60afa994e7f542d18d12aa9"
|
checksum = "9e05e7e6723e3455f4818c7b26e855439f7546cf617ef669d1adedb8669e5cb9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gravity"
|
name = "gravity"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"console_error_panic_hook",
|
||||||
"glam",
|
"glam",
|
||||||
"nodarium_macros",
|
"nodarium_macros",
|
||||||
"nodarium_utils",
|
"nodarium_utils",
|
||||||
]
|
"noise",
|
||||||
|
"serde",
|
||||||
[[package]]
|
"serde-wasm-bindgen",
|
||||||
name = "instance"
|
"wasm-bindgen",
|
||||||
version = "0.1.0"
|
"wasm-bindgen-test",
|
||||||
dependencies = [
|
"web-sys",
|
||||||
"glam",
|
|
||||||
"nodarium_macros",
|
|
||||||
"nodarium_utils",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "1.0.17"
|
version = "1.0.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
|
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "js-sys"
|
||||||
|
version = "0.3.69"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d"
|
||||||
|
dependencies = [
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.21"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "math"
|
name = "math"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"console_error_panic_hook",
|
||||||
"nodarium_macros",
|
"nodarium_macros",
|
||||||
"nodarium_utils",
|
"nodarium_utils",
|
||||||
|
"serde",
|
||||||
|
"serde-wasm-bindgen",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-test",
|
||||||
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "max-plantarium-triangle"
|
||||||
version = "2.7.6"
|
version = "0.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
dependencies = [
|
||||||
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
|
"console_error_panic_hook",
|
||||||
|
"nodarium_macros",
|
||||||
|
"nodarium_utils",
|
||||||
|
"serde",
|
||||||
|
"serde-wasm-bindgen",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-test",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "max-plantarium-vec3"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"console_error_panic_hook",
|
||||||
|
"nodarium_macros",
|
||||||
|
"nodarium_utils",
|
||||||
|
"serde",
|
||||||
|
"serde-wasm-bindgen",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-test",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nodarium_instance"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"console_error_panic_hook",
|
||||||
|
"glam",
|
||||||
|
"nodarium_macros",
|
||||||
|
"nodarium_utils",
|
||||||
|
"serde",
|
||||||
|
"serde-wasm-bindgen",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-test",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nodarium_macros"
|
name = "nodarium_macros"
|
||||||
@@ -84,7 +180,7 @@ dependencies = [
|
|||||||
"quote",
|
"quote",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"syn",
|
"syn 1.0.109",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -99,19 +195,29 @@ dependencies = [
|
|||||||
name = "nodarium_utils"
|
name = "nodarium_utils"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"console_error_panic_hook",
|
||||||
"glam",
|
"glam",
|
||||||
"noise 0.9.0",
|
"noise",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "noise"
|
name = "nodes-noise"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"console_error_panic_hook",
|
||||||
|
"glam",
|
||||||
"nodarium_macros",
|
"nodarium_macros",
|
||||||
"nodarium_utils",
|
"nodarium_utils",
|
||||||
"noise 0.9.0",
|
"noise",
|
||||||
|
"serde",
|
||||||
|
"serde-wasm-bindgen",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-test",
|
||||||
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -127,35 +233,48 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.19"
|
version = "0.2.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "once_cell"
|
||||||
|
version = "1.19.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "output"
|
name = "output"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"console_error_panic_hook",
|
||||||
|
"glam",
|
||||||
"nodarium_macros",
|
"nodarium_macros",
|
||||||
"nodarium_utils",
|
"nodarium_utils",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-test",
|
||||||
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.105"
|
version = "1.0.81"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7"
|
checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.43"
|
version = "1.0.36"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a"
|
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
@@ -188,76 +307,103 @@ dependencies = [
|
|||||||
name = "random"
|
name = "random"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"console_error_panic_hook",
|
||||||
"nodarium_macros",
|
"nodarium_macros",
|
||||||
"nodarium_utils",
|
"nodarium_utils",
|
||||||
|
"serde",
|
||||||
|
"serde-wasm-bindgen",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-test",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rotate"
|
name = "rotate"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"console_error_panic_hook",
|
||||||
"glam",
|
"glam",
|
||||||
"nodarium_macros",
|
"nodarium_macros",
|
||||||
"nodarium_utils",
|
"nodarium_utils",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde-wasm-bindgen",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-test",
|
||||||
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scoped-tls"
|
||||||
|
version = "1.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.228"
|
version = "1.0.198"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_core",
|
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_core"
|
name = "serde-wasm-bindgen"
|
||||||
version = "1.0.228"
|
version = "0.4.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
checksum = "e3b4c031cd0d9014307d82b8abf653c0290fbdaeb4c02d00c63cf52f728628bf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"js-sys",
|
||||||
|
"serde",
|
||||||
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.228"
|
version = "1.0.198"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn 2.0.60",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.149"
|
version = "1.0.116"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
|
checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"memchr",
|
"ryu",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_core",
|
|
||||||
"zmij",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stem"
|
name = "stem"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"console_error_panic_hook",
|
||||||
"nodarium_macros",
|
"nodarium_macros",
|
||||||
"nodarium_utils",
|
"nodarium_utils",
|
||||||
|
"serde",
|
||||||
|
"serde-wasm-bindgen",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-test",
|
||||||
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.114"
|
version = "1.0.109"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a"
|
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -265,30 +411,119 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "triangle"
|
name = "syn"
|
||||||
version = "0.1.0"
|
version = "2.0.60"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nodarium_macros",
|
"proc-macro2",
|
||||||
"nodarium_utils",
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.22"
|
version = "1.0.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vec3"
|
name = "wasm-bindgen"
|
||||||
version = "0.1.0"
|
version = "0.2.92"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nodarium_macros",
|
"cfg-if",
|
||||||
"nodarium_utils",
|
"wasm-bindgen-macro",
|
||||||
"serde",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zmij"
|
name = "wasm-bindgen-backend"
|
||||||
version = "1.0.15"
|
version = "0.2.92"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "94f63c051f4fe3c1509da62131a678643c5b6fbdc9273b2b79d4378ebda003d2"
|
checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da"
|
||||||
|
dependencies = [
|
||||||
|
"bumpalo",
|
||||||
|
"log",
|
||||||
|
"once_cell",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.60",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-futures"
|
||||||
|
version = "0.4.42"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro"
|
||||||
|
version = "0.2.92"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"wasm-bindgen-macro-support",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-macro-support"
|
||||||
|
version = "0.2.92"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.60",
|
||||||
|
"wasm-bindgen-backend",
|
||||||
|
"wasm-bindgen-shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-shared"
|
||||||
|
version = "0.2.92"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-test"
|
||||||
|
version = "0.3.42"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d9bf62a58e0780af3e852044583deee40983e5886da43a271dd772379987667b"
|
||||||
|
dependencies = [
|
||||||
|
"console_error_panic_hook",
|
||||||
|
"js-sys",
|
||||||
|
"scoped-tls",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-futures",
|
||||||
|
"wasm-bindgen-test-macro",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-bindgen-test-macro"
|
||||||
|
version = "0.3.42"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.60",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "web-sys"
|
||||||
|
version = "0.3.69"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef"
|
||||||
|
dependencies = [
|
||||||
|
"js-sys",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|||||||
@@ -14,30 +14,29 @@
|
|||||||
"@nodarium/ui": "link:../packages/ui",
|
"@nodarium/ui": "link:../packages/ui",
|
||||||
"@nodarium/utils": "link:../packages/utils",
|
"@nodarium/utils": "link:../packages/utils",
|
||||||
"@sveltejs/kit": "^2.50.0",
|
"@sveltejs/kit": "^2.50.0",
|
||||||
"@tailwindcss/vite": "^4.1.18",
|
|
||||||
"@threlte/core": "8.3.1",
|
"@threlte/core": "8.3.1",
|
||||||
"@threlte/extras": "9.7.1",
|
"@threlte/extras": "9.7.1",
|
||||||
|
"@types/three": "^0.182.0",
|
||||||
|
"@unocss/reset": "^66.6.0",
|
||||||
"comlink": "^4.4.2",
|
"comlink": "^4.4.2",
|
||||||
"file-saver": "^2.0.5",
|
"file-saver": "^2.0.5",
|
||||||
"idb": "^8.0.3",
|
"idb": "^8.0.3",
|
||||||
"jsondiffpatch": "^0.7.3",
|
"jsondiffpatch": "^0.7.3",
|
||||||
"tailwindcss": "^4.1.18",
|
"three": "^0.182.0"
|
||||||
"three": "^0.182.0",
|
|
||||||
"wabt": "^1.0.39"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@iconify-json/tabler": "^1.2.26",
|
"@iconify-json/tabler": "^1.2.26",
|
||||||
"@iconify/tailwind4": "^1.2.1",
|
|
||||||
"@nodarium/types": "link:../packages/types",
|
"@nodarium/types": "link:../packages/types",
|
||||||
"@sveltejs/adapter-static": "^3.0.10",
|
"@sveltejs/adapter-static": "^3.0.10",
|
||||||
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
||||||
"@tsconfig/svelte": "^5.0.6",
|
"@tsconfig/svelte": "^5.0.6",
|
||||||
"@types/file-saver": "^2.0.7",
|
"@types/file-saver": "^2.0.7",
|
||||||
"@types/three": "^0.182.0",
|
"@unocss/preset-icons": "^66.6.0",
|
||||||
"svelte": "^5.46.4",
|
"svelte": "^5.46.4",
|
||||||
"svelte-check": "^4.3.5",
|
"svelte-check": "^4.3.5",
|
||||||
"tslib": "^2.8.1",
|
"tslib": "^2.8.1",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
|
"unocss": "^66.6.0",
|
||||||
"vite": "^7.3.1",
|
"vite": "^7.3.1",
|
||||||
"vite-plugin-comlink": "^5.3.0",
|
"vite-plugin-comlink": "^5.3.0",
|
||||||
"vite-plugin-glsl": "^1.5.5",
|
"vite-plugin-glsl": "^1.5.5",
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
@import "tailwindcss";
|
|
||||||
@source "../../packages/ui/**/*.svelte";
|
|
||||||
@plugin "@iconify/tailwind4" {
|
|
||||||
prefix: "i";
|
|
||||||
icon-sets: from-folder(custom, "./src/lib/icons")
|
|
||||||
};
|
|
||||||
@@ -177,11 +177,9 @@
|
|||||||
<EdgeEl z={graphState.cameraPosition[2]} {x1} {y1} {x2} {y2} />
|
<EdgeEl z={graphState.cameraPosition[2]} {x1} {y1} {x2} {y2} />
|
||||||
{/each}
|
{/each}
|
||||||
|
|
||||||
<HTML transform={false}>
|
<HTML>
|
||||||
<div
|
<div
|
||||||
role="tree"
|
|
||||||
id="graph"
|
id="graph"
|
||||||
tabindex="0"
|
|
||||||
class="wrapper"
|
class="wrapper"
|
||||||
style:transform={`scale(${graphState.cameraPosition[2] * 0.1})`}
|
style:transform={`scale(${graphState.cameraPosition[2] * 0.1})`}
|
||||||
class:hovering-sockets={graphState.activeSocket}
|
class:hovering-sockets={graphState.activeSocket}
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { getContext, type Snippet } from "svelte";
|
import { getContext } from "svelte";
|
||||||
|
|
||||||
let index = $state(-1);
|
let index = -1;
|
||||||
let wrapper: HTMLDivElement;
|
let wrapper: HTMLDivElement;
|
||||||
|
|
||||||
const { children } = $props<{ children?: Snippet }>();
|
$: if (index === -1) {
|
||||||
|
|
||||||
$effect(() => {
|
|
||||||
if (index === -1) {
|
|
||||||
index = getContext<() => number>("registerCell")();
|
index = getContext<() => number>("registerCell")();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
const sizes = getContext<{ value: string[] }>("sizes");
|
const sizes = getContext<{ value: string[] }>("sizes");
|
||||||
|
|
||||||
@@ -35,8 +31,8 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window
|
<svelte:window
|
||||||
onmouseup={() => (mouseDown = false)}
|
on:mouseup={() => (mouseDown = false)}
|
||||||
onmousemove={handleMouseMove}
|
on:mousemove={handleMouseMove}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#if index > 0}
|
{#if index > 0}
|
||||||
@@ -44,12 +40,12 @@
|
|||||||
class="seperator"
|
class="seperator"
|
||||||
role="button"
|
role="button"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
onmousedown={handleMouseDown}
|
on:mousedown={handleMouseDown}
|
||||||
></div>
|
></div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="cell" bind:this={wrapper}>
|
<div class="cell" bind:this={wrapper}>
|
||||||
{@render children?.()}
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { setContext, type Snippet } from "svelte";
|
import { setContext } from "svelte";
|
||||||
|
|
||||||
const { children, id } = $props<{ children?: Snippet; id?: string }>();
|
export let id = "grid-0";
|
||||||
|
|
||||||
setContext("grid-id", id);
|
setContext("grid-id", id);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{@render children({ id })}
|
<slot {id} />
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import fs from "fs/promises";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
||||||
export async function getWasm(id: `${string}/${string}/${string}`) {
|
export async function getWasm(id: `${string}/${string}/${string}`) {
|
||||||
const filePath = path.resolve(`../nodes/${id}/pkg/node.wasm`);
|
const filePath = path.resolve(`../nodes/${id}/pkg/index_bg.wasm`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fs.access(filePath);
|
await fs.access(filePath);
|
||||||
|
|||||||
@@ -14,10 +14,7 @@
|
|||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<div class="bars">
|
<div class="bars">
|
||||||
{#each values as value, i}
|
{#each values as value, i}
|
||||||
<div
|
<div class="bar bg-{colors[i]}" style="width: {(value / total) * 100}%;">
|
||||||
class="bar bg-{colors[i]}-400"
|
|
||||||
style="width: {(value / total) * 100}%;"
|
|
||||||
>
|
|
||||||
{Math.round(value)}ms
|
{Math.round(value)}ms
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
@@ -25,12 +22,10 @@
|
|||||||
|
|
||||||
<div class="labels mt-2">
|
<div class="labels mt-2">
|
||||||
{#each values as _label, i}
|
{#each values as _label, i}
|
||||||
<div class="text-{colors[i]}-400">{labels[i]}</div>
|
<div class="text-{colors[i]}">{labels[i]}</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
<span
|
<span class="bg-red bg-green bg-blue text-red text-green text-blue"></span>
|
||||||
class="bg-red-400 bg-green-400 bg-blue-400 text-red-400 text-green-400 text-blue-400"
|
|
||||||
></span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -244,14 +244,13 @@ export class MemoryRuntimeExecutor implements RuntimeExecutor {
|
|||||||
}
|
}
|
||||||
this.perf?.addPoint("cache-hit", 0);
|
this.perf?.addPoint("cache-hit", 0);
|
||||||
|
|
||||||
log.group(`executing ${node_type.id}-${node.id}`);
|
log.group(`executing ${node_type.id || node.id}`);
|
||||||
log.log(`Inputs:`, inputs);
|
log.log(`Inputs:`, inputs);
|
||||||
a = performance.now();
|
a = performance.now();
|
||||||
results[node.id] = node_type.execute(encoded_inputs);
|
results[node.id] = node_type.execute(encoded_inputs);
|
||||||
log.log("Executed", node.type, node.id)
|
|
||||||
b = performance.now();
|
b = performance.now();
|
||||||
|
|
||||||
if (this.cache && node.id !== outputNode.id) {
|
if (this.cache) {
|
||||||
this.cache.set(inputHash, results[node.id]);
|
this.cache.set(inputHash, results[node.id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import NestedSettings from "./NestedSettings.svelte";
|
import NestedSettings from "./NestedSettings.svelte";
|
||||||
import { localState } from "$lib/helpers/localState.svelte";
|
import { localState } from "$lib/helpers/localState.svelte";
|
||||||
import type { NodeInput } from "@nodarium/types";
|
import type { NodeInput } from "@nodarium/types";
|
||||||
import Input from "@nodarium/ui";
|
import { Input } from "@nodarium/ui";
|
||||||
|
|
||||||
type Button = { type: "button"; callback: () => void; label?: string };
|
type Button = { type: "button"; callback: () => void; label?: string };
|
||||||
|
|
||||||
|
|||||||
@@ -1,46 +1,43 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { getContext, type Snippet } from "svelte";
|
import { getContext } from "svelte";
|
||||||
import type { PanelState } from "./PanelState.svelte";
|
import type { Readable } from "svelte/store";
|
||||||
|
|
||||||
const {
|
export let id: string;
|
||||||
id,
|
export let icon: string = "";
|
||||||
icon = "",
|
export let title = "";
|
||||||
title = "",
|
export let classes = "";
|
||||||
classes = "",
|
export let hidden: boolean | undefined = undefined;
|
||||||
hidden,
|
|
||||||
children,
|
|
||||||
} = $props<{
|
|
||||||
id: string;
|
|
||||||
icon?: string;
|
|
||||||
title?: string;
|
|
||||||
classes?: string;
|
|
||||||
hidden?: boolean;
|
|
||||||
children?: Snippet;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const panelState = getContext<PanelState>("panel-state");
|
const setVisibility =
|
||||||
|
getContext<(id: string, visible: boolean) => void>("setVisibility");
|
||||||
|
|
||||||
const panel = panelState.registerPanel(id, icon, classes, hidden);
|
$: if (typeof hidden === "boolean") {
|
||||||
$effect(() => {
|
setVisibility(id, !hidden);
|
||||||
panel.hidden = hidden;
|
}
|
||||||
});
|
|
||||||
|
const registerPanel =
|
||||||
|
getContext<
|
||||||
|
(id: string, icon: string, classes: string) => Readable<boolean>
|
||||||
|
>("registerPanel");
|
||||||
|
|
||||||
|
let visible = registerPanel(id, icon, classes);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if panelState.activePanel.value === id}
|
{#if $visible}
|
||||||
<div class="wrapper" class:hidden>
|
<div class="wrapper" class:hidden>
|
||||||
{#if title}
|
{#if title}
|
||||||
<header>
|
<header>
|
||||||
<h3>{title}</h3>
|
<h3>{title}</h3>
|
||||||
</header>
|
</header>
|
||||||
{/if}
|
{/if}
|
||||||
{@render children?.()}
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
header {
|
header {
|
||||||
border-bottom: solid thin var(--outline);
|
border-bottom: solid thin var(--outline);
|
||||||
height: 70px;
|
height: 69px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
import { localState } from "$lib/helpers/localState.svelte";
|
|
||||||
|
|
||||||
type Panel = {
|
|
||||||
icon: string;
|
|
||||||
classes: string;
|
|
||||||
hidden?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class PanelState {
|
|
||||||
|
|
||||||
panels = $state<Record<string, Panel>>({});
|
|
||||||
activePanel = localState<string | boolean>("node.activePanel", "")
|
|
||||||
|
|
||||||
get keys() {
|
|
||||||
return Object.keys(this.panels);
|
|
||||||
}
|
|
||||||
|
|
||||||
public registerPanel(id: string, icon: string, classes: string, hidden: boolean): Panel {
|
|
||||||
const state = $state({
|
|
||||||
icon: icon,
|
|
||||||
classes: classes,
|
|
||||||
hidden: hidden,
|
|
||||||
});
|
|
||||||
this.panels[id] = state;
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public toggleOpen() {
|
|
||||||
if (this.activePanel.value) {
|
|
||||||
this.activePanel.value = false;
|
|
||||||
} else {
|
|
||||||
this.activePanel.value = this.keys[0]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +1,77 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { setContext, type Snippet } from "svelte";
|
import localStore from "$lib/helpers/localStore";
|
||||||
import { PanelState } from "./PanelState.svelte";
|
import { setContext } from "svelte";
|
||||||
|
import { derived } from "svelte/store";
|
||||||
|
|
||||||
const state = new PanelState();
|
let panels: Record<
|
||||||
setContext("panel-state", state);
|
string,
|
||||||
|
{
|
||||||
|
icon: string;
|
||||||
|
id: string;
|
||||||
|
classes: string;
|
||||||
|
visible?: boolean;
|
||||||
|
}
|
||||||
|
> = {};
|
||||||
|
|
||||||
const { children } = $props<{ children?: Snippet }>();
|
const activePanel = localStore<keyof typeof panels | false>(
|
||||||
|
"nodes.settings.activePanel",
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
|
$: keys = panels
|
||||||
|
? (Object.keys(panels) as unknown as (keyof typeof panels)[]).filter(
|
||||||
|
(key) => !!panels[key]?.id,
|
||||||
|
)
|
||||||
|
: [];
|
||||||
|
|
||||||
|
setContext("setVisibility", (id: string, visible: boolean) => {
|
||||||
|
panels[id].visible = visible;
|
||||||
|
panels = { ...panels };
|
||||||
|
});
|
||||||
|
|
||||||
|
setContext("registerPanel", (id: string, icon: string, classes: string) => {
|
||||||
|
panels[id] = { id, icon, classes };
|
||||||
|
return derived(activePanel, ($activePanel) => {
|
||||||
|
return $activePanel === id;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function setActivePanel(panel: keyof typeof panels | false) {
|
||||||
|
if (panel === $activePanel) {
|
||||||
|
$activePanel = false;
|
||||||
|
} else if (panel) {
|
||||||
|
$activePanel = panel;
|
||||||
|
} else {
|
||||||
|
$activePanel = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="wrapper" class:visible={state.activePanel.value}>
|
<div class="wrapper" class:visible={$activePanel}>
|
||||||
<div class="tabs">
|
<div class="tabs">
|
||||||
<button aria-label="Close" onclick={() => state.toggleOpen()}>
|
|
||||||
<span class="icon-[tabler--settings]"></span>
|
|
||||||
<span class="absolute i-[tabler--chevron-left] w-6 h-6 block"></span>
|
|
||||||
</button>
|
|
||||||
{#each state.keys as panelId (panelId)}
|
|
||||||
{#if !state.panels[panelId].hidden}
|
|
||||||
<button
|
<button
|
||||||
aria-label={panelId}
|
aria-label="Close"
|
||||||
class="tab {state.panels[panelId].classes}"
|
on:click={() => {
|
||||||
class:active={panelId === state.activePanel.value}
|
setActivePanel($activePanel ? false : keys[0]);
|
||||||
onclick={() => (state.activePanel.value = panelId)}
|
}}
|
||||||
>
|
>
|
||||||
<span class={`block w-6 h-6 iconify ${state.panels[panelId].icon}`}
|
<span class="absolute i-tabler-chevron-left w-6 h-6 block"></span>
|
||||||
></span>
|
</button>
|
||||||
|
{#each keys as panel (panels[panel].id)}
|
||||||
|
{#if panels[panel].visible !== false}
|
||||||
|
<button
|
||||||
|
aria-label={panel}
|
||||||
|
class="tab {panels[panel].classes}"
|
||||||
|
class:active={panel === $activePanel}
|
||||||
|
on:click={() => setActivePanel(panel)}
|
||||||
|
>
|
||||||
|
<span class={`block w-6 h-6 ${panels[panel].icon}`}></span>
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{@render children?.()}
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
FileSaver.saveAs(blob, name + "." + extension);
|
FileSaver.saveAs(blob, name + "." + extension);
|
||||||
};
|
};
|
||||||
|
|
||||||
const { scene } = $props<{ scene: Group }>();
|
export let scene: Group;
|
||||||
|
|
||||||
let gltfExporter: GLTFExporter;
|
let gltfExporter: GLTFExporter;
|
||||||
async function exportGltf() {
|
async function exportGltf() {
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="p-4">
|
<div class="p-2">
|
||||||
<button onclick={exportObj}> export obj </button>
|
<button on:click={exportObj}> export obj </button>
|
||||||
<button onclick={exportGltf}> export gltf </button>
|
<button on:click={exportGltf}> export gltf </button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -13,8 +13,7 @@
|
|||||||
let { keymaps }: Props = $props();
|
let { keymaps }: Props = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="p-4">
|
<table class="wrapper">
|
||||||
<table class="wrapper">
|
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each keymaps as keymap}
|
{#each keymaps as keymap}
|
||||||
<tr>
|
<tr>
|
||||||
@@ -39,8 +38,7 @@
|
|||||||
{/each}
|
{/each}
|
||||||
{/each}
|
{/each}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.wrapper {
|
.wrapper {
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import "@nodarium/ui/app.css";
|
import "@nodarium/ui/app.css";
|
||||||
import "../app.css";
|
import "virtual:uno.css";
|
||||||
import type { Snippet } from "svelte";
|
import "@unocss/reset/normalize.css";
|
||||||
const { children } = $props<{ children?: Snippet }>();
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{@render children?.()}
|
<slot />
|
||||||
|
|||||||
@@ -178,7 +178,7 @@
|
|||||||
onsave={(graph) => handleSave(graph)}
|
onsave={(graph) => handleSave(graph)}
|
||||||
/>
|
/>
|
||||||
<Sidebar>
|
<Sidebar>
|
||||||
<Panel id="general" title="General" icon="i-[tabler--settings]">
|
<Panel id="general" title="General" icon="i-tabler-settings">
|
||||||
<NestedSettings
|
<NestedSettings
|
||||||
id="general"
|
id="general"
|
||||||
bind:value={appSettings.value}
|
bind:value={appSettings.value}
|
||||||
@@ -188,7 +188,7 @@
|
|||||||
<Panel
|
<Panel
|
||||||
id="shortcuts"
|
id="shortcuts"
|
||||||
title="Keyboard Shortcuts"
|
title="Keyboard Shortcuts"
|
||||||
icon="i-[tabler--keyboard]"
|
icon="i-tabler-keyboard"
|
||||||
>
|
>
|
||||||
<Keymap
|
<Keymap
|
||||||
keymaps={[
|
keymaps={[
|
||||||
@@ -197,21 +197,23 @@
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Panel>
|
</Panel>
|
||||||
<Panel id="exports" title="Exporter" icon="i-[tabler--package-export]">
|
<Panel id="exports" title="Exporter" icon="i-tabler-package-export">
|
||||||
<ExportSettings {scene} />
|
<ExportSettings {scene} />
|
||||||
</Panel>
|
</Panel>
|
||||||
<Panel
|
<Panel
|
||||||
id="node-store"
|
id="node-store"
|
||||||
|
classes="text-green-400"
|
||||||
title="Node Store"
|
title="Node Store"
|
||||||
icon="i-[tabler--database] bg-green-400"
|
icon="i-tabler-database"
|
||||||
>
|
>
|
||||||
<NodeStore registry={nodeRegistry} />
|
<NodeStore registry={nodeRegistry} />
|
||||||
</Panel>
|
</Panel>
|
||||||
<Panel
|
<Panel
|
||||||
id="performance"
|
id="performance"
|
||||||
title="Performance"
|
title="Performance"
|
||||||
|
classes="text-red-400"
|
||||||
hidden={!appSettings.value.debug.showPerformancePanel}
|
hidden={!appSettings.value.debug.showPerformancePanel}
|
||||||
icon="i-[tabler--brand-speedtest] bg-red-400"
|
icon="i-tabler-brand-speedtest"
|
||||||
>
|
>
|
||||||
{#if $performanceStore}
|
{#if $performanceStore}
|
||||||
<PerformanceViewer data={$performanceStore} />
|
<PerformanceViewer data={$performanceStore} />
|
||||||
@@ -221,22 +223,24 @@
|
|||||||
id="graph-source"
|
id="graph-source"
|
||||||
title="Graph Source"
|
title="Graph Source"
|
||||||
hidden={!appSettings.value.debug.showGraphJson}
|
hidden={!appSettings.value.debug.showGraphJson}
|
||||||
icon="i-[tabler--code]"
|
icon="i-tabler-code"
|
||||||
>
|
>
|
||||||
<GraphSource graph={graph && manager.serialize()} />
|
<GraphSource {graph} />
|
||||||
</Panel>
|
</Panel>
|
||||||
<Panel
|
<Panel
|
||||||
id="benchmark"
|
id="benchmark"
|
||||||
title="Benchmark"
|
title="Benchmark"
|
||||||
|
classes="text-red-400"
|
||||||
hidden={!appSettings.value.debug.showBenchmarkPanel}
|
hidden={!appSettings.value.debug.showBenchmarkPanel}
|
||||||
icon="i-[tabler--graph] bg-red-400"
|
icon="i-tabler-graph"
|
||||||
>
|
>
|
||||||
<BenchmarkPanel run={randomGenerate} />
|
<BenchmarkPanel run={randomGenerate} />
|
||||||
</Panel>
|
</Panel>
|
||||||
<Panel
|
<Panel
|
||||||
id="graph-settings"
|
id="graph-settings"
|
||||||
title="Graph Settings"
|
title="Graph Settings"
|
||||||
icon="i-[custom--graph] bg-blue-400"
|
classes="text-blue-400"
|
||||||
|
icon="i-custom-graph"
|
||||||
>
|
>
|
||||||
<NestedSettings
|
<NestedSettings
|
||||||
id="graph-settings"
|
id="graph-settings"
|
||||||
@@ -247,7 +251,8 @@
|
|||||||
<Panel
|
<Panel
|
||||||
id="active-node"
|
id="active-node"
|
||||||
title="Node Settings"
|
title="Node Settings"
|
||||||
icon="i-[tabler--adjustments] bg-blue-400"
|
classes="text-blue-400"
|
||||||
|
icon="i-tabler-adjustments"
|
||||||
>
|
>
|
||||||
<ActiveNodeSettings {manager} bind:node={activeNode} />
|
<ActiveNodeSettings {manager} bind:node={activeNode} />
|
||||||
</Panel>
|
</Panel>
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import type { Snippet } from "svelte";
|
|
||||||
const { children } = $props<{ children?: Snippet }>();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<main class="w-screen overflow-x-hidden">
|
|
||||||
{@render children()}
|
|
||||||
</main>
|
|
||||||
@@ -1,120 +1,25 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import NodeHTML from "$lib/graph-interface/node/NodeHTML.svelte";
|
import Grid from "$lib/grid";
|
||||||
import { localState } from "$lib/helpers/localState.svelte";
|
|
||||||
import Panel from "$lib/sidebar/Panel.svelte";
|
import Panel from "$lib/sidebar/Panel.svelte";
|
||||||
import Sidebar from "$lib/sidebar/Sidebar.svelte";
|
import Sidebar from "$lib/sidebar/Sidebar.svelte";
|
||||||
import { IndexDBCache, RemoteNodeRegistry } from "@nodarium/registry";
|
|
||||||
import { type NodeId, type NodeInstance } from "@nodarium/types";
|
|
||||||
import Code from "./Code.svelte";
|
|
||||||
import Grid from "$lib/grid";
|
|
||||||
import {
|
|
||||||
concatEncodedArrays,
|
|
||||||
createWasmWrapper,
|
|
||||||
encodeNestedArray,
|
|
||||||
} from "@nodarium/utils";
|
|
||||||
|
|
||||||
const registryCache = new IndexDBCache("node-registry");
|
|
||||||
const nodeRegistry = new RemoteNodeRegistry("", registryCache);
|
|
||||||
|
|
||||||
let activeNode = localState<NodeId | undefined>(
|
|
||||||
"node.dev.activeNode",
|
|
||||||
undefined,
|
|
||||||
);
|
|
||||||
|
|
||||||
let nodeWasm = $state<ArrayBuffer>();
|
|
||||||
let nodeInstance = $state<NodeInstance>();
|
|
||||||
let nodeWasmWrapper = $state<ReturnType<typeof createWasmWrapper>>();
|
|
||||||
|
|
||||||
async function fetchNodeData(nodeId?: NodeId) {
|
|
||||||
console.log("FETCHING", { nodeId });
|
|
||||||
nodeWasm = undefined;
|
|
||||||
nodeInstance = undefined;
|
|
||||||
|
|
||||||
if (!nodeId) return;
|
|
||||||
|
|
||||||
const data = await nodeRegistry.fetchNodeDefinition(nodeId);
|
|
||||||
nodeWasm = await nodeRegistry.fetchArrayBuffer("nodes/" + nodeId + ".wasm");
|
|
||||||
nodeInstance = {
|
|
||||||
id: 0,
|
|
||||||
type: nodeId,
|
|
||||||
position: [0, 0] as [number, number],
|
|
||||||
props: {},
|
|
||||||
state: {
|
|
||||||
type: data,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
nodeWasmWrapper = createWasmWrapper(nodeWasm);
|
|
||||||
}
|
|
||||||
|
|
||||||
$effect(() => {
|
|
||||||
fetchNodeData(activeNode.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
$effect(() => {
|
|
||||||
if (nodeInstance?.props && nodeWasmWrapper) {
|
|
||||||
const keys = Object.keys(nodeInstance.state.type?.inputs || {});
|
|
||||||
let ins = Object.values(nodeInstance.props) as number[];
|
|
||||||
if (keys[0] === "plant") {
|
|
||||||
ins = [[0, 0, 0, 0, 0, 0, 0, 0], ...ins];
|
|
||||||
}
|
|
||||||
const inputs = concatEncodedArrays(encodeNestedArray(ins));
|
|
||||||
nodeWasmWrapper?.execute(inputs);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="node-wrapper absolute bottom-8 left-8">
|
|
||||||
{#if nodeInstance}
|
|
||||||
<NodeHTML inView position="relative" z={5} bind:node={nodeInstance} />
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Grid.Row>
|
<Grid.Row>
|
||||||
|
<Grid.Cell></Grid.Cell>
|
||||||
<Grid.Cell>
|
<Grid.Cell>
|
||||||
<pre>
|
<Sidebar>
|
||||||
<code>
|
|
||||||
{JSON.stringify(nodeInstance?.props)}
|
|
||||||
</code>
|
|
||||||
</pre>
|
|
||||||
</Grid.Cell>
|
|
||||||
|
|
||||||
<Grid.Cell>
|
|
||||||
<div class="h-screen w-[80vw] overflow-y-auto">
|
|
||||||
{#if nodeWasm}
|
|
||||||
<Code wasm={nodeWasm} />
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
</Grid.Cell>
|
|
||||||
</Grid.Row>
|
|
||||||
|
|
||||||
<Sidebar>
|
|
||||||
<Panel
|
<Panel
|
||||||
id="node-store"
|
id="node-store"
|
||||||
classes="text-green-400"
|
classes="text-green-400"
|
||||||
title="Node Store"
|
title="Node Store"
|
||||||
icon="i-[tabler--database]"
|
icon="i-tabler-database"
|
||||||
>
|
></Panel>
|
||||||
<div class="p-4 flex flex-col gap-2">
|
</Sidebar>
|
||||||
{#await nodeRegistry.fetchCollection("max/plantarium")}
|
</Grid.Cell>
|
||||||
<p>Loading Nodes...</p>
|
</Grid.Row>
|
||||||
{:then result}
|
|
||||||
{#each result.nodes as n}
|
|
||||||
<button
|
|
||||||
class="cursor-pointer p-2 bg-layer-1 {activeNode.value === n.id
|
|
||||||
? 'outline outline-offset-1'
|
|
||||||
: ''}"
|
|
||||||
onclick={() => (activeNode.value = n.id)}>{n.id}</button
|
|
||||||
>
|
|
||||||
{/each}
|
|
||||||
{/await}
|
|
||||||
</div>
|
|
||||||
</Panel>
|
|
||||||
</Sidebar>
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
:global body {
|
:global body {
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
width: 100vw;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import wabtInit from "wabt";
|
|
||||||
|
|
||||||
const { wasm } = $props<{ wasm: ArrayBuffer }>();
|
|
||||||
|
|
||||||
async function toWat(arrayBuffer: ArrayBuffer) {
|
|
||||||
const wabt = await wabtInit();
|
|
||||||
|
|
||||||
const module = wabt.readWasm(new Uint8Array(arrayBuffer), {
|
|
||||||
readDebugNames: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
module.generateNames();
|
|
||||||
module.applyNames();
|
|
||||||
|
|
||||||
return module.toText({ foldExprs: false, inlineExport: false });
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{#await toWat(wasm)}
|
|
||||||
<p>Converting to WAT</p>
|
|
||||||
{:then c}
|
|
||||||
<pre>
|
|
||||||
<code class="text-gray-50">{c}</code>
|
|
||||||
</pre>
|
|
||||||
{/await}
|
|
||||||
@@ -14,9 +14,6 @@ export const entries: EntryGenerator = async () => {
|
|||||||
|
|
||||||
|
|
||||||
export const GET: RequestHandler = async function GET({ params }) {
|
export const GET: RequestHandler = async function GET({ params }) {
|
||||||
|
|
||||||
const namespaces = await registry.getUser(params.user)
|
const namespaces = await registry.getUser(params.user)
|
||||||
|
|
||||||
return json(namespaces);
|
return json(namespaces);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,6 @@ export const entries: EntryGenerator = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const GET: RequestHandler = async function GET({ params }) {
|
export const GET: RequestHandler = async function GET({ params }) {
|
||||||
|
|
||||||
const namespaces = await registry.getCollection(`${params.user}/${params.collection}`);
|
const namespaces = await registry.getCollection(`${params.user}/${params.collection}`);
|
||||||
|
|
||||||
return json(namespaces);
|
return json(namespaces);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import * as registry from "$lib/node-registry";
|
|||||||
|
|
||||||
export const prerender = true;
|
export const prerender = true;
|
||||||
|
|
||||||
|
|
||||||
export const entries: EntryGenerator = async () => {
|
export const entries: EntryGenerator = async () => {
|
||||||
const users = await registry.getUsers();
|
const users = await registry.getUsers();
|
||||||
return users.map(user => {
|
return users.map(user => {
|
||||||
@@ -18,9 +17,7 @@ export const entries: EntryGenerator = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const GET: RequestHandler = async function GET({ params }) {
|
export const GET: RequestHandler = async function GET({ params }) {
|
||||||
|
|
||||||
const nodeId = `${params.user}/${params.collection}/${params.node}` as const;
|
const nodeId = `${params.user}/${params.collection}/${params.node}` as const;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const node = await getNode(nodeId);
|
const node = await getNode(nodeId);
|
||||||
return json(node);
|
return json(node);
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ import * as registry from "$lib/node-registry";
|
|||||||
export const prerender = true;
|
export const prerender = true;
|
||||||
|
|
||||||
export const GET: RequestHandler = async function GET() {
|
export const GET: RequestHandler = async function GET() {
|
||||||
|
|
||||||
const users = await registry.getUsers();
|
const users = await registry.getUsers();
|
||||||
|
|
||||||
return json(users);
|
return json(users);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
18
app/uno.config.ts
Normal file
18
app/uno.config.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// uno.config.ts
|
||||||
|
import { defineConfig } from 'unocss'
|
||||||
|
import presetIcons from '@unocss/preset-icons'
|
||||||
|
import fs from 'node:fs'
|
||||||
|
|
||||||
|
const icons = Object.fromEntries(fs.readdirSync('./src/lib/icons')
|
||||||
|
.map(name => [name.replace(".svg", ""), fs.readFileSync(`./src/lib/icons/${name}`, 'utf-8')]))
|
||||||
|
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
presets: [
|
||||||
|
presetIcons({
|
||||||
|
collections: {
|
||||||
|
custom: icons
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
]
|
||||||
|
})
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
import { sveltekit } from '@sveltejs/kit/vite';
|
import { sveltekit } from '@sveltejs/kit/vite';
|
||||||
|
import UnoCSS from 'unocss/vite';
|
||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import tailwindcss from '@tailwindcss/vite'
|
|
||||||
import comlink from 'vite-plugin-comlink';
|
import comlink from 'vite-plugin-comlink';
|
||||||
import glsl from "vite-plugin-glsl";
|
import glsl from "vite-plugin-glsl";
|
||||||
import wasm from "vite-plugin-wasm";
|
import wasm from "vite-plugin-wasm";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
tailwindcss(),
|
|
||||||
comlink(),
|
comlink(),
|
||||||
|
UnoCSS(),
|
||||||
sveltekit(),
|
sveltekit(),
|
||||||
glsl(),
|
glsl(),
|
||||||
wasm()
|
wasm()
|
||||||
|
|||||||
27
flake.lock
generated
27
flake.lock
generated
@@ -1,27 +0,0 @@
|
|||||||
{
|
|
||||||
"nodes": {
|
|
||||||
"nixpkgs": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1768564909,
|
|
||||||
"narHash": "sha256-Kell/SpJYVkHWMvnhqJz/8DqQg2b6PguxVWOuadbHCc=",
|
|
||||||
"owner": "nixos",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "e4bae1bd10c9c57b2cf517953ab70060a828ee6f",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nixos",
|
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": "nixpkgs"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": "root",
|
|
||||||
"version": 7
|
|
||||||
}
|
|
||||||
40
flake.nix
40
flake.nix
@@ -1,40 +0,0 @@
|
|||||||
{
|
|
||||||
inputs = {
|
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
||||||
};
|
|
||||||
|
|
||||||
outputs = {nixpkgs, ...}: let
|
|
||||||
systems = ["aarch64-darwin" "x86_64-linux"];
|
|
||||||
eachSystem = function:
|
|
||||||
nixpkgs.lib.genAttrs systems (system:
|
|
||||||
function {
|
|
||||||
inherit system;
|
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
});
|
|
||||||
in {
|
|
||||||
devShells = eachSystem ({pkgs, ...}: {
|
|
||||||
default = pkgs.mkShellNoCC {
|
|
||||||
packages = [
|
|
||||||
# general deps
|
|
||||||
pkgs.nodejs_24
|
|
||||||
pkgs.pnpm_10
|
|
||||||
|
|
||||||
# wasm/rust stuff
|
|
||||||
pkgs.rustc
|
|
||||||
pkgs.cargo
|
|
||||||
pkgs.rust-analyzer
|
|
||||||
pkgs.rustfmt
|
|
||||||
pkgs.wasm-bindgen-cli
|
|
||||||
pkgs.wasm-pack
|
|
||||||
pkgs.lld
|
|
||||||
|
|
||||||
# frontend
|
|
||||||
pkgs.vscode-langservers-extracted
|
|
||||||
pkgs.typescript-language-server
|
|
||||||
pkgs.prettier
|
|
||||||
pkgs.tailwindcss-language-server
|
|
||||||
];
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -11,8 +11,18 @@ crate-type = ["cdylib", "rlib"]
|
|||||||
default = ["console_error_panic_hook"]
|
default = ["console_error_panic_hook"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.84"
|
||||||
|
|
||||||
|
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||||
|
# logging them with `console.error`. This is great for development, but requires
|
||||||
|
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||||
|
# code size when deploying.
|
||||||
utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
||||||
macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde-wasm-bindgen = "0.4"
|
||||||
console_error_panic_hook = { version = "0.1.7", optional = true }
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
web-sys = { version = "0.3.69", features = ["console"] }
|
web-sys = { version = "0.3.69", features = ["console"] }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
wasm-bindgen-test = "0.3.34"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cargo build --target wasm32-unknown-unknown --release && mkdir -p pkg && cp ../../../../target/wasm32-unknown-unknown/release/out.wasm ./pkg/node.wasm",
|
"build": "wasm-pack build --release --out-name index --no-default-features",
|
||||||
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
nodes/max/plantarium/.template/tests/web.rs
Normal file
13
nodes/max/plantarium/.template/tests/web.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
//! Test suite for the Web and headless browsers.
|
||||||
|
|
||||||
|
#![cfg(target_arch = "wasm32")]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen_test;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
|
wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn pass() {
|
||||||
|
assert_eq!(1 + 1, 2);
|
||||||
|
}
|
||||||
@@ -7,6 +7,22 @@ edition = "2018"
|
|||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["console_error_panic_hook"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.84"
|
||||||
|
|
||||||
|
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||||
|
# logging them with `console.error`. This is great for development, but requires
|
||||||
|
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||||
|
# code size when deploying.
|
||||||
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
||||||
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde-wasm-bindgen = "0.4"
|
||||||
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
|
web-sys = { version = "0.3.69", features = ["console"] }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
wasm-bindgen-test = "0.3.34"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cargo build --target wasm32-unknown-unknown --release && mkdir -p pkg && cp ../../../../target/wasm32-unknown-unknown/release/box.wasm ./pkg/node.wasm",
|
"build": "wasm-pack build --release --out-name index --no-default-features",
|
||||||
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
use nodarium_macros::nodarium_definition_file;
|
use nodarium_macros::include_definition_file;
|
||||||
use nodarium_macros::nodarium_execute;
|
|
||||||
use nodarium_utils::{
|
use nodarium_utils::{
|
||||||
encode_float, evaluate_float, geometry::calculate_normals,log,
|
concat_args, encode_float, evaluate_float, geometry::calculate_normals, log, set_panic_hook,
|
||||||
split_args, wrap_arg,
|
split_args, wrap_arg,
|
||||||
};
|
};
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
nodarium_definition_file!("src/input.json");
|
include_definition_file!("src/input.json");
|
||||||
|
|
||||||
#[nodarium_execute]
|
#[rustfmt::skip]
|
||||||
|
#[wasm_bindgen]
|
||||||
pub fn execute(input: &[i32]) -> Vec<i32> {
|
pub fn execute(input: &[i32]) -> Vec<i32> {
|
||||||
|
|
||||||
|
set_panic_hook();
|
||||||
|
|
||||||
let args = split_args(input);
|
let args = split_args(input);
|
||||||
|
|
||||||
log!("WASM(cube): input: {:?} -> {:?}", input, args);
|
log!("WASM(cube): input: {:?} -> {:?}", input, args);
|
||||||
@@ -19,6 +22,7 @@ pub fn execute(input: &[i32]) -> Vec<i32> {
|
|||||||
let p = encode_float(size);
|
let p = encode_float(size);
|
||||||
let n = encode_float(-size);
|
let n = encode_float(-size);
|
||||||
|
|
||||||
|
|
||||||
// [[1,3, x, y, z, x, y,z,x,y,z]];
|
// [[1,3, x, y, z, x, y,z,x,y,z]];
|
||||||
let mut cube_geometry = [
|
let mut cube_geometry = [
|
||||||
|
|
||||||
|
|||||||
13
nodes/max/plantarium/box/tests/web.rs
Normal file
13
nodes/max/plantarium/box/tests/web.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
//! Test suite for the Web and headless browsers.
|
||||||
|
|
||||||
|
#![cfg(target_arch = "wasm32")]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen_test;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
|
wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn pass() {
|
||||||
|
assert_eq!(1 + 1, 2);
|
||||||
|
}
|
||||||
@@ -7,6 +7,23 @@ edition = "2018"
|
|||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["console_error_panic_hook"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.84"
|
||||||
|
|
||||||
|
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||||
|
# logging them with `console.error`. This is great for development, but requires
|
||||||
|
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||||
|
# code size when deploying.
|
||||||
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
||||||
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde-wasm-bindgen = "0.4"
|
||||||
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
|
web-sys = { version = "0.3.69", features = ["console"] }
|
||||||
|
glam = "0.27.0"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
wasm-bindgen-test = "0.3.34"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cargo build --target wasm32-unknown-unknown --release && mkdir -p pkg && cp ../../../../target/wasm32-unknown-unknown/release/branch.wasm ./pkg/node.wasm",
|
"build": "wasm-pack build --release --out-name index --no-default-features",
|
||||||
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
use nodarium_macros::nodarium_definition_file;
|
use nodarium_macros::include_definition_file;
|
||||||
use nodarium_macros::nodarium_execute;
|
|
||||||
use nodarium_utils::{
|
use nodarium_utils::{
|
||||||
concat_arg_vecs, evaluate_float, evaluate_int,
|
concat_arg_vecs, evaluate_float, evaluate_int,
|
||||||
geometry::{
|
geometry::{
|
||||||
create_path, interpolate_along_path, rotate_vector_by_angle, wrap_path, wrap_path_mut,
|
create_path, interpolate_along_path, rotate_vector_by_angle, wrap_path, wrap_path_mut,
|
||||||
},
|
},
|
||||||
log, split_args,
|
log, set_panic_hook, split_args,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
nodarium_definition_file!("src/input.json");
|
include_definition_file!("src/input.json");
|
||||||
|
|
||||||
#[nodarium_execute]
|
#[wasm_bindgen]
|
||||||
pub fn execute(input: &[i32]) -> Vec<i32> {
|
pub fn execute(input: &[i32]) -> Vec<i32> {
|
||||||
|
set_panic_hook();
|
||||||
|
|
||||||
let args = split_args(input);
|
let args = split_args(input);
|
||||||
|
|
||||||
let paths = split_args(args[0]);
|
let paths = split_args(args[0]);
|
||||||
|
|||||||
13
nodes/max/plantarium/branch/tests/web.rs
Normal file
13
nodes/max/plantarium/branch/tests/web.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
//! Test suite for the Web and headless browsers.
|
||||||
|
|
||||||
|
#![cfg(target_arch = "wasm32")]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen_test;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
|
wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn pass() {
|
||||||
|
assert_eq!(1 + 1, 2);
|
||||||
|
}
|
||||||
@@ -7,6 +7,21 @@ edition = "2018"
|
|||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["console_error_panic_hook"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.84"
|
||||||
|
|
||||||
|
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||||
|
# logging them with `console.error`. This is great for development, but requires
|
||||||
|
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||||
|
# code size when deploying.
|
||||||
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
||||||
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde-wasm-bindgen = "0.4"
|
||||||
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
wasm-bindgen-test = "0.3.34"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cargo build --target wasm32-unknown-unknown --release && mkdir -p pkg && cp ../../../../target/wasm32-unknown-unknown/release/float.wasm ./pkg/node.wasm",
|
"build": "wasm-pack build --release --out-name index --no-default-features",
|
||||||
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use nodarium_macros::nodarium_definition_file;
|
use nodarium_macros::include_definition_file;
|
||||||
use nodarium_macros::nodarium_execute;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
nodarium_definition_file!("src/input.json");
|
include_definition_file!("src/input.json");
|
||||||
|
|
||||||
#[nodarium_execute]
|
#[wasm_bindgen]
|
||||||
pub fn execute(args: &[i32]) -> Vec<i32> {
|
pub fn execute(args: &[i32]) -> Vec<i32> {
|
||||||
args.into()
|
args.into()
|
||||||
}
|
}
|
||||||
|
|||||||
13
nodes/max/plantarium/float/tests/web.rs
Normal file
13
nodes/max/plantarium/float/tests/web.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
//! Test suite for the Web and headless browsers.
|
||||||
|
|
||||||
|
#![cfg(target_arch = "wasm32")]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen_test;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
|
wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn pass() {
|
||||||
|
assert_eq!(1 + 1, 2);
|
||||||
|
}
|
||||||
@@ -7,7 +7,24 @@ edition = "2018"
|
|||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["console_error_panic_hook"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.84"
|
||||||
|
|
||||||
|
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||||
|
# logging them with `console.error`. This is great for development, but requires
|
||||||
|
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||||
|
# code size when deploying.
|
||||||
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
||||||
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
||||||
glam = "0.30.10"
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde-wasm-bindgen = "0.4"
|
||||||
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
|
web-sys = { version = "0.3.69", features = ["console"] }
|
||||||
|
noise = "0.9.0"
|
||||||
|
glam = "0.27.0"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
wasm-bindgen-test = "0.3.34"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cargo build --target wasm32-unknown-unknown --release && mkdir -p pkg && cp ../../../../target/wasm32-unknown-unknown/release/gravity.wasm ./pkg/node.wasm",
|
"build": "wasm-pack build --release --out-name index --no-default-features",
|
||||||
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
use glam::Vec3;
|
use glam::Vec3;
|
||||||
use nodarium_macros::nodarium_definition_file;
|
use nodarium_macros::include_definition_file;
|
||||||
use nodarium_macros::nodarium_execute;
|
|
||||||
use nodarium_utils::{
|
use nodarium_utils::{
|
||||||
concat_args, evaluate_float, evaluate_int,
|
concat_args, evaluate_float, evaluate_int,
|
||||||
geometry::{wrap_path, wrap_path_mut},
|
geometry::{wrap_path, wrap_path_mut},
|
||||||
log, reset_call_count, split_args,
|
log, reset_call_count, set_panic_hook, split_args,
|
||||||
};
|
};
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
nodarium_definition_file!("src/input.json");
|
include_definition_file!("src/input.json");
|
||||||
|
|
||||||
fn lerp_vec3(a: Vec3, b: Vec3, t: f32) -> Vec3 {
|
fn lerp_vec3(a: Vec3, b: Vec3, t: f32) -> Vec3 {
|
||||||
a + (b - a) * t
|
a + (b - a) * t
|
||||||
}
|
}
|
||||||
|
|
||||||
#[nodarium_execute]
|
#[wasm_bindgen]
|
||||||
pub fn execute(input: &[i32]) -> Vec<i32> {
|
pub fn execute(input: &[i32]) -> Vec<i32> {
|
||||||
|
set_panic_hook();
|
||||||
|
|
||||||
reset_call_count();
|
reset_call_count();
|
||||||
|
|
||||||
let args = split_args(input);
|
let args = split_args(input);
|
||||||
|
|||||||
13
nodes/max/plantarium/gravity/tests/web.rs
Normal file
13
nodes/max/plantarium/gravity/tests/web.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
//! Test suite for the Web and headless browsers.
|
||||||
|
|
||||||
|
#![cfg(target_arch = "wasm32")]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen_test;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
|
wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn pass() {
|
||||||
|
assert_eq!(1 + 1, 2);
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "instance"
|
name = "nodarium_instance"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Max Richter <jim-x@web.de>"]
|
authors = ["Max Richter <jim-x@web.de>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
@@ -7,7 +7,23 @@ edition = "2018"
|
|||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["console_error_panic_hook"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.84"
|
||||||
|
|
||||||
|
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||||
|
# logging them with `console.error`. This is great for development, but requires
|
||||||
|
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||||
|
# code size when deploying.
|
||||||
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
||||||
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
||||||
glam = "0.30.10"
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde-wasm-bindgen = "0.4"
|
||||||
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
|
web-sys = { version = "0.3.69", features = ["console"] }
|
||||||
|
glam = "0.27.0"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
wasm-bindgen-test = "0.3.34"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cargo build --target wasm32-unknown-unknown --release && mkdir -p pkg && cp ../../../../target/wasm32-unknown-unknown/release/instance.wasm ./pkg/node.wasm",
|
"build": "wasm-pack build --release --out-name index --no-default-features",
|
||||||
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
use glam::{Mat4, Quat, Vec3};
|
use glam::{Mat4, Quat, Vec3};
|
||||||
use nodarium_macros::nodarium_execute;
|
use nodarium_macros::include_definition_file;
|
||||||
use nodarium_macros::nodarium_definition_file;
|
|
||||||
use nodarium_utils::{
|
use nodarium_utils::{
|
||||||
concat_args, evaluate_float, evaluate_int,
|
concat_args, encode_float, evaluate_float, evaluate_int,
|
||||||
geometry::{
|
geometry::{
|
||||||
create_instance_data, wrap_geometry_data, wrap_instance_data, wrap_path,
|
calculate_normals, create_instance_data, wrap_geometry_data, wrap_instance_data, wrap_path,
|
||||||
},
|
},
|
||||||
log, split_args,
|
log, set_panic_hook, split_args, wrap_arg,
|
||||||
};
|
};
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
nodarium_definition_file!("src/input.json");
|
include_definition_file!("src/input.json");
|
||||||
|
|
||||||
#[nodarium_execute]
|
#[wasm_bindgen]
|
||||||
pub fn execute(input: &[i32]) -> Vec<i32> {
|
pub fn execute(input: &[i32]) -> Vec<i32> {
|
||||||
|
set_panic_hook();
|
||||||
|
|
||||||
let args = split_args(input);
|
let args = split_args(input);
|
||||||
let mut inputs = split_args(args[0]);
|
let mut inputs = split_args(args[0]);
|
||||||
log!("WASM(instance): inputs: {:?}", inputs);
|
log!("WASM(instance): inputs: {:?}", inputs);
|
||||||
|
|||||||
13
nodes/max/plantarium/instance/tests/web.rs
Normal file
13
nodes/max/plantarium/instance/tests/web.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
//! Test suite for the Web and headless browsers.
|
||||||
|
|
||||||
|
#![cfg(target_arch = "wasm32")]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen_test;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
|
wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn pass() {
|
||||||
|
assert_eq!(1 + 1, 2);
|
||||||
|
}
|
||||||
@@ -7,6 +7,17 @@ edition = "2018"
|
|||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["console_error_panic_hook"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.84"
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde-wasm-bindgen = "0.4"
|
||||||
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
||||||
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
||||||
|
web-sys = { version = "0.3.69", features = ["console"] }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
wasm-bindgen-test = "0.3.34"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cargo build --target wasm32-unknown-unknown --release && mkdir -p pkg && cp ../../../../target/wasm32-unknown-unknown/release/math.wasm ./pkg/node.wasm",
|
"build": "wasm-pack build --release --out-name index --no-default-features",
|
||||||
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
use nodarium_macros::nodarium_definition_file;
|
use nodarium_macros::include_definition_file;
|
||||||
use nodarium_macros::nodarium_execute;
|
use nodarium_utils::{concat_args, set_panic_hook, split_args};
|
||||||
use nodarium_utils::{
|
use wasm_bindgen::prelude::*;
|
||||||
concat_args, split_args
|
|
||||||
};
|
|
||||||
|
|
||||||
#[nodarium_execute]
|
include_definition_file!("src/input.json");
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
pub fn execute(args: &[i32]) -> Vec<i32> {
|
pub fn execute(args: &[i32]) -> Vec<i32> {
|
||||||
|
set_panic_hook();
|
||||||
let args = split_args(args);
|
let args = split_args(args);
|
||||||
concat_args(vec![&[0], args[0], args[1], args[2]])
|
concat_args(vec![&[0], args[0], args[1], args[2]])
|
||||||
}
|
}
|
||||||
|
|
||||||
nodarium_definition_file!("src/input.json");
|
|
||||||
|
|||||||
13
nodes/max/plantarium/math/tests/web.rs
Normal file
13
nodes/max/plantarium/math/tests/web.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
//! Test suite for the Web and headless browsers.
|
||||||
|
|
||||||
|
#![cfg(target_arch = "wasm32")]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen_test;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
|
wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn pass() {
|
||||||
|
assert_eq!(1 + 1, 2);
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "noise"
|
name = "nodes-noise"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Max Richter <jim-x@web.de>"]
|
authors = ["Max Richter <jim-x@web.de>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
@@ -7,8 +7,24 @@ edition = "2018"
|
|||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["console_error_panic_hook"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.84"
|
||||||
|
|
||||||
|
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||||
|
# logging them with `console.error`. This is great for development, but requires
|
||||||
|
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||||
|
# code size when deploying.
|
||||||
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
||||||
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde-wasm-bindgen = "0.4"
|
||||||
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
|
web-sys = { version = "0.3.69", features = ["console"] }
|
||||||
noise = "0.9.0"
|
noise = "0.9.0"
|
||||||
|
glam = "0.27.0"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
wasm-bindgen-test = "0.3.34"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cargo build --target wasm32-unknown-unknown --release && mkdir -p pkg && cp ../../../../target/wasm32-unknown-unknown/release/noise.wasm ./pkg/node.wasm",
|
"build": "wasm-pack build --release --out-name index --no-default-features",
|
||||||
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
use nodarium_macros::nodarium_definition_file;
|
use nodarium_macros::include_definition_file;
|
||||||
use nodarium_macros::nodarium_execute;
|
|
||||||
use nodarium_utils::{
|
use nodarium_utils::{
|
||||||
concat_args, evaluate_float, evaluate_int, evaluate_vec3, geometry::wrap_path_mut,
|
concat_args, evaluate_float, evaluate_int, evaluate_vec3, geometry::wrap_path_mut, log,
|
||||||
reset_call_count, split_args,
|
reset_call_count, set_panic_hook, split_args,
|
||||||
};
|
};
|
||||||
use noise::{HybridMulti, MultiFractal, NoiseFn, OpenSimplex};
|
use noise::{HybridMulti, MultiFractal, NoiseFn, OpenSimplex};
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
nodarium_definition_file!("src/input.json");
|
include_definition_file!("src/input.json");
|
||||||
|
|
||||||
fn lerp(a: f32, b: f32, t: f32) -> f32 {
|
fn lerp(a: f32, b: f32, t: f32) -> f32 {
|
||||||
a + t * (b - a)
|
a + t * (b - a)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[nodarium_execute]
|
#[wasm_bindgen]
|
||||||
pub fn execute(input: &[i32]) -> Vec<i32> {
|
pub fn execute(input: &[i32]) -> Vec<i32> {
|
||||||
|
set_panic_hook();
|
||||||
|
|
||||||
reset_call_count();
|
reset_call_count();
|
||||||
|
|
||||||
let args = split_args(input);
|
let args = split_args(input);
|
||||||
|
|||||||
13
nodes/max/plantarium/noise/tests/web.rs
Normal file
13
nodes/max/plantarium/noise/tests/web.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
//! Test suite for the Web and headless browsers.
|
||||||
|
|
||||||
|
#![cfg(target_arch = "wasm32")]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen_test;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
|
wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn pass() {
|
||||||
|
assert_eq!(1 + 1, 2);
|
||||||
|
}
|
||||||
@@ -7,6 +7,24 @@ edition = "2018"
|
|||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["console_error_panic_hook"]
|
||||||
|
console_error_panic_hook = ["dep:console_error_panic_hook"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.84"
|
||||||
|
|
||||||
|
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||||
|
# logging them with `console.error`. This is great for development, but requires
|
||||||
|
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||||
|
# code size when deploying.
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
|
||||||
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
||||||
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
||||||
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
|
web-sys = { version = "0.3.69", features = ["console"] }
|
||||||
|
glam = "0.27.0"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
wasm-bindgen-test = "0.3.34"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cargo build --target wasm32-unknown-unknown --release && mkdir -p pkg && cp ../../../../target/wasm32-unknown-unknown/release/output.wasm ./pkg/node.wasm",
|
"build": "wasm-pack build --release --out-name index --no-default-features",
|
||||||
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
use nodarium_macros::nodarium_definition_file;
|
use nodarium_macros::include_definition_file;
|
||||||
use nodarium_macros::nodarium_execute;
|
|
||||||
use nodarium_utils::{
|
use nodarium_utils::{
|
||||||
concat_args, evaluate_int,
|
concat_args, evaluate_int,
|
||||||
geometry::{extrude_path, wrap_path},
|
geometry::{extrude_path, wrap_path},
|
||||||
log, split_args,
|
log, set_panic_hook, split_args,
|
||||||
};
|
};
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
nodarium_definition_file!("src/inputs.json");
|
include_definition_file!("src/inputs.json");
|
||||||
|
|
||||||
#[nodarium_execute]
|
#[wasm_bindgen]
|
||||||
pub fn execute(input: &[i32]) -> Vec<i32> {
|
pub fn execute(input: &[i32]) -> Vec<i32> {
|
||||||
|
set_panic_hook();
|
||||||
|
|
||||||
log!("WASM(output): input: {:?}", input);
|
log!("WASM(output): input: {:?}", input);
|
||||||
|
|
||||||
let args = split_args(input);
|
let args = split_args(input);
|
||||||
|
|||||||
13
nodes/max/plantarium/output/tests/web.rs
Normal file
13
nodes/max/plantarium/output/tests/web.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
//! Test suite for the Web and headless browsers.
|
||||||
|
|
||||||
|
#![cfg(target_arch = "wasm32")]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen_test;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
|
wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn pass() {
|
||||||
|
assert_eq!(1 + 1, 2);
|
||||||
|
}
|
||||||
@@ -7,7 +7,21 @@ edition = "2018"
|
|||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["console_error_panic_hook"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.84"
|
||||||
|
|
||||||
|
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||||
|
# logging them with `console.error`. This is great for development, but requires
|
||||||
|
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||||
|
# code size when deploying.
|
||||||
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
||||||
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde-wasm-bindgen = "0.4"
|
||||||
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
wasm-bindgen-test = "0.3.34"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cargo build --target wasm32-unknown-unknown --release && mkdir -p pkg && cp ../../../../target/wasm32-unknown-unknown/release/random.wasm ./pkg/node.wasm",
|
"build": "wasm-pack build --release --out-name index --no-default-features",
|
||||||
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
use nodarium_macros::nodarium_definition_file;
|
use nodarium_macros::include_definition_file;
|
||||||
use nodarium_macros::nodarium_execute;
|
use nodarium_utils::{concat_args, set_panic_hook, split_args};
|
||||||
use nodarium_utils::{concat_args, split_args};
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
nodarium_definition_file!("src/definition.json");
|
include_definition_file!("src/definition.json");
|
||||||
|
|
||||||
#[nodarium_execute]
|
#[wasm_bindgen]
|
||||||
pub fn execute(args: &[i32]) -> Vec<i32> {
|
pub fn execute(args: &[i32]) -> Vec<i32> {
|
||||||
|
set_panic_hook();
|
||||||
let args = split_args(args);
|
let args = split_args(args);
|
||||||
concat_args(vec![&[1], args[0], args[1], args[2]])
|
concat_args(vec![&[1], args[0], args[1], args[2]])
|
||||||
}
|
}
|
||||||
|
|||||||
13
nodes/max/plantarium/random/tests/web.rs
Normal file
13
nodes/max/plantarium/random/tests/web.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
//! Test suite for the Web and headless browsers.
|
||||||
|
|
||||||
|
#![cfg(target_arch = "wasm32")]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen_test;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
|
wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn pass() {
|
||||||
|
assert_eq!(1 + 1, 2);
|
||||||
|
}
|
||||||
@@ -7,8 +7,23 @@ edition = "2018"
|
|||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["console_error_panic_hook"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.84"
|
||||||
|
|
||||||
|
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||||
|
# logging them with `console.error`. This is great for development, but requires
|
||||||
|
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||||
|
# code size when deploying.
|
||||||
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
||||||
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
glam = "0.30.10"
|
serde-wasm-bindgen = "0.4"
|
||||||
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
|
web-sys = { version = "0.3.69", features = ["console"] }
|
||||||
|
glam = "0.27.0"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
wasm-bindgen-test = "0.3.34"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cargo build --target wasm32-unknown-unknown --release && mkdir -p pkg && cp ../../../../target/wasm32-unknown-unknown/release/rotate.wasm ./pkg/node.wasm",
|
"build": "wasm-pack build --release --out-name index --no-default-features",
|
||||||
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
use glam::{Mat4, Vec3};
|
use glam::{Mat4, Vec3};
|
||||||
use nodarium_macros::nodarium_definition_file;
|
use nodarium_macros::include_definition_file;
|
||||||
use nodarium_macros::nodarium_execute;
|
|
||||||
use nodarium_utils::{
|
use nodarium_utils::{
|
||||||
concat_args, evaluate_float, evaluate_int, geometry::wrap_path_mut, log,
|
concat_args, evaluate_float, evaluate_int, geometry::wrap_path_mut, log, set_panic_hook,
|
||||||
split_args,
|
split_args,
|
||||||
};
|
};
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
nodarium_definition_file!("src/input.json");
|
include_definition_file!("src/input.json");
|
||||||
|
|
||||||
#[nodarium_execute]
|
#[wasm_bindgen]
|
||||||
pub fn execute(input: &[i32]) -> Vec<i32> {
|
pub fn execute(input: &[i32]) -> Vec<i32> {
|
||||||
|
set_panic_hook();
|
||||||
|
|
||||||
log!("DEBUG args: {:?}", input);
|
log!("DEBUG args: {:?}", input);
|
||||||
|
|
||||||
|
|||||||
13
nodes/max/plantarium/rotate/tests/web.rs
Normal file
13
nodes/max/plantarium/rotate/tests/web.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
//! Test suite for the Web and headless browsers.
|
||||||
|
|
||||||
|
#![cfg(target_arch = "wasm32")]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen_test;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
|
wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn pass() {
|
||||||
|
assert_eq!(1 + 1, 2);
|
||||||
|
}
|
||||||
@@ -7,6 +7,23 @@ edition = "2018"
|
|||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["console_error_panic_hook"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.84"
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde-wasm-bindgen = "0.4"
|
||||||
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
||||||
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
||||||
|
web-sys = { version = "0.3.69", features = ["console"] }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
wasm-bindgen-test = "0.3.34"
|
||||||
|
|
||||||
|
[package.metadata.wasm-pack.profile.release.wasm-bindgen]
|
||||||
|
debug-js-glue = true
|
||||||
|
demangle-name-section = true
|
||||||
|
dwarf-debug-info = false
|
||||||
|
omit-default-module-path = true
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cargo build --target wasm32-unknown-unknown --release && mkdir -p pkg && cp ../../../../target/wasm32-unknown-unknown/release/stem.wasm ./pkg/node.wasm",
|
"build": "wasm-pack build --release --out-name index --no-default-features",
|
||||||
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
use nodarium_macros::nodarium_definition_file;
|
use nodarium_macros::include_definition_file;
|
||||||
use nodarium_macros::nodarium_execute;
|
|
||||||
use nodarium_utils::{
|
use nodarium_utils::{
|
||||||
evaluate_float, evaluate_int, evaluate_vec3,
|
evaluate_float, evaluate_int, evaluate_vec3,
|
||||||
geometry::{create_multiple_paths, wrap_multiple_paths},
|
geometry::{create_multiple_paths, wrap_multiple_paths},
|
||||||
log, reset_call_count, split_args,
|
log, reset_call_count, set_panic_hook, split_args,
|
||||||
};
|
};
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
nodarium_definition_file!("src/input.json");
|
include_definition_file!("src/input.json");
|
||||||
|
|
||||||
#[nodarium_execute]
|
#[wasm_bindgen]
|
||||||
pub fn execute(input: &[i32]) -> Vec<i32> {
|
pub fn execute(input: &[i32]) -> Vec<i32> {
|
||||||
|
set_panic_hook();
|
||||||
|
|
||||||
reset_call_count();
|
reset_call_count();
|
||||||
|
|
||||||
let args = split_args(input);
|
let args = split_args(input);
|
||||||
|
|||||||
13
nodes/max/plantarium/stem/tests/web.rs
Normal file
13
nodes/max/plantarium/stem/tests/web.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
//! Test suite for the Web and headless browsers.
|
||||||
|
|
||||||
|
#![cfg(target_arch = "wasm32")]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen_test;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
|
wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn pass() {
|
||||||
|
assert_eq!(1 + 1, 2);
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "triangle"
|
name = "max-plantarium-triangle"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Max Richter <jim-x@web.de>"]
|
authors = ["Max Richter <jim-x@web.de>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
@@ -7,6 +7,22 @@ edition = "2018"
|
|||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["console_error_panic_hook"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.84"
|
||||||
|
|
||||||
|
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||||
|
# logging them with `console.error`. This is great for development, but requires
|
||||||
|
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||||
|
# code size when deploying.
|
||||||
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
||||||
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
||||||
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde-wasm-bindgen = "0.4"
|
||||||
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
|
web-sys = { version = "0.3.69", features = ["console"] }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
wasm-bindgen-test = "0.3.34"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cargo build --target wasm32-unknown-unknown --release && mkdir -p pkg && cp ../../../../target/wasm32-unknown-unknown/release/triangle.wasm ./pkg/node.wasm",
|
"build": "wasm-pack build --release --out-name index --no-default-features",
|
||||||
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,25 @@
|
|||||||
use nodarium_macros::nodarium_definition_file;
|
use nodarium_macros::include_definition_file;
|
||||||
use nodarium_macros::nodarium_execute;
|
|
||||||
use nodarium_utils::{
|
use nodarium_utils::{
|
||||||
decode_float, encode_float, evaluate_int, split_args, wrap_arg, log
|
decode_float, encode_float, evaluate_int, set_panic_hook, split_args, wrap_arg,
|
||||||
};
|
};
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
use web_sys::console;
|
||||||
|
|
||||||
nodarium_definition_file!("src/input.json");
|
include_definition_file!("src/input.json");
|
||||||
|
|
||||||
#[nodarium_execute]
|
#[rustfmt::skip]
|
||||||
|
#[wasm_bindgen]
|
||||||
pub fn execute(input: &[i32]) -> Vec<i32> {
|
pub fn execute(input: &[i32]) -> Vec<i32> {
|
||||||
|
|
||||||
|
set_panic_hook();
|
||||||
|
|
||||||
let args = split_args(input);
|
let args = split_args(input);
|
||||||
|
|
||||||
let size = evaluate_int(args[0]);
|
let size = evaluate_int(args[0]);
|
||||||
let decoded = decode_float(size);
|
let decoded = decode_float(size);
|
||||||
let negative_size = encode_float(-decoded);
|
let negative_size = encode_float(-decoded);
|
||||||
|
|
||||||
log!("WASM(triangle): input: {:?} -> {}", args[0],decoded);
|
console::log_1(&format!("WASM(triangle): input: {:?} -> {}", args[0],decoded).into());
|
||||||
|
|
||||||
// [[1,3, x, y, z, x, y,z,x,y,z]];
|
// [[1,3, x, y, z, x, y,z,x,y,z]];
|
||||||
wrap_arg(&[
|
wrap_arg(&[
|
||||||
|
|||||||
13
nodes/max/plantarium/triangle/tests/web.rs
Normal file
13
nodes/max/plantarium/triangle/tests/web.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
//! Test suite for the Web and headless browsers.
|
||||||
|
|
||||||
|
#![cfg(target_arch = "wasm32")]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen_test;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
|
wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn pass() {
|
||||||
|
assert_eq!(1 + 1, 2);
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "vec3"
|
name = "max-plantarium-vec3"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Max Richter <jim-x@web.de>"]
|
authors = ["Max Richter <jim-x@web.de>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
@@ -7,8 +7,22 @@ edition = "2018"
|
|||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["console_error_panic_hook"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.84"
|
||||||
|
|
||||||
|
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||||
|
# logging them with `console.error`. This is great for development, but requires
|
||||||
|
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||||
|
# code size when deploying.
|
||||||
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
nodarium_utils = { version = "0.1.0", path = "../../../../packages/utils" }
|
||||||
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
nodarium_macros = { version = "0.1.0", path = "../../../../packages/macros" }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
serde-wasm-bindgen = "0.4"
|
||||||
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
|
web-sys = { version = "0.3.69", features = ["console"] }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
wasm-bindgen-test = "0.3.34"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cargo build --target wasm32-unknown-unknown --release && mkdir -p pkg && cp ../../../../target/wasm32-unknown-unknown/release/vec3.wasm ./pkg/node.wasm",
|
"build": "wasm-pack build --release --out-name index --no-default-features",
|
||||||
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
"dev": "cargo watch -s 'wasm-pack build --dev --out-name index --no-default-features'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use nodarium_macros::nodarium_definition_file;
|
use nodarium_macros::include_definition_file;
|
||||||
use nodarium_macros::nodarium_execute;
|
|
||||||
use nodarium_utils::{concat_args, log, split_args};
|
use nodarium_utils::{concat_args, log, split_args};
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
nodarium_definition_file!("src/input.json");
|
include_definition_file!("src/input.json");
|
||||||
|
|
||||||
#[nodarium_execute]
|
#[wasm_bindgen]
|
||||||
pub fn execute(input: &[i32]) -> Vec<i32> {
|
pub fn execute(input: &[i32]) -> Vec<i32> {
|
||||||
let args = split_args(input);
|
let args = split_args(input);
|
||||||
log!("vec3 input: {:?}", input);
|
log!("vec3 input: {:?}", input);
|
||||||
|
|||||||
13
nodes/max/plantarium/vec3/tests/web.rs
Normal file
13
nodes/max/plantarium/vec3/tests/web.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
//! Test suite for the Web and headless browsers.
|
||||||
|
|
||||||
|
#![cfg(target_arch = "wasm32")]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen_test;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
|
||||||
|
wasm_bindgen_test_configure!(run_in_browser);
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn pass() {
|
||||||
|
assert_eq!(1 + 1, 2);
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ repository = "https://github.com/jim-fx/nodes"
|
|||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
syn = { version = "2.0", features = ["full"] }
|
syn = { version = "1.0", features = ["full"] }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
|
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
|
|||||||
@@ -5,7 +5,32 @@ use quote::quote;
|
|||||||
use std::env;
|
use std::env;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use syn::parse_macro_input;
|
use syn::{parse_macro_input, LitStr};
|
||||||
|
|
||||||
|
#[proc_macro]
|
||||||
|
pub fn node_definition(input: TokenStream) -> TokenStream {
|
||||||
|
let input_string = parse_macro_input!(input as LitStr).value();
|
||||||
|
|
||||||
|
// Validate JSON format
|
||||||
|
let json: NodeDefinition = match serde_json::from_str(&input_string) {
|
||||||
|
Ok(json) => json,
|
||||||
|
Err(e) => panic!("Invalid JSON input: {}", e),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convert the validated JSON back to a pretty-printed string
|
||||||
|
let formatted_json = serde_json::to_string_pretty(&json).expect("Failed to serialize JSON");
|
||||||
|
|
||||||
|
// Generate the output function
|
||||||
|
let expanded = quote! {
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub fn get_definition() -> String {
|
||||||
|
String::from(#formatted_json)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Convert the generated code back to a TokenStream
|
||||||
|
TokenStream::from(expanded)
|
||||||
|
}
|
||||||
|
|
||||||
fn add_line_numbers(input: String) -> String {
|
fn add_line_numbers(input: String) -> String {
|
||||||
return input
|
return input
|
||||||
@@ -16,120 +41,39 @@ fn add_line_numbers(input: String) -> String {
|
|||||||
.join("\n");
|
.join("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
|
||||||
pub fn nodarium_execute(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
|
||||||
let input_fn = parse_macro_input!(item as syn::ItemFn);
|
|
||||||
let _fn_name = &input_fn.sig.ident;
|
|
||||||
let _fn_vis = &input_fn.vis;
|
|
||||||
let fn_body = &input_fn.block;
|
|
||||||
|
|
||||||
let first_arg_ident = if let Some(syn::FnArg::Typed(pat_type)) = input_fn.sig.inputs.first() {
|
|
||||||
if let syn::Pat::Ident(pat_ident) = &*pat_type.pat {
|
|
||||||
&pat_ident.ident
|
|
||||||
} else {
|
|
||||||
panic!("Expected a simple identifier for the first argument");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
panic!("The execute function must have at least one argument (the input slice)");
|
|
||||||
};
|
|
||||||
|
|
||||||
// We create a wrapper that handles the C ABI and pointer math
|
|
||||||
let expanded = quote! {
|
|
||||||
extern "C" {
|
|
||||||
fn host_log_panic(ptr: *const u8, len: usize);
|
|
||||||
fn host_log(ptr: *const u8, len: usize);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn setup_panic_hook() {
|
|
||||||
static SET_HOOK: std::sync::Once = std::sync::Once::new();
|
|
||||||
SET_HOOK.call_once(|| {
|
|
||||||
std::panic::set_hook(Box::new(|info| {
|
|
||||||
let msg = info.to_string();
|
|
||||||
unsafe { host_log_panic(msg.as_ptr(), msg.len()); }
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn __alloc(len: usize) -> *mut i32 {
|
|
||||||
let mut buf = Vec::with_capacity(len);
|
|
||||||
let ptr = buf.as_mut_ptr();
|
|
||||||
std::mem::forget(buf);
|
|
||||||
ptr
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn __free(ptr: *mut i32, len: usize) {
|
|
||||||
unsafe {
|
|
||||||
let _ = Vec::from_raw_parts(ptr, 0, len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static mut OUTPUT_BUFFER: Vec<i32> = Vec::new();
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn execute(ptr: *const i32, len: usize) -> *mut i32 {
|
|
||||||
setup_panic_hook();
|
|
||||||
// 1. Convert raw pointer to slice
|
|
||||||
let input = unsafe { core::slice::from_raw_parts(ptr, len) };
|
|
||||||
|
|
||||||
// 2. Call the logic (which we define below)
|
|
||||||
let result_data: Vec<i32> = internal_logic(input);
|
|
||||||
|
|
||||||
// 3. Use the static buffer for the result
|
|
||||||
let result_len = result_data.len();
|
|
||||||
unsafe {
|
|
||||||
OUTPUT_BUFFER.clear();
|
|
||||||
OUTPUT_BUFFER.reserve(result_len + 1);
|
|
||||||
OUTPUT_BUFFER.push(result_len as i32);
|
|
||||||
OUTPUT_BUFFER.extend(result_data);
|
|
||||||
|
|
||||||
OUTPUT_BUFFER.as_mut_ptr()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn internal_logic(#first_arg_ident: &[i32]) -> Vec<i32> {
|
|
||||||
#fn_body
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TokenStream::from(expanded)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro]
|
#[proc_macro]
|
||||||
pub fn nodarium_definition_file(input: TokenStream) -> TokenStream {
|
pub fn include_definition_file(input: TokenStream) -> TokenStream {
|
||||||
let path_lit = syn::parse_macro_input!(input as syn::LitStr);
|
let file_path = syn::parse_macro_input!(input as syn::LitStr).value();
|
||||||
let file_path = path_lit.value();
|
|
||||||
|
|
||||||
|
// Retrieve the directory containing the Cargo.toml file
|
||||||
let project_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
let project_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||||
let full_path = Path::new(&project_dir).join(&file_path);
|
let full_path = Path::new(&project_dir).join(&file_path);
|
||||||
|
|
||||||
let json_content = fs::read_to_string(&full_path).unwrap_or_else(|err| {
|
// Read the JSON file content
|
||||||
panic!("Failed to read JSON file at '{}/{}': {}", project_dir, file_path, err)
|
let json_content = fs::read_to_string(full_path).unwrap_or_else(|err| {
|
||||||
|
panic!(
|
||||||
|
"Failed to read JSON file at '{}/{}': {}",
|
||||||
|
project_dir, file_path, err
|
||||||
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Optionally, validate that the content is valid JSON
|
||||||
let _: NodeDefinition = serde_json::from_str(&json_content).unwrap_or_else(|err| {
|
let _: NodeDefinition = serde_json::from_str(&json_content).unwrap_or_else(|err| {
|
||||||
panic!("JSON file contains invalid JSON: \n{} \n{}", err, add_line_numbers(json_content.clone()))
|
panic!(
|
||||||
|
"JSON file contains invalid JSON: \n{} \n{}",
|
||||||
|
err,
|
||||||
|
add_line_numbers(json_content.clone())
|
||||||
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
// We use the span from the input path literal
|
// Generate the function that returns the JSON string
|
||||||
let bytes = syn::LitByteStr::new(json_content.as_bytes(), path_lit.span());
|
|
||||||
let len = json_content.len();
|
|
||||||
|
|
||||||
let expanded = quote! {
|
let expanded = quote! {
|
||||||
#[link_section = "nodarium_definition"]
|
#[wasm_bindgen]
|
||||||
static DEFINITION_DATA: [u8; #len] = *#bytes;
|
pub fn get_definition() -> String {
|
||||||
|
String::from(#json_content)
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn get_definition_ptr() -> *const u8 {
|
|
||||||
DEFINITION_DATA.as_ptr()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn get_definition_len() -> usize {
|
|
||||||
DEFINITION_DATA.len()
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Convert the generated code back to a TokenStream
|
||||||
TokenStream::from(expanded)
|
TokenStream::from(expanded)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export class RemoteNodeRegistry implements NodeRegistry {
|
|||||||
status: "loading" | "ready" | "error" = "loading";
|
status: "loading" | "ready" | "error" = "loading";
|
||||||
private nodes: Map<string, NodeDefinition> = new Map();
|
private nodes: Map<string, NodeDefinition> = new Map();
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private url: string,
|
private url: string,
|
||||||
private cache?: AsyncCache<ArrayBuffer | string>,
|
private cache?: AsyncCache<ArrayBuffer | string>,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@hey-api/openapi-ts": "^0.90.4"
|
"@hey-api/openapi-ts": "^0.90.4"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import { type ClientOptions, type Config, createClient, createConfig } from './client';
|
|
||||||
import type { ClientOptions as ClientOptions2 } from './types.gen';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The `createClientConfig()` function will be called on client initialization
|
|
||||||
* and the returned object will become the client's initial configuration.
|
|
||||||
*
|
|
||||||
* You may want to initialize your client this way instead of calling
|
|
||||||
* `setConfig()`. This is useful for example if you're using Next.js
|
|
||||||
* to ensure your client always has the correct values.
|
|
||||||
*/
|
|
||||||
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
|
|
||||||
|
|
||||||
export const client = createClient(createConfig<ClientOptions2>());
|
|
||||||
@@ -1,311 +0,0 @@
|
|||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import { createSseClient } from '../core/serverSentEvents.gen';
|
|
||||||
import type { HttpMethod } from '../core/types.gen';
|
|
||||||
import { getValidRequestBody } from '../core/utils.gen';
|
|
||||||
import type {
|
|
||||||
Client,
|
|
||||||
Config,
|
|
||||||
RequestOptions,
|
|
||||||
ResolvedRequestOptions,
|
|
||||||
} from './types.gen';
|
|
||||||
import {
|
|
||||||
buildUrl,
|
|
||||||
createConfig,
|
|
||||||
createInterceptors,
|
|
||||||
getParseAs,
|
|
||||||
mergeConfigs,
|
|
||||||
mergeHeaders,
|
|
||||||
setAuthParams,
|
|
||||||
} from './utils.gen';
|
|
||||||
|
|
||||||
type ReqInit = Omit<RequestInit, 'body' | 'headers'> & {
|
|
||||||
body?: any;
|
|
||||||
headers: ReturnType<typeof mergeHeaders>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const createClient = (config: Config = {}): Client => {
|
|
||||||
let _config = mergeConfigs(createConfig(), config);
|
|
||||||
|
|
||||||
const getConfig = (): Config => ({ ..._config });
|
|
||||||
|
|
||||||
const setConfig = (config: Config): Config => {
|
|
||||||
_config = mergeConfigs(_config, config);
|
|
||||||
return getConfig();
|
|
||||||
};
|
|
||||||
|
|
||||||
const interceptors = createInterceptors<
|
|
||||||
Request,
|
|
||||||
Response,
|
|
||||||
unknown,
|
|
||||||
ResolvedRequestOptions
|
|
||||||
>();
|
|
||||||
|
|
||||||
const beforeRequest = async (options: RequestOptions) => {
|
|
||||||
const opts = {
|
|
||||||
..._config,
|
|
||||||
...options,
|
|
||||||
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
||||||
headers: mergeHeaders(_config.headers, options.headers),
|
|
||||||
serializedBody: undefined,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (opts.security) {
|
|
||||||
await setAuthParams({
|
|
||||||
...opts,
|
|
||||||
security: opts.security,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts.requestValidator) {
|
|
||||||
await opts.requestValidator(opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts.body !== undefined && opts.bodySerializer) {
|
|
||||||
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove Content-Type header if body is empty to avoid sending invalid requests
|
|
||||||
if (opts.body === undefined || opts.serializedBody === '') {
|
|
||||||
opts.headers.delete('Content-Type');
|
|
||||||
}
|
|
||||||
|
|
||||||
const url = buildUrl(opts);
|
|
||||||
|
|
||||||
return { opts, url };
|
|
||||||
};
|
|
||||||
|
|
||||||
const request: Client['request'] = async (options) => {
|
|
||||||
// @ts-expect-error
|
|
||||||
const { opts, url } = await beforeRequest(options);
|
|
||||||
const requestInit: ReqInit = {
|
|
||||||
redirect: 'follow',
|
|
||||||
...opts,
|
|
||||||
body: getValidRequestBody(opts),
|
|
||||||
};
|
|
||||||
|
|
||||||
let request = new Request(url, requestInit);
|
|
||||||
|
|
||||||
for (const fn of interceptors.request.fns) {
|
|
||||||
if (fn) {
|
|
||||||
request = await fn(request, opts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// fetch must be assigned here, otherwise it would throw the error:
|
|
||||||
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
||||||
const _fetch = opts.fetch!;
|
|
||||||
let response: Response;
|
|
||||||
|
|
||||||
try {
|
|
||||||
response = await _fetch(request);
|
|
||||||
} catch (error) {
|
|
||||||
// Handle fetch exceptions (AbortError, network errors, etc.)
|
|
||||||
let finalError = error;
|
|
||||||
|
|
||||||
for (const fn of interceptors.error.fns) {
|
|
||||||
if (fn) {
|
|
||||||
finalError = (await fn(
|
|
||||||
error,
|
|
||||||
undefined as any,
|
|
||||||
request,
|
|
||||||
opts,
|
|
||||||
)) as unknown;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
finalError = finalError || ({} as unknown);
|
|
||||||
|
|
||||||
if (opts.throwOnError) {
|
|
||||||
throw finalError;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return error response
|
|
||||||
return opts.responseStyle === 'data'
|
|
||||||
? undefined
|
|
||||||
: {
|
|
||||||
error: finalError,
|
|
||||||
request,
|
|
||||||
response: undefined as any,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const fn of interceptors.response.fns) {
|
|
||||||
if (fn) {
|
|
||||||
response = await fn(response, request, opts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = {
|
|
||||||
request,
|
|
||||||
response,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (response.ok) {
|
|
||||||
const parseAs =
|
|
||||||
(opts.parseAs === 'auto'
|
|
||||||
? getParseAs(response.headers.get('Content-Type'))
|
|
||||||
: opts.parseAs) ?? 'json';
|
|
||||||
|
|
||||||
if (
|
|
||||||
response.status === 204 ||
|
|
||||||
response.headers.get('Content-Length') === '0'
|
|
||||||
) {
|
|
||||||
let emptyData: any;
|
|
||||||
switch (parseAs) {
|
|
||||||
case 'arrayBuffer':
|
|
||||||
case 'blob':
|
|
||||||
case 'text':
|
|
||||||
emptyData = await response[parseAs]();
|
|
||||||
break;
|
|
||||||
case 'formData':
|
|
||||||
emptyData = new FormData();
|
|
||||||
break;
|
|
||||||
case 'stream':
|
|
||||||
emptyData = response.body;
|
|
||||||
break;
|
|
||||||
case 'json':
|
|
||||||
default:
|
|
||||||
emptyData = {};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return opts.responseStyle === 'data'
|
|
||||||
? emptyData
|
|
||||||
: {
|
|
||||||
data: emptyData,
|
|
||||||
...result,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
let data: any;
|
|
||||||
switch (parseAs) {
|
|
||||||
case 'arrayBuffer':
|
|
||||||
case 'blob':
|
|
||||||
case 'formData':
|
|
||||||
case 'text':
|
|
||||||
data = await response[parseAs]();
|
|
||||||
break;
|
|
||||||
case 'json': {
|
|
||||||
// Some servers return 200 with no Content-Length and empty body.
|
|
||||||
// response.json() would throw; read as text and parse if non-empty.
|
|
||||||
const text = await response.text();
|
|
||||||
data = text ? JSON.parse(text) : {};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'stream':
|
|
||||||
return opts.responseStyle === 'data'
|
|
||||||
? response.body
|
|
||||||
: {
|
|
||||||
data: response.body,
|
|
||||||
...result,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parseAs === 'json') {
|
|
||||||
if (opts.responseValidator) {
|
|
||||||
await opts.responseValidator(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts.responseTransformer) {
|
|
||||||
data = await opts.responseTransformer(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return opts.responseStyle === 'data'
|
|
||||||
? data
|
|
||||||
: {
|
|
||||||
data,
|
|
||||||
...result,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const textError = await response.text();
|
|
||||||
let jsonError: unknown;
|
|
||||||
|
|
||||||
try {
|
|
||||||
jsonError = JSON.parse(textError);
|
|
||||||
} catch {
|
|
||||||
// noop
|
|
||||||
}
|
|
||||||
|
|
||||||
const error = jsonError ?? textError;
|
|
||||||
let finalError = error;
|
|
||||||
|
|
||||||
for (const fn of interceptors.error.fns) {
|
|
||||||
if (fn) {
|
|
||||||
finalError = (await fn(error, response, request, opts)) as string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
finalError = finalError || ({} as string);
|
|
||||||
|
|
||||||
if (opts.throwOnError) {
|
|
||||||
throw finalError;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: we probably want to return error and improve types
|
|
||||||
return opts.responseStyle === 'data'
|
|
||||||
? undefined
|
|
||||||
: {
|
|
||||||
error: finalError,
|
|
||||||
...result,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const makeMethodFn =
|
|
||||||
(method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
|
|
||||||
request({ ...options, method });
|
|
||||||
|
|
||||||
const makeSseFn =
|
|
||||||
(method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
|
|
||||||
const { opts, url } = await beforeRequest(options);
|
|
||||||
return createSseClient({
|
|
||||||
...opts,
|
|
||||||
body: opts.body as BodyInit | null | undefined,
|
|
||||||
headers: opts.headers as unknown as Record<string, string>,
|
|
||||||
method,
|
|
||||||
onRequest: async (url, init) => {
|
|
||||||
let request = new Request(url, init);
|
|
||||||
for (const fn of interceptors.request.fns) {
|
|
||||||
if (fn) {
|
|
||||||
request = await fn(request, opts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return request;
|
|
||||||
},
|
|
||||||
serializedBody: getValidRequestBody(opts) as
|
|
||||||
| BodyInit
|
|
||||||
| null
|
|
||||||
| undefined,
|
|
||||||
url,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
buildUrl,
|
|
||||||
connect: makeMethodFn('CONNECT'),
|
|
||||||
delete: makeMethodFn('DELETE'),
|
|
||||||
get: makeMethodFn('GET'),
|
|
||||||
getConfig,
|
|
||||||
head: makeMethodFn('HEAD'),
|
|
||||||
interceptors,
|
|
||||||
options: makeMethodFn('OPTIONS'),
|
|
||||||
patch: makeMethodFn('PATCH'),
|
|
||||||
post: makeMethodFn('POST'),
|
|
||||||
put: makeMethodFn('PUT'),
|
|
||||||
request,
|
|
||||||
setConfig,
|
|
||||||
sse: {
|
|
||||||
connect: makeSseFn('CONNECT'),
|
|
||||||
delete: makeSseFn('DELETE'),
|
|
||||||
get: makeSseFn('GET'),
|
|
||||||
head: makeSseFn('HEAD'),
|
|
||||||
options: makeSseFn('OPTIONS'),
|
|
||||||
patch: makeSseFn('PATCH'),
|
|
||||||
post: makeSseFn('POST'),
|
|
||||||
put: makeSseFn('PUT'),
|
|
||||||
trace: makeSseFn('TRACE'),
|
|
||||||
},
|
|
||||||
trace: makeMethodFn('TRACE'),
|
|
||||||
} as Client;
|
|
||||||
};
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
export type { Auth } from '../core/auth.gen';
|
|
||||||
export type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
|
||||||
export {
|
|
||||||
formDataBodySerializer,
|
|
||||||
jsonBodySerializer,
|
|
||||||
urlSearchParamsBodySerializer,
|
|
||||||
} from '../core/bodySerializer.gen';
|
|
||||||
export { buildClientParams } from '../core/params.gen';
|
|
||||||
export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
|
|
||||||
export { createClient } from './client.gen';
|
|
||||||
export type {
|
|
||||||
Client,
|
|
||||||
ClientOptions,
|
|
||||||
Config,
|
|
||||||
CreateClientConfig,
|
|
||||||
Options,
|
|
||||||
RequestOptions,
|
|
||||||
RequestResult,
|
|
||||||
ResolvedRequestOptions,
|
|
||||||
ResponseStyle,
|
|
||||||
TDataShape,
|
|
||||||
} from './types.gen';
|
|
||||||
export { createConfig, mergeHeaders } from './utils.gen';
|
|
||||||
@@ -1,241 +0,0 @@
|
|||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import type { Auth } from '../core/auth.gen';
|
|
||||||
import type {
|
|
||||||
ServerSentEventsOptions,
|
|
||||||
ServerSentEventsResult,
|
|
||||||
} from '../core/serverSentEvents.gen';
|
|
||||||
import type {
|
|
||||||
Client as CoreClient,
|
|
||||||
Config as CoreConfig,
|
|
||||||
} from '../core/types.gen';
|
|
||||||
import type { Middleware } from './utils.gen';
|
|
||||||
|
|
||||||
export type ResponseStyle = 'data' | 'fields';
|
|
||||||
|
|
||||||
export interface Config<T extends ClientOptions = ClientOptions>
|
|
||||||
extends Omit<RequestInit, 'body' | 'headers' | 'method'>,
|
|
||||||
CoreConfig {
|
|
||||||
/**
|
|
||||||
* Base URL for all requests made by this client.
|
|
||||||
*/
|
|
||||||
baseUrl?: T['baseUrl'];
|
|
||||||
/**
|
|
||||||
* Fetch API implementation. You can use this option to provide a custom
|
|
||||||
* fetch instance.
|
|
||||||
*
|
|
||||||
* @default globalThis.fetch
|
|
||||||
*/
|
|
||||||
fetch?: typeof fetch;
|
|
||||||
/**
|
|
||||||
* Please don't use the Fetch client for Next.js applications. The `next`
|
|
||||||
* options won't have any effect.
|
|
||||||
*
|
|
||||||
* Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
|
|
||||||
*/
|
|
||||||
next?: never;
|
|
||||||
/**
|
|
||||||
* Return the response data parsed in a specified format. By default, `auto`
|
|
||||||
* will infer the appropriate method from the `Content-Type` response header.
|
|
||||||
* You can override this behavior with any of the {@link Body} methods.
|
|
||||||
* Select `stream` if you don't want to parse response data at all.
|
|
||||||
*
|
|
||||||
* @default 'auto'
|
|
||||||
*/
|
|
||||||
parseAs?:
|
|
||||||
| 'arrayBuffer'
|
|
||||||
| 'auto'
|
|
||||||
| 'blob'
|
|
||||||
| 'formData'
|
|
||||||
| 'json'
|
|
||||||
| 'stream'
|
|
||||||
| 'text';
|
|
||||||
/**
|
|
||||||
* Should we return only data or multiple fields (data, error, response, etc.)?
|
|
||||||
*
|
|
||||||
* @default 'fields'
|
|
||||||
*/
|
|
||||||
responseStyle?: ResponseStyle;
|
|
||||||
/**
|
|
||||||
* Throw an error instead of returning it in the response?
|
|
||||||
*
|
|
||||||
* @default false
|
|
||||||
*/
|
|
||||||
throwOnError?: T['throwOnError'];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RequestOptions<
|
|
||||||
TData = unknown,
|
|
||||||
TResponseStyle extends ResponseStyle = 'fields',
|
|
||||||
ThrowOnError extends boolean = boolean,
|
|
||||||
Url extends string = string,
|
|
||||||
> extends Config<{
|
|
||||||
responseStyle: TResponseStyle;
|
|
||||||
throwOnError: ThrowOnError;
|
|
||||||
}>,
|
|
||||||
Pick<
|
|
||||||
ServerSentEventsOptions<TData>,
|
|
||||||
| 'onSseError'
|
|
||||||
| 'onSseEvent'
|
|
||||||
| 'sseDefaultRetryDelay'
|
|
||||||
| 'sseMaxRetryAttempts'
|
|
||||||
| 'sseMaxRetryDelay'
|
|
||||||
> {
|
|
||||||
/**
|
|
||||||
* Any body that you want to add to your request.
|
|
||||||
*
|
|
||||||
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
|
|
||||||
*/
|
|
||||||
body?: unknown;
|
|
||||||
path?: Record<string, unknown>;
|
|
||||||
query?: Record<string, unknown>;
|
|
||||||
/**
|
|
||||||
* Security mechanism(s) to use for the request.
|
|
||||||
*/
|
|
||||||
security?: ReadonlyArray<Auth>;
|
|
||||||
url: Url;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ResolvedRequestOptions<
|
|
||||||
TResponseStyle extends ResponseStyle = 'fields',
|
|
||||||
ThrowOnError extends boolean = boolean,
|
|
||||||
Url extends string = string,
|
|
||||||
> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
|
||||||
serializedBody?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type RequestResult<
|
|
||||||
TData = unknown,
|
|
||||||
TError = unknown,
|
|
||||||
ThrowOnError extends boolean = boolean,
|
|
||||||
TResponseStyle extends ResponseStyle = 'fields',
|
|
||||||
> = ThrowOnError extends true
|
|
||||||
? Promise<
|
|
||||||
TResponseStyle extends 'data'
|
|
||||||
? TData extends Record<string, unknown>
|
|
||||||
? TData[keyof TData]
|
|
||||||
: TData
|
|
||||||
: {
|
|
||||||
data: TData extends Record<string, unknown>
|
|
||||||
? TData[keyof TData]
|
|
||||||
: TData;
|
|
||||||
request: Request;
|
|
||||||
response: Response;
|
|
||||||
}
|
|
||||||
>
|
|
||||||
: Promise<
|
|
||||||
TResponseStyle extends 'data'
|
|
||||||
?
|
|
||||||
| (TData extends Record<string, unknown>
|
|
||||||
? TData[keyof TData]
|
|
||||||
: TData)
|
|
||||||
| undefined
|
|
||||||
: (
|
|
||||||
| {
|
|
||||||
data: TData extends Record<string, unknown>
|
|
||||||
? TData[keyof TData]
|
|
||||||
: TData;
|
|
||||||
error: undefined;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
data: undefined;
|
|
||||||
error: TError extends Record<string, unknown>
|
|
||||||
? TError[keyof TError]
|
|
||||||
: TError;
|
|
||||||
}
|
|
||||||
) & {
|
|
||||||
request: Request;
|
|
||||||
response: Response;
|
|
||||||
}
|
|
||||||
>;
|
|
||||||
|
|
||||||
export interface ClientOptions {
|
|
||||||
baseUrl?: string;
|
|
||||||
responseStyle?: ResponseStyle;
|
|
||||||
throwOnError?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
type MethodFn = <
|
|
||||||
TData = unknown,
|
|
||||||
TError = unknown,
|
|
||||||
ThrowOnError extends boolean = false,
|
|
||||||
TResponseStyle extends ResponseStyle = 'fields',
|
|
||||||
>(
|
|
||||||
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>,
|
|
||||||
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
||||||
|
|
||||||
type SseFn = <
|
|
||||||
TData = unknown,
|
|
||||||
TError = unknown,
|
|
||||||
ThrowOnError extends boolean = false,
|
|
||||||
TResponseStyle extends ResponseStyle = 'fields',
|
|
||||||
>(
|
|
||||||
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>,
|
|
||||||
) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
||||||
|
|
||||||
type RequestFn = <
|
|
||||||
TData = unknown,
|
|
||||||
TError = unknown,
|
|
||||||
ThrowOnError extends boolean = false,
|
|
||||||
TResponseStyle extends ResponseStyle = 'fields',
|
|
||||||
>(
|
|
||||||
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> &
|
|
||||||
Pick<
|
|
||||||
Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>,
|
|
||||||
'method'
|
|
||||||
>,
|
|
||||||
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
||||||
|
|
||||||
type BuildUrlFn = <
|
|
||||||
TData extends {
|
|
||||||
body?: unknown;
|
|
||||||
path?: Record<string, unknown>;
|
|
||||||
query?: Record<string, unknown>;
|
|
||||||
url: string;
|
|
||||||
},
|
|
||||||
>(
|
|
||||||
options: TData & Options<TData>,
|
|
||||||
) => string;
|
|
||||||
|
|
||||||
export type Client = CoreClient<
|
|
||||||
RequestFn,
|
|
||||||
Config,
|
|
||||||
MethodFn,
|
|
||||||
BuildUrlFn,
|
|
||||||
SseFn
|
|
||||||
> & {
|
|
||||||
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The `createClientConfig()` function will be called on client initialization
|
|
||||||
* and the returned object will become the client's initial configuration.
|
|
||||||
*
|
|
||||||
* You may want to initialize your client this way instead of calling
|
|
||||||
* `setConfig()`. This is useful for example if you're using Next.js
|
|
||||||
* to ensure your client always has the correct values.
|
|
||||||
*/
|
|
||||||
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (
|
|
||||||
override?: Config<ClientOptions & T>,
|
|
||||||
) => Config<Required<ClientOptions> & T>;
|
|
||||||
|
|
||||||
export interface TDataShape {
|
|
||||||
body?: unknown;
|
|
||||||
headers?: unknown;
|
|
||||||
path?: unknown;
|
|
||||||
query?: unknown;
|
|
||||||
url: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
||||||
|
|
||||||
export type Options<
|
|
||||||
TData extends TDataShape = TDataShape,
|
|
||||||
ThrowOnError extends boolean = boolean,
|
|
||||||
TResponse = unknown,
|
|
||||||
TResponseStyle extends ResponseStyle = 'fields',
|
|
||||||
> = OmitKeys<
|
|
||||||
RequestOptions<TResponse, TResponseStyle, ThrowOnError>,
|
|
||||||
'body' | 'path' | 'query' | 'url'
|
|
||||||
> &
|
|
||||||
([TData] extends [never] ? unknown : Omit<TData, 'url'>);
|
|
||||||
@@ -1,332 +0,0 @@
|
|||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import { getAuthToken } from '../core/auth.gen';
|
|
||||||
import type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
|
||||||
import { jsonBodySerializer } from '../core/bodySerializer.gen';
|
|
||||||
import {
|
|
||||||
serializeArrayParam,
|
|
||||||
serializeObjectParam,
|
|
||||||
serializePrimitiveParam,
|
|
||||||
} from '../core/pathSerializer.gen';
|
|
||||||
import { getUrl } from '../core/utils.gen';
|
|
||||||
import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
|
|
||||||
|
|
||||||
export const createQuerySerializer = <T = unknown>({
|
|
||||||
parameters = {},
|
|
||||||
...args
|
|
||||||
}: QuerySerializerOptions = {}) => {
|
|
||||||
const querySerializer = (queryParams: T) => {
|
|
||||||
const search: string[] = [];
|
|
||||||
if (queryParams && typeof queryParams === 'object') {
|
|
||||||
for (const name in queryParams) {
|
|
||||||
const value = queryParams[name];
|
|
||||||
|
|
||||||
if (value === undefined || value === null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = parameters[name] || args;
|
|
||||||
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
const serializedArray = serializeArrayParam({
|
|
||||||
allowReserved: options.allowReserved,
|
|
||||||
explode: true,
|
|
||||||
name,
|
|
||||||
style: 'form',
|
|
||||||
value,
|
|
||||||
...options.array,
|
|
||||||
});
|
|
||||||
if (serializedArray) search.push(serializedArray);
|
|
||||||
} else if (typeof value === 'object') {
|
|
||||||
const serializedObject = serializeObjectParam({
|
|
||||||
allowReserved: options.allowReserved,
|
|
||||||
explode: true,
|
|
||||||
name,
|
|
||||||
style: 'deepObject',
|
|
||||||
value: value as Record<string, unknown>,
|
|
||||||
...options.object,
|
|
||||||
});
|
|
||||||
if (serializedObject) search.push(serializedObject);
|
|
||||||
} else {
|
|
||||||
const serializedPrimitive = serializePrimitiveParam({
|
|
||||||
allowReserved: options.allowReserved,
|
|
||||||
name,
|
|
||||||
value: value as string,
|
|
||||||
});
|
|
||||||
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return search.join('&');
|
|
||||||
};
|
|
||||||
return querySerializer;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Infers parseAs value from provided Content-Type header.
|
|
||||||
*/
|
|
||||||
export const getParseAs = (
|
|
||||||
contentType: string | null,
|
|
||||||
): Exclude<Config['parseAs'], 'auto'> => {
|
|
||||||
if (!contentType) {
|
|
||||||
// If no Content-Type header is provided, the best we can do is return the raw response body,
|
|
||||||
// which is effectively the same as the 'stream' option.
|
|
||||||
return 'stream';
|
|
||||||
}
|
|
||||||
|
|
||||||
const cleanContent = contentType.split(';')[0]?.trim();
|
|
||||||
|
|
||||||
if (!cleanContent) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
cleanContent.startsWith('application/json') ||
|
|
||||||
cleanContent.endsWith('+json')
|
|
||||||
) {
|
|
||||||
return 'json';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cleanContent === 'multipart/form-data') {
|
|
||||||
return 'formData';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
['application/', 'audio/', 'image/', 'video/'].some((type) =>
|
|
||||||
cleanContent.startsWith(type),
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return 'blob';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cleanContent.startsWith('text/')) {
|
|
||||||
return 'text';
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
const checkForExistence = (
|
|
||||||
options: Pick<RequestOptions, 'auth' | 'query'> & {
|
|
||||||
headers: Headers;
|
|
||||||
},
|
|
||||||
name?: string,
|
|
||||||
): boolean => {
|
|
||||||
if (!name) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
options.headers.has(name) ||
|
|
||||||
options.query?.[name] ||
|
|
||||||
options.headers.get('Cookie')?.includes(`${name}=`)
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const setAuthParams = async ({
|
|
||||||
security,
|
|
||||||
...options
|
|
||||||
}: Pick<Required<RequestOptions>, 'security'> &
|
|
||||||
Pick<RequestOptions, 'auth' | 'query'> & {
|
|
||||||
headers: Headers;
|
|
||||||
}) => {
|
|
||||||
for (const auth of security) {
|
|
||||||
if (checkForExistence(options, auth.name)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const token = await getAuthToken(auth, options.auth);
|
|
||||||
|
|
||||||
if (!token) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const name = auth.name ?? 'Authorization';
|
|
||||||
|
|
||||||
switch (auth.in) {
|
|
||||||
case 'query':
|
|
||||||
if (!options.query) {
|
|
||||||
options.query = {};
|
|
||||||
}
|
|
||||||
options.query[name] = token;
|
|
||||||
break;
|
|
||||||
case 'cookie':
|
|
||||||
options.headers.append('Cookie', `${name}=${token}`);
|
|
||||||
break;
|
|
||||||
case 'header':
|
|
||||||
default:
|
|
||||||
options.headers.set(name, token);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const buildUrl: Client['buildUrl'] = (options) =>
|
|
||||||
getUrl({
|
|
||||||
baseUrl: options.baseUrl as string,
|
|
||||||
path: options.path,
|
|
||||||
query: options.query,
|
|
||||||
querySerializer:
|
|
||||||
typeof options.querySerializer === 'function'
|
|
||||||
? options.querySerializer
|
|
||||||
: createQuerySerializer(options.querySerializer),
|
|
||||||
url: options.url,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const mergeConfigs = (a: Config, b: Config): Config => {
|
|
||||||
const config = { ...a, ...b };
|
|
||||||
if (config.baseUrl?.endsWith('/')) {
|
|
||||||
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
||||||
}
|
|
||||||
config.headers = mergeHeaders(a.headers, b.headers);
|
|
||||||
return config;
|
|
||||||
};
|
|
||||||
|
|
||||||
const headersEntries = (headers: Headers): Array<[string, string]> => {
|
|
||||||
const entries: Array<[string, string]> = [];
|
|
||||||
headers.forEach((value, key) => {
|
|
||||||
entries.push([key, value]);
|
|
||||||
});
|
|
||||||
return entries;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const mergeHeaders = (
|
|
||||||
...headers: Array<Required<Config>['headers'] | undefined>
|
|
||||||
): Headers => {
|
|
||||||
const mergedHeaders = new Headers();
|
|
||||||
for (const header of headers) {
|
|
||||||
if (!header) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const iterator =
|
|
||||||
header instanceof Headers
|
|
||||||
? headersEntries(header)
|
|
||||||
: Object.entries(header);
|
|
||||||
|
|
||||||
for (const [key, value] of iterator) {
|
|
||||||
if (value === null) {
|
|
||||||
mergedHeaders.delete(key);
|
|
||||||
} else if (Array.isArray(value)) {
|
|
||||||
for (const v of value) {
|
|
||||||
mergedHeaders.append(key, v as string);
|
|
||||||
}
|
|
||||||
} else if (value !== undefined) {
|
|
||||||
// assume object headers are meant to be JSON stringified, i.e. their
|
|
||||||
// content value in OpenAPI specification is 'application/json'
|
|
||||||
mergedHeaders.set(
|
|
||||||
key,
|
|
||||||
typeof value === 'object' ? JSON.stringify(value) : (value as string),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return mergedHeaders;
|
|
||||||
};
|
|
||||||
|
|
||||||
type ErrInterceptor<Err, Res, Req, Options> = (
|
|
||||||
error: Err,
|
|
||||||
response: Res,
|
|
||||||
request: Req,
|
|
||||||
options: Options,
|
|
||||||
) => Err | Promise<Err>;
|
|
||||||
|
|
||||||
type ReqInterceptor<Req, Options> = (
|
|
||||||
request: Req,
|
|
||||||
options: Options,
|
|
||||||
) => Req | Promise<Req>;
|
|
||||||
|
|
||||||
type ResInterceptor<Res, Req, Options> = (
|
|
||||||
response: Res,
|
|
||||||
request: Req,
|
|
||||||
options: Options,
|
|
||||||
) => Res | Promise<Res>;
|
|
||||||
|
|
||||||
class Interceptors<Interceptor> {
|
|
||||||
fns: Array<Interceptor | null> = [];
|
|
||||||
|
|
||||||
clear(): void {
|
|
||||||
this.fns = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
eject(id: number | Interceptor): void {
|
|
||||||
const index = this.getInterceptorIndex(id);
|
|
||||||
if (this.fns[index]) {
|
|
||||||
this.fns[index] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exists(id: number | Interceptor): boolean {
|
|
||||||
const index = this.getInterceptorIndex(id);
|
|
||||||
return Boolean(this.fns[index]);
|
|
||||||
}
|
|
||||||
|
|
||||||
getInterceptorIndex(id: number | Interceptor): number {
|
|
||||||
if (typeof id === 'number') {
|
|
||||||
return this.fns[id] ? id : -1;
|
|
||||||
}
|
|
||||||
return this.fns.indexOf(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
update(
|
|
||||||
id: number | Interceptor,
|
|
||||||
fn: Interceptor,
|
|
||||||
): number | Interceptor | false {
|
|
||||||
const index = this.getInterceptorIndex(id);
|
|
||||||
if (this.fns[index]) {
|
|
||||||
this.fns[index] = fn;
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
use(fn: Interceptor): number {
|
|
||||||
this.fns.push(fn);
|
|
||||||
return this.fns.length - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Middleware<Req, Res, Err, Options> {
|
|
||||||
error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
|
|
||||||
request: Interceptors<ReqInterceptor<Req, Options>>;
|
|
||||||
response: Interceptors<ResInterceptor<Res, Req, Options>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const createInterceptors = <Req, Res, Err, Options>(): Middleware<
|
|
||||||
Req,
|
|
||||||
Res,
|
|
||||||
Err,
|
|
||||||
Options
|
|
||||||
> => ({
|
|
||||||
error: new Interceptors<ErrInterceptor<Err, Res, Req, Options>>(),
|
|
||||||
request: new Interceptors<ReqInterceptor<Req, Options>>(),
|
|
||||||
response: new Interceptors<ResInterceptor<Res, Req, Options>>(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const defaultQuerySerializer = createQuerySerializer({
|
|
||||||
allowReserved: false,
|
|
||||||
array: {
|
|
||||||
explode: true,
|
|
||||||
style: 'form',
|
|
||||||
},
|
|
||||||
object: {
|
|
||||||
explode: true,
|
|
||||||
style: 'deepObject',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const defaultHeaders = {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
};
|
|
||||||
|
|
||||||
export const createConfig = <T extends ClientOptions = ClientOptions>(
|
|
||||||
override: Config<Omit<ClientOptions, keyof T> & T> = {},
|
|
||||||
): Config<Omit<ClientOptions, keyof T> & T> => ({
|
|
||||||
...jsonBodySerializer,
|
|
||||||
headers: defaultHeaders,
|
|
||||||
parseAs: 'auto',
|
|
||||||
querySerializer: defaultQuerySerializer,
|
|
||||||
...override,
|
|
||||||
});
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
export type AuthToken = string | undefined;
|
|
||||||
|
|
||||||
export interface Auth {
|
|
||||||
/**
|
|
||||||
* Which part of the request do we use to send the auth?
|
|
||||||
*
|
|
||||||
* @default 'header'
|
|
||||||
*/
|
|
||||||
in?: 'header' | 'query' | 'cookie';
|
|
||||||
/**
|
|
||||||
* Header or query parameter name.
|
|
||||||
*
|
|
||||||
* @default 'Authorization'
|
|
||||||
*/
|
|
||||||
name?: string;
|
|
||||||
scheme?: 'basic' | 'bearer';
|
|
||||||
type: 'apiKey' | 'http';
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getAuthToken = async (
|
|
||||||
auth: Auth,
|
|
||||||
callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,
|
|
||||||
): Promise<string | undefined> => {
|
|
||||||
const token =
|
|
||||||
typeof callback === 'function' ? await callback(auth) : callback;
|
|
||||||
|
|
||||||
if (!token) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (auth.scheme === 'bearer') {
|
|
||||||
return `Bearer ${token}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (auth.scheme === 'basic') {
|
|
||||||
return `Basic ${btoa(token)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return token;
|
|
||||||
};
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import type {
|
|
||||||
ArrayStyle,
|
|
||||||
ObjectStyle,
|
|
||||||
SerializerOptions,
|
|
||||||
} from './pathSerializer.gen';
|
|
||||||
|
|
||||||
export type QuerySerializer = (query: Record<string, unknown>) => string;
|
|
||||||
|
|
||||||
export type BodySerializer = (body: any) => any;
|
|
||||||
|
|
||||||
type QuerySerializerOptionsObject = {
|
|
||||||
allowReserved?: boolean;
|
|
||||||
array?: Partial<SerializerOptions<ArrayStyle>>;
|
|
||||||
object?: Partial<SerializerOptions<ObjectStyle>>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type QuerySerializerOptions = QuerySerializerOptionsObject & {
|
|
||||||
/**
|
|
||||||
* Per-parameter serialization overrides. When provided, these settings
|
|
||||||
* override the global array/object settings for specific parameter names.
|
|
||||||
*/
|
|
||||||
parameters?: Record<string, QuerySerializerOptionsObject>;
|
|
||||||
};
|
|
||||||
|
|
||||||
const serializeFormDataPair = (
|
|
||||||
data: FormData,
|
|
||||||
key: string,
|
|
||||||
value: unknown,
|
|
||||||
): void => {
|
|
||||||
if (typeof value === 'string' || value instanceof Blob) {
|
|
||||||
data.append(key, value);
|
|
||||||
} else if (value instanceof Date) {
|
|
||||||
data.append(key, value.toISOString());
|
|
||||||
} else {
|
|
||||||
data.append(key, JSON.stringify(value));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const serializeUrlSearchParamsPair = (
|
|
||||||
data: URLSearchParams,
|
|
||||||
key: string,
|
|
||||||
value: unknown,
|
|
||||||
): void => {
|
|
||||||
if (typeof value === 'string') {
|
|
||||||
data.append(key, value);
|
|
||||||
} else {
|
|
||||||
data.append(key, JSON.stringify(value));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const formDataBodySerializer = {
|
|
||||||
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
|
|
||||||
body: T,
|
|
||||||
): FormData => {
|
|
||||||
const data = new FormData();
|
|
||||||
|
|
||||||
Object.entries(body).forEach(([key, value]) => {
|
|
||||||
if (value === undefined || value === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
value.forEach((v) => serializeFormDataPair(data, key, v));
|
|
||||||
} else {
|
|
||||||
serializeFormDataPair(data, key, value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return data;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export const jsonBodySerializer = {
|
|
||||||
bodySerializer: <T>(body: T): string =>
|
|
||||||
JSON.stringify(body, (_key, value) =>
|
|
||||||
typeof value === 'bigint' ? value.toString() : value,
|
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
export const urlSearchParamsBodySerializer = {
|
|
||||||
bodySerializer: <T extends Record<string, any> | Array<Record<string, any>>>(
|
|
||||||
body: T,
|
|
||||||
): string => {
|
|
||||||
const data = new URLSearchParams();
|
|
||||||
|
|
||||||
Object.entries(body).forEach(([key, value]) => {
|
|
||||||
if (value === undefined || value === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
|
||||||
} else {
|
|
||||||
serializeUrlSearchParamsPair(data, key, value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return data.toString();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,176 +0,0 @@
|
|||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
type Slot = 'body' | 'headers' | 'path' | 'query';
|
|
||||||
|
|
||||||
export type Field =
|
|
||||||
| {
|
|
||||||
in: Exclude<Slot, 'body'>;
|
|
||||||
/**
|
|
||||||
* Field name. This is the name we want the user to see and use.
|
|
||||||
*/
|
|
||||||
key: string;
|
|
||||||
/**
|
|
||||||
* Field mapped name. This is the name we want to use in the request.
|
|
||||||
* If omitted, we use the same value as `key`.
|
|
||||||
*/
|
|
||||||
map?: string;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
in: Extract<Slot, 'body'>;
|
|
||||||
/**
|
|
||||||
* Key isn't required for bodies.
|
|
||||||
*/
|
|
||||||
key?: string;
|
|
||||||
map?: string;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
/**
|
|
||||||
* Field name. This is the name we want the user to see and use.
|
|
||||||
*/
|
|
||||||
key: string;
|
|
||||||
/**
|
|
||||||
* Field mapped name. This is the name we want to use in the request.
|
|
||||||
* If `in` is omitted, `map` aliases `key` to the transport layer.
|
|
||||||
*/
|
|
||||||
map: Slot;
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface Fields {
|
|
||||||
allowExtra?: Partial<Record<Slot, boolean>>;
|
|
||||||
args?: ReadonlyArray<Field>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type FieldsConfig = ReadonlyArray<Field | Fields>;
|
|
||||||
|
|
||||||
const extraPrefixesMap: Record<string, Slot> = {
|
|
||||||
$body_: 'body',
|
|
||||||
$headers_: 'headers',
|
|
||||||
$path_: 'path',
|
|
||||||
$query_: 'query',
|
|
||||||
};
|
|
||||||
const extraPrefixes = Object.entries(extraPrefixesMap);
|
|
||||||
|
|
||||||
type KeyMap = Map<
|
|
||||||
string,
|
|
||||||
| {
|
|
||||||
in: Slot;
|
|
||||||
map?: string;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
in?: never;
|
|
||||||
map: Slot;
|
|
||||||
}
|
|
||||||
>;
|
|
||||||
|
|
||||||
const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => {
|
|
||||||
if (!map) {
|
|
||||||
map = new Map();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const config of fields) {
|
|
||||||
if ('in' in config) {
|
|
||||||
if (config.key) {
|
|
||||||
map.set(config.key, {
|
|
||||||
in: config.in,
|
|
||||||
map: config.map,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if ('key' in config) {
|
|
||||||
map.set(config.key, {
|
|
||||||
map: config.map,
|
|
||||||
});
|
|
||||||
} else if (config.args) {
|
|
||||||
buildKeyMap(config.args, map);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return map;
|
|
||||||
};
|
|
||||||
|
|
||||||
interface Params {
|
|
||||||
body: unknown;
|
|
||||||
headers: Record<string, unknown>;
|
|
||||||
path: Record<string, unknown>;
|
|
||||||
query: Record<string, unknown>;
|
|
||||||
}
|
|
||||||
|
|
||||||
const stripEmptySlots = (params: Params) => {
|
|
||||||
for (const [slot, value] of Object.entries(params)) {
|
|
||||||
if (value && typeof value === 'object' && !Object.keys(value).length) {
|
|
||||||
delete params[slot as Slot];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const buildClientParams = (
|
|
||||||
args: ReadonlyArray<unknown>,
|
|
||||||
fields: FieldsConfig,
|
|
||||||
) => {
|
|
||||||
const params: Params = {
|
|
||||||
body: {},
|
|
||||||
headers: {},
|
|
||||||
path: {},
|
|
||||||
query: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
const map = buildKeyMap(fields);
|
|
||||||
|
|
||||||
let config: FieldsConfig[number] | undefined;
|
|
||||||
|
|
||||||
for (const [index, arg] of args.entries()) {
|
|
||||||
if (fields[index]) {
|
|
||||||
config = fields[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!config) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('in' in config) {
|
|
||||||
if (config.key) {
|
|
||||||
const field = map.get(config.key)!;
|
|
||||||
const name = field.map || config.key;
|
|
||||||
if (field.in) {
|
|
||||||
(params[field.in] as Record<string, unknown>)[name] = arg;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
params.body = arg;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (const [key, value] of Object.entries(arg ?? {})) {
|
|
||||||
const field = map.get(key);
|
|
||||||
|
|
||||||
if (field) {
|
|
||||||
if (field.in) {
|
|
||||||
const name = field.map || key;
|
|
||||||
(params[field.in] as Record<string, unknown>)[name] = value;
|
|
||||||
} else {
|
|
||||||
params[field.map] = value;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const extra = extraPrefixes.find(([prefix]) =>
|
|
||||||
key.startsWith(prefix),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (extra) {
|
|
||||||
const [prefix, slot] = extra;
|
|
||||||
(params[slot] as Record<string, unknown>)[
|
|
||||||
key.slice(prefix.length)
|
|
||||||
] = value;
|
|
||||||
} else if ('allowExtra' in config && config.allowExtra) {
|
|
||||||
for (const [slot, allowed] of Object.entries(config.allowExtra)) {
|
|
||||||
if (allowed) {
|
|
||||||
(params[slot as Slot] as Record<string, unknown>)[key] = value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stripEmptySlots(params);
|
|
||||||
|
|
||||||
return params;
|
|
||||||
};
|
|
||||||
@@ -1,181 +0,0 @@
|
|||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
interface SerializeOptions<T>
|
|
||||||
extends SerializePrimitiveOptions,
|
|
||||||
SerializerOptions<T> {}
|
|
||||||
|
|
||||||
interface SerializePrimitiveOptions {
|
|
||||||
allowReserved?: boolean;
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SerializerOptions<T> {
|
|
||||||
/**
|
|
||||||
* @default true
|
|
||||||
*/
|
|
||||||
explode: boolean;
|
|
||||||
style: T;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
|
|
||||||
export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
|
|
||||||
type MatrixStyle = 'label' | 'matrix' | 'simple';
|
|
||||||
export type ObjectStyle = 'form' | 'deepObject';
|
|
||||||
type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
|
|
||||||
|
|
||||||
interface SerializePrimitiveParam extends SerializePrimitiveOptions {
|
|
||||||
value: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const separatorArrayExplode = (style: ArraySeparatorStyle) => {
|
|
||||||
switch (style) {
|
|
||||||
case 'label':
|
|
||||||
return '.';
|
|
||||||
case 'matrix':
|
|
||||||
return ';';
|
|
||||||
case 'simple':
|
|
||||||
return ',';
|
|
||||||
default:
|
|
||||||
return '&';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => {
|
|
||||||
switch (style) {
|
|
||||||
case 'form':
|
|
||||||
return ',';
|
|
||||||
case 'pipeDelimited':
|
|
||||||
return '|';
|
|
||||||
case 'spaceDelimited':
|
|
||||||
return '%20';
|
|
||||||
default:
|
|
||||||
return ',';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const separatorObjectExplode = (style: ObjectSeparatorStyle) => {
|
|
||||||
switch (style) {
|
|
||||||
case 'label':
|
|
||||||
return '.';
|
|
||||||
case 'matrix':
|
|
||||||
return ';';
|
|
||||||
case 'simple':
|
|
||||||
return ',';
|
|
||||||
default:
|
|
||||||
return '&';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const serializeArrayParam = ({
|
|
||||||
allowReserved,
|
|
||||||
explode,
|
|
||||||
name,
|
|
||||||
style,
|
|
||||||
value,
|
|
||||||
}: SerializeOptions<ArraySeparatorStyle> & {
|
|
||||||
value: unknown[];
|
|
||||||
}) => {
|
|
||||||
if (!explode) {
|
|
||||||
const joinedValues = (
|
|
||||||
allowReserved ? value : value.map((v) => encodeURIComponent(v as string))
|
|
||||||
).join(separatorArrayNoExplode(style));
|
|
||||||
switch (style) {
|
|
||||||
case 'label':
|
|
||||||
return `.${joinedValues}`;
|
|
||||||
case 'matrix':
|
|
||||||
return `;${name}=${joinedValues}`;
|
|
||||||
case 'simple':
|
|
||||||
return joinedValues;
|
|
||||||
default:
|
|
||||||
return `${name}=${joinedValues}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const separator = separatorArrayExplode(style);
|
|
||||||
const joinedValues = value
|
|
||||||
.map((v) => {
|
|
||||||
if (style === 'label' || style === 'simple') {
|
|
||||||
return allowReserved ? v : encodeURIComponent(v as string);
|
|
||||||
}
|
|
||||||
|
|
||||||
return serializePrimitiveParam({
|
|
||||||
allowReserved,
|
|
||||||
name,
|
|
||||||
value: v as string,
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.join(separator);
|
|
||||||
return style === 'label' || style === 'matrix'
|
|
||||||
? separator + joinedValues
|
|
||||||
: joinedValues;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const serializePrimitiveParam = ({
|
|
||||||
allowReserved,
|
|
||||||
name,
|
|
||||||
value,
|
|
||||||
}: SerializePrimitiveParam) => {
|
|
||||||
if (value === undefined || value === null) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof value === 'object') {
|
|
||||||
throw new Error(
|
|
||||||
'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const serializeObjectParam = ({
|
|
||||||
allowReserved,
|
|
||||||
explode,
|
|
||||||
name,
|
|
||||||
style,
|
|
||||||
value,
|
|
||||||
valueOnly,
|
|
||||||
}: SerializeOptions<ObjectSeparatorStyle> & {
|
|
||||||
value: Record<string, unknown> | Date;
|
|
||||||
valueOnly?: boolean;
|
|
||||||
}) => {
|
|
||||||
if (value instanceof Date) {
|
|
||||||
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (style !== 'deepObject' && !explode) {
|
|
||||||
let values: string[] = [];
|
|
||||||
Object.entries(value).forEach(([key, v]) => {
|
|
||||||
values = [
|
|
||||||
...values,
|
|
||||||
key,
|
|
||||||
allowReserved ? (v as string) : encodeURIComponent(v as string),
|
|
||||||
];
|
|
||||||
});
|
|
||||||
const joinedValues = values.join(',');
|
|
||||||
switch (style) {
|
|
||||||
case 'form':
|
|
||||||
return `${name}=${joinedValues}`;
|
|
||||||
case 'label':
|
|
||||||
return `.${joinedValues}`;
|
|
||||||
case 'matrix':
|
|
||||||
return `;${name}=${joinedValues}`;
|
|
||||||
default:
|
|
||||||
return joinedValues;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const separator = separatorObjectExplode(style);
|
|
||||||
const joinedValues = Object.entries(value)
|
|
||||||
.map(([key, v]) =>
|
|
||||||
serializePrimitiveParam({
|
|
||||||
allowReserved,
|
|
||||||
name: style === 'deepObject' ? `${name}[${key}]` : key,
|
|
||||||
value: v as string,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.join(separator);
|
|
||||||
return style === 'label' || style === 'matrix'
|
|
||||||
? separator + joinedValues
|
|
||||||
: joinedValues;
|
|
||||||
};
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JSON-friendly union that mirrors what Pinia Colada can hash.
|
|
||||||
*/
|
|
||||||
export type JsonValue =
|
|
||||||
| null
|
|
||||||
| string
|
|
||||||
| number
|
|
||||||
| boolean
|
|
||||||
| JsonValue[]
|
|
||||||
| { [key: string]: JsonValue };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
|
|
||||||
*/
|
|
||||||
export const queryKeyJsonReplacer = (_key: string, value: unknown) => {
|
|
||||||
if (
|
|
||||||
value === undefined ||
|
|
||||||
typeof value === 'function' ||
|
|
||||||
typeof value === 'symbol'
|
|
||||||
) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
if (typeof value === 'bigint') {
|
|
||||||
return value.toString();
|
|
||||||
}
|
|
||||||
if (value instanceof Date) {
|
|
||||||
return value.toISOString();
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Safely stringifies a value and parses it back into a JsonValue.
|
|
||||||
*/
|
|
||||||
export const stringifyToJsonValue = (input: unknown): JsonValue | undefined => {
|
|
||||||
try {
|
|
||||||
const json = JSON.stringify(input, queryKeyJsonReplacer);
|
|
||||||
if (json === undefined) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return JSON.parse(json) as JsonValue;
|
|
||||||
} catch {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Detects plain objects (including objects with a null prototype).
|
|
||||||
*/
|
|
||||||
const isPlainObject = (value: unknown): value is Record<string, unknown> => {
|
|
||||||
if (value === null || typeof value !== 'object') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const prototype = Object.getPrototypeOf(value as object);
|
|
||||||
return prototype === Object.prototype || prototype === null;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turns URLSearchParams into a sorted JSON object for deterministic keys.
|
|
||||||
*/
|
|
||||||
const serializeSearchParams = (params: URLSearchParams): JsonValue => {
|
|
||||||
const entries = Array.from(params.entries()).sort(([a], [b]) =>
|
|
||||||
a.localeCompare(b),
|
|
||||||
);
|
|
||||||
const result: Record<string, JsonValue> = {};
|
|
||||||
|
|
||||||
for (const [key, value] of entries) {
|
|
||||||
const existing = result[key];
|
|
||||||
if (existing === undefined) {
|
|
||||||
result[key] = value;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(existing)) {
|
|
||||||
(existing as string[]).push(value);
|
|
||||||
} else {
|
|
||||||
result[key] = [existing, value];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalizes any accepted value into a JSON-friendly shape for query keys.
|
|
||||||
*/
|
|
||||||
export const serializeQueryKeyValue = (
|
|
||||||
value: unknown,
|
|
||||||
): JsonValue | undefined => {
|
|
||||||
if (value === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
typeof value === 'string' ||
|
|
||||||
typeof value === 'number' ||
|
|
||||||
typeof value === 'boolean'
|
|
||||||
) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
value === undefined ||
|
|
||||||
typeof value === 'function' ||
|
|
||||||
typeof value === 'symbol'
|
|
||||||
) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof value === 'bigint') {
|
|
||||||
return value.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof Date) {
|
|
||||||
return value.toISOString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
return stringifyToJsonValue(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
typeof URLSearchParams !== 'undefined' &&
|
|
||||||
value instanceof URLSearchParams
|
|
||||||
) {
|
|
||||||
return serializeSearchParams(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isPlainObject(value)) {
|
|
||||||
return stringifyToJsonValue(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
@@ -1,266 +0,0 @@
|
|||||||
// This file is auto-generated by @hey-api/openapi-ts
|
|
||||||
|
|
||||||
import type { Config } from './types.gen';
|
|
||||||
|
|
||||||
export type ServerSentEventsOptions<TData = unknown> = Omit<
|
|
||||||
RequestInit,
|
|
||||||
'method'
|
|
||||||
> &
|
|
||||||
Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & {
|
|
||||||
/**
|
|
||||||
* Fetch API implementation. You can use this option to provide a custom
|
|
||||||
* fetch instance.
|
|
||||||
*
|
|
||||||
* @default globalThis.fetch
|
|
||||||
*/
|
|
||||||
fetch?: typeof fetch;
|
|
||||||
/**
|
|
||||||
* Implementing clients can call request interceptors inside this hook.
|
|
||||||
*/
|
|
||||||
onRequest?: (url: string, init: RequestInit) => Promise<Request>;
|
|
||||||
/**
|
|
||||||
* Callback invoked when a network or parsing error occurs during streaming.
|
|
||||||
*
|
|
||||||
* This option applies only if the endpoint returns a stream of events.
|
|
||||||
*
|
|
||||||
* @param error The error that occurred.
|
|
||||||
*/
|
|
||||||
onSseError?: (error: unknown) => void;
|
|
||||||
/**
|
|
||||||
* Callback invoked when an event is streamed from the server.
|
|
||||||
*
|
|
||||||
* This option applies only if the endpoint returns a stream of events.
|
|
||||||
*
|
|
||||||
* @param event Event streamed from the server.
|
|
||||||
* @returns Nothing (void).
|
|
||||||
*/
|
|
||||||
onSseEvent?: (event: StreamEvent<TData>) => void;
|
|
||||||
serializedBody?: RequestInit['body'];
|
|
||||||
/**
|
|
||||||
* Default retry delay in milliseconds.
|
|
||||||
*
|
|
||||||
* This option applies only if the endpoint returns a stream of events.
|
|
||||||
*
|
|
||||||
* @default 3000
|
|
||||||
*/
|
|
||||||
sseDefaultRetryDelay?: number;
|
|
||||||
/**
|
|
||||||
* Maximum number of retry attempts before giving up.
|
|
||||||
*/
|
|
||||||
sseMaxRetryAttempts?: number;
|
|
||||||
/**
|
|
||||||
* Maximum retry delay in milliseconds.
|
|
||||||
*
|
|
||||||
* Applies only when exponential backoff is used.
|
|
||||||
*
|
|
||||||
* This option applies only if the endpoint returns a stream of events.
|
|
||||||
*
|
|
||||||
* @default 30000
|
|
||||||
*/
|
|
||||||
sseMaxRetryDelay?: number;
|
|
||||||
/**
|
|
||||||
* Optional sleep function for retry backoff.
|
|
||||||
*
|
|
||||||
* Defaults to using `setTimeout`.
|
|
||||||
*/
|
|
||||||
sseSleepFn?: (ms: number) => Promise<void>;
|
|
||||||
url: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface StreamEvent<TData = unknown> {
|
|
||||||
data: TData;
|
|
||||||
event?: string;
|
|
||||||
id?: string;
|
|
||||||
retry?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ServerSentEventsResult<
|
|
||||||
TData = unknown,
|
|
||||||
TReturn = void,
|
|
||||||
TNext = unknown,
|
|
||||||
> = {
|
|
||||||
stream: AsyncGenerator<
|
|
||||||
TData extends Record<string, unknown> ? TData[keyof TData] : TData,
|
|
||||||
TReturn,
|
|
||||||
TNext
|
|
||||||
>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const createSseClient = <TData = unknown>({
|
|
||||||
onRequest,
|
|
||||||
onSseError,
|
|
||||||
onSseEvent,
|
|
||||||
responseTransformer,
|
|
||||||
responseValidator,
|
|
||||||
sseDefaultRetryDelay,
|
|
||||||
sseMaxRetryAttempts,
|
|
||||||
sseMaxRetryDelay,
|
|
||||||
sseSleepFn,
|
|
||||||
url,
|
|
||||||
...options
|
|
||||||
}: ServerSentEventsOptions): ServerSentEventsResult<TData> => {
|
|
||||||
let lastEventId: string | undefined;
|
|
||||||
|
|
||||||
const sleep =
|
|
||||||
sseSleepFn ??
|
|
||||||
((ms: number) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
||||||
|
|
||||||
const createStream = async function* () {
|
|
||||||
let retryDelay: number = sseDefaultRetryDelay ?? 3000;
|
|
||||||
let attempt = 0;
|
|
||||||
const signal = options.signal ?? new AbortController().signal;
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
if (signal.aborted) break;
|
|
||||||
|
|
||||||
attempt++;
|
|
||||||
|
|
||||||
const headers =
|
|
||||||
options.headers instanceof Headers
|
|
||||||
? options.headers
|
|
||||||
: new Headers(options.headers as Record<string, string> | undefined);
|
|
||||||
|
|
||||||
if (lastEventId !== undefined) {
|
|
||||||
headers.set('Last-Event-ID', lastEventId);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const requestInit: RequestInit = {
|
|
||||||
redirect: 'follow',
|
|
||||||
...options,
|
|
||||||
body: options.serializedBody,
|
|
||||||
headers,
|
|
||||||
signal,
|
|
||||||
};
|
|
||||||
let request = new Request(url, requestInit);
|
|
||||||
if (onRequest) {
|
|
||||||
request = await onRequest(url, requestInit);
|
|
||||||
}
|
|
||||||
// fetch must be assigned here, otherwise it would throw the error:
|
|
||||||
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
||||||
const _fetch = options.fetch ?? globalThis.fetch;
|
|
||||||
const response = await _fetch(request);
|
|
||||||
|
|
||||||
if (!response.ok)
|
|
||||||
throw new Error(
|
|
||||||
`SSE failed: ${response.status} ${response.statusText}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!response.body) throw new Error('No body in SSE response');
|
|
||||||
|
|
||||||
const reader = response.body
|
|
||||||
.pipeThrough(new TextDecoderStream())
|
|
||||||
.getReader();
|
|
||||||
|
|
||||||
let buffer = '';
|
|
||||||
|
|
||||||
const abortHandler = () => {
|
|
||||||
try {
|
|
||||||
reader.cancel();
|
|
||||||
} catch {
|
|
||||||
// noop
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
signal.addEventListener('abort', abortHandler);
|
|
||||||
|
|
||||||
try {
|
|
||||||
while (true) {
|
|
||||||
const { done, value } = await reader.read();
|
|
||||||
if (done) break;
|
|
||||||
buffer += value;
|
|
||||||
// Normalize line endings: CRLF -> LF, then CR -> LF
|
|
||||||
buffer = buffer.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
||||||
|
|
||||||
const chunks = buffer.split('\n\n');
|
|
||||||
buffer = chunks.pop() ?? '';
|
|
||||||
|
|
||||||
for (const chunk of chunks) {
|
|
||||||
const lines = chunk.split('\n');
|
|
||||||
const dataLines: Array<string> = [];
|
|
||||||
let eventName: string | undefined;
|
|
||||||
|
|
||||||
for (const line of lines) {
|
|
||||||
if (line.startsWith('data:')) {
|
|
||||||
dataLines.push(line.replace(/^data:\s*/, ''));
|
|
||||||
} else if (line.startsWith('event:')) {
|
|
||||||
eventName = line.replace(/^event:\s*/, '');
|
|
||||||
} else if (line.startsWith('id:')) {
|
|
||||||
lastEventId = line.replace(/^id:\s*/, '');
|
|
||||||
} else if (line.startsWith('retry:')) {
|
|
||||||
const parsed = Number.parseInt(
|
|
||||||
line.replace(/^retry:\s*/, ''),
|
|
||||||
10,
|
|
||||||
);
|
|
||||||
if (!Number.isNaN(parsed)) {
|
|
||||||
retryDelay = parsed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let data: unknown;
|
|
||||||
let parsedJson = false;
|
|
||||||
|
|
||||||
if (dataLines.length) {
|
|
||||||
const rawData = dataLines.join('\n');
|
|
||||||
try {
|
|
||||||
data = JSON.parse(rawData);
|
|
||||||
parsedJson = true;
|
|
||||||
} catch {
|
|
||||||
data = rawData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parsedJson) {
|
|
||||||
if (responseValidator) {
|
|
||||||
await responseValidator(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (responseTransformer) {
|
|
||||||
data = await responseTransformer(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onSseEvent?.({
|
|
||||||
data,
|
|
||||||
event: eventName,
|
|
||||||
id: lastEventId,
|
|
||||||
retry: retryDelay,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (dataLines.length) {
|
|
||||||
yield data as any;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
signal.removeEventListener('abort', abortHandler);
|
|
||||||
reader.releaseLock();
|
|
||||||
}
|
|
||||||
|
|
||||||
break; // exit loop on normal completion
|
|
||||||
} catch (error) {
|
|
||||||
// connection failed or aborted; retry after delay
|
|
||||||
onSseError?.(error);
|
|
||||||
|
|
||||||
if (
|
|
||||||
sseMaxRetryAttempts !== undefined &&
|
|
||||||
attempt >= sseMaxRetryAttempts
|
|
||||||
) {
|
|
||||||
break; // stop after firing error
|
|
||||||
}
|
|
||||||
|
|
||||||
// exponential backoff: double retry each attempt, cap at 30s
|
|
||||||
const backoff = Math.min(
|
|
||||||
retryDelay * 2 ** (attempt - 1),
|
|
||||||
sseMaxRetryDelay ?? 30000,
|
|
||||||
);
|
|
||||||
await sleep(backoff);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const stream = createStream();
|
|
||||||
|
|
||||||
return { stream };
|
|
||||||
};
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user