@scalar/workspace-store 0.17.1 → 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 (174) hide show
  1. package/CHANGELOG.md +47 -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 +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/navigation/get-navigation-options.d.ts +1 -1
  70. package/dist/navigation/get-navigation-options.d.ts.map +1 -1
  71. package/dist/navigation/get-navigation-options.js +66 -54
  72. package/dist/navigation/get-navigation-options.js.map +2 -2
  73. package/dist/navigation/helpers/get-tag.d.ts +7 -2
  74. package/dist/navigation/helpers/get-tag.d.ts.map +1 -1
  75. package/dist/navigation/helpers/get-tag.js +16 -2
  76. package/dist/navigation/helpers/get-tag.js.map +2 -2
  77. package/dist/navigation/helpers/traverse-description.d.ts +7 -2
  78. package/dist/navigation/helpers/traverse-description.d.ts.map +1 -1
  79. package/dist/navigation/helpers/traverse-description.js +24 -6
  80. package/dist/navigation/helpers/traverse-description.js.map +2 -2
  81. package/dist/navigation/helpers/traverse-document.d.ts +5 -2
  82. package/dist/navigation/helpers/traverse-document.d.ts.map +1 -1
  83. package/dist/navigation/helpers/traverse-document.js +53 -15
  84. package/dist/navigation/helpers/traverse-document.js.map +2 -2
  85. package/dist/navigation/helpers/traverse-paths.d.ts +9 -3
  86. package/dist/navigation/helpers/traverse-paths.d.ts.map +1 -1
  87. package/dist/navigation/helpers/traverse-paths.js +63 -9
  88. package/dist/navigation/helpers/traverse-paths.js.map +2 -2
  89. package/dist/navigation/helpers/traverse-schemas.d.ts +7 -8
  90. package/dist/navigation/helpers/traverse-schemas.d.ts.map +1 -1
  91. package/dist/navigation/helpers/traverse-schemas.js +35 -7
  92. package/dist/navigation/helpers/traverse-schemas.js.map +2 -2
  93. package/dist/navigation/helpers/traverse-tags.d.ts +8 -4
  94. package/dist/navigation/helpers/traverse-tags.d.ts.map +1 -1
  95. package/dist/navigation/helpers/traverse-tags.js +65 -17
  96. package/dist/navigation/helpers/traverse-tags.js.map +2 -2
  97. package/dist/navigation/helpers/traverse-webhooks.d.ts +9 -3
  98. package/dist/navigation/helpers/traverse-webhooks.d.ts.map +1 -1
  99. package/dist/navigation/helpers/traverse-webhooks.js +43 -17
  100. package/dist/navigation/helpers/traverse-webhooks.js.map +2 -2
  101. package/dist/navigation/types.d.ts +5 -24
  102. package/dist/navigation/types.d.ts.map +1 -1
  103. package/dist/persistence/index.d.ts +86 -0
  104. package/dist/persistence/index.d.ts.map +1 -0
  105. package/dist/persistence/index.js +196 -0
  106. package/dist/persistence/index.js.map +7 -0
  107. package/dist/persistence/indexdb.d.ts +87 -0
  108. package/dist/persistence/indexdb.d.ts.map +1 -0
  109. package/dist/persistence/indexdb.js +125 -0
  110. package/dist/persistence/indexdb.js.map +7 -0
  111. package/dist/{plugins.d.ts → plugins/bundler/index.d.ts} +1 -1
  112. package/dist/plugins/bundler/index.d.ts.map +1 -0
  113. package/dist/{plugins.js → plugins/bundler/index.js} +2 -2
  114. package/dist/{plugins.js.map → plugins/bundler/index.js.map} +1 -1
  115. package/dist/plugins/client/index.d.ts +3 -0
  116. package/dist/plugins/client/index.d.ts.map +1 -0
  117. package/dist/plugins/client/index.js +5 -0
  118. package/dist/plugins/client/index.js.map +7 -0
  119. package/dist/plugins/client/persistence.d.ts +13 -0
  120. package/dist/plugins/client/persistence.d.ts.map +1 -0
  121. package/dist/plugins/client/persistence.js +57 -0
  122. package/dist/plugins/client/persistence.js.map +7 -0
  123. package/dist/schemas/extensions.d.ts +1 -0
  124. package/dist/schemas/extensions.d.ts.map +1 -1
  125. package/dist/schemas/extensions.js +1 -0
  126. package/dist/schemas/extensions.js.map +2 -2
  127. package/dist/schemas/inmemory-workspace.d.ts +71 -12
  128. package/dist/schemas/inmemory-workspace.d.ts.map +1 -1
  129. package/dist/schemas/inmemory-workspace.js +1 -9
  130. package/dist/schemas/inmemory-workspace.js.map +2 -2
  131. package/dist/schemas/navigation.d.ts +128 -1
  132. package/dist/schemas/navigation.d.ts.map +1 -1
  133. package/dist/schemas/navigation.js +20 -1
  134. package/dist/schemas/navigation.js.map +2 -2
  135. package/dist/schemas/reference-config/index.d.ts +231 -198
  136. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  137. package/dist/schemas/reference-config/index.js.map +2 -2
  138. package/dist/schemas/reference-config/settings.d.ts +33 -1
  139. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  140. package/dist/schemas/reference-config/settings.js +1 -1
  141. package/dist/schemas/reference-config/settings.js.map +1 -1
  142. package/dist/schemas/v3.1/strict/openapi-document.d.ts +1131 -37
  143. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  144. package/dist/schemas/v3.1/strict/openapi-document.js +16 -9
  145. package/dist/schemas/v3.1/strict/openapi-document.js.map +2 -2
  146. package/dist/schemas/v3.1/strict/parameter.d.ts +23 -1
  147. package/dist/schemas/v3.1/strict/parameter.d.ts.map +1 -1
  148. package/dist/schemas/v3.1/strict/parameter.js +5 -1
  149. package/dist/schemas/v3.1/strict/parameter.js.map +2 -2
  150. package/dist/schemas/v3.1/strict/ref-definitions.d.ts +2 -0
  151. package/dist/schemas/v3.1/strict/ref-definitions.d.ts.map +1 -1
  152. package/dist/schemas/v3.1/strict/ref-definitions.js +4 -1
  153. package/dist/schemas/v3.1/strict/ref-definitions.js.map +2 -2
  154. package/dist/schemas/workspace-specification/config.d.ts +34 -7
  155. package/dist/schemas/workspace-specification/config.d.ts.map +1 -1
  156. package/dist/schemas/workspace-specification/config.js.map +1 -1
  157. package/dist/schemas/workspace-specification/index.d.ts +36 -3
  158. package/dist/schemas/workspace-specification/index.d.ts.map +1 -1
  159. package/dist/schemas/workspace.d.ts +238 -10
  160. package/dist/schemas/workspace.d.ts.map +1 -1
  161. package/dist/schemas/workspace.js +3 -1
  162. package/dist/schemas/workspace.js.map +2 -2
  163. package/dist/server.d.ts +4 -3
  164. package/dist/server.d.ts.map +1 -1
  165. package/dist/server.js +7 -6
  166. package/dist/server.js.map +2 -2
  167. package/dist/workspace-plugin.d.ts +49 -0
  168. package/dist/workspace-plugin.d.ts.map +1 -0
  169. package/dist/workspace-plugin.js +1 -0
  170. package/dist/workspace-plugin.js.map +7 -0
  171. package/package.json +21 -9
  172. package/dist/events/definitions.d.ts.map +0 -1
  173. package/dist/events/definitions.js.map +0 -7
  174. package/dist/plugins.d.ts.map +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/schemas/workspace.ts"],
