@scalar/workspace-store 0.25.2 → 0.26.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 (100) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +0 -46
  3. package/dist/client.d.ts +4 -33
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +45 -84
  6. package/dist/client.js.map +2 -2
  7. package/dist/events/definitions/hooks.d.ts +13 -2
  8. package/dist/events/definitions/hooks.d.ts.map +1 -1
  9. package/dist/events/definitions/operation.d.ts +11 -0
  10. package/dist/events/definitions/operation.d.ts.map +1 -1
  11. package/dist/events/definitions/ui.d.ts +12 -0
  12. package/dist/events/definitions/ui.d.ts.map +1 -1
  13. package/dist/helpers/apply-selective-updates.d.ts +1 -1
  14. package/dist/helpers/apply-selective-updates.d.ts.map +1 -1
  15. package/dist/helpers/apply-selective-updates.js +13 -3
  16. package/dist/helpers/apply-selective-updates.js.map +3 -3
  17. package/dist/helpers/get-fetch.d.ts +10 -0
  18. package/dist/helpers/get-fetch.d.ts.map +1 -0
  19. package/dist/helpers/get-fetch.js +11 -0
  20. package/dist/helpers/get-fetch.js.map +7 -0
  21. package/dist/mutators/fetch-request-to-har.d.ts +62 -0
  22. package/dist/mutators/fetch-request-to-har.d.ts.map +1 -0
  23. package/dist/mutators/fetch-request-to-har.js +117 -0
  24. package/dist/mutators/fetch-request-to-har.js.map +7 -0
  25. package/dist/mutators/fetch-response-to-har.d.ts +67 -0
  26. package/dist/mutators/fetch-response-to-har.d.ts.map +1 -0
  27. package/dist/mutators/fetch-response-to-har.js +104 -0
  28. package/dist/mutators/fetch-response-to-har.js.map +7 -0
  29. package/dist/mutators/har-to-operation.d.ts +37 -0
  30. package/dist/mutators/har-to-operation.d.ts.map +1 -0
  31. package/dist/mutators/har-to-operation.js +146 -0
  32. package/dist/mutators/har-to-operation.js.map +7 -0
  33. package/dist/mutators/index.d.ts +4 -0
  34. package/dist/mutators/index.d.ts.map +1 -1
  35. package/dist/mutators/operation.d.ts +5 -0
  36. package/dist/mutators/operation.d.ts.map +1 -1
  37. package/dist/mutators/operation.js +83 -15
  38. package/dist/mutators/operation.js.map +2 -2
  39. package/dist/navigation/get-navigation-options.d.ts +3 -2
  40. package/dist/navigation/get-navigation-options.d.ts.map +1 -1
  41. package/dist/navigation/get-navigation-options.js +14 -18
  42. package/dist/navigation/get-navigation-options.js.map +2 -2
  43. package/dist/navigation/helpers/traverse-document.d.ts +2 -2
  44. package/dist/navigation/helpers/traverse-document.d.ts.map +1 -1
  45. package/dist/navigation/helpers/traverse-document.js +2 -2
  46. package/dist/navigation/helpers/traverse-document.js.map +2 -2
  47. package/dist/persistence/index.d.ts +1 -7
  48. package/dist/persistence/index.d.ts.map +1 -1
  49. package/dist/persistence/index.js +3 -25
  50. package/dist/persistence/index.js.map +2 -2
  51. package/dist/plugins/client/persistence.d.ts.map +1 -1
  52. package/dist/plugins/client/persistence.js +0 -6
  53. package/dist/plugins/client/persistence.js.map +2 -2
  54. package/dist/schemas/extensions/document/x-scalar-is-dirty.d.ts +43 -0
  55. package/dist/schemas/extensions/document/x-scalar-is-dirty.d.ts.map +1 -0
  56. package/dist/schemas/extensions/document/x-scalar-is-dirty.js +9 -0
  57. package/dist/schemas/extensions/document/x-scalar-is-dirty.js.map +7 -0
  58. package/dist/schemas/extensions/operation/x-scalar-history.d.ts +217 -0
  59. package/dist/schemas/extensions/operation/x-scalar-history.d.ts.map +1 -0
  60. package/dist/schemas/extensions/operation/x-scalar-history.js +100 -0
  61. package/dist/schemas/extensions/operation/x-scalar-history.js.map +7 -0
  62. package/dist/schemas/inmemory-workspace.d.ts +68 -1492
  63. package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
  64. package/dist/schemas/inmemory-workspace.js +0 -2
  65. package/dist/schemas/inmemory-workspace.js.map +2 -2
  66. package/dist/schemas/reference-config/index.d.ts +64 -0
  67. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  68. package/dist/schemas/reference-config/settings.d.ts +64 -0
  69. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  70. package/dist/schemas/v3.1/strict/openapi-document.d.ts +2306 -1
  71. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  72. package/dist/schemas/v3.1/strict/openapi-document.js +3 -1
  73. package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
  74. package/dist/schemas/v3.1/strict/operation.d.ts +64 -1
  75. package/dist/schemas/v3.1/strict/operation.d.ts.map +1 -1
  76. package/dist/schemas/v3.1/strict/operation.js +3 -1
  77. package/dist/schemas/v3.1/strict/operation.js.map +2 -2
  78. package/dist/schemas/workspace-specification/index.d.ts +5 -1491
  79. package/dist/schemas/workspace-specification/index.d.ts.map +1 -1
  80. package/dist/schemas/workspace-specification/index.js +0 -2
  81. package/dist/schemas/workspace-specification/index.js.map +2 -2
  82. package/dist/schemas/workspace.d.ts +457 -9
  83. package/dist/schemas/workspace.d.ts.map +1 -1
  84. package/dist/schemas/workspace.js +14 -8
  85. package/dist/schemas/workspace.js.map +2 -2
  86. package/dist/server.d.ts +3 -2
  87. package/dist/server.d.ts.map +1 -1
  88. package/dist/server.js +2 -2
  89. package/dist/server.js.map +2 -2
  90. package/dist/workspace-plugin.d.ts +0 -4
  91. package/dist/workspace-plugin.d.ts.map +1 -1
  92. package/package.json +5 -5
  93. package/dist/preprocessing/server.d.ts +0 -23
  94. package/dist/preprocessing/server.d.ts.map +0 -1
  95. package/dist/preprocessing/server.js +0 -84
  96. package/dist/preprocessing/server.js.map +0 -7
  97. package/dist/schemas/workspace-specification/config.d.ts +0 -1520
  98. package/dist/schemas/workspace-specification/config.d.ts.map +0 -1
  99. package/dist/schemas/workspace-specification/config.js +0 -11
  100. package/dist/schemas/workspace-specification/config.js.map +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @scalar/workspace-store
