@bun-native/core 0.37.7 → 0.37.8
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 +1 -1
- package/bun-native-source.json +7 -7
- package/package.json +3 -3
- package/src/application.ts +2 -2
- package/src/batches.ts +22 -3
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.
|
|
5
|
+
Part of [Bun Native](https://github.com/AndrewM-F/bun-native), an experimental developer preview. Version 0.37.8 was built from [c9d259f4519c](https://github.com/AndrewM-F/bun-native/tree/c9d259f4519c46fd015aeb6ef3370a9d8cb09fd7) 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/c9d259f4519c46fd015aeb6ef3370a9d8cb09fd7/docs/getting-started.md); `bun-native host install` fetches the matching release host. The license notice is in LICENSE.
|
package/bun-native-source.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"commit": "
|
|
4
|
-
"tree": "
|
|
3
|
+
"commit": "c9d259f4519c46fd015aeb6ef3370a9d8cb09fd7",
|
|
4
|
+
"tree": "c85ae1e3faa2007047bd0ae1620e231cf82daa21",
|
|
5
5
|
"files": {
|
|
6
6
|
"package.json": {
|
|
7
7
|
"bytes": 2259,
|
|
8
|
-
"sha256": "
|
|
8
|
+
"sha256": "5b02cfa24c7a1d867d7d757c9216c7d3f60d92ceb7ede72bb3a415bcdcbdae4b"
|
|
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":
|
|
20
|
-
"sha256": "
|
|
19
|
+
"bytes": 67175,
|
|
20
|
+
"sha256": "a1c955eff1c9d08f65454f87d83f4147e9f2787fc798c41472985289288237c3"
|
|
21
21
|
},
|
|
22
22
|
"packages/core/src/batches.ts": {
|
|
23
|
-
"bytes":
|
|
24
|
-
"sha256": "
|
|
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.
|
|
3
|
+
"version": "0.37.8",
|
|
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.
|
|
22
|
-
"@bun-native/runtime": "0.37.
|
|
21
|
+
"@bun-native/protocol": "0.37.8",
|
|
22
|
+
"@bun-native/runtime": "0.37.8"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|
package/src/application.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
|
35
|
-
else member.entry
|
|
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
|
}
|