@momo2555/koppeliajs 0.0.91
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 +110 -0
- package/dist/components/DynamicCursor.svelte +0 -0
- package/dist/components/DynamicCursor.svelte.d.ts +26 -0
- package/dist/components/DynamicTextField.svelte +0 -0
- package/dist/components/DynamicTextField.svelte.d.ts +26 -0
- package/dist/components/GrowableElement.svelte +62 -0
- package/dist/components/GrowableElement.svelte.d.ts +29 -0
- package/dist/components/KBase.svelte +8 -0
- package/dist/components/KBase.svelte.d.ts +22 -0
- package/dist/components/KButton.svelte +0 -0
- package/dist/components/KButton.svelte.d.ts +26 -0
- package/dist/components/Koppelia.svelte +11 -0
- package/dist/components/Koppelia.svelte.d.ts +20 -0
- package/dist/components/ResizableText.svelte +0 -0
- package/dist/components/ResizableText.svelte.d.ts +26 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +12 -0
- package/dist/scripts/console.d.ts +75 -0
- package/dist/scripts/console.js +180 -0
- package/dist/scripts/device.d.ts +49 -0
- package/dist/scripts/device.js +123 -0
- package/dist/scripts/game.d.ts +5 -0
- package/dist/scripts/game.js +8 -0
- package/dist/scripts/koppelia.d.ts +70 -0
- package/dist/scripts/koppelia.js +196 -0
- package/dist/scripts/koppeliaWebsocket.d.ts +77 -0
- package/dist/scripts/koppeliaWebsocket.js +159 -0
- package/dist/scripts/message.d.ts +116 -0
- package/dist/scripts/message.js +178 -0
- package/dist/scripts/play.d.ts +49 -0
- package/dist/scripts/play.js +107 -0
- package/dist/scripts/stage.d.ts +12 -0
- package/dist/scripts/stage.js +38 -0
- package/dist/scripts/state.d.ts +36 -0
- package/dist/scripts/state.js +82 -0
- package/dist/scripts/utils.d.ts +1 -0
- package/dist/scripts/utils.js +5 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +2 -0
- package/dist/server/koppeliaServerApi.d.ts +7 -0
- package/dist/server/koppeliaServerApi.js +97 -0
- package/dist/stores/routeStore.d.ts +2 -0
- package/dist/stores/routeStore.js +21 -0
- package/dist/stores/stateStore.d.ts +1 -0
- package/dist/stores/stateStore.js +7 -0
- package/package.json +64 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import express from 'express';
|
|
4
|
+
import bodyParser from 'body-parser';
|
|
5
|
+
const app = express();
|
|
6
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
7
|
+
app.use(bodyParser.json());
|
|
8
|
+
export class KoppeliaServerApi {
|
|
9
|
+
path;
|
|
10
|
+
constructor(path) {
|
|
11
|
+
this.path = path;
|
|
12
|
+
}
|
|
13
|
+
run() {
|
|
14
|
+
this.serveApi();
|
|
15
|
+
app.listen(2227);
|
|
16
|
+
}
|
|
17
|
+
getContentType(file) {
|
|
18
|
+
let contentType = "";
|
|
19
|
+
let ext = path.extname(file).substring(1);
|
|
20
|
+
console.log(ext);
|
|
21
|
+
switch (ext) {
|
|
22
|
+
case 'html':
|
|
23
|
+
contentType = "text/html";
|
|
24
|
+
break;
|
|
25
|
+
case 'css':
|
|
26
|
+
contentType = "text/css";
|
|
27
|
+
break;
|
|
28
|
+
case 'js':
|
|
29
|
+
contentType = "text/javascript; charset=utf-8";
|
|
30
|
+
break;
|
|
31
|
+
case 'png':
|
|
32
|
+
case 'jpeg':
|
|
33
|
+
case 'bmp':
|
|
34
|
+
case 'gif':
|
|
35
|
+
case 'webp':
|
|
36
|
+
case 'jpg':
|
|
37
|
+
contentType = "image/" + ext;
|
|
38
|
+
break;
|
|
39
|
+
case 'mp3':
|
|
40
|
+
case 'midi':
|
|
41
|
+
case 'mpeg':
|
|
42
|
+
case 'webm':
|
|
43
|
+
case 'ogg':
|
|
44
|
+
case 'wav':
|
|
45
|
+
contentType = "audio/" + ext;
|
|
46
|
+
break;
|
|
47
|
+
case 'pdf':
|
|
48
|
+
case 'xml':
|
|
49
|
+
case "json":
|
|
50
|
+
contentType = "application/" + ext;
|
|
51
|
+
}
|
|
52
|
+
console.log(file + "; " + contentType);
|
|
53
|
+
return contentType;
|
|
54
|
+
}
|
|
55
|
+
serveApi() {
|
|
56
|
+
// Get the game ID
|
|
57
|
+
app.get('/game/api/gameid', (req, res) => {
|
|
58
|
+
res.json({
|
|
59
|
+
gameId: process.env.GAME_ID,
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
// Get a play data
|
|
63
|
+
app.get('/game/api/playdata/:playid/:playfile', (req, res) => {
|
|
64
|
+
// get the game folder
|
|
65
|
+
// get the plays folder by play id
|
|
66
|
+
let error = "";
|
|
67
|
+
let gameId = process.env.GAME_ID;
|
|
68
|
+
let playId = req.params.playid;
|
|
69
|
+
let playFile = req.params.playfile;
|
|
70
|
+
let playsPath = "/koppelia/games/" + gameId + "/plays";
|
|
71
|
+
if (!fs.existsSync(playsPath)) {
|
|
72
|
+
fs.mkdirSync(playsPath, { recursive: true });
|
|
73
|
+
}
|
|
74
|
+
// check if the play exist:
|
|
75
|
+
let playPath = playsPath + "/" + playId;
|
|
76
|
+
if (fs.existsSync(playPath)) {
|
|
77
|
+
// the play exist and it is downloaded
|
|
78
|
+
// find the play file requested :
|
|
79
|
+
let filePath = playPath + "/" + playFile;
|
|
80
|
+
if (fs.existsSync(playPath)) {
|
|
81
|
+
res.setHeader("Content-Type", this.getContentType(filePath));
|
|
82
|
+
res.writeHead(200);
|
|
83
|
+
fs.readFile(filePath, (err, data) => {
|
|
84
|
+
res.end(data);
|
|
85
|
+
});
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
error = "Cannot found the file " + playFile + " in the play with id " + playId;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
error = "The play is not downloaded (play not found)";
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/lib/routeStore.js (dans la librairie)
|
|
2
|
+
import { writable, get } from 'svelte/store';
|
|
3
|
+
import { page } from '$app/stores';
|
|
4
|
+
// Crée un store pour la route active
|
|
5
|
+
export const routeType = writable('');
|
|
6
|
+
// Cette fonction met à jour le store en fonction de la route
|
|
7
|
+
export function updateRoute() {
|
|
8
|
+
const path = get(page).url.pathname;
|
|
9
|
+
console.log("updateRoue with path = ", path);
|
|
10
|
+
if (path.includes('controller')) {
|
|
11
|
+
routeType.set('controller');
|
|
12
|
+
console.log(path, "CONTROLLER");
|
|
13
|
+
}
|
|
14
|
+
else if (path.includes('monitor')) {
|
|
15
|
+
routeType.set('monitor');
|
|
16
|
+
console.log(path, "MONITOR");
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
routeType.set('');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const gameState: import("svelte/store").Writable<{}>;
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@momo2555/koppeliajs",
|
|
3
|
+
"version": "0.0.91",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"dev": "vite dev",
|
|
6
|
+
"build": "vite build && npm run package",
|
|
7
|
+
"preview": "vite preview",
|
|
8
|
+
"package": "svelte-kit sync && svelte-package && publint",
|
|
9
|
+
"prepublishOnly": "npm run package",
|
|
10
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
11
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
12
|
+
"format": "prettier --write .",
|
|
13
|
+
"lint": "prettier --check . && eslint ."
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"!dist/**/*.test.*",
|
|
18
|
+
"!dist/**/*.spec.*"
|
|
19
|
+
],
|
|
20
|
+
"sideEffects": [
|
|
21
|
+
"**/*.css"
|
|
22
|
+
],
|
|
23
|
+
"svelte": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"svelte": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./server": {
|
|
32
|
+
"types": "./dist/server/index.d.ts",
|
|
33
|
+
"svelte": "./dist/server/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"svelte": "^5.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@eslint/compat": "^1.2.3",
|
|
41
|
+
"@sveltejs/adapter-auto": "^3.0.0",
|
|
42
|
+
"@sveltejs/kit": "^2.9.0",
|
|
43
|
+
"@sveltejs/package": "^2.0.0",
|
|
44
|
+
"@sveltejs/vite-plugin-svelte": "^5.0.0",
|
|
45
|
+
"@types/express": "^5.0.0",
|
|
46
|
+
"@types/node": "^22.10.2",
|
|
47
|
+
"eslint": "^9.7.0",
|
|
48
|
+
"eslint-config-prettier": "^9.1.0",
|
|
49
|
+
"eslint-plugin-svelte": "^2.36.0",
|
|
50
|
+
"globals": "^15.0.0",
|
|
51
|
+
"prettier": "^3.3.2",
|
|
52
|
+
"prettier-plugin-svelte": "^3.2.6",
|
|
53
|
+
"publint": "^0.2.0",
|
|
54
|
+
"svelte": "^5.0.0",
|
|
55
|
+
"svelte-check": "^4.0.0",
|
|
56
|
+
"typescript": "^5.0.0",
|
|
57
|
+
"typescript-eslint": "^8.0.0",
|
|
58
|
+
"vite": "^6.0.0"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"express": "^4.21.2",
|
|
62
|
+
"fs": "^0.0.1-security"
|
|
63
|
+
}
|
|
64
|
+
}
|