Skip to content
229 changes: 121 additions & 108 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next2d/player",
"version": "2.1.2",
"version": "2.1.3",
"description": "Experience the fast and beautiful anti-aliased rendering of WebGL. You can create rich, interactive graphics, cross-platform applications and games without worrying about browser or device compatibility.",
"author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
"license": "MIT",
Expand Down Expand Up @@ -51,18 +51,18 @@
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.1.2",
"@types/node": "^22.13.15",
"@types/node": "^22.14.0",
"@typescript-eslint/eslint-plugin": "^8.29.0",
"@typescript-eslint/parser": "^8.29.0",
"@vitest/web-worker": "^3.1.1",
"eslint": "^9.23.0",
"eslint-plugin-unused-imports": "^4.1.4",
"globals": "^16.0.0",
"jsdom": "^26.0.0",
"rollup": "^4.38.0",
"rollup": "^4.39.0",
"tslib": "^2.8.1",
"typescript": "^5.8.2",
"vite": "^6.2.4",
"vite": "^6.2.5",
"vitest": "^3.1.1",
"vitest-webgl-canvas-mock": "^1.1.0"
},
Expand Down
13 changes: 13 additions & 0 deletions packages/events/src/Event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,19 @@ export class Event
return "addedToStage";
}

/**
* @description 要素の値を変更したときに発行されます。
* Occurs when the value of an element changes.
*
* @return {string}
* @const
* @static
*/
static get CHANGE (): string
{
return "change";
}

/**
* @description 読み込みや、処理完了時に発生します。
* Occurs when loading or processing is complete.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { execute } from "./TextFieldGenerateFontStyleService";
import { describe, expect, it } from "vitest";
import type { ITextFormat } from "../../interface/ITextFormat";

describe("TextFieldGenerateFontStyleService.js test", () =>
{
it("execute test", () =>
{
const mockTextFormat = {
italic: true,
bold: true,
size: 12,
font: "Arial",
} as ITextFormat;
expect(execute(mockTextFormat)).toBe("italic bold 12px 'Arial','sans-serif'");
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { TextField } from "../../TextField";
import { execute } from "./TextAreaMovePositionService";
import { describe, expect, it } from "vitest";
import {
$textArea,
} from "../../TextUtil";

describe("TextAreaMovePositionService.js Test", () =>
{
it("test case", () =>
{
// Arrange
const textField = {
localToGlobal: () => ({ x: 20, y: 30 }),
$textData: {
textTable: [
{ line: 0, mode: "break", w: 10 },
{ line: 1, mode: "normal", w: 20 },
],
heightTable: [10, 20],
}
} as unknown as TextField;

// Act
execute(textField);

// Assert
expect($textArea.style.left).toBe("20px");
expect($textArea.style.top).toBe("30px");
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { execute } from "./TextAreaRegisterEventUseCase";
import { describe, expect, it, vi } from "vitest";

describe("TextAreaRegisterEventUseCase Test", () =>
{
it("test case", () =>
{
const textArea = document.createElement("textarea");

let compositionstart = false;
let compositionupdate = false;
let compositionend = false;
let input = false;
textArea.addEventListener = vi.fn((type) =>
{
switch (type) {
case "compositionstart":
compositionstart = true;
break;

case "compositionupdate":
compositionupdate = true;
break;

case "compositionend":
compositionend = true;
break;

case "input":
input = true;
break;

default:
break;
}
});

expect(compositionstart).toBe(false);
expect(compositionupdate).toBe(false);
expect(compositionend).toBe(false);
expect(input).toBe(false);

execute(textArea);

expect(compositionstart).toBe(true);
expect(compositionupdate).toBe(true);
expect(compositionend).toBe(true);
expect(input).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { execute as textAreaInputUseCase } from "./TextAreaInputUseCase";
*/
export const execute = (text_area: HTMLTextAreaElement): void =>
{
// omposition evnet
// composition evnet
text_area.addEventListener("compositionstart", textAreaCompositionStartUseCase as EventListener);
text_area.addEventListener("compositionupdate", textAreaCompositionUpdateUseCase as EventListener);
text_area.addEventListener("compositionend", textAreaCompositionEndUseCase as EventListener);
Expand Down
10 changes: 9 additions & 1 deletion packages/text/src/TextField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { ITextFieldType } from "./interface/ITextFieldType";
import type { ITextFieldCharacter } from "./interface/ITextFieldCharacter";
import type { ICharacter } from "./interface/ICharacter";
import type { LoaderInfo } from "@next2d/display";
import { FocusEvent } from "@next2d/events";
import { FocusEvent, Event } from "@next2d/events";
import { Rectangle } from "@next2d/geom";
import { TextData } from "./TextData";
import { TextFormat } from "./TextFormat";
Expand Down Expand Up @@ -854,6 +854,10 @@ export class TextField extends InteractiveObject
this._$text = "";
this._$isHTML = true;
textFieldReloadUseCase(this);

if (this.hasEventListener(Event.CHANGE)) {
this.dispatchEvent(new Event(Event.CHANGE));
}
}

