@scalar/workspace-store 0.17.1 → 0.18.1

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 (202) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/client.d.ts +31 -19
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +267 -88
  5. package/dist/client.js.map +3 -3
  6. package/dist/events/bus.d.ts +96 -0
  7. package/dist/events/bus.d.ts.map +1 -0
  8. package/dist/events/bus.js +60 -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/common.d.ts +5 -0
  19. package/dist/events/definitions/common.d.ts.map +1 -0
  20. package/dist/events/definitions/common.js +1 -0
  21. package/dist/events/definitions/common.js.map +7 -0
  22. package/dist/events/definitions/document.d.ts +14 -0
  23. package/dist/events/definitions/document.d.ts.map +1 -0
  24. package/dist/events/definitions/document.js +1 -0
  25. package/dist/events/definitions/document.js.map +7 -0
  26. package/dist/events/definitions/environment.d.ts +37 -0
  27. package/dist/events/definitions/environment.d.ts.map +1 -0
  28. package/dist/events/definitions/environment.js +1 -0
  29. package/dist/events/definitions/environment.js.map +7 -0
  30. package/dist/events/definitions/index.d.ts +12 -0
  31. package/dist/events/definitions/index.d.ts.map +1 -0
  32. package/dist/events/definitions/index.js +1 -0
  33. package/dist/events/definitions/index.js.map +7 -0
  34. package/dist/events/definitions/meta.d.ts +17 -0
  35. package/dist/events/definitions/meta.d.ts.map +1 -0
  36. package/dist/events/definitions/meta.js +1 -0
  37. package/dist/events/definitions/meta.js.map +7 -0
  38. package/dist/events/definitions/operation.d.ts +11 -0
  39. package/dist/events/definitions/operation.d.ts.map +1 -0
  40. package/dist/events/definitions/operation.js +1 -0
  41. package/dist/events/definitions/operation.js.map +7 -0
  42. package/dist/events/definitions/server.d.ts +50 -0
  43. package/dist/events/definitions/server.d.ts.map +1 -0
  44. package/dist/events/definitions/server.js +1 -0
  45. package/dist/events/definitions/server.js.map +7 -0
  46. package/dist/events/definitions/ui.d.ts +52 -0
  47. package/dist/events/definitions/ui.d.ts.map +1 -0
  48. package/dist/events/definitions/ui.js +1 -0
  49. package/dist/events/definitions/ui.js.map +7 -0
  50. package/dist/events/index.d.ts +3 -1
  51. package/dist/events/index.d.ts.map +1 -1
  52. package/dist/events/index.js +3 -1
  53. package/dist/events/index.js.map +2 -2
  54. package/dist/events/listeners.d.ts +2 -1
  55. package/dist/events/listeners.d.ts.map +1 -1
  56. package/dist/events/listeners.js.map +2 -2
  57. package/dist/events/{definitions.d.ts → old-definitions.d.ts} +35 -11
  58. package/dist/events/old-definitions.d.ts.map +1 -0
  59. package/dist/events/{definitions.js → old-definitions.js} +1 -1
  60. package/dist/events/old-definitions.js.map +7 -0
  61. package/dist/helpers/debounce.d.ts +28 -0
  62. package/dist/helpers/debounce.d.ts.map +1 -0
  63. package/dist/helpers/debounce.js +31 -0
  64. package/dist/helpers/debounce.js.map +7 -0
  65. package/dist/helpers/detect-changes-proxy.d.ts +47 -0
  66. package/dist/helpers/detect-changes-proxy.d.ts.map +1 -0
  67. package/dist/helpers/detect-changes-proxy.js +59 -0
  68. package/dist/helpers/detect-changes-proxy.js.map +7 -0
  69. package/dist/helpers/overrides-proxy.d.ts +17 -6
  70. package/dist/helpers/overrides-proxy.d.ts.map +1 -1
  71. package/dist/helpers/overrides-proxy.js +33 -18
  72. package/dist/helpers/overrides-proxy.js.map +3 -3
  73. package/dist/helpers/unpack-proxy.d.ts +6 -0
  74. package/dist/helpers/unpack-proxy.d.ts.map +1 -0
  75. package/dist/helpers/unpack-proxy.js +9 -0
  76. package/dist/helpers/unpack-proxy.js.map +7 -0
  77. package/dist/mutators/environment.d.ts +21 -13
  78. package/dist/mutators/environment.d.ts.map +1 -1
  79. package/dist/mutators/environment.js +46 -25
  80. package/dist/mutators/environment.js.map +2 -2
  81. package/dist/mutators/index.d.ts +4 -12
  82. package/dist/mutators/index.d.ts.map +1 -1
  83. package/dist/mutators/index.js +7 -4
  84. package/dist/mutators/index.js.map +2 -2
  85. package/dist/navigation/get-navigation-options.d.ts +1 -1
  86. package/dist/navigation/get-navigation-options.d.ts.map +1 -1
  87. package/dist/navigation/get-navigation-options.js +66 -54
  88. package/dist/navigation/get-navigation-options.js.map +2 -2
  89. package/dist/navigation/helpers/get-tag.d.ts +7 -2
  90. package/dist/navigation/helpers/get-tag.d.ts.map +1 -1
  91. package/dist/navigation/helpers/get-tag.js +16 -2
  92. package/dist/navigation/helpers/get-tag.js.map +2 -2
  93. package/dist/navigation/helpers/traverse-description.d.ts +7 -2
  94. package/dist/navigation/helpers/traverse-description.d.ts.map +1 -1
  95. package/dist/navigation/helpers/traverse-description.js +24 -6
  96. package/dist/navigation/helpers/traverse-description.js.map +2 -2
  97. package/dist/navigation/helpers/traverse-document.d.ts +5 -2
  98. package/dist/navigation/helpers/traverse-document.d.ts.map +1 -1
  99. package/dist/navigation/helpers/traverse-document.js +53 -15
  100. package/dist/navigation/helpers/traverse-document.js.map +2 -2
  101. package/dist/navigation/helpers/traverse-paths.d.ts +9 -3
  102. package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
  103. package/dist/navigation/helpers/traverse-paths.js +63 -9
  104. package/dist/navigation/helpers/traverse-paths.js.map +2 -2
  105. package/dist/navigation/helpers/traverse-schemas.d.ts +7 -8
  106. package/dist/navigation/helpers/traverse-schemas.d.ts.map +1 -1
  107. package/dist/navigation/helpers/traverse-schemas.js +35 -7
  108. package/dist/navigation/helpers/traverse-schemas.js.map +2 -2
  109. package/dist/navigation/helpers/traverse-tags.d.ts +8 -4
  110. package/dist/navigation/helpers/traverse-tags.d.ts.map +1 -1
  111. package/dist/navigation/helpers/traverse-tags.js +65 -17
  112. package/dist/navigation/helpers/traverse-tags.js.map +2 -2
  113. package/dist/navigation/helpers/traverse-webhooks.d.ts +9 -3
  114. package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
  115. package/dist/navigation/helpers/traverse-webhooks.js +43 -17
  116. package/dist/navigation/helpers/traverse-webhooks.js.map +2 -2
  117. package/dist/navigation/types.d.ts +5 -24
  118. package/dist/navigation/types.d.ts.map +1 -1
  119. package/dist/persistence/index.d.ts +86 -0
  120. package/dist/persistence/index.d.ts.map +1 -0
  121. package/dist/persistence/index.js +196 -0
  122. package/dist/persistence/index.js.map +7 -0
  123. package/dist/persistence/indexdb.d.ts +87 -0
  124. package/dist/persistence/indexdb.d.ts.map +1 -0
  125. package/dist/persistence/indexdb.js +125 -0
  126. package/dist/persistence/indexdb.js.map +7 -0
  127. package/dist/{plugins.d.ts → plugins/bundler/index.d.ts} +1 -1
  128. package/dist/plugins/bundler/index.d.ts.map +1 -0
  129. package/dist/{plugins.js → plugins/bundler/index.js} +2 -2
  130. package/dist/{plugins.js.map → plugins/bundler/index.js.map} +1 -1
  131. package/dist/plugins/client/index.d.ts +3 -0
  132. package/dist/plugins/client/index.d.ts.map +1 -0
  133. package/dist/plugins/client/index.js +5 -0
  134. package/dist/plugins/client/index.js.map +7 -0
  135. package/dist/plugins/client/persistence.d.ts +13 -0
  136. package/dist/plugins/client/persistence.d.ts.map +1 -0
  137. package/dist/plugins/client/persistence.js +57 -0
  138. package/dist/plugins/client/persistence.js.map +7 -0
  139. package/dist/schemas/extensions/document/x-scalar-environments.d.ts +52 -0
  140. package/dist/schemas/extensions/document/x-scalar-environments.d.ts.map +1 -0
  141. package/dist/schemas/extensions/document/x-scalar-environments.js +25 -0
  142. package/dist/schemas/extensions/document/x-scalar-environments.js.map +7 -0
  143. package/dist/schemas/extensions/workspace/x-scalar-active-environment.d.ts +8 -0
  144. package/dist/schemas/extensions/workspace/x-scalar-active-environment.d.ts.map +1 -0
  145. package/dist/schemas/extensions/workspace/x-scalar-active-environment.js +8 -0
  146. package/dist/schemas/extensions/workspace/x-scalar-active-environment.js.map +7 -0
  147. package/dist/schemas/extensions.d.ts +1 -0
  148. package/dist/schemas/extensions.d.ts.map +1 -1
  149. package/dist/schemas/extensions.js +1 -0
  150. package/dist/schemas/extensions.js.map +2 -2
  151. package/dist/schemas/inmemory-workspace.d.ts +95 -28
  152. package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
  153. package/dist/schemas/inmemory-workspace.js +1 -9
  154. package/dist/schemas/inmemory-workspace.js.map +2 -2
  155. package/dist/schemas/navigation.d.ts +128 -1
  156. package/dist/schemas/navigation.d.ts.map +1 -1
  157. package/dist/schemas/navigation.js +20 -1
  158. package/dist/schemas/navigation.js.map +2 -2
  159. package/dist/schemas/reference-config/index.d.ts +243 -206
  160. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  161. package/dist/schemas/reference-config/index.js.map +2 -2
  162. package/dist/schemas/reference-config/settings.d.ts +45 -9
  163. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  164. package/dist/schemas/reference-config/settings.js +1 -1
  165. package/dist/schemas/reference-config/settings.js.map +1 -1
  166. package/dist/schemas/v3.1/strict/openapi-document.d.ts +1540 -311
  167. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  168. package/dist/schemas/v3.1/strict/openapi-document.js +20 -13
  169. package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
  170. package/dist/schemas/v3.1/strict/parameter.d.ts +23 -1
  171. package/dist/schemas/v3.1/strict/parameter.d.ts.map +1 -1
  172. package/dist/schemas/v3.1/strict/parameter.js +5 -1
  173. package/dist/schemas/v3.1/strict/parameter.js.map +2 -2
  174. package/dist/schemas/v3.1/strict/ref-definitions.d.ts +2 -0
  175. package/dist/schemas/v3.1/strict/ref-definitions.d.ts.map +1 -1
  176. package/dist/schemas/v3.1/strict/ref-definitions.js +4 -1
  177. package/dist/schemas/v3.1/strict/ref-definitions.js.map +2 -2
  178. package/dist/schemas/workspace-specification/config.d.ts +46 -15
  179. package/dist/schemas/workspace-specification/config.d.ts.map +1 -1
  180. package/dist/schemas/workspace-specification/config.js.map +1 -1
  181. package/dist/schemas/workspace-specification/index.d.ts +48 -11
  182. package/dist/schemas/workspace-specification/index.d.ts.map +1 -1
  183. package/dist/schemas/workspace.d.ts +353 -85
  184. package/dist/schemas/workspace.d.ts.map +1 -1
  185. package/dist/schemas/workspace.js +19 -11
  186. package/dist/schemas/workspace.js.map +2 -2
  187. package/dist/server.d.ts +4 -3
  188. package/dist/server.d.ts.map +1 -1
  189. package/dist/server.js +7 -6
  190. package/dist/server.js.map +2 -2
  191. package/dist/workspace-plugin.d.ts +49 -0
  192. package/dist/workspace-plugin.d.ts.map +1 -0
  193. package/dist/workspace-plugin.js +1 -0
  194. package/dist/workspace-plugin.js.map +7 -0
  195. package/package.json +26 -9
  196. package/dist/events/definitions.d.ts.map +0 -1
  197. package/dist/events/definitions.js.map +0 -7
  198. package/dist/plugins.d.ts.map +0 -1
  199. package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.d.ts +0 -33
  200. package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.d.ts.map +0 -1
  201. package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.js +0 -23
  202. package/dist/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments.js.map +0 -7
