@shell-shock/plugin-console 0.0.5 → 0.1.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.
@@ -4,6 +4,7 @@ let __alloy_js_core = require("@alloy-js/core");
4
4
  let __alloy_js_typescript = require("@alloy-js/typescript");
5
5
  let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
6
6
  let __powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
7
+ let __powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
7
8
  let __powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
8
9
  let __powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
9
10
  let __shell_shock_core_components_helpers = require("@shell-shock/core/components/helpers");
@@ -1209,6 +1210,144 @@ function ColorsDeclaration() {
1209
1210
  }
1210
1211
  })}
1211
1212
  }
1213
+ },
1214
+ spinner: {
1215
+ icon: {
1216
+ active: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
1217
+ get ansi16() {
1218
+ return colors.ansi16.theme.text.spinner.icon.active;
1219
+ },
1220
+ get ansi256() {
1221
+ return colors.ansi256.theme.text.spinner.icon.active;
1222
+ },
1223
+ get ansi16m() {
1224
+ return colors.ansi16m.theme.text.spinner.icon.active;
1225
+ }
1226
+ })},
1227
+ warning: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
1228
+ get ansi16() {
1229
+ return colors.ansi16.theme.text.spinner.icon.warning;
1230
+ },
1231
+ get ansi256() {
1232
+ return colors.ansi256.theme.text.spinner.icon.warning;
1233
+ },
1234
+ get ansi16m() {
1235
+ return colors.ansi16m.theme.text.spinner.icon.warning;
1236
+ }
1237
+ })},
1238
+ error: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
1239
+ get ansi16() {
1240
+ return colors.ansi16.theme.text.spinner.icon.error;
1241
+ },
1242
+ get ansi256() {
1243
+ return colors.ansi256.theme.text.spinner.icon.error;
1244
+ },
1245
+ get ansi16m() {
1246
+ return colors.ansi16m.theme.text.spinner.icon.error;
1247
+ }
1248
+ })},
1249
+ success: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
1250
+ get ansi16() {
1251
+ return colors.ansi16.theme.text.spinner.icon.success;
1252
+ },
1253
+ get ansi256() {
1254
+ return colors.ansi256.theme.text.spinner.icon.success;
1255
+ },
1256
+ get ansi16m() {
1257
+ return colors.ansi16m.theme.text.spinner.icon.success;
1258
+ }
1259
+ })},
1260
+ info: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
1261
+ get ansi16() {
1262
+ return colors.ansi16.theme.text.spinner.icon.info;
1263
+ },
1264
+ get ansi256() {
1265
+ return colors.ansi256.theme.text.spinner.icon.info;
1266
+ },
1267
+ get ansi16m() {
1268
+ return colors.ansi16m.theme.text.spinner.icon.info;
1269
+ }
1270
+ })},
1271
+ help: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
1272
+ get ansi16() {
1273
+ return colors.ansi16.theme.text.spinner.icon.help;
1274
+ },
1275
+ get ansi256() {
1276
+ return colors.ansi256.theme.text.spinner.icon.help;
1277
+ },
1278
+ get ansi16m() {
1279
+ return colors.ansi16m.theme.text.spinner.icon.help;
1280
+ }
1281
+ })}
1282
+ },
1283
+ message: {
1284
+ active: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
1285
+ get ansi16() {
1286
+ return colors.ansi16.theme.text.spinner.message.active;
1287
+ },
1288
+ get ansi256() {
1289
+ return colors.ansi256.theme.text.spinner.message.active;
1290
+ },
1291
+ get ansi16m() {
1292
+ return colors.ansi16m.theme.text.spinner.message.active;
1293
+ }
1294
+ })},
1295
+ warning: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
1296
+ get ansi16() {
1297
+ return colors.ansi16.theme.text.spinner.message.warning;
1298
+ },
1299
+ get ansi256() {
1300
+ return colors.ansi256.theme.text.spinner.message.warning;
1301
+ },
1302
+ get ansi16m() {
1303
+ return colors.ansi16m.theme.text.spinner.message.warning;
1304
+ }
1305
+ })},
1306
+ error: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
1307
+ get ansi16() {
1308
+ return colors.ansi16.theme.text.spinner.message.error;
1309
+ },
1310
+ get ansi256() {
1311
+ return colors.ansi256.theme.text.spinner.message.error;
1312
+ },
1313
+ get ansi16m() {
1314
+ return colors.ansi16m.theme.text.spinner.message.error;
1315
+ }
1316
+ })},
1317
+ success: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
1318
+ get ansi16() {
1319
+ return colors.ansi16.theme.text.spinner.message.success;
1320
+ },
1321
+ get ansi256() {
1322
+ return colors.ansi256.theme.text.spinner.message.success;
1323
+ },
1324
+ get ansi16m() {
1325
+ return colors.ansi16m.theme.text.spinner.message.success;
1326
+ }
1327
+ })},
1328
+ info: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
1329
+ get ansi16() {
1330
+ return colors.ansi16.theme.text.spinner.message.info;
1331
+ },
1332
+ get ansi256() {
1333
+ return colors.ansi256.theme.text.spinner.message.info;
1334
+ },
1335
+ get ansi16m() {
1336
+ return colors.ansi16m.theme.text.spinner.message.info;
1337
+ }
1338
+ })},
1339
+ help: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
1340
+ get ansi16() {
1341
+ return colors.ansi16.theme.text.spinner.message.help;
1342
+ },
1343
+ get ansi256() {
1344
+ return colors.ansi256.theme.text.spinner.message.help;
1345
+ },
1346
+ get ansi16m() {
1347
+ return colors.ansi16m.theme.text.spinner.message.help;
1348
+ }
1349
+ })}
1350
+ }
1212
1351
  }
