@agendize/vue-tools 0.0.0

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.
@@ -0,0 +1,11 @@
1
+ declare type Subscription<S> = (state: S) => void;
2
+ export declare abstract class Bloc<S> {
3
+ private internalState;
4
+ private listeners;
5
+ constructor(initialState: S);
6
+ get state(): S;
7
+ changeState(state: S): void;
8
+ subscribe(listener: Subscription<S>): void;
9
+ unsubscribe(listener: Subscription<S>): void;
10
+ }
11
+ export {};
@@ -0,0 +1,3 @@
1
+ import { Bloc } from "./Bloc";
2
+ import { DeepReadonly, Ref } from "vue";
3
+ export declare function useBlocState<S>(bloc: Bloc<S>): DeepReadonly<Ref<S>>;
@@ -0,0 +1 @@
1
+ export * from './bloc/Bloc';
@@ -0,0 +1,32 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ class Bloc {
8
+ constructor(initialState) {
9
+ __publicField(this, "internalState");
10
+ __publicField(this, "listeners", []);
11
+ this.internalState = initialState;
12
+ }
13
+ get state() {
14
+ return this.internalState;
15
+ }
16
+ changeState(state) {
17
+ this.internalState = state;
18
+ if (this.listeners.length > 0) {
19
+ this.listeners.forEach((listener) => listener(this.state));
20
+ }
21
+ }
22
+ subscribe(listener) {
23
+ this.listeners.push(listener);
24
+ }
25
+ unsubscribe(listener) {
26
+ const index = this.listeners.indexOf(listener);
27
+ if (index > -1) {
28
+ this.listeners.splice(index, 1);
29
+ }
30
+ }
31
+ }
32
+ export { Bloc };
@@ -0,0 +1 @@
1
+ (function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t((e.agendize=e.agendize||{},e.agendize.tools={})))})(this,function(e){"use strict";var o=Object.defineProperty;var l=(e,t,s)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var r=(e,t,s)=>(l(e,typeof t!="symbol"?t+"":t,s),s);class t{constructor(i){r(this,"internalState");r(this,"listeners",[]);this.internalState=i}get state(){return this.internalState}changeState(i){this.internalState=i,this.listeners.length>0&&this.listeners.forEach(n=>n(this.state))}subscribe(i){this.listeners.push(i)}unsubscribe(i){const n=this.listeners.indexOf(i);n>-1&&this.listeners.splice(n,1)}}e.Bloc=t,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@agendize/vue-tools",
3
+ "version": "0.0.0",
4
+ "description": "Agendize tools",
5
+ "private": false,
6
+ "keywords": [
7
+ "agendize",
8
+ "tools"
9
+ ],
10
+ "homepage": "https://github.com/agendize/vue-tools",
11
+ "bugs": {
12
+ "url": "https://github.com/agendize/vue-tools/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/agendize/vue-tools.git"
17
+ },
18
+ "license": "Apache-2.0",
19
+ "author": "David Tant",
20
+ "main": "./dist/vue-tools.umd.js",
21
+ "module": "./dist/vue-tools.es.js",
22
+ "unpkg": "./dist/vue-tools.min.js",
23
+ "types": "./dist/index.d.ts",
24
+ "files": [
25
+ "dist/"
26
+ ],
27
+ "exports": {
28
+ ".": {
29
+ "import": "./dist/vue-tools.es.js",
30
+ "require": "./dist/vue-tools.umd.js"
31
+ }
32
+ },
33
+ "scripts": {
34
+ "dev": "vite",
35
+ "build": "vite build && vue-tsc --emitDeclarationOnly",
36
+ "build-quick": "vite build",
37
+ "preview": "vite preview",
38
+ "test": "jest",
39
+ "publish-public": "npm publish --access=public",
40
+ "publish-beta": "npm publish --access=public --tag=beta"
41
+ },
42
+ "dependencies": {
43
+ "vue": "^3.2.37"
44
+ },
45
+ "devDependencies": {
46
+ "@intlify/vite-plugin-vue-i18n": "^3.4.0",
47
+ "@types/node": "^17.0.45",
48
+ "@vitejs/plugin-vue": "^2.3.3",
49
+ "typescript": "4.7.4",
50
+ "vite": "^2.9.14",
51
+ "vue-tsc": "^0.29.8"
52
+ }
53
+ }