From 7c33aac488256abd995ed25ab234c516c392d375 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Feb 2026 16:02:33 +0000 Subject: [PATCH 1/2] Add Schema Explorer tab to website with interactive form builder Adds a new top-level tab that lets users paste ASN.1 schema text, parse it into SchemaNodes, and interact with a dynamically generated form. Each node type has a dedicated React component with constraint validation: INTEGER (min/max), ENUMERATED (dropdown), string types (alphabet/size), BIT/OCTET STRING (hex input with size), CHOICE (alternative selector), SEQUENCE (optional/default field toggles), and SEQUENCE OF (dynamic list with add/remove). Default values show a checkbox to use default or enter a custom value. The form value can be encoded to PER hex directly. https://claude.ai/code/session_01FGo9d46JcomFtvqefcrABF --- PROMPT.md | 4 + website/src/App.tsx | 64 +- website/src/components/NodeEditor.tsx | 867 ++++++++++++++++++++++ website/src/components/SchemaExplorer.tsx | 244 ++++++ 4 files changed, 1167 insertions(+), 12 deletions(-) create mode 100644 website/src/components/NodeEditor.tsx create mode 100644 website/src/components/SchemaExplorer.tsx diff --git a/PROMPT.md b/PROMPT.md index 33a205d..482bc56 100644 --- a/PROMPT.md +++ b/PROMPT.md @@ -237,3 +237,7 @@ v1.2.0 was published with `"type": "module"` in `package.json` but `tsconfig.bui ## Add `encodeToRawBytes()` to SchemaCodec Add `encodeToRawBytes(value): RawBytes` method to `SchemaCodec` that encodes a value and returns a `RawBytes` with exact bit-length preserved. This avoids the precision loss from `encode()` which returns `Uint8Array` (rounded up to whole bytes). Add tests for roundtrip, bit-length preservation, equivalence with manual approach, and nested passthrough. Update encoding documentation to recommend `encodeToRawBytes` as the primary approach for embedding pre-encoded data. + +## Website Schema Explorer tab + +In website, add a new tab. There is a textarea to input an ASN.1 schema. The npm module parses the schema to generate nodes. Then each node is represented by a React component. For elements that accept inside elements such as SEQUENCE, it's recursive. Each element displays the name of the field. If a default value is present, let the user check default value or set an actual value. Inputs must implement constraints in JavaScript too. diff --git a/website/src/App.tsx b/website/src/App.tsx index e6d1db1..9b3054a 100644 --- a/website/src/App.tsx +++ b/website/src/App.tsx @@ -4,6 +4,7 @@ import ProjectDescription from './components/ProjectDescription'; import SchemaBuilder from './components/SchemaBuilder'; import EncoderDecoder from './components/EncoderDecoder'; import AsnSchemaParser from './components/AsnSchemaParser'; +import SchemaExplorer from './components/SchemaExplorer'; import Footer from './components/Footer'; import type { SchemaNode } from 'asn1-per-ts'; @@ -20,6 +21,7 @@ const DEFAULT_SCHEMA: SchemaNode = { }; export default function App() { + const [activeTab, setActiveTab] = useState<'codec' | 'explorer'>('codec'); const [schema, setSchema] = useState(DEFAULT_SCHEMA); const [schemaText, setSchemaText] = useState(JSON.stringify(DEFAULT_SCHEMA, null, 2)); const [schemaError, setSchemaError] = useState(null); @@ -41,20 +43,58 @@ export default function App() {
-
-

ASN.1 Schema Parser

-
- -
-
+
+ + +
- + {activeTab === 'codec' ? ( + <> +
+

ASN.1 Schema Parser

+
+ +
+
- + + + + + ) : ( +
+

Schema Explorer

+

+ Parse an ASN.1 module and interactively fill in values with constraint validation, + then encode to PER hex. +

+
+ +
+
+ )}