diff --git a/README.md b/README.md deleted file mode 100644 index e8ebac2..0000000 --- a/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# WASM Extension Template - -This template allows you to generate a "Hello World" web extension running a **Rust program compiled to WASM**. -The program will be executed as a **content script**, without the need of being injected into the page. - -Supports both manifest v2 and v3. - -![Demo image](https://media.discordapp.net/attachments/546761853297229825/919179215390261258/unknown.png?width=1080&height=181) - -## Install tools - -```sh -cargo install cargo-generate -cargo install wasm-pack -``` - -## Generate an extension - -You can use `cargo-generate` to generate a new crate (modify the name at the end of the command): - -```sh -cargo generate --git https://github.com/Mubelotix/wasm-extension-template --name amazing-extension -``` - -Your crate is now generated and ready to be compiled. - -## Compile your extension - -You cannot use `cargo build` to compile your crate. Use the `build.sh` script instead: - -```sh -sh build.sh -``` - -Once compiled, the target files are ready to be used in the `pkg` folder. - -## Test your program - -Web browsers allow developpers to test web extensions before publishment. -See your browser's specific instructions to do that. -After build, the `manifest.json` file is located in the `pkg` folder. -By default, your extension will run on example.com and have no other permissions. -You should want to modify the manifest (see [the doc](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json)). diff --git a/Cargo.toml b/background-worker/Cargo.toml similarity index 100% rename from Cargo.toml rename to background-worker/Cargo.toml diff --git a/build.sh b/background-worker/build.sh similarity index 100% rename from build.sh rename to background-worker/build.sh diff --git a/js/content_script.js b/background-worker/js/content_script.js similarity index 100% rename from js/content_script.js rename to background-worker/js/content_script.js diff --git a/js/service_worker.js b/background-worker/js/service_worker.js similarity index 100% rename from js/service_worker.js rename to background-worker/js/service_worker.js diff --git a/src/lib.rs b/background-worker/src/lib.rs similarity index 100% rename from src/lib.rs rename to background-worker/src/lib.rs diff --git a/src/util.rs b/background-worker/src/util.rs similarity index 100% rename from src/util.rs rename to background-worker/src/util.rs diff --git a/flake.lock b/flake.lock index 34e88a4..845c972 100644 --- a/flake.lock +++ b/flake.lock @@ -86,29 +86,12 @@ "type": "github" } }, - "nixpkgs_3": { - "locked": { - "lastModified": 1705316053, - "narHash": "sha256-J2Ey5mPFT8gdfL2XC0JTZvKaBw/b2pnyudEXFvl+dQM=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "c3e128f3c0ecc1fb04aef9f72b3dcc2f6cecf370", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { "flake-parts": "flake-parts", "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay", - "systems": "systems_2", - "treefmt-nix": "treefmt-nix" + "systems": "systems_2" } }, "rust-overlay": { @@ -159,24 +142,6 @@ "repo": "default", "type": "github" } - }, - "treefmt-nix": { - "inputs": { - "nixpkgs": "nixpkgs_3" - }, - "locked": { - "lastModified": 1706111218, - "narHash": "sha256-ueC4DvzFzN9Ft3kLSv8g6uuT3Ghz+jZ7UlGQFPZxBrg=", - "owner": "numtide", - "repo": "treefmt-nix", - "rev": "23f601bfdef75e21fe8854e24a043bb642201794", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "treefmt-nix", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index d7ccd30..3db3ebc 100644 --- a/flake.nix +++ b/flake.nix @@ -4,19 +4,29 @@ flake-parts.url = "github:hercules-ci/flake-parts"; systems.url = "github:nix-systems/default"; rust-overlay.url = "github:oxalica/rust-overlay"; - - # Dev tools - treefmt-nix.url = "github:numtide/treefmt-nix"; }; outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } { systems = import inputs.systems; - imports = [ - inputs.treefmt-nix.flakeModule - ]; perSystem = { config, self', pkgs, lib, system, rust-overlay, ... }: let - rust-toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + rust = rec { + toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + nativeBuildInputs = with pkgs; [ + toolchain + rust-analyzer + ]; + buildInputs = with pkgs; [ + pkg-config + openssl + wasm-pack + ]; + }; + + web = { + nativeBuildInputs = [ pkgs.nodePackages.pnpm ]; + buildInputs = []; + }; in { _module.args.pkgs = import inputs.nixpkgs { inherit system; @@ -25,34 +35,13 @@ # Rust dev environment devShells.default = pkgs.mkShell { - inputsFrom = [ - config.treefmt.build.devShell - ]; shellHook = '' # For rust-analyzer 'hover' tooltips to work. - export RUST_SRC_PATH=${rust-toolchain.availableComponents.rust-src} + export RUST_SRC_PATH=${rust.toolchain.availableComponents.rust-src} export PATH=~/.cargo/bin:$PATH ''; - nativeBuildInputs = with pkgs; [ - rust-toolchain - rust-analyzer - ]; - - buildInputs = with pkgs; [ - pkg-config - openssl - wasm-pack - ]; - }; - - # Add your auto-formatters here. - # cf. https://numtide.github.io/treefmt/ - treefmt.config = { - projectRootFile = "flake.nix"; - programs = { - nixpkgs-fmt.enable = true; - rustfmt.enable = true; - }; + nativeBuildInputs = rust.nativeBuildInputs ++ web.nativeBuildInputs; + buildInputs = rust.buildInputs ++ web.buildInputs; }; }; }; diff --git a/linera-web/.gitignore b/linera-web/.gitignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/linera-web/.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/linera-web/package.json b/linera-web/package.json new file mode 100644 index 0000000..1144621 --- /dev/null +++ b/linera-web/package.json @@ -0,0 +1,20 @@ +{ + "name": "linera-web", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc && vite build", + "preview": "vite preview" + }, + "dependencies": { + "lit": "^3.1.2", + "webext-bridge": "^6.0.1" + }, + "devDependencies": { + "@types/chrome": "^0.0.267", + "typescript": "^5.2.2", + "vite": "^5.2.0" + } +} diff --git a/linera-web/pnpm-lock.yaml b/linera-web/pnpm-lock.yaml new file mode 100644 index 0000000..6b3a74a --- /dev/null +++ b/linera-web/pnpm-lock.yaml @@ -0,0 +1,591 @@ +lockfileVersion: '6.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +dependencies: + lit: + specifier: ^3.1.2 + version: 3.1.3 + webext-bridge: + specifier: ^6.0.1 + version: 6.0.1 + +devDependencies: + '@types/chrome': + specifier: ^0.0.267 + version: 0.0.267 + typescript: + specifier: ^5.2.2 + version: 5.4.5 + vite: + specifier: ^5.2.0 + version: 5.2.11 + +packages: + + /@esbuild/aix-ppc64@0.20.2: + resolution: {integrity: sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [aix] + requiresBuild: true + dev: true + optional: true + + /@esbuild/android-arm64@0.20.2: + resolution: {integrity: sha512-mRzjLacRtl/tWU0SvD8lUEwb61yP9cqQo6noDZP/O8VkwafSYwZ4yWy24kan8jE/IMERpYncRt2dw438LP3Xmg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/android-arm@0.20.2: + resolution: {integrity: sha512-t98Ra6pw2VaDhqNWO2Oph2LXbz/EJcnLmKLGBJwEwXX/JAN83Fym1rU8l0JUWK6HkIbWONCSSatf4sf2NBRx/w==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/android-x64@0.20.2: + resolution: {integrity: sha512-btzExgV+/lMGDDa194CcUQm53ncxzeBrWJcncOBxuC6ndBkKxnHdFJn86mCIgTELsooUmwUm9FkhSp5HYu00Rg==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@esbuild/darwin-arm64@0.20.2: + resolution: {integrity: sha512-4J6IRT+10J3aJH3l1yzEg9y3wkTDgDk7TSDFX+wKFiWjqWp/iCfLIYzGyasx9l0SAFPT1HwSCR+0w/h1ES/MjA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@esbuild/darwin-x64@0.20.2: + resolution: {integrity: sha512-tBcXp9KNphnNH0dfhv8KYkZhjc+H3XBkF5DKtswJblV7KlT9EI2+jeA8DgBjp908WEuYll6pF+UStUCfEpdysA==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@esbuild/freebsd-arm64@0.20.2: + resolution: {integrity: sha512-d3qI41G4SuLiCGCFGUrKsSeTXyWG6yem1KcGZVS+3FYlYhtNoNgYrWcvkOoaqMhwXSMrZRl69ArHsGJ9mYdbbw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/freebsd-x64@0.20.2: + resolution: {integrity: sha512-d+DipyvHRuqEeM5zDivKV1KuXn9WeRX6vqSqIDgwIfPQtwMP4jaDsQsDncjTDDsExT4lR/91OLjRo8bmC1e+Cw==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-arm64@0.20.2: + resolution: {integrity: sha512-9pb6rBjGvTFNira2FLIWqDk/uaf42sSyLE8j1rnUpuzsODBq7FvpwHYZxQ/It/8b+QOS1RYfqgGFNLRI+qlq2A==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-arm@0.20.2: + resolution: {integrity: sha512-VhLPeR8HTMPccbuWWcEUD1Az68TqaTYyj6nfE4QByZIQEQVWBB8vup8PpR7y1QHL3CpcF6xd5WVBU/+SBEvGTg==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-ia32@0.20.2: + resolution: {integrity: sha512-o10utieEkNPFDZFQm9CoP7Tvb33UutoJqg3qKf1PWVeeJhJw0Q347PxMvBgVVFgouYLGIhFYG0UGdBumROyiig==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-loong64@0.20.2: + resolution: {integrity: sha512-PR7sp6R/UC4CFVomVINKJ80pMFlfDfMQMYynX7t1tNTeivQ6XdX5r2XovMmha/VjR1YN/HgHWsVcTRIMkymrgQ==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-mips64el@0.20.2: + resolution: {integrity: sha512-4BlTqeutE/KnOiTG5Y6Sb/Hw6hsBOZapOVF6njAESHInhlQAghVVZL1ZpIctBOoTFbQyGW+LsVYZ8lSSB3wkjA==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-ppc64@0.20.2: + resolution: {integrity: sha512-rD3KsaDprDcfajSKdn25ooz5J5/fWBylaaXkuotBDGnMnDP1Uv5DLAN/45qfnf3JDYyJv/ytGHQaziHUdyzaAg==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-riscv64@0.20.2: + resolution: {integrity: sha512-snwmBKacKmwTMmhLlz/3aH1Q9T8v45bKYGE3j26TsaOVtjIag4wLfWSiZykXzXuE1kbCE+zJRmwp+ZbIHinnVg==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-s390x@0.20.2: + resolution: {integrity: sha512-wcWISOobRWNm3cezm5HOZcYz1sKoHLd8VL1dl309DiixxVFoFe/o8HnwuIwn6sXre88Nwj+VwZUvJf4AFxkyrQ==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-x64@0.20.2: + resolution: {integrity: sha512-1MdwI6OOTsfQfek8sLwgyjOXAu+wKhLEoaOLTjbijk6E2WONYpH9ZU2mNtR+lZ2B4uwr+usqGuVfFT9tMtGvGw==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/netbsd-x64@0.20.2: + resolution: {integrity: sha512-K8/DhBxcVQkzYc43yJXDSyjlFeHQJBiowJ0uVL6Tor3jGQfSGHNNJcWxNbOI8v5k82prYqzPuwkzHt3J1T1iZQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/openbsd-x64@0.20.2: + resolution: {integrity: sha512-eMpKlV0SThJmmJgiVyN9jTPJ2VBPquf6Kt/nAoo6DgHAoN57K15ZghiHaMvqjCye/uU4X5u3YSMgVBI1h3vKrQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + + /@esbuild/sunos-x64@0.20.2: + resolution: {integrity: sha512-2UyFtRC6cXLyejf/YEld4Hajo7UHILetzE1vsRcGL3earZEW77JxrFjH4Ez2qaTiEfMgAXxfAZCm1fvM/G/o8w==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-arm64@0.20.2: + resolution: {integrity: sha512-GRibxoawM9ZCnDxnP3usoUDO9vUkpAxIIZ6GQI+IlVmr5kP3zUq+l17xELTHMWTWzjxa2guPNyrpq1GWmPvcGQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-ia32@0.20.2: + resolution: {integrity: sha512-HfLOfn9YWmkSKRQqovpnITazdtquEW8/SoHW7pWpuEeguaZI4QnCRW6b+oZTztdBnZOS2hqJ6im/D5cPzBTTlQ==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-x64@0.20.2: + resolution: {integrity: sha512-N49X4lJX27+l9jbLKSqZ6bKNjzQvHaT8IIFUy+YIqmXQdjYCToGWwOItDrfby14c78aDd5NHQl29xingXfCdLQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@lit-labs/ssr-dom-shim@1.2.0: + resolution: {integrity: sha512-yWJKmpGE6lUURKAaIltoPIE/wrbY3TEkqQt+X0m+7fQNnAv0keydnYvbiJFP1PnMhizmIWRWOG5KLhYyc/xl+g==} + dev: false + + /@lit/reactive-element@2.0.4: + resolution: {integrity: sha512-GFn91inaUa2oHLak8awSIigYz0cU0Payr1rcFsrkf5OJ5eSPxElyZfKh0f2p9FsTiZWXQdWGJeXZICEfXXYSXQ==} + dependencies: + '@lit-labs/ssr-dom-shim': 1.2.0 + dev: false + + /@rollup/rollup-android-arm-eabi@4.17.2: + resolution: {integrity: sha512-NM0jFxY8bB8QLkoKxIQeObCaDlJKewVlIEkuyYKm5An1tdVZ966w2+MPQ2l8LBZLjR+SgyV+nRkTIunzOYBMLQ==} + cpu: [arm] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-android-arm64@4.17.2: + resolution: {integrity: sha512-yeX/Usk7daNIVwkq2uGoq2BYJKZY1JfyLTaHO/jaiSwi/lsf8fTFoQW/n6IdAsx5tx+iotu2zCJwz8MxI6D/Bw==} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-darwin-arm64@4.17.2: + resolution: {integrity: sha512-kcMLpE6uCwls023+kknm71ug7MZOrtXo+y5p/tsg6jltpDtgQY1Eq5sGfHcQfb+lfuKwhBmEURDga9N0ol4YPw==} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-darwin-x64@4.17.2: + resolution: {integrity: sha512-AtKwD0VEx0zWkL0ZjixEkp5tbNLzX+FCqGG1SvOu993HnSz4qDI6S4kGzubrEJAljpVkhRSlg5bzpV//E6ysTQ==} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-arm-gnueabihf@4.17.2: + resolution: {integrity: sha512-3reX2fUHqN7sffBNqmEyMQVj/CKhIHZd4y631duy0hZqI8Qoqf6lTtmAKvJFYa6bhU95B1D0WgzHkmTg33In0A==} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-arm-musleabihf@4.17.2: + resolution: {integrity: sha512-uSqpsp91mheRgw96xtyAGP9FW5ChctTFEoXP0r5FAzj/3ZRv3Uxjtc7taRQSaQM/q85KEKjKsZuiZM3GyUivRg==} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-arm64-gnu@4.17.2: + resolution: {integrity: sha512-EMMPHkiCRtE8Wdk3Qhtciq6BndLtstqZIroHiiGzB3C5LDJmIZcSzVtLRbwuXuUft1Cnv+9fxuDtDxz3k3EW2A==} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-arm64-musl@4.17.2: + resolution: {integrity: sha512-NMPylUUZ1i0z/xJUIx6VUhISZDRT+uTWpBcjdv0/zkp7b/bQDF+NfnfdzuTiB1G6HTodgoFa93hp0O1xl+/UbA==} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-powerpc64le-gnu@4.17.2: + resolution: {integrity: sha512-T19My13y8uYXPw/L/k0JYaX1fJKFT/PWdXiHr8mTbXWxjVF1t+8Xl31DgBBvEKclw+1b00Chg0hxE2O7bTG7GQ==} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-riscv64-gnu@4.17.2: + resolution: {integrity: sha512-BOaNfthf3X3fOWAB+IJ9kxTgPmMqPPH5f5k2DcCsRrBIbWnaJCgX2ll77dV1TdSy9SaXTR5iDXRL8n7AnoP5cg==} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-s390x-gnu@4.17.2: + resolution: {integrity: sha512-W0UP/x7bnn3xN2eYMql2T/+wpASLE5SjObXILTMPUBDB/Fg/FxC+gX4nvCfPBCbNhz51C+HcqQp2qQ4u25ok6g==} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-x64-gnu@4.17.2: + resolution: {integrity: sha512-Hy7pLwByUOuyaFC6mAr7m+oMC+V7qyifzs/nW2OJfC8H4hbCzOX07Ov0VFk/zP3kBsELWNFi7rJtgbKYsav9QQ==} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-x64-musl@4.17.2: + resolution: {integrity: sha512-h1+yTWeYbRdAyJ/jMiVw0l6fOOm/0D1vNLui9iPuqgRGnXA0u21gAqOyB5iHjlM9MMfNOm9RHCQ7zLIzT0x11Q==} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-win32-arm64-msvc@4.17.2: + resolution: {integrity: sha512-tmdtXMfKAjy5+IQsVtDiCfqbynAQE/TQRpWdVataHmhMb9DCoJxp9vLcCBjEQWMiUYxO1QprH/HbY9ragCEFLA==} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-win32-ia32-msvc@4.17.2: + resolution: {integrity: sha512-7II/QCSTAHuE5vdZaQEwJq2ZACkBpQDOmQsE6D6XUbnBHW8IAhm4eTufL6msLJorzrHDFv3CF8oCA/hSIRuZeQ==} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-win32-x64-msvc@4.17.2: + resolution: {integrity: sha512-TGGO7v7qOq4CYmSBVEYpI1Y5xDuCEnbVC5Vth8mOsW0gDSzxNrVERPc790IGHsrT2dQSimgMr9Ub3Y1Jci5/8w==} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /@types/chrome@0.0.267: + resolution: {integrity: sha512-vnCWPpYjazSPRMNmybRH+0q4f738F+Pbbls4ZPFsPr9/4TTNJyK1OLZDpSnghnEWb4stfmIUtq/GegnlfD4sPA==} + dependencies: + '@types/filesystem': 0.0.36 + '@types/har-format': 1.2.15 + dev: true + + /@types/estree@1.0.5: + resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} + dev: true + + /@types/filesystem@0.0.36: + resolution: {integrity: sha512-vPDXOZuannb9FZdxgHnqSwAG/jvdGM8Wq+6N4D/d80z+D4HWH+bItqsZaVRQykAn6WEVeEkLm2oQigyHtgb0RA==} + dependencies: + '@types/filewriter': 0.0.33 + dev: true + + /@types/filewriter@0.0.33: + resolution: {integrity: sha512-xFU8ZXTw4gd358lb2jw25nxY9QAgqn2+bKKjKOYfNCzN4DKCFetK7sPtrlpg66Ywe3vWY9FNxprZawAh9wfJ3g==} + dev: true + + /@types/har-format@1.2.15: + resolution: {integrity: sha512-RpQH4rXLuvTXKR0zqHq3go0RVXYv/YVqv4TnPH95VbwUxZdQlK1EtcMvQvMpDngHbt13Csh9Z4qT9AbkiQH5BA==} + dev: true + + /@types/trusted-types@2.0.7: + resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==} + dev: false + + /@types/webextension-polyfill@0.8.3: + resolution: {integrity: sha512-GN+Hjzy9mXjWoXKmaicTegv3FJ0WFZ3aYz77Wk8TMp1IY3vEzvzj1vnsa0ggV7vMI1i+PUxe4qqnIJKCzf9aTg==} + dev: false + + /esbuild@0.20.2: + resolution: {integrity: sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@esbuild/aix-ppc64': 0.20.2 + '@esbuild/android-arm': 0.20.2 + '@esbuild/android-arm64': 0.20.2 + '@esbuild/android-x64': 0.20.2 + '@esbuild/darwin-arm64': 0.20.2 + '@esbuild/darwin-x64': 0.20.2 + '@esbuild/freebsd-arm64': 0.20.2 + '@esbuild/freebsd-x64': 0.20.2 + '@esbuild/linux-arm': 0.20.2 + '@esbuild/linux-arm64': 0.20.2 + '@esbuild/linux-ia32': 0.20.2 + '@esbuild/linux-loong64': 0.20.2 + '@esbuild/linux-mips64el': 0.20.2 + '@esbuild/linux-ppc64': 0.20.2 + '@esbuild/linux-riscv64': 0.20.2 + '@esbuild/linux-s390x': 0.20.2 + '@esbuild/linux-x64': 0.20.2 + '@esbuild/netbsd-x64': 0.20.2 + '@esbuild/openbsd-x64': 0.20.2 + '@esbuild/sunos-x64': 0.20.2 + '@esbuild/win32-arm64': 0.20.2 + '@esbuild/win32-ia32': 0.20.2 + '@esbuild/win32-x64': 0.20.2 + dev: true + + /fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /lit-element@4.0.5: + resolution: {integrity: sha512-iTWskWZEtn9SyEf4aBG6rKT8GABZMrTWop1+jopsEOgEcugcXJGKuX5bEbkq9qfzY+XB4MAgCaSPwnNpdsNQ3Q==} + dependencies: + '@lit-labs/ssr-dom-shim': 1.2.0 + '@lit/reactive-element': 2.0.4 + lit-html: 3.1.3 + dev: false + + /lit-html@3.1.3: + resolution: {integrity: sha512-FwIbqDD8O/8lM4vUZ4KvQZjPPNx7V1VhT7vmRB8RBAO0AU6wuTVdoXiu2CivVjEGdugvcbPNBLtPE1y0ifplHA==} + dependencies: + '@types/trusted-types': 2.0.7 + dev: false + + /lit@3.1.3: + resolution: {integrity: sha512-l4slfspEsnCcHVRTvaP7YnkTZEZggNFywLEIhQaGhYDczG+tu/vlgm/KaWIEjIp+ZyV20r2JnZctMb8LeLCG7Q==} + dependencies: + '@lit/reactive-element': 2.0.4 + lit-element: 4.0.5 + lit-html: 3.1.3 + dev: false + + /nanoevents@6.0.2: + resolution: {integrity: sha512-FRS2otuFcPPYDPYViNWQ42+1iZqbXydinkRHTHFxrF4a1CpBfmydR9zkI44WSXAXCyPrkcGtPk5CnpW6Y3lFKQ==} + engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + dev: false + + /nanoid@3.3.7: + resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + dev: true + + /picocolors@1.0.0: + resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} + dev: true + + /postcss@8.4.38: + resolution: {integrity: sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==} + engines: {node: ^10 || ^12 || >=14} + dependencies: + nanoid: 3.3.7 + picocolors: 1.0.0 + source-map-js: 1.2.0 + dev: true + + /rollup@4.17.2: + resolution: {integrity: sha512-/9ClTJPByC0U4zNLowV1tMBe8yMEAxewtR3cUNX5BoEpGH3dQEWpJLr6CLp0fPdYRF/fzVOgvDb1zXuakwF5kQ==} + engines: {node: '>=18.0.0', npm: '>=8.0.0'} + hasBin: true + dependencies: + '@types/estree': 1.0.5 + optionalDependencies: + '@rollup/rollup-android-arm-eabi': 4.17.2 + '@rollup/rollup-android-arm64': 4.17.2 + '@rollup/rollup-darwin-arm64': 4.17.2 + '@rollup/rollup-darwin-x64': 4.17.2 + '@rollup/rollup-linux-arm-gnueabihf': 4.17.2 + '@rollup/rollup-linux-arm-musleabihf': 4.17.2 + '@rollup/rollup-linux-arm64-gnu': 4.17.2 + '@rollup/rollup-linux-arm64-musl': 4.17.2 + '@rollup/rollup-linux-powerpc64le-gnu': 4.17.2 + '@rollup/rollup-linux-riscv64-gnu': 4.17.2 + '@rollup/rollup-linux-s390x-gnu': 4.17.2 + '@rollup/rollup-linux-x64-gnu': 4.17.2 + '@rollup/rollup-linux-x64-musl': 4.17.2 + '@rollup/rollup-win32-arm64-msvc': 4.17.2 + '@rollup/rollup-win32-ia32-msvc': 4.17.2 + '@rollup/rollup-win32-x64-msvc': 4.17.2 + fsevents: 2.3.3 + dev: true + + /serialize-error@9.1.1: + resolution: {integrity: sha512-6uZQLGyUkNA4N+Zii9fYukmNu9PEA1F5rqcwXzN/3LtBjwl2dFBbVZ1Zyn08/CGkB4H440PIemdOQBt1Wvjbrg==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + type-fest: 2.19.0 + dev: false + + /source-map-js@1.2.0: + resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} + engines: {node: '>=0.10.0'} + dev: true + + /tiny-uid@1.1.2: + resolution: {integrity: sha512-0beRFXR+fv4C40ND2PqgNjq6iyB1dKXciKJjslLw0kPYCcR82aNd2b+Tt2yy06LimIlvtoehgvrm/fUZCutSfg==} + dev: false + + /type-fest@2.19.0: + resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==} + engines: {node: '>=12.20'} + dev: false + + /typescript@5.4.5: + resolution: {integrity: sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==} + engines: {node: '>=14.17'} + hasBin: true + dev: true + + /vite@5.2.11: + resolution: {integrity: sha512-HndV31LWW05i1BLPMUCE1B9E9GFbOu1MbenhS58FuK6owSO5qHm7GiCotrNY1YE5rMeQSFBGmT5ZaLEjFizgiQ==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + '@types/node': ^18.0.0 || >=20.0.0 + less: '*' + lightningcss: ^1.21.0 + sass: '*' + stylus: '*' + sugarss: '*' + terser: ^5.4.0 + peerDependenciesMeta: + '@types/node': + optional: true + less: + optional: true + lightningcss: + optional: true + sass: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + dependencies: + esbuild: 0.20.2 + postcss: 8.4.38 + rollup: 4.17.2 + optionalDependencies: + fsevents: 2.3.3 + dev: true + + /webext-bridge@6.0.1: + resolution: {integrity: sha512-GruIrN+vNwbxVCi8UW4Dqk5YkcGA9V0ZfJ57jXP9JXHbrsDs5k2N6NNYQR5e+wSCnQpGYOGAGihwUpKlhg8QIw==} + dependencies: + '@types/webextension-polyfill': 0.8.3 + nanoevents: 6.0.2 + serialize-error: 9.1.1 + tiny-uid: 1.1.2 + webextension-polyfill: 0.9.0 + dev: false + + /webextension-polyfill@0.9.0: + resolution: {integrity: sha512-LTtHb0yR49xa9irkstDxba4GATDAcDw3ncnFH9RImoFwDlW47U95ME5sn5IiQX2ghfaECaf6xyXM8yvClIBkkw==} + dev: false diff --git a/linera-web/public/assets/Linera_Black_Mark@2x cropped.png b/linera-web/public/assets/Linera_Black_Mark@2x cropped.png new file mode 100644 index 0000000..29aea0e Binary files /dev/null and b/linera-web/public/assets/Linera_Black_Mark@2x cropped.png differ diff --git a/linera-web/public/assets/Linera_FullColor_H.svg b/linera-web/public/assets/Linera_FullColor_H.svg new file mode 100644 index 0000000..4fd7433 --- /dev/null +++ b/linera-web/public/assets/Linera_FullColor_H.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/linera-web/public/assets/Linera_Red_Mark.png b/linera-web/public/assets/Linera_Red_Mark.png new file mode 100644 index 0000000..a988cc7 Binary files /dev/null and b/linera-web/public/assets/Linera_Red_Mark.png differ diff --git a/linera-web/public/assets/Linera_Red_Mark.svg b/linera-web/public/assets/Linera_Red_Mark.svg new file mode 100644 index 0000000..4edf5ef --- /dev/null +++ b/linera-web/public/assets/Linera_Red_Mark.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/linera-web/public/assets/Linera_Red_Mark@2x cropped.png b/linera-web/public/assets/Linera_Red_Mark@2x cropped.png new file mode 100644 index 0000000..99ee245 Binary files /dev/null and b/linera-web/public/assets/Linera_Red_Mark@2x cropped.png differ diff --git a/linera-web/public/assets/Linera_Red_Mark@2x.png b/linera-web/public/assets/Linera_Red_Mark@2x.png new file mode 100644 index 0000000..33ca841 Binary files /dev/null and b/linera-web/public/assets/Linera_Red_Mark@2x.png differ diff --git a/linera-web/public/manifest.json b/linera-web/public/manifest.json new file mode 100644 index 0000000..d0375b3 --- /dev/null +++ b/linera-web/public/manifest.json @@ -0,0 +1,35 @@ +{ + "name" : "Linera", + "version" : "1.0", + "description" : "Linera is a user-focused blockchain protocol based on microchains.", + "permissions": ["sidePanel"], + "icons": { + "558": "assets/Linera_Black_Mark@2x cropped.png" + }, + "content_security_policy": { + "extension_pages": "script-src 'self' 'wasm-unsafe-eval';" + }, + "options_page": "src/options/index.html", + "action": { + "default_icon": "assets/Linera_Black_Mark@2x cropped.png", + "default_title": "Linera", + "default_popup": "src/popup/index.html" + }, + "side_panel": { + "default_icon": "assets/Linera_Black_Mark@2x cropped.png", + "default_title": "SIDEBAR TITLE", + "default_path": "src/sidebar/index.html", + "open_at_install": true + }, + "content_scripts": [ + { + "matches": [""], + "js": ["content-script.js"] + } + ], + "background": { + "service_worker": "service-worker.js", + "type": "module" + }, + "manifest_version": 3 +} diff --git a/linera-web/src/components/linera-logo/index.ts b/linera-web/src/components/linera-logo/index.ts new file mode 100644 index 0000000..41f8413 --- /dev/null +++ b/linera-web/src/components/linera-logo/index.ts @@ -0,0 +1,23 @@ +import { LitElement, html, css } from 'lit' +import { customElement } from 'lit/decorators.js' +import lineraLogo from './logo.svg'; + +@customElement('linera-logo') +export class LineraLogo extends LitElement { + static styles = css` + img { + padding: 2rem; + max-width: 30rem; + } + `; + + render = () => html` + Linera + `; +} + +declare global { + interface HTMLElementTagNameMap { + 'linera-logo': LineraLogo + } +} diff --git a/linera-web/src/components/linera-logo/logo.svg b/linera-web/src/components/linera-logo/logo.svg new file mode 100644 index 0000000..4fd7433 --- /dev/null +++ b/linera-web/src/components/linera-logo/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/linera-web/src/content-script/index.ts b/linera-web/src/content-script/index.ts new file mode 100644 index 0000000..3d446b7 --- /dev/null +++ b/linera-web/src/content-script/index.ts @@ -0,0 +1 @@ +console.log("Content script"); diff --git a/linera-web/src/env.d.ts b/linera-web/src/env.d.ts new file mode 100644 index 0000000..11f02fe --- /dev/null +++ b/linera-web/src/env.d.ts @@ -0,0 +1 @@ +/// diff --git a/linera-web/src/index.css b/linera-web/src/index.css new file mode 100644 index 0000000..a9f6b20 --- /dev/null +++ b/linera-web/src/index.css @@ -0,0 +1,30 @@ +@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap'); + +:root { + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + + --color-linera-red: #ff2a00; + --color-linera-blue: #0e2630; + --color-linera-teal: #70d4d3; + --color-linera-beige: #d6ba92; + --color-linera-white: #ffffff; + + --color-background: var(--color-linera-white); + --color-foreground: var(--color-linera-blue); +} + +body { + background-color: var(--color-background); + color: var(--color-foreground); + font-family: Poppins; + + margin: 1rem; + min-width: 20rem; +} + +h2 { + font-size: 150%; +} diff --git a/linera-web/src/options/index.html b/linera-web/src/options/index.html new file mode 100644 index 0000000..c52aead --- /dev/null +++ b/linera-web/src/options/index.html @@ -0,0 +1,17 @@ + + + + + + Linera + + + +
+

