ink 4.4.1 → 5.0.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.
- package/build/apply-styles.js +175 -0
- package/build/build-layout.js +77 -0
- package/build/calculate-wrapped-text.js +53 -0
- package/build/colorize.js.map +1 -1
- package/build/components/App.d.ts +1 -1
- package/build/components/App.js +198 -296
- package/build/components/App.js.map +1 -1
- package/build/components/AppContext.js +1 -1
- package/build/components/Box.d.ts +51 -1
- package/build/components/Box.js +2 -2
- package/build/components/Color.js +62 -0
- package/build/components/ErrorOverview.js +1 -1
- package/build/components/ErrorOverview.js.map +1 -1
- package/build/components/FocusContext.js +1 -1
- package/build/components/Static.js +1 -1
- package/build/components/StderrContext.js +1 -1
- package/build/components/StdinContext.js +1 -1
- package/build/components/StdoutContext.js +1 -1
- package/build/components/Text.d.ts +1 -1
- package/build/components/Text.js +1 -1
- package/build/components/Text.js.map +1 -1
- package/build/components/Transform.js.map +1 -1
- package/build/devtools-window-polyfill.js +11 -17
- package/build/devtools-window-polyfill.js.map +1 -1
- package/build/dom.js +2 -3
- package/build/dom.js.map +1 -1
- package/build/experimental/apply-style.js +140 -0
- package/build/experimental/dom.js +123 -0
- package/build/experimental/output.js +91 -0
- package/build/experimental/reconciler.js +141 -0
- package/build/experimental/renderer.js +81 -0
- package/build/get-max-width.js +0 -1
- package/build/get-max-width.js.map +1 -1
- package/build/hooks/use-focus-manager.js +1 -1
- package/build/hooks/use-focus.d.ts +1 -1
- package/build/hooks/use-focus.js +2 -2
- package/build/hooks/use-focus.js.map +1 -1
- package/build/hooks/use-input.js +2 -3
- package/build/hooks/use-input.js.map +1 -1
- package/build/hooks/useInput.js +38 -0
- package/build/ink.js +81 -170
- package/build/ink.js.map +1 -1
- package/build/instance.js +205 -0
- package/build/log-update.d.ts +1 -0
- package/build/log-update.js.map +1 -1
- package/build/measure-element.js +1 -1
- package/build/measure-text.js +1 -1
- package/build/measure-text.js.map +1 -1
- package/build/output.js +11 -26
- package/build/output.js.map +1 -1
- package/build/parse-keypress.d.ts +1 -0
- package/build/parse-keypress.js +4 -4
- package/build/parse-keypress.js.map +1 -1
- package/build/reconciler.js +9 -7
- package/build/reconciler.js.map +1 -1
- package/build/render-border.js +1 -1
- package/build/render-border.js.map +1 -1
- package/build/render-node-to-output.js +2 -3
- package/build/render-node-to-output.js.map +1 -1
- package/build/render.d.ts +4 -0
- package/build/render.js +3 -3
- package/build/render.js.map +1 -1
- package/build/renderer.js +5 -5
- package/build/renderer.js.map +1 -1
- package/build/squash-text-nodes.js.map +1 -1
- package/build/styles.d.ts +1 -1
- package/build/styles.js +0 -1
- package/build/styles.js.map +1 -1
- package/build/wrap-text.js +1 -1
- package/build/wrap-text.js.map +1 -1
- package/package.json +35 -39
- package/readme.md +5 -18
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _arrify = _interopRequireDefault(require("arrify"));
|
|
13
|
+
|
|
14
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
19
|
+
|
|
20
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
21
|
+
|
|
22
|
+
const methods = ['hex', 'hsl', 'hsv', 'hwb', 'rgb', 'keyword', 'bgHex', 'bgHsl', 'bgHsv', 'bgHwb', 'bgRgb', 'bgKeyword'];
|
|
23
|
+
|
|
24
|
+
const Color = (_ref) => {
|
|
25
|
+
let {
|
|
26
|
+
children
|
|
27
|
+
} = _ref,
|
|
28
|
+
colorProps = _objectWithoutProperties(_ref, ["children"]);
|
|
29
|
+
|
|
30
|
+
if (children === '') {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const transformChildren = children => {
|
|
35
|
+
Object.keys(colorProps).forEach(method => {
|
|
36
|
+
if (colorProps[method]) {
|
|
37
|
+
if (methods.includes(method)) {
|
|
38
|
+
children = _chalk.default[method](...(0, _arrify.default)(colorProps[method]))(children);
|
|
39
|
+
} else if (typeof _chalk.default[method] === 'function') {
|
|
40
|
+
children = _chalk.default[method](children);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return children;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return _react.default.createElement("span", {
|
|
48
|
+
style: {
|
|
49
|
+
flexDirection: 'row'
|
|
50
|
+
},
|
|
51
|
+
unstable__transformChildren: transformChildren
|
|
52
|
+
}, children);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
Color.propTypes = {
|
|
56
|
+
children: _propTypes.default.node
|
|
57
|
+
};
|
|
58
|
+
Color.defaultProps = {
|
|
59
|
+
children: ''
|
|
60
|
+
};
|
|
61
|
+
var _default = Color;
|
|
62
|
+
exports.default = _default;
|
|
@@ -12,7 +12,7 @@ const cleanupPath = (path) => {
|
|
|
12
12
|
};
|
|
13
13
|
const stackUtils = new StackUtils({
|
|
14
14
|
cwd: cwd(),
|
|
15
|
-
internals: StackUtils.nodeInternals()
|
|
15
|
+
internals: StackUtils.nodeInternals(),
|
|
16
16
|
});
|
|
17
17
|
export default function ErrorOverview({ error }) {
|
|
18
18
|
const stack = error.stack ? error.stack.split('\n').slice(1) : undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorOverview.js","sourceRoot":"","sources":["../../src/components/ErrorOverview.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,GAAG,EAAC,MAAM,cAAc,CAAC;AACjC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,WAA+B,MAAM,cAAc,CAAC;AAC3D,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,+DAA+D;AAC/D,8CAA8C;AAC9C,MAAM,WAAW,GAAG,CAAC,IAAwB,EAAsB,EAAE;IACpE,OAAO,IAAI,EAAE,OAAO,CAAC,UAAU,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC;IACjC,GAAG,EAAE,GAAG,EAAE;IACV,SAAS,EAAE,UAAU,CAAC,aAAa,EAAE;CACrC,CAAC,CAAC;AAMH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAC,KAAK,EAAQ;IACnD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACzE,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC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AAU;oBACxB,oBAAC,IAAI,IAAC,QAAQ,QAAC,IAAI,UACjB,IAAI,CACC,CACF,CACN,CAAC;YACH,CAAC;YAED,OAAO,CACN,oBAAC,GAAG,IAAC,GAAG,EAAE,IAAI;gBACb,oBAAC,IAAI,IAAC,QAAQ,eAAU;gBACxB,oBAAC,IAAI,IAAC,QAAQ,QAAC,IAAI,UACjB,UAAU,CAAC,QAAQ,CACd;gBACP,oBAAC,IAAI,IAAC,QAAQ,QAAC,KAAK,EAAC,MAAM;oBACzB,GAAG;;oBACF,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE;;oBAAG,UAAU,CAAC,IAAI;;oBACrD,UAAU,CAAC,MAAM;wBACZ,CACF,CACN,CAAC;QACH,CAAC,CAAC,CACE,CACN,CACI,CACN,CAAC;AACH,CAAC"}
|
|
@@ -26,7 +26,7 @@ export default function Static(props) {
|
|
|
26
26
|
const style = useMemo(() => ({
|
|
27
27
|
position: 'absolute',
|
|
28
28
|
flexDirection: 'column',
|
|
29
|
-
...customStyle
|
|
29
|
+
...customStyle,
|
|
30
30
|
}), [customStyle]);
|
|
31
31
|
return (React.createElement("ink-box", { internal_static: true, style: style }, children));
|
|
32
32
|
}
|
|
@@ -6,7 +6,7 @@ import { createContext } from 'react';
|
|
|
6
6
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
7
|
const StderrContext = createContext({
|
|
8
8
|
stderr: process.stderr,
|
|
9
|
-
write() { }
|
|
9
|
+
write() { },
|
|
10
10
|
});
|
|
11
11
|
StderrContext.displayName = 'InternalStderrContext';
|
|
12
12
|
export default StderrContext;
|
|
@@ -12,7 +12,7 @@ const StdinContext = createContext({
|
|
|
12
12
|
setRawMode() { },
|
|
13
13
|
isRawModeSupported: false,
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
15
|
-
internal_exitOnCtrlC: true
|
|
15
|
+
internal_exitOnCtrlC: true,
|
|
16
16
|
});
|
|
17
17
|
StdinContext.displayName = 'InternalStdinContext';
|
|
18
18
|
export default StdinContext;
|
|
@@ -6,7 +6,7 @@ import { createContext } from 'react';
|
|
|
6
6
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
7
|
const StdoutContext = createContext({
|
|
8
8
|
stdout: process.stdout,
|
|
9
|
-
write() { }
|
|
9
|
+
write() { },
|
|
10
10
|
});
|
|
11
11
|
StdoutContext.displayName = 'InternalStdoutContext';
|
|
12
12
|
export default StdoutContext;
|
|
@@ -46,4 +46,4 @@ export type Props = {
|
|
|
46
46
|
/**
|
|
47
47
|
* This component can display text, and change its style to make it colorful, bold, underline, italic or strikethrough.
|
|
48
48
|
*/
|
|
49
|
-
export default function Text({ color, backgroundColor, dimColor, bold, italic, underline, strikethrough, inverse, wrap, children }: Props): React.JSX.Element | null;
|
|
49
|
+
export default function Text({ color, backgroundColor, dimColor, bold, italic, underline, strikethrough, inverse, wrap, children, }: Props): React.JSX.Element | null;
|
package/build/components/Text.js
CHANGED
|
@@ -4,7 +4,7 @@ import colorize from '../colorize.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* This component can display text, and change its style to make it colorful, bold, underline, italic or strikethrough.
|
|
6
6
|
*/
|
|
7
|
-
export default function Text({ color, backgroundColor, dimColor = false, bold = false, italic = false, underline = false, strikethrough = false, inverse = false, wrap = 'wrap', children }) {
|
|
7
|
+
export default function Text({ color, backgroundColor, dimColor = false, bold = false, italic = false, underline = false, strikethrough = false, inverse = false, wrap = 'wrap', children, }) {
|
|
8
8
|
if (children === undefined || children === null) {
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.js","sourceRoot":"","sources":["../../src/components/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuB,MAAM,OAAO,CAAC;AAC5C,OAAO,KAAiC,MAAM,OAAO,CAAC;AAEtD,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAsDtC;;GAEG;AACH,MAAM,CAAC,O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AAI,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;QAED,IAAI,MAAM,EAAE,CAAC;YACZ,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnC,CAAC;QAED,IAAI,SAAS,EAAE,CAAC;YACf,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,aAAa,EAAE,CAAC;YACnB,QAAQ,GAAG,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC;QAED,IAAI,OAAO,EAAE,CAAC;YACb,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;QAED,OAAO,QAAQ,CAAC;IACjB,CAAC,CAAC;IAEF,OAAO,CACN,kCACC,KAAK,EAAE,EAAC,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAC,EACzE,kBAAkB,EAAE,SAAS,IAE5B,QAAQ,CACC,CACX,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transform.js","sourceRoot":"","sources":["../../src/components/Transform.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuB,MAAM,OAAO,CAAC;AAW5C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAAC,QAAQ,EAAE,SAAS,EAAQ;IAC7D,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,EAAE;
|
|
1
|
+
{"version":3,"file":"Transform.js","sourceRoot":"","sources":["../../src/components/Transform.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuB,MAAM,OAAO,CAAC;AAW5C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAAC,QAAQ,EAAE,SAAS,EAAQ;IAC7D,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACjD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,CACN,kCACC,KAAK,EAAE,EAAC,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,aAAa,EAAE,KAAK,EAAC,EACzD,kBAAkB,EAAE,SAAS,IAE5B,QAAQ,CACC,CACX,CAAC;AACH,CAAC"}
|
|
@@ -3,15 +3,9 @@ import ws from 'ws';
|
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
4
4
|
const customGlobal = global;
|
|
5
5
|
// These things must exist before importing `react-devtools-core`
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (!customGlobal.window) {
|
|
10
|
-
customGlobal.window = global;
|
|
11
|
-
}
|
|
12
|
-
if (!customGlobal.self) {
|
|
13
|
-
customGlobal.self = global;
|
|
14
|
-
}
|
|
6
|
+
customGlobal.WebSocket ||= ws;
|
|
7
|
+
customGlobal.window ||= global;
|
|
8
|
+
customGlobal.self ||= global;
|
|
15
9
|
// Filter out Ink's internal components from devtools for a cleaner view.
|
|
16
10
|
// Also, ince `react-devtools-shared` package isn't published on npm, we can't
|
|
17
11
|
// use its types, that's why there are hard-coded values in `type` fields below.
|
|
@@ -22,49 +16,49 @@ customGlobal.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = [
|
|
|
22
16
|
type: 1,
|
|
23
17
|
// ElementTypeHostComponent
|
|
24
18
|
value: 7,
|
|
25
|
-
isEnabled: true
|
|
19
|
+
isEnabled: true,
|
|
26
20
|
},
|
|
27
21
|
{
|
|
28
22
|
// ComponentFilterDisplayName
|
|
29
23
|
type: 2,
|
|
30
24
|
value: 'InternalApp',
|
|
31
25
|
isEnabled: true,
|
|
32
|
-
isValid: true
|
|
26
|
+
isValid: true,
|
|
33
27
|
},
|
|
34
28
|
{
|
|
35
29
|
// ComponentFilterDisplayName
|
|
36
30
|
type: 2,
|
|
37
31
|
value: 'InternalAppContext',
|
|
38
32
|
isEnabled: true,
|
|
39
|
-
isValid: true
|
|
33
|
+
isValid: true,
|
|
40
34
|
},
|
|
41
35
|
{
|
|
42
36
|
// ComponentFilterDisplayName
|
|
43
37
|
type: 2,
|
|
44
38
|
value: 'InternalStdoutContext',
|
|
45
39
|
isEnabled: true,
|
|
46
|
-
isValid: true
|
|
40
|
+
isValid: true,
|
|
47
41
|
},
|
|
48
42
|
{
|
|
49
43
|
// ComponentFilterDisplayName
|
|
50
44
|
type: 2,
|
|
51
45
|
value: 'InternalStderrContext',
|
|
52
46
|
isEnabled: true,
|
|
53
|
-
isValid: true
|
|
47
|
+
isValid: true,
|
|
54
48
|
},
|
|
55
49
|
{
|
|
56
50
|
// ComponentFilterDisplayName
|
|
57
51
|
type: 2,
|
|
58
52
|
value: 'InternalStdinContext',
|
|
59
53
|
isEnabled: true,
|
|
60
|
-
isValid: true
|
|
54
|
+
isValid: true,
|
|
61
55
|
},
|
|
62
56
|
{
|
|
63
57
|
// ComponentFilterDisplayName
|
|
64
58
|
type: 2,
|
|
65
59
|
value: 'InternalFocusContext',
|
|
66
60
|
isEnabled: true,
|
|
67
|
-
isValid: true
|
|
68
|
-
}
|
|
61
|
+
isValid: true,
|
|
62
|
+
},
|
|
69
63
|
];
|
|
70
64
|
//# sourceMappingURL=devtools-window-polyfill.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtools-window-polyfill.js","sourceRoot":"","sources":["../src/devtools-window-polyfill.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,mEAAmE;AACnE,MAAM,YAAY,GAAG,MAAa,CAAC;AAEnC,iEAAiE;AACjE,
|
|
1
|
+
{"version":3,"file":"devtools-window-polyfill.js","sourceRoot":"","sources":["../src/devtools-window-polyfill.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,m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
1
|
import Yoga from 'yoga-wasm-web/auto';
|
|
3
2
|
import measureText from './measure-text.js';
|
|
4
3
|
import wrapText from './wrap-text.js';
|
|
@@ -10,7 +9,7 @@ export const createNode = (nodeName) => {
|
|
|
10
9
|
attributes: {},
|
|
11
10
|
childNodes: [],
|
|
12
11
|
parentNode: undefined,
|
|
13
|
-
yogaNode: nodeName === 'ink-virtual-text' ? undefined : Yoga.Node.create()
|
|
12
|
+
yogaNode: nodeName === 'ink-virtual-text' ? undefined : Yoga.Node.create(),
|
|
14
13
|
};
|
|
15
14
|
if (nodeName === 'ink-text') {
|
|
16
15
|
node.yogaNode?.setMeasureFunc(measureTextNode.bind(null, node));
|
|
@@ -76,7 +75,7 @@ export const createTextNode = (text) => {
|
|
|
76
75
|
nodeValue: text,
|
|
77
76
|
yogaNode: undefined,
|
|
78
77
|
parentNode: undefined,
|
|
79
|
-
style: {}
|
|
78
|
+
style: {},
|
|
80
79
|
};
|
|
81
80
|
setTextNodeValue(node, text);
|
|
82
81
|
return node;
|
package/build/dom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.js","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"dom.js","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAAA,OAAO,IAA6B,MAAM,oBAAoB,CAAC;AAC/D,OAAO,WAAW,MAAM,mBAAmB,CAAC;AAE5C,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,eAAe,MAAM,wBAAwB,CAAC;AAmDrD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAAsB,EAAc,EAAE;IAChE,MAAM,IAAI,GAAe;QACxB,QAAQ;QACR,KAAK,EAAE,EAAE;QACT,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,SAAS;QACrB,QAAQ,EAAE,QAAQ,KAAK,kBAAkB,CAAC,CAAC,CAAC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,KAAK,EAAE,QAAQ,IAAI,MAAM,CAAC;IAChD,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAEpD,OAAO,WAAW,CAAC,WAAW,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,IAAc,EAAwB,EAAE;IACpE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC;QACvB,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,OAAO,IAAI,CAAC,QAAQ,IAAI,mBAAmB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AAC9D,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CAAC,IAAc,EAAQ,EAAE;IAChD,mEAAmE;IACnE,MAAM,QAAQ,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,QAAQ,EAAE,SAAS,EAAE,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAc,EAAE,IAAY,EAAQ,EAAE;IACtE,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IAED,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACtB,eAAe,CAAC,IAAI,CAAC,CAAC;AACvB,CAAC,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _yogaLayoutPrebuilt = _interopRequireDefault(require("yoga-layout-prebuilt"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
const applyPositionStyles = (node, style) => {
|
|
13
|
+
if (!style.position) {
|
|
14
|
+
node.setPositionType(NaN);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (style.position === 'absolute') {
|
|
18
|
+
node.setPositionType(_yogaLayoutPrebuilt.default.POSITION_TYPE_ABSOLUTE);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const applyMarginStyles = (node, style) => {
|
|
23
|
+
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_START, style.marginLeft || style.marginX || style.margin || 0);
|
|
24
|
+
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_END, style.marginRight || style.marginX || style.margin || 0);
|
|
25
|
+
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_TOP, style.marginTop || style.marginY || style.margin || 0);
|
|
26
|
+
node.setMargin(_yogaLayoutPrebuilt.default.EDGE_BOTTOM, style.marginBottom || style.marginY || style.margin || 0);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const applyPaddingStyles = (node, style) => {
|
|
30
|
+
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_LEFT, style.paddingLeft || style.paddingX || style.padding || 0);
|
|
31
|
+
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_RIGHT, style.paddingRight || style.paddingX || style.padding || 0);
|
|
32
|
+
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_TOP, style.paddingTop || style.paddingY || style.padding || 0);
|
|
33
|
+
node.setPadding(_yogaLayoutPrebuilt.default.EDGE_BOTTOM, style.paddingBottom || style.paddingY || style.padding || 0);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const applyFlexStyles = (node, style) => {
|
|
37
|
+
node.setFlexGrow(style.flexGrow || 0);
|
|
38
|
+
node.setFlexShrink(typeof style.flexShrink === 'number' ? style.flexShrink : 1);
|
|
39
|
+
|
|
40
|
+
if (style.flexDirection === 'row') {
|
|
41
|
+
node.setFlexDirection(_yogaLayoutPrebuilt.default.FLEX_DIRECTION_ROW);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (style.flexDirection === 'row-reverse') {
|
|
45
|
+
node.setFlexDirection(_yogaLayoutPrebuilt.default.FLEX_DIRECTION_ROW_REVERSE);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (style.flexDirection === 'column') {
|
|
49
|
+
node.setFlexDirection(_yogaLayoutPrebuilt.default.FLEX_DIRECTION_COLUMN);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (style.flexDirection === 'column-reverse') {
|
|
53
|
+
node.setFlexDirection(_yogaLayoutPrebuilt.default.FLEX_DIRECTION_COLUMN_REVERSE);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (typeof style.flexBasis === 'number') {
|
|
57
|
+
node.setFlexBasis(style.flexBasis);
|
|
58
|
+
} else if (typeof style.flexBasis === 'string') {
|
|
59
|
+
node.setFlexBasisPercent(parseInt(style.flexBasis, 10));
|
|
60
|
+
} else {
|
|
61
|
+
// This should be replaced with node.setFlexBasisAuto() when new Yoga release is out
|
|
62
|
+
node.setFlexBasis(NaN);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (style.alignItems === 'stretch' || !style.alignItems) {
|
|
66
|
+
node.setAlignItems(_yogaLayoutPrebuilt.default.ALIGN_STRETCH);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (style.alignItems === 'flex-start') {
|
|
70
|
+
node.setAlignItems(_yogaLayoutPrebuilt.default.ALIGN_FLEX_START);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (style.alignItems === 'center') {
|
|
74
|
+
node.setAlignItems(_yogaLayoutPrebuilt.default.ALIGN_CENTER);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (style.alignItems === 'flex-end') {
|
|
78
|
+
node.setAlignItems(_yogaLayoutPrebuilt.default.ALIGN_FLEX_END);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (style.justifyContent === 'flex-start' || !style.justifyContent) {
|
|
82
|
+
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_FLEX_START);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (style.justifyContent === 'center') {
|
|
86
|
+
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_CENTER);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (style.justifyContent === 'flex-end') {
|
|
90
|
+
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_FLEX_END);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (style.justifyContent === 'space-between') {
|
|
94
|
+
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_SPACE_BETWEEN);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (style.justifyContent === 'space-around') {
|
|
98
|
+
node.setJustifyContent(_yogaLayoutPrebuilt.default.JUSTIFY_SPACE_AROUND);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const applyDimensionStyles = (node, style) => {
|
|
103
|
+
if (typeof style.width === 'number') {
|
|
104
|
+
node.setWidth(style.width);
|
|
105
|
+
} else if (typeof style.width === 'string') {
|
|
106
|
+
node.setWidthPercent(parseInt(style.width, 10));
|
|
107
|
+
} else {
|
|
108
|
+
node.setWidthAuto();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (typeof style.height === 'number') {
|
|
112
|
+
node.setHeight(style.height);
|
|
113
|
+
} else if (typeof style.height === 'string') {
|
|
114
|
+
node.setHeightPercent(parseInt(style.height, 10));
|
|
115
|
+
} else {
|
|
116
|
+
node.setHeightAuto();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (typeof style.minWidth === 'string') {
|
|
120
|
+
node.setMinWidthPercent(parseInt(style.minWidth, 10));
|
|
121
|
+
} else {
|
|
122
|
+
node.setMinWidth(style.minWidth || 0);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (typeof style.minHeight === 'string') {
|
|
126
|
+
node.setMinHeightPercent(parseInt(style.minHeight, 10));
|
|
127
|
+
} else {
|
|
128
|
+
node.setMinHeight(style.minHeight || 0);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
var _default = (node, style = {}) => {
|
|
133
|
+
applyPositionStyles(node, style);
|
|
134
|
+
applyMarginStyles(node, style);
|
|
135
|
+
applyPaddingStyles(node, style);
|
|
136
|
+
applyFlexStyles(node, style);
|
|
137
|
+
applyDimensionStyles(node, style);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
exports.default = _default;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.setTextContent = exports.createTextNode = exports.setAttribute = exports.setStyle = exports.removeChildNode = exports.insertBeforeNode = exports.appendChildNode = exports.createNode = void 0;
|
|
7
|
+
|
|
8
|
+
var _yogaLayoutPrebuilt = _interopRequireDefault(require("yoga-layout-prebuilt"));
|
|
9
|
+
|
|
10
|
+
var _measureText = _interopRequireDefault(require("../measure-text"));
|
|
11
|
+
|
|
12
|
+
var _applyStyle = _interopRequireDefault(require("./apply-style"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
// Helper utilities implementing some common DOM methods to simplify reconciliation code
|
|
17
|
+
const createNode = tagName => ({
|
|
18
|
+
nodeName: tagName.toUpperCase(),
|
|
19
|
+
style: {},
|
|
20
|
+
attributes: {},
|
|
21
|
+
childNodes: [],
|
|
22
|
+
parentNode: null,
|
|
23
|
+
textContent: null,
|
|
24
|
+
yogaNode: _yogaLayoutPrebuilt.default.Node.create()
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
exports.createNode = createNode;
|
|
28
|
+
|
|
29
|
+
const appendChildNode = (node, childNode) => {
|
|
30
|
+
if (childNode.parentNode) {
|
|
31
|
+
removeChildNode(childNode.parentNode, childNode);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
childNode.parentNode = node;
|
|
35
|
+
node.childNodes.push(childNode);
|
|
36
|
+
node.yogaNode.insertChild(childNode.yogaNode, node.yogaNode.getChildCount());
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.appendChildNode = appendChildNode;
|
|
40
|
+
|
|
41
|
+
const insertBeforeNode = (node, newChildNode, beforeChildNode) => {
|
|
42
|
+
if (newChildNode.parentNode) {
|
|
43
|
+
removeChildNode(newChildNode.parentNode, newChildNode);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
newChildNode.parentNode = node;
|
|
47
|
+
const index = node.childNodes.indexOf(beforeChildNode);
|
|
48
|
+
|
|
49
|
+
if (index >= 0) {
|
|
50
|
+
node.childNodes.splice(index, 0, newChildNode);
|
|
51
|
+
node.yogaNode.insertChild(newChildNode.yogaNode, index);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
node.childNodes.push(newChildNode);
|
|
56
|
+
node.yogaNode.insertChild(newChildNode.yogaNode, node.yogaNode.getChildCount());
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
exports.insertBeforeNode = insertBeforeNode;
|
|
60
|
+
|
|
61
|
+
const removeChildNode = (node, removeNode) => {
|
|
62
|
+
removeNode.parentNode.yogaNode.removeChild(removeNode.yogaNode);
|
|
63
|
+
removeNode.parentNode = null;
|
|
64
|
+
const index = node.childNodes.indexOf(removeNode);
|
|
65
|
+
|
|
66
|
+
if (index >= 0) {
|
|
67
|
+
node.childNodes.splice(index, 1);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
exports.removeChildNode = removeChildNode;
|
|
72
|
+
|
|
73
|
+
const setStyle = (node, style) => {
|
|
74
|
+
node.style = style;
|
|
75
|
+
(0, _applyStyle.default)(node.yogaNode, style);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
exports.setStyle = setStyle;
|
|
79
|
+
|
|
80
|
+
const setAttribute = (node, key, value) => {
|
|
81
|
+
node.attributes[key] = value;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
exports.setAttribute = setAttribute;
|
|
85
|
+
|
|
86
|
+
const createTextNode = text => {
|
|
87
|
+
const node = {
|
|
88
|
+
nodeName: '#text',
|
|
89
|
+
nodeValue: text,
|
|
90
|
+
yogaNode: _yogaLayoutPrebuilt.default.Node.create()
|
|
91
|
+
};
|
|
92
|
+
setTextContent(node, text);
|
|
93
|
+
return node;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
exports.createTextNode = createTextNode;
|
|
97
|
+
|
|
98
|
+
const setTextContent = (node, text) => {
|
|
99
|
+
if (typeof text !== 'string') {
|
|
100
|
+
text = String(text);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
let width = 0;
|
|
104
|
+
let height = 0;
|
|
105
|
+
|
|
106
|
+
if (text.length > 0) {
|
|
107
|
+
const dimensions = (0, _measureText.default)(text);
|
|
108
|
+
width = dimensions.width;
|
|
109
|
+
height = dimensions.height;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (node.nodeName === '#text') {
|
|
113
|
+
node.nodeValue = text;
|
|
114
|
+
node.yogaNode.setWidth(width);
|
|
115
|
+
node.yogaNode.setHeight(height);
|
|
116
|
+
} else {
|
|
117
|
+
node.textContent = text;
|
|
118
|
+
node.yogaNode.setWidth(node.style.width || width);
|
|
119
|
+
node.yogaNode.setHeight(node.style.height || height);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
exports.setTextContent = setTextContent;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _stringLength = _interopRequireDefault(require("string-length"));
|
|
9
|
+
|
|
10
|
+
var _sliceAnsi = _interopRequireDefault(require("slice-ansi"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* "Virtual" output class
|
|
16
|
+
*
|
|
17
|
+
* Handles the positioning and saving of the output of each node in the tree.
|
|
18
|
+
* Also responsible for applying transformations to each character of the output.
|
|
19
|
+
*
|
|
20
|
+
* Used to generate the final output of all nodes before writing it to actual output stream (e.g. stdout)
|
|
21
|
+
*/
|
|
22
|
+
class Output {
|
|
23
|
+
constructor({
|
|
24
|
+
width,
|
|
25
|
+
height
|
|
26
|
+
}) {
|
|
27
|
+
this.width = width;
|
|
28
|
+
this.height = height;
|
|
29
|
+
this.writes = []; // Initialize output array with a specific set of rows, so that margin/padding at the bottom is preserved
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
write(x, y, text, {
|
|
33
|
+
transformers
|
|
34
|
+
}) {
|
|
35
|
+
if (!text) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this.writes.push({
|
|
40
|
+
x,
|
|
41
|
+
y,
|
|
42
|
+
text,
|
|
43
|
+
transformers
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
get() {
|
|
48
|
+
const output = [];
|
|
49
|
+
|
|
50
|
+
for (let y = 0; y < this.height; y++) {
|
|
51
|
+
output.push(' '.repeat(this.width));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
for (const write of this.writes) {
|
|
55
|
+
const {
|
|
56
|
+
x,
|
|
57
|
+
y,
|
|
58
|
+
text,
|
|
59
|
+
transformers
|
|
60
|
+
} = write;
|
|
61
|
+
const lines = text.split('\n');
|
|
62
|
+
let offsetY = 0;
|
|
63
|
+
|
|
64
|
+
for (let line of lines) {
|
|
65
|
+
const currentLine = output[y + offsetY]; // Line can be missing if `text` is taller than height of pre-initialized `this.output`
|
|
66
|
+
|
|
67
|
+
if (!currentLine) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const length = (0, _stringLength.default)(line);
|
|
72
|
+
|
|
73
|
+
for (const transformer of transformers) {
|
|
74
|
+
line = transformer(line);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
output[y + offsetY] = (0, _sliceAnsi.default)(currentLine, 0, x) + line + (0, _sliceAnsi.default)(currentLine, x + length);
|
|
78
|
+
offsetY++;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const generatedOutput = output.map(line => line.trimRight()).join('\n');
|
|
83
|
+
return {
|
|
84
|
+
output: generatedOutput,
|
|
85
|
+
height: output.length
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
exports.default = Output;
|