diff --git a/plugins/tauri-plugin-revenue-cat/.gitignore b/plugins/tauri-plugin-revenue-cat/.gitignore new file mode 100644 index 00000000..50d8e32e --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/.gitignore @@ -0,0 +1,17 @@ +/.vs +.DS_Store +.Thumbs.db +*.sublime* +.idea/ +debug.log +package-lock.json +.vscode/settings.json +yarn.lock + +/.tauri +/target +Cargo.lock +node_modules/ + +dist-js +dist diff --git a/plugins/tauri-plugin-revenue-cat/Cargo.toml b/plugins/tauri-plugin-revenue-cat/Cargo.toml new file mode 100644 index 00000000..71ee52a0 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "tauri-plugin-revenue-cat" +version = "0.1.0" +authors = [ "You" ] +description = "" +edition = "2021" +rust-version = "1.77.2" +exclude = ["/examples", "/dist-js", "/guest-js", "/node_modules"] +links = "tauri-plugin-revenue-cat" + +[dependencies] +tauri = { version = "2.2.4" } +serde = "1.0" +thiserror = "2" + +[build-dependencies] +tauri-plugin = { version = "2.0.3", features = ["build"] } diff --git a/plugins/tauri-plugin-revenue-cat/README.md b/plugins/tauri-plugin-revenue-cat/README.md new file mode 100644 index 00000000..1de9bf59 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/README.md @@ -0,0 +1 @@ +# Tauri Plugin revenue-cat diff --git a/plugins/tauri-plugin-revenue-cat/build.rs b/plugins/tauri-plugin-revenue-cat/build.rs new file mode 100644 index 00000000..20eb734b --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/build.rs @@ -0,0 +1,8 @@ +const COMMANDS: &[&str] = &["ping", "createCustomer", "fetchProjectOverviewData", "getCustomersData"]; + +fn main() { + tauri_plugin::Builder::new(COMMANDS) + .android_path("android") + .ios_path("ios") + .build(); +} diff --git a/plugins/tauri-plugin-revenue-cat/bun.lock b/plugins/tauri-plugin-revenue-cat/bun.lock new file mode 100644 index 00000000..28c931cb --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/bun.lock @@ -0,0 +1,88 @@ +{ + "lockfileVersion": 1, + "workspaces": { + "": { + "name": "tauri-plugin-revenue-cat-api", + "dependencies": { + "@tauri-apps/api": ">=2.0.0-beta.6", + }, + "devDependencies": { + "@rollup/plugin-typescript": "^11.1.6", + "rollup": "^4.9.6", + "tslib": "^2.6.2", + "typescript": "^5.3.3", + }, + }, + }, + "packages": { + "@rollup/plugin-typescript": ["@rollup/plugin-typescript@11.1.6", "", { "dependencies": { "@rollup/pluginutils": "^5.1.0", "resolve": "^1.22.1" }, "peerDependencies": { "rollup": "^2.14.0||^3.0.0||^4.0.0", "tslib": "*", "typescript": ">=3.7.0" }, "optionalPeers": ["rollup", "tslib"] }, "sha512-R92yOmIACgYdJ7dJ97p4K69I8gg6IEHt8M7dUBxN3W6nrO8uUxX5ixl0yU/N3aZTi8WhPuICvOHXQvF6FaykAA=="], + + "@rollup/pluginutils": ["@rollup/pluginutils@5.1.4", "", { "dependencies": { "@types/estree": "^1.0.0", "estree-walker": "^2.0.2", "picomatch": "^4.0.2" }, "peerDependencies": { "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" }, "optionalPeers": ["rollup"] }, "sha512-USm05zrsFxYLPdWWq+K3STlWiT/3ELn3RcV5hJMghpeAIhxfsUIg6mt12CBJBInWMV4VneoV7SfGv8xIwo2qNQ=="], + + "@rollup/rollup-android-arm-eabi": ["@rollup/rollup-android-arm-eabi@4.34.8", "", { "os": "android", "cpu": "arm" }, "sha512-q217OSE8DTp8AFHuNHXo0Y86e1wtlfVrXiAlwkIvGRQv9zbc6mE3sjIVfwI8sYUyNxwOg0j/Vm1RKM04JcWLJw=="], + + "@rollup/rollup-android-arm64": ["@rollup/rollup-android-arm64@4.34.8", "", { "os": "android", "cpu": "arm64" }, "sha512-Gigjz7mNWaOL9wCggvoK3jEIUUbGul656opstjaUSGC3eT0BM7PofdAJaBfPFWWkXNVAXbaQtC99OCg4sJv70Q=="], + + "@rollup/rollup-darwin-arm64": ["@rollup/rollup-darwin-arm64@4.34.8", "", { "os": "darwin", "cpu": "arm64" }, "sha512-02rVdZ5tgdUNRxIUrFdcMBZQoaPMrxtwSb+/hOfBdqkatYHR3lZ2A2EGyHq2sGOd0Owk80oV3snlDASC24He3Q=="], + + "@rollup/rollup-darwin-x64": ["@rollup/rollup-darwin-x64@4.34.8", "", { "os": "darwin", "cpu": "x64" }, "sha512-qIP/elwR/tq/dYRx3lgwK31jkZvMiD6qUtOycLhTzCvrjbZ3LjQnEM9rNhSGpbLXVJYQ3rq39A6Re0h9tU2ynw=="], + + "@rollup/rollup-freebsd-arm64": ["@rollup/rollup-freebsd-arm64@4.34.8", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-IQNVXL9iY6NniYbTaOKdrlVP3XIqazBgJOVkddzJlqnCpRi/yAeSOa8PLcECFSQochzqApIOE1GHNu3pCz+BDA=="], + + "@rollup/rollup-freebsd-x64": ["@rollup/rollup-freebsd-x64@4.34.8", "", { "os": "freebsd", "cpu": "x64" }, "sha512-TYXcHghgnCqYFiE3FT5QwXtOZqDj5GmaFNTNt3jNC+vh22dc/ukG2cG+pi75QO4kACohZzidsq7yKTKwq/Jq7Q=="], + + "@rollup/rollup-linux-arm-gnueabihf": ["@rollup/rollup-linux-arm-gnueabihf@4.34.8", "", { "os": "linux", "cpu": "arm" }, "sha512-A4iphFGNkWRd+5m3VIGuqHnG3MVnqKe7Al57u9mwgbyZ2/xF9Jio72MaY7xxh+Y87VAHmGQr73qoKL9HPbXj1g=="], + + "@rollup/rollup-linux-arm-musleabihf": ["@rollup/rollup-linux-arm-musleabihf@4.34.8", "", { "os": "linux", "cpu": "arm" }, "sha512-S0lqKLfTm5u+QTxlFiAnb2J/2dgQqRy/XvziPtDd1rKZFXHTyYLoVL58M/XFwDI01AQCDIevGLbQrMAtdyanpA=="], + + "@rollup/rollup-linux-arm64-gnu": ["@rollup/rollup-linux-arm64-gnu@4.34.8", "", { "os": "linux", "cpu": "arm64" }, "sha512-jpz9YOuPiSkL4G4pqKrus0pn9aYwpImGkosRKwNi+sJSkz+WU3anZe6hi73StLOQdfXYXC7hUfsQlTnjMd3s1A=="], + + "@rollup/rollup-linux-arm64-musl": ["@rollup/rollup-linux-arm64-musl@4.34.8", "", { "os": "linux", "cpu": "arm64" }, "sha512-KdSfaROOUJXgTVxJNAZ3KwkRc5nggDk+06P6lgi1HLv1hskgvxHUKZ4xtwHkVYJ1Rep4GNo+uEfycCRRxht7+Q=="], + + "@rollup/rollup-linux-loongarch64-gnu": ["@rollup/rollup-linux-loongarch64-gnu@4.34.8", "", { "os": "linux", "cpu": "none" }, "sha512-NyF4gcxwkMFRjgXBM6g2lkT58OWztZvw5KkV2K0qqSnUEqCVcqdh2jN4gQrTn/YUpAcNKyFHfoOZEer9nwo6uQ=="], + + "@rollup/rollup-linux-powerpc64le-gnu": ["@rollup/rollup-linux-powerpc64le-gnu@4.34.8", "", { "os": "linux", "cpu": "ppc64" }, "sha512-LMJc999GkhGvktHU85zNTDImZVUCJ1z/MbAJTnviiWmmjyckP5aQsHtcujMjpNdMZPT2rQEDBlJfubhs3jsMfw=="], + + "@rollup/rollup-linux-riscv64-gnu": ["@rollup/rollup-linux-riscv64-gnu@4.34.8", "", { "os": "linux", "cpu": "none" }, "sha512-xAQCAHPj8nJq1PI3z8CIZzXuXCstquz7cIOL73HHdXiRcKk8Ywwqtx2wrIy23EcTn4aZ2fLJNBB8d0tQENPCmw=="], + + "@rollup/rollup-linux-s390x-gnu": ["@rollup/rollup-linux-s390x-gnu@4.34.8", "", { "os": "linux", "cpu": "s390x" }, "sha512-DdePVk1NDEuc3fOe3dPPTb+rjMtuFw89gw6gVWxQFAuEqqSdDKnrwzZHrUYdac7A7dXl9Q2Vflxpme15gUWQFA=="], + + "@rollup/rollup-linux-x64-gnu": ["@rollup/rollup-linux-x64-gnu@4.34.8", "", { "os": "linux", "cpu": "x64" }, "sha512-8y7ED8gjxITUltTUEJLQdgpbPh1sUQ0kMTmufRF/Ns5tI9TNMNlhWtmPKKHCU0SilX+3MJkZ0zERYYGIVBYHIA=="], + + "@rollup/rollup-linux-x64-musl": ["@rollup/rollup-linux-x64-musl@4.34.8", "", { "os": "linux", "cpu": "x64" }, "sha512-SCXcP0ZpGFIe7Ge+McxY5zKxiEI5ra+GT3QRxL0pMMtxPfpyLAKleZODi1zdRHkz5/BhueUrYtYVgubqe9JBNQ=="], + + "@rollup/rollup-win32-arm64-msvc": ["@rollup/rollup-win32-arm64-msvc@4.34.8", "", { "os": "win32", "cpu": "arm64" }, "sha512-YHYsgzZgFJzTRbth4h7Or0m5O74Yda+hLin0irAIobkLQFRQd1qWmnoVfwmKm9TXIZVAD0nZ+GEb2ICicLyCnQ=="], + + "@rollup/rollup-win32-ia32-msvc": ["@rollup/rollup-win32-ia32-msvc@4.34.8", "", { "os": "win32", "cpu": "ia32" }, "sha512-r3NRQrXkHr4uWy5TOjTpTYojR9XmF0j/RYgKCef+Ag46FWUTltm5ziticv8LdNsDMehjJ543x/+TJAek/xBA2w=="], + + "@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.34.8", "", { "os": "win32", "cpu": "x64" }, "sha512-U0FaE5O1BCpZSeE6gBl3c5ObhePQSfk9vDRToMmTkbhCOgW4jqvtS5LGyQ76L1fH8sM0keRp4uDTsbjiUyjk0g=="], + + "@tauri-apps/api": ["@tauri-apps/api@2.2.0", "", {}, "sha512-R8epOeZl1eJEl603aUMIGb4RXlhPjpgxbGVEaqY+0G5JG9vzV/clNlzTeqc+NLYXVqXcn8mb4c5b9pJIUDEyAg=="], + + "@types/estree": ["@types/estree@1.0.6", "", {}, "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw=="], + + "estree-walker": ["estree-walker@2.0.2", "", {}, "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="], + + "fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="], + + "function-bind": ["function-bind@1.1.2", "", {}, "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA=="], + + "hasown": ["hasown@2.0.2", "", { "dependencies": { "function-bind": "^1.1.2" } }, "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ=="], + + "is-core-module": ["is-core-module@2.16.1", "", { "dependencies": { "hasown": "^2.0.2" } }, "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w=="], + + "path-parse": ["path-parse@1.0.7", "", {}, "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw=="], + + "picomatch": ["picomatch@4.0.2", "", {}, "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg=="], + + "resolve": ["resolve@1.22.10", "", { "dependencies": { "is-core-module": "^2.16.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, "bin": { "resolve": "bin/resolve" } }, "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w=="], + + "rollup": ["rollup@4.34.8", "", { "dependencies": { "@types/estree": "1.0.6" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.34.8", "@rollup/rollup-android-arm64": "4.34.8", "@rollup/rollup-darwin-arm64": "4.34.8", "@rollup/rollup-darwin-x64": "4.34.8", "@rollup/rollup-freebsd-arm64": "4.34.8", "@rollup/rollup-freebsd-x64": "4.34.8", "@rollup/rollup-linux-arm-gnueabihf": "4.34.8", "@rollup/rollup-linux-arm-musleabihf": "4.34.8", "@rollup/rollup-linux-arm64-gnu": "4.34.8", "@rollup/rollup-linux-arm64-musl": "4.34.8", "@rollup/rollup-linux-loongarch64-gnu": "4.34.8", "@rollup/rollup-linux-powerpc64le-gnu": "4.34.8", "@rollup/rollup-linux-riscv64-gnu": "4.34.8", "@rollup/rollup-linux-s390x-gnu": "4.34.8", "@rollup/rollup-linux-x64-gnu": "4.34.8", "@rollup/rollup-linux-x64-musl": "4.34.8", "@rollup/rollup-win32-arm64-msvc": "4.34.8", "@rollup/rollup-win32-ia32-msvc": "4.34.8", "@rollup/rollup-win32-x64-msvc": "4.34.8", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-489gTVMzAYdiZHFVA/ig/iYFllCcWFHMvUHI1rpFmkoUtRlQxqh6/yiNqnYibjMZ2b/+FUQwldG+aLsEt6bglQ=="], + + "supports-preserve-symlinks-flag": ["supports-preserve-symlinks-flag@1.0.0", "", {}, "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w=="], + + "tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="], + + "typescript": ["typescript@5.7.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw=="], + } +} diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/.gitignore b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/.gitignore new file mode 100644 index 00000000..a547bf36 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/.vscode/extensions.json b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/.vscode/extensions.json new file mode 100644 index 00000000..61343e9b --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "svelte.svelte-vscode", + "tauri-apps.tauri-vscode", + "rust-lang.rust-analyzer" + ] +} diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/README.md b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/README.md new file mode 100644 index 00000000..72726a1f --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/README.md @@ -0,0 +1,8 @@ +# Svelte + Vite + +This template should help get you started developing with Tauri and Svelte in Vite. + +## Recommended IDE Setup + +[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer). + diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/index.html b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/index.html new file mode 100644 index 00000000..fad1c5d9 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/index.html @@ -0,0 +1,14 @@ + + + + + + + Tauri + Svelte + + + +
+ + + diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/jsconfig.json b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/jsconfig.json new file mode 100644 index 00000000..ee5e92f2 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/jsconfig.json @@ -0,0 +1,34 @@ +{ + "compilerOptions": { + "moduleResolution": "Node", + "target": "ESNext", + "module": "ESNext", + /** + * svelte-preprocess cannot figure out whether you have + * a value or a type, so tell TypeScript to enforce using + * `import type` instead of `import` for Types. + */ + "importsNotUsedAsValues": "error", + "isolatedModules": true, + "resolveJsonModule": true, + /** + * To have warnings / errors of the Svelte compiler at the + * correct position, enable source maps by default. + */ + "sourceMap": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "baseUrl": ".", + /** + * Typecheck JS in `.svelte` and `.js` files by default. + * Disable this if you'd like to use dynamic types. + */ + "checkJs": true + }, + /** + * Use global.d.ts instead of compilerOptions.types + * to avoid limiting type declarations. + */ + "include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"] +} diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/package.json b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/package.json new file mode 100644 index 00000000..f3443010 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/package.json @@ -0,0 +1,22 @@ +{ + "name": "tauri-app", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "tauri": "tauri" + }, + "dependencies": { + "@tauri-apps/api": "^2.0.0", + "tauri-plugin-revenue-cat-api": "file:../../" + }, + "devDependencies": { + "@sveltejs/vite-plugin-svelte": "^5.0.0", + "svelte": "^5.0.0", + "vite": "^6.0.0", + "@tauri-apps/cli": "^2.0.0" + } +} diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/public/svelte.svg b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/public/svelte.svg new file mode 100644 index 00000000..c5e08481 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/public/svelte.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/public/tauri.svg b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/public/tauri.svg new file mode 100644 index 00000000..31b62c92 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/public/tauri.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/public/vite.svg b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/public/vite.svg new file mode 100644 index 00000000..e7b8dfb1 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/.gitignore b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/.gitignore new file mode 100644 index 00000000..f4dfb82b --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/.gitignore @@ -0,0 +1,4 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ + diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/Cargo.toml b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/Cargo.toml new file mode 100644 index 00000000..d93c00a6 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "tauri-app" +version = "0.1.0" +description = "A Tauri App" +authors = ["you"] +license = "" +repository = "" +edition = "2021" +rust-version = "1.77.2" + +[lib] +name = "tauri_app_lib" +crate-type = ["staticlib", "cdylib", "rlib"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[build-dependencies] +tauri-build = { version = "2.0.4", default-features = false } + +[dependencies] +tauri = { version = "2.2.4" } +tauri-plugin-revenue-cat = { path = "../../../" } + diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/build.rs b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/build.rs new file mode 100644 index 00000000..795b9b7c --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/build.rs @@ -0,0 +1,3 @@ +fn main() { + tauri_build::build() +} diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/capabilities/default.json b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/capabilities/default.json new file mode 100644 index 00000000..7c78aef1 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/capabilities/default.json @@ -0,0 +1,12 @@ +{ + "$schema": "../gen/schemas/desktop-schema.json", + "identifier": "default", + "description": "enables the default permissions", + "windows": [ + "main" + ], + "permissions": [ + "core:default", + "revenue-cat:default" + ] +} diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/128x128.png b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/128x128.png new file mode 100644 index 00000000..77e7d233 Binary files /dev/null and b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/128x128.png differ diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/128x128@2x.png b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/128x128@2x.png new file mode 100644 index 00000000..0f7976f1 Binary files /dev/null and b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/128x128@2x.png differ diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/32x32.png b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/32x32.png new file mode 100644 index 00000000..98fda06f Binary files /dev/null and b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/32x32.png differ diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/icon.icns b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/icon.icns new file mode 100644 index 00000000..29d6685a Binary files /dev/null and b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/icon.icns differ diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/icon.ico b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/icon.ico new file mode 100644 index 00000000..06c23c82 Binary files /dev/null and b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/icon.ico differ diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/icon.png b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/icon.png new file mode 100644 index 00000000..d1756ce4 Binary files /dev/null and b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/icons/icon.png differ diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/src/lib.rs b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/src/lib.rs new file mode 100644 index 00000000..623c4804 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/src/lib.rs @@ -0,0 +1,14 @@ +// Learn more about Tauri commands at https://v2.tauri.app/develop/calling-rust/#commands +#[tauri::command] +fn greet(name: &str) -> String { + format!("Hello, {}! You've been greeted from Rust!", name) +} + +#[cfg_attr(mobile, tauri::mobile_entry_point)] +pub fn run() { + tauri::Builder::default() + .invoke_handler(tauri::generate_handler![greet]) + .plugin(tauri_plugin_revenue_cat::init()) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/src/main.rs b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/src/main.rs new file mode 100644 index 00000000..455963ee --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/src/main.rs @@ -0,0 +1,6 @@ +// Prevents additional console window on Windows in release, DO NOT REMOVE!! +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +fn main() { + tauri_app_lib::run(); +} diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/tauri.conf.json b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/tauri.conf.json new file mode 100644 index 00000000..72ebf400 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src-tauri/tauri.conf.json @@ -0,0 +1,37 @@ +{ + "productName": "tauri-app", + "version": "0.1.0", + "identifier": "com.tauri.dev", + "build": { + "beforeDevCommand": "pnpm dev", + "beforeBuildCommand": "pnpm build", + "devUrl": "http://localhost:1420", + "frontendDist": "../dist" + }, + "app": { + "withGlobalTauri": false, + "security": { + "csp": null + }, + "windows": [ + { + "fullscreen": false, + "height": 600, + "resizable": true, + "title": "tauri-app", + "width": 800 + } + ] + }, + "bundle": { + "active": true, + "targets": "all", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ] + } +} diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src/App.svelte b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src/App.svelte new file mode 100644 index 00000000..1b2e6120 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src/App.svelte @@ -0,0 +1,54 @@ + + +
+

Welcome to Tauri!

+ +
+ + + + + + + + + +
+ +

+ Click on the Tauri, Vite, and Svelte logos to learn more. +

+ +
+ +
+ +
+ +
{@html response}
+
+ +
+ + diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src/lib/Greet.svelte b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src/lib/Greet.svelte new file mode 100644 index 00000000..41e901b5 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src/lib/Greet.svelte @@ -0,0 +1,22 @@ + + +
+
+ + +
+

{greetMsg}

+
+ diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src/main.js b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src/main.js new file mode 100644 index 00000000..6b4e1a96 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src/main.js @@ -0,0 +1,8 @@ +import "./style.css"; +import App from "./App.svelte"; + +const app = new App({ + target: document.getElementById("app"), +}); + +export default app; diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src/style.css b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src/style.css new file mode 100644 index 00000000..c0f9e3bc --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src/style.css @@ -0,0 +1,102 @@ +:root { + font-family: Inter, Avenir, Helvetica, Arial, sans-serif; + font-size: 16px; + line-height: 24px; + font-weight: 400; + + color: #0f0f0f; + background-color: #f6f6f6; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + -webkit-text-size-adjust: 100%; +} + +.container { + margin: 0; + padding-top: 10vh; + display: flex; + flex-direction: column; + justify-content: center; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: 0.75s; +} + +.logo.tauri:hover { + filter: drop-shadow(0 0 2em #24c8db); +} + +.row { + display: flex; + justify-content: center; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} + +a:hover { + color: #535bf2; +} + +h1 { + text-align: center; +} + +input, +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + color: #0f0f0f; + background-color: #ffffff; + transition: border-color 0.25s; + box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2); +} + +button { + cursor: pointer; +} + +button:hover { + border-color: #396cd8; +} + +input, +button { + outline: none; +} + +#greet-input { + margin-right: 5px; +} + +@media (prefers-color-scheme: dark) { + :root { + color: #f6f6f6; + background-color: #2f2f2f; + } + + a:hover { + color: #24c8db; + } + + input, + button { + color: #ffffff; + background-color: #0f0f0f98; + } +} diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src/vite-env.d.ts b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src/vite-env.d.ts new file mode 100644 index 00000000..4078e747 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/src/vite-env.d.ts @@ -0,0 +1,2 @@ +/// +/// diff --git a/plugins/tauri-plugin-revenue-cat/examples/tauri-app/vite.config.js b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/vite.config.js new file mode 100644 index 00000000..3b85afb9 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/examples/tauri-app/vite.config.js @@ -0,0 +1,24 @@ +import { defineConfig } from "vite"; +import { svelte } from "@sveltejs/vite-plugin-svelte"; + +const host = process.env.TAURI_DEV_HOST; + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [svelte()], + + // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` + // prevent vite from obscuring rust errors + clearScreen: false, + // tauri expects a fixed port, fail if that port is not available + server: { + host: host || false, + port: 1420, + strictPort: true, + hmr: host ? { + protocol: 'ws', + host, + port: 1421 + } : undefined, + }, +}) diff --git a/plugins/tauri-plugin-revenue-cat/guest-js/index.ts b/plugins/tauri-plugin-revenue-cat/guest-js/index.ts new file mode 100644 index 00000000..28a3d55a --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/guest-js/index.ts @@ -0,0 +1,38 @@ +import { invoke } from '@tauri-apps/api/core' + +export async function ping(value: string): Promise { + return await invoke<{value?: string}>('plugin:revenue-cat|ping', { + payload: { + value, + }, + }).then((r) => (r.value ? r.value : null)); +} + +export async function createCustomer(projectId: string, apiKey: string, customerId: string, email: string): Promise { + return await invoke<{value?: string}>('plugin:revenue-cat|createCustomer', { + payload: { + projectId, + apiKey, + customerId, + email, + }, + }).then((r) => (r.value ? r.value : null)); +} + +export async function fetchProjectOverviewData(projectId: string, apiKey: string): Promise { + return await invoke<{value?: string}>('plugin:revenue-cat|fetchProjectOverviewData', { + payload: { + projectId, + apiKey, + }, + }).then((r) => (r.value ? r.value : null)); +} + +export async function getCustomersData(projectId: string, apiKey: string): Promise { + return await invoke<{value?: string}>('plugin:revenue-cat|getCustomersData', { + payload: { + projectId, + apiKey, + }, + }).then((r) => (r.value ? r.value : null)); +} diff --git a/plugins/tauri-plugin-revenue-cat/ios/.gitignore b/plugins/tauri-plugin-revenue-cat/ios/.gitignore new file mode 100644 index 00000000..5922fdaa --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/ios/.gitignore @@ -0,0 +1,10 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc +Package.resolved diff --git a/plugins/tauri-plugin-revenue-cat/ios/Package.swift b/plugins/tauri-plugin-revenue-cat/ios/Package.swift new file mode 100644 index 00000000..de3f9122 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/ios/Package.swift @@ -0,0 +1,32 @@ +// swift-tools-version:5.3 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "tauri-plugin-revenue-cat", + platforms: [ + .macOS(.v10_13), + .iOS(.v13), + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "tauri-plugin-revenue-cat", + type: .static, + targets: ["tauri-plugin-revenue-cat"]), + ], + dependencies: [ + .package(name: "Tauri", path: "../.tauri/tauri-api") + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "tauri-plugin-revenue-cat", + dependencies: [ + .byName(name: "Tauri") + ], + path: "Sources") + ] +) diff --git a/plugins/tauri-plugin-revenue-cat/ios/README.md b/plugins/tauri-plugin-revenue-cat/ios/README.md new file mode 100644 index 00000000..1d6a3735 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/ios/README.md @@ -0,0 +1,3 @@ +# Tauri Plugin revenue-cat + +A description of this package. diff --git a/plugins/tauri-plugin-revenue-cat/ios/Sources/ExamplePlugin.swift b/plugins/tauri-plugin-revenue-cat/ios/Sources/ExamplePlugin.swift new file mode 100644 index 00000000..1e97fd90 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/ios/Sources/ExamplePlugin.swift @@ -0,0 +1,81 @@ +import Tauri +import UIKit +import WebKit + +class PingArgs: Decodable { + let projectId: String + let apiKey: String +} + +class CreateCustomerArgs: Decodable { + let projectId: String + let apiKey: String + let customerId: String + let email: String +} + +class FetchProjectOverviewDataArgs: Decodable { + let projectId: String + let apiKey: String +} + +class GetCustomersDataArgs: Decodable { + let projectId: String + let apiKey: String +} + +class ExamplePlugin: Plugin { + @objc public func ping(_ invoke: Invoke) throws { + let args = try invoke.parseArgs(PingArgs.self) + invoke.resolve(["value": args.value ?? ""]) + } + + @objc public func createCustomer(_ invoke: Invoke) { + Task { + do { + let args = try invoke.parseArgs(CreateCustomerArgs.self) + let projectId = args.projectId + let apiKey = args.apiKey + let customerId = args.customerId + let email = args.email + let data = try await createCustomer(projectId: projectId, apiKey: apiKey, customerId: customerId, email: email) + invoke.resolve(["value": String(data: data, encoding: .utf8) ?? ""]) + } catch { + invoke.reject(error.localizedDescription) + } + } + } + + @objc public func fetchProjectOverviewData(_ invoke: Invoke) { + Task { + do { + let args = try invoke.parseArgs(FetchProjectOverviewDataArgs.self) + let projectId = args.projectId + let apiKey = args.apiKey + let data = try await fetchProjectOverviewData(projectId: projectId, apiKey: apiKey) + invoke.resolve(["value": String(data: data, encoding: .utf8) ?? ""]) + } catch { + invoke.reject(error.localizedDescription) + } + } + } + + @objc public func getCustomersData(_ invoke: Invoke) { + Task { + do { + let args = try invoke.parseArgs(GetCustomersDataArgs.self) + let projectId = args.projectId + let apiKey = args.apiKey + let data = try await getCustomersData(projectId: projectId, apiKey: apiKey) + invoke.resolve(["value": String(data: data, encoding: .utf8) ?? ""]) + } catch { + invoke.reject(error.localizedDescription) + } + } + } +} + +@_cdecl("init_plugin_revenue_cat") +func initPlugin() -> Plugin { + return ExamplePlugin() +} diff --git a/plugins/tauri-plugin-revenue-cat/ios/Sources/RevenueCat.swift b/plugins/tauri-plugin-revenue-cat/ios/Sources/RevenueCat.swift new file mode 100644 index 00000000..941e1c1e --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/ios/Sources/RevenueCat.swift @@ -0,0 +1,77 @@ +import Foundation + +let BASE_URL = "https://api.revenuecat.com/v2" + +func fetchProjectOverviewData(projectId: String, apiKey: String) async throws -> Data { + let urlString = BASE_URL + "/projects/\(projectId)/metrics/overview" + guard let url = URL(string: urlString) else { + throw NSError(domain: "Invalid URL", code: -1) + } + + var request = URLRequest(url: url) + request.httpMethod = "GET" + request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization") + + let (data, response) = try await URLSession.shared.data(for: request) + + guard let httpResponse = response as? HTTPURLResponse, + (200...299).contains(httpResponse.statusCode) else { + throw NSError(domain: "HTTP Error", code: (response as? HTTPURLResponse)?.statusCode ?? -1) + } + + return data +} + +func createCustomer(projectId: String, apiKey: String, customerId: String, attributes: [String: Any]) async throws -> Data { + let urlString = BASE_URL + "/projects/\(projectId)/customers" + guard let url = URL(string: urlString) else { + throw NSError(domain: "Invalid URL", code: -1) + } + + // Create the request body + let requestBody: [String: Any] = [ + "id": customerId, + "attributes": attributes + ] + ] + + // Convert body to JSON data + let jsonData = try JSONSerialization.data(withJSONObject: requestBody) + + // Create and configure the request + var request = URLRequest(url: url) + request.httpMethod = "POST" + request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization") + request.setValue("application/json", forHTTPHeaderField: "Content-Type") + request.httpBody = jsonData + + let (data, response) = try await URLSession.shared.data(for: request) + + guard let httpResponse = response as? HTTPURLResponse, + (200...299).contains(httpResponse.statusCode) else { + throw NSError(domain: "HTTP Error", code: (response as? HTTPURLResponse)?.statusCode ?? -1) + } + + return data +} + +func getCustomersData(projectId: String, apiKey: String) async throws -> Data { + let urlString = BASE_URL + "/projects/\(projectId)/customers" + guard let url = URL(string: urlString) else { + throw NSError(domain: "Invalid URL", code: -1) + } + + // Create and configure the request + var request = URLRequest(url: url) + request.httpMethod = "GET" + request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization") + + let (data, response) = try await URLSession.shared.data(for: request) + + guard let httpResponse = response as? HTTPURLResponse, + (200...299).contains(httpResponse.statusCode) else { + throw NSError(domain: "HTTP Error", code: (response as? HTTPURLResponse)?.statusCode ?? -1) + } + + return data +} diff --git a/plugins/tauri-plugin-revenue-cat/ios/Sources/data.json b/plugins/tauri-plugin-revenue-cat/ios/Sources/data.json new file mode 100644 index 00000000..e173148e --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/ios/Sources/data.json @@ -0,0 +1,23 @@ +{ + "object" : "list", + "items" : [ + { + "project_id" : "proj7139ead4", + "id" : "19b8de26-77c1-49f1-aa18-019a391603e2", + "first_seen_at" : 1740026777427, + "object" : "customer", + "last_seen_at" : 1740026777429, + "experiment" : null + }, + { + "project_id" : "proj7139ead4", + "id" : "customer_123", + "first_seen_at" : 1740026563933, + "object" : "customer", + "last_seen_at" : 1740026563936, + "experiment" : null + } + ], + "url" : "https:\/\/api.revenuecat.com\/v2\/projects\/7139ead4\/customers", + "next_page" : null +} \ No newline at end of file diff --git a/plugins/tauri-plugin-revenue-cat/ios/Tests/PluginTests/PluginTests.swift b/plugins/tauri-plugin-revenue-cat/ios/Tests/PluginTests/PluginTests.swift new file mode 100644 index 00000000..4f8e9ace --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/ios/Tests/PluginTests/PluginTests.swift @@ -0,0 +1,8 @@ +import XCTest +@testable import ExamplePlugin + +final class ExamplePluginTests: XCTestCase { + func testExample() throws { + let plugin = ExamplePlugin() + } +} diff --git a/plugins/tauri-plugin-revenue-cat/package.json b/plugins/tauri-plugin-revenue-cat/package.json new file mode 100644 index 00000000..44aec91c --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/package.json @@ -0,0 +1,33 @@ +{ + "name": "tauri-plugin-revenue-cat-api", + "version": "0.1.0", + "author": "You", + "description": "", + "type": "module", + "types": "./dist-js/index.d.ts", + "main": "./dist-js/index.cjs", + "module": "./dist-js/index.js", + "exports": { + "types": "./dist-js/index.d.ts", + "import": "./dist-js/index.js", + "require": "./dist-js/index.cjs" + }, + "files": [ + "dist-js", + "README.md" + ], + "scripts": { + "build": "rollup -c", + "prepublishOnly": "pnpm build", + "pretest": "pnpm build" + }, + "dependencies": { + "@tauri-apps/api": ">=2.0.0-beta.6" + }, + "devDependencies": { + "@rollup/plugin-typescript": "^11.1.6", + "rollup": "^4.9.6", + "typescript": "^5.3.3", + "tslib": "^2.6.2" + } +} diff --git a/plugins/tauri-plugin-revenue-cat/permissions/autogenerated/commands/createCustomer.toml b/plugins/tauri-plugin-revenue-cat/permissions/autogenerated/commands/createCustomer.toml new file mode 100644 index 00000000..710e4b8e --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/permissions/autogenerated/commands/createCustomer.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-createCustomer" +description = "Enables the createCustomer command without any pre-configured scope." +commands.allow = ["createCustomer"] + +[[permission]] +identifier = "deny-createCustomer" +description = "Denies the createCustomer command without any pre-configured scope." +commands.deny = ["createCustomer"] diff --git a/plugins/tauri-plugin-revenue-cat/permissions/autogenerated/commands/fetchProjectOverviewData.toml b/plugins/tauri-plugin-revenue-cat/permissions/autogenerated/commands/fetchProjectOverviewData.toml new file mode 100644 index 00000000..cc43208c --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/permissions/autogenerated/commands/fetchProjectOverviewData.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-fetchProjectOverviewData" +description = "Enables the fetchProjectOverviewData command without any pre-configured scope." +commands.allow = ["fetchProjectOverviewData"] + +[[permission]] +identifier = "deny-fetchProjectOverviewData" +description = "Denies the fetchProjectOverviewData command without any pre-configured scope." +commands.deny = ["fetchProjectOverviewData"] diff --git a/plugins/tauri-plugin-revenue-cat/permissions/autogenerated/commands/getCustomersData.toml b/plugins/tauri-plugin-revenue-cat/permissions/autogenerated/commands/getCustomersData.toml new file mode 100644 index 00000000..ba14ca69 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/permissions/autogenerated/commands/getCustomersData.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-getCustomersData" +description = "Enables the getCustomersData command without any pre-configured scope." +commands.allow = ["getCustomersData"] + +[[permission]] +identifier = "deny-getCustomersData" +description = "Denies the getCustomersData command without any pre-configured scope." +commands.deny = ["getCustomersData"] diff --git a/plugins/tauri-plugin-revenue-cat/permissions/autogenerated/commands/ping.toml b/plugins/tauri-plugin-revenue-cat/permissions/autogenerated/commands/ping.toml new file mode 100644 index 00000000..1d135880 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/permissions/autogenerated/commands/ping.toml @@ -0,0 +1,13 @@ +# Automatically generated - DO NOT EDIT! + +"$schema" = "../../schemas/schema.json" + +[[permission]] +identifier = "allow-ping" +description = "Enables the ping command without any pre-configured scope." +commands.allow = ["ping"] + +[[permission]] +identifier = "deny-ping" +description = "Denies the ping command without any pre-configured scope." +commands.deny = ["ping"] diff --git a/plugins/tauri-plugin-revenue-cat/permissions/autogenerated/reference.md b/plugins/tauri-plugin-revenue-cat/permissions/autogenerated/reference.md new file mode 100644 index 00000000..fa936532 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/permissions/autogenerated/reference.md @@ -0,0 +1,122 @@ +## Default Permission + +Default permissions for the plugin + +- `allow-ping` +- `allow-createCustomer` +- `allow-fetchProjectOverviewData` +- `allow-getCustomersData` + +## Permission Table + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
IdentifierDescription
+ +`revenue-cat:allow-createCustomer` + + + +Enables the createCustomer command without any pre-configured scope. + +
+ +`revenue-cat:deny-createCustomer` + + + +Denies the createCustomer command without any pre-configured scope. + +
+ +`revenue-cat:allow-fetchProjectOverviewData` + + + +Enables the fetchProjectOverviewData command without any pre-configured scope. + +
+ +`revenue-cat:deny-fetchProjectOverviewData` + + + +Denies the fetchProjectOverviewData command without any pre-configured scope. + +
+ +`revenue-cat:allow-getCustomersData` + + + +Enables the getCustomersData command without any pre-configured scope. + +
+ +`revenue-cat:deny-getCustomersData` + + + +Denies the getCustomersData command without any pre-configured scope. + +
+ +`revenue-cat:allow-ping` + + + +Enables the ping command without any pre-configured scope. + +
+ +`revenue-cat:deny-ping` + + + +Denies the ping command without any pre-configured scope. + +
diff --git a/plugins/tauri-plugin-revenue-cat/permissions/default.toml b/plugins/tauri-plugin-revenue-cat/permissions/default.toml new file mode 100644 index 00000000..343220b9 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/permissions/default.toml @@ -0,0 +1,3 @@ +[default] +description = "Default permissions for the plugin" +permissions = ["allow-ping", "allow-createCustomer", "allow-fetchProjectOverviewData", "allow-getCustomersData"] diff --git a/plugins/tauri-plugin-revenue-cat/permissions/schemas/schema.json b/plugins/tauri-plugin-revenue-cat/permissions/schemas/schema.json new file mode 100644 index 00000000..bccfc81c --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/permissions/schemas/schema.json @@ -0,0 +1,345 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "PermissionFile", + "description": "Permission file that can define a default permission, a set of permissions or a list of inlined permissions.", + "type": "object", + "properties": { + "default": { + "description": "The default permission set for the plugin", + "anyOf": [ + { + "$ref": "#/definitions/DefaultPermission" + }, + { + "type": "null" + } + ] + }, + "set": { + "description": "A list of permissions sets defined", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionSet" + } + }, + "permission": { + "description": "A list of inlined permissions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + }, + "definitions": { + "DefaultPermission": { + "description": "The default permission set of the plugin.\n\nWorks similarly to a permission with the \"default\" identifier.", + "type": "object", + "required": [ + "permissions" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri convention is to use

headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PermissionSet": { + "description": "A set of direct permissions grouped together under a new name.", + "type": "object", + "required": [ + "description", + "identifier", + "permissions" + ], + "properties": { + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does.", + "type": "string" + }, + "permissions": { + "description": "All permissions this set contains.", + "type": "array", + "items": { + "$ref": "#/definitions/PermissionKind" + } + } + } + }, + "Permission": { + "description": "Descriptions of explicit privileges of commands.\n\nIt can enable commands to be accessible in the frontend of the application.\n\nIf the scope is defined it can be used to fine grain control the access of individual or multiple commands.", + "type": "object", + "required": [ + "identifier" + ], + "properties": { + "version": { + "description": "The version of the permission.", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 1.0 + }, + "identifier": { + "description": "A unique identifier for the permission.", + "type": "string" + }, + "description": { + "description": "Human-readable description of what the permission does. Tauri internal convention is to use

headings in markdown content for Tauri documentation generation purposes.", + "type": [ + "string", + "null" + ] + }, + "commands": { + "description": "Allowed or denied commands when using this permission.", + "default": { + "allow": [], + "deny": [] + }, + "allOf": [ + { + "$ref": "#/definitions/Commands" + } + ] + }, + "scope": { + "description": "Allowed or denied scoped when using this permission.", + "allOf": [ + { + "$ref": "#/definitions/Scopes" + } + ] + }, + "platforms": { + "description": "Target platforms this permission applies. By default all platforms are affected by this permission.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Target" + } + } + } + }, + "Commands": { + "description": "Allowed and denied commands inside a permission.\n\nIf two commands clash inside of `allow` and `deny`, it should be denied by default.", + "type": "object", + "properties": { + "allow": { + "description": "Allowed command.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "deny": { + "description": "Denied command, which takes priority.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "Scopes": { + "description": "An argument for fine grained behavior control of Tauri commands.\n\nIt can be of any serde serializable type and is used to allow or prevent certain actions inside a Tauri command. The configured scope is passed to the command and will be enforced by the command implementation.\n\n## Example\n\n```json { \"allow\": [{ \"path\": \"$HOME/**\" }], \"deny\": [{ \"path\": \"$HOME/secret.txt\" }] } ```", + "type": "object", + "properties": { + "allow": { + "description": "Data that defines what is allowed by the scope.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + }, + "deny": { + "description": "Data that defines what is denied by the scope. This should be prioritized by validation logic.", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/definitions/Value" + } + } + } + }, + "Value": { + "description": "All supported ACL values.", + "anyOf": [ + { + "description": "Represents a null JSON value.", + "type": "null" + }, + { + "description": "Represents a [`bool`].", + "type": "boolean" + }, + { + "description": "Represents a valid ACL [`Number`].", + "allOf": [ + { + "$ref": "#/definitions/Number" + } + ] + }, + { + "description": "Represents a [`String`].", + "type": "string" + }, + { + "description": "Represents a list of other [`Value`]s.", + "type": "array", + "items": { + "$ref": "#/definitions/Value" + } + }, + { + "description": "Represents a map of [`String`] keys to [`Value`]s.", + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/Value" + } + } + ] + }, + "Number": { + "description": "A valid ACL number.", + "anyOf": [ + { + "description": "Represents an [`i64`].", + "type": "integer", + "format": "int64" + }, + { + "description": "Represents a [`f64`].", + "type": "number", + "format": "double" + } + ] + }, + "Target": { + "description": "Platform target.", + "oneOf": [ + { + "description": "MacOS.", + "type": "string", + "enum": [ + "macOS" + ] + }, + { + "description": "Windows.", + "type": "string", + "enum": [ + "windows" + ] + }, + { + "description": "Linux.", + "type": "string", + "enum": [ + "linux" + ] + }, + { + "description": "Android.", + "type": "string", + "enum": [ + "android" + ] + }, + { + "description": "iOS.", + "type": "string", + "enum": [ + "iOS" + ] + } + ] + }, + "PermissionKind": { + "type": "string", + "oneOf": [ + { + "description": "Enables the createCustomer command without any pre-configured scope.", + "type": "string", + "const": "allow-createCustomer" + }, + { + "description": "Denies the createCustomer command without any pre-configured scope.", + "type": "string", + "const": "deny-createCustomer" + }, + { + "description": "Enables the fetchProjectOverviewData command without any pre-configured scope.", + "type": "string", + "const": "allow-fetchProjectOverviewData" + }, + { + "description": "Denies the fetchProjectOverviewData command without any pre-configured scope.", + "type": "string", + "const": "deny-fetchProjectOverviewData" + }, + { + "description": "Enables the getCustomersData command without any pre-configured scope.", + "type": "string", + "const": "allow-getCustomersData" + }, + { + "description": "Denies the getCustomersData command without any pre-configured scope.", + "type": "string", + "const": "deny-getCustomersData" + }, + { + "description": "Enables the ping command without any pre-configured scope.", + "type": "string", + "const": "allow-ping" + }, + { + "description": "Denies the ping command without any pre-configured scope.", + "type": "string", + "const": "deny-ping" + }, + { + "description": "Default permissions for the plugin", + "type": "string", + "const": "default" + } + ] + } + } +} \ No newline at end of file diff --git a/plugins/tauri-plugin-revenue-cat/rollup.config.js b/plugins/tauri-plugin-revenue-cat/rollup.config.js new file mode 100644 index 00000000..d8343635 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/rollup.config.js @@ -0,0 +1,31 @@ +import { readFileSync } from 'fs' +import { join } from 'path' +import { cwd } from 'process' +import typescript from '@rollup/plugin-typescript' + +const pkg = JSON.parse(readFileSync(join(cwd(), 'package.json'), 'utf8')) + +export default { + input: 'guest-js/index.ts', + output: [ + { + file: pkg.exports.import, + format: 'esm' + }, + { + file: pkg.exports.require, + format: 'cjs' + } + ], + plugins: [ + typescript({ + declaration: true, + declarationDir: `./${pkg.exports.import.split('/')[0]}` + }) + ], + external: [ + /^@tauri-apps\/api/, + ...Object.keys(pkg.dependencies || {}), + ...Object.keys(pkg.peerDependencies || {}) + ] +} diff --git a/plugins/tauri-plugin-revenue-cat/src/commands.rs b/plugins/tauri-plugin-revenue-cat/src/commands.rs new file mode 100644 index 00000000..d3370cb1 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/src/commands.rs @@ -0,0 +1,13 @@ +use tauri::{AppHandle, command, Runtime}; + +use crate::models::*; +use crate::Result; +use crate::RevenueCatExt; + +#[command] +pub(crate) async fn ping( + app: AppHandle, + payload: PingRequest, +) -> Result { + app.revenue_cat().ping(payload) +} diff --git a/plugins/tauri-plugin-revenue-cat/src/desktop.rs b/plugins/tauri-plugin-revenue-cat/src/desktop.rs new file mode 100644 index 00000000..6bde5951 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/src/desktop.rs @@ -0,0 +1,22 @@ +use serde::de::DeserializeOwned; +use tauri::{plugin::PluginApi, AppHandle, Runtime}; + +use crate::models::*; + +pub fn init( + app: &AppHandle, + _api: PluginApi, +) -> crate::Result> { + Ok(RevenueCat(app.clone())) +} + +/// Access to the revenue-cat APIs. +pub struct RevenueCat(AppHandle); + +impl RevenueCat { + pub fn ping(&self, payload: PingRequest) -> crate::Result { + Ok(PingResponse { + value: payload.value, + }) + } +} diff --git a/plugins/tauri-plugin-revenue-cat/src/error.rs b/plugins/tauri-plugin-revenue-cat/src/error.rs new file mode 100644 index 00000000..895220da --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/src/error.rs @@ -0,0 +1,21 @@ +use serde::{ser::Serializer, Serialize}; + +pub type Result = std::result::Result; + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error(transparent)] + Io(#[from] std::io::Error), + #[cfg(mobile)] + #[error(transparent)] + PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError), +} + +impl Serialize for Error { + fn serialize(&self, serializer: S) -> std::result::Result + where + S: Serializer, + { + serializer.serialize_str(self.to_string().as_ref()) + } +} diff --git a/plugins/tauri-plugin-revenue-cat/src/lib.rs b/plugins/tauri-plugin-revenue-cat/src/lib.rs new file mode 100644 index 00000000..e6daf4d2 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/src/lib.rs @@ -0,0 +1,48 @@ +use tauri::{ + plugin::{Builder, TauriPlugin}, + Manager, Runtime, +}; + +pub use models::*; + +#[cfg(desktop)] +mod desktop; +#[cfg(mobile)] +mod mobile; + +mod commands; +mod error; +mod models; + +pub use error::{Error, Result}; + +#[cfg(desktop)] +use desktop::RevenueCat; +#[cfg(mobile)] +use mobile::RevenueCat; + +/// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the revenue-cat APIs. +pub trait RevenueCatExt { + fn revenue_cat(&self) -> &RevenueCat; +} + +impl> crate::RevenueCatExt for T { + fn revenue_cat(&self) -> &RevenueCat { + self.state::>().inner() + } +} + +/// Initializes the plugin. +pub fn init() -> TauriPlugin { + Builder::new("revenue-cat") + .invoke_handler(tauri::generate_handler![commands::ping]) + .setup(|app, api| { + #[cfg(mobile)] + let revenue_cat = mobile::init(app, api)?; + #[cfg(desktop)] + let revenue_cat = desktop::init(app, api)?; + app.manage(revenue_cat); + Ok(()) + }) + .build() +} diff --git a/plugins/tauri-plugin-revenue-cat/src/mobile.rs b/plugins/tauri-plugin-revenue-cat/src/mobile.rs new file mode 100644 index 00000000..105e5662 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/src/mobile.rs @@ -0,0 +1,34 @@ +use serde::de::DeserializeOwned; +use tauri::{ + plugin::{PluginApi, PluginHandle}, + AppHandle, Runtime, +}; + +use crate::models::*; + +#[cfg(target_os = "ios")] +tauri::ios_plugin_binding!(init_plugin_revenue_cat); + +// initializes the Kotlin or Swift plugin classes +pub fn init( + _app: &AppHandle, + api: PluginApi, +) -> crate::Result> { + #[cfg(target_os = "android")] + let handle = api.register_android_plugin("com.plugin.revenue-cat", "ExamplePlugin")?; + #[cfg(target_os = "ios")] + let handle = api.register_ios_plugin(init_plugin_revenue_cat)?; + Ok(RevenueCat(handle)) +} + +/// Access to the revenue-cat APIs. +pub struct RevenueCat(PluginHandle); + +impl RevenueCat { + pub fn ping(&self, payload: PingRequest) -> crate::Result { + self + .0 + .run_mobile_plugin("ping", payload) + .map_err(Into::into) + } +} diff --git a/plugins/tauri-plugin-revenue-cat/src/models.rs b/plugins/tauri-plugin-revenue-cat/src/models.rs new file mode 100644 index 00000000..1b53e9e2 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/src/models.rs @@ -0,0 +1,13 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct PingRequest { + pub value: Option, +} + +#[derive(Debug, Clone, Default, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct PingResponse { + pub value: Option, +} diff --git a/plugins/tauri-plugin-revenue-cat/tsconfig.json b/plugins/tauri-plugin-revenue-cat/tsconfig.json new file mode 100644 index 00000000..05911227 --- /dev/null +++ b/plugins/tauri-plugin-revenue-cat/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "target": "es2021", + "module": "esnext", + "moduleResolution": "bundler", + "skipLibCheck": true, + "strict": true, + "noUnusedLocals": true, + "noImplicitAny": true, + "noEmit": true + }, + "include": ["guest-js/*.ts"], + "exclude": ["dist-js", "node_modules"] +}