@kardalum/plugin-sdk 0.0.0-stage → 0.16.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 (332) hide show
  1. package/CHANGELOG.md +118 -0
  2. package/LICENSE +202 -0
  3. package/README.md +80 -2
  4. package/dist/admin-section-registry.d.ts +34 -0
  5. package/dist/admin-section-registry.js +49 -0
  6. package/dist/built-in-serializers.d.ts +3 -0
  7. package/dist/built-in-serializers.js +18 -0
  8. package/dist/built-in-settings-schemas.d.ts +14 -0
  9. package/dist/built-in-settings-schemas.js +225 -0
  10. package/dist/built-in-value-schemas.d.ts +4 -0
  11. package/dist/built-in-value-schemas.js +47 -0
  12. package/dist/built-ins.d.ts +1 -0
  13. package/dist/built-ins.js +257 -0
  14. package/dist/capabilities.d.ts +29 -0
  15. package/dist/capabilities.js +67 -0
  16. package/dist/data-type-plugin.d.ts +28 -0
  17. package/dist/data-type-plugin.js +1 -0
  18. package/dist/datatype-validation.d.ts +26 -0
  19. package/dist/datatype-validation.js +110 -0
  20. package/dist/datatypes-entry.d.ts +4 -0
  21. package/dist/datatypes-entry.js +18 -0
  22. package/dist/define-plugin.d.ts +25 -0
  23. package/dist/define-plugin.js +51 -0
  24. package/dist/entitlement-entry.d.ts +5 -0
  25. package/dist/entitlement-entry.js +24 -0
  26. package/dist/entitlement-gate.d.ts +36 -0
  27. package/dist/entitlement-gate.js +201 -0
  28. package/dist/entitlement-types.d.ts +39 -0
  29. package/dist/entitlement-types.js +1 -0
  30. package/dist/entitlement.d.ts +57 -0
  31. package/dist/entitlement.js +170 -0
  32. package/dist/host-entry.d.ts +1 -0
  33. package/dist/host-entry.js +11 -0
  34. package/dist/icon-name.d.ts +1 -0
  35. package/dist/icon-name.js +1 -0
  36. package/dist/icons.d.ts +2 -0
  37. package/dist/icons.js +10 -0
  38. package/dist/index.d.ts +28 -0
  39. package/dist/index.js +94 -0
  40. package/dist/license-verdict-keys.d.ts +18 -0
  41. package/dist/license-verdict-keys.js +26 -0
  42. package/dist/local-host.d.ts +3 -0
  43. package/dist/local-host.js +38 -0
  44. package/dist/manifest-entry.d.ts +8 -0
  45. package/dist/manifest-entry.js +13 -0
  46. package/dist/manifest-schema.d.ts +476 -0
  47. package/dist/manifest-schema.js +823 -0
  48. package/dist/manifest.d.ts +611 -0
  49. package/dist/manifest.js +86 -0
  50. package/dist/media/media-picker.d.ts +39 -0
  51. package/dist/media/media-picker.js +447 -0
  52. package/dist/media/upload-error.d.ts +12 -0
  53. package/dist/media/upload-error.js +30 -0
  54. package/dist/plugin-context.d.ts +82 -0
  55. package/dist/plugin-context.js +77 -0
  56. package/dist/plugin-screen-context.d.ts +71 -0
  57. package/dist/plugin-screen-context.js +41 -0
  58. package/dist/read-all-pages.d.ts +23 -0
  59. package/dist/read-all-pages.js +30 -0
  60. package/dist/register-built-ins.d.ts +1 -0
  61. package/dist/register-built-ins.js +41 -0
  62. package/dist/registry.d.ts +4 -0
  63. package/dist/registry.js +17 -0
  64. package/dist/rendition-eligibility.d.ts +24 -0
  65. package/dist/rendition-eligibility.js +40 -0
  66. package/dist/richtext/block-panel.d.ts +27 -0
  67. package/dist/richtext/block-panel.js +232 -0
  68. package/dist/richtext/extensions.d.ts +19 -0
  69. package/dist/richtext/extensions.js +56 -0
  70. package/dist/richtext/insert-menu.d.ts +24 -0
  71. package/dist/richtext/insert-menu.js +142 -0
  72. package/dist/richtext/kardalum-block.d.ts +33 -0
  73. package/dist/richtext/kardalum-block.js +282 -0
  74. package/dist/richtext/style-listbox.d.ts +10 -0
  75. package/dist/richtext/style-listbox.js +69 -0
  76. package/dist/richtext/text-style-class.d.ts +18 -0
  77. package/dist/richtext/text-style-class.js +36 -0
  78. package/dist/simple-storage-value-provider.d.ts +9 -0
  79. package/dist/simple-storage-value-provider.js +96 -0
  80. package/dist/structured-storage-types.d.ts +61 -0
  81. package/dist/structured-storage-types.js +11 -0
  82. package/dist/tailwind.d.ts +1 -0
  83. package/dist/tailwind.js +5 -0
  84. package/dist/tokens/system-dark.css +75 -0
  85. package/dist/tokens/tokens.css +239 -0
  86. package/dist/tokens/tokens.json +212 -0
  87. package/dist/tokens.d.ts +1 -0
  88. package/dist/tokens.js +11 -0
  89. package/dist/ui-entry.d.ts +5 -0
  90. package/dist/ui-entry.js +42 -0
  91. package/dist/views/content-list-preview.d.ts +1 -0
  92. package/dist/views/content-list-preview.js +14 -0
  93. package/dist/views/content-list-settings-view.d.ts +1 -0
  94. package/dist/views/content-list-settings-view.js +97 -0
  95. package/dist/views/content-list-view.d.ts +19 -0
  96. package/dist/views/content-list-view.js +248 -0
  97. package/dist/views/crop-view.d.ts +55 -0
  98. package/dist/views/crop-view.js +161 -0
  99. package/dist/views/date-range-view.d.ts +6 -0
  100. package/dist/views/date-range-view.js +55 -0
  101. package/dist/views/file-upload-view.d.ts +43 -0
  102. package/dist/views/file-upload-view.js +104 -0
  103. package/dist/views/html-code-editor.d.ts +10 -0
  104. package/dist/views/html-code-editor.js +101 -0
  105. package/dist/views/html-view.d.ts +3 -0
  106. package/dist/views/html-view.js +53 -0
  107. package/dist/views/image-view.d.ts +3 -0
  108. package/dist/views/image-view.js +372 -0
  109. package/dist/views/rich-text-view.d.ts +2 -0
  110. package/dist/views/rich-text-view.js +429 -0
  111. package/node_modules/@kardalum/api-schemas/LICENSE +202 -0
  112. package/node_modules/@kardalum/api-schemas/README.md +56 -0
  113. package/node_modules/@kardalum/api-schemas/dist/action.schema.d.ts +30 -0
  114. package/node_modules/@kardalum/api-schemas/dist/action.schema.js +88 -0
  115. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +17 -0
  116. package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +25 -0
  117. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +93 -0
  118. package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +88 -0
  119. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +89 -0
  120. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +60 -0
  121. package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +24 -0
  122. package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +47 -0
  123. package/node_modules/@kardalum/api-schemas/dist/auth.schema.d.ts +38 -0
  124. package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +38 -0
  125. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +542 -0
  126. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +357 -0
  127. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +158 -0
  128. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +139 -0
  129. package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +125 -0
  130. package/node_modules/@kardalum/api-schemas/dist/content-path.js +260 -0
  131. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +20 -0
  132. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +23 -0
  133. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +152 -0
  134. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +82 -0
  135. package/node_modules/@kardalum/api-schemas/dist/content-version.schema.d.ts +18 -0
  136. package/node_modules/@kardalum/api-schemas/dist/content-version.schema.js +22 -0
  137. package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +17 -0
  138. package/node_modules/@kardalum/api-schemas/dist/content.schema.js +20 -0
  139. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +352 -0
  140. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +133 -0
  141. package/node_modules/@kardalum/api-schemas/dist/culture-direction.d.ts +1 -0
  142. package/node_modules/@kardalum/api-schemas/dist/culture-direction.js +9 -0
  143. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +37 -0
  144. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +32 -0
  145. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +9 -0
  146. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +32 -0
  147. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +298 -0
  148. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +138 -0
  149. package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +121 -0
  150. package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +147 -0
  151. package/node_modules/@kardalum/api-schemas/dist/health.schema.d.ts +6 -0
  152. package/node_modules/@kardalum/api-schemas/dist/health.schema.js +5 -0
  153. package/node_modules/@kardalum/api-schemas/dist/html-entities.d.ts +4 -0
  154. package/node_modules/@kardalum/api-schemas/dist/html-entities.js +250 -0
  155. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +113 -0
  156. package/node_modules/@kardalum/api-schemas/dist/index.js +64 -0
  157. package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +15 -0
  158. package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +14 -0
  159. package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +73 -0
  160. package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +104 -0
  161. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +682 -0
  162. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +269 -0
  163. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +177 -0
  164. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +222 -0
  165. package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +77 -0
  166. package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.js +53 -0
  167. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +75 -0
  168. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +117 -0
  169. package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +27 -0
  170. package/node_modules/@kardalum/api-schemas/dist/media-reference.js +279 -0
  171. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.d.ts +74 -0
  172. package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +157 -0
  173. package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +80 -0
  174. package/node_modules/@kardalum/api-schemas/dist/media.schema.js +156 -0
  175. package/node_modules/@kardalum/api-schemas/dist/nav.schema.d.ts +23 -0
  176. package/node_modules/@kardalum/api-schemas/dist/nav.schema.js +55 -0
  177. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +846 -0
  178. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +356 -0
  179. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +20 -0
  180. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +27 -0
  181. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +249 -0
  182. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +84 -0
  183. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.d.ts +65 -0
  184. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +889 -0
  185. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +172 -0
  186. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +196 -0
  187. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +31 -0
  188. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +38 -0
  189. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +69 -0
  190. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +59 -0
  191. package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +585 -0
  192. package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +536 -0
  193. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +75 -0
  194. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +213 -0
  195. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +391 -0
  196. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +413 -0
  197. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +29 -0
  198. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +100 -0
  199. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +44 -0
  200. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +162 -0
  201. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +31 -0
  202. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +25 -0
  203. package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +15 -0
  204. package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +24 -0
  205. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +314 -0
  206. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +338 -0
  207. package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +79 -0
  208. package/node_modules/@kardalum/api-schemas/dist/render-editing.js +50 -0
  209. package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.d.ts +9 -0
  210. package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +13 -0
  211. package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.d.ts +2 -0
  212. package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.js +16 -0
  213. package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +96 -0
  214. package/node_modules/@kardalum/api-schemas/dist/role.schema.js +75 -0
  215. package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.d.ts +17 -0
  216. package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.js +27 -0
  217. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +35 -0
  218. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +79 -0
  219. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +138 -0
  220. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +105 -0
  221. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +243 -0
  222. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +296 -0
  223. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +47 -0
  224. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +27 -0
  225. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +30 -0
  226. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +19 -0
  227. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +112 -0
  228. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +74 -0
  229. package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +41 -0
  230. package/node_modules/@kardalum/api-schemas/dist/template.schema.js +39 -0
  231. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +21 -0
  232. package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +14 -0
  233. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +97 -0
  234. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +73 -0
  235. package/node_modules/@kardalum/api-schemas/package.json +35 -0
  236. package/node_modules/@kardalum/design-tokens/LICENSE +202 -0
  237. package/node_modules/@kardalum/design-tokens/README.md +29 -0
  238. package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +32 -0
  239. package/node_modules/@kardalum/design-tokens/dist/build-css.js +88 -0
  240. package/node_modules/@kardalum/design-tokens/dist/generate.d.ts +1 -0
  241. package/node_modules/@kardalum/design-tokens/dist/generate.js +18 -0
  242. package/node_modules/@kardalum/design-tokens/dist/index.d.ts +6 -0
  243. package/node_modules/@kardalum/design-tokens/dist/index.js +4 -0
  244. package/node_modules/@kardalum/design-tokens/dist/system-dark.css +75 -0
  245. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +33 -0
  246. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +54 -0
  247. package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +12 -0
  248. package/node_modules/@kardalum/design-tokens/dist/theme-css.js +42 -0
  249. package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +43 -0
  250. package/node_modules/@kardalum/design-tokens/dist/theme-types.js +1 -0
  251. package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +13 -0
  252. package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +120 -0
  253. package/node_modules/@kardalum/design-tokens/dist/themes/index.d.ts +5 -0
  254. package/node_modules/@kardalum/design-tokens/dist/themes/index.js +4 -0
  255. package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +9 -0
  256. package/node_modules/@kardalum/design-tokens/dist/themes/light.js +13 -0
  257. package/node_modules/@kardalum/design-tokens/dist/tokens.css +239 -0
  258. package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +25 -0
  259. package/node_modules/@kardalum/design-tokens/dist/tokens.js +276 -0
  260. package/node_modules/@kardalum/design-tokens/dist/tokens.json +212 -0
  261. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +91 -0
  262. package/node_modules/@kardalum/design-tokens/dist/types.js +5 -0
  263. package/node_modules/@kardalum/design-tokens/package.json +42 -0
  264. package/node_modules/@kardalum/plugin-package/LICENSE +202 -0
  265. package/node_modules/@kardalum/plugin-package/README.md +71 -0
  266. package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +111 -0
  267. package/node_modules/@kardalum/plugin-package/dist/build-reference.js +61 -0
  268. package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +103 -0
  269. package/node_modules/@kardalum/plugin-package/dist/capabilities.js +351 -0
  270. package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +50 -0
  271. package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +659 -0
  272. package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +19 -0
  273. package/node_modules/@kardalum/plugin-package/dist/envelope.js +104 -0
  274. package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +37 -0
  275. package/node_modules/@kardalum/plugin-package/dist/extract.js +199 -0
  276. package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +17 -0
  277. package/node_modules/@kardalum/plugin-package/dist/hash.js +69 -0
  278. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +13 -0
  279. package/node_modules/@kardalum/plugin-package/dist/index.js +8 -0
  280. package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +185 -0
  281. package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +236 -0
  282. package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +50 -0
  283. package/node_modules/@kardalum/plugin-package/dist/package-contract.js +115 -0
  284. package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +2 -0
  285. package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +6 -0
  286. package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +20 -0
  287. package/node_modules/@kardalum/plugin-package/dist/sample-content.js +57 -0
  288. package/node_modules/@kardalum/plugin-package/dist/types.d.ts +43 -0
  289. package/node_modules/@kardalum/plugin-package/dist/types.js +15 -0
  290. package/node_modules/@kardalum/plugin-package/package.json +54 -0
  291. package/node_modules/@kardalum/ui/LICENSE +202 -0
  292. package/node_modules/@kardalum/ui/README.md +35 -0
  293. package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +14 -0
  294. package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +38 -0
  295. package/node_modules/@kardalum/ui/dist/components/badge.d.ts +9 -0
  296. package/node_modules/@kardalum/ui/dist/components/badge.js +30 -0
  297. package/node_modules/@kardalum/ui/dist/components/button.d.ts +11 -0
  298. package/node_modules/@kardalum/ui/dist/components/button.js +37 -0
  299. package/node_modules/@kardalum/ui/dist/components/checkbox.d.ts +5 -0
  300. package/node_modules/@kardalum/ui/dist/components/checkbox.js +7 -0
  301. package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +17 -0
  302. package/node_modules/@kardalum/ui/dist/components/dialog.js +48 -0
  303. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +18 -0
  304. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +53 -0
  305. package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +30 -0
  306. package/node_modules/@kardalum/ui/dist/components/empty-state.js +9 -0
  307. package/node_modules/@kardalum/ui/dist/components/input.d.ts +4 -0
  308. package/node_modules/@kardalum/ui/dist/components/input.js +6 -0
  309. package/node_modules/@kardalum/ui/dist/components/panel.d.ts +5 -0
  310. package/node_modules/@kardalum/ui/dist/components/panel.js +6 -0
  311. package/node_modules/@kardalum/ui/dist/components/property-field.d.ts +19 -0
  312. package/node_modules/@kardalum/ui/dist/components/property-field.js +89 -0
  313. package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +17 -0
  314. package/node_modules/@kardalum/ui/dist/components/sheet.js +55 -0
  315. package/node_modules/@kardalum/ui/dist/components/skeleton.d.ts +3 -0
  316. package/node_modules/@kardalum/ui/dist/components/skeleton.js +9 -0
  317. package/node_modules/@kardalum/ui/dist/components/switch.d.ts +5 -0
  318. package/node_modules/@kardalum/ui/dist/components/switch.js +7 -0
  319. package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +34 -0
  320. package/node_modules/@kardalum/ui/dist/components/tab-strip.js +72 -0
  321. package/node_modules/@kardalum/ui/dist/components/toast.d.ts +18 -0
  322. package/node_modules/@kardalum/ui/dist/components/toast.js +42 -0
  323. package/node_modules/@kardalum/ui/dist/components/toaster.d.ts +12 -0
  324. package/node_modules/@kardalum/ui/dist/components/toaster.js +11 -0
  325. package/node_modules/@kardalum/ui/dist/components/use-toast.d.ts +17 -0
  326. package/node_modules/@kardalum/ui/dist/components/use-toast.js +62 -0
  327. package/node_modules/@kardalum/ui/dist/index.d.ts +18 -0
  328. package/node_modules/@kardalum/ui/dist/index.js +18 -0
  329. package/node_modules/@kardalum/ui/dist/lib/cn.d.ts +2 -0
  330. package/node_modules/@kardalum/ui/dist/lib/cn.js +5 -0
  331. package/node_modules/@kardalum/ui/package.json +63 -0
  332. package/package.json +146 -4
