Merge branch 'master' into package_upgrades
This commit is contained in:
@@ -22,6 +22,9 @@ build/
|
|||||||
yarn.lock
|
yarn.lock
|
||||||
test-results/
|
test-results/
|
||||||
|
|
||||||
|
# Tracing/debug files
|
||||||
|
.cursor/nal-trace/
|
||||||
|
|
||||||
# Keep bundled code out of Git
|
# Keep bundled code out of Git
|
||||||
dist/
|
dist/
|
||||||
demo/dist/
|
demo/dist/
|
||||||
|
|||||||
@@ -253,6 +253,7 @@ Xterm.js is used in many world-class applications to provide great terminal expe
|
|||||||
- [**SSH Connection Manager**](https://github.com/Amtrend/ssh-manager): Modern web-based SSH terminal and SFTP manager with AES-256 encryption, PWA support, and session management.
|
- [**SSH Connection Manager**](https://github.com/Amtrend/ssh-manager): Modern web-based SSH terminal and SFTP manager with AES-256 encryption, PWA support, and session management.
|
||||||
- [**WooTTY**](https://github.com/icoretech/wootty): Flawless browser terminal for real operators.
|
- [**WooTTY**](https://github.com/icoretech/wootty): Flawless browser terminal for real operators.
|
||||||
- [**Orca**](https://github.com/stablyai/orca): Agentic development environment for 100x builders.
|
- [**Orca**](https://github.com/stablyai/orca): Agentic development environment for 100x builders.
|
||||||
|
- [**4bit**](https://ciembor.github.io/4bit): Terminal Color Scheme Designer.
|
||||||
- [And much more...](https://github.com/xtermjs/xterm.js/network/dependents?package_id=UGFja2FnZS0xNjYzMjc4OQ%3D%3D)
|
- [And much more...](https://github.com/xtermjs/xterm.js/network/dependents?package_id=UGFja2FnZS0xNjYzMjc4OQ%3D%3D)
|
||||||
|
|
||||||
Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it on our list. Please add any new contributions to the end of the list.
|
Do you use xterm.js in your application as well? Please [open a Pull Request](https://github.com/sourcelair/xterm.js/pulls) to include it here. We would love to have it on our list. Please add any new contributions to the end of the list.
|
||||||
|
|||||||
@@ -533,8 +533,8 @@ export class KittyGraphicsHandler implements IApcHandler, IResetHandler, IDispos
|
|||||||
|
|
||||||
private _sendResponse(id: number, message: string, quiet: number, placementId?: number): void {
|
private _sendResponse(id: number, message: string, quiet: number, placementId?: number): void {
|
||||||
const isOk = message === 'OK';
|
const isOk = message === 'OK';
|
||||||
if (isOk && quiet === 1) return;
|
if (isOk && quiet >= 1) return;
|
||||||
if (!isOk && quiet === 2) return;
|
if (!isOk && quiet >= 2) return;
|
||||||
|
|
||||||
const pPart = placementId ? `,p=${placementId}` : '';
|
const pPart = placementId ? `,p=${placementId}` : '';
|
||||||
const response = `\x1b_Gi=${id}${pPart};${message}\x1b\\`;
|
const response = `\x1b_Gi=${id}${pPart};${message}\x1b\\`;
|
||||||
|
|||||||
@@ -613,6 +613,18 @@ test.describe('Kitty Graphics Protocol', () => {
|
|||||||
strictEqual(await ctx.page.evaluate('window.kittyGotResponse'), false);
|
strictEqual(await ctx.page.evaluate('window.kittyGotResponse'), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('suppresses OK response when q=2', async () => {
|
||||||
|
await ctx.page.evaluate(() => {
|
||||||
|
(window as any).kittyGotResponse = false;
|
||||||
|
(window as any).term.onData(() => { (window as any).kittyGotResponse = true; });
|
||||||
|
});
|
||||||
|
|
||||||
|
await ctx.proxy.write(`\x1b_Gi=81,a=q,q=2,f=100;${KITTY_BLACK_1X1_BASE64}\x1b\\`);
|
||||||
|
await timeout(100);
|
||||||
|
|
||||||
|
strictEqual(await ctx.page.evaluate('window.kittyGotResponse'), false);
|
||||||
|
});
|
||||||
|
|
||||||
test('suppresses error response when q=2', async () => {
|
test('suppresses error response when q=2', async () => {
|
||||||
await ctx.page.evaluate(() => {
|
await ctx.page.evaluate(() => {
|
||||||
(window as any).kittyGotResponse = false;
|
(window as any).kittyGotResponse = false;
|
||||||
@@ -791,6 +803,30 @@ test.describe('Kitty Graphics Protocol', () => {
|
|||||||
|
|
||||||
strictEqual(await ctx.page.evaluate('window.kittyGotResponse'), false);
|
strictEqual(await ctx.page.evaluate('window.kittyGotResponse'), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('a=t OK suppressed by q=2', async () => {
|
||||||
|
await ctx.page.evaluate(() => {
|
||||||
|
(window as any).kittyGotResponse = false;
|
||||||
|
(window as any).term.onData(() => { (window as any).kittyGotResponse = true; });
|
||||||
|
});
|
||||||
|
|
||||||
|
await ctx.proxy.write(`\x1b_Gi=181,a=t,q=2,f=100;${KITTY_BLACK_1X1_BASE64}\x1b\\`);
|
||||||
|
await timeout(100);
|
||||||
|
|
||||||
|
strictEqual(await ctx.page.evaluate('window.kittyGotResponse'), false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('a=T OK suppressed by q=2', async () => {
|
||||||
|
await ctx.page.evaluate(() => {
|
||||||
|
(window as any).kittyGotResponse = false;
|
||||||
|
(window as any).term.onData(() => { (window as any).kittyGotResponse = true; });
|
||||||
|
});
|
||||||
|
|
||||||
|
await ctx.proxy.write(`\x1b_Gi=191,a=T,q=2,f=100;${KITTY_BLACK_1X1_BASE64}\x1b\\`);
|
||||||
|
await timeout(100);
|
||||||
|
|
||||||
|
strictEqual(await ctx.page.evaluate('window.kittyGotResponse'), false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test.describe('Transmission medium rejection', () => {
|
test.describe('Transmission medium rejection', () => {
|
||||||
@@ -1140,6 +1176,22 @@ test.describe('Kitty Graphics Protocol', () => {
|
|||||||
strictEqual(await getImageStorageLength(), 1);
|
strictEqual(await getImageStorageLength(), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('OK response suppressed by q=2', async () => {
|
||||||
|
await ctx.proxy.write(`\x1b_Ga=t,f=100,i=221;${KITTY_BLACK_1X1_BASE64}\x1b\\`);
|
||||||
|
await timeout(100);
|
||||||
|
|
||||||
|
await ctx.page.evaluate(() => {
|
||||||
|
(window as any).kittyGotResponse = false;
|
||||||
|
(window as any).term.onData(() => { (window as any).kittyGotResponse = true; });
|
||||||
|
});
|
||||||
|
|
||||||
|
await ctx.proxy.write(`\x1b_Ga=p,i=221,q=2\x1b\\`);
|
||||||
|
await timeout(100);
|
||||||
|
|
||||||
|
strictEqual(await ctx.page.evaluate('window.kittyGotResponse'), false);
|
||||||
|
strictEqual(await getImageStorageLength(), 1);
|
||||||
|
});
|
||||||
|
|
||||||
test('ENOENT error suppressed by q=2', async () => {
|
test('ENOENT error suppressed by q=2', async () => {
|
||||||
await ctx.page.evaluate(() => {
|
await ctx.page.evaluate(() => {
|
||||||
(window as any).kittyGotResponse = false;
|
(window as any).kittyGotResponse = false;
|
||||||
|
|||||||
@@ -358,7 +358,9 @@ export class GlyphRenderer extends Disposable {
|
|||||||
gl.bindBuffer(gl.ARRAY_BUFFER, this._attributesBuffer);
|
gl.bindBuffer(gl.ARRAY_BUFFER, this._attributesBuffer);
|
||||||
gl.bufferData(gl.ARRAY_BUFFER, activeBuffer.subarray(0, bufferLength), gl.STREAM_DRAW);
|
gl.bufferData(gl.ARRAY_BUFFER, activeBuffer.subarray(0, bufferLength), gl.STREAM_DRAW);
|
||||||
|
|
||||||
// Bind the atlas page texture if they have changed
|
// Bind the atlas page texture if they have changed. AtlasPage.version is globally
|
||||||
|
// monotonic, so a page object swap at the same index (which happens after a page merge)
|
||||||
|
// is detected by the same comparison.
|
||||||
for (let i = 0; i < this._atlas.pages.length; i++) {
|
for (let i = 0; i < this._atlas.pages.length; i++) {
|
||||||
if (this._atlas.pages[i].version !== this._atlasTextures[i].version) {
|
if (this._atlas.pages[i].version !== this._atlasTextures[i].version) {
|
||||||
this._bindAtlasPageTexture(gl, this._atlas, i);
|
this._bindAtlasPageTexture(gl, this._atlas, i);
|
||||||
@@ -371,6 +373,10 @@ export class GlyphRenderer extends Disposable {
|
|||||||
|
|
||||||
public setAtlas(atlas: ITextureAtlas): void {
|
public setAtlas(atlas: ITextureAtlas): void {
|
||||||
this._atlas = atlas;
|
this._atlas = atlas;
|
||||||
|
this.invalidateAtlasTextures();
|
||||||
|
}
|
||||||
|
|
||||||
|
public invalidateAtlasTextures(): void {
|
||||||
for (const glTexture of this._atlasTextures) {
|
for (const glTexture of this._atlasTextures) {
|
||||||
glTexture.version = -1;
|
glTexture.version = -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -336,8 +336,9 @@ export class RectangleRenderer extends Disposable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vertices.attributes.length < offset + 4) {
|
if (vertices.attributes.length < offset + INDICES_PER_RECTANGLE) {
|
||||||
vertices.attributes = expandFloat32Array(vertices.attributes, this._terminal.rows * this._terminal.cols * INDICES_PER_RECTANGLE);
|
// +1 for the viewport-clear rectangle at offset 0.
|
||||||
|
vertices.attributes = expandFloat32Array(vertices.attributes, (this._terminal.rows * this._terminal.cols + 1) * INDICES_PER_RECTANGLE);
|
||||||
}
|
}
|
||||||
$x1 = startX * this._dimensions.device.cell.width;
|
$x1 = startX * this._dimensions.device.cell.width;
|
||||||
$y1 = y * this._dimensions.device.cell.height;
|
$y1 = y * this._dimensions.device.cell.height;
|
||||||
|
|||||||
@@ -133,7 +133,9 @@ export class TextureAtlas implements ITextureAtlas {
|
|||||||
|
|
||||||
private _requestClearModel = false;
|
private _requestClearModel = false;
|
||||||
public beginFrame(): boolean {
|
public beginFrame(): boolean {
|
||||||
return this._requestClearModel;
|
const result = this._requestClearModel;
|
||||||
|
this._requestClearModel = false;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearTexture(): void {
|
public clearTexture(): void {
|
||||||
@@ -193,7 +195,7 @@ export class TextureAtlas implements ITextureAtlas {
|
|||||||
|
|
||||||
// Merge into the new page
|
// Merge into the new page
|
||||||
const mergedPage = this._mergePages(mergingPages, mergedPageIndex);
|
const mergedPage = this._mergePages(mergingPages, mergedPageIndex);
|
||||||
mergedPage.version++;
|
mergedPage.version = ++AtlasPage.nextVersion;
|
||||||
|
|
||||||
// Delete the pages, shifting glyph texture pages as needed
|
// Delete the pages, shifting glyph texture pages as needed
|
||||||
for (let i = sortedMergingPagesIndexes.length - 1; i >= 0; i--) {
|
for (let i = sortedMergingPagesIndexes.length - 1; i >= 0; i--) {
|
||||||
@@ -251,7 +253,7 @@ export class TextureAtlas implements ITextureAtlas {
|
|||||||
for (const g of adjustingPage.glyphs) {
|
for (const g of adjustingPage.glyphs) {
|
||||||
g.texturePage--;
|
g.texturePage--;
|
||||||
}
|
}
|
||||||
adjustingPage.version++;
|
adjustingPage.version = ++AtlasPage.nextVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -937,7 +939,7 @@ export class TextureAtlas implements ITextureAtlas {
|
|||||||
rasterizedGlyph.size.y
|
rasterizedGlyph.size.y
|
||||||
);
|
);
|
||||||
activePage.addGlyph(rasterizedGlyph);
|
activePage.addGlyph(rasterizedGlyph);
|
||||||
activePage.version++;
|
activePage.version = ++AtlasPage.nextVersion;
|
||||||
|
|
||||||
return rasterizedGlyph;
|
return rasterizedGlyph;
|
||||||
}
|
}
|
||||||
@@ -1047,9 +1049,13 @@ class AtlasPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to check whether the canvas of the atlas page has changed.
|
* Monotonically increasing across all atlas pages globally. Used to detect when the texture
|
||||||
|
* unit at a given index needs to be re-uploaded — both for content changes within the same
|
||||||
|
* page and for a page object swap at the same index (which happens after a page merge,
|
||||||
|
* where a per-page counter could coincide with the previously-bound page's value).
|
||||||
*/
|
*/
|
||||||
public version = 0;
|
public static nextVersion: number = 0;
|
||||||
|
public version = ++AtlasPage.nextVersion;
|
||||||
|
|
||||||
// Texture atlas current positioning data. The texture packing strategy used is to fill from
|
// Texture atlas current positioning data. The texture packing strategy used is to fill from
|
||||||
// left-to-right and top-to-bottom. When the glyph being written is less than half of the current
|
// left-to-right and top-to-bottom. When the glyph being written is less than half of the current
|
||||||
@@ -1092,7 +1098,7 @@ class AtlasPage {
|
|||||||
this.currentRow.y = 0;
|
this.currentRow.y = 0;
|
||||||
this.currentRow.height = 0;
|
this.currentRow.height = 0;
|
||||||
this.fixedRows.length = 0;
|
this.fixedRows.length = 0;
|
||||||
this.version++;
|
this.version = ++AtlasPage.nextVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ import { addDisposableListener } from 'browser/Dom';
|
|||||||
import { combinedDisposable, Disposable, MutableDisposable, toDisposable } from 'common/Lifecycle';
|
import { combinedDisposable, Disposable, MutableDisposable, toDisposable } from 'common/Lifecycle';
|
||||||
import { createRenderDimensions } from 'browser/renderer/shared/RendererUtils';
|
import { createRenderDimensions } from 'browser/renderer/shared/RendererUtils';
|
||||||
|
|
||||||
|
const enum Constants {
|
||||||
|
MERGE_RETRY_LIMIT = 32
|
||||||
|
}
|
||||||
|
|
||||||
export class WebglRenderer extends Disposable implements IRenderer {
|
export class WebglRenderer extends Disposable implements IRenderer {
|
||||||
private _renderLayers: IRenderLayer[];
|
private _renderLayers: IRenderLayer[];
|
||||||
private _cursorBlinkStateManager: MutableDisposable<CursorBlinkStateManager> = this._register(new MutableDisposable());
|
private _cursorBlinkStateManager: MutableDisposable<CursorBlinkStateManager> = this._register(new MutableDisposable());
|
||||||
@@ -375,6 +379,19 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
this._updateModel(start, end);
|
this._updateModel(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A mid-update atlas page merge invalidates vertex data and may not bump the host
|
||||||
|
// page's version, so re-run the update and force a full texture rebind.
|
||||||
|
let merged = false;
|
||||||
|
let mergeRetries = 0;
|
||||||
|
while (this._charAtlas && this._glyphRenderer.value.beginFrame() && mergeRetries++ < Constants.MERGE_RETRY_LIMIT) {
|
||||||
|
merged = true;
|
||||||
|
this._clearModel(true);
|
||||||
|
this._updateModel(0, this._terminal.rows - 1);
|
||||||
|
}
|
||||||
|
if (merged) {
|
||||||
|
this._glyphRenderer.value.invalidateAtlasTextures();
|
||||||
|
}
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
this._rectangleRenderer.value.renderBackgrounds();
|
this._rectangleRenderer.value.renderBackgrounds();
|
||||||
this._glyphRenderer.value.render(this._model);
|
this._glyphRenderer.value.render(this._model);
|
||||||
|
|||||||
@@ -252,6 +252,11 @@ export class OptionsWindow extends BaseWindow implements IControlWindow {
|
|||||||
input.value = 'auto';
|
input.value = 'auto';
|
||||||
this._handlers.updateTerminalSize();
|
this._handlers.updateTerminalSize();
|
||||||
}
|
}
|
||||||
|
const screenElement = document.querySelector('.xterm-screen');
|
||||||
|
if (screenElement instanceof HTMLElement) {
|
||||||
|
screenElement.style.outline = this._autoResize ? ''
|
||||||
|
: 'solid thin red';
|
||||||
|
}
|
||||||
} else if (o === 'theme') {
|
} else if (o === 'theme') {
|
||||||
value = this._getTheme();
|
value = this._getTheme();
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+206
-1005
File diff suppressed because it is too large
Load Diff
@@ -56,7 +56,6 @@
|
|||||||
"test-unit": "node ./bin/test_unit.js",
|
"test-unit": "node ./bin/test_unit.js",
|
||||||
"test-unit-slow-tests": "npm run test-unit | grep \"ms)\"",
|
"test-unit-slow-tests": "npm run test-unit | grep \"ms)\"",
|
||||||
"test-unit-coverage": "node ./bin/test_unit.js --coverage",
|
"test-unit-coverage": "node ./bin/test_unit.js --coverage",
|
||||||
"test-unit-dev": "cross-env NODE_PATH='./out' mocha",
|
|
||||||
"test-integration": "node ./bin/test_integration.js --workers=75%",
|
"test-integration": "node ./bin/test_integration.js --workers=75%",
|
||||||
"test-integration-chromium": "node ./bin/test_integration.js --workers=75% \"--project=Chromium\"",
|
"test-integration-chromium": "node ./bin/test_integration.js --workers=75% \"--project=Chromium\"",
|
||||||
"test-integration-firefox": "node ./bin/test_integration.js --workers=75% \"--project=FirefoxStable\"",
|
"test-integration-firefox": "node ./bin/test_integration.js --workers=75% \"--project=FirefoxStable\"",
|
||||||
@@ -81,15 +80,11 @@
|
|||||||
"@playwright/test": "^1.59.1",
|
"@playwright/test": "^1.59.1",
|
||||||
"@stylistic/eslint-plugin": "^5.10.0",
|
"@stylistic/eslint-plugin": "^5.10.0",
|
||||||
"@types/chai": "^5.2.3",
|
"@types/chai": "^5.2.3",
|
||||||
"@types/debug": "^4.1.13",
|
|
||||||
"@types/deep-equal": "^1.0.1",
|
|
||||||
"@types/express": "^5.0.6",
|
"@types/express": "^5.0.6",
|
||||||
"@types/express-ws": "^3.0.1",
|
"@types/express-ws": "^3.0.1",
|
||||||
"@types/jsdom": "^28.0.1",
|
"@types/jsdom": "^28.0.1",
|
||||||
"@types/mocha": "^10.0.10",
|
"@types/mocha": "^10.0.10",
|
||||||
"@types/node": "^22.19.3",
|
"@types/node": "^22.19.3",
|
||||||
"@types/trusted-types": "^2.0.7",
|
|
||||||
"@types/utf8": "^3.0.0",
|
|
||||||
"@types/webpack": "^5.28.0",
|
"@types/webpack": "^5.28.0",
|
||||||
"@types/ws": "^8.2.0",
|
"@types/ws": "^8.2.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.59.2",
|
"@typescript-eslint/eslint-plugin": "^8.59.2",
|
||||||
@@ -97,8 +92,6 @@
|
|||||||
"@typescript/native-preview": "^7.0.0-dev.20260509.2",
|
"@typescript/native-preview": "^7.0.0-dev.20260509.2",
|
||||||
"chai": "^6.2.2",
|
"chai": "^6.2.2",
|
||||||
"concurrently": "^9.1.2",
|
"concurrently": "^9.1.2",
|
||||||
"cross-env": "^10.1.0",
|
|
||||||
"deep-equal": "^2.0.5",
|
|
||||||
"esbuild": "^0.28.0",
|
"esbuild": "^0.28.0",
|
||||||
"eslint": "^10.3.0",
|
"eslint": "^10.3.0",
|
||||||
"eslint-plugin-jsdoc": "^62.9.0",
|
"eslint-plugin-jsdoc": "^62.9.0",
|
||||||
@@ -114,7 +107,6 @@
|
|||||||
"ts-loader": "^9.5.7",
|
"ts-loader": "^9.5.7",
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"typescript-eslint": "^8.59.2",
|
"typescript-eslint": "^8.59.2",
|
||||||
"utf8": "^3.0.0",
|
|
||||||
"webpack": "^5.106.2",
|
"webpack": "^5.106.2",
|
||||||
"webpack-cli": "^7.0.2",
|
"webpack-cli": "^7.0.2",
|
||||||
"ws": "^8.20.0",
|
"ws": "^8.20.0",
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
import { assert } from 'chai';
|
import { assert } from 'chai';
|
||||||
import { StringToUtf32, stringFromCodePoint, Utf8ToUtf32, utf32ToString } from 'common/input/TextDecoder';
|
import { StringToUtf32, stringFromCodePoint, Utf8ToUtf32, utf32ToString } from 'common/input/TextDecoder';
|
||||||
import { encode } from 'utf8';
|
|
||||||
|
|
||||||
|
|
||||||
// convert UTF32 codepoints to string
|
// convert UTF32 codepoints to string
|
||||||
@@ -29,6 +28,35 @@ function fromByteString(s: string): Uint8Array {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stringToUtf8Bytes(s: string): Uint8Array {
|
||||||
|
const bytes: number[] = [];
|
||||||
|
for (let i = 0; i < s.length; i++) {
|
||||||
|
let cp = s.charCodeAt(i);
|
||||||
|
if (cp >= 0xD800 && cp <= 0xDBFF && i + 1 < s.length) {
|
||||||
|
const next = s.charCodeAt(i + 1);
|
||||||
|
if (next >= 0xDC00 && next <= 0xDFFF) {
|
||||||
|
cp = 0x10000 + ((cp - 0xD800) << 10) + (next - 0xDC00);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cp < 0x80) {
|
||||||
|
bytes.push(cp);
|
||||||
|
} else if (cp < 0x800) {
|
||||||
|
bytes.push(0xC0 | (cp >> 6), 0x80 | (cp & 0x3F));
|
||||||
|
} else if (cp < 0x10000) {
|
||||||
|
bytes.push(0xE0 | (cp >> 12), 0x80 | ((cp >> 6) & 0x3F), 0x80 | (cp & 0x3F));
|
||||||
|
} else {
|
||||||
|
bytes.push(
|
||||||
|
0xF0 | (cp >> 18),
|
||||||
|
0x80 | ((cp >> 12) & 0x3F),
|
||||||
|
0x80 | ((cp >> 6) & 0x3F),
|
||||||
|
0x80 | (cp & 0x3F)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Uint8Array(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
function assertDecodedRange(
|
function assertDecodedRange(
|
||||||
min: number,
|
min: number,
|
||||||
max: number,
|
max: number,
|
||||||
@@ -172,7 +200,7 @@ describe('text encodings', () => {
|
|||||||
max,
|
max,
|
||||||
(i) => (i >= 0xD800 && i <= 0xDFFF) || i === 0xFEFF,
|
(i) => (i >= 0xD800 && i <= 0xDFFF) || i === 0xFEFF,
|
||||||
(i) => String.fromCharCode(i),
|
(i) => String.fromCharCode(i),
|
||||||
(input, target) => decoder.decode(fromByteString(encode(input)), target),
|
(input, target) => decoder.decode(stringToUtf8Bytes(input), target),
|
||||||
(data, length) => toString(data, length)
|
(data, length) => toString(data, length)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -187,7 +215,7 @@ describe('text encodings', () => {
|
|||||||
max,
|
max,
|
||||||
() => false,
|
() => false,
|
||||||
(i) => stringFromCodePoint(i),
|
(i) => stringFromCodePoint(i),
|
||||||
(input, target) => decoder.decode(fromByteString(encode(input)), target),
|
(input, target) => decoder.decode(stringToUtf8Bytes(input), target),
|
||||||
(data, length) => toString(data, length)
|
(data, length) => toString(data, length)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -196,7 +224,7 @@ describe('text encodings', () => {
|
|||||||
it('0xFEFF(BOM)', () => {
|
it('0xFEFF(BOM)', () => {
|
||||||
const decoder = new Utf8ToUtf32();
|
const decoder = new Utf8ToUtf32();
|
||||||
const target = new Uint32Array(5);
|
const target = new Uint32Array(5);
|
||||||
const utf8Data = fromByteString(encode(String.fromCharCode(0xFEFF)));
|
const utf8Data = stringToUtf8Bytes(String.fromCharCode(0xFEFF));
|
||||||
const length = decoder.decode(utf8Data, target);
|
const length = decoder.decode(utf8Data, target);
|
||||||
assert.equal(length, 0);
|
assert.equal(length, 0);
|
||||||
decoder.clear();
|
decoder.clear();
|
||||||
@@ -207,7 +235,7 @@ describe('text encodings', () => {
|
|||||||
const decoder = new Utf8ToUtf32();
|
const decoder = new Utf8ToUtf32();
|
||||||
const target = new Uint32Array(500);
|
const target = new Uint32Array(500);
|
||||||
for (let i = 0; i < TEST_STRINGS.length; ++i) {
|
for (let i = 0; i < TEST_STRINGS.length; ++i) {
|
||||||
const utf8Data = fromByteString(encode(TEST_STRINGS[i]));
|
const utf8Data = stringToUtf8Bytes(TEST_STRINGS[i]);
|
||||||
const length = decoder.decode(utf8Data, target);
|
const length = decoder.decode(utf8Data, target);
|
||||||
assert.equal(toString(target, length), TEST_STRINGS[i]);
|
assert.equal(toString(target, length), TEST_STRINGS[i]);
|
||||||
decoder.clear();
|
decoder.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user