4
- "sourcesContent": ["import { Type } from '@scalar/typebox'\nimport { AVAILABLE_CLIENTS, type AvailableClients } from '@scalar/types/snippetz'\n\nimport { compose } from '@/schemas/compose'\nimport { extensions } from '@/schemas/extensions'\nimport {\n type XScalarClientConfigCookies,\n xScalarClientConfigCookiesSchema,\n} from '@/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies'\nimport {\n type XScalarClientConfigEnvironments,\n xScalarClientConfigEnvironmentsSchema,\n} from '@/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments'\nimport type { SecuritySchemeObject } from '@/schemas/v3.1/strict/security-scheme'\nimport type { ServerObject } from '@/schemas/v3.1/strict/server'\n\nimport {\n OpenAPIDocumentSchema,\n type OpenApiDocument,\n SecuritySchemeObjectSchema,\n ServerObjectSchema,\n} from './v3.1/strict/openapi-document'\n\nexport const WorkspaceDocumentMetaSchema = Type.Partial(\n Type.Object({\n [extensions.document.activeAuth]: Type.String(),\n [extensions.document.activeServer]: Type.String(),\n }),\n)\n\nexport type WorkspaceDocumentMeta = {\n [extensions.document.activeAuth]?: string\n [extensions.document.activeServer]?: string\n}\n\n// Note: use Type.Intersect to combine schemas here because Type.Compose does not work as expected with Modules\nexport const WorkspaceDocumentSchema = Type.Intersect([WorkspaceDocumentMetaSchema, OpenAPIDocumentSchema])\n\nexport type WorkspaceDocument = WorkspaceDocumentMeta & OpenApiDocument\n\nexport const WorkspaceMetaSchema = Type.Partial(\n Type.Object({\n [extensions.workspace.darkMode]: Type.Boolean(),\n [extensions.workspace.defaultClient]: Type.Union(AVAILABLE_CLIENTS.map((client) => Type.Literal(client))),\n [extensions.workspace.activeDocument]: Type.String(),\n [extensions.workspace.theme]: Type.String(),\n }),\n)\n\nexport type WorkspaceMeta = {\n [extensions.workspace.darkMode]?: boolean\n [extensions.workspace.defaultClient]?: AvailableClients[number]\n [extensions.workspace.activeDocument]?: string\n [extensions.workspace.theme]?: string\n}\n\nexport const WorkspaceExtensionsSchema = Type.Partial(\n Type.Object({\n 'x-scalar-client-config-environments': xScalarClientConfigEnvironmentsSchema,\n 'x-scalar-client-config-cookies': xScalarClientConfigCookiesSchema,\n 'x-scalar-client-config-servers': Type.Array(ServerObjectSchema),\n 'x-scalar-client-config-security-schemes': Type.Record(Type.String(), SecuritySchemeObjectSchema),\n }),\n)\n\nexport type WorkspaceExtensions = {\n 'x-scalar-client-config-environments'?: XScalarClientConfigEnvironments\n 'x-scalar-client-config-cookies'?: XScalarClientConfigCookies\n 'x-scalar-client-config-servers'?: ServerObject[]\n 'x-scalar-client-config-security-schemes'?: Record<string, SecuritySchemeObject>\n}\n\nexport const WorkspaceSchema = compose(\n WorkspaceMetaSchema,\n Type.Object({\n documents: Type.Record(Type.String(), WorkspaceDocumentSchema),\n /** Active document is possibly undefined if we attempt to lookup with an invalid key */\n activeDocument: Type.Union([Type.Undefined(), WorkspaceDocumentSchema]),\n }),\n WorkspaceExtensionsSchema,\n)\n\nexport type Workspace = WorkspaceMeta & {\n documents: Record<string, WorkspaceDocument>\n activeDocument: WorkspaceDocument | undefined\n} & WorkspaceExtensions\n"],
5
- "mappings": "AAAA,SAAS,YAAY;AACrB,SAAS,yBAAgD;AAEzD,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AAIP;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,8BAA8B,KAAK;AAAA,EAC9C,KAAK,OAAO;AAAA,IACV,CAAC,WAAW,SAAS,UAAU,GAAG,KAAK,OAAO;AAAA,IAC9C,CAAC,WAAW,SAAS,YAAY,GAAG,KAAK,OAAO;AAAA,EAClD,CAAC;AACH;AAQO,MAAM,0BAA0B,KAAK,UAAU,CAAC,6BAA6B,qBAAqB,CAAC;AAInG,MAAM,sBAAsB,KAAK;AAAA,EACtC,KAAK,OAAO;AAAA,IACV,CAAC,WAAW,UAAU,QAAQ,GAAG,KAAK,QAAQ;AAAA,IAC9C,CAAC,WAAW,UAAU,aAAa,GAAG,KAAK,MAAM,kBAAkB,IAAI,CAAC,WAAW,KAAK,QAAQ,MAAM,CAAC,CAAC;AAAA,IACxG,CAAC,WAAW,UAAU,cAAc,GAAG,KAAK,OAAO;AAAA,IACnD,CAAC,WAAW,UAAU,KAAK,GAAG,KAAK,OAAO;AAAA,EAC5C,CAAC;AACH;AASO,MAAM,4BAA4B,KAAK;AAAA,EAC5C,KAAK,OAAO;AAAA,IACV,uCAAuC;AAAA,IACvC,kCAAkC;AAAA,IAClC,kCAAkC,KAAK,MAAM,kBAAkB;AAAA,IAC/D,2CAA2C,KAAK,OAAO,KAAK,OAAO,GAAG,0BAA0B;AAAA,EAClG,CAAC;AACH;AASO,MAAM,kBAAkB;AAAA,EAC7B;AAAA,EACA,KAAK,OAAO;AAAA,IACV,WAAW,KAAK,OAAO,KAAK,OAAO,GAAG,uBAAuB;AAAA;AAAA,IAE7D,gBAAgB,KAAK,MAAM,CAAC,KAAK,UAAU,GAAG,uBAAuB,CAAC;AAAA,EACxE,CAAC;AAAA,EACD;AACF;",
4
+ "sourcesContent": ["import { type ThemeId, themeIds } from '@scalar/themes'\nimport { Type } from '@scalar/typebox'\nimport { AVAILABLE_CLIENTS, type AvailableClients } from '@scalar/types/snippetz'\n\nimport { compose } from '@/schemas/compose'\nimport { extensions } from '@/schemas/extensions'\nimport {\n type XScalarClientConfigCookies,\n xScalarClientConfigCookiesSchema,\n} from '@/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-cookies'\nimport {\n type XScalarClientConfigEnvironments,\n xScalarClientConfigEnvironmentsSchema,\n} from '@/schemas/v3.1/strict/client-config-extensions/x-scalar-client-config-environments'\nimport type { SecuritySchemeObject } from '@/schemas/v3.1/strict/security-scheme'\nimport type { ServerObject } from '@/schemas/v3.1/strict/server'\n\nimport {\n OpenAPIDocumentSchema,\n type OpenApiDocument,\n SecuritySchemeObjectSchema,\n ServerObjectSchema,\n} from './v3.1/strict/openapi-document'\n\nexport const WorkspaceDocumentMetaSchema = Type.Partial(\n Type.Object({\n [extensions.document.activeAuth]: Type.String(),\n [extensions.document.activeServer]: Type.String(),\n }),\n)\n\nexport type WorkspaceDocumentMeta = {\n [extensions.document.activeAuth]?: string\n [extensions.document.activeServer]?: string\n}\n\n// Note: use Type.Intersect to combine schemas here because Type.Compose does not work as expected with Modules\nexport const WorkspaceDocumentSchema = Type.Intersect([WorkspaceDocumentMetaSchema, OpenAPIDocumentSchema])\n\nexport type WorkspaceDocument = WorkspaceDocumentMeta & OpenApiDocument\n\nexport const WorkspaceMetaSchema = Type.Partial(\n Type.Object({\n [extensions.workspace.darkMode]: Type.Boolean(),\n [extensions.workspace.defaultClient]: Type.Union(AVAILABLE_CLIENTS.map((client) => Type.Literal(client))),\n [extensions.workspace.activeDocument]: Type.String(),\n [extensions.workspace.theme]: Type.Union(themeIds.map((t) => Type.Literal(t))),\n [extensions.workspace.sidebarWidth]: Type.Number({ default: 288 }),\n }),\n)\n\nexport type WorkspaceMeta = {\n [extensions.workspace.darkMode]?: boolean\n [extensions.workspace.defaultClient]?: AvailableClients[number]\n [extensions.workspace.activeDocument]?: string\n [extensions.workspace.theme]?: ThemeId\n [extensions.workspace.sidebarWidth]?: number\n}\n\nexport const WorkspaceExtensionsSchema = Type.Partial(\n Type.Object({\n 'x-scalar-client-config-environments': xScalarClientConfigEnvironmentsSchema,\n 'x-scalar-client-config-cookies': xScalarClientConfigCookiesSchema,\n 'x-scalar-client-config-servers': Type.Array(ServerObjectSchema),\n 'x-scalar-client-config-security-schemes': Type.Record(Type.String(), SecuritySchemeObjectSchema),\n }),\n)\n\nexport type WorkspaceExtensions = {\n 'x-scalar-client-config-environments'?: XScalarClientConfigEnvironments\n 'x-scalar-client-config-cookies'?: XScalarClientConfigCookies\n 'x-scalar-client-config-servers'?: ServerObject[]\n 'x-scalar-client-config-security-schemes'?: Record<string, SecuritySchemeObject>\n}\n\nexport const WorkspaceSchema = compose(\n WorkspaceMetaSchema,\n Type.Object({\n documents: Type.Record(Type.String(), WorkspaceDocumentSchema),\n /** Active document is possibly undefined if we attempt to lookup with an invalid key */\n activeDocument: Type.Union([Type.Undefined(), WorkspaceDocumentSchema]),\n }),\n WorkspaceExtensionsSchema,\n)\n\nexport type Workspace = WorkspaceMeta & {\n documents: Record<string, WorkspaceDocument>\n activeDocument: WorkspaceDocument | undefined\n} & WorkspaceExtensions\n"],
5
+ "mappings": "AAAA,SAAuB,gBAAgB;AACvC,SAAS,YAAY;AACrB,SAAS,yBAAgD;AAEzD,SAAS,eAAe;AACxB,SAAS,kBAAkB;AAC3B;AAAA,EAEE;AAAA,OACK;AACP;AAAA,EAEE;AAAA,OACK;AAIP;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,8BAA8B,KAAK;AAAA,EAC9C,KAAK,OAAO;AAAA,IACV,CAAC,WAAW,SAAS,UAAU,GAAG,KAAK,OAAO;AAAA,IAC9C,CAAC,WAAW,SAAS,YAAY,GAAG,KAAK,OAAO;AAAA,EAClD,CAAC;AACH;AAQO,MAAM,0BAA0B,KAAK,UAAU,CAAC,6BAA6B,qBAAqB,CAAC;AAInG,MAAM,sBAAsB,KAAK;AAAA,EACtC,KAAK,OAAO;AAAA,IACV,CAAC,WAAW,UAAU,QAAQ,GAAG,KAAK,QAAQ;AAAA,IAC9C,CAAC,WAAW,UAAU,aAAa,GAAG,KAAK,MAAM,kBAAkB,IAAI,CAAC,WAAW,KAAK,QAAQ,MAAM,CAAC,CAAC;AAAA,IACxG,CAAC,WAAW,UAAU,cAAc,GAAG,KAAK,OAAO;AAAA,IACnD,CAAC,WAAW,UAAU,KAAK,GAAG,KAAK,MAAM,SAAS,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC;AAAA,IAC7E,CAAC,WAAW,UAAU,YAAY,GAAG,KAAK,OAAO,EAAE,SAAS,IAAI,CAAC;AAAA,EACnE,CAAC;AACH;AAUO,MAAM,4BAA4B,KAAK;AAAA,EAC5C,KAAK,OAAO;AAAA,IACV,uCAAuC;AAAA,IACvC,kCAAkC;AAAA,IAClC,kCAAkC,KAAK,MAAM,kBAAkB;AAAA,IAC/D,2CAA2C,KAAK,OAAO,KAAK,OAAO,GAAG,0BAA0B;AAAA,EAClG,CAAC;AACH;AASO,MAAM,kBAAkB;AAAA,EAC7B;AAAA,EACA,KAAK,OAAO;AAAA,IACV,WAAW,KAAK,OAAO,KAAK,OAAO,GAAG,uBAAuB;AAAA;AAAA,IAE7D,gBAAgB,KAAK,MAAM,CAAC,KAAK,UAAU,GAAG,uBAAuB,CAAC;AAAA,EACxE,CAAC;AAAA,EACD;AACF;",
6
6
  "names": []
