@jujulego/jill 3.0.8 → 3.0.9

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.
@@ -1,4 +1,4 @@
1
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"jill@3.0.8"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="69d627b0-a502-4990-affa-044c26cd58fb",e._sentryDebugIdIdentifier="sentry-dbid-69d627b0-a502-4990-affa-044c26cd58fb");}catch(e){}}();import { init } from '@sentry/node';
1
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"jill@3.0.9"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="69d627b0-a502-4990-affa-044c26cd58fb",e._sentryDebugIdIdentifier="sentry-dbid-69d627b0-a502-4990-affa-044c26cd58fb");}catch(e){}}();import { init } from '@sentry/node';
2
2
 
3
3
  init({
4
4
  dsn: 'https://53e6d10c16975ebd025175d9836d039b@o4508229080055808.ingest.de.sentry.io/4509876546895952',
@@ -1,4 +1,4 @@
1
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"jill@3.0.8"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a620d7be-983c-46b4-86bc-2e28da10d166",e._sentryDebugIdIdentifier="sentry-dbid-a620d7be-983c-46b4-86bc-2e28da10d166");}catch(e){}}();import { r as reactExports, S as StdinContext, p as parseKeypress, n as nonAlphanumericKeys, a as reconciler, b as StdoutContext, j as jsxRuntimeExports, T as Text, B as Box, i as inked } from './inked.js';
1
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"jill@3.0.9"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9d8fa87a-70e8-4b1f-a4f7-a813d8fa7042",e._sentryDebugIdIdentifier="sentry-dbid-9d8fa87a-70e8-4b1f-a4f7-a813d8fa7042");}catch(e){}}();import { r as reactExports, S as StdinContext, p as parseKeypress, n as nonAlphanumericKeys, a as reconciler, b as StdoutContext, j as jsxRuntimeExports, T as Text, B as Box, i as inked } from './inked.js';
2
2
  import process from 'node:process';
3
3
  import 'node:stream';
4
4
  import { createHash } from 'node:crypto';
@@ -14,7 +14,6 @@ import 'node:tty';
14
14
  import 'node:os';
15
15
  import 'node:events';
16
16
  import 'module';
17
- import 'node:buffer';
18
17
  import 'yargs/helpers';
19
18
  import 'node:path';
20
19
  import '@swc/helpers/_/_apply_decs_2203_r';
@@ -193,11 +192,13 @@ function prettyMilliseconds(milliseconds, options) {
193
192
  }
194
193
 
195
194
  /**
196
- `useStdin` is a React hook that exposes the stdin stream.
195
+ A React hook that returns the stdin stream and stdin-related utilities.
197
196
  */ const useStdin = ()=>reactExports.useContext(StdinContext);
197
+ const useStdinContext = ()=>reactExports.useContext(StdinContext);
198
198
 
199
199
  /**
200
- This hook is used for handling user input. It's a more convenient alternative to using `StdinContext` and listening for `data` events. The callback you pass to `useInput` is called for each character when the user enters any input. However, if the user pastes text and it's more than one character, the callback will be called only once, and the whole string will be passed as `input`.
200
+ A React hook that returns `void` and handles user input.
201
+ It's a more convenient alternative to using `StdinContext` and listening for `data` events. The callback you pass to `useInput` is called for each character when the user enters any input. However, if the user pastes text and it's more than one character, the callback will be called only once, and the whole string will be passed as `input`.
201
202
 
202
203
  ```
203
204
  import {useInput} from 'ink';
@@ -218,7 +219,7 @@ const UserInput = () => {
218
219
  ```
219
220
  */ const useInput = (inputHandler, options = {})=>{
220
221
  // eslint-disable-next-line @typescript-eslint/naming-convention
221
- const { stdin, setRawMode, internal_exitOnCtrlC, internal_eventEmitter } = useStdin();
222
+ const { setRawMode, internal_exitOnCtrlC, internal_eventEmitter } = useStdinContext();
222
223
  reactExports.useEffect(()=>{
223
224
  if (options.isActive === false) {
224
225
  return;
@@ -231,92 +232,93 @@ const UserInput = () => {
231
232
  options.isActive,
232
233
  setRawMode
233
234
  ]);
234
- reactExports.useEffect(()=>{
235
- if (options.isActive === false) {
236
- return;
237
- }
238
- const handleData = (data)=>{
239
- const keypress = parseKeypress(data);
240
- const key = {
241
- upArrow: keypress.name === 'up',
242
- downArrow: keypress.name === 'down',
243
- leftArrow: keypress.name === 'left',
244
- rightArrow: keypress.name === 'right',
245
- pageDown: keypress.name === 'pagedown',
246
- pageUp: keypress.name === 'pageup',
247
- home: keypress.name === 'home',
248
- end: keypress.name === 'end',
249
- return: keypress.name === 'return',
250
- escape: keypress.name === 'escape',
251
- ctrl: keypress.ctrl,
252
- shift: keypress.shift,
253
- tab: keypress.name === 'tab',
254
- backspace: keypress.name === 'backspace',
255
- delete: keypress.name === 'delete',
256
- // `parseKeypress` parses \u001B\u001B[A (meta + up arrow) as meta = false
257
- // but with option = true, so we need to take this into account here
258
- // to avoid breaking changes in Ink.
259
- // TODO(vadimdemedes): consider removing this in the next major version.
260
- meta: keypress.meta || keypress.name === 'escape' || keypress.option,
261
- // Kitty keyboard protocol modifiers
262
- super: keypress.super ?? false,
263
- hyper: keypress.hyper ?? false,
264
- capsLock: keypress.capsLock ?? false,
265
- numLock: keypress.numLock ?? false,
266
- eventType: keypress.eventType
267
- };
268
- let input;
269
- if (keypress.isKittyProtocol) {
270
- // Use text-as-codepoints field for printable keys (needed when
271
- // reportAllKeysAsEscapeCodes flag is enabled), suppress non-printable
272
- if (keypress.isPrintable) {
273
- input = keypress.text ?? keypress.name;
274
- } else if (keypress.ctrl && keypress.name.length === 1) {
275
- // Ctrl+letter via codepoint 1-26 form: not printable text, but
276
- // the letter name must flow through so handlers (e.g. exitOnCtrlC
277
- // checking `input === 'c' && key.ctrl`) still work.
278
- input = keypress.name;
279
- } else {
280
- input = '';
281
- }
282
- } else if (keypress.ctrl) {
235
+ const handleData = reactExports.useEffectEvent((data)=>{
236
+ const keypress = parseKeypress(data);
237
+ const key = {
238
+ upArrow: keypress.name === 'up',
239
+ downArrow: keypress.name === 'down',
240
+ leftArrow: keypress.name === 'left',
241
+ rightArrow: keypress.name === 'right',
242
+ pageDown: keypress.name === 'pagedown',
243
+ pageUp: keypress.name === 'pageup',
244
+ home: keypress.name === 'home',
245
+ end: keypress.name === 'end',
246
+ return: keypress.name === 'return',
247
+ escape: keypress.name === 'escape',
248
+ ctrl: keypress.ctrl,
249
+ shift: keypress.shift,
250
+ tab: keypress.name === 'tab',
251
+ backspace: keypress.name === 'backspace',
252
+ delete: keypress.name === 'delete',
253
+ meta: keypress.meta,
254
+ // Kitty keyboard protocol modifiers
255
+ super: keypress.super ?? false,
256
+ hyper: keypress.hyper ?? false,
257
+ capsLock: keypress.capsLock ?? false,
258
+ numLock: keypress.numLock ?? false,
259
+ eventType: keypress.eventType
260
+ };
261
+ let input;
262
+ if (keypress.isKittyProtocol) {
263
+ // Use text-as-codepoints field for printable keys (needed when
264
+ // reportAllKeysAsEscapeCodes flag is enabled), suppress non-printable
265
+ if (keypress.isPrintable) {
266
+ input = keypress.text ?? keypress.name;
267
+ } else if (keypress.ctrl && keypress.name.length === 1) {
268
+ // Ctrl+letter via codepoint 1-26 form: not printable text, but
269
+ // the letter name must flow through so handlers (e.g. exitOnCtrlC
270
+ // checking `input === 'c' && key.ctrl`) still work.
283
271
  input = keypress.name;
284
272
  } else {
285
- input = keypress.sequence;
286
- }
287
- if (!keypress.isKittyProtocol && nonAlphanumericKeys.includes(keypress.name)) {
288
273
  input = '';
289
274
  }
290
- // Strip meta if it's still remaining after `parseKeypress`
291
- // TODO(vadimdemedes): remove this in the next major version.
292
- if (input.startsWith('\u001B')) {
293
- input = input.slice(1);
294
- }
295
- if (input.length === 1 && typeof input[0] === 'string' && /[A-Z]/.test(input[0])) {
296
- key.shift = true;
297
- }
298
- // If app is not supposed to exit on Ctrl+C, then let input listener handle it
299
- if (!(input === 'c' && key.ctrl) || !internal_exitOnCtrlC) {
300
- // @ts-expect-error TypeScript types for `batchedUpdates` require an argument, but React's codebase doesn't provide it and it works without it as expected.
301
- reconciler.batchedUpdates(()=>{
302
- inputHandler(input, key);
303
- });
304
- }
305
- };
306
- internal_eventEmitter?.on('input', handleData);
275
+ } else if (keypress.ctrl) {
276
+ // Keypress.name is guaranteed non-undefined by parseKeypress,
277
+ // but guard defensively since a TypeError here would crash the
278
+ // entire Ink app (see https://github.com/vadimdemedes/ink/issues/901).
279
+ input = keypress.name ?? '';
280
+ } else {
281
+ input = keypress.sequence;
282
+ }
283
+ if (!keypress.isKittyProtocol && nonAlphanumericKeys.includes(keypress.name)) {
284
+ input = '';
285
+ }
286
+ // Strip escape prefix from broken/incomplete sequences that
287
+ // parseKeypress did not fully resolve (e.g. a flushed "\u001B[").
288
+ if (input.startsWith('\u001B')) {
289
+ input = input.slice(1);
290
+ }
291
+ if (input.length === 1 && /[A-Z]/.test(input)) {
292
+ key.shift = true;
293
+ }
294
+ // If app is supposed to exit on Ctrl+C, skip input listeners.
295
+ if (input === 'c' && key.ctrl && internal_exitOnCtrlC) {
296
+ return;
297
+ }
298
+ // Use discreteUpdates to assign DiscreteEventPriority to state
299
+ // updates from keyboard input, ensuring they are processed at the
300
+ // highest priority in concurrent mode.
301
+ // @ts-expect-error Types require 5 arguments (fn, a, b, c, d) but only fn is needed at runtime.
302
+ reconciler.discreteUpdates(()=>{
303
+ inputHandler(input, key);
304
+ });
305
+ });
306
+ reactExports.useEffect(()=>{
307
+ if (options.isActive === false) {
308
+ return;
309
+ }
310
+ internal_eventEmitter.on('input', handleData);
307
311
  return ()=>{
308
- internal_eventEmitter?.removeListener('input', handleData);
312
+ internal_eventEmitter.removeListener('input', handleData);
309
313
  };
310
314
  }, [
311
315
  options.isActive,
312
- stdin,
313
- internal_exitOnCtrlC,
314
- inputHandler
316
+ internal_eventEmitter
315
317
  ]);
316
318
  };
317
319
 
318
320
  /**
319
- `useStdout` is a React hook that exposes the stdout stream where Ink renders your app.
321
+ A React hook that returns the stdout stream where Ink renders your app.
320
322
  */ const useStdout = ()=>reactExports.useContext(StdoutContext);
321
323
 
322
324
  // Hook