From 1e275c971a2e108803f5202222e6f21b831f9481 Mon Sep 17 00:00:00 2001 From: Jonas Strehle Date: Wed, 16 Oct 2024 18:45:06 +0200 Subject: [PATCH] Prepare for release --- .github/workflows/uix-deploy-prod.yml | 2 +- backend/.dx | 2 +- common/TOR-Worker.ts | 2 +- common/components/MainPage.css | 87 ++++++++++++++++++++++++++ common/components/MainPage.scss | 89 -------------------------- common/components/MainPage.tsx | 90 +++++++++++++++++---------- deno.json | 4 +- frontend/entrypoint.css | 2 +- importmap.dev.json | 10 --- importmap.json | 14 ++--- 10 files changed, 156 insertions(+), 146 deletions(-) create mode 100644 common/components/MainPage.css delete mode 100644 common/components/MainPage.scss delete mode 100644 importmap.dev.json diff --git a/.github/workflows/uix-deploy-prod.yml b/.github/workflows/uix-deploy-prod.yml index 3a4925f..c14f6a1 100644 --- a/.github/workflows/uix-deploy-prod.yml +++ b/.github/workflows/uix-deploy-prod.yml @@ -16,4 +16,4 @@ jobs: - name: Setup Deno uses: "denoland/setup-deno@v1" - name: Deploy UIX App - run: "deno run --importmap ./importmap.dev.json -Aqr https://dev.cdn.unyt.org/uix1/run.ts --stage prod --detach" + run: "deno run --importmap ./importmap.json -Aqr https://cdn.unyt.org/uix@0.3.x/run.ts --stage prod --detach" diff --git a/backend/.dx b/backend/.dx index 54ff0bd..53c5790 100644 --- a/backend/.dx +++ b/backend/.dx @@ -5,7 +5,7 @@ endpoint: stage { }, location: stage { - prod: @+unyt-host-4 + prod: @+unyt-private-1 }, domain: stage { diff --git a/common/TOR-Worker.ts b/common/TOR-Worker.ts index 87b26ca..7b35edf 100644 --- a/common/TOR-Worker.ts +++ b/common/TOR-Worker.ts @@ -80,7 +80,7 @@ async function generateOnionV3(keys: KeyPair | Promise = generateKeys() hash.update(version); const checksum = hash.digest().slice(0, 2); - + const decoded = new Uint8Array([...publicKey, ...checksum, ...version]); const address = base32.encode(Array.from(decoded)).toLowerCase().concat(".onion"); const _publicKey = getPublicKey(address); diff --git a/common/components/MainPage.css b/common/components/MainPage.css new file mode 100644 index 0000000..34113d2 --- /dev/null +++ b/common/components/MainPage.css @@ -0,0 +1,87 @@ + +:host { + display: flex; + flex-direction: column; + font-size: x-large; + padding: 10px; + width: 70%; + margin: auto; + align-items: center; + margin-top: 40px; + text-align: center; + &>div { + margin-top: 30px; + width: 100%; + flex-wrap: wrap; + justify-content: center; + &>h2 { + width: 100%; + } + grid-gap: 20px; + gap: 20px; + display: flex; + border-bottom: 1px solid gray; + padding-bottom: 30px; + &>input { + flex: 1; + padding: 20px; + border-radius: var(--standard-border-radius); + max-width: 300px; + background-color: transparent; + color: var(--text_highlight); + padding-left: 20px; + font-size: x-large; + border: 2px solid var(--accent); + } + + &.hidden { + &>.button { + opacity: 0.4; + background-color: transparent; + border-color: var(--red); + color: var(--text_highlight); + } + } + &>div { + transition: opacity 0.2s; + background-color: var(--text_highlight); + border: 3px solid var(--text_highlight); + border-radius: var(--standard-border-radius); + padding: 10px; + cursor: pointer; + transition: background-color 0.2s; + box-sizing: border-box; + color: var(--accent); + &:hover { + color: var(--text_highlight); + background-color: transparent; + } + } + &>.results { + text-align: left; + word-break: break-word; + width: 100%; + gap: 6px; + font-family: monospace; + display: flex; + flex-direction: column; + } + } + &>#tor { + span { + max-width: 1000px; + margin: auto; + width: 100%; + display: flex; + flex-wrap: wrap; + b { + width: 50%; + } + a { + margin: auto; + margin-bottom: 10px; + text-align: center; + } + } + } +} diff --git a/common/components/MainPage.scss b/common/components/MainPage.scss deleted file mode 100644 index 19e989d..0000000 --- a/common/components/MainPage.scss +++ /dev/null @@ -1,89 +0,0 @@ - -:host { - &>div { - display: flex; - flex-direction: column; - font-size: x-large; - padding: 10px; - width: 70%; - margin: auto; - align-items: center; - margin-top: 40px; - text-align: center; - &>div { - margin-top: 30px; - width: 100%; - flex-wrap: wrap; - justify-content: center; - &>h2 { - width: 100%; - } - grid-gap: 20px; - gap: 20px; - display: flex; - border-bottom: 1px solid gray; - padding-bottom: 30px; - &>input { - flex: 1; - padding: 20px; - border-radius: var(--standard-border-radius); - max-width: 300px; - background-color: transparent; - color: var(--text_highlight); - padding-left: 20px; - font-size: x-large; - border: 2px solid var(--accent); - } - - &.hidden { - &>.button { - opacity: 0.4; - background-color: transparent; - border-color: var(--red); - color: var(--text_highlight); - } - } - &>div { - transition: opacity 0.2s; - background-color: var(--text_highlight); - border: 3px solid var(--text_highlight); - border-radius: var(--standard-border-radius); - padding: 10px; - cursor: pointer; - transition: background-color 0.2s; - box-sizing: border-box; - color: var(--accent); - &:hover { - color: var(--text_highlight); - background-color: transparent; - } - } - &>.results { - text-align: left; - word-break: break-word; - width: 100%; - gap: 6px; - font-family: monospace; - display: flex; - flex-direction: column; - } - } - &>#tor { - span { - max-width: 1000px; - margin: auto; - width: 100%; - display: flex; - flex-wrap: wrap; - b { - width: 50%; - } - a { - margin: auto; - margin-bottom: 10px; - text-align: center; - } - } - } - } -} diff --git a/common/components/MainPage.tsx b/common/components/MainPage.tsx index c150471..2d9ea7d 100644 --- a/common/components/MainPage.tsx +++ b/common/components/MainPage.tsx @@ -1,17 +1,43 @@ import { template } from "uix/html/template.ts"; import { Component } from "uix/components/Component.ts"; -import { spawnThreads, spawnThread } from "datex-core-legacy/threads/threads.ts"; -import { always, map } from "datex-core-legacy/functions.ts"; +import { spawnThreads, spawnThread, run } from "datex-core-legacy/threads/threads.ts"; import type { AddressData } from "common/TOR-Worker.ts"; @template(function(this: MainPage) { - return
-
this.calculatingAddress?'hidden':'')}> + return <> +
+

Use Console

+
this.runConsole()} class="button"> + Run in Thread +
+
+
+

