Skip to content

Commit 06c392c

Browse files
author
VPRamon
committed
feat: add siderust-js package and integrate language color functionality in project cards
1 parent edf6a67 commit 06c392c

8 files changed

Lines changed: 135 additions & 19 deletions

File tree

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@astrojs/check": "^0.9.4",
1616
"@astrojs/tailwind": "^5.1.3",
1717
"astro": "^4.16.18",
18+
"siderust-js": "0.1.0",
1819
"tailwindcss": "^3.4.15",
1920
"typescript": "^5.7.2"
2021
},

scripts/build-wasm-demo.sh

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22
# ──────────────────────────────────────────────────────────────────
33
# build-wasm-demo.sh — Vendor browser WASM packages into public/vendor/
44
#
5-
# Sources pre-built packages from the sibling javascript workspace:
6-
# ../javascript/{qtty-js,tempoch-js,siderust-js}/<pkg>/
5+
# Sources browser packages from the published npm tarball installed at:
6+
# node_modules/siderust-js
77
#
8-
# Each package must already have been built with wasm-pack
9-
# (i.e. its pkg/ directory must exist with .wasm + .js bindings).
10-
#
11-
# To rebuild from Rust source first:
12-
# cd /path/to/javascript/<pkg-dir> && wasm-pack build --target web --release
8+
# The npm package ships the browser wrapper sources, but not the generated
9+
# wasm-bindgen pkg/ outputs. This script builds pkg/ in node_modules on demand
10+
# and then copies the browser package files into public/vendor/.
1311
#
1412
# Usage:
1513
# ./scripts/build-wasm-demo.sh
@@ -18,14 +16,19 @@ set -euo pipefail
1816

1917
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
2018
VENDOR="$ROOT/public/vendor"
21-
# Pre-built JS/WASM packages live in the sibling javascript workspace
22-
JS_ROOT="$(cd "$ROOT/.." && pwd)/javascript"
19+
NPM_ROOT="$ROOT/node_modules/siderust-js"
20+
21+
if [ ! -d "$NPM_ROOT" ]; then
22+
echo "✗ npm package not found at $NPM_ROOT"
23+
echo " Run: npm install"
24+
exit 1
25+
fi
2326

2427
# ── Package definitions ─────────────────────────────────────────
2528
declare -A PKG_DIRS=(
2629
[qtty-web]="qtty-js/qtty-web"
2730
[tempoch-web]="tempoch-js/tempoch-web"
28-
[siderust-web]="siderust-js/siderust-web"
31+
[siderust-web]="siderust-web"
2932
)
3033

3134
# Order matters: qtty-web first (no deps), then tempoch-web, then siderust-web
@@ -34,16 +37,18 @@ ORDERED_PKGS=(qtty-web tempoch-web siderust-web)
3437
echo "🔧 Vendoring WASM demo assets…"
3538

3639
for pkg in "${ORDERED_PKGS[@]}"; do
37-
dir="$JS_ROOT/${PKG_DIRS[$pkg]}"
40+
dir="$NPM_ROOT/${PKG_DIRS[$pkg]}"
3841
dest="$VENDOR/$pkg"
3942

4043
echo ""
4144
echo "── $pkg ──────────────────────────────────────"
4245

4346
if [ ! -d "$dir/pkg" ]; then
44-
echo " ✗ pkg/ not found at $dir/pkg"
45-
echo " Run: cd $dir && wasm-pack build --target web --release"
46-
exit 1
47+
echo " → Building pkg/ in $dir"
48+
(
49+
cd "$dir"
50+
wasm-pack build --target web --out-dir pkg --release --scope siderust
51+
)
4752
fi
4853

4954
rm -rf "$dest"

siderust-js

