@wrnrlr/prelude 0.2.3 → 0.2.10

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.
@@ -1,41 +1,57 @@
1
- name: Publish
1
+ name: Prelude CI/CD
2
2
 
3
3
  on:
4
4
  push:
5
5
  branches:
6
6
  - main
7
-
8
- permissions:
9
- contents: read
10
- pages: write
11
- id-token: write
7
+ - release
12
8
 
13
9
  jobs:
14
- publish:
10
+ test:
15
11
  runs-on: ubuntu-latest
16
- environment:
17
- name: github-pages
18
- url: ${{ steps.deployment.outputs.page_url }}
12
+ # if: github.ref == 'refs/heads/main'
19
13
  steps:
20
- - name: Check out the repository to the runner
14
+ - name: Checkout the repository
21
15
  uses: actions/checkout@v4
22
-
23
16
  - name: Setup Deno
24
17
  uses: denoland/setup-deno@v2
25
18
  with:
26
19
  deno-version: v2.x
27
-
28
20
  - name: Deno install
29
21
  run: deno install
30
-
31
22
  # - name: Lint
32
23
  # run: deno lint
33
-
34
24
  - name: Run tests
35
25
  run: deno task test
26
+ publish:
27
+ needs: test
28
+ if: github.ref == 'refs/heads/release'
29
+ runs-on: ubuntu-latest
30
+ permissions:
31
+ contents: read
32
+ id-token: write
33
+ steps:
34
+ - name: Checkout repository
35
+ uses: actions/checkout@v4
36
36
 
37
- - name: Build
38
- run: deno task build
37
+ - name: Setup Deno
38
+ uses: denoland/setup-deno@v2
39
+ with:
40
+ deno-version: v2.x
41
+
42
+ - name: Publish to JSR
43
+ run: deno publish --allow-slow-types --allow-dirty
44
+
45
+ - name: Setup Node
46
+ uses: actions/setup-node@v4
47
+ with:
48
+ node-version: 20
49
+ registry-url: 'https://registry.npmjs.org/'
50
+
51
+ - name: Publish to NPM
52
+ run: npm publish --access public
53
+ env:
54
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
39
55
 
40
56
  # Moving artifacts, website and docs into their own project...
41
57
  # - name: Setup Pages
@@ -49,10 +65,3 @@ jobs:
49
65
  # - name: Deploy to GitHub Pages
50
66
  # id: deployment
51
67
  # uses: actions/deploy-pages@v4
52
-
53
- # - name: Setup NPM
54
- # run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > /home/runner/.npmrc
55
- # env:
56
- # NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
57
- # - name: Run release script
58
- # run: /home/runner/.deno/bin/deno task release
package/deno.jsonc CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrnrlr/prelude",
3
- "version": "0.2.3",
3
+ "version": "0.2.10",
4
4
  "exports": "./src/mod.ts",
5
5
  "compilerOptions": {
6
6
  "strict": true,
@@ -11,18 +11,16 @@
11
11
  "@std/fs": "jsr:@std/fs@^1.0.5",
12
12
  "@std/path": "jsr:@std/path@^1.0.6",
13
13
  "@std/testing": "jsr:@std/testing@^0.225.3",
14
- "happy-dom": "npm:happy-dom@^17.1.0",
15
- "typedoc": "npm:typedoc@^0.26.6",
16
- "vite": "npm:vite@^5.4.9",
17
- "esbuild": "npm:esbuild@^0.24.0"
14
+ "happy-dom": "npm:happy-dom@^17.1.0"
18
15
  },
19
16
  "tasks": {
20
17
  "dev": "deno run -A npm:vite --config www/vite.config.js",
21
18
  "test": "deno test -A ./test/*.[jt]s",
22
- "release": "deno publish --allow-slow-types --allow-dirty && npm publish --access public"
19
+ "release": "git push origin main:release"
23
20
  },
24
21
  "lint": {
25
- "include": ["src"]
22
+ "include": ["src"],
23
+ "exclude": ["src/runtime.ts"]
26
24
  },