Linera

+
+
+

This is the Linera options page.

+
+ + diff --git a/linera-web/src/popup/index.html b/linera-web/src/popup/index.html new file mode 100644 index 0000000..be9b679 --- /dev/null +++ b/linera-web/src/popup/index.html @@ -0,0 +1,17 @@ + + + + + + Linera + + + +
+

Linera

+
+
+

This is the Linera popup.

+
+ + diff --git a/linera-web/src/service-worker/index.ts b/linera-web/src/service-worker/index.ts new file mode 100644 index 0000000..525f780 --- /dev/null +++ b/linera-web/src/service-worker/index.ts @@ -0,0 +1 @@ +import './setup.ts'; diff --git a/linera-web/src/service-worker/setup.ts b/linera-web/src/service-worker/setup.ts new file mode 100644 index 0000000..cb72ac4 --- /dev/null +++ b/linera-web/src/service-worker/setup.ts @@ -0,0 +1,10 @@ +chrome.sidePanel.setPanelBehavior({ + openPanelOnActionClick: true, +}).catch((error) => console.error(error)); + +chrome.runtime.onInstalled.addListener(async () => { + const windowId = (await chrome.windows.getCurrent()).id; + if (windowId === undefined) return; + chrome.action.setPopup({ popup: "src/welcome/index.html" }); + await chrome.action.openPopup({ windowId }); +}); diff --git a/linera-web/src/sidebar/index.html b/linera-web/src/sidebar/index.html new file mode 100644 index 0000000..0a69370 --- /dev/null +++ b/linera-web/src/sidebar/index.html @@ -0,0 +1,20 @@ + + + + + + Linera + + + + + + +
+

