@next2d/core 1.14.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Next2D
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ @next2d/core
2
+ =============
3
+
4
+ ## Installation
5
+
6
+ ```
7
+ npm install @next2d/core
8
+ ```
9
+
10
+ ## License
11
+ This project is licensed under the [MIT License](https://opensource.org/licenses/MIT) - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,3 @@
1
+ import type { DisplayImpl } from "@next2d/interface";
2
+ declare const display: DisplayImpl;
3
+ export { display };
@@ -0,0 +1,24 @@
1
+ import { DisplayObject, InteractiveObject, DisplayObjectContainer, Sprite, MovieClip, BitmapData, BlendMode, FrameLabel, Graphics, Loader, LoaderInfo, Shape, Stage } from "@next2d/display";
2
+ const display = {
3
+ DisplayObject,
4
+ InteractiveObject,
5
+ DisplayObjectContainer,
6
+ Sprite,
7
+ MovieClip,
8
+ BitmapData,
9
+ BlendMode,
10
+ FrameLabel,
11
+ Graphics,
12
+ Loader,
13
+ LoaderInfo,
14
+ Shape,
15
+ Stage
16
+ };
17
+ Object.entries(display).forEach(([key, DisplayClass]) => {
18
+ Object.defineProperty(display, key, {
19
+ get() {
20
+ return DisplayClass;
21
+ }
22
+ });
23
+ });
24
+ export { display };
@@ -0,0 +1,3 @@
1
+ import { EventsImpl } from "@next2d/interface";
2
+ declare const events: EventsImpl;
3
+ export { events };
package/dist/Events.js ADDED
@@ -0,0 +1,20 @@
1
+ import { Event, EventDispatcher, EventPhase, FocusEvent, HTTPStatusEvent, IOErrorEvent, MouseEvent, ProgressEvent, VideoEvent } from "@next2d/events";
2
+ const events = {
3
+ Event,
4
+ EventDispatcher,
5
+ EventPhase,
6
+ FocusEvent,
7
+ HTTPStatusEvent,
8
+ IOErrorEvent,
9
+ MouseEvent,
10
+ ProgressEvent,
11
+ VideoEvent
12
+ };
13
+ Object.entries(events).forEach(([key, EventClass]) => {
14
+ Object.defineProperty(events, key, {
15
+ get() {
16
+ return EventClass;
17
+ }
18
+ });
19
+ });
20
+ export { events };
@@ -0,0 +1,3 @@
1
+ import type { FiltersImpl } from "@next2d/interface";
2
+ declare const filters: FiltersImpl;
3
+ export { filters };
@@ -0,0 +1,20 @@
1
+ import { BevelFilter, BlurFilter, ColorMatrixFilter, ConvolutionFilter, DisplacementMapFilter, DropShadowFilter, GlowFilter, GradientBevelFilter, GradientGlowFilter } from "@next2d/filters";
2
+ const filters = {
3
+ BevelFilter,
4
+ BlurFilter,
5
+ ColorMatrixFilter,
6
+ ConvolutionFilter,
7
+ DisplacementMapFilter,
8
+ DropShadowFilter,
9
+ GlowFilter,
10
+ GradientBevelFilter,
11
+ GradientGlowFilter
12
+ };
13
+ Object.entries(filters).forEach(([key, FilterClass]) => {
14
+ Object.defineProperty(filters, key, {
15
+ get() {
16
+ return FilterClass;
17
+ }
18
+ });
19
+ });
20
+ export { filters };
package/dist/Geom.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { GeomImpl } from "@next2d/interface";
2
+ declare const geom: GeomImpl;
3
+ export { geom };
package/dist/Geom.js ADDED
@@ -0,0 +1,16 @@
1
+ import { ColorTransform, Matrix, Point, Rectangle, Transform } from "@next2d/geom";
2
+ const geom = {
3
+ ColorTransform,
4
+ Matrix,
5
+ Point,
6
+ Rectangle,
7
+ Transform
8
+ };
9
+ Object.entries(geom).forEach(([key, GeomClass]) => {
10
+ Object.defineProperty(geom, key, {
11
+ get() {
12
+ return GeomClass;
13
+ }
14
+ });
15
+ });
16
+ export { geom };
@@ -0,0 +1,3 @@
1
+ import { MediaImpl } from "@next2d/interface";
2
+ declare const media: MediaImpl;
3
+ export { media };
package/dist/Media.js ADDED
@@ -0,0 +1,15 @@
1
+ import { Sound, SoundMixer, SoundTransform, Video } from "@next2d/media";
2
+ const media = {
3
+ Sound,
4
+ SoundMixer,
5
+ SoundTransform,
6
+ Video
7
+ };
8
+ Object.entries(media).forEach(([key, MediaClass]) => {
9
+ Object.defineProperty(media, key, {
10
+ get() {
11
+ return MediaClass;
12
+ }
13
+ });
14
+ });
15
+ export { media };
package/dist/Net.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { NetImpl } from "@next2d/interface";
2
+ declare const net: NetImpl;
3
+ export { net };
package/dist/Net.js ADDED
@@ -0,0 +1,13 @@
1
+ import { URLRequest, URLRequestHeader } from "@next2d/net";
2
+ const net = {
3
+ URLRequest,
4
+ URLRequestHeader
5
+ };
6
+ Object.entries(net).forEach(([key, NetClass]) => {
7
+ Object.defineProperty(net, key, {
8
+ get() {
9
+ return NetClass;
10
+ }
11
+ });
12
+ });
13
+ export { net };
@@ -0,0 +1,62 @@
1
+ import { Player } from "@next2d/core";
2
+ import { Sprite } from "@next2d/display";
3
+ import { PlayerOptionsImpl, DisplayImpl, EventsImpl, FiltersImpl, GeomImpl, MediaImpl, NetImpl, TextImpl, UIImpl } from "@next2d/interface";
4
+ /**
5
+ * playerの起動管理クラス
6
+ * player startup management class
7
+ * @class
8
+ */
9
+ export declare class Next2D {
10
+ private readonly _$promises;
11
+ private readonly _$player;
12
+ readonly display: DisplayImpl;
13
+ readonly events: EventsImpl;
14
+ readonly filters: FiltersImpl;
15
+ readonly geom: GeomImpl;
16
+ readonly media: MediaImpl;
17
+ readonly net: NetImpl;
18
+ readonly text: TextImpl;
19
+ readonly ui: UIImpl;
20
+ /**
21
+ * @constructor
22
+ * @public
23
+ */
24
+ constructor(promises: Promise<void>[]);
25
+ /**
26
+ * @member {Player}
27
+ * @readonly
28
+ * @return {Player}
29
+ */
30
+ get player(): Player;
31
+ /**
32
+ * @description 指定したURLのJSONファイルを読み込みます。
33
+ * Reads the JSON file at the specified URL.
34
+ *
35
+ * @param {string} url JSONファイルのURL
36
+ * URL of the JSON file
37
+ *
38
+ * @param {object} [options=null] {number} width = Stageの幅 | Stage width
39
+ * {number} height = Stageの高さ | Stage height
40
+ * {string} [tagId=null] canvasを追加対象のDOMのID | ID of the DOM to which the canvas is added
41
+ * {string} [base="/"] Loaderが読み込む際の絶対パス | Absolute path for Loader to load.
42
+ * {number|string|boolean} [bgColor=null] 背景色 | background color
43
+ *
44
+ * @return {void}
45
+ * @method
46
+ * @public
47
+ */
48
+ load(url: string, options: PlayerOptionsImpl): void;
49
+ /**
50
+ * @description 指定したサイズのplayerを設定して、rootのMovieClipを作成
51
+ * Create a root MovieClip with the specified size player set
52
+ *
53
+ * @param {number} [width=240]
54
+ * @param {number} [height=240]
55
+ * @param {number} [fps=24]
56
+ * @param {object} [options=null]
57
+ * @return {Sprite}
58
+ * @method
59
+ * @public
60
+ */
61
+ createRootMovieClip(width?: number, height?: number, fps?: number, options?: PlayerOptionsImpl | null): Promise<Sprite>;
62
+ }
package/dist/Next2D.js ADDED
@@ -0,0 +1,190 @@
1
+ import { events } from "./Events";
2
+ import { display } from "./Display";
3
+ import { filters } from "./Filters";
4
+ import { geom } from "./Geom";
5
+ import { media } from "./Media";
6
+ import { net } from "./Net";
7
+ import { text } from "./Text";
8
+ import { ui } from "./UI";
9
+ import { Player } from "@next2d/core";
10
+ import { URLRequest } from "@next2d/net";
11
+ import { Loader, Sprite } from "@next2d/display";
12
+ import { Event, IOErrorEvent } from "@next2d/events";
13
+ import { $clamp, $poolArray } from "@next2d/share";
14
+ /**
15
+ * playerの起動管理クラス
16
+ * player startup management class
17
+ * @class
18
+ */
19
+ export class Next2D {
20
+ /**
21
+ * @constructor
22
+ * @public
23
+ */
24
+ constructor(promises) {
25
+ /**
26
+ * @type {array}
27
+ * @private
28
+ */
29
+ this._$promises = promises;
30
+ /**
31
+ * @type {Player}
32
+ * @private
33
+ */
34
+ this._$player = new Player();
35
+ /**
36
+ * @type {DisplayImpl}
37
+ * @public
38
+ */
39
+ this.display = display;
40
+ /**
41
+ * @type {EventsImpl}
42
+ * @public
43
+ */
44
+ this.events = events;
45
+ /**
46
+ * @type {FiltersImpl}
47
+ * @public
48
+ */
49
+ this.filters = filters;
50
+ /**
51
+ * @type {GeomImpl}
52
+ * @public
53
+ */
54
+ this.geom = geom;
55
+ /**
56
+ * @type {MediaImpl}
57
+ * @public
58
+ */
59
+ this.media = media;
60
+ /**
61
+ * @type {NetImpl}
62
+ * @public
63
+ */
64
+ this.net = net;
65
+ /**
66
+ * @type {TextImpl}
67
+ * @public
68
+ */
69
+ this.text = text;
70
+ /**
71
+ * @type {UIImpl}
72
+ * @public
73
+ */
74
+ this.ui = ui;
75
+ }
76
+ /**
77
+ * @member {Player}
78
+ * @readonly
79
+ * @return {Player}
80
+ */
81
+ get player() {
82
+ return this._$player;
83
+ }
84
+ /**
85
+ * @description 指定したURLのJSONファイルを読み込みます。
86
+ * Reads the JSON file at the specified URL.
87
+ *
88
+ * @param {string} url JSONファイルのURL
89
+ * URL of the JSON file
90
+ *
91
+ * @param {object} [options=null] {number} width = Stageの幅 | Stage width
92
+ * {number} height = Stageの高さ | Stage height
93
+ * {string} [tagId=null] canvasを追加対象のDOMのID | ID of the DOM to which the canvas is added
94
+ * {string} [base="/"] Loaderが読み込む際の絶対パス | Absolute path for Loader to load.
95
+ * {number|string|boolean} [bgColor=null] 背景色 | background color
96
+ *
97
+ * @return {void}
98
+ * @method
99
+ * @public
100
+ */
101
+ load(url, options) {
102
+ Promise
103
+ .all(this._$promises)
104
+ .then(() => {
105
+ $poolArray(this._$promises);
106
+ if (url === "develop") {
107
+ const path = location
108
+ .search
109
+ .slice(1)
110
+ .split("&")[0];
111
+ if (!path) {
112
+ return;
113
+ }
114
+ url = `${location.origin}/${path}`;
115
+ }
116
+ if (!url) {
117
+ return;
118
+ }
119
+ if (url.charAt(1) === "/") {
120
+ url = url.slice(1);
121
+ }
122
+ // base set
123
+ if ((!options || !("base" in options)) && url.indexOf("//") > -1) {
124
+ this._$player.base = url;
125
+ }
126
+ this._$player.setOptions(options);
127
+ this._$player._$initialize();
128
+ const loader = new Loader();
129
+ loader
130
+ .contentLoaderInfo
131
+ .addEventListener(IOErrorEvent.IO_ERROR, (event) => {
132
+ if (event.target) {
133
+ event.target.removeEventListener(IOErrorEvent.IO_ERROR, event.listener);
134
+ }
135
+ alert("Error: " + event.text);
136
+ });
137
+ loader
138
+ .contentLoaderInfo
139
+ .addEventListener(Event.COMPLETE, (event) => {
140
+ const loaderInfo = event.target;
141
+ const player = this._$player;
142
+ loaderInfo
143
+ .removeEventListener(Event.COMPLETE, event.listener);
144
+ if (loaderInfo._$data) {
145
+ const stage = loaderInfo._$data.stage;
146
+ player.bgColor = stage.bgColor;
147
+ player._$setBackgroundColor(stage.bgColor);
148
+ player.stage.addChild(loaderInfo.content);
149
+ player.width = stage.width;
150
+ player.height = stage.height;
151
+ // set fps fixed logic
152
+ player.stage._$frameRate = $clamp(+stage.fps, 1, 60, 60);
153
+ }
154
+ player._$resize();
155
+ });
156
+ loader.load(new URLRequest(url));
157
+ });
158
+ }
159
+ /**
160
+ * @description 指定したサイズのplayerを設定して、rootのMovieClipを作成
161
+ * Create a root MovieClip with the specified size player set
162
+ *
163
+ * @param {number} [width=240]
164
+ * @param {number} [height=240]
165
+ * @param {number} [fps=24]
166
+ * @param {object} [options=null]
167
+ * @return {Sprite}
168
+ * @method
169
+ * @public
170
+ */
171
+ createRootMovieClip(width = 240, height = 240, fps = 24, options = null) {
172
+ return Promise
173
+ .all(this._$promises)
174
+ .then(() => {
175
+ $poolArray(this._$promises);
176
+ const player = this._$player;
177
+ // setup
178
+ player.width = width | 0;
179
+ player.height = height | 0;
180
+ player.mode = "create";
181
+ player.stage._$frameRate = fps | 0;
182
+ player.setOptions(options);
183
+ player._$initialize();
184
+ const root = player.stage.addChild(new Sprite());
185
+ player._$loadStatus = Player.LOAD_END;
186
+ player.play();
187
+ return Promise.resolve(root);
188
+ });
189
+ }
190
+ }