@kohryan/moodui 0.0.8 → 0.0.10
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/dist/chunk-WRMZ2MC6.mjs +572 -0
- package/dist/cli.d.mts +1 -2
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +600 -24
- package/dist/cli.mjs +583 -7
- package/dist/index.js +1 -0
- package/dist/index.mjs +2 -1
- package/dist/ui/assets/index-BKsInBa3.js +7 -0
- package/dist/ui/assets/index-CMk6XQXy.js +58 -0
- package/dist/ui/index.html +12 -0
- package/package.json +12 -7
- package/src/ui/index.html +12 -0
- package/src/ui/main.tsx +11 -0
- package/src/ui/vite.config.ts +17 -0
package/dist/cli.mjs
CHANGED
|
@@ -1,10 +1,531 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
#!/usr/bin/env node
|
|
1
3
|
import {
|
|
2
4
|
generateReactFromPrompt
|
|
3
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-WRMZ2MC6.mjs";
|
|
4
6
|
|
|
5
7
|
// src/cli.ts
|
|
6
|
-
import
|
|
8
|
+
import fs6 from "fs/promises";
|
|
9
|
+
import path2 from "path";
|
|
10
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
11
|
+
import http from "http";
|
|
12
|
+
|
|
13
|
+
// node_modules/open/index.js
|
|
14
|
+
import process7 from "process";
|
|
15
|
+
import { Buffer } from "buffer";
|
|
7
16
|
import path from "path";
|
|
17
|
+
import { fileURLToPath } from "url";
|
|
18
|
+
import { promisify as promisify5 } from "util";
|
|
19
|
+
import childProcess from "child_process";
|
|
20
|
+
import fs5, { constants as fsConstants2 } from "fs/promises";
|
|
21
|
+
|
|
22
|
+
// node_modules/wsl-utils/index.js
|
|
23
|
+
import process3 from "process";
|
|
24
|
+
import fs4, { constants as fsConstants } from "fs/promises";
|
|
25
|
+
|
|
26
|
+
// node_modules/is-wsl/index.js
|
|
27
|
+
import process2 from "process";
|
|
28
|
+
import os from "os";
|
|
29
|
+
import fs3 from "fs";
|
|
30
|
+
|
|
31
|
+
// node_modules/is-inside-container/index.js
|
|
32
|
+
import fs2 from "fs";
|
|
33
|
+
|
|
34
|
+
// node_modules/is-docker/index.js
|
|
35
|
+
import fs from "fs";
|
|
36
|
+
var isDockerCached;
|
|
37
|
+
function hasDockerEnv() {
|
|
38
|
+
try {
|
|
39
|
+
fs.statSync("/.dockerenv");
|
|
40
|
+
return true;
|
|
41
|
+
} catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function hasDockerCGroup() {
|
|
46
|
+
try {
|
|
47
|
+
return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
48
|
+
} catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function isDocker() {
|
|
53
|
+
if (isDockerCached === void 0) {
|
|
54
|
+
isDockerCached = hasDockerEnv() || hasDockerCGroup();
|
|
55
|
+
}
|
|
56
|
+
return isDockerCached;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// node_modules/is-inside-container/index.js
|
|
60
|
+
var cachedResult;
|
|
61
|
+
var hasContainerEnv = () => {
|
|
62
|
+
try {
|
|
63
|
+
fs2.statSync("/run/.containerenv");
|
|
64
|
+
return true;
|
|
65
|
+
} catch {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
function isInsideContainer() {
|
|
70
|
+
if (cachedResult === void 0) {
|
|
71
|
+
cachedResult = hasContainerEnv() || isDocker();
|
|
72
|
+
}
|
|
73
|
+
return cachedResult;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// node_modules/is-wsl/index.js
|
|
77
|
+
var isWsl = () => {
|
|
78
|
+
if (process2.platform !== "linux") {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (os.release().toLowerCase().includes("microsoft")) {
|
|
82
|
+
if (isInsideContainer()) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
if (fs3.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft")) {
|
|
89
|
+
return !isInsideContainer();
|
|
90
|
+
}
|
|
91
|
+
} catch {
|
|
92
|
+
}
|
|
93
|
+
if (fs3.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop") || fs3.existsSync("/run/WSL")) {
|
|
94
|
+
return !isInsideContainer();
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
};
|
|
98
|
+
var is_wsl_default = process2.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
99
|
+
|
|
100
|
+
// node_modules/wsl-utils/index.js
|
|
101
|
+
var wslDrivesMountPoint = /* @__PURE__ */ (() => {
|
|
102
|
+
const defaultMountPoint = "/mnt/";
|
|
103
|
+
let mountPoint;
|
|
104
|
+
return async function() {
|
|
105
|
+
if (mountPoint) {
|
|
106
|
+
return mountPoint;
|
|
107
|
+
}
|
|
108
|
+
const configFilePath = "/etc/wsl.conf";
|
|
109
|
+
let isConfigFileExists = false;
|
|
110
|
+
try {
|
|
111
|
+
await fs4.access(configFilePath, fsConstants.F_OK);
|
|
112
|
+
isConfigFileExists = true;
|
|
113
|
+
} catch {
|
|
114
|
+
}
|
|
115
|
+
if (!isConfigFileExists) {
|
|
116
|
+
return defaultMountPoint;
|
|
117
|
+
}
|
|
118
|
+
const configContent = await fs4.readFile(configFilePath, { encoding: "utf8" });
|
|
119
|
+
const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
|
|
120
|
+
if (!configMountPoint) {
|
|
121
|
+
return defaultMountPoint;
|
|
122
|
+
}
|
|
123
|
+
mountPoint = configMountPoint.groups.mountPoint.trim();
|
|
124
|
+
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
|
|
125
|
+
return mountPoint;
|
|
126
|
+
};
|
|
127
|
+
})();
|
|
128
|
+
var powerShellPathFromWsl = async () => {
|
|
129
|
+
const mountPoint = await wslDrivesMountPoint();
|
|
130
|
+
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
131
|
+
};
|
|
132
|
+
var powerShellPath = async () => {
|
|
133
|
+
if (is_wsl_default) {
|
|
134
|
+
return powerShellPathFromWsl();
|
|
135
|
+
}
|
|
136
|
+
return `${process3.env.SYSTEMROOT || process3.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// node_modules/define-lazy-prop/index.js
|
|
140
|
+
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
141
|
+
const define = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
|
|
142
|
+
Object.defineProperty(object, propertyName, {
|
|
143
|
+
configurable: true,
|
|
144
|
+
enumerable: true,
|
|
145
|
+
get() {
|
|
146
|
+
const result = valueGetter();
|
|
147
|
+
define(result);
|
|
148
|
+
return result;
|
|
149
|
+
},
|
|
150
|
+
set(value) {
|
|
151
|
+
define(value);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
return object;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// node_modules/default-browser/index.js
|
|
158
|
+
import { promisify as promisify4 } from "util";
|
|
159
|
+
import process6 from "process";
|
|
160
|
+
import { execFile as execFile4 } from "child_process";
|
|
161
|
+
|
|
162
|
+
// node_modules/default-browser-id/index.js
|
|
163
|
+
import { promisify } from "util";
|
|
164
|
+
import process4 from "process";
|
|
165
|
+
import { execFile } from "child_process";
|
|
166
|
+
var execFileAsync = promisify(execFile);
|
|
167
|
+
async function defaultBrowserId() {
|
|
168
|
+
if (process4.platform !== "darwin") {
|
|
169
|
+
throw new Error("macOS only");
|
|
170
|
+
}
|
|
171
|
+
const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
|
|
172
|
+
const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
173
|
+
const browserId = match?.groups.id ?? "com.apple.Safari";
|
|
174
|
+
if (browserId === "com.apple.safari") {
|
|
175
|
+
return "com.apple.Safari";
|
|
176
|
+
}
|
|
177
|
+
return browserId;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// node_modules/run-applescript/index.js
|
|
181
|
+
import process5 from "process";
|
|
182
|
+
import { promisify as promisify2 } from "util";
|
|
183
|
+
import { execFile as execFile2, execFileSync } from "child_process";
|
|
184
|
+
var execFileAsync2 = promisify2(execFile2);
|
|
185
|
+
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
186
|
+
if (process5.platform !== "darwin") {
|
|
187
|
+
throw new Error("macOS only");
|
|
188
|
+
}
|
|
189
|
+
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
190
|
+
const execOptions = {};
|
|
191
|
+
if (signal) {
|
|
192
|
+
execOptions.signal = signal;
|
|
193
|
+
}
|
|
194
|
+
const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
|
|
195
|
+
return stdout.trim();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// node_modules/bundle-name/index.js
|
|
199
|
+
async function bundleName(bundleId) {
|
|
200
|
+
return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
|
|
201
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// node_modules/default-browser/windows.js
|
|
205
|
+
import { promisify as promisify3 } from "util";
|
|
206
|
+
import { execFile as execFile3 } from "child_process";
|
|
207
|
+
var execFileAsync3 = promisify3(execFile3);
|
|
208
|
+
var windowsBrowserProgIds = {
|
|
209
|
+
MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
|
|
210
|
+
// The missing `L` is correct.
|
|
211
|
+
MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
|
|
212
|
+
MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
|
|
213
|
+
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
|
|
214
|
+
ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
|
|
215
|
+
ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
|
|
216
|
+
ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
|
|
217
|
+
ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
|
|
218
|
+
BraveHTML: { name: "Brave", id: "com.brave.Browser" },
|
|
219
|
+
BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
|
|
220
|
+
BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
|
|
221
|
+
BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
|
|
222
|
+
FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
|
|
223
|
+
OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
|
|
224
|
+
VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
|
|
225
|
+
"IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
|
|
226
|
+
};
|
|
227
|
+
var _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
228
|
+
var UnknownBrowserError = class extends Error {
|
|
229
|
+
};
|
|
230
|
+
async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
231
|
+
const { stdout } = await _execFileAsync("reg", [
|
|
232
|
+
"QUERY",
|
|
233
|
+
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
234
|
+
"/v",
|
|
235
|
+
"ProgId"
|
|
236
|
+
]);
|
|
237
|
+
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
238
|
+
if (!match) {
|
|
239
|
+
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
240
|
+
}
|
|
241
|
+
const { id } = match.groups;
|
|
242
|
+
const dotIndex = id.lastIndexOf(".");
|
|
243
|
+
const hyphenIndex = id.lastIndexOf("-");
|
|
244
|
+
const baseIdByDot = dotIndex === -1 ? void 0 : id.slice(0, dotIndex);
|
|
245
|
+
const baseIdByHyphen = hyphenIndex === -1 ? void 0 : id.slice(0, hyphenIndex);
|
|
246
|
+
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// node_modules/default-browser/index.js
|
|
250
|
+
var execFileAsync4 = promisify4(execFile4);
|
|
251
|
+
var titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
|
|
252
|
+
async function defaultBrowser2() {
|
|
253
|
+
if (process6.platform === "darwin") {
|
|
254
|
+
const id = await defaultBrowserId();
|
|
255
|
+
const name = await bundleName(id);
|
|
256
|
+
return { name, id };
|
|
257
|
+
}
|
|
258
|
+
if (process6.platform === "linux") {
|
|
259
|
+
const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
|
|
260
|
+
const id = stdout.trim();
|
|
261
|
+
const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
|
|
262
|
+
return { name, id };
|
|
263
|
+
}
|
|
264
|
+
if (process6.platform === "win32") {
|
|
265
|
+
return defaultBrowser();
|
|
266
|
+
}
|
|
267
|
+
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// node_modules/open/index.js
|
|
271
|
+
var execFile5 = promisify5(childProcess.execFile);
|
|
272
|
+
var __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
273
|
+
var localXdgOpenPath = path.join(__dirname, "xdg-open");
|
|
274
|
+
var { platform, arch } = process7;
|
|
275
|
+
async function getWindowsDefaultBrowserFromWsl() {
|
|
276
|
+
const powershellPath = await powerShellPath();
|
|
277
|
+
const rawCommand = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
278
|
+
const encodedCommand = Buffer.from(rawCommand, "utf16le").toString("base64");
|
|
279
|
+
const { stdout } = await execFile5(
|
|
280
|
+
powershellPath,
|
|
281
|
+
[
|
|
282
|
+
"-NoProfile",
|
|
283
|
+
"-NonInteractive",
|
|
284
|
+
"-ExecutionPolicy",
|
|
285
|
+
"Bypass",
|
|
286
|
+
"-EncodedCommand",
|
|
287
|
+
encodedCommand
|
|
288
|
+
],
|
|
289
|
+
{ encoding: "utf8" }
|
|
290
|
+
);
|
|
291
|
+
const progId = stdout.trim();
|
|
292
|
+
const browserMap = {
|
|
293
|
+
ChromeHTML: "com.google.chrome",
|
|
294
|
+
BraveHTML: "com.brave.Browser",
|
|
295
|
+
MSEdgeHTM: "com.microsoft.edge",
|
|
296
|
+
FirefoxURL: "org.mozilla.firefox"
|
|
297
|
+
};
|
|
298
|
+
return browserMap[progId] ? { id: browserMap[progId] } : {};
|
|
299
|
+
}
|
|
300
|
+
var pTryEach = async (array, mapper) => {
|
|
301
|
+
let latestError;
|
|
302
|
+
for (const item of array) {
|
|
303
|
+
try {
|
|
304
|
+
return await mapper(item);
|
|
305
|
+
} catch (error) {
|
|
306
|
+
latestError = error;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
throw latestError;
|
|
310
|
+
};
|
|
311
|
+
var baseOpen = async (options) => {
|
|
312
|
+
options = {
|
|
313
|
+
wait: false,
|
|
314
|
+
background: false,
|
|
315
|
+
newInstance: false,
|
|
316
|
+
allowNonzeroExitCode: false,
|
|
317
|
+
...options
|
|
318
|
+
};
|
|
319
|
+
if (Array.isArray(options.app)) {
|
|
320
|
+
return pTryEach(options.app, (singleApp) => baseOpen({
|
|
321
|
+
...options,
|
|
322
|
+
app: singleApp
|
|
323
|
+
}));
|
|
324
|
+
}
|
|
325
|
+
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
326
|
+
appArguments = [...appArguments];
|
|
327
|
+
if (Array.isArray(app)) {
|
|
328
|
+
return pTryEach(app, (appName) => baseOpen({
|
|
329
|
+
...options,
|
|
330
|
+
app: {
|
|
331
|
+
name: appName,
|
|
332
|
+
arguments: appArguments
|
|
333
|
+
}
|
|
334
|
+
}));
|
|
335
|
+
}
|
|
336
|
+
if (app === "browser" || app === "browserPrivate") {
|
|
337
|
+
const ids = {
|
|
338
|
+
"com.google.chrome": "chrome",
|
|
339
|
+
"google-chrome.desktop": "chrome",
|
|
340
|
+
"com.brave.Browser": "brave",
|
|
341
|
+
"org.mozilla.firefox": "firefox",
|
|
342
|
+
"firefox.desktop": "firefox",
|
|
343
|
+
"com.microsoft.msedge": "edge",
|
|
344
|
+
"com.microsoft.edge": "edge",
|
|
345
|
+
"com.microsoft.edgemac": "edge",
|
|
346
|
+
"microsoft-edge.desktop": "edge"
|
|
347
|
+
};
|
|
348
|
+
const flags = {
|
|
349
|
+
chrome: "--incognito",
|
|
350
|
+
brave: "--incognito",
|
|
351
|
+
firefox: "--private-window",
|
|
352
|
+
edge: "--inPrivate"
|
|
353
|
+
};
|
|
354
|
+
const browser = is_wsl_default ? await getWindowsDefaultBrowserFromWsl() : await defaultBrowser2();
|
|
355
|
+
if (browser.id in ids) {
|
|
356
|
+
const browserName = ids[browser.id];
|
|
357
|
+
if (app === "browserPrivate") {
|
|
358
|
+
appArguments.push(flags[browserName]);
|
|
359
|
+
}
|
|
360
|
+
return baseOpen({
|
|
361
|
+
...options,
|
|
362
|
+
app: {
|
|
363
|
+
name: apps[browserName],
|
|
364
|
+
arguments: appArguments
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
throw new Error(`${browser.name} is not supported as a default browser`);
|
|
369
|
+
}
|
|
370
|
+
let command;
|
|
371
|
+
const cliArguments = [];
|
|
372
|
+
const childProcessOptions = {};
|
|
373
|
+
if (platform === "darwin") {
|
|
374
|
+
command = "open";
|
|
375
|
+
if (options.wait) {
|
|
376
|
+
cliArguments.push("--wait-apps");
|
|
377
|
+
}
|
|
378
|
+
if (options.background) {
|
|
379
|
+
cliArguments.push("--background");
|
|
380
|
+
}
|
|
381
|
+
if (options.newInstance) {
|
|
382
|
+
cliArguments.push("--new");
|
|
383
|
+
}
|
|
384
|
+
if (app) {
|
|
385
|
+
cliArguments.push("-a", app);
|
|
386
|
+
}
|
|
387
|
+
} else if (platform === "win32" || is_wsl_default && !isInsideContainer() && !app) {
|
|
388
|
+
command = await powerShellPath();
|
|
389
|
+
cliArguments.push(
|
|
390
|
+
"-NoProfile",
|
|
391
|
+
"-NonInteractive",
|
|
392
|
+
"-ExecutionPolicy",
|
|
393
|
+
"Bypass",
|
|
394
|
+
"-EncodedCommand"
|
|
395
|
+
);
|
|
396
|
+
if (!is_wsl_default) {
|
|
397
|
+
childProcessOptions.windowsVerbatimArguments = true;
|
|
398
|
+
}
|
|
399
|
+
const encodedArguments = ["Start"];
|
|
400
|
+
if (options.wait) {
|
|
401
|
+
encodedArguments.push("-Wait");
|
|
402
|
+
}
|
|
403
|
+
if (app) {
|
|
404
|
+
encodedArguments.push(`"\`"${app}\`""`);
|
|
405
|
+
if (options.target) {
|
|
406
|
+
appArguments.push(options.target);
|
|
407
|
+
}
|
|
408
|
+
} else if (options.target) {
|
|
409
|
+
encodedArguments.push(`"${options.target}"`);
|
|
410
|
+
}
|
|
411
|
+
if (appArguments.length > 0) {
|
|
412
|
+
appArguments = appArguments.map((argument) => `"\`"${argument}\`""`);
|
|
413
|
+
encodedArguments.push("-ArgumentList", appArguments.join(","));
|
|
414
|
+
}
|
|
415
|
+
options.target = Buffer.from(encodedArguments.join(" "), "utf16le").toString("base64");
|
|
416
|
+
} else {
|
|
417
|
+
if (app) {
|
|
418
|
+
command = app;
|
|
419
|
+
} else {
|
|
420
|
+
const isBundled = !__dirname || __dirname === "/";
|
|
421
|
+
let exeLocalXdgOpen = false;
|
|
422
|
+
try {
|
|
423
|
+
await fs5.access(localXdgOpenPath, fsConstants2.X_OK);
|
|
424
|
+
exeLocalXdgOpen = true;
|
|
425
|
+
} catch {
|
|
426
|
+
}
|
|
427
|
+
const useSystemXdgOpen = process7.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
|
|
428
|
+
command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
|
|
429
|
+
}
|
|
430
|
+
if (appArguments.length > 0) {
|
|
431
|
+
cliArguments.push(...appArguments);
|
|
432
|
+
}
|
|
433
|
+
if (!options.wait) {
|
|
434
|
+
childProcessOptions.stdio = "ignore";
|
|
435
|
+
childProcessOptions.detached = true;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
if (platform === "darwin" && appArguments.length > 0) {
|
|
439
|
+
cliArguments.push("--args", ...appArguments);
|
|
440
|
+
}
|
|
441
|
+
if (options.target) {
|
|
442
|
+
cliArguments.push(options.target);
|
|
443
|
+
}
|
|
444
|
+
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
445
|
+
if (options.wait) {
|
|
446
|
+
return new Promise((resolve, reject) => {
|
|
447
|
+
subprocess.once("error", reject);
|
|
448
|
+
subprocess.once("close", (exitCode) => {
|
|
449
|
+
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
|
450
|
+
reject(new Error(`Exited with code ${exitCode}`));
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
resolve(subprocess);
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
subprocess.unref();
|
|
458
|
+
return subprocess;
|
|
459
|
+
};
|
|
460
|
+
var open = (target, options) => {
|
|
461
|
+
if (typeof target !== "string") {
|
|
462
|
+
throw new TypeError("Expected a `target`");
|
|
463
|
+
}
|
|
464
|
+
return baseOpen({
|
|
465
|
+
...options,
|
|
466
|
+
target
|
|
467
|
+
});
|
|
468
|
+
};
|
|
469
|
+
function detectArchBinary(binary) {
|
|
470
|
+
if (typeof binary === "string" || Array.isArray(binary)) {
|
|
471
|
+
return binary;
|
|
472
|
+
}
|
|
473
|
+
const { [arch]: archBinary } = binary;
|
|
474
|
+
if (!archBinary) {
|
|
475
|
+
throw new Error(`${arch} is not supported`);
|
|
476
|
+
}
|
|
477
|
+
return archBinary;
|
|
478
|
+
}
|
|
479
|
+
function detectPlatformBinary({ [platform]: platformBinary }, { wsl }) {
|
|
480
|
+
if (wsl && is_wsl_default) {
|
|
481
|
+
return detectArchBinary(wsl);
|
|
482
|
+
}
|
|
483
|
+
if (!platformBinary) {
|
|
484
|
+
throw new Error(`${platform} is not supported`);
|
|
485
|
+
}
|
|
486
|
+
return detectArchBinary(platformBinary);
|
|
487
|
+
}
|
|
488
|
+
var apps = {};
|
|
489
|
+
defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
|
|
490
|
+
darwin: "google chrome",
|
|
491
|
+
win32: "chrome",
|
|
492
|
+
linux: ["google-chrome", "google-chrome-stable", "chromium"]
|
|
493
|
+
}, {
|
|
494
|
+
wsl: {
|
|
495
|
+
ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
|
|
496
|
+
x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
|
|
497
|
+
}
|
|
498
|
+
}));
|
|
499
|
+
defineLazyProperty(apps, "brave", () => detectPlatformBinary({
|
|
500
|
+
darwin: "brave browser",
|
|
501
|
+
win32: "brave",
|
|
502
|
+
linux: ["brave-browser", "brave"]
|
|
503
|
+
}, {
|
|
504
|
+
wsl: {
|
|
505
|
+
ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
|
|
506
|
+
x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
|
|
507
|
+
}
|
|
508
|
+
}));
|
|
509
|
+
defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
|
|
510
|
+
darwin: "firefox",
|
|
511
|
+
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
512
|
+
linux: "firefox"
|
|
513
|
+
}, {
|
|
514
|
+
wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
|
|
515
|
+
}));
|
|
516
|
+
defineLazyProperty(apps, "edge", () => detectPlatformBinary({
|
|
517
|
+
darwin: "microsoft edge",
|
|
518
|
+
win32: "msedge",
|
|
519
|
+
linux: ["microsoft-edge", "microsoft-edge-dev"]
|
|
520
|
+
}, {
|
|
521
|
+
wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
|
|
522
|
+
}));
|
|
523
|
+
defineLazyProperty(apps, "browser", () => "browser");
|
|
524
|
+
defineLazyProperty(apps, "browserPrivate", () => "browserPrivate");
|
|
525
|
+
var open_default = open;
|
|
526
|
+
|
|
527
|
+
// src/cli.ts
|
|
528
|
+
var __dirname2 = path2.dirname(fileURLToPath2(import.meta.url));
|
|
8
529
|
async function main() {
|
|
9
530
|
const argv = process.argv.slice(2);
|
|
10
531
|
const command = argv[0] ?? "help";
|
|
@@ -12,6 +533,10 @@ async function main() {
|
|
|
12
533
|
printHelp();
|
|
13
534
|
return;
|
|
14
535
|
}
|
|
536
|
+
if (command === "ui") {
|
|
537
|
+
await runUI();
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
15
540
|
if (command !== "generate") {
|
|
16
541
|
console.error(`Unknown command: ${command}`);
|
|
17
542
|
printHelp();
|
|
@@ -74,17 +599,65 @@ async function main() {
|
|
|
74
599
|
temperature,
|
|
75
600
|
maxAttempts
|
|
76
601
|
});
|
|
77
|
-
const resolvedOut =
|
|
78
|
-
await
|
|
79
|
-
await
|
|
602
|
+
const resolvedOut = path2.resolve(process.cwd(), outFile);
|
|
603
|
+
await fs6.mkdir(path2.dirname(resolvedOut), { recursive: true });
|
|
604
|
+
await fs6.writeFile(resolvedOut, result.code, "utf8");
|
|
80
605
|
console.log(`OK: wrote ${resolvedOut}`);
|
|
81
606
|
}
|
|
607
|
+
async function runUI() {
|
|
608
|
+
let uiDir = path2.join(__dirname2, "ui");
|
|
609
|
+
try {
|
|
610
|
+
await fs6.access(uiDir);
|
|
611
|
+
} catch {
|
|
612
|
+
uiDir = path2.join(__dirname2, "..", "dist", "ui");
|
|
613
|
+
}
|
|
614
|
+
const PORT = 3e3;
|
|
615
|
+
console.log(`Starting MoodUI UI...`);
|
|
616
|
+
const server = http.createServer(async (req, res) => {
|
|
617
|
+
let filePath = path2.join(uiDir, req.url === "/" ? "index.html" : req.url);
|
|
618
|
+
const extname = String(path2.extname(filePath)).toLowerCase();
|
|
619
|
+
const mimeTypes = {
|
|
620
|
+
".html": "text/html",
|
|
621
|
+
".js": "text/javascript",
|
|
622
|
+
".css": "text/css",
|
|
623
|
+
".json": "application/json",
|
|
624
|
+
".png": "image/png",
|
|
625
|
+
".jpg": "image/jpg",
|
|
626
|
+
".gif": "image/gif",
|
|
627
|
+
".svg": "image/svg+xml",
|
|
628
|
+
".ico": "image/x-icon"
|
|
629
|
+
};
|
|
630
|
+
const contentType = mimeTypes[extname] || "application/octet-stream";
|
|
631
|
+
try {
|
|
632
|
+
const content = await fs6.readFile(filePath);
|
|
633
|
+
res.writeHead(200, { "Content-Type": contentType });
|
|
634
|
+
res.end(content, "utf-8");
|
|
635
|
+
} catch (err) {
|
|
636
|
+
res.writeHead(404);
|
|
637
|
+
res.end("Not Found", "utf-8");
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
server.listen(PORT, () => {
|
|
641
|
+
const url = `http://localhost:${PORT}`;
|
|
642
|
+
console.log(`MoodUI UI running at ${url}`);
|
|
643
|
+
open_default(url);
|
|
644
|
+
});
|
|
645
|
+
process.on("SIGINT", () => {
|
|
646
|
+
server.close();
|
|
647
|
+
process.exit(0);
|
|
648
|
+
});
|
|
649
|
+
}
|
|
82
650
|
function printHelp() {
|
|
83
651
|
console.log(
|
|
84
652
|
[
|
|
85
|
-
"moodui
|
|
653
|
+
"moodui <command>",
|
|
654
|
+
"",
|
|
655
|
+
"Commands:",
|
|
656
|
+
" generate [options] <prompt...> Generate component via CLI",
|
|
657
|
+
" ui Launch Web UI for generating components",
|
|
658
|
+
" help, --help, -h Show this help message",
|
|
86
659
|
"",
|
|
87
|
-
"Options:",
|
|
660
|
+
"Generate Options:",
|
|
88
661
|
" --provider gemini|ollama|openai-compatible default: gemini",
|
|
89
662
|
" --model <name> required (default for gemini: gemini-3-flash-preview)",
|
|
90
663
|
" --out <path> path lengkap ke file output (termasuk direktori), default: src/generated/MoodScreen.tsx",
|
|
@@ -100,6 +673,9 @@ function printHelp() {
|
|
|
100
673
|
" OPENAI_COMPATIBLE_API_KEY",
|
|
101
674
|
"",
|
|
102
675
|
"Examples:",
|
|
676
|
+
" # Launch Web UI",
|
|
677
|
+
" npx @kohryan/moodui ui",
|
|
678
|
+
"",
|
|
103
679
|
" # Generate ke src/generated/MoodScreen.tsx (default)",
|
|
104
680
|
' GEMINI_API_KEY=... npx @kohryan/moodui generate --model gemini-3-flash-preview "Buat UI login sederhana"',
|
|
105
681
|
"",
|
package/dist/index.js
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
import {
|
|
2
3
|
assertMoodUISpec,
|
|
3
4
|
createGeminiClient,
|
|
@@ -8,7 +9,7 @@ import {
|
|
|
8
9
|
renderReact,
|
|
9
10
|
renderReactJSX,
|
|
10
11
|
validateMoodUISpec
|
|
11
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-WRMZ2MC6.mjs";
|
|
12
13
|
|
|
13
14
|
// src/react/MoodUIRuntime.tsx
|
|
14
15
|
import * as React from "react";
|