+
+
+ +
+ + diff --git a/linera-web/src/sidebar/index.ts b/linera-web/src/sidebar/index.ts new file mode 100644 index 0000000..66976dd --- /dev/null +++ b/linera-web/src/sidebar/index.ts @@ -0,0 +1,78 @@ +import { LitElement, html, css } from 'lit' +import { customElement, property } from 'lit/decorators.js' + +type Wallet = { + default: string; +}; + +@customElement('linera-wallet-picker') +export class WalletPicker extends LitElement { + static styles = css` + input[type="file"] { + display: none; + } + + label { + background-color: var(--color-linera-teal); + padding: 0.75em; + border-radius: 0.75em; + font-weight: bold; + display: inline-block; + } + `; + + @property() + wallet?: Wallet; + + @property() + onChange?: (event: Event) => void; + + render = () => html` +
+ + +
+ `; + + private async _onChange(event: Event & { target: HTMLInputElement }) { + const contents = await event.target.files![0].text(); + this.onChange?.(contents); + } +} + +@customElement('linera-sidebar') +export class Sidebar extends LitElement { + wallet?: Wallet; + + static styles = css` + .chain-id { + background-color: var(--color-linera-beige); + font-family: monospace; + overflow-wrap: break-word; + padding: 3px; + } + `; + + render = () => html` +

Wallet

+ ${this.wallet && html`

Your current wallet is ${this.wallet.default}.

`} + + `; + + constructor() { + super(); + let wallet = window.localStorage.getItem("wallet"); + if (wallet) this.wallet = JSON.parse(wallet); + } + + private async onWalletChange(wallet: string) { + window.localStorage.setItem("wallet", wallet); + this.wallet = JSON.parse(wallet); + } +} + +declare global { + interface HTMLElementTagNameMap { + 'linera-sidebar': Sidebar + } +} diff --git a/linera-web/src/sidebar/style.css b/linera-web/src/sidebar/style.css new file mode 100644 index 0000000..e69de29 diff --git a/linera-web/src/sidebar/wallet-picker.ts b/linera-web/src/sidebar/wallet-picker.ts new file mode 100644 index 0000000..e69de29 diff --git a/linera-web/src/welcome/index.html b/linera-web/src/welcome/index.html new file mode 100644 index 0000000..c01d217 --- /dev/null +++ b/linera-web/src/welcome/index.html @@ -0,0 +1,19 @@ + + + + + + Linera + + + + +
+

