gokul/macro-six-usbc

A six-key macro keyboard PCB paired with a separate physical enclosure.

Version
0.1.16
License
unset
Stars
0

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone gokul/macro-six-usbc  # download the package files into ./macro-six-usbc
tsci add gokul/macro-six-usbc    # add it to your project as @tsci/gokul.macro-six-usbc

In a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.

scripts/bundle-package.ts

import ts from 'typescript'
import { mkdir } from 'node:fs/promises'

// Keep library packaging separate from full-program TypeScript validation.
// The circuit build and `typecheck` remain independent release checks.
await mkdir('dist', { recursive: true })
for (const format of ['esm', 'cjs'] as const) {
  const result = await Bun.build({ entrypoints: ['open-assembly.tsx'], target: 'browser', format, packages: 'external', minify: false })
  if (!result.success) throw new AggregateError(result.logs, `${format} bundle failed`)
  if (result.outputs.length !== 1) throw new Error('Expected one library bundle')
  await Bun.write(`dist/index.${format === 'esm' ? 'js' : 'cjs'}`, result.outputs[0])
}
const declarations = ts.transpileDeclaration(await Bun.file('open-assembly.tsx').text(), {
  fileName: 'open-assembly.tsx',
  compilerOptions: { jsx: ts.JsxEmit.ReactJSX, isolatedDeclarations: true },
  reportDiagnostics: true,
})
const errors = declarations.diagnostics?.filter(d => d.category === ts.DiagnosticCategory.Error) ?? []
if (errors.length) throw new Error(errors.map(d => ts.flattenDiagnosticMessageText(d.messageText, '\n')).join('\n'))
await Bun.write('dist/index.d.ts', declarations.outputText)
console.log('ESM, CommonJS and declaration bundles written')