ccjk 12.2.2 → 12.3.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/dist/chunks/agent-teams.mjs +3 -3
- package/dist/chunks/agent.mjs +2 -2
- package/dist/chunks/agents.mjs +4 -5
- package/dist/chunks/api-cli.mjs +5 -5
- package/dist/chunks/api-providers.mjs +1 -1
- package/dist/chunks/api.mjs +4 -4
- package/dist/chunks/auto-bootstrap.mjs +1 -1
- package/dist/chunks/auto-fixer.mjs +3 -3
- package/dist/chunks/auto-init.mjs +3 -3
- package/dist/chunks/auto-updater.mjs +9 -9
- package/dist/chunks/banner.mjs +2 -2
- package/dist/chunks/boost.mjs +4 -4
- package/dist/chunks/ccjk-agents.mjs +3 -3
- package/dist/chunks/ccjk-all.mjs +6 -6
- package/dist/chunks/ccjk-config.mjs +2 -2
- package/dist/chunks/ccjk-hooks.mjs +4 -4
- package/dist/chunks/ccjk-mcp.mjs +5 -5
- package/dist/chunks/ccjk-setup.mjs +5 -5
- package/dist/chunks/ccjk-skills.mjs +5 -5
- package/dist/chunks/ccr.mjs +14 -14
- package/dist/chunks/ccu.mjs +2 -2
- package/dist/chunks/check-updates.mjs +6 -6
- package/dist/chunks/claude-code-config-manager.mjs +5 -4
- package/dist/chunks/claude-code-incremental-manager.mjs +6 -6
- package/dist/chunks/claude-config.mjs +1 -1
- package/dist/chunks/claude-wrapper.mjs +1 -1
- package/dist/chunks/cli-hook.mjs +9 -10
- package/dist/chunks/codex-config-switch.mjs +6 -6
- package/dist/chunks/codex-provider-manager.mjs +6 -6
- package/dist/chunks/codex-uninstaller.mjs +2 -2
- package/dist/chunks/codex.mjs +5 -5
- package/dist/chunks/commands.mjs +2 -2
- package/dist/chunks/commands2.mjs +1 -1
- package/dist/chunks/commit.mjs +2 -2
- package/dist/chunks/completion.mjs +2 -2
- package/dist/chunks/config-consolidator.mjs +2 -2
- package/dist/chunks/config-switch.mjs +7 -7
- package/dist/chunks/config.mjs +3 -3
- package/dist/chunks/config2.mjs +4 -4
- package/dist/chunks/config3.mjs +3 -3
- package/dist/chunks/constants.mjs +1 -1
- package/dist/chunks/context-opt.mjs +442 -0
- package/dist/chunks/convoy-manager.mjs +355 -3
- package/dist/chunks/dashboard.mjs +2 -2
- package/dist/chunks/doctor.mjs +4 -4
- package/dist/chunks/evolution.mjs +2 -2
- package/dist/chunks/health-alerts.mjs +530 -4
- package/dist/chunks/help.mjs +1 -1
- package/dist/chunks/index.mjs +0 -23
- package/dist/chunks/index10.mjs +571 -634
- package/dist/chunks/index11.mjs +569 -1061
- package/dist/chunks/index12.mjs +1076 -914
- package/dist/chunks/index13.mjs +951 -135
- package/dist/chunks/index14.mjs +184 -209
- package/dist/chunks/index15.mjs +218 -0
- package/dist/chunks/index2.mjs +24 -19
- package/dist/chunks/index3.mjs +12 -19085
- package/dist/chunks/index4.mjs +19092 -16
- package/dist/chunks/index5.mjs +16 -7602
- package/dist/chunks/index6.mjs +7590 -159
- package/dist/chunks/index7.mjs +171 -1602
- package/dist/chunks/index8.mjs +1602 -19
- package/dist/chunks/index9.mjs +15 -612
- package/dist/chunks/init.mjs +13 -13
- package/dist/chunks/installer.mjs +5 -5
- package/dist/chunks/installer2.mjs +1 -1
- package/dist/chunks/interview.mjs +4 -4
- package/dist/chunks/manager.mjs +1 -1
- package/dist/chunks/marketplace.mjs +2 -2
- package/dist/chunks/mcp-cli.mjs +9 -9
- package/dist/chunks/mcp.mjs +7 -7
- package/dist/chunks/memory.mjs +3 -3
- package/dist/chunks/menu-hierarchical.mjs +14 -14
- package/dist/chunks/menu.mjs +12 -12
- package/dist/chunks/metrics-display.mjs +1 -1
- package/dist/chunks/migrator.mjs +1 -1
- package/dist/chunks/monitor.mjs +2 -2
- package/dist/chunks/notification.mjs +4 -4
- package/dist/chunks/onboarding-wizard.mjs +2 -2
- package/dist/chunks/onboarding.mjs +4 -4
- package/dist/chunks/package.mjs +1 -1
- package/dist/chunks/paradigm.mjs +1 -1
- package/dist/chunks/permission-manager.mjs +2 -2
- package/dist/chunks/permissions.mjs +3 -3
- package/dist/chunks/persistence-manager.mjs +3 -3
- package/dist/chunks/plugin.mjs +2 -2
- package/dist/chunks/prompts.mjs +5 -5
- package/dist/chunks/providers.mjs +2 -2
- package/dist/chunks/quick-actions.mjs +2 -2
- package/dist/chunks/quick-provider.mjs +6 -5
- package/dist/chunks/quick-setup.mjs +10 -10
- package/dist/chunks/remote.mjs +5 -5
- package/dist/chunks/session.mjs +2 -2
- package/dist/chunks/sessions.mjs +1 -1
- package/dist/chunks/silent-updater.mjs +1 -1
- package/dist/chunks/simple-config.mjs +1 -1
- package/dist/chunks/skill2.mjs +3 -3
- package/dist/chunks/skills-sync.mjs +4 -4
- package/dist/chunks/skills.mjs +3 -3
- package/dist/chunks/slash-commands.mjs +3 -3
- package/dist/chunks/startup.mjs +1 -1
- package/dist/chunks/stats.mjs +2 -2
- package/dist/chunks/status.mjs +2 -2
- package/dist/chunks/team.mjs +3 -3
- package/dist/chunks/thinking.mjs +4 -4
- package/dist/chunks/trace.mjs +2 -2
- package/dist/chunks/uninstall.mjs +8 -8
- package/dist/chunks/update.mjs +9 -9
- package/dist/chunks/upgrade-manager.mjs +3 -3
- package/dist/chunks/version-checker.mjs +4 -4
- package/dist/chunks/vim.mjs +3 -3
- package/dist/chunks/workflows.mjs +1 -1
- package/dist/chunks/wsl.mjs +1 -1
- package/dist/chunks/zero-config.mjs +3 -3
- package/dist/cli.mjs +56 -23
- package/dist/index.mjs +5 -5
- package/dist/shared/{ccjk.CCcQfbni.mjs → ccjk.B1TwPltj.mjs} +1 -1
- package/dist/shared/{ccjk.CePkJq2S.mjs → ccjk.BfIpomdz.mjs} +1 -1
- package/dist/shared/{ccjk.D8ZLYSZZ.mjs → ccjk.CXzjn01x.mjs} +1 -1
- package/dist/shared/{ccjk.Cjj8SVrn.mjs → ccjk.Cot9p9_n.mjs} +1 -1
- package/dist/shared/{ccjk.CvChMYvB.mjs → ccjk.DCw2WnZU.mjs} +1 -1
- package/dist/shared/{ccjk.DG_o24cZ.mjs → ccjk.DJdmgr2d.mjs} +1 -1
- package/dist/shared/{ccjk.BIxuVL3_.mjs → ccjk.DcKLglJQ.mjs} +2 -2
- package/dist/shared/{ccjk.DLLw-h4Y.mjs → ccjk.DfXjf8EC.mjs} +2 -2
- package/dist/shared/{ccjk.KpFl2RDA.mjs → ccjk.DpstNaeR.mjs} +3 -3
- package/dist/shared/{ccjk.DOBWBkFR.mjs → ccjk.XsJWJuQP.mjs} +5 -5
- package/dist/shared/{ccjk._dESH4Rk.mjs → ccjk.dYDLfmph.mjs} +1 -1
- package/dist/shared/{ccjk.DS7UESmF.mjs → ccjk.hrRv8G6j.mjs} +4 -4
- package/dist/shared/{ccjk.BWFpnOr3.mjs → ccjk.mJpVRDZ8.mjs} +1 -1
- package/dist/templates/claude-code/common/settings.json +3 -1
- package/package.json +20 -18
- package/templates/claude-code/common/settings.json +3 -1
- package/dist/chunks/context-loader.mjs +0 -351
- package/dist/chunks/context.mjs +0 -372
- package/dist/chunks/health-check.mjs +0 -532
package/dist/chunks/index7.mjs
CHANGED
|
@@ -1,1602 +1,171 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (code < 16) {
|
|
175
|
-
return 90 + (code - 8);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
let red;
|
|
179
|
-
let green;
|
|
180
|
-
let blue;
|
|
181
|
-
|
|
182
|
-
if (code >= 232) {
|
|
183
|
-
red = (((code - 232) * 10) + 8) / 255;
|
|
184
|
-
green = red;
|
|
185
|
-
blue = red;
|
|
186
|
-
} else {
|
|
187
|
-
code -= 16;
|
|
188
|
-
|
|
189
|
-
const remainder = code % 36;
|
|
190
|
-
|
|
191
|
-
red = Math.floor(code / 36) / 5;
|
|
192
|
-
green = Math.floor(remainder / 6) / 5;
|
|
193
|
-
blue = (remainder % 6) / 5;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const value = Math.max(red, green, blue) * 2;
|
|
197
|
-
|
|
198
|
-
if (value === 0) {
|
|
199
|
-
return 30;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// eslint-disable-next-line no-bitwise
|
|
203
|
-
let result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));
|
|
204
|
-
|
|
205
|
-
if (value === 2) {
|
|
206
|
-
result += 60;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return result;
|
|
210
|
-
},
|
|
211
|
-
enumerable: false,
|
|
212
|
-
},
|
|
213
|
-
rgbToAnsi: {
|
|
214
|
-
value: (red, green, blue) => styles$1.ansi256ToAnsi(styles$1.rgbToAnsi256(red, green, blue)),
|
|
215
|
-
enumerable: false,
|
|
216
|
-
},
|
|
217
|
-
hexToAnsi: {
|
|
218
|
-
value: hex => styles$1.ansi256ToAnsi(styles$1.hexToAnsi256(hex)),
|
|
219
|
-
enumerable: false,
|
|
220
|
-
},
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
return styles$1;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const ansiStyles = assembleStyles();
|
|
227
|
-
|
|
228
|
-
/* eslint-env browser */
|
|
229
|
-
|
|
230
|
-
const level = (() => {
|
|
231
|
-
if (!('navigator' in globalThis)) {
|
|
232
|
-
return 0;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if (globalThis.navigator.userAgentData) {
|
|
236
|
-
const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium');
|
|
237
|
-
if (brand && brand.version > 93) {
|
|
238
|
-
return 3;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if (/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)) {
|
|
243
|
-
return 1;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return 0;
|
|
247
|
-
})();
|
|
248
|
-
|
|
249
|
-
const colorSupport = level !== 0 && {
|
|
250
|
-
level};
|
|
251
|
-
|
|
252
|
-
const supportsColor = {
|
|
253
|
-
stdout: colorSupport,
|
|
254
|
-
stderr: colorSupport,
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
// TODO: When targeting Node.js 16, use `String.prototype.replaceAll`.
|
|
258
|
-
function stringReplaceAll(string, substring, replacer) {
|
|
259
|
-
let index = string.indexOf(substring);
|
|
260
|
-
if (index === -1) {
|
|
261
|
-
return string;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const substringLength = substring.length;
|
|
265
|
-
let endIndex = 0;
|
|
266
|
-
let returnValue = '';
|
|
267
|
-
do {
|
|
268
|
-
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
269
|
-
endIndex = index + substringLength;
|
|
270
|
-
index = string.indexOf(substring, endIndex);
|
|
271
|
-
} while (index !== -1);
|
|
272
|
-
|
|
273
|
-
returnValue += string.slice(endIndex);
|
|
274
|
-
return returnValue;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
278
|
-
let endIndex = 0;
|
|
279
|
-
let returnValue = '';
|
|
280
|
-
do {
|
|
281
|
-
const gotCR = string[index - 1] === '\r';
|
|
282
|
-
returnValue += string.slice(endIndex, (gotCR ? index - 1 : index)) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
|
|
283
|
-
endIndex = index + 1;
|
|
284
|
-
index = string.indexOf('\n', endIndex);
|
|
285
|
-
} while (index !== -1);
|
|
286
|
-
|
|
287
|
-
returnValue += string.slice(endIndex);
|
|
288
|
-
return returnValue;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
const {stdout: stdoutColor, stderr: stderrColor} = supportsColor;
|
|
292
|
-
|
|
293
|
-
const GENERATOR = Symbol('GENERATOR');
|
|
294
|
-
const STYLER = Symbol('STYLER');
|
|
295
|
-
const IS_EMPTY = Symbol('IS_EMPTY');
|
|
296
|
-
|
|
297
|
-
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
|
298
|
-
const levelMapping = [
|
|
299
|
-
'ansi',
|
|
300
|
-
'ansi',
|
|
301
|
-
'ansi256',
|
|
302
|
-
'ansi16m',
|
|
303
|
-
];
|
|
304
|
-
|
|
305
|
-
const styles = Object.create(null);
|
|
306
|
-
|
|
307
|
-
const applyOptions = (object, options = {}) => {
|
|
308
|
-
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
309
|
-
throw new Error('The `level` option should be an integer from 0 to 3');
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// Detect level if not set manually
|
|
313
|
-
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
314
|
-
object.level = options.level === undefined ? colorLevel : options.level;
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
const chalkFactory = options => {
|
|
318
|
-
const chalk = (...strings) => strings.join(' ');
|
|
319
|
-
applyOptions(chalk, options);
|
|
320
|
-
|
|
321
|
-
Object.setPrototypeOf(chalk, createChalk.prototype);
|
|
322
|
-
|
|
323
|
-
return chalk;
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
function createChalk(options) {
|
|
327
|
-
return chalkFactory(options);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
331
|
-
|
|
332
|
-
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
|
333
|
-
styles[styleName] = {
|
|
334
|
-
get() {
|
|
335
|
-
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
336
|
-
Object.defineProperty(this, styleName, {value: builder});
|
|
337
|
-
return builder;
|
|
338
|
-
},
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
styles.visible = {
|
|
343
|
-
get() {
|
|
344
|
-
const builder = createBuilder(this, this[STYLER], true);
|
|
345
|
-
Object.defineProperty(this, 'visible', {value: builder});
|
|
346
|
-
return builder;
|
|
347
|
-
},
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
const getModelAnsi = (model, level, type, ...arguments_) => {
|
|
351
|
-
if (model === 'rgb') {
|
|
352
|
-
if (level === 'ansi16m') {
|
|
353
|
-
return ansiStyles[type].ansi16m(...arguments_);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
if (level === 'ansi256') {
|
|
357
|
-
return ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_));
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
return ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_));
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
if (model === 'hex') {
|
|
364
|
-
return getModelAnsi('rgb', level, type, ...ansiStyles.hexToRgb(...arguments_));
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
return ansiStyles[type][model](...arguments_);
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
const usedModels = ['rgb', 'hex', 'ansi256'];
|
|
371
|
-
|
|
372
|
-
for (const model of usedModels) {
|
|
373
|
-
styles[model] = {
|
|
374
|
-
get() {
|
|
375
|
-
const {level} = this;
|
|
376
|
-
return function (...arguments_) {
|
|
377
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], 'color', ...arguments_), ansiStyles.color.close, this[STYLER]);
|
|
378
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
379
|
-
};
|
|
380
|
-
},
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
|
384
|
-
styles[bgModel] = {
|
|
385
|
-
get() {
|
|
386
|
-
const {level} = this;
|
|
387
|
-
return function (...arguments_) {
|
|
388
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], 'bgColor', ...arguments_), ansiStyles.bgColor.close, this[STYLER]);
|
|
389
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
390
|
-
};
|
|
391
|
-
},
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
const proto = Object.defineProperties(() => {}, {
|
|
396
|
-
...styles,
|
|
397
|
-
level: {
|
|
398
|
-
enumerable: true,
|
|
399
|
-
get() {
|
|
400
|
-
return this[GENERATOR].level;
|
|
401
|
-
},
|
|
402
|
-
set(level) {
|
|
403
|
-
this[GENERATOR].level = level;
|
|
404
|
-
},
|
|
405
|
-
},
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
const createStyler = (open, close, parent) => {
|
|
409
|
-
let openAll;
|
|
410
|
-
let closeAll;
|
|
411
|
-
if (parent === undefined) {
|
|
412
|
-
openAll = open;
|
|
413
|
-
closeAll = close;
|
|
414
|
-
} else {
|
|
415
|
-
openAll = parent.openAll + open;
|
|
416
|
-
closeAll = close + parent.closeAll;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
return {
|
|
420
|
-
open,
|
|
421
|
-
close,
|
|
422
|
-
openAll,
|
|
423
|
-
closeAll,
|
|
424
|
-
parent,
|
|
425
|
-
};
|
|
426
|
-
};
|
|
427
|
-
|
|
428
|
-
const createBuilder = (self, _styler, _isEmpty) => {
|
|
429
|
-
// Single argument is hot path, implicit coercion is faster than anything
|
|
430
|
-
// eslint-disable-next-line no-implicit-coercion
|
|
431
|
-
const builder = (...arguments_) => applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
|
|
432
|
-
|
|
433
|
-
// We alter the prototype because we must return a function, but there is
|
|
434
|
-
// no way to create a function with a different prototype
|
|
435
|
-
Object.setPrototypeOf(builder, proto);
|
|
436
|
-
|
|
437
|
-
builder[GENERATOR] = self;
|
|
438
|
-
builder[STYLER] = _styler;
|
|
439
|
-
builder[IS_EMPTY] = _isEmpty;
|
|
440
|
-
|
|
441
|
-
return builder;
|
|
442
|
-
};
|
|
443
|
-
|
|
444
|
-
const applyStyle = (self, string) => {
|
|
445
|
-
if (self.level <= 0 || !string) {
|
|
446
|
-
return self[IS_EMPTY] ? '' : string;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
let styler = self[STYLER];
|
|
450
|
-
|
|
451
|
-
if (styler === undefined) {
|
|
452
|
-
return string;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
const {openAll, closeAll} = styler;
|
|
456
|
-
if (string.includes('\u001B')) {
|
|
457
|
-
while (styler !== undefined) {
|
|
458
|
-
// Replace any instances already present with a re-opening code
|
|
459
|
-
// otherwise only the part of the string until said closing code
|
|
460
|
-
// will be colored, and the rest will simply be 'plain'.
|
|
461
|
-
string = stringReplaceAll(string, styler.close, styler.open);
|
|
462
|
-
|
|
463
|
-
styler = styler.parent;
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
// We can move both next actions out of loop, because remaining actions in loop won't have
|
|
468
|
-
// any/visible effect on parts we add here. Close the styling before a linebreak and reopen
|
|
469
|
-
// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
|
|
470
|
-
const lfIndex = string.indexOf('\n');
|
|
471
|
-
if (lfIndex !== -1) {
|
|
472
|
-
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
return openAll + string + closeAll;
|
|
476
|
-
};
|
|
477
|
-
|
|
478
|
-
Object.defineProperties(createChalk.prototype, styles);
|
|
479
|
-
|
|
480
|
-
const chalk = createChalk();
|
|
481
|
-
createChalk({level: stderrColor ? stderrColor.level : 0});
|
|
482
|
-
|
|
483
|
-
const copyProperty = (to, from, property, ignoreNonConfigurable) => {
|
|
484
|
-
// `Function#length` should reflect the parameters of `to` not `from` since we keep its body.
|
|
485
|
-
// `Function#prototype` is non-writable and non-configurable so can never be modified.
|
|
486
|
-
if (property === 'length' || property === 'prototype') {
|
|
487
|
-
return;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
// `Function#arguments` and `Function#caller` should not be copied. They were reported to be present in `Reflect.ownKeys` for some devices in React Native (#41), so we explicitly ignore them here.
|
|
491
|
-
if (property === 'arguments' || property === 'caller') {
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
|
|
496
|
-
const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
|
|
497
|
-
|
|
498
|
-
if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
Object.defineProperty(to, property, fromDescriptor);
|
|
503
|
-
};
|
|
504
|
-
|
|
505
|
-
// `Object.defineProperty()` throws if the property exists, is not configurable and either:
|
|
506
|
-
// - one its descriptors is changed
|
|
507
|
-
// - it is non-writable and its value is changed
|
|
508
|
-
const canCopyProperty = function (toDescriptor, fromDescriptor) {
|
|
509
|
-
return toDescriptor === undefined || toDescriptor.configurable || (
|
|
510
|
-
toDescriptor.writable === fromDescriptor.writable
|
|
511
|
-
&& toDescriptor.enumerable === fromDescriptor.enumerable
|
|
512
|
-
&& toDescriptor.configurable === fromDescriptor.configurable
|
|
513
|
-
&& (toDescriptor.writable || toDescriptor.value === fromDescriptor.value)
|
|
514
|
-
);
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
const changePrototype = (to, from) => {
|
|
518
|
-
const fromPrototype = Object.getPrototypeOf(from);
|
|
519
|
-
if (fromPrototype === Object.getPrototypeOf(to)) {
|
|
520
|
-
return;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
Object.setPrototypeOf(to, fromPrototype);
|
|
524
|
-
};
|
|
525
|
-
|
|
526
|
-
const wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/\n${fromBody}`;
|
|
527
|
-
|
|
528
|
-
const toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');
|
|
529
|
-
const toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, 'name');
|
|
530
|
-
|
|
531
|
-
// We call `from.toString()` early (not lazily) to ensure `from` can be garbage collected.
|
|
532
|
-
// We use `bind()` instead of a closure for the same reason.
|
|
533
|
-
// Calling `from.toString()` early also allows caching it in case `to.toString()` is called several times.
|
|
534
|
-
const changeToString = (to, from, name) => {
|
|
535
|
-
const withName = name === '' ? '' : `with ${name.trim()}() `;
|
|
536
|
-
const newToString = wrappedToString.bind(null, withName, from.toString());
|
|
537
|
-
// Ensure `to.toString.toString` is non-enumerable and has the same `same`
|
|
538
|
-
Object.defineProperty(newToString, 'name', toStringName);
|
|
539
|
-
const {writable, enumerable, configurable} = toStringDescriptor; // We destructue to avoid a potential `get` descriptor.
|
|
540
|
-
Object.defineProperty(to, 'toString', {value: newToString, writable, enumerable, configurable});
|
|
541
|
-
};
|
|
542
|
-
|
|
543
|
-
function mimicFunction(to, from, {ignoreNonConfigurable = false} = {}) {
|
|
544
|
-
const {name} = to;
|
|
545
|
-
|
|
546
|
-
for (const property of Reflect.ownKeys(from)) {
|
|
547
|
-
copyProperty(to, from, property, ignoreNonConfigurable);
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
changePrototype(to, from);
|
|
551
|
-
changeToString(to, from, name);
|
|
552
|
-
|
|
553
|
-
return to;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
const calledFunctions = new WeakMap();
|
|
557
|
-
|
|
558
|
-
const onetime = (function_, options = {}) => {
|
|
559
|
-
if (typeof function_ !== 'function') {
|
|
560
|
-
throw new TypeError('Expected a function');
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
let returnValue;
|
|
564
|
-
let callCount = 0;
|
|
565
|
-
const functionName = function_.displayName || function_.name || '<anonymous>';
|
|
566
|
-
|
|
567
|
-
const onetime = function (...arguments_) {
|
|
568
|
-
calledFunctions.set(onetime, ++callCount);
|
|
569
|
-
|
|
570
|
-
if (callCount === 1) {
|
|
571
|
-
returnValue = function_.apply(this, arguments_);
|
|
572
|
-
function_ = undefined;
|
|
573
|
-
} else if (options.throw === true) {
|
|
574
|
-
throw new Error(`Function \`${functionName}\` can only be called once`);
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
return returnValue;
|
|
578
|
-
};
|
|
579
|
-
|
|
580
|
-
mimicFunction(onetime, function_);
|
|
581
|
-
calledFunctions.set(onetime, callCount);
|
|
582
|
-
|
|
583
|
-
return onetime;
|
|
584
|
-
};
|
|
585
|
-
|
|
586
|
-
onetime.callCount = function_ => {
|
|
587
|
-
if (!calledFunctions.has(function_)) {
|
|
588
|
-
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
return calledFunctions.get(function_);
|
|
592
|
-
};
|
|
593
|
-
|
|
594
|
-
const terminal = process__default.stderr.isTTY
|
|
595
|
-
? process__default.stderr
|
|
596
|
-
: (process__default.stdout.isTTY ? process__default.stdout : undefined);
|
|
597
|
-
|
|
598
|
-
const restoreCursor = terminal ? onetime(() => {
|
|
599
|
-
onExit(() => {
|
|
600
|
-
terminal.write('\u001B[?25h');
|
|
601
|
-
}, {alwaysLast: true});
|
|
602
|
-
}) : () => {};
|
|
603
|
-
|
|
604
|
-
let isHidden = false;
|
|
605
|
-
|
|
606
|
-
const cliCursor = {};
|
|
607
|
-
|
|
608
|
-
cliCursor.show = (writableStream = process__default.stderr) => {
|
|
609
|
-
if (!writableStream.isTTY) {
|
|
610
|
-
return;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
isHidden = false;
|
|
614
|
-
writableStream.write('\u001B[?25h');
|
|
615
|
-
};
|
|
616
|
-
|
|
617
|
-
cliCursor.hide = (writableStream = process__default.stderr) => {
|
|
618
|
-
if (!writableStream.isTTY) {
|
|
619
|
-
return;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
restoreCursor();
|
|
623
|
-
isHidden = true;
|
|
624
|
-
writableStream.write('\u001B[?25l');
|
|
625
|
-
};
|
|
626
|
-
|
|
627
|
-
cliCursor.toggle = (force, writableStream) => {
|
|
628
|
-
if (force !== undefined) {
|
|
629
|
-
isHidden = force;
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
if (isHidden) {
|
|
633
|
-
cliCursor.show(writableStream);
|
|
634
|
-
} else {
|
|
635
|
-
cliCursor.hide(writableStream);
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
|
-
|
|
639
|
-
var cliSpinnersExports = requireCliSpinners();
|
|
640
|
-
const cliSpinners = /*@__PURE__*/getDefaultExportFromCjs(cliSpinnersExports);
|
|
641
|
-
|
|
642
|
-
const logSymbols = {
|
|
643
|
-
info: 'ℹ️',
|
|
644
|
-
success: '✅',
|
|
645
|
-
warning: '⚠️',
|
|
646
|
-
error: '❌️',
|
|
647
|
-
};
|
|
648
|
-
|
|
649
|
-
function ansiRegex({onlyFirst = false} = {}) {
|
|
650
|
-
// Valid string terminator sequences are BEL, ESC\, and 0x9c
|
|
651
|
-
const ST = '(?:\\u0007|\\u001B\\u005C|\\u009C)';
|
|
652
|
-
const pattern = [
|
|
653
|
-
`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
|
|
654
|
-
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))',
|
|
655
|
-
].join('|');
|
|
656
|
-
|
|
657
|
-
return new RegExp(pattern, onlyFirst ? undefined : 'g');
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
const regex = ansiRegex();
|
|
661
|
-
|
|
662
|
-
function stripAnsi(string) {
|
|
663
|
-
if (typeof string !== 'string') {
|
|
664
|
-
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
// Even though the regex is global, we don't need to reset the `.lastIndex`
|
|
668
|
-
// because unlike `.exec()` and `.test()`, `.replace()` does it automatically
|
|
669
|
-
// and doing it manually has a performance penalty.
|
|
670
|
-
return string.replace(regex, '');
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
// Generated code.
|
|
674
|
-
|
|
675
|
-
function isAmbiguous(x) {
|
|
676
|
-
return x === 0xA1
|
|
677
|
-
|| x === 0xA4
|
|
678
|
-
|| x === 0xA7
|
|
679
|
-
|| x === 0xA8
|
|
680
|
-
|| x === 0xAA
|
|
681
|
-
|| x === 0xAD
|
|
682
|
-
|| x === 0xAE
|
|
683
|
-
|| x >= 0xB0 && x <= 0xB4
|
|
684
|
-
|| x >= 0xB6 && x <= 0xBA
|
|
685
|
-
|| x >= 0xBC && x <= 0xBF
|
|
686
|
-
|| x === 0xC6
|
|
687
|
-
|| x === 0xD0
|
|
688
|
-
|| x === 0xD7
|
|
689
|
-
|| x === 0xD8
|
|
690
|
-
|| x >= 0xDE && x <= 0xE1
|
|
691
|
-
|| x === 0xE6
|
|
692
|
-
|| x >= 0xE8 && x <= 0xEA
|
|
693
|
-
|| x === 0xEC
|
|
694
|
-
|| x === 0xED
|
|
695
|
-
|| x === 0xF0
|
|
696
|
-
|| x === 0xF2
|
|
697
|
-
|| x === 0xF3
|
|
698
|
-
|| x >= 0xF7 && x <= 0xFA
|
|
699
|
-
|| x === 0xFC
|
|
700
|
-
|| x === 0xFE
|
|
701
|
-
|| x === 0x101
|
|
702
|
-
|| x === 0x111
|
|
703
|
-
|| x === 0x113
|
|
704
|
-
|| x === 0x11B
|
|
705
|
-
|| x === 0x126
|
|
706
|
-
|| x === 0x127
|
|
707
|
-
|| x === 0x12B
|
|
708
|
-
|| x >= 0x131 && x <= 0x133
|
|
709
|
-
|| x === 0x138
|
|
710
|
-
|| x >= 0x13F && x <= 0x142
|
|
711
|
-
|| x === 0x144
|
|
712
|
-
|| x >= 0x148 && x <= 0x14B
|
|
713
|
-
|| x === 0x14D
|
|
714
|
-
|| x === 0x152
|
|
715
|
-
|| x === 0x153
|
|
716
|
-
|| x === 0x166
|
|
717
|
-
|| x === 0x167
|
|
718
|
-
|| x === 0x16B
|
|
719
|
-
|| x === 0x1CE
|
|
720
|
-
|| x === 0x1D0
|
|
721
|
-
|| x === 0x1D2
|
|
722
|
-
|| x === 0x1D4
|
|
723
|
-
|| x === 0x1D6
|
|
724
|
-
|| x === 0x1D8
|
|
725
|
-
|| x === 0x1DA
|
|
726
|
-
|| x === 0x1DC
|
|
727
|
-
|| x === 0x251
|
|
728
|
-
|| x === 0x261
|
|
729
|
-
|| x === 0x2C4
|
|
730
|
-
|| x === 0x2C7
|
|
731
|
-
|| x >= 0x2C9 && x <= 0x2CB
|
|
732
|
-
|| x === 0x2CD
|
|
733
|
-
|| x === 0x2D0
|
|
734
|
-
|| x >= 0x2D8 && x <= 0x2DB
|
|
735
|
-
|| x === 0x2DD
|
|
736
|
-
|| x === 0x2DF
|
|
737
|
-
|| x >= 0x300 && x <= 0x36F
|
|
738
|
-
|| x >= 0x391 && x <= 0x3A1
|
|
739
|
-
|| x >= 0x3A3 && x <= 0x3A9
|
|
740
|
-
|| x >= 0x3B1 && x <= 0x3C1
|
|
741
|
-
|| x >= 0x3C3 && x <= 0x3C9
|
|
742
|
-
|| x === 0x401
|
|
743
|
-
|| x >= 0x410 && x <= 0x44F
|
|
744
|
-
|| x === 0x451
|
|
745
|
-
|| x === 0x2010
|
|
746
|
-
|| x >= 0x2013 && x <= 0x2016
|
|
747
|
-
|| x === 0x2018
|
|
748
|
-
|| x === 0x2019
|
|
749
|
-
|| x === 0x201C
|
|
750
|
-
|| x === 0x201D
|
|
751
|
-
|| x >= 0x2020 && x <= 0x2022
|
|
752
|
-
|| x >= 0x2024 && x <= 0x2027
|
|
753
|
-
|| x === 0x2030
|
|
754
|
-
|| x === 0x2032
|
|
755
|
-
|| x === 0x2033
|
|
756
|
-
|| x === 0x2035
|
|
757
|
-
|| x === 0x203B
|
|
758
|
-
|| x === 0x203E
|
|
759
|
-
|| x === 0x2074
|
|
760
|
-
|| x === 0x207F
|
|
761
|
-
|| x >= 0x2081 && x <= 0x2084
|
|
762
|
-
|| x === 0x20AC
|
|
763
|
-
|| x === 0x2103
|
|
764
|
-
|| x === 0x2105
|
|
765
|
-
|| x === 0x2109
|
|
766
|
-
|| x === 0x2113
|
|
767
|
-
|| x === 0x2116
|
|
768
|
-
|| x === 0x2121
|
|
769
|
-
|| x === 0x2122
|
|
770
|
-
|| x === 0x2126
|
|
771
|
-
|| x === 0x212B
|
|
772
|
-
|| x === 0x2153
|
|
773
|
-
|| x === 0x2154
|
|
774
|
-
|| x >= 0x215B && x <= 0x215E
|
|
775
|
-
|| x >= 0x2160 && x <= 0x216B
|
|
776
|
-
|| x >= 0x2170 && x <= 0x2179
|
|
777
|
-
|| x === 0x2189
|
|
778
|
-
|| x >= 0x2190 && x <= 0x2199
|
|
779
|
-
|| x === 0x21B8
|
|
780
|
-
|| x === 0x21B9
|
|
781
|
-
|| x === 0x21D2
|
|
782
|
-
|| x === 0x21D4
|
|
783
|
-
|| x === 0x21E7
|
|
784
|
-
|| x === 0x2200
|
|
785
|
-
|| x === 0x2202
|
|
786
|
-
|| x === 0x2203
|
|
787
|
-
|| x === 0x2207
|
|
788
|
-
|| x === 0x2208
|
|
789
|
-
|| x === 0x220B
|
|
790
|
-
|| x === 0x220F
|
|
791
|
-
|| x === 0x2211
|
|
792
|
-
|| x === 0x2215
|
|
793
|
-
|| x === 0x221A
|
|
794
|
-
|| x >= 0x221D && x <= 0x2220
|
|
795
|
-
|| x === 0x2223
|
|
796
|
-
|| x === 0x2225
|
|
797
|
-
|| x >= 0x2227 && x <= 0x222C
|
|
798
|
-
|| x === 0x222E
|
|
799
|
-
|| x >= 0x2234 && x <= 0x2237
|
|
800
|
-
|| x === 0x223C
|
|
801
|
-
|| x === 0x223D
|
|
802
|
-
|| x === 0x2248
|
|
803
|
-
|| x === 0x224C
|
|
804
|
-
|| x === 0x2252
|
|
805
|
-
|| x === 0x2260
|
|
806
|
-
|| x === 0x2261
|
|
807
|
-
|| x >= 0x2264 && x <= 0x2267
|
|
808
|
-
|| x === 0x226A
|
|
809
|
-
|| x === 0x226B
|
|
810
|
-
|| x === 0x226E
|
|
811
|
-
|| x === 0x226F
|
|
812
|
-
|| x === 0x2282
|
|
813
|
-
|| x === 0x2283
|
|
814
|
-
|| x === 0x2286
|
|
815
|
-
|| x === 0x2287
|
|
816
|
-
|| x === 0x2295
|
|
817
|
-
|| x === 0x2299
|
|
818
|
-
|| x === 0x22A5
|
|
819
|
-
|| x === 0x22BF
|
|
820
|
-
|| x === 0x2312
|
|
821
|
-
|| x >= 0x2460 && x <= 0x24E9
|
|
822
|
-
|| x >= 0x24EB && x <= 0x254B
|
|
823
|
-
|| x >= 0x2550 && x <= 0x2573
|
|
824
|
-
|| x >= 0x2580 && x <= 0x258F
|
|
825
|
-
|| x >= 0x2592 && x <= 0x2595
|
|
826
|
-
|| x === 0x25A0
|
|
827
|
-
|| x === 0x25A1
|
|
828
|
-
|| x >= 0x25A3 && x <= 0x25A9
|
|
829
|
-
|| x === 0x25B2
|
|
830
|
-
|| x === 0x25B3
|
|
831
|
-
|| x === 0x25B6
|
|
832
|
-
|| x === 0x25B7
|
|
833
|
-
|| x === 0x25BC
|
|
834
|
-
|| x === 0x25BD
|
|
835
|
-
|| x === 0x25C0
|
|
836
|
-
|| x === 0x25C1
|
|
837
|
-
|| x >= 0x25C6 && x <= 0x25C8
|
|
838
|
-
|| x === 0x25CB
|
|
839
|
-
|| x >= 0x25CE && x <= 0x25D1
|
|
840
|
-
|| x >= 0x25E2 && x <= 0x25E5
|
|
841
|
-
|| x === 0x25EF
|
|
842
|
-
|| x === 0x2605
|
|
843
|
-
|| x === 0x2606
|
|
844
|
-
|| x === 0x2609
|
|
845
|
-
|| x === 0x260E
|
|
846
|
-
|| x === 0x260F
|
|
847
|
-
|| x === 0x261C
|
|
848
|
-
|| x === 0x261E
|
|
849
|
-
|| x === 0x2640
|
|
850
|
-
|| x === 0x2642
|
|
851
|
-
|| x === 0x2660
|
|
852
|
-
|| x === 0x2661
|
|
853
|
-
|| x >= 0x2663 && x <= 0x2665
|
|
854
|
-
|| x >= 0x2667 && x <= 0x266A
|
|
855
|
-
|| x === 0x266C
|
|
856
|
-
|| x === 0x266D
|
|
857
|
-
|| x === 0x266F
|
|
858
|
-
|| x === 0x269E
|
|
859
|
-
|| x === 0x269F
|
|
860
|
-
|| x === 0x26BF
|
|
861
|
-
|| x >= 0x26C6 && x <= 0x26CD
|
|
862
|
-
|| x >= 0x26CF && x <= 0x26D3
|
|
863
|
-
|| x >= 0x26D5 && x <= 0x26E1
|
|
864
|
-
|| x === 0x26E3
|
|
865
|
-
|| x === 0x26E8
|
|
866
|
-
|| x === 0x26E9
|
|
867
|
-
|| x >= 0x26EB && x <= 0x26F1
|
|
868
|
-
|| x === 0x26F4
|
|
869
|
-
|| x >= 0x26F6 && x <= 0x26F9
|
|
870
|
-
|| x === 0x26FB
|
|
871
|
-
|| x === 0x26FC
|
|
872
|
-
|| x === 0x26FE
|
|
873
|
-
|| x === 0x26FF
|
|
874
|
-
|| x === 0x273D
|
|
875
|
-
|| x >= 0x2776 && x <= 0x277F
|
|
876
|
-
|| x >= 0x2B56 && x <= 0x2B59
|
|
877
|
-
|| x >= 0x3248 && x <= 0x324F
|
|
878
|
-
|| x >= 0xE000 && x <= 0xF8FF
|
|
879
|
-
|| x >= 0xFE00 && x <= 0xFE0F
|
|
880
|
-
|| x === 0xFFFD
|
|
881
|
-
|| x >= 0x1F100 && x <= 0x1F10A
|
|
882
|
-
|| x >= 0x1F110 && x <= 0x1F12D
|
|
883
|
-
|| x >= 0x1F130 && x <= 0x1F169
|
|
884
|
-
|| x >= 0x1F170 && x <= 0x1F18D
|
|
885
|
-
|| x === 0x1F18F
|
|
886
|
-
|| x === 0x1F190
|
|
887
|
-
|| x >= 0x1F19B && x <= 0x1F1AC
|
|
888
|
-
|| x >= 0xE0100 && x <= 0xE01EF
|
|
889
|
-
|| x >= 0xF0000 && x <= 0xFFFFD
|
|
890
|
-
|| x >= 0x100000 && x <= 0x10FFFD;
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
function isFullWidth(x) {
|
|
894
|
-
return x === 0x3000
|
|
895
|
-
|| x >= 0xFF01 && x <= 0xFF60
|
|
896
|
-
|| x >= 0xFFE0 && x <= 0xFFE6;
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
function isWide(x) {
|
|
900
|
-
return x >= 0x1100 && x <= 0x115F
|
|
901
|
-
|| x === 0x231A
|
|
902
|
-
|| x === 0x231B
|
|
903
|
-
|| x === 0x2329
|
|
904
|
-
|| x === 0x232A
|
|
905
|
-
|| x >= 0x23E9 && x <= 0x23EC
|
|
906
|
-
|| x === 0x23F0
|
|
907
|
-
|| x === 0x23F3
|
|
908
|
-
|| x === 0x25FD
|
|
909
|
-
|| x === 0x25FE
|
|
910
|
-
|| x === 0x2614
|
|
911
|
-
|| x === 0x2615
|
|
912
|
-
|| x >= 0x2630 && x <= 0x2637
|
|
913
|
-
|| x >= 0x2648 && x <= 0x2653
|
|
914
|
-
|| x === 0x267F
|
|
915
|
-
|| x >= 0x268A && x <= 0x268F
|
|
916
|
-
|| x === 0x2693
|
|
917
|
-
|| x === 0x26A1
|
|
918
|
-
|| x === 0x26AA
|
|
919
|
-
|| x === 0x26AB
|
|
920
|
-
|| x === 0x26BD
|
|
921
|
-
|| x === 0x26BE
|
|
922
|
-
|| x === 0x26C4
|
|
923
|
-
|| x === 0x26C5
|
|
924
|
-
|| x === 0x26CE
|
|
925
|
-
|| x === 0x26D4
|
|
926
|
-
|| x === 0x26EA
|
|
927
|
-
|| x === 0x26F2
|
|
928
|
-
|| x === 0x26F3
|
|
929
|
-
|| x === 0x26F5
|
|
930
|
-
|| x === 0x26FA
|
|
931
|
-
|| x === 0x26FD
|
|
932
|
-
|| x === 0x2705
|
|
933
|
-
|| x === 0x270A
|
|
934
|
-
|| x === 0x270B
|
|
935
|
-
|| x === 0x2728
|
|
936
|
-
|| x === 0x274C
|
|
937
|
-
|| x === 0x274E
|
|
938
|
-
|| x >= 0x2753 && x <= 0x2755
|
|
939
|
-
|| x === 0x2757
|
|
940
|
-
|| x >= 0x2795 && x <= 0x2797
|
|
941
|
-
|| x === 0x27B0
|
|
942
|
-
|| x === 0x27BF
|
|
943
|
-
|| x === 0x2B1B
|
|
944
|
-
|| x === 0x2B1C
|
|
945
|
-
|| x === 0x2B50
|
|
946
|
-
|| x === 0x2B55
|
|
947
|
-
|| x >= 0x2E80 && x <= 0x2E99
|
|
948
|
-
|| x >= 0x2E9B && x <= 0x2EF3
|
|
949
|
-
|| x >= 0x2F00 && x <= 0x2FD5
|
|
950
|
-
|| x >= 0x2FF0 && x <= 0x2FFF
|
|
951
|
-
|| x >= 0x3001 && x <= 0x303E
|
|
952
|
-
|| x >= 0x3041 && x <= 0x3096
|
|
953
|
-
|| x >= 0x3099 && x <= 0x30FF
|
|
954
|
-
|| x >= 0x3105 && x <= 0x312F
|
|
955
|
-
|| x >= 0x3131 && x <= 0x318E
|
|
956
|
-
|| x >= 0x3190 && x <= 0x31E5
|
|
957
|
-
|| x >= 0x31EF && x <= 0x321E
|
|
958
|
-
|| x >= 0x3220 && x <= 0x3247
|
|
959
|
-
|| x >= 0x3250 && x <= 0xA48C
|
|
960
|
-
|| x >= 0xA490 && x <= 0xA4C6
|
|
961
|
-
|| x >= 0xA960 && x <= 0xA97C
|
|
962
|
-
|| x >= 0xAC00 && x <= 0xD7A3
|
|
963
|
-
|| x >= 0xF900 && x <= 0xFAFF
|
|
964
|
-
|| x >= 0xFE10 && x <= 0xFE19
|
|
965
|
-
|| x >= 0xFE30 && x <= 0xFE52
|
|
966
|
-
|| x >= 0xFE54 && x <= 0xFE66
|
|
967
|
-
|| x >= 0xFE68 && x <= 0xFE6B
|
|
968
|
-
|| x >= 0x16FE0 && x <= 0x16FE4
|
|
969
|
-
|| x === 0x16FF0
|
|
970
|
-
|| x === 0x16FF1
|
|
971
|
-
|| x >= 0x17000 && x <= 0x187F7
|
|
972
|
-
|| x >= 0x18800 && x <= 0x18CD5
|
|
973
|
-
|| x >= 0x18CFF && x <= 0x18D08
|
|
974
|
-
|| x >= 0x1AFF0 && x <= 0x1AFF3
|
|
975
|
-
|| x >= 0x1AFF5 && x <= 0x1AFFB
|
|
976
|
-
|| x === 0x1AFFD
|
|
977
|
-
|| x === 0x1AFFE
|
|
978
|
-
|| x >= 0x1B000 && x <= 0x1B122
|
|
979
|
-
|| x === 0x1B132
|
|
980
|
-
|| x >= 0x1B150 && x <= 0x1B152
|
|
981
|
-
|| x === 0x1B155
|
|
982
|
-
|| x >= 0x1B164 && x <= 0x1B167
|
|
983
|
-
|| x >= 0x1B170 && x <= 0x1B2FB
|
|
984
|
-
|| x >= 0x1D300 && x <= 0x1D356
|
|
985
|
-
|| x >= 0x1D360 && x <= 0x1D376
|
|
986
|
-
|| x === 0x1F004
|
|
987
|
-
|| x === 0x1F0CF
|
|
988
|
-
|| x === 0x1F18E
|
|
989
|
-
|| x >= 0x1F191 && x <= 0x1F19A
|
|
990
|
-
|| x >= 0x1F200 && x <= 0x1F202
|
|
991
|
-
|| x >= 0x1F210 && x <= 0x1F23B
|
|
992
|
-
|| x >= 0x1F240 && x <= 0x1F248
|
|
993
|
-
|| x === 0x1F250
|
|
994
|
-
|| x === 0x1F251
|
|
995
|
-
|| x >= 0x1F260 && x <= 0x1F265
|
|
996
|
-
|| x >= 0x1F300 && x <= 0x1F320
|
|
997
|
-
|| x >= 0x1F32D && x <= 0x1F335
|
|
998
|
-
|| x >= 0x1F337 && x <= 0x1F37C
|
|
999
|
-
|| x >= 0x1F37E && x <= 0x1F393
|
|
1000
|
-
|| x >= 0x1F3A0 && x <= 0x1F3CA
|
|
1001
|
-
|| x >= 0x1F3CF && x <= 0x1F3D3
|
|
1002
|
-
|| x >= 0x1F3E0 && x <= 0x1F3F0
|
|
1003
|
-
|| x === 0x1F3F4
|
|
1004
|
-
|| x >= 0x1F3F8 && x <= 0x1F43E
|
|
1005
|
-
|| x === 0x1F440
|
|
1006
|
-
|| x >= 0x1F442 && x <= 0x1F4FC
|
|
1007
|
-
|| x >= 0x1F4FF && x <= 0x1F53D
|
|
1008
|
-
|| x >= 0x1F54B && x <= 0x1F54E
|
|
1009
|
-
|| x >= 0x1F550 && x <= 0x1F567
|
|
1010
|
-
|| x === 0x1F57A
|
|
1011
|
-
|| x === 0x1F595
|
|
1012
|
-
|| x === 0x1F596
|
|
1013
|
-
|| x === 0x1F5A4
|
|
1014
|
-
|| x >= 0x1F5FB && x <= 0x1F64F
|
|
1015
|
-
|| x >= 0x1F680 && x <= 0x1F6C5
|
|
1016
|
-
|| x === 0x1F6CC
|
|
1017
|
-
|| x >= 0x1F6D0 && x <= 0x1F6D2
|
|
1018
|
-
|| x >= 0x1F6D5 && x <= 0x1F6D7
|
|
1019
|
-
|| x >= 0x1F6DC && x <= 0x1F6DF
|
|
1020
|
-
|| x === 0x1F6EB
|
|
1021
|
-
|| x === 0x1F6EC
|
|
1022
|
-
|| x >= 0x1F6F4 && x <= 0x1F6FC
|
|
1023
|
-
|| x >= 0x1F7E0 && x <= 0x1F7EB
|
|
1024
|
-
|| x === 0x1F7F0
|
|
1025
|
-
|| x >= 0x1F90C && x <= 0x1F93A
|
|
1026
|
-
|| x >= 0x1F93C && x <= 0x1F945
|
|
1027
|
-
|| x >= 0x1F947 && x <= 0x1F9FF
|
|
1028
|
-
|| x >= 0x1FA70 && x <= 0x1FA7C
|
|
1029
|
-
|| x >= 0x1FA80 && x <= 0x1FA89
|
|
1030
|
-
|| x >= 0x1FA8F && x <= 0x1FAC6
|
|
1031
|
-
|| x >= 0x1FACE && x <= 0x1FADC
|
|
1032
|
-
|| x >= 0x1FADF && x <= 0x1FAE9
|
|
1033
|
-
|| x >= 0x1FAF0 && x <= 0x1FAF8
|
|
1034
|
-
|| x >= 0x20000 && x <= 0x2FFFD
|
|
1035
|
-
|| x >= 0x30000 && x <= 0x3FFFD;
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
function validate(codePoint) {
|
|
1039
|
-
if (!Number.isSafeInteger(codePoint)) {
|
|
1040
|
-
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
function eastAsianWidth(codePoint, {ambiguousAsWide = false} = {}) {
|
|
1045
|
-
validate(codePoint);
|
|
1046
|
-
|
|
1047
|
-
if (
|
|
1048
|
-
isFullWidth(codePoint)
|
|
1049
|
-
|| isWide(codePoint)
|
|
1050
|
-
|| (ambiguousAsWide && isAmbiguous(codePoint))
|
|
1051
|
-
) {
|
|
1052
|
-
return 2;
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
return 1;
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
const emojiRegex = () => {
|
|
1059
|
-
// https://mths.be/emoji
|
|
1060
|
-
return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
|
|
1061
|
-
};
|
|
1062
|
-
|
|
1063
|
-
const segmenter = new Intl.Segmenter();
|
|
1064
|
-
|
|
1065
|
-
const defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
|
|
1066
|
-
|
|
1067
|
-
function stringWidth(string, options = {}) {
|
|
1068
|
-
if (typeof string !== 'string' || string.length === 0) {
|
|
1069
|
-
return 0;
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
const {
|
|
1073
|
-
ambiguousIsNarrow = true,
|
|
1074
|
-
countAnsiEscapeCodes = false,
|
|
1075
|
-
} = options;
|
|
1076
|
-
|
|
1077
|
-
if (!countAnsiEscapeCodes) {
|
|
1078
|
-
string = stripAnsi(string);
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
if (string.length === 0) {
|
|
1082
|
-
return 0;
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
let width = 0;
|
|
1086
|
-
const eastAsianWidthOptions = {ambiguousAsWide: !ambiguousIsNarrow};
|
|
1087
|
-
|
|
1088
|
-
for (const {segment: character} of segmenter.segment(string)) {
|
|
1089
|
-
const codePoint = character.codePointAt(0);
|
|
1090
|
-
|
|
1091
|
-
// Ignore control characters
|
|
1092
|
-
if (codePoint <= 0x1F || (codePoint >= 0x7F && codePoint <= 0x9F)) {
|
|
1093
|
-
continue;
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
// Ignore zero-width characters
|
|
1097
|
-
if (
|
|
1098
|
-
(codePoint >= 0x20_0B && codePoint <= 0x20_0F) // Zero-width space, non-joiner, joiner, left-to-right mark, right-to-left mark
|
|
1099
|
-
|| codePoint === 0xFE_FF // Zero-width no-break space
|
|
1100
|
-
) {
|
|
1101
|
-
continue;
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
// Ignore combining characters
|
|
1105
|
-
if (
|
|
1106
|
-
(codePoint >= 0x3_00 && codePoint <= 0x3_6F) // Combining diacritical marks
|
|
1107
|
-
|| (codePoint >= 0x1A_B0 && codePoint <= 0x1A_FF) // Combining diacritical marks extended
|
|
1108
|
-
|| (codePoint >= 0x1D_C0 && codePoint <= 0x1D_FF) // Combining diacritical marks supplement
|
|
1109
|
-
|| (codePoint >= 0x20_D0 && codePoint <= 0x20_FF) // Combining diacritical marks for symbols
|
|
1110
|
-
|| (codePoint >= 0xFE_20 && codePoint <= 0xFE_2F) // Combining half marks
|
|
1111
|
-
) {
|
|
1112
|
-
continue;
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
// Ignore surrogate pairs
|
|
1116
|
-
if (codePoint >= 0xD8_00 && codePoint <= 0xDF_FF) {
|
|
1117
|
-
continue;
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
// Ignore variation selectors
|
|
1121
|
-
if (codePoint >= 0xFE_00 && codePoint <= 0xFE_0F) {
|
|
1122
|
-
continue;
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
// This covers some of the above cases, but we still keep them for performance reasons.
|
|
1126
|
-
if (defaultIgnorableCodePointRegex.test(character)) {
|
|
1127
|
-
continue;
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
// TODO: Use `/\p{RGI_Emoji}/v` when targeting Node.js 20.
|
|
1131
|
-
if (emojiRegex().test(character)) {
|
|
1132
|
-
width += 2;
|
|
1133
|
-
continue;
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
|
-
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
return width;
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
function isInteractive({stream = process.stdout} = {}) {
|
|
1143
|
-
return Boolean(
|
|
1144
|
-
stream && stream.isTTY &&
|
|
1145
|
-
process.env.TERM !== 'dumb' &&
|
|
1146
|
-
!('CI' in process.env)
|
|
1147
|
-
);
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
function isUnicodeSupported() {
|
|
1151
|
-
const {env} = process__default;
|
|
1152
|
-
const {TERM, TERM_PROGRAM} = env;
|
|
1153
|
-
|
|
1154
|
-
if (process__default.platform !== 'win32') {
|
|
1155
|
-
return TERM !== 'linux'; // Linux console (kernel)
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
return Boolean(env.WT_SESSION) // Windows Terminal
|
|
1159
|
-
|| Boolean(env.TERMINUS_SUBLIME) // Terminus (<0.2.27)
|
|
1160
|
-
|| env.ConEmuTask === '{cmd::Cmder}' // ConEmu and cmder
|
|
1161
|
-
|| TERM_PROGRAM === 'Terminus-Sublime'
|
|
1162
|
-
|| TERM_PROGRAM === 'vscode'
|
|
1163
|
-
|| TERM === 'xterm-256color'
|
|
1164
|
-
|| TERM === 'alacritty'
|
|
1165
|
-
|| TERM === 'rxvt-unicode'
|
|
1166
|
-
|| TERM === 'rxvt-unicode-256color'
|
|
1167
|
-
|| env.TERMINAL_EMULATOR === 'JetBrains-JediTerm';
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
const ASCII_ETX_CODE = 0x03; // Ctrl+C emits this code
|
|
1171
|
-
|
|
1172
|
-
class StdinDiscarder {
|
|
1173
|
-
#activeCount = 0;
|
|
1174
|
-
|
|
1175
|
-
start() {
|
|
1176
|
-
this.#activeCount++;
|
|
1177
|
-
|
|
1178
|
-
if (this.#activeCount === 1) {
|
|
1179
|
-
this.#realStart();
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
stop() {
|
|
1184
|
-
if (this.#activeCount <= 0) {
|
|
1185
|
-
throw new Error('`stop` called more times than `start`');
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
this.#activeCount--;
|
|
1189
|
-
|
|
1190
|
-
if (this.#activeCount === 0) {
|
|
1191
|
-
this.#realStop();
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
#realStart() {
|
|
1196
|
-
// No known way to make it work reliably on Windows.
|
|
1197
|
-
if (process__default.platform === 'win32' || !process__default.stdin.isTTY) {
|
|
1198
|
-
return;
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
process__default.stdin.setRawMode(true);
|
|
1202
|
-
process__default.stdin.on('data', this.#handleInput);
|
|
1203
|
-
process__default.stdin.resume();
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
|
-
#realStop() {
|
|
1207
|
-
if (!process__default.stdin.isTTY) {
|
|
1208
|
-
return;
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
process__default.stdin.off('data', this.#handleInput);
|
|
1212
|
-
process__default.stdin.pause();
|
|
1213
|
-
process__default.stdin.setRawMode(false);
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
#handleInput(chunk) {
|
|
1217
|
-
// Allow Ctrl+C to gracefully exit.
|
|
1218
|
-
if (chunk[0] === ASCII_ETX_CODE) {
|
|
1219
|
-
process__default.emit('SIGINT');
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
const stdinDiscarder = new StdinDiscarder();
|
|
1225
|
-
|
|
1226
|
-
class Ora {
|
|
1227
|
-
#linesToClear = 0;
|
|
1228
|
-
#isDiscardingStdin = false;
|
|
1229
|
-
#lineCount = 0;
|
|
1230
|
-
#frameIndex = -1;
|
|
1231
|
-
#lastSpinnerFrameTime = 0;
|
|
1232
|
-
#options;
|
|
1233
|
-
#spinner;
|
|
1234
|
-
#stream;
|
|
1235
|
-
#id;
|
|
1236
|
-
#initialInterval;
|
|
1237
|
-
#isEnabled;
|
|
1238
|
-
#isSilent;
|
|
1239
|
-
#indent;
|
|
1240
|
-
#text;
|
|
1241
|
-
#prefixText;
|
|
1242
|
-
#suffixText;
|
|
1243
|
-
color;
|
|
1244
|
-
|
|
1245
|
-
constructor(options) {
|
|
1246
|
-
if (typeof options === 'string') {
|
|
1247
|
-
options = {
|
|
1248
|
-
text: options,
|
|
1249
|
-
};
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
this.#options = {
|
|
1253
|
-
color: 'cyan',
|
|
1254
|
-
stream: process__default.stderr,
|
|
1255
|
-
discardStdin: true,
|
|
1256
|
-
hideCursor: true,
|
|
1257
|
-
...options,
|
|
1258
|
-
};
|
|
1259
|
-
|
|
1260
|
-
// Public
|
|
1261
|
-
this.color = this.#options.color;
|
|
1262
|
-
|
|
1263
|
-
// It's important that these use the public setters.
|
|
1264
|
-
this.spinner = this.#options.spinner;
|
|
1265
|
-
|
|
1266
|
-
this.#initialInterval = this.#options.interval;
|
|
1267
|
-
this.#stream = this.#options.stream;
|
|
1268
|
-
this.#isEnabled = typeof this.#options.isEnabled === 'boolean' ? this.#options.isEnabled : isInteractive({stream: this.#stream});
|
|
1269
|
-
this.#isSilent = typeof this.#options.isSilent === 'boolean' ? this.#options.isSilent : false;
|
|
1270
|
-
|
|
1271
|
-
// Set *after* `this.#stream`.
|
|
1272
|
-
// It's important that these use the public setters.
|
|
1273
|
-
this.text = this.#options.text;
|
|
1274
|
-
this.prefixText = this.#options.prefixText;
|
|
1275
|
-
this.suffixText = this.#options.suffixText;
|
|
1276
|
-
this.indent = this.#options.indent;
|
|
1277
|
-
|
|
1278
|
-
if (process__default.env.NODE_ENV === 'test') {
|
|
1279
|
-
this._stream = this.#stream;
|
|
1280
|
-
this._isEnabled = this.#isEnabled;
|
|
1281
|
-
|
|
1282
|
-
Object.defineProperty(this, '_linesToClear', {
|
|
1283
|
-
get() {
|
|
1284
|
-
return this.#linesToClear;
|
|
1285
|
-
},
|
|
1286
|
-
set(newValue) {
|
|
1287
|
-
this.#linesToClear = newValue;
|
|
1288
|
-
},
|
|
1289
|
-
});
|
|
1290
|
-
|
|
1291
|
-
Object.defineProperty(this, '_frameIndex', {
|
|
1292
|
-
get() {
|
|
1293
|
-
return this.#frameIndex;
|
|
1294
|
-
},
|
|
1295
|
-
});
|
|
1296
|
-
|
|
1297
|
-
Object.defineProperty(this, '_lineCount', {
|
|
1298
|
-
get() {
|
|
1299
|
-
return this.#lineCount;
|
|
1300
|
-
},
|
|
1301
|
-
});
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
|
-
get indent() {
|
|
1306
|
-
return this.#indent;
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
set indent(indent = 0) {
|
|
1310
|
-
if (!(indent >= 0 && Number.isInteger(indent))) {
|
|
1311
|
-
throw new Error('The `indent` option must be an integer from 0 and up');
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
this.#indent = indent;
|
|
1315
|
-
this.#updateLineCount();
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
get interval() {
|
|
1319
|
-
return this.#initialInterval ?? this.#spinner.interval ?? 100;
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
get spinner() {
|
|
1323
|
-
return this.#spinner;
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
set spinner(spinner) {
|
|
1327
|
-
this.#frameIndex = -1;
|
|
1328
|
-
this.#initialInterval = undefined;
|
|
1329
|
-
|
|
1330
|
-
if (typeof spinner === 'object') {
|
|
1331
|
-
if (spinner.frames === undefined) {
|
|
1332
|
-
throw new Error('The given spinner must have a `frames` property');
|
|
1333
|
-
}
|
|
1334
|
-
|
|
1335
|
-
this.#spinner = spinner;
|
|
1336
|
-
} else if (!isUnicodeSupported()) {
|
|
1337
|
-
this.#spinner = cliSpinners.line;
|
|
1338
|
-
} else if (spinner === undefined) {
|
|
1339
|
-
// Set default spinner
|
|
1340
|
-
this.#spinner = cliSpinners.dots;
|
|
1341
|
-
} else if (spinner !== 'default' && cliSpinners[spinner]) {
|
|
1342
|
-
this.#spinner = cliSpinners[spinner];
|
|
1343
|
-
} else {
|
|
1344
|
-
throw new Error(`There is no built-in spinner named '${spinner}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`);
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
|
|
1348
|
-
get text() {
|
|
1349
|
-
return this.#text;
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
set text(value = '') {
|
|
1353
|
-
this.#text = value;
|
|
1354
|
-
this.#updateLineCount();
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
get prefixText() {
|
|
1358
|
-
return this.#prefixText;
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
|
-
set prefixText(value = '') {
|
|
1362
|
-
this.#prefixText = value;
|
|
1363
|
-
this.#updateLineCount();
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
get suffixText() {
|
|
1367
|
-
return this.#suffixText;
|
|
1368
|
-
}
|
|
1369
|
-
|
|
1370
|
-
set suffixText(value = '') {
|
|
1371
|
-
this.#suffixText = value;
|
|
1372
|
-
this.#updateLineCount();
|
|
1373
|
-
}
|
|
1374
|
-
|
|
1375
|
-
get isSpinning() {
|
|
1376
|
-
return this.#id !== undefined;
|
|
1377
|
-
}
|
|
1378
|
-
|
|
1379
|
-
#getFullPrefixText(prefixText = this.#prefixText, postfix = ' ') {
|
|
1380
|
-
if (typeof prefixText === 'string' && prefixText !== '') {
|
|
1381
|
-
return prefixText + postfix;
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
if (typeof prefixText === 'function') {
|
|
1385
|
-
return prefixText() + postfix;
|
|
1386
|
-
}
|
|
1387
|
-
|
|
1388
|
-
return '';
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
#getFullSuffixText(suffixText = this.#suffixText, prefix = ' ') {
|
|
1392
|
-
if (typeof suffixText === 'string' && suffixText !== '') {
|
|
1393
|
-
return prefix + suffixText;
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
|
-
if (typeof suffixText === 'function') {
|
|
1397
|
-
return prefix + suffixText();
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
return '';
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
#updateLineCount() {
|
|
1404
|
-
const columns = this.#stream.columns ?? 80;
|
|
1405
|
-
const fullPrefixText = this.#getFullPrefixText(this.#prefixText, '-');
|
|
1406
|
-
const fullSuffixText = this.#getFullSuffixText(this.#suffixText, '-');
|
|
1407
|
-
const fullText = ' '.repeat(this.#indent) + fullPrefixText + '--' + this.#text + '--' + fullSuffixText;
|
|
1408
|
-
|
|
1409
|
-
this.#lineCount = 0;
|
|
1410
|
-
for (const line of stripAnsi(fullText).split('\n')) {
|
|
1411
|
-
this.#lineCount += Math.max(1, Math.ceil(stringWidth(line, {countAnsiEscapeCodes: true}) / columns));
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
get isEnabled() {
|
|
1416
|
-
return this.#isEnabled && !this.#isSilent;
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
set isEnabled(value) {
|
|
1420
|
-
if (typeof value !== 'boolean') {
|
|
1421
|
-
throw new TypeError('The `isEnabled` option must be a boolean');
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
this.#isEnabled = value;
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
get isSilent() {
|
|
1428
|
-
return this.#isSilent;
|
|
1429
|
-
}
|
|
1430
|
-
|
|
1431
|
-
set isSilent(value) {
|
|
1432
|
-
if (typeof value !== 'boolean') {
|
|
1433
|
-
throw new TypeError('The `isSilent` option must be a boolean');
|
|
1434
|
-
}
|
|
1435
|
-
|
|
1436
|
-
this.#isSilent = value;
|
|
1437
|
-
}
|
|
1438
|
-
|
|
1439
|
-
frame() {
|
|
1440
|
-
// Ensure we only update the spinner frame at the wanted interval,
|
|
1441
|
-
// even if the render method is called more often.
|
|
1442
|
-
const now = Date.now();
|
|
1443
|
-
if (this.#frameIndex === -1 || now - this.#lastSpinnerFrameTime >= this.interval) {
|
|
1444
|
-
this.#frameIndex = ++this.#frameIndex % this.#spinner.frames.length;
|
|
1445
|
-
this.#lastSpinnerFrameTime = now;
|
|
1446
|
-
}
|
|
1447
|
-
|
|
1448
|
-
const {frames} = this.#spinner;
|
|
1449
|
-
let frame = frames[this.#frameIndex];
|
|
1450
|
-
|
|
1451
|
-
if (this.color) {
|
|
1452
|
-
frame = chalk[this.color](frame);
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
const fullPrefixText = (typeof this.#prefixText === 'string' && this.#prefixText !== '') ? this.#prefixText + ' ' : '';
|
|
1456
|
-
const fullText = typeof this.text === 'string' ? ' ' + this.text : '';
|
|
1457
|
-
const fullSuffixText = (typeof this.#suffixText === 'string' && this.#suffixText !== '') ? ' ' + this.#suffixText : '';
|
|
1458
|
-
|
|
1459
|
-
return fullPrefixText + frame + fullText + fullSuffixText;
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
clear() {
|
|
1463
|
-
if (!this.#isEnabled || !this.#stream.isTTY) {
|
|
1464
|
-
return this;
|
|
1465
|
-
}
|
|
1466
|
-
|
|
1467
|
-
this.#stream.cursorTo(0);
|
|
1468
|
-
|
|
1469
|
-
for (let index = 0; index < this.#linesToClear; index++) {
|
|
1470
|
-
if (index > 0) {
|
|
1471
|
-
this.#stream.moveCursor(0, -1);
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
this.#stream.clearLine(1);
|
|
1475
|
-
}
|
|
1476
|
-
|
|
1477
|
-
if (this.#indent || this.lastIndent !== this.#indent) {
|
|
1478
|
-
this.#stream.cursorTo(this.#indent);
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
this.lastIndent = this.#indent;
|
|
1482
|
-
this.#linesToClear = 0;
|
|
1483
|
-
|
|
1484
|
-
return this;
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
render() {
|
|
1488
|
-
if (this.#isSilent) {
|
|
1489
|
-
return this;
|
|
1490
|
-
}
|
|
1491
|
-
|
|
1492
|
-
this.clear();
|
|
1493
|
-
this.#stream.write(this.frame());
|
|
1494
|
-
this.#linesToClear = this.#lineCount;
|
|
1495
|
-
|
|
1496
|
-
return this;
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
start(text) {
|
|
1500
|
-
if (text) {
|
|
1501
|
-
this.text = text;
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
if (this.#isSilent) {
|
|
1505
|
-
return this;
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
if (!this.#isEnabled) {
|
|
1509
|
-
if (this.text) {
|
|
1510
|
-
this.#stream.write(`- ${this.text}\n`);
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
|
-
return this;
|
|
1514
|
-
}
|
|
1515
|
-
|
|
1516
|
-
if (this.isSpinning) {
|
|
1517
|
-
return this;
|
|
1518
|
-
}
|
|
1519
|
-
|
|
1520
|
-
if (this.#options.hideCursor) {
|
|
1521
|
-
cliCursor.hide(this.#stream);
|
|
1522
|
-
}
|
|
1523
|
-
|
|
1524
|
-
if (this.#options.discardStdin && process__default.stdin.isTTY) {
|
|
1525
|
-
this.#isDiscardingStdin = true;
|
|
1526
|
-
stdinDiscarder.start();
|
|
1527
|
-
}
|
|
1528
|
-
|
|
1529
|
-
this.render();
|
|
1530
|
-
this.#id = setInterval(this.render.bind(this), this.interval);
|
|
1531
|
-
|
|
1532
|
-
return this;
|
|
1533
|
-
}
|
|
1534
|
-
|
|
1535
|
-
stop() {
|
|
1536
|
-
if (!this.#isEnabled) {
|
|
1537
|
-
return this;
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
clearInterval(this.#id);
|
|
1541
|
-
this.#id = undefined;
|
|
1542
|
-
this.#frameIndex = 0;
|
|
1543
|
-
this.clear();
|
|
1544
|
-
if (this.#options.hideCursor) {
|
|
1545
|
-
cliCursor.show(this.#stream);
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
if (this.#options.discardStdin && process__default.stdin.isTTY && this.#isDiscardingStdin) {
|
|
1549
|
-
stdinDiscarder.stop();
|
|
1550
|
-
this.#isDiscardingStdin = false;
|
|
1551
|
-
}
|
|
1552
|
-
|
|
1553
|
-
return this;
|
|
1554
|
-
}
|
|
1555
|
-
|
|
1556
|
-
succeed(text) {
|
|
1557
|
-
return this.stopAndPersist({symbol: logSymbols.success, text});
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
fail(text) {
|
|
1561
|
-
return this.stopAndPersist({symbol: logSymbols.error, text});
|
|
1562
|
-
}
|
|
1563
|
-
|
|
1564
|
-
warn(text) {
|
|
1565
|
-
return this.stopAndPersist({symbol: logSymbols.warning, text});
|
|
1566
|
-
}
|
|
1567
|
-
|
|
1568
|
-
info(text) {
|
|
1569
|
-
return this.stopAndPersist({symbol: logSymbols.info, text});
|
|
1570
|
-
}
|
|
1571
|
-
|
|
1572
|
-
stopAndPersist(options = {}) {
|
|
1573
|
-
if (this.#isSilent) {
|
|
1574
|
-
return this;
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
|
-
const prefixText = options.prefixText ?? this.#prefixText;
|
|
1578
|
-
const fullPrefixText = this.#getFullPrefixText(prefixText, ' ');
|
|
1579
|
-
|
|
1580
|
-
const symbolText = options.symbol ?? ' ';
|
|
1581
|
-
|
|
1582
|
-
const text = options.text ?? this.text;
|
|
1583
|
-
const separatorText = symbolText ? ' ' : '';
|
|
1584
|
-
const fullText = (typeof text === 'string') ? separatorText + text : '';
|
|
1585
|
-
|
|
1586
|
-
const suffixText = options.suffixText ?? this.#suffixText;
|
|
1587
|
-
const fullSuffixText = this.#getFullSuffixText(suffixText, ' ');
|
|
1588
|
-
|
|
1589
|
-
const textToWrite = fullPrefixText + symbolText + fullText + fullSuffixText + '\n';
|
|
1590
|
-
|
|
1591
|
-
this.stop();
|
|
1592
|
-
this.#stream.write(textToWrite);
|
|
1593
|
-
|
|
1594
|
-
return this;
|
|
1595
|
-
}
|
|
1596
|
-
}
|
|
1597
|
-
|
|
1598
|
-
function ora(options) {
|
|
1599
|
-
return new Ora(options);
|
|
1600
|
-
}
|
|
1601
|
-
|
|
1602
|
-
export { ora as default, cliSpinners as spinners };
|
|
1
|
+
export { T as TomlDate, a as TomlError, p as parse } from '../shared/ccjk.BBtCGd_g.mjs';
|
|
2
|
+
|
|
3
|
+
/*!
|
|
4
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
5
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
+
*
|
|
7
|
+
* Redistribution and use in source and binary forms, with or without
|
|
8
|
+
* modification, are permitted provided that the following conditions are met:
|
|
9
|
+
*
|
|
10
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
11
|
+
* list of conditions and the following disclaimer.
|
|
12
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
* this list of conditions and the following disclaimer in the
|
|
14
|
+
* documentation and/or other materials provided with the distribution.
|
|
15
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
16
|
+
* may be used to endorse or promote products derived from this software without
|
|
17
|
+
* specific prior written permission.
|
|
18
|
+
*
|
|
19
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
20
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
21
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
+
*/
|
|
30
|
+
let BARE_KEY = /^[a-z0-9-_]+$/i;
|
|
31
|
+
function extendedTypeOf(obj) {
|
|
32
|
+
let type = typeof obj;
|
|
33
|
+
if (type === 'object') {
|
|
34
|
+
if (Array.isArray(obj))
|
|
35
|
+
return 'array';
|
|
36
|
+
if (obj instanceof Date)
|
|
37
|
+
return 'date';
|
|
38
|
+
}
|
|
39
|
+
return type;
|
|
40
|
+
}
|
|
41
|
+
function isArrayOfTables(obj) {
|
|
42
|
+
for (let i = 0; i < obj.length; i++) {
|
|
43
|
+
if (extendedTypeOf(obj[i]) !== 'object')
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return obj.length != 0;
|
|
47
|
+
}
|
|
48
|
+
function formatString(s) {
|
|
49
|
+
return JSON.stringify(s).replace(/\x7f/g, '\\u007f');
|
|
50
|
+
}
|
|
51
|
+
function stringifyValue(val, type, depth, numberAsFloat) {
|
|
52
|
+
if (depth === 0) {
|
|
53
|
+
throw new Error('Could not stringify the object: maximum object depth exceeded');
|
|
54
|
+
}
|
|
55
|
+
if (type === 'number') {
|
|
56
|
+
if (isNaN(val))
|
|
57
|
+
return 'nan';
|
|
58
|
+
if (val === Infinity)
|
|
59
|
+
return 'inf';
|
|
60
|
+
if (val === -Infinity)
|
|
61
|
+
return '-inf';
|
|
62
|
+
if (numberAsFloat && Number.isInteger(val))
|
|
63
|
+
return val.toFixed(1);
|
|
64
|
+
return val.toString();
|
|
65
|
+
}
|
|
66
|
+
if (type === 'bigint' || type === 'boolean') {
|
|
67
|
+
return val.toString();
|
|
68
|
+
}
|
|
69
|
+
if (type === 'string') {
|
|
70
|
+
return formatString(val);
|
|
71
|
+
}
|
|
72
|
+
if (type === 'date') {
|
|
73
|
+
if (isNaN(val.getTime())) {
|
|
74
|
+
throw new TypeError('cannot serialize invalid date');
|
|
75
|
+
}
|
|
76
|
+
return val.toISOString();
|
|
77
|
+
}
|
|
78
|
+
if (type === 'object') {
|
|
79
|
+
return stringifyInlineTable(val, depth, numberAsFloat);
|
|
80
|
+
}
|
|
81
|
+
if (type === 'array') {
|
|
82
|
+
return stringifyArray(val, depth, numberAsFloat);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function stringifyInlineTable(obj, depth, numberAsFloat) {
|
|
86
|
+
let keys = Object.keys(obj);
|
|
87
|
+
if (keys.length === 0)
|
|
88
|
+
return '{}';
|
|
89
|
+
let res = '{ ';
|
|
90
|
+
for (let i = 0; i < keys.length; i++) {
|
|
91
|
+
let k = keys[i];
|
|
92
|
+
if (i)
|
|
93
|
+
res += ', ';
|
|
94
|
+
res += BARE_KEY.test(k) ? k : formatString(k);
|
|
95
|
+
res += ' = ';
|
|
96
|
+
res += stringifyValue(obj[k], extendedTypeOf(obj[k]), depth - 1, numberAsFloat);
|
|
97
|
+
}
|
|
98
|
+
return res + ' }';
|
|
99
|
+
}
|
|
100
|
+
function stringifyArray(array, depth, numberAsFloat) {
|
|
101
|
+
if (array.length === 0)
|
|
102
|
+
return '[]';
|
|
103
|
+
let res = '[ ';
|
|
104
|
+
for (let i = 0; i < array.length; i++) {
|
|
105
|
+
if (i)
|
|
106
|
+
res += ', ';
|
|
107
|
+
if (array[i] === null || array[i] === void 0) {
|
|
108
|
+
throw new TypeError('arrays cannot contain null or undefined values');
|
|
109
|
+
}
|
|
110
|
+
res += stringifyValue(array[i], extendedTypeOf(array[i]), depth - 1, numberAsFloat);
|
|
111
|
+
}
|
|
112
|
+
return res + ' ]';
|
|
113
|
+
}
|
|
114
|
+
function stringifyArrayTable(array, key, depth, numberAsFloat) {
|
|
115
|
+
if (depth === 0) {
|
|
116
|
+
throw new Error('Could not stringify the object: maximum object depth exceeded');
|
|
117
|
+
}
|
|
118
|
+
let res = '';
|
|
119
|
+
for (let i = 0; i < array.length; i++) {
|
|
120
|
+
res += `${res && '\n'}[[${key}]]\n`;
|
|
121
|
+
res += stringifyTable(0, array[i], key, depth, numberAsFloat);
|
|
122
|
+
}
|
|
123
|
+
return res;
|
|
124
|
+
}
|
|
125
|
+
function stringifyTable(tableKey, obj, prefix, depth, numberAsFloat) {
|
|
126
|
+
if (depth === 0) {
|
|
127
|
+
throw new Error('Could not stringify the object: maximum object depth exceeded');
|
|
128
|
+
}
|
|
129
|
+
let preamble = '';
|
|
130
|
+
let tables = '';
|
|
131
|
+
let keys = Object.keys(obj);
|
|
132
|
+
for (let i = 0; i < keys.length; i++) {
|
|
133
|
+
let k = keys[i];
|
|
134
|
+
if (obj[k] !== null && obj[k] !== void 0) {
|
|
135
|
+
let type = extendedTypeOf(obj[k]);
|
|
136
|
+
if (type === 'symbol' || type === 'function') {
|
|
137
|
+
throw new TypeError(`cannot serialize values of type '${type}'`);
|
|
138
|
+
}
|
|
139
|
+
let key = BARE_KEY.test(k) ? k : formatString(k);
|
|
140
|
+
if (type === 'array' && isArrayOfTables(obj[k])) {
|
|
141
|
+
tables += (tables && '\n') + stringifyArrayTable(obj[k], prefix ? `${prefix}.${key}` : key, depth - 1, numberAsFloat);
|
|
142
|
+
}
|
|
143
|
+
else if (type === 'object') {
|
|
144
|
+
let tblKey = prefix ? `${prefix}.${key}` : key;
|
|
145
|
+
tables += (tables && '\n') + stringifyTable(tblKey, obj[k], tblKey, depth - 1, numberAsFloat);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
preamble += key;
|
|
149
|
+
preamble += ' = ';
|
|
150
|
+
preamble += stringifyValue(obj[k], type, depth, numberAsFloat);
|
|
151
|
+
preamble += '\n';
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (tableKey && (preamble || !tables)) // Create table only if necessary
|
|
156
|
+
preamble = preamble ? `[${tableKey}]\n${preamble}` : `[${tableKey}]`;
|
|
157
|
+
return preamble && tables
|
|
158
|
+
? `${preamble}\n${tables}`
|
|
159
|
+
: preamble || tables;
|
|
160
|
+
}
|
|
161
|
+
function stringify(obj, { maxDepth = 1000, numbersAsFloat = false } = {}) {
|
|
162
|
+
if (extendedTypeOf(obj) !== 'object') {
|
|
163
|
+
throw new TypeError('stringify can only be called with an object');
|
|
164
|
+
}
|
|
165
|
+
let str = stringifyTable(0, obj, '', maxDepth, numbersAsFloat);
|
|
166
|
+
if (str[str.length - 1] !== '\n')
|
|
167
|
+
return str + '\n';
|
|
168
|
+
return str;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export { stringify };
|