27
25
  "fmt": {
28
26
  "lineWidth": 120,
@@ -15,9 +15,9 @@ function Checkbox(props) {
15
15
  }
16
16
 
17
17
  function App() {
18
- const todos = signal([true,false])
19
- // const obj = signal({todos:[true]})
20
- // const todos = wrap(obj,'todos')
18
+ // const todos = signal([true,false])
19
+ const obj = signal({todos:[true]})
20
+ const todos = wrap(obj,'todos')
21
21
  const first = wrap(todos, 0)
22
22
  const removeItem = i => {
23
23
  // console.log('remove', i)
package/package.json CHANGED
@@ -1,14 +1,10 @@
1
1
  {
2
2
  "name": "@wrnrlr/prelude",
3
3
  "type": "module",
4
- "version": "0.2.3",
4
+ "version": "0.2.10",
5
5
  "author": "Werner Laurensse",
6
6
  "description": "A signal based frontend library with fine-grained reactivity",
7
7
  "main": "./src/mod.ts",
8
8
  "scripts": {},
9
- "dependencies": {
10
- "@codemirror/lang-html": "^6.4.9",
11
- "codemirror": "^6.0.1",
12
- "happy-dom": "^17.1.0"
13
- }
9
+ "dependencies": {}
14
10
  }
@@ -82,8 +82,10 @@ export function listArray<T, U extends Mountable>(
82
82
  disposeList(items)
83
83
  })
84
84
 
85
+ let newItems
86
+
85
87
  return () => {
86
- const newItems = typeof list==='function' ? list() || [] : list;
88
+ newItems = typeof list==='function' ? list() || [] : list;
87
89
  return untrack(() => {
88
90
  if (newItems.length > 0 && fallbackDisposer) {
89
91
  fallbackDisposer();
@@ -186,7 +188,7 @@ export function listArray<T, U extends Mountable>(
186
188
  return (mapped = temp);
187
189
  })
188
190
  }
189
- function newValueGetter(a:unknown) { console.log({a}); return newValue }
191
+ function newValueGetter() { return newValue }
190
192
  function changeBoth() {
191
193
  item!.index = i!
192
194
  item!.indexSetter?.(i)
@@ -204,10 +206,11 @@ export function listArray<T, U extends Mountable>(
204
206
  let sV = (...a) => {
205
207
  sV = (...a) => {
206
208
  if (a.length===0) {
207
- return list()[sI()]
209
+ return newItems[t.index]
208
210
  } else {
209
- const k = untrack(sI)
210
- return list(b => b.toSpliced(k, 1, typeof a[0] === 'function' ? a[0]() : a[0])).at(k)
211
+ const k = t.index
212
+ const b = newItems.toSpliced(k, 1, typeof a[0] === 'function' ? a[0]() : a[0])
213
+ return list(b).at(k)
211
214
  }
212
215
  }
213
216
  t.valueSetter = sV
package/src/resource.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // @ts-nocheck:
2
- import {signal,effect,untrack,memo,batch,useContext,onCleanup} from './reactive.ts'
2
+ import {signal,effect,untrack,memo,batch,onCleanup} from './reactive.ts'
3
3
 
4
4
  const NO_INIT = {}
5
5
 
package/src/runtime.ts CHANGED
@@ -339,7 +339,7 @@ function setAttribute(node: Element, name: string, value?: string): undefined {
339
339
  }
340
340
 
341
341
  function setAttributeNS(node:Node, ns:string, name:string, value?:string):void {
342
- value ? node.setAttributeNS(ns, name, value) : node.removeAttributeNS(ns, name)
342
+ value===undefined || value===null ? node.setAttributeNS(ns, name, value) : node.removeAttributeNS(ns, name)
343
343
  }
344
344
 
345
345
  function addEventListener(node: Element, name: string, handler:((e:Event)=>void), delegate:boolean): void {
package/test/list.js CHANGED
@@ -25,10 +25,10 @@ import { listArray } from '../src/controlflow.ts'
25
25
  // l(l => [3, ...l])
26
26
  // assertEquals(r(), [{e:3,i:0}, {e:0,i:1}, {e:1,i:2}, {e:2,i:3}])
27
27
  // })
28
- const l1 = signal(['a'])
29
- const r1 = listArray(l1, (e,i)=>([i(),e()]))
28
+ // const l1 = signal(['a'])
29
+ // const r1 = listArray(l1, (e,i)=>([i(),e()]))
30
30
  // r1()
31
- l1(l => ['x', ...l])
31
+ // l1(l => ['x', ...l])
32
32
  // l1(l => [...l, 'x', 'y'])
33
- console.log(JSON.stringify(r1()))
33
+ // console.log(JSON.stringify(r1()))
34
34
  // assertEquals(r(), )
package/test/reactive.js CHANGED
@@ -128,7 +128,6 @@ describe('wrap', ()=>{
128
128
  const obj = signal({todos:[{done:false,name:'a'}, {done:false,name:'b'}]}), todos = wrap(obj, 'todos'), todo = wrap(todos, 0),
129
129
  name = wrap(todo, 'name'), done = wrap(todo,'done')
130
130
  assertEquals(done(true),true)
131
- console.log('OBJ',obj())
132
131
  effect(()=>{
133
132
  name();done()
134
133
  })