@replicast/core 0.1.2 → 1.0.0-rc.10
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/dist/decorators/entity.d.ts +43 -0
- package/dist/decorators/entity.d.ts.map +1 -0
- package/dist/decorators/entity.js +75 -0
- package/dist/decorators/entity.js.map +1 -0
- package/dist/decorators/index.d.ts +2 -0
- package/dist/decorators/index.d.ts.map +1 -1
- package/dist/decorators/index.js +1 -0
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/metadata.d.ts +9 -6
- package/dist/decorators/metadata.d.ts.map +1 -1
- package/dist/decorators/metadata.js +20 -13
- package/dist/decorators/metadata.js.map +1 -1
- package/dist/decorators/store.d.ts +5 -8
- package/dist/decorators/store.d.ts.map +1 -1
- package/dist/decorators/store.js +10 -11
- package/dist/decorators/store.js.map +1 -1
- package/dist/decorators/system.d.ts +7 -10
- package/dist/decorators/system.d.ts.map +1 -1
- package/dist/decorators/system.js +15 -23
- package/dist/decorators/system.js.map +1 -1
- package/dist/entity/base-entity.d.ts +19 -0
- package/dist/entity/base-entity.d.ts.map +1 -0
- package/dist/entity/base-entity.js +18 -0
- package/dist/entity/base-entity.js.map +1 -0
- package/dist/entity/fields.d.ts +21 -0
- package/dist/entity/fields.d.ts.map +1 -0
- package/dist/entity/fields.js +67 -0
- package/dist/entity/fields.js.map +1 -0
- package/dist/entity/registry.d.ts +53 -0
- package/dist/entity/registry.d.ts.map +1 -0
- package/dist/entity/registry.js +167 -0
- package/dist/entity/registry.js.map +1 -0
- package/dist/entity/replicator.d.ts +40 -0
- package/dist/entity/replicator.d.ts.map +1 -0
- package/dist/entity/replicator.js +82 -0
- package/dist/entity/replicator.js.map +1 -0
- package/dist/entity/types.d.ts +29 -0
- package/dist/entity/types.d.ts.map +1 -0
- package/dist/entity/types.js +4 -0
- package/dist/entity/types.js.map +1 -0
- package/dist/entity/visibility.d.ts +11 -0
- package/dist/entity/visibility.d.ts.map +1 -0
- package/dist/entity/visibility.js +10 -0
- package/dist/entity/visibility.js.map +1 -0
- package/dist/entity/world.d.ts +67 -0
- package/dist/entity/world.d.ts.map +1 -0
- package/dist/entity/world.js +183 -0
- package/dist/entity/world.js.map +1 -0
- package/dist/index.d.ts +18 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/lifecycle/types.d.ts +2 -0
- package/dist/lifecycle/types.d.ts.map +1 -1
- package/dist/store/base-store.d.ts +24 -4
- package/dist/store/base-store.d.ts.map +1 -1
- package/dist/store/base-store.js +47 -20
- package/dist/store/base-store.js.map +1 -1
- package/dist/transport/app.d.ts +53 -0
- package/dist/transport/app.d.ts.map +1 -0
- package/dist/transport/app.js +53 -0
- package/dist/transport/app.js.map +1 -0
- package/dist/transport/client.d.ts +14 -1
- package/dist/transport/client.d.ts.map +1 -1
- package/dist/transport/client.js +58 -13
- package/dist/transport/client.js.map +1 -1
- package/dist/transport/codec.d.ts +7 -0
- package/dist/transport/codec.d.ts.map +1 -0
- package/dist/transport/codec.js +14 -0
- package/dist/transport/codec.js.map +1 -0
- package/dist/transport/context-browser.d.ts +6 -0
- package/dist/transport/context-browser.d.ts.map +1 -0
- package/dist/transport/context-browser.js +11 -0
- package/dist/transport/context-browser.js.map +1 -0
- package/dist/transport/context.d.ts +5 -0
- package/dist/transport/context.d.ts.map +1 -0
- package/dist/transport/context.js +9 -0
- package/dist/transport/context.js.map +1 -0
- package/dist/transport/protocol.d.ts +19 -1
- package/dist/transport/protocol.d.ts.map +1 -1
- package/dist/transport/protocol.js.map +1 -1
- package/dist/transport/server.d.ts +24 -1
- package/dist/transport/server.d.ts.map +1 -1
- package/dist/transport/server.js +188 -25
- package/dist/transport/server.js.map +1 -1
- package/dist/transport/ws-browser.d.ts +1 -1
- package/dist/transport/ws-browser.d.ts.map +1 -1
- package/dist/transport/ws-browser.js +1 -0
- package/dist/transport/ws-browser.js.map +1 -1
- package/package.json +10 -4
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { EntityWorldView } from '../entity/types.js';
|
|
2
|
+
/** Client lifecycle / server scheduler hooks an entity method can carry. */
|
|
3
|
+
export type EntityHook = 'serverTick' | 'clientSpawn' | 'clientDespawn';
|
|
4
|
+
/** Who may invoke an entity's `@Server` methods: its owner, anyone, or a custom predicate. */
|
|
5
|
+
export type CanCall<T> = 'owner' | 'anyone' | ((callerId: string, entity: T, world: EntityWorldView) => boolean);
|
|
6
|
+
export interface EntityOptions<T = any> {
|
|
7
|
+
/** Wire name for this type. Defaults to the class name (or the Vite plugin's `__replicastName` stamp). */
|
|
8
|
+
name?: string;
|
|
9
|
+
/** Scopes replication. Return false to hide the entity from that viewer. Default: visible to everyone. */
|
|
10
|
+
visibleTo?: (viewerId: string, entity: T, world: EntityWorldView) => boolean;
|
|
11
|
+
/** Authorisation for `@Server` methods on this entity. Default: `'owner'`. */
|
|
12
|
+
canCall?: CanCall<T>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Registers a class as a replicated entity type. One class per entity type, written once and run on
|
|
16
|
+
* both sides; the field and method decorators below say which parts travel where.
|
|
17
|
+
*/
|
|
18
|
+
export declare function Entity<T extends object = object>(options?: EntityOptions<T>): (_value: abstract new (...args: any[]) => T, context: ClassDecoratorContext) => void;
|
|
19
|
+
/** Replicated to every client that can see the entity; diffed per flush. */
|
|
20
|
+
export declare function Replicated(_value: undefined, context: ClassFieldDecoratorContext): void;
|
|
21
|
+
/** Replicated only to the client identified by `entity.ownerId`. */
|
|
22
|
+
export declare function OwnerReplicated(_value: undefined, context: ClassFieldDecoratorContext): void;
|
|
23
|
+
/**
|
|
24
|
+
* Rounds a numeric field to `step` on the server before diffing, so float noise does not produce
|
|
25
|
+
* updates. A pure modifier: combine with `@Replicated` / `@OwnerReplicated` to actually replicate.
|
|
26
|
+
*/
|
|
27
|
+
export declare function Quantized(step: number): (_value: undefined, context: ClassFieldDecoratorContext) => void;
|
|
28
|
+
/** Runs on the server each sim tick with `dt` (seconds). Absent from the client bundle. */
|
|
29
|
+
export declare function ServerTick(_value: Function, context: ClassMethodDecoratorContext): void;
|
|
30
|
+
/** Runs on the client when the entity enters this viewer's set, after its fields are assigned. */
|
|
31
|
+
export declare function ClientSpawn(_value: Function, context: ClassMethodDecoratorContext): void;
|
|
32
|
+
/** Runs on the client when the entity leaves this viewer's set, before it is dropped. */
|
|
33
|
+
export declare function ClientDespawn(_value: Function, context: ClassMethodDecoratorContext): void;
|
|
34
|
+
export declare function isEntityClass(cls: Function): boolean;
|
|
35
|
+
export declare function getEntityOptions<T = any>(cls: Function): EntityOptions<T> | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Wire name for an entity type. Read lazily so the Vite plugin's `static __replicastName` stamp wins
|
|
38
|
+
* over `cls.name`, which bundlers and minifiers may rename.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getEntityName(cls: Function): string;
|
|
41
|
+
export declare function getQuantizedFields(proto: object): Record<string, number>;
|
|
42
|
+
export declare function getEntityHooks(proto: object): Record<string, EntityHook>;
|
|
43
|
+
//# sourceMappingURL=entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/decorators/entity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAMzD,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,aAAa,GAAG,eAAe,CAAA;AAEvE,8FAA8F;AAC9F,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,OAAO,GAAG,QAAQ,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC,CAAA;AAEhH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,GAAG;IACpC,0GAA0G;IAC1G,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,0GA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AS,CAErF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM,CAInD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAExE;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAExE"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { setPropertyRole } from './metadata.js';
|
|
2
|
+
const entityOptionsKey = Symbol.for('replicast:entityOptions');
|
|
3
|
+
const quantizedFieldsKey = Symbol.for('replicast:quantizedFields');
|
|
4
|
+
const entityHooksKey = Symbol.for('replicast:entityHooks');
|
|
5
|
+
function meta(cls) {
|
|
6
|
+
return cls[Symbol.metadata];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Registers a class as a replicated entity type. One class per entity type, written once and run on
|
|
10
|
+
* both sides; the field and method decorators below say which parts travel where.
|
|
11
|
+
*/
|
|
12
|
+
export function Entity(options = {}) {
|
|
13
|
+
return function (_value, context) {
|
|
14
|
+
;
|
|
15
|
+
context.metadata[entityOptionsKey] = options;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** Replicated to every client that can see the entity; diffed per flush. */
|
|
19
|
+
export function Replicated(_value, context) {
|
|
20
|
+
setPropertyRole(context.metadata, String(context.name), 'replicated');
|
|
21
|
+
}
|
|
22
|
+
/** Replicated only to the client identified by `entity.ownerId`. */
|
|
23
|
+
export function OwnerReplicated(_value, context) {
|
|
24
|
+
setPropertyRole(context.metadata, String(context.name), 'ownerReplicated');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Rounds a numeric field to `step` on the server before diffing, so float noise does not produce
|
|
28
|
+
* updates. A pure modifier: combine with `@Replicated` / `@OwnerReplicated` to actually replicate.
|
|
29
|
+
*/
|
|
30
|
+
export function Quantized(step) {
|
|
31
|
+
return function (_value, context) {
|
|
32
|
+
const m = context.metadata;
|
|
33
|
+
const existing = m[quantizedFieldsKey] ?? {};
|
|
34
|
+
m[quantizedFieldsKey] = { ...existing, [String(context.name)]: step };
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function setHook(context, hook) {
|
|
38
|
+
const m = context.metadata;
|
|
39
|
+
const existing = m[entityHooksKey] ?? {};
|
|
40
|
+
m[entityHooksKey] = { ...existing, [String(context.name)]: hook };
|
|
41
|
+
}
|
|
42
|
+
/** Runs on the server each sim tick with `dt` (seconds). Absent from the client bundle. */
|
|
43
|
+
export function ServerTick(_value, context) {
|
|
44
|
+
setHook(context, 'serverTick');
|
|
45
|
+
}
|
|
46
|
+
/** Runs on the client when the entity enters this viewer's set, after its fields are assigned. */
|
|
47
|
+
export function ClientSpawn(_value, context) {
|
|
48
|
+
setHook(context, 'clientSpawn');
|
|
49
|
+
}
|
|
50
|
+
/** Runs on the client when the entity leaves this viewer's set, before it is dropped. */
|
|
51
|
+
export function ClientDespawn(_value, context) {
|
|
52
|
+
setHook(context, 'clientDespawn');
|
|
53
|
+
}
|
|
54
|
+
export function isEntityClass(cls) {
|
|
55
|
+
return meta(cls)?.[entityOptionsKey] !== undefined;
|
|
56
|
+
}
|
|
57
|
+
export function getEntityOptions(cls) {
|
|
58
|
+
return meta(cls)?.[entityOptionsKey];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Wire name for an entity type. Read lazily so the Vite plugin's `static __replicastName` stamp wins
|
|
62
|
+
* over `cls.name`, which bundlers and minifiers may rename.
|
|
63
|
+
*/
|
|
64
|
+
export function getEntityName(cls) {
|
|
65
|
+
return cls.__replicastName
|
|
66
|
+
?? getEntityOptions(cls)?.name
|
|
67
|
+
?? cls.name;
|
|
68
|
+
}
|
|
69
|
+
export function getQuantizedFields(proto) {
|
|
70
|
+
return meta(proto.constructor)?.[quantizedFieldsKey] ?? {};
|
|
71
|
+
}
|
|
72
|
+
export function getEntityHooks(proto) {
|
|
73
|
+
return meta(proto.constructor)?.[entityHooksKey] ?? {};
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.js","sourceRoot":"","sources":["../../src/decorators/entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAG/C,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAA;AAC9D,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;AAClE,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAA;AAiB1D,SAAS,IAAI,CAAC,GAAa;IACzB,OAAQ,GAAW,CAAC,MAAM,CAAC,QAAQ,CAAwC,CAAA;AAC7E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,MAAM,CAA4B,UAA4B,EAAE;IAC9E,OAAO,UAAU,MAA0C,EAAE,OAA8B;QACzF,CAAC;QAAC,OAAO,CAAC,QAAoC,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAA;IAC5E,CAAC,CAAA;AACH,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,UAAU,CAAC,MAAiB,EAAE,OAAmC;IAC/E,eAAe,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAA;AACvE,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,eAAe,CAAC,MAAiB,EAAE,OAAmC;IACpF,eAAe,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,iBAAiB,CAAC,CAAA;AAC5E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,UAAU,MAAiB,EAAE,OAAmC;QACrE,MAAM,CAAC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CAAC,GAAa;IACzC,OAAQ,GAAoC,CAAC,eAAe;WACvD,gBAAgB,CAAC,GAAG,CAAC,EAAE,IAAI;WAC3B,GAAG,CAAC,IAAI,CAAA;AACf,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,OAAQ,IAAI,CAAE,KAAa,CAAC,WAAW,CAAC,EAAE,CAAC,kBAAkB,CAA4B,IAAI,EAAE,CAAA;AACjG,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAQ,IAAI,CAAE,KAAa,CAAC,WAAW,CAAC,EAAE,CAAC,cAAc,CAAgC,IAAI,EAAE,CAAA;AACjG,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { GlobalStore, OwnerStore, Global, OwnerOnly, ServerOnly } from './store.js';
|
|
2
2
|
export { System, Server, Client, Multicast, isSystemKey, isServerClassKey, isClientClassKey } from './system.js';
|
|
3
|
+
export { Entity, Replicated, OwnerReplicated, Quantized, ServerTick, ClientSpawn, ClientDespawn, isEntityClass, getEntityName, getEntityOptions, getEntityHooks, getQuantizedFields, } from './entity.js';
|
|
4
|
+
export type { EntityOptions, EntityHook, CanCall } from './entity.js';
|
|
3
5
|
export { getStoreType, getPropertyRoles, getMethodRoles } from './metadata.js';
|
|
4
6
|
export type { StoreType, PropertyRole, MethodRole } from './metadata.js';
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAChH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9E,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAChH,OAAO,EACL,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EACtF,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,GACnF,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9E,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/decorators/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { GlobalStore, OwnerStore, Global, OwnerOnly, ServerOnly } from './store.js';
|
|
2
2
|
export { System, Server, Client, Multicast, isSystemKey, isServerClassKey, isClientClassKey } from './system.js';
|
|
3
|
+
export { Entity, Replicated, OwnerReplicated, Quantized, ServerTick, ClientSpawn, ClientDespawn, isEntityClass, getEntityName, getEntityOptions, getEntityHooks, getQuantizedFields, } from './entity.js';
|
|
3
4
|
export { getStoreType, getPropertyRoles, getMethodRoles } from './metadata.js';
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAChH,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAChH,OAAO,EACL,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EACtF,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,GACnF,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
1
|
export declare const storeTypeKey: unique symbol;
|
|
3
2
|
export declare const propertyRolesKey: unique symbol;
|
|
4
3
|
export declare const methodRolesKey: unique symbol;
|
|
5
4
|
export type StoreType = 'global' | 'owner';
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Where a decorated field is allowed to travel. `global` / `ownerOnly` are store roles;
|
|
7
|
+
* `replicated` / `ownerReplicated` are the entity equivalents. `serverOnly` is shared by both.
|
|
8
|
+
*/
|
|
9
|
+
export type PropertyRole = 'global' | 'ownerOnly' | 'serverOnly' | 'replicated' | 'ownerReplicated';
|
|
7
10
|
export type MethodRole = 'server' | 'client' | 'multicast';
|
|
8
|
-
export declare function getStoreType(
|
|
9
|
-
export declare function setStoreType(
|
|
11
|
+
export declare function getStoreType(cls: Function): StoreType | undefined;
|
|
12
|
+
export declare function setStoreType(metadata: DecoratorMetadata, type: StoreType): void;
|
|
10
13
|
export declare function getPropertyRoles(proto: object): Record<string, PropertyRole>;
|
|
11
|
-
export declare function setPropertyRole(
|
|
14
|
+
export declare function setPropertyRole(metadata: DecoratorMetadata, key: string, role: PropertyRole): void;
|
|
12
15
|
export declare function getMethodRoles(proto: object): Record<string, MethodRole>;
|
|
13
|
-
export declare function setMethodRole(
|
|
16
|
+
export declare function setMethodRole(metadata: DecoratorMetadata, key: string, role: MethodRole): void;
|
|
14
17
|
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/decorators/metadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../src/decorators/metadata.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,eAAgC,CAAA;AACzD,eAAO,MAAM,gBAAgB,eAAoC,CAAA;AACjE,eAAO,MAAM,cAAc,eAAkC,CAAA;AAE7D,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;AAC1C;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,WAAW,GAAG,YAAY,GAAG,YAAY,GAAG,iBAAiB,CAAA;AACnG,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAA;AAE1D,wBAAgB,YAAY,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAGjE;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI,CAE/E;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAG5E;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CAIlG;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAGxE;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAI9F"}
|
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
// Symbol.metadata polyfill for Node < 22
|
|
2
|
+
;
|
|
3
|
+
Symbol.metadata ??= Symbol('Symbol.metadata');
|
|
2
4
|
export const storeTypeKey = Symbol('replicast:storeType');
|
|
3
5
|
export const propertyRolesKey = Symbol('replicast:propertyRoles');
|
|
4
6
|
export const methodRolesKey = Symbol('replicast:methodRoles');
|
|
5
|
-
export function getStoreType(
|
|
6
|
-
|
|
7
|
+
export function getStoreType(cls) {
|
|
8
|
+
const meta = cls[Symbol.metadata];
|
|
9
|
+
return meta?.[storeTypeKey];
|
|
7
10
|
}
|
|
8
|
-
export function setStoreType(
|
|
9
|
-
|
|
11
|
+
export function setStoreType(metadata, type) {
|
|
12
|
+
metadata[storeTypeKey] = type;
|
|
10
13
|
}
|
|
11
14
|
export function getPropertyRoles(proto) {
|
|
12
|
-
|
|
15
|
+
const meta = proto.constructor[Symbol.metadata];
|
|
16
|
+
return meta?.[propertyRolesKey] ?? {};
|
|
13
17
|
}
|
|
14
|
-
export function setPropertyRole(
|
|
15
|
-
const
|
|
16
|
-
|
|
18
|
+
export function setPropertyRole(metadata, key, role) {
|
|
19
|
+
const m = metadata;
|
|
20
|
+
const existing = m[propertyRolesKey] ?? {};
|
|
21
|
+
m[propertyRolesKey] = { ...existing, [key]: role };
|
|
17
22
|
}
|
|
18
23
|
export function getMethodRoles(proto) {
|
|
19
|
-
|
|
24
|
+
const meta = proto.constructor[Symbol.metadata];
|
|
25
|
+
return meta?.[methodRolesKey] ?? {};
|
|
20
26
|
}
|
|
21
|
-
export function setMethodRole(
|
|
22
|
-
const
|
|
23
|
-
|
|
27
|
+
export function setMethodRole(metadata, key, role) {
|
|
28
|
+
const m = metadata;
|
|
29
|
+
const existing = m[methodRolesKey] ?? {};
|
|
30
|
+
m[methodRolesKey] = { ...existing, [key]: role };
|
|
24
31
|
}
|
|
25
32
|
//# sourceMappingURL=metadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/decorators/metadata.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/decorators/metadata.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,CAAC;AAAC,MAAc,CAAC,QAAQ,KAAK,MAAM,CAAC,iBAAiB,CAAC,CAAA;AAEvD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAA;AACzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAA;AACjE,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAA;AAU7D,MAAM,UAAU,YAAY,CAAC,GAAa;IACxC,MAAM,IAAI,GAAI,GAAW,CAAC,MAAM,CAAC,QAAQ,CAA+C,CAAA;IACxF,OAAO,IAAI,EAAE,CAAC,YAAY,CAA0B,CAAA;AACtD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,QAA2B,EAAE,IAAe;IACtE,QAAoC,CAAC,YAAY,CAAC,GAAG,IAAI,CAAA;AAC5D,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,MAAM,IAAI,GAAI,KAAa,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAA+C,CAAA;IACtG,OAAQ,IAAI,EAAE,CAAC,gBAAgB,CAAkC,IAAI,EAAE,CAAA;AACzE,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,QAA2B,EAAE,GAAW,EAAE,IAAkB;IAC1F,MAAM,CAAC,GAAG,QAAmC,CAAA;IAC7C,MAAM,QAAQ,GAAI,CAAC,CAAC,gBAAgB,CAAkC,IAAI,EAAE,CAAA;IAC5E,CAAC,CAAC,gBAAgB,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAA;AACpD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,MAAM,IAAI,GAAI,KAAa,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAA+C,CAAA;IACtG,OAAQ,IAAI,EAAE,CAAC,cAAc,CAAgC,IAAI,EAAE,CAAA;AACrE,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,QAA2B,EAAE,GAAW,EAAE,IAAgB;IACtF,MAAM,CAAC,GAAG,QAAmC,CAAA;IAC7C,MAAM,QAAQ,GAAI,CAAC,CAAC,cAAc,CAAgC,IAAI,EAAE,CAAA;IACxE,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAA;AAClD,CAAC"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function OwnerOnly(target: object, propertyKey: string): void;
|
|
7
|
-
export declare function ServerOnly(target: object, propertyKey: string): void;
|
|
8
|
-
export {};
|
|
1
|
+
export declare function GlobalStore(value: abstract new (...args: any[]) => object, context: ClassDecoratorContext): void;
|
|
2
|
+
export declare function OwnerStore(value: abstract new (...args: any[]) => object, context: ClassDecoratorContext): void;
|
|
3
|
+
export declare function Global(value: undefined, context: ClassFieldDecoratorContext): void;
|
|
4
|
+
export declare function OwnerOnly(value: undefined, context: ClassFieldDecoratorContext): void;
|
|
5
|
+
export declare function ServerOnly(value: undefined, context: ClassFieldDecoratorContext): void;
|
|
9
6
|
//# sourceMappingURL=store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/decorators/store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/decorators/store.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CACzB,KAAK,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,EAC9C,OAAO,EAAE,qBAAqB,GAC7B,IAAI,CAEN;AAED,wBAAgB,UAAU,CACxB,KAAK,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,EAC9C,OAAO,EAAE,qBAAqB,GAC7B,IAAI,CAEN;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,0BAA0B,GAAG,IAAI,CAElF;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,0BAA0B,GAAG,IAAI,CAErF;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,0BAA0B,GAAG,IAAI,CAEtF"}
|
package/dist/decorators/store.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
1
|
import { setStoreType, setPropertyRole } from './metadata.js';
|
|
3
|
-
export function GlobalStore(
|
|
4
|
-
setStoreType(
|
|
2
|
+
export function GlobalStore(value, context) {
|
|
3
|
+
setStoreType(context.metadata, 'global');
|
|
5
4
|
}
|
|
6
|
-
export function OwnerStore(
|
|
7
|
-
setStoreType(
|
|
5
|
+
export function OwnerStore(value, context) {
|
|
6
|
+
setStoreType(context.metadata, 'owner');
|
|
8
7
|
}
|
|
9
|
-
export function Global(
|
|
10
|
-
setPropertyRole(
|
|
8
|
+
export function Global(value, context) {
|
|
9
|
+
setPropertyRole(context.metadata, String(context.name), 'global');
|
|
11
10
|
}
|
|
12
|
-
export function OwnerOnly(
|
|
13
|
-
setPropertyRole(
|
|
11
|
+
export function OwnerOnly(value, context) {
|
|
12
|
+
setPropertyRole(context.metadata, String(context.name), 'ownerOnly');
|
|
14
13
|
}
|
|
15
|
-
export function ServerOnly(
|
|
16
|
-
setPropertyRole(
|
|
14
|
+
export function ServerOnly(value, context) {
|
|
15
|
+
setPropertyRole(context.metadata, String(context.name), 'serverOnly');
|
|
17
16
|
}
|
|
18
17
|
//# sourceMappingURL=store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/decorators/store.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/decorators/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE7D,MAAM,UAAU,WAAW,CACzB,KAA8C,EAC9C,OAA8B;IAE9B,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;AAC1C,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,KAA8C,EAC9C,OAA8B;IAE9B,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;AACzC,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,KAAgB,EAAE,OAAmC;IAC1E,eAAe,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAA;AACnE,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAgB,EAAE,OAAmC;IAC7E,eAAe,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,CAAA;AACtE,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAgB,EAAE,OAAmC;IAC9E,eAAe,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAA;AACvE,CAAC"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
declare const
|
|
3
|
-
declare const
|
|
4
|
-
declare
|
|
5
|
-
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function Client(target: object | AnyConstructor, propertyKey?: string): void;
|
|
9
|
-
export declare function Multicast(target: object, propertyKey: string): void;
|
|
10
|
-
export { isSystemKey, isServerClassKey, isClientClassKey };
|
|
1
|
+
export declare const isSystemKey: unique symbol;
|
|
2
|
+
export declare const isServerClassKey: unique symbol;
|
|
3
|
+
export declare const isClientClassKey: unique symbol;
|
|
4
|
+
export declare function System(value: Function, context: ClassDecoratorContext): void;
|
|
5
|
+
export declare function Server(value: Function, context: ClassDecoratorContext | ClassMethodDecoratorContext): void;
|
|
6
|
+
export declare function Client(value: Function, context: ClassDecoratorContext | ClassMethodDecoratorContext): void;
|
|
7
|
+
export declare function Multicast(value: Function, context: ClassMethodDecoratorContext): void;
|
|
11
8
|
//# sourceMappingURL=system.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/decorators/system.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/decorators/system.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,eAAmC,CAAA;AAC3D,eAAO,MAAM,gBAAgB,eAAwC,CAAA;AACrE,eAAO,MAAM,gBAAgB,eAAwC,CAAA;AAErE,wBAAgB,MAAM,CACpB,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,qBAAqB,GAC7B,IAAI,CAEN;AAED,wBAAgB,MAAM,CACpB,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,qBAAqB,GAAG,2BAA2B,GAC3D,IAAI,CAMN;AAED,wBAAgB,MAAM,CACpB,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,qBAAqB,GAAG,2BAA2B,GAC3D,IAAI,CAMN;AAED,wBAAgB,SAAS,CACvB,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,2BAA2B,GACnC,IAAI,CAEN"}
|
|
@@ -1,35 +1,27 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
1
|
import { setMethodRole } from './metadata.js';
|
|
3
|
-
const isSystemKey = Symbol.for('replicast:isSystem');
|
|
4
|
-
const isServerClassKey = Symbol.for('replicast:isServerClass');
|
|
5
|
-
const isClientClassKey = Symbol.for('replicast:isClientClass');
|
|
6
|
-
export function System(
|
|
7
|
-
|
|
2
|
+
export const isSystemKey = Symbol.for('replicast:isSystem');
|
|
3
|
+
export const isServerClassKey = Symbol.for('replicast:isServerClass');
|
|
4
|
+
export const isClientClassKey = Symbol.for('replicast:isClientClass');
|
|
5
|
+
export function System(value, context) {
|
|
6
|
+
context.metadata[isSystemKey] = true;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (propertyKey === undefined) {
|
|
13
|
-
// Class decorator
|
|
14
|
-
Reflect.defineMetadata(isServerClassKey, true, target);
|
|
8
|
+
export function Server(value, context) {
|
|
9
|
+
if (context.kind === 'class') {
|
|
10
|
+
context.metadata[isServerClassKey] = true;
|
|
15
11
|
}
|
|
16
12
|
else {
|
|
17
|
-
|
|
18
|
-
setMethodRole(target, propertyKey, 'server');
|
|
13
|
+
setMethodRole(context.metadata, String(context.name), 'server');
|
|
19
14
|
}
|
|
20
15
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (propertyKey === undefined) {
|
|
25
|
-
Reflect.defineMetadata(isClientClassKey, true, target);
|
|
16
|
+
export function Client(value, context) {
|
|
17
|
+
if (context.kind === 'class') {
|
|
18
|
+
context.metadata[isClientClassKey] = true;
|
|
26
19
|
}
|
|
27
20
|
else {
|
|
28
|
-
setMethodRole(
|
|
21
|
+
setMethodRole(context.metadata, String(context.name), 'client');
|
|
29
22
|
}
|
|
30
23
|
}
|
|
31
|
-
export function Multicast(
|
|
32
|
-
setMethodRole(
|
|
24
|
+
export function Multicast(value, context) {
|
|
25
|
+
setMethodRole(context.metadata, String(context.name), 'multicast');
|
|
33
26
|
}
|
|
34
|
-
export { isSystemKey, isServerClassKey, isClientClassKey };
|
|
35
27
|
//# sourceMappingURL=system.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../src/decorators/system.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../src/decorators/system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE7C,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AAC3D,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAA;AACrE,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAA;AAErE,MAAM,UAAU,MAAM,CACpB,KAAe,EACf,OAA8B;IAE7B,OAAO,CAAC,QAAoC,CAAC,WAAW,CAAC,GAAG,IAAI,CAAA;AACnE,CAAC;AAED,MAAM,UAAU,MAAM,CACpB,KAAe,EACf,OAA4D;IAE5D,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,OAAO,CAAC,QAAoC,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAA;IACxE,CAAC;SAAM,CAAC;QACN,aAAa,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAA;IACjE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,MAAM,CACpB,KAAe,EACf,OAA4D;IAE5D,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,OAAO,CAAC,QAAoC,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAA;IACxE,CAAC;SAAM,CAAC;QACN,aAAa,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAA;IACjE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,SAAS,CACvB,KAAe,EACf,OAAoC;IAEpC,aAAa,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,CAAA;AACpE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { EntityId } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Optional base for `@Entity` classes. The runtime assigns these on spawn (server) and on enter
|
|
4
|
+
* (client), so extending is not required — it just makes them visible to TypeScript.
|
|
5
|
+
*
|
|
6
|
+
* Entity constructors must take no arguments: the client mirror creates the instance first and
|
|
7
|
+
* assigns replicated fields afterwards.
|
|
8
|
+
*/
|
|
9
|
+
export declare class BaseEntity {
|
|
10
|
+
/** Server-assigned id. 0 until the entity is spawned. */
|
|
11
|
+
id: EntityId;
|
|
12
|
+
/** The player this entity belongs to, or null. Replicated to every viewer. */
|
|
13
|
+
ownerId: string | null;
|
|
14
|
+
/** True in the server runtime, false on a client mirror. */
|
|
15
|
+
isServer: boolean;
|
|
16
|
+
/** True on the server; on a client, true only for entities this client owns. */
|
|
17
|
+
hasAuthority: boolean;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=base-entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-entity.d.ts","sourceRoot":"","sources":["../../src/entity/base-entity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C;;;;;;GAMG;AACH,qBAAa,UAAU;IACrB,yDAAyD;IACzD,EAAE,EAAE,QAAQ,CAAI;IAChB,8EAA8E;IAC9E,OAAO,EAAE,MAAM,GAAG,IAAI,CAAO;IAC7B,4DAA4D;IAC5D,QAAQ,EAAE,OAAO,CAAQ;IACzB,gFAAgF;IAChF,YAAY,EAAE,OAAO,CAAQ;CAC9B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional base for `@Entity` classes. The runtime assigns these on spawn (server) and on enter
|
|
3
|
+
* (client), so extending is not required — it just makes them visible to TypeScript.
|
|
4
|
+
*
|
|
5
|
+
* Entity constructors must take no arguments: the client mirror creates the instance first and
|
|
6
|
+
* assigns replicated fields afterwards.
|
|
7
|
+
*/
|
|
8
|
+
export class BaseEntity {
|
|
9
|
+
/** Server-assigned id. 0 until the entity is spawned. */
|
|
10
|
+
id = 0;
|
|
11
|
+
/** The player this entity belongs to, or null. Replicated to every viewer. */
|
|
12
|
+
ownerId = null;
|
|
13
|
+
/** True in the server runtime, false on a client mirror. */
|
|
14
|
+
isServer = false;
|
|
15
|
+
/** True on the server; on a client, true only for entities this client owns. */
|
|
16
|
+
hasAuthority = false;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=base-entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-entity.js","sourceRoot":"","sources":["../../src/entity/base-entity.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,OAAO,UAAU;IACrB,yDAAyD;IACzD,EAAE,GAAa,CAAC,CAAA;IAChB,8EAA8E;IAC9E,OAAO,GAAkB,IAAI,CAAA;IAC7B,4DAA4D;IAC5D,QAAQ,GAAY,KAAK,CAAA;IACzB,gFAAgF;IAChF,YAAY,GAAY,KAAK,CAAA;CAC9B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { EntityConstructor } from './types.js';
|
|
2
|
+
/** Which fields of an entity type travel to whom, and how they are rounded first. */
|
|
3
|
+
export interface FieldPlan {
|
|
4
|
+
replicated: string[];
|
|
5
|
+
ownerReplicated: string[];
|
|
6
|
+
quantized: Record<string, number>;
|
|
7
|
+
}
|
|
8
|
+
/** `ownerId` is a replicated built-in: `@OwnerReplicated` fields and `@Client` calls key off it. */
|
|
9
|
+
export declare const ownerIdField = "ownerId";
|
|
10
|
+
/** Derives the field plan for an entity type. Pure — callers cache it per registered type. */
|
|
11
|
+
export declare function fieldPlanOf(Type: EntityConstructor<object> | Function): FieldPlan;
|
|
12
|
+
/** Rounds a numeric value to `step` so float noise does not produce updates. */
|
|
13
|
+
export declare function quantize(value: unknown, step: number | undefined): unknown;
|
|
14
|
+
/**
|
|
15
|
+
* The replicated field set of one entity as one viewer should see it. `isOwner` adds the
|
|
16
|
+
* `@OwnerReplicated` fields.
|
|
17
|
+
*/
|
|
18
|
+
export declare function snapshotFields(entity: object, plan: FieldPlan, isOwner: boolean): Record<string, unknown>;
|
|
19
|
+
/** Keys of `next` whose value changed since `prev`, plus keys that disappeared (as `undefined`). */
|
|
20
|
+
export declare function diffFields(prev: Record<string, unknown>, next: Record<string, unknown>): Record<string, unknown>;
|
|
21
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/entity/fields.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD,qFAAqF;AACrF,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAClC;AAED,oGAAoG;AACpG,eAAO,MAAM,YAAY,YAAY,CAAA;AAErC,8FAA8F;AAC9F,wBAAgB,WAAW,CAAC,IAAI,EAAE,iBAAiB,CAAC,MAAM,CAAC,GAAG,QAAQ,GAAG,SAAS,CAUjF;AAED,gFAAgF;AAChF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAG1E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzG;AAgBD,oGAAoG;AACpG,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CASzB"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { getPropertyRoles } from '../decorators/metadata.js';
|
|
2
|
+
import { getQuantizedFields } from '../decorators/entity.js';
|
|
3
|
+
/** `ownerId` is a replicated built-in: `@OwnerReplicated` fields and `@Client` calls key off it. */
|
|
4
|
+
export const ownerIdField = 'ownerId';
|
|
5
|
+
/** Derives the field plan for an entity type. Pure — callers cache it per registered type. */
|
|
6
|
+
export function fieldPlanOf(Type) {
|
|
7
|
+
const proto = Type.prototype;
|
|
8
|
+
const roles = getPropertyRoles(proto);
|
|
9
|
+
const replicated = [];
|
|
10
|
+
const ownerReplicated = [];
|
|
11
|
+
for (const [key, role] of Object.entries(roles)) {
|
|
12
|
+
if (role === 'replicated')
|
|
13
|
+
replicated.push(key);
|
|
14
|
+
else if (role === 'ownerReplicated')
|
|
15
|
+
ownerReplicated.push(key);
|
|
16
|
+
}
|
|
17
|
+
return { replicated, ownerReplicated, quantized: getQuantizedFields(proto) };
|
|
18
|
+
}
|
|
19
|
+
/** Rounds a numeric value to `step` so float noise does not produce updates. */
|
|
20
|
+
export function quantize(value, step) {
|
|
21
|
+
if (step === undefined || step <= 0 || typeof value !== 'number' || !Number.isFinite(value))
|
|
22
|
+
return value;
|
|
23
|
+
return Math.round(value / step) * step;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The replicated field set of one entity as one viewer should see it. `isOwner` adds the
|
|
27
|
+
* `@OwnerReplicated` fields.
|
|
28
|
+
*/
|
|
29
|
+
export function snapshotFields(entity, plan, isOwner) {
|
|
30
|
+
const source = entity;
|
|
31
|
+
const out = { [ownerIdField]: source[ownerIdField] ?? null };
|
|
32
|
+
for (const key of plan.replicated)
|
|
33
|
+
out[key] = quantize(source[key], plan.quantized[key]);
|
|
34
|
+
if (isOwner) {
|
|
35
|
+
for (const key of plan.ownerReplicated)
|
|
36
|
+
out[key] = quantize(source[key], plan.quantized[key]);
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
/** Shallow value equality: primitives by Object.is, arrays and plain objects one level deep. */
|
|
41
|
+
function valuesEqual(a, b) {
|
|
42
|
+
if (Object.is(a, b))
|
|
43
|
+
return true;
|
|
44
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
45
|
+
return a.length === b.length && a.every((v, i) => Object.is(v, b[i]));
|
|
46
|
+
}
|
|
47
|
+
if (typeof a === 'object' && typeof b === 'object' && a !== null && b !== null) {
|
|
48
|
+
const ka = Object.keys(a), kb = Object.keys(b);
|
|
49
|
+
return ka.length === kb.length
|
|
50
|
+
&& ka.every(k => Object.is(a[k], b[k]));
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
/** Keys of `next` whose value changed since `prev`, plus keys that disappeared (as `undefined`). */
|
|
55
|
+
export function diffFields(prev, next) {
|
|
56
|
+
const patch = {};
|
|
57
|
+
for (const [key, value] of Object.entries(next)) {
|
|
58
|
+
if (!valuesEqual(prev[key], value))
|
|
59
|
+
patch[key] = value;
|
|
60
|
+
}
|
|
61
|
+
for (const key of Object.keys(prev)) {
|
|
62
|
+
if (!(key in next))
|
|
63
|
+
patch[key] = undefined;
|
|
64
|
+
}
|
|
65
|
+
return patch;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../src/entity/fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAU5D,oGAAoG;AACpG,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAA;AAErC,8FAA8F;AAC9F,MAAM,UAAU,WAAW,CAAC,IAA0C;IACpE,MAAM,KAAK,GAAI,IAA8B,CAAC,SAAS,CAAA;IACvD,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACrC,MAAM,UAAU,GAAa,EAAE,CAAA;IAC/B,MAAM,eAAe,GAAa,EAAE,CAAA;IACpC,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChD,IAAI,IAAI,KAAK,YAAY;YAAE,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;aAC1C,IAAI,IAAI,KAAK,iBAAiB;YAAE,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAChE,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAA;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AAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { EntityConstructor, EntityId, EntitySync } from './types.js';
|
|
2
|
+
/** The slice of the transport a mirrored entity needs for its `@Server` calls. */
|
|
3
|
+
export interface EntityCaller {
|
|
4
|
+
callEntity(id: EntityId, method: string, args: unknown[]): Promise<unknown> | void;
|
|
5
|
+
}
|
|
6
|
+
export interface ClientEntityRegistryOptions {
|
|
7
|
+
types: EntityConstructor<object>[];
|
|
8
|
+
/** Reads the local playerId lazily — it is only known after the connection is authenticated. */
|
|
9
|
+
getPlayerId: () => string | null;
|
|
10
|
+
client?: EntityCaller;
|
|
11
|
+
}
|
|
12
|
+
type Listener<T extends object = object> = (entity: T) => void;
|
|
13
|
+
/**
|
|
14
|
+
* The client's mirror of the entities it can currently see. Creates the same class on `enter`,
|
|
15
|
+
* applies `update` patches in place, and calls `@ClientSpawn` / `@ClientDespawn` as entities join
|
|
16
|
+
* and leave this viewer's set.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ClientEntityRegistry {
|
|
19
|
+
private options;
|
|
20
|
+
private entities;
|
|
21
|
+
private infoByName;
|
|
22
|
+
private infoByCtor;
|
|
23
|
+
private spawnListeners;
|
|
24
|
+
private despawnListeners;
|
|
25
|
+
private subscribers;
|
|
26
|
+
private byTypeCache;
|
|
27
|
+
/** Per-type version, bumped only for types actually touched by a sync — keeps an update to one
|
|
28
|
+
* type from invalidating every other type's `byType()` cache (and its `useEntities()` callers). */
|
|
29
|
+
private typeVersions;
|
|
30
|
+
private version;
|
|
31
|
+
constructor(options: ClientEntityRegistryOptions);
|
|
32
|
+
get(id: EntityId): object | undefined;
|
|
33
|
+
all(): object[];
|
|
34
|
+
/** Entities of one type. The array is referentially stable until that type's entities change. */
|
|
35
|
+
byType<T extends object>(Type: EntityConstructor<T>): T[];
|
|
36
|
+
private touchType;
|
|
37
|
+
private hasAuthorityFor;
|
|
38
|
+
/** Called when an entity of `Type` enters this viewer's set, after its fields are assigned. */
|
|
39
|
+
onSpawn<T extends object>(Type: EntityConstructor<T>, listener: Listener<T>): () => void;
|
|
40
|
+
/** Called when an entity of `Type` leaves this viewer's set, before it is dropped. */
|
|
41
|
+
onDespawn<T extends object>(Type: EntityConstructor<T>, listener: Listener<T>): () => void;
|
|
42
|
+
/** Fires once per applied sync, after the whole batch is in place. For game loops and React. */
|
|
43
|
+
subscribe(listener: () => void): () => void;
|
|
44
|
+
/** Applies one `{ enter, update, leave }` delta from the server. */
|
|
45
|
+
applySync(sync: EntitySync): void;
|
|
46
|
+
/** Dispatches a server-pushed `@Client` / `@Multicast` call onto the mirrored entity. */
|
|
47
|
+
applyRpc(id: EntityId, method: string, args: unknown[]): void;
|
|
48
|
+
/** Despawns every mirror — used when the connection drops so a reconnect starts clean. */
|
|
49
|
+
clear(): void;
|
|
50
|
+
private remove;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=registry.d.ts.map
|