@rbxts/replion 1.0.1 → 1.0.3

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 CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  ## Install
4
4
  Install with [wally](https://wally.run/):\
5
- `Replion = "shouxtech/replion@1.0.1"`
5
+ `Replion = "shouxtech/replion@1.0.3"`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/replion",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "main": "src/init.lua",
6
6
  "scripts": {},
package/src/Client.lua CHANGED
@@ -97,7 +97,7 @@ function Client:_applyUpdates(updates: Shared.GenericDataTable)
97
97
  anyChanged = true
98
98
  local signal = self._signals[key];
99
99
  if signal then
100
- signal:Fire(self.data[key], self.data[key]); -- Note: Sends improper 'old' argument due to shallow copy optimization.
100
+ signal:Fire(self.data[key], self.data[key]); -- Warning: Sends improper 'old' argument due to shallow copy optimization.
101
101
  end;
102
102
  elseif self.data[key] ~= oldValue then
103
103
  anyChanged = true;
package/src/Server.lua CHANGED
@@ -55,7 +55,7 @@ type Replion = typeof(setmetatable({}, Server));
55
55
  Server._activeReplions = {} :: { [Player]: { [string]: Replion } };
56
56
  Server._globalReplions = {} :: { [string]: Replion };
57
57
 
58
- -- This method is private because this it isn't able to give correct types for the found Replion, and that's unideal for public use.
58
+ -- Note: This method is private because this it isn't able to give correct types for the found Replion, and that's unideal for public use.
59
59
  function Server._getPlayerReplion(player: Player, channel: string)
60
60
  local playerReplions = Server._activeReplions[player];
61
61
  if not playerReplions then return nil; end;
@@ -63,7 +63,7 @@ function Server._getPlayerReplion(player: Player, channel: string)
63
63
  return playerReplions[channel];
64
64
  end;
65
65
 
66
- -- This method is private because this it isn't able to give correct types for the found Replion, and that's unideal for public use.
66
+ -- Note: This method is private because this it isn't able to give correct types for the found Replion, and that's unideal for public use.
67
67
  function Server._getGlobalReplion(channel: string)
68
68
  return Server._globalReplions[channel];
69
69
  end;
package/src/index.d.ts CHANGED
@@ -1,20 +1,40 @@
1
- interface State<T> {
2
- get(): T;
3
- set(newValue: T): void;
4
- }
1
+ import { Connection } from '@rbxts/sleitnick-signal';
2
+
3
+ declare namespace Replion {
4
+ interface ServerConfig<T extends object> {
5
+ channel: string;
6
+ replicateTo?: Player;
7
+ data: T;
8
+ }
9
+
10
+ class Server<T extends object> {
11
+ constructor(config: ServerConfig<T>);
12
+
13
+ set<K extends keyof T>(key: K, value: T[K] | ((oldValue: T[K]) => T[K])): void;
14
+ set(path: string[], value: any | ((oldValue: any) => any)): void;
15
+
16
+ get(): T;
17
+ get<K extends keyof T>(key: K): T[K];
18
+ get(path: string[]): any;
19
+
20
+ destroy(): void;
21
+ }
22
+
23
+ class Client<T extends object> {
24
+ static waitForReplion<T extends object>(channel: string): Client<T>;
25
+
26
+ get(): T;
27
+ get<K extends keyof T>(key: K): T[K];
28
+ get(path: string[]): any;
29
+
30
+ observe(key: undefined, callback: (newValue: T, oldValue: T | undefined) => void): Connection;
31
+ observe<K extends keyof T>(
32
+ key: K,
33
+ callback: (newValue: T[K], oldValue: T[K] | undefined) => void,
34
+ ): Connection;
5
35
 
6
- declare namespace Observers {
7
- function state<T>(initialValue: T): State<T>;
8
- function state<T>(): State<T | undefined>;
9
-
10
- function observeAttribute<T extends AttributeValue>(instance: Instance, attribute: string, callback: (value: T | undefined) => (() => void) | void): () => void;
11
- function observeState<T>(state: State<T>, callback: (value: T) => void): () => void;
12
- function observePlayers(callback: (player: Player) => (() => void) | void): () => void;
13
- function observeCharacters(callback: (char: Model, player: Player) => (() => void) | void): () => void;
14
- function observeAttribute<T extends AttributeValue>(instance: Instance, attribute: string, callback: (value: T | undefined) => (() => void) | void): () => void;
15
- function observeChildren(instance: Instance, callback: (child: Instance) => (() => void) | void): () => void;
16
- function observeTag<T extends Instance>(tag: string, callback: (instance: T) => (() => void) | void, ancestors?: Instance[]): () => void;
17
- function observeProperty<P extends Instance, K extends InstancePropertyNames<P>>(instance: P, property: K, callback: (value: P[K]) => (() => void) | void): () => void;
36
+ destroy(): void;
37
+ }
18
38
  }
19
39
 
20
- export = Observers;
40
+ export = Replion;