sygnal 4.2.0 → 4.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sygnal",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "description": "An intuitive framework for building fast and small components or applications based on Cycle.js",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "types": "./dist/index.d.ts",
@@ -51,10 +51,12 @@
51
51
  "src"
52
52
  ],
53
53
  "scripts": {
54
- "test": "echo \"Tests to come...\"",
54
+ "test": "vitest run",
55
+ "test:watch": "vitest",
55
56
  "build": "npx rollup -c",
56
57
  "build:types": "npx rollup -c rollup.config.dts.mjs",
57
58
  "build:all": "npm run build && npm run build:types",
59
+ "build:devtools": "node devtools/build.mjs",
58
60
  "start": "npx rollup -c -w"
59
61
  },
60
62
  "repository": {
@@ -94,6 +96,7 @@
94
96
  "rollup": "^3.28.1",
95
97
  "rollup-plugin-dts": "^6.1.1",
96
98
  "tslib": "^2.6.2",
97
- "typescript": "^5.4.5"
99
+ "typescript": "^5.4.5",
100
+ "vitest": "^4.0.18"
98
101
  }
99
102
  }
package/src/collection.js CHANGED
@@ -4,9 +4,12 @@ import isolate from '@cycle/isolate'
4
4
  import { makeCollection } from '@cycle/state'
5
5
  import { h } from '@cycle/dom'
6
6
 
7
-
7
+ let COLLECTION_COUNT = 0
8
8
 
9
9
  export default function collection(component, stateLense, opts={}) {
10
+ if (typeof component !== 'function') {
11
+ throw new Error('collection: first argument (component) must be a function')
12
+ }
10
13
  const {
11
14
  combineList = ['DOM'],
12
15
  globalList = ['EVENTS'],
@@ -17,7 +20,7 @@ export default function collection(component, stateLense, opts={}) {
17
20
  } = opts
18
21
 
19
22
  return (sources) => {
20
- const key = Date.now()
23
+ const key = `sygnal-collection-${COLLECTION_COUNT++}`
21
24
  const collectionOpts = {
22
25
  item: component,
23
26
  itemKey: (state, ind) => typeof state.id !== 'undefined' ? state.id : ind,