[common] 还原对 2.3.0 版本模板的错误修改,增加 2.4.0 模板

This commit is contained in:
SmallMain 2024-11-22 16:57:07 +08:00
parent 5a03a9dc86
commit 2a337098e4
No known key found for this signature in database
5 changed files with 106 additions and 5 deletions

View File

@ -74,8 +74,3 @@ declare var CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL: number;
* Worker HTTP
*/
declare var CC_WORKER_HTTP_REQUEST: boolean;
/**
* Worker WebSocket
*/
declare var CC_WORKER_WEBSOCKET: boolean;

View File

@ -0,0 +1,81 @@
declare namespace worker {
export const createInnerAudioContext: any;
export const connectSocket: any;
export function createSharedArrayBuffer(size: number): WXSharedArrayBuffer;
export const downloadFile: any;
export const env: { USER_DATA_PATH: string };
export const getFileSystemManager: any;
export const onMessage: any;
export const postMessage: any;
export const request: any;
export const uploadFile: any;
export interface WXSharedArrayBuffer {
buffer: SharedArrayBuffer;
}
}
declare module "ipc-worker.js" {
/**
*
*
* -
*/
export const inited: boolean;
/**
* 访线
*/
export const main: any;
/**
* 线访
*
*
*/
export function registerHandler(name: string, handler: object): void;
}
/**
* Worker
*/
declare var CC_CUSTOM_WORKER: boolean;
/**
* Worker
*/
declare var CC_WORKER_SCHEDULER: boolean;
/**
* Worker
*/
declare var CC_WORKER_DEBUG: boolean;
/**
* Worker 使 API
*/
declare var CC_WORKER_FS_SYNC: boolean;
/**
* Worker 线
*/
declare var CC_WORKER_ASSET_PIPELINE: boolean;
/**
* Worker
*/
declare var CC_WORKER_AUDIO_SYSTEM: boolean;
/**
* Worker
*/
declare var CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL: number;
/**
* Worker HTTP
*/
declare var CC_WORKER_HTTP_REQUEST: boolean;
/**
* Worker WebSocket
*/
declare var CC_WORKER_WEBSOCKET: boolean;

View File

@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ES5",
"skipLibCheck": true,
"downlevelIteration": true,
"allowSyntheticDefaultImports": true,
},
"include": [
"src",
"creator-worker.d.ts"
],
}

View File

@ -0,0 +1,3 @@
// 该文件会在 Worker 初始化时执行,可在这里初始化或者引用其它脚本
// This file will be executed when the Worker is initialized, either initialize it here or require another script.
require("math.js");

View File

@ -0,0 +1,9 @@
const { registerHandler } = require("ipc-worker.js");
export function add(x, y, callback) {
callback(x + y);
}
registerHandler("math", {
add,
});