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/package-lock.json b/package-lock.json index 9acc045..85c829c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "asn1-per-ts", - "version": "1.0.0", + "version": "1.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "asn1-per-ts", - "version": "1.0.0", + "version": "1.4.0", "license": "MIT", "dependencies": { "peggy": "^5.0.6" 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. +

+
+ +
+
+ )}