@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,659 @@
1
+ import { closeSync, existsSync, openSync, readFileSync, readSync, readdirSync, statSync } from "node:fs";
2
+ import { join, resolve, sep } from "node:path";
3
+ import { MAX_DOC_PAGE_BYTES, PluginDocsPageSchema, PluginReferenceSchema, checkDocsDeclaration, docsFactsFrom, effectiveDocsPages, extractDocHeadings, isRenderableExternalHref, MAX_DOCS_TARGET_LENGTH, referencePageSlugs, requiredDocRoles, resolveDocsLink, resolveDocsPath, } from "@kardalum/api-schemas";
4
+ /** The most a manifest.json or reference.json may weigh. The door parses both
5
+ * synchronously on the event loop, so a schema-valid file of tens of
6
+ * megabytes would block it on every request that reads one. */
7
+ export const MAX_PACKAGE_JSON_BYTES = 1048576;
8
+ const IMAGE_EXTENSION = /\.(png|jpe?g|gif|webp)$/i;
9
+ /** Past this many links and images a page is refused rather than checked. */
10
+ const MAX_TARGETS_PER_PAGE = 2000;
11
+ const TAB = 9;
12
+ const NEWLINE = 10;
13
+ const SPACE = 32;
14
+ const BANG = 33;
15
+ const DOUBLE_QUOTE = 34;
16
+ const SINGLE_QUOTE = 39;
17
+ const PAREN_OPEN = 40;
18
+ const PAREN_CLOSE = 41;
19
+ const COLON = 58;
20
+ const ANGLE_OPEN = 60;
21
+ const ANGLE_CLOSE = 62;
22
+ const BRACKET_OPEN = 91;
23
+ const BACKSLASH = 92;
24
+ const BRACKET_CLOSE = 93;
25
+ const BACKTICK = 96;
26
+ const TILDE = 126;
27
+ function isSpace(code) {
28
+ return code === SPACE || (code >= TAB && code <= 13);
29
+ }
30
+ function skipSpace(text, from, end) {
31
+ let i = from;
32
+ while (i < end && isSpace(text.charCodeAt(i)))
33
+ i++;
34
+ return i;
35
+ }
36
+ function hasBacktick(text, from, end) {
37
+ for (let i = from; i < end; i++)
38
+ if (text.charCodeAt(i) === BACKTICK)
39
+ return true;
40
+ return false;
41
+ }
42
+ /** Records a target, or marks the page as holding too many and returns false. */
43
+ function collect(out, list, target) {
44
+ if (out.links.length + out.images.length >= MAX_TARGETS_PER_PAGE) {
45
+ out.tooMany = true;
46
+ return false;
47
+ }
48
+ list.push(target);
49
+ return true;
50
+ }
51
+ /** Where each run of backticks starts, by run length, so the scan can find a
52
+ * code span's closing run without searching the text again. `from` only
53
+ * ever grows across calls, so each list is walked once in total. */
54
+ class BacktickRuns {
55
+ starts = new Map();
56
+ cursor = new Map();
57
+ constructor(text) {
58
+ for (let i = 0; i < text.length; i++) {
59
+ if (text.charCodeAt(i) !== BACKTICK)
60
+ continue;
61
+ const start = i;
62
+ while (i + 1 < text.length && text.charCodeAt(i + 1) === BACKTICK)
63
+ i++;
64
+ const length = i - start + 1;
65
+ const list = this.starts.get(length);
66
+ if (list === undefined)
67
+ this.starts.set(length, [start]);
68
+ else
69
+ list.push(start);
70
+ }
71
+ }
72
+ /** The start of the first run of exactly `length` backticks at or after
73
+ * `from`, or -1. */
74
+ next(length, from) {
75
+ const list = this.starts.get(length);
76
+ if (list === undefined)
77
+ return -1;
78
+ let at = this.cursor.get(length) ?? 0;
79
+ while (at < list.length && list[at] < from)
80
+ at++;
81
+ this.cursor.set(length, at);
82
+ return at < list.length ? list[at] : -1;
83
+ }
84
+ }
85
+ /** The target that starts at `from`, up to but not including any title: an
86
+ * angle-bracket target, or a run without whitespace. With `inParens` (an
87
+ * inline link) the run's parentheses must balance, one level deep, and it
88
+ * stops at the ")" that closes the link. `end` is where the target stopped. */
89
+ function readTarget(text, from, end, inParens) {
90
+ if (from < end && text.charCodeAt(from) === ANGLE_OPEN) {
91
+ for (let i = from + 1; i < end; i++) {
92
+ const code = text.charCodeAt(i);
93
+ if (code === ANGLE_CLOSE)
94
+ return { target: text.slice(from + 1, i), end: i + 1 };
95
+ if (code === ANGLE_OPEN || code === NEWLINE)
96
+ return null;
97
+ }
98
+ return null;
99
+ }
100
+ let depth = 0;
101
+ let i = from;
102
+ for (; i < end; i++) {
103
+ const code = text.charCodeAt(i);
104
+ if (isSpace(code))
105
+ break;
106
+ if (code === BACKSLASH && i + 1 < end && !isSpace(text.charCodeAt(i + 1))) {
107
+ i++; // an escaped character is part of the target, whatever it is
108
+ }
109
+ else if (inParens && code === PAREN_OPEN) {
110
+ // A second level is refused at once: reading on to find where it
111
+ // closes is what would make a page of unfinished links quadratic.
112
+ if (depth === 1)
113
+ return null;
114
+ depth++;
115
+ }
116
+ else if (inParens && code === PAREN_CLOSE) {
117
+ if (depth === 0)
118
+ break;
119
+ depth--;
120
+ }
121
+ }
122
+ return depth === 0 ? { target: text.slice(from, i), end: i } : null;
123
+ }
124
+ /** The index after a title that opens at `from` ("...", '...' or (...)), or
125
+ * -1. A parenthesised title stops at a nested "(", so an unfinished one is
126
+ * not read to the end of the text once per link. */
127
+ function skipTitle(text, from, end) {
128
+ const open = text.charCodeAt(from);
129
+ if (open !== DOUBLE_QUOTE && open !== SINGLE_QUOTE && open !== PAREN_OPEN)
130
+ return -1;
131
+ const close = open === PAREN_OPEN ? PAREN_CLOSE : open;
132
+ for (let i = from + 1; i < end; i++) {
133
+ const code = text.charCodeAt(i);
134
+ if (code === BACKSLASH)
135
+ i++;
136
+ else if (code === close)
137
+ return i + 1;
138
+ else if (open === PAREN_OPEN && code === PAREN_OPEN)
139
+ return -1;
140
+ }
141
+ return -1;
142
+ }
143
+ /** What follows the "(" of an inline link: a target, an optional title, and
144
+ * the closing ")". `next` is the index after it. */
145
+ function readInlineTarget(text, from, end) {
146
+ const read = readTarget(text, skipSpace(text, from, end), end, true);
147
+ if (read === null)
148
+ return null;
149
+ let i = skipSpace(text, read.end, end);
150
+ if (i > read.end && i < end && text.charCodeAt(i) !== PAREN_CLOSE) {
151
+ const afterTitle = skipTitle(text, i, end);
152
+ if (afterTitle === -1)
153
+ return null;
154
+ i = skipSpace(text, afterTitle, end);
155
+ }
156
+ return i < end && text.charCodeAt(i) === PAREN_CLOSE ? { target: read.target, next: i + 1 } : null;
157
+ }
158
+ /** The target of a reference definition (`[label]: target "title"`) whose
159
+ * "[" is at `open`, or null when the line is not one. */
160
+ function readDefinition(text, open, lineEnd) {
161
+ let i = open + 1;
162
+ for (; i < lineEnd; i++) {
163
+ const code = text.charCodeAt(i);
164
+ if (code === BRACKET_CLOSE)
165
+ break;
166
+ if (code === BRACKET_OPEN)
167
+ return null;
168
+ if (code === BACKSLASH)
169
+ i++;
170
+ }
171
+ if (i >= lineEnd || i === open + 1 || text.charCodeAt(i + 1) !== COLON)
172
+ return null;
173
+ const read = readTarget(text, skipSpace(text, i + 2, lineEnd), lineEnd, false);
174
+ if (read === null || read.target === "")
175
+ return null;
176
+ let rest = skipSpace(text, read.end, lineEnd);
177
+ if (rest < lineEnd) {
178
+ if (rest === read.end)
179
+ return null;
180
+ const afterTitle = skipTitle(text, rest, lineEnd);
181
+ if (afterTitle === -1)
182
+ return null;
183
+ rest = skipSpace(text, afterTitle, lineEnd);
184
+ }
185
+ return rest >= lineEnd ? read.target : null;
186
+ }
187
+ /** Inline links and images in one paragraph, `text[start, end)`. A stack of
188
+ * open brackets pairs each "]" with its "[", so a linked image yields the
189
+ * image and then the link around it. */
190
+ function scanParagraph(text, start, end, backticks, out) {
191
+ const openImages = []; // one entry per open "[": whether "!" precedes it
192
+ let lastBang = -2;
193
+ let i = start;
194
+ while (i < end) {
195
+ const code = text.charCodeAt(i);
196
+ if (code === BACKSLASH) {
197
+ i += 2;
198
+ }
199
+ else if (code === BACKTICK) {
200
+ let runEnd = i + 1;
201
+ while (runEnd < end && text.charCodeAt(runEnd) === BACKTICK)
202
+ runEnd++;
203
+ const length = runEnd - i;
204
+ const close = backticks.next(length, runEnd);
205
+ i = close !== -1 && close + length <= end ? close + length : runEnd;
206
+ }
207
+ else if (code === BANG) {
208
+ lastBang = i++;
209
+ }
210
+ else if (code === BRACKET_OPEN) {
211
+ openImages.push(lastBang === i - 1);
212
+ i++;
213
+ }
214
+ else if (code === BRACKET_CLOSE) {
215
+ const image = openImages.pop();
216
+ i++;
217
+ if (image === undefined || i >= end || text.charCodeAt(i) !== PAREN_OPEN)
218
+ continue;
219
+ const read = readInlineTarget(text, i + 1, end);
220
+ if (read === null)
221
+ continue;
222
+ if (read.target !== "" && !collect(out, image ? out.images : out.links, read.target))
223
+ return;
224
+ i = read.next;
225
+ }
226
+ else {
227
+ i++;
228
+ }
229
+ }
230
+ }
231
+ /** Link and image targets in a markdown page, in one pass: fenced code and
232
+ * code spans are skipped, so a documented example of link syntax is not
233
+ * checked as a link. Every character is visited a bounded number of times,
234
+ * whatever the page holds. Raw HTML is not read: the renderer drops it. */
235
+ function targetsIn(text) {
236
+ const out = { links: [], images: [], tooMany: false };
237
+ const backticks = new BacktickRuns(text);
238
+ let fence = null;
239
+ let paragraphStart = -1;
240
+ const endParagraph = (end) => {
241
+ if (paragraphStart !== -1 && !out.tooMany)
242
+ scanParagraph(text, paragraphStart, end, backticks, out);
243
+ paragraphStart = -1;
244
+ };
245
+ let lineStart = 0;
246
+ while (lineStart < text.length && !out.tooMany) {
247
+ const newline = text.indexOf("\n", lineStart);
248
+ const lineEnd = newline === -1 ? text.length : newline;
249
+ let first = lineStart;
250
+ while (first < lineEnd && first - lineStart < 4 && text.charCodeAt(first) === SPACE)
251
+ first++;
252
+ const indented = first - lineStart > 3;
253
+ const lead = first < lineEnd ? text.charCodeAt(first) : -1;
254
+ let run = 0;
255
+ if (!indented && (lead === BACKTICK || lead === TILDE)) {
256
+ while (first + run < lineEnd && text.charCodeAt(first + run) === lead)
257
+ run++;
258
+ }
259
+ if (fence !== null) {
260
+ // A fence that never closes runs to the end of the page.
261
+ if (lead === fence.code && run >= fence.length && skipSpace(text, first + run, lineEnd) === lineEnd)
262
+ fence = null;
263
+ }
264
+ else if (run >= 3 && (lead === TILDE || !hasBacktick(text, first + run, lineEnd))) {
265
+ endParagraph(lineStart);
266
+ fence = { code: lead, length: run };
267
+ }
268
+ else if (skipSpace(text, first, lineEnd) === lineEnd) {
269
+ endParagraph(lineStart);
270
+ }
271
+ else {
272
+ const definition = !indented && lead === BRACKET_OPEN ? readDefinition(text, first, lineEnd) : null;
273
+ if (definition !== null) {
274
+ endParagraph(lineStart);
275
+ if (!out.tooMany)
276
+ collect(out, out.links, definition);
277
+ }
278
+ else if (paragraphStart === -1) {
279
+ paragraphStart = lineStart;
280
+ }
281
+ }
282
+ lineStart = lineEnd + 1;
283
+ }
284
+ endParagraph(text.length);
285
+ return out;
286
+ }
287
+ /** A target that names somewhere else: a URL with a scheme, or a
288
+ * protocol-relative one. One letter before the colon is a drive, not a
289
+ * scheme. */
290
+ function isExternal(target) {
291
+ return /^[a-z][a-z0-9+.-]+:/i.test(target) || target.startsWith("//");
292
+ }
293
+ /** Posix package-relative paths of every file under `dir`, and of every
294
+ * directory named like a page or an image (it is in the way of one). */
295
+ function entriesUnder(dir, base) {
296
+ if (!isDirectory(dir))
297
+ return [];
298
+ return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
299
+ const path = `${base}/${entry.name}`;
300
+ if (!entry.isDirectory())
301
+ return [path];
302
+ const inside = entriesUnder(join(dir, entry.name), path);
303
+ return entry.name.endsWith(".md") || IMAGE_EXTENSION.test(entry.name) ? [path, ...inside] : inside;
304
+ });
305
+ }
306
+ /** A posix package-relative path as a native filesystem path. This is the
307
+ * one place such a path becomes a real one, so it is also where leaving the
308
+ * package is made impossible: a path that would is a defect in the checks
309
+ * before it, not a violation to report, and throws. */
310
+ export function packageFilePath(dir, posixPath) {
311
+ const root = resolve(dir);
312
+ const segments = posixPath.split("/");
313
+ const full = resolve(root, ...segments);
314
+ const inside = full.startsWith(root.endsWith(sep) ? root : root + sep);
315
+ if (posixPath.includes("\\") || posixPath.includes("\0") || posixPath.includes(":") || segments.some((s) => s === "" || s === "..") || !inside) {
316
+ throw new Error(`docs contract: "${posixPath}" is outside the package`);
317
+ }
318
+ return full;
319
+ }
320
+ /** Whether `path` is a regular file. Never throws: the doors ask this of a
321
+ * package nobody has vetted, where a name that should be a file can be a
322
+ * directory, and the other way round. */
323
+ export function isFile(path) {
324
+ try {
325
+ return statSync(path, { throwIfNoEntry: false })?.isFile() === true;
326
+ }
327
+ catch {
328
+ return false;
329
+ }
330
+ }
331
+ function isDirectory(path) {
332
+ try {
333
+ return statSync(path, { throwIfNoEntry: false })?.isDirectory() === true;
334
+ }
335
+ catch {
336
+ return false;
337
+ }
338
+ }
339
+ /** A link or image target, quoted and cut to its first 80 characters, so one
340
+ * violation stays a line however long the author's text was. */
341
+ function quotedTarget(target) {
342
+ return target.length > 80 ? `${target.slice(0, 80)}...` : target;
343
+ }
344
+ /** The longest one reason may be, in characters, before it is cut. */
345
+ const MAX_REASON_LENGTH = 300;
346
+ /** The most violations a door reports for one package. */
347
+ export const MAX_VIOLATIONS = 50;
348
+ /** At most MAX_VIOLATIONS lines: when there are more, the last line says how
349
+ * many are not shown, so one refusal stays readable whatever the package
350
+ * holds. */
351
+ export function capViolations(reasons) {
352
+ // A reason can quote an unbounded path or schema message, so each is cut too.
353
+ const cut = reasons.map((reason) => (reason.length > MAX_REASON_LENGTH ? `${reason.slice(0, MAX_REASON_LENGTH)}...` : reason));
354
+ if (cut.length <= MAX_VIOLATIONS)
355
+ return cut;
356
+ const shown = cut.slice(0, MAX_VIOLATIONS - 1);
357
+ return [...shown, `and ${cut.length - shown.length} more violations`];
358
+ }
359
+ /** At most the first MAX_DOC_PAGE_BYTES of a file, as text. */
360
+ function readHead(file, size) {
361
+ const buffer = Buffer.alloc(Math.min(size, MAX_DOC_PAGE_BYTES));
362
+ const fd = openSync(file, "r");
363
+ try {
364
+ let length = 0;
365
+ while (length < buffer.length) {
366
+ const read = readSync(fd, buffer, length, buffer.length - length, length);
367
+ if (read === 0)
368
+ break;
369
+ length += read;
370
+ }
371
+ return buffer.toString("utf8", 0, length);
372
+ }
373
+ finally {
374
+ closeSync(fd);
375
+ }
376
+ }
377
+ /** Each declared page, read once per call. The README is never refused for
378
+ * its size, but like every page only its first MAX_DOC_PAGE_BYTES are
379
+ * scanned (the marketplace keeps no more of it than that). */
380
+ function scanPages(dir, pages) {
381
+ return pages.map((page) => {
382
+ const none = { page, size: 0, links: [], images: [], tooMany: false, headings: new Set() };
383
+ const file = packageFilePath(dir, page.path);
384
+ if (!isFile(file))
385
+ return { ...none, status: "missing" };
386
+ const size = statSync(file).size;
387
+ if (page.path !== "README.md" && size > MAX_DOC_PAGE_BYTES)
388
+ return { ...none, status: "oversize", size };
389
+ const markdown = readHead(file, size);
390
+ if (markdown.trim().length === 0)
391
+ return { ...none, status: "empty", size };
392
+ return { page, status: "ok", size, ...targetsIn(markdown), headings: new Set(extractDocHeadings(markdown, page.path)) };
393
+ });
394
+ }
395
+ /** What an image target is: somewhere else, not a file in the package, a
396
+ * file of a type the docs do not show, or an image the page shows. */
397
+ function imageTarget(dir, pagePath, target) {
398
+ if (isExternal(target))
399
+ return { kind: "external" }; // the renderer refuses remote images; not this check's job
400
+ if (target.length > MAX_DOCS_TARGET_LENGTH)
401
+ return { kind: "missing" };
402
+ const resolved = resolveDocsPath(pagePath, target);
403
+ if (resolved === null) {
404
+ // Reported as it always was: a target that names a directory or the page's
405
+ // own folder (a trailing slash, "", ".") is not an image, rather than absent.
406
+ const path = target.split("#")[0].split("?")[0];
407
+ let end = path.length;
408
+ while (end > 0 && path.charCodeAt(end - 1) === 47)
409
+ end--;
410
+ const naming = end < path.length && resolveDocsPath(pagePath, path.slice(0, end)) !== null;
411
+ return naming || ["", ".", "./"].includes(path) ? { kind: "not-an-image" } : { kind: "missing" };
412
+ }
413
+ if (!IMAGE_EXTENSION.test(resolved))
414
+ return { kind: "not-an-image" };
415
+ try {
416
+ return isFile(packageFilePath(dir, resolved)) ? { kind: "shown", path: resolved } : { kind: "missing" };
417
+ }
418
+ catch {
419
+ // A target is the page author's text: whatever it is, it is refused as a
420
+ // violation and never raised to the door as an exception.
421
+ return { kind: "missing" };
422
+ }
423
+ }
424
+ /** Whether a target holds a percent-encoded byte (`%20`). The door reads a
425
+ * path exactly as written and never decodes it, so such a target names a
426
+ * file whose name holds a literal `%`, which is almost never what was meant. */
427
+ function hasPercentEscape(target) {
428
+ for (let i = target.indexOf("%"); i !== -1 && i + 2 < target.length; i = target.indexOf("%", i + 1)) {
429
+ if (/^[0-9a-f]{2}$/i.test(target.slice(i + 1, i + 3)))
430
+ return true;
431
+ }
432
+ return false;
433
+ }
434
+ const PERCENT_HINT = "; write the path as written, or in angle brackets: <docs/my image.png>";
435
+ /** The heading id a `#hash` names. An author may write a heading's id with
436
+ * or without its `doc-` prefix (the admin's renderer finds either), and a
437
+ * hash in a URL may be percent-encoded. */
438
+ function decodedHash(hash) {
439
+ try {
440
+ return decodeURIComponent(hash);
441
+ }
442
+ catch {
443
+ return hash; // not valid percent-encoding: read as written
444
+ }
445
+ }
446
+ function docAnchorId(hash) {
447
+ const raw = decodedHash(hash);
448
+ return raw.startsWith("doc-") ? raw : `doc-${raw}`;
449
+ }
450
+ /** Whether the page has the heading a hash names, by the renderer's own
451
+ * rule (headingIdFor in render-docs-html.ts): `#doc-x` names the id doc-x
452
+ * exactly, never doc-doc-x, and `#x` names doc-x. */
453
+ function hasAnchor(headings, hash) {
454
+ return headings.has(docAnchorId(hash));
455
+ }
456
+ /** What one link target of a scanned page costs it: a refusal, a warning,
457
+ * or nothing. */
458
+ function linkFinding(scan, target, context) {
459
+ const { page } = scan;
460
+ const link = resolveDocsLink(page.path, target, context.declared, context.reference);
461
+ if (link.kind === "external") {
462
+ if (isRenderableExternalHref(target))
463
+ return null;
464
+ return {
465
+ kind: "warning",
466
+ text: `docs: "${page.path}" links to "${quotedTarget(target)}", which never renders as a link (only relative links to declared pages and https links do)`,
467
+ };
468
+ }
469
+ if (link.kind === "invalid") {
470
+ const hint = hasPercentEscape(target) ? PERCENT_HINT : "";
471
+ return {
472
+ kind: "reason",
473
+ text: link.reason === "reference"
474
+ ? `${page.path} links to "${quotedTarget(target)}", a reference page this plugin does not generate`
475
+ : `${page.path} links to "${quotedTarget(target)}", which is not a declared docs page${hint}`,
476
+ };
477
+ }
478
+ // An anchor must name a heading of the page it points into: the contract
479
+ // renders only links that resolve (spec D6). A reference page's headings
480
+ // are generated, so its anchors are not checked here.
481
+ if (link.kind === "reference" || link.hash === undefined || link.hash === "")
482
+ return null;
483
+ const into = link.kind === "anchor" ? scan : context.scanByPath.get(link.path);
484
+ if (into === undefined || into.status !== "ok" || hasAnchor(into.headings, link.hash))
485
+ return null;
486
+ return {
487
+ kind: "reason",
488
+ text: `docs: "${page.path}" links to "${quotedTarget(target)}" but that page has no heading with id "${docAnchorId(link.hash)}"`,
489
+ };
490
+ }
491
+ export function checkDocsContract(dir, input) {
492
+ const reasons = [];
493
+ const warnings = [];
494
+ const declared = new Set(input.pages.map((page) => page.path));
495
+ const reference = new Set(input.referenceSlugs);
496
+ const shownImages = new Set();
497
+ for (const required of requiredDocRoles(input.facts)) {
498
+ if (!input.pages.some((page) => page.role === required.role)) {
499
+ reasons.push(required.role === "overview"
500
+ ? 'an "overview" docs page is required for every plugin'
501
+ : `a "${required.role}" docs page is required because this plugin declares ${required.because}`);
502
+ }
503
+ }
504
+ const scans = scanPages(dir, input.pages);
505
+ const scanByPath = new Map(scans.map((scan) => [scan.page.path, scan]));
506
+ for (const scan of scans) {
507
+ const { page } = scan;
508
+ // The README's own absence or emptiness is the README check's to report.
509
+ if (scan.status === "missing") {
510
+ if (page.path !== "README.md")
511
+ reasons.push(`docs page "${page.path}" is declared but missing from the package`);
512
+ continue;
513
+ }
514
+ if (scan.status === "oversize") {
515
+ reasons.push(`docs page "${page.path}" is ${scan.size} bytes, over the ${MAX_DOC_PAGE_BYTES} byte limit`);
516
+ continue;
517
+ }
518
+ if (scan.status === "empty") {
519
+ if (page.path !== "README.md")
520
+ reasons.push(`docs page "${page.path}" is empty`);
521
+ continue;
522
+ }
523
+ if (scan.tooMany)
524
+ reasons.push(`${page.path} has more than ${MAX_TARGETS_PER_PAGE} links and images`);
525
+ for (const target of scan.links) {
526
+ const finding = linkFinding(scan, target, { declared, reference, scanByPath });
527
+ if (finding?.kind === "reason")
528
+ reasons.push(finding.text);
529
+ else if (finding?.kind === "warning")
530
+ warnings.push(finding.text);
531
+ }
532
+ for (const target of scan.images) {
533
+ const image = imageTarget(dir, page.path, target);
534
+ if (image.kind === "shown")
535
+ shownImages.add(image.path);
536
+ else if (image.kind === "missing") {
537
+ const hint = hasPercentEscape(target) ? PERCENT_HINT : "";
538
+ reasons.push(`${page.path} shows the image "${quotedTarget(target)}", which is not in the package${hint}`);
539
+ }
540
+ else if (image.kind === "not-an-image") {
541
+ reasons.push(`${page.path} shows "${quotedTarget(target)}", which is not a PNG, JPEG, GIF or WebP image in the package`);
542
+ }
543
+ }
544
+ }
545
+ const docsDir = join(dir, "docs");
546
+ if (existsSync(docsDir) && !isDirectory(docsDir))
547
+ reasons.push("docs is not a directory");
548
+ for (const entry of entriesUnder(docsDir, "docs").sort()) {
549
+ if (declared.has(entry) || shownImages.has(entry))
550
+ continue;
551
+ reasons.push(entry.endsWith(".md")
552
+ ? `${entry} is not declared in the manifest's docs: declare it or remove it`
553
+ : `${entry} is not a docs page or an image a page shows: remove it`);
554
+ }
555
+ return { reasons, warnings };
556
+ }
557
+ /** The files a package ships for its docs: each declared page that exists,
558
+ * then the images those pages show, deduplicated, as posix package-relative
559
+ * paths. Every one has been through `packageFilePath`, so none leaves the package. */
560
+ export function docsFilesToShip(dir, pages) {
561
+ const scans = scanPages(dir, pages);
562
+ const files = scans.filter((scan) => scan.status !== "missing").map((scan) => scan.page.path);
563
+ for (const scan of scans) {
564
+ for (const target of scan.images) {
565
+ const image = imageTarget(dir, scan.page.path, target);
566
+ if (image.kind === "shown")
567
+ files.push(image.path);
568
+ }
569
+ }
570
+ return [...new Set(files)];
571
+ }
572
+ /** How many images across the declared pages name somewhere else (the door's
573
+ * own `isExternal` test). No docs surface shows a remote image, so an author
574
+ * is told. It reads the same single-pass scan the other checks read. */
575
+ export function countRemoteImages(dir, pages) {
576
+ let count = 0;
577
+ for (const scan of scanPages(dir, pages)) {
578
+ for (const target of scan.images)
579
+ if (isExternal(target))
580
+ count++;
581
+ }
582
+ return count;
583
+ }
584
+ /** The first three schema issues as one clause. */
585
+ function issueText(issues) {
586
+ return issues.slice(0, 3).map((issue) => `${issue.path.map(String).join(".")}: ${issue.message}`).join(", ");
587
+ }
588
+ /** Whether the file is past MAX_PACKAGE_JSON_BYTES, by its size alone. */
589
+ function oversize(path) {
590
+ try {
591
+ return statSync(path).size > MAX_PACKAGE_JSON_BYTES;
592
+ }
593
+ catch {
594
+ return false;
595
+ }
596
+ }
597
+ /** The door's inputs, from a built package. A package with no manifest.json
598
+ * is not this function's to refuse: every caller checks for it itself. */
599
+ export function readDocsContractInput(dir) {
600
+ const reasons = [];
601
+ let manifest = {};
602
+ const manifestPath = join(dir, "manifest.json");
603
+ if (oversize(manifestPath)) {
604
+ reasons.push(`manifest.json is larger than ${MAX_PACKAGE_JSON_BYTES} bytes`);
605
+ }
606
+ else
607
+ try {
608
+ const parsed = JSON.parse(readFileSync(manifestPath, "utf8"));
609
+ if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed))
610
+ manifest = parsed;
611
+ else
612
+ reasons.push("manifest.json is not a JSON object");
613
+ }
614
+ catch {
615
+ reasons.push("manifest.json is missing or not valid JSON");
616
+ }
617
+ let pages = [];
618
+ if (manifest.docs === undefined) {
619
+ pages = effectiveDocsPages(undefined, typeof manifest.name === "string" ? manifest.name : "Overview");
620
+ }
621
+ else {
622
+ const parsed = PluginDocsPageSchema.array().safeParse(manifest.docs);
623
+ if (!parsed.success) {
624
+ reasons.push(`manifest.json's docs is not a valid list of pages: ${issueText(parsed.error.issues)}`);
625
+ }
626
+ else {
627
+ pages = parsed.data;
628
+ for (const issue of checkDocsDeclaration(pages))
629
+ reasons.push(`manifest.json's docs: ${issue.message}`);
630
+ }
631
+ }
632
+ let referenceSlugs = [];
633
+ let reference = null;
634
+ const referencePath = join(dir, "reference.json");
635
+ if (!existsSync(referencePath)) {
636
+ reasons.push("reference.json is missing: rebuild the package with a current kardalum plugin");
637
+ }
638
+ else if (oversize(referencePath)) {
639
+ reasons.push(`reference.json is larger than ${MAX_PACKAGE_JSON_BYTES} bytes`);
640
+ }
641
+ else {
642
+ try {
643
+ const parsed = PluginReferenceSchema.safeParse(JSON.parse(readFileSync(referencePath, "utf8")));
644
+ if (parsed.success) {
645
+ reference = parsed.data;
646
+ referenceSlugs = referencePageSlugs(parsed.data);
647
+ }
648
+ else
649
+ reasons.push(`reference.json is not valid: ${issueText(parsed.error.issues)}`);
650
+ }
651
+ catch {
652
+ reasons.push("reference.json is not valid JSON");
653
+ }
654
+ }
655
+ if (reasons.length > 0 || reference === null)
656
+ return { ok: false, reasons };
657
+ // `reference` is handed back so a caller that wants it need not parse the file again.
658
+ return { ok: true, input: { pages, facts: docsFactsFrom(manifest), referenceSlugs }, reference };
659
+ }
@@ -0,0 +1,19 @@
1
+ import type { SignatureEnvelope, TrustedKey, VerifyResult } from "./types.js";
2
+ export declare function deriveKeyId(publicKeyBase64: string): string;
3
+ export declare function generateSigningKeyPair(): {
4
+ privateKey: string;
5
+ publicKey: string;
6
+ keyId: string;
7
+ };
8
+ /** Deterministic serialization. Deliberately NOT full JCS — we own both
9
+ * ends, and a fixed-order literal is the entire requirement. */
10
+ export declare function canonicalizeEnvelope(envelope: SignatureEnvelope): Buffer;
11
+ export declare function signEnvelope(envelope: SignatureEnvelope, privateKeyBase64: string): string;
12
+ /**
13
+ * Check order is deliberate and produces better diagnostics than the
14
+ * reverse: authenticate the envelope FIRST (bad-signature = forged or
15
+ * corrupt), then compare it to the artifact we actually have
16
+ * (hash-mismatch = authentic envelope, tampered bytes — the flipped-byte
17
+ * case). Never throws.
18
+ */
19
+ export declare function verifyEnvelope(sidecar: unknown, tarballSha256: string, trustedKeys: TrustedKey[]): VerifyResult;