partial-tsx 0.0.0 → 0.0.2

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.
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # partial-tsx
2
+
3
+ Completes prefix-growing TSX.
4
+
5
+ ## Input
6
+
7
+ ```ts
8
+ import { completePartialTsx, normalizeGeneratedTsx } from "partial-tsx";
9
+
10
+ completePartialTsx("<div>Hello");
11
+ completePartialTsx("function App() { return <div>Hello", { mode: "streaming" });
12
+ normalizeGeneratedTsx("function Card() { return <button>OK");
13
+ ```
14
+
15
+ ## Output
16
+
17
+ - `completePartialTsx(code)` returns syntactically safer TSX for a partial prefix.
18
+ - `normalizeGeneratedTsx(code)` returns renderer-ready TSX:
19
+ - Markdown fences removed.
20
+ - Safe partial syntax completed.
21
+ - Missing default export added when a component can be found.
22
+ - Missing imports added for known React hooks such as `useState`.
23
+ - `{ mode: "streaming" }` first rolls script back to its last committed syntax boundary. It never closes an unfinished call, initializer, callback, control-flow statement, or JSX `{expression`; unterminated JSX string attributes remain the one value-completion exception.
24
+ - The default `{ mode: "final" }` preserves the existing completion behavior. `partial-react` uses streaming mode only for incremental frames and sends final input to the compiler unchanged.
25
+
26
+ ## Corner Cases
27
+
28
+ - Incomplete component/tag names are left alone when completing them would likely render the wrong element.
29
+ - Unterminated JSX string attributes can be closed; incomplete expression attributes are dropped.
30
+ - Void HTML tags are normalized as self-closing tags.
31
+ - Unknown hooks or custom hooks are not auto-imported.
32
+ - Existing default exports are preserved.
33
+ - Invalid TypeScript semantics are not repaired.
34
+
35
+ ## Test
36
+
37
+ ```sh
38
+ bun test lib/partial-tsx
39
+ ```
package/package.json CHANGED
@@ -1,11 +1,19 @@
1
1
  {
2
2
  "name": "partial-tsx",
3
- "version": "0.0.0",
4
- "description": "Placeholder for partial-tsx",
5
- "main": "index.js",
6
- "scripts": {},
7
- "keywords": [],
8
- "author": "muspi-merol (https://www.npmjs.com/~muspi-merol)",
9
- "license": "UNLICENSED",
10
- "private": false
11
- }
3
+ "description": "Utilities for completing prefix-growing TSX.",
4
+ "version": "0.0.2",
5
+ "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/MindLab-Research/macaron-genui-demo",
9
+ "directory": "lib/partial-tsx"
10
+ },
11
+ "exports": {
12
+ ".": "./src/partial.ts"
13
+ },
14
+ "files": [
15
+ "src/**/*",
16
+ "!src/**/*.test.*"
17
+ ],
18
+ "sideEffects": false
19
+ }