Skip to content

Commit aceaa19

Browse files
committed
Prepare for publishing to JSR and other small improvements
1 parent 234d2cb commit aceaa19

14 files changed

Lines changed: 141 additions & 124 deletions

File tree

.github/workflows/publish-jsr.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Publish to JSR
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
id-token: write
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Runtime
21+
uses: denoland/setup-deno@v2
22+
with:
23+
deno-version: v2.x
24+
25+
- name: Publish
26+
run: deno publish

deno.jsonc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"name": "@kuchta/radixverse",
3+
"version": "0.1.0",
4+
"exports": "./src/radixes.ts",
25
"nodeModulesDir": "auto",
36
"exclude": [ ".history" ],
47
"tasks": {
@@ -27,7 +30,7 @@
2730
}
2831
},
2932
"publish": {
30-
"include": [ "README.md", "deno.json", "package.json", "src/utils.ts" ]
33+
"include": [ "README.md", "deno.json", "package.json", "src/radixes.ts" ]
3134
},
3235
"deploy": {
3336
"org": "kuchta",

deno.lock

Lines changed: 27 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "radixverse",
3-
"version": "0.0.4",
3+
"version": "0.1.0",
44
"license": "MIT",
55
"repository": "kuchta/radixverse",
66
"homepage": "https://kuchta.github.io/radixverse",
@@ -9,7 +9,7 @@
99
"email": "mila.kuchta@gmail.com"
1010
},
1111
"type": "module",
12-
"exports": "./utils.ts",
12+
"exports": "./src/radixes.ts",
1313
"imports": {
1414
"#/*": "./src/*"
1515
},
@@ -52,7 +52,7 @@
5252
"react-icons": "^5.6.0",
5353
"react-router-dom": "^7.14.0",
5454
"react-textarea-autosize": "^8.5.9",
55-
"tailwind-csstree": "^0.3.0",
55+
"tailwind-csstree": "^0.3.1",
5656
"tailwindcss": "^4.2.2",
5757
"typescript": "6.0.2",
5858
"typescript-eslint": "^8.58.1",

src/app.tsx

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
1-
21
import { createRoot } from 'react-dom/client'
32
import { useState, useEffect } from 'react'
43
import { BrowserRouter, Routes, Route, Link, useLocation, useSearchParams } from 'react-router-dom'
54
import { ErrorBoundary, getErrorMessage } from 'react-error-boundary'
65

76
import { LS_RADIXES, AppContext, getCharsLS, sanitizeInput, serializeRadixes, unserializeRadixes } from './common.ts'
7+
import { type Radix, createRadixes, createRadix, num2str, str2num, allowedCharaters, } from './radixes.ts'
8+
89
import Header from './components/header.tsx'
910
import Show from './components/show.tsx'
1011
import Add from './components/add.tsx'
1112
import Multiply from './components/multiply.tsx'
1213
import Convert from './components/convert.tsx'
13-
import {
14-
type Radix,
15-
createRadixes,
16-
createRadix,
17-
num2str,
18-
str2num,
19-
allowedCharaters,
20-
} from '#/utils.ts'
2114

2215
import './app.css'
2316

@@ -77,8 +70,21 @@ function useStore(updateError: (error: unknown) => void) {
7770
const [ radixes, setRadixes ] = useState(getRadixesLS(updateError) ?? createRadixes(getCharsLS()))
7871
const [ enabledRadixes, setEnabledRadixes ] = useState(radixes.filter(r => r.enabled))
7972
const [ searchParams, setSearchParams ] = useSearchParams()
80-
const [ value, setValue ] = useState(BIG_INT_0)
8173
const [ radix, setRadix ] = useState(createRadix(10))
74+
const [ value, setValue ] = useState(BIG_INT_0)
75+
76+
const updateRadixes: UpdateRadixes = (radixes) => {
77+
setRadixes(radixes)
78+
79+
const enabledRadixes = radixes.filter(v => v.enabled)
80+
setEnabledRadixes(enabledRadixes)
81+
82+
searchParams.delete('r')
83+
enabledRadixes.forEach(r => { searchParams.append('r', r.name) })
84+
setSearchParams(searchParams)
85+
86+
localStorage.setItem(LS_RADIXES, serializeRadixes(radixes))
87+
}
8288

8389
const updateValue: UpdateValue = (value, r = radix) => {
8490
if (value === BIG_INT_0) {
@@ -97,19 +103,6 @@ function useStore(updateError: (error: unknown) => void) {
97103
setSearchParams(searchParams)
98104
}
99105

100-
const updateRadixes: UpdateRadixes = (radixes) => {
101-
setRadixes(radixes)
102-
103-
const enabledRadixes = radixes.filter(v => v.enabled)
104-
setEnabledRadixes(enabledRadixes)
105-
106-
searchParams.delete('r')
107-
enabledRadixes.forEach(r => { searchParams.append('r', r.name) })
108-
setSearchParams(searchParams)
109-
110-
localStorage.setItem(LS_RADIXES, serializeRadixes(radixes))
111-
}
112-
113106
useEffect(() => {
114107
if (searchParams.has('clear-settings')) localStorage.clear()
115108
if (searchParams.has('r')) {

src/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createContext } from 'react'
22
import { z } from 'zod'
33

4-
import { createRadix, type Radix } from "./utils.ts"
4+
import { createRadix, type Radix } from "./radixes.ts"
55
import { getErrorMessage } from "react-error-boundary"
66

77

src/components/add.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { useState, useEffect } from "react"
22

3+
import type { Radix } from '#/radixes.ts'
34
import Table, { Tables } from './table.tsx'
4-
import type { Radix } from '#/utils.ts'
55

66
const { isNaN } = Number
77

88
export default function Add({ radixes }: { radixes: Radix[] }) {
9-
return <Tables>{ radixes.map(radix => <AddTable radix={radix} key={radix.name}/>) }</Tables>
9+
return <Tables>{ radixes.map(radix =>
10+
<AddTable radix={radix} key={radix.name}/>) }
11+
</Tables>
1012
}
1113

1214
function AddTable({ radix }: { radix: Radix }) {

src/components/convert.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { type ComponentProps, type InputEventHandler, type ClipboardEventHandler, useState, useEffectEvent, useEffect, useRef } from 'react'
22
import { getErrorMessage } from 'react-error-boundary'
33

4+
import { type Radix, num2str, str2num, allowedCharaters, createRadix, } from '#/radixes.ts'
45
import type { UpdateValue } from '#/app.tsx'
56
import { sanitizeInput } from "#/common.ts"
67
import { getCharsForTooltip } from './table.tsx'
7-
import { type Radix, num2str, str2num, allowedCharaters, createRadix, } from '#/utils.ts'
8+
89

910
const BIG_INT_0 = 0n
1011
const BIG_INT_1 = 1n

0 commit comments

Comments
 (0)