@vnejs/plugins.save.auto 0.1.2 → 0.1.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/index.js CHANGED
@@ -4,6 +4,6 @@ import { SUBSCRIBE_EVENTS } from "./const/events";
4
4
  import * as params from "./const/params";
5
5
  import { SETTINGS_KEYS } from "./const/settings";
6
6
 
7
- import { Autosave } from "./modules/autosave";
7
+ import { SaveAuto } from "./modules/autosave";
8
8
 
9
- regPlugin("SAVE_AUTO", { events: SUBSCRIBE_EVENTS, params, settings: SETTINGS_KEYS }, [Autosave]);
9
+ regPlugin("SAVE_AUTO", { events: SUBSCRIBE_EVENTS, params, settings: SETTINGS_KEYS }, [SaveAuto]);
@@ -1,6 +1,6 @@
1
1
  import { Module } from "@vnejs/module";
2
2
 
3
- export class Autosave extends Module {
3
+ export class SaveAuto extends Module {
4
4
  name = "save.auto";
5
5
 
6
6
  lastTs = -1;
@@ -12,24 +12,19 @@ export class Autosave extends Module {
12
12
  init = () =>
13
13
  Promise.all([
14
14
  this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.SAVE_AUTO.INTERVAL, value: this.PARAMS.SAVE_AUTO.DEFAULT_INTERVAL }),
15
- this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: "autosave", handler: this.onLineExec }),
15
+ this.emit(this.EVENTS.SCENARIO.LINE_EXEC_REG, { module: this.name, handler: this.onLineExec }),
16
16
  ]);
17
17
 
18
18
  onLineExec = () => this.emit(this.EVENTS.SAVE_AUTO.MAKE);
19
19
 
20
- onMake = async ({ isForce = false } = {}) => {
20
+ onMake = ({ isForce = false } = {}) => {
21
21
  const [ts, autosaveInterval] = [new Date().getTime(), this.shared.settings[this.SETTINGS.SAVE_AUTO.INTERVAL]];
22
22
 
23
23
  if (!isForce) if (this.shared.isFastforwardOn || ts - this.lastTs < autosaveInterval * 1000) return;
24
24
 
25
25
  this.lastTs = ts;
26
-
27
- this.emit(this.EVENTS.LOGS.EMIT, { module: this.name, value: { action: "start", index: this.index } });
28
-
29
26
  this.index = (this.index + 1) % this.PARAMS.SAVE_AUTO.MAX_INDEX;
30
27
 
31
- await this.emit(this.EVENTS.SAVE.CREATE, { key: `auto-${this.index}` });
32
-
33
- this.emit(this.EVENTS.LOGS.EMIT, { module: this.name, value: { action: "end", index: this.index } });
28
+ return this.emit(this.EVENTS.SAVE.CREATE, { key: `auto-${this.index}` });
34
29
  };
35
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.save.auto",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
package/const/const.js DELETED
File without changes