+
+
+

Welcome to Linera!

+

Click this button at any time to manage your chains.

+
+ + diff --git a/linera-web/tsconfig.json b/linera-web/tsconfig.json new file mode 100644 index 0000000..7a42345 --- /dev/null +++ b/linera-web/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "target": "ES2021", + "experimentalDecorators": true, + "useDefineForClassFields": false, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "plugins": [ + { + "name": "ts-lit-plugin", + "strict": true + } + ] + }, + "include": ["src"] +} diff --git a/linera-web/vite.config.ts b/linera-web/vite.config.ts new file mode 100644 index 0000000..c91cc3d --- /dev/null +++ b/linera-web/vite.config.ts @@ -0,0 +1,23 @@ +import { resolve } from 'path' +import { defineConfig } from 'vite' + +// https://vitejs.dev/config/ +export default defineConfig({ + build: { + rollupOptions: { + input: { + popup: resolve(__dirname, 'src/popup/index.html'), + sidebar: resolve(__dirname, 'src/sidebar/index.html'), + options: resolve(__dirname, 'src/options/index.html'), + welcome: resolve(__dirname, 'src/welcome/index.html'), + "content-script": resolve(__dirname, 'src/content-script/index.ts'), + "service-worker": resolve(__dirname, 'src/service-worker/index.ts'), + manifest: resolve(__dirname, 'public/manifest.json'), + }, + output: { + preserveModules: false, + entryFileNames: '[name].js', + } + }, + }, +}) diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 4244b0b..0000000 --- a/manifest.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name" : "linera-web", - "version" : "1.0", - "description" : "linera-web", - "permissions": [], - "content_scripts": [ - { - "matches": ["file:///*"], - "js": ["content_script.js"] - } - ], - "background": { - "service_worker": "service_worker.js", - "type": "module" - }, - "content_security_policy": { - "extension_pages": "script-src 'self' 'wasm-unsafe-eval';" - }, - "manifest_version": 3 -}