floating-live 0.15.0-beta.4 → 0.15.0-beta.5

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/live.d.ts CHANGED
@@ -2,9 +2,9 @@
2
2
  import { EventEmitter } from "events";
3
3
  import { ModPlugin } from "./module/plugin";
4
4
  import { ModRoom } from "./module/room";
5
- import { ModStore } from "./module/store";
6
- import ModCommand from "./module/command";
7
- import { ModValues } from "./module/values";
5
+ import { ModManifest } from "./module/manifest";
6
+ import { ModCommand } from "./module/command";
7
+ import { ModValue } from "./module/value";
8
8
  import { ModHook } from "./module/hook";
9
9
  import { FloatingEventMap } from "./types/events";
10
10
  import { FloatingCommandMap } from "./types";
@@ -15,10 +15,10 @@ export declare class FloatingLive extends EventEmitter {
15
15
  plugin: ModPlugin;
16
16
  /** 命令模块 */
17
17
  command: ModCommand;
18
- /** 状态模块 */
19
- store: ModStore;
18
+ /** Manifest模块 */
19
+ manifest: ModManifest;
20
20
  /** 数值模块 */
21
- values: ModValues;
21
+ value: ModValue;
22
22
  /** 钩子模块 */
23
23
  hook: ModHook;
24
24
  constructor();
@@ -26,10 +26,10 @@ export declare class FloatingLive extends EventEmitter {
26
26
  on<T extends keyof FloatingEventMap>(eventName: T, listener: FloatingEventMap[T]): this;
27
27
  emit<T extends keyof FloatingEventMap>(eventName: T, ...args: Parameters<FloatingEventMap[T]>): boolean;
28
28
  throw(err: Error): void;
29
- snapshot(): {
29
+ getSnapshot(): {
30
30
  room: import("./types").RoomInfo[];
31
- values: Record<string, any>;
32
- store: Record<string, Record<string, any>>;
31
+ value: Record<string, any>;
32
+ manifest: Record<string, Record<string, any>>;
33
33
  command: string[];
34
34
  };
35
35
  }
package/dist/live.js CHANGED
@@ -1,24 +1,21 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.FloatingLive = void 0;
7
4
  const events_1 = require("events");
8
5
  const plugin_1 = require("./module/plugin");
9
6
  const room_1 = require("./module/room");
10
- const store_1 = require("./module/store");
11
- const command_1 = __importDefault(require("./module/command"));
12
- const values_1 = require("./module/values");
7
+ const manifest_1 = require("./module/manifest");
8
+ const command_1 = require("./module/command");
9
+ const value_1 = require("./module/value");
13
10
  const hook_1 = require("./module/hook");
14
11
  class FloatingLive extends events_1.EventEmitter {
15
12
  constructor() {
16
13
  super();
17
- this.command = new command_1.default(this);
18
- this.store = new store_1.ModStore(this);
14
+ this.command = new command_1.ModCommand(this);
15
+ this.manifest = new manifest_1.ModManifest(this);
19
16
  this.plugin = new plugin_1.ModPlugin(this);
20
17
  this.room = new room_1.ModRoom(this);
21
- this.values = new values_1.ModValues(this);
18
+ this.value = new value_1.ModValue(this);
22
19
  this.hook = new hook_1.ModHook(this);
23
20
  }
24
21
  call(name, ...args) {
@@ -33,12 +30,12 @@ class FloatingLive extends events_1.EventEmitter {
33
30
  throw(err) {
34
31
  this.emit("error", err);
35
32
  }
36
- snapshot() {
33
+ getSnapshot() {
37
34
  return {
38
- room: this.room.snapshot(),
39
- values: this.values.snapshot(),
40
- store: this.store.snapshot(),
41
- command: this.command.snapshot(),
35
+ room: this.room.getSnapshot(),
36
+ value: this.value.getSnapshot(),
37
+ manifest: this.manifest.getSnapshot(),
38
+ command: this.command.getSnapshot(),
42
39
  };
43
40
  }
44
41
  }
@@ -1,6 +1,6 @@
1
1
  import { FloatingLive } from "../live";
2
2
  import { FloatingCommandMap } from "../types";
3
- export default class ModCommand {
3
+ export declare class ModCommand {
4
4
  /** 功能列表 */
5
5
  private readonly list;
6
6
  protected readonly main: FloatingLive;
@@ -12,5 +12,5 @@ export default class ModCommand {
12
12
  /** 调用命令 */
13
13
  call<T extends keyof FloatingCommandMap>(name: T, ...args: Parameters<FloatingCommandMap[T]>): any;
14
14
  /** 获取快照 */
15
- snapshot(): string[];
15
+ getSnapshot(): string[];
16
16
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ModCommand = void 0;
3
4
  class ModCommand {
4
5
  constructor(main) {
5
6
  /** 功能列表 */
@@ -21,8 +22,8 @@ class ModCommand {
21
22
  return this.list.get(name)?.(...args);
22
23
  }
23
24
  /** 获取快照 */
24
- snapshot() {
25
+ getSnapshot() {
25
26
  return [...this.list].map(([key]) => key);
26
27
  }
27
28
  }
28
- exports.default = ModCommand;
29
+ exports.ModCommand = ModCommand;
@@ -0,0 +1,15 @@
1
+ import { FloatingLive } from "../live";
2
+ import { FloatingManifestMap } from "../types/manifest";
3
+ export declare class ModManifest {
4
+ private list;
5
+ protected readonly main: FloatingLive;
6
+ constructor(main: FloatingLive);
7
+ /** 注册manifest */
8
+ register<T extends keyof FloatingManifestMap>(name: T, id: string, value: FloatingManifestMap[T]): void;
9
+ /** 取消注册manifest */
10
+ unregister<T extends keyof FloatingManifestMap>(name: T, id: string): void;
11
+ /** 获取值 */
12
+ get(name: string): Map<string, any> | undefined;
13
+ /** 获取快照 */
14
+ getSnapshot(): Record<string, Record<string, any>>;
15
+ }
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ModStore = void 0;
4
- class ModStore {
3
+ exports.ModManifest = void 0;
4
+ class ModManifest {
5
5
  constructor(main) {
6
6
  this.list = new Map();
7
7
  this.main = main;
8
8
  }
9
- /** 注册store */
9
+ /** 注册manifest */
10
10
  register(name, id, value) {
11
11
  let store = this.list.get(name);
12
12
  if (!store) {
@@ -14,14 +14,14 @@ class ModStore {
14
14
  this.list.set(name, store);
15
15
  }
16
16
  store.set(id, value);
17
- this.main.emit("store:add", name, id, value);
17
+ this.main.emit("manifest:add", name, id, value);
18
18
  }
19
- /** 取消注册store */
19
+ /** 取消注册manifest */
20
20
  unregister(name, id) {
21
21
  let store = this.list.get(name);
22
22
  if (store) {
23
23
  store.delete(id);
24
- this.main.emit("store:remove", name, id);
24
+ this.main.emit("manifest:remove", name, id);
25
25
  }
26
26
  }
27
27
  /** 获取值 */
@@ -29,7 +29,7 @@ class ModStore {
29
29
  return this.list.get(name);
30
30
  }
31
31
  /** 获取快照 */
32
- snapshot() {
32
+ getSnapshot() {
33
33
  const map = {};
34
34
  this.list.forEach((store, name) => {
35
35
  const part = {};
@@ -41,4 +41,4 @@ class ModStore {
41
41
  return map;
42
42
  }
43
43
  }
44
- exports.ModStore = ModStore;
44
+ exports.ModManifest = ModManifest;
@@ -27,5 +27,5 @@ export declare class ModRoom {
27
27
  /** 更改某个房间的顺序 */
28
28
  move(roomKey: string, position: number): void;
29
29
  /** 获取快照 */
30
- snapshot(): RoomInfo[];
30
+ getSnapshot(): RoomInfo[];
31
31
  }
@@ -77,7 +77,7 @@ class ModRoom {
77
77
  if (typeof config == "boolean") {
78
78
  config = { open: config };
79
79
  }
80
- const room = this.main.call(`room.create.${platform}`, id, config);
80
+ const room = this.main.call(`${platform}.room.create`, id, config);
81
81
  room && this.addRoom(room);
82
82
  }
83
83
  /** 移除房间 */
@@ -132,7 +132,7 @@ class ModRoom {
132
132
  this.list = new Map(arr);
133
133
  }
134
134
  /** 获取快照 */
135
- snapshot() {
135
+ getSnapshot() {
136
136
  return [...this.list].map(([key, room]) => room.info);
137
137
  }
138
138
  }
@@ -1,10 +1,10 @@
1
1
  import { FloatingLive } from "../live";
2
- import { FloatingValueMap } from "../types/values";
2
+ import { FloatingValueMap } from "../types/value";
3
3
  interface ValueConfig<T> {
4
4
  get: () => T;
5
5
  set?: (value: T) => void;
6
6
  }
7
- export declare class ModValues {
7
+ export declare class ModValue {
8
8
  private list;
9
9
  protected readonly main: FloatingLive;
10
10
  constructor(main: FloatingLive);
@@ -17,7 +17,7 @@ export declare class ModValues {
17
17
  /** 设置值 */
18
18
  set(name: string, value: any): boolean;
19
19
  /** 获取注册的所有值 */
20
- snapshot(): Record<string, any>;
20
+ getSnapshot(): Record<string, any>;
21
21
  emit<T extends keyof FloatingValueMap>(name: T, value: FloatingValueMap[T]): void;
22
22
  watch<T extends keyof FloatingValueMap>(name: T, listener: (value: FloatingValueMap[T]) => void): void;
23
23
  unwatch<T extends keyof FloatingValueMap>(name: T, listener: (value: FloatingValueMap[T]) => void): void;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ModValues = void 0;
4
- class ModValues {
3
+ exports.ModValue = void 0;
4
+ class ModValue {
5
5
  constructor(main) {
6
6
  this.list = new Map();
7
7
  this.main = main;
@@ -9,10 +9,12 @@ class ModValues {
9
9
  /** 注册值 */
10
10
  register(name, config) {
11
11
  this.list.set(name, config);
12
+ this.main.emit("value:add", name);
12
13
  }
13
14
  /** 取消注册 */
14
15
  unregister(name) {
15
16
  this.list.delete(name);
17
+ this.main.emit("value:remove", name);
16
18
  }
17
19
  /** 获取值 */
18
20
  get(name) {
@@ -30,7 +32,7 @@ class ModValues {
30
32
  }
31
33
  }
32
34
  /** 获取注册的所有值 */
33
- snapshot() {
35
+ getSnapshot() {
34
36
  const map = {};
35
37
  this.list.forEach((config, name) => {
36
38
  map[name] = config.get();
@@ -38,8 +40,8 @@ class ModValues {
38
40
  return map;
39
41
  }
40
42
  emit(name, value) {
41
- this.main.emit("values:change", name, value);
42
43
  this.main.emit(`change:${name}`, value);
44
+ this.main.emit("value:change", name, value);
43
45
  }
44
46
  watch(name, listener) {
45
47
  this.main.on(`change:${name}`, listener);
@@ -48,4 +50,4 @@ class ModValues {
48
50
  this.main.off(`change:${name}`, listener);
49
51
  }
50
52
  }
51
- exports.ModValues = ModValues;
53
+ exports.ModValue = ModValue;
@@ -5,5 +5,5 @@ export interface FloatingCommandMap {
5
5
  open: (key: string) => void;
6
6
  close: (key: string) => void;
7
7
  update: (key: string) => void;
8
- [name: `room.create.${string}`]: (id: string | number, config?: Record<string, any>) => LiveRoom;
8
+ [name: `${string}.room.create`]: (id: string | number, config?: Record<string, any>) => LiveRoom;
9
9
  }
@@ -25,10 +25,11 @@ export interface FloatingEventMap {
25
25
  "plugin:remove": (name: string) => void;
26
26
  "command:add": (name: string) => void;
27
27
  "command:remove": (name: string) => void;
28
- "store:add": (name: string, id: string, value: any) => void;
29
- "store:remove": (name: string, id: string) => void;
30
- "values:register": (name: string) => void;
31
- "values:change": (name: string, value: any) => void;
28
+ "manifest:add": (name: string, id: string, value: any) => void;
29
+ "manifest:remove": (name: string, id: string) => void;
30
+ "value:add": (name: string) => void;
31
+ "value:remove": (name: string) => void;
32
+ "value:change": (name: string, value: any) => void;
32
33
  [name: `change:${string}`]: (value: any) => void;
33
34
  error: (err: Error) => void;
34
35
  }
@@ -3,3 +3,6 @@ export * from "./plugin";
3
3
  export * from "./room";
4
4
  export * from "./command";
5
5
  export * from "./events";
6
+ export * from "./manifest";
7
+ export * from "./hook";
8
+ export * from "./value";
@@ -19,3 +19,6 @@ __exportStar(require("./plugin"), exports);
19
19
  __exportStar(require("./room"), exports);
20
20
  __exportStar(require("./command"), exports);
21
21
  __exportStar(require("./events"), exports);
22
+ __exportStar(require("./manifest"), exports);
23
+ __exportStar(require("./hook"), exports);
24
+ __exportStar(require("./value"), exports);
@@ -1,4 +1,4 @@
1
1
  import { PlatformInfo } from "./room";
2
- export interface FloatingStoreMap {
2
+ export interface FloatingManifestMap {
3
3
  platform: PlatformInfo;
4
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "floating-live",
3
- "version": "0.15.0-beta.4",
3
+ "version": "0.15.0-beta.5",
4
4
  "type": "commonjs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,15 +0,0 @@
1
- import { FloatingLive } from "../live";
2
- import { FloatingStoreMap } from "../types/store";
3
- export declare class ModStore {
4
- private list;
5
- protected readonly main: FloatingLive;
6
- constructor(main: FloatingLive);
7
- /** 注册store */
8
- register<T extends keyof FloatingStoreMap>(name: T, id: string, value: FloatingStoreMap[T]): void;
9
- /** 取消注册store */
10
- unregister<T extends keyof FloatingStoreMap>(name: T, id: string): void;
11
- /** 获取值 */
12
- get(name: string): Map<string, any> | undefined;
13
- /** 获取快照 */
14
- snapshot(): Record<string, Record<string, any>>;
15
- }
File without changes
File without changes
File without changes