@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,136 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Derived from Yoga. See THIRD_PARTY_NOTICES.md.
|
|
3
|
+
|
|
4
|
+
// Port of yoga/algorithm/Cache.cpp.
|
|
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";
|
|
10
|
+
|
|
11
|
+
function sizeIsExactAndMatchesOldMeasuredSize(
|
|
12
|
+
sizeMode: SizingMode,
|
|
13
|
+
size: number,
|
|
14
|
+
lastComputedSize: number,
|
|
15
|
+
): boolean {
|
|
16
|
+
return sizeMode === SizingMode.StretchFit && inexactEquals(size, lastComputedSize);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function oldSizeIsMaxContentAndStillFits(
|
|
20
|
+
sizeMode: SizingMode,
|
|
21
|
+
size: number,
|
|
22
|
+
lastSizeMode: SizingMode,
|
|
23
|
+
lastComputedSize: number,
|
|
24
|
+
): boolean {
|
|
25
|
+
return (
|
|
26
|
+
sizeMode === SizingMode.FitContent &&
|
|
27
|
+
lastSizeMode === SizingMode.MaxContent &&
|
|
28
|
+
(size >= lastComputedSize || inexactEquals(size, lastComputedSize))
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function newSizeIsStricterAndStillValid(
|
|
33
|
+
sizeMode: SizingMode,
|
|
34
|
+
size: number,
|
|
35
|
+
lastSizeMode: SizingMode,
|
|
36
|
+
lastSize: number,
|
|
37
|
+
lastComputedSize: number,
|
|
38
|
+
): boolean {
|
|
39
|
+
return (
|
|
40
|
+
lastSizeMode === SizingMode.FitContent &&
|
|
41
|
+
sizeMode === SizingMode.FitContent &&
|
|
42
|
+
isDefined(lastSize) &&
|
|
43
|
+
isDefined(size) &&
|
|
44
|
+
isDefined(lastComputedSize) &&
|
|
45
|
+
lastSize > size &&
|
|
46
|
+
(lastComputedSize <= size || inexactEquals(size, lastComputedSize))
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function canUseCachedMeasurement(
|
|
51
|
+
widthMode: SizingMode,
|
|
52
|
+
availableWidth: number,
|
|
53
|
+
heightMode: SizingMode,
|
|
54
|
+
availableHeight: number,
|
|
55
|
+
lastWidthMode: SizingMode,
|
|
56
|
+
lastAvailableWidth: number,
|
|
57
|
+
lastHeightMode: SizingMode,
|
|
58
|
+
lastAvailableHeight: number,
|
|
59
|
+
lastComputedWidth: number,
|
|
60
|
+
lastComputedHeight: number,
|
|
61
|
+
marginRow: number,
|
|
62
|
+
marginColumn: number,
|
|
63
|
+
config: Config,
|
|
64
|
+
): boolean {
|
|
65
|
+
if (
|
|
66
|
+
(isDefined(lastComputedHeight) && lastComputedHeight < 0) ||
|
|
67
|
+
(isDefined(lastComputedWidth) && lastComputedWidth < 0)
|
|
68
|
+
) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const pointScaleFactor = config.getPointScaleFactor();
|
|
73
|
+
|
|
74
|
+
const useRoundedComparison = pointScaleFactor !== 0;
|
|
75
|
+
const effectiveWidth = useRoundedComparison
|
|
76
|
+
? roundValueToPixelGrid(availableWidth, pointScaleFactor, false, false)
|
|
77
|
+
: availableWidth;
|
|
78
|
+
const effectiveHeight = useRoundedComparison
|
|
79
|
+
? roundValueToPixelGrid(availableHeight, pointScaleFactor, false, false)
|
|
80
|
+
: availableHeight;
|
|
81
|
+
const effectiveLastWidth = useRoundedComparison
|
|
82
|
+
? roundValueToPixelGrid(lastAvailableWidth, pointScaleFactor, false, false)
|
|
83
|
+
: lastAvailableWidth;
|
|
84
|
+
const effectiveLastHeight = useRoundedComparison
|
|
85
|
+
? roundValueToPixelGrid(lastAvailableHeight, pointScaleFactor, false, false)
|
|
86
|
+
: lastAvailableHeight;
|
|
87
|
+
|
|
88
|
+
const hasSameWidthSpec =
|
|
89
|
+
lastWidthMode === widthMode && inexactEquals(effectiveLastWidth, effectiveWidth);
|
|
90
|
+
const hasSameHeightSpec =
|
|
91
|
+
lastHeightMode === heightMode && inexactEquals(effectiveLastHeight, effectiveHeight);
|
|
92
|
+
|
|
93
|
+
const widthIsCompatible =
|
|
94
|
+
hasSameWidthSpec ||
|
|
95
|
+
sizeIsExactAndMatchesOldMeasuredSize(
|
|
96
|
+
widthMode,
|
|
97
|
+
availableWidth - marginRow,
|
|
98
|
+
lastComputedWidth,
|
|
99
|
+
) ||
|
|
100
|
+
oldSizeIsMaxContentAndStillFits(
|
|
101
|
+
widthMode,
|
|
102
|
+
availableWidth - marginRow,
|
|
103
|
+
lastWidthMode,
|
|
104
|
+
lastComputedWidth,
|
|
105
|
+
) ||
|
|
106
|
+
newSizeIsStricterAndStillValid(
|
|
107
|
+
widthMode,
|
|
108
|
+
availableWidth - marginRow,
|
|
109
|
+
lastWidthMode,
|
|
110
|
+
lastAvailableWidth,
|
|
111
|
+
lastComputedWidth,
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
const heightIsCompatible =
|
|
115
|
+
hasSameHeightSpec ||
|
|
116
|
+
sizeIsExactAndMatchesOldMeasuredSize(
|
|
117
|
+
heightMode,
|
|
118
|
+
availableHeight - marginColumn,
|
|
119
|
+
lastComputedHeight,
|
|
120
|
+
) ||
|
|
121
|
+
oldSizeIsMaxContentAndStillFits(
|
|
122
|
+
heightMode,
|
|
123
|
+
availableHeight - marginColumn,
|
|
124
|
+
lastHeightMode,
|
|
125
|
+
lastComputedHeight,
|
|
126
|
+
) ||
|
|
127
|
+
newSizeIsStricterAndStillValid(
|
|
128
|
+
heightMode,
|
|
129
|
+
availableHeight - marginColumn,
|
|
130
|
+
lastHeightMode,
|
|
131
|
+
lastAvailableHeight,
|
|
132
|
+
lastComputedHeight,
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
return widthIsCompatible && heightIsCompatible;
|
|
136
|
+
}
|