@scalar/workspace-store 0.17.0 → 0.18.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 (182) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/dist/client.d.ts +38 -26
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +286 -84
  5. package/dist/client.js.map +3 -3
  6. package/dist/events/bus.d.ts +86 -0
  7. package/dist/events/bus.d.ts.map +1 -0
  8. package/dist/events/bus.js +58 -0
  9. package/dist/events/bus.js.map +7 -0
  10. package/dist/events/definitions/analytics.d.ts +27 -0
  11. package/dist/events/definitions/analytics.d.ts.map +1 -0
  12. package/dist/events/definitions/analytics.js +1 -0
  13. package/dist/events/definitions/analytics.js.map +7 -0
  14. package/dist/events/definitions/auth.d.ts +30 -0
  15. package/dist/events/definitions/auth.d.ts.map +1 -0
  16. package/dist/events/definitions/auth.js +1 -0
  17. package/dist/events/definitions/auth.js.map +7 -0
  18. package/dist/events/definitions/document.d.ts +14 -0
  19. package/dist/events/definitions/document.d.ts.map +1 -0
  20. package/dist/events/definitions/document.js +1 -0
  21. package/dist/events/definitions/document.js.map +7 -0
  22. package/dist/events/definitions/index.d.ts +10 -0
  23. package/dist/events/definitions/index.d.ts.map +1 -0
  24. package/dist/events/definitions/index.js +1 -0
  25. package/dist/events/definitions/index.js.map +7 -0
  26. package/dist/events/definitions/meta.d.ts +11 -0
  27. package/dist/events/definitions/meta.d.ts.map +1 -0
  28. package/dist/events/definitions/meta.js +1 -0
  29. package/dist/events/definitions/meta.js.map +7 -0
  30. package/dist/events/definitions/operation.d.ts +11 -0
  31. package/dist/events/definitions/operation.d.ts.map +1 -0
  32. package/dist/events/definitions/operation.js +1 -0
  33. package/dist/events/definitions/operation.js.map +7 -0
  34. package/dist/events/definitions/server.d.ts +50 -0
  35. package/dist/events/definitions/server.d.ts.map +1 -0
  36. package/dist/events/definitions/server.js +1 -0
  37. package/dist/events/definitions/server.js.map +7 -0
  38. package/dist/events/definitions/ui.d.ts +52 -0
  39. package/dist/events/definitions/ui.d.ts.map +1 -0
  40. package/dist/events/definitions/ui.js +1 -0
  41. package/dist/events/definitions/ui.js.map +7 -0
  42. package/dist/events/index.d.ts +2 -1
  43. package/dist/events/index.d.ts.map +1 -1
  44. package/dist/events/index.js +3 -1
  45. package/dist/events/index.js.map +2 -2
  46. package/dist/events/listeners.d.ts +2 -1
  47. package/dist/events/listeners.d.ts.map +1 -1
  48. package/dist/events/listeners.js.map +2 -2
  49. package/dist/events/{definitions.d.ts → old-definitions.d.ts} +35 -11
  50. package/dist/events/old-definitions.d.ts.map +1 -0
  51. package/dist/events/{definitions.js → old-definitions.js} +1 -1
  52. package/dist/events/old-definitions.js.map +7 -0
  53. package/dist/helpers/debounce.d.ts +28 -0
  54. package/dist/helpers/debounce.d.ts.map +1 -0
  55. package/dist/helpers/debounce.js +31 -0
  56. package/dist/helpers/debounce.js.map +7 -0
  57. package/dist/helpers/detect-changes-proxy.d.ts +47 -0
  58. package/dist/helpers/detect-changes-proxy.d.ts.map +1 -0
  59. package/dist/helpers/detect-changes-proxy.js +59 -0
  60. package/dist/helpers/detect-changes-proxy.js.map +7 -0
  61. package/dist/helpers/overrides-proxy.d.ts +17 -6
  62. package/dist/helpers/overrides-proxy.d.ts.map +1 -1
  63. package/dist/helpers/overrides-proxy.js +33 -18
  64. package/dist/helpers/overrides-proxy.js.map +3 -3
  65. package/dist/helpers/unpack-proxy.d.ts +6 -0
  66. package/dist/helpers/unpack-proxy.d.ts.map +1 -0
  67. package/dist/helpers/unpack-proxy.js +9 -0
  68. package/dist/helpers/unpack-proxy.js.map +7 -0
  69. package/dist/mutators/request.d.ts +1 -1
  70. package/dist/mutators/request.d.ts.map +1 -1
  71. package/dist/mutators/request.js.map +1 -1
  72. package/dist/navigation/get-navigation-options.d.ts +1 -1
  73. package/dist/navigation/get-navigation-options.d.ts.map +1 -1
  74. package/dist/navigation/get-navigation-options.js +66 -54
  75. package/dist/navigation/get-navigation-options.js.map +2 -2
  76. package/dist/navigation/helpers/get-tag.d.ts +7 -2
  77. package/dist/navigation/helpers/get-tag.d.ts.map +1 -1
  78. package/dist/navigation/helpers/get-tag.js +16 -2
  79. package/dist/navigation/helpers/get-tag.js.map +2 -2
  80. package/dist/navigation/helpers/traverse-description.d.ts +7 -2
  81. package/dist/navigation/helpers/traverse-description.d.ts.map +1 -1
  82. package/dist/navigation/helpers/traverse-description.js +24 -6
  83. package/dist/navigation/helpers/traverse-description.js.map +2 -2
  84. package/dist/navigation/helpers/traverse-document.d.ts +5 -2
  85. package/dist/navigation/helpers/traverse-document.d.ts.map +1 -1
  86. package/dist/navigation/helpers/traverse-document.js +53 -15
  87. package/dist/navigation/helpers/traverse-document.js.map +2 -2
  88. package/dist/navigation/helpers/traverse-paths.d.ts +9 -3
  89. package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
  90. package/dist/navigation/helpers/traverse-paths.js +63 -9
  91. package/dist/navigation/helpers/traverse-paths.js.map +2 -2
  92. package/dist/navigation/helpers/traverse-schemas.d.ts +7 -8
  93. package/dist/navigation/helpers/traverse-schemas.d.ts.map +1 -1
  94. package/dist/navigation/helpers/traverse-schemas.js +35 -7
  95. package/dist/navigation/helpers/traverse-schemas.js.map +2 -2
  96. package/dist/navigation/helpers/traverse-tags.d.ts +8 -4
  97. package/dist/navigation/helpers/traverse-tags.d.ts.map +1 -1
  98. package/dist/navigation/helpers/traverse-tags.js +65 -17
  99. package/dist/navigation/helpers/traverse-tags.js.map +2 -2
  100. package/dist/navigation/helpers/traverse-webhooks.d.ts +9 -3
  101. package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
  102. package/dist/navigation/helpers/traverse-webhooks.js +43 -17
  103. package/dist/navigation/helpers/traverse-webhooks.js.map +2 -2
  104. package/dist/navigation/types.d.ts +5 -24
  105. package/dist/navigation/types.d.ts.map +1 -1
  106. package/dist/persistence/index.d.ts +86 -0
  107. package/dist/persistence/index.d.ts.map +1 -0
  108. package/dist/persistence/index.js +196 -0
  109. package/dist/persistence/index.js.map +7 -0
  110. package/dist/persistence/indexdb.d.ts +87 -0
  111. package/dist/persistence/indexdb.d.ts.map +1 -0
  112. package/dist/persistence/indexdb.js +125 -0
  113. package/dist/persistence/indexdb.js.map +7 -0
  114. package/dist/{plugins.d.ts → plugins/bundler/index.d.ts} +1 -1
  115. package/dist/plugins/bundler/index.d.ts.map +1 -0
  116. package/dist/{plugins.js → plugins/bundler/index.js} +2 -2
  117. package/dist/{plugins.js.map → plugins/bundler/index.js.map} +1 -1
  118. package/dist/plugins/client/index.d.ts +3 -0
  119. package/dist/plugins/client/index.d.ts.map +1 -0
  120. package/dist/plugins/client/index.js +5 -0
  121. package/dist/plugins/client/index.js.map +7 -0
  122. package/dist/plugins/client/persistence.d.ts +13 -0
  123. package/dist/plugins/client/persistence.d.ts.map +1 -0
  124. package/dist/plugins/client/persistence.js +57 -0
  125. package/dist/plugins/client/persistence.js.map +7 -0
  126. package/dist/schemas/extensions.d.ts +1 -0
  127. package/dist/schemas/extensions.d.ts.map +1 -1
  128. package/dist/schemas/extensions.js +1 -0
  129. package/dist/schemas/extensions.js.map +2 -2
  130. package/dist/schemas/inmemory-workspace.d.ts +73 -14
  131. package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
  132. package/dist/schemas/inmemory-workspace.js +1 -9
  133. package/dist/schemas/inmemory-workspace.js.map +2 -2
  134. package/dist/schemas/navigation.d.ts +128 -1
  135. package/dist/schemas/navigation.d.ts.map +1 -1
  136. package/dist/schemas/navigation.js +20 -1
  137. package/dist/schemas/navigation.js.map +2 -2
  138. package/dist/schemas/reference-config/index.d.ts +233 -200
  139. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  140. package/dist/schemas/reference-config/index.js.map +2 -2
  141. package/dist/schemas/reference-config/settings.d.ts +35 -3
  142. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  143. package/dist/schemas/reference-config/settings.js +1 -1
  144. package/dist/schemas/reference-config/settings.js.map +1 -1
  145. package/dist/schemas/v3.1/strict/openapi-document.d.ts +1165 -71
  146. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  147. package/dist/schemas/v3.1/strict/openapi-document.js +16 -9
  148. package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
  149. package/dist/schemas/v3.1/strict/parameter.d.ts +23 -1
  150. package/dist/schemas/v3.1/strict/parameter.d.ts.map +1 -1
  151. package/dist/schemas/v3.1/strict/parameter.js +5 -1
  152. package/dist/schemas/v3.1/strict/parameter.js.map +2 -2
  153. package/dist/schemas/v3.1/strict/ref-definitions.d.ts +2 -0
  154. package/dist/schemas/v3.1/strict/ref-definitions.d.ts.map +1 -1
  155. package/dist/schemas/v3.1/strict/ref-definitions.js +4 -1
  156. package/dist/schemas/v3.1/strict/ref-definitions.js.map +2 -2
  157. package/dist/schemas/v3.1/strict/schema.d.ts +2 -2
  158. package/dist/schemas/v3.1/strict/schema.d.ts.map +1 -1
  159. package/dist/schemas/v3.1/strict/schema.js +1 -1
  160. package/dist/schemas/v3.1/strict/schema.js.map +2 -2
  161. package/dist/schemas/workspace-specification/config.d.ts +35 -8
  162. package/dist/schemas/workspace-specification/config.d.ts.map +1 -1
  163. package/dist/schemas/workspace-specification/config.js.map +1 -1
  164. package/dist/schemas/workspace-specification/index.d.ts +38 -5
  165. package/dist/schemas/workspace-specification/index.d.ts.map +1 -1
  166. package/dist/schemas/workspace-specification/index.js.map +1 -1
  167. package/dist/schemas/workspace.d.ts +245 -17
  168. package/dist/schemas/workspace.d.ts.map +1 -1
  169. package/dist/schemas/workspace.js +3 -1
  170. package/dist/schemas/workspace.js.map +2 -2
  171. package/dist/server.d.ts +4 -3
  172. package/dist/server.d.ts.map +1 -1
  173. package/dist/server.js +7 -6
  174. package/dist/server.js.map +2 -2
  175. package/dist/workspace-plugin.d.ts +49 -0
  176. package/dist/workspace-plugin.d.ts.map +1 -0
  177. package/dist/workspace-plugin.js +1 -0
  178. package/dist/workspace-plugin.js.map +7 -0
  179. package/package.json +22 -10
  180. package/dist/events/definitions.d.ts.map +0 -1
  181. package/dist/events/definitions.js.map +0 -7
  182. package/dist/plugins.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,69 @@
