usage-board 4.0.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/index.mjs +40 -22
  2. package/dist/public/_nuxt/3inMrCcs.js +146 -0
  3. package/dist/public/_nuxt/5M1aAlPv.js +6 -0
  4. package/dist/public/_nuxt/{C0GhHHgI.js → BHGcQrYH.js} +2 -2
  5. package/dist/public/_nuxt/{DF2WsXH3.js → BgVTqBr9.js} +1 -1
  6. package/dist/public/_nuxt/{DXWxIyGU.js → BhTZzeJU.js} +1 -1
  7. package/dist/public/_nuxt/{D7qEPtpx.js → BlxNEZ3W.js} +1 -1
  8. package/dist/public/_nuxt/BwYRMC0_.js +1 -0
  9. package/dist/public/_nuxt/C3BLG0Zo.js +21 -0
  10. package/dist/public/_nuxt/{De8DvPWL.js → C8lAAJpL.js} +1 -1
  11. package/dist/public/_nuxt/Cxd8QZxF.js +261 -0
  12. package/dist/public/_nuxt/DXeNXt_b.js +1 -0
  13. package/dist/public/_nuxt/DavRiQHq.js +25 -0
  14. package/dist/public/_nuxt/{Jp5cgQZi.js → DfL4oXhq.js} +3 -3
  15. package/dist/public/_nuxt/DjKivtvZ.js +1 -0
  16. package/dist/public/_nuxt/{37OOe3RF.js → OPi16VNs.js} +1 -1
  17. package/dist/public/_nuxt/builds/latest.json +1 -1
  18. package/dist/public/_nuxt/builds/meta/eff380a6-8407-4f41-af1f-39f3ae1dface.json +1 -0
  19. package/dist/public/_nuxt/{entry.DnkKc-6G.css → entry.BYVbC6M5.css} +1 -1
  20. package/dist/public/_nuxt/error-404.ABvo6GrV.css +1 -0
  21. package/dist/public/_nuxt/error-500.CaR7LJUF.css +1 -0
  22. package/dist/public/pricing-data/fast-multiplier-overrides.json +12 -0
  23. package/dist/public/pricing-data/litellm-pricing.json +43714 -0
  24. package/dist/public/pricing-data/models-dev-pricing.json +178004 -0
  25. package/dist/server/chunks/_/analysis-handlers.mjs +54 -0
  26. package/dist/server/chunks/_/pagination.mjs +16 -0
  27. package/dist/server/chunks/build/client.precomputed.mjs +1 -1
  28. package/dist/server/chunks/nitro/nitro.mjs +4976 -5765
  29. package/dist/server/chunks/routes/api/analysis/agent/session.json.mjs +28 -4
  30. package/dist/server/chunks/routes/api/analysis/agent/token.json.mjs +14 -4
  31. package/dist/server/chunks/routes/api/analysis/cache.json.mjs +12 -3
  32. package/dist/server/chunks/routes/api/analysis/hot-project.json.mjs +15 -5
  33. package/dist/server/chunks/routes/api/analysis/live-state.json.mjs +32 -0
  34. package/dist/server/chunks/routes/api/analysis/model.json.mjs +12 -3
  35. package/dist/server/chunks/routes/api/analysis/overview-cards.json.mjs +12 -3
  36. package/dist/server/chunks/routes/api/analysis/session.json.mjs +12 -3
  37. package/dist/server/chunks/routes/api/analysis/token/daily.json.mjs +25 -4
  38. package/dist/server/chunks/routes/api/analysis/token/today-hourly.json.mjs +12 -3
  39. package/dist/server/chunks/routes/api/analysis/token.json.mjs +12 -3
  40. package/dist/server/chunks/routes/api/projects/_project/modules.get.mjs +14 -6
  41. package/dist/server/chunks/routes/api/projects/catalog.get.mjs +12 -4
  42. package/dist/server/chunks/routes/renderer.mjs +11 -3
  43. package/dist/server/chunks/routes/ws.mjs +64 -59
  44. package/dist/server/index.mjs +11 -3
  45. package/dist/server/node_modules/@clack/core/dist/index.mjs +17 -0
  46. package/dist/server/node_modules/@clack/core/package.json +63 -0
  47. package/dist/server/node_modules/@clack/prompts/dist/index.mjs +145 -0
  48. package/dist/server/node_modules/@clack/prompts/package.json +68 -0
  49. package/dist/server/node_modules/dayjs/dayjs.min.js +1 -0
  50. package/dist/server/node_modules/dayjs/package.json +85 -0
  51. package/dist/server/node_modules/dayjs/plugin/utc.js +1 -0
  52. package/dist/server/node_modules/fast-string-truncated-width/dist/index.js +111 -0
  53. package/dist/server/node_modules/fast-string-truncated-width/dist/utils.js +20 -0
  54. package/dist/server/node_modules/fast-string-truncated-width/package.json +35 -0
  55. package/dist/server/node_modules/fast-string-width/dist/index.js +14 -0
  56. package/dist/server/node_modules/fast-string-width/package.json +34 -0
  57. package/dist/server/node_modules/fast-wrap-ansi/lib/main.js +218 -0
  58. package/dist/server/node_modules/fast-wrap-ansi/package.json +51 -0
  59. package/dist/server/node_modules/sisteransi/package.json +34 -0
  60. package/dist/server/node_modules/sisteransi/src/index.js +58 -0
  61. package/dist/server/node_modules/xdg-basedir/index.js +30 -0
  62. package/dist/server/node_modules/xdg-basedir/package.json +47 -0
  63. package/dist/server/package.json +10 -2
  64. package/package.json +11 -9
  65. package/dist/public/_nuxt/65Ayv2XK.js +0 -146
  66. package/dist/public/_nuxt/BOWwkrCY.js +0 -25
  67. package/dist/public/_nuxt/D9-Yw1TR.js +0 -1
  68. package/dist/public/_nuxt/DKaPq50Z.js +0 -6
  69. package/dist/public/_nuxt/DgMMKsPE.js +0 -258
  70. package/dist/public/_nuxt/DxvuOJRP.js +0 -1
  71. package/dist/public/_nuxt/builds/meta/34b12f78-e5b7-490f-99ba-b4a8ab41b914.json +0 -1
  72. package/dist/public/_nuxt/error-404.CFBEg71j.css +0 -1
  73. package/dist/public/_nuxt/error-500.BqCnH31G.css +0 -1
  74. package/dist/public/_nuxt/qXgLTL_3.js +0 -21
  75. package/dist/public/_nuxt/y6mAKUDU.js +0 -1
  76. package/dist/server/chunks/routes/api/payload.json.mjs +0 -26
