@bun-native/protocol 0.33.0 → 0.33.2

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/src/index.ts CHANGED
@@ -1,55 +1,27 @@
1
- export { encodeFrame, FrameDecoder, MAX_FRAME_BYTES, ProtocolError } from './framing.ts'
2
- export {
3
- DECORATION_FIELDS,
4
- MAX_ACCESSIBLE_SET_SIZE,
5
- MAX_OVERLAY_DEPTH,
6
- parseElement,
7
- SPLIT_DIVIDER,
8
- type Element,
9
- type OverlayElement,
10
- type AccessibleLabel,
11
- type BoxAccessibility,
12
- type OverlayKeyboard,
13
- type SplitStyle,
14
- type Style,
15
- } from './elements.ts'
16
- export { MAX_TEXT_BYTES } from './values.ts'
1
+ export { encodeFrame, FrameDecoder, ProtocolError } from './framing.ts'
2
+ export { parseElement, type Element, type Style } from './elements.ts'
17
3
  export {
18
4
  FILE_ACCESS,
19
5
  fileResultAnswers,
20
6
  filesystemRootArgument,
21
7
  filesystemRootsFromArguments,
22
- MAX_DIRECTORY_ENTRIES,
23
- MAX_FILE_CHUNK_BYTES,
24
- MAX_FILE_GRANTS,
25
- MAX_FILESYSTEM_ROOTS,
26
8
  parseFilePath,
27
9
  parseFilesystemRoots,
28
10
  parseRootId,
29
- type DirectoryEntry,
30
11
  type FileAccess,
31
12
  type FileKind,
32
13
  type FileOperation,
33
14
  type FileResult,
34
- type FilesystemRoot,
35
15
  type WriteMode,
36
16
  } from './files.ts'
