@kardalum/plugin-sdk 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (274) hide show
  1. package/CHANGELOG.md +105 -0
  2. package/README.md +4 -3
  3. package/dist/admin-section-registry.d.ts +14 -5
  4. package/dist/admin-section-registry.js +14 -4
  5. package/dist/assets/asset-picker.d.ts +11 -0
  6. package/dist/assets/asset-picker.js +109 -0
  7. package/dist/assets/asset-tree.d.ts +30 -0
  8. package/dist/assets/asset-tree.js +150 -0
  9. package/dist/built-in-editor-ids.d.ts +1 -0
  10. package/dist/built-in-editor-ids.js +20 -0
  11. package/dist/built-in-settings-schemas.d.ts +2 -0
  12. package/dist/built-in-settings-schemas.js +27 -0
  13. package/dist/built-in-value-schemas.js +3 -0
  14. package/dist/built-ins.js +10 -1
  15. package/dist/capabilities.js +5 -3
  16. package/dist/datatype-validation.js +18 -4
  17. package/dist/datatypes-entry.d.ts +1 -0
  18. package/dist/datatypes-entry.js +1 -0
  19. package/dist/entitlement-entry.d.ts +3 -2
  20. package/dist/entitlement-entry.js +13 -1
  21. package/dist/entitlement-gate.d.ts +18 -0
  22. package/dist/entitlement-gate.js +95 -21
  23. package/dist/entitlement-plan.d.ts +21 -0
  24. package/dist/entitlement-plan.js +26 -0
  25. package/dist/entitlement-types.d.ts +21 -4
  26. package/dist/entitlement.d.ts +29 -1
  27. package/dist/entitlement.js +39 -0
  28. package/dist/grid-arrow-step.d.ts +7 -0
  29. package/dist/grid-arrow-step.js +20 -0
  30. package/dist/host-entry.d.ts +1 -1
  31. package/dist/host-entry.js +1 -1
  32. package/dist/index.d.ts +8 -3
  33. package/dist/index.js +13 -18
  34. package/dist/license-verdict-keys.d.ts +4 -3
  35. package/dist/license-verdict-keys.js +4 -7
  36. package/dist/manifest-entry.d.ts +6 -2
  37. package/dist/manifest-entry.js +5 -1
  38. package/dist/manifest-schema.d.ts +56 -63
  39. package/dist/manifest-schema.js +103 -249
  40. package/dist/manifest.d.ts +61 -73
  41. package/dist/manifest.js +13 -36
  42. package/dist/media/media-picker.js +32 -32
  43. package/dist/notify.d.ts +17 -0
  44. package/dist/notify.js +17 -0
  45. package/dist/plugin-screen-context.d.ts +11 -1
  46. package/dist/richtext/block-panel.js +19 -20
  47. package/dist/richtext/extensions.js +10 -1
  48. package/dist/richtext/insert-menu.js +1 -1
  49. package/dist/richtext/kardalum-block.js +17 -17
  50. package/dist/richtext/style-listbox.js +4 -4
  51. package/dist/richtext-html-entry.d.ts +35 -0
  52. package/dist/richtext-html-entry.js +73 -0
  53. package/dist/structured-storage-types.d.ts +11 -0
  54. package/dist/tailwind.js +10 -3
  55. package/dist/tokens/tailwind-theme.css +176 -0
  56. package/dist/tokens/tokens.css +2 -0
  57. package/dist/tokens/tokens.json +4 -2
  58. package/dist/type-equality.d.ts +2 -0
  59. package/dist/type-equality.js +1 -0
  60. package/dist/vendor-check.d.ts +39 -0
  61. package/dist/vendor-check.js +79 -0
  62. package/dist/vendor-entry.d.ts +3 -0
  63. package/dist/vendor-entry.js +9 -0
  64. package/dist/vendor-service.d.ts +20 -0
  65. package/dist/vendor-service.js +20 -0
  66. package/dist/views/asset-view.d.ts +6 -0
  67. package/dist/views/asset-view.js +55 -0
  68. package/dist/views/content-list-settings-view.js +1 -1
  69. package/dist/views/content-list-view.js +1 -1
  70. package/dist/views/html-code-editor.js +0 -1
  71. package/dist/views/html-view.js +1 -1
  72. package/dist/views/image-view.js +1 -1
  73. package/dist/views/rich-text-view.js +30 -30
  74. package/node_modules/@kardalum/api-schemas/README.md +1 -1
  75. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +90 -0
  76. package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +43 -10
  77. package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.d.ts +21 -0
  78. package/node_modules/@kardalum/api-schemas/dist/asset-field.schema.js +42 -0
  79. package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +23 -1
  80. package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +60 -18
  81. package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +204 -0
  82. package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +134 -0
  83. package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.d.ts +36 -0
  84. package/node_modules/@kardalum/api-schemas/dist/checkout-shown.schema.js +46 -0
  85. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +12 -0
  86. package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +22 -6
  87. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +2 -2
  88. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +4 -0
  89. package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +3 -0
  90. package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +2 -1
  91. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +52 -10
  92. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +33 -14
  93. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +50 -0
  94. package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +25 -5
  95. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +1 -0
  96. package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +3 -0
  97. package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.d.ts +11 -0
  98. package/node_modules/@kardalum/api-schemas/dist/data-type-cursor.js +28 -0
  99. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +42 -2
  100. package/node_modules/@kardalum/api-schemas/dist/home.schema.d.ts +130 -0
  101. package/node_modules/@kardalum/api-schemas/dist/home.schema.js +87 -0
  102. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +73 -31
  103. package/node_modules/@kardalum/api-schemas/dist/index.js +47 -17
  104. package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.d.ts +4 -0
  105. package/node_modules/@kardalum/api-schemas/dist/install-warnings.schema.js +8 -0
  106. package/node_modules/@kardalum/api-schemas/dist/issue-list.d.ts +6 -0
  107. package/node_modules/@kardalum/api-schemas/dist/issue-list.js +6 -0
  108. package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.d.ts +7 -0
  109. package/node_modules/@kardalum/api-schemas/dist/kardalum-latest.schema.js +9 -0
  110. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +216 -63
  111. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +117 -5
  112. package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +17 -0
  113. package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +16 -0
  114. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +26 -0
  115. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +6 -0
  116. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +10 -0
  117. package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +4 -4
  118. package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +93 -0
  119. package/node_modules/@kardalum/api-schemas/dist/news.schema.js +86 -0
  120. package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +13 -0
  121. package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +410 -0
  122. package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +193 -0
  123. package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +86 -0
  124. package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +92 -0
  125. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +6 -2
  126. package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +8 -6
  127. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +8 -18
  128. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +7 -0
  129. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +3 -19
  130. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +13 -15
  131. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +17 -7
  132. package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +18 -8
  133. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +1 -1
  134. package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +97 -85
  135. package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +35 -68
  136. package/node_modules/@kardalum/api-schemas/dist/plugin-labels.d.ts +60 -0
  137. package/node_modules/@kardalum/api-schemas/dist/plugin-labels.js +116 -0
  138. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +9 -2
  139. package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +22 -7
  140. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +240 -6
  141. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +164 -32
  142. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +4 -3
  143. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +1 -1
  144. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +14 -0
  145. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +37 -1
  146. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.d.ts +64 -0
  147. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-fields.js +134 -0
  148. package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.d.ts +19 -0
  149. package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +33 -0
  150. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +2 -0
  151. package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +4 -0
  152. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.d.ts +83 -0
  153. package/node_modules/@kardalum/api-schemas/dist/plugin-template-payload.js +152 -0
  154. package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.d.ts +13 -0
  155. package/node_modules/@kardalum/api-schemas/dist/plugin-vocabulary.js +15 -0
  156. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +5 -0
  157. package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +35 -23
  158. package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.d.ts +83 -0
  159. package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +73 -0
  160. package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +11 -0
  161. package/node_modules/@kardalum/api-schemas/dist/role.schema.js +7 -0
  162. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +11 -2
  163. package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +21 -3
  164. package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +126 -0
  165. package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.js +70 -0
  166. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +6 -6
  167. package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +58 -25
  168. package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +194 -48
  169. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +18 -6
  170. package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +14 -0
  171. package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +2 -2
  172. package/node_modules/@kardalum/api-schemas/dist/strict-url.d.ts +12 -0
  173. package/node_modules/@kardalum/api-schemas/dist/strict-url.js +31 -0
  174. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +115 -1
  175. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +65 -10
  176. package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +37 -2
  177. package/node_modules/@kardalum/api-schemas/dist/template.schema.js +34 -8
  178. package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.d.ts +4 -0
  179. package/node_modules/@kardalum/api-schemas/dist/trash-cursor.schema.js +29 -0
  180. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +16 -0
  181. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +8 -0
  182. package/node_modules/@kardalum/api-schemas/dist/uuid.schema.d.ts +2 -0
  183. package/node_modules/@kardalum/api-schemas/dist/uuid.schema.js +4 -0
  184. package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +88 -0
  185. package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +100 -0
  186. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.d.ts +32 -0
  187. package/node_modules/@kardalum/api-schemas/dist/whoami-api.schema.js +27 -0
  188. package/node_modules/@kardalum/api-schemas/package.json +2 -2
  189. package/node_modules/@kardalum/design-tokens/README.md +1 -1
  190. package/node_modules/@kardalum/design-tokens/dist/build-theme-css.d.ts +16 -0
  191. package/node_modules/@kardalum/design-tokens/dist/build-theme-css.js +76 -0
  192. package/node_modules/@kardalum/design-tokens/dist/generate.js +4 -1
  193. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +176 -0
  194. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +2 -1
  195. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
  196. package/node_modules/@kardalum/design-tokens/dist/tokens.css +2 -0
  197. package/node_modules/@kardalum/design-tokens/dist/tokens.js +4 -0
  198. package/node_modules/@kardalum/design-tokens/dist/tokens.json +4 -2
  199. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +2 -0
  200. package/node_modules/@kardalum/design-tokens/package.json +6 -3
  201. package/node_modules/@kardalum/plugin-package/README.md +5 -2
  202. package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +6 -21
  203. package/node_modules/@kardalum/plugin-package/dist/build-reference.js +13 -8
  204. package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +4 -4
  205. package/node_modules/@kardalum/plugin-package/dist/capabilities.js +59 -16
  206. package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +4 -0
  207. package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +25 -0
  208. package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.d.ts +25 -0
  209. package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.js +203 -0
  210. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.d.ts +3 -0
  211. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +73 -0
  212. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.d.ts +8 -0
  213. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +77 -0
  214. package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.d.ts +1 -0
  215. package/node_modules/@kardalum/plugin-package/dist/delivery/icon-names.generated.js +2052 -0
  216. package/node_modules/@kardalum/plugin-package/dist/delivery/icons.d.ts +2 -0
  217. package/node_modules/@kardalum/plugin-package/dist/delivery/icons.js +51 -0
  218. package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +8 -0
  219. package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +7 -0
  220. package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.d.ts +17 -0
  221. package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +119 -0
  222. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +14 -0
  223. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +21 -0
  224. package/node_modules/@kardalum/plugin-package/dist/delivery/locales.d.ts +5 -0
  225. package/node_modules/@kardalum/plugin-package/dist/delivery/locales.js +148 -0
  226. package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.d.ts +5 -0
  227. package/node_modules/@kardalum/plugin-package/dist/delivery/package-files.js +76 -0
  228. package/node_modules/@kardalum/plugin-package/dist/delivery/registry.d.ts +22 -0
  229. package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +137 -0
  230. package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.d.ts +3 -0
  231. package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +90 -0
  232. package/node_modules/@kardalum/plugin-package/dist/delivery/support.d.ts +24 -0
  233. package/node_modules/@kardalum/plugin-package/dist/delivery/support.js +55 -0
  234. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +7 -0
  235. package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +215 -0
  236. package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +53 -0
  237. package/node_modules/@kardalum/plugin-package/dist/delivery/types.js +1 -0
  238. package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +3 -2
  239. package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +4 -2
  240. package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +92 -3
  241. package/node_modules/@kardalum/plugin-package/dist/extract.js +251 -41
  242. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +13 -4
  243. package/node_modules/@kardalum/plugin-package/dist/index.js +10 -3
  244. package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +56 -19
  245. package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +119 -25
  246. package/node_modules/@kardalum/plugin-package/dist/manifest-entry.d.ts +5 -0
  247. package/node_modules/@kardalum/plugin-package/dist/manifest-entry.js +20 -0
  248. package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +1 -0
  249. package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +1 -0
  250. package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +21 -3
  251. package/node_modules/@kardalum/plugin-package/dist/sample-content.js +37 -9
  252. package/node_modules/@kardalum/plugin-package/dist/shipped-files.d.ts +39 -0
  253. package/node_modules/@kardalum/plugin-package/dist/shipped-files.js +133 -0
  254. package/node_modules/@kardalum/plugin-package/dist/shipped-locales.d.ts +7 -0
  255. package/node_modules/@kardalum/plugin-package/dist/shipped-locales.js +27 -0
  256. package/node_modules/@kardalum/plugin-package/dist/vendor-token.d.ts +24 -0
  257. package/node_modules/@kardalum/plugin-package/dist/vendor-token.js +118 -0
  258. package/node_modules/@kardalum/plugin-package/package.json +4 -2
  259. package/node_modules/@kardalum/ui/README.md +1 -1
  260. package/node_modules/@kardalum/ui/dist/components/button.js +1 -1
  261. package/node_modules/@kardalum/ui/dist/components/checkbox.js +1 -1
  262. package/node_modules/@kardalum/ui/dist/components/dialog.js +5 -2
  263. package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +3 -3
  264. package/node_modules/@kardalum/ui/dist/components/input.js +1 -1
  265. package/node_modules/@kardalum/ui/dist/components/popover-panel.d.ts +4 -0
  266. package/node_modules/@kardalum/ui/dist/components/popover-panel.js +13 -0
  267. package/node_modules/@kardalum/ui/dist/components/sheet.js +5 -4
  268. package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
  269. package/node_modules/@kardalum/ui/dist/components/tab-strip.js +1 -1
  270. package/node_modules/@kardalum/ui/dist/components/toast.js +1 -1
  271. package/node_modules/@kardalum/ui/dist/index.d.ts +1 -0
  272. package/node_modules/@kardalum/ui/dist/index.js +1 -0
  273. package/node_modules/@kardalum/ui/package.json +1 -1
  274. package/package.json +19 -6
