pixifact 0.6.0 → 0.7.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.
Files changed (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -29
  3. package/dist/client.d.ts +23 -0
  4. package/dist/compiler/compileScenes.js +13 -4
  5. package/dist/compiler/typescriptCompiler.js +2 -2
  6. package/dist/compiler-node/vite.d.ts +16 -6
  7. package/dist/compiler-node/vite.js +417 -32
  8. package/dist/errors.d.ts +1 -1
  9. package/dist/errors.js +6 -0
  10. package/dist/platform/{wechat → minigame}/adapter.d.ts +7 -6
  11. package/dist/platform/{wechat → minigame}/adapter.js +10 -8
  12. package/dist/platform/minigame/application.d.ts +4 -0
  13. package/dist/platform/minigame/application.js +53 -0
  14. package/dist/platform/minigame/fetch.d.ts +2 -0
  15. package/dist/platform/{wechat → minigame}/fetch.js +13 -15
  16. package/dist/platform/minigame/index.d.ts +8 -0
  17. package/dist/platform/minigame/index.js +8 -0
  18. package/dist/platform/minigame/input.d.ts +16 -0
  19. package/dist/platform/{wechat → minigame}/input.js +18 -19
  20. package/dist/platform/minigame/lifecycle.d.ts +15 -0
  21. package/dist/platform/{wechat → minigame}/lifecycle.js +5 -7
  22. package/dist/platform/{wechat → minigame}/runtime.d.ts +5 -5
  23. package/dist/platform/{wechat → minigame}/runtime.js +14 -20
  24. package/dist/platform/minigame/subpackage.d.ts +3 -0
  25. package/dist/platform/minigame/subpackage.js +36 -0
  26. package/dist/platform/{wechat → minigame}/types.d.ts +24 -21
  27. package/dist/platform/minigame/types.js +1 -0
  28. package/dist/platform/web/index.d.ts +2 -0
  29. package/dist/platform/web/index.js +6 -0
  30. package/dist/project/index.d.ts +5 -24
  31. package/dist/project/index.js +45 -59
  32. package/dist/scene/index.d.ts +0 -1
  33. package/dist/scene/index.js +0 -1
  34. package/package.json +16 -7
  35. package/dist/platform/wechat/application.d.ts +0 -32
  36. package/dist/platform/wechat/application.js +0 -79
  37. package/dist/platform/wechat/fetch.d.ts +0 -1
  38. package/dist/platform/wechat/index.d.ts +0 -4
  39. package/dist/platform/wechat/index.js +0 -3
  40. package/dist/platform/wechat/input.d.ts +0 -12
  41. package/dist/platform/wechat/lifecycle.d.ts +0 -14
  42. package/dist/platform/wechat/subpackage.d.ts +0 -1
  43. package/dist/platform/wechat/subpackage.js +0 -27
  44. package/dist/platform/wechat/types.js +0 -3
  45. package/dist/scene/sceneAssetRuntime.d.ts +0 -11
  46. package/dist/scene/sceneAssetRuntime.js +0 -43
@@ -1,5 +1,4 @@
1
- import { wechatApi } from './types.js';
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 WechatResourceResponse {
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 WechatResponseHeaders(responseHeaders);
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 WeChat resource adapter.');
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 WechatResourceResponse(body, this.status, this.url);
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 WeChat resource adapter.');
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 fetchWechatResource(input, init = {}) {
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 WeChat resource adapter only supports GET requests, received ${method}.`));
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) => wx.request({
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 WechatResourceResponse(toResponseBody(result.data), result.statusCode, url, result.header)),
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('Data URLs are not supported by the WeChat resource adapter.'));
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) => wx.getFileSystemManager().readFile({
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 WechatResourceResponse(toResponseBody(result.data), 200, url)),
141
+ success: (result) => resolve(new MiniGameResourceResponse(toResponseBody(result.data), 200, url)),
144
142
  }));
145
143
  }
@@ -0,0 +1,8 @@
1
+ export * from './adapter.js';
2
+ export * from './application.js';
3
+ export * from './fetch.js';
4
+ export * from './input.js';
5
+ export * from './lifecycle.js';
6
+ export * from './runtime.js';
7
+ export * from './subpackage.js';
8
+ export * from './types.js';
@@ -0,0 +1,8 @@
1
+ export * from './adapter.js';
2
+ export * from './application.js';
3
+ export * from './fetch.js';
4
+ export * from './input.js';
5
+ export * from './lifecycle.js';
6
+ export * from './runtime.js';
7
+ export * from './subpackage.js';
8
+ export * from './types.js';
@@ -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 { WechatPointerEvent } from './runtime.js';
2
- import { wechatApi } from './types.js';
3
- function pointerState(touch) {
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: touch.clientX ?? touch.x ?? touch.pageX ?? 0,
8
- y: touch.clientY ?? touch.y ?? touch.pageY ?? 0,
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 bindWechatPointerEvents(canvas, sink) {
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 WechatPointerEvent(type, {
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
- wx.onTouchStart(handleStart);
67
- wx.onTouchMove(handleMove);
68
- wx.onTouchEnd(handleEnd);
69
- wx.onTouchCancel(handleCancel);
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
- wx.offTouchStart?.(handleStart);
88
- wx.offTouchMove?.(handleMove);
89
- wx.offTouchEnd?.(handleEnd);
90
- wx.offTouchCancel?.(handleCancel);
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
- import { wechatApi } from './types.js';
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
- wx.onHide(handleHide);
27
- wx.onShow(handleShow);
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
- wx.offHide?.(handleHide);
36
- wx.offShow?.(handleShow);
33
+ api.offHide?.(handleHide);
34
+ api.offShow?.(handleShow);
37
35
  },
38
36
  get hidden() {
39
37
  return hidden;
@@ -1,6 +1,6 @@
1
- import { type WechatCanvas } from './types.js';
2
- export interface WechatRuntime {
3
- canvas: WechatCanvas;
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 WechatPointerEvent {
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 createWechatRuntime(): WechatRuntime;
49
+ export declare function createMiniGameRuntime(api: MiniGameApi, userAgent: string): MiniGameRuntime;
@@ -1,5 +1,4 @@
1
- import { wechatApi } from './types.js';
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 = wx.createOffscreenCanvas?.({ type: '2d', width: 1, height: 1 }) ?? wx.createCanvas();
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: WechatPointerEvent });
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 WeChat Mini Game runtime does not provide WebGL.');
167
+ throw new Error('The current Mini Game runtime does not provide WebGL.');
170
168
  }
171
- export function createWechatRuntime() {
172
- const wx = wechatApi();
173
- const canvas = wx.createCanvas();
169
+ export function createMiniGameRuntime(api, userAgent) {
170
+ const canvas = api.createCanvas();
174
171
  const info = {
175
- ...(wx.getSystemInfoSync?.() ?? {}),
176
- ...(wx.getDeviceInfo?.() ?? {}),
177
- ...(wx.getWindowInfo?.() ?? {}),
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 WechatCanvas {
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 WechatImage {
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 WechatTouch {
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 WechatTouchEvent {
43
- changedTouches?: WechatTouch[];
44
- touches?: WechatTouch[];
44
+ export interface MiniGameTouchEvent {
45
+ changedTouches?: MiniGameTouch[];
46
+ touches?: MiniGameTouch[];
45
47
  }
46
- export interface WechatMiniGameApi {
47
- createCanvas(): WechatCanvas;
48
- createImage(): WechatImage;
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
- }): WechatCanvas;
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: WechatTouchEvent) => void): void;
97
- offTouchStart?(callback: (event: WechatTouchEvent) => void): void;
98
- onTouchMove(callback: (event: WechatTouchEvent) => void): void;
99
- offTouchMove?(callback: (event: WechatTouchEvent) => void): void;
100
- onTouchEnd(callback: (event: WechatTouchEvent) => void): void;
101
- offTouchEnd?(callback: (event: WechatTouchEvent) => void): void;
102
- onTouchCancel(callback: (event: WechatTouchEvent) => void): void;
103
- offTouchCancel?(callback: (event: WechatTouchEvent) => void): void;
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 declare function wechatApi(): WechatMiniGameApi;
108
+ export type MiniGameFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { Application, type ApplicationOptions } from 'pixi.js';
2
+ export declare function createApplication(options?: Partial<ApplicationOptions>): Promise<Application>;
@@ -0,0 +1,6 @@
1
+ import { Application } from 'pixi.js';
2
+ export async function createApplication(options = {}) {
3
+ const app = new Application();
4
+ await app.init(options);
5
+ return app;
6
+ }
@@ -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: 1;
14
+ version: 2;
34
15
  name: string;
35
16
  resolution: PixifactProjectResolution;
36
17
  viewport: PixifactProjectViewport;
37
18
  scenes: Record<string, string>;
38
- resourcePacks?: Record<string, PixifactProjectResourcePack>;
39
- targets?: PixifactProjectTargets;
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?: Record<string, PixifactProjectResourcePack>;
49
- targets?: PixifactProjectTargets;
29
+ resourcePacks?: string[];
30
+ remoteResourcePacks?: Record<string, string>;
50
31
  run?: PixifactProjectRunConfig;
51
32
  }
52
33
  export declare const defaultPixifactProjectResolution: PixifactProjectResolution;