37
17
  export {
38
- MAX_PROCESS_ARGS,
39
- MAX_PROCESS_ENV,
40
- MAX_PROCESS_EXECUTABLES,
41
- MAX_PROCESS_OUTPUT_CREDIT,
42
- MAX_PROCESSES,
43
18
  parseProcessExecutables,
44
19
  parseProcessLaunch,
45
- parseProcessLimits,
46
20
  parseProcessLimitsArgument,
47
21
  PROCESS_SIGNALS,
48
22
  processArguments,
49
23
  processLimitsArgument,
50
24
  processesFromArguments,
51
- type ProcessExecutable,
52
- type ProcessLimits,
53
25
  type ProcessExit,
54
26
  type ProcessLaunch,
55
27
  type ProcessSignal,
@@ -58,68 +30,26 @@ export {
58
30
  } from './processes.ts'
59
31
  export {
60
32
  APP_MENU_KEYS,
61
- APP_MENU_NAMED_KEYS,
62
- APP_MENU_PUNCTUATION_KEYS,
63
- MAX_APP_MENU_DEPTH,
64
- MAX_APP_MENU_ENTRIES,
65
- MAX_APP_MENU_ITEM_ID_BYTES,
66
- MAX_APP_MENU_LABEL_BYTES,
67
- MAX_APP_MENUS,
68
33
  parseAppMenus,
69
34
  parseContextMenuItems,
70
35
  type AppMenu,
71
36
  type AppMenuEntry,
72
- type MenuShortcut,
73
- type MenuShortcutModifiers,
74
37
  } from './app-menu.ts'
75
38
  export {
76
39
  FILE_DIALOG_MODES,
77
- MAX_DIALOG_FILTER_NAME_BYTES,
78
- MAX_DIALOG_FILTER_PATTERNS,
79
- MAX_DIALOG_FILTERS,
80
- MAX_DIALOG_LABEL_BYTES,
81
- MAX_DIALOG_NAME_BYTES,
82
- MAX_DIALOG_PATH_BYTES,
83
- MAX_DIALOG_PATHS,
84
- MAX_DIALOG_PATTERN_BYTES,
85
- MAX_DIALOG_TITLE_BYTES,
86
- MAX_FILE_DIALOGS,
87
40
  parseFileDialogOptions,
88
41
  type FileDialogMode,
89
42
  type FileDialogOptions,
90
43
  type FileDialogResult,
91
- type FileFilter,
92
44
  } from './dialogs.ts'
93
45
  export {
94
- MAX_MESSAGE_DIALOG_BUTTONS,
95
- MAX_MESSAGE_DIALOG_DETAIL_BYTES,
96
- MAX_MESSAGE_DIALOG_ID_BYTES,
97
- MAX_MESSAGE_DIALOG_LABEL_BYTES,
98
- MAX_MESSAGE_DIALOG_MESSAGE_BYTES,
99
- MAX_MESSAGE_DIALOG_TITLE_BYTES,
100
- MAX_MESSAGE_DIALOGS,
101
- parseMessageDialogOptions,
102
46
  type MessageDialogButton,
103
47
  type MessageDialogOptions,
104
48
  type MessageDialogResult,
105
49
  } from './message-dialogs.ts'
106
- export {
107
- DRAG_STATES,
108
- DROP_REJECTIONS,
109
- MAX_DROP_ITEMS,
110
- MAX_DROP_NAME_BYTES,
111
- MAX_DROP_TARGETS,
112
- type DragState,
113
- type DroppedItem,
114
- type DropRejection,
115
- } from './drops.ts'
50
+ export { DRAG_STATES, DROP_REJECTIONS, type DropRejection } from './drops.ts'
116
51
  export {
117
52
  GLOBAL_SHORTCUT_KEYS,
118
- MAX_CLIPBOARD_BYTES,
119
- MAX_GLOBAL_SHORTCUTS,
120
- MAX_NOTIFICATION_BODY_BYTES,
121
- MAX_NOTIFICATION_TITLE_BYTES,
122
- MAX_NOTIFICATIONS,
123
53
  NOTIFICATION_DISMISSALS,
124
54
  type ClipboardText,
125
55
  type DisplaySnapshot,
@@ -129,16 +59,14 @@ export {
129
59
  type ShortcutModifiers,
130
60
  } from './services.ts'
131
61
  export {
132
- DEFAULT_LIMITS,
133
- ERROR_CODES,
134
- MAX_OPERATIONS,
135
- MAX_SCROLL_OFFSET,
62
+ OperationList,
136
63
  parseCommand,
137
64
  parseEvent,
138
- PROTOCOL_VERSION,
139
- REQUIRED_CAPABILITIES,
140
65
  type Command,
66
+ type ApplicationEvent,
67
+ type HostEvent,
141
68
  type NativeEvent,
69
+ type WindowEvent,
142
70
  type Operation,
143
71
  type Limits,
144
72
  type ErrorCode,
@@ -148,3 +76,53 @@ export {
148
76
  type DismissReason,
149
77
  type ResizeSource,
150
78
  } from './messages.ts'
79
+ export {
80
+ DECORATION_FIELDS,
81
+ DEFAULT_LIMITS,
82
+ ERROR_CODES,
83
+ MAX_APP_MENU_DEPTH,
84
+ MAX_APP_MENU_ENTRIES,
85
+ MAX_CLIPBOARD_BYTES,
86
+ MAX_DIALOG_FILTER_NAME_BYTES,
87
+ MAX_DIALOG_FILTER_PATTERNS,
88
+ MAX_DIALOG_FILTERS,
89
+ MAX_DIALOG_LABEL_BYTES,
90
+ MAX_DIALOG_NAME_BYTES,
91
+ MAX_DIALOG_PATH_BYTES,
92
+ MAX_DIALOG_PATHS,
93
+ MAX_DIALOG_PATTERN_BYTES,
94
+ MAX_DIALOG_TITLE_BYTES,
95
+ MAX_DIRECTORY_ENTRIES,
96
+ MAX_DROP_ITEMS,
97
+ MAX_DROP_NAME_BYTES,
98
+ MAX_DROP_TARGETS,
99
+ MAX_EVENT_FRAME_BYTES,
100
+ MAX_FILE_CHUNK_BYTES,
101
+ MAX_FILE_DIALOGS,
102
+ MAX_FILE_GRANTS,
103
+ MAX_FILESYSTEM_ROOTS,
104
+ MAX_FRAME_BYTES,
105
+ MAX_GLOBAL_SHORTCUTS,
106
+ MAX_MESSAGE_DIALOG_BUTTONS,
107
+ MAX_MESSAGE_DIALOG_DETAIL_BYTES,
108
+ MAX_MESSAGE_DIALOG_ID_BYTES,
109
+ MAX_MESSAGE_DIALOG_LABEL_BYTES,
110
+ MAX_MESSAGE_DIALOG_MESSAGE_BYTES,
111
+ MAX_MESSAGE_DIALOG_TITLE_BYTES,
112
+ MAX_NOTIFICATION_BODY_BYTES,
113
+ MAX_NOTIFICATION_TITLE_BYTES,
114
+ MAX_NOTIFICATIONS,
115
+ MAX_OPERATIONS,
116
+ MAX_OVERLAY_DEPTH,
117
+ MAX_POINTER_COORDINATE,
118
+ MAX_PROCESS_ARGS,
119
+ MAX_PROCESS_ENV,
120
+ MAX_PROCESS_EXECUTABLES,
121
+ MAX_PROCESS_OUTPUT_CREDIT,
122
+ MAX_PROCESSES,
123
+ MAX_SCROLL_OFFSET,
124
+ MAX_TEXT_BYTES,
125
+ PROTOCOL_VERSION,
126
+ REQUIRED_CAPABILITIES,
127
+ SPLIT_DIVIDER,
128
+ } from './wire-schema.ts'
@@ -1,14 +1,14 @@
1
1
  import { ProtocolError } from './framing.ts'
2
2
  import { keys, object, string } from './values.ts'
3
-
4
- /** Live OS message dialogs per session. Each window owns at most one at a time. */
5
- export const MAX_MESSAGE_DIALOGS = 16
6
- export const MAX_MESSAGE_DIALOG_BUTTONS = 4
7
- export const MAX_MESSAGE_DIALOG_TITLE_BYTES = 256
8
- export const MAX_MESSAGE_DIALOG_MESSAGE_BYTES = 2_048
9
- export const MAX_MESSAGE_DIALOG_DETAIL_BYTES = 4_096
10
- export const MAX_MESSAGE_DIALOG_LABEL_BYTES = 64
11
- export const MAX_MESSAGE_DIALOG_ID_BYTES = 64
3
+ import {
4
+ MAX_MESSAGE_DIALOG_BUTTONS,
5
+ MAX_MESSAGE_DIALOG_DETAIL_BYTES,
6
+ MAX_MESSAGE_DIALOG_ID_BYTES,
7
+ MAX_MESSAGE_DIALOG_LABEL_BYTES,
8
+ MAX_MESSAGE_DIALOG_MESSAGE_BYTES,
9
+ MAX_MESSAGE_DIALOG_TITLE_BYTES,
10
+ PAYLOAD_KEYS,
11
+ } from './wire-schema.ts'
12
12
 
13
13
  export interface MessageDialogButton {
14
14
  id: string
@@ -41,7 +41,7 @@ function text(value: unknown, field: string, limit: number, block: boolean): str
41
41
 
42
42
  function button(value: unknown): MessageDialogButton {
43
43
  const data = object(value)
44
- keys(data, ['id', 'label'])
44
+ keys(data, PAYLOAD_KEYS.message_dialog_button)
45
45
  return {
46
46
  id: text(data['id'], 'message dialog button id', MAX_MESSAGE_DIALOG_ID_BYTES, false),
47
47
  label: text(
@@ -55,15 +55,7 @@ function button(value: unknown): MessageDialogButton {
55
55
 
56
56
  export function parseMessageDialogOptions(value: unknown): MessageDialogOptions {
57
57
  const data = object(value)
58
- keys(data, [
59
- 'title',
60
- 'message',
61
- 'detail',
62
- 'buttons',
63
- 'default_button',
64
- 'cancel_button',
65
- 'dismissible',
66
- ])
58
+ keys(data, PAYLOAD_KEYS.message_dialog_options)
67
59
  const list = data['buttons']
68
60
  if (!Array.isArray(list) || list.length < 1 || list.length > MAX_MESSAGE_DIALOG_BUTTONS)
69
61
  throw new ProtocolError('A message dialog needs between 1 and 4 buttons')
@@ -108,16 +100,16 @@ export function parseMessageDialogResult(value: unknown): MessageDialogResult {
108
100
  const data = object(value)
109
101
  switch (data['kind']) {
110
102
  case 'button':
111
- keys(data, ['kind', 'id'])
103
+ keys(data, PAYLOAD_KEYS.message_dialog_result.button)
112
104
  return {
113
105
  kind: 'button',
114
106
  id: text(data['id'], 'message dialog result id', MAX_MESSAGE_DIALOG_ID_BYTES, false),
115
107
  }
116
108
  case 'dismissed':
117
- keys(data, ['kind'])
109
+ keys(data, PAYLOAD_KEYS.message_dialog_result.dismissed)
118
110
  return { kind: 'dismissed' }
119
111
  case 'failed':
120
- keys(data, ['kind'])
112
+ keys(data, PAYLOAD_KEYS.message_dialog_result.failed)
121
113
  return { kind: 'failed' }
122
114
  default:
123
115
  throw new ProtocolError('Unknown message dialog result')