7
7
  }
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { extensions } from './schemas/extensions.js';
2
- import type { TraversedEntry } from './schemas/navigation.js';
2
+ import type { TraversedDocument } from './schemas/navigation.js';
3
3
  import { type OpenApiDocument, type OperationObject, type PathsObject } from './schemas/v3.1/strict/openapi-document.js';
4
4
  import type { DocumentConfiguration } from './schemas/workspace-specification/config.js';
5
5
  import type { WorkspaceDocumentMeta, WorkspaceMeta } from './schemas/workspace.js';
@@ -117,12 +117,13 @@ export declare function createServerWorkspaceStore(workspaceProps: CreateServerW
117
117
  */
118
118
  getWorkspace: () => {
119
119
  documents: Record<string, OpenApiDocument & {
120
- [extensions.document.navigation]: TraversedEntry[];
120
+ [extensions.document.navigation]: TraversedDocument;
121
121
  }>;
122
122
  "x-scalar-dark-mode"?: boolean;
123
123
  "x-scalar-default-client"?: import("@scalar/snippetz").AvailableClients[number];
124
124
  "x-scalar-active-document"?: string;
125
- "x-scalar-theme"?: string;
125
+ "x-scalar-theme"?: import("@scalar/themes").ThemeId;
126
+ "x-scalar-sidebar-width"?: number;
126
127
  };
127
128
  /**
128
129
  * Retrieves a chunk of data from the workspace using a JSON Pointer
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,EAAE,cAAc,EA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;;;;OASG;yBA9G6B,sBAAsB;GAiHzD"}
package/dist/server.js CHANGED
@@ -81,17 +81,18 @@ function externalizePathReferences(document, meta) {
81
81
  });
82
82
  return result;
83
83
  }
84
- async function loadDocument(workspaceDocument) {
84
+ function loadDocument(workspaceDocument) {
85
85
  if ("url" in workspaceDocument) {
86
86
  return fetchUrls().exec(workspaceDocument.url);
87
87
  }
88
88
  if ("path" in workspaceDocument) {
89
89
  return readFiles().exec(workspaceDocument.path);
90
90
  }
91
- return {
91
+ return Promise.resolve({
92
92
  ok: true,
93
- data: workspaceDocument.document
94
- };
93
+ data: workspaceDocument.document,
94
+ raw: JSON.stringify(workspaceDocument.document)
95
+ });
95
96
  }
96
97
  async function createServerWorkspaceStore(workspaceProps) {
97
98
  const workspace = {
@@ -109,13 +110,13 @@ async function createServerWorkspaceStore(workspaceProps) {
109
110
  const options = workspaceProps.mode === "ssr" ? { mode: workspaceProps.mode, name, baseUrl: workspaceProps.baseUrl } : { mode: workspaceProps.mode, name, directory: workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER };
110
111
  const components = externalizeComponentReferences(documentV3, options);
111
112
  const paths = externalizePathReferences(documentV3, options);
112
- const { entries } = createNavigation(documentV3, workspaceProps.config ?? {});
113
+ const navigation = createNavigation(name, documentV3, workspaceProps.config ?? {});
113
114
  workspace.documents[meta.name] = {
114
115
  ...documentMeta,
115
116
  ...documentV3,
116
117
  components,
117
118
  paths,
118
- [extensions.document.navigation]: entries
119
+ [extensions.document.navigation]: navigation
119
120
  };
120
121
  };
121
122
  const addDocument = async (input) => {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/server.ts"],
4
- "sourcesContent": ["import fs from 'node:fs/promises'\nimport { cwd } from 'node:process'\n\nimport { fetchUrls, readFiles } from '@scalar/json-magic/bundle/plugins/node'\nimport { escapeJsonPointer } from '@scalar/json-magic/helpers/escape-json-pointer'\nimport { upgrade } from '@scalar/openapi-upgrader'\n\nimport { keyOf } from '@/helpers/general'\nimport { createNavigation } from '@/navigation'\nimport { extensions } from '@/schemas/extensions'\nimport type { TraversedEntry } from '@/schemas/navigation'\nimport { coerceValue } from '@/schemas/typebox-coerce'\nimport {\n type ComponentsObject,\n OpenAPIDocumentSchema,\n type OpenApiDocument,\n type OperationObject,\n type PathsObject,\n} from '@/schemas/v3.1/strict/openapi-document'\nimport type { DocumentConfiguration } from '@/schemas/workspace-specification/config'\n\nimport { getValueByPath, parseJsonPointer } from './helpers/json-path-utils'\nimport type { WorkspaceDocumentMeta, WorkspaceMeta } from './schemas/workspace'\n\nconst DEFAULT_ASSETS_FOLDER = 'assets'\nexport const WORKSPACE_FILE_NAME = 'scalar-workspace.json'\n\ntype WorkspaceDocumentMetaInput = {\n name: string\n meta?: WorkspaceDocumentMeta\n}\n\ntype UrlDoc = { url: string } & WorkspaceDocumentMetaInput\ntype FileDoc = { path: string } & WorkspaceDocumentMetaInput\ntype ObjectDoc = { document: Record<string, unknown> } & WorkspaceDocumentMetaInput\n\ntype WorkspaceDocumentInput = UrlDoc | ObjectDoc | FileDoc\n\ntype CreateServerWorkspaceStoreBase = {\n documents: WorkspaceDocumentInput[]\n meta?: WorkspaceMeta\n config?: DocumentConfiguration\n}\ntype CreateServerWorkspaceStore =\n | ({\n directory?: string\n mode: 'static'\n } & CreateServerWorkspaceStoreBase)\n | ({\n baseUrl: string\n mode: 'ssr'\n } & CreateServerWorkspaceStoreBase)\n\nconst httpMethods = new Set(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'])\n\n/**\n * Filters an OpenAPI PathsObject to only include standard HTTP methods.\n * Removes any vendor extensions or other non-HTTP properties.\n *\n * @param paths - The OpenAPI PathsObject to filter\n * @returns A new PathsObject containing only standard HTTP methods\n *\n * @example\n * Input: {\n * \"/users\": {\n * \"get\": {...},\n * \"x-custom\": {...},\n * \"post\": {...}\n * }\n * }\n * Output: {\n * \"/users\": {\n * \"get\": {...},\n * \"post\": {...}\n * }\n * }\n */\nexport function filterHttpMethodsOnly(paths: PathsObject): Record<string, Record<string, OperationObject>> {\n const result: Record<string, Record<string, OperationObject>> = {}\n\n // Todo: skip extension properties\n for (const [path, methods] of Object.entries(paths)) {\n if (!methods) {\n continue\n }\n\n const filteredMethods: Record<string, any> = {}\n\n for (const [method, operation] of Object.entries(methods)) {\n if (httpMethods.has(method.toLowerCase())) {\n filteredMethods[method] = operation\n }\n }\n\n if (Object.keys(filteredMethods).length > 0) {\n result[path] = filteredMethods\n }\n }\n\n return result\n}\n\n/**\n * Escapes path keys in an OpenAPI PathsObject to be JSON Pointer compatible.\n * This is necessary because OpenAPI paths can contain characters that need to be escaped\n * when used as JSON Pointer references (like '/' and '~').\n *\n * @example\n * Input: { \"/users/{id}\": { ... } }\n * Output: { \"/users~1{id}\": { ... } }\n */\nexport function escapePaths(\n paths: Record<string, Record<string, OperationObject>>,\n): Record<string, Record<string, OperationObject>> {\n const result: Record<string, Record<string, OperationObject>> = {}\n\n Object.keys(paths).forEach((path) => {\n if (paths[path]) {\n result[escapeJsonPointer(path)] = paths[path]\n }\n })\n\n return result\n}\n\n/**\n * Externalizes components by turning them into refs.\n */\nexport function externalizeComponentReferences(\n document: OpenApiDocument,\n meta: { mode: 'ssr'; name: string; baseUrl: string } | { mode: 'static'; name: string; directory: string },\n) {\n const result: Record<string, any> = {}\n\n if (!document.components) {\n return result\n }\n\n Object.entries(document.components).forEach(([type, component]) => {\n if (!component || typeof component !== 'object') {\n return\n }\n\n result[type] = {}\n Object.keys(component).forEach((name) => {\n const ref =\n meta.mode === 'ssr'\n ? `${meta.baseUrl}/${meta.name}/components/${type}/${name}#`\n : `./chunks/${meta.name}/components/${type}/${name}.json#`\n\n result[type][name] = { '$ref': ref, $global: true }\n })\n })\n\n return result\n}\n\n/**\n * Externalizes paths operations by turning them into refs.\n */\nexport function externalizePathReferences(\n document: OpenApiDocument,\n meta: { mode: 'ssr'; name: string; baseUrl: string } | { mode: 'static'; name: string; directory: string },\n) {\n const result: Record<string, any> = {}\n\n if (!document.paths) {\n return result\n }\n\n Object.entries(document.paths).forEach(([path, pathItem]) => {\n if (!pathItem || typeof pathItem !== 'object') {\n return\n }\n\n const pathItemRecord = pathItem as Record<string, unknown>\n\n result[path] = {}\n\n const escapedPath = escapeJsonPointer(path)\n\n keyOf(pathItemRecord).forEach((type) => {\n if (httpMethods.has(type)) {\n const ref =\n meta.mode === 'ssr'\n ? `${meta.baseUrl}/${meta.name}/operations/${escapedPath}/${type}#`\n : `./chunks/${meta.name}/operations/${escapedPath}/${type}.json#`\n\n result[path][type] = { '$ref': ref, $global: true }\n } else {\n result[path][type] = pathItemRecord[type]\n }\n })\n })\n\n return result\n}\n\n/**\n * Resolves a workspace document from various input sources (URL, local file, or direct document object).\n *\n * @param workspaceDocument - The document input to resolve, which can be:\n * - A URL to fetch the document from\n * - A local file path to read the document from\n * - A direct document object\n * @returns A promise that resolves to an object containing:\n * - ok: boolean indicating if the resolution was successful\n * - data: The resolved document data\n *\n * @example\n * // Resolve from URL\n * const urlDoc = await loadDocument({ name: 'api', url: 'https://api.example.com/openapi.json' })\n *\n * // Resolve direct document\n * const directDoc = await loadDocument({\n * name: 'inline',\n * document: { openapi: '3.0.0', paths: {} }\n * })\n */\nasync function loadDocument(workspaceDocument: WorkspaceDocumentInput) {\n if ('url' in workspaceDocument) {\n return fetchUrls().exec(workspaceDocument.url)\n }\n\n if ('path' in workspaceDocument) {\n return readFiles().exec(workspaceDocument.path)\n }\n\n return {\n ok: true as const,\n data: workspaceDocument.document,\n }\n}\n\n/**\n * Create server state workspace store\n */\nexport async function createServerWorkspaceStore(workspaceProps: CreateServerWorkspaceStore) {\n /**\n * Base workspace document containing essential metadata and document references.\n *\n * This workspace document provides the minimal information needed for initial rendering.\n * All components and path operations are replaced with references to enable lazy loading.\n *\n * In SSR mode, references point to API endpoints.\n * In static mode, references point to filesystem chunks.\n */\n const workspace = {\n ...workspaceProps.meta,\n documents: {} as Record<string, OpenApiDocument & { [extensions.document.navigation]: TraversedEntry[] }>,\n }\n\n /**\n * A map of document chunks that can be loaded asynchronously by the client.\n * Each document is split into components and operations to enable lazy loading.\n * The keys are document names and values contain the components and operations\n * for that document.\n */\n const assets = {} as Record<\n string,\n { components?: ComponentsObject; operations?: Record<string, Record<string, OperationObject>> }\n >\n\n /**\n * Adds a new document to the workspace.\n *\n * This function processes an OpenAPI document by:\n * 1. Converting it to OpenAPI 3.1 format if needed\n * 2. Separating it into reusable components and path operations\n * 3. Externalizing references based on the workspace mode (SSR or static)\n * 4. Adding the processed document to the workspace with its metadata\n *\n * The resulting document contains minimal information with externalized references\n * that will be resolved on-demand through the workspace's get() method.\n *\n * @param document - The OpenAPI document to process and add\n * @param meta - Document metadata containing the required name and optional settings\n */\n const addDocumentSync = (document: Record<string, unknown>, meta: { name: string } & WorkspaceDocumentMeta) => {\n const { name, ...documentMeta } = meta\n\n const documentV3 = coerceValue(OpenAPIDocumentSchema, upgrade(document, '3.1'))\n\n // add the assets\n assets[meta.name] = {\n components: documentV3.components,\n operations: documentV3.paths && escapePaths(filterHttpMethodsOnly(documentV3.paths)),\n }\n\n const options =\n workspaceProps.mode === 'ssr'\n ? { mode: workspaceProps.mode, name, baseUrl: workspaceProps.baseUrl }\n : { mode: workspaceProps.mode, name, directory: workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER }\n\n const components = externalizeComponentReferences(documentV3, options)\n const paths = externalizePathReferences(documentV3, options)\n\n // Build the sidebar entries\n const { entries } = createNavigation(documentV3, workspaceProps.config ?? {})\n\n // The document is now a minimal version with externalized references to components and operations.\n // These references will be resolved asynchronously when needed through the workspace's get() method.\n workspace.documents[meta.name] = {\n ...documentMeta,\n ...documentV3,\n components,\n paths,\n [extensions.document.navigation]: entries,\n }\n }\n\n /**\n * Adds a new document to the workspace asynchronously.\n *\n * This function:\n * 1. Loads the document using the provided input\n * 2. Checks if the document loaded successfully\n * 3. If successful, adds the document to the workspace using addDocumentSync\n *\n * @param input - The document input containing the document source and metadata\n */\n const addDocument = async (input: WorkspaceDocumentInput) => {\n const document = await loadDocument(input)\n\n if (!document.ok) {\n console.warn(`Failed to load document \"${input.name}`)\n return\n }\n\n addDocumentSync(document.data as Record<string, unknown>, { name: input.name, ...input.meta })\n }\n\n // Load and process all initial documents in parallel\n await Promise.all(workspaceProps.documents.map(addDocument))\n\n return {\n /**\n * Generates workspace chunks by writing components and operations to the filesystem.\n *\n * This method is only available in static mode. It creates a directory structure containing:\n * - A workspace file with metadata and document references\n * - Component chunks split by type (schemas, parameters, etc)\n * - Operation chunks split by path and HTTP method\n *\n * The generated workspace references will be relative file paths pointing to these chunks.\n *\n * @throws {Error} If called when mode is not 'static'\n */\n generateWorkspaceChunks: async () => {\n if (workspaceProps.mode !== 'static') {\n throw 'Mode has to be set to `static` to generate filesystem workspace chunks'\n }\n\n // Write the workspace document\n const basePath = `${cwd()}/${workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER}`\n await fs.mkdir(basePath, { recursive: true })\n\n // Write the workspace contents on the file system\n await fs.writeFile(`${basePath}/${WORKSPACE_FILE_NAME}`, JSON.stringify(workspace))\n\n // Write the chunks\n for (const [name, { components, operations }] of Object.entries(assets)) {\n // Write the components chunks\n if (components) {\n for (const [type, component] of Object.entries(components as Record<string, Record<string, unknown>>)) {\n const componentPath = `${basePath}/chunks/${name}/components/${type}`\n await fs.mkdir(componentPath, { recursive: true })\n\n for (const [key, value] of Object.entries(component)) {\n await fs.writeFile(`${componentPath}/${key}.json`, JSON.stringify(value))\n }\n }\n }\n\n // Write the operations chunks\n if (operations) {\n for (const [path, methods] of Object.entries(operations)) {\n const operationPath = `${basePath}/chunks/${name}/operations/${path}`\n await fs.mkdir(operationPath, { recursive: true })\n\n for (const [method, operation] of Object.entries(methods)) {\n await fs.writeFile(`${operationPath}/${method}.json`, JSON.stringify(operation))\n }\n }\n }\n }\n },\n /**\n * Returns the workspace document containing metadata and all sparse documents.\n *\n * The workspace document includes:\n * - Global workspace metadata (theme, active document, etc)\n * - Document metadata and sparse document\n * - In SSR mode: References point to in-memory chunks\n * - In static mode: References point to filesystem chunks\n *\n * @returns The complete workspace document\n */\n getWorkspace: () => {\n return workspace\n },\n /**\n * Retrieves a chunk of data from the workspace using a JSON Pointer\n *\n * A JSON Pointer is a string that references a specific location in a JSON document.\n * Only components and operations chunks can be retrieved.\n *\n * @example\n * ```ts\n * // Get a component\n * get('#/document-name/components/schemas/User')\n *\n * // Get an operation\n * get('#/document-name/operations/pets/get')\n * ```\n *\n * @param pointer - The JSON Pointer string to locate the chunk\n * @returns The chunk data if found, undefined otherwise\n */\n get: (pointer: string) => {\n return getValueByPath(assets, parseJsonPointer(pointer))\n },\n /**\n * Adds a new document to the workspace asynchronously.\n *\n * This function:\n * 1. Loads the document using the provided input\n * 2. Checks if the document loaded successfully\n * 3. If successful, adds the document to the workspace using addDocumentSync\n *\n * @param input - The document input containing the document source and metadata\n */\n addDocument,\n }\n}\n"],
5
- "mappings": "AAAA,OAAO,QAAQ;AACf,SAAS,WAAW;AAEpB,SAAS,WAAW,iBAAiB;AACrC,SAAS,yBAAyB;AAClC,SAAS,eAAe;AAExB,SAAS,aAAa;AACtB,SAAS,wBAAwB;AACjC,SAAS,kBAAkB;AAE3B,SAAS,mBAAmB;AAC5B;AAAA,EAEE;AAAA,OAIK;AAGP,SAAS,gBAAgB,wBAAwB;AAGjD,MAAM,wBAAwB;AACvB,MAAM,sBAAsB;AA4BnC,MAAM,cAAc,oBAAI,IAAI,CAAC,OAAO,OAAO,QAAQ,UAAU,WAAW,QAAQ,SAAS,OAAO,CAAC;AAwB1F,SAAS,sBAAsB,OAAqE;AACzG,QAAM,SAA0D,CAAC;AAGjE,aAAW,CAAC,MAAM,OAAO,KAAK,OAAO,QAAQ,KAAK,GAAG;AACnD,QAAI,CAAC,SAAS;AACZ;AAAA,IACF;AAEA,UAAM,kBAAuC,CAAC;AAE9C,eAAW,CAAC,QAAQ,SAAS,KAAK,OAAO,QAAQ,OAAO,GAAG;AACzD,UAAI,YAAY,IAAI,OAAO,Y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D,GAAG;AACrG,kBAAM,gBAAgB,GAAG,QAAQ,WAAW,IAAI,eAAe,IAAI;AACnE,kBAAM,GAAG,MAAM,eAAe,EAAE,WAAW,KAAK,CAAC;AAEjD,uBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,SAAS,GAAG;AACpD,oBAAM,GAAG,UAAU,GAAG,aAAa,IAAI,GAAG,SAAS,KAAK,UAAU,KAAK,CAAC;AAAA,YAC1E;AAAA,UACF;AAAA,QACF;AAGA,YAAI,YAAY;AACd,qBAAW,CAAC,MAAM,OAAO,KAAK,OAAO,QAAQ,UAAU,GAAG;AACxD,kBAAM,gBAAgB,GAAG,QAAQ,WAAW,IAAI,eAAe,IAAI;AACnE,kBAAM,GAAG,MAAM,eAAe,EAAE,WAAW,KAAK,CAAC;AAEjD,uBAAW,CAAC,QAAQ,SAAS,KAAK,OAAO,QAAQ,OAAO,GAAG;AACzD,oBAAM,GAAG,UAAU,GAAG,aAAa,IAAI,MAAM,SAAS,KAAK,UAAU,SAAS,CAAC;AAAA,YACjF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAYA,cAAc,MAAM;AAClB,aAAO;AAAA,IACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAmBA,KAAK,CAAC,YAAoB;AACxB,aAAO,eAAe,QAAQ,iBAAiB,OAAO,CAAC;AAAA,IACzD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWA;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import fs from 'node:fs/promises'\nimport { cwd } from 'node:process'\n\nimport type { LoaderPlugin } from '@scalar/json-magic/bundle'\nimport { fetchUrls, readFiles } from '@scalar/json-magic/bundle/plugins/node'\nimport { escapeJsonPointer } from '@scalar/json-magic/helpers/escape-json-pointer'\nimport { upgrade } from '@scalar/openapi-upgrader'\n\nimport { keyOf } from '@/helpers/general'\nimport { createNavigation } from '@/navigation'\nimport { extensions } from '@/schemas/extensions'\nimport type { TraversedDocument } from '@/schemas/navigation'\nimport { coerceValue } from '@/schemas/typebox-coerce'\nimport {\n type ComponentsObject,\n OpenAPIDocumentSchema,\n type OpenApiDocument,\n type OperationObject,\n type PathsObject,\n} from '@/schemas/v3.1/strict/openapi-document'\nimport type { DocumentConfiguration } from '@/schemas/workspace-specification/config'\n\nimport { getValueByPath, parseJsonPointer } from './helpers/json-path-utils'\nimport type { WorkspaceDocumentMeta, WorkspaceMeta } from './schemas/workspace'\n\nconst DEFAULT_ASSETS_FOLDER = 'assets'\nexport const WORKSPACE_FILE_NAME = 'scalar-workspace.json'\n\ntype WorkspaceDocumentMetaInput = {\n name: string\n meta?: WorkspaceDocumentMeta\n}\n\ntype UrlDoc = { url: string } & WorkspaceDocumentMetaInput\ntype FileDoc = { path: string } & WorkspaceDocumentMetaInput\ntype ObjectDoc = { document: Record<string, unknown> } & WorkspaceDocumentMetaInput\n\ntype WorkspaceDocumentInput = UrlDoc | ObjectDoc | FileDoc\n\ntype CreateServerWorkspaceStoreBase = {\n documents: WorkspaceDocumentInput[]\n meta?: WorkspaceMeta\n config?: DocumentConfiguration\n}\ntype CreateServerWorkspaceStore =\n | ({\n directory?: string\n mode: 'static'\n } & CreateServerWorkspaceStoreBase)\n | ({\n baseUrl: string\n mode: 'ssr'\n } & CreateServerWorkspaceStoreBase)\n\nconst httpMethods = new Set(['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'])\n\n/**\n * Filters an OpenAPI PathsObject to only include standard HTTP methods.\n * Removes any vendor extensions or other non-HTTP properties.\n *\n * @param paths - The OpenAPI PathsObject to filter\n * @returns A new PathsObject containing only standard HTTP methods\n *\n * @example\n * Input: {\n * \"/users\": {\n * \"get\": {...},\n * \"x-custom\": {...},\n * \"post\": {...}\n * }\n * }\n * Output: {\n * \"/users\": {\n * \"get\": {...},\n * \"post\": {...}\n * }\n * }\n */\nexport function filterHttpMethodsOnly(paths: PathsObject): Record<string, Record<string, OperationObject>> {\n const result: Record<string, Record<string, OperationObject>> = {}\n\n // Todo: skip extension properties\n for (const [path, methods] of Object.entries(paths)) {\n if (!methods) {\n continue\n }\n\n const filteredMethods: Record<string, any> = {}\n\n for (const [method, operation] of Object.entries(methods)) {\n if (httpMethods.has(method.toLowerCase())) {\n filteredMethods[method] = operation\n }\n }\n\n if (Object.keys(filteredMethods).length > 0) {\n result[path] = filteredMethods\n }\n }\n\n return result\n}\n\n/**\n * Escapes path keys in an OpenAPI PathsObject to be JSON Pointer compatible.\n * This is necessary because OpenAPI paths can contain characters that need to be escaped\n * when used as JSON Pointer references (like '/' and '~').\n *\n * @example\n * Input: { \"/users/{id}\": { ... } }\n * Output: { \"/users~1{id}\": { ... } }\n */\nexport function escapePaths(\n paths: Record<string, Record<string, OperationObject>>,\n): Record<string, Record<string, OperationObject>> {\n const result: Record<string, Record<string, OperationObject>> = {}\n\n Object.keys(paths).forEach((path) => {\n if (paths[path]) {\n result[escapeJsonPointer(path)] = paths[path]\n }\n })\n\n return result\n}\n\n/**\n * Externalizes components by turning them into refs.\n */\nexport function externalizeComponentReferences(\n document: OpenApiDocument,\n meta: { mode: 'ssr'; name: string; baseUrl: string } | { mode: 'static'; name: string; directory: string },\n) {\n const result: Record<string, any> = {}\n\n if (!document.components) {\n return result\n }\n\n Object.entries(document.components).forEach(([type, component]) => {\n if (!component || typeof component !== 'object') {\n return\n }\n\n result[type] = {}\n Object.keys(component).forEach((name) => {\n const ref =\n meta.mode === 'ssr'\n ? `${meta.baseUrl}/${meta.name}/components/${type}/${name}#`\n : `./chunks/${meta.name}/components/${type}/${name}.json#`\n\n result[type][name] = { '$ref': ref, $global: true }\n })\n })\n\n return result\n}\n\n/**\n * Externalizes paths operations by turning them into refs.\n */\nexport function externalizePathReferences(\n document: OpenApiDocument,\n meta: { mode: 'ssr'; name: string; baseUrl: string } | { mode: 'static'; name: string; directory: string },\n) {\n const result: Record<string, any> = {}\n\n if (!document.paths) {\n return result\n }\n\n Object.entries(document.paths).forEach(([path, pathItem]) => {\n if (!pathItem || typeof pathItem !== 'object') {\n return\n }\n\n const pathItemRecord = pathItem as Record<string, unknown>\n\n result[path] = {}\n\n const escapedPath = escapeJsonPointer(path)\n\n keyOf(pathItemRecord).forEach((type) => {\n if (httpMethods.has(type)) {\n const ref =\n meta.mode === 'ssr'\n ? `${meta.baseUrl}/${meta.name}/operations/${escapedPath}/${type}#`\n : `./chunks/${meta.name}/operations/${escapedPath}/${type}.json#`\n\n result[path][type] = { '$ref': ref, $global: true }\n } else {\n result[path][type] = pathItemRecord[type]\n }\n })\n })\n\n return result\n}\n\n/**\n * Resolves a workspace document from various input sources (URL, local file, or direct document object).\n *\n * @param workspaceDocument - The document input to resolve, which can be:\n * - A URL to fetch the document from\n * - A local file path to read the document from\n * - A direct document object\n * @returns A promise that resolves to an object containing:\n * - ok: boolean indicating if the resolution was successful\n * - data: The resolved document data\n *\n * @example\n * // Resolve from URL\n * const urlDoc = await loadDocument({ name: 'api', url: 'https://api.example.com/openapi.json' })\n *\n * // Resolve direct document\n * const directDoc = await loadDocument({\n * name: 'inline',\n * document: { openapi: '3.0.0', paths: {} }\n * })\n */\nfunction loadDocument(workspaceDocument: WorkspaceDocumentInput): ReturnType<LoaderPlugin['exec']> {\n if ('url' in workspaceDocument) {\n return fetchUrls().exec(workspaceDocument.url)\n }\n\n if ('path' in workspaceDocument) {\n return readFiles().exec(workspaceDocument.path)\n }\n\n return Promise.resolve({\n ok: true,\n data: workspaceDocument.document,\n raw: JSON.stringify(workspaceDocument.document),\n })\n}\n\n/**\n * Create server state workspace store\n */\nexport async function createServerWorkspaceStore(workspaceProps: CreateServerWorkspaceStore) {\n /**\n * Base workspace document containing essential metadata and document references.\n *\n * This workspace document provides the minimal information needed for initial rendering.\n * All components and path operations are replaced with references to enable lazy loading.\n *\n * In SSR mode, references point to API endpoints.\n * In static mode, references point to filesystem chunks.\n */\n const workspace = {\n ...workspaceProps.meta,\n documents: {} as Record<string, OpenApiDocument & { [extensions.document.navigation]: TraversedDocument }>,\n }\n\n /**\n * A map of document chunks that can be loaded asynchronously by the client.\n * Each document is split into components and operations to enable lazy loading.\n * The keys are document names and values contain the components and operations\n * for that document.\n */\n const assets = {} as Record<\n string,\n { components?: ComponentsObject; operations?: Record<string, Record<string, OperationObject>> }\n >\n\n /**\n * Adds a new document to the workspace.\n *\n * This function processes an OpenAPI document by:\n * 1. Converting it to OpenAPI 3.1 format if needed\n * 2. Separating it into reusable components and path operations\n * 3. Externalizing references based on the workspace mode (SSR or static)\n * 4. Adding the processed document to the workspace with its metadata\n *\n * The resulting document contains minimal information with externalized references\n * that will be resolved on-demand through the workspace's get() method.\n *\n * @param document - The OpenAPI document to process and add\n * @param meta - Document metadata containing the required name and optional settings\n */\n const addDocumentSync = (document: Record<string, unknown>, meta: { name: string } & WorkspaceDocumentMeta) => {\n const { name, ...documentMeta } = meta\n\n const documentV3 = coerceValue(OpenAPIDocumentSchema, upgrade(document, '3.1'))\n\n // add the assets\n assets[meta.name] = {\n components: documentV3.components,\n operations: documentV3.paths && escapePaths(filterHttpMethodsOnly(documentV3.paths)),\n }\n\n const options =\n workspaceProps.mode === 'ssr'\n ? { mode: workspaceProps.mode, name, baseUrl: workspaceProps.baseUrl }\n : { mode: workspaceProps.mode, name, directory: workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER }\n\n const components = externalizeComponentReferences(documentV3, options)\n const paths = externalizePathReferences(documentV3, options)\n\n // Build the sidebar entries\n const navigation = createNavigation(name, documentV3, workspaceProps.config ?? {})\n\n // The document is now a minimal version with externalized references to components and operations.\n // These references will be resolved asynchronously when needed through the workspace's get() method.\n workspace.documents[meta.name] = {\n ...documentMeta,\n ...documentV3,\n components,\n paths,\n [extensions.document.navigation]: navigation,\n }\n }\n\n /**\n * Adds a new document to the workspace asynchronously.\n *\n * This function:\n * 1. Loads the document using the provided input\n * 2. Checks if the document loaded successfully\n * 3. If successful, adds the document to the workspace using addDocumentSync\n *\n * @param input - The document input containing the document source and metadata\n */\n const addDocument = async (input: WorkspaceDocumentInput) => {\n const document = await loadDocument(input)\n\n if (!document.ok) {\n console.warn(`Failed to load document \"${input.name}`)\n return\n }\n\n addDocumentSync(document.data as Record<string, unknown>, { name: input.name, ...input.meta })\n }\n\n // Load and process all initial documents in parallel\n await Promise.all(workspaceProps.documents.map(addDocument))\n\n return {\n /**\n * Generates workspace chunks by writing components and operations to the filesystem.\n *\n * This method is only available in static mode. It creates a directory structure containing:\n * - A workspace file with metadata and document references\n * - Component chunks split by type (schemas, parameters, etc)\n * - Operation chunks split by path and HTTP method\n *\n * The generated workspace references will be relative file paths pointing to these chunks.\n *\n * @throws {Error} If called when mode is not 'static'\n */\n generateWorkspaceChunks: async () => {\n if (workspaceProps.mode !== 'static') {\n throw 'Mode has to be set to `static` to generate filesystem workspace chunks'\n }\n\n // Write the workspace document\n const basePath = `${cwd()}/${workspaceProps.directory ?? DEFAULT_ASSETS_FOLDER}`\n await fs.mkdir(basePath, { recursive: true })\n\n // Write the workspace contents on the file system\n await fs.writeFile(`${basePath}/${WORKSPACE_FILE_NAME}`, JSON.stringify(workspace))\n\n // Write the chunks\n for (const [name, { components, operations }] of Object.entries(assets)) {\n // Write the components chunks\n if (components) {\n for (const [type, component] of Object.entries(components as Record<string, Record<string, unknown>>)) {\n const componentPath = `${basePath}/chunks/${name}/components/${type}`\n await fs.mkdir(componentPath, { recursive: true })\n\n for (const [key, value] of Object.entries(component)) {\n await fs.writeFile(`${componentPath}/${key}.json`, JSON.stringify(value))\n }\n }\n }\n\n // Write the operations chunks\n if (operations) {\n for (const [path, methods] of Object.entries(operations)) {\n const operationPath = `${basePath}/chunks/${name}/operations/${path}`\n await fs.mkdir(operationPath, { recursive: true })\n\n for (const [method, operation] of Object.entries(methods)) {\n await fs.writeFile(`${operationPath}/${method}.json`, JSON.stringify(operation))\n }\n }\n }\n }\n },\n /**\n * Returns the workspace document containing metadata and all sparse documents.\n *\n * The workspace document includes:\n * - Global workspace metadata (theme, active document, etc)\n * - Document metadata and sparse document\n * - In SSR mode: References point to in-memory chunks\n * - In static mode: References point to filesystem chunks\n *\n * @returns The complete workspace document\n */\n getWorkspace: () => {\n return workspace\n },\n /**\n * Retrieves a chunk of data from the workspace using a JSON Pointer\n *\n * A JSON Pointer is a string that references a specific location in a JSON document.\n * Only components and operations chunks can be retrieved.\n *\n * @example\n * ```ts\n * // Get a component\n * get('#/document-name/components/schemas/User')\n *\n * // Get an operation\n * get('#/document-name/operations/pets/get')\n * ```\n *\n * @param pointer - The JSON Pointer string to locate the chunk\n * @returns The chunk data if found, undefined otherwise\n */\n get: (pointer: string) => {\n return getValueByPath(assets, parseJsonPointer(pointer))\n },\n /**\n * Adds a new document to the workspace asynchronously.\n *\n * This function:\n * 1. Loads the document using the provided input\n * 2. Checks if the document loaded successfully\n * 3. If successful, adds the document to the workspace using addDocumentSync\n *\n * @param input - The document input containing the document source and metadata\n */\n addDocument,\n }\n}\n"],
5
+ "mappings": "AAAA,OAAO,QAAQ;AACf,SAAS,WAAW;AAGpB,SAAS,WAAW,iBAAiB;AACrC,SAAS,yBAAyB;AAClC,SAAS,eAAe;AAExB,SAAS,aAAa;AACtB,SAAS,wBAAwB;AACjC,SAAS,kBAAkB;AAE3B,SAAS,mBAAmB;AAC5B;AAAA,EAEE;AAAA,OAIK;AAGP,SAAS,gBAAgB,wBAAwB;AAGjD,MAAM,wBAAwB;AACvB,MAAM,sBAAsB;AA4BnC,MAAM,cAAc,oBAAI,IAAI,CAAC,OAAO,OAAO,QAAQ,UAAU,WAAW,QAAQ,SAAS,OAAO,CAAC;AAwB1F,SAAS,sBAAsB,OAAqE;AACzG,QAAM,SAA0D,CAAC;AAGjE,aAAW,CAAC,MAAM,OAAO,KAAK,OAAO,QAAQ,KAAK,GAAG;AACnD,QA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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWA;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,49 @@
1
+ import type { InMemoryWorkspace } from './schemas/inmemory-workspace.js';
2
+ /**
3
+ * Represents a state change event in the workspace.
4
+ * This can be triggered for changes to documents, configs, meta, and overrides.
5
+ * The union covers each workspace property that, when changed, can notify plugins/reactive logic.
6
+ *
7
+ * - 'documents', 'originalDocuments', 'intermediateDocuments', 'documentConfigs', 'overrides', 'documentMeta':
8
+ * All provide the changed document's name and its new value.
9
+ * - 'meta': Provides the new meta value for the workspace.
10
+ */
11
+ export type WorkspaceStateChangeEvent = {
12
+ type: 'documents';
13
+ documentName: string;
14
+ value: InMemoryWorkspace['documents'][string];
15
+ } | {
16
+ type: 'originalDocuments';
17
+ documentName: string;
18
+ value: InMemoryWorkspace['originalDocuments'][string];
19
+ } | {
20
+ type: 'intermediateDocuments';
21
+ documentName: string;
22
+ value: InMemoryWorkspace['intermediateDocuments'][string];
23
+ } | {
24
+ type: 'documentConfigs';
25
+ documentName: string;
26
+ value: InMemoryWorkspace['documentConfigs'][string];
27
+ } | {
28
+ type: 'overrides';
29
+ documentName: string;
30
+ value: InMemoryWorkspace['overrides'][string];
31
+ } | {
32
+ type: 'meta';
33
+ value: InMemoryWorkspace['meta'];
34
+ };
35
+ /**
36
+ * Plugin type for extending workspace-store behavior with hooks.
37
+ *
38
+ * - hooks.onWorkspaceStateChanges: Optional hook called when workspace state changes.
39
+ */
40
+ export type WorkspacePlugin = Partial<{
41
+ hooks: Partial<{
42
+ /**
43
+ * Called when the workspace state changes (documents, configs, metadata etc).
44
+ * @param event Detailed info about the state change.
45
+ */
46
+ onWorkspaceStateChanges: (event: WorkspaceStateChangeEvent) => void;
47
+ }>;
48
+ }>;
49
+ //# sourceMappingURL=workspace-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-plugin.d.ts","sourceRoot":"","sources":["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,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "openapi",
17
17
  "scalar"
18
18
  ],
