Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
604 changes: 302 additions & 302 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next2d/player",
"version": "2.1.1",
"version": "2.1.2",
"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,19 +51,19 @@
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.1.2",
"@types/node": "^22.13.13",
"@typescript-eslint/eslint-plugin": "^8.28.0",
"@typescript-eslint/parser": "^8.28.0",
"@vitest/web-worker": "^3.0.9",
"@types/node": "^22.13.15",
"@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.37.0",
"rollup": "^4.38.0",
"tslib": "^2.8.1",
"typescript": "^5.8.2",
"vite": "^6.2.3",
"vitest": "^3.0.9",
"vite": "^6.2.4",
"vitest": "^3.1.1",
"vitest-webgl-canvas-mock": "^1.1.0"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { execute } from "./BitmapDataCanvasToBufferService";
import { describe, expect, it } from "vitest";

describe("BitmapDataCanvasToBufferService.js test", () =>
{
it("execute test", () =>
{
const canvas = document.createElement("canvas");

const buffer = execute(canvas);
expect(buffer.length).toBe(180000);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { execute } from "./BitmapDataImageToBufferService";
import { describe, expect, it } from "vitest";

describe("BitmapDataImageToBufferService.js test", () =>
{
it("execute test", () =>
{
const iamge = new Image(100, 100);
const buffer = execute(iamge);
expect(buffer.length).toBe(40000);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import type { IDictionaryTag } from "../../interface/IDictionaryTag";
import { execute } from "./DisplayObjectBaseBuildService";
import { DisplayObject } from "../../DisplayObject";
import { MovieClip } from "../../MovieClip";
import { LoaderInfo } from "../../LoaderInfo";
import { describe, expect, it } from "vitest";
import {
$loaderInfoMap,
$rootMap
} from "../../DisplayObjectUtil";

describe("DisplayObjectBaseBuildService.js test", () =>
{
it("execute test case1", () =>
{
const displayObject = new DisplayObject();
const movieClip = new MovieClip();

$loaderInfoMap.set(movieClip, new LoaderInfo());

const mockTag = {
"characterId": 1,
"clipDepth": 1,
"startFrame": 2,
"endFrame": 10,
"name": "test"
} as IDictionaryTag;

expect(displayObject.dictionaryId).toBe(-1);
expect(displayObject.characterId).toBe(-1);
expect(displayObject.clipDepth).toBe(0);
expect(displayObject.startFrame).toBe(1);
expect(displayObject.endFrame).toBe(0);
expect(displayObject.name).toBe("");
expect(displayObject.placeId).toBe(-1);
expect(displayObject.parent).toBe(null);
expect($rootMap.has(displayObject)).toBe(false);
expect($loaderInfoMap.has(displayObject)).toBe(false);

execute(displayObject, 99, mockTag, movieClip, 22);

expect(displayObject.dictionaryId).toBe(99);
expect(displayObject.characterId).toBe(mockTag.characterId);
expect(displayObject.clipDepth).toBe(mockTag.clipDepth);
expect(displayObject.startFrame).toBe(mockTag.startFrame);
expect(displayObject.endFrame).toBe(mockTag.endFrame);
expect(displayObject.name).toBe(mockTag.name);
expect(displayObject.placeId).toBe(22);
expect(displayObject.parent).toBe(movieClip);
expect($rootMap.has(displayObject)).toBe(true);
expect($loaderInfoMap.has(displayObject)).toBe(true);

$rootMap.delete(displayObject);
$loaderInfoMap.delete(movieClip);
});
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
import { execute } from "./DisplayObjectDispatchAddedEventService";
import { DisplayObject } from "../../DisplayObject";
import { describe, expect, it } from "vitest";
import { describe, expect, it, vi } from "vitest";
import { Event } from "@next2d/events";

describe("DisplayObjectDispatchAddedEventService.js test", () =>
{
it("execute test case", () =>
{
const displayObject = new DisplayObject();
displayObject.willTrigger = vi.fn(() => true);

let type = "";
displayObject.dispatchEvent = vi.fn((event): boolean =>
{
type = event.type;
return true;
});

expect(type).toBe("");
expect(displayObject.$added).toBe(false);
execute(displayObject);
expect(displayObject.$added).toBe(true);
expect(type).toBe(Event.ADDED);
});
});
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
import { execute } from "./DisplayObjectDispatchAddedToStageEventService";
import { DisplayObject } from "../../DisplayObject";
import { $stageAssignedMap } from "../../DisplayObjectUtil";
import { describe, expect, it } from "vitest";
import { describe, expect, it, vi } from "vitest";
import { Event } from "@next2d/events";

describe("DisplayObjectDispatchAddedToStageEventService.js test", () =>
{
it("execute test case", () =>
{
const displayObject = new DisplayObject();
displayObject.willTrigger = vi.fn(() => true);
let type = "";
displayObject.dispatchEvent = vi.fn((event): boolean =>
{
type = event.type;
return true;
});

$stageAssignedMap.add(displayObject.instanceId);

expect(type).toBe("");
expect(displayObject.$addedToStage).toBe(false);
execute(displayObject);

expect(type).toBe(Event.ADDED_TO_STAGE);
$stageAssignedMap.delete(displayObject.instanceId);
expect(displayObject.$addedToStage).toBe(true);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { execute } from "./DisplayObjectDispatchRemovedEventService";
import { DisplayObject } from "../../DisplayObject";
import { describe, expect, it, vi } from "vitest";
import { Event } from "@next2d/events";

describe("DisplayObjectDispatchRemovedEventService.js test", () =>
{
it("execute test case", () =>
{
const displayObject = new DisplayObject();
displayObject.willTrigger = vi.fn(() => true);
let type = "";
displayObject.dispatchEvent = vi.fn((event): boolean =>
{
type = event.type;
return true;
});

displayObject.$added = true;
expect(type).toBe("");
expect(displayObject.$added).toBe(true);
execute(displayObject);
expect(displayObject.$added).toBe(false);
expect(type).toBe(Event.REMOVED);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { execute } from "./DisplayObjectDispatchRemovedToStageEventService";
import { DisplayObject } from "../../DisplayObject";
import { $stageAssignedMap } from "../../DisplayObjectUtil";
import { describe, expect, it, vi } from "vitest";
import { Event } from "@next2d/events";

describe("DisplayObjectDispatchRemovedToStageEventService.js test", () =>
{
it("execute test case", () =>
{
const displayObject = new DisplayObject();
displayObject.willTrigger = vi.fn(() => true);
let type = "";
displayObject.dispatchEvent = vi.fn((event): boolean =>
{
type = event.type;
return true;
});

$stageAssignedMap.add(displayObject.instanceId);

displayObject.$addedToStage = true;
expect(type).toBe("");
expect(displayObject.$addedToStage).toBe(true);

execute(displayObject);

expect(type).toBe(Event.REMOVED_FROM_STAGE);
expect(displayObject.$addedToStage).toBe(false);

$stageAssignedMap.delete(displayObject.instanceId);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { execute } from "./DisplayObjectGenerateHashService";
import { describe, expect, it } from "vitest";

describe("DisplayObjectGenerateHashService.js test", () =>
{
it("execute test", () =>
{
expect(execute(new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))).toBe(9749870);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { execute } from "./DisplayObjectRemoveService";
import { DisplayObject } from "../../DisplayObject";
import { MovieClip } from "../../MovieClip";
import { describe, expect, it } from "vitest";

describe("DisplayObjectRemoveService.js test", () =>
{
it("execute test case1", () =>
{
const displayObject = new DisplayObject();
const movieClip = new MovieClip();
movieClip.addChild(displayObject);

expect(movieClip.numChildren).toBe(1);
execute(displayObject);
expect(movieClip.numChildren).toBe(0);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { execute } from "./DisplayObjectContainerGenerateClipQueueUseCase";
import { describe, expect, it } from "vitest";
import { renderQueue } from "@next2d/render-queue";
import { MovieClip } from "../../MovieClip";
import { $RENDERER_CONTAINER_TYPE } from "../../DisplayObjectUtil";

describe("DisplayObjectContainerGenerateClipQueueUseCase.js test", () =>
{
it("execute test", () =>
{
const movieClip = new MovieClip();
const matrix = new Float32Array(6);

renderQueue.offset = 0;
expect(renderQueue.offset).toBe(0);
renderQueue.buffer.fill(0);
expect(renderQueue.buffer.length).toBe(256);

execute(movieClip, matrix);

expect(renderQueue.buffer[0]).toBe($RENDERER_CONTAINER_TYPE);
expect(renderQueue.buffer[1]).toBe(movieClip.children.length);
expect(renderQueue.offset).toBe(2);

renderQueue.buffer.fill(0);
renderQueue.offset = 0;
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { execute as shapeGenerateClipQueueUseCase } from "../../Shape/usecase/Sh
* Generate mask drawing data of DisplayObjectContainer to pass to renderer
*
* @param {DisplayObjectContainer} display_object_container
* @param {number[]} render_queue
* @param {Float32Array} matrix
* @return {void}
* @method
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { execute } from "./DisplayObjectContainerGenerateRenderQueueUseCase";
import { describe, expect, it } from "vitest";
import { renderQueue } from "@next2d/render-queue";
import { MovieClip } from "../../MovieClip";
import { $RENDERER_CONTAINER_TYPE } from "../../DisplayObjectUtil";

describe("DisplayObjectContainerGenerateRenderQueueUseCase.js test", () =>
{
it("execute test", () =>
{
const movieClip = new MovieClip();
movieClip.addChild(new MovieClip());
const matrix = new Float32Array([1, 0, 0, 1, 0, 0]);
const colorTransform = new Float32Array([1, 1, 1, 1, 0, 0, 0, 0]);

renderQueue.offset = 0;
expect(renderQueue.offset).toBe(0);

renderQueue.buffer.fill(0);
expect(renderQueue.buffer.length).toBe(256);

execute(
movieClip, [], matrix, colorTransform,
0, 0, 0, 0
);

expect(renderQueue.buffer[0]).toBe(1);
expect(renderQueue.buffer[1]).toBe($RENDERER_CONTAINER_TYPE);
expect(renderQueue.buffer[2]).toBe(0);
expect(renderQueue.buffer[3]).toBe(movieClip.children.length);
expect(renderQueue.buffer[4]).toBe(-1);
expect(renderQueue.buffer[5]).toBe(0);
expect(renderQueue.buffer[6]).toBe(0);
expect(renderQueue.offset).toBe(7);

renderQueue.buffer.fill(0);
renderQueue.offset = 0;
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const execute = <P extends DisplayObjectContainer>(
? ColorTransform.multiply(color_transform, rawColor)
: color_transform;

const alpha: number = $clamp(tColorTransform[3] + tColorTransform[7] / 255, 0, 1, 0);
const alpha = $clamp(tColorTransform[3] + tColorTransform[7] / 255, 0, 1, 0);
if (!alpha) {
if (tColorTransform !== color_transform) {
ColorTransform.release(tColorTransform);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { execute } from "./DisplayObjectContainerPrepareUseCase";
import { describe, expect, it } from "vitest";
import { MovieClip } from "../../MovieClip";

describe("DisplayObjectContainerPrepareUseCase.js test", () =>
{
it("execute test", () =>
{
const container = new MovieClip();
const movieClip = container.addChild(new MovieClip());

expect(movieClip.$canSound).toBe(true);
expect(movieClip.$canAction).toBe(true);

execute(container);

expect(movieClip.$canSound).toBe(false);
expect(movieClip.$canAction).toBe(false);
});
});
Loading