@inflatable-cookie/longhorn 0.4.3 → 0.6.0

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.
Files changed (126) hide show
  1. package/package.json +1 -1
  2. package/src/agent-control/inject.ts +4 -1
  3. package/src/agent-control/selection.ts +35 -20
  4. package/src/agent-control/shim.ts +302 -144
  5. package/src/bridge/direct.ts +1 -1
  6. package/src/bridge/generated/fields.ts +3 -2
  7. package/src/bridge/generated/protocol.ts +7 -3
  8. package/src/bridge/job.ts +4 -14
  9. package/src/bridge/loopback.ts +7 -25
  10. package/src/bridge/operation.ts +13 -43
  11. package/src/bridge/router.ts +10 -23
  12. package/src/bridge/runtime/connection.ts +77 -105
  13. package/src/bridge/runtime/policy.ts +8 -28
  14. package/src/bridge/runtime/retry.ts +6 -18
  15. package/src/bridge/session.ts +4 -14
  16. package/src/bridge/stream/connection.ts +16 -38
  17. package/src/bridge/stream/source.ts +2 -6
  18. package/src/bridge/stream/tracker.ts +7 -12
  19. package/src/bridge/supervision.ts +11 -26
  20. package/src/bridge/validation/base.ts +17 -39
  21. package/src/bridge/validation/jobs.ts +11 -25
  22. package/src/bridge/validation/negotiation.ts +27 -37
  23. package/src/bridge/validation/operations.ts +28 -52
  24. package/src/bridge/validation/streams.ts +3 -10
  25. package/src/commands/client.ts +21 -26
  26. package/src/commands/controller.ts +32 -47
  27. package/src/commands/generated/fields.ts +3 -2
  28. package/src/commands/generated/protocol.ts +4 -0
  29. package/src/commands/keyboard.ts +92 -89
  30. package/src/commands/ports.ts +6 -12
  31. package/src/commands/projectors.ts +50 -48
  32. package/src/commands/validation.ts +70 -97
  33. package/src/config/client.ts +6 -19
  34. package/src/config/generated/fields.ts +2 -2
  35. package/src/config/names.ts +6 -12
  36. package/src/config/validation/commands.ts +5 -17
  37. package/src/config/validation/outcomes.ts +31 -39
  38. package/src/config/validation/primitives.ts +36 -53
  39. package/src/config/validation/projection.ts +66 -94
  40. package/src/core/connection.ts +70 -61
  41. package/src/core/record.ts +4 -0
  42. package/src/core/transport.ts +4 -15
  43. package/src/core/wire-copy.ts +6 -0
  44. package/src/history/client.ts +6 -12
  45. package/src/history/controller.ts +46 -46
  46. package/src/history/direct.ts +1 -3
  47. package/src/history/generated/fields.ts +2 -2
  48. package/src/history/ports.ts +4 -6
  49. package/src/history/serialized.ts +9 -13
  50. package/src/history/validation.ts +71 -55
  51. package/src/history-tree/client.ts +87 -11
  52. package/src/history-tree/controller.ts +313 -70
  53. package/src/history-tree/direct.ts +3 -1
  54. package/src/history-tree/generated/fields.ts +2 -2
  55. package/src/history-tree/ports.ts +3 -1
  56. package/src/history-tree/serialized.ts +39 -11
  57. package/src/history-tree/validation.ts +262 -63
  58. package/src/layout/generated/protocol.ts +2 -2
  59. package/src/layout/ratio.ts +2 -8
  60. package/src/layout/validation.ts +10 -19
  61. package/src/layout/visibility.ts +1 -2
  62. package/src/licence/client.ts +44 -7
  63. package/src/licence/controller.ts +76 -40
  64. package/src/licence/direct.ts +3 -1
  65. package/src/licence/generated/fields.ts +2 -2
  66. package/src/licence/generated/key-conformance.json +28 -0
  67. package/src/licence/generated/protocol.ts +1 -1
  68. package/src/licence/key.ts +40 -12
  69. package/src/licence/ports.ts +3 -1
  70. package/src/licence/serialized.ts +32 -9
  71. package/src/licence/validation.ts +120 -36
  72. package/src/native-content/client.ts +178 -236
  73. package/src/native-content/generated/fields.ts +2 -2
  74. package/src/native-content/ports.ts +9 -15
  75. package/src/native-content/serialized.ts +12 -19
  76. package/src/native-content/validation/base.ts +57 -50
  77. package/src/native-content/validation/messages.ts +21 -35
  78. package/src/native-content/validation/state.ts +31 -33
  79. package/src/notifications/client.ts +87 -31
  80. package/src/notifications/controller.ts +215 -61
  81. package/src/notifications/direct.ts +3 -1
  82. package/src/notifications/generated/fields.ts +2 -2
  83. package/src/notifications/ports.ts +7 -3
  84. package/src/notifications/serialized.ts +11 -9
  85. package/src/notifications/validation.ts +147 -43
  86. package/src/operation/bridge.ts +117 -50
  87. package/src/operation/client.ts +38 -24
  88. package/src/operation/controller.ts +33 -42
  89. package/src/operation/direct.ts +1 -3
  90. package/src/operation/generated/fields.ts +2 -2
  91. package/src/operation/ports.ts +10 -9
  92. package/src/operation/serialized.ts +8 -9
  93. package/src/operation/validation.ts +152 -65
  94. package/src/settings/client.ts +11 -44
  95. package/src/settings/connection.ts +26 -40
  96. package/src/settings/generated/fields.ts +3 -3
  97. package/src/settings/generated/protocol.ts +9 -4
  98. package/src/settings/names.ts +2 -4
  99. package/src/settings/registry.ts +23 -25
  100. package/src/settings/validation/authority.ts +19 -17
  101. package/src/settings/validation/command.ts +17 -37
  102. package/src/settings/validation/error.ts +2 -8
  103. package/src/settings/validation/primitives.ts +26 -42
  104. package/src/settings/validation/projection.ts +8 -24
  105. package/src/settings/validation/registry.ts +25 -73
  106. package/src/surface-transfer/client.ts +6 -18
  107. package/src/surface-transfer/generated/fields.ts +2 -2
  108. package/src/surface-transfer/validation.ts +31 -49
  109. package/src/surfaces/client.ts +12 -22
  110. package/src/surfaces/generated/fields.ts +2 -2
  111. package/src/surfaces/validation.ts +40 -49
  112. package/src/transfer/client.ts +26 -60
  113. package/src/transfer/connection.ts +12 -20
  114. package/src/transfer/generated/fields.ts +5 -5
  115. package/src/transfer/generated/protocol.ts +4 -4
  116. package/src/transfer/payload.ts +13 -31
  117. package/src/transfer/validation.ts +39 -75
  118. package/src/update/client.ts +59 -9
  119. package/src/update/controller.ts +113 -48
  120. package/src/update/direct.ts +3 -1
  121. package/src/update/generated/fields.ts +3 -3
  122. package/src/update/generated/protocol.ts +7 -3
  123. package/src/update/generated/variant-fields.ts +1 -0
  124. package/src/update/ports.ts +6 -2
  125. package/src/update/serialized.ts +34 -10
  126. package/src/update/validation.ts +115 -35
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inflatable-cookie/longhorn",
3
- "version": "0.4.3",
3
+ "version": "0.6.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,4 +1,7 @@
1
- import { installAgentControlShim, type ShimWorld } from "./shim.ts";
1
+ import { installAgentControlShim } from "./shim.ts";
2
+ import type { ShimWorld } from "./shim.ts";
2
3
 