19
- "version": "0.17.1",
19
+ "version": "0.18.0",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -32,6 +32,16 @@
32
32
  "types": "./dist/client.d.ts",
33
33
  "default": "./dist/client.js"
34
34
  },
35
+ "./persistence": {
36
+ "import": "./dist/persistence/index.js",
37
+ "types": "./dist/persistence/index.d.ts",
38
+ "default": "./dist/persistence/index.js"
39
+ },
40
+ "./plugins/client": {
41
+ "import": "./dist/plugins/client/index.js",
42
+ "types": "./dist/plugins/client/index.d.ts",
43
+ "default": "./dist/plugins/client/index.js"
44
+ },
35
45
  "./schemas": {
36
46
  "import": "./dist/schemas.js",
37
47
  "types": "./dist/schemas.d.ts",
@@ -76,21 +86,23 @@
76
86
  "@scalar/typebox": "0.1.1",
77
87
  "github-slugger": "^2.0.0",
78
88
  "type-fest": "5.0.0",
79
- "vue": "^3.5.17",
89
+ "vue": "^3.5.21",
80
90
  "yaml": "2.8.0",
81
91
  "@scalar/code-highlight": "0.2.0",
82
- "@scalar/helpers": "0.0.12",
83
- "@scalar/snippetz": "0.5.1",
84
- "@scalar/json-magic": "0.6.1",
85
- "@scalar/types": "0.3.2",
86
- "@scalar/openapi-upgrader": "0.1.3"
92
+ "@scalar/helpers": "0.0.13",
93
+ "@scalar/json-magic": "0.7.0",
94
+ "@scalar/openapi-upgrader": "0.1.4",
95
+ "@scalar/snippetz": "0.5.2",
96
+ "@scalar/themes": "0.13.23",
97
+ "@scalar/types": "0.4.0"
87
98
  },