Calculate PI

+ +
this.computePI()} class="button">{ + this.calculatingPI ? "Waiting" : "Calculate" + }
+
+ {this.resultPIs.map(pi => + {pi} + )} +
+
+

Create TOR Address

- -
this.createVanityAddress()} class="button">Compute
+ +
this.createVanityAddress()} class="button">{ + this.calculatingAddress ? "Waiting" : "Calculate" + }
- {map(this.resultAddresses, (address: AddressData) => + {this.resultAddresses.map(address => {address.address} Pub: {address.public.b64} @@ -20,44 +46,26 @@ import type { AddressData } from "common/TOR-Worker.ts"; )}
-
this.calculatingPI?'hidden':'')}> -

Calculate PI

- -
this.computePI()} class="button">Compute
-
- {map(this.resultPIs, (pi: string) => - {pi} - )} -
-
-
+ }) export class MainPage extends Component { - // reference properties for input values @property piDigits = 5; - @property addressPrefix = ""; + @property addressPrefix = ''; // reference properties for calculation state @property calculatingPI = false @property calculatingAddress = false // arrays containing history of calculated results - @property resultPIs:string[] = [] - @property resultAddresses:AddressData[] = [] - - async createVanityAddress() { - this.calculatingAddress = true; + @property resultPIs: string[] = [] + @property resultAddresses: AddressData[] = [] - // spawn 10 new threads - using threads = await spawnThreads('../TOR-Worker.ts', 10); - // try to find an address in parallel - const address = await Promise.any( - threads.map(thread => thread.generateVanityAddress(this.addressPrefix)) - ); - this.resultAddresses.unshift(address); - - this.calculatingAddress = false; + runConsole() { + run(() => { + console.log("Hello, main thread!"); + globalThis.console.log("Hello, worker!"); + }); } async computePI() { @@ -71,4 +79,18 @@ export class MainPage extends Component { this.calculatingPI = false; } + + async createVanityAddress() { + this.calculatingAddress = true; + + // spawn 10 new threads + using threads = await spawnThreads('../TOR-Worker.ts', 10); + // try to find an address in parallel + const address = await Promise.any( + threads.map(thread => thread.generateVanityAddress(this.addressPrefix)) + ); + this.resultAddresses.unshift(address); + + this.calculatingAddress = false; + } } \ No newline at end of file diff --git a/deno.json b/deno.json index e509330..52772f1 100644 --- a/deno.json +++ b/deno.json @@ -1,9 +1,9 @@ { - "_publicImportMap": "./importmap.dev.json", + "_publicImportMap": "./importmap.json", "importMap": "./.datex-cache/importmap.lock.json", "compilerOptions": { "jsx": "react-jsx", - "jsxImportSource": "uix", + "jsxImportSource": "jusix", "lib": [ "dom", "deno.window" diff --git a/frontend/entrypoint.css b/frontend/entrypoint.css index 4bf59c9..87fdff7 100644 --- a/frontend/entrypoint.css +++ b/frontend/entrypoint.css @@ -1,7 +1,7 @@ slot#main { overflow-y: scroll; } -.button { +div.button { display: flex; align-items: center; } diff --git a/importmap.dev.json b/importmap.dev.json deleted file mode 100644 index 507fb3d..0000000 --- a/importmap.dev.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "imports": { - "datex-core-legacy": "https://dev.cdn.unyt.org/unyt_core/datex.ts", - "datex-core-legacy/": "https://dev.cdn.unyt.org/unyt_core/", - "uix": "https://dev.cdn.unyt.org/uix1/uix.ts", - "uix/": "https://dev.cdn.unyt.org/uix1/src/", - "uix/jsx-runtime": "https://dev.cdn.unyt.org/uix1/src/jsx-runtime/jsx.ts", - "unyt-tests/": "https://dev.cdn.unyt.org/unyt_tests/" - } -} \ No newline at end of file diff --git a/importmap.json b/importmap.json index 061523b..e3f21f3 100644 --- a/importmap.json +++ b/importmap.json @@ -1,11 +1,11 @@ { "imports": { - "datex-core-legacy": "https://cdn.unyt.org/datex-core-js-legacy@0.1.x/datex.ts", - "datex-core-legacy/": "https://cdn.unyt.org/datex-core-js-legacy@0.1.x/", - "unyt_core": "https://cdn.unyt.org/datex-core-js-legacy@0.1.x/datex.ts", - "unyt_core/": "https://cdn.unyt.org/datex-core-js-legacy@0.1.x/", - "uix": "https://cdn.unyt.org/uix@0.2.x/uix.ts", - "uix/": "https://cdn.unyt.org/uix@0.2.x/src/", - "uix/jsx-runtime": "https://cdn.unyt.org/uix@0.2.x/src/jsx-runtime/jsx.ts" + "datex-core-legacy": "https://cdn.unyt.org/datex-core-js-legacy@0.2.x/datex.ts", + "datex-core-legacy/": "https://cdn.unyt.org/datex-core-js-legacy@0.2.x/", + "uix": "https://cdn.unyt.org/uix@0.3.x/uix.ts", + "uix/": "https://cdn.unyt.org/uix@0.3.x/src/", + "uix/jsx-runtime": "https://cdn.unyt.org/uix@0.3.x/src/jsx-runtime/jsx.ts", + "jusix/jsx-runtime": "https://cdn.unyt.org/uix@0.3.x/src/jsx-runtime/jsx.ts", + "unyt-tests/": "https://cdn.unyt.org/unyt_tests/" } } \ No newline at end of file