@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
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,11 @@
1
+ /** Event definitions for the operation */
2
+ export type OperationEvents = {
3
+ /**
4
+ * Update the selected example for the operation
5
+ */
6
+ 'update:selected-example': {
7
+ /** The name of the example to select */
8
+ name: string;
9
+ };
10
+ };
11
+ //# sourceMappingURL=operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/operation.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,yBAAyB,EAAE;QACzB,wCAAwC;QACxC,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;CACF,CAAA"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=operation.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,50 @@
1
+ import type { ServerObject } from '../../schemas/v3.1/strict/openapi-document.js';
2
+ export type ServerEvents<T extends keyof ServerObject = keyof ServerObject> = {
3
+ /**
4
+ * Add a new server to the document
5
+ */
6
+ 'add:server': {
7
+ /** The new server payload to add */
8
+ server: ServerObject;
9
+ };
10
+ /**
11
+ * Delete a server from the document
12
+ */
13
+ 'delete:server': {
14
+ /** The URL of the server to delete */
15
+ url: string;
16
+ };
17
+ /**
18
+ * Update the selected server via URL
19
+ */
20
+ 'update:selected-server': {
21
+ /** The new selected server URL */
22
+ url: string;
23
+ };
24
+ /**
25
+ * Update the selected server variable for the document
26
+ */
27
+ 'update:selected-server-variables': {
28
+ /** The key of the variable to update */
29
+ key: string;
30
+ /** The new value of the variable */
31
+ value: string;
32
+ };
33
+ /**
34
+ * Update the selected server properties for the document
35
+ */
36
+ 'update:selected-server-properties': {
37
+ /** The key of the property to update */
38
+ key: T;
39
+ /** The new value of the property */
40
+ value: ServerObject[T];
41
+ };
42
+ /**
43
+ * Replace all servers in the document
44
+ */
45
+ 'update:all-servers': {
46
+ /** The new servers to replace the current servers with */
47
+ servers: ServerObject[];
48
+ };
49
+ };
50
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,YAAY,GAAG,MAAM,YAAY,IAAI;IAC5E;;OAEG;IACH,YAAY,EAAE;QACZ,oCAAoC;QACpC,MAAM,EAAE,YAAY,CAAA;KACrB,CAAA;IACD;;OAEG;IACH,eAAe,EAAE;QACf,sCAAsC;QACtC,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD;;OAEG;IACH,wBAAwB,EAAE;QACxB,kCAAkC;QAClC,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;IACD;;OAEG;IACH,kCAAkC,EAAE;QAClC,wCAAwC;QACxC,GAAG,EAAE,MAAM,CAAA;QACX,oCAAoC;QACpC,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD;;OAEG;IACH,mCAAmC,EAAE;QACnC,wCAAwC;QACxC,GAAG,EAAE,CAAC,CAAA;QACN,oCAAoC;QACpC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;KACvB,CAAA;IACD;;OAEG;IACH,oBAAoB,EAAE;QACpB,0DAA0D;QAC1D,OAAO,EAAE,YAAY,EAAE,CAAA;KACxB,CAAA;CACF,CAAA"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,52 @@
1
+ import type { HttpMethod } from '@scalar/helpers/http/http-methods';
2
+ /** Event definitions to control the ui */
3
+ export type UIEvents = {
4
+ /**
5
+ * Download the document from the store
6
+ */
7
+ 'download:document': {
8
+ /** Format to download the document in */
9
+ format: 'json' | 'yaml' | 'direct';
10
+ };
11
+ /**
12
+ * Open the Api Client modal to a specific operation
13
+ */
14
+ 'open:client': {
15
+ /** The HTTP method of the operation to load */
16
+ method: HttpMethod;
17
+ /** The path of the operation to load */
18
+ path: string;
19
+ };
20
+ /**
21
+ * Open our command palette
22
+ */
23
+ 'open:command-palette': 'import' | 'addServer' | 'addCollection' | 'addTag' | 'addExample' | 'addOperation' | undefined;
24
+ /** Set a navigation item's (such as a tag or operation) expanded state */
25
+ 'toggle:nav-item': {
26
+ /** The name of the nav item to toggle */
27
+ id: string;
28
+ /** Optional defined state for the nav item. */
29
+ open?: boolean;
30
+ };
31
+ /** Select a navigation item. Run on sidebar clicks where a scroll handler would typically be expected */
32
+ 'select:nav-item': {
33
+ /** The id of the nav item to select */
34
+ id: string;
35
+ };
36
+ /** Fired when a navigation item intersects with the viewport */
37
+ 'intersecting:nav-item': {
38
+ /** The id of the nav item that is intersecting */
39
+ id: string;
40
+ };
41
+ /** Explicity scroll to a navigation item */
42
+ 'scroll-to:nav-item': {
43
+ /** The id of the nav item to scroll to */
44
+ id: string;
45
+ };
46
+ /** Copy the url including anchor details for a navigation item */
47
+ 'copy-url:nav-item': {
48
+ /** The id of the nav item to copy the anchor url for */
49
+ id: string;
50
+ };
51
+ };
52
+ //# sourceMappingURL=ui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AAEnE,0CAA0C;AAC1C,MAAM,MAAM,QAAQ,GAAG;IACrB;;OAEG;IACH,mBAAmB,EAAE;QACnB,yCAAyC;QACzC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAA;KACnC,CAAA;IACD;;OAEG;IACH,aAAa,EAAE;QACb,+CAA+C;QAC/C,MAAM,EAAE,UAAU,CAAA;QAClB,wCAAwC;QACxC,IAAI,EAAE,MAAM,CAAA;KACb,CAAA;IACD;;OAEG;IACH,sBAAsB,EAClB,QAAQ,GACR,WAAW,GACX,eAAe,GACf,QAAQ,GACR,YAAY,GACZ,cAAc,GACd,SAAS,CAAA;IAEb,0EAA0E;IAC1E,iBAAiB,EAAE;QACjB,yCAAyC;QACzC,EAAE,EAAE,MAAM,CAAA;QACV,+CAA+C;QAC/C,IAAI,CAAC,EAAE,OAAO,CAAA;KACf,CAAA;IAED,yGAAyG;IACzG,iBAAiB,EAAE;QACjB,uCAAuC;QACvC,EAAE,EAAE,MAAM,CAAA;KACX,CAAA;IAED,gEAAgE;IAChE,uBAAuB,EAAE;QACvB,kDAAkD;QAClD,EAAE,EAAE,MAAM,CAAA;KACX,CAAA;IAED,4CAA4C;IAC5C,oBAAoB,EAAE;QACpB,0CAA0C;QAC1C,EAAE,EAAE,MAAM,CAAA;KACX,CAAA;IAED,kEAAkE;IAClE,mBAAmB,EAAE;QACnB,wDAAwD;QACxD,EAAE,EAAE,MAAM,CAAA;KACX,CAAA;CACF,CAAA"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=ui.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,3 +1,4 @@
1
- export { type ApiReferenceEvent, type ApiReferenceEvents, emitCustomEvent } from './definitions.js';
1
+ export { type WorkspaceEventBus, createWorkspaceEventBus } from './bus.js';
2
2
  export { onCustomEvent } from './listeners.js';
