@stencil/store 2.0.15 → 2.1.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.
package/README.md CHANGED
@@ -4,10 +4,10 @@ Store is a lightweight shared state library by the [StencilJS](https://stenciljs
4
4
 
5
5
  **Highlights:**
6
6
 
7
- - Lightweight
8
- - Zero dependencies
9
- - Simple API, like a reactive Map
10
- - Best performance
7
+ - ðŸŠķ Lightweight
8
+ - ⚡ Zero dependencies
9
+ - ðŸ“Ķ Simple API, like a reactive Map
10
+ - 🚀 Best performance
11
11
 
12
12
  ## Installation
13
13
 
@@ -1,4 +1,6 @@
1
- import { getRenderingRef, forceUpdate } from '@stencil/core';
1
+ 'use strict';
2
+
3
+ var core = require('@stencil/core');
2
4
 
3
5
  const appendToMap = (map, propName, value) => {
4
6
  const items = map.get(propName);
@@ -36,9 +38,9 @@ const cleanupElements = debounce((map) => {
36
38
  for (let key of map.keys()) {
37
39
  map.set(key, map.get(key).filter(isConnected));
38
40
  }
39
- }, 2000);
41
+ }, 2_000);
40
42
  const stencilSubscription = () => {
41
- if (typeof getRenderingRef !== 'function') {
43
+ if (typeof core.getRenderingRef !== 'function') {
42
44
  // If we are not in a stencil project, we do nothing.
43
45
  // This function is not really exported by @stencil/core.
44
46
  return {};
@@ -47,7 +49,7 @@ const stencilSubscription = () => {
47
49
  return {
48
50
  dispose: () => elmsToUpdate.clear(),
49
51
  get: (propName) => {
50
- const elm = getRenderingRef();
52
+ const elm = core.getRenderingRef();
51
53
  if (elm) {
52
54
  appendToMap(elmsToUpdate, propName, elm);
53
55
  }
@@ -55,12 +57,12 @@ const stencilSubscription = () => {
55
57
  set: (propName) => {
56
58
  const elements = elmsToUpdate.get(propName);
57
59
  if (elements) {
58
- elmsToUpdate.set(propName, elements.filter(forceUpdate));
60
+ elmsToUpdate.set(propName, elements.filter(core.forceUpdate));
59
61
  }
60
62
  cleanupElements(elmsToUpdate);
61
63
  },
62
64
  reset: () => {
63
- elmsToUpdate.forEach((elms) => elms.forEach(forceUpdate));
65
+ elmsToUpdate.forEach((elms) => elms.forEach(core.forceUpdate));
64
66
  cleanupElements(elmsToUpdate);
65
67
  },
66
68
  };
@@ -69,7 +71,7 @@ const stencilSubscription = () => {
69
71
  const unwrap = (val) => (typeof val === 'function' ? val() : val);
70
72
  const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
71
73
  const unwrappedState = unwrap(defaultState);
72
- let states = new Map(Object.entries(unwrappedState !== null && unwrappedState !== void 0 ? unwrappedState : {}));
74
+ let states = new Map(Object.entries(unwrappedState ?? {}));
73
75
  const handlers = {
74
76
  dispose: [],
75
77
  get: [],
@@ -77,10 +79,9 @@ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) =>
77
79
  reset: [],
78
80
  };
79
81
  const reset = () => {
80
- var _a;
81
82
  // When resetting the state, the default state may be a function - unwrap it to invoke it.
82
83
  // otherwise, the state won't be properly reset
83
- states = new Map(Object.entries((_a = unwrap(defaultState)) !== null && _a !== void 0 ? _a : {}));
84
+ states = new Map(Object.entries(unwrap(defaultState) ?? {}));
84
85
  handlers.reset.forEach((cb) => cb());
85
86
  };
86
87
  const dispose = () => {
@@ -191,4 +192,5 @@ const createStore = (defaultState, shouldUpdate) => {
191
192
  return map;
192
193
  };
193
194
 
194
- export { createObservableMap, createStore };
195
+ exports.createObservableMap = createObservableMap;
196
+ exports.createStore = createStore;
package/dist/index.js CHANGED
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- var core = require('@stencil/core');
1
+ import { getRenderingRef, forceUpdate } from '@stencil/core';
4
2
 
5
3
  const appendToMap = (map, propName, value) => {
6
4
  const items = map.get(propName);
@@ -38,9 +36,9 @@ const cleanupElements = debounce((map) => {
38
36
  for (let key of map.keys()) {
39
37
  map.set(key, map.get(key).filter(isConnected));
40
38
  }
41
- }, 2000);
39
+ }, 2_000);
42
40
  const stencilSubscription = () => {
43
- if (typeof core.getRenderingRef !== 'function') {
41
+ if (typeof getRenderingRef !== 'function') {
44
42
  // If we are not in a stencil project, we do nothing.
45
43
  // This function is not really exported by @stencil/core.
46
44
  return {};
@@ -49,7 +47,7 @@ const stencilSubscription = () => {
49
47
  return {
50
48
  dispose: () => elmsToUpdate.clear(),
51
49
  get: (propName) => {
52
- const elm = core.getRenderingRef();
50
+ const elm = getRenderingRef();
53
51
  if (elm) {
54
52
  appendToMap(elmsToUpdate, propName, elm);
55
53
  }
@@ -57,12 +55,12 @@ const stencilSubscription = () => {
57
55
  set: (propName) => {
58
56
  const elements = elmsToUpdate.get(propName);
59
57
  if (elements) {
60
- elmsToUpdate.set(propName, elements.filter(core.forceUpdate));
58
+ elmsToUpdate.set(propName, elements.filter(forceUpdate));
61
59
  }
62
60
  cleanupElements(elmsToUpdate);
63
61
  },
64
62
  reset: () => {
65
- elmsToUpdate.forEach((elms) => elms.forEach(core.forceUpdate));
63
+ elmsToUpdate.forEach((elms) => elms.forEach(forceUpdate));
66
64
  cleanupElements(elmsToUpdate);
67
65
  },
68
66
  };
@@ -71,7 +69,7 @@ const stencilSubscription = () => {
71
69
  const unwrap = (val) => (typeof val === 'function' ? val() : val);
72
70
  const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
73
71
  const unwrappedState = unwrap(defaultState);
74
- let states = new Map(Object.entries(unwrappedState !== null && unwrappedState !== void 0 ? unwrappedState : {}));
72
+ let states = new Map(Object.entries(unwrappedState ?? {}));
75
73
  const handlers = {
76
74
  dispose: [],
77
75
  get: [],
@@ -79,10 +77,9 @@ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) =>
79
77
  reset: [],
80
78
  };
81
79
  const reset = () => {
82
- var _a;
83
80
  // When resetting the state, the default state may be a function - unwrap it to invoke it.
84
81
  // otherwise, the state won't be properly reset
85
- states = new Map(Object.entries((_a = unwrap(defaultState)) !== null && _a !== void 0 ? _a : {}));
82
+ states = new Map(Object.entries(unwrap(defaultState) ?? {}));
86
83
  handlers.reset.forEach((cb) => cb());
87
84
  };
88
85
  const dispose = () => {
@@ -193,5 +190,4 @@ const createStore = (defaultState, shouldUpdate) => {
193
190
  return map;
194
191
  };
195
192
 
196
- exports.createObservableMap = createObservableMap;
197
- exports.createStore = createStore;
193
+ export { createObservableMap, createStore };
package/dist/utils.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export declare const appendToMap: <K, V>(map: Map<K, V[]>, propName: K, value: V) => void;
2
- export declare const debounce: <T extends (...args: any[]) => any>(fn: T, ms: number) => (...args: Parameters<T>) => void;
2
+ export declare const debounce: <T extends (...args: any[]) => any>(fn: T, ms: number) => ((...args: Parameters<T>) => void);
package/package.json CHANGED
@@ -1,61 +1,68 @@
1
1
  {
2
2
  "name": "@stencil/store",
3
- "version": "2.0.15",
3
+ "author": "StencilJS Team",
4
+ "version": "2.1.0",
4
5
  "description": "Store is a lightweight shared state library by the StencilJS core team. Implements a simple key/value map that efficiently re-renders components when necessary.",
5
- "main": "dist/index.js",
6
- "module": "dist/index.mjs",
7
- "types": "dist/index.d.ts",
6
+ "license": "MIT",
7
+ "homepage": "https://stenciljs.com/docs/stencil-store",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git://github.com/stenciljs/store.git"
11
+ },
12
+ "keywords": [
13
+ "stencil",
14
+ "redux",
15
+ "global",
16
+ "state",
17
+ "tunnel",
18
+ "hooks"
19
+ ],
20
+ "type": "module",
21
+ "module": "dist/index.js",
22
+ "main": "dist/index.cjs",
23
+ "types": "./dist/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "import": "./dist/index.js",
28
+ "require": "./dist/index.cjs"
29
+ }
30
+ },
8
31
  "engines": {
9
- "node": ">=12.0.0",
32
+ "node": ">=18.0.0",
10
33
  "npm": ">=6.0.0"
11
34
  },
12
35
  "scripts": {
13
- "build": "rm -rf dist && tsc -p . && npm run rollup",
36
+ "build": "run-s build.*",
37
+ "build.clean": "rm -rf dist",
38
+ "build.rollup": "rollup -c rollup.config.js",
14
39
  "prettier": "npm run prettier.base -- --write",
15
40
  "prettier.base": "prettier --cache 'src/**/*.ts'",
16
41
  "prettier.dry-run": "npm run prettier.base -- --list-different",
17
42
  "release": "np",
18
- "rollup": "rollup -c rollup.config.mjs",
19
- "test": "jest",
20
- "test.ci": "npm run test && npm run prettier.dry-run",
43
+ "test": "run-s test.*",
44
+ "test.prettier": "npm run prettier.dry-run",
45
+ "test.unit": "vitest",
21
46
  "version": "npm run build"
22
47
  },
23
- "keywords": [
24
- "stencil",
25
- "redux",
26
- "global",
27
- "state",
28
- "tunnel",
29
- "hooks"
30
- ],
31
48
  "files": [
32
49
  "dist"
33
50
  ],
34
- "author": "Ionic Team",
35
- "license": "MIT",
36
- "homepage": "https://stenciljs.com/docs/stencil-store",
37
51
  "peerDependencies": {
38
52
  "@stencil/core": ">=2.0.0 || >=3.0.0 || >= 4.0.0-beta.0 || >= 4.0.0"
39
53
  },
40
54
  "devDependencies": {
41
55
  "@ionic/prettier-config": "^4.0.0",
42
- "@stencil/core": "^4.0.0",
43
- "@types/jest": "^29.0.0",
44
- "@types/node": "^20.2.0",
45
- "jest": "^29.0.0",
46
- "np": "^10.0.0",
47
- "prettier": "^3.0.0",
48
- "rollup": "^4.0.0",
49
- "ts-jest": "^29.0.0",
50
- "typescript": "~5.0.0"
51
- },
52
- "repository": {
53
- "type": "git",
54
- "url": "git://github.com/ionic-team/stencil-store.git"
56
+ "@rollup/plugin-typescript": "^12.1.2",
57
+ "@stencil/core": "^4.27.1",
58
+ "@types/node": "^22.13.5",
59
+ "@vitest/coverage-v8": "^3.0.7",
60
+ "np": "^10.2.0",
61
+ "npm-run-all2": "^7.0.2",
62
+ "prettier": "^3.5.2",
63
+ "rollup": "^4.34.8",
64
+ "typescript": "~5.7.3",
65
+ "vitest": "^3.0.7"
55
66
  },
56
- "prettier": "@ionic/prettier-config",
57
- "volta": {
58
- "node": "20.11.1",
59
- "npm": "10.5.0"
60
- }
67
+ "prettier": "@ionic/prettier-config"
61
68
  }