4
+ // The standalone IIFE runs in the browser world carrying these DOM globals.
5
+ // oxlint-disable-next-line typescript/no-unsafe-type-assertion, quality/no-chained-type-assertions -- The injection host supplies the browser world, including its dynamically installed shim key.
3
6
  const target = globalThis as unknown as ShimWorld;
4
7
  installAgentControlShim(target);
@@ -4,7 +4,8 @@
4
4
  //! opens. Human-originated calls pass the original options to the plugin
5
5
  //! unchanged. Origin is the in-page shim, not an active-server flag.
6
6
 
7
- import { SHIM_GLOBAL, type AgentControlApi } from "./shim.ts";
7
+ import { SHIM_GLOBAL } from "./shim.ts";
8
+ import type { AgentControlApi } from "./shim.ts";
8
9
 
9
10
  /** Renderer invoke name. Host-protocol pairs this with the Rust command. */
10
11
  export const BEGIN_SELECTION_COMMAND = "longhorn_agent_control_begin_selection";
@@ -23,13 +24,13 @@ export type SelectionOrigin = typeof SELECTION_ORIGIN_AGENT | typeof SELECTION_O
23
24
 
24
25
  export type DialogFilter = {
25
26
  name: string;
26
- extensions: string[];
27
+ extensions: Array<string>;
27
28
  };