@@ -0,0 +1,37 @@
1
+ import type { CollectionType } from '../../events/definitions/common.js';
2
+ import type { XScalarEnvVar, XScalarEnvironment } from '../../schemas/extensions/document/x-scalar-environments.js';
3
+ /** Event definitions for all things environment related */
4
+ export type EnvironmentEvents = {
5
+ /**
6
+ * Add OR update an environment
7
+ */
8
+ 'environment:upsert:environment': {
9
+ environmentName: string;
10
+ payload: Partial<XScalarEnvironment>;
11
+ /** Only needed when renaming the environment */
12
+ oldEnvironmentName?: string;
13
+ } & CollectionType;
14
+ /**
15
+ * Add or update an environment variable
16
+ */
17
+ 'environment:upsert:environment-variable': {
18
+ environmentName: string;
19
+ variable: XScalarEnvVar;
20
+ /** Only needed for update, omit it for add */
21
+ index?: number;
22
+ } & CollectionType;
23
+ /**
24
+ * Delete an environment
25
+ */
26
+ 'environment:delete:environment': {
27
+ environmentName: string;
28
+ } & CollectionType;
29
+ /**
30
+ * Delete an environment variable by index
31
+ */
32
+ 'environment:delete:environment-variable': {
33
+ environmentName: string;
34
+ index: number;
35
+ } & CollectionType;
36
+ };
37
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAA;AAE5G,2DAA2D;AAC3D,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,gCAAgC,EAAE;QAChC,eAAe,EAAE,MAAM,CAAA;QACvB,OAAO,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAA;QACpC,gDAAgD;QAChD,kBAAkB,CAAC,EAAE,MAAM,CAAA;KAC5B,GAAG,cAAc,CAAA;IAClB;;OAEG;IACH,yCAAyC,EAAE;QACzC,eAAe,EAAE,MAAM,CAAA;QACvB,QAAQ,EAAE,aAAa,CAAA;QACvB,8CAA8C;QAC9C,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,GAAG,cAAc,CAAA;IAClB;;OAEG;IACH,gCAAgC,EAAE;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,GAAG,cAAc,CAAA;IAC9E;;OAEG;IACH,yCAAyC,EAAE;QAAE,eAAe,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,cAAc,CAAA;CACvG,CAAA"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,12 @@
1
+ import type { EnvironmentEvents } from '../../events/definitions/environment.js';
2
+ import type { ServerObject } from '../../schemas/v3.1/strict/openapi-document.js';
3
+ import type { AnalyticsEvents } from './analytics.js';
4
+ import type { AuthEvents } from './auth.js';
5
+ import type { DocumentEvents } from './document.js';
6
+ import type { MetaEvents } from './meta.js';
7
+ import type { OperationEvents } from './operation.js';
8
+ import type { ServerEvents } from './server.js';
9
+ import type { UIEvents } from './ui.js';
10
+ export type ApiReferenceEvents<T extends keyof ServerObject = keyof ServerObject> = AuthEvents & AnalyticsEvents & DocumentEvents & EnvironmentEvents & MetaEvents & OperationEvents & ServerEvents<T> & UIEvents;
11
+ export type { CollectionType } from './common.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAEpC,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,YAAY,GAAG,MAAM,YAAY,IAAI,UAAU,GAC5F,eAAe,GACf,cAAc,GACd,iBAAiB,GACjB,UAAU,GACV,eAAe,GACf,YAAY,CAAC,CAAC,CAAC,GACf,QAAQ,CAAA;AAEV,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,17 @@
1
+ import type { AvailableClients } from '@scalar/types/snippetz';
2
+ /** Event definitions for the workspace/document meta */
3
+ export type MetaEvents = {
4
+ /**
5
+ * Update the dark mode theme setting
6
+ */
7
+ 'update:dark-mode': boolean;
8
+ /**
9
+ * Update the active document on the workspace
10
+ */
11
+ 'update:active-document': string;
12
+ /**
13
+ * Update the selected client on the workspace
14
+ */
15
+ 'update:selected-client': AvailableClients[number];
16
+ };
17
+ //# sourceMappingURL=meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/events/definitions/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAE9D,wDAAwD;AACxD,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,kBAAkB,EAAE,OAAO,CAAA;IAC3B;;OAEG;IACH,wBAAwB,EAAE,MAAM,CAAA;IAChC;;OAEG;IACH,wBAAwB,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;CACnD,CAAA"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=meta.js.map
@@ -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,5 @@
1
- export { type ApiReferenceEvent, type ApiReferenceEvents, emitCustomEvent } from './definitions.js';
1
+ export { type WorkspaceEventBus, createWorkspaceEventBus } from './bus.js';
2
+ export type { CollectionType } from './definitions/index.js';
2
3
  export { onCustomEvent } from './listeners.js';
4
+ export { type ApiReferenceEvent, type ApiReferenceEvents, emitCustomEvent } from './old-definitions.js';
3
5
  //# 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,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACnD,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 type { CollectionType } from './definitions'\nexport { onCustomEvent } from './listeners'\nexport { type ApiReferenceEvent, type ApiReferenceEvents, emitCustomEvent } from './old-definitions'\n"],
5
+ "mappings": "AACA,SAAiC,+BAA+B;AAEhE,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":"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"}
@@ -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"}