From 0c03b8cba23487965b2badc185dbe7f56bb450ae Mon Sep 17 00:00:00 2001 From: Joe Hildebrand Date: Fri, 13 Nov 2026 14:24:38 -0700 Subject: [PATCH] Add slightly better locale processing, and export the used locale. --- .ncurc | 4 - .ncurc.js | 6 + lib/index.js | 33 +++-- package.json | 11 +- pnpm-lock.yaml | 294 +++++++++++++++++++++++--------------------- pnpm-workspace.yaml | 6 + test/info.test.js | 4 +- 7 files changed, 197 insertions(+), 161 deletions(-) delete mode 100644 .ncurc create mode 100644 .ncurc.js create mode 100644 pnpm-workspace.yaml diff --git a/.ncurc b/.ncurc deleted file mode 100644 index 9c1d860..0000000 --- a/.ncurc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "dep": ["prod", "dev", "packageManager"], - "cooldown": 7 -} diff --git a/.ncurc.js b/.ncurc.js new file mode 100644 index 0000000..8968777 --- /dev/null +++ b/.ncurc.js @@ -0,0 +1,6 @@ +import {localCooldown} from '@cto.af/ncurc'; + +export default { + dep: ['prod', 'dev', 'packageManager'], + cooldown: await localCooldown(), +}; diff --git a/lib/index.js b/lib/index.js index c379fd3..1cb09cd 100644 --- a/lib/index.js +++ b/lib/index.js @@ -4,7 +4,9 @@ import ansi from 'ansi-regex'; import emojiRegex from 'emoji-regex'; const ASCII_REGEX = /^[\x20-\x7e]*$/; -const DEFAULT_LOCALE = new Intl.Segmenter().resolvedOptions().locale; +const DEFAULT_LOCALE = new Intl.Locale( + new Intl.Segmenter().resolvedOptions().locale +).maximize(); const EMOJI_REGEX = emojiRegex(); const ANSI = ansi(); const ANSI_CAP = new RegExp(`(${ANSI.source})`, 'g'); @@ -62,12 +64,12 @@ const NO_EXTRAS = { */ /** - * @typedef {object} StringWidthOptions - * Options for creating a StringWidth instance. + * @typedef {object} StringWidthOptions Options for creating a StringWidth + * instance. * - * @prop {string} [locale] The locale to use for grapheme segmentation and to - * determine if we are in a CJK context for code points that have ambiguous - * East Asian Width. Defaults to systems's locale. + * @prop {string|Intl.Locale} [locale] The locale to use for grapheme + * segmentation and to determine if we are in a CJK context for code points + * that have ambiguous East Asian Width. Defaults to systems's locale. * @prop {ExtraWidths} [extraWidths] A lookup map for code points whose width * you would like to override. Might be a Map, UnicodeTrie, * or anything else that has a `get(codePoint: number) => number` method. @@ -90,10 +92,11 @@ const NO_EXTRAS = { * than individual sequences (e.g. cursor movements) or overlapping pairs. */ export class StringWidth { - #graphemes; - #isCJK; #extraWidths; + #graphemes; #includeANSI; + #isCJK; + #locale; /** * Create a StringWidth instance. @@ -111,7 +114,12 @@ export class StringWidth { includeANSI: false, ...opts, }; - this.#graphemes = new Intl.Segmenter(options.locale, { + + this.#locale = (typeof options.locale === 'string') ? + new Intl.Locale(options.locale).maximize() : + options.locale.maximize(); + + this.#graphemes = new Intl.Segmenter(this.#locale, { granularity: 'grapheme', }); @@ -119,10 +127,9 @@ export class StringWidth { if (typeof opts?.isCJK === 'boolean') { this.#isCJK = options.isCJK; } else { - const loc = new Intl.Locale(options.locale).maximize(); // Script is never undefined after going through Segmenter this.#isCJK = ['Hans', 'Hant', 'Kore', 'Jpan'] - .includes(/** @type {string} */ (loc.script)); + .includes(/** @type {string} */ (this.#locale.script)); } this.#extraWidths = options.extraWidths; this.#includeANSI = options.includeANSI; @@ -139,10 +146,10 @@ export class StringWidth { /** * Resolved locale for grapheme segmentation. - * @returns {string} + * @returns {Intl.Locale} */ get locale() { - return this.#graphemes.resolvedOptions().locale; + return this.#locale; } /** diff --git a/package.json b/package.json index b4752f7..1c18130 100644 --- a/package.json +++ b/package.json @@ -33,22 +33,23 @@ "license": "MIT", "dependencies": { "@cto.af/unicode-trie-runtime": "3.2.11", - "ansi-regex": "~6.4.0", + "ansi-regex": "~6.5.0", "emoji-regex": "~11.0.0" }, "devDependencies": { - "@cto.af/eslint-config": "^7.0.3", + "@cto.af/eslint-config": "^7.0.4", + "@cto.af/ncurc": "^0.0.3", "@cto.af/unicode-trie": "^3.2.11", - "@types/node": "^26.6.5", + "@types/node": "^26.6.6", "@typescript/native": "npm:typescript@^7.0.2", - "eslint": "^10.13.0", + "eslint": "^10.14.0", "eslint-plugin-mocha": "^12.0.2", "mocha": "^12.0.3", "superc8": "^12.7.0", "typedoc": "^0.28.20", "typescript": "npm:@typescript/typescript6@^6.0.2" }, - "packageManager": "pnpm@12.15.0", + "packageManager": "pnpm@12.18.0", "engines": { "node": ">= 22" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1c7f00a..8dd9a1d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,153 +7,153 @@ importers: configDependencies: {} packageManagerDependencies: pnpm: - specifier: 12.15.0 - version: 12.15.0 + specifier: 12.18.0 + version: 12.18.0 packages: - '@pnpm/exe.android-arm64@12.15.0': - resolution: {integrity: sha512-eVCqmscY70LGvgRzu3mi8IBWBFGix+a6mNZoWmXxESsBdeiKEF9xQSuaeel10yn+zI7TXy2jlI63vFLzETk+aQ==} + '@pnpm/exe.android-arm64@12.18.0': + resolution: {integrity: sha512-fOF6IwgvnUKEmVedGqiAsNPfN2Ry8GvaqzSQOiF3RJFbpBfPKO/6YT54s1GjToyYinRxw9preHHPe4y2N3SzhA==} cpu: [arm64] os: [android] - '@pnpm/exe.android-x64@12.15.0': - resolution: {integrity: sha512-Gx/WbkFcdUFUg8g8AShezcS9EiQxfYvdAm2hfKLO8sfJmJvKOCt5fzlgHWDzmGhoclibgW+tUGZ/KF4F4wOTCA==} + '@pnpm/exe.android-x64@12.18.0': + resolution: {integrity: sha512-6OiolnaCsB3/GcJ9XNrenbUH3zFHRJ+5QynrMUUEyThbgnnCzWxa199hpQlOmxN4rAXuYQ0IYgWFNUZxyzg31Q==} cpu: [x64] os: [android] - '@pnpm/exe.darwin-arm64@12.15.0': - resolution: {integrity: sha512-N0ZykiDWCvqSBJvt71j7cSoBR993FqvYZFtmpCtqvW3pguiI+NAgraLPA5OTwu5mV+/d8hYpVcPktJA3xFDLtA==} + '@pnpm/exe.darwin-arm64@12.18.0': + resolution: {integrity: sha512-zkq+4YzVIX39ETYLyC3W7LY7MpHEU/J3nRhHl4i2yPld2Cf2+rEKRh3ejJ4AmaQ77HHJLCktY4Z3jq0fpcxFXg==} cpu: [arm64] os: [darwin] - '@pnpm/exe.darwin-x64@12.15.0': - resolution: {integrity: sha512-7Ntr2HlBUxzwWOg7NwDxCbRW/3vXuqKO+hcXm+w3SBi9rrHY53li1wLqWVT7Gjxd+lVEHM1QJZo6WJEGFU8C6A==} + '@pnpm/exe.darwin-x64@12.18.0': + resolution: {integrity: sha512-qMsL9qx92unOTa6hgkfiTJv8ceZaTx0IQg7InhYDVX2ZrTECujaVEEVypnJK5m3eGUsP1KD7Y4qIgleCwfRsYw==} cpu: [x64] os: [darwin] - '@pnpm/exe.freebsd-x64@12.15.0': - resolution: {integrity: sha512-btOiyL7fL7W4uQGH0aqFai2TNC3IoKcZ7gNHBVbEFZt2dWrnrD0SufL3iGs3fLlmb4OtuU35uf4Zpr9V9Jh9mA==} + '@pnpm/exe.freebsd-x64@12.18.0': + resolution: {integrity: sha512-/9vy/4ms52cU4MjZ5NhHd6N2d9L9W0kARf5/ff2tweAHu0VeUzs/0qp/7ZHFuddm2Wa/m0AKQoPum9AVUCqKsw==} cpu: [x64] os: [freebsd] - '@pnpm/exe.linux-arm64-musl@12.15.0': - resolution: {integrity: sha512-pNC38k+O+90FOjbPNSnw0E7apq1PKTmz3fFe1amn+lys/U5kL++uzir8bRiho8ONcyA3d9EU7wdqcY0DKkj+JA==} + '@pnpm/exe.linux-arm64-musl@12.18.0': + resolution: {integrity: sha512-Vp+TIMPPyackVCXkOdEKH/RmAn/r07EcIyrgZYQK7VrkksqZOie0GnWIx+85mPqeFEYCRtXIZAFJ9L4ceTndDg==} cpu: [arm64] os: [linux] libc: [musl] - '@pnpm/exe.linux-arm64@12.15.0': - resolution: {integrity: sha512-qML/8aCXslh8td/w4U+HJNqUcZ2+m6EfTbWScIzZRmyPsRFN+xB4LP1U/hymxc1iSJiKtG56HJx2fvUErWFIGw==} + '@pnpm/exe.linux-arm64@12.18.0': + resolution: {integrity: sha512-2dpyVBCHT+FfpuQh9i+7MXAqNWYLCvD5vYr5p6Eimxoga8USLnjbUgyj72AOrO0hjc5ri3TEFP3jiyBHjkSZpQ==} cpu: [arm64] os: [linux] libc: [glibc] - '@pnpm/exe.linux-ppc64@12.15.0': - resolution: {integrity: sha512-tjRDUUl7RCJ6T/6eoNPxOqkwU4Mzi5RtTXmSAxujyz37OTwwsMU7Ps087Zk4gHcUvRSeyF40ZFsew3vtE+nmUA==} + '@pnpm/exe.linux-ppc64@12.18.0': + resolution: {integrity: sha512-BBOOOfNJ2QwIIya3eKqOjiN4WNTszfRz7HCvw9XggcT7+ftMjNP8XJ/GfW+ltCBeUFR9d8WBVsr2m/NLjX2CZQ==} cpu: [ppc64] os: [linux] libc: [glibc] - '@pnpm/exe.linux-riscv64@12.15.0': - resolution: {integrity: sha512-bF1uBWEfbwaeryz6lIiaJ8AWD082otZfvzGX5l+6LZRpRwUEpJHUsJrORaYP5/cNMv5ZR2p6TvvcJcQzwtDzmw==} + '@pnpm/exe.linux-riscv64@12.18.0': + resolution: {integrity: sha512-7kMN77xSOYJX8GPSH5RbNAc5oM61LMmcSUukDDUwllnZPXm8GRPskCNsTWy8SCw01Kr1FB+5SwGNMiTdiziLNQ==} cpu: [riscv64] os: [linux] libc: [glibc] - '@pnpm/exe.linux-s390x@12.15.0': - resolution: {integrity: sha512-zKMhIzsexYMToeLmqV5jPsvV/f9vwsJb2kUH2NFYzalbxImeBrlA4kL7GwF8gD4pagV6jYYcJb8RjbZIdjHptg==} + '@pnpm/exe.linux-s390x@12.18.0': + resolution: {integrity: sha512-htuSCpEcmDzhKoJqXbPkvfr176dBHU0QIF5mWcRiqxRXAB/1JoYiMYotfjWpk+ztgpB9qlx4XnWlLFAf7gzc6g==} cpu: [s390x] os: [linux] libc: [glibc] - '@pnpm/exe.linux-x64-musl@12.15.0': - resolution: {integrity: sha512-A9J0Jg0Rdx+qQU4qXtwyST5tto9IOu1zi4fDk35nbc6DWahggbcKtFvZPKFwL2qgUXGXOX//hXv6z/sp6emO8A==} + '@pnpm/exe.linux-x64-musl@12.18.0': + resolution: {integrity: sha512-Uj+vzfIQ62kDP10x36yHZIXVs5ohdNtiPYwn5FhCLlNScHPo0OAI+ShGDtLofiBXKE7umu71Jmjm7N8a8zVcDw==} cpu: [x64] os: [linux] libc: [musl] - '@pnpm/exe.linux-x64@12.15.0': - resolution: {integrity: sha512-yc+QlZR+9+nr29J4fRzhMoapgxTBDndq/+peyoq1XUufnQFnfbXUMFudDIKzHi545linGqmOmXfn0NoufNgcOg==} + '@pnpm/exe.linux-x64@12.18.0': + resolution: {integrity: sha512-OJ+X2wcraldCwj75pCIerWARQSRpdfj0eBTs/2ODyhfeW46ylOnjTIE/GKra6Mn6E72/gBmXS8igrUioa+F9fQ==} cpu: [x64] os: [linux] libc: [glibc] - '@pnpm/exe.win32-arm64@12.15.0': - resolution: {integrity: sha512-fPXZxuY1VclkOga9bc53qNCXcegfeoBR8+Ue+AospDwKzuGGSHll0oDxkLfkmpjyRqpe7bH5DyQPYp/xSMaIVA==} + '@pnpm/exe.win32-arm64@12.18.0': + resolution: {integrity: sha512-wEY6jiACGcbhhi5yD59doHqNTndS7AaujaPmtWAu1DKkHru2hy5fJ9yUGecW72Ypaw2/I3BEprfMOopap2NQtw==} cpu: [arm64] os: [win32] - '@pnpm/exe.win32-x64@12.15.0': - resolution: {integrity: sha512-nrd+Tp1We1DGj4DGG5Bea9lZNh9y1PjlLBdEwdInS4D0h0UIDtM7JaGGGDJhNzIwcHASyihWI7HLV+dtG+fhYg==} + '@pnpm/exe.win32-x64@12.18.0': + resolution: {integrity: sha512-5FJkghO7RLRkQpWxeVEygW9XsmnNuxzPfXbgwFWCHsFyFhpDn/vOdL88ToQEM0Kt5igdW5s6U0/IDH8Dvkt3pg==} cpu: [x64] os: [win32] - pnpm@12.15.0: - resolution: {integrity: sha512-s5UdbW/0qfE9x89WzSjSuOs328ycaOUuHhGRhz6p+CoBcoerULqtxczElPA2xnwOR+sTYIwvo29HcRth6hKOYQ==} + pnpm@12.18.0: + resolution: {integrity: sha512-nXiC1dyCFH7PxOBiqjSDTgrQKWcQoYN6ERWuASEn02txCeMhrBWYod0KZVl2gbHpmRfhLtDXSerpEYeUM2O+sw==} engines: {node: '>=18'} hasBin: true snapshots: - '@pnpm/exe.android-arm64@12.15.0': + '@pnpm/exe.android-arm64@12.18.0': optional: true - '@pnpm/exe.android-x64@12.15.0': + '@pnpm/exe.android-x64@12.18.0': optional: true - '@pnpm/exe.darwin-arm64@12.15.0': + '@pnpm/exe.darwin-arm64@12.18.0': optional: true - '@pnpm/exe.darwin-x64@12.15.0': + '@pnpm/exe.darwin-x64@12.18.0': optional: true - '@pnpm/exe.freebsd-x64@12.15.0': + '@pnpm/exe.freebsd-x64@12.18.0': optional: true - '@pnpm/exe.linux-arm64-musl@12.15.0': + '@pnpm/exe.linux-arm64-musl@12.18.0': optional: true - '@pnpm/exe.linux-arm64@12.15.0': + '@pnpm/exe.linux-arm64@12.18.0': optional: true - '@pnpm/exe.linux-ppc64@12.15.0': + '@pnpm/exe.linux-ppc64@12.18.0': optional: true - '@pnpm/exe.linux-riscv64@12.15.0': + '@pnpm/exe.linux-riscv64@12.18.0': optional: true - '@pnpm/exe.linux-s390x@12.15.0': + '@pnpm/exe.linux-s390x@12.18.0': optional: true - '@pnpm/exe.linux-x64-musl@12.15.0': + '@pnpm/exe.linux-x64-musl@12.18.0': optional: true - '@pnpm/exe.linux-x64@12.15.0': + '@pnpm/exe.linux-x64@12.18.0': optional: true - '@pnpm/exe.win32-arm64@12.15.0': + '@pnpm/exe.win32-arm64@12.18.0': optional: true - '@pnpm/exe.win32-x64@12.15.0': + '@pnpm/exe.win32-x64@12.18.0': optional: true - pnpm@12.15.0: + pnpm@12.18.0: optionalDependencies: - '@pnpm/exe.android-arm64': 12.15.0 - '@pnpm/exe.android-x64': 12.15.0 - '@pnpm/exe.darwin-arm64': 12.15.0 - '@pnpm/exe.darwin-x64': 12.15.0 - '@pnpm/exe.freebsd-x64': 12.15.0 - '@pnpm/exe.linux-arm64': 12.15.0 - '@pnpm/exe.linux-arm64-musl': 12.15.0 - '@pnpm/exe.linux-ppc64': 12.15.0 - '@pnpm/exe.linux-riscv64': 12.15.0 - '@pnpm/exe.linux-s390x': 12.15.0 - '@pnpm/exe.linux-x64': 12.15.0 - '@pnpm/exe.linux-x64-musl': 12.15.0 - '@pnpm/exe.win32-arm64': 12.15.0 - '@pnpm/exe.win32-x64': 12.15.0 + '@pnpm/exe.android-arm64': 12.18.0 + '@pnpm/exe.android-x64': 12.18.0 + '@pnpm/exe.darwin-arm64': 12.18.0 + '@pnpm/exe.darwin-x64': 12.18.0 + '@pnpm/exe.freebsd-x64': 12.18.0 + '@pnpm/exe.linux-arm64': 12.18.0 + '@pnpm/exe.linux-arm64-musl': 12.18.0 + '@pnpm/exe.linux-ppc64': 12.18.0 + '@pnpm/exe.linux-riscv64': 12.18.0 + '@pnpm/exe.linux-s390x': 12.18.0 + '@pnpm/exe.linux-x64': 12.18.0 + '@pnpm/exe.linux-x64-musl': 12.18.0 + '@pnpm/exe.win32-arm64': 12.18.0 + '@pnpm/exe.win32-x64': 12.18.0 --- lockfileVersion: '9.0' @@ -162,6 +162,10 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +overrides: + glob: ~14.0.6 + minimatch: ~11.0.8 + importers: .: @@ -170,30 +174,33 @@ importers: specifier: 3.2.11 version: 3.2.11 ansi-regex: - specifier: ~6.4.0 - version: 6.4.0 + specifier: ~6.5.0 + version: 6.5.0 emoji-regex: specifier: ~11.0.0 version: 11.0.0 devDependencies: '@cto.af/eslint-config': - specifier: ^7.0.3 - version: 7.0.3(@typescript/typescript6@6.0.2)(eslint@10.13.0(supports-color@8.1.1)) + specifier: ^7.0.4 + version: 7.0.4(@typescript/typescript6@6.0.2)(eslint@10.14.0(supports-color@8.1.1)) + '@cto.af/ncurc': + specifier: ^0.0.3 + version: 0.0.3 '@cto.af/unicode-trie': specifier: ^3.2.11 version: 3.2.11(@cto.af/unicode-trie-runtime@3.2.11) '@types/node': - specifier: ^26.6.5 - version: 26.6.5 + specifier: ^26.6.6 + version: 26.6.6 '@typescript/native': specifier: npm:typescript@^7.0.2 version: typescript@7.0.2 eslint: - specifier: ^10.13.0 - version: 10.13.0(supports-color@8.1.1) + specifier: ^10.14.0 + version: 10.14.0(supports-color@8.1.1) eslint-plugin-mocha: specifier: ^12.0.2 - version: 12.0.2(eslint@10.13.0(supports-color@8.1.1)) + version: 12.0.2(eslint@10.14.0(supports-color@8.1.1)) mocha: specifier: ^12.0.3 version: 12.0.3 @@ -312,14 +319,18 @@ packages: peerDependencies: postcss-selector-parser: ^7.1.1 - '@cto.af/eslint-config@7.0.3': - resolution: {integrity: sha512-oHKnP5qCWAhclOi1k7aXCM4LPrbQL1/ScTyltXfoLjZibJXFG0yUpracfjPgnffrLV/9ZSDp6Ryr6kAB7UD9Sg==} + '@cto.af/eslint-config@7.0.4': + resolution: {integrity: sha512-judPJ5pq9mCQAtOj5HGOI/tjMPgJZw286/VZWx7AbLSu+A/3F44TW77+LEN3RsBIPTceoVhL1xYG3S4p42UGXA==} engines: {node: '>=22'} '@cto.af/log@2.0.2': resolution: {integrity: sha512-qPooOBHtJ8FwtpmoC8BOxpQnNrKZR3sq2kgun3Tq8vG43+mzGeb59OwzCelK8RlJTsD3ajZaK9Mm4ub2QcsN1A==} engines: {node: '>=22'} + '@cto.af/ncurc@0.0.3': + resolution: {integrity: sha512-b+QROEHt/5Y3MhG8abgjIDw++7mWvPdVmijCFkA/B+L4l1tVICZEAoyCIRocGA1pRel7RTN8v7mPFtlqlDxv5g==} + engines: {node: '>=22'} + '@cto.af/ucd@1.1.6': resolution: {integrity: sha512-CPTSXe+7/5TDv7aFWm/L6gdVeOQchm1QigKjLlwuX6mxKHIICzB56sZNNb5iMZjNlvh7Q5yOOpXzRwO8tx8c/Q==} engines: {node: '>=22'} @@ -411,6 +422,9 @@ packages: resolution: {integrity: sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==} engines: {node: '>=18.18'} + '@isaacs/nonrecursive-glob-match@1.1.0': + resolution: {integrity: sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==} + '@istanbuljs/schema@0.1.6': resolution: {integrity: sha512-+Sg6GCR/wy1oSmQDFq4LQDAhm3ETKnorxN+y5nbLULOR3P0c14f2Wurzj3/xqPXtasLFfHd5iRFQ7AJt4KH2cw==} engines: {node: '>=8'} @@ -1390,8 +1404,8 @@ packages: '@types/ms@2.1.0': resolution: {integrity: sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==} - '@types/node@26.6.5': - resolution: {integrity: sha512-uMzsv9stDdofIZBx4UGh4Z9ZgXnGC9seRDscilBcTHAeOFk67MZg/k9bWVfO+bk4qZmG+l52hRnLwUiH2LnJTg==} + '@types/node@26.6.6': + resolution: {integrity: sha512-MzQj+8Kx3XI40OmUAE6Qoh58ZMNstNNMwn2nfd3qWsfe7nDNSqJNzes4njhz6AHwrSHOffSLwXU6yb474Q4aog==} '@types/unist@3.0.3': resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==} @@ -1562,8 +1576,8 @@ packages: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} - ansi-regex@6.4.0: - resolution: {integrity: sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==} + ansi-regex@6.5.0: + resolution: {integrity: sha512-zhvbbbdt1kbw7EJ9OQoxmQcuaNR9P5kTj7e/YdmOSU10aHWbycofJxA6jKfoEy3vlLdctOF9ZHaxLtmSm998wQ==} engines: {node: '>=12'} ansi-styles@4.3.0: @@ -1872,8 +1886,8 @@ packages: peerDependencies: eslint: '>=10.2.0' - eslint-plugin-n@18.3.0: - resolution: {integrity: sha512-cPVguuDe6DrIPb/qUXHf8P89MaVTUmiYWwpt5gX5AILsvRIiZAxMFXcFR6QHYBksqKJpjfUBlL/RleCJUWcD7w==} + eslint-plugin-n@18.5.0: + resolution: {integrity: sha512-M7uF6MTN/An+AXqvyIbXq7npJIZOkd5eKo8iMMvWrcDVNyZVdA6TF2lw01aKQfCEidRfpnR78GhAjZorlXNHiw==} engines: {node: ^20.19.0 || ^22.13.0 || >=24} peerDependencies: eslint: '>=8.57.1' @@ -1907,8 +1921,8 @@ packages: resolution: {integrity: sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==} engines: {node: ^20.19.0 || ^22.13.0 || >=24} - eslint@10.13.0: - resolution: {integrity: sha512-UohDjD4zSzEwhf58M3O7vc/ycc8O1I7dNlhtD0WxE8Px8EHNJKtUwzBqrzeGhisRuv2ag4sAYswszCJRgKXYUg==} + eslint@10.14.0: + resolution: {integrity: sha512-T0pNsxkb9IKmtQjhpK3d7nWOpFv+YHuMbTJnSVMoQblF0onvXfErrtp4V1jHtsQPan7dKaGVD0q1WCXnzMF31A==} engines: {node: ^20.19.0 || ^22.13.0 || >=24} hasBin: true peerDependencies: @@ -2100,8 +2114,8 @@ packages: resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} engines: {node: '>=10.13.0'} - glob@13.0.6: - resolution: {integrity: sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==} + glob@14.0.6: + resolution: {integrity: sha512-OwXjVP2svY5EyLY75Vek96C8qK43gqrt4xsZ+qSILdnaEiJPXkd62mcfUSNx/TQErQRdu5uM5kF67sfONragKw==} engines: {node: 18 || 20 || >=22} global-modules@2.0.0: @@ -2116,8 +2130,8 @@ packages: resolution: {integrity: sha512-7ACyT3wmyp3I61S4fG682L0VA2RGD9otkqGJIwNUMF1SWUombIIk+af1unuDYgMm082aHYwD+mzJvv9Iu8dsgg==} engines: {node: '>=18'} - globals@17.12.0: - resolution: {integrity: sha512-cezEd/DTyyht9cvSSURyygXPfy04GtWO/5e6ZPvH7fCtjKz9PYOmuawphw1Ctd1f6C+5JypXfGD7ahNMXvevBA==} + globals@17.13.0: + resolution: {integrity: sha512-RwMTC61u7hrG3ZJMkZQOK4JLJrKS8QtoTii63EmWvFXHqycY9FObBJQCbsLxSO8kjKhWE5kV1GC+Vb1g3RI0Zg==} engines: {node: '>=18'} globals@17.8.0: @@ -2659,9 +2673,9 @@ packages: resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} engines: {node: '>=8.6'} - minimatch@10.2.6: - resolution: {integrity: sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==} - engines: {node: 18 || 20 || >=22} + minimatch@11.0.8: + resolution: {integrity: sha512-nFQuYSTVrGvysVBps5Ih+0BdnYFN/Cj3C816r6+p7yK+FHrVLGE4O4N9AFwykrlNlvM2HYt+Rad1Uiro6h88Ig==} + engines: {node: 20 || >=22} minimist@1.2.8: resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} @@ -2784,8 +2798,8 @@ packages: resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} engines: {node: '>=12'} - path-scurry@2.0.2: - resolution: {integrity: sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==} + path-scurry@3.0.0: + resolution: {integrity: sha512-1pTbQqH1wIwMi/eleQ5leFTTCkzFsPcgXNjwOA8YGGW/W4/kHT3dssE7Z6NH+zuqNLOzOB0uaD61yl7cAcVhgg==} engines: {node: 18 || 20 || >=22} picocolors@1.1.1: @@ -3540,13 +3554,13 @@ snapshots: dependencies: postcss-selector-parser: 7.1.7 - '@cto.af/eslint-config@7.0.3(@typescript/typescript6@6.0.2)(eslint@10.13.0(supports-color@8.1.1))': + '@cto.af/eslint-config@7.0.4(@typescript/typescript6@6.0.2)(eslint@10.14.0(supports-color@8.1.1))': dependencies: '@eslint/json': 2.1.1 - '@stylistic/eslint-plugin': 5.10.0(eslint@10.13.0(supports-color@8.1.1)) - eslint-plugin-n: 18.3.0(@typescript/typescript6@6.0.2)(eslint@10.13.0(supports-color@8.1.1)) - eslint-plugin-redos: 4.5.0(eslint@10.13.0(supports-color@8.1.1)) - globals: 17.12.0 + '@stylistic/eslint-plugin': 5.10.0(eslint@10.14.0(supports-color@8.1.1)) + eslint-plugin-n: 18.5.0(@typescript/typescript6@6.0.2)(eslint@10.14.0(supports-color@8.1.1)) + eslint-plugin-redos: 4.5.0(eslint@10.14.0(supports-color@8.1.1)) + globals: 17.13.0 transitivePeerDependencies: - eslint - ts-declaration-location @@ -3558,6 +3572,8 @@ snapshots: pino: 10.4.0 pino-pretty: 13.2.0 + '@cto.af/ncurc@0.0.3': {} + '@cto.af/ucd@1.1.6': dependencies: '@cto.af/log': 2.0.2 @@ -3619,9 +3635,9 @@ snapshots: - supports-color - typescript - '@eslint-community/eslint-utils@4.10.1(eslint@10.13.0(supports-color@8.1.1))': + '@eslint-community/eslint-utils@4.10.1(eslint@10.14.0(supports-color@8.1.1))': dependencies: - eslint: 10.13.0(supports-color@8.1.1) + eslint: 10.14.0(supports-color@8.1.1) eslint-visitor-keys: 3.4.3 '@eslint-community/regexpp@4.12.2': {} @@ -3630,7 +3646,7 @@ snapshots: dependencies: '@eslint/object-schema': 3.0.5 debug: 4.4.3(supports-color@8.1.1) - minimatch: 10.2.6 + minimatch: 11.0.8 transitivePeerDependencies: - supports-color @@ -3682,6 +3698,8 @@ snapshots: '@humanwhocodes/retry@0.4.3': {} + '@isaacs/nonrecursive-glob-match@1.1.0': {} + '@istanbuljs/schema@0.1.6': {} '@jridgewell/gen-mapping@0.4.0-beta.0': @@ -3764,9 +3782,9 @@ snapshots: try-catch: 4.1.1 try-to-catch: 4.1.0 - '@putout/cli-process-file@7.1.0(eslint@10.13.0(supports-color@8.1.1))(putout@42.22.1(@putout/printer@18.48.0)(@typescript/typescript6@6.0.2)(supports-color@8.1.1))': + '@putout/cli-process-file@7.1.0(eslint@10.14.0(supports-color@8.1.1))(putout@42.22.1(@putout/printer@18.48.0)(@typescript/typescript6@6.0.2)(supports-color@8.1.1))': dependencies: - '@putout/eslint': 6.0.0(eslint@10.13.0(supports-color@8.1.1)) + '@putout/eslint': 6.0.0(eslint@10.14.0(supports-color@8.1.1)) deepmerge: 4.3.1 once: 1.4.0 putout: 42.22.1(@putout/printer@18.48.0)(@typescript/typescript6@6.0.2)(supports-color@8.1.1) @@ -3854,9 +3872,9 @@ snapshots: transitivePeerDependencies: - putout - '@putout/eslint@6.0.0(eslint@10.13.0(supports-color@8.1.1))': + '@putout/eslint@6.0.0(eslint@10.14.0(supports-color@8.1.1))': dependencies: - eslint: 10.13.0(supports-color@8.1.1) + eslint: 10.14.0(supports-color@8.1.1) once: 1.4.0 try-to-catch: 4.1.0 @@ -4571,11 +4589,11 @@ snapshots: '@sindresorhus/merge-streams@4.0.0': {} - '@stylistic/eslint-plugin@5.10.0(eslint@10.13.0(supports-color@8.1.1))': + '@stylistic/eslint-plugin@5.10.0(eslint@10.14.0(supports-color@8.1.1))': dependencies: - '@eslint-community/eslint-utils': 4.10.1(eslint@10.13.0(supports-color@8.1.1)) + '@eslint-community/eslint-utils': 4.10.1(eslint@10.14.0(supports-color@8.1.1)) '@typescript-eslint/types': 8.72.0 - eslint: 10.13.0(supports-color@8.1.1) + eslint: 10.14.0(supports-color@8.1.1) eslint-visitor-keys: 4.2.1 espree: 10.4.0 estraverse: 5.3.0 @@ -4620,7 +4638,7 @@ snapshots: '@types/ms@2.1.0': {} - '@types/node@26.6.5': + '@types/node@26.6.6': dependencies: undici-types: 8.9.0 @@ -4726,7 +4744,7 @@ snapshots: ansi-regex@5.0.1: {} - ansi-regex@6.4.0: {} + ansi-regex@6.5.0: {} ansi-styles@4.3.0: dependencies: @@ -5060,45 +5078,46 @@ snapshots: escape-string-regexp@5.0.0: {} - eslint-compat-utils@0.5.1(eslint@10.13.0(supports-color@8.1.1)): + eslint-compat-utils@0.5.1(eslint@10.14.0(supports-color@8.1.1)): dependencies: - eslint: 10.13.0(supports-color@8.1.1) + eslint: 10.14.0(supports-color@8.1.1) semver: 7.8.5 - eslint-plugin-es-x@7.8.0(eslint@10.13.0(supports-color@8.1.1)): + eslint-plugin-es-x@7.8.0(eslint@10.14.0(supports-color@8.1.1)): dependencies: - '@eslint-community/eslint-utils': 4.10.1(eslint@10.13.0(supports-color@8.1.1)) + '@eslint-community/eslint-utils': 4.10.1(eslint@10.14.0(supports-color@8.1.1)) '@eslint-community/regexpp': 4.12.2 - eslint: 10.13.0(supports-color@8.1.1) - eslint-compat-utils: 0.5.1(eslint@10.13.0(supports-color@8.1.1)) + eslint: 10.14.0(supports-color@8.1.1) + eslint-compat-utils: 0.5.1(eslint@10.14.0(supports-color@8.1.1)) - eslint-plugin-mocha@12.0.2(eslint@10.13.0(supports-color@8.1.1)): + eslint-plugin-mocha@12.0.2(eslint@10.14.0(supports-color@8.1.1)): dependencies: - '@eslint-community/eslint-utils': 4.10.1(eslint@10.13.0(supports-color@8.1.1)) + '@eslint-community/eslint-utils': 4.10.1(eslint@10.14.0(supports-color@8.1.1)) '@eslint/core': 1.2.1 '@types/estree': 1.0.9 - eslint: 10.13.0(supports-color@8.1.1) + eslint: 10.14.0(supports-color@8.1.1) globals: 17.8.0 json-schema-to-ts: 3.1.1 type-fest: 5.8.0 - eslint-plugin-n@18.3.0(@typescript/typescript6@6.0.2)(eslint@10.13.0(supports-color@8.1.1)): + eslint-plugin-n@18.5.0(@typescript/typescript6@6.0.2)(eslint@10.14.0(supports-color@8.1.1)): dependencies: - '@eslint-community/eslint-utils': 4.10.1(eslint@10.13.0(supports-color@8.1.1)) + '@eslint-community/eslint-utils': 4.10.1(eslint@10.14.0(supports-color@8.1.1)) enhanced-resolve: 5.26.0 - eslint: 10.13.0(supports-color@8.1.1) - eslint-plugin-es-x: 7.8.0(eslint@10.13.0(supports-color@8.1.1)) + eslint: 10.14.0(supports-color@8.1.1) + eslint-plugin-es-x: 7.8.0(eslint@10.14.0(supports-color@8.1.1)) get-tsconfig: 4.14.3 globals: 15.15.0 globrex: 0.1.2 ignore: 5.3.2 + js-yaml: 5.5.0 semver: 7.8.5 optionalDependencies: typescript: '@typescript/typescript6@6.0.2' - eslint-plugin-redos@4.5.0(eslint@10.13.0(supports-color@8.1.1)): + eslint-plugin-redos@4.5.0(eslint@10.14.0(supports-color@8.1.1)): dependencies: - eslint: 10.13.0(supports-color@8.1.1) + eslint: 10.14.0(supports-color@8.1.1) recheck: 4.5.0 eslint-scope@9.1.2: @@ -5114,9 +5133,9 @@ snapshots: eslint-visitor-keys@5.0.1: {} - eslint@10.13.0(supports-color@8.1.1): + eslint@10.14.0(supports-color@8.1.1): dependencies: - '@eslint-community/eslint-utils': 4.10.1(eslint@10.13.0(supports-color@8.1.1)) + '@eslint-community/eslint-utils': 4.10.1(eslint@10.14.0(supports-color@8.1.1)) '@eslint-community/regexpp': 4.12.2 '@eslint/config-array': 0.23.5(supports-color@8.1.1) '@eslint/config-helpers': 0.7.0 @@ -5143,7 +5162,7 @@ snapshots: imurmurhash: 0.1.4 is-glob: 4.0.3 json-stable-stringify-without-jsonify: 1.0.1 - minimatch: 10.2.6 + minimatch: 11.0.8 natural-compare: 1.4.0 optionator: 0.9.4 transitivePeerDependencies: @@ -5359,11 +5378,11 @@ snapshots: dependencies: is-glob: 4.0.3 - glob@13.0.6: + glob@14.0.6: dependencies: - minimatch: 10.2.6 + minimatch: 11.0.8 minipass: 7.1.3 - path-scurry: 2.0.2 + path-scurry: 3.0.0 global-modules@2.0.0: dependencies: @@ -5377,7 +5396,7 @@ snapshots: globals@15.15.0: {} - globals@17.12.0: {} + globals@17.13.0: {} globals@17.8.0: {} @@ -6097,8 +6116,9 @@ snapshots: braces: 3.0.3 picomatch: 2.3.2 - minimatch@10.2.6: + minimatch@11.0.8: dependencies: + '@isaacs/nonrecursive-glob-match': 1.1.0 brace-expansion: 5.0.12 minimist@1.2.8: {} @@ -6112,11 +6132,11 @@ snapshots: debug: 4.4.3(supports-color@8.1.1) diff: 9.0.0 find-up-simple: 1.0.1 - glob: 13.0.6 + glob: 14.0.6 is-path-inside: 4.0.0 is-unicode-supported: 0.1.0 js-yaml: 5.5.0 - minimatch: 10.2.6 + minimatch: 11.0.8 ms: 2.1.3 picocolors: 1.1.1 serialize-javascript: 7.1.4 @@ -6219,7 +6239,7 @@ snapshots: path-key@4.0.0: {} - path-scurry@2.0.2: + path-scurry@3.0.0: dependencies: lru-cache: 11.5.3 minipass: 7.1.3 @@ -6315,7 +6335,7 @@ snapshots: '@putout/cli-choose-formatter': 7.0.0(putout@42.22.1(@putout/printer@18.48.0)(@typescript/typescript6@6.0.2)(supports-color@8.1.1)) '@putout/cli-keypress': 4.0.0 '@putout/cli-match': 3.0.1 - '@putout/cli-process-file': 7.1.0(eslint@10.13.0(supports-color@8.1.1))(putout@42.22.1(@putout/printer@18.48.0)(@typescript/typescript6@6.0.2)(supports-color@8.1.1)) + '@putout/cli-process-file': 7.1.0(eslint@10.14.0(supports-color@8.1.1))(putout@42.22.1(@putout/printer@18.48.0)(@typescript/typescript6@6.0.2)(supports-color@8.1.1)) '@putout/cli-ruler': 5.0.0 '@putout/cli-staged': 3.0.0 '@putout/cli-validate-args': 2.0.0 @@ -6926,7 +6946,7 @@ snapshots: strip-ansi@7.2.0: dependencies: - ansi-regex: 6.4.0 + ansi-regex: 6.5.0 strip-final-newline@4.0.0: {} @@ -7043,8 +7063,8 @@ snapshots: test-exclude@8.0.0: dependencies: '@istanbuljs/schema': 0.1.6 - glob: 13.0.6 - minimatch: 10.2.6 + glob: 14.0.6 + minimatch: 11.0.8 thread-stream@4.2.0: dependencies: @@ -7111,7 +7131,7 @@ snapshots: '@gerrit0/mini-shiki': 3.23.0 lunr: 2.3.9 markdown-it: 14.3.3 - minimatch: 10.2.6 + minimatch: 11.0.8 typescript: '@typescript/typescript6@6.0.2' yaml: 2.9.1 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..58d6e74 --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,6 @@ +auditConfig: + ignoreGhsas: + - GHSA-gcqx-w48m-w2h4 +overrides: + glob: ~14.0.6 + minimatch: ~11.0.8 diff --git a/test/info.test.js b/test/info.test.js index 8d7e153..a6a1d1f 100644 --- a/test/info.test.js +++ b/test/info.test.js @@ -6,11 +6,11 @@ const sw = new StringWidth({locale: LOCALE}); describe('info', () => { it('has some debug info', () => { - assert.equal(sw.locale, 'en-US'); + assert.equal(sw.locale.baseName, 'en-Latn-US'); assert.equal(sw.isCJK, false); assert.equal(new StringWidth({locale: 'zh-TW'}).isCJK, true); assert.equal(new StringWidth({locale: 'zh-CN'}).isCJK, true); assert.equal(new StringWidth({locale: 'ja'}).isCJK, true); - assert.equal(new StringWidth({locale: 'ko'}).isCJK, true); + assert.equal(new StringWidth({locale: new Intl.Locale('ko')}).isCJK, true); }); });