3
+ export { type ApiReferenceEvent, type ApiReferenceEvents, emitCustomEvent } from './old-definitions.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAA;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA"}
@@ -1,6 +1,8 @@
1
- import { emitCustomEvent } from "./definitions.js";
1
+ import { createWorkspaceEventBus } from "./bus.js";
2
2
  import { onCustomEvent } from "./listeners.js";
3
+ import { emitCustomEvent } from "./old-definitions.js";
3
4
  export {
5
+ createWorkspaceEventBus,
4
6
  emitCustomEvent,
5
7
  onCustomEvent
6
8
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/events/index.ts"],
4
- "sourcesContent": ["// biome-ignore lint/performance/noBarrelFile: Entry point for /events\nexport { type ApiReferenceEvent, type ApiReferenceEvents, emitCustomEvent } from './definitions'\nexport { onCustomEvent } from './listeners'\n"],
5
- "mappings": "AACA,SAA0D,uBAAuB;AACjF,SAAS,qBAAqB;",
4
+ "sourcesContent": ["// biome-ignore lint/performance/noBarrelFile: Entry point for /events\nexport { type WorkspaceEventBus, createWorkspaceEventBus } from './bus'\nexport { onCustomEvent } from './listeners'\nexport { type ApiReferenceEvent, type ApiReferenceEvents, emitCustomEvent } from './old-definitions'\n"],
5
+ "mappings": "AACA,SAAiC,+BAA+B;AAChE,SAAS,qBAAqB;AAC9B,SAA0D,uBAAuB;",
6
6
  "names": []
7
7
  }
@@ -1,8 +1,9 @@
1
1
  import { type Ref } from 'vue';
2
- import type { ApiReferenceEvent, ApiReferenceEvents } from './definitions.js';
2
+ import type { ApiReferenceEvent, ApiReferenceEvents } from './old-definitions.js';
3
3
  /**
4
4
  * Vue wrapper for attaching and removing event listeners
5
5
  *
6
+ * @deprecated Use the the event bus instead
6
7
  */
7
8
  export declare function onCustomEvent<E extends ApiReferenceEvent>(el: Ref<HTMLElement | null>, event: E, handler: (event: CustomEvent<ApiReferenceEvents[E]['detail']>) => void): void;
8
9
  //# sourceMappingURL=listeners.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"listeners.d.ts","sourceRoot":"","sources":["../../src/events/listeners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAA0B,MAAM,KAAK,CAAA;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAE1E;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,iBAAiB,EACvD,EAAE,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,EAC3B,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,IAAI,QAsBvE"}
