sapdon 3.0.3 → 3.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/README.md +3 -2
- package/dist/cli/build.js +3 -1
- package/dist/cli/dev-server/syncFiles.js +9 -1
- package/dist/cli/index.d.ts +5 -8
- package/dist/cli/index.js +90 -1
- package/dist/cli/start.js +1398 -2
- package/dist/core/addon/controllers/render_controllers.js +162 -0
- package/dist/core/entity/bundles/BasicMoveBundle.js +8 -0
- package/dist/core/entity/bundles/basicBundle.js +0 -7
- package/dist/core/entity/componets/entityComponet.js +7 -0
- package/dist/core/entity/dummyEntity.js +14 -0
- package/dist/core/entity/entity.js +4 -11
- package/dist/core/entity/nativeEntity.js +2 -2
- package/dist/core/factory/entityFactory.js +9 -9
- package/dist/core/index.d.ts +201 -22
- package/dist/core/index.js +1 -1
- package/dist/core/registry.js +1 -0
- package/dist/oc/actor.js +44 -0
- package/dist/oc/core.js +201 -0
- package/dist/oc/index.d.ts +3 -3
- package/dist/oc/index.js +1 -1
- package/dist/oc/input.js +67 -0
- package/dist/oc/optional.js +31 -0
- package/doc/oc/index.md +0 -0
- package/doc/sapdon-ts.md +7 -5
- package/package.json +1 -1
- package/doc/cli.md +0 -24
- /package/doc/hello_sapdon/{sapdon/344/275/277/347/224/250/346/225/231/347/250/213.md" → hello_sapdon.md} +0 -0
package/README.md
CHANGED
package/dist/cli/build.js
CHANGED
|
@@ -17,13 +17,16 @@ export async function syncDevFilesServer(projectPath, projectName) {
|
|
|
17
17
|
}
|
|
18
18
|
export async function writeLib(projectPath) {
|
|
19
19
|
const projectModules = path.join(projectPath, "node_modules");
|
|
20
|
-
const rootDir = path.join(dirname(import.meta), '
|
|
20
|
+
const rootDir = path.join(dirname(import.meta), '../');
|
|
21
21
|
const corePath = path.join(rootDir, 'core');
|
|
22
22
|
const cliPath = path.join(rootDir, 'cli');
|
|
23
|
+
const ocPath = path.join(rootDir, 'oc');
|
|
23
24
|
const targetCorePath = path.join(projectModules, '@sapdon/core');
|
|
24
25
|
const targetCliPath = path.join(projectModules, '@sapdon/cli');
|
|
26
|
+
const targetOcPath = path.join(projectModules, '@sapdon/oc');
|
|
25
27
|
fs.cpSync(corePath, targetCorePath, { recursive: true, force: true });
|
|
26
28
|
fs.cpSync(cliPath, targetCliPath, { recursive: true, force: true });
|
|
29
|
+
fs.cpSync(ocPath, targetOcPath, { recursive: true, force: true });
|
|
27
30
|
fs.writeFileSync(path.join(targetCorePath, 'package.json'), JSON.stringify({
|
|
28
31
|
name: '@sapdon/core',
|
|
29
32
|
main: 'index.js',
|
|
@@ -34,4 +37,9 @@ export async function writeLib(projectPath) {
|
|
|
34
37
|
main: 'index.js',
|
|
35
38
|
version: '1.0.0',
|
|
36
39
|
}));
|
|
40
|
+
fs.writeFileSync(path.join(targetOcPath, 'package.json'), JSON.stringify({
|
|
41
|
+
name: '@sapdon/oc',
|
|
42
|
+
main: 'index.js',
|
|
43
|
+
version: '1.0.0',
|
|
44
|
+
}));
|
|
37
45
|
}
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import http from 'http';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
WRITE_ADDON = "write-addon",
|
|
5
|
-
WRITE_GAME_DEV = "write-dev"
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
type ServerHandler = (...args: Transferable[]) => void;
|
|
3
|
+
type ServerHandler = (...args: (Uint8Array & string)[]) => void | Promise<void>;
|
|
9
4
|
type HandlerInterceptor = (handler: ServerHandler) => ServerHandler;
|
|
10
5
|
declare class DevelopmentServer {
|
|
11
6
|
readonly cliServerHandlers: Map<string, ServerHandler>;
|
|
@@ -18,6 +13,8 @@ declare class DevelopmentServer {
|
|
|
18
13
|
}
|
|
19
14
|
declare const server: DevelopmentServer;
|
|
20
15
|
|
|
21
|
-
declare
|
|
16
|
+
declare namespace client {
|
|
17
|
+
function call(name: any, ...args: any[]): Promise<void>;
|
|
18
|
+
}
|
|
22
19
|
|
|
23
|
-
export {
|
|
20
|
+
export { client, server as devServer };
|
package/dist/cli/index.js
CHANGED
|
@@ -1 +1,90 @@
|
|
|
1
|
-
import
|
|
1
|
+
import http from 'http';
|
|
2
|
+
|
|
3
|
+
const devServerConfig = {
|
|
4
|
+
port: 49037
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
port: port$1
|
|
9
|
+
} = devServerConfig;
|
|
10
|
+
|
|
11
|
+
async function cliRequest(path, ...params) {
|
|
12
|
+
try {
|
|
13
|
+
await fetch(`http://localhost:${port$1}/${path}`, {
|
|
14
|
+
method: 'POST',
|
|
15
|
+
headers: {
|
|
16
|
+
'Content-Type': 'application/json'
|
|
17
|
+
},
|
|
18
|
+
body: JSON.stringify(params)
|
|
19
|
+
});
|
|
20
|
+
} catch (error) {
|
|
21
|
+
console.error(error);
|
|
22
|
+
console.error('尝试在构建脚本中使用 server.startDevServer() 启动开发服务器');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const { port } = devServerConfig;
|
|
27
|
+
class DevelopmentServer {
|
|
28
|
+
cliServerHandlers = new Map();
|
|
29
|
+
listening = false;
|
|
30
|
+
isListening() {
|
|
31
|
+
return this.listening;
|
|
32
|
+
}
|
|
33
|
+
bootstrap() {
|
|
34
|
+
this.listening = true;
|
|
35
|
+
const svr = http.createServer(async (req, res) => {
|
|
36
|
+
const handler = this.cliServerHandlers.get((req.url ?? '/').slice(1));
|
|
37
|
+
if (handler) {
|
|
38
|
+
try {
|
|
39
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
40
|
+
let buf = Buffer.alloc(0);
|
|
41
|
+
req.on('data', chunk => buf = Buffer.concat([buf, chunk]));
|
|
42
|
+
req.on('end', () => {
|
|
43
|
+
try {
|
|
44
|
+
resolve(JSON.parse(buf));
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
reject(error);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
await handler(...await promise);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.error(error);
|
|
54
|
+
res.writeHead(500);
|
|
55
|
+
res.end();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
res.writeHead(200);
|
|
59
|
+
res.end();
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
res.writeHead(404);
|
|
63
|
+
res.end();
|
|
64
|
+
}
|
|
65
|
+
}).listen(port, () => console.log(`Dev Server listening on port ${port}`));
|
|
66
|
+
svr.on('error', () => this.listening = false);
|
|
67
|
+
return svr;
|
|
68
|
+
}
|
|
69
|
+
handle(url, handler) {
|
|
70
|
+
this.cliServerHandlers.set(url, handler);
|
|
71
|
+
}
|
|
72
|
+
getHandler(url) {
|
|
73
|
+
return this.cliServerHandlers.get(url);
|
|
74
|
+
}
|
|
75
|
+
interceptHandler(url, interceptor) {
|
|
76
|
+
const currentHandler = this.getHandler(url) ?? Function.prototype;
|
|
77
|
+
const newHandler = interceptor(currentHandler);
|
|
78
|
+
this.cliServerHandlers.set(url, newHandler);
|
|
79
|
+
return newHandler;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const server = new DevelopmentServer();
|
|
83
|
+
|
|
84
|
+
const client = {
|
|
85
|
+
call: async (name, ...args) => {
|
|
86
|
+
return await cliRequest(name, ...args)
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export { client, server as devServer };
|