Files
zCode-CLI-X/~/.npm-cache/get-east-asian-width@1.5.0@@@1/lookup.js
admin 875c7f9b91 feat: Complete zCode CLI X with Telegram bot integration
- Add full Telegram bot functionality with Z.AI API integration
- Implement 4 tools: Bash, FileEdit, WebSearch, Git
- Add 3 agents: Code Reviewer, Architect, DevOps Engineer
- Add 6 skills for common coding tasks
- Add systemd service file for 24/7 operation
- Add nginx configuration for HTTPS webhook
- Add comprehensive documentation
- Implement WebSocket server for real-time updates
- Add logging system with Winston
- Add environment validation

🤖 zCode CLI X - Agentic coder with Z.AI + Telegram integration
2026-05-05 09:01:26 +00:00

136 lines
2.8 KiB
JavaScript

import {
ambiguousRanges,
fullwidthRanges,
halfwidthRanges,
narrowRanges,
wideRanges,
} from './lookup-data.js';
import {isInRange} from './utilities.js';
const minimumAmbiguousCodePoint = ambiguousRanges[0];
const maximumAmbiguousCodePoint = ambiguousRanges.at(-1);
const minimumFullWidthCodePoint = fullwidthRanges[0];
const maximumFullWidthCodePoint = fullwidthRanges.at(-1);
const minimumHalfWidthCodePoint = halfwidthRanges[0];
const maximumHalfWidthCodePoint = halfwidthRanges.at(-1);
const minimumNarrowCodePoint = narrowRanges[0];
const maximumNarrowCodePoint = narrowRanges.at(-1);
const minimumWideCodePoint = wideRanges[0];
const maximumWideCodePoint = wideRanges.at(-1);
const commonCjkCodePoint = 0x4E_00;
const [wideFastPathStart, wideFastPathEnd] = findWideFastPathRange(wideRanges);
// Use a hot-path range so common `isWide` calls can skip binary search.
// The range containing U+4E00 covers common CJK ideographs;
// fallback to the largest range for resilience to Unicode table changes.
function findWideFastPathRange(ranges) {
let fastPathStart = ranges[0];
let fastPathEnd = ranges[1];
for (let index = 0; index < ranges.length; index += 2) {
const start = ranges[index];
const end = ranges[index + 1];
if (
commonCjkCodePoint >= start
&& commonCjkCodePoint <= end
) {
return [start, end];
}
if ((end - start) > (fastPathEnd - fastPathStart)) {
fastPathStart = start;
fastPathEnd = end;
}
}
return [fastPathStart, fastPathEnd];
}
export const isAmbiguous = codePoint => {
if (
codePoint < minimumAmbiguousCodePoint
|| codePoint > maximumAmbiguousCodePoint
) {
return false;
}
return isInRange(ambiguousRanges, codePoint);
};
export const isFullWidth = codePoint => {
if (
codePoint < minimumFullWidthCodePoint
|| codePoint > maximumFullWidthCodePoint
) {
return false;
}
return isInRange(fullwidthRanges, codePoint);
};
const isHalfWidth = codePoint => {
if (
codePoint < minimumHalfWidthCodePoint
|| codePoint > maximumHalfWidthCodePoint
) {
return false;
}
return isInRange(halfwidthRanges, codePoint);
};
const isNarrow = codePoint => {
if (
codePoint < minimumNarrowCodePoint
|| codePoint > maximumNarrowCodePoint
) {
return false;
}
return isInRange(narrowRanges, codePoint);
};
export const isWide = codePoint => {
if (
codePoint >= wideFastPathStart
&& codePoint <= wideFastPathEnd
) {
return true;
}
if (
codePoint < minimumWideCodePoint
|| codePoint > maximumWideCodePoint
) {
return false;
}
return isInRange(wideRanges, codePoint);
};
export function getCategory(codePoint) {
if (isAmbiguous(codePoint)) {
return 'ambiguous';
}
if (isFullWidth(codePoint)) {
return 'fullwidth';
}
if (isHalfWidth(codePoint)) {
return 'halfwidth';
}
if (isNarrow(codePoint)) {
return 'narrow';
}
if (isWide(codePoint)) {
return 'wide';
}
return 'neutral';
}