1
+ {"version":3,"file":"listeners.d.ts","sourceRoot":"","sources":["../../src/events/listeners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAA0B,MAAM,KAAK,CAAA;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAE9E;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,iBAAiB,EACvD,EAAE,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,EAC3B,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,IAAI,QAsBvE"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/events/listeners.ts"],
4
- "sourcesContent": ["import { type Ref, onBeforeUnmount, watch } from 'vue'\n\nimport type { ApiReferenceEvent, ApiReferenceEvents } from './definitions'\n\n/**\n * Vue wrapper for attaching and removing event listeners\n *\n */\nexport function onCustomEvent<E extends ApiReferenceEvent>(\n el: Ref<HTMLElement | null>,\n event: E,\n handler: (event: CustomEvent<ApiReferenceEvents[E]['detail']>) => void,\n) {\n // Any time the element reference changes, we need to add the event listener\n watch(\n () => el.value,\n (element) => {\n if (!element) {\n return\n }\n\n element.addEventListener(event, handler as any)\n },\n { immediate: true },\n )\n\n onBeforeUnmount(() => {\n if (!el.value) {\n return\n }\n\n el.value.removeEventListener(event, handler as any)\n })\n}\n"],
5
- "mappings": "AAAA,SAAmB,iBAAiB,aAAa;AAQ1C,SAAS,cACd,IACA,OACA,SACA;AAEA;AAAA,IACE,MAAM,GAAG;AAAA,IACT,CAAC,YAAY;AACX,UAAI,CAAC,SAAS;AACZ;AAAA,MACF;AAEA,cAAQ,iBAAiB,OAAO,OAAc;AAAA,IAChD;AAAA,IACA,EAAE,WAAW,KAAK;AAAA,EACpB;AAEA,kBAAgB,MAAM;AACpB,QAAI,CAAC,GAAG,OAAO;AACb;AAAA,IACF;AAEA,OAAG,MAAM,oBAAoB,OAAO,OAAc;AAAA,EACpD,CAAC;AACH;",
4
+ "sourcesContent": ["import { type Ref, onBeforeUnmount, watch } from 'vue'\n\nimport type { ApiReferenceEvent, ApiReferenceEvents } from './old-definitions'\n\n/**\n * Vue wrapper for attaching and removing event listeners\n *\n * @deprecated Use the the event bus instead\n */\nexport function onCustomEvent<E extends ApiReferenceEvent>(\n el: Ref<HTMLElement | null>,\n event: E,\n handler: (event: CustomEvent<ApiReferenceEvents[E]['detail']>) => void,\n) {\n // Any time the element reference changes, we need to add the event listener\n watch(\n () => el.value,\n (element) => {\n if (!element) {\n return\n }\n\n element.addEventListener(event, handler as any)\n },\n { immediate: true },\n )\n\n onBeforeUnmount(() => {\n if (!el.value) {\n return\n }\n\n el.value.removeEventListener(event, handler as any)\n })\n}\n"],
5
+ "mappings": "AAAA,SAAmB,iBAAiB,aAAa;AAS1C,SAAS,cACd,IACA,OACA,SACA;AAEA;AAAA,IACE,MAAM,GAAG;AAAA,IACT,CAAC,YAAY;AACX,UAAI,CAAC,SAAS;AACZ;AAAA,MACF;AAEA,cAAQ,iBAAiB,OAAO,OAAc;AAAA,IAChD;AAAA,IACA,EAAE,WAAW,KAAK;AAAA,EACpB;AAEA,kBAAgB,MAAM;AACpB,QAAI,CAAC,GAAG,OAAO;AACb;AAAA,IACF;AAEA,OAAG,MAAM,oBAAoB,OAAO,OAAc;AAAA,EACpD,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,4 @@
1
+ import type { HttpMethod } from '@scalar/helpers/http/http-methods';
1
2
  import type { AvailableClients } from '@scalar/snippetz';
2
3
  import type { Simplify } from 'type-fest';
3
4
  import type { ServerObject } from '../schemas/v3.1/strict/openapi-document.js';
@@ -5,18 +6,11 @@ import type { ServerObject } from '../schemas/v3.1/strict/openapi-document.js';
5
6
  * Event definitions for scalar blocks
6
7
  *
7
8
  * Events can have a typed payload using the `data` property.
9
+ *
10
+ * @deprecated use the new definitions instead
8
11
  */
9
12
  export type ApiReferenceEvents<T extends keyof ServerObject = keyof ServerObject> = {
10
- 'scalar-update-sidebar': {
11
- detail: {
12
- value: boolean;
13
- };
14
- };
15
- 'scalar-update-dark-mode': {
16
- detail: {
17
- value: boolean;
18
- };
19
- };
13
+ /** Store mutation events */
20
14
  'scalar-update-active-document': {
21
15
  detail: {
22
16
  value: string;
@@ -144,12 +138,42 @@ export type ApiReferenceEvents<T extends keyof ServerObject = keyof ServerObject
144
138
  uid: string;
145
139
  };
146
140
  };
141
+ /** UI Events. Allows users to tie into UI events as needed */
142
+ /** Download the document from the store */
143
+ 'scalar-download-document': {
144
+ detail: {
145
+ format: 'json' | 'yaml' | 'direct';
146
+ };
147
+ };
148
+ /** Add a new document to the store */
149
+ 'scalar-open-client': {
150
+ detail: {
151
+ method: HttpMethod;
152
+ path: string;
153
+ };
154
+ };
155
+ /** Fired when the user clicks the "Show more" button on the references */
156
+ 'scalar-on-show-more': {
157
+ detail: {
158
+ id: string;
159
+ };
160
+ };
161
+ 'scalar-on-loaded': {
162
+ detail: {};
163
+ };
164
+ 'scalar-update-dark-mode': {
165
+ detail: {
166
+ value: boolean;
167
+ };
168
+ };
147
169
  };
148
170
  export type ApiReferenceEvent = Simplify<keyof ApiReferenceEvents>;
149
171
  /**
150
172
  * Scalar blocks will use vanilla events to allow more flexibility in integrations
151
173
  *
152
174
  * Event can include typed payloads using the `data` property. A target for the dispatch must be provided.
175
+ *
176
+ * @deprecated Use the the event bus instead
153
177
  */
154
178
  export declare function emitCustomEvent<E extends ApiReferenceEvent>(target: HTMLElement | null | undefined, event: E, detail: ApiReferenceEvents[E]['detail']): void;
155
- //# sourceMappingURL=definitions.d.ts.map
179
+ //# sourceMappingURL=old-definitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"old-definitions.d.ts","sourceRoot":"","sources":["../../src/events/old-definitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,M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;IACD,kBAAkB,EAAE;QAClB,MAAM,EAAE,EAAE,CAAA;KACX,CAAA;IACD,yBAAyB,EAAE;QACzB,MAAM,EAAE;YACN,KAAK,EAAE,OAAO,CAAA;SACf,CAAA;KACF,CAAA;CACF,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,kBAAkB,CAAC,CAAA;AAElE;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,iBAAiB,EACzD,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,EACtC,KAAK,EAAE,CAAC,EACR,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAUxC"}
@@ -10,4 +10,4 @@ function emitCustomEvent(target, event, detail) {
10
10
  export {
11
11
  emitCustomEvent
12
12
  };
13
- //# sourceMappingURL=definitions.js.map
13
+ //# sourceMappingURL=old-definitions.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/events/old-definitions.ts"],
4
+ "sourcesContent": ["import type { HttpMethod } from '@scalar/helpers/http/http-methods'\nimport type { AvailableClients } from '@scalar/snippetz'\nimport type { Simplify } from 'type-fest'\n\nimport type { ServerObject } from '@/schemas/v3.1/strict/openapi-document'\n\n/**\n * Event definitions for scalar blocks\n *\n * Events can have a typed payload using the `data` property.\n *\n * @deprecated use the new definitions instead\n */\nexport type ApiReferenceEvents<T extends keyof ServerObject = keyof ServerObject> = {\n // ---------------------------------------------------------------------------\n /** Store mutation events */\n\n 'scalar-update-active-document': {\n detail: {\n value: string\n }\n }\n /** Controls the selected client in our code example blocks */\n 'scalar-update-selected-client': {\n detail: AvailableClients[number]\n }\n /** Controls the selected example key in our operation blocks + children */\n 'scalar-update-selected-example': {\n detail: string\n }\n /** Controls the selected server URL in our server selector blocks */\n 'scalar-update-selected-server': {\n detail: {\n value?: string\n options?: {\n /**\n * Update only new store\n *\n * Do not update the old store since it will be handled manually\n */\n disableOldStoreUpdate: boolean\n }\n }\n }\n /** Controls the selected server URL in our server selector blocks */\n 'scalar-update-selected-server-variables': {\n detail: {\n key: string\n value: string\n options?: {\n /**\n * Update only new store\n *\n * Do not update the old store since it will be handled manually\n */\n disableOldStoreUpdate: boolean\n }\n }\n }\n 'store-update-selected-server-properties': {\n detail: {\n key: T\n value: ServerObject[T]\n options?: {\n /**\n * Update only new store\n *\n * Do not update the old store since it will be handled manually\n */\n disableOldStoreUpdate: boolean\n }\n }\n }\n /** Replace all document servers */\n 'scalar-replace-servers': {\n detail: {\n servers: ServerObject[]\n options?: {\n /**\n * Update only new store\n *\n * Do not update the old store since it will be handled manually\n */\n disableOldStoreUpdate: boolean\n }\n }\n }\n /** Add a new server to the active document */\n 'scalar-add-server': {\n detail: {\n server: ServerObject\n options?: {\n /**\n * Update only new store\n *\n * Do not update the old store since it will be handled manually\n */\n disableOldStoreUpdate: boolean\n }\n }\n }\n /** Add a new server to the active document */\n 'scalar-delete-server': {\n detail: {\n url: string\n options?: {\n /**\n * Update only new store\n *\n * Do not update the old store since it will be handled manually\n */\n disableOldStoreUpdate: boolean\n }\n }\n }\n\n // ---------------------------------------------------------------------------\n /** Auth events */\n 'scalar-select-security-schemes': {\n detail: {\n uids: string[]\n }\n }\n\n 'scalar-select-operation-security-schemes': {\n detail: {\n operationUid: string\n uids: string[]\n }\n }\n\n 'scalar-edit-security-scheme': {\n detail: {\n uid: string\n path: string\n value: any\n }\n }\n\n 'scalar-add-auth-option': {\n detail: {\n payload: any\n }\n }\n\n 'scalar-delete-security-scheme': {\n detail: {\n uid: string\n }\n }\n // ---------------------------------------------------------------------------\n /** UI Events. Allows users to tie into UI events as needed */\n\n /** Download the document from the store */\n 'scalar-download-document': {\n detail: {\n format: 'json' | 'yaml' | 'direct'\n }\n }\n /** Add a new document to the store */\n 'scalar-open-client': {\n detail: {\n method: HttpMethod\n path: string\n }\n }\n /** Fired when the user clicks the \"Show more\" button on the references */\n 'scalar-on-show-more': {\n detail: {\n id: string\n }\n }\n 'scalar-on-loaded': {\n detail: {}\n }\n 'scalar-update-dark-mode': {\n detail: {\n value: boolean\n }\n }\n}\n\nexport type ApiReferenceEvent = Simplify<keyof ApiReferenceEvents>\n\n/**\n * Scalar blocks will use vanilla events to allow more flexibility in integrations\n *\n * Event can include typed payloads using the `data` property. A target for the dispatch must be provided.\n *\n * @deprecated Use the the event bus instead\n */\nexport function emitCustomEvent<E extends ApiReferenceEvent>(\n target: HTMLElement | null | undefined,\n event: E,\n detail: ApiReferenceEvents[E]['detail'],\n) {\n const instance = new CustomEvent(event, {\n detail: detail,\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n\n target?.dispatchEvent(instance)\n}\n"],
5
+ "mappings": "AA+LO,SAAS,gBACd,QACA,OACA,QACA;AACA,QAAM,WAAW,IAAI,YAAY,OAAO;AAAA,IACtC;AAAA,IACA,SAAS;AAAA,IACT,UAAU;AAAA,IACV,YAAY;AAAA,EACd,CAAC;AAED,UAAQ,cAAc,QAAQ;AAChC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Options for configuring the debounce behavior.
3
+ */
4
+ export type DebounceOptions = {
5
+ /** The delay in milliseconds before executing the function. Defaults to 100ms. */
6
+ delay?: number;
7
+ /** Custom separator for joining key parts. Defaults to a null byte to prevent collisions. */
8
+ separator?: string;
9
+ };
10
+ /**
11
+ * Creates a debounced function executor that delays execution until after a specified time.
12
+ * Multiple calls with the same key will cancel previous pending executions.
13
+ *
14
+ * This is useful for batching rapid updates (like auto-save or API calls) to avoid
15
+ * unnecessary processing or network requests.
16
+ *
17
+ * @param options - Configuration options for delay and key separator
18
+ * @returns A function that accepts a key array and callback to execute
19
+ *
20
+ * @example
21
+ * const debouncedSave = debounce({ delay: 500 })
22
+ * debouncedSave(['user', '123'], () => saveUser(user))
23
+ */
24
+ export declare const debounce: (options?: DebounceOptions) => {
25
+ execute: (key: readonly string[], fn: () => unknown | Promise<unknown>) => void;
26
+ cleanup: () => void;
27
+ };
28
+ //# sourceMappingURL=debounce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/helpers/debounce.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,kFAAkF;IAClF,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,6FAA6F;IAC7F,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,QAAQ,GAAI,UAAS,eAAoB;mBAsB9B,SAAS,MAAM,EAAE,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAG,IAAI;mBAdhE,IAAI;CAyCzB,CAAA"}
@@ -0,0 +1,31 @@
1
+ const debounce = (options = {}) => {
2
+ const { delay = 100, separator = "\0" } = options;
3
+ const timeouts = /* @__PURE__ */ new Map();
4
+ const cleanup = () => {
5
+ for (const timeout of timeouts.values()) {
6
+ clearTimeout(timeout);
7
+ }
8
+ timeouts.clear();
9
+ };
10
+ const execute = (key, fn) => {
11
+ const compositeKey = `${key.join(separator)}-${key.length}`;
12
+ const existingTimeout = timeouts.get(compositeKey);
13
+ if (existingTimeout !== void 0) {
14
+ clearTimeout(existingTimeout);
15
+ }
16
+ const timeout = setTimeout(() => {
17
+ try {
18
+ fn();
19
+ } catch {
20
+ } finally {
21
+ timeouts.delete(compositeKey);
22
+ }
23
+ }, delay);
24
+ timeouts.set(compositeKey, timeout);
25
+ };
26
+ return { execute, cleanup };
27
+ };
28
+ export {
29
+ debounce
30
+ };
31
+ //# sourceMappingURL=debounce.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/helpers/debounce.ts"],
4
+ "sourcesContent": ["/**\n * Options for configuring the debounce behavior.\n */\nexport type DebounceOptions = {\n /** The delay in milliseconds before executing the function. Defaults to 100ms. */\n delay?: number\n /** Custom separator for joining key parts. Defaults to a null byte to prevent collisions. */\n separator?: string\n}\n\n/**\n * Creates a debounced function executor that delays execution until after a specified time.\n * Multiple calls with the same key will cancel previous pending executions.\n *\n * This is useful for batching rapid updates (like auto-save or API calls) to avoid\n * unnecessary processing or network requests.\n *\n * @param options - Configuration options for delay and key separator\n * @returns A function that accepts a key array and callback to execute\n *\n * @example\n * const debouncedSave = debounce({ delay: 500 })\n * debouncedSave(['user', '123'], () => saveUser(user))\n */\nexport const debounce = (options: DebounceOptions = {}) => {\n const { delay = 100, separator = '\\0' } = options\n const timeouts = new Map<string, ReturnType<typeof setTimeout>>()\n\n /**\n * Cleanup function to clear all pending timeouts.\n * Call this when you need to cancel all pending operations (e.g., component unmount).\n */\n const cleanup = (): void => {\n for (const timeout of timeouts.values()) {\n clearTimeout(timeout)\n }\n timeouts.clear()\n }\n\n /**\n * Schedules a function to run after the configured delay.\n * If called again with the same key before the delay expires, the previous call is cancelled.\n *\n * @param key - Array of strings to uniquely identify this operation\n * @param fn - The function to execute after the delay\n */\n const execute = (key: readonly string[], fn: () => unknown | Promise<unknown>): void => {\n // Add the length of the key to the composite key to prevent collisions\n const compositeKey = `${key.join(separator)}-${key.length}`\n\n // Cancel any existing timeout for this key\n const existingTimeout = timeouts.get(compositeKey)\n if (existingTimeout !== undefined) {\n clearTimeout(existingTimeout)\n }\n\n // Schedule the new timeout\n const timeout = setTimeout(() => {\n try {\n // biome-ignore lint/nursery/noFloatingPromises: No need to await for the result, fire and forget\n fn()\n } catch {\n // do not throw if the function throws\n } finally {\n // Always clean up the timeout reference, even if fn throws\n timeouts.delete(compositeKey)\n }\n }, delay)\n\n timeouts.set(compositeKey, timeout)\n }\n\n return { execute, cleanup }\n}\n"],
5
+ "mappings": "AAwBO,MAAM,WAAW,CAAC,UAA2B,CAAC,MAAM;AACzD,QAAM,EAAE,QAAQ,KAAK,YAAY,KAAK,IAAI;AAC1C,QAAM,WAAW,oBAAI,IAA2C;AAMhE,QAAM,UAAU,MAAY;AAC1B,eAAW,WAAW,SAAS,OAAO,GAAG;AACvC,mBAAa,OAAO;AAAA,IACtB;AACA,aAAS,MAAM;AAAA,EACjB;AASA,QAAM,UAAU,CAAC,KAAwB,OAA+C;AAEtF,UAAM,eAAe,GAAG,IAAI,KAAK,SAAS,CAAC,IAAI,IAAI,MAAM;AAGzD,UAAM,kBAAkB,SAAS,IAAI,YAAY;AACjD,QAAI,oBAAoB,QAAW;AACjC,mBAAa,eAAe;AAAA,IAC9B;AAGA,UAAM,UAAU,WAAW,MAAM;AAC/B,UAAI;AAEF,WAAG;AAAA,MACL,QAAQ;AAAA,MAER,UAAE;AAEA,iBAAS,OAAO,YAAY;AAAA,MAC9B;AAAA,IACF,GAAG,KAAK;AAER,aAAS,IAAI,cAAc,OAAO;AAAA,EACpC;AAEA,SAAO,EAAE,SAAS,QAAQ;AAC5B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * createDetectChangesProxy - Creates a proxy for an object or array that detects and triggers hooks on changes.
3
+ *
4
+ * This proxy enables detection of set operations, triggering optional hooks (onBeforeChange, onAfterChange) with the path and value changed.
5
+ * The proxy can be applied recursively to all nested objects/arrays, and caches proxies to prevent creating multiple proxies for the same object.
6
+ *
7
+ * Example usage:
8
+ *
9
+ * const obj = { foo: 1, bar: { baz: 2 } };
10
+ * const proxy = createDetectChangesProxy(obj, {
11
+ * hooks: {
12
+ * onBeforeChange: (path, value) => console.log('Before', path, value),
13
+ * onAfterChange: (path, value) => console.log('After', path, value),
14
+ * }
15
+ * });
16
+ * proxy.foo = 42; // Console: Before ['foo'] '42', After ['foo'] '42'
17
+ * proxy.bar.baz = 99; // Console: Before ['bar', 'baz'] '99', After ['bar', 'baz'] '99'
18
+ *
19
+ * @param target The target object or array to wrap in a proxy
20
+ * @param options Optional: hooks for change detection
21
+ * @param args Internal: proxy cache and current property path (used for recursion)
22
+ * @returns The proxied object/array with change detection capabilities
23
+ */
24
+ export declare const createDetectChangesProxy: <T>(target: T, options?: {
25
+ hooks: Partial<{
26
+ onBeforeChange: (path: string[], value: unknown) => void;
27
+ onAfterChange: (path: string[], value: unknown) => void;
28
+ }>;
29
+ }, args?: {
30
+ /** Cache for storing proxies */
31
+ proxyCache: WeakMap<object, unknown>;
32
+ /** Path for the target */
33
+ path: string[];
34
+ }) => T;
35
+ export declare const isDetectChangesProxyObject: (obj: unknown) => boolean;
36
+ /**
37
+ * Returns the raw/original (non-proxy) object if the passed object is a detect-changes proxy.
38
+ * If the object is not a proxy, it returns the same object.
39
+ *
40
+ * @example
41
+ * const proxy = createDetectChangesProxy({ a: 1 });
42
+ * const raw = unpackDetectChangesProxy(proxy); // Gets the original object { a: 1 }
43
+ * const notProxy = { b: 2 };
44
+ * const stillRaw = unpackDetectChangesProxy(notProxy); // Returns { b: 2 }, unchanged
45
+ */
46
+ export declare const unpackDetectChangesProxy: <T>(obj: T) => T;
47
+ //# sourceMappingURL=detect-changes-proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-changes-proxy.d.ts","sourceRoot":"","sources":["../../src/helpers/detect-changes-proxy.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,wBAAwB,GAAI,CAAC,EACxC,QAAQ,CAAC,EACT,UAAU;IACR,KAAK,EAAE,OAAO,CAAC;QACb,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;QACxD,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;KACxD,CAAC,CAAA;CACH,EACD,OAAM;IACJ,gCAAgC;IAChC,UAAU,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,0BAA0B;IAC1B,IAAI,EAAE,MAAM,EAAE,CAAA;CAIf,KACA,CA6CF,CAAA;AAED,eAAO,MAAM,0BAA0B,GAAI,KAAK,OAAO,KAAG,OAMzD,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,GAAI,CAAC,EAAE,KAAK,CAAC,KAAG,CAWpD,CAAA"}
@@ -0,0 +1,59 @@
1
+ import { isObject } from "../helpers/general.js";
2
+ const isDetectChangesProxy = Symbol("isDetectChangesProxy");
3
+ const detectChangesProxyTarget = Symbol("detectChangesProxyTarget");
4
+ const isPropsVue = (prop) => {
5
+ return typeof prop === "symbol" || prop === "__v_isReactive" || prop === "__v_isReadonly" || prop === "__v_raw" || prop === "__v_skip";
6
+ };
7
+ const createDetectChangesProxy = (target, options, args = {
8
+ proxyCache: /* @__PURE__ */ new WeakMap(),
9
+ path: []
10
+ }) => {
11
+ if (!isObject(target) && !Array.isArray(target)) {
12
+ return target;
13
+ }
14
+ if (args.proxyCache.has(target)) {
15
+ return args.proxyCache.get(target);
16
+ }
17
+ const proxy = new Proxy(target, {
18
+ get(target2, prop, receiver) {
19
+ if (prop === isDetectChangesProxy) {
20
+ return true;
21
+ }
22
+ if (prop === detectChangesProxyTarget) {
23
+ return target2;
24
+ }
25
+ const value = Reflect.get(target2, prop, receiver);
26
+ if (isDetectChangesProxyObject(value) || isPropsVue(prop)) {
27
+ return value;
28
+ }
29
+ return createDetectChangesProxy(value, options, { ...args, path: [...args.path, String(prop)] });
30
+ },
31
+ set(target2, prop, value, receiver) {
32
+ const path = [...args.path, String(prop)];
33
+ options?.hooks?.onBeforeChange?.(path, value);
34
+ const result = Reflect.set(target2, prop, value, receiver);
35
+ options?.hooks?.onAfterChange?.(path, value);
36
+ return result;
37
+ }
38
+ });
39
+ args.proxyCache.set(target, proxy);
40
+ return proxy;
41
+ };
42
+ const isDetectChangesProxyObject = (obj) => {
43
+ return typeof obj === "object" && obj !== null && obj[isDetectChangesProxy] === true;
44
+ };
45
+ const unpackDetectChangesProxy = (obj) => {
46
+ if (typeof obj !== "object" || obj === null) {
47
+ return obj;
48
+ }
49
+ if (obj[isDetectChangesProxy]) {
50
+ return obj[detectChangesProxyTarget];
51
+ }
52
+ return obj;
53
+ };
54
+ export {
55
+ createDetectChangesProxy,
56
+ isDetectChangesProxyObject,
57
+ unpackDetectChangesProxy
58
+ };
59
+ //# sourceMappingURL=detect-changes-proxy.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/helpers/detect-changes-proxy.ts"],
4
+ "sourcesContent": ["import { isObject } from '@/helpers/general'\n\nconst isDetectChangesProxy = Symbol('isDetectChangesProxy')\nconst detectChangesProxyTarget = Symbol('detectChangesProxyTarget')\n\nconst isPropsVue = (prop: string | Symbol) => {\n return (\n typeof prop === 'symbol' ||\n prop === '__v_isReactive' ||\n prop === '__v_isReadonly' ||\n prop === '__v_raw' ||\n prop === '__v_skip'\n )\n}\n\n/**\n * createDetectChangesProxy - Creates a proxy for an object or array that detects and triggers hooks on changes.\n *\n * This proxy enables detection of set operations, triggering optional hooks (onBeforeChange, onAfterChange) with the path and value changed.\n * The proxy can be applied recursively to all nested objects/arrays, and caches proxies to prevent creating multiple proxies for the same object.\n *\n * Example usage:\n *\n * const obj = { foo: 1, bar: { baz: 2 } };\n * const proxy = createDetectChangesProxy(obj, {\n * hooks: {\n * onBeforeChange: (path, value) => console.log('Before', path, value),\n * onAfterChange: (path, value) => console.log('After', path, value),\n * }\n * });\n * proxy.foo = 42; // Console: Before ['foo'] '42', After ['foo'] '42'\n * proxy.bar.baz = 99; // Console: Before ['bar', 'baz'] '99', After ['bar', 'baz'] '99'\n *\n * @param target The target object or array to wrap in a proxy\n * @param options Optional: hooks for change detection\n * @param args Internal: proxy cache and current property path (used for recursion)\n * @returns The proxied object/array with change detection capabilities\n */\nexport const createDetectChangesProxy = <T>(\n target: T,\n options?: {\n hooks: Partial<{\n onBeforeChange: (path: string[], value: unknown) => void\n onAfterChange: (path: string[], value: unknown) => void\n }>\n },\n args: {\n /** Cache for storing proxies */\n proxyCache: WeakMap<object, unknown>\n /** Path for the target */\n path: string[]\n } = {\n proxyCache: new WeakMap<object, unknown>(),\n path: [],\n },\n): T => {\n // Only wrap objects or arrays\n if (!isObject(target) && !Array.isArray(target)) {\n return target\n }\n\n // Return cached proxy if already created for this target\n if (args.proxyCache.has(target)) {\n return args.proxyCache.get(target)! as T\n }\n\n const proxy = new Proxy(target, {\n get(target, prop, receiver) {\n // Allow identifying if an object is a detect changes proxy\n if (prop === isDetectChangesProxy) {\n return true\n }\n // Allow access to the original target\n if (prop === detectChangesProxyTarget) {\n return target\n }\n\n // Recursively wrap property values in the detect changes proxy\n const value = Reflect.get(target, prop, receiver)\n\n if (isDetectChangesProxyObject(value) || isPropsVue(prop)) {\n return value\n }\n\n return createDetectChangesProxy(value, options, { ...args, path: [...args.path, String(prop)] })\n },\n set(target, prop, value, receiver) {\n const path = [...args.path, String(prop)]\n // Call before-change hook if provided\n options?.hooks?.onBeforeChange?.(path, value)\n const result = Reflect.set(target, prop, value, receiver)\n // Call after-change hook if provided\n options?.hooks?.onAfterChange?.(path, value)\n return result\n },\n })\n\n // Cache the proxy for this target\n args.proxyCache.set(target, proxy)\n return proxy\n}\n\nexport const isDetectChangesProxyObject = (obj: unknown): boolean => {\n return (\n typeof obj === 'object' &&\n obj !== null &&\n (obj as { [isDetectChangesProxy]: boolean })[isDetectChangesProxy] === true\n )\n}\n\n/**\n * Returns the raw/original (non-proxy) object if the passed object is a detect-changes proxy.\n * If the object is not a proxy, it returns the same object.\n *\n * @example\n * const proxy = createDetectChangesProxy({ a: 1 });\n * const raw = unpackDetectChangesProxy(proxy); // Gets the original object { a: 1 }\n * const notProxy = { b: 2 };\n * const stillRaw = unpackDetectChangesProxy(notProxy); // Returns { b: 2 }, unchanged\n */\nexport const unpackDetectChangesProxy = <T>(obj: T): T => {\n if (typeof obj !== 'object' || obj === null) {\n return obj\n }\n\n // If object is a detect-changes proxy, return its underlying target\n if ((obj as T & { [isDetectChangesProxy]: boolean | undefined })[isDetectChangesProxy]) {\n return (obj as T & { [detectChangesProxyTarget]: T })[detectChangesProxyTarget]\n }\n\n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AGD,OAAK,WAAW,IAAI,QAAQ,KAAK;AACjC,SAAO;AACT;AAEO,MAAM,6BAA6B,CAAC,QAA0B;AACnE,SACE,OAAO,QAAQ,YACf,QAAQ,QACP,IAA4C,oBAAoB,MAAM;AAE3E;AAYO,MAAM,2BAA2B,CAAI,QAAc;AACxD,MAAI,OAAO,QAAQ,YAAY,QAAQ,MAAM;AAC3C,WAAO;AAAA,EACT;AAGA,MAAK,IAA4D,oBAAoB,GAAG;AACtF,WAAQ,IAA8C,wBAAwB;AAAA,EAChF;AAEA,SAAO;AACT;",
6
+ "names": ["target"]
7
+ }
@@ -1,4 +1,4 @@
1
- import { type UnknownObject } from '../helpers/general.js';
1
+ export declare const getOverridesTarget: unique symbol;
2
2
  /**
3
3
  * Recursively makes all properties of a type optional.
4
4
  *
@@ -23,14 +23,14 @@ export type DeepPartial<T> = T extends object ? {
23
23
  * - Special symbols are used to identify the proxy and to access the original target.
24
24
  *
25
25
  * @template T - The type of the target object.
26
- * @param targetObject - The original object to proxy.
26
+ * @param target - The original object to proxy.
27
27
  * @param overrides - An optional object containing override values (deeply partial).
28
28
  * @returns A proxy object that reflects overrides on top of the target.
29
29
  *
30
30
  * @example
31
31
  * const original = { a: 1, b: { c: 2 } }
32
32
  * const overrides = { b: { c: 42 } }
33
- * const proxy = createOverridesProxy(original, overrides)
33
+ * const proxy = createOverridesProxy(original, { overrides })
34
34
  *
35
35
  * console.log(proxy.a) // 1 (from original)
36
36
  * console.log(proxy.b.c) // 42 (from overrides)
@@ -41,7 +41,18 @@ export type DeepPartial<T> = T extends object ? {
41
41
  * proxy.b.c = 99
42
42
  * console.log(overrides.b.c) // 99
43
43
  */
44
- export declare const createOverridesProxy: <T extends Record<string, unknown>>(targetObject: T, overrides?: DeepPartial<T>) => T;
45
- export declare const TARGET_SYMBOL: unique symbol;
46
- export declare function unpackOverridesProxy<T extends UnknownObject>(obj: T): T;
44
+ export declare const createOverridesProxy: <T extends Record<string, unknown>>(target: T, options?: {
45
+ overrides?: DeepPartial<T>;
46
+ }, args?: {
47
+ cache: WeakMap<object, any>;
48
+ }) => T;
49
+ export declare const isOverridesProxyObject: (obj: unknown) => boolean;
50
+ /**
51
+ * Unpacks an object from the overrides proxy, returning the original (unproxied) target object.
52
+ * If the input is not an overrides proxy, returns the object as-is.
53
+ *
54
+ * @param input - The potentially proxied object
55
+ * @returns The original unproxied target object or the input object
56
+ */
57
+ export declare function unpackOverridesProxy<T>(input: T): T;
47
58
  //# sourceMappingURL=overrides-proxy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"overrides-proxy.d.ts","sourceRoot":"","sources":["../../src/helpers/overrides-proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAY,MAAM,mBAAmB,CAAA;AAIhE;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,CAAC,CAAA;AAE1F;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpE,cAAc,CAAC,EACf,YAAY,WAAW,CAAC,CAAC,CAAC,KACzB,CAkDF,CAAA;AAED,eAAO,MAAM,aAAa,eAAiC,CAAA;AAC3D,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,aAAa,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAMvE"}
1
+ {"version":3,"file":"overrides-proxy.d.ts","sourceRoot":"","sources":["../../src/helpers/overrides-proxy.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,eAA+B,CAAA;AAE9D;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG;KAAG,CAA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