@momo2555/koppeliajs 0.0.117 → 0.0.119

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.
@@ -0,0 +1,29 @@
1
+ <script lang="ts">
2
+ export let text: String;
3
+ export let callback: () => void;
4
+
5
+ </script>
6
+
7
+ <div class="button" on:click={callback}>
8
+ <p class="luciole">
9
+ {text}
10
+ </p>
11
+ </div>
12
+
13
+ <style>
14
+ .button {
15
+ background-color: #245bec;
16
+ display: flex;
17
+ padding: 15px;
18
+ border-radius: 28px;
19
+ margin: 10px;
20
+ z-index: 1;
21
+ }
22
+
23
+ .button p {
24
+ color: white;
25
+ margin: auto;
26
+ padding: 0;
27
+ font-size: 22px;
28
+ }
29
+ </style>
@@ -0,0 +1,21 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: Props & {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const Button: $$__sveltets_2_IsomorphicComponent<{
15
+ text: String;
16
+ callback: () => void;
17
+ }, {
18
+ [evt: string]: CustomEvent<any>;
19
+ }, {}, {}, string>;
20
+ type Button = InstanceType<typeof Button>;
21
+ export default Button;
@@ -0,0 +1,25 @@
1
+ <script lang="ts">
2
+ import { routeType } from '../stores/routeStore.js';
3
+ import { Koppelia } from '../scripts/koppelia.js';
4
+
5
+ export let id: string = '';
6
+
7
+ $: fontSize = 10;
8
+
9
+ let koppelia = Koppelia.instance;
10
+
11
+ koppelia.onReady(async () => {
12
+ await koppelia.registerNewResizableText(id, fontSize, (newFontSize: number) => {
13
+ fontSize = newFontSize;
14
+ });
15
+ });
16
+
17
+ </script>
18
+
19
+ <div class="resizable-text" id="resizable-text-{id}" style="font-size: {fontSize}px;">
20
+ <slot />
21
+ </div>
22
+
23
+ <style>
24
+
25
+ </style>
@@ -1,21 +1,8 @@
1
- export default ResizableText;
2
- type ResizableText = SvelteComponent<{
3
- [x: string]: never;
4
- }, {
5
- [evt: string]: CustomEvent<any>;
6
- }, {}> & {
7
- $$bindings?: string | undefined;
8
- };
9
- declare const ResizableText: $$__sveltets_2_IsomorphicComponent<{
10
- [x: string]: never;
11
- }, {
12
- [evt: string]: CustomEvent<any>;
13
- }, {}, {}, string>;
14
1
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
15
- new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
16
3
  $$bindings?: Bindings;
17
4
  } & Exports;
18
- (internal: unknown, props: {
5
+ (internal: unknown, props: Props & {
19
6
  $$events?: Events;
20
7
  $$slots?: Slots;
21
8
  }): Exports & {
@@ -24,3 +11,19 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
24
11
  };
25
12
  z_$$bindings?: Bindings;
26
13
  }
14
+ type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
15
+ default: any;
16
+ } ? Props extends Record<string, never> ? any : {
17
+ children?: any;
18
+ } : {});
19
+ declare const ResizableText: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
20
+ id?: string;
21
+ }, {
22
+ default: {};
23
+ }>, {
24
+ [evt: string]: CustomEvent<any>;
25
+ }, {
26
+ default: {};
27
+ }, {}, string>;
28
+ type ResizableText = InstanceType<typeof ResizableText>;
29
+ export default ResizableText;
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import "./styles/fonts.css";
2
2
  import KBase from "./components/KBase.svelte";
3
3
  import GrowableElement from "./components/GrowableElement.svelte";
4
+ import Button from "./components/Button.svelte";
4
5
  import { Koppelia } from "./scripts/koppelia.js";
5
6
  import { Console } from "./scripts/console.js";
6
7
  import { Message } from "./scripts/message.js";
7
8
  import { Device } from "./scripts/device.js";
8
9
  import { Play } from "./scripts/play.js";
9
10
  import { updateRoute, routeType } from './stores/routeStore.js';
10
- import { gameState } from "./stores/stateStore.js";
11
- export { KBase };
12
- export { updateRoute, routeType, Koppelia, Console, Message, Device, gameState, Play, GrowableElement };
11
+ export { KBase, GrowableElement, Button };
12
+ export { updateRoute, routeType, Koppelia, Console, Message, Device, Play };
package/dist/index.js CHANGED
@@ -2,12 +2,12 @@
2
2
  import "./styles/fonts.css";
