@lull-ext/game-adapter-phaser 0.0.0-stage → 0.1.0
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 +202 -0
- package/README.md +47 -2
- package/dist/index.d.ts +85 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +203 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @lull-ext/game-adapter-phaser
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Phaser 渲染适配器(P4)。**宿主不加载、不依赖**本包;由游戏包的 `entry.replica` 自己 import 并打包。
|
|
4
|
+
|
|
5
|
+
它只做三件事:
|
|
6
|
+
|
|
7
|
+
1. 用 LULL 的渲染几何(`render.viewport`)创建 `Phaser.Game`,之后几何变化时同步 `scale.resize`;
|
|
8
|
+
2. 把宿主生命周期映射到 `game.loop.sleep()/wake()`(`suspended`/`stopped`/`failed` 暂停,`resumed`/`running` 恢复);
|
|
9
|
+
3. 把只读快照 / 渲染态分发给 `applySnapshot` / `applyRenderState`。
|
|
10
|
+
|
|
11
|
+
零运行时依赖:不 import Phaser 类型,用结构化 `PhaserGameLike`;Phaser 的版本由你的包决定。
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import Phaser from "phaser";
|
|
15
|
+
import { createPhaserGameAdapter } from "@lull-ext/game-adapter-phaser";
|
|
16
|
+
import { connectLullGameRender } from "@lull-ext/game-sdk/scene";
|
|
17
|
+
|
|
18
|
+
const game = await connectLullGameRender();
|
|
19
|
+
if (game) {
|
|
20
|
+
const adapter = createPhaserGameAdapter({
|
|
21
|
+
game,
|
|
22
|
+
create: ({ width, height, dpr }) => {
|
|
23
|
+
const runtime = new Phaser.Game({
|
|
24
|
+
type: Phaser.AUTO,
|
|
25
|
+
parent: "stage",
|
|
26
|
+
width,
|
|
27
|
+
height,
|
|
28
|
+
scale: { mode: Phaser.Scale.NONE },
|
|
29
|
+
scene: [MyScene],
|
|
30
|
+
});
|
|
31
|
+
runtime.registry.set("dpr", dpr);
|
|
32
|
+
return runtime;
|
|
33
|
+
},
|
|
34
|
+
applySnapshot: (runtime, snapshot) => {
|
|
35
|
+
runtime.scene.getScene("MyScene")?.applyLullSnapshot(snapshot.state);
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
await adapter.start();
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
注意:
|
|
43
|
+
|
|
44
|
+
- Phaser 3 的 Scale Manager 以 **CSS 像素**为基准,不直接吃 `devicePixelRatio`;需要更高清时可自行用 `zoom`/自定义渲染尺寸,或改用 PixiJS / Three.js。
|
|
45
|
+
- 适配器不写状态、不发命令、不创建窗口;游戏规则仍在你自己的 scene 里。
|
|
46
|
+
- `start()` 只创建引擎;`destroy()` 取消订阅并 `game.destroy(true)`。
|
|
47
|
+
|
|
48
|
+
参考示例:`examples/games/phaser-demo`。
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phaser 渲染适配器(P4)。
|
|
3
|
+
*
|
|
4
|
+
* 零运行时依赖:Phaser 由游戏包自己 import 并打包,宿主不加载本包。
|
|
5
|
+
* 适配器只做三件事:
|
|
6
|
+
* - 用 LULL 的渲染几何创建游戏,并在显示器几何/DPI 变化时同步 Scale Manager;
|
|
7
|
+
* - 把宿主生命周期(suspended/stopped/failed → 暂停,resumed/running → 恢复)
|
|
8
|
+
* 映射到 Phaser 的 `game.loop.sleep()/wake()`;
|
|
9
|
+
* - 把只读快照 / 渲染态分发给 `applySnapshot` / `applyRenderState`。
|
|
10
|
+
*
|
|
11
|
+
* 它不写权威状态、不发命令、不碰窗口。
|
|
12
|
+
*/
|
|
13
|
+
export type EngineViewport = {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
dpr: number;
|
|
17
|
+
};
|
|
18
|
+
export type EngineSnapshot = {
|
|
19
|
+
state: unknown;
|
|
20
|
+
revision: number;
|
|
21
|
+
simulationTimeMs: number;
|
|
22
|
+
};
|
|
23
|
+
export type EngineLifecycleEvent = {
|
|
24
|
+
state: string;
|
|
25
|
+
reason?: string;
|
|
26
|
+
offlineMs?: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* 只读游戏来源。`@lull-ext/game-sdk/scene` 的 `LullGameRenderClient` 直接满足该结构。
|
|
30
|
+
* 约定:`onSnapshot` 在订阅时回放当前快照(SDK 行为),适配器会按 revision 去重。
|
|
31
|
+
*/
|
|
32
|
+
export type EngineGameSource = {
|
|
33
|
+
readonly render: {
|
|
34
|
+
viewport: EngineViewport;
|
|
35
|
+
} | null;
|
|
36
|
+
getSnapshot(): Promise<EngineSnapshot | null>;
|
|
37
|
+
onSnapshot(listener: (snapshot: EngineSnapshot) => void): () => void;
|
|
38
|
+
onRenderState(listener: (state: unknown) => void): () => void;
|
|
39
|
+
onLifecycle(listener: (event: EngineLifecycleEvent) => void): () => void;
|
|
40
|
+
};
|
|
41
|
+
/** 适配器实际用到的 Phaser.Game 结构;不引入 Phaser 类型依赖。 */
|
|
42
|
+
export type PhaserGameLike = {
|
|
43
|
+
scale: {
|
|
44
|
+
resize(width: number, height: number): void;
|
|
45
|
+
};
|
|
46
|
+
loop: {
|
|
47
|
+
sleep(): void;
|
|
48
|
+
wake(): void;
|
|
49
|
+
};
|
|
50
|
+
destroy(removeCanvas?: boolean, noReturn?: boolean): void;
|
|
51
|
+
};
|
|
52
|
+
export type PhaserAdapterOptions<T extends PhaserGameLike> = {
|
|
53
|
+
/** 只读游戏来源,通常是 `await connectLullGameRender()`。 */
|
|
54
|
+
game: EngineGameSource;
|
|
55
|
+
/**
|
|
56
|
+
* 创建 Phaser.Game。示例:
|
|
57
|
+
* `({ width, height }) => new Phaser.Game({ type: Phaser.AUTO, parent: "stage", width, height, scene: [...] })`
|
|
58
|
+
*/
|
|
59
|
+
create: (context: {
|
|
60
|
+
width: number;
|
|
61
|
+
height: number;
|
|
62
|
+
dpr: number;
|
|
63
|
+
}) => T | Promise<T>;
|
|
64
|
+
applySnapshot?: (engine: T, snapshot: EngineSnapshot) => void;
|
|
65
|
+
applyRenderState?: (engine: T, renderState: unknown) => void;
|
|
66
|
+
/** 默认 `engine.loop.sleep()`。 */
|
|
67
|
+
pause?: (engine: T) => void;
|
|
68
|
+
/** 默认 `engine.loop.wake()`。 */
|
|
69
|
+
resume?: (engine: T) => void;
|
|
70
|
+
/** 默认 `engine.scale.resize(width, height)`;Phaser 3 以 CSS 像素为基准。 */
|
|
71
|
+
resize?: (engine: T, viewport: EngineViewport) => void;
|
|
72
|
+
/** 默认 `engine.destroy(true)`。 */
|
|
73
|
+
destroy?: (engine: T) => void;
|
|
74
|
+
onError?: (error: unknown) => void;
|
|
75
|
+
/** 视口变化轮询间隔,默认 500ms;传 0 关闭。 */
|
|
76
|
+
pollMs?: number;
|
|
77
|
+
};
|
|
78
|
+
export type PhaserAdapter<T extends PhaserGameLike> = {
|
|
79
|
+
start(): Promise<void>;
|
|
80
|
+
destroy(): void;
|
|
81
|
+
readonly running: boolean;
|
|
82
|
+
readonly engine: T | null;
|
|
83
|
+
};
|
|
84
|
+
export declare function createPhaserGameAdapter<T extends PhaserGameLike>(options: PhaserAdapterOptions<T>): PhaserAdapter<T>;
|
|
85
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|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AE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC;CAC3B,CAAC;AAgCF,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,cAAc,EAC9D,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC/B,aAAa,CAAC,CAAC,CAAC,CAuJlB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phaser 渲染适配器(P4)。
|
|
3
|
+
*
|
|
4
|
+
* 零运行时依赖:Phaser 由游戏包自己 import 并打包,宿主不加载本包。
|
|
5
|
+
* 适配器只做三件事:
|
|
6
|
+
* - 用 LULL 的渲染几何创建游戏,并在显示器几何/DPI 变化时同步 Scale Manager;
|
|
7
|
+
* - 把宿主生命周期(suspended/stopped/failed → 暂停,resumed/running → 恢复)
|
|
8
|
+
* 映射到 Phaser 的 `game.loop.sleep()/wake()`;
|
|
9
|
+
* - 把只读快照 / 渲染态分发给 `applySnapshot` / `applyRenderState`。
|
|
10
|
+
*
|
|
11
|
+
* 它不写权威状态、不发命令、不碰窗口。
|
|
12
|
+
*/
|
|
13
|
+
const PAUSED_STATES = new Set(["suspended", "stopped", "failed"]);
|
|
14
|
+
const DEFAULT_POLL_MS = 500;
|
|
15
|
+
function report(error, onError) {
|
|
16
|
+
if (onError) {
|
|
17
|
+
onError(error);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
console.error("[lull/phaser] adapter error", error);
|
|
21
|
+
}
|
|
22
|
+
function readViewport(game) {
|
|
23
|
+
const viewport = game.render?.viewport;
|
|
24
|
+
const dpr = viewport && Number.isFinite(viewport.dpr) && viewport.dpr > 0
|
|
25
|
+
? viewport.dpr
|
|
26
|
+
: (globalThis.devicePixelRatio ?? 1);
|
|
27
|
+
const width = viewport && viewport.width > 0 ? viewport.width : 1;
|
|
28
|
+
const height = viewport && viewport.height > 0 ? viewport.height : 1;
|
|
29
|
+
return { width, height, dpr };
|
|
30
|
+
}
|
|
31
|
+
function sameViewport(left, right) {
|
|
32
|
+
return (left.width === right.width &&
|
|
33
|
+
left.height === right.height &&
|
|
34
|
+
left.dpr === right.dpr);
|
|
35
|
+
}
|
|
36
|
+
export function createPhaserGameAdapter(options) {
|
|
37
|
+
const { game } = options;
|
|
38
|
+
const pollMs = options.pollMs ?? DEFAULT_POLL_MS;
|
|
39
|
+
let engine = null;
|
|
40
|
+
let started = false;
|
|
41
|
+
let destroyed = false;
|
|
42
|
+
let paused = false;
|
|
43
|
+
let lastRevision = -1;
|
|
44
|
+
let applied = null;
|
|
45
|
+
let timer = null;
|
|
46
|
+
const unsubscribers = [];
|
|
47
|
+
const fail = (error) => report(error, options.onError);
|
|
48
|
+
const syncViewport = () => {
|
|
49
|
+
if (!engine || destroyed)
|
|
50
|
+
return;
|
|
51
|
+
const viewport = readViewport(game);
|
|
52
|
+
if (applied && sameViewport(applied, viewport))
|
|
53
|
+
return;
|
|
54
|
+
applied = viewport;
|
|
55
|
+
try {
|
|
56
|
+
if (options.resize) {
|
|
57
|
+
options.resize(engine, viewport);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
engine.scale.resize(Math.max(1, Math.round(viewport.width)), Math.max(1, Math.round(viewport.height)));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
fail(error);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const applySnapshot = (snapshot) => {
|
|
68
|
+
if (!engine || destroyed)
|
|
69
|
+
return;
|
|
70
|
+
if (snapshot.revision <= lastRevision)
|
|
71
|
+
return;
|
|
72
|
+
lastRevision = snapshot.revision;
|
|
73
|
+
try {
|
|
74
|
+
options.applySnapshot?.(engine, snapshot);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
fail(error);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const applyLifecycle = (event) => {
|
|
81
|
+
if (!engine || destroyed)
|
|
82
|
+
return;
|
|
83
|
+
if (PAUSED_STATES.has(event.state)) {
|
|
84
|
+
paused = true;
|
|
85
|
+
try {
|
|
86
|
+
if (options.pause)
|
|
87
|
+
options.pause(engine);
|
|
88
|
+
else
|
|
89
|
+
engine.loop.sleep();
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
fail(error);
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (!paused)
|
|
97
|
+
return;
|
|
98
|
+
paused = false;
|
|
99
|
+
try {
|
|
100
|
+
if (options.resume)
|
|
101
|
+
options.resume(engine);
|
|
102
|
+
else
|
|
103
|
+
engine.loop.wake();
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
fail(error);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const start = async () => {
|
|
110
|
+
if (started || destroyed)
|
|
111
|
+
return;
|
|
112
|
+
started = true;
|
|
113
|
+
applied = readViewport(game);
|
|
114
|
+
let created;
|
|
115
|
+
try {
|
|
116
|
+
created = await Promise.resolve(options.create({ ...applied }));
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
started = false;
|
|
120
|
+
fail(error);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (destroyed) {
|
|
124
|
+
try {
|
|
125
|
+
created.destroy(true);
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
// 已在销毁流程中,忽略二次销毁异常。
|
|
129
|
+
}
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
engine = created;
|
|
133
|
+
unsubscribers.push(game.onSnapshot((snapshot) => applySnapshot(snapshot)), game.onRenderState((state) => {
|
|
134
|
+
if (!engine || destroyed)
|
|
135
|
+
return;
|
|
136
|
+
try {
|
|
137
|
+
options.applyRenderState?.(engine, state);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
fail(error);
|
|
141
|
+
}
|
|
142
|
+
}), game.onLifecycle((event) => applyLifecycle(event)));
|
|
143
|
+
if (paused) {
|
|
144
|
+
try {
|
|
145
|
+
if (options.pause)
|
|
146
|
+
options.pause(created);
|
|
147
|
+
else
|
|
148
|
+
created.loop.sleep();
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
fail(error);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const initial = await game.getSnapshot().catch(() => null);
|
|
155
|
+
if (initial)
|
|
156
|
+
applySnapshot(initial);
|
|
157
|
+
if (pollMs > 0 && !destroyed) {
|
|
158
|
+
timer = setInterval(() => syncViewport(), pollMs);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const destroy = () => {
|
|
162
|
+
if (destroyed)
|
|
163
|
+
return;
|
|
164
|
+
destroyed = true;
|
|
165
|
+
started = false;
|
|
166
|
+
if (timer !== null) {
|
|
167
|
+
clearInterval(timer);
|
|
168
|
+
timer = null;
|
|
169
|
+
}
|
|
170
|
+
for (const unsubscribe of unsubscribers.splice(0)) {
|
|
171
|
+
try {
|
|
172
|
+
unsubscribe();
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
fail(error);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const current = engine;
|
|
179
|
+
engine = null;
|
|
180
|
+
if (!current)
|
|
181
|
+
return;
|
|
182
|
+
try {
|
|
183
|
+
if (options.destroy)
|
|
184
|
+
options.destroy(current);
|
|
185
|
+
else
|
|
186
|
+
current.destroy(true);
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
fail(error);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
return {
|
|
193
|
+
start,
|
|
194
|
+
destroy,
|
|
195
|
+
get running() {
|
|
196
|
+
return started && !paused && !destroyed && engine !== null;
|
|
197
|
+
},
|
|
198
|
+
get engine() {
|
|
199
|
+
return engine;
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=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AC,OAAO;YAAE,OAAO;QACrB,IAAI,CAAC;YACH,IAAI,OAAO,CAAC,OAAO;gBAAE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;;gBACzC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,KAAK;QACL,OAAO;QACP,IAAI,OAAO;YACT,OAAO,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,SAAS,IAAI,MAAM,KAAK,IAAI,CAAC;QAC7D,CAAC;QACD,IAAI,MAAM;YACR,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lull-ext/game-adapter-phaser",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Lull Game SDK 的 Phaser 渲染适配器:把快照/渲染态/生命周期对齐到 Phaser.Game。",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"lull",
|
|
7
|
+
"game",
|
|
8
|
+
"phaser",
|
|
9
|
+
"adapter",
|
|
10
|
+
"sdk",
|
|
11
|
+
"typescript"
|
|
12
|
+
],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./package.json": "./package.json"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc -p tsconfig.json",
|
|
32
|
+
"check": "tsc -p tsconfig.check.json",
|
|
33
|
+
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
34
|
+
"prepack": "npm run clean && npm run build"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"typescript": "~5.9.3",
|
|
38
|
+
"vitest": "^4.1.0"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=20"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "git+https://github.com/Lull-Desktop/Lull.git",
|
|
49
|
+
"directory": "packages/game-adapter-phaser"
|
|
50
|
+
},
|
|
51
|
+
"homepage": "https://github.com/Lull-Desktop/Lull/tree/dev/packages/game-adapter-phaser#readme",
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "https://github.com/Lull-Desktop/Lull/issues"
|
|
54
|
+
}
|
|
55
|
+
}
|