pixifact 0.6.1 → 0.8.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 +21 -0
- package/README.md +30 -29
- package/dist/client.d.ts +23 -0
- package/dist/compiler/compileScenes.js +13 -4
- package/dist/compiler/typescriptCompiler.js +2 -2
- package/dist/compiler-node/runtimeVite.js +96 -23
- package/dist/compiler-node/vite.d.ts +16 -6
- package/dist/compiler-node/vite.js +418 -32
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +6 -0
- package/dist/platform/{wechat → minigame}/adapter.d.ts +7 -6
- package/dist/platform/{wechat → minigame}/adapter.js +10 -8
- package/dist/platform/minigame/application.d.ts +4 -0
- package/dist/platform/minigame/application.js +53 -0
- package/dist/platform/minigame/fetch.d.ts +2 -0
- package/dist/platform/{wechat → minigame}/fetch.js +13 -15
- package/dist/platform/minigame/index.d.ts +8 -0
- package/dist/platform/minigame/index.js +8 -0
- package/dist/platform/minigame/input.d.ts +16 -0
- package/dist/platform/{wechat → minigame}/input.js +18 -19
- package/dist/platform/minigame/lifecycle.d.ts +15 -0
- package/dist/platform/{wechat → minigame}/lifecycle.js +5 -7
- package/dist/platform/{wechat → minigame}/runtime.d.ts +5 -5
- package/dist/platform/{wechat → minigame}/runtime.js +14 -20
- package/dist/platform/minigame/subpackage.d.ts +3 -0
- package/dist/platform/minigame/subpackage.js +36 -0
- package/dist/platform/{wechat → minigame}/types.d.ts +24 -21
- package/dist/platform/minigame/types.js +1 -0
- package/dist/platform/web/index.d.ts +2 -0
- package/dist/platform/web/index.js +6 -0
- package/dist/project/index.d.ts +5 -24
- package/dist/project/index.js +45 -59
- package/dist/runtime-dev/index.d.ts +1 -1
- package/dist/runtime-dev/protocol.d.ts +12 -1
- package/dist/runtime-dev/runtimeClient.js +21 -1
- package/dist/scene/index.d.ts +0 -1
- package/dist/scene/index.js +0 -1
- package/package.json +16 -7
- package/dist/platform/wechat/application.d.ts +0 -32
- package/dist/platform/wechat/application.js +0 -79
- package/dist/platform/wechat/fetch.d.ts +0 -1
- package/dist/platform/wechat/index.d.ts +0 -4
- package/dist/platform/wechat/index.js +0 -3
- package/dist/platform/wechat/input.d.ts +0 -12
- package/dist/platform/wechat/lifecycle.d.ts +0 -14
- package/dist/platform/wechat/subpackage.d.ts +0 -1
- package/dist/platform/wechat/subpackage.js +0 -27
- package/dist/platform/wechat/types.js +0 -3
- package/dist/scene/sceneAssetRuntime.d.ts +0 -11
- package/dist/scene/sceneAssetRuntime.js +0 -43
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
class WechatResponseHeaders {
|
|
1
|
+
class MiniGameResponseHeaders {
|
|
3
2
|
values;
|
|
4
3
|
constructor(headers) {
|
|
5
4
|
this.values = new Map(Object.entries(headers).map(([name, value]) => [name.toLowerCase(), String(value)]));
|
|
@@ -54,7 +53,7 @@ function encodeUtf8(value) {
|
|
|
54
53
|
}
|
|
55
54
|
return new Uint8Array(bytes).buffer;
|
|
56
55
|
}
|
|
57
|
-
class
|
|
56
|
+
class MiniGameResourceResponse {
|
|
58
57
|
responseBody;
|
|
59
58
|
status;
|
|
60
59
|
url;
|
|
@@ -70,7 +69,7 @@ class WechatResourceResponse {
|
|
|
70
69
|
this.status = status;
|
|
71
70
|
this.url = url;
|
|
72
71
|
this.ok = status >= 200 && status < 300;
|
|
73
|
-
this.headers = new
|
|
72
|
+
this.headers = new MiniGameResponseHeaders(responseHeaders);
|
|
74
73
|
}
|
|
75
74
|
async arrayBuffer() {
|
|
76
75
|
return typeof this.responseBody === 'string'
|
|
@@ -78,16 +77,16 @@ class WechatResourceResponse {
|
|
|
78
77
|
: this.responseBody.slice(0);
|
|
79
78
|
}
|
|
80
79
|
async blob() {
|
|
81
|
-
throw new Error('Blob responses are not supported by the
|
|
80
|
+
throw new Error('Blob responses are not supported by the Mini Game resource adapter.');
|
|
82
81
|
}
|
|
83
82
|
clone() {
|
|
84
83
|
const body = typeof this.responseBody === 'string'
|
|
85
84
|
? this.responseBody
|
|
86
85
|
: this.responseBody.slice(0);
|
|
87
|
-
return new
|
|
86
|
+
return new MiniGameResourceResponse(body, this.status, this.url);
|
|
88
87
|
}
|
|
89
88
|
async formData() {
|
|
90
|
-
throw new Error('FormData responses are not supported by the
|
|
89
|
+
throw new Error('FormData responses are not supported by the Mini Game resource adapter.');
|
|
91
90
|
}
|
|
92
91
|
async json() {
|
|
93
92
|
return JSON.parse((await this.text()).replace(/^\uFEFF/, ''));
|
|
@@ -114,32 +113,31 @@ function localPath(url) {
|
|
|
114
113
|
const suffix = url.search(/[?#]/);
|
|
115
114
|
return (suffix >= 0 ? url.slice(0, suffix) : url).replace(/^(\.\/)+/, '');
|
|
116
115
|
}
|
|
117
|
-
export function
|
|
116
|
+
export function fetchMiniGameResource(api, input, init = {}, platformName) {
|
|
118
117
|
const method = (init.method ?? 'GET').toUpperCase();
|
|
119
118
|
const url = requestUrl(input);
|
|
120
119
|
if (method !== 'GET') {
|
|
121
|
-
return Promise.reject(new Error(`The
|
|
120
|
+
return Promise.reject(new Error(`The ${platformName} resource adapter only supports GET requests, received ${method}.`));
|
|
122
121
|
}
|
|
123
122
|
if (init.signal?.aborted) {
|
|
124
123
|
return Promise.reject(new Error(`Resource request was aborted: ${url}`));
|
|
125
124
|
}
|
|
126
|
-
const wx = wechatApi();
|
|
127
125
|
if (/^https?:\/\//i.test(url)) {
|
|
128
|
-
return new Promise((resolve, reject) =>
|
|
126
|
+
return new Promise((resolve, reject) => api.request({
|
|
129
127
|
url,
|
|
130
128
|
method: 'GET',
|
|
131
129
|
responseType: 'arraybuffer',
|
|
132
130
|
fail: (error) => reject(new Error(`Failed to request ${url}: ${error.errMsg}`)),
|
|
133
|
-
success: (result) => resolve(new
|
|
131
|
+
success: (result) => resolve(new MiniGameResourceResponse(toResponseBody(result.data), result.statusCode, url, result.header)),
|
|
134
132
|
}));
|
|
135
133
|
}
|
|
136
134
|
if (/^data:/i.test(url)) {
|
|
137
|
-
return Promise.reject(new Error(
|
|
135
|
+
return Promise.reject(new Error(`Data URLs are not supported by the ${platformName} resource adapter.`));
|
|
138
136
|
}
|
|
139
137
|
const filePath = localPath(url);
|
|
140
|
-
return new Promise((resolve, reject) =>
|
|
138
|
+
return new Promise((resolve, reject) => api.getFileSystemManager().readFile({
|
|
141
139
|
filePath,
|
|
142
140
|
fail: (error) => reject(new Error(`Failed to read ${filePath}: ${error.errMsg}`)),
|
|
143
|
-
success: (result) => resolve(new
|
|
141
|
+
success: (result) => resolve(new MiniGameResourceResponse(toResponseBody(result.data), 200, url)),
|
|
144
142
|
}));
|
|
145
143
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MiniGameApi, MiniGameCanvas, MiniGameTouch } from './types.js';
|
|
2
|
+
export interface MiniGamePointerEventSink {
|
|
3
|
+
pointerdown(event: Event): void;
|
|
4
|
+
pointermove(event: Event): void;
|
|
5
|
+
pointerup(event: Event): void;
|
|
6
|
+
}
|
|
7
|
+
export interface MiniGamePointerBinding {
|
|
8
|
+
readonly activePointerCount: number;
|
|
9
|
+
cancelAll(): void;
|
|
10
|
+
dispose(): void;
|
|
11
|
+
}
|
|
12
|
+
export type MiniGameTouchCoordinates = (touch: MiniGameTouch) => {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
};
|
|
16
|
+
export declare function bindMiniGamePointerEvents(api: MiniGameApi, canvas: MiniGameCanvas, sink: MiniGamePointerEventSink, coordinates: MiniGameTouchCoordinates): MiniGamePointerBinding;
|
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { MiniGamePointerEvent } from './runtime.js';
|
|
2
|
+
function pointerState(touch, coordinates) {
|
|
3
|
+
const point = coordinates(touch);
|
|
4
4
|
return {
|
|
5
5
|
force: touch.force ?? 0.5,
|
|
6
6
|
pointerId: (touch.identifier ?? 0) + 1,
|
|
7
|
-
x:
|
|
8
|
-
y:
|
|
7
|
+
x: point.x,
|
|
8
|
+
y: point.y,
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
function changedTouches(event) {
|
|
12
12
|
return event.changedTouches?.length ? event.changedTouches : event.touches ?? [];
|
|
13
13
|
}
|
|
14
|
-
export function
|
|
15
|
-
const wx = wechatApi();
|
|
14
|
+
export function bindMiniGamePointerEvents(api, canvas, sink, coordinates) {
|
|
16
15
|
const activePointers = new Map();
|
|
17
16
|
let disposed = false;
|
|
18
17
|
let primaryPointerId = null;
|
|
19
18
|
const dispatch = (type, state, eventTarget, buttons) => {
|
|
20
|
-
const event = new
|
|
19
|
+
const event = new MiniGamePointerEvent(type, {
|
|
21
20
|
button: 0,
|
|
22
21
|
buttons,
|
|
23
22
|
clientX: state.x,
|
|
@@ -36,7 +35,7 @@ export function bindWechatPointerEvents(canvas, sink) {
|
|
|
36
35
|
};
|
|
37
36
|
const handleStart = (event) => {
|
|
38
37
|
for (const touch of changedTouches(event)) {
|
|
39
|
-
const state = pointerState(touch);
|
|
38
|
+
const state = pointerState(touch, coordinates);
|
|
40
39
|
primaryPointerId ??= state.pointerId;
|
|
41
40
|
activePointers.set(state.pointerId, state);
|
|
42
41
|
dispatch('pointerdown', state, canvas, 1);
|
|
@@ -44,14 +43,14 @@ export function bindWechatPointerEvents(canvas, sink) {
|
|
|
44
43
|
};
|
|
45
44
|
const handleMove = (event) => {
|
|
46
45
|
for (const touch of changedTouches(event)) {
|
|
47
|
-
const state = pointerState(touch);
|
|
46
|
+
const state = pointerState(touch, coordinates);
|
|
48
47
|
activePointers.set(state.pointerId, state);
|
|
49
48
|
dispatch('pointermove', state, canvas, 1);
|
|
50
49
|
}
|
|
51
50
|
};
|
|
52
51
|
const release = (event, cancelled) => {
|
|
53
52
|
const touches = event.changedTouches?.length
|
|
54
|
-
? event.changedTouches.map(pointerState)
|
|
53
|
+
? event.changedTouches.map((touch) => pointerState(touch, coordinates))
|
|
55
54
|
: [...activePointers.values()];
|
|
56
55
|
for (const state of touches) {
|
|
57
56
|
dispatch('pointerup', state, cancelled ? globalThis : canvas, 0);
|
|
@@ -63,10 +62,10 @@ export function bindWechatPointerEvents(canvas, sink) {
|
|
|
63
62
|
};
|
|
64
63
|
const handleEnd = (event) => release(event, false);
|
|
65
64
|
const handleCancel = (event) => release(event, true);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
api.onTouchStart(handleStart);
|
|
66
|
+
api.onTouchMove(handleMove);
|
|
67
|
+
api.onTouchEnd(handleEnd);
|
|
68
|
+
api.onTouchCancel(handleCancel);
|
|
70
69
|
return {
|
|
71
70
|
get activePointerCount() {
|
|
72
71
|
return activePointers.size;
|
|
@@ -84,10 +83,10 @@ export function bindWechatPointerEvents(canvas, sink) {
|
|
|
84
83
|
}
|
|
85
84
|
disposed = true;
|
|
86
85
|
this.cancelAll();
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
api.offTouchStart?.(handleStart);
|
|
87
|
+
api.offTouchMove?.(handleMove);
|
|
88
|
+
api.offTouchEnd?.(handleEnd);
|
|
89
|
+
api.offTouchCancel?.(handleCancel);
|
|
91
90
|
},
|
|
92
91
|
};
|
|
93
92
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MiniGameApi } from './types.js';
|
|
2
|
+
interface LifecycleTarget {
|
|
3
|
+
readonly started?: boolean;
|
|
4
|
+
start(): void;
|
|
5
|
+
stop(): void;
|
|
6
|
+
}
|
|
7
|
+
export interface MiniGameLifecycleBinding {
|
|
8
|
+
dispose(): void;
|
|
9
|
+
readonly hidden: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function bindMiniGameLifecycle(api: MiniGameApi, target: LifecycleTarget, options?: {
|
|
12
|
+
onHide?(): void;
|
|
13
|
+
onShow?(): void;
|
|
14
|
+
}): MiniGameLifecycleBinding;
|
|
15
|
+
export {};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export function bindWechatLifecycle(target, options = {}) {
|
|
3
|
-
const wx = wechatApi();
|
|
1
|
+
export function bindMiniGameLifecycle(api, target, options = {}) {
|
|
4
2
|
let disposed = false;
|
|
5
3
|
let hidden = false;
|
|
6
4
|
let resumeOnShow = false;
|
|
@@ -23,8 +21,8 @@ export function bindWechatLifecycle(target, options = {}) {
|
|
|
23
21
|
}
|
|
24
22
|
options.onShow?.();
|
|
25
23
|
};
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
api.onHide(handleHide);
|
|
25
|
+
api.onShow(handleShow);
|
|
28
26
|
return {
|
|
29
27
|
dispose() {
|
|
30
28
|
if (disposed) {
|
|
@@ -32,8 +30,8 @@ export function bindWechatLifecycle(target, options = {}) {
|
|
|
32
30
|
}
|
|
33
31
|
disposed = true;
|
|
34
32
|
target.stop();
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
api.offHide?.(handleHide);
|
|
34
|
+
api.offShow?.(handleShow);
|
|
37
35
|
},
|
|
38
36
|
get hidden() {
|
|
39
37
|
return hidden;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface
|
|
3
|
-
canvas:
|
|
1
|
+
import type { MiniGameApi, MiniGameCanvas } from './types.js';
|
|
2
|
+
export interface MiniGameRuntime {
|
|
3
|
+
canvas: MiniGameCanvas;
|
|
4
4
|
context: WebGLRenderingContext | WebGL2RenderingContext;
|
|
5
5
|
height: number;
|
|
6
6
|
resolution: number;
|
|
@@ -8,7 +8,7 @@ export interface WechatRuntime {
|
|
|
8
8
|
webGLVersion: 1 | 2;
|
|
9
9
|
width: number;
|
|
10
10
|
}
|
|
11
|
-
export declare class
|
|
11
|
+
export declare class MiniGamePointerEvent {
|
|
12
12
|
altKey: boolean;
|
|
13
13
|
bubbles: boolean;
|
|
14
14
|
button: number;
|
|
@@ -46,4 +46,4 @@ export declare class WechatPointerEvent {
|
|
|
46
46
|
stopImmediatePropagation(): void;
|
|
47
47
|
stopPropagation(): void;
|
|
48
48
|
}
|
|
49
|
-
export declare function
|
|
49
|
+
export declare function createMiniGameRuntime(api: MiniGameApi, userAgent: string): MiniGameRuntime;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export class WechatPointerEvent {
|
|
1
|
+
export class MiniGamePointerEvent {
|
|
3
2
|
altKey = false;
|
|
4
3
|
bubbles = true;
|
|
5
4
|
button = 0;
|
|
@@ -104,10 +103,9 @@ function installCanvasSurface(canvas, width, height) {
|
|
|
104
103
|
}),
|
|
105
104
|
});
|
|
106
105
|
}
|
|
107
|
-
function createDocumentElement(tagName) {
|
|
108
|
-
const wx = wechatApi();
|
|
106
|
+
function createDocumentElement(api, tagName) {
|
|
109
107
|
if (tagName.toLowerCase() === 'canvas') {
|
|
110
|
-
const canvas =
|
|
108
|
+
const canvas = api.createOffscreenCanvas?.({ type: '2d', width: 1, height: 1 }) ?? api.createCanvas();
|
|
111
109
|
canvas.width = 1;
|
|
112
110
|
canvas.height = 1;
|
|
113
111
|
return canvas;
|
|
@@ -117,18 +115,18 @@ function createDocumentElement(tagName) {
|
|
|
117
115
|
}
|
|
118
116
|
return {};
|
|
119
117
|
}
|
|
120
|
-
function installGlobals(canvas, userAgent) {
|
|
118
|
+
function installGlobals(api, canvas, userAgent) {
|
|
121
119
|
const globals = globalThis;
|
|
122
120
|
const mutableGlobals = globals;
|
|
123
121
|
installEventTarget(mutableGlobals);
|
|
124
122
|
const documentTarget = (globals.document ?? {});
|
|
125
123
|
installEventTarget(documentTarget);
|
|
126
|
-
documentTarget.createElement ??= createDocumentElement;
|
|
124
|
+
documentTarget.createElement ??= (tagName) => createDocumentElement(api, tagName);
|
|
127
125
|
if (!globals.document) {
|
|
128
126
|
Object.defineProperty(globals, 'document', { configurable: true, value: documentTarget });
|
|
129
127
|
}
|
|
130
128
|
if (!globals.PointerEvent) {
|
|
131
|
-
Object.defineProperty(globals, 'PointerEvent', { configurable: true, value:
|
|
129
|
+
Object.defineProperty(globals, 'PointerEvent', { configurable: true, value: MiniGamePointerEvent });
|
|
132
130
|
}
|
|
133
131
|
if (!globals.navigator) {
|
|
134
132
|
Object.defineProperty(globals, 'navigator', {
|
|
@@ -166,24 +164,20 @@ function createContext(canvas) {
|
|
|
166
164
|
if (webGL1) {
|
|
167
165
|
return { context: webGL1, webGLVersion: 1 };
|
|
168
166
|
}
|
|
169
|
-
throw new Error('The current
|
|
167
|
+
throw new Error('The current Mini Game runtime does not provide WebGL.');
|
|
170
168
|
}
|
|
171
|
-
export function
|
|
172
|
-
const
|
|
173
|
-
const canvas = wx.createCanvas();
|
|
169
|
+
export function createMiniGameRuntime(api, userAgent) {
|
|
170
|
+
const canvas = api.createCanvas();
|
|
174
171
|
const info = {
|
|
175
|
-
...(
|
|
176
|
-
...(
|
|
177
|
-
...(
|
|
172
|
+
...(api.getSystemInfoSync?.() ?? {}),
|
|
173
|
+
...(api.getDeviceInfo?.() ?? {}),
|
|
174
|
+
...(api.getWindowInfo?.() ?? {}),
|
|
178
175
|
};
|
|
179
176
|
const width = Math.max(1, Math.round(Number(info.windowWidth ?? info.screenWidth)));
|
|
180
177
|
const height = Math.max(1, Math.round(Number(info.windowHeight ?? info.screenHeight)));
|
|
181
|
-
const resolution = Math.min(2, Math.max(1, Number(info.pixelRatio)));
|
|
182
|
-
const userAgent = ['WeChatMiniGame', info.platform, info.system, info.model]
|
|
183
|
-
.filter(Boolean)
|
|
184
|
-
.join('/');
|
|
178
|
+
const resolution = Math.min(2, Math.max(1, Number(info.pixelRatio ?? 1)));
|
|
185
179
|
installCanvasSurface(canvas, width, height);
|
|
186
|
-
installGlobals(canvas, userAgent);
|
|
180
|
+
installGlobals(api, canvas, userAgent);
|
|
187
181
|
const { context, webGLVersion } = createContext(canvas);
|
|
188
182
|
return { canvas, context, height, resolution, userAgent, webGLVersion, width };
|
|
189
183
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { MiniGameApi } from './types.js';
|
|
2
|
+
export declare function miniGameResourceSubpackage(input: RequestInfo | URL): string | undefined;
|
|
3
|
+
export declare function createMiniGameSubpackageLoader(apiOrFactory: MiniGameApi | (() => MiniGameApi), platformName: string): (name: string) => Promise<void>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export function miniGameResourceSubpackage(input) {
|
|
2
|
+
const url = typeof input === 'string' ? input : (input.url ?? String(input));
|
|
3
|
+
if (/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(url))
|
|
4
|
+
return undefined;
|
|
5
|
+
const path = url.replace(/[?#].*$/, '').replace(/^\.?\//, '');
|
|
6
|
+
return path.match(/^subpackages\/([^/]+)\//)?.[1];
|
|
7
|
+
}
|
|
8
|
+
export function createMiniGameSubpackageLoader(apiOrFactory, platformName) {
|
|
9
|
+
const getApi = typeof apiOrFactory === 'function' ? apiOrFactory : () => apiOrFactory;
|
|
10
|
+
const loaded = new Set();
|
|
11
|
+
const loading = new Map();
|
|
12
|
+
return function loadSubpackage(name) {
|
|
13
|
+
if (loaded.has(name)) {
|
|
14
|
+
return Promise.resolve();
|
|
15
|
+
}
|
|
16
|
+
const existing = loading.get(name);
|
|
17
|
+
if (existing) {
|
|
18
|
+
return existing;
|
|
19
|
+
}
|
|
20
|
+
const pending = new Promise((resolve, reject) => {
|
|
21
|
+
getApi().loadSubpackage({
|
|
22
|
+
name,
|
|
23
|
+
fail: (error) => reject(new Error(`Failed to load ${platformName} subpackage ${name}: ${error.errMsg}`)),
|
|
24
|
+
success: resolve,
|
|
25
|
+
});
|
|
26
|
+
}).then(() => {
|
|
27
|
+
loaded.add(name);
|
|
28
|
+
loading.delete(name);
|
|
29
|
+
}, (error) => {
|
|
30
|
+
loading.delete(name);
|
|
31
|
+
throw error;
|
|
32
|
+
});
|
|
33
|
+
loading.set(name, pending);
|
|
34
|
+
return pending;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface MiniGameCanvas {
|
|
2
2
|
width: number;
|
|
3
3
|
height: number;
|
|
4
4
|
isConnected?: boolean;
|
|
@@ -20,7 +20,7 @@ export interface WechatCanvas {
|
|
|
20
20
|
removeEventListener?(type: string, listener: EventListenerOrEventListenerObject, options?: unknown): void;
|
|
21
21
|
dispatchEvent?(event: Event): boolean;
|
|
22
22
|
}
|
|
23
|
-
export interface
|
|
23
|
+
export interface MiniGameImage {
|
|
24
24
|
width: number;
|
|
25
25
|
height: number;
|
|
26
26
|
complete?: boolean;
|
|
@@ -29,31 +29,34 @@ export interface WechatImage {
|
|
|
29
29
|
onload: (() => void) | null;
|
|
30
30
|
onerror: ((error: unknown) => void) | null;
|
|
31
31
|
}
|
|
32
|
-
export interface
|
|
32
|
+
export interface MiniGameTouch {
|
|
33
33
|
clientX?: number;
|
|
34
34
|
clientY?: number;
|
|
35
35
|
force?: number;
|
|
36
36
|
identifier?: number;
|
|
37
37
|
pageX?: number;
|
|
38
38
|
pageY?: number;
|
|
39
|
+
screenX?: number;
|
|
40
|
+
screenY?: number;
|
|
39
41
|
x?: number;
|
|
40
42
|
y?: number;
|
|
41
43
|
}
|
|
42
|
-
export interface
|
|
43
|
-
changedTouches?:
|
|
44
|
-
touches?:
|
|
44
|
+
export interface MiniGameTouchEvent {
|
|
45
|
+
changedTouches?: MiniGameTouch[];
|
|
46
|
+
touches?: MiniGameTouch[];
|
|
45
47
|
}
|
|
46
|
-
export interface
|
|
47
|
-
createCanvas():
|
|
48
|
-
createImage():
|
|
49
|
-
createOffscreenCanvas?(options
|
|
48
|
+
export interface MiniGameApi {
|
|
49
|
+
createCanvas(): MiniGameCanvas;
|
|
50
|
+
createImage(): MiniGameImage;
|
|
51
|
+
createOffscreenCanvas?(options?: {
|
|
50
52
|
type: '2d' | 'webgl';
|
|
51
53
|
width: number;
|
|
52
54
|
height: number;
|
|
53
|
-
}):
|
|
55
|
+
}): MiniGameCanvas;
|
|
54
56
|
getDeviceInfo?(): Record<string, unknown>;
|
|
55
57
|
getFileSystemManager(): {
|
|
56
58
|
readFile(options: {
|
|
59
|
+
encoding?: string;
|
|
57
60
|
filePath: string;
|
|
58
61
|
fail(error: {
|
|
59
62
|
errMsg: string;
|
|
@@ -72,7 +75,7 @@ export interface WechatMiniGameApi {
|
|
|
72
75
|
}): void;
|
|
73
76
|
success(): void;
|
|
74
77
|
}): {
|
|
75
|
-
onProgressUpdate(callback: (progress: {
|
|
78
|
+
onProgressUpdate?(callback: (progress: {
|
|
76
79
|
progress: number;
|
|
77
80
|
}) => void): void;
|
|
78
81
|
};
|
|
@@ -93,13 +96,13 @@ export interface WechatMiniGameApi {
|
|
|
93
96
|
offHide?(callback: () => void): void;
|
|
94
97
|
onShow(callback: () => void): void;
|
|
95
98
|
offShow?(callback: () => void): void;
|
|
96
|
-
onTouchStart(callback: (event:
|
|
97
|
-
offTouchStart?(callback: (event:
|
|
98
|
-
onTouchMove(callback: (event:
|
|
99
|
-
offTouchMove?(callback: (event:
|
|
100
|
-
onTouchEnd(callback: (event:
|
|
101
|
-
offTouchEnd?(callback: (event:
|
|
102
|
-
onTouchCancel(callback: (event:
|
|
103
|
-
offTouchCancel?(callback: (event:
|
|
99
|
+
onTouchStart(callback: (event: MiniGameTouchEvent) => void): void;
|
|
100
|
+
offTouchStart?(callback: (event: MiniGameTouchEvent) => void): void;
|
|
101
|
+
onTouchMove(callback: (event: MiniGameTouchEvent) => void): void;
|
|
102
|
+
offTouchMove?(callback: (event: MiniGameTouchEvent) => void): void;
|
|
103
|
+
onTouchEnd(callback: (event: MiniGameTouchEvent) => void): void;
|
|
104
|
+
offTouchEnd?(callback: (event: MiniGameTouchEvent) => void): void;
|
|
105
|
+
onTouchCancel(callback: (event: MiniGameTouchEvent) => void): void;
|
|
106
|
+
offTouchCancel?(callback: (event: MiniGameTouchEvent) => void): void;
|
|
104
107
|
}
|
|
105
|
-
export
|
|
108
|
+
export type MiniGameFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/project/index.d.ts
CHANGED
|
@@ -10,33 +10,14 @@ export interface PixifactProjectResolution {
|
|
|
10
10
|
width: number;
|
|
11
11
|
height: number;
|
|
12
12
|
}
|
|
13
|
-
export interface PixifactProjectResourcePack {
|
|
14
|
-
root: string;
|
|
15
|
-
}
|
|
16
|
-
export type PixifactWechatResourcePack = {
|
|
17
|
-
delivery: 'subpackage';
|
|
18
|
-
root: string;
|
|
19
|
-
} | {
|
|
20
|
-
delivery: 'remote';
|
|
21
|
-
baseUrl: string;
|
|
22
|
-
};
|
|
23
|
-
export interface PixifactWechatTargetConfig {
|
|
24
|
-
entry: string;
|
|
25
|
-
configDir: string;
|
|
26
|
-
outDir: string;
|
|
27
|
-
resourcePacks: Record<string, PixifactWechatResourcePack>;
|
|
28
|
-
}
|
|
29
|
-
export interface PixifactProjectTargets {
|
|
30
|
-
wechat?: PixifactWechatTargetConfig;
|
|
31
|
-
}
|
|
32
13
|
export interface PixifactProjectConfig {
|
|
33
|
-
version:
|
|
14
|
+
version: 2;
|
|
34
15
|
name: string;
|
|
35
16
|
resolution: PixifactProjectResolution;
|
|
36
17
|
viewport: PixifactProjectViewport;
|
|
37
18
|
scenes: Record<string, string>;
|
|
38
|
-
resourcePacks?:
|
|
39
|
-
|
|
19
|
+
resourcePacks?: string[];
|
|
20
|
+
remoteResourcePacks?: Record<string, string>;
|
|
40
21
|
run?: PixifactProjectRunConfig;
|
|
41
22
|
}
|
|
42
23
|
export type PixifactProjectViewport = PixifactViewportConfig;
|
|
@@ -45,8 +26,8 @@ export interface PixifactProjectSummary {
|
|
|
45
26
|
resolution: PixifactProjectResolution;
|
|
46
27
|
viewport: PixifactProjectViewport;
|
|
47
28
|
scenes: Record<string, string>;
|
|
48
|
-
resourcePacks?:
|
|
49
|
-
|
|
29
|
+
resourcePacks?: string[];
|
|
30
|
+
remoteResourcePacks?: Record<string, string>;
|
|
50
31
|
run?: PixifactProjectRunConfig;
|
|
51
32
|
}
|
|
52
33
|
export declare const defaultPixifactProjectResolution: PixifactProjectResolution;
|