package/CHANGELOG.md CHANGED
@@ -8,6 +8,111 @@ Subpaths are noted per entry. `.` is the package index; `./manifest` is the
8
8
  server-safe manifest contract subpath, which pulls in no React and no
9
9
  `@kardalum/ui`.
10
10
 
11
+ ## 0.18.0
12
+
13
+ Plugins can be sold on plans with a term they can read, and a plugin can call its
14
+ author's own server with a short-lived licence token. The release also adds a
15
+ vendor-side licence check, rich text from HTML for the server, notifications
16
+ from a plugin, and the Tailwind 4 theme.
17
+
18
+ ### Added
19
+
20
+ - `./vendor`: a new subpath for the author's own server (any Node server).
21
+ `createVendorLicenceCheck({ pluginId, origin })` checks the licence token
22
+ the CMS sends with a call and answers `check(authorization)` or throws
23
+ `VendorLicenceError` (status 401 or 402) from `requireLive(authorization)`.
24
+ It also exports `VENDOR_AUTH_SCHEME`, `isVendorLicenceError`, the
25
+ `VendorLicence*` types and `LICENSE_VERDICT_PUBLIC_KEYS`.
26
+ - `./manifest` and `.`: the manifest may declare `vendorService`, the origin of
27
+ the author's server. A plugin that declares it gets
28
+ `context.vendorService.fetch(path, init?)` in its routes and hooks, which
29
+ calls that origin with a 5-minute licence token and never sends the key.
30
+ It throws `VendorServiceError` (check it with `isVendorServiceError`) with
31
+ one of the codes in `VENDOR_SERVICE_ERROR_CODES`. Declaring it is declaring
32
+ outbound network use.
33
+ - `./manifest` and `.`: the manifest may declare
34
+ `contributions.notifications: true`, which derives the
35
+ `admin.notifications` capability. The plugin then gets `context.notify(input)`
36
+ in its routes and hooks, which answers how many people it reached and
37
+ throws `NotificationRefusedError` (check it with
38
+ `isNotificationRefusedError`) with one of `NOTIFICATION_REFUSAL_REASONS`.
39
+ Those three come from `./manifest`; `.` carries their types only.
40
+ - `./richtext-html`: `richtextFromHtml(html)` turns a rich text value given as
41
+ HTML into the editor's stored JSON, using the editor's own extensions. It
42
+ refuses (`RichtextHtmlError`, check it with `isRichtextHtmlError`) a value
43
+ over `MAX_RICHTEXT_HTML_BYTES` (1 MiB), an image that names no media item,
44
+ and HTML it cannot parse. It is Node-safe and imports no React.
45
+ - `./datatypes`: `BUILT_IN_EDITOR_IDS`, the ids of the built-in editors. A
46
+ plugin may not contribute an editor under one of them.
47
+ - `.` and `./manifest`: route and hook contexts, and the structured storage
48
+ context, gain the optional `notify` and `vendorService` members described
49
+ above, and `readOnly` described below.
50
+ - `./entitlement`: `entitlementPlan(entitlement, { pluginId, listingPlans?, trustedKeys? })`,
51
+ the plan key
52
+ and the term (`active`, `renewing`, `past_due`, `lapsed`, with its end, the
53
+ next charge and whether it was cancelled) of a verdict whose signature and
54
+ new `termSignature` verify. A verdict from before this release reads as
55
+ plan unknown, term active. On a non-production install it answers the
56
+ listing's highest plan when the host or the caller hands the listing's
57
+ plans. `EntitlementVerdict` gains an optional `termSignature`, `exempt` an
58
+ optional `listingPlans`. A lapsed term still comes with a `valid` verdict,
59
+ so `requireEntitlement` keeps passing for reads. `entitlementPlan` checks
60
+ the plugin id and the `valid` status like `requireEntitlement` and answers
61
+ null otherwise.
62
+ - `.`: `useEntitlement` answers `readOnly`, true while the verified term is
63
+ lapsed.
64
+ - `./manifest`: route and hook contexts carry `readOnly`, the host's own
65
+ decision; the host refuses a lapsed plugin's writes with 403
66
+ `plugin_read_only` whatever the plugin does.
67
+ - `.`: `EntitlementPlan`, `ListingPlanSummary`, `LicenseVerdictTerm`,
68
+ `highestListingPlan`, `planFromEnvelope` and `UNKNOWN_TERM`.
69
+ - `./tailwind/theme.css`: the design tokens' scales as a Tailwind 4 `@theme`
70
+ block, generated from the same source as `tailwindTheme`. Import it after
71
+ `@import "tailwindcss"`. `./tailwind` keeps exporting the Tailwind 3
72
+ `tailwindTheme` unchanged.
73
+ - `.`: `gridArrowStep(key, rtl)`, how far an arrow key moves in an option
74
+ grid read in the page direction (Right goes back in a right-to-left page;
75
+ Up and Down move back and forward in both). The media and asset pickers
76
+ have used it since S314c4.
77
+
78
+ ## 0.17.0
79
+
80
+ The licence verdict key set shrinks to one, three manifest contributions that
81
+ no admin screen hosted are gone, and display names can be per-language maps.
82
+
83
+ ### Removed
84
+
85
+ - The licence verdict key `a4c4a883bf1392a6` from `LICENSE_VERDICT_PUBLIC_KEYS`
86
+ (`./entitlement`). The list now holds `e72c11dbcdf71e68` alone, so a verdict
87
+ signed with the retired key no longer verifies.
88
+ - `settingsPages`, `contentTreeActions` and `editorToolbar` from
89
+ `PluginContributions` and the manifest schema (`.` and `./manifest`), with
90
+ their types `SettingsPageContribution`, `ContentTreeActionContribution` and
91
+ `EditorToolbarContribution`. A manifest that declares one now fails
92
+ validation. The `admin.settingsPage`, `admin.contentTreeAction` and
93
+ `admin.editorToolbarItem` capability labels went with them.
94
+
95
+ ### Changed
96
+
97
+ - The display name of an action, a role, a dashboard widget, a scheduled task,
98
+ a media processor and an exposed service may be a plain string or a map of
99
+ language code to text with `en` required (`.` and `./manifest`). Existing
100
+ string names stay valid.
101
+ - `PluginScreenContext.slot` (`.`) is a union that gains
102
+ `{ kind: "widget"; sectionId: null; entryId: null; widgetId: string }`, the
103
+ slot of a dashboard widget on the admin's Home page. `navigate` is a no-op
104
+ for a widget.
105
+ - A manifest whose `dashboardWidgets` repeat an id fails validation, as
106
+ sections and rail entries already did (`./manifest`).
107
+
108
+ ### Added
109
+
110
+ - `DATABASE_DIALECTS`, `PLUGIN_TYPES` and `TIER1_DIALECTS` (`.` and
111
+ `./manifest`), the vocabulary the manifest schema checks against.
112
+ - `listDashboardWidgets` and the `RegisteredDashboardWidget` type (`./host`),
113
+ host-only: the Home page's list of registered widgets. `registerPluginSlots`
114
+ now registers a manifest's `dashboardWidgets` too.
115
+
11
116
  ## 0.15.0 and 0.16.0 (after 0.14.0, the last release under the former scope)
