@alchemy.run/sigil 0.0.0-alpha.1 → 0.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +299 -299
- package/dist/ansi.d.ts +223 -0
- package/dist/ansi.js +2 -0
- package/dist/{devtools-QpCMm9JH.mjs → devtools-BhYGjb7h.js} +1 -1
- package/dist/index-DDVME65c.d.ts +919 -0
- package/dist/index.d.ts +1657 -0
- package/dist/index.js +4643 -0
- package/dist/sgr-CMfEpjSk.d.ts +91 -0
- package/dist/truncate-CBiyyZzw.js +2156 -0
- package/dist/yoga-5jKhYCJC.js +3465 -0
- package/dist/yoga.d.ts +2 -0
- package/dist/yoga.js +2 -0
- package/package.json +37 -17
- package/src/ansi/chalk.ts +179 -0
- package/src/ansi/cursor.ts +48 -0
- package/src/ansi/east-asian-width.ts +215 -0
- package/src/ansi/escapes.ts +128 -0
- package/src/ansi/index.ts +27 -0
- package/src/ansi/sgr.ts +237 -0
- package/src/ansi/slice.ts +43 -0
- package/src/ansi/string-width.ts +236 -0
- package/src/ansi/strip.ts +33 -0
- package/src/ansi/supports-color.ts +213 -0
- package/src/ansi/tokenize.ts +453 -0
- package/src/ansi/truncate.ts +194 -0
- package/src/ansi/widest-line.ts +12 -0
- package/src/ansi/wrap.ts +766 -0
- package/src/ansi-tokenizer.ts +510 -0
- package/src/auto-bind.ts +41 -0
- package/src/boxes.ts +100 -0
- package/src/code-excerpt.ts +39 -0
- package/src/colorize.ts +60 -0
- package/src/components/AccessibilityContext.ts +5 -0
- package/src/components/AnimationContext.ts +24 -0
- package/src/components/App.tsx +781 -0
- package/src/components/AppContext.ts +111 -0
- package/src/components/BackgroundContext.ts +8 -0
- package/src/components/Box.tsx +116 -0
- package/src/components/CursorContext.ts +19 -0
- package/src/components/ErrorBoundary.tsx +38 -0
- package/src/components/ErrorOverview.tsx +133 -0
- package/src/components/FocusContext.ts +30 -0
- package/src/components/Newline.tsx +15 -0
- package/src/components/Spacer.tsx +10 -0
- package/src/components/Static.tsx +59 -0
- package/src/components/StderrContext.ts +26 -0
- package/src/components/StdinContext.ts +49 -0
- package/src/components/StdoutContext.ts +28 -0
- package/src/components/Text.tsx +144 -0
- package/src/components/Transform.tsx +37 -0
- package/src/cursor-position.ts +103 -0
- package/src/devtools-window-polyfill.ts +73 -0
- package/src/devtools.ts +43 -0
- package/src/dom.ts +292 -0
- package/src/get-max-width.ts +11 -0
- package/src/global.d.ts +36 -0
- package/src/hooks/use-animation.ts +142 -0
- package/src/hooks/use-app.ts +8 -0
- package/src/hooks/use-box-metrics.ts +134 -0
- package/src/hooks/use-cursor.ts +33 -0
- package/src/hooks/use-focus-manager.ts +62 -0
- package/src/hooks/use-focus.ts +83 -0
- package/src/hooks/use-input.ts +267 -0
- package/src/hooks/use-is-screen-reader-enabled.ts +12 -0
- package/src/hooks/use-paste.ts +78 -0
- package/src/hooks/use-stderr.ts +8 -0
- package/src/hooks/use-stdin.ts +10 -0
- package/src/hooks/use-stdout.ts +8 -0
- package/src/hooks/use-window-size.ts +41 -0
- package/src/indent-string.ts +16 -0
- package/src/index.ts +44 -0
- package/src/ink.tsx +1506 -0
- package/src/input-parser.ts +283 -0
- package/src/instances.ts +9 -0
- package/src/is-in-ci.ts +7 -0
- package/src/kitty-keyboard.ts +57 -0
- package/src/log-update.ts +370 -0
- package/src/measure-element.ts +62 -0
- package/src/measure-text.ts +31 -0
- package/src/output.ts +308 -0
- package/src/parse-keypress.ts +516 -0
- package/src/parse-stack-line.ts +139 -0
- package/src/patch-console.ts +62 -0
- package/src/quick-lru.ts +85 -0
- package/src/reconciler.ts +451 -0
- package/src/render-background.ts +38 -0
- package/src/render-border.ts +134 -0
- package/src/render-node-to-output.ts +191 -0
- package/src/render-to-string.ts +131 -0
- package/src/render.ts +276 -0
- package/src/renderer.ts +73 -0
- package/src/sanitize-ansi.ts +33 -0
- package/src/signal-exit.ts +107 -0
- package/src/squash-text-nodes.ts +40 -0
- package/src/stream.ts +30 -0
- package/src/styles.ts +748 -0
- package/src/terminal-size.ts +57 -0
- package/src/throttle.ts +73 -0
- package/src/types.ts +15 -0
- package/src/utils.ts +40 -0
- package/src/wrap-text.ts +50 -0
- package/src/write-synchronized.ts +9 -0
- package/src/yoga/config.ts +57 -0
- package/src/yoga/core/absoluteLayout.ts +626 -0
- package/src/yoga/core/baseline.ts +66 -0
- package/src/yoga/core/cache.ts +136 -0
- package/src/yoga/core/calculateLayout.ts +2920 -0
- package/src/yoga/core/config.ts +104 -0
- package/src/yoga/core/flexLine.ts +177 -0
- package/src/yoga/core/helpers.ts +293 -0
- package/src/yoga/core/layoutResults.ts +167 -0
- package/src/yoga/core/node.ts +611 -0
- package/src/yoga/core/numeric.ts +44 -0
- package/src/yoga/core/pixelGrid.ts +151 -0
- package/src/yoga/core/style.ts +887 -0
- package/src/yoga/core/types.ts +224 -0
- package/src/yoga/generated/YGEnums.ts +263 -0
- package/src/yoga/index.ts +19 -0
- package/src/yoga/node.ts +1140 -0
- package/dist/index.d.mts +0 -2379
- package/dist/index.mjs +0 -10072
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Derived from Yoga. See THIRD_PARTY_NOTICES.md.
|
|
3
|
+
|
|
4
|
+
// Port of yoga/node/LayoutResults.h and yoga/node/CachedMeasurement.h.
|
|
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";
|
|
10
|
+
|
|
11
|
+
export class CachedMeasurement {
|
|
12
|
+
availableWidth = -1;
|
|
13
|
+
availableHeight = -1;
|
|
14
|
+
widthSizingMode: SizingMode = SizingMode.MaxContent;
|
|
15
|
+
heightSizingMode: SizingMode = SizingMode.MaxContent;
|
|
16
|
+
|
|
17
|
+
computedWidth = -1;
|
|
18
|
+
computedHeight = -1;
|
|
19
|
+
|
|
20
|
+
equals(measurement: CachedMeasurement): boolean {
|
|
21
|
+
let isEqual =
|
|
22
|
+
this.widthSizingMode === measurement.widthSizingMode &&
|
|
23
|
+
this.heightSizingMode === measurement.heightSizingMode;
|
|
24
|
+
|
|
25
|
+
if (!isUndefined(this.availableWidth) || !isUndefined(measurement.availableWidth)) {
|
|
26
|
+
isEqual = isEqual && this.availableWidth === measurement.availableWidth;
|
|
27
|
+
}
|
|
28
|
+
if (!isUndefined(this.availableHeight) || !isUndefined(measurement.availableHeight)) {
|
|
29
|
+
isEqual = isEqual && this.availableHeight === measurement.availableHeight;
|
|
30
|
+
}
|
|
31
|
+
if (!isUndefined(this.computedWidth) || !isUndefined(measurement.computedWidth)) {
|
|
32
|
+
isEqual = isEqual && this.computedWidth === measurement.computedWidth;
|
|
33
|
+
}
|
|
34
|
+
if (!isUndefined(this.computedHeight) || !isUndefined(measurement.computedHeight)) {
|
|
35
|
+
isEqual = isEqual && this.computedHeight === measurement.computedHeight;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return isEqual;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class LayoutResults {
|
|
43
|
+
// This value was chosen based on empirical data:
|
|
44
|
+
// 98% of analyzed layouts require less than 8 entries.
|
|
45
|
+
static readonly MaxCachedMeasurements = 8;
|
|
46
|
+
|
|
47
|
+
computedFlexBasisGeneration = 0;
|
|
48
|
+
computedFlexBasis = NaN;
|
|
49
|
+
|
|
50
|
+
// Per-flex-item floor along the main axis derived from CSS Flexbox §4.5
|
|
51
|
+
// automatic minimum sizing. NaN means "no auto-min applies."
|
|
52
|
+
computedAutoMinMainSize = NaN;
|
|
53
|
+
|
|
54
|
+
// Instead of recomputing the entire layout every single time, we cache some
|
|
55
|
+
// information to break early when nothing changed
|
|
56
|
+
generationCount = 0;
|
|
57
|
+
configVersion = 0;
|
|
58
|
+
lastOwnerDirection: Direction = Direction.Inherit;
|
|
59
|
+
|
|
60
|
+
nextCachedMeasurementsIndex = 0;
|
|
61
|
+
// Entries are allocated lazily on first write; reads are gated by
|
|
62
|
+
// nextCachedMeasurementsIndex so unwritten slots are never observed.
|
|
63
|
+
cachedMeasurements: CachedMeasurement[] = [];
|
|
64
|
+
|
|
65
|
+
// Pixel-grid bookkeeping: true when this node or any descendant had a
|
|
66
|
+
// position/dimension write (or text-rounding change) since the last
|
|
67
|
+
// rounding pass. Together with the last-seen absolute offsets this lets
|
|
68
|
+
// roundLayoutResultsToPixelGrid skip subtrees whose inputs are unchanged —
|
|
69
|
+
// the pass is deterministic, so skipping is output-identical.
|
|
70
|
+
roundingDirty = true;
|
|
71
|
+
roundedAbsLeft = NaN;
|
|
72
|
+
roundedAbsTop = NaN;
|
|
73
|
+
roundedScale = NaN;
|
|
74
|
+
|
|
75
|
+
cachedLayout: CachedMeasurement = new CachedMeasurement();
|
|
76
|
+
|
|
77
|
+
// Lazily-created scratch state reused by flex layout passes. Keeping this
|
|
78
|
+
// per node makes recursive and cross-tree layouts independent while
|
|
79
|
+
// removing per-line arrays and objects from repeat layouts.
|
|
80
|
+
flexLine: FlexLine | null = null;
|
|
81
|
+
flexLineStarts: number[] | null = null;
|
|
82
|
+
|
|
83
|
+
private direction_: Direction = Direction.Inherit;
|
|
84
|
+
private hadOverflow_ = false;
|
|
85
|
+
|
|
86
|
+
// All float layout state lives in one packed numeric array. Writes are
|
|
87
|
+
// kept as native JavaScript numbers to avoid repeated float32 coercion.
|
|
88
|
+
// Layout: [0-1] dimensions, [2-3] measuredDimensions, [4-5] rawDimensions,
|
|
89
|
+
// [6-9] position, [10-13] margin, [14-17] border, [18-21] padding.
|
|
90
|
+
private values_: number[] = initialLayoutValues();
|
|
91
|
+
|
|
92
|
+
direction(): Direction {
|
|
93
|
+
return this.direction_;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
setDirection(direction: Direction): void {
|
|
97
|
+
this.direction_ = direction;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
hadOverflow(): boolean {
|
|
101
|
+
return this.hadOverflow_;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
setHadOverflow(hadOverflow: boolean): void {
|
|
105
|
+
this.hadOverflow_ = hadOverflow;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
dimension(axis: Dimension): number {
|
|
109
|
+
return this.values_[axis]!;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
setDimension(axis: Dimension, dimension: number): void {
|
|
113
|
+
this.values_[axis] = dimension;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
measuredDimension(axis: Dimension): number {
|
|
117
|
+
return this.values_[2 + axis]!;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
rawDimension(axis: Dimension): number {
|
|
121
|
+
return this.values_[4 + axis]!;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
setMeasuredDimension(axis: Dimension, dimension: number): void {
|
|
125
|
+
this.values_[2 + axis] = dimension;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
setRawDimension(axis: Dimension, dimension: number): void {
|
|
129
|
+
this.values_[4 + axis] = dimension;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
position(physicalEdge: PhysicalEdge): number {
|
|
133
|
+
return this.values_[6 + physicalEdge]!;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
setPosition(physicalEdge: PhysicalEdge, dimension: number): void {
|
|
137
|
+
this.values_[6 + physicalEdge] = dimension;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
margin(physicalEdge: PhysicalEdge): number {
|
|
141
|
+
return this.values_[10 + physicalEdge]!;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
setMargin(physicalEdge: PhysicalEdge, dimension: number): void {
|
|
145
|
+
this.values_[10 + physicalEdge] = dimension;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
border(physicalEdge: PhysicalEdge): number {
|
|
149
|
+
return this.values_[14 + physicalEdge]!;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
setBorder(physicalEdge: PhysicalEdge, dimension: number): void {
|
|
153
|
+
this.values_[14 + physicalEdge] = dimension;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
padding(physicalEdge: PhysicalEdge): number {
|
|
157
|
+
return this.values_[18 + physicalEdge]!;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
setPadding(physicalEdge: PhysicalEdge, dimension: number): void {
|
|
161
|
+
this.values_[18 + physicalEdge] = dimension;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function initialLayoutValues(): number[] {
|
|
166
|
+
return [NaN, NaN, NaN, NaN, NaN, NaN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
167
|
+
}
|