@alchemy.run/sigil 0.0.0-alpha.2 → 0.0.0-alpha.4

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.
Files changed (107) hide show
  1. package/README.md +2 -4
  2. package/THIRD_PARTY_NOTICES.md +31 -22
  3. package/dist/ansi.d.ts +17 -14
  4. package/dist/ansi.js +7 -2
  5. package/dist/{devtools-BhYGjb7h.js → devtools-DbthxoD1.js} +22 -23
  6. package/dist/index.d.ts +125 -288
  7. package/dist/index.js +2460 -2864
  8. package/dist/{truncate-CBiyyZzw.js → truncate-Cr6xVFMa.js} +447 -273
  9. package/package.json +3 -9
  10. package/src/ansi/chalk.ts +8 -51
  11. package/src/ansi/cursor.ts +2 -4
  12. package/src/ansi/east-asian-width.ts +44 -0
  13. package/src/ansi/escapes.ts +4 -26
  14. package/src/ansi/index.ts +12 -14
  15. package/src/ansi/sgr.ts +2 -5
  16. package/src/ansi/slice.ts +1 -1
  17. package/src/ansi/string-width.ts +91 -206
  18. package/src/ansi/strip.ts +13 -33
  19. package/src/ansi/supports-color.ts +8 -14
  20. package/src/ansi/tokenize.ts +94 -166
  21. package/src/ansi/truncate.ts +5 -3
  22. package/src/ansi/wrap.ts +13 -14
  23. package/src/ansi-tokenizer.ts +1 -1
  24. package/src/colorize.ts +1 -1
  25. package/src/components/App.tsx +14 -14
  26. package/src/components/BackgroundContext.ts +2 -2
  27. package/src/components/Box.tsx +51 -59
  28. package/src/components/CursorContext.ts +1 -1
  29. package/src/components/ErrorBoundary.tsx +2 -1
  30. package/src/components/ErrorOverview.tsx +9 -7
  31. package/src/components/Newline.tsx +1 -0
  32. package/src/components/Spacer.tsx +2 -1
  33. package/src/components/Static.tsx +2 -1
  34. package/src/components/StderrContext.ts +0 -2
  35. package/src/components/StdinContext.ts +0 -1
  36. package/src/components/StdoutContext.ts +1 -3
  37. package/src/components/Text.tsx +7 -6
  38. package/src/components/Transform.tsx +2 -1
  39. package/src/cursor-position.ts +1 -1
  40. package/src/devtools.ts +84 -24
  41. package/src/dom.ts +7 -7
  42. package/src/env.ts +12 -0
  43. package/src/get-max-width.ts +1 -1
  44. package/src/global.d.ts +3 -4
  45. package/src/{boxes.ts → glyphs.ts} +17 -18
  46. package/src/hooks/use-animation.ts +1 -1
  47. package/src/hooks/use-app.ts +1 -1
  48. package/src/hooks/use-box-metrics.ts +1 -1
  49. package/src/hooks/use-cursor.ts +2 -2
  50. package/src/hooks/use-focus-manager.ts +1 -1
  51. package/src/hooks/use-focus.ts +5 -6
  52. package/src/hooks/use-input.ts +4 -4
  53. package/src/hooks/use-is-screen-reader-enabled.ts +1 -1
  54. package/src/hooks/use-paste.ts +2 -2
  55. package/src/hooks/use-stderr.ts +1 -1
  56. package/src/hooks/use-stdin.ts +1 -1
  57. package/src/hooks/use-stdout.ts +1 -1
  58. package/src/hooks/use-window-size.ts +2 -2
  59. package/src/index.ts +44 -44
  60. package/src/ink.tsx +536 -720
  61. package/src/input-parser.ts +1 -1
  62. package/src/instances.ts +1 -1
  63. package/src/kitty-keyboard.ts +128 -0
  64. package/src/log-update.ts +4 -4
  65. package/src/measure-element.ts +1 -1
  66. package/src/measure-text.ts +2 -2
  67. package/src/output.ts +4 -4
  68. package/src/parse-keypress.ts +4 -5
  69. package/src/parse-stack-line.ts +0 -1
  70. package/src/patch-console.ts +44 -0
  71. package/src/reconciler.ts +13 -60
  72. package/src/render-background.ts +3 -3
  73. package/src/render-border.ts +6 -6
  74. package/src/render-node-to-output.ts +13 -11
  75. package/src/render-to-string.ts +4 -4
  76. package/src/render.ts +9 -10
  77. package/src/renderer.ts +3 -3
  78. package/src/sanitize-ansi.ts +1 -1
  79. package/src/signal-exit.ts +4 -5
  80. package/src/squash-text-nodes.ts +2 -2
  81. package/src/stream.ts +2 -4
  82. package/src/styles.ts +6 -6
  83. package/src/terminal-size.ts +9 -8
  84. package/src/types.ts +1 -6
  85. package/src/utils.ts +2 -2
  86. package/src/wrap-text.ts +4 -4
  87. package/src/yoga/config.ts +2 -2
  88. package/src/yoga/core/absoluteLayout.ts +15 -15
  89. package/src/yoga/core/baseline.ts +3 -3
  90. package/src/yoga/core/cache.ts +4 -4
  91. package/src/yoga/core/calculateLayout.ts +33 -27
  92. package/src/yoga/core/config.ts +1 -1
  93. package/src/yoga/core/flexLine.ts +3 -3
  94. package/src/yoga/core/helpers.ts +3 -3
  95. package/src/yoga/core/layoutResults.ts +4 -4
  96. package/src/yoga/core/node.ts +16 -16
  97. package/src/yoga/core/pixelGrid.ts +4 -4
  98. package/src/yoga/core/style.ts +11 -11
  99. package/src/yoga/core/types.ts +2 -2
  100. package/src/yoga/index.ts +6 -6
  101. package/src/yoga/node.ts +8 -8
  102. package/src/ansi/widest-line.ts +0 -12
  103. package/src/auto-bind.ts +0 -41
  104. package/src/devtools-window-polyfill.ts +0 -73
  105. package/src/indent-string.ts +0 -16
  106. package/src/is-in-ci.ts +0 -7
  107. package/src/write-synchronized.ts +0 -9