1
1
  # @scalar/workspace-store
2
2
 
3
+ ## 0.18.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#7185](https://github.com/scalar/scalar/pull/7185) [`6ca835e`](https://github.com/scalar/scalar/commit/6ca835e5afd3e8c603e073e7c83f2cdd961a0f69) Thanks [@DemonHa](https://github.com/DemonHa)! - feat: add support for watch mode
8
+
9
+ - [#7129](https://github.com/scalar/scalar/pull/7129) [`6ec8c29`](https://github.com/scalar/scalar/commit/6ec8c299d912111b029e8058979d00968b70691a) Thanks [@geoffgscott](https://github.com/geoffgscott)! - feat: prefix generated navigation ids with the document name
10
+
11
+ - [#7136](https://github.com/scalar/scalar/pull/7136) [`75ad74c`](https://github.com/scalar/scalar/commit/75ad74c0eee10103b966ce4707e4823d819456a8) Thanks [@DemonHa](https://github.com/DemonHa)! - feat(workspace-store): persistence layer for client store
12
+
13
+ ### Patch Changes
14
+
15
+ - [#7077](https://github.com/scalar/scalar/pull/7077) [`913607c`](https://github.com/scalar/scalar/commit/913607c7d67236f08f5369408f304440c6c42b22) Thanks [@hanspagel](https://github.com/hanspagel)! - fix: uses scalar proxy as the default
16
+
17
+ - [#7216](https://github.com/scalar/scalar/pull/7216) [`17817ad`](https://github.com/scalar/scalar/commit/17817addbca916c8d625a03335ae58be3a1c4e4b) Thanks [@marcalexiei](https://github.com/marcalexiei)! - fix(workspace-store): remove `async` from synchronous functions
18
+
19
+ - [#7159](https://github.com/scalar/scalar/pull/7159) [`c22fc4e`](https://github.com/scalar/scalar/commit/c22fc4e5acb49d648014a6100c724a5b33c59cde) Thanks [@amritk](https://github.com/amritk)! - feat: added new layouts for client v2
20
+
21
+ - [#7129](https://github.com/scalar/scalar/pull/7129) [`6ec8c29`](https://github.com/scalar/scalar/commit/6ec8c299d912111b029e8058979d00968b70691a) Thanks [@geoffgscott](https://github.com/geoffgscott)! - Simplify ApiReferences state management and migrate to new shared sidebar component. Eliminates the useSidebar and useNav hooks in favour of event bubbling and centralized state management in ApiReference.vue
22
+
23
+ - [#7186](https://github.com/scalar/scalar/pull/7186) [`c162bb6`](https://github.com/scalar/scalar/commit/c162bb64b86e698427c1fce36f6d8a2b789e094a) Thanks [@amritk](https://github.com/amritk)! - feat: hooking up event bus to the store
24
+
25
+ - [#7181](https://github.com/scalar/scalar/pull/7181) [`b64265b`](https://github.com/scalar/scalar/commit/b64265b3e8b447a4d1c6dafaca8135ef69545d98) Thanks [@amritk](https://github.com/amritk)! - chore: type updates to workspace bus
26
+
27
+ - [#7135](https://github.com/scalar/scalar/pull/7135) [`6aa06b0`](https://github.com/scalar/scalar/commit/6aa06b0f843ae3d8e6771e3c02ac11ee0043a4b1) Thanks [@marcalexiei](https://github.com/marcalexiei)! - fix: re-add request method and path to `scalar-open-client` event
28
+
29
+ - [#7143](https://github.com/scalar/scalar/pull/7143) [`81b0a7a`](https://github.com/scalar/scalar/commit/81b0a7a4245619f03161eae639dc5834b77432b6) Thanks [@amritk](https://github.com/amritk)! - fix: remove ignored parameters
30
+
31
+ - [#7227](https://github.com/scalar/scalar/pull/7227) [`704fa30`](https://github.com/scalar/scalar/commit/704fa302b2cdbb17b19ca2d742537ca163d58c1c) Thanks [@hwkr](https://github.com/hwkr)! - feat(sidebar): cleanup structure and improve text wrapping
32
+
33
+ - [#7184](https://github.com/scalar/scalar/pull/7184) [`33edbf2`](https://github.com/scalar/scalar/commit/33edbf2a2648eb72ae49e36dfd289d4d57dc18e0) Thanks [@geoffgscott](https://github.com/geoffgscott)! - move to event bus for internal events
34
+
35
+ - [#7167](https://github.com/scalar/scalar/pull/7167) [`4fe1643`](https://github.com/scalar/scalar/commit/4fe1643be51f76a8ebdfd75f5675337b8d43418e) Thanks [@amritk](https://github.com/amritk)! - feat: add new event bus to workspace store
36
+
37
+ - [#7094](https://github.com/scalar/scalar/pull/7094) [`eba18d0`](https://github.com/scalar/scalar/commit/eba18d06267a163a8f91396a66f817100ee59461) Thanks [@geoffgscott](https://github.com/geoffgscott)! - Migrate to workspace store as primary source of truth.
38
+
39
+ - [#7213](https://github.com/scalar/scalar/pull/7213) [`43bc5e8`](https://github.com/scalar/scalar/commit/43bc5e8b90dc0edf7176d0ddfc64bf3212494458) Thanks [@DemonHa](https://github.com/DemonHa)! - fix: proxy performance issue because of multiple proxies
40
+
41
+ - Updated dependencies [[`eb022f2`](https://github.com/scalar/scalar/commit/eb022f2c8f93c84a04c0093fefe8a1e05d6ec80d), [`11a6e64`](https://github.com/scalar/scalar/commit/11a6e6405d4f30f001a16d6afda4d2b759c0ed09), [`6ec8c29`](https://github.com/scalar/scalar/commit/6ec8c299d912111b029e8058979d00968b70691a), [`134ff5f`](https://github.com/scalar/scalar/commit/134ff5f32aa6842696bf146c7e0817b1662905eb), [`6ca835e`](https://github.com/scalar/scalar/commit/6ca835e5afd3e8c603e073e7c83f2cdd961a0f69), [`da7ab2f`](https://github.com/scalar/scalar/commit/da7ab2fb2e422b9cec2de5faba58ea83dd774808), [`eba18d0`](https://github.com/scalar/scalar/commit/eba18d06267a163a8f91396a66f817100ee59461), [`43bc5e8`](https://github.com/scalar/scalar/commit/43bc5e8b90dc0edf7176d0ddfc64bf3212494458)]:
42
+ - @scalar/types@0.4.0
43
+ - @scalar/openapi-upgrader@0.1.4
44
+ - @scalar/helpers@0.0.13
45
+ - @scalar/json-magic@0.7.0
46
+ - @scalar/snippetz@0.5.2
47
+ - @scalar/themes@0.13.23
48
+ - @scalar/code-highlight@0.2.0
49
+
50
+ ## 0.17.1
51
+
52
+ ### Patch Changes
53
+
54
+ - 1335923: fix: do not upgrade the document for the original documents
55
+ - 07397c8: fix(workspace-store): use `measureSync` for `mergeObjects` metric
56
+ - Updated dependencies [3f6d0b9]
57
+ - Updated dependencies [2089748]
58
+ - Updated dependencies [f3e17d8]
59
+ - Updated dependencies [8a7fb2a]
60
+ - @scalar/helpers@0.0.12
61
+ - @scalar/json-magic@0.6.1
62
+ - @scalar/types@0.3.2
63
+ - @scalar/openapi-upgrader@0.1.3
64
+ - @scalar/snippetz@0.5.1
65
+ - @scalar/code-highlight@0.2.0
66
+
3
67
  ## 0.17.0
4
68
 
5
69
  ### Minor Changes
package/dist/client.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { type Difference, merge } from '@scalar/json-magic/diff';
2
- import type { PartialDeep } from 'type-fest/source/partial-deep';
3
- import type { RequiredDeep } from 'type-fest/source/required-deep';
2
+ import type { PartialDeep, RequiredDeep } from 'type-fest';
3
+ import { type InMemoryWorkspace } from './schemas/inmemory-workspace.js';
4
4
  import { type OpenApiDocument } from './schemas/v3.1/strict/openapi-document.js';
5
5
  import type { Workspace, WorkspaceDocumentMeta, WorkspaceMeta } from './schemas/workspace.js';
6
6
  import type { WorkspaceSpecification } from './schemas/workspace-specification/index.js';
7
7
  import type { Config, DocumentConfiguration } from './schemas/workspace-specification/config.js';
8
+ import type { WorkspacePlugin } from './workspace-plugin.js';
8
9
  declare const defaultConfig: RequiredDeep<Config>;
9
10
  /**
10
11
  * Input type for workspace document metadata and configuration.
@@ -52,6 +53,8 @@ type WorkspaceProps = {
52
53
  config?: PartialDeep<Config>;
53
54
  /** Fetch function for retrieving documents */
54
55
  fetch?: WorkspaceDocumentInput['fetch'];
56
+ /** A list of all registered plugins for the current workspace */
57
+ plugins?: WorkspacePlugin[];
55
58
  };
56
59
  /**
57
60
  * Type definition for the workspace store return object.
@@ -165,7 +168,7 @@ export type WorkspaceStore = {
165
168
  * // Export a document as YAML
166
169
  * const yamlString = store.exportDocument('api', 'yaml')
167
170
  */
168
- exportDocument(documentName: string, format: 'json' | 'yaml'): string | undefined;
171
+ exportDocument(documentName: string, format: 'json' | 'yaml', minify?: boolean): string | undefined;
169
172
  /**
170
173
  * Exports the currently active document in the requested format.
171
174
  *
@@ -184,7 +187,7 @@ export type WorkspaceStore = {
184
187
  * // Export the active document as YAML
185
188
  * const yamlString = store.exportActiveDocument('yaml')
186
189
  */
187
- exportActiveDocument(format: 'json' | 'yaml'): string | undefined;
190
+ exportActiveDocument(format: 'json' | 'yaml', minify?: boolean): string | undefined;
188
191
  /**
189
192
  * Saves the current state of the specified document to the intermediate documents map.
190
193
  *
@@ -235,16 +238,17 @@ export type WorkspaceStore = {
235
238
  */
236
239
  commitDocument(documentName: string): void;
237
240
  /**
238
- * Serializes the current workspace state to a JSON string for backup, persistence, or sharing.
241
+ * Exports the complete current workspace state as a plain JavaScript object.
239
242
  *
240
- * This method exports all workspace documents (removing Vue reactivity proxies), workspace metadata,
241
- * document configurations, and both the original and intermediate document states. The resulting JSON
242
- * can be imported later to fully restore the workspace to this exact state, including all documents
243
- * and their configurations.
243
+ * The returned object includes all workspace documents (with Vue reactivity removed), workspace metadata,
244
+ * document configurations, and both the original and intermediate document maps. This object can be
245
+ * serialized (e.g., with JSON.stringify) and later imported to fully restore the workspaceincluding
246
+ * all documents, their configurations, metadata, and historical states.
244
247
  *
245
- * @returns A JSON string representing the complete workspace state.
248
+ * @returns An `InMemoryWorkspace` object representing the entire workspace state,
249
+ * suitable for persistence, backup, or sharing.
246
250
  */
247
- exportWorkspace(): string;
251
+ exportWorkspace(): InMemoryWorkspace;
248
252
  /**
249
253
  * Imports a workspace from a serialized JSON string.
250
254
  *
@@ -254,7 +258,7 @@ export type WorkspaceStore = {
254
258
  *
255
259
  * @param input - The serialized workspace JSON string to import.
256
260
  */
257
- loadWorkspace(input: string): void;
261
+ loadWorkspace(input: InMemoryWorkspace): void;
258
262
  /**
259
263
  * Imports a workspace from a WorkspaceSpecification object.
260
264
  *
@@ -281,26 +285,34 @@ export type WorkspaceStore = {
281
285
  */
282
286
  importWorkspaceFromSpecification(specification: WorkspaceSpecification): Promise<void[]>;
283
287
  /**
284
- * Rebases a document in the workspace with a new origin, resolving conflicts if provided.
288
+ * Rebases a document in the workspace by refetching its origin and merging with local edits.
285
289
  *
286
- * This method is used to rebase a document (e.g., after pulling remote changes) by applying the changes
287
- * from the new origin and merging them with local edits. If there are conflicts, they can be resolved
288
- * by providing a list of resolved conflicts.
290
+ * This method fetches the latest version of the document (optionally with custom fetch/config),
291
+ * calculates changes relative to the original and locally edited versions,
292
+ * and attempts to update the workspace document while preserving user edits.
293
+ * If automatic resolution isn't possible due to conflicts, returns a conflict list for the caller to resolve.
294
+ * If `resolvedConflicts` are provided (e.g., after user intervention), applies them to complete the rebase.
289
295
  *
290
- * @param documentName - The name of the document to rebase.
291
- * @param newDocumentOrigin - The new origin document (as an object) to rebase onto.
292
- * @param resolvedConflicts - (Optional) An array of resolved conflicts to apply.
293
- * @returns If there are unresolved conflicts and no resolution is provided, returns the list of conflicts.
296
+ * @param input Object specifying which document to rebase
297
+ * @returns If there are unresolved conflicts, resolves to an object containing the list of conflicts and a method to apply user-resolved conflicts; otherwise resolves to void.
294
298
  *
295
299
  * @example
296
- * // Example: Rebase a document with a new origin and resolve conflicts
297
- * const conflicts = store.rebaseDocument('api', newOriginDoc)
298
- * if (conflicts && conflicts.length > 0) {
299
- * // User resolves conflicts here...
300
- * store.rebaseDocument('api', newOriginDoc, userResolvedConflicts)
300
+ * // Rebase a document and handle conflicts interactively
301
+ * const result = await store.rebaseDocument({ name: 'api', fetch: customFetch });
302
+ * if (result && result.ok) {
303
+ * // Present conflicts to the user and collect resolutions...
304
+ * await result.applyChanges(userResolvedConflicts);
301
305
  * }
302
306
  */
303
- rebaseDocument: (documentName: string, newDocumentOrigin: Record<string, unknown>, resolvedConflicts?: Difference<unknown>[]) => void | ReturnType<typeof merge>['conflicts'];
307
+ rebaseDocument: (input: WorkspaceDocumentInput) => Promise<{
308
+ ok: false;
309
+ type: 'CORRUPTED_STATE' | 'FETCH_FAILED' | 'NO_CHANGES_DETECTED';
310
+ message: string;
311
+ } | {
312
+ ok: true;
313
+ conflicts: ReturnType<typeof merge>['conflicts'];
314
+ applyChanges: (resolvedConflicts: Difference<unknown>[]) => Promise<void>;
315
+ }>;
304
316
  };
305
317
  /**
306
318
  * Creates a reactive workspace store that manages documents and their metadata.
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,UAAU,EAAe,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAK7E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAiBlE,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAC1F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAA;AAC/E,OAAO,KAAK,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAA;AAS7F,QAAA,MAAM,aAAa,EAAE,YAAY,CAAC,MAAM,CAEvC,CAAA;AAED;;;GAGG;AACH,KAAK,0BAA0B,GAAG;IAChC,wEAAwE;IACxE,IAAI,CAAC,EAAE,qBAAqB,CAAA;IAC5B,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAA;IACZ,qCAAqC;IACrC,MAAM,CAAC,EAAE,qBAAqB,CAAA;IAC9B,iCAAiC;IACjC,SAAS,CAAC,EAAE,WAAW,CAAC,eAAe,CAAC,CAAA;IACxC,wIAAwI;IACxI,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CAC5F,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,6CAA6C;IAC7C,GAAG,EAAE,MAAM,CAAA;CACZ,GAAG,0BAA0B,CAAA;AAE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