mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2024-12-26 03:38:29 +00:00
[common] 还原对 2.3.0 版本模板的错误修改,增加 2.4.0 模板
This commit is contained in:
parent
5a03a9dc86
commit
2a337098e4
@ -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;
|
||||
|
81
extension/templates/2.4.13/2.4.0/worker/creator-worker.d.ts
vendored
Normal file
81
extension/templates/2.4.13/2.4.0/worker/creator-worker.d.ts
vendored
Normal 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;
|
13
extension/templates/2.4.13/2.4.0/worker/jsconfig.json
Normal file
13
extension/templates/2.4.13/2.4.0/worker/jsconfig.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "ES5",
|
||||
"skipLibCheck": true,
|
||||
"downlevelIteration": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
},
|
||||
"include": [
|
||||
"src",
|
||||
"creator-worker.d.ts"
|
||||
],
|
||||
}
|
3
extension/templates/2.4.13/2.4.0/worker/src/index.js
Normal file
3
extension/templates/2.4.13/2.4.0/worker/src/index.js
Normal 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");
|
9
extension/templates/2.4.13/2.4.0/worker/src/math.js
Normal file
9
extension/templates/2.4.13/2.4.0/worker/src/math.js
Normal file
@ -0,0 +1,9 @@
|
||||
const { registerHandler } = require("ipc-worker.js");
|
||||
|
||||
export function add(x, y, callback) {
|
||||
callback(x + y);
|
||||
}
|
||||
|
||||
registerHandler("math", {
|
||||
add,
|
||||
});
|
Loading…
Reference in New Issue
Block a user