@@ -1,11 +1,12 @@
1
- import fs from "node:fs";
2
1
  // Derived from `terminal-size` (MIT, Sindre Sorhus), reduced for Ink's usage as a
3
2
  // fallback when the stdout stream reports no dimensions. Unlike the original,
4
3
  // this never shells out to `tput`/`resize` — it checks the process streams,
5
4
  // the COLUMNS/LINES environment variables and /dev/tty, then falls back to
6
5
  // the standard 80×24.
7
- import process from "node:process";
8
- import tty from "node:tty";
6
+ import { openSync, constants } from "node:fs";
7
+ import { WriteStream } from "node:tty";
8
+
9
+ import { isMacos } from "#/env.ts";
9
10
 
10
11
  type TerminalSize = {
11
12
  columns: number;
@@ -20,14 +21,14 @@ const create = (columns: number | string, rows: number | string): TerminalSize =
20
21
  const devTty = (): TerminalSize | undefined => {
21
22
  try {
22
23
  // O_EVTONLY is macOS-only and missing from the Node type definitions.
23
- const { O_EVTONLY: evtOnly } = fs.constants as { O_EVTONLY?: number };
24
+ const { O_EVTONLY: evtOnly } = constants as { O_EVTONLY?: number };
24
25
  const flags =
25
- process.platform === "darwin" && evtOnly !== undefined
26
+ isMacos && evtOnly !== undefined
26
27
  ? // eslint-disable-next-line no-bitwise
27
- evtOnly | fs.constants.O_NONBLOCK
28
- : fs.constants.O_NONBLOCK;
28
+ evtOnly | constants.O_NONBLOCK
29
+ : constants.O_NONBLOCK;
29
30
 
30
- const { columns, rows } = new tty.WriteStream(fs.openSync("/dev/tty", flags));
31
+ const { columns, rows } = new WriteStream(openSync("/dev/tty", flags));
31
32
 
32
33
  if (columns && rows) {
33
34
  return { columns, rows };
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- // The two `type-fest` types Ink used, inlined (MIT, Sindre Sorhus).
1
+ // The one `type-fest` type Ink used, inlined (MIT, Sindre Sorhus).
2
2
 
3
3
  /**
4
4
  Allows creating a union type by combining primitive types and literal types
@@ -8,8 +8,3 @@ union.
8
8
  export type LiteralUnion<LiteralType, BaseType extends string | number> =
9
9
  | LiteralType
10
10
  | (BaseType & Record<never, never>);
11
-
12
- /**
13
- Create a type from an object type without certain keys.
14
- */
15
- export type Except<ObjectType, KeysType extends keyof ObjectType> = Omit<ObjectType, KeysType>;
package/src/utils.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { OutputStream } from "./stream.ts";
2
- import { terminalSize } from "./terminal-size.ts";
1
+ import type { OutputStream } from "#/stream.ts";
2
+ import { terminalSize } from "#/terminal-size.ts";
3
3
 
4
4
  const resolveDimension = (
5
5
  value: number | undefined,
package/src/wrap-text.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { cliTruncate } from "./ansi/truncate.ts";
2
- import { wrapAnsi } from "./ansi/wrap.ts";
3
- import { QuickLru as QuickLRU } from "./quick-lru.ts";
4
- import { type Styles } from "./styles.ts";
1
+ import { cliTruncate } from "#/ansi/truncate.ts";
2
+ import { wrapAnsi } from "#/ansi/wrap.ts";
3
+ import { QuickLru as QuickLRU } from "#/quick-lru.ts";
4
+ import { type Styles } from "#/styles.ts";
5
5
 
6
6
  export const wrapTextCache = new QuickLRU<string, string>({ maxSize: 4096 });
7
7
 
@@ -1,8 +1,8 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Derived from Yoga. See THIRD_PARTY_NOTICES.md.
3
3
 
4
- import { Config as CoreConfig } from "./core/config.ts";
5
- import type { Errata, ExperimentalFeature } from "./generated/YGEnums.ts";
4
+ import { Config as CoreConfig } from "#/yoga/core/config.ts";
5
+ import type { Errata, ExperimentalFeature } from "#/yoga/generated/YGEnums.ts";
6
6
 
7
7
  /**
8
8
  * Public Config wrapper over the core config, exposing the same surface as
@@ -4,23 +4,12 @@
4
4
  // Port of yoga/algorithm/AbsoluteLayout.cpp. Grid-specific branches are kept
5
5
  // where they read from style, but Display.Grid is not otherwise supported.
6
6
 
7
- import {
8
- Align,
9
- Dimension,
10
- Direction,
11
- Display,
12
- Errata,
13
- FlexDirection,
14
- Justify,
15
- PositionType,
16
- Wrap,
17
- } from "../generated/YGEnums.ts";
18
7
  import {
19
8
  type LayoutData,
20
9
  LayoutPassReason,
21
10
  calculateLayoutInternal,
22
11
  cleanupContentsNodesRecursively,
23
- } from "./calculateLayout.ts";
12
+ } from "#/yoga/core/calculateLayout.ts";
24
13
  import {
25
14
  PhysicalEdge,
26
15
  SizingMode,
@@ -37,9 +26,20 @@ import {
37
26
  resolveCrossDirection,
38
27
  resolveDirection,
39
28
  setChildTrailingPosition,
40
- } from "./helpers.ts";
41
- import type { Node } from "./node.ts";
42
- import { isDefined, isUndefined } from "./numeric.ts";
29
+ } from "#/yoga/core/helpers.ts";
30
+ import type { Node } from "#/yoga/core/node.ts";
31
+ import { isDefined, isUndefined } from "#/yoga/core/numeric.ts";
32
+ import {
33
+ Align,
34
+ Dimension,
35
+ Direction,
36
+ Display,
37
+ Errata,
38
+ FlexDirection,
39
+ Justify,
40
+ PositionType,
41
+ Wrap,
42
+ } from "#/yoga/generated/YGEnums.ts";
43
43
 
44
44
  function setFlexStartLayoutPosition(
45
45
  parent: Node,
@@ -3,9 +3,9 @@
3
3
 
4
4
  // Port of yoga/algorithm/Baseline.cpp.
5
5
 
6
- import { Align, Dimension, PositionType } from "../generated/YGEnums.ts";
7
- import { PhysicalEdge, isColumn, resolveChildAlignment } from "./helpers.ts";
8
- import type { Node } from "./node.ts";
6
+ import { PhysicalEdge, isColumn, resolveChildAlignment } from "#/yoga/core/helpers.ts";
7
+ import type { Node } from "#/yoga/core/node.ts";
8
+ import { Align, Dimension, PositionType } from "#/yoga/generated/YGEnums.ts";
9
9
 
10
10
  export function calculateBaseline(node: Node): number {
11
11
  if (node.hasBaselineFunc()) {
@@ -3,10 +3,10 @@
3
3
 
4
4
  // Port of yoga/algorithm/Cache.cpp.
5
5
 
6
- import type { Config } from "./config.ts";
7
- import { SizingMode } from "./helpers.ts";
8
- import { inexactEquals, isDefined } from "./numeric.ts";
9
- import { roundValueToPixelGrid } from "./pixelGrid.ts";
6
+ import type { Config } from "#/yoga/core/config.ts";
7
+ import { SizingMode } from "#/yoga/core/helpers.ts";
8
+ import { inexactEquals, isDefined } from "#/yoga/core/numeric.ts";
9
+ import { roundValueToPixelGrid } from "#/yoga/core/pixelGrid.ts";
10
10
 
11
11
  function sizeIsExactAndMatchesOldMeasuredSize(
12
12
  sizeMode: SizingMode,
@@ -4,26 +4,10 @@
4
4
  // Port of yoga/algorithm/CalculateLayout.cpp. The event system and
5
5
  // LayoutPassReason-keyed instrumentation are reduced to plain counters.
6
6
 
7
- import {
8
- Align,
9
- Dimension,
10
- Direction,
11
- Display,
12
- Edge,
13
- Errata,
14
- ExperimentalFeature,
15
- FlexDirection,
16
- Gutter,
17
- Justify,
18
- MeasureMode,
19
- Overflow,
20
- PositionType,
21
- Wrap,
22
- } from "../generated/YGEnums.ts";
23
- import { layoutAbsoluteDescendants } from "./absoluteLayout.ts";
24
- import { calculateBaseline, isBaselineLayout } from "./baseline.ts";
25
- import { canUseCachedMeasurement } from "./cache.ts";
26
- import { type FlexLine, calculateFlexLine } from "./flexLine.ts";
7
+ import { layoutAbsoluteDescendants } from "#/yoga/core/absoluteLayout.ts";
8
+ import { calculateBaseline, isBaselineLayout } from "#/yoga/core/baseline.ts";
9
+ import { canUseCachedMeasurement } from "#/yoga/core/cache.ts";
10
+ import { type FlexLine, calculateFlexLine } from "#/yoga/core/flexLine.ts";
27
11
  import {
28
12
  PhysicalEdge,
29
13
  SizingMode,
@@ -42,13 +26,35 @@ import {
42
26
  resolveCrossDirection,
43
27
  resolveDirection,
44
28
  setChildTrailingPosition,
45
- } from "./helpers.ts";
46
- import { CachedMeasurement, LayoutResults } from "./layoutResults.ts";
47
- import type { Node } from "./node.ts";
48
- import { isDefined, isUndefined, inexactEquals, maxOrDefined, minOrDefined } from "./numeric.ts";
49
- import { roundLayoutResultsToPixelGrid } from "./pixelGrid.ts";
50
- import type { Style } from "./style.ts";
51
- import type { StyleLength } from "./types.ts";
29
+ } from "#/yoga/core/helpers.ts";
30
+ import { CachedMeasurement, LayoutResults } from "#/yoga/core/layoutResults.ts";
31
+ import type { Node } from "#/yoga/core/node.ts";
32
+ import {
33
+ isDefined,
34
+ isUndefined,
35
+ inexactEquals,
36
+ maxOrDefined,
37
+ minOrDefined,
38
+ } from "#/yoga/core/numeric.ts";
39
+ import { roundLayoutResultsToPixelGrid } from "#/yoga/core/pixelGrid.ts";
40
+ import type { Style } from "#/yoga/core/style.ts";
41
+ import type { StyleLength } from "#/yoga/core/types.ts";
42
+ import {
43
+ Align,
44
+ Dimension,
45
+ Direction,
46
+ Display,
47
+ Edge,
48
+ Errata,
49
+ ExperimentalFeature,
50
+ FlexDirection,
51
+ Gutter,
52
+ Justify,
53
+ MeasureMode,
54
+ Overflow,
55
+ PositionType,
56
+ Wrap,
57
+ } from "#/yoga/generated/YGEnums.ts";
52
58
 
53
59
  export const LayoutPassReason = {
54
60
  Initial: 0,
@@ -3,7 +3,7 @@
3
3
 
4
4
  // Port of yoga/config/Config.h and yoga/config/Config.cpp.
5
5
 
6
- import { Errata, ExperimentalFeature } from "../generated/YGEnums.ts";
6
+ import { Errata, ExperimentalFeature } from "#/yoga/generated/YGEnums.ts";
7
7
 
8
8
  // Whether moving a node from an old to new config should dirty previously
9
9
  // calculated layout results.
@@ -8,9 +8,9 @@
8
8
  // receives the start index, returning the index of the first child of the next
9
9
  // line alongside the line itself.
10
10
 
11
- import { Direction, Display, PositionType, Wrap } from "../generated/YGEnums.ts";
12
- import { boundAxisWithinMinAndMax, resolveDirection } from "./helpers.ts";
13
- import type { Node } from "./node.ts";
11
+ import { boundAxisWithinMinAndMax, resolveDirection } from "#/yoga/core/helpers.ts";
12
+ import type { Node } from "#/yoga/core/node.ts";
13
+ import { Direction, Display, PositionType, Wrap } from "#/yoga/generated/YGEnums.ts";
14
14
 
15
15
  export interface FlexLineRunningLayout {
16
16
  // Total flex grow factors of flex items which are to be laid in the current
@@ -5,6 +5,8 @@
5
5
  // yoga/algorithm/SizingMode.h, yoga/algorithm/TrailingPosition.h and
6
6
  // yoga/algorithm/BoundAxis.h, plus the internal PhysicalEdge enum.
7
7
 
8
+ import type { Node } from "#/yoga/core/node.ts";
9
+ import { maxOrDefined } from "#/yoga/core/numeric.ts";
8
10
  import {
9
11
  Align,
10
12
  Dimension,
@@ -13,9 +15,7 @@ import {
13
15
  FlexDirection,
14
16
  Justify,
15
17
  MeasureMode,
16
- } from "../generated/YGEnums.ts";
17
- import type { Node } from "./node.ts";
18
- import { maxOrDefined } from "./numeric.ts";
18
+ } from "#/yoga/generated/YGEnums.ts";
19
19
 
20
20
  export const PhysicalEdge = {
21
21
  Left: 0,
@@ -3,10 +3,10 @@
3
3
 
4
4
  // Port of yoga/node/LayoutResults.h and yoga/node/CachedMeasurement.h.
5
5
 
6
- import { Dimension, Direction } from "../generated/YGEnums.ts";
7
- import type { FlexLine } from "./flexLine.ts";
8
- import { PhysicalEdge, SizingMode } from "./helpers.ts";
9
- import { isUndefined } from "./numeric.ts";
6
+ import type { FlexLine } from "#/yoga/core/flexLine.ts";
7
+ import { PhysicalEdge, SizingMode } from "#/yoga/core/helpers.ts";
8
+ import { isUndefined } from "#/yoga/core/numeric.ts";
9
+ import { Dimension, Direction } from "#/yoga/generated/YGEnums.ts";
10
10
 
11
11
  export class CachedMeasurement {
12
12
  availableWidth = -1;
@@ -8,6 +8,21 @@
8
8
  // callbacks) is not exposed through the JS binding, so children are always
9
9
  // uniquely owned and cloneChildrenIfNeeded is a no-op.
10
10
 
11
+ import { Config, configUpdateInvalidatesLayout, getDefaultConfig } from "#/yoga/core/config.ts";
12
+ import {
13
+ PhysicalEdge,
14
+ dimension,
15
+ inlineStartEdge,
16
+ inlineEndEdge,
17
+ isRow,
18
+ resolveCrossDirection,
19
+ resolveDirection,
20
+ } from "#/yoga/core/helpers.ts";
21
+ import { LayoutResults } from "#/yoga/core/layoutResults.ts";
22
+ import { isDefined, isUndefined, maxOrDefined } from "#/yoga/core/numeric.ts";
23
+ import { Style } from "#/yoga/core/style.ts";
24
+ import type { Size, StyleSizeLength } from "#/yoga/core/types.ts";
25
+ import { StyleSizeLength as SizeLength } from "#/yoga/core/types.ts";
11
26
  import {
12
27
  Align,
13
28
  BoxSizing,
@@ -18,22 +33,7 @@ import {
18
33
  MeasureMode,
19
34
  NodeType,
20
35
  PositionType,
21
- } from "../generated/YGEnums.ts";
22
- import { Config, configUpdateInvalidatesLayout, getDefaultConfig } from "./config.ts";
23
- import {
24
- PhysicalEdge,
25
- dimension,
26
- inlineStartEdge,
27
- inlineEndEdge,
28
- isRow,
29
- resolveCrossDirection,
30
- resolveDirection,
31
- } from "./helpers.ts";
32
- import { LayoutResults } from "./layoutResults.ts";
33
- import { isDefined, isUndefined, maxOrDefined } from "./numeric.ts";
34
- import { Style } from "./style.ts";
35
- import type { Size, StyleSizeLength } from "./types.ts";
36
- import { StyleSizeLength as SizeLength } from "./types.ts";
36
+ } from "#/yoga/generated/YGEnums.ts";
37
37
 
38
38
  export type MeasureFunc = (
39
39
  width: number,
@@ -3,10 +3,10 @@
3
3
 
4
4
  // Port of yoga/algorithm/PixelGrid.cpp.
5
5
 
6
- import { Dimension, NodeType } from "../generated/YGEnums.ts";
7
- import { PhysicalEdge } from "./helpers.ts";
8
- import type { Node } from "./node.ts";
9
- import { inexactEquals } from "./numeric.ts";
6
+ import { PhysicalEdge } from "#/yoga/core/helpers.ts";
7
+ import type { Node } from "#/yoga/core/node.ts";
8
+ import { inexactEquals } from "#/yoga/core/numeric.ts";
9
+ import { Dimension, NodeType } from "#/yoga/generated/YGEnums.ts";
10
10
 
11
11
  export function roundValueToPixelGrid(
12
12
  value: number,
@@ -4,6 +4,16 @@
4
4
  // Port of yoga/style/Style.h (grid properties omitted — the JS binding does
5
5
  // not expose them and no algorithm consumes them).
6
6
 
7
+ import {
8
+ PhysicalEdge,
9
+ flexStartEdge,
10
+ flexEndEdge,
11
+ inlineStartEdge,
12
+ inlineEndEdge,
13
+ isRow,
14
+ } from "#/yoga/core/helpers.ts";
15
+ import { isDefined, maxOrDefined } from "#/yoga/core/numeric.ts";
16
+ import { StyleLength, StyleSizeLength } from "#/yoga/core/types.ts";
7
17
  import {
8
18
  Align,
9
19
  BoxSizing,
@@ -18,17 +28,7 @@ import {
18
28
  PositionType,
19
29
  Unit,
20
30
  Wrap,
21
- } from "../generated/YGEnums.ts";
22
- import {
23
- PhysicalEdge,
24
- flexStartEdge,
25
- flexEndEdge,
26
- inlineStartEdge,
27
- inlineEndEdge,
28
- isRow,
29
- } from "./helpers.ts";
30
- import { isDefined, maxOrDefined } from "./numeric.ts";
31
- import { StyleLength, StyleSizeLength } from "./types.ts";
31
+ } from "#/yoga/generated/YGEnums.ts";
32
32
 
33
33
  const EDGE_COUNT = 9;
34
34
  const GUTTER_COUNT = 3;
@@ -3,8 +3,8 @@
3
3
 
4
4
  // Port of yoga/style/StyleLength.h and yoga/style/StyleSizeLength.h.
5
5
 
6
- import { Unit } from "../generated/YGEnums.ts";
7
- import { isUndefined, optionalEquals, inexactEquals } from "./numeric.ts";
6
+ import { isUndefined, optionalEquals, inexactEquals } from "#/yoga/core/numeric.ts";
7
+ import { Unit } from "#/yoga/generated/YGEnums.ts";
8
8
 
9
9
  function isInvalidValue(value: number): boolean {
10
10
  return isUndefined(value) || !Number.isFinite(value);
package/src/yoga/index.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Derived from Yoga. See THIRD_PARTY_NOTICES.md.
3
3
 
4
- import { Config } from "./config.ts";
5
- import { constants as YGEnums } from "./generated/YGEnums.ts";
6
- import { Node } from "./node.ts";
4
+ import { Config } from "#/yoga/config.ts";
5
+ import { constants as YGEnums } from "#/yoga/generated/YGEnums.ts";
6
+ import { Node } from "#/yoga/node.ts";
7
7
 
8
- export type { Config } from "./config.ts";
9
- export type { DirtiedFunction, MeasureFunction, Node } from "./node.ts";
8
+ export type { Config } from "#/yoga/config.ts";
9
+ export type { DirtiedFunction, MeasureFunction, Node } from "#/yoga/node.ts";
10
10
 
11
11
  export const Yoga = {
12
12
  Config,
@@ -16,4 +16,4 @@ export const Yoga = {
16
16
 
17
17
  export type Yoga = typeof Yoga;
18
18
 
19
- export * from "./generated/YGEnums.ts";
19
+ export * from "#/yoga/generated/YGEnums.ts";
package/src/yoga/node.ts CHANGED
@@ -4,13 +4,13 @@
4
4
  // Public Yoga API on the engine node itself. This keeps the WASM-compatible
5
5
  // surface without allocating a separate binding wrapper for every node.
6
6
 
7
- import { Config } from "./config.ts";
8
- import { calculateLayout } from "./core/calculateLayout.ts";
9
- import { getDefaultConfig } from "./core/config.ts";
10
- import { PhysicalEdge } from "./core/helpers.ts";
11
- import { LayoutResults } from "./core/layoutResults.ts";
12
- import { Node as CoreNode } from "./core/node.ts";
13
- import { StyleLength, StyleSizeLength } from "./core/types.ts";
7
+ import { Config } from "#/yoga/config.ts";
8
+ import { calculateLayout } from "#/yoga/core/calculateLayout.ts";
9
+ import { getDefaultConfig } from "#/yoga/core/config.ts";
10
+ import { PhysicalEdge } from "#/yoga/core/helpers.ts";
11
+ import { LayoutResults } from "#/yoga/core/layoutResults.ts";
12
+ import { Node as CoreNode } from "#/yoga/core/node.ts";
13
+ import { StyleLength, StyleSizeLength } from "#/yoga/core/types.ts";
14
14
  import {
15
15
  Align,
16
16
  BoxSizing,
@@ -26,7 +26,7 @@ import {
26
26
  PositionType,
27
27
  Unit,
28
28
  Wrap,
29
- } from "./generated/YGEnums.ts";
29
+ } from "#/yoga/generated/YGEnums.ts";
30
30
 
31
31
  type Layout = {
32
32
  left: number;
@@ -1,12 +0,0 @@
1
- // Derived from `widest-line` (MIT, Sindre Sorhus).
2
- import { stringWidth } from "./string-width.ts";
3
-
4
- export const widestLine = (string: string): number => {
5
- let lineWidth = 0;
6
-
7
- for (const line of string.split("\n")) {
8
- lineWidth = Math.max(lineWidth, stringWidth(line));
9
- }
10
-
11
- return lineWidth;
12
- };
package/src/auto-bind.ts DELETED
@@ -1,41 +0,0 @@
1
- // Derived from `auto-bind` (MIT, Sindre Sorhus), reduced to the surface Ink uses.
2
- // Reflective prototype-walking code: the broad `object` type is the right one here.
3
- /* eslint-disable @typescript-eslint/no-restricted-types */
4
-
5
- // Gets all non-builtin properties up the prototype chain.
6
- const getAllProperties = (object: object): Array<[object, string | symbol]> => {
7
- const properties: Array<[object, string | symbol]> = [];
8
- let current: object | null = object;
9
-
10
- do {
11
- for (const key of Reflect.ownKeys(current)) {
12
- properties.push([current, key]);
13
- }
14
-
15
- current = Reflect.getPrototypeOf(current);
16
- } while (current && current !== Object.prototype);
17
-
18
- return properties;
19
- };
20
-
21
- export const autoBind = <T extends object>(self: T): T => {
22
- for (const [object, key] of getAllProperties(
23
- (self.constructor as { prototype: object }).prototype,
24
- )) {
25
- if (key === "constructor") {
26
- continue;
27
- }
28
-
29
- const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
30
-
31
- if (descriptor && typeof descriptor.value === "function") {
32
- const value = (self as Record<string | symbol, unknown>)[key];
33
-
34
- if (typeof value === "function") {
35
- (self as Record<string | symbol, unknown>)[key] = value.bind(self);
36
- }
37
- }
38
- }
39
-
40
- return self;
41
- };
@@ -1,73 +0,0 @@
1
- // Ignoring missing types error to avoid adding another dependency for this hack to work
2
- import ws from "ws";
3
-
4
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
5
- const customGlobal = globalThis as any;
6
-
7
- // These things must exist before importing `react-devtools-core`
8
- // Using ||= intentionally to set falsy values, not just null/undefined
9
-
10
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
11
- customGlobal.WebSocket ||= ws;
12
-
13
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
14
- customGlobal.window ||= globalThis;
15
-
16
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
17
- customGlobal.self ||= globalThis;
18
-
19
- // Filter out Ink's internal components from devtools for a cleaner view.
20
- // Also, ince `react-devtools-shared` package isn't published on npm, we can't
21
- // use its types, that's why there are hard-coded values in `type` fields below.
22
- // See https://github.com/facebook/react/blob/edf6eac8a181860fd8a2d076a43806f1237495a1/packages/react-devtools-shared/src/types.js#L24
23
- customGlobal.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = [
24
- {
25
- // ComponentFilterElementType
26
- type: 1,
27
- // ElementTypeHostComponent
28
- value: 7,
29
- isEnabled: true,
30
- },
31
- {
32
- // ComponentFilterDisplayName
33
- type: 2,
34
- value: "InternalApp",
35
- isEnabled: true,
36
- isValid: true,
37
- },
38
- {
39
- // ComponentFilterDisplayName
40
- type: 2,
41
- value: "InternalAppContext",
42
- isEnabled: true,
43
- isValid: true,
44
- },
45
- {
46
- // ComponentFilterDisplayName
47
- type: 2,
48
- value: "InternalStdoutContext",
49
- isEnabled: true,
50
- isValid: true,
51
- },
52
- {
53
- // ComponentFilterDisplayName
54
- type: 2,
55
- value: "InternalStderrContext",
56
- isEnabled: true,
57
- isValid: true,
58
- },
59
- {
60
- // ComponentFilterDisplayName
61
- type: 2,
62
- value: "InternalStdinContext",
63
- isEnabled: true,
64
- isValid: true,
65
- },
66
- {
67
- // ComponentFilterDisplayName
68
- type: 2,
69
- value: "InternalFocusContext",
70
- isEnabled: true,
71
- isValid: true,
72
- },
73
- ];
@@ -1,16 +0,0 @@
1
- // Derived from `indent-string` (MIT, Sindre Sorhus), reduced to the surface Ink uses.
2
- export const indentString = (
3
- string: string,
4
- count = 1,
5
- options: { indent?: string; includeEmptyLines?: boolean } = {},
6
- ): string => {
7
- const { indent = " ", includeEmptyLines = false } = options;
8
-
9
- if (count === 0) {
10
- return string;
11
- }
12
-
13
- const regex = includeEmptyLines ? /^/gm : /^(?!\s*$)/gm;
14
-
15
- return string.replace(regex, indent.repeat(count));
16
- };
package/src/is-in-ci.ts DELETED
@@ -1,7 +0,0 @@
1
- // Derived from `is-in-ci` (MIT, Sindre Sorhus).
2
- import process from "node:process";
3
-
4
- const check = (key: string): boolean =>
5
- key in process.env && process.env[key] !== "0" && process.env[key] !== "false";
6
-
7
- export const isInCi = check("CI") || check("CONTINUOUS_INTEGRATION");
@@ -1,9 +0,0 @@
1
- import { isInCi } from "./is-in-ci.ts";
2
-
3
- export function shouldSynchronize(stream: NodeJS.WritableStream, interactive?: boolean): boolean {
4
- return (
5
- "isTTY" in stream &&
6
- (stream as NodeJS.WritableStream & { isTTY: boolean }).isTTY &&
7
- (interactive ?? !isInCi)
8
- );
9
- }