mono-jsx-dom 0.1.2 → 0.1.3

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 CHANGED
@@ -16,12 +16,6 @@
16
16
 
17
17
  Playground: https://val.town/x/ije/mono-jsx-dom
18
18
 
19
- ## Installation
20
-
21
- ```bash
22
- npm install mono-jsx-dom
23
- ```
24
-
25
19
  ## Getting Started
26
20
 
27
21
  You can run the `mono-jsx-dom int` command to initialize a project with mono-jsx-dom boilerplate.
package/bin/build.mjs CHANGED
@@ -5,7 +5,7 @@ import { lstat, readFile, writeFile } from "node:fs/promises";
5
5
  import * as esbuild from "esbuild";
6
6
 
7
7
  // bin/utils.ts
8
- import { argv, stdin, stdout } from "node:process";
8
+ import { argv, exit, stdin, stdout } from "node:process";
9
9
  import { access, mkdir } from "node:fs/promises";
10
10
  import { createInterface } from "node:readline/promises";
11
11
  function parseFlags() {
package/bin/dev.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  // bin/dev.ts
2
- import { cwd, env, exit, versions } from "node:process";
2
+ import { cwd, env, exit as exit2, versions } from "node:process";
3
3
  import { join, relative } from "node:path";
4
4
  import { spawn } from "node:child_process";
5
5
 
6
6
  // bin/utils.ts
7
- import { argv, stdin, stdout } from "node:process";
7
+ import { argv, exit, stdin, stdout } from "node:process";
8
8
  import { access, mkdir } from "node:fs/promises";
9
9
  import { createInterface } from "node:readline/promises";
10
10
  function parseFlags() {
@@ -178,10 +178,10 @@ async function dev(options) {
178
178
  ac.abort();
179
179
  };
180
180
  if (!isBun) {
181
- const [major, minor] = versions.node.slice(1).split(".").map(Number);
181
+ const [major, minor] = versions.node.split(".").map(Number);
182
182
  if (major < 22 || major === 22 && minor < 18) {
183
183
  console.error("Node.js version 22.18.0 or higher is required to use the dev command.");
184
- exit(1);
184
+ exit2(1);
185
185
  }
186
186
  }
187
187
  await build({
package/bin/init.mjs CHANGED
@@ -5,14 +5,62 @@ import { dirname, join } from "node:path";
5
5
  import { readFile, writeFile } from "node:fs/promises";
6
6
 
7
7
  // bin/utils.ts
8
- import { argv, stdin, stdout } from "node:process";
8
+ import { argv, exit, stdin, stdout } from "node:process";
9
9
  import { access, mkdir } from "node:fs/promises";
10
10
  import { createInterface } from "node:readline/promises";
11
+ async function input(prompt, placeholder = "") {
12
+ const rl = createInterface({ input: stdin, output: stdout });
13
+ try {
14
+ const line = await rl.question("\x1B[34m?\x1B[0m " + prompt + ":" + (placeholder ? " \x1B[90m" + placeholder + "\x1B[0m" : ""));
15
+ if (stdout.isTTY) {
16
+ stdout.write(`\x1B[1A\r\x1B[34m?\x1B[0m ${prompt} "\x1B[32m${line.trim()}\x1B[0m"\x1B[K
17
+ `);
18
+ }
19
+ return line.trim() || placeholder;
20
+ } finally {
21
+ rl.close();
22
+ }
23
+ }
11
24
  async function confirm(prompt) {
25
+ const hint = "\x1B[34m?\x1B[0m " + prompt + " \x1B[90m(y/N)\x1B[0m ";
26
+ if (stdin.isTTY) {
27
+ stdout.write(hint);
28
+ const wasRaw = stdin.isRaw;
29
+ stdin.setRawMode(true);
30
+ try {
31
+ const yes = await new Promise((resolve) => {
32
+ stdin.once("data", (buf) => {
33
+ const c = typeof buf === "string" ? buf.charCodeAt(0) : buf[0];
34
+ switch (c) {
35
+ case 3:
36
+ exit(130);
37
+ break;
38
+ case 89:
39
+ // Y
40
+ case 121:
41
+ resolve(true);
42
+ break;
43
+ default:
44
+ resolve(false);
45
+ break;
46
+ }
47
+ });
48
+ });
49
+ if (stdout.isTTY) {
50
+ const answer = yes ? "\x1B[32myes\x1B[0m" : "\x1B[90mno\x1B[0m";
51
+ stdout.write(`\r\x1B[2K\x1B[34m?\x1B[0m ${prompt} ${answer}
52
+ `);
53
+ }
54
+ return yes;
55
+ } finally {
56
+ stdin.setRawMode(wasRaw ?? false);
57
+ }
58
+ }
12
59
  const rl = createInterface({ input: stdin, output: stdout });
13
60
  try {
14
- const line = await rl.question("\x1B[34m?\x1B[0m " + prompt + " \x1B[90m(y/N)\x1B[0m ");
15
- const yes = /^y(es)?$/i.test(line.trim());
61
+ const line = await rl.question(hint);
62
+ const t = line.trim();
63
+ const yes = t === "" || /^y(es)?$/i.test(t);
16
64
  if (stdout.isTTY) {
17
65
  const answer = yes ? "\x1B[32myes\x1B[0m" : "\x1B[90mno\x1B[0m";
18
66
  stdout.write(`\x1B[1A\r\x1B[34m?\x1B[0m ${prompt} ${answer}\x1B[K
@@ -53,9 +101,9 @@ var template = {
53
101
  version: "0.0.0",
54
102
  private: true,
55
103
  scripts: {
56
- dev: "mono-jsx-dom dev",
57
- build: "mono-jsx-dom build",
58
- start: bun ? "mono-jsx-dom build && bun dist/server.mjs" : "mono-jsx-dom build --node && node dist/server.mjs"
104
+ dev: (bun ? "bun --bun" : "") + " mono-jsx-dom dev",
105
+ build: (bun ? "bun --bun" : "") + " mono-jsx-dom build",
106
+ start: bun ? "bun --bun mono-jsx-dom build && bun dist/server.mjs" : "mono-jsx-dom build --node && node dist/server.mjs"
59
107
  }
60
108
  },
61
109
  null,
@@ -109,8 +157,8 @@ export default {
109
157
  }
110
158
  `
111
159
  };
112
- function run() {
113
- const appName = argv2[3] ?? "mono-app";
160
+ async function run() {
161
+ const appName = argv2[3] ?? await input("Enter the name of the app:", "mono-app");
114
162
  return init(appName);
115
163
  }
116
164
  async function init(appName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mono-jsx-dom",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "A JSX runtime for browsers.",
5
5
  "keywords": [
6
6
  "jsx",