Skip to content

Commit

Permalink
Prepare for release
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasstrehle committed Oct 16, 2024
1 parent 26004f9 commit 1e275c9
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 146 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/uix-deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion backend/.dx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ endpoint: stage {
},

location: stage {
prod: @+unyt-host-4
prod: @+unyt-private-1
},

domain: stage {
Expand Down
2 changes: 1 addition & 1 deletion common/TOR-Worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function generateOnionV3(keys: KeyPair | Promise<KeyPair> = 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);
Expand Down
87 changes: 87 additions & 0 deletions common/components/MainPage.css
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
}
89 changes: 0 additions & 89 deletions common/components/MainPage.scss

This file was deleted.

90 changes: 56 additions & 34 deletions common/components/MainPage.tsx
Original file line number Diff line number Diff line change
@@ -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 <div>
<div id="tor" class={always(()=>this.calculatingAddress?'hidden':'')}>
return <>
<div id="run" class={this.calculatingPI ? 'hidden': ''}>
<h2>Use Console</h2>
<div onclick={() => this.runConsole()} class="button">
Run in Thread
</div>
</div>
<div id="pi" class={this.calculatingPI ? 'hidden': ''}>
<h2>Calculate PI</h2>
<input id="inputPiDigits"
type="number"
placeholder="Number of digits"
value={this.piDigits}/>
<div onclick={() => this.computePI()} class="button">{
this.calculatingPI ? "Waiting" : "Calculate"
}</div>
<section class="results">
{this.resultPIs.map(pi =>
<span>{pi}</span>
)}
</section>
</div>
<div id="tor" class={this.calculatingAddress ? 'hidden': ''}>
<h2>Create TOR Address</h2>
<input id="torAddress" maxlength="3" type="text" placeholder="Prefix of vanity address" value={this.$.addressPrefix}/>
<div onclick={() => this.createVanityAddress()} class="button">Compute</div>
<input id="torAddress"
maxlength="3"
type="text"
placeholder="Prefix of vanity address"
value={this.addressPrefix}/>
<div onclick={() => this.createVanityAddress()} class="button">{
this.calculatingAddress ? "Waiting" : "Calculate"
}</div>
<section class="results">
{map(this.resultAddresses, (address: AddressData) =>
{this.resultAddresses.map(address =>
<span>
<a>{address.address}</a>
<b>Pub: {address.public.b64}</b>
Expand All @@ -20,44 +46,26 @@ import type { AddressData } from "common/TOR-Worker.ts";
)}
</section>
</div>
<div id="pi" class={always(()=>this.calculatingPI?'hidden':'')}>
<h2>Calculate PI</h2>
<input id="inputPiDigits" type="number" placeholder="Number of digits" value={this.$.piDigits}/>
<div onclick={() => this.computePI()} class="button">Compute</div>
<section class="results">
{map(this.resultPIs, (pi: string) =>
<span>{pi}</span>
)}
</section>
</div>
</div>
</>
})
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<typeof import('../TOR-Worker.ts')>('../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() {
Expand All @@ -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<typeof import('../TOR-Worker.ts')>('../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;
}
}
4 changes: 2 additions & 2 deletions deno.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion frontend/entrypoint.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
slot#main {
overflow-y: scroll;
}
.button {
div.button {
display: flex;
align-items: center;
}
Expand Down
10 changes: 0 additions & 10 deletions importmap.dev.json

This file was deleted.

14 changes: 7 additions & 7 deletions importmap.json
Original file line number Diff line number Diff line change
@@ -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/"
}
}

0 comments on commit 1e275c9

Please sign in to comment.