jsmdcui 0.9.0 → 0.11.1
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/CHANGELOG.md +119 -0
- package/README.md +104 -0
- package/package.json +7 -5
- package/runmd.mjs +71 -18
- package/runtime/help/help.md +104 -0
- package/runtime/jsplugins/example/example.js +3 -1
- package/single-exe/README.md +102 -0
- package/single-exe/README.md-rpc.js +623 -0
- package/single-exe/README.md-server.js +127 -0
- package/single-exe/README.md.back.js +2 -0
- package/single-exe/README.md.front.js +27 -0
- package/single-exe/README.md.html +325 -0
- package/single-exe/compiled.js +57 -3
- package/src/index.js +381 -76
- package/src/plugins/js-bridge.js +5 -0
- package/tests/cat-markdown.test.js +59 -0
- package/tests/compiled-runtime.test.js +68 -1
- package/tests/demo.test.js +177 -3
- package/tests/js-plugin-prompts.test.js +30 -0
- package/tests/wui-responsive-images.test.js +21 -2
- package/tests/wui.test.js +31 -0
package/single-exe/README.md
CHANGED
|
@@ -31,6 +31,67 @@ executable to the current directory. To pass a Bun compilation target, use:
|
|
|
31
31
|
bun ./src/index.js --build-for <target>
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
Any additional arguments after `--build-exe`, or after the target passed to
|
|
35
|
+
`--build-for`, are forwarded to the `bun build` command:
|
|
36
|
+
|
|
37
|
+
```shell
|
|
38
|
+
bun ./src/index.js --build-exe --sourcemap
|
|
39
|
+
bun ./src/index.js --build-for <target> --sourcemap
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Bun expects `--define` values to be JSON-style literals, so strings normally
|
|
43
|
+
need quotes. `stringifyNonPrimitiveDefineValues()` converts a bare value with
|
|
44
|
+
`JSON.stringify()` before it reaches Bun. jsmdcui uses it for
|
|
45
|
+
`global.MDCUI_MAIN`.
|
|
46
|
+
|
|
47
|
+
The switch defines below are presence-based: `=0` and `=false` still enable
|
|
48
|
+
them. Omit a switch define to disable it; examples consistently use `=1`.
|
|
49
|
+
|
|
50
|
+
- `MDCUI_DEFAULT_EDIT=1`: editable-text default.
|
|
51
|
+
- `MDCUI_DEFAULT_DEMO=1`: no-argument `testapp.md` TUI.
|
|
52
|
+
- `MDCUI_DEFAULT_DEMO_WUI=1`: no-argument `testapp.md` WUI.
|
|
53
|
+
- `MDCUI_OVERWRITE_DEMO=1`: overwrite modifier; it does not select a demo.
|
|
54
|
+
- `global.MDCUI_MAIN=<path>.md`: embed a custom Markdown app and its generated
|
|
55
|
+
front, RPC, back, HTML, and server modules.
|
|
56
|
+
- `global.MDCUI_MAIN_BASE`: generated internally from `MDCUI_MAIN`; do not pass
|
|
57
|
+
it manually.
|
|
58
|
+
|
|
59
|
+
Put defines after `--build-exe` (or after the `--build-for` target), and choose
|
|
60
|
+
at most one `MDCUI_DEFAULT_*` mode.
|
|
61
|
+
|
|
62
|
+
| Build defines | No-argument launch | Switch UI |
|
|
63
|
+
| --- | --- | --- |
|
|
64
|
+
| `MDCUI_DEFAULT_EDIT=1` | text editor | `./mdcui --tui app.md` |
|
|
65
|
+
| `MDCUI_DEFAULT_DEMO=1` | `testapp.md` TUI | `./mdcui --wui --demo` |
|
|
66
|
+
| `MDCUI_DEFAULT_DEMO_WUI=1` | `testapp.md` WUI | `./mdcui --tui --demo` |
|
|
67
|
+
| `global.MDCUI_MAIN=../中文工具.md` | custom TUI | `./mdcui --wui --demo-中文工具` |
|
|
68
|
+
| MAIN plus `MDCUI_DEFAULT_DEMO_WUI=1` | custom WUI | `./mdcui --tui --demo-中文工具` |
|
|
69
|
+
|
|
70
|
+
For a custom TUI-default executable:
|
|
71
|
+
|
|
72
|
+
```shell
|
|
73
|
+
bun ./src/index.js --build-exe \
|
|
74
|
+
--define global.MDCUI_MAIN=../中文工具.md
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
For a custom WUI-default executable:
|
|
78
|
+
|
|
79
|
+
```shell
|
|
80
|
+
bun ./src/index.js --build-exe \
|
|
81
|
+
--define global.MDCUI_MAIN=../中文工具.md \
|
|
82
|
+
--define MDCUI_DEFAULT_DEMO_WUI=1
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Explicit runtime arguments suppress automatic demo/WUI selection, so switching
|
|
86
|
+
UI must repeat `--demo` or `--demo-中文工具`. The main basename must end in
|
|
87
|
+
lowercase `.md`; its demo name allows Unicode letters/numbers (including
|
|
88
|
+
Chinese), dots, underscores, and hyphens, but no whitespace.
|
|
89
|
+
|
|
90
|
+
The custom demo uses embedded TUI front/RPC or the embedded WUI server when its
|
|
91
|
+
local Markdown byte length matches the embedded asset. Missing or overwritten
|
|
92
|
+
demos use embedded modules after the asset is written. A differing byte length
|
|
93
|
+
warns and selects filesystem companion modules.
|
|
94
|
+
|
|
34
95
|
To perform the same steps manually, run these commands from `single-exe/`:
|
|
35
96
|
|
|
36
97
|
```shell
|
|
@@ -176,6 +237,47 @@ bun ./packAssets.sh
|
|
|
176
237
|
bun build --format=esm --compile --minify --bytecode ./entry.mjs --outfile=my-bin
|
|
177
238
|
```
|
|
178
239
|
|
|
240
|
+
#### Passing --define to bun build
|
|
241
|
+
|
|
242
|
+
`buildEarlyExit()` forwards build arguments to Bun, whose define parser expects
|
|
243
|
+
strings to be quoted literals. To accept a bare value such as a path, call the below
|
|
244
|
+
helper to normalize it before `buildEarlyExit()`:
|
|
245
|
+
|
|
246
|
+
```js
|
|
247
|
+
import {
|
|
248
|
+
buildEarlyExit,
|
|
249
|
+
stringifyNonPrimitiveDefineValues,
|
|
250
|
+
} from "../single-exe/compiled.js";
|
|
251
|
+
|
|
252
|
+
stringifyNonPrimitiveDefineValues(process.argv, "MY_STRING_DEFINE");
|
|
253
|
+
await buildEarlyExit(process.argv, "my-bin");
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
```shell
|
|
257
|
+
# Wrong: Bun parses the define before the helper runs.
|
|
258
|
+
bun --define MY_STRING_DEFINE=../app.md ./src/index.js --build-exe
|
|
259
|
+
|
|
260
|
+
# Correct
|
|
261
|
+
bun ./src/index.js --build-exe --define MY_STRING_DEFINE=../app.md
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Before normalization:
|
|
265
|
+
|
|
266
|
+
```js
|
|
267
|
+
["--define", "MY_STRING_DEFINE=../app.md"]
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
After normalization:
|
|
271
|
+
|
|
272
|
+
```js
|
|
273
|
+
["--define", 'MY_STRING_DEFINE="../app.md"']
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
The inline form works too:
|
|
277
|
+
`--define=MY_STRING_DEFINE=../app.md` becomes
|
|
278
|
+
`--define=MY_STRING_DEFINE="../app.md"`.
|
|
279
|
+
|
|
280
|
+
|
|
179
281
|
### 6. Verify both execution paths
|
|
180
282
|
|
|
181
283
|
Verify the compiled asset archive and then run the program normally:
|