Skip to content

Commit

Permalink
#154 イベん処理の基盤を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
ienaga committed Aug 3, 2024
1 parent ebf8769 commit fd2d652
Show file tree
Hide file tree
Showing 86 changed files with 1,213 additions and 2,883 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"htmlparser2": "^9.1.0"
},
"devDependencies": {
"@types/node": "^22.0.3",
"@types/node": "^22.1.0",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"@vitest/web-worker": "^2.0.5",
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/Events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
FocusEvent,
HTTPStatusEvent,
IOErrorEvent,
MouseEvent,
PointerEvent,
JobEvent,
ProgressEvent,
VideoEvent
} from "@next2d/events";
Expand All @@ -18,7 +19,8 @@ const events: EventsImpl = {
FocusEvent,
HTTPStatusEvent,
IOErrorEvent,
MouseEvent,
PointerEvent,
JobEvent,
ProgressEvent,
VideoEvent
};
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Next2D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class Next2D
* @method
* @public
*/
async load (url: string, options: PlayerOptionsImpl): Promise<void>
async load (url: string, options: PlayerOptionsImpl | null = null): Promise<void>
{
await Promise.all([this._$promise]);
await loadService(url, options);
Expand Down
11 changes: 7 additions & 4 deletions packages/core/src/Next2D/LoadService.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import type { PlayerOptionsImpl } from "../interface/PlayerOptionsImpl";
import type { StageDataImpl } from "../interface/StageDataImpl";
import type { MovieClip } from "@next2d/display";
import { $player } from "../Player";
import { $stage } from "../Stage";
import { $clamp } from "../CoreUtil";
import { URLRequest } from "@next2d/net";
import { IOErrorEvent } from "@next2d/events";
import { Loader } from "@next2d/display";
import { execute as playerResizeEventService } from "../Player/PlayerResizeEventService";
import { execute as playerRemoveLoadingElementService } from "../Player/PlayerRemoveLoadingElementService";
import { execute as playerAppendCanvasElementService } from "../Player/PlayerAppendCanvasElementService";
import { execute as playerReadyCompleteService } from "../Player/PlayerReadyCompleteService";
import {
Loader,
$stage
} from "@next2d/display";

/**
* @description 指定のURLからJSONファイルを読み込みます。
Expand All @@ -21,7 +24,7 @@ import { execute as playerReadyCompleteService } from "../Player/PlayerReadyComp
* @method
* @protected
*/
export const execute = async (url: string, options: PlayerOptionsImpl): Promise<void> =>
export const execute = async (url: string, options: PlayerOptionsImpl | null = null): Promise<void> =>
{
if (url === "develop") {
const path: string = location
Expand Down Expand Up @@ -67,7 +70,7 @@ export const execute = async (url: string, options: PlayerOptionsImpl): Promise<
$player.frameRate = $clamp(stageData.fps, 1, 60, 60);
$player.bgColor = stageData.bgColor;

// $stage.addChild(loaderInfo.content);
$stage.addChild<MovieClip>(loaderInfo.content as MovieClip);

// resize
playerResizeEventService();
Expand Down
149 changes: 9 additions & 140 deletions packages/core/src/Player.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
import type { PlayerModeImpl } from "./interface/PlayerModeImpl";
import type { EventDispatcherImpl } from "./interface/EventDispatcherImpl";
// import type { ParentImpl } from "./interface/ParentImpl";
// import type { PlayerHitObjectImpl } from "./interface/PlayerHitObjectImpl";
import type { PlayerOptionsImpl } from "./interface/PlayerOptionsImpl";
// import type {
// MovieClip,
// TextField
// } from "@next2d/display";
import type { MovieClip } from "@next2d/display";
import { SoundMixer } from "@next2d/media";
import { $cacheStore } from "@next2d/cache";
import {
$devicePixelRatio,
$LOAD_START,
$LOAD_END,
$PREFIX
} from "./CoreUtil";
import { $devicePixelRatio } from "./CoreUtil";
import { execute as playerCreateContainerElementService } from "./Player/PlayerCreateContainerElementService";
import { execute as playerApplyContainerElementStyleService } from "./Player/PlayerApplyContainerElementStyleService";
import { execute as playerLoadingAnimationService } from "./Player/PlayerLoadingAnimationService";
Expand All @@ -31,8 +19,7 @@ import { execute as playerUpdateBackgroundColorPostMessageService } from "./Play
*/
export class Player
{
// private readonly _$actions: MovieClip[];
private readonly _$loaders: EventDispatcherImpl<any>[];
private readonly _$actions: MovieClip[];
// private readonly _$sounds: Map<any, MovieClip>;
// private readonly _$hitObject: PlayerHitObjectImpl;
private readonly _$matrix: Float32Array;
Expand All @@ -45,23 +32,21 @@ export class Player
private _$fixedHeight: number;
private _$frameRate: number;
private _$stopFlag: boolean;
private _$loadStatus: number;
private _$scale: number;
// private _$state: "up" | "down";
// private _$textField: TextField | null;
private _$mode: PlayerModeImpl;
// private _$rollOverObject: EventDispatcherImpl<any> | null;
// private _$mouseOverTarget: EventDispatcherImpl<any> | null;
// private _$startTime: number;
// private _$fps: number;
private _$fps: number;
// private _$hitTestStart: boolean;
// private _$stageX: number;
// private _$stageY: number;
private _$tagId: string;
private _$bgColor: string;
private _$fullScreen: boolean;
private _$timerId: number;
private _$loadId: number;
// private _$deltaX: number;
// private _$deltaY: number;
// private _$clickTarget: ParentImpl<any> | null;
Expand All @@ -79,17 +64,11 @@ export class Player
*/
this._$mode = "loader";

// /**
// * @type {array}
// * @private
// */
// this._$actions = [];

/**
* @type {array}
* @public
* @private
*/
this._$loaders = [];
this._$actions = [];

// /**
// * @type {Map}
Expand Down Expand Up @@ -143,19 +122,12 @@ export class Player
// */
// this._$startTime = 0;

// /**
// * @type {number}
// * @default 16
// * @private
// */
// this._$fps = 16;

/**
* @type {number}
* @default 0
* @default 16
* @private
*/
this._$loadStatus = 0;
this._$fps = 16;

// /**
// * @type {number}
Expand Down Expand Up @@ -677,7 +649,7 @@ export class Player
}

// initialize resize
playerResizeEventService(this);
playerResizeEventService();
}

// /**
Expand Down Expand Up @@ -752,109 +724,6 @@ export class Player

// }

// // @ts-ignore
// this._$canvas.addEventListener($TOUCH_START, (event: TouchEvent) =>
// {
// $setEvent(event);
// $setEventType($TOUCH_START);

// // start position
// this._$hitTest();
// });

// // @ts-ignore
// this._$canvas.addEventListener($TOUCH_MOVE, (event: TouchEvent) =>
// {
// $setEvent(event);
// $setEventType($TOUCH_MOVE);
// this._$hitTest();
// });

// // @ts-ignore
// this._$canvas.addEventListener($TOUCH_END, (event: TouchEvent) =>
// {
// $setEvent(event);
// $setEventType($TOUCH_END);
// this._$hitTest();
// });

// // @ts-ignore
// this._$canvas.addEventListener($TOUCH_MOVE, (event: TouchEvent) =>
// {
// $setEvent(event);
// $setEventType($TOUCH_MOVE);

// this._$hitTest();
// }, { "passive": false });

// // @ts-ignore
// this._$canvas.addEventListener($MOUSE_DOWN, (event: MouseEvent) =>
// {
// $setEvent(event);
// $setEventType($MOUSE_DOWN);

// if (!event.button) {
// this._$hitTest();
// }
// });

// // @ts-ignore
// this._$canvas.addEventListener($DOUBLE_CLICK, (event: MouseEvent) =>
// {
// $setEvent(event);
// $setEventType($DOUBLE_CLICK);

// if (!event.button) {
// this._$hitTest();
// }
// });

// // @ts-ignore
// this._$canvas.addEventListener($MOUSE_LEAVE, (event: MouseEvent) =>
// {
// $setEvent(event);
// $setEventType($MOUSE_LEAVE);

// this._$hitTest();

// $setEvent(null);
// this._$stageX = -1;
// this._$stageY = -1;
// });

// // @ts-ignore
// this._$canvas.addEventListener($MOUSE_UP, (event: MouseEvent) =>
// {
// $setEvent(event);
// $setEventType($MOUSE_UP);

// if (!event.button) {
// this._$hitTest();
// }
// });

// // @ts-ignore
// this._$canvas.addEventListener($MOUSE_MOVE, (event: MouseEvent) =>
// {
// $setEvent(event);
// $setEventType($MOUSE_MOVE);

// this._$hitTest();
// });

// // @ts-ignore
// this._$canvas.addEventListener($MOUSE_WHEEL, (event: MouseEvent) =>
// {
// if (!event.defaultPrevented) {

// $setEvent(event);
// $setEventType($MOUSE_WHEEL);

// this._$hitTest();
// }
// }, { "passive": false });
// }

// /**
// * @param {Event} event
// * @return {boolean}
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/interface/EventsImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import type {
FocusEvent,
HTTPStatusEvent,
IOErrorEvent,
MouseEvent,
PointerEvent,
JobEvent,
ProgressEvent,
VideoEvent
} from "@next2d/events";
Expand All @@ -17,7 +18,8 @@ export interface EventsImpl {
FocusEvent: typeof FocusEvent;
HTTPStatusEvent: typeof HTTPStatusEvent;
IOErrorEvent: typeof IOErrorEvent;
MouseEvent: typeof MouseEvent;
PointerEvent: typeof PointerEvent;
JobEvent: typeof JobEvent;
ProgressEvent: typeof ProgressEvent;
VideoEvent: typeof VideoEvent;
}
Loading

0 comments on commit fd2d652

Please sign in to comment.