@kubohiroya/turbowarp-markdown 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,49 @@
1
+ # Architecture
2
+
3
+ [日本語](architecture.ja.md)
4
+
5
+ ## Model
6
+
7
+ Markdown is represented as immutable fragments:
8
+
9
+ ```text
10
+ MarkdownFragment
11
+ -> inline(text, bold, italic, link, code)
12
+ -> block(heading, paragraph, quote, codeBlock, list, listItem)
13
+ -> sequence(children)
14
+ -> empty
15
+ ```
16
+
17
+ Builder operations return new fragment values. Rendering is the only operation that produces final Markdown text.
18
+
19
+ ## Safety Policy
20
+
21
+ Plain text escapes Markdown metacharacters so user strings are not interpreted as raw Markdown. Inline code and fenced code blocks choose deterministic delimiters. Link destinations reject executable URL schemes such as `javascript:`.
22
+
23
+ There is no raw Markdown block in v1.
24
+
25
+ ## Validation
26
+
27
+ The validator is a lightweight tree check. `render Markdown [FRAGMENT]` renders without validation. `render Markdown with validation [FRAGMENT]` runs validation before rendering and stores the validation result from the most recent validated render. The stored error text is available through `last Markdown validation errors`, and the boolean state is available through `last rendered Markdown has validation errors?`.
28
+
29
+ This is intended as the integration point for HTTP response handling: a server extension can use the validated render block, inspect the stored validation errors, and replace the response body with an explanatory error page while logging the same diagnostics.
30
+
31
+ The validator reports errors for issues that make the generated Markdown structure clearly wrong, such as `listItem` outside a list and block fragments nested inside inline-only fragments. It reports warnings for likely authoring problems such as empty fragments, empty lists, empty headings, and links without visible content or destinations.
32
+
33
+ Validation does not replace a full CommonMark conformance checker.
34
+
35
+ ## TurboWarp Boundary
36
+
37
+ Reporter blocks serialize fragments with a `turbowarp-markdown:v1:` prefix. Plain strings passed into content arguments are treated as text fragments.
38
+
39
+ ## Build Outputs
40
+
41
+ ```text
42
+ src/index.ts + src/extension.ts + src/markdown.ts
43
+ -> vite-plugin-turbowarp-extension
44
+ -> dist/turbowarp-markdown.js
45
+
46
+ src/config.ts + src/block-definitions.json
47
+ -> extension-api-manifest Vite plugin
48
+ -> dist/extension-manifest.json
49
+ ```
@@ -0,0 +1,52 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <title>TurboWarp Markdown documentation</title>
7
+ <style>
8
+ body{font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;max-width:920px;margin:0 auto;padding:2rem;line-height:1.6;color:#1f2937}
9
+ code{background:#f3f4f6;padding:.1em .3em;border-radius:.25em}
10
+ pre{background:#f8fafc;border:1px solid #e5e7eb;padding:1rem;overflow:auto;border-radius:.5rem}
11
+ table{border-collapse:collapse;width:100%}
12
+ th,td{border:1px solid #d1d5db;padding:.5rem;text-align:left;vertical-align:top}
13
+ </style>
14
+ </head>
15
+ <body>
16
+ <h1>TurboWarp Markdown</h1>
17
+ <p>TurboWarp Markdown builds Markdown as immutable structured fragments. Blocks create escaped inline fragments, block fragments, lists, and sequences; final Markdown text is produced only by an explicit render block.</p>
18
+
19
+ <h2>Core Flow</h2>
20
+ <pre><code>heading [1] [Sensor]
21
+ paragraph [temperature]
22
+ [heading result] followed by [paragraph result]
23
+ render Markdown [combined result]</code></pre>
24
+
25
+ <h2>Safety Model</h2>
26
+ <ul>
27
+ <li>Plain text is escaped instead of treated as raw Markdown.</li>
28
+ <li>Inline code and fenced code blocks choose deterministic delimiters.</li>
29
+ <li>Link destinations reject executable URL schemes such as <code>javascript:</code>.</li>
30
+ <li>No raw Markdown injection block is provided.</li>
31
+ </ul>
32
+
33
+ <h2>Common Blocks</h2>
34
+ <table>
35
+ <thead>
36
+ <tr><th>Category</th><th>Blocks</th></tr>
37
+ </thead>
38
+ <tbody>
39
+ <tr><td>Inline</td><td><code>text</code>, <code>bold</code>, <code>italic</code>, <code>link</code>, <code>code</code></td></tr>
40
+ <tr><td>Blocks</td><td><code>heading</code>, <code>paragraph</code>, <code>quote</code>, <code>codeBlock</code></td></tr>
41
+ <tr><td>Lists</td><td><code>listItem</code>, <code>unorderedList</code>, <code>orderedList</code></td></tr>
42
+ <tr><td>Composition</td><td><code>concat</code>, <code>render</code></td></tr>
43
+ </tbody>
44
+ </table>
45
+
46
+ <h2>HTTP Server Interoperability</h2>
47
+ <p>For <code>turbowarp-http-server</code>, pass the rendered string as the response body and set <code>Content-Type: text/markdown; charset=utf-8</code>. The HTTP server does not need to depend on this package.</p>
48
+
49
+ <h2>TypeScript API</h2>
50
+ <p>The package also exports block-free builder functions from <code>@kubohiroya/turbowarp-markdown</code>, including <code>text</code>, <code>bold</code>, <code>italic</code>, <code>link</code>, <code>heading</code>, <code>paragraph</code>, <code>quote</code>, <code>codeBlock</code>, <code>listItem</code>, <code>unorderedList</code>, <code>orderedList</code>, <code>concat</code>, and <code>render</code>.</p>
51
+ </body>
52
+ </html>
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@kubohiroya/turbowarp-markdown",
3
+ "version": "0.2.0",
4
+ "description": "An immutable Markdown builder extension for TurboWarp.",
5
+ "author": "Hiroya Kubo <hiroya@cuc.ac.jp>",
6
+ "license": "MPL-2.0",
7
+ "homepage": "https://github.com/kubohiroya/turbowarp-markdown#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/kubohiroya/turbowarp-markdown.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/kubohiroya/turbowarp-markdown/issues"
14
+ },
15
+ "keywords": [
16
+ "turbowarp",
17
+ "scratch",
18
+ "extension",
19
+ "markdown",
20
+ "builder",
21
+ "vite",
22
+ "typescript"
23
+ ],
24
+ "type": "module",
25
+ "files": [
26
+ "dist/",
27
+ "docs/",
28
+ "schemas/",
29
+ "src/",
30
+ "README.md",
31
+ "README.ja.md",
32
+ "LICENSE"
33
+ ],
34
+ "exports": {
35
+ ".": "./src/markdown.ts",
36
+ "./extension": "./dist/turbowarp-markdown.js"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public",
40
+ "registry": "https://registry.npmjs.org/"
41
+ },
42
+ "engines": {
43
+ "node": ">=22.18.0"
44
+ },
45
+ "devDependencies": {
46
+ "@eslint/js": "^9.39.5",
47
+ "@kubohiroya/vite-plugin-turbowarp-extension": "0.4.0",
48
+ "@types/node": "^24.13.3",
49
+ "eslint": "^9.39.5",
50
+ "typescript": "^5.9.3",
51
+ "typescript-eslint": "^8.66.0",
52
+ "vite": "^8.2.2",
53
+ "vitest": "^4.1.10"
54
+ },
55
+ "scripts": {
56
+ "dev": "vite build --watch",
57
+ "typecheck": "tsc --noEmit",
58
+ "build": "vite build",
59
+ "lint": "eslint src tests vite.config.ts",
60
+ "test": "vitest run",
61
+ "docs": "node scripts/generate-readme.ts",
62
+ "docs:check": "pnpm run docs && git diff --exit-code -- README.md",
63
+ "template:readme": "node scripts/apply-readme-template.ts",
64
+ "repo:check": "node scripts/check-repo.ts",
65
+ "pack:check": "npm pack --dry-run --ignore-scripts",
66
+ "check": "pnpm run typecheck && pnpm run lint && pnpm run test && pnpm run docs:check && pnpm run check:dist && pnpm run repo:check && pnpm run pack:check",
67
+ "check:dist": "pnpm run build && node scripts/check-dist.ts"
68
+ }
69
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://raw.githubusercontent.com/kubohiroya/turbowarp-markdown/main/schemas/extension-manifest.schema.json",
4
+ "title": "TurboWarp Extension API Manifest",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["formatVersion", "id", "blocks", "menus"],
8
+ "properties": {
9
+ "formatVersion": {"const": 1},
10
+ "id": {"type": "string", "pattern": "^[a-z0-9]+$"},
11
+ "blocks": {
12
+ "type": "array",
13
+ "items": {
14
+ "type": "object",
15
+ "additionalProperties": false,
16
+ "required": ["opcode", "blockType", "arguments"],
17
+ "properties": {
18
+ "opcode": {"type": "string", "minLength": 1},
19
+ "blockType": {"type": "string", "minLength": 1},
20
+ "arguments": {
21
+ "type": "array",
22
+ "items": {
23
+ "type": "object",
24
+ "additionalProperties": false,
25
+ "required": ["id", "type"],
26
+ "properties": {
27
+ "id": {"type": "string", "minLength": 1},
28
+ "type": {"type": "string", "minLength": 1},
29
+ "menu": {"type": "string", "minLength": 1}
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
35
+ },
36
+ "menus": {
37
+ "type": "array",
38
+ "items": {
39
+ "type": "object",
40
+ "additionalProperties": false,
41
+ "required": ["id", "acceptReporters"],
42
+ "properties": {
43
+ "id": {"type": "string", "minLength": 1},
44
+ "acceptReporters": {"type": "boolean"}
45
+ }
46
+ }
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,150 @@
1
+ {
2
+ "extensionName": "TurboWarp Markdown",
3
+ "blocks": [
4
+ {
5
+ "opcode": "text",
6
+ "blockType": "REPORTER",
7
+ "text": "text [TEXT]",
8
+ "description": "Creates escaped Markdown text.",
9
+ "arguments": {"TEXT": {"type": "STRING", "defaultValue": "Hello *world*"}}
10
+ },
11
+ {
12
+ "opcode": "bold",
13
+ "blockType": "REPORTER",
14
+ "text": "bold [CONTENT]",
15
+ "description": "Creates bold inline Markdown content.",
16
+ "arguments": {"CONTENT": {"type": "STRING", "defaultValue": "important"}}
17
+ },
18
+ {
19
+ "opcode": "italic",
20
+ "blockType": "REPORTER",
21
+ "text": "italic [CONTENT]",
22
+ "description": "Creates italic inline Markdown content.",
23
+ "arguments": {"CONTENT": {"type": "STRING", "defaultValue": "note"}}
24
+ },
25
+ {
26
+ "opcode": "link",
27
+ "blockType": "REPORTER",
28
+ "text": "link [CONTENT] URL [URL]",
29
+ "description": "Creates a Markdown link with a conservatively validated destination.",
30
+ "arguments": {
31
+ "CONTENT": {"type": "STRING", "defaultValue": "TurboWarp"},
32
+ "URL": {"type": "STRING", "defaultValue": "https://turbowarp.org/"}
33
+ }
34
+ },
35
+ {
36
+ "opcode": "code",
37
+ "blockType": "REPORTER",
38
+ "text": "code [TEXT]",
39
+ "description": "Creates inline code content.",
40
+ "arguments": {"TEXT": {"type": "STRING", "defaultValue": "status"}}
41
+ },
42
+ {
43
+ "opcode": "heading",
44
+ "blockType": "REPORTER",
45
+ "text": "heading [LEVEL] [CONTENT]",
46
+ "description": "Creates a heading with the level clamped to 1 through 6.",
47
+ "arguments": {
48
+ "LEVEL": {"type": "NUMBER", "defaultValue": 1},
49
+ "CONTENT": {"type": "STRING", "defaultValue": "Sensor"}
50
+ }
51
+ },
52
+ {
53
+ "opcode": "paragraph",
54
+ "blockType": "REPORTER",
55
+ "text": "paragraph [CONTENT]",
56
+ "description": "Creates a paragraph block.",
57
+ "arguments": {"CONTENT": {"type": "STRING", "defaultValue": "ready"}}
58
+ },
59
+ {
60
+ "opcode": "quote",
61
+ "blockType": "REPORTER",
62
+ "text": "quote [CONTENT]",
63
+ "description": "Creates a block quote.",
64
+ "arguments": {"CONTENT": {"type": "STRING", "defaultValue": "quoted"}}
65
+ },
66
+ {
67
+ "opcode": "codeBlock",
68
+ "blockType": "REPORTER",
69
+ "text": "code block [TEXT] language [LANGUAGE]",
70
+ "description": "Creates a fenced code block.",
71
+ "arguments": {
72
+ "TEXT": {"type": "STRING", "defaultValue": "console.log('ok')"},
73
+ "LANGUAGE": {"type": "STRING", "defaultValue": "js"}
74
+ }
75
+ },
76
+ {
77
+ "opcode": "listItem",
78
+ "blockType": "REPORTER",
79
+ "text": "list item [CONTENT]",
80
+ "description": "Creates a list item fragment.",
81
+ "arguments": {"CONTENT": {"type": "STRING", "defaultValue": "item"}}
82
+ },
83
+ {
84
+ "opcode": "unorderedList",
85
+ "blockType": "REPORTER",
86
+ "text": "unordered list [ITEMS]",
87
+ "description": "Creates an unordered list from item fragments.",
88
+ "arguments": {"ITEMS": {"type": "STRING", "defaultValue": ""}}
89
+ },
90
+ {
91
+ "opcode": "orderedList",
92
+ "blockType": "REPORTER",
93
+ "text": "ordered list [ITEMS]",
94
+ "description": "Creates an ordered list from item fragments.",
95
+ "arguments": {"ITEMS": {"type": "STRING", "defaultValue": ""}}
96
+ },
97
+ {
98
+ "opcode": "concat",
99
+ "blockType": "REPORTER",
100
+ "text": "[LEFT] followed by [RIGHT]",
101
+ "description": "Creates a new Markdown fragment sequence without mutating either input.",
102
+ "arguments": {
103
+ "LEFT": {"type": "STRING", "defaultValue": ""},
104
+ "RIGHT": {"type": "STRING", "defaultValue": ""}
105
+ }
106
+ },
107
+ {
108
+ "opcode": "render",
109
+ "blockType": "REPORTER",
110
+ "text": "render Markdown [FRAGMENT]",
111
+ "description": "Renders a Markdown fragment to final Markdown text without updating stored validation errors.",
112
+ "arguments": {"FRAGMENT": {"type": "STRING", "defaultValue": ""}}
113
+ },
114
+ {
115
+ "opcode": "renderWithValidation",
116
+ "blockType": "REPORTER",
117
+ "text": "render Markdown with validation [FRAGMENT]",
118
+ "description": "Validates a Markdown fragment, stores any validation errors, and renders final Markdown text.",
119
+ "arguments": {"FRAGMENT": {"type": "STRING", "defaultValue": ""}}
120
+ },
121
+ {
122
+ "opcode": "lastValidationErrors",
123
+ "blockType": "REPORTER",
124
+ "text": "last Markdown validation errors",
125
+ "description": "Returns validation errors stored by the most recent render Markdown with validation block.",
126
+ "arguments": {}
127
+ },
128
+ {
129
+ "opcode": "lastRenderHasValidationErrors",
130
+ "blockType": "BOOLEAN",
131
+ "text": "last rendered Markdown has validation errors?",
132
+ "description": "Reports whether the most recent validated Markdown render stored validation errors.",
133
+ "arguments": {}
134
+ },
135
+ {
136
+ "opcode": "validateMarkdown",
137
+ "blockType": "REPORTER",
138
+ "text": "validate Markdown [FRAGMENT]",
139
+ "description": "Returns simple validation diagnostics for a Markdown fragment.",
140
+ "arguments": {"FRAGMENT": {"type": "STRING", "defaultValue": ""}}
141
+ },
142
+ {
143
+ "opcode": "isValidMarkdown",
144
+ "blockType": "BOOLEAN",
145
+ "text": "Markdown [FRAGMENT] is valid?",
146
+ "description": "Reports whether simple validation found no Markdown errors.",
147
+ "arguments": {"FRAGMENT": {"type": "STRING", "defaultValue": ""}}
148
+ }
149
+ ]
150
+ }
package/src/config.ts ADDED
@@ -0,0 +1,12 @@
1
+ export const extensionConfig = {
2
+ id: 'kubohiroyamarkdown',
3
+ slug: 'turbowarp-markdown',
4
+ name: 'TurboWarp Markdown',
5
+ description: 'Build Markdown documents with immutable reporter blocks.',
6
+ author: 'Hiroya Kubo',
7
+ license: 'MPL-2.0',
8
+ unsandboxed: false,
9
+ docsURI: 'https://kubohiroya.github.io/turbowarp-markdown/',
10
+ blockIconURI:
11
+ 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0OCA0OCI+PHJlY3QgeD0iNiIgeT0iOCIgd2lkdGg9IjM2IiBoZWlnaHQ9IjMyIiByeD0iNCIgZmlsbD0iIzJGNjM4NiIvPjxwYXRoIGQ9Ik0xMyAzMFYxOGw1IDcgNS03djEyTTMwIDE4djEyTTI2IDMwaDgiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2ZmZmZmZiIgc3Ryb2tlLXdpZHRoPSIzIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4='
12
+ } as const;
@@ -0,0 +1,149 @@
1
+ import type {Plugin} from 'vite';
2
+
3
+ export const EXTENSION_MANIFEST_FORMAT_VERSION = 1 as const;
4
+
5
+ export interface ExtensionManifestArgument {
6
+ id: string;
7
+ type: string;
8
+ menu?: string;
9
+ }
10
+
11
+ export interface ExtensionManifestBlock {
12
+ opcode: string;
13
+ blockType: string;
14
+ arguments: ExtensionManifestArgument[];
15
+ }
16
+
17
+ export interface ExtensionManifestMenu {
18
+ id: string;
19
+ acceptReporters: boolean;
20
+ }
21
+
22
+ export interface ExtensionManifest {
23
+ formatVersion: typeof EXTENSION_MANIFEST_FORMAT_VERSION;
24
+ id: string;
25
+ blocks: ExtensionManifestBlock[];
26
+ menus: ExtensionManifestMenu[];
27
+ }
28
+
29
+ export interface ExtensionManifestPluginOptions {
30
+ id: string;
31
+ definitions: unknown;
32
+ fileName?: string;
33
+ }
34
+
35
+ export function createExtensionManifest(id: string, definitions: unknown): ExtensionManifest {
36
+ if (!/^[a-z0-9]+$/.test(id)) {
37
+ throw new TypeError('Extension manifest ID must contain only lowercase letters and numbers.');
38
+ }
39
+
40
+ const source = requireRecord(definitions, 'Block definitions');
41
+ const sourceBlocks = source.blocks;
42
+ if (!Array.isArray(sourceBlocks)) {
43
+ throw new TypeError('Block definitions must contain a blocks array.');
44
+ }
45
+
46
+ const menus = normalizeMenus(source.menus);
47
+ const menuIds = new Set(menus.map((menu) => menu.id));
48
+ const seenOpcodes = new Set<string>();
49
+ const blocks = sourceBlocks.map((block, index) => {
50
+ const normalized = normalizeBlock(block, index, menuIds);
51
+ if (seenOpcodes.has(normalized.opcode)) {
52
+ throw new TypeError(`Duplicate block opcode: ${normalized.opcode}`);
53
+ }
54
+ seenOpcodes.add(normalized.opcode);
55
+ return normalized;
56
+ });
57
+
58
+ return {
59
+ formatVersion: EXTENSION_MANIFEST_FORMAT_VERSION,
60
+ id,
61
+ blocks: blocks.sort((left, right) => compareIds(left.opcode, right.opcode)),
62
+ menus
63
+ };
64
+ }
65
+
66
+ export function serializeExtensionManifest(id: string, definitions: unknown): string {
67
+ return `${JSON.stringify(createExtensionManifest(id, definitions), null, 2)}\n`;
68
+ }
69
+
70
+ export function extensionManifestPlugin(options: ExtensionManifestPluginOptions): Plugin {
71
+ return {
72
+ name: 'extension-api-manifest',
73
+ apply: 'build',
74
+ enforce: 'post',
75
+ generateBundle() {
76
+ this.emitFile({
77
+ type: 'asset',
78
+ fileName: options.fileName ?? 'extension-manifest.json',
79
+ source: serializeExtensionManifest(options.id, options.definitions)
80
+ });
81
+ }
82
+ };
83
+ }
84
+
85
+ function normalizeBlock(
86
+ value: unknown,
87
+ index: number,
88
+ menuIds: ReadonlySet<string>
89
+ ): ExtensionManifestBlock {
90
+ const block = requireRecord(value, `Block at index ${index}`);
91
+ const opcode = requireNonEmptyString(block.opcode, `Block at index ${index} opcode`);
92
+ const blockType = requireNonEmptyString(block.blockType, `Block ${opcode} blockType`);
93
+ const sourceArguments = block.arguments ?? {};
94
+ const argumentRecord = requireRecord(sourceArguments, `Block ${opcode} arguments`);
95
+ const argumentsList = Object.entries(argumentRecord).map(([argumentId, argument]) => {
96
+ requireNonEmptyString(argumentId, `Block ${opcode} argument ID`);
97
+ const definition = requireRecord(argument, `Block ${opcode} argument ${argumentId}`);
98
+ const type = requireNonEmptyString(
99
+ definition.type,
100
+ `Block ${opcode} argument ${argumentId} type`
101
+ );
102
+ const menu = definition.menu;
103
+ if (menu !== undefined && (typeof menu !== 'string' || !menuIds.has(menu))) {
104
+ throw new TypeError(`Block ${opcode} argument ${argumentId} references unknown menu: ${menu}`);
105
+ }
106
+ return menu === undefined ? {id: argumentId, type} : {id: argumentId, type, menu};
107
+ });
108
+
109
+ return {
110
+ opcode,
111
+ blockType,
112
+ arguments: argumentsList.sort((left, right) => compareIds(left.id, right.id))
113
+ };
114
+ }
115
+
116
+ function normalizeMenus(value: unknown): ExtensionManifestMenu[] {
117
+ const menuRecord = requireRecord(value ?? {}, 'Block definition menus');
118
+ return Object.entries(menuRecord)
119
+ .map(([id, menu]) => {
120
+ requireNonEmptyString(id, 'Menu ID');
121
+ const definition = requireRecord(menu, `Menu ${id}`);
122
+ const acceptReporters = definition.acceptReporters ?? false;
123
+ if (typeof acceptReporters !== 'boolean') {
124
+ throw new TypeError(`Menu ${id} acceptReporters must be a boolean.`);
125
+ }
126
+ return {id, acceptReporters};
127
+ })
128
+ .sort((left, right) => compareIds(left.id, right.id));
129
+ }
130
+
131
+ function requireRecord(value: unknown, label: string): Record<string, unknown> {
132
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
133
+ throw new TypeError(`${label} must be an object.`);
134
+ }
135
+ return value as Record<string, unknown>;
136
+ }
137
+
138
+ function requireNonEmptyString(value: unknown, label: string): string {
139
+ if (typeof value !== 'string' || value.length === 0) {
140
+ throw new TypeError(`${label} must be a non-empty string.`);
141
+ }
142
+ return value;
143
+ }
144
+
145
+ function compareIds(left: string, right: string): number {
146
+ if (left < right) return -1;
147
+ if (left > right) return 1;
148
+ return 0;
149
+ }