/**
Expand Down Expand Up @@ -978,6 +982,10 @@ export class TextField extends InteractiveObject

this._$text = text;
textFieldReloadUseCase(this);

if (this.hasEventListener(Event.CHANGE)) {
this.dispatchEvent(new Event(Event.CHANGE));
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { execute } from "./TextFormatGenerateFontStyleService";
import { TextFormat } from "../../TextFormat";
import { describe, expect, it } from "vitest";

describe("TextFormatGenerateFontStyleService.js length test", () =>
describe("TextFormatGenerateFontStyleService.js test", () =>
{
it("test case1", () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { execute } from "./TextFormatGetWidthMarginService";
import { TextFormat } from "../../TextFormat";
import { describe, expect, it } from "vitest";

describe("TextFormatGetWidthMarginService.js length test", () =>
describe("TextFormatGetWidthMarginService.js test", () =>
{
it("test case1", () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { execute as textFormatSetDefaultService } from "./TextFormatSetDefaultSe
import { TextFormat } from "../../TextFormat";
import { describe, expect, it } from "vitest";

describe("TextFormatHtmlTextGenerateStyleService.js length test", () =>
describe("TextFormatHtmlTextGenerateStyleService.js test", () =>
{
it("test case1", () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { execute } from "./TextFormatIsSameService";
import { TextFormat } from "../../TextFormat";
import { describe, expect, it } from "vitest";

describe("TextFormatIsSameService.js length test", () =>
describe("TextFormatIsSameService.js test", () =>
{
it("test case1", () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { execute } from "./TextFormatSetDefaultService";
import { TextFormat } from "../../TextFormat";
import { describe, expect, it } from "vitest";

describe("TextFormatSetDefaultService.js length test", () =>
describe("TextFormatSetDefaultService.js test", () =>
{
it("default test case1", () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TextData } from "../../TextData";
import { describe, expect, it } from "vitest";
import { ITextObject } from "../../interface/ITextObject";

describe("TextParserAdjustmentHeightService.js length test", () =>
describe("TextParserAdjustmentHeightService.js Test", () =>
{
it("test case1", () =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { execute } from "./TextParserParseStyleService";
import { describe, expect, it } from "vitest";

describe("TextParserParseStyleService.js length test", () =>
describe("TextParserParseStyleService.js Test", () =>
{
it("test case1", () =>
{
Expand Down
2 changes: 0 additions & 2 deletions packages/text/src/TextUtil.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { IRGBA } from "./interface/IRGBA";
import type { IElementPosition } from "./interface/IElementPosition";
import type { TextField } from "./TextField";
import { execute as textAreaRegisterEventUseCase } from "./TextArea/usecase/TextAreaRegisterEventUseCase";

/**
* @description 選択中のテキストフィールド
Expand Down Expand Up @@ -46,7 +45,6 @@ export const $getSelectedTextField = (): TextField | null =>
* @protected
*/
export const $textArea: HTMLTextAreaElement = document.createElement("textarea") as HTMLTextAreaElement;
textAreaRegisterEventUseCase($textArea);

$textArea.tabIndex = -1;

Expand Down
6 changes: 5 additions & 1 deletion packages/text/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ export {
$getSelectedTextField,
$setSelectedTextField,
$mainCanvasPosition
} from "./TextUtil";
} from "./TextUtil";

