fluxie 1.0.0 → 1.2.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.
@@ -15,20 +15,5 @@ jobs:
15
15
  steps:
16
16
  - uses: googleapis/release-please-action@v4
17
17
  with:
18
- token: ${{ secrets.GITHUB_TOKEN }}
19
- release-type: simple
20
-
21
- deploy-npm:
22
- needs: release-please
23
- runs-on: ubuntu-latest
24
- steps:
25
- - uses: actions/checkout@v3
26
- - uses: actions/setup-node@v3
27
- with:
28
- node-version-file: ".nvmrc"
29
- registry-url: https://registry.npmjs.org
30
- - run: npm install
31
- - run: npm run build
32
- - run: npm publish
33
- env:
34
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
18
+ token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
19
+ release-type: node
@@ -0,0 +1,20 @@
1
+ on:
2
+ release:
3
+ types: [published]
4
+
5
+ name: publish-npm
6
+
7
+ jobs:
8
+ deploy-npm:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v3
12
+ - uses: actions/setup-node@v3
13
+ with:
14
+ node-version-file: ".nvmrc"
15
+ registry-url: "https://registry.npmjs.org"
16
+ - run: npm install
17
+ - run: npm run build
18
+ - run: npm publish
19
+ env:
20
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ ## [1.2.0](https://github.com/LesFabricants/Fluxie/compare/v1.1.0...v1.2.0) (2024-06-04)
4
+
5
+
6
+ ### Features
7
+
8
+ * **pkg:** add package.json data ([23b1b79](https://github.com/LesFabricants/Fluxie/commit/23b1b79e6a2f5d448cb0e7a6a263b7259a5809c2))
9
+
10
+ ## [1.1.0](https://github.com/LesFabricants/Fluxie/compare/v1.0.0...v1.1.0) (2024-06-04)
11
+
12
+
13
+ ### Features
14
+
15
+ * **store:** update store name to prevent conflicts ([5f1662c](https://github.com/LesFabricants/Fluxie/commit/5f1662cae25ba8c70cc3113bd28014c16d8229d9))
package/README.md CHANGED
@@ -183,5 +183,3 @@ if (!environment.production) {
183
183
  ```
184
184
 
185
185
  Your redux devtool menu will now show all your store actions, the option `storeName` will be the store instance name there (defaults to the class name if not provided), and every service extending the `Store` class will be its own instance in the dropdown at the top.
186
-
187
- ![The redux devtool window is opened, showing the store called "Users", in the "action" section, "set users" and "toggle user selection" are shown being called multiple times](assets/devtool.png)
@@ -0,0 +1,5 @@
1
+ import { BehaviorSubject } from "rxjs";
2
+ export declare let isDevtoolEnabled: boolean;
3
+ export declare function enableReduxDevtools(): void;
4
+ export declare function initializeReduxDevtools(storeName: string, state: BehaviorSubject<any>, initialState: any): false | undefined;
5
+ export declare function sendActionToDevtools(storeName: string, actionName: string, payload: any): false | undefined;
@@ -0,0 +1,2 @@
1
+ export { Store } from "./store";
2
+ export { enableReduxDevtools, isDevtoolEnabled } from "./devtools";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{BehaviorSubject as p}from"rxjs";var r={},o=!1;function h(){o=!0}function l(i,t,s){if(!d())return!1;let e=window?.__REDUX_DEVTOOLS_EXTENSION__.connect({name:i});e.init(s),e.subscribe(n=>{n.type==="DISPATCH"&&n.payload.type==="JUMP_TO_ACTION"&&t.next(JSON.parse(n.state))}),r[i]=e}function c(i,t,s){if(!d())return!1;if(!o)throw new Error("Devtools not enabled, please call enableReduxDevtools() in app.module.ts");r[i].send(t,s)}function d(){return window?.__REDUX_DEVTOOLS_EXTENSION__!==void 0}import{toSignal as u}from"@angular/core/rxjs-interop";var a=class{options;state;select$;select;db;constructor(t,s){if(this.options={...s,storeName:s?.storeName??this.constructor.name},this.state=new p(t),this.select$=this.state.asObservable(),this.select=u(this.state),s?.cache){let e=globalThis.indexedDB.open("__FLUXIE_STORE",1);e.onerror=()=>{console.error(`IndexedDB error: ${e.error}`)},e.onsuccess=()=>{this.db=e.result,this.initializeFromIndexedDB()},e.onupgradeneeded=n=>{this.db=e.result,n.newVersion===1&&this.db.createObjectStore("cachedData"),this.initializeFromIndexedDB()}}o&&l(this.options.storeName,this.state,this.state.getValue())}setState(t,s){let e=s(this.state.getValue());this.state.next(e),this.options?.cache&&this.sendToIndexedDB(this.state.getValue()),o&&c(this.options.storeName,t,e)}async initializeFromIndexedDB(){let t=this.db.transaction("cachedData").objectStore("cachedData").get(this.options.storeName);t.onsuccess=()=>{let s=t.result;s?this.state.next(s):this.sendToIndexedDB(this.state.getValue())}}async sendToIndexedDB(t){this.db.transaction("cachedData","readwrite").objectStore("cachedData").put(t,this.options.storeName)}};export{a as Store,h as enableReduxDevtools,o as isDevtoolEnabled};
@@ -0,0 +1,18 @@
1
+ import { Observable } from "rxjs";
2
+ import { Signal } from "@angular/core";
3
+ interface Options {
4
+ storeName: string;
5
+ cache?: boolean;
6
+ }
7
+ export declare class Store<T = any> {
8
+ private options;
9
+ private state;
10
+ readonly select$: Observable<T>;
11
+ readonly select: Signal<T | undefined>;
12
+ private db?;
13
+ constructor(initialState: T, options?: Partial<Options>);
14
+ setState(actionName: string, mutationFn: (state: T) => T): void;
15
+ private initializeFromIndexedDB;
16
+ private sendToIndexedDB;
17
+ }
18
+ export {};
package/package.json CHANGED
@@ -2,17 +2,35 @@
2
2
  "name": "fluxie",
3
3
  "description": "Small helper class to easily implement Flux architecture using angular service, complete with redux devtool and caching support",
4
4
  "authors": "Anthony Lenglet",
5
- "version": "1.0.0",
5
+ "version": "1.2.0",
6
6
  "type": "module",
7
- "main": "dist/main.js",
7
+ "main": "dist/index.js",
8
+ "author": {
9
+ "name": "Anthony Lenglet",
10
+ "url": "https://github.com/anthonylenglet"
11
+ },
12
+ "license": "MIT",
13
+ "homepage": "https://github.com/LesFabricants/Fluxie",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/LesFabricants/Fluxie"
17
+ },
18
+ "keywords": [
19
+ "angular",
20
+ "flux",
21
+ "redux",
22
+ "devtool",
23
+ "caching"
24
+ ],
8
25
  "scripts": {
9
- "build": "node esbuild.config.js"
26
+ "build": "node esbuild.config.js && ./node_modules/.bin/tsc -p tsconfig.json"
10
27
  },
11
28
  "peerDependencies": {
12
29
  "@angular/core": ">=17.0.0",
13
30
  "rxjs": ">=5.0.0"
14
31
  },
15
32
  "devDependencies": {
16
- "esbuild": "^0.21.4"
33
+ "esbuild": "^0.21.4",
34
+ "typescript": "^5.4.5"
17
35
  }
18
36
  }
Binary file
package/dist/main.js DELETED
@@ -1 +0,0 @@
1
- import{BehaviorSubject as p}from"rxjs";var r={},o=!1;function h(){o=!0}function l(i,t,s){if(!d())return!1;let e=window?.__REDUX_DEVTOOLS_EXTENSION__.connect({name:i});e.init(s),e.subscribe(n=>{n.type==="DISPATCH"&&n.payload.type==="JUMP_TO_ACTION"&&t.next(JSON.parse(n.state))}),r[i]=e}function c(i,t,s){if(!d())return!1;if(!o)throw new Error("Devtools not enabled, please call enableReduxDevtools() in app.module.ts");r[i].send(t,s)}function d(){return window?.__REDUX_DEVTOOLS_EXTENSION__!==void 0}import{toSignal as u}from"@angular/core/rxjs-interop";var a=class{options;state;select$;select;db;constructor(t,s){if(this.options={...s,storeName:s?.storeName??this.constructor.name},this.state=new p(t),this.select$=this.state.asObservable(),this.select=u(this.state),s?.cache){let e=globalThis.indexedDB.open("store",1);e.onerror=()=>{console.error(`IndexedDB error: ${e.error}`)},e.onsuccess=()=>{this.db=e.result,this.initializeFromIndexedDB()},e.onupgradeneeded=n=>{this.db=e.result,n.newVersion===1&&this.db.createObjectStore("cachedData"),this.initializeFromIndexedDB()}}o&&l(this.options.storeName,this.state,this.state.getValue())}setState(t,s){let e=s(this.state.getValue());this.state.next(e),this.options?.cache&&this.sendToIndexedDB(this.state.getValue()),o&&c(this.options.storeName,t,e)}async initializeFromIndexedDB(){let t=this.db.transaction("cachedData").objectStore("cachedData").get(this.options.storeName);t.onsuccess=()=>{let s=t.result;s?this.state.next(s):this.sendToIndexedDB(this.state.getValue())}}async sendToIndexedDB(t){this.db.transaction("cachedData","readwrite").objectStore("cachedData").put(t,this.options.storeName)}};export{a as Store,h as enableReduxDevtools,o as isDevtoolEnabled};