3
3
  import KBase from "./components/KBase.svelte";
4
4
  import GrowableElement from "./components/GrowableElement.svelte";
5
+ import Button from "./components/Button.svelte";
5
6
  import { Koppelia } from "./scripts/koppelia.js";
6
7
  import { Console } from "./scripts/console.js";
7
8
  import { Message } from "./scripts/message.js";
8
9
  import { Device } from "./scripts/device.js";
9
10
  import { Play } from "./scripts/play.js";
10
11
  import { updateRoute, routeType } from './stores/routeStore.js';
11
- import { gameState } from "./stores/stateStore.js";
12
- export { KBase }; // Compoenents
13
- export { updateRoute, routeType, Koppelia, Console, Message, Device, gameState, Play, GrowableElement }; // libraries and stores
12
+ export { KBase, GrowableElement, Button }; // Compoenents
13
+ export { updateRoute, routeType, Koppelia, Console, Message, Device, Play }; // libraries and stores
@@ -57,7 +57,7 @@ export declare class Koppelia {
57
57
  */
58
58
  getCurrentPlay(): Promise<Play>;
59
59
  /**
60
- * This function enables the difficulty cursor, to change the difficulty in live when playing from Koppeli'App
60
+ * This function enables the difficulty cursor, to change the difficulty live when playing from Koppeli'App
61
61
  * @param callback : callback to call when difficulty changes
62
62
  */
63
63
  enableDifficultyCursor(callback: (difficulty: number) => void): Promise<void>;
@@ -73,4 +73,8 @@ export declare class Koppelia {
73
73
  * @param grown
74
74
  */
75
75
  updateGrowableElement(id: string, grown: boolean): Promise<void>;
76
+ /**
77
+ *
78
+ */
79
+ registerNewResizableText(id: string, defaultSize: number, onTextResized: (newSize: number) => void): Promise<void>;
76
80
  }
@@ -157,7 +157,7 @@ export class Koppelia {
157
157
  });
158
158
  }
159
159
  /**
160
- * This function enables the difficulty cursor, to change the difficulty in live when playing from Koppeli'App
160
+ * This function enables the difficulty cursor, to change the difficulty live when playing from Koppeli'App
161
161
  * @param callback : callback to call when difficulty changes
162
162
  */
163
163
  async enableDifficultyCursor(callback) {
@@ -211,4 +211,32 @@ export class Koppelia {
211
211
  });
212
212
  });
213
213
  }
214
+ /**
215
+ *
216
+ */
217
+ async registerNewResizableText(id, defaultSize, onTextResized) {
218
+ return new Promise((resolve, reject) => {
219
+ if (get(routeType) == "controller") {
220
+ let addGrowableElRequest = new Message();
221
+ addGrowableElRequest.setRequest("addResizableText");
222
+ addGrowableElRequest.addParam("id", id);
223
+ addGrowableElRequest.addParam("defaultSize", defaultSize);
224
+ addGrowableElRequest.setDestination(PeerType.MASTER, "");
225
+ // send the message to the console (only the controller sends the )
226
+ this._console.sendMessage(addGrowableElRequest, (response) => {
227
+ });
228
+ }
229
+ this._console.onRequest((req, params) => {
230
+ if (req == "resizableTextNotification") {
231
+ if (params.id !== undefined && params.id == id) {
232
+ let fontSize = defaultSize;
233
+ if (params.fontSize != undefined)
234
+ fontSize = params.fontSize;
235
+ onTextResized(fontSize);
236
+ }
237
+ }
238
+ });
239
+ resolve();
240
+ });
241
+ }
214
242
  }
@@ -34,8 +34,7 @@ export class State {
34
34
  * @param newState
35
35
  */
36
36
  setState(newState, force = false) {
37
- this._forceState = force;
38
- console.log("force from setstate = ", force);
37
+ this._forceState = force; // if force to true -> force the state to be sent entirely instead of sending an update
39
38
  this._globalState.set(newState);
40
39
  }
41
40
  /**
@@ -87,7 +86,6 @@ export class State {
87
86
  req.setRequest("changeState");
88
87
  req.addParam("state", update);
89
88
  req.addParam("update", !this._forceState);
90
- console.log("force from subscriber = ", this._forceState);
91
89
  this._forceState = false;
92
90
  this._console.sendMessage(req);
93
91
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo2555/koppeliajs",
3
- "version": "0.0.117",
3
+ "version": "0.0.119",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",