12
117
 
13
118
  The plugin manifest is no longer a discriminated union on `type`. One
package/README.md CHANGED
@@ -50,7 +50,8 @@ the root; the subpaths below are bundled into whatever imports them.
50
50
  | `@kardalum/plugin-sdk/tokens.css` | Every token as a CSS custom property, light theme by default. |
51
51
  | `@kardalum/plugin-sdk/tokens/system-dark.css` | The dark theme's custom properties under `prefers-color-scheme: dark`. |
52
52
  | `@kardalum/plugin-sdk/tokens.json` | The same tokens as JSON, for build tools. |
53
- | `@kardalum/plugin-sdk/tailwind` | `tailwindTheme`, the Tailwind preset generated from the tokens. |
53
+ | `@kardalum/plugin-sdk/tailwind` | `tailwindTheme`, the Tailwind 3 theme generated from the tokens (use it as `theme` in a `tailwind.config`). |
54
+ | `@kardalum/plugin-sdk/tailwind/theme.css` | The same scales for Tailwind 4, as an `@theme` block reference. In the plugin's stylesheet: `@import "tailwindcss/theme.css" layer(theme);`, then `@import "@kardalum/plugin-sdk/tailwind/theme.css";`, then `@import "tailwindcss/utilities.css" layer(utilities);` and an `@source` line for the plugin's own files. Never `@import "tailwindcss";` (it brings Tailwind's base reset into the admin). The theme is reference-only (values are `var(--x)`), so a standalone preview outside the admin also needs `@kardalum/plugin-sdk/tokens.css`. |
54
55
  | `@kardalum/plugin-sdk/icons` | The Lucide icons the admin draws with, and the `IconName` type a manifest's `icon` takes. |
55
56
  | `@kardalum/plugin-sdk/entitlement` | A paid plugin's licence check (`requireEntitlement`), for plugin server code only. |
56
57
  | `@kardalum/plugin-sdk/datatypes` | The built-in data types' settings schemas and serializers, for server code. |
@@ -66,13 +67,13 @@ management API that the admin itself calls with the signed-in session. A plugin
66
67
  view that calls a CMS family builds its path from it, for example the content
67
68
  roots at `/api/manage/v1/content/roots`, and calls its own routes under
68
69
  `/api/plugins/:pluginId/`. The
69
- [management routes](https://docs.kardalum.com/v1/reference/manage/) page lists
70
+ [management routes](https://dev.kardalum.com/docs/v1/reference/manage/) page lists
70
71
  every operation.
71
72
 
72
73
  ## Docs
73
74
 
74
75
  The plugin guide, the manifest reference and the storage reference are at
75
- [docs.kardalum.com](https://docs.kardalum.com/v1/learn/build-a-plugin/).
76
+ [dev.kardalum.com/docs](https://dev.kardalum.com/docs/v1/learn/build-a-plugin/).
76
77
 
77
78
  ## Support
78
79
 
@@ -1,4 +1,4 @@
1
- import type { AdminSectionContribution, BuiltInRailEntryContribution, BuiltInRailSection, PluginManifest } from "./manifest.js";
1
+ import type { AdminSectionContribution, BuiltInRailEntryContribution, BuiltInRailSection, DashboardWidgetContribution, PluginManifest } from "./manifest.js";
2
2
  /** @internal A section in the host's registry, with the plugin it came from. */
3
3
  export interface RegisteredSection {
4
4
  pluginId: string;
@@ -9,12 +9,18 @@ export interface RegisteredRailEntry {
9
9
  pluginId: string;
10
10
  entry: BuiltInRailEntryContribution;
11
11
  }
12
+ /** @internal A dashboard widget in the host's registry, with its plugin
13
+ * (S313b, W8). The Home page lists them in registration order. */
14
+ export interface RegisteredDashboardWidget {
15
+ pluginId: string;
16
+ widget: DashboardWidgetContribution;
17
+ }
12
18
  /**
13
19
  * Register every slot a plugin's manifest declares: its top-level sections
14
- * (each with its own rail) and its rail entries in built-in sections.
15
- * Replaces `registerAdminSection`. Throws on a second registration of the
16
- * same plugin id, slots or not, so a caller that boots a plugin twice finds
17
- * out rather than doubling its entries in the app bar.
20
+ * (each with its own rail), its rail entries in built-in sections and its
21
+ * dashboard widgets. Replaces `registerAdminSection`. Throws on a second
22
+ * registration of the same plugin id, slots or not, so a caller that boots a
23
+ * plugin twice finds out rather than doubling its entries in the app bar.
18
24
  *
19
25
  * @internal Host-only: the admin calls it with a validated manifest.
20
26
  */
@@ -29,6 +35,9 @@ export declare function listPluginSections(): RegisteredSection[];
29
35
  export declare function listRailEntries(section: BuiltInRailSection): RegisteredRailEntry[];
30
36
  /** @internal Host-only lookup of one plugin's entry in a built-in rail. */
31
37
  export declare function getRailEntry(section: BuiltInRailSection, pluginId: string, entryId: string): RegisteredRailEntry | undefined;
38
+ /** @internal Every registered dashboard widget, in registration order. A
39
+ * copy: changing it changes nothing registered. */
40
+ export declare function listDashboardWidgets(): RegisteredDashboardWidget[];
32
41
  /** @internal Clears every registered slot and plugin id. Tests only: the
33
42
  * admin registers once per page load. */
34
43
  export declare function resetPluginSlotsForTests(): void;
@@ -1,12 +1,13 @@
1
1
  const registeredPlugins = new Set();
2
2
  const sections = [];
3
3
  const railEntries = [];
4
+ const dashboardWidgets = [];
4
5
  /**
5
6
  * Register every slot a plugin's manifest declares: its top-level sections
6
- * (each with its own rail) and its rail entries in built-in sections.
7
- * Replaces `registerAdminSection`. Throws on a second registration of the
8
- * same plugin id, slots or not, so a caller that boots a plugin twice finds
9
- * out rather than doubling its entries in the app bar.
7
+ * (each with its own rail), its rail entries in built-in sections and its
8
+ * dashboard widgets. Replaces `registerAdminSection`. Throws on a second
9
+ * registration of the same plugin id, slots or not, so a caller that boots a
10
+ * plugin twice finds out rather than doubling its entries in the app bar.
10
11
  *
11
12
  * @internal Host-only: the admin calls it with a validated manifest.
12
13
  */
@@ -21,6 +22,9 @@ export function registerPluginSlots(pluginId, manifest) {
21
22
  for (const entry of manifest.contributions.railEntries ?? []) {
22
23
  railEntries.push({ pluginId, entry });
23
24
  }
25
+ for (const widget of manifest.contributions.dashboardWidgets ?? []) {
26
+ dashboardWidgets.push({ pluginId, widget });
27
+ }
24
28
  }
25
29
  /** @internal Host-only lookup of one plugin's section by its id. */
26
30
  export function getPluginSection(pluginId, sectionId) {
@@ -40,10 +44,16 @@ export function listRailEntries(section) {
40
44
  export function getRailEntry(section, pluginId, entryId) {
41
45
  return railEntries.find((registered) => registered.entry.section === section && registered.pluginId === pluginId && registered.entry.id === entryId);
42
46
  }
47
+ /** @internal Every registered dashboard widget, in registration order. A
48
+ * copy: changing it changes nothing registered. */
49
+ export function listDashboardWidgets() {
50
+ return [...dashboardWidgets];
51
+ }
43
52
  /** @internal Clears every registered slot and plugin id. Tests only: the
44
53
  * admin registers once per page load. */
45
54
  export function resetPluginSlotsForTests() {
46
55
  registeredPlugins.clear();
47
56
  sections.length = 0;
48
57
  railEntries.length = 0;
58
+ dashboardWidgets.length = 0;
49
59
  }
@@ -0,0 +1,11 @@
1
+ import { type AssetAccepts } from "@kardalum/api-schemas";
2
+ export interface AssetPickerProps {
3
+ accepts: AssetAccepts;
4
+ /** The folder the drawer opens in; the root when null or when it names no folder. */
5
+ startFolder: string | null;
6
+ /** The file the field holds now: the drawer opens in its folder with it selected, when it exists and is taken. */
7
+ currentPath?: string | null;
8
+ onPick: (path: string) => void;
9
+ onClose: () => void;
10
+ }
11
+ export declare function AssetPicker({ accepts, startFolder: rawStartFolder, currentPath, onPick, onClose }: AssetPickerProps): import("react").JSX.Element;
@@ -0,0 +1,109 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useRef, useState } from "react";
3
+ import { ChevronRight, Folder as FolderIcon } from "lucide-react";
4
+ import { assetPathAccepted, assetPathIsImage } from "@kardalum/api-schemas";
5
+ import { Button, cn, Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle } from "@kardalum/ui";
6
+ import { usePluginTranslate } from "../plugin-screen-context.js";
7
+ import { gridArrowStep } from "../grid-arrow-step.js";
8
+ import { assetBaseName, assetParent, normalizeStartFolder, useAssetThumbnail, useAssetTree } from "./asset-tree.js";
9
+ const NO_ENTRIES = [];
10
+ function inFolder(entries, folder, kind) {
11
+ return entries
12
+ .filter((entry) => entry.kind === kind && assetParent(entry.path) === folder)
13
+ .sort((a, b) => assetBaseName(a.path).localeCompare(assetBaseName(b.path)));
14
+ }
15
+ function formatSize(size) {
16
+ return size === null ? "" : `${Math.max(1, Math.round(size / 1024))} KiB`;
17
+ }
18
+ function TileThumbnail({ path }) {
19
+ const [element, setElement] = useState(null);
20
+ const url = useAssetThumbnail(assetPathIsImage(path) ? path : null, element);
21
+ return (_jsx("span", { ref: setElement, className: "block aspect-square overflow-hidden bg-background-subtle", children: url ? _jsx("img", { src: url, alt: "", className: "h-full w-full object-cover" }) : null }));
22
+ }
23
+ const LINK_CLASS = "rounded-md px-1 hover:text-primary-600 hover:underline focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600";
24
+ export function AssetPicker({ accepts, startFolder: rawStartFolder, currentPath = null, onPick, onClose }) {
25
+ const t = usePluginTranslate();
26
+ const tree = useAssetTree(true, true);
27
+ const startFolder = normalizeStartFolder(rawStartFolder);
28
+ // Whatever had focus when the drawer mounted, read once during the first render (see MediaPicker).
29
+ const [opener] = useState(() => typeof document === "undefined" ? null : document.activeElement);
30
+ const [chosenFolder, setChosenFolder] = useState(null);
31
+ const [pending, setPending] = useState(currentPath);
32
+ const [activeIndex, setActiveIndex] = useState(0);
33
+ const optionRefs = useRef([]);
34
+ const entries = tree.status === "ready" ? tree.entries : NO_ENTRIES;
35
+ const startExists = startFolder !== null && entries.some((entry) => entry.kind === "folder" && entry.path === startFolder);
36
+ const currentEntry = currentPath === null ? undefined : entries.find((entry) => entry.kind === "file" && entry.path === currentPath);
37
+ const currentUsable = currentEntry !== undefined && assetPathAccepted(currentEntry.path, accepts);
38
+ const folder = chosenFolder ?? (currentUsable && currentPath !== null ? assetParent(currentPath) : startExists && startFolder !== null ? startFolder : "");
39
+ // The held path is a selection only when the file is there and the type takes it.
40
+ const selectedPath = pending === currentPath && !currentUsable ? null : pending;
41
+ const folders = useMemo(() => inFolder(entries, folder, "folder"), [entries, folder]);
42
+ const files = useMemo(() => inFolder(entries, folder, "file"), [entries, folder]);
43
+ const crumbs = folder === "" ? [] : folder.split("/").map((name, index, all) => ({ name, path: all.slice(0, index + 1).join("/") }));
44
+ function openFolder(path) {
45
+ setChosenFolder(path);
46
+ setPending(null);
47
+ setActiveIndex(0);
48
+ }
49
+ function choose(entry) {
50
+ if (assetPathAccepted(entry.path, accepts))
51
+ setPending(entry.path);
52
+ }
53
+ function focusIndex(index) {
54
+ setActiveIndex(index);
55
+ optionRefs.current[index]?.focus();
56
+ }
57
+ function handleGridKeyDown(event) {
58
+ if (files.length === 0)
59
+ return;
60
+ // The grid reads in the page's direction (the compose sheet reads it the same way).
61
+ const step = gridArrowStep(event.key, event.currentTarget.closest('[dir="rtl"]') !== null);
62
+ let next = activeIndex;
63
+ if (step !== 0) {
64
+ next = Math.min(Math.max(activeIndex + step, 0), files.length - 1);
65
+ }
66
+ else {
67
+ switch (event.key) {
68
+ case "Home":
69
+ next = 0;
70
+ break;
71
+ case "End":
72
+ next = files.length - 1;
73
+ break;
74
+ case "Enter":
75
+ case " ": {
76
+ event.preventDefault();
77
+ const focused = files[activeIndex];
78
+ if (focused)
79
+ choose(focused);
80
+ return;
81
+ }
82
+ default:
83
+ return;
84
+ }
85
+ }
86
+ event.preventDefault();
87
+ focusIndex(next);
88
+ }
89
+ return (_jsx(Sheet, { open: true, onOpenChange: (next) => {
90
+ if (!next)
91
+ onClose();
92
+ }, children: _jsxs(SheetContent, { onCloseAutoFocus: (event) => {
93
+ if (opener?.isConnected) {
94
+ event.preventDefault();
95
+ opener.focus();
96
+ }
97
+ }, children: [_jsxs(SheetHeader, { className: "flex-col items-start gap-1", children: [_jsx(SheetTitle, { children: t("asset.pickerTitle") }), _jsx(SheetDescription, { children: t(accepts === "any" ? "asset.pickerAny" : "asset.pickerImages") })] }), _jsx("nav", { "aria-label": t("asset.location"), className: "shrink-0 border-b border-border-default px-4 py-2", children: _jsxs("ol", { className: "flex flex-wrap items-center gap-1 text-sm text-text-tertiary", children: [_jsx("li", { children: folder === "" ? (_jsx("span", { "aria-current": "page", className: "font-medium text-text-primary", children: t("asset.root") })) : (_jsx("button", { type: "button", onClick: () => openFolder(""), className: LINK_CLASS, children: t("asset.root") })) }), crumbs.map((crumb, index) => (_jsxs("li", { className: "flex min-w-0 items-center gap-1", children: [_jsx(ChevronRight, { "aria-hidden": "true", className: "size-3 shrink-0 rtl:rotate-180" }), index === crumbs.length - 1 ? (_jsx("span", { "aria-current": "page", className: "truncate font-medium text-text-primary", children: crumb.name })) : (_jsx("button", { type: "button", onClick: () => openFolder(crumb.path), className: cn("truncate", LINK_CLASS), children: crumb.name }))] }, crumb.path)))] }) }), _jsxs("div", { className: "flex flex-1 flex-col gap-4 overflow-y-auto p-4", children: [tree.status === "loading" && _jsx("p", { className: "text-sm text-text-secondary", children: t("asset.loading") }), tree.status === "forbidden" && _jsx("p", { className: "text-sm text-text-secondary", children: t("asset.noAccess") }), tree.status === "failed" && _jsx("p", { className: "text-sm text-danger-600", children: t("asset.loadFailed") }), tree.status === "ready" && tree.truncated && _jsx("p", { className: "text-sm text-text-tertiary", children: t("asset.truncated") }), folders.length > 0 && (_jsx("ul", { "aria-label": t("asset.folders"), className: "flex flex-wrap gap-2", children: folders.map((entry) => (_jsx("li", { className: "min-w-0", children: _jsxs("button", { type: "button", onClick: () => openFolder(entry.path), className: "flex max-w-full items-center gap-2 rounded-full border border-border-default bg-background-elevated px-3 py-1 text-xs text-text-secondary hover:bg-background-hover focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600", children: [_jsx(FolderIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-text-tertiary" }), _jsx("span", { className: "truncate", children: assetBaseName(entry.path) })] }) }, entry.path))) })), tree.status === "ready" && files.length === 0 && folders.length === 0 && (_jsx("p", { className: "text-sm text-text-secondary", children: t("asset.empty") })), files.length > 0 && (_jsx("div", { role: "listbox", "aria-label": t("asset.files"), onKeyDown: handleGridKeyDown, className: "grid grid-cols-2 gap-3 sm:grid-cols-3", children: files.map((entry, index) => {
98
+ const accepted = assetPathAccepted(entry.path, accepts);
99
+ const selected = selectedPath === entry.path;
100
+ return (_jsxs("button", { type: "button", ref: (element) => {
101
+ optionRefs.current[index] = element;
102
+ }, role: "option", "aria-selected": selected, "aria-disabled": !accepted, tabIndex: index === activeIndex ? 0 : -1, onFocus: () => setActiveIndex(index), onClick: () => choose(entry), className: cn("flex flex-col overflow-hidden rounded-md border text-start focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600", selected ? "border-primary-600 bg-primary-100" : "border-border-subtle hover:bg-background-elevated", !accepted && "cursor-not-allowed opacity-50 hover:bg-transparent"), children: [_jsx(TileThumbnail, { path: entry.path }), _jsxs("span", { className: "block min-w-0 px-2 py-1", children: [_jsx("span", { className: "block truncate font-mono text-xs text-text-primary", children: assetBaseName(entry.path) }), _jsx("span", { className: "block truncate text-xs text-text-tertiary", children: accepted ? formatSize(entry.size) : t("asset.notAnImage") })] })] }, entry.path));
103
+ }) }))] }), _jsxs(SheetFooter, { className: "items-center justify-end gap-2", children: [_jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: t("asset.cancel") }), _jsx(Button, { type: "button", disabled: selectedPath === null, onClick: () => {
104
+ if (selectedPath === null)
105
+ return;
106
+ onPick(selectedPath);
107
+ onClose();
108
+ }, children: selectedPath === null ? t("asset.confirmNone") : t("asset.confirm", { name: assetBaseName(selectedPath) }) })] })] }) }));
109
+ }
@@ -0,0 +1,30 @@
1
+ import type { AssetTreeEntry } from "@kardalum/api-schemas";
2
+ export type AssetTreeState = {
3
+ status: "loading";
4
+ } | {
5
+ status: "ready";
6
+ entries: AssetTreeEntry[];
7
+ truncated: boolean;
8
+ } | {
9
+ status: "forbidden";
10
+ } | {
11
+ status: "failed";
12
+ };
13
+ /** The folder a path sits in, "" for the root. */
14
+ export declare function assetParent(path: string): string;
15
+ /** The last segment of a path. */
16
+ export declare function assetBaseName(path: string): string;
17
+ export declare function assetRawUrl(path: string): string;
18
+ /** A start folder as the tree spells it: trimmed, no leading or trailing slash; null when nothing is left. */
19
+ export declare function normalizeStartFolder(value: string | null): string | null;
20
+ /**
21
+ * Reads the tree (shared, see loadTree). `enabled` false makes no request. `fresh` skips the shared
22
+ * copy once, for the picker. A 403 is its own state.
23
+ */
24
+ export declare function useAssetTree(enabled?: boolean, fresh?: boolean): AssetTreeState;
25
+ /**
26
+ * An object URL for an image's bytes, or null (no path, not near the viewport yet, still loading, or the
27
+ * read failed). `element` is the tile to watch (null until it mounts); leave it undefined to fetch at once.
28
+ * At most 6 reads run at a time. Revoked when the path changes or the view goes.
29
+ */
30
+ export declare function useAssetThumbnail(path: string | null, element?: Element | null): string | null;
@@ -0,0 +1,150 @@
1
+ import { useEffect, useState } from "react";
2
+ import { MANAGE_API, usePluginApi } from "../plugin-context.js";
3
+ /** The folder a path sits in, "" for the root. */
4
+ export function assetParent(path) {
5
+ const slash = path.lastIndexOf("/");
6
+ return slash === -1 ? "" : path.slice(0, slash);
7
+ }
8
+ /** The last segment of a path. */
9
+ export function assetBaseName(path) {
10
+ return path.slice(path.lastIndexOf("/") + 1);
11
+ }
12
+ export function assetRawUrl(path) {
13
+ return `${MANAGE_API}/assets/raw?path=${encodeURIComponent(path)}`;
14
+ }
15
+ /** A start folder as the tree spells it: trimmed, no leading or trailing slash; null when nothing is left. */
16
+ export function normalizeStartFolder(value) {
17
+ if (value === null)
18
+ return null;
19
+ const folder = value
20
+ .trim()
21
+ .split("/")
22
+ .filter((part) => part !== "")
23
+ .join("/");
24
+ return folder === "" ? null : folder;
25
+ }
26
+ const TREE_LIFETIME_MS = 30_000;
27
+ const treeCache = new WeakMap();
28
+ function readTree(fetchApi) {
29
+ return fetchApi(`${MANAGE_API}/assets/tree`)
30
+ .then(async (response) => {
31
+ if (response.status === 403)
32
+ return { status: "forbidden" };
33
+ if (!response.ok)
34
+ return { status: "failed" };
35
+ const body = (await response.json());
36
+ return { status: "ready", entries: body.entries, truncated: body.truncated };
37
+ })
38
+ .catch(() => ({ status: "failed" }));
39
+ }
40
+ /** One read shared by every caller of the same API for a short while (and while in flight); a failed read is never kept. */
41
+ function loadTree(fetchApi, fresh) {
42
+ const cached = treeCache.get(fetchApi);
43
+ if (!fresh && cached && Date.now() - cached.at < TREE_LIFETIME_MS)
44
+ return cached.promise;
45
+ const entry = { at: Date.now(), promise: readTree(fetchApi) };
46
+ treeCache.set(fetchApi, entry);
47
+ void entry.promise.then((state) => {
48
+ if (state.status !== "ready" && treeCache.get(fetchApi) === entry)
49
+ treeCache.delete(fetchApi);
50
+ });
51
+ return entry.promise;
52
+ }
53
+ /**
54
+ * Reads the tree (shared, see loadTree). `enabled` false makes no request. `fresh` skips the shared
55
+ * copy once, for the picker. A 403 is its own state.
56
+ */
57
+ export function useAssetTree(enabled = true, fresh = false) {
58
+ const fetchApi = usePluginApi();
59
+ const [state, setState] = useState({ status: "loading" });
60
+ useEffect(() => {
61
+ if (!enabled)
62
+ return;
63
+ let cancelled = false;
64
+ void loadTree(fetchApi, fresh).then((next) => {
65
+ if (!cancelled)
66
+ setState(next);
67
+ });
68
+ return () => {
69
+ cancelled = true;
70
+ };
71
+ }, [fetchApi, enabled, fresh]);
72
+ return state;
73
+ }
74
+ const MAX_THUMBNAIL_FETCHES = 6;
75
+ let activeFetches = 0;
76
+ const waitingFetches = [];
77
+ function acquireSlot() {
78
+ if (activeFetches < MAX_THUMBNAIL_FETCHES) {
79
+ activeFetches += 1;
80
+ return Promise.resolve();
81
+ }
82
+ return new Promise((resolve) => waitingFetches.push(resolve));
83
+ }
84
+ function releaseSlot() {
85
+ const next = waitingFetches.shift();
86
+ if (next)
87
+ next();
88
+ else
89
+ activeFetches -= 1;
90
+ }
91
+ /** True once `element` has been near the viewport; always true where IntersectionObserver is absent. */
92
+ function useNearViewport(element) {
93
+ const supported = typeof IntersectionObserver !== "undefined";
94
+ const [seen, setSeen] = useState(false);
95
+ useEffect(() => {
96
+ if (!supported || !element || seen)
97
+ return;
98
+ const observer = new IntersectionObserver((entries) => {
99
+ if (entries.some((entry) => entry.isIntersecting))
100
+ setSeen(true);
101
+ }, { rootMargin: "200px" });
102
+ observer.observe(element);
103
+ return () => observer.disconnect();
104
+ }, [supported, element, seen]);
105
+ return !supported || seen;
106
+ }
107
+ /**
108
+ * An object URL for an image's bytes, or null (no path, not near the viewport yet, still loading, or the
109
+ * read failed). `element` is the tile to watch (null until it mounts); leave it undefined to fetch at once.
110
+ * At most 6 reads run at a time. Revoked when the path changes or the view goes.
111
+ */
112
+ export function useAssetThumbnail(path, element) {
113
+ const fetchApi = usePluginApi();
114
+ const near = useNearViewport(element ?? null);
115
+ const ready = element === undefined || near;
116
+ const [url, setUrl] = useState(null);
117
+ useEffect(() => {
118
+ setUrl(null);
119
+ if (path === null || !ready)
120
+ return;
121
+ let cancelled = false;
122
+ let objectUrl = null;
123
+ void acquireSlot().then(async () => {
124
+ try {
125
+ if (cancelled)
126
+ return;
127
+ const response = await fetchApi(assetRawUrl(path));
128
+ if (!response.ok || cancelled)
129
+ return;
130
+ const bytes = await response.blob();
131
+ if (cancelled)
132
+ return;
133
+ objectUrl = URL.createObjectURL(bytes);
134
+ setUrl(objectUrl);
135
+ }
136
+ catch {
137
+ // A failed read leaves the tile without a picture.
138
+ }
139
+ finally {
140
+ releaseSlot();
141
+ }
142
+ });
143
+ return () => {
144
+ cancelled = true;
145
+ if (objectUrl)
146
+ URL.revokeObjectURL(objectUrl);
147
+ };
148
+ }, [fetchApi, path, ready]);
149
+ return url;
150
+ }
@@ -0,0 +1 @@
1
+ export declare const BUILT_IN_EDITOR_IDS: readonly string[];
@@ -0,0 +1,20 @@
1
+ // S314o3 (D1): the ids of the built-in editors, as plain data the server can read without the
2
+ // React registry in built-ins.tsx. A plugin may not contribute an editor under one of these ids:
3
+ // the install refuses it, because the admin would refuse to register it and the server would
4
+ // validate the field by the built-in's rules. built-ins.test.tsx holds this list to what
5
+ // built-ins.tsx registers.
6
+ export const BUILT_IN_EDITOR_IDS = [
7
+ "com.kardalum.text",
8
+ "com.kardalum.number",
9
+ "com.kardalum.boolean",
10
+ "com.kardalum.date",
11
+ "com.kardalum.image",
12
+ "com.kardalum.fileupload",
13
+ "com.kardalum.richtext",
14
+ "com.kardalum.html",
15
+ "com.kardalum.daterange",
16
+ "com.kardalum.contentlist",
17
+ "com.kardalum.crop",
18
+ "com.kardalum.thumbnail",
19
+ "com.kardalum.asset",
20
+ ];
@@ -11,4 +11,6 @@ export declare const CROP_SETTINGS_SCHEMA: JSONSchema7;
11
11
  export declare const THUMBNAIL_SETTINGS_SCHEMA: JSONSchema7;
12
12
  export declare const CROP_DEFAULT_SETTINGS: Record<string, unknown>;
13
13
  export declare const THUMBNAIL_DEFAULT_SETTINGS: Record<string, unknown>;
14
+ export declare const ASSET_SETTINGS_SCHEMA: JSONSchema7;
15
+ export declare const ASSET_DEFAULT_SETTINGS: Record<string, unknown>;
14
16
  export declare const BUILT_IN_SETTINGS_SCHEMAS: Readonly<Record<string, JSONSchema7>>;
@@ -208,6 +208,32 @@ export const THUMBNAIL_SETTINGS_SCHEMA = {
208
208
  // not open and save back unchanged.
209
209
  export const CROP_DEFAULT_SETTINGS = { ratio: "1:1", maxWidth: null };
210
210
  export const THUMBNAIL_DEFAULT_SETTINGS = { longestEdge: 320 };
211
+ // S314p (D3). The hand-kept mirror of AssetFieldSettingsSchema in @kardalum/api-schemas, the
212
+ // generator's literal input-mode output (built-ins.test.tsx holds the two equal). Input mode for
213
+ // the crop's reason: both members carry defaults, and a client may send `{}`. The start folder's
214
+ // AssetPathSchema refinements have no JSON Schema form, so ajv checks its type and length only; a
215
+ // start folder that names no folder is harmless (the picker opens at the root).
216
+ export const ASSET_SETTINGS_SCHEMA = {
217
+ type: "object",
218
+ properties: {
219
+ accepts: { default: "images", type: "string", enum: ["images", "any"] },
220
+ startFolder: {
221
+ default: null,
222
+ anyOf: [
223
+ {
224
+ type: "string",
225
+ minLength: 1,
226
+ maxLength: 400,
227
+ description: "A path under public/: segments of letters, digits, spaces and _ - . ~ @ + , ( ) ! $ ' = ; & joined by /, none starting with a dot or ending with a dot or space, each at most 255 bytes, never under a reserved root.",
228
+ },
229
+ { type: "null" },
230
+ ],
231
+ },
232
+ },
233
+ additionalProperties: false,
234
+ };
235
+ // The settings migration 0033 seeds (ASSET_DATA_TYPE_CONFIG in @kardalum/api-schemas).
236
+ export const ASSET_DEFAULT_SETTINGS = { accepts: "images", startFolder: null };
211
237
  // com.kardalum.contentlist is the first entry whose schema has a REQUIRED
212
238
  // member (`columns`), so unlike the three above it cannot fall back to the
213
239
  // "stored settings are {} until a webmaster edits them" convention: its
@@ -222,4 +248,5 @@ export const BUILT_IN_SETTINGS_SCHEMAS = {
222
248
  "com.kardalum.fileupload": FILE_UPLOAD_SETTINGS_SCHEMA,
223
249
  "com.kardalum.crop": CROP_SETTINGS_SCHEMA,
224
250
  "com.kardalum.thumbnail": THUMBNAIL_SETTINGS_SCHEMA,
251
+ "com.kardalum.asset": ASSET_SETTINGS_SCHEMA,
225
252
  };
@@ -44,4 +44,7 @@ export const BUILT_IN_VALUE_SCHEMAS = {
44
44
  // and the rendition row records it. So this field, like the content list
45
45
  // above, carries no value of its own.
46
46
  "com.kardalum.thumbnail": { type: "null" },
47
+ // S314p (D3). A path under public/, as Settings, Assets names the file; the address a template
48
+ // prints is worked out at render.
49
+ "com.kardalum.asset": { type: "string" },
47
50
  };
package/dist/built-ins.js CHANGED
@@ -1,13 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { CONTENT_LIST_DEFAULT_SETTINGS } from "@kardalum/api-schemas";
3
3
  import { Checkbox, Input, PropertyField, usePropertyFieldControl } from "@kardalum/ui";
4
- import { CONTENT_LIST_SETTINGS_SCHEMA, CROP_DEFAULT_SETTINGS, CROP_SETTINGS_SCHEMA, FILE_UPLOAD_SETTINGS_SCHEMA, HTML_DEFAULT_SETTINGS, HTML_SETTINGS_SCHEMA, IMAGE_DEFAULT_SETTINGS, IMAGE_SETTINGS_SCHEMA, TEXT_DEFAULT_SETTINGS, TEXT_SETTINGS_SCHEMA, THUMBNAIL_DEFAULT_SETTINGS, THUMBNAIL_SETTINGS_SCHEMA, } from "./built-in-settings-schemas.js";
4
+ import { ASSET_DEFAULT_SETTINGS, ASSET_SETTINGS_SCHEMA, CONTENT_LIST_SETTINGS_SCHEMA, CROP_DEFAULT_SETTINGS, CROP_SETTINGS_SCHEMA, FILE_UPLOAD_SETTINGS_SCHEMA, HTML_DEFAULT_SETTINGS, HTML_SETTINGS_SCHEMA, IMAGE_DEFAULT_SETTINGS, IMAGE_SETTINGS_SCHEMA, TEXT_DEFAULT_SETTINGS, TEXT_SETTINGS_SCHEMA, THUMBNAIL_DEFAULT_SETTINGS, THUMBNAIL_SETTINGS_SCHEMA, } from "./built-in-settings-schemas.js";
5
5
  import { BUILT_IN_VALUE_SCHEMAS } from "./built-in-value-schemas.js";
6
6
  import { BUILT_IN_SERIALIZERS, identitySerializer } from "./built-in-serializers.js";
7
7
  import { BUILT_IN_DATATYPE_VALIDATORS } from "./datatype-validation.js";
8
8
  import { definePlugin } from "./define-plugin.js";
9
9
  import { usePluginSettings, usePluginSettingsValue, usePluginValue } from "./plugin-context.js";
10
10
  import { registerDataType } from "./registry.js";
11
+ import { AssetInputView, AssetReadOnlyView, AssetSettingsView } from "./views/asset-view.js";
11
12
  import { ContentListPreview } from "./views/content-list-preview.js";
12
13
  import { ContentListSettingsView } from "./views/content-list-settings-view.js";
13
14
  import { ContentListInputView, ContentListReadOnlyView } from "./views/content-list-view.js";
@@ -255,3 +256,11 @@ registerDataType(builtIn("thumbnail", "Thumbnail", "image-down", BUILT_IN_VALUE_
255
256
  settings: ThumbnailSettingsView,
256
257
  preview: ThumbnailReadOnlyView,
257
258
  }, { settingsSchema: THUMBNAIL_SETTINGS_SCHEMA, defaultSettings: THUMBNAIL_DEFAULT_SETTINGS }));
259
+ // S314p (D3): the Asset editor, a file from Settings, Assets. Seeded as the "Asset" data type by
260
+ // migration 0033; its views read the asset tree through the host's fetch.
261
+ registerDataType(builtIn("asset", "Asset", "folder-open", BUILT_IN_VALUE_SCHEMAS["com.kardalum.asset"], {
262
+ input: AssetInputView,
263
+ readOnly: AssetReadOnlyView,
264
+ settings: AssetSettingsView,
265
+ preview: AssetReadOnlyView,
266
+ }, { settingsSchema: ASSET_SETTINGS_SCHEMA, defaultSettings: ASSET_DEFAULT_SETTINGS }));