@bun-native/core 0.33.2 → 0.33.4

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/0xPlayerOne/bun-native), an experimental developer preview. Version 0.33.2 was built from [577f6fc5015b](https://github.com/0xPlayerOne/bun-native/tree/577f6fc5015b6eeef956efcc63f97e2a749d74ff) 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/0xPlayerOne/bun-native/blob/577f6fc5015b6eeef956efcc63f97e2a749d74ff/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/0xPlayerOne/bun-native), an experimental developer preview. Version 0.33.4 was built from [15878c8be33a](https://github.com/0xPlayerOne/bun-native/tree/15878c8be33a5e2e551ec410efa913d766322d58) 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/0xPlayerOne/bun-native/blob/15878c8be33a5e2e551ec410efa913d766322d58/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": "577f6fc5015b6eeef956efcc63f97e2a749d74ff",
4
- "tree": "c599e781af2ce0749d5e3a6d8700834690e872f4",
3
+ "commit": "15878c8be33a5e2e551ec410efa913d766322d58",
4
+ "tree": "a171291687ce489ba071fee44181bde13ce4a858",
5
5
  "files": {
6
6
  "package.json": {
7
7
  "bytes": 2258,
8
- "sha256": "38e2f0f89b5f6c4ba80b3baefcdf0806dd73c684294153df74ab470fda6bf3f9"
8
+ "sha256": "18b028c0ddc8ed94f8dc8c8bb8e3e953a19ba65818acf19b829d70221caeca6b"
9
9
  },
10
10
  "packages/core/package.json": {
11
11
  "bytes": 282,
@@ -92,8 +92,8 @@
92
92
  "sha256": "c460c4e1a2e9d337e79294bce333e53896381529af8f7e35b23e207c6e132b85"
93
93
  },
94
94
  "packages/core/src/tree.ts": {
95
- "bytes": 26849,
96
- "sha256": "625288cead96ed1705dcadbb7e88382c4b1e9db5999ec26550521095939bfc0f"
95
+ "bytes": 27909,
96
+ "sha256": "51e2edcc0f1e6d5d92e1f7edf79c6dc6bc5c2f5acc8bffa20b211523f3971bb8"
97
97
  },
98
98
  "packages/core/src/types.ts": {
99
99
  "bytes": 14315,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bun-native/core",
3
- "version": "0.33.2",
3
+ "version": "0.33.4",
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.33.2",
22
- "@bun-native/runtime": "0.33.2"
21
+ "@bun-native/protocol": "0.33.4",
22
+ "@bun-native/runtime": "0.33.4"
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",
package/src/tree.ts CHANGED
@@ -473,8 +473,29 @@ export class Transaction implements NativeBatch {
473
473
  throw new NativeStateError('invalid_state', 'Child insertion index is out of range')
474
474
  child = this.writable(child)
475
475
  if (child.parent !== undefined) {
476
- const previous = this.writable(this.nodes.get(child.parent)!)
477
- previous.children.splice(previous.children.indexOf(child.id), 1)
476
+ const siblings = this.writable(this.nodes.get(child.parent)!).children
477
+ if (child.parent === parent.id) {
478
+ const from =
479
+ siblings[siblings.length - 1] === child.id
480
+ ? siblings.length - 1
481
+ : siblings.indexOf(child.id)
482
+ // Adjacent moves swap two entries; a no-op still emits an insert.
483
+ if (Math.abs(from - index) === 1) {
484
+ siblings[from] = siblings[index]!
485
+ siblings[index] = child.id
486
+ } else if (from === 0 && index > 0 && index === siblings.length - 1) {
487
+ siblings.shift()
488
+ siblings.push(child.id)
489
+ } else if (from !== index) {
490
+ siblings.splice(from, 1)
491
+ siblings.splice(index, 0, child.id)
492
+ }
493
+ this.attached.push(child.id)
494
+ this.operations.insert(parent.id, child.id, index)
495
+ return
496
+ }
497
+ if (siblings[siblings.length - 1] === child.id) siblings.pop()
498
+ else siblings.splice(siblings.indexOf(child.id), 1)
478
499
  }
479
500
  parent = this.writable(parent)
480
501
  parent.children.splice(index, 0, child.id)
@@ -622,11 +643,17 @@ export class Transaction implements NativeBatch {
622
643
  */
623
644
  validate(): void {
624
645
  const { limits, nodes } = this
625
- if (this.text.oversized.size || this.textBytes() > limits.max_text_bytes_per_window)
626
- return this.walk()
627
- for (const node of nodes.writes.values())
628
- for (const size of textSizesOf(node.element))
646
+ if (this.text.oversized.size) return this.walk()
647
+ let bytes = this.text.bytes
648
+ for (const [id, node] of nodes.writes) {
649
+ bytes -= textBytesOf(nodes.base.get(id)?.element)
650
+ for (const size of textSizesOf(node.element)) {
629
651
  if (size > limits.max_text_bytes) return this.walk()
652
+ bytes += size
653
+ }
654
+ }
655
+ for (const id of nodes.deletes) bytes -= textBytesOf(nodes.base.get(id)?.element)
656
+ if (bytes > limits.max_text_bytes_per_window) return this.walk()
630
657
  const seen = new Set<number>()
631
658
  // Flat (id, depth) pairs.
632
659
  const pending: number[] = []