import { $textArea } from "./TextUtil";
import { execute as textAreaRegisterEventUseCase } from "./TextArea/usecase/TextAreaRegisterEventUseCase";
textAreaRegisterEventUseCase($textArea);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { execute } from "./ColorBufferObjectMeguruBinarySearchService";
import { describe, expect, it, vi } from "vitest";
import { describe, expect, it } from "vitest";
import { $objectPool } from "../../ColorBufferObject";

describe("ColorBufferObjectMeguruBinarySearchService.js method test", () =>
Expand All @@ -11,6 +11,7 @@ describe("ColorBufferObjectMeguruBinarySearchService.js method test", () =>
{
"resource": {} as unknown as WebGLRenderbuffer,
"stencil": {
"id": 0,
"resource": {} as unknown as WebGLRenderbuffer,
"width": 0,
"height": 0,
Expand All @@ -25,6 +26,7 @@ describe("ColorBufferObjectMeguruBinarySearchService.js method test", () =>
{
"resource": {} as unknown as WebGLRenderbuffer,
"stencil": {
"id": 1,
"resource": {} as unknown as WebGLRenderbuffer,
"width": 0,
"height": 0,
Expand All @@ -39,6 +41,7 @@ describe("ColorBufferObjectMeguruBinarySearchService.js method test", () =>
{
"resource": {} as unknown as WebGLRenderbuffer,
"stencil": {
"id": 2,
"resource": {} as unknown as WebGLRenderbuffer,
"width": 0,
"height": 0,
Expand All @@ -53,6 +56,7 @@ describe("ColorBufferObjectMeguruBinarySearchService.js method test", () =>
{
"resource": {} as unknown as WebGLRenderbuffer,
"stencil": {
"id": 3,
"resource": {} as unknown as WebGLRenderbuffer,
"width": 0,
"height": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe("ColorBufferObjectAcquireObjectUseCase.js method test", () =>
{
"resource": {} as unknown as WebGLRenderbuffer,
"stencil": {
"id": 0,
"resource": {} as unknown as WebGLRenderbuffer,
"width": 0,
"height": 0,
Expand All @@ -42,6 +43,7 @@ describe("ColorBufferObjectAcquireObjectUseCase.js method test", () =>
{
"resource": {} as unknown as WebGLRenderbuffer,
"stencil": {
"id": 1,
"resource": {} as unknown as WebGLRenderbuffer,
"width": 0,
"height": 0,
Expand All @@ -56,6 +58,7 @@ describe("ColorBufferObjectAcquireObjectUseCase.js method test", () =>
{
"resource": {} as unknown as WebGLRenderbuffer,
"stencil": {
"id": 2,
"resource": {} as unknown as WebGLRenderbuffer,
"width": 0,
"height": 0,
Expand All @@ -70,6 +73,7 @@ describe("ColorBufferObjectAcquireObjectUseCase.js method test", () =>
{
"resource": {} as unknown as WebGLRenderbuffer,
"stencil": {
"id": 3,
"resource": {} as unknown as WebGLRenderbuffer,
"width": 0,
"height": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe("ColorBufferObjectGetColorBufferObjectUseCase.js method test", () =>
{
"resource": {} as unknown as WebGLRenderbuffer,
"stencil": {
"id": 0,
"resource": {} as unknown as WebGLRenderbuffer,
"width": 0,
"height": 0,
Expand All @@ -38,6 +39,7 @@ describe("ColorBufferObjectGetColorBufferObjectUseCase.js method test", () =>
{
"resource": {} as unknown as WebGLRenderbuffer,
"stencil": {
"id": 1,
"resource": {} as unknown as WebGLRenderbuffer,
"width": 0,
"height": 0,
Expand All @@ -52,6 +54,7 @@ describe("ColorBufferObjectGetColorBufferObjectUseCase.js method test", () =>
{
"resource": {} as unknown as WebGLRenderbuffer,
"stencil": {
"id": 2,
"resource": {} as unknown as WebGLRenderbuffer,
"width": 0,
"height": 0,
Expand All @@ -66,6 +69,7 @@ describe("ColorBufferObjectGetColorBufferObjectUseCase.js method test", () =>
{
"resource": {} as unknown as WebGLRenderbuffer,
"stencil": {
"id": 3,
"resource": {} as unknown as WebGLRenderbuffer,
"width": 0,
"height": 0,
Expand Down
Loading