2
2
 
3
+ ## 0.26.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#7866](https://github.com/scalar/scalar/pull/7866): feat: history per operation support
8
+
9
+ ### Patch Changes
10
+
11
+ - [#7886](https://github.com/scalar/scalar/pull/7886): fix: unpack proxy when we pop history items
12
+
13
+ #### Updated Dependencies
14
+
15
+ - **@scalar/snippetz@0.6.7**
16
+ - [#7866](https://github.com/scalar/scalar/pull/7866): chore: expose har types
17
+
18
+ - **@scalar/types@0.5.9**
19
+ - [#7866](https://github.com/scalar/scalar/pull/7866): chore: expose har types
20
+
21
+ - **@scalar/openapi-upgrader@0.1.8**
22
+
23
+ ## 0.25.3
24
+
25
+ ### Patch Changes
26
+
27
+ - [#7850](https://github.com/scalar/scalar/pull/7850): fix: remove unused workspace config
28
+ - [#7868](https://github.com/scalar/scalar/pull/7868): fix: updating path with a variable in it
29
+
3
30
  ## 0.25.2
4
31
 
5
32
  ### Patch Changes
package/README.md CHANGED
@@ -239,52 +239,6 @@ await store.addDocument({
239
239
  console.log(store.workspace.documents.default)
240
240
  ```
241
241
 
242
- #### Configuration
243
-
244
- You can pass configuration object to the workspace store which is going to be applied to all the documents
245
-
246
- ```ts
247
- const store = createWorkspaceStore({
248
- config: {
249
- "x-scalar-reference-config": {
250
- features: {
251
- showModels: true,
252
- },
253
- appearance: {
254
- layout: 'modern'
255
- },
256
- }
257
- }
258
- })
259
- ```
260
-
261
- You can override specific document configuration when you add the document to the store
262
-
263
- ```ts
264
- await store.addDocument({
265
- name: 'example',
266
- document: {
267
- openapi: '3.0.0',
268
- info: { title: 'Example API', version: '1.0.0' },
269
- paths: {},
270
- },
271
- config: {
272
- features: {
273
- showModels: false,
274
- },
275
- }
276
- })
277
- ```
278
-
279
- To get the active document configuration you can use config getter
280
-
281
- ```ts
282
- // Get the configuration for the active document
283
- console.log(store.config['x-scalar-reference-config'].features.showModels)
284
- ```
285
-
286
- When no configuration is provided it will return the default configuration
287
-
288
242
  #### Document Persistence and Export
289
243
 
290
244
  The workspace store provides several methods for managing document persistence and exporting:
package/dist/client.d.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  import { type Difference, merge } from '@scalar/json-magic/diff';
2
- import type { PartialDeep, RequiredDeep } from 'type-fest';
2
+ import type { PartialDeep } from 'type-fest';
3
+ import type { NavigationOptions } from './navigation/get-navigation-options.js';
3
4
  import type { InMemoryWorkspace } from './schemas/inmemory-workspace.js';
4
5
  import { type OpenApiDocument } from './schemas/v3.1/strict/openapi-document.js';
5
6
  import type { Workspace, WorkspaceDocumentMeta, WorkspaceExtensions, WorkspaceMeta } from './schemas/workspace.js';
6
7
  import type { WorkspaceSpecification } from './schemas/workspace-specification/index.js';
7
- import type { Config, DocumentConfiguration } from './schemas/workspace-specification/config.js';
8
8
  import type { WorkspacePlugin } from './workspace-plugin.js';
9
- declare const defaultConfig: RequiredDeep<Config>;
10
9
  /**
11
10
  * Input type for workspace document metadata and configuration.
12
11
  * This type defines the required and optional fields for initializing a document in the workspace.
@@ -16,8 +15,6 @@ type WorkspaceDocumentMetaInput = {
16
15
  meta?: WorkspaceDocumentMeta;
17
16
  /** Required unique identifier for the document */
18
17
  name: string;
19
- /** Optional configuration options */
20
- config?: DocumentConfiguration;
21
18
  /** Overrides for the document */
22
19
  overrides?: PartialDeep<OpenApiDocument>;
23
20
  /** Optional custom fetch implementation to use when retrieving the document. By default the global fetch implementation will be used */
@@ -49,8 +46,6 @@ export type WorkspaceDocumentInput = UrlDoc | ObjectDoc;
49
46
  type WorkspaceProps = {
50
47
  /** Optional metadata for the workspace including theme, active document, etc */
51
48
  meta?: WorkspaceMeta;
52
- /** Workspace configuration */
53
- config?: PartialDeep<Config>;
54
49
  /** Fetch function for retrieving documents */
55
50
  fetch?: WorkspaceDocumentInput['fetch'];
56
51
  /** A list of all registered plugins for the current workspace */
@@ -136,7 +131,7 @@ export type WorkspaceStore = {
136
131
  * }
137
132
  * })
138
133
  */
139
- addDocument(input: WorkspaceDocumentInput): Promise<boolean>;
134
+ addDocument(input: WorkspaceDocumentInput, navigationOptions?: NavigationOptions): Promise<boolean>;
140
135
  /**
141
136
  * Deletes a document from the workspace and all associated data.
142
137
  *
@@ -166,30 +161,6 @@ export type WorkspaceStore = {
166
161
  * ['api', 'petstore'].forEach(name => store.deleteDocument(name))
167
162
  */
168
163
  deleteDocument(documentName: string): void;
169
- /**
170
- * Returns the merged configuration for the active document.
171
- *
172
- * This getter merges configurations in the following order of precedence:
173
- * 1. Document-specific configuration (highest priority)
174
- * 2. Workspace-level configuration
175
- * 3. Default configuration (lowest priority)
176
- *
177
- * The active document is determined by the workspace's activeDocument extension,
178
- * falling back to the first document if none is specified.
179
- */
180
- readonly config: typeof defaultConfig;
181
- /**
182
- * Returns the merged configuration for a specific document.
183
- *
184
- * This method merges configurations in the following order of precedence:
185
- * 1. Document-specific configuration (highest priority)
186
- * 2. Workspace-level configuration
187
- * 3. Default configuration (lowest priority)
188
- *
189
- * @param documentName - The name of the document to get the configuration for
190
- * @returns The merged configuration for the specified document
191
- */
192
- getDocumentConfiguration(documentName: string): typeof defaultConfig;
193
164
  /**
194
165
  * Exports the specified document in the requested format.
195
166
  *
@@ -369,7 +340,7 @@ export type WorkspaceStore = {
369
340
  * @param workspaceProps - Configuration object for the workspace
370
341
  * @param workspaceProps.meta - Optional metadata for the workspace
371
342
  * @param workspaceProps.documents - Optional record of documents to initialize the workspace with
372
- * Documents that require asynchronous loading must be added using `addDocument` after the store is created
343
+ * Documents that require asynchronous loading must be added using `1` after the store is created
373
344
  * this allows atomic awaiting and does not block page load for the store initialization
374
345
  * @returns An object containing methods and getters for managing the workspace
375
346
  */
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,UAAU,EAAe,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAK7E,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAsB1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAGrE,OAAO,EAEL,KA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IAAI,iBAAiB,CAAA;IACpC;;;;;;;;OAQG;IACH,aAAa,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAC7C;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,gCAAgC,CAAC,aAAa,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAC3F;;;;;;;;;;;;;;;;;;;OAmBG;IACH,cAAc,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,OAAO,CACtD;QAAE,EAAE,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,iBAAiB,GAAG,cAAc,GAAG,qBAAqB,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAChG;QACE,EAAE,EAAE,IAAI,CAAA;QACR,SAAS,EAAE,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,WAAW,CAAC,CAAA;QAChD,YAAY,EAAE,CAAC,iBAAiB,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAC1E,CACJ,CAAA;CACF,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,iBAAiB,cAAc,KAAG,cA0vBtE,CAAA;AAGD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA"}
package/dist/client.js CHANGED
@@ -13,6 +13,7 @@ import { applySelectiveUpdates } from "./helpers/apply-selective-updates.js";
13
13
  import { deepClone } from "./helpers/deep-clone.js";
14
14
  import { createDetectChangesProxy } from "./helpers/detect-changes-proxy.js";
15
15
  import { isObject, safeAssign } from "./helpers/general.js";
16
+ import { getFetch } from "./helpers/get-fetch.js";
16
17
  import { getValueByPath } from "./helpers/json-path-utils.js";
17
18
  import { mergeObjects } from "./helpers/merge-object.js";
18
19
  import { createOverridesProxy, unpackOverridesProxy } from "./helpers/overrides-proxy.js";
@@ -25,16 +26,11 @@ import {
25
26
  refsEverywhere,
26
27
  restoreOriginalRefs
27
28
  } from "./plugins/bundler/index.js";
28
- import { getServersFromDocument } from "./preprocessing/server.js";
29
29
  import { extensions } from "./schemas/extensions.js";
30
- import { defaultReferenceConfig } from "./schemas/reference-config/index.js";
31
30
  import { coerceValue } from "./schemas/typebox-coerce.js";
32
31
  import {
33
32
  OpenAPIDocumentSchema as OpenAPIDocumentSchemaStrict
34
33
  } from "./schemas/v3.1/strict/openapi-document.js";
35
- const defaultConfig = {
36
- "x-scalar-reference-config": defaultReferenceConfig
37
- };
38
34
  function loadDocument(workspaceDocument) {
39
35
  if ("url" in workspaceDocument) {
40
36
  return fetchUrls({ fetch: workspaceDocument.fetch }).exec(workspaceDocument.url);
@@ -83,35 +79,39 @@ const createWorkspaceStore = (workspaceProps) => {
83
79
  return;
84
80
  }
85
81
  const documentName = path[1];
82
+ const document = workspace.documents[documentName] ?? {
83
+ openapi: "3.1.0",
84
+ info: { title: "", version: "" },
85
+ "x-scalar-original-document-hash": ""
86
+ };
86
87
  const event2 = {
87
88
  type: "documents",
88
89
  documentName,
89
- value: unpackProxyObject(
90
- workspace.documents[documentName] ?? {
91
- openapi: "3.1.0",
92
- info: { title: "", version: "" },
93
- "x-scalar-original-document-hash": ""
94
- }
95
- ),
96
- path: path.splice(2)
90
+ value: unpackProxyObject(document),
91
+ path: path.slice(2)
97
92
  };
93
+ if (event2.path.length > 0 && event2.path[0] !== "x-scalar-is-dirty") {
94
+ document["x-scalar-is-dirty"] = true;
95
+ }
98
96
  fireWorkspaceChange(event2);
99
97
  return;
100
98
  }
101
99
  if (type === "activeDocument") {
102
100
  const documentName = getActiveDocumentName();
101
+ const document = workspace.documents[documentName] ?? {
102
+ openapi: "3.1.0",
103
+ info: { title: "", version: "" },
104
+ "x-scalar-original-document-hash": ""
105
+ };
103
106
  const event2 = {
104
107
  type: "documents",
105
108
  documentName,
106
- value: unpackProxyObject(
107
- workspace.documents[documentName] ?? {
108
- openapi: "3.1.0",
109
- info: { title: "", version: "" },
110
- "x-scalar-original-document-hash": ""
111
- }
112
- ),
113
- path: path.splice(2)
109
+ value: unpackProxyObject(document),
110
+ path: path.slice(2)
114
111
  };
112
+ if (event2.path.length > 0 && event2.path[0] !== "x-scalar-is-dirty") {
113
+ document["x-scalar-is-dirty"] = true;
114
+ }
115
115
  fireWorkspaceChange(event2);
116
116
  return;
117
117
  }
@@ -127,7 +127,7 @@ const createWorkspaceStore = (workspaceProps) => {
127
127
  }
128
128
  )
129
129
  );
130
- const { originalDocuments, intermediateDocuments, overrides, documentConfigs } = createDetectChangesProxy(
130
+ const { originalDocuments, intermediateDocuments, overrides } = createDetectChangesProxy(
131
131
  {
132
132
  /**
133
133
  * Holds the original, unmodified documents as they were initially loaded into the workspace.
@@ -150,13 +150,6 @@ const createWorkspaceStore = (workspaceProps) => {
150
150
  * - The current in-memory (possibly unsaved) workspace document (`workspace.documents`)
151
151
  */
152
152
  intermediateDocuments: {},
153
- /**
154
- * A map of document configurations keyed by document name.
155
- * This stores the configuration options for each document in the workspace,
156
- * allowing for document-specific settings like navigation options, appearance,
157
- * and other reference configuration.
158
- */
159
- documentConfigs: {},
160
153
  /**
161
154
  * Stores per-document overrides for OpenAPI documents.
162
155
  * This object is used to override specific fields of a document
@@ -197,14 +190,6 @@ const createWorkspaceStore = (workspaceProps) => {
197
190
  };
198
191
  fireWorkspaceChange(event);
199
192
  }
200
- if (type === "documentConfigs") {
201
- const event = {
202
- type,
203
- documentName,
204
- value: unpackProxyObject(documentConfigs[documentName] ?? {})
205
- };
206
- fireWorkspaceChange(event);
207
- }
208
193
  if (type === "overrides") {
209
194
  const event = {
210
195
  type,
@@ -236,36 +221,27 @@ const createWorkspaceStore = (workspaceProps) => {
236
221
  if (!workspaceDocument) {
237
222
  return;
238
223
  }
239
- const updatedDocument = getRaw(workspaceDocument);
240
- if (!intermediateDocument || !updatedDocument) {
224
+ const activeDocumentRaw = unpackProxyObject(workspaceDocument);
225
+ if (!intermediateDocument || !activeDocumentRaw) {
226
+ console.warn("Failed to save document, intermediate document and/or active document is missing");
241
227
  return;
242
228
  }
243
- const updatedWithOriginalRefs = await bundle(deepClone(updatedDocument), {
229
+ const updatedWithOriginalRefs = await bundle(deepClone(activeDocumentRaw), {
244
230
  plugins: [restoreOriginalRefs()],
245
231
  treeShake: false,
246
232
  urlMap: true
247
233
  });
248
234
  const excludedDiffs = applySelectiveUpdates(intermediateDocument, updatedWithOriginalRefs);
235
+ workspaceDocument["x-scalar-is-dirty"] = false;
249
236
  return excludedDiffs;
250
237
  }
251
- const processDocument = (input, options) => {
252
- const servers = getServersFromDocument(options["x-scalar-reference-config"]?.settings?.servers ?? input.servers, {
253
- baseServerUrl: options["x-scalar-reference-config"]?.settings?.baseServerUrl,
254
- documentUrl: options.documentSource
255
- });
256
- if (servers.length) {
257
- input.servers = servers.map((it) => ({ url: it.url, description: it.description, variables: it.variables }));
258
- }
259
- return input;
260
- };
261
- async function addInMemoryDocument(input) {
238
+ async function addInMemoryDocument(input, navigationOptions) {
262
239
  const { name, meta } = input;
263
240
  const clonedRawInputDocument = measureSync("deepClone", () => deepClone(input.document));
264
241
  measureSync("initialize", () => {
265
242
  if (input.initialize !== false) {
266
243
  originalDocuments[name] = deepClone(clonedRawInputDocument);
267
244
  intermediateDocuments[name] = deepClone(clonedRawInputDocument);
268
- documentConfigs[name] = input.config ?? {};
269
245
  overrides[name] = input.overrides ?? {};
270
246
  extraDocumentConfigurations[name] = { fetch: input.fetch };
271
247
  }
@@ -319,23 +295,20 @@ const createWorkspaceStore = (workspaceProps) => {
319
295
  );
320
296
  }
321
297
  if (strictDocument[extensions.document.navigation] === void 0) {
322
- const navigation = createNavigation(name, strictDocument, input.config);
298
+ const navigation = createNavigation(name, strictDocument, navigationOptions);
323
299
  strictDocument[extensions.document.navigation] = navigation;
324
- processDocument(getRaw(strictDocument), {
325
- ...documentConfigs[name] ?? {},
326
- documentSource: input.documentSource
327
- });
328
300
  }
329
301
  workspace.documents[name] = createOverridesProxy(createMagicProxy(getRaw(strictDocument)), {
330
302
  overrides: unpackProxyObject(overrides[name])
331
303
  });
332
304
  }
333
- async function addDocument(input) {
305
+ async function addDocument(input, navigationOptions) {
334
306
  const { name, meta } = input;
335
- const resolve = await measureAsync(
336
- "loadDocument",
337
- async () => await loadDocument({ ...input, fetch: input.fetch ?? workspaceProps?.fetch })
338
- );
307
+ const fetch = getFetch({
308
+ fetch: input.fetch ?? workspaceProps?.fetch,
309
+ proxyUrl: workspace["x-scalar-active-proxy"]
310
+ });
311
+ const resolve = await measureAsync("loadDocument", async () => await loadDocument({ ...input, fetch }));
339
312
  return await measureAsync("addDocument", async () => {
340
313
  if (!resolve.ok) {
341
314
  console.error(`Failed to fetch document '${name}': request was not successful`);
@@ -363,12 +336,15 @@ const createWorkspaceStore = (workspaceProps) => {
363
336
  };
364
337
  return false;
365
338
  }
366
- await addInMemoryDocument({
367
- ...input,
368
- document: resolve.data,
369
- documentSource: getDocumentSource(input),
370
- documentHash: generateHash(resolve.raw)
371
- });
339
+ await addInMemoryDocument(
340
+ {
341
+ ...input,
342
+ document: resolve.data,
343
+ documentSource: getDocumentSource(input),
344
+ documentHash: generateHash(resolve.raw)
345
+ },
346
+ navigationOptions
347
+ );
372
348
  return true;
373
349
  });
374
350
  }
@@ -378,17 +354,10 @@ const createWorkspaceStore = (workspaceProps) => {
378
354
  console.error(`Document '${documentName}' does not exist in the workspace.`);
379
355
  return false;
380
356
  }
381
- const navigation = createNavigation(documentName, document, getDocumentConfiguration(documentName));
357
+ const navigation = createNavigation(documentName, document);
382
358
  document[extensions.document.navigation] = navigation;
383
359
  return true;
384
360
  };
385
- const getDocumentConfiguration = (name) => {
386
- return mergeObjects(
387
- mergeObjects(deepClone(defaultConfig), workspaceProps?.config ?? {}, true),
388
- documentConfigs[name] ?? {},
389
- true
390
- );
391
- };
392
361
  const visitedNodesCache = /* @__PURE__ */ new Set();
393
362
  return {
394
363
  get workspace() {
@@ -455,7 +424,6 @@ const createWorkspaceStore = (workspaceProps) => {
455
424
  delete workspace.documents[documentName];
456
425
  delete originalDocuments[documentName];
457
426
  delete intermediateDocuments[documentName];
458
- delete documentConfigs[documentName];
459
427
  delete overrides[documentName];
460
428
  delete extraDocumentConfigurations[documentName];
461
429
  const remainingDocuments = Object.keys(workspace.documents);
@@ -468,10 +436,6 @@ const createWorkspaceStore = (workspaceProps) => {
468
436
  documentName
469
437
  });
470
438
  },
471
- get config() {
472
- return getDocumentConfiguration(getActiveDocumentName());
473
- },
474
- getDocumentConfiguration,
475
439
  exportDocument,
476
440
  exportActiveDocument: (format, minify) => exportDocument(getActiveDocumentName(), format, minify),
477
441
  buildSidebar,
@@ -506,7 +470,6 @@ const createWorkspaceStore = (workspaceProps) => {
506
470
  )
507
471
  },
508
472
  meta: unpackProxyObject(meta) ?? {},
509
- documentConfigs: unpackProxyObject(documentConfigs),
510
473
  originalDocuments: unpackProxyObject(originalDocuments),
511
474
  intermediateDocuments: unpackProxyObject(intermediateDocuments),
512
475
  overrides: unpackProxyObject(overrides)
@@ -526,7 +489,6 @@ const createWorkspaceStore = (workspaceProps) => {
526
489
  );
527
490
  safeAssign(originalDocuments, input.originalDocuments);
528
491
  safeAssign(intermediateDocuments, input.intermediateDocuments);
529
- safeAssign(documentConfigs, input.documentConfigs);
530
492
  safeAssign(overrides, input.overrides);
531
493
  safeAssign(workspace, input.meta);
532
494
  },
@@ -571,7 +533,6 @@ const createWorkspaceStore = (workspaceProps) => {
571
533
  };
572
534
  }
573
535
  const newDocumentOrigin = resolve.data;
574
- documentConfigs[name] = input.config ?? {};
575
536
  overrides[name] = input.overrides ?? {};
576
537
  extraDocumentConfigurations[name] = { fetch: input.fetch };
577
538
  const changelogAA = diff(originalDocument, newDocumentOrigin);