@@ -0,0 +1,85 @@
1
+ {
2
+ "name": "dayjs",
3
+ "version": "1.11.21",
4
+ "description": "2KB immutable date time library alternative to Moment.js with the same modern API ",
5
+ "main": "dayjs.min.js",
6
+ "types": "index.d.ts",
7
+ "scripts": {
8
+ "test": "cross-env TZ=Pacific/Auckland npm run test-tz && cross-env TZ=Europe/London npm run test-tz && cross-env TZ=America/Whitehorse npm run test-tz && npm run test-tz && jest --coverage --coverageThreshold=\"{ \\\"global\\\": { \\\"lines\\\": 100} }\"",
9
+ "test-tz": "date && jest test/timezone.test --coverage=false",
10
+ "lint": "./node_modules/.bin/eslint src/* test/* build/*",
11
+ "prettier": "prettier --write \"docs/**/*.md\"",
12
+ "babel": "cross-env BABEL_ENV=build babel src --out-dir esm --copy-files && node build/esm",
13
+ "build": "cross-env BABEL_ENV=build node build && npm run size",
14
+ "sauce": "npx karma start karma.sauce.conf.js",
15
+ "test:sauce": "npm run sauce -- 0 && npm run sauce -- 1 && npm run sauce -- 2 && npm run sauce -- 3",
16
+ "size": "size-limit && gzip-size dayjs.min.js"
17
+ },
18
+ "pre-commit": [
19
+ "lint"
20
+ ],
21
+ "size-limit": [
22
+ {
23
+ "limit": "2.99 KB",
24
+ "path": "dayjs.min.js"
25
+ }
26
+ ],
27
+ "jest": {
28
+ "roots": [
29
+ "test"
30
+ ],
31
+ "testRegex": "test/(.*?/)?.*test.js$",
32
+ "testURL": "http://localhost",
33
+ "coverageDirectory": "./coverage/",
34
+ "collectCoverage": true,
35
+ "collectCoverageFrom": [
36
+ "src/**/*"
37
+ ]
38
+ },
39
+ "keywords": [
40
+ "dayjs",
41
+ "date",
42
+ "time",
43
+ "immutable",
44
+ "moment"
45
+ ],
46
+ "author": "iamkun",
47
+ "license": "MIT",
48
+ "homepage": "https://day.js.org",
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "https://github.com/iamkun/dayjs.git"
52
+ },
53
+ "devDependencies": {
54
+ "@babel/cli": "^7.0.0-beta.44",
55
+ "@babel/core": "^7.0.0-beta.44",
56
+ "@babel/node": "^7.0.0-beta.44",
57
+ "@babel/preset-env": "^7.0.0-beta.44",
58
+ "@semantic-release/github": "^11.0.4",
59
+ "babel-core": "^7.0.0-bridge.0",
60
+ "babel-jest": "^22.4.3",
61
+ "babel-plugin-external-helpers": "^6.22.0",
62
+ "cross-env": "^5.1.6",
63
+ "eslint": "^4.19.1",
64
+ "eslint-config-airbnb-base": "^12.1.0",
65
+ "eslint-plugin-import": "^2.10.0",
66
+ "eslint-plugin-jest": "^21.15.0",
67
+ "gzip-size-cli": "^2.1.0",
68
+ "jasmine-core": "^2.99.1",
69
+ "jest": "^22.4.3",
70
+ "karma": "^2.0.2",
71
+ "karma-jasmine": "^1.1.2",
72
+ "karma-sauce-launcher": "^1.1.0",
73
+ "mockdate": "^2.0.2",
74
+ "moment": "2.29.2",
75
+ "moment-timezone": "0.5.31",
76
+ "ncp": "^2.0.0",
77
+ "pre-commit": "^1.2.2",
78
+ "prettier": "^1.16.1",
79
+ "rollup": "^2.45.1",
80
+ "rollup-plugin-babel": "^4.4.0",
81
+ "rollup-plugin-terser": "^7.0.2",
82
+ "size-limit": "^0.18.0",
83
+ "typescript": "^2.8.3"
84
+ }
85
+ }
@@ -0,0 +1 @@
1
+ !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t="undefined"!=typeof globalThis?globalThis:t||self).dayjs_plugin_utc=i()}(this,(function(){"use strict";var t="minute",i=/[+-]\d\d(?::?\d\d)?/g,e=/([+-]|\d\d)/g;return function(s,f,n){var u=f.prototype;n.utc=function(t){var i={date:t,utc:!0,args:arguments};return new f(i)},u.utc=function(i){var e=n(this.toDate(),{locale:this.$L,utc:!0});return i?e.add(this.utcOffset(),t):e},u.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var r=u.parse;u.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),r.call(this,t)};var o=u.init;u.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else o.call(this)};var a=u.utcOffset;u.utcOffset=function(s,f){var n=this.$utils().u;if(n(s))return this.$u?0:n(this.$offset)?a.call(this):this.$offset;if("string"==typeof s&&(s=function(t){void 0===t&&(t="");var s=t.match(i);if(!s)return null;var f=(""+s[0]).match(e)||["-",0,0],n=f[0],u=60*+f[1]+ +f[2];return 0===u?0:"+"===n?u:-u}(s),null===s))return this;var u=Math.abs(s)<=16?60*s:s;if(0===u)return this.utc(f);var r=this.clone();if(f)return r.$offset=u,r.$u=!1,r;var o=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(r=this.local().add(u+o,t)).$offset=u,r.$x.$localOffset=o,r};var h=u.format;u.format=function(t){var i=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,i)},u.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},u.isUTC=function(){return!!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var l=u.toDate;u.toDate=function(t){return"s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():l.call(this)};var c=u.diff;u.diff=function(t,i,e){if(t&&this.$u===t.$u)return c.call(this,t,i,e);var s=this.local(),f=n(t).local();return c.call(s,f,i,e)}}}));
@@ -0,0 +1,111 @@
1
+ /* IMPORT */
2
+ import { getCodePointsLength, isFullWidth, isWideNotCJKTNotEmoji } from './utils.js';
3
+ /* HELPERS */
4
+ const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
5
+ const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
6
+ const CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
7
+ const TAB_RE = /\t{1,1000}/y;
8
+ const EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
9
+ const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
10
+ const MODIFIER_RE = /\p{M}+/gu;
11
+ const NO_TRUNCATION = { limit: Infinity, ellipsis: '' };
12
+ /* MAIN */
13
+ const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {}) => {
14
+ /* CONSTANTS */
15
+ const LIMIT = truncationOptions.limit ?? Infinity;
16
+ const ELLIPSIS = truncationOptions.ellipsis ?? '';
17
+ const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
18
+ const ANSI_WIDTH = 0;
19
+ const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
20
+ const TAB_WIDTH = widthOptions.tabWidth ?? 8;
21
+ const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
22
+ const FULL_WIDTH_WIDTH = 2;
23
+ const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
24
+ const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
25
+ const PARSE_BLOCKS = [
26
+ [LATIN_RE, REGULAR_WIDTH],
27
+ [ANSI_RE, ANSI_WIDTH],
28
+ [CONTROL_RE, CONTROL_WIDTH],
29
+ [TAB_RE, TAB_WIDTH],
30
+ [EMOJI_RE, EMOJI_WIDTH],
31
+ [CJKT_WIDE_RE, WIDE_WIDTH],
32
+ ];
33
+ /* STATE */
34
+ let indexPrev = 0;
35
+ let index = 0;
36
+ let length = input.length;
37
+ let lengthExtra = 0;
38
+ let truncationEnabled = false;
39
+ let truncationIndex = length;
40
+ let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
41
+ let unmatchedStart = 0;
42
+ let unmatchedEnd = 0;
43
+ let width = 0;
44
+ let widthExtra = 0;
45
+ /* PARSE LOOP */
46
+ outer: while (true) {
47
+ /* UNMATCHED */
48
+ if ((unmatchedEnd > unmatchedStart) || (index >= length && index > indexPrev)) {
49
+ const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
50
+ lengthExtra = 0;
51
+ for (const char of unmatched.replaceAll(MODIFIER_RE, '')) {
52
+ const codePoint = char.codePointAt(0) || 0;
53
+ if (isFullWidth(codePoint)) {
54
+ widthExtra = FULL_WIDTH_WIDTH;
55
+ }
56
+ else if (isWideNotCJKTNotEmoji(codePoint)) {
57
+ widthExtra = WIDE_WIDTH;
58
+ }
59
+ else {
60
+ widthExtra = REGULAR_WIDTH;
61
+ }
62
+ if ((width + widthExtra) > truncationLimit) {
63
+ truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
64
+ }
65
+ if ((width + widthExtra) > LIMIT) {
66
+ truncationEnabled = true;
67
+ break outer;
68
+ }
69
+ lengthExtra += char.length;
70
+ width += widthExtra;
71
+ }
72
+ unmatchedStart = unmatchedEnd = 0;
73
+ }
74
+ /* EXITING */
75
+ if (index >= length) {
76
+ break outer;
77
+ }
78
+ /* PARSE BLOCKS */
79
+ for (let i = 0, l = PARSE_BLOCKS.length; i < l; i++) {
80
+ const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
81
+ BLOCK_RE.lastIndex = index;
82
+ if (BLOCK_RE.test(input)) {
83
+ lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
84
+ widthExtra = lengthExtra * BLOCK_WIDTH;
85
+ if ((width + widthExtra) > truncationLimit) {
86
+ truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
87
+ }
88
+ if ((width + widthExtra) > LIMIT) {
89
+ truncationEnabled = true;
90
+ break outer;
91
+ }
92
+ width += widthExtra;
93
+ unmatchedStart = indexPrev;
94
+ unmatchedEnd = index;
95
+ index = indexPrev = BLOCK_RE.lastIndex;
96
+ continue outer;
97
+ }
98
+ }
99
+ /* UNMATCHED INDEX */
100
+ index += 1;
101
+ }
102
+ /* RETURN */
103
+ return {
104
+ width: truncationEnabled ? truncationLimit : width,
105
+ index: truncationEnabled ? truncationIndex : length,
106
+ truncated: truncationEnabled,
107
+ ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
108
+ };
109
+ };
110
+ /* EXPORT */
111
+ export default getStringTruncatedWidth;
@@ -0,0 +1,20 @@
1
+ /* MAIN */
2
+ const getCodePointsLength = (() => {
3
+ const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
4
+ return (input) => {
5
+ let surrogatePairsNr = 0;
6
+ SURROGATE_PAIR_RE.lastIndex = 0;
7
+ while (SURROGATE_PAIR_RE.test(input)) {
8
+ surrogatePairsNr += 1;
9
+ }
10
+ return input.length - surrogatePairsNr;
11
+ };
12
+ })();
13
+ const isFullWidth = (x) => {
14
+ return x === 0x3000 || x >= 0xFF01 && x <= 0xFF60 || x >= 0xFFE0 && x <= 0xFFE6;
15
+ };
16
+ const isWideNotCJKTNotEmoji = (x) => {
17
+ return x === 0x231B || x === 0x2329 || x >= 0x2FF0 && x <= 0x2FFF || x >= 0x3001 && x <= 0x303E || x >= 0x3099 && x <= 0x30FF || x >= 0x3105 && x <= 0x312F || x >= 0x3131 && x <= 0x318E || x >= 0x3190 && x <= 0x31E3 || x >= 0x31EF && x <= 0x321E || x >= 0x3220 && x <= 0x3247 || x >= 0x3250 && x <= 0x4DBF || x >= 0xFE10 && x <= 0xFE19 || x >= 0xFE30 && x <= 0xFE52 || x >= 0xFE54 && x <= 0xFE66 || x >= 0xFE68 && x <= 0xFE6B || x >= 0x1F200 && x <= 0x1F202 || x >= 0x1F210 && x <= 0x1F23B || x >= 0x1F240 && x <= 0x1F248 || x >= 0x20000 && x <= 0x2FFFD || x >= 0x30000 && x <= 0x3FFFD;
18
+ };
19
+ /* EXPORT */
20
+ export { getCodePointsLength, isFullWidth, isWideNotCJKTNotEmoji };
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "fast-string-truncated-width",
3
+ "repository": "github:fabiospampinato/fast-string-truncated-width",
4
+ "description": "A fast function for calculating where a string should be truncated, given an optional width limit and an ellipsis string.",
5
+ "license": "MIT",
6
+ "version": "3.0.3",
7
+ "type": "module",
8
+ "main": "dist/index.js",
9
+ "exports": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "scripts": {
12
+ "benchmark": "tsex benchmark",
13
+ "benchmark:watch": "tsex benchmark --watch",
14
+ "clean": "tsex clean",
15
+ "compile": "tsex compile",
16
+ "compile:watch": "tsex compile --watch",
17
+ "test": "tsex test",
18
+ "test:watch": "tsex test --watch",
19
+ "prepublishOnly": "tsex prepare"
20
+ },
21
+ "keywords": [
22
+ "fast",
23
+ "string",
24
+ "truncated",
25
+ "width",
26
+ "cli",
27
+ "terminal"
28
+ ],
29
+ "devDependencies": {
30
+ "benchloop": "^2.1.1",
31
+ "fava": "^0.3.4",
32
+ "tsex": "^4.0.2",
33
+ "typescript": "^5.7.3"
34
+ }
35
+ }
@@ -0,0 +1,14 @@
1
+ /* IMPORT */
2
+ import fastStringTruncatedWidth from 'fast-string-truncated-width';
3
+ /* HELPERS */
4
+ const NO_TRUNCATION = {
5
+ limit: Infinity,
6
+ ellipsis: '',
7
+ ellipsisWidth: 0,
8
+ };
9
+ /* MAIN */
10
+ const fastStringWidth = (input, options = {}) => {
11
+ return fastStringTruncatedWidth(input, NO_TRUNCATION, options).width;
12
+ };
13
+ /* EXPORT */
14
+ export default fastStringWidth;
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "fast-string-width",
3
+ "repository": "github:fabiospampinato/fast-string-width",
4
+ "description": "A fast function for calculating the visual width of a string once printed to the terminal.",
5
+ "license": "MIT",
6
+ "version": "3.0.2",
7
+ "type": "module",
8
+ "main": "dist/index.js",
9
+ "exports": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "scripts": {
12
+ "clean": "tsex clean",
13
+ "compile": "tsex compile",
14
+ "compile:watch": "tsex compile --watch",
15
+ "test": "tsex test",
16
+ "test:watch": "tsex test --watch",
17
+ "prepublishOnly": "tsex prepare"
18
+ },
19
+ "keywords": [
20
+ "fast",
21
+ "string",
22
+ "width",
23
+ "cli",
24
+ "terminal"
25
+ ],
26
+ "dependencies": {
27
+ "fast-string-truncated-width": "^3.0.2"
28
+ },
29
+ "devDependencies": {
30
+ "fava": "^0.3.4",
31
+ "tsex": "^4.0.2",
32
+ "typescript": "^5.7.3"
33
+ }
34
+ }
@@ -0,0 +1,218 @@
1
+ import stringWidth from 'fast-string-width';
2
+ const ESC = '\x1B';
3
+ const CSI = '\x9B';
4
+ const END_CODE = 39;
5
+ const ANSI_ESCAPE_BELL = '\u0007';
6
+ const ANSI_CSI = '[';
7
+ const ANSI_OSC = ']';
8
+ const ANSI_SGR_TERMINATOR = 'm';
9
+ const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
10
+ const GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, 'y');
11
+ const getClosingCode = (openingCode) => {
12
+ if (openingCode >= 30 && openingCode <= 37)
13
+ return 39;
14
+ if (openingCode >= 90 && openingCode <= 97)
15
+ return 39;
16
+ if (openingCode >= 40 && openingCode <= 47)
17
+ return 49;
18
+ if (openingCode >= 100 && openingCode <= 107)
19
+ return 49;
20
+ if (openingCode === 1 || openingCode === 2)
21
+ return 22;
22
+ if (openingCode === 3)
23
+ return 23;
24
+ if (openingCode === 4)
25
+ return 24;
26
+ if (openingCode === 7)
27
+ return 27;
28
+ if (openingCode === 8)
29
+ return 28;
30
+ if (openingCode === 9)
31
+ return 29;
32
+ if (openingCode === 0)
33
+ return 0;
34
+ return undefined;
35
+ };
36
+ const wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
37
+ const wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
38
+ const wrapWord = (rows, word, columns) => {
39
+ const characters = word[Symbol.iterator]();
40
+ let isInsideEscape = false;
41
+ let isInsideLinkEscape = false;
42
+ let lastRow = rows.at(-1);
43
+ let visible = lastRow === undefined ? 0 : stringWidth(lastRow);
44
+ let currentCharacter = characters.next();
45
+ let nextCharacter = characters.next();
46
+ let rawCharacterIndex = 0;
47
+ while (!currentCharacter.done) {
48
+ const character = currentCharacter.value;
49
+ const characterLength = stringWidth(character);
50
+ if (visible + characterLength <= columns) {
51
+ rows[rows.length - 1] += character;
52
+ }
53
+ else {
54
+ rows.push(character);
55
+ visible = 0;
56
+ }
57
+ if (character === ESC || character === CSI) {
58
+ isInsideEscape = true;
59
+ isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
60
+ }
61
+ if (isInsideEscape) {
62
+ if (isInsideLinkEscape) {
63
+ if (character === ANSI_ESCAPE_BELL) {
64
+ isInsideEscape = false;
65
+ isInsideLinkEscape = false;
66
+ }
67
+ }
68
+ else if (character === ANSI_SGR_TERMINATOR) {
69
+ isInsideEscape = false;
70
+ }
71
+ }
72
+ else {
73
+ visible += characterLength;
74
+ if (visible === columns && !nextCharacter.done) {
75
+ rows.push('');
76
+ visible = 0;
77
+ }
78
+ }
79
+ currentCharacter = nextCharacter;
80
+ nextCharacter = characters.next();
81
+ rawCharacterIndex += character.length;
82
+ }
83
+ lastRow = rows.at(-1);
84
+ if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
85
+ rows[rows.length - 2] += rows.pop();
86
+ }
87
+ };
88
+ const stringVisibleTrimSpacesRight = (string) => {
89
+ const words = string.split(' ');
90
+ let last = words.length;
91
+ while (last) {
92
+ if (stringWidth(words[last - 1])) {
93
+ break;
94
+ }
95
+ last--;
96
+ }
97
+ if (last === words.length) {
98
+ return string;
99
+ }
100
+ return words.slice(0, last).join(' ') + words.slice(last).join('');
101
+ };
102
+ const exec = (string, columns, options = {}) => {
103
+ if (options.trim !== false && string.trim() === '') {
104
+ return '';
105
+ }
106
+ let returnValue = '';
107
+ let escapeCode;
108
+ let escapeUrl;
109
+ const words = string.split(' ');
110
+ let rows = [''];
111
+ let rowLength = 0;
112
+ for (let index = 0; index < words.length; index++) {
113
+ const word = words[index];
114
+ if (options.trim !== false) {
115
+ const row = rows.at(-1) ?? '';
116
+ const trimmed = row.trimStart();
117
+ if (row.length !== trimmed.length) {
118
+ rows[rows.length - 1] = trimmed;
119
+ rowLength = stringWidth(trimmed);
120
+ }
121
+ }
122
+ if (index !== 0) {
123
+ if (rowLength >= columns &&
124
+ (options.wordWrap === false || options.trim === false)) {
125
+ rows.push('');
126
+ rowLength = 0;
127
+ }
128
+ if (rowLength || options.trim === false) {
129
+ rows[rows.length - 1] += ' ';
130
+ rowLength++;
131
+ }
132
+ }
133
+ const wordLength = stringWidth(word);
134
+ if (options.hard && wordLength > columns) {
135
+ const remainingColumns = columns - rowLength;
136
+ const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
137
+ const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
138
+ if (breaksStartingNextLine < breaksStartingThisLine) {
139
+ rows.push('');
140
+ }
141
+ wrapWord(rows, word, columns);
142
+ rowLength = stringWidth(rows.at(-1) ?? '');
143
+ continue;
144
+ }
145
+ if (rowLength + wordLength > columns && rowLength && wordLength) {
146
+ if (options.wordWrap === false && rowLength < columns) {
147
+ wrapWord(rows, word, columns);
148
+ rowLength = stringWidth(rows.at(-1) ?? '');
149
+ continue;
150
+ }
151
+ rows.push('');
152
+ rowLength = 0;
153
+ }
154
+ if (rowLength + wordLength > columns && options.wordWrap === false) {
155
+ wrapWord(rows, word, columns);
156
+ rowLength = stringWidth(rows.at(-1) ?? '');
157
+ continue;
158
+ }
159
+ rows[rows.length - 1] += word;
160
+ rowLength += wordLength;
161
+ }
162
+ if (options.trim !== false) {
163
+ rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
164
+ }
165
+ const preString = rows.join('\n');
166
+ let inSurrogate = false;
167
+ for (let i = 0; i < preString.length; i++) {
168
+ const character = preString[i];
169
+ returnValue += character;
170
+ if (!inSurrogate) {
171
+ inSurrogate = character >= '\ud800' && character <= '\udbff';
172
+ if (inSurrogate) {
173
+ continue;
174
+ }
175
+ }
176
+ else {
177
+ inSurrogate = false;
178
+ }
179
+ if (character === ESC || character === CSI) {
180
+ GROUP_REGEX.lastIndex = i + 1;
181
+ const groupsResult = GROUP_REGEX.exec(preString);
182
+ const groups = groupsResult?.groups;
183
+ if (groups?.code !== undefined) {
184
+ const code = Number.parseFloat(groups.code);
185
+ escapeCode = code === END_CODE ? undefined : code;
186
+ }
187
+ else if (groups?.uri !== undefined) {
188
+ escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
189
+ }
190
+ }
191
+ if (preString[i + 1] === '\n') {
192
+ if (escapeUrl) {
193
+ returnValue += wrapAnsiHyperlink('');
194
+ }
195
+ const closingCode = escapeCode ? getClosingCode(escapeCode) : undefined;
196
+ if (escapeCode && closingCode) {
197
+ returnValue += wrapAnsiCode(closingCode);
198
+ }
199
+ }
200
+ else if (character === '\n') {
201
+ if (escapeCode && getClosingCode(escapeCode)) {
202
+ returnValue += wrapAnsiCode(escapeCode);
203
+ }
204
+ if (escapeUrl) {
205
+ returnValue += wrapAnsiHyperlink(escapeUrl);
206
+ }
207
+ }
208
+ }
209
+ return returnValue;
210
+ };
211
+ const CRLF_OR_LF = /\r?\n/;
212
+ export function wrapAnsi(string, columns, options) {
213
+ return String(string)
214
+ .normalize()
215
+ .split(CRLF_OR_LF)
216
+ .map((line) => exec(line, columns, options))
217
+ .join('\n');
218
+ }
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "fast-wrap-ansi",
3
+ "version": "0.2.2",
4
+ "files": [
5
+ "lib"
6
+ ],
7
+ "description": "A tiny and fast text wrap library which takes ANSI escapes into account.",
8
+ "keywords": [
9
+ "wrap",
10
+ "ansi",
11
+ "term",
12
+ "colors"
13
+ ],
14
+ "homepage": "https://github.com/43081j/fast-wrap-ansi#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/43081j/fast-wrap-ansi/issues"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/43081j/fast-wrap-ansi.git"
21
+ },
22
+ "license": "MIT",
23
+ "author": "James Garbutt (https://github.com/43081j)",
24
+ "type": "module",
25
+ "main": "lib/main.js",
26
+ "scripts": {
27
+ "format": "prettier --write src test",
28
+ "lint": "npm run lint:js && npm run lint:format && npm run lint:types",
29
+ "lint:js": "eslint src test",
30
+ "lint:format": "prettier --check src test",
31
+ "lint:types": "npx tsc --noEmit -p tsconfig.test.json",
32
+ "build": "tsc",
33
+ "test": "vitest run"
34
+ },
35
+ "devDependencies": {
36
+ "@eslint/js": "^10.0.1",
37
+ "@types/node": "^25.8.0",
38
+ "eslint": "^10.4.0",
39
+ "fast-wrap-ansi-prod": "npm:fast-wrap-ansi@*",
40
+ "picocolors": "^1.1.1",
41
+ "prettier": "^3.8.3",
42
+ "tinybench": "^6.0.2",
43
+ "typescript": "^6.0.3",
44
+ "typescript-eslint": "^8.59.3",
45
+ "vitest": "^4.1.6",
46
+ "wrap-ansi": "^10.0.0"
47
+ },
48
+ "dependencies": {
49
+ "fast-string-width": "^3.0.2"
50
+ }
51
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "sisteransi",
3
+ "version": "1.0.5",
4
+ "description": "ANSI escape codes for some terminal swag",
5
+ "main": "src/index.js",
6
+ "license": "MIT",
7
+ "author": {
8
+ "name": "Terkel Gjervig",
9
+ "email": "terkel@terkel.com",
10
+ "url": "https://terkel.com"
11
+ },
12
+ "scripts": {
13
+ "test": "tape test/*.js | tap-spec"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/terkelg/sisteransi"
18
+ },
19
+ "files": [
20
+ "src"
21
+ ],
22
+ "types": "./src/sisteransi.d.ts",
23
+ "keywords": [
24
+ "ansi",
25
+ "escape codes",
26
+ "escape",
27
+ "terminal",
28
+ "style"
29
+ ],
30
+ "devDependencies": {
31
+ "tap-spec": "^5.0.0",
32
+ "tape": "^4.13.2"
33
+ }
34
+ }
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ const ESC = '\x1B';
4
+ const CSI = `${ESC}[`;
5
+ const beep = '\u0007';
6
+
7
+ const cursor = {
8
+ to(x, y) {
9
+ if (!y) return `${CSI}${x + 1}G`;
10
+ return `${CSI}${y + 1};${x + 1}H`;
11
+ },
12
+ move(x, y) {
13
+ let ret = '';
14
+
15
+ if (x < 0) ret += `${CSI}${-x}D`;
16
+ else if (x > 0) ret += `${CSI}${x}C`;
17
+
18
+ if (y < 0) ret += `${CSI}${-y}A`;
19
+ else if (y > 0) ret += `${CSI}${y}B`;
20
+
21
+ return ret;
22
+ },
23
+ up: (count = 1) => `${CSI}${count}A`,
24
+ down: (count = 1) => `${CSI}${count}B`,
25
+ forward: (count = 1) => `${CSI}${count}C`,
26
+ backward: (count = 1) => `${CSI}${count}D`,
27
+ nextLine: (count = 1) => `${CSI}E`.repeat(count),
28
+ prevLine: (count = 1) => `${CSI}F`.repeat(count),
29
+ left: `${CSI}G`,
30
+ hide: `${CSI}?25l`,
31
+ show: `${CSI}?25h`,
32
+ save: `${ESC}7`,
33
+ restore: `${ESC}8`
34
+ }
35
+
36
+ const scroll = {
37
+ up: (count = 1) => `${CSI}S`.repeat(count),
38
+ down: (count = 1) => `${CSI}T`.repeat(count)
39
+ }
40
+
41
+ const erase = {
42
+ screen: `${CSI}2J`,
43
+ up: (count = 1) => `${CSI}1J`.repeat(count),
44
+ down: (count = 1) => `${CSI}J`.repeat(count),
45
+ line: `${CSI}2K`,
46
+ lineEnd: `${CSI}K`,
47
+ lineStart: `${CSI}1K`,
48
+ lines(count) {
49
+ let clear = '';
50
+ for (let i = 0; i < count; i++)
51
+ clear += this.line + (i < count - 1 ? cursor.up() : '');
52
+ if (count)
53
+ clear += cursor.left;
54
+ return clear;
55
+ }
56
+ }
57
+
58
+ module.exports = { cursor, scroll, erase, beep };