@@ -0,0 +1,889 @@
1
+ // S287: the pure rules a docs page is read by, shared by the package door
2
+ // (@kardalum/plugin-package), the server's search index and the renderer
3
+ // (@kardalum/markdown), so a link or an anchor means the same thing in
4
+ // all three. No Node imports: this runs in the browser too.
5
+ import { namedEntityForId } from "./html-entities.js";
6
+ /** A heading's anchor id. `seen` records every id issued so far (and, under
7
+ * a text's bare id, how many times that text came up), so no two headings
8
+ * of one page ever share an id: "Part", "Part", "Part 2" give doc-part,
9
+ * doc-part-2, doc-part-2-2. */
10
+ export function docHeadingId(text, seen) {
11
+ // The first replace leaves only single dashes, so the trim below cannot be slow.
12
+ const slug = text.toLowerCase().replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-+|-+$/g, "");
13
+ const base = `doc-${slug === "" ? "section" : slug}`;
14
+ if (!seen.has(base)) {
15
+ seen.set(base, 1);
16
+ return base;
17
+ }
18
+ let count = seen.get(base) + 1;
19
+ while (seen.has(`${base}-${count}`))
20
+ count++;
21
+ seen.set(base, count);
22
+ seen.set(`${base}-${count}`, 1);
23
+ return `${base}-${count}`;
24
+ }
25
+ /** Refusal text for a field that fails `hasHostileChars`. */
26
+ export const HOSTILE_CHARS_MESSAGE = "must not contain control or bidirectional-override characters";
27
+ // Trojan-Source guard: control characters, zero-width characters and bidi
28
+ // overrides can make displayed text lie about what bytes actually ship, so
29
+ // any author text a listing or a docs page shows as-is refuses them.
30
+ const HOSTILE_CHARS_PATTERN = new RegExp("[\u0000-\u001f\u007f\u200b-\u200f\u202a-\u202e\u2066-\u2069]", "u");
31
+ /** Whether the text holds a control, zero-width or bidirectional-override
32
+ * character. One rule for the marketplace's manifest fields and the docs
33
+ * page titles of the manifest schema. */
34
+ export function hasHostileChars(text) {
35
+ return HOSTILE_CHARS_PATTERN.test(text);
36
+ }
37
+ const HAS_SCHEME = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
38
+ const RENDERABLE_SCHEMES = new Set(["http:", "https:", "mailto:"]);
39
+ /** Whether an absolute link target is one the renderers draw as a link:
40
+ * http, https or mailto, and for http(s) with `//` straight after the
41
+ * colon. `https:/path` and `https:host` parse as URLs, but a browser
42
+ * resolves them against the page's own origin, so they never render as
43
+ * external links; nor does `//host` or `ftp:`. The package door warns on
44
+ * the targets this refuses, and the renderers' safeReadmeHref uses it, so
45
+ * the warning and the rendering cannot disagree. */
46
+ export function isRenderableExternalHref(target) {
47
+ if (!HAS_SCHEME.test(target))
48
+ return false;
49
+ let url;
50
+ try {
51
+ url = new URL(target);
52
+ }
53
+ catch {
54
+ return false;
55
+ }
56
+ if (!RENDERABLE_SCHEMES.has(url.protocol))
57
+ return false;
58
+ if (url.protocol === "mailto:")
59
+ return true;
60
+ const colon = target.indexOf(":");
61
+ return target.slice(colon + 1, colon + 3) === "//";
62
+ }
63
+ /** The longest link or image target the docs rules read. A real target is a
64
+ * short path; anything longer is refused before any work is done on it. */
65
+ export const MAX_DOCS_TARGET_LENGTH = 2048;
66
+ /** A relative target resolved against the page's directory as a
67
+ * package-relative posix path, or null when it is not a plain relative
68
+ * path that stays in the package. Nothing is percent-decoded. */
69
+ export function resolveDocsPath(pagePath, target) {
70
+ if (target.length > MAX_DOCS_TARGET_LENGTH)
71
+ return null;
72
+ if (target.includes("\\") || target.includes("\0") || target.startsWith("/") || /^[a-z]:/i.test(target))
73
+ return null;
74
+ const clean = target.split("#")[0].split("?")[0];
75
+ if (clean.endsWith("/"))
76
+ return null;
77
+ const segments = pagePath.split("/").slice(0, -1);
78
+ for (const segment of clean.split("/")) {
79
+ if (segment === "" || segment === ".")
80
+ continue;
81
+ if (segment === "..") {
82
+ if (segments.length === 0)
83
+ return null;
84
+ segments.pop();
85
+ }
86
+ else {
87
+ segments.push(segment);
88
+ }
89
+ }
90
+ const resolved = segments.join("/");
91
+ if (resolved === "" || resolved.includes(":"))
92
+ return null;
93
+ return resolved;
94
+ }
95
+ export function resolveDocsLink(pagePath, target, declaredPaths, referenceSlugs) {
96
+ if (target.startsWith("#"))
97
+ return { kind: "anchor", hash: target.slice(1) };
98
+ if (/^[a-z][a-z0-9+.-]+:/i.test(target) || target.startsWith("//"))
99
+ return { kind: "external", href: target };
100
+ if (target.length > MAX_DOCS_TARGET_LENGTH)
101
+ return { kind: "invalid", reason: "page" };
102
+ const hashAt = target.indexOf("#");
103
+ const hash = hashAt >= 0 ? target.slice(hashAt + 1) : undefined;
104
+ const withHash = (link) => (hash === undefined ? link : { ...link, hash });
105
+ const bare = (hashAt >= 0 ? target.slice(0, hashAt) : target).split("?")[0].replace(/^\.\//, "");
106
+ const referenceSlug = /^(?:\.\.\/)?reference\/([a-z-]+)$/.exec(bare)?.[1];
107
+ if (referenceSlug !== undefined) {
108
+ return referenceSlugs.has(referenceSlug) ? withHash({ kind: "reference", slug: referenceSlug }) : { kind: "invalid", reason: "reference" };
109
+ }
110
+ const resolved = resolveDocsPath(pagePath, target);
111
+ if (resolved === null || !declaredPaths.has(resolved))
112
+ return { kind: "invalid", reason: "page" };
113
+ return withHash({ kind: "page", path: resolved });
114
+ }
115
+ const MAX_SEARCH_READ = 262144;
116
+ const MAX_SEARCH_HEADINGS = 200;
117
+ const MAX_SEARCH_HEADING_TEXT = 200;
118
+ const MAX_HEADING_KEY_INPUT = 500;
119
+ /** The words of md[from, to) with markup dropped, in one left-to-right pass:
120
+ * `*`, backtick and `~` dropped, `|` and `][` read as a space, a leading run
121
+ * of `>` and spaces dropped, a link target dropped (to its `)` on this line,
122
+ * else to the end of the line), `[`, `]` and an image's `!` dropped, runs of
123
+ * spaces, tabs and no-break spaces collapsed and the result trimmed. Runs of
124
+ * kept characters are sliced out whole. */
125
+ function cleanSearchSpan(md, from, to) {
126
+ const out = [];
127
+ let i = from;
128
+ while (i < to && (md.charCodeAt(i) === 62 || md.charCodeAt(i) === 32))
129
+ i++;
130
+ let lastSpace = false;
131
+ let run = -1;
132
+ while (i < to) {
133
+ const at = i;
134
+ const c = md.charCodeAt(i);
135
+ let keep = false;
136
+ let space = false;
137
+ if (c === 93) {
138
+ const next = i + 1 < to ? md.charCodeAt(i + 1) : 0;
139
+ if (next === 40) {
140
+ let j = i + 2;
141
+ while (j < to && md.charCodeAt(j) !== 41)
142
+ j++;
143
+ i = j; // on the ")" (dropped with the target) or at the end of the line
144
+ }
145
+ else if (next === 91) {
146
+ space = true;
147
+ i++;
148
+ }
149
+ }
150
+ else if (c === 124 || c === 32 || c === 9 || c === 160) {
151
+ space = true;
152
+ }
153
+ else if (c === 33) {
154
+ keep = !(i + 1 < to && md.charCodeAt(i + 1) === 91);
155
+ }
156
+ else if (c !== 42 && c !== 96 && c !== 126 && c !== 91) {
157
+ keep = true;
158
+ }
159
+ if (keep) {
160
+ if (run < 0)
161
+ run = at;
162
+ }
163
+ else {
164
+ if (run >= 0) {
165
+ out.push(md.slice(run, at));
166
+ run = -1;
167
+ lastSpace = false;
168
+ }
169
+ if (space && out.length > 0 && !lastSpace) {
170
+ out.push(" ");
171
+ lastSpace = true;
172
+ }
173
+ }
174
+ i++;
175
+ }
176
+ if (run >= 0)
177
+ out.push(md.slice(run, to));
178
+ else if (lastSpace)
179
+ out.pop();
180
+ return out.join("");
181
+ }
182
+ /** What search matches in one page: its heading lines and its prose, read in
183
+ * one linear pass. Not a markdown parser and not used for rendering. */
184
+ export function docSearchEntry(markdown, maxChars = 20000) {
185
+ const md = markdown.length > MAX_SEARCH_READ ? markdown.slice(0, MAX_SEARCH_READ) : markdown;
186
+ const headings = [];
187
+ const lines = [];
188
+ let kept = 0;
189
+ let inFence = false;
190
+ let fenceChar = 0;
191
+ let fenceLen = 0;
192
+ let pos = 0;
193
+ while (pos <= md.length) {
194
+ let end = md.indexOf("\n", pos);
195
+ if (end === -1)
196
+ end = md.length;
197
+ const lineStart = pos;
198
+ pos = end + 1;
199
+ let lineEnd = end;
200
+ if (lineEnd > lineStart && md.charCodeAt(lineEnd - 1) === 13)
201
+ lineEnd--;
202
+ let first = lineStart;
203
+ while (first < lineEnd && md.charCodeAt(first) === 32)
204
+ first++;
205
+ if (first >= lineEnd)
206
+ continue;
207
+ const f = md.charCodeAt(first);
208
+ if (inFence) {
209
+ // A closing fence: the same character, at least as long, then only blanks.
210
+ if (f === fenceChar) {
211
+ let r = first;
212
+ while (r < lineEnd && md.charCodeAt(r) === fenceChar)
213
+ r++;
214
+ if (r - first >= fenceLen) {
215
+ while (r < lineEnd && (md.charCodeAt(r) === 32 || md.charCodeAt(r) === 9))
216
+ r++;
217
+ if (r === lineEnd)
218
+ inFence = false;
219
+ }
220
+ }
221
+ continue;
222
+ }
223
+ if (f === 96 || f === 126) {
224
+ let r = first;
225
+ while (r < lineEnd && md.charCodeAt(r) === f)
226
+ r++;
227
+ if (r - first >= 3) {
228
+ let opens = true;
229
+ if (f === 96) {
230
+ for (let k = r; k < lineEnd; k++) {
231
+ if (md.charCodeAt(k) === 96) {
232
+ opens = false; // inline code, not a fence
233
+ break;
234
+ }
235
+ }
236
+ }
237
+ if (opens) {
238
+ inFence = true;
239
+ fenceChar = f;
240
+ fenceLen = r - first;
241
+ continue;
242
+ }
243
+ }
244
+ }
245
+ if (f === 60)
246
+ continue;
247
+ let text = null;
248
+ let level = 0;
249
+ if (f === 35 && first - lineStart <= 3) {
250
+ let h = first;
251
+ while (h < lineEnd && md.charCodeAt(h) === 35)
252
+ h++;
253
+ level = h - first;
254
+ if (level <= 6 && (h === lineEnd || md.charCodeAt(h) === 32)) {
255
+ text = cleanSearchSpan(md, h, lineEnd);
256
+ let t = text.length;
257
+ while (t > 0 && (text.charCodeAt(t - 1) === 35 || text.charCodeAt(t - 1) === 32))
258
+ t--;
259
+ if (t < text.length)
260
+ text = text.slice(0, t);
261
+ if (text.length > MAX_SEARCH_HEADING_TEXT) {
262
+ let cut = MAX_SEARCH_HEADING_TEXT;
263
+ while (cut > 0 && text.charCodeAt(cut - 1) === 32)
264
+ cut--;
265
+ text = text.slice(0, cut);
266
+ }
267
+ }
268
+ }
269
+ if (text === null) {
270
+ // A table separator or a setext underline carries no words.
271
+ let onlyRule = true;
272
+ let onlyEquals = true;
273
+ for (let k = first; k < lineEnd; k++) {
274
+ const c = md.charCodeAt(k);
275
+ if (c !== 45 && c !== 58 && c !== 124 && c !== 32)
276
+ onlyRule = false;
277
+ if (c !== 61 && c !== 32)
278
+ onlyEquals = false;
279
+ if (!onlyRule && !onlyEquals)
280
+ break;
281
+ }
282
+ if (onlyRule || onlyEquals)
283
+ continue;
284
+ text = cleanSearchSpan(md, first, lineEnd);
285
+ }
286
+ else if (level <= 3 && text !== "" && headings.length < MAX_SEARCH_HEADINGS) {
287
+ headings.push({ text, level });
288
+ }
289
+ if (text === "")
290
+ continue;
291
+ if (kept <= maxChars) {
292
+ lines.push(text);
293
+ kept += text.length + 1;
294
+ }
295
+ }
296
+ const joined = lines.join("\n");
297
+ return { headings, text: joined.length > maxChars ? joined.slice(0, maxChars) : joined };
298
+ }
299
+ /** A heading reduced to what it keeps, lowercased, so a heading found by
300
+ * docSearchEntry can be matched to the one the renderer drew. It keeps cased
301
+ * letters, ASCII digits and any non-ASCII character that is not whitespace. */
302
+ export function docHeadingKey(text) {
303
+ const lower = (text.length > MAX_HEADING_KEY_INPUT ? text.slice(0, MAX_HEADING_KEY_INPUT) : text).toLowerCase();
304
+ const kept = [];
305
+ for (const ch of lower) {
306
+ // Scripts without case (Arabic, Hebrew, CJK, Devanagari) keep their
307
+ // letters through the non-ASCII clause, so their headings do not all
308
+ // share one empty key.
309
+ if (ch.toLowerCase() !== ch.toUpperCase() || (ch >= "0" && ch <= "9") || (ch.charCodeAt(0) >= 0x80 && ch.trim() !== ""))
310
+ kept.push(ch);
311
+ }
312
+ return kept.join("");
313
+ }
314
+ // The heading ids a page will carry, for the package door's anchor check.
315
+ // The renderer mints an id from each heading's rendered text with
316
+ // docHeadingId; this reads the same headings without the markdown parser
317
+ // (which is quadratic on emphasis runs), in one forward pass over the lines
318
+ // and one pass over each heading's own text. It reads ATX headings (up to
319
+ // three spaces of indent past the open list item's content column, inside a
320
+ // blockquote or after a list marker too), setext headings under a plain
321
+ // paragraph (in a blockquote too), and skips fenced code and HTML blocks (a
322
+ // comment, a processing instruction, a declaration and CDATA end at their
323
+ // closing marker, any other block at a blank line). A heading's text drops
324
+ // what the renderer drops: emphasis and strikethrough markers, a link's
325
+ // target (inline, or a full reference whose label the page defines), inline
326
+ // HTML, a closing run of `#`, and the alt text of an image shown from the
327
+ // package; character references are decoded.
328
+ const HASH = 35;
329
+ const GT = 62;
330
+ const LT = 60;
331
+ const AMP = 38;
332
+ const LBRACKET = 91;
333
+ const RBRACKET = 93;
334
+ function isAsciiPunctuation(code) {
335
+ return (code >= 33 && code <= 47) || (code >= 58 && code <= 64) || (code >= 91 && code <= 96) || (code >= 123 && code <= 126);
336
+ }
337
+ function isLetter(code) {
338
+ return (code >= 65 && code <= 90) || (code >= 97 && code <= 122);
339
+ }
340
+ function isDigit(code) {
341
+ return code >= 48 && code <= 57;
342
+ }
343
+ function isHexDigit(code) {
344
+ return isDigit(code) || (code >= 65 && code <= 70) || (code >= 97 && code <= 102);
345
+ }
346
+ function isBlank(code) {
347
+ return code === 32 || code === 9;
348
+ }
349
+ /** The image extensions the renderer serves from a package (render-docs-html.ts). */
350
+ const DOCS_IMAGE_EXTENSION = /\.(png|jpe?g|gif|webp)$/i;
351
+ /** A link or image destination as the renderer reads it from what is
352
+ * between the parentheses: the part inside `<...>`, else up to the first
353
+ * blank (a title after it is not part of the target). */
354
+ function destinationOf(raw) {
355
+ const trimmed = raw.trim();
356
+ if (trimmed.startsWith("<")) {
357
+ const close = trimmed.indexOf(">");
358
+ return close === -1 ? trimmed : trimmed.slice(1, close);
359
+ }
360
+ let end = 0;
361
+ while (end < trimmed.length && !isBlank(trimmed.charCodeAt(end)))
362
+ end++;
363
+ return trimmed.slice(0, end);
364
+ }
365
+ /** Whether the renderer shows this image as a picture (its alt text then
366
+ * carries no words): a package image of a served type, resolved against
367
+ * the page the way docsImageSrc resolves it. */
368
+ function showsAsPicture(target, pagePath) {
369
+ const resolved = resolveDocsPath(pagePath, target.trim());
370
+ return resolved !== null && DOCS_IMAGE_EXTENSION.test(resolved);
371
+ }
372
+ /** A reference label as CommonMark matches it: trimmed, inner whitespace
373
+ * collapsed, case-folded. */
374
+ function normalizeLabel(label) {
375
+ return label.trim().split(/[ \t\r\n]+/).join(" ").toLowerCase();
376
+ }
377
+ /** The character reference at md[at] (an `&`) within md[.., end): its
378
+ * length and what it reads as in a heading id, or null when it is not one. */
379
+ function characterReference(md, at, end) {
380
+ const limit = Math.min(end, at + 34);
381
+ let k = at + 1;
382
+ if (k < limit && md.charCodeAt(k) === HASH) {
383
+ k++;
384
+ const hex = k < limit && (md.charCodeAt(k) === 120 || md.charCodeAt(k) === 88);
385
+ if (hex)
386
+ k++;
387
+ const digitsFrom = k;
388
+ while (k < limit && (hex ? isHexDigit(md.charCodeAt(k)) : isDigit(md.charCodeAt(k))))
389
+ k++;
390
+ const digits = k - digitsFrom;
391
+ if (digits === 0 || digits > (hex ? 6 : 7) || k >= limit || md.charCodeAt(k) !== 59)
392
+ return null;
393
+ const code = Number.parseInt(md.slice(digitsFrom, k), hex ? 16 : 10);
394
+ const valid = code > 0 && code <= 0x10ffff && !(code >= 0xd800 && code <= 0xdfff);
395
+ return { length: k + 1 - at, text: valid ? String.fromCodePoint(code) : "�" };
396
+ }
397
+ const nameFrom = k;
398
+ while (k < limit && (isLetter(md.charCodeAt(k)) || isDigit(md.charCodeAt(k))))
399
+ k++;
400
+ if (k === nameFrom || k >= limit || md.charCodeAt(k) !== 59)
401
+ return null;
402
+ const text = namedEntityForId(md.slice(nameFrom, k));
403
+ return text === null ? null : { length: k + 1 - at, text };
404
+ }
405
+ /** A heading's text as the renderer shows it, from md[from, to). Every
406
+ * search ahead (a closing backtick run, a link's ")", a label's "]", a
407
+ * tag's ">") reads an index computed once for the heading, so the pass
408
+ * stays linear. */
409
+ function headingText(md, from, to, context) {
410
+ let start = from;
411
+ while (start < to && isBlank(md.charCodeAt(start)))
412
+ start++;
413
+ let end = to;
414
+ while (end > start && isBlank(md.charCodeAt(end - 1)))
415
+ end--;
416
+ // A closing sequence: a run of # that is the whole text or follows a blank.
417
+ let h = end;
418
+ while (h > start && md.charCodeAt(h - 1) === HASH)
419
+ h--;
420
+ if (h < end && (h === start || isBlank(md.charCodeAt(h - 1)))) {
421
+ end = h;
422
+ while (end > start && isBlank(md.charCodeAt(end - 1)))
423
+ end--;
424
+ }
425
+ const length = end - start;
426
+ if (length <= 0)
427
+ return "";
428
+ // The next ")", ">", "<", "[" and "]" at or after each offset, and the
429
+ // backtick runs by length.
430
+ const nextParen = new Int32Array(length + 1).fill(-1);
431
+ const nextGt = new Int32Array(length + 1).fill(-1);
432
+ const nextLt = new Int32Array(length + 1).fill(-1);
433
+ const nextOpen = new Int32Array(length + 1).fill(-1);
434
+ const nextClose = new Int32Array(length + 1).fill(-1);
435
+ for (let k = length - 1; k >= 0; k--) {
436
+ const c = md.charCodeAt(start + k);
437
+ nextParen[k] = c === 41 ? k : nextParen[k + 1];
438
+ nextGt[k] = c === GT ? k : nextGt[k + 1];
439
+ nextLt[k] = c === LT ? k : nextLt[k + 1];
440
+ nextOpen[k] = c === LBRACKET ? k : nextOpen[k + 1];
441
+ nextClose[k] = c === RBRACKET ? k : nextClose[k + 1];
442
+ }
443
+ const runs = new Map();
444
+ for (let k = 0; k < length; k++) {
445
+ if (md.charCodeAt(start + k) !== 96)
446
+ continue;
447
+ const runStart = k;
448
+ while (k + 1 < length && md.charCodeAt(start + k + 1) === 96)
449
+ k++;
450
+ const list = runs.get(k - runStart + 1);
451
+ if (list)
452
+ list.push(runStart);
453
+ else
454
+ runs.set(k - runStart + 1, [runStart]);
455
+ }
456
+ const runCursor = new Map();
457
+ const closingRun = (size, after) => {
458
+ const list = runs.get(size);
459
+ if (!list)
460
+ return -1;
461
+ let at = runCursor.get(size) ?? 0;
462
+ while (at < list.length && list[at] < after)
463
+ at++;
464
+ runCursor.set(size, at);
465
+ return at < list.length ? list[at] : -1;
466
+ };
467
+ const out = [];
468
+ const open = [];
469
+ /** Closes the bracket opened at `bracket` as a link or image to `target`. */
470
+ const closeLink = (bracket, target) => {
471
+ if (bracket.image && showsAsPicture(target, context.pagePath)) {
472
+ // An image shown from the package has no text.
473
+ out.length = bracket.at;
474
+ }
475
+ else {
476
+ out[bracket.at] = "";
477
+ }
478
+ };
479
+ let k = 0;
480
+ while (k < length) {
481
+ const c = md.charCodeAt(start + k);
482
+ if (c === 92 && k + 1 < length && isAsciiPunctuation(md.charCodeAt(start + k + 1))) {
483
+ out.push(md[start + k + 1]);
484
+ k += 2;
485
+ }
486
+ else if (c === 96) {
487
+ let runEnd = k;
488
+ while (runEnd < length && md.charCodeAt(start + runEnd) === 96)
489
+ runEnd++;
490
+ const close = closingRun(runEnd - k, runEnd);
491
+ if (close === -1) {
492
+ out.push(md.slice(start + k, start + runEnd));
493
+ k = runEnd;
494
+ }
495
+ else {
496
+ out.push(md.slice(start + runEnd, start + close));
497
+ k = close + (runEnd - k);
498
+ }
499
+ }
500
+ else if (c === 42 || c === 126) {
501
+ k++;
502
+ }
503
+ else if (c === AMP) {
504
+ const reference = characterReference(md, start + k, end);
505
+ if (reference === null) {
506
+ out.push("&");
507
+ k++;
508
+ }
509
+ else {
510
+ out.push(reference.text);
511
+ k += reference.length;
512
+ }
513
+ }
514
+ else if (c === 33 && k + 1 < length && md.charCodeAt(start + k + 1) === LBRACKET) {
515
+ open.push({ at: out.length, image: true, src: k + 2 });
516
+ out.push("![");
517
+ k += 2;
518
+ }
519
+ else if (c === LBRACKET) {
520
+ open.push({ at: out.length, image: false, src: k + 1 });
521
+ out.push("[");
522
+ k++;
523
+ }
524
+ else if (c === RBRACKET) {
525
+ const bracket = open.pop();
526
+ const nextChar = k + 1 < length ? md.charCodeAt(start + k + 1) : -1;
527
+ if (bracket !== undefined && nextChar === 40 && nextParen[k + 2] !== -1) {
528
+ const close = nextParen[k + 2];
529
+ closeLink(bracket, destinationOf(md.slice(start + k + 2, start + close)));
530
+ k = close + 1;
531
+ continue;
532
+ }
533
+ // A reference whose label the page defines: a link shows its text and
534
+ // not the label, an image shows nothing (the renderer reads no words
535
+ // from an image reference). `[text][]` and `[text]` use the text as
536
+ // the label.
537
+ // A label is at most 999 characters, so the text is read only that
538
+ // far, which keeps nested brackets from costing a pass each.
539
+ const textDefined = () => bracket !== undefined && k - bracket.src <= 999 && context.definitions.has(normalizeLabel(md.slice(start + bracket.src, start + k)));
540
+ if (bracket !== undefined && nextChar === LBRACKET) {
541
+ const labelEnd = nextClose[k + 2];
542
+ const innerOpen = nextOpen[k + 2];
543
+ if (labelEnd !== -1 && (innerOpen === -1 || innerOpen > labelEnd)) {
544
+ const label = md.slice(start + k + 2, start + labelEnd);
545
+ const collapsed = label.trim() === "";
546
+ const defined = collapsed ? textDefined() : context.definitions.has(normalizeLabel(label));
547
+ if (collapsed || defined) {
548
+ if (bracket.image && defined)
549
+ out.length = bracket.at;
550
+ else
551
+ out[bracket.at] = "";
552
+ k = labelEnd + 1;
553
+ continue;
554
+ }
555
+ }
556
+ }
557
+ else if (bracket !== undefined && bracket.image && textDefined()) {
558
+ out.length = bracket.at;
559
+ k++;
560
+ continue;
561
+ }
562
+ out.push("]");
563
+ k++;
564
+ }
565
+ else if (c === LT) {
566
+ // A "<" before the ">" makes this one literal, so no two tags are
567
+ // read over the same characters.
568
+ const gtAt = nextGt[k + 1];
569
+ const ltAt = nextLt[k + 1];
570
+ const gt = ltAt !== -1 && ltAt < gtAt ? -1 : gtAt;
571
+ const inner = gt === -1 ? "" : md.slice(start + k + 1, start + gt);
572
+ if (gt !== -1 && (/^[a-z][a-z0-9+.-]+:[^\s<>]*$/i.test(inner) || /^[^\s<>@]+@[^\s<>@]+$/.test(inner))) {
573
+ out.push(inner); // an autolink shows its target
574
+ k = gt + 1;
575
+ }
576
+ else if (gt !== -1 && inner.length > 0 && (isLetter(inner.charCodeAt(0)) || inner[0] === "/" || inner[0] === "!" || inner[0] === "?")) {
577
+ k = gt + 1; // inline HTML is dropped
578
+ }
579
+ else {
580
+ out.push("<");
581
+ k++;
582
+ }
583
+ }
584
+ else {
585
+ let run = k + 1;
586
+ while (run < length) {
587
+ const d = md.charCodeAt(start + run);
588
+ if (d === 92 || d === 96 || d === 42 || d === 126 || d === 33 || d === LBRACKET || d === RBRACKET || d === LT || d === AMP)
589
+ break;
590
+ run++;
591
+ }
592
+ out.push(md.slice(start + k, start + run));
593
+ k = run;
594
+ }
595
+ }
596
+ return out.join("");
597
+ }
598
+ /** What ends the HTML block md[from, to) opens: a marker for a comment,
599
+ * a processing instruction, a declaration or CDATA (CommonMark types 2 to
600
+ * 5), "" for any other block (it ends at a blank line), or null when the
601
+ * line opens none. An autolink such as `<https://x>` does not. */
602
+ function htmlBlockEnd(md, from, to) {
603
+ if (md.charCodeAt(from) !== LT || from + 1 >= to)
604
+ return null;
605
+ if (md.startsWith("<!--", from))
606
+ return "-->";
607
+ if (md.startsWith("<![CDATA[", from))
608
+ return "]]>";
609
+ const next = md.charCodeAt(from + 1);
610
+ if (next === 63)
611
+ return "?>";
612
+ if (next === 33)
613
+ return from + 2 < to && isLetter(md.charCodeAt(from + 2)) ? ">" : "";
614
+ if (next === 47)
615
+ return "";
616
+ if (!isLetter(next))
617
+ return null;
618
+ let k = from + 2;
619
+ while (k < to && (isLetter(md.charCodeAt(k)) || isDigit(md.charCodeAt(k)) || md.charCodeAt(k) === 45))
620
+ k++;
621
+ if (k >= to)
622
+ return "";
623
+ const after = md.charCodeAt(k);
624
+ return isBlank(after) || after === GT || after === 47 ? "" : null;
625
+ }
626
+ /** Whether md[from, to) contains `marker`, read inside the line only. */
627
+ function lineHas(md, from, to, marker) {
628
+ const first = marker.charCodeAt(0);
629
+ for (let k = from; k + marker.length <= to; k++) {
630
+ if (md.charCodeAt(k) === first && md.startsWith(marker, k))
631
+ return true;
632
+ }
633
+ return false;
634
+ }
635
+ /** The length of a list marker and the blanks after it at md[from], or 0. */
636
+ function listMarkerLength(md, from, to) {
637
+ let k = from;
638
+ const c = md.charCodeAt(k);
639
+ if (c === 45 || c === 42 || c === 43) {
640
+ k++;
641
+ }
642
+ else {
643
+ while (k < to && k - from < 9 && isDigit(md.charCodeAt(k)))
644
+ k++;
645
+ if (k === from || k >= to || (md.charCodeAt(k) !== 46 && md.charCodeAt(k) !== 41))
646
+ return 0;
647
+ k++;
648
+ }
649
+ if (k >= to || !isBlank(md.charCodeAt(k)))
650
+ return 0;
651
+ while (k < to && isBlank(md.charCodeAt(k)))
652
+ k++;
653
+ return k - from;
654
+ }
655
+ /** Whether md[from, to) is a thematic break: three or more of one of - * _,
656
+ * blanks between. */
657
+ function isThematicBreak(md, from, to) {
658
+ const f = md.charCodeAt(from);
659
+ if (f !== 45 && f !== 42 && f !== 95)
660
+ return false;
661
+ let count = 0;
662
+ for (let r = from; r < to; r++) {
663
+ const c = md.charCodeAt(r);
664
+ if (c === f)
665
+ count++;
666
+ else if (!isBlank(c))
667
+ return false;
668
+ }
669
+ return count >= 3;
670
+ }
671
+ /** The page's link reference definitions (`[label]: destination`, up to
672
+ * three spaces of indent, outside fenced code), normalized label to
673
+ * destination; the first definition of a label wins, as in CommonMark. */
674
+ function referenceDefinitions(md) {
675
+ const definitions = new Map();
676
+ let fenceChar = 0;
677
+ let pos = 0;
678
+ while (pos < md.length) {
679
+ let end = md.indexOf("\n", pos);
680
+ if (end === -1)
681
+ end = md.length;
682
+ const lineStart = pos;
683
+ pos = end + 1;
684
+ let first = lineStart;
685
+ while (first < end && isBlank(md.charCodeAt(first)))
686
+ first++;
687
+ if (first >= end || first - lineStart > 3)
688
+ continue;
689
+ const f = md.charCodeAt(first);
690
+ if (f === 96 || f === 126) {
691
+ let r = first;
692
+ while (r < end && md.charCodeAt(r) === f)
693
+ r++;
694
+ if (r - first >= 3) {
695
+ if (fenceChar === 0)
696
+ fenceChar = f;
697
+ else if (fenceChar === f)
698
+ fenceChar = 0;
699
+ continue;
700
+ }
701
+ }
702
+ if (fenceChar !== 0 || f !== LBRACKET)
703
+ continue;
704
+ let k = first + 1;
705
+ while (k < end && k - first <= 1000) {
706
+ const c = md.charCodeAt(k);
707
+ if (c === 92)
708
+ k += 2;
709
+ else if (c === LBRACKET || c === RBRACKET)
710
+ break;
711
+ else
712
+ k++;
713
+ }
714
+ if (k >= end || md.charCodeAt(k) !== RBRACKET || k + 1 >= end || md.charCodeAt(k + 1) !== 58)
715
+ continue;
716
+ const label = normalizeLabel(md.slice(first + 1, k));
717
+ const destination = destinationOf(md.slice(k + 2, end).replace(/\r$/, ""));
718
+ if (label !== "" && destination !== "" && !definitions.has(label))
719
+ definitions.set(label, destination);
720
+ }
721
+ return definitions;
722
+ }
723
+ /** The heading ids of a page in order, as the renderer mints them: each
724
+ * heading's text through docHeadingId with one `seen` map for the page.
725
+ * `pagePath` is the page's package path, which decides whether an image in
726
+ * a heading is shown as a picture; it defaults to the README. */
727
+ export function extractDocHeadings(markdown, pagePath = "README.md") {
728
+ const md = markdown.length > MAX_SEARCH_READ ? markdown.slice(0, MAX_SEARCH_READ) : markdown;
729
+ const context = { definitions: referenceDefinitions(md), pagePath };
730
+ const ids = [];
731
+ const seen = new Map();
732
+ let fenceChar = 0;
733
+ let fenceLen = 0;
734
+ // The open HTML block's end marker: "" ends at a blank line, null is none.
735
+ let htmlEnd = null;
736
+ // The open paragraph as [from, to) spans, whether a setext underline may
737
+ // turn it into a heading, and the blockquote depth it opened at.
738
+ let paragraph = null;
739
+ let paragraphPlain = false;
740
+ let paragraphDepth = 0;
741
+ // The content columns of the open list items, innermost last: a line
742
+ // indented to an item's column belongs to it.
743
+ const listColumns = [];
744
+ let pos = 0;
745
+ while (pos < md.length) {
746
+ let end = md.indexOf("\n", pos);
747
+ if (end === -1)
748
+ end = md.length;
749
+ const lineStart = pos;
750
+ pos = end + 1;
751
+ let lineEnd = end;
752
+ if (lineEnd > lineStart && md.charCodeAt(lineEnd - 1) === 13)
753
+ lineEnd--;
754
+ let first = lineStart;
755
+ while (first < lineEnd && isBlank(md.charCodeAt(first)))
756
+ first++;
757
+ if (first >= lineEnd) {
758
+ paragraph = null;
759
+ if (htmlEnd === "")
760
+ htmlEnd = null;
761
+ continue;
762
+ }
763
+ const indent = first - lineStart;
764
+ const f = md.charCodeAt(first);
765
+ if (fenceChar !== 0) {
766
+ if (f === fenceChar && (indent <= 3 || listColumns.length > 0)) {
767
+ let r = first;
768
+ while (r < lineEnd && md.charCodeAt(r) === fenceChar)
769
+ r++;
770
+ if (r - first >= fenceLen) {
771
+ while (r < lineEnd && isBlank(md.charCodeAt(r)))
772
+ r++;
773
+ if (r === lineEnd)
774
+ fenceChar = 0;
775
+ }
776
+ }
777
+ continue;
778
+ }
779
+ if (htmlEnd !== null) {
780
+ if (htmlEnd !== "" && lineHas(md, first, lineEnd, htmlEnd))
781
+ htmlEnd = null;
782
+ continue;
783
+ }
784
+ // Which list item the line belongs to. A line less indented than the
785
+ // innermost item's content leaves it, unless it is a lazy continuation
786
+ // of that item's open paragraph.
787
+ const opensBlock = f === HASH || f === GT || f === 96 || f === 126 || listMarkerLength(md, first, lineEnd) > 0 || isThematicBreak(md, first, lineEnd);
788
+ if (listColumns.length > 0 && indent < listColumns[listColumns.length - 1]) {
789
+ if (paragraph !== null && !opensBlock) {
790
+ paragraph.push([first, lineEnd]);
791
+ continue;
792
+ }
793
+ while (listColumns.length > 0 && indent < listColumns[listColumns.length - 1])
794
+ listColumns.pop();
795
+ }
796
+ const relative = indent - (listColumns.length > 0 ? listColumns[listColumns.length - 1] : 0);
797
+ if (relative > 3) {
798
+ // A lazy continuation of the open paragraph, or indented code.
799
+ if (paragraph)
800
+ paragraph.push([first, lineEnd]);
801
+ continue;
802
+ }
803
+ if (f === 96 || f === 126) {
804
+ let r = first;
805
+ while (r < lineEnd && md.charCodeAt(r) === f)
806
+ r++;
807
+ if (r - first >= 3) {
808
+ let opens = true;
809
+ if (f === 96) {
810
+ for (let b = r; b < lineEnd; b++) {
811
+ if (md.charCodeAt(b) === 96) {
812
+ opens = false; // inline code, not a fence
813
+ break;
814
+ }
815
+ }
816
+ }
817
+ if (opens) {
818
+ fenceChar = f;
819
+ fenceLen = r - first;
820
+ paragraph = null;
821
+ continue;
822
+ }
823
+ }
824
+ }
825
+ const blockEnd = htmlBlockEnd(md, first, lineEnd);
826
+ // A comment, instruction, declaration or CDATA block may interrupt a
827
+ // paragraph; any other HTML block may not.
828
+ if (blockEnd !== null && (paragraph === null || blockEnd !== "")) {
829
+ paragraph = null;
830
+ if (blockEnd === "" || !lineHas(md, first + 2, lineEnd, blockEnd))
831
+ htmlEnd = blockEnd;
832
+ continue;
833
+ }
834
+ // A blockquote's markers, then a list marker a heading follows.
835
+ let p = first;
836
+ let depth = 0;
837
+ while (p < lineEnd && md.charCodeAt(p) === GT) {
838
+ depth++;
839
+ p++;
840
+ while (p < lineEnd && isBlank(md.charCodeAt(p)))
841
+ p++;
842
+ }
843
+ const marker = p < lineEnd ? listMarkerLength(md, p, lineEnd) : 0;
844
+ if (marker > 0 && depth === 0 && !isThematicBreak(md, p, lineEnd))
845
+ listColumns.push(indent + marker);
846
+ if (marker > 0 && md.charCodeAt(p + marker) === HASH)
847
+ p += marker;
848
+ if (p < lineEnd && md.charCodeAt(p) === HASH) {
849
+ let h = p;
850
+ while (h < lineEnd && md.charCodeAt(h) === HASH)
851
+ h++;
852
+ const level = h - p;
853
+ if (level <= 6 && (h === lineEnd || isBlank(md.charCodeAt(h)))) {
854
+ ids.push(docHeadingId(headingText(md, h, lineEnd, context), seen));
855
+ paragraph = null;
856
+ continue;
857
+ }
858
+ }
859
+ // A setext underline under the open plain paragraph, at its depth.
860
+ const u = md.charCodeAt(p);
861
+ if ((u === 61 || u === 45) && paragraph !== null && paragraphPlain && depth === paragraphDepth && marker === 0) {
862
+ let r = p;
863
+ while (r < lineEnd && md.charCodeAt(r) === u)
864
+ r++;
865
+ while (r < lineEnd && isBlank(md.charCodeAt(r)))
866
+ r++;
867
+ if (r === lineEnd) {
868
+ ids.push(docHeadingId(paragraph.map(([a, b]) => headingText(md, a, b, context)).join(" "), seen));
869
+ paragraph = null;
870
+ continue;
871
+ }
872
+ }
873
+ if (isThematicBreak(md, p, lineEnd)) {
874
+ paragraph = null;
875
+ continue;
876
+ }
877
+ if (paragraph === null) {
878
+ paragraph = [[p, lineEnd]];
879
+ paragraphPlain = marker === 0;
880
+ paragraphDepth = depth;
881
+ }
882
+ else {
883
+ paragraph.push([p, lineEnd]);
884
+ if (marker > 0 || depth !== paragraphDepth)
885
+ paragraphPlain = false;
886
+ }
887
+ }
888
+ return ids;
889
+ }