88
99
  "devDependencies": {
89
100
  "@google-cloud/storage": "7.16.0",
101
+ "fake-indexeddb": "6.2.3",
90
102
  "fastify": "^5.3.3",
91
- "vite": "7.1.5",
103
+ "vite": "7.1.11",
92
104
  "vitest": "3.2.4",
93
- "@scalar/build-tooling": "0.2.7"
105
+ "@scalar/build-tooling": "0.2.8"
94
106
  },
95
107
  "scripts": {
96
108
  "build": "scalar-build-esbuild",
@@ -1 +0,0 @@
1
- {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/events/definitions.ts"],"names":[],"mappings":"AAAA,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;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,YAAY,GAAG,MAAM,YAAY,IAAI;IAClF,uBAAuB,EAAE;QACvB,MAAM,EAAE;YACN,KAAK,EAAE,OAAO,CAAA;SACf,CAAA;KACF,CAAA;IACD,yBAAyB,EAAE;QACzB,MAAM,EAAE;YACN,KAAK,EAAE,OAAO,CAAA;SACf,CAAA;KACF,CAAA;IACD,+BAA+B,EAAE;QAC/B,MAAM,EAAE;YACN,KAAK,EAAE,MAAM,CAAA;SACd,CAAA;KACF,CAAA;IACD,8DAA8D;IAC9D,+BAA+B,EAAE;QAC/B,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;KACjC,CAAA;IACD,2EAA2E;IAC3E,gCAAgC,EAAE;QAChC,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;IACD,qEAAqE;IACrE,+BAA+B,EAAE;QAC/B,MAAM,EAAE;YACN,KAAK,CAAC,EAAE,MAAM,CAAA;YACd,OAAO,CAAC,EAAE;gBACR;;;;mBAIG;gBACH,qBAAqB,EAAE,OAAO,CAAA;aAC/B,CAAA;SACF,CAAA;KACF,CAAA;IACD,qEAAqE;IACrE,yCAAyC,EAAE;QACzC,MAAM,EAAE;YACN,GAAG,EAAE,MAAM,CAAA;YACX,KAAK,EAAE,MAAM,CAAA;YACb,OAAO,CAAC,EAAE;gBACR;;;;mBAIG;gBACH,qBAA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;IAED,wBAAwB,EAAE;QACxB,MAAM,EAAE;YACN,OAAO,EAAE,GAAG,CAAA;SACb,CAAA;KACF,CAAA;IAED,+BAA+B,EAAE;QAC/B,MAAM,EAAE;YACN,GAAG,EAAE,MAAM,CAAA;SACZ,CAAA;KACF,CAAA;CACF,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,kBAAkB,CAAC,CAAA;AAElE;;;;GAIG;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"}
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/events/definitions.ts"],
4
- "sourcesContent": ["import 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 */\nexport type ApiReferenceEvents<T extends keyof ServerObject = keyof ServerObject> = {\n 'scalar-update-sidebar': {\n detail: {\n value: boolean\n }\n }\n 'scalar-update-dark-mode': {\n detail: {\n value: boolean\n }\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 /** 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\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 */\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": "AAkKO,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
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAIhE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,QAAO,eAahC,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,QAAO,eA+BxC,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,QAAO,eAwCjC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,mBAAmB,QAAO,eAuBtC,CAAA"}