1213
1352
  },
1214
1353
  border: {
@@ -2096,6 +2235,558 @@ function LinkFunctionDeclaration() {
2096
2235
  }
2097
2236
  })];
2098
2237
  }
2238
+ /**
2239
+ * A component to generate the `spinner` function in the `shell-shock:console` builtin module.
2240
+ */
2241
+ function SpinnerFunctionDeclaration() {
2242
+ const theme = (0, __shell_shock_plugin_theme_contexts_theme.useTheme)();
2243
+ return [
2244
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.TypeDeclaration, {
2245
+ name: "WriteStream",
2246
+ children: `NodeJS.WriteStream;`
2247
+ }),
2248
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2249
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
2250
+ "const": true,
2251
+ name: "activeHooksPerStream",
2252
+ initializer: "new Set();"
2253
+ }),
2254
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2255
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceDeclaration, {
2256
+ "export": true,
2257
+ name: "SpinnerOptions",
2258
+ doc: "Options for configuring the spinner.",
2259
+ get children() {
2260
+ return [
2261
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceMember, {
2262
+ name: "message",
2263
+ optional: true,
2264
+ type: "string",
2265
+ doc: "The message text to display next to the spinner. Defaults to an empty string."
2266
+ }),
2267
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2268
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceMember, {
2269
+ name: "stream",
2270
+ optional: true,
2271
+ type: "WriteStream",
2272
+ doc: "The output stream to write the spinner to. Defaults to process.stderr."
2273
+ }),
2274
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2275
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceMember, {
2276
+ name: "spinner",
2277
+ optional: true,
2278
+ type: "ThemeSpinnerResolvedConfig | SpinnerPreset",
2279
+ doc: "The spinner animation to use. Should be an object with a 'frames' property (an array of strings representing each frame of the animation) and an 'interval' property (the time in milliseconds between each frame). If not specified, a default spinner animation will be used."
2280
+ })
2281
+ ];
2282
+ }
2283
+ }),
2284
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2285
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassDeclaration, {
2286
+ name: "Spinner",
2287
+ get children() {
2288
+ return [
2289
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassField, {
2290
+ name: "frames",
2291
+ isPrivateMember: true,
2292
+ type: "string[]"
2293
+ }),
2294
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2295
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassField, {
2296
+ name: "interval",
2297
+ isPrivateMember: true,
2298
+ type: "number"
2299
+ }),
2300
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2301
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassField, {
2302
+ name: "currentFrame",
2303
+ isPrivateMember: true,
2304
+ type: "number",
2305
+ children: __alloy_js_core.code`-1`
2306
+ }),
2307
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2308
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassField, {
2309
+ name: "timer",
2310
+ isPrivateMember: true,
2311
+ optional: true,
2312
+ type: "NodeJS.Timeout"
2313
+ }),
2314
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2315
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassField, {
2316
+ name: "message",
2317
+ isPrivateMember: true,
2318
+ type: "string",
2319
+ children: __alloy_js_core.code`""`
2320
+ }),
2321
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2322
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassField, {
2323
+ name: "stream",
2324
+ isPrivateMember: true,
2325
+ type: "WriteStream",
2326
+ children: __alloy_js_core.code`process.stderr`
2327
+ }),
2328
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2329
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassField, {
2330
+ name: "lines",
2331
+ isPrivateMember: true,
2332
+ type: "number",
2333
+ children: __alloy_js_core.code`0`
2334
+ }),
2335
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2336
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassField, {
2337
+ name: "exitHandlerBound",
2338
+ isPrivateMember: true,
2339
+ type: "(signal: any) => void",
2340
+ children: __alloy_js_core.code`() => {}`
2341
+ }),
2342
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2343
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassField, {
2344
+ name: "lastSpinnerFrameTime",
2345
+ isPrivateMember: true,
2346
+ type: "number",
2347
+ children: __alloy_js_core.code`0`
2348
+ }),
2349
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2350
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassField, {
2351
+ name: "isSpinning",
2352
+ isPrivateMember: true,
2353
+ type: "boolean",
2354
+ children: __alloy_js_core.code`false`
2355
+ }),
2356
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2357
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassField, {
2358
+ name: "hookedStreams",
2359
+ isPrivateMember: true,
2360
+ type: "Map<WriteStream, { write?: WriteStream[\"write\"]; originalWrite: WriteStream[\"write\"]; hookedWrite: WriteStream[\"write\"] }>",
2361
+ children: __alloy_js_core.code`new Map()`
2362
+ }),
2363
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2364
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassField, {
2365
+ name: "isInternalWrite",
2366
+ isPrivateMember: true,
2367
+ type: "boolean",
2368
+ children: __alloy_js_core.code`false`
2369
+ }),
2370
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2371
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassField, {
2372
+ name: "isDeferringRender",
2373
+ isPrivateMember: true,
2374
+ type: "boolean",
2375
+ children: __alloy_js_core.code`false`
2376
+ }),
2377
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2378
+ (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`constructor(options: SpinnerOptions = {}) {
2379
+ const spinner = (typeof options.spinner === "string" ? resolveSpinner(options.spinner as SpinnerPreset) : options.spinner) ?? ${JSON.stringify(theme.spinner)};
2380
+ this.#frames = spinner.frames;
2381
+ this.#interval = spinner.interval;
2382
+
2383
+ if (options.message) {
2384
+ this.#message = options.message;
2385
+ }
2386
+ if (options.stream) {
2387
+ this.#stream = options.stream;
2388
+ }
2389
+
2390
+ this.#exitHandlerBound = this.#exitHandler.bind(this);
2391
+ }
2392
+
2393
+ #internalWrite(action: () => unknown) {
2394
+ this.#isInternalWrite = true;
2395
+ try {
2396
+ return action();
2397
+ } finally {
2398
+ this.#isInternalWrite = false;
2399
+ }
2400
+ }
2401
+
2402
+ #stringifyChunk(chunk: string | Uint8Array<ArrayBufferLike> | ArrayBufferLike) {
2403
+ if (chunk === undefined || chunk === null) {
2404
+ return "";
2405
+ }
2406
+
2407
+ if (typeof chunk === "string") {
2408
+ return chunk;
2409
+ }
2410
+
2411
+ if (Buffer.isBuffer(chunk) || ArrayBuffer.isView(chunk)) {
2412
+ return Buffer.from(chunk).toString("utf8");
2413
+ }
2414
+
2415
+ return String(chunk);
2416
+ }
2417
+
2418
+ #withSynchronizedOutput(action: () => unknown) {
2419
+ if (!isInteractive) {
2420
+ return action();
2421
+ }
2422
+
2423
+ try {
2424
+ this.#write("\\u001B[?2026h");
2425
+ return action();
2426
+ } finally {
2427
+ this.#write("\\u001B[?2026l");
2428
+ }
2429
+ }
2430
+
2431
+ #hookStream(stream: WriteStream) {
2432
+ if (!stream || this.#hookedStreams.has(stream) || typeof stream.write !== "function") {
2433
+ return;
2434
+ }
2435
+
2436
+ if (activeHooksPerStream.has(stream)) {
2437
+ return;
2438
+ }
2439
+
2440
+ const originalWrite = stream.write;
2441
+ const hookedWrite = ((...writeArguments: Parameters<WriteStream["write"]>) => this.#hookedWrite(stream, originalWrite, writeArguments)) as WriteStream["write"];
2442
+
2443
+ this.#hookedStreams.set(stream, {originalWrite, hookedWrite});
2444
+ activeHooksPerStream.add(stream);
2445
+ stream.write = hookedWrite;
2446
+ }
2447
+
2448
+ #installHook() {
2449
+ if (!isInteractive || this.#hookedStreams.size > 0) {
2450
+ return;
2451
+ }
2452
+
2453
+ const streamsToHook = new Set([this.#stream]);
2454
+ if (isInteractive && (this.#stream === process.stdout || this.#stream === process.stderr)) {
2455
+ streamsToHook.add(process.stdout);
2456
+ streamsToHook.add(process.stderr);
2457
+ }
2458
+
2459
+ for (const stream of streamsToHook) {
2460
+ this.#hookStream(stream);
2461
+ }
2462
+ }
2463
+
2464
+ #uninstallHook() {
2465
+ for (const [stream, hookInfo] of this.#hookedStreams) {
2466
+ if (stream.write === hookInfo.hookedWrite) {
2467
+ stream.write = hookInfo.originalWrite;
2468
+ }
2469
+
2470
+ activeHooksPerStream.delete(stream);
2471
+ }
2472
+
2473
+ this.#hookedStreams.clear();
2474
+ }
2475
+
2476
+ #hookedWrite(stream: WriteStream, originalWrite: typeof stream.write, writeArguments: Parameters<typeof stream.write>) {
2477
+ const [chunk, callback] = writeArguments;
2478
+
2479
+ if (this.#isInternalWrite || !this.isSpinning) {
2480
+ return originalWrite.call(stream, chunk);
2481
+ }
2482
+
2483
+ if (this.#lines > 0) {
2484
+ this.clear();
2485
+ }
2486
+
2487
+ const chunkString = this.#stringifyChunk(chunk);
2488
+ const chunkTerminatesLine = chunkString.at(-1) === "\\n";
2489
+ const writeResult = originalWrite.call(stream, chunk);
2490
+
2491
+ if (chunkTerminatesLine) {
2492
+ this.#isDeferringRender = false;
2493
+ } else if (chunkString !== "") {
2494
+ this.#isDeferringRender = true;
2495
+ }
2496
+
2497
+ if (this.isSpinning && !this.#isDeferringRender) {
2498
+ this.#render();
2499
+ }
2500
+
2501
+ return writeResult;
2502
+ }
2503
+
2504
+ #stopWithIcon(icon: string, message: string) {
2505
+ return this.stop(\` \${icon} \${message ?? this.#message}\`);
2506
+ }
2507
+
2508
+ #render() {
2509
+ if (this.#isDeferringRender) {
2510
+ return;
2511
+ }
2512
+
2513
+ if (this.#currentFrame === -1 || Date.now() - this.#lastSpinnerFrameTime >= this.#interval) {
2514
+ this.#currentFrame = ++this.#currentFrame % this.#frames.length;
2515
+ this.#lastSpinnerFrameTime = Date.now();
2516
+ }
2517
+
2518
+ let display = \`\${colors.text.spinner.icon.active(this.#frames[this.#currentFrame])} \${colors.text.spinner.message.active(this.#message)}\`;
2519
+ if (!isInteractive) {
2520
+ display += "\\n";
2521
+ }
2522
+
2523
+ if (isInteractive) {
2524
+ this.#withSynchronizedOutput(() => {
2525
+ this.clear();
2526
+ this.#write(display);
2527
+ });
2528
+ } else {
2529
+ this.#write(display);
2530
+ }
2531
+
2532
+ if (isInteractive) {
2533
+ this.#lines = this.#lineCount(display);
2534
+ }
2535
+ }
2536
+
2537
+ #write(message: string) {
2538
+ this.#internalWrite(() => {
2539
+ this.#stream.write(message);
2540
+ });
2541
+ }
2542
+
2543
+ #lineCount(message: string) {
2544
+ const width = this.#stream.columns ?? 80;
2545
+ const lines = stripVTControlCharacters(message).split("\\n");
2546
+
2547
+ let lineCount = 0;
2548
+ for (const line of lines) {
2549
+ lineCount += Math.max(1, Math.ceil(line.length / width));
2550
+ }
2551
+
2552
+ return lineCount;
2553
+ }
2554
+
2555
+ #hideCursor() {
2556
+ if (isInteractive) {
2557
+ this.#write("\\u001B[?25l");
2558
+ }
2559
+ }
2560
+
2561
+ #showCursor() {
2562
+ if (isInteractive) {
2563
+ this.#write("\\u001B[?25h");
2564
+ }
2565
+ }
2566
+
2567
+ #subscribeToProcessEvents() {
2568
+ process.once("SIGINT", this.#exitHandlerBound);
2569
+ process.once("SIGTERM", this.#exitHandlerBound);
2570
+ }
2571
+
2572
+ #unsubscribeFromProcessEvents() {
2573
+ process.off("SIGINT", this.#exitHandlerBound);
2574
+ process.off("SIGTERM", this.#exitHandlerBound);
2575
+ }
2576
+
2577
+ #exitHandler(signal: any) {
2578
+ if (this.isSpinning) {
2579
+ this.stop();
2580
+ }
2581
+
2582
+ process.exit(signal === "SIGINT" ? 130 : (signal === "SIGTERM" ? 143 : 1));
2583
+ } `),
2584
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassPropertyGet, {
2585
+ "public": true,
2586
+ name: "isSpinning",
2587
+ type: "boolean",
2588
+ doc: "Whether the spinner is currently active and spinning.",
2589
+ children: __alloy_js_core.code`return this.#isSpinning;`
2590
+ }),
2591
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2592
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassPropertySet, {
2593
+ "public": true,
2594
+ name: "message",
2595
+ type: "string",
2596
+ doc: "Set the message displayed by the spinner.",
2597
+ children: __alloy_js_core.code`this.#message = value;`
2598
+ }),
2599
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2600
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassPropertyGet, {
2601
+ "public": true,
2602
+ name: "message",
2603
+ type: "string",
2604
+ doc: "Get the message displayed by the spinner.",
2605
+ children: __alloy_js_core.code`return this.#message;`
2606
+ }),
2607
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2608
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassMethod, {
2609
+ name: "start",
2610
+ doc: "Start the spinner animation.",
2611
+ parameters: [{
2612
+ name: "message",
2613
+ type: "string"
2614
+ }],
2615
+ get children() {
2616
+ return [
2617
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
2618
+ condition: __alloy_js_core.code`message !== undefined`,
2619
+ children: __alloy_js_core.code`this.#message = message;`
2620
+ }),
2621
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
2622
+ condition: __alloy_js_core.code`this.isSpinning`,
2623
+ children: __alloy_js_core.code`return this;`
2624
+ }),
2625
+ __alloy_js_core.code`this.#isSpinning = true;
2626
+ this.#hideCursor();
2627
+ this.#installHook();
2628
+ this.#render();
2629
+ this.#subscribeToProcessEvents();
2630
+
2631
+ if (isInteractive) {
2632
+ this.#timer = setInterval(() => {
2633
+ this.#render();
2634
+ }, this.#interval);
2635
+ }
2636
+
2637
+ return this;
2638
+ `
2639
+ ];
2640
+ }
2641
+ }),
2642
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2643
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassMethod, {
2644
+ name: "stop",
2645
+ doc: "Stop the spinner animation.",
2646
+ parameters: [{
2647
+ name: "finalMessage",
2648
+ optional: true,
2649
+ type: "string"
2650
+ }],
2651
+ children: __alloy_js_core.code`if (!this.isSpinning) {
2652
+ return this;
2653
+ }
2654
+
2655
+ const shouldWriteNewline = this.#isDeferringRender;
2656
+ this.#isSpinning = false;
2657
+ if (this.#timer) {
2658
+ clearInterval(this.#timer);
2659
+ this.#timer = undefined;
2660
+ }
2661
+
2662
+ this.#isDeferringRender = false;
2663
+ this.#uninstallHook();
2664
+ this.#showCursor();
2665
+ this.clear();
2666
+ this.#unsubscribeFromProcessEvents();
2667
+
2668
+ if (finalMessage) {
2669
+ const prefix = shouldWriteNewline ? "\\n" : "";
2670
+ this.#stream.write(\`\${prefix}\${finalMessage}\\n\`);
2671
+ }
2672
+
2673
+ return this;
2674
+
2675
+ `
2676
+ }),
2677
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2678
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassMethod, {
2679
+ name: "clear",
2680
+ doc: "Clear the spinner animation.",
2681
+ children: __alloy_js_core.code`if (!isInteractive) {
2682
+ return this;
2683
+ }
2684
+
2685
+ if (this.#lines === 0) {
2686
+ return this;
2687
+ }
2688
+
2689
+ this.#internalWrite(() => {
2690
+ this.#stream.cursorTo(0);
2691
+
2692
+ for (let index = 0; index < this.#lines; index++) {
2693
+ if (index > 0) {
2694
+ this.#stream.moveCursor(0, -1);
2695
+ }
2696
+
2697
+ this.#stream.clearLine(1);
2698
+ }
2699
+ });
2700
+
2701
+ this.#lines = 0;
2702
+ return this; `
2703
+ }),
2704
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2705
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassMethod, {
2706
+ name: "success",
2707
+ doc: "Mark the spinner as successful.",
2708
+ parameters: [{
2709
+ name: "message",
2710
+ type: "string"
2711
+ }],
2712
+ get children() {
2713
+ return __alloy_js_core.code`return this.#stopWithIcon(colors.text.spinner.icon.success("${theme.icons.spinner.success}"), colors.text.spinner.message.success(message)); `;
2714
+ }
2715
+ }),
2716
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2717
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassMethod, {
2718
+ name: "error",
2719
+ doc: "Mark the spinner as failed.",
2720
+ parameters: [{
2721
+ name: "message",
2722
+ type: "string"
2723
+ }],
2724
+ get children() {
2725
+ return __alloy_js_core.code`return this.#stopWithIcon(colors.text.spinner.icon.error("${theme.icons.spinner.error}"), colors.text.spinner.message.error(message)); `;
2726
+ }
2727
+ }),
2728
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2729
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassMethod, {
2730
+ name: "warning",
2731
+ doc: "Mark the spinner as warning.",
2732
+ parameters: [{
2733
+ name: "message",
2734
+ type: "string"
2735
+ }],
2736
+ get children() {
2737
+ return __alloy_js_core.code`return this.#stopWithIcon(colors.text.spinner.icon.warning("${theme.icons.spinner.warning}"), colors.text.spinner.message.warning(message)); `;
2738
+ }
2739
+ }),
2740
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2741
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassMethod, {
2742
+ name: "info",
2743
+ doc: "Mark the spinner as informational.",
2744
+ parameters: [{
2745
+ name: "message",
2746
+ type: "string"
2747
+ }],
2748
+ get children() {
2749
+ return __alloy_js_core.code`return this.#stopWithIcon(colors.text.spinner.icon.info("${theme.icons.spinner.info}"), colors.text.spinner.message.info(message)); `;
2750
+ }
2751
+ }),
2752
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2753
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript.ClassMethod, {
2754
+ name: "help",
2755
+ doc: "Mark the spinner as help.",
2756
+ parameters: [{
2757
+ name: "message",
2758
+ type: "string"
2759
+ }],
2760
+ get children() {
2761
+ return __alloy_js_core.code`return this.#stopWithIcon(colors.text.spinner.icon.help("${theme.icons.spinner.help}"), colors.text.spinner.message.help(message)); `;
2762
+ }
2763
+ }),
2764
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {})
2765
+ ];
2766
+ }
2767
+ }),
2768
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2769
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
2770
+ heading: "Render a spinner in the console.",
2771
+ get children() {
2772
+ return [(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
2773
+ name: "options",
2774
+ children: `Options for configuring the spinner, including the message to display, the output stream to write to, and the spinner animation to use.`
2775
+ }), (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `An instance of the Spinner class, which can be used to control the spinner animation (e.g., start, stop, mark as success/error, etc.).` })];
2776
+ }
2777
+ }),
2778
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
2779
+ "export": true,
2780
+ name: "createSpinner",
2781
+ parameters: [{
2782
+ name: "options",
2783
+ type: "SpinnerOptions",
2784
+ optional: true
2785
+ }],
2786
+ children: __alloy_js_core.code`return new Spinner(options);`
2787
+ })
2788
+ ];
2789
+ }
2099
2790
  function extractBorderOptionsObject(direction, theme) {
2100
2791
  return `borderOptions.${direction} === "primary" ? colors.border.app.table.primary("${theme.borderStyles.app.table.primary[direction]}") : borderOptions.${direction} === "secondary" ? colors.border.app.table.secondary("${theme.borderStyles.app.table.secondary[direction]}") : borderOptions.${direction} === "tertiary" ? colors.border.app.table.tertiary("${theme.borderStyles.app.table.tertiary[direction]}") : !borderOptions.${direction} || borderOptions.${direction} === "none" ? "" : borderOptions.${direction}`;
2101
2792
  }
