@vnejs/plugins.settings.potato 0.1.5 → 0.1.6
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 +1 -0
- package/dist/index.js +4 -0
- package/dist/modules/potato.d.ts +12 -0
- package/dist/modules/potato.js +32 -0
- package/dist/types.d.ts +11 -0
- package/dist/types.js +4 -0
- package/dist/utils/settings.d.ts +4 -0
- package/dist/utils/settings.js +1 -0
- package/package.json +35 -6
- package/src/index.ts +6 -0
- package/{modules/potato.js → src/modules/potato.ts} +10 -5
- package/src/types.ts +16 -0
- package/src/utils/settings.ts +4 -0
- package/tsconfig.json +9 -0
- package/const/settings.js +0 -3
- package/index.js +0 -7
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Module } from "@vnejs/module";
|
|
2
|
+
import type { PotatoPluginConstants, PotatoPluginEvents, PotatoPluginParams, PotatoPluginSettings } from "../types.js";
|
|
3
|
+
import type { SettingsChangedPayload } from "../utils/settings.js";
|
|
4
|
+
export declare class Potato extends Module<PotatoPluginEvents, PotatoPluginConstants, PotatoPluginSettings, PotatoPluginParams> {
|
|
5
|
+
name: string;
|
|
6
|
+
styleElement?: HTMLStyleElement;
|
|
7
|
+
subscribe: () => void;
|
|
8
|
+
init: () => Promise<void>;
|
|
9
|
+
onSettingChange: ({ name, value }?: SettingsChangedPayload) => false | void;
|
|
10
|
+
setEnabled: (value: boolean) => void;
|
|
11
|
+
notPotato: (e: string) => boolean;
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Module } from "@vnejs/module";
|
|
2
|
+
export class Potato extends Module {
|
|
3
|
+
name = "potato";
|
|
4
|
+
styleElement;
|
|
5
|
+
subscribe = () => {
|
|
6
|
+
this.on(this.EVENTS.SETTINGS.CHANGED, this.onSettingChange);
|
|
7
|
+
};
|
|
8
|
+
init = async () => {
|
|
9
|
+
await this.emit(this.EVENTS.SETTINGS.INIT, { name: this.SETTINGS.POTATO.ENABLED, value: false });
|
|
10
|
+
this.styleElement = document.createElement("style");
|
|
11
|
+
this.styleElement.innerHTML = "*{transition:none!important}";
|
|
12
|
+
this.shared.settings[this.SETTINGS.POTATO.ENABLED] && this.setEnabled(true);
|
|
13
|
+
};
|
|
14
|
+
onSettingChange = ({ name, value } = {}) => name === this.SETTINGS.POTATO.ENABLED && this.setEnabled(Boolean(value));
|
|
15
|
+
setEnabled = (value) => {
|
|
16
|
+
if (value) {
|
|
17
|
+
this.shared.audioNoSmoothSources.push(this.name);
|
|
18
|
+
this.shared.mediaNoTimeoutSources.push(this.name);
|
|
19
|
+
this.shared.textNoAnimationSources.push(this.name);
|
|
20
|
+
this.shared.viewForceAnimationSources.push(this.name);
|
|
21
|
+
this.styleElement && document.head.appendChild(this.styleElement);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
this.shared.audioNoSmoothSources = this.shared.audioNoSmoothSources.filter(this.notPotato);
|
|
25
|
+
this.shared.mediaNoTimeoutSources = this.shared.mediaNoTimeoutSources.filter(this.notPotato);
|
|
26
|
+
this.shared.textNoAnimationSources = this.shared.textNoAnimationSources.filter(this.notPotato);
|
|
27
|
+
this.shared.viewForceAnimationSources = this.shared.viewForceAnimationSources.filter(this.notPotato);
|
|
28
|
+
this.styleElement?.isConnected && document.head.removeChild(this.styleElement);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
notPotato = (e) => e !== this.name;
|
|
32
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "@vnejs/plugins.audio.contract";
|
|
2
|
+
import "@vnejs/plugins.core.components.contract";
|
|
3
|
+
import "@vnejs/plugins.core.media.contract";
|
|
4
|
+
import "@vnejs/plugins.settings.potato.contract";
|
|
5
|
+
import type { VnePluginConstantsMapRegistry, VnePluginEventsMapRegistry, VnePluginParamsMapRegistry, VnePluginSettingsMapRegistry } from "@vnejs/shared";
|
|
6
|
+
import type { PluginName as SettingsPluginName, SubscribeEvents as SettingsSubscribeEvents } from "@vnejs/plugins.core.settings.contract";
|
|
7
|
+
import type { PluginName, SettingsKeys } from "@vnejs/plugins.settings.potato.contract";
|
|
8
|
+
export type PotatoPluginEvents = VnePluginEventsMapRegistry & Record<SettingsPluginName, SettingsSubscribeEvents>;
|
|
9
|
+
export type PotatoPluginConstants = VnePluginConstantsMapRegistry;
|
|
10
|
+
export type PotatoPluginSettings = VnePluginSettingsMapRegistry & Record<PluginName, SettingsKeys>;
|
|
11
|
+
export type PotatoPluginParams = VnePluginParamsMapRegistry;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,17 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/plugins.settings.potato",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.1.6",
|
|
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
|
+
],
|
|
5
20
|
"scripts": {
|
|
6
21
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
22
|
+
"build": "npx @vnejs/monorepo package",
|
|
7
23
|
"publish:major:plugin": "npm run publish:major",
|
|
8
24
|
"publish:minor:plugin": "npm run publish:minor",
|
|
9
25
|
"publish:patch:plugin": "npm run publish:patch",
|
|
10
|
-
"publish:major": "
|
|
11
|
-
"publish:minor": "
|
|
12
|
-
"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"
|
|
13
29
|
},
|
|
14
30
|
"author": "",
|
|
15
31
|
"license": "ISC",
|
|
16
|
-
"
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@vnejs/plugins.settings.potato.contract": "~0.0.1"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@vnejs/module": "~0.0.1",
|
|
37
|
+
"@vnejs/plugins.audio.contract": "~0.0.1",
|
|
38
|
+
"@vnejs/plugins.core.components.contract": "~0.0.1",
|
|
39
|
+
"@vnejs/plugins.core.media.contract": "~0.0.1",
|
|
40
|
+
"@vnejs/plugins.core.settings.contract": "~0.0.1",
|
|
41
|
+
"@vnejs/shared": "~0.0.9"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@vnejs/configs.ts-common": "~0.0.1"
|
|
45
|
+
}
|
|
17
46
|
}
|
package/src/index.ts
ADDED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { Module } from "@vnejs/module";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { PotatoPluginConstants, PotatoPluginEvents, PotatoPluginParams, PotatoPluginSettings } from "../types.js";
|
|
4
|
+
import type { SettingsChangedPayload } from "../utils/settings.js";
|
|
5
|
+
|
|
6
|
+
export class Potato extends Module<PotatoPluginEvents, PotatoPluginConstants, PotatoPluginSettings, PotatoPluginParams> {
|
|
4
7
|
name = "potato";
|
|
5
8
|
|
|
9
|
+
styleElement?: HTMLStyleElement;
|
|
10
|
+
|
|
6
11
|
subscribe = () => {
|
|
7
12
|
this.on(this.EVENTS.SETTINGS.CHANGED, this.onSettingChange);
|
|
8
13
|
};
|
|
@@ -16,9 +21,9 @@ export class Potato extends Module {
|
|
|
16
21
|
this.shared.settings[this.SETTINGS.POTATO.ENABLED] && this.setEnabled(true);
|
|
17
22
|
};
|
|
18
23
|
|
|
19
|
-
onSettingChange = ({ name, value }) => name === this.SETTINGS.POTATO.ENABLED && this.setEnabled(value);
|
|
24
|
+
onSettingChange = ({ name, value }: SettingsChangedPayload = {}) => name === this.SETTINGS.POTATO.ENABLED && this.setEnabled(Boolean(value));
|
|
20
25
|
|
|
21
|
-
setEnabled = (value) => {
|
|
26
|
+
setEnabled = (value: boolean) => {
|
|
22
27
|
if (value) {
|
|
23
28
|
this.shared.audioNoSmoothSources.push(this.name);
|
|
24
29
|
this.shared.mediaNoTimeoutSources.push(this.name);
|
|
@@ -30,9 +35,9 @@ export class Potato extends Module {
|
|
|
30
35
|
this.shared.mediaNoTimeoutSources = this.shared.mediaNoTimeoutSources.filter(this.notPotato);
|
|
31
36
|
this.shared.textNoAnimationSources = this.shared.textNoAnimationSources.filter(this.notPotato);
|
|
32
37
|
this.shared.viewForceAnimationSources = this.shared.viewForceAnimationSources.filter(this.notPotato);
|
|
33
|
-
this.styleElement
|
|
38
|
+
this.styleElement?.isConnected && document.head.removeChild(this.styleElement);
|
|
34
39
|
}
|
|
35
40
|
};
|
|
36
41
|
|
|
37
|
-
notPotato = (e) => e !== this.name;
|
|
42
|
+
notPotato = (e: string) => e !== this.name;
|
|
38
43
|
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "@vnejs/plugins.audio.contract";
|
|
2
|
+
import "@vnejs/plugins.core.components.contract";
|
|
3
|
+
import "@vnejs/plugins.core.media.contract";
|
|
4
|
+
import "@vnejs/plugins.settings.potato.contract";
|
|
5
|
+
|
|
6
|
+
import type { VnePluginConstantsMapRegistry, VnePluginEventsMapRegistry, VnePluginParamsMapRegistry, VnePluginSettingsMapRegistry } from "@vnejs/shared";
|
|
7
|
+
import type { PluginName as SettingsPluginName, SubscribeEvents as SettingsSubscribeEvents } from "@vnejs/plugins.core.settings.contract";
|
|
8
|
+
import type { PluginName, SettingsKeys } from "@vnejs/plugins.settings.potato.contract";
|
|
9
|
+
|
|
10
|
+
export type PotatoPluginEvents = VnePluginEventsMapRegistry & Record<SettingsPluginName, SettingsSubscribeEvents>;
|
|
11
|
+
|
|
12
|
+
export type PotatoPluginConstants = VnePluginConstantsMapRegistry;
|
|
13
|
+
|
|
14
|
+
export type PotatoPluginSettings = VnePluginSettingsMapRegistry & Record<PluginName, SettingsKeys>;
|
|
15
|
+
|
|
16
|
+
export type PotatoPluginParams = VnePluginParamsMapRegistry;
|
package/tsconfig.json
ADDED
package/const/settings.js
DELETED