28
29
 
29
30
  export type OpenDialogOptions = {
30
31
  title?: string;
31
32
  defaultPath?: string;
32
- filters?: DialogFilter[];
33
+ filters?: Array<DialogFilter>;
33
34
  multiple?: boolean;
34
35
  directory?: boolean;
35
36
  };
@@ -37,10 +38,10 @@ export type OpenDialogOptions = {
37
38
  export type SaveDialogOptions = {
38
39
  title?: string;
39
40
  defaultPath?: string;
40
- filters?: DialogFilter[];
41
+ filters?: Array<DialogFilter>;
41
42
  };
42
43
 
43
- export type OpenDialogResult = string | string[] | null;
44
+ export type OpenDialogResult = string | Array<string> | null;
44
45
  export type SaveDialogResult = string | null;
45
46
 
46
47
  export type FileSelectionPorts = {
@@ -66,17 +67,13 @@ function isAgentOriginated(world: FileSelectionWorld): boolean {
66
67
  * Page origin as a command-argument token. Reads the installed shim;
67
68
  * with no shim, or when the shim reports human, the token is `"human"`.
68
69
  */
70
+ // oxlint-disable-next-line quality/no-object-parameters -- The world is a page global with an optional shim, including plain host test doubles.
69
71
  export function currentSelectionOrigin(world: object = globalThis): SelectionOrigin {
70
- return isAgentOriginated(world as FileSelectionWorld)
71
- ? SELECTION_ORIGIN_AGENT
72
- : SELECTION_ORIGIN_HUMAN;
72
+ return isAgentOriginated(world) ? SELECTION_ORIGIN_AGENT : SELECTION_ORIGIN_HUMAN;
73
73
  }
74
74
 
75
- function beginOptions(
76
- kind: "open" | "save",
77
- options: OpenDialogOptions | SaveDialogOptions | undefined,
78
- ): Record<string, unknown> {
79
- const open = kind === "open" ? (options as OpenDialogOptions | undefined) : undefined;
75
+ function beginOptions(kind: "open" | "save", options: OpenDialogOptions | undefined) {
76
+ const open = kind === "open" ? options : undefined;
80
77
  return {
81
78
  kind,
82
79
  directory: open?.directory ?? false,
@@ -93,21 +90,39 @@ function beginOptions(
93
90
  */
94
91
  export function bindFileSelection(
95
92
  ports: FileSelectionPorts,
93
+ // oxlint-disable-next-line quality/no-object-parameters -- The world is a page global with an optional shim.
96
94
  world: object = globalThis,
97
95
  ): FileSelectionApi {
98
- const originWorld = world as FileSelectionWorld;
99
96
  return {
100
97
  open: async (options?: OpenDialogOptions) => {
101
- if (!isAgentOriginated(originWorld)) return ports.pluginOpen(options);
102
- return (await ports.invoke(BEGIN_SELECTION_COMMAND, {
98
+ if (!isAgentOriginated(world)) {
99
+ return ports.pluginOpen(options);
100
+ }
101
+ const result = await ports.invoke(BEGIN_SELECTION_COMMAND, {
103
102
  options: beginOptions("open", options),
104
- })) as OpenDialogResult;
103
+ });
104
+ if (result === null || typeof result === "string") {
105
+ return result;
106
+ }
107
+ if (
108
+ Array.isArray(result) &&
109
+ result.every((path): path is string => typeof path === "string")
110
+ ) {
111
+ return result;
112
+ }
113
+ throw new TypeError("invalid agent open-dialog result");
105
114
  },
106
115
  save: async (options?: SaveDialogOptions) => {
107
- if (!isAgentOriginated(originWorld)) return ports.pluginSave(options);
108
- return (await ports.invoke(BEGIN_SELECTION_COMMAND, {
116
+ if (!isAgentOriginated(world)) {
117
+ return ports.pluginSave(options);
118
+ }
119
+ const result = await ports.invoke(BEGIN_SELECTION_COMMAND, {
109
120
  options: beginOptions("save", options),
110
- })) as SaveDialogResult;
121
+ });
122
+ if (result === null || typeof result === "string") {
123
+ return result;
124
+ }
125
+ throw new TypeError("invalid agent save-dialog result");
111
126
  },
112
127
  };
113
128
  }