@vnejs/compatibility.canvas.layer-with-save 0.1.7
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/index.d.ts +11 -0
- package/dist/index.js +26 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.js +1 -0
- package/package.json +41 -0
- package/src/index.ts +34 -0
- package/src/types.ts +11 -0
- package/tsconfig.json +6 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "@vnejs/contracts.canvas.layer";
|
|
2
|
+
import "@vnejs/contracts.save";
|
|
3
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
4
|
+
import type { SettingsChangedResult } from "@vnejs/module.core";
|
|
5
|
+
import type { PluginConstants, PluginEvents, PluginParams, PluginSettings } from "./types.js";
|
|
6
|
+
export declare class CompatibilitySaveLayer extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
|
|
7
|
+
name: string;
|
|
8
|
+
subscribe: () => void;
|
|
9
|
+
onSettingChange: ({ name, value }: SettingsChangedResult) => void;
|
|
10
|
+
syncFromSettings: () => void;
|
|
11
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import "@vnejs/contracts.canvas.layer";
|
|
2
|
+
import "@vnejs/contracts.save";
|
|
3
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
4
|
+
import { regModule } from "@vnejs/shared";
|
|
5
|
+
export class CompatibilitySaveLayer extends ModuleCore {
|
|
6
|
+
name = "compatibility.canvas.layer-with-save";
|
|
7
|
+
subscribe = () => {
|
|
8
|
+
this.on(this.EVENTS.SETTINGS.CHANGED, this.onSettingChange);
|
|
9
|
+
this.on(this.EVENTS.SYSTEM.STARTED, this.syncFromSettings);
|
|
10
|
+
};
|
|
11
|
+
onSettingChange = ({ name, value }) => {
|
|
12
|
+
if (name === this.SETTINGS.LAYER.WIDTH && typeof value === "number")
|
|
13
|
+
this.PARAMS.SAVE.SCREENSHOT_WIDTH = value / 2;
|
|
14
|
+
if (name === this.SETTINGS.LAYER.HEIGHT && typeof value === "number")
|
|
15
|
+
this.PARAMS.SAVE.SCREENSHOT_HEIGHT = value / 2;
|
|
16
|
+
};
|
|
17
|
+
syncFromSettings = () => {
|
|
18
|
+
const width = this.shared.settings[this.SETTINGS.LAYER.WIDTH];
|
|
19
|
+
const height = this.shared.settings[this.SETTINGS.LAYER.HEIGHT];
|
|
20
|
+
if (typeof width === "number")
|
|
21
|
+
this.PARAMS.SAVE.SCREENSHOT_WIDTH = width / 2;
|
|
22
|
+
if (typeof height === "number")
|
|
23
|
+
this.PARAMS.SAVE.SCREENSHOT_HEIGHT = height / 2;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
regModule(CompatibilitySaveLayer);
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
|
|
2
|
+
import type { SettingsKeys as LayerSettingsKeys, PluginName as LayerPluginName, SubscribeEvents as LayerSubscribeEvents } from "@vnejs/contracts.canvas.layer";
|
|
3
|
+
import type { Params as SaveParams, PluginName as SavePluginName } from "@vnejs/contracts.save";
|
|
4
|
+
export type PluginEvents = ModuleCoreEvents & Record<LayerPluginName, LayerSubscribeEvents>;
|
|
5
|
+
export type PluginConstants = ModuleCoreConstants;
|
|
6
|
+
export type PluginSettings = ModuleCoreSettings & Record<LayerPluginName, LayerSettingsKeys>;
|
|
7
|
+
export type PluginParams = ModuleCoreParams & Record<SavePluginName, SaveParams>;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vnejs/compatibility.canvas.layer-with-save",
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src",
|
|
18
|
+
"tsconfig.json"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
22
|
+
"build": "npx @vnejs/monorepo package",
|
|
23
|
+
"publish:major:plugin": "npm run publish:major",
|
|
24
|
+
"publish:minor:plugin": "npm run publish:minor",
|
|
25
|
+
"publish:patch:plugin": "npm run publish:patch",
|
|
26
|
+
"publish:major": "npx @vnejs/monorepo publish major --access public",
|
|
27
|
+
"publish:minor": "npx @vnejs/monorepo publish minor --access public",
|
|
28
|
+
"publish:patch": "npx @vnejs/monorepo publish patch --access public"
|
|
29
|
+
},
|
|
30
|
+
"author": "",
|
|
31
|
+
"license": "ISC",
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@vnejs/module.core": "~0.1.0",
|
|
34
|
+
"@vnejs/contracts.canvas.layer": "~0.1.0",
|
|
35
|
+
"@vnejs/contracts.save": "~0.1.0",
|
|
36
|
+
"@vnejs/shared": "~0.1.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@vnejs/configs.ts-common": "~0.1.0"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import "@vnejs/contracts.canvas.layer";
|
|
2
|
+
import "@vnejs/contracts.save";
|
|
3
|
+
|
|
4
|
+
import { ModuleCore } from "@vnejs/module.core";
|
|
5
|
+
import { regModule } from "@vnejs/shared";
|
|
6
|
+
|
|
7
|
+
import type { SettingsChangedResult } from "@vnejs/module.core";
|
|
8
|
+
|
|
9
|
+
import type { PluginConstants, PluginEvents, PluginParams, PluginSettings } from "./types.js";
|
|
10
|
+
|
|
11
|
+
export class CompatibilitySaveLayer extends ModuleCore<PluginEvents, PluginConstants, PluginSettings, PluginParams> {
|
|
12
|
+
name = "compatibility.canvas.layer-with-save";
|
|
13
|
+
|
|
14
|
+
subscribe = () => {
|
|
15
|
+
this.on(this.EVENTS.SETTINGS.CHANGED, this.onSettingChange);
|
|
16
|
+
|
|
17
|
+
this.on(this.EVENTS.SYSTEM.STARTED, this.syncFromSettings);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
onSettingChange = ({ name, value }: SettingsChangedResult) => {
|
|
21
|
+
if (name === this.SETTINGS.LAYER.WIDTH && typeof value === "number") this.PARAMS.SAVE.SCREENSHOT_WIDTH = value / 2;
|
|
22
|
+
if (name === this.SETTINGS.LAYER.HEIGHT && typeof value === "number") this.PARAMS.SAVE.SCREENSHOT_HEIGHT = value / 2;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
syncFromSettings = () => {
|
|
26
|
+
const width = this.shared.settings[this.SETTINGS.LAYER.WIDTH];
|
|
27
|
+
const height = this.shared.settings[this.SETTINGS.LAYER.HEIGHT];
|
|
28
|
+
|
|
29
|
+
if (typeof width === "number") this.PARAMS.SAVE.SCREENSHOT_WIDTH = width / 2;
|
|
30
|
+
if (typeof height === "number") this.PARAMS.SAVE.SCREENSHOT_HEIGHT = height / 2;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
regModule(CompatibilitySaveLayer);
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ModuleCoreConstants, ModuleCoreEvents, ModuleCoreParams, ModuleCoreSettings } from "@vnejs/module.core";
|
|
2
|
+
import type { SettingsKeys as LayerSettingsKeys, PluginName as LayerPluginName, SubscribeEvents as LayerSubscribeEvents } from "@vnejs/contracts.canvas.layer";
|
|
3
|
+
import type { Params as SaveParams, PluginName as SavePluginName } from "@vnejs/contracts.save";
|
|
4
|
+
|
|
5
|
+
export type PluginEvents = ModuleCoreEvents & Record<LayerPluginName, LayerSubscribeEvents>;
|
|
6
|
+
|
|
7
|
+
export type PluginConstants = ModuleCoreConstants;
|
|
8
|
+
|
|
9
|
+
export type PluginSettings = ModuleCoreSettings & Record<LayerPluginName, LayerSettingsKeys>;
|
|
10
|
+
|
|
11
|
+
export type PluginParams = ModuleCoreParams & Record<SavePluginName, SaveParams>;
|