@@ -2797,16 +3488,28 @@ function ConsoleBuiltin(props) {
2797
3488
  id: "console",
2798
3489
  description: "A collection of helper utilities to assist in generating content meant for display in the console.",
2799
3490
  get imports() {
2800
- return (0, defu.defu)(imports, { "@shell-shock/plugin-theme/types/theme": [{
2801
- name: "ThemeColorsResolvedConfig",
2802
- type: true
2803
- }] });
3491
+ return (0, defu.defu)(imports, {
3492
+ "@shell-shock/plugin-theme/types/theme": [{
3493
+ name: "ThemeColorsResolvedConfig",
3494
+ type: true
3495
+ }, {
3496
+ name: "ThemeSpinnerResolvedConfig",
3497
+ type: true
3498
+ }],
3499
+ "@shell-shock/plugin-theme/helpers/spinners": [{
3500
+ name: "SpinnerPreset",
3501
+ type: true
3502
+ }, { name: "resolveSpinner" }],
3503
+ "node:buffer": ["WithImplicitCoercion"],
3504
+ "node:util": ["stripVTControlCharacters"]
3505
+ });
2804
3506
  },
2805
3507
  get builtinImports() {
2806
3508
  return (0, defu.defu)(builtinImports, {
2807
3509
  utils: [
2808
3510
  "hasFlag",
2809
3511
  "isMinimal",
3512
+ "isInteractive",
2810
3513
  "isColorSupported",
2811
3514
  "colorSupportLevels",
2812
3515
  "isHyperlinkSupported"
@@ -2834,6 +3537,8 @@ function ConsoleBuiltin(props) {
2834
3537
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2835
3538
  (0, __alloy_js_core_jsx_runtime.createComponent)(DividerFunctionDeclaration, {}),
2836
3539
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
3540
+ (0, __alloy_js_core_jsx_runtime.createComponent)(SpinnerFunctionDeclaration, {}),
3541
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
2837
3542
  (0, __alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
2838
3543
  type: "help",
2839
3544
  variant: "help",
@@ -2932,8 +3637,8 @@ function ConsoleBuiltin(props) {
2932
3637
  get children() {
2933
3638
  return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
2934
3639
  condition: __alloy_js_core.code`(err as Error)?.stack`,
2935
- children: __alloy_js_core.code`message += " \\n\\n" + (err as Error).stack;`
2936
- }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseClause, { children: __alloy_js_core.code`message += " \\n\\n" + (new Error(" ")).stack.split("\\n").slice(2).map(line => line.trim()).join("\\n");` })];
3640
+ children: __alloy_js_core.code`message += " \\n\\n" + ((err as Error).stack || "");`
3641
+ }), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseClause, { children: __alloy_js_core.code`message += " \\n\\n" + ((new Error(" ")).stack || "").split("\\n").slice(2).map(line => line.trim()).join("\\n");` })];
2937
3642
  }
2938
3643
  })
2939
3644
  ];
@@ -2956,6 +3661,7 @@ exports.ConsoleBuiltin = ConsoleBuiltin;
2956
3661
  exports.DividerFunctionDeclaration = DividerFunctionDeclaration;
2957
3662
  exports.LinkFunctionDeclaration = LinkFunctionDeclaration;
2958
3663
  exports.MessageFunctionDeclaration = MessageFunctionDeclaration;
3664
+ exports.SpinnerFunctionDeclaration = SpinnerFunctionDeclaration;
2959
3665
  exports.StripAnsiFunctionDeclaration = StripAnsiFunctionDeclaration;
2960
3666
  exports.TableFunctionDeclaration = TableFunctionDeclaration;
2961
3667
  exports.WrapAnsiFunction = WrapAnsiFunction;