@bun-native/core 0.37.7 → 0.37.9

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
@@ -2,4 +2,4 @@
2
2
 
3
3
  The public TypeScript API of the Bun Native desktop framework.
4
4
 
5
- Part of [Bun Native](https://github.com/AndrewM-F/bun-native), an experimental developer preview. Version 0.37.7 was built from [c801653a1dd3](https://github.com/AndrewM-F/bun-native/tree/c801653a1dd37d738122b7e99f5af8923efc377f) and published from GitHub Actions with npm provenance. Use the Bun revision pinned in that commit's toolchain.json. Start with the [getting-started guide](https://github.com/AndrewM-F/bun-native/blob/c801653a1dd37d738122b7e99f5af8923efc377f/docs/getting-started.md); `bun-native host install` fetches the matching release host. The license notice is in LICENSE.
5
+ Part of [Bun Native](https://github.com/AndrewM-F/bun-native), an experimental developer preview. Version 0.37.9 was built from [6ff07451d491](https://github.com/AndrewM-F/bun-native/tree/6ff07451d49182cce3e672dea4944b2591bf6848) and published from GitHub Actions with npm provenance. Use the Bun revision pinned in that commit's toolchain.json. Start with the [getting-started guide](https://github.com/AndrewM-F/bun-native/blob/6ff07451d49182cce3e672dea4944b2591bf6848/docs/getting-started.md); `bun-native host install` fetches the matching release host. The license notice is in LICENSE.
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "commit": "c801653a1dd37d738122b7e99f5af8923efc377f",
4
- "tree": "55279b32ae660c0395408eda418e4315042a472f",
3
+ "commit": "6ff07451d49182cce3e672dea4944b2591bf6848",
4
+ "tree": "55e85af00d95f1a2f5b2086fcbba70c655635eb7",
5
5
  "files": {
6
6
  "package.json": {
7
7
  "bytes": 2259,
8
- "sha256": "20c2715461a81069271dcf193d97c62894b97af029ff7c7500f36d1299c98b42"
8
+ "sha256": "4dd69b350d772ec187f628b90a572ccad4f65b848649af4d22eebb0544d207bd"
9
9
  },
10
10
  "packages/core/package.json": {
11
11
  "bytes": 282,
@@ -16,12 +16,12 @@
16
16
  "sha256": "be41f76ea03059acb892700a172a8df3f07821af79f16332173399aaf6db7731"
17
17
  },
18
18
  "packages/core/src/application.ts": {
19
- "bytes": 67150,
20
- "sha256": "c4169633cf81c76e0163e7eaef67585cd55781c08ce51c615a3f1beb2a4c9600"
19
+ "bytes": 67175,
20
+ "sha256": "a1c955eff1c9d08f65454f87d83f4147e9f2787fc798c41472985289288237c3"
21
21
  },
22
22
  "packages/core/src/batches.ts": {
23
- "bytes": 6731,
24
- "sha256": "60725d766db72490aff5008c87d012d9992a2a1a66254781b67ee9cf72493c61"
23
+ "bytes": 7425,
24
+ "sha256": "3008c10b6c1625d251a9eb73a370042bb000b4adc21e61cae9c0f1580b353a45"
25
25
  },
26
26
  "packages/core/src/context-menus.ts": {
27
27
  "bytes": 2592,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bun-native/core",
3
- "version": "0.37.7",
3
+ "version": "0.37.9",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -18,8 +18,8 @@
18
18
  },
19
19
  "description": "The public TypeScript API of the Bun Native desktop framework.",
20
20
  "dependencies": {
21
- "@bun-native/protocol": "0.37.7",
22
- "@bun-native/runtime": "0.37.7"
21
+ "@bun-native/protocol": "0.37.9",
22
+ "@bun-native/runtime": "0.37.9"
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",
@@ -96,7 +96,7 @@ import {
96
96
  type MessageDialogOptions,
97
97
  type MessageDialogResult,
98
98
  } from './message-dialogs.ts'
99
- import { runBatches, type BatchEntry } from './batches.ts'
99
+ import { runBatches, settleEntry, type BatchEntry } from './batches.ts'
100
100
  import { CommittedText, makeNode, own, Transaction, type NodeState } from './tree.ts'
101
101
  import {
102
102
  NativeStateError,
@@ -337,7 +337,7 @@ class Application implements NativeApplication {
337
337
  },
338
338
  (error: unknown) => {
339
339
  this.queued -= group.entries.length - 1
340
- for (const queued of group.entries) queued.reject(error)
340
+ for (const queued of group.entries) settleEntry(queued, true, error)
341
341
  }
342
342
  )
343
343
  this.openGroup = group
package/src/batches.ts CHANGED
@@ -5,7 +5,7 @@ import { NativeStateError, type NativeBatch } from './types.ts'
5
5
 
6
6
  /** One caller's batch callback, queued behind the transaction in flight. */
7
7
  export interface BatchEntry {
8
- readonly update: (batch: NativeBatch) => unknown
8
+ update: (batch: NativeBatch) => unknown
9
9
  resolve(value: unknown): void
10
10
  reject(error: unknown): void
11
11
  }
@@ -30,9 +30,22 @@ type Member = { entry: BatchEntry; transaction?: Transaction } & (
30
30
  | { failed: true; error: unknown }
31
31
  )
32
32
 
33
+ /** A finished entry cannot keep caller closures or its settled promise alive. */
34
+ const consumedEntry = () => {
35
+ throw new NativeStateError('invalid_state', 'Batch entry has already settled')
36
+ }
37
+
38
+ export function settleEntry(entry: BatchEntry, failed: boolean, value: unknown): void {
39
+ const callback = failed ? entry.reject : entry.resolve
40
+ entry.update = consumedUpdate
41
+ entry.resolve = consumedEntry
42
+ entry.reject = consumedEntry
43
+ callback(value)
44
+ }
45
+
33
46
  function settle(member: Member): void {
34
- if (member.failed) member.entry.reject(member.error)
35
- else member.entry.resolve(member.value)
47
+ if (member.failed) settleEntry(member.entry, true, member.error)
48
+ else settleEntry(member.entry, false, member.value)
36
49
  }
37
50
 
38
51
  function isThenable(value: unknown): boolean {
@@ -43,6 +56,11 @@ function isThenable(value: unknown): boolean {
43
56
  )
44
57
  }
45
58
 
59
+ /** A completed entry cannot run again or retain its caller's closure. */
60
+ const consumedUpdate = () => {
61
+ throw new NativeStateError('invalid_state', 'Batch callback has already run')
62
+ }
63
+
46
64
  /** Run one callback in its own transaction; a failure is that caller's alone. */
47
65
  function build(window: BatchWindow, entry: BatchEntry, base: Transaction | undefined): Member {
48
66
  let transaction: Transaction | undefined
@@ -62,6 +80,7 @@ function build(window: BatchWindow, entry: BatchEntry, base: Transaction | undef
62
80
  } catch (error) {
63
81
  return { entry, failed: true, error }
64
82
  } finally {
83
+ entry.update = consumedUpdate
65
84
  transaction?.finish()
66
85
  }
67
86
  }