src/components/ProjectCard.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Displays a project with metadata badges and links.
66
*/
77
import type { RepoMetadata } from '../lib/github';
8-
import { getStatusColor, getStatusLabel, formatRelativeTime } from '../lib/github';
8+
import { getStatusColor, getStatusLabel, formatRelativeTime, getLanguageColor } from '../lib/github';
99
import { t, localePath, defaultLocale, type Locale } from '../i18n/index';
1010
1111
interface Props {
@@ -33,7 +33,7 @@ const { project, featured = false, locale = defaultLocale } = Astro.props;
3333
</h3>
3434
{project.language && (
3535
<div class="flex items-center gap-2 mt-1">
36-
<span class="w-3 h-3 rounded-full bg-rust-500" aria-hidden="true"></span>
36+
<span class:list={['w-3 h-3 rounded-full', getLanguageColor(project.language)]} aria-hidden="true"></span>
3737
<span class="text-sm text-gray-600 dark:text-gray-400">{project.language}</span>
3838
</div>
3939
)}

src/lib/github.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,22 @@ function getCratesIoUrl(repo: string, configUrl?: string): string | null {
294294
return `https://crates.io/crates/${repo}`;
295295
}
296296

297+
export function getLanguageColor(language: string | null): string {
298+
switch ((language || '').toLowerCase()) {
299+
case 'rust':
300+
return 'bg-rust-500';
301+
case 'c++':
302+
case 'cpp':
303+
return 'bg-blue-500';
304+
case 'javascript':
305+
return 'bg-yellow-400';
306+
case 'typescript':
307+
return 'bg-sky-500';
308+
default:
309+
return 'bg-gray-400';
310+
}
311+
}
312+
297313
/**
298314
* Fetches complete metadata for a repository
299315
*/
@@ -326,7 +342,7 @@ export async function getRepoMetadata(
326342
openIssues: repoData?.open_issues_count ?? 0,
327343

328344
// Metadata
329-
language: repoData?.language || 'Rust',
345+
language: projectConfig?.language || repoData?.language || null,
330346
topics: repoData?.topics || projectConfig?.tags || [],
331347
license: repoData?.license?.spdx_id || null,
332348

src/pages/[locale]/projects/[slug].astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
getRepoMetadata,
1111
formatDate,
1212
formatRelativeTime,
13+
getLanguageColor,
1314
getStatusColor,
1415
getStatusLabel
1516
} from '../../../lib/github';
@@ -42,6 +43,7 @@ const displayName = normalizeText(project.displayName);
4243
const description = normalizeText(project.description);
4344
const purpose = normalizeText(project.purpose);
4445
const language = normalizeText(project.language);
46+
const languageColor = getLanguageColor(project.language);
4547
const license = normalizeText(project.license);
4648
const features = (project.features ?? []).map(normalizeText).filter(Boolean);
4749
const tags = (project.tags ?? []).map(normalizeText).filter(Boolean);
@@ -121,7 +123,7 @@ const otherProjects = siteConfig.projects
121123

122124
{project.language && (
123125
<div class="flex items-center gap-2">
124-
<span class="w-3 h-3 rounded-full bg-rust-500" aria-hidden="true"></span>
126+
<span class:list={['w-3 h-3 rounded-full', languageColor]} aria-hidden="true"></span>
125127
<span>{language}</span>
126128
</div>
127129
)}

src/site.config.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export interface ProjectConfig {
1010
repo: string;
1111
/** Optional custom display name (defaults to repo name) */
1212
name?: string;
13+
/** Optional language override for display/filtering */
14+
language?: string;
1315
/** Optional custom description (overrides GitHub description) */
1416
description?: string;
1517
/** Project status: 'active', 'experimental', 'stable', 'maintenance', 'deprecated' */
@@ -241,6 +243,89 @@ let approx = evaluate(&coeffs, tau);
241243
println!("sin({tau}) ~= {approx}");`,
242244
tags: ['math', 'interpolation', 'chebyshev', 'numerics', 'rust'],
243245
},
246+
{
247+
repo: 'qtty-js',
248+
name: 'qtty-js',
249+
language: 'JavaScript',
250+
description: 'JavaScript and WebAssembly bindings for qtty, with Node and browser packages for typed units and conversions.',
251+
status: 'active',
252+
featured: false,
253+
purpose: 'qtty-js exposes the qtty unit system to JavaScript runtimes through aligned Node and Web packages. It keeps the canonical conversion model in the vendored Rust workspace while presenting ergonomic JS and TypeScript APIs.',
254+
features: [
255+
'Node package: @siderust/qtty',
256+
'Browser/WASM package: @siderust/qtty-web',
257+
'Typed Quantity and DerivedQuantity APIs',
258+
'Unit factories and TypeScript declarations',
259+
'Shared conversion semantics from vendored qtty',
260+
],
261+
docsUrl: 'https://github.com/Siderust/qtty-js#readme',
262+
gettingStarted: `npm install @siderust/qtty
263+
264+
const { Quantity, Unit, convert } = require('@siderust/qtty');
265+
266+
const distance = new Quantity(1500, Unit.Meter);
267+
console.log(distance.to(Unit.Kilometer).value);
268+
console.log(convert(2, Unit.Hour, Unit.Minute));`,
269+
tags: ['javascript', 'wasm', 'node', 'browser', 'units', 'bindings'],
270+
},
271+
{
272+
repo: 'tempoch-js',
273+
name: 'tempoch-js',
274+
language: 'JavaScript',
275+
description: 'JavaScript and WebAssembly bindings for astronomical time primitives: Julian Date, Modified Julian Date, UTC conversion, and periods.',
276+
status: 'active',
277+
featured: false,
278+
purpose: 'tempoch-js brings Siderust’s typed astronomical time model to JavaScript. The workspace ships aligned Node and browser packages that preserve the same strongly-typed Julian date, UTC, and period concepts used by the Rust backend.',
279+
features: [
280+
'Node package: @siderust/tempoch',
281+
'Browser/WASM package: @siderust/tempoch-web',
282+
'JulianDate, ModifiedJulianDate, and Period APIs',
283+
'Interop with qtty-js quantity objects',
284+
'TypeScript declarations for both targets',
285+
],
286+
docsUrl: 'https://github.com/Siderust/tempoch-js#readme',
287+
gettingStarted: `npm install @siderust/tempoch @siderust/qtty
288+
289+
const { JulianDate } = require('@siderust/tempoch');
290+
const { Hours } = require('@siderust/qtty/units');
291+
292+
const jd = JulianDate.j2000();
293+
const later = jd.add(Hours(6));
294+
console.log(later.toDate().toISOString());`,
295+
tags: ['javascript', 'wasm', 'node', 'browser', 'time', 'astronomy', 'bindings'],
296+
},
297+
{
298+
repo: 'siderust-js',
299+
name: 'siderust-js',
300+
language: 'JavaScript',
301+
description: 'JavaScript and WebAssembly bindings for Siderust astronomy: observers, ephemerides, coordinate transforms, and event searches.',
302+
status: 'active',
303+
featured: false,
304+
purpose: 'siderust-js exposes the Siderust astronomy stack to JavaScript through synchronized Node and Web packages. Its public API stays strongly typed by requiring qtty-js and tempoch-js quantity and time objects at the boundary.',
305+
features: [
306+
'Node package: @siderust/siderust',
307+
'Browser/WASM package: @siderust/siderust-web',
308+
'Observer models, ephemerides, and transforms',
309+
'Altitude, azimuth, crossing, and culmination search',
310+
'Strict interop with qtty-js and tempoch-js types',
311+
],
312+
docsUrl: 'https://github.com/Siderust/siderust-js#readme',
313+
gettingStarted: `npm install @siderust/siderust @siderust/qtty @siderust/tempoch
314+
315+
const { Quantity } = require('@siderust/qtty');
316+
const { JulianDate } = require('@siderust/tempoch');
317+
const { Observer, bodyAltitudeAt } = require('@siderust/siderust');
318+
319+
const observer = new Observer(
320+
new Quantity(-17.8925, 'Degree'),
321+
new Quantity(28.7543, 'Degree'),
322+
new Quantity(2396, 'Meter'),
323+
);
324+
325+
const altitude = bodyAltitudeAt('Sun', observer, new JulianDate(2451545.0).toModifiedJulianDate());
326+
console.log(altitude.value, altitude.unit);`,
327+
tags: ['javascript', 'wasm', 'node', 'browser', 'astronomy', 'ephemeris', 'bindings'],
328+
},
244329
{
245330
repo: 'siderust-cpp',
246331
name: 'siderust-cpp',

0 commit comments

Comments
 (0)