@kardalum/plugin-sdk 0.20.0 → 0.21.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 (323) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/dist/admin-section-registry.d.ts +33 -1
  3. package/dist/admin-section-registry.js +67 -0
  4. package/dist/capabilities.js +46 -1
  5. package/dist/consent-entry.d.ts +11 -0
  6. package/dist/consent-entry.js +18 -0
  7. package/dist/content-library.d.ts +17 -0
  8. package/dist/content-list-extensions.d.ts +50 -0
  9. package/dist/content-list-extensions.js +11 -0
  10. package/dist/content-picker/page-picker-sheet.d.ts +2 -0
  11. package/dist/content-picker/page-picker-sheet.js +1 -1
  12. package/dist/content-picker/page-picker.d.ts +18 -0
  13. package/dist/content-picker/page-picker.js +20 -0
  14. package/dist/datatype-validation.js +10 -2
  15. package/dist/datatypes-entry.d.ts +1 -0
  16. package/dist/datatypes-entry.js +2 -0
  17. package/dist/entitlement-types.d.ts +18 -1
  18. package/dist/host-entry.d.ts +7 -1
  19. package/dist/host-entry.js +14 -1
  20. package/dist/index.d.ts +35 -7
  21. package/dist/index.js +46 -5
  22. package/dist/mail.d.ts +6 -2
  23. package/dist/manifest-entry.d.ts +22 -4
  24. package/dist/manifest-entry.js +25 -1
  25. package/dist/manifest-schema.d.ts +570 -31
  26. package/dist/manifest-schema.js +240 -12
  27. package/dist/manifest.d.ts +757 -32
  28. package/dist/manifest.js +8 -4
  29. package/dist/plugin-context.d.ts +47 -0
  30. package/dist/plugin-context.js +27 -0
  31. package/dist/plugin-permissions.d.ts +18 -0
  32. package/dist/plugin-permissions.js +25 -0
  33. package/dist/plugin-screen-context.d.ts +152 -11
  34. package/dist/plugin-screen-context.js +30 -0
  35. package/dist/providers.d.ts +47 -2
  36. package/dist/render-page.d.ts +15 -0
  37. package/dist/render-page.js +20 -0
  38. package/dist/richtext/block-panel.d.ts +12 -1
  39. package/dist/richtext/block-panel.js +27 -21
  40. package/dist/richtext/button-view.d.ts +11 -0
  41. package/dist/richtext/button-view.js +45 -0
  42. package/dist/richtext/content-guard.d.ts +4 -0
  43. package/dist/richtext/content-guard.js +27 -0
  44. package/dist/richtext/editor-handle.d.ts +34 -0
  45. package/dist/richtext/editor-handle.js +225 -0
  46. package/dist/richtext/extensions.d.ts +6 -0
  47. package/dist/richtext/extensions.js +16 -0
  48. package/dist/richtext/insert-menu.d.ts +6 -1
  49. package/dist/richtext/insert-menu.js +38 -18
  50. package/dist/richtext/item-attributes.d.ts +6 -0
  51. package/dist/richtext/item-attributes.js +19 -0
  52. package/dist/richtext/item-panel.d.ts +25 -0
  53. package/dist/richtext/item-panel.js +118 -0
  54. package/dist/richtext/item-view.d.ts +58 -0
  55. package/dist/richtext/item-view.js +172 -0
  56. package/dist/richtext/mark-form.d.ts +10 -0
  57. package/dist/richtext/mark-form.js +38 -0
  58. package/dist/richtext/paste-choice.d.ts +9 -0
  59. package/dist/richtext/paste-choice.js +13 -0
  60. package/dist/richtext/plugin-items.d.ts +72 -0
  61. package/dist/richtext/plugin-items.js +562 -0
  62. package/dist/richtext/plugin-mark-tooltips.d.ts +5 -0
  63. package/dist/richtext/plugin-mark-tooltips.js +44 -0
  64. package/dist/richtext/plugin-toolbar.d.ts +57 -0
  65. package/dist/richtext/plugin-toolbar.js +186 -0
  66. package/dist/richtext/rich-item-icons.d.ts +5 -0
  67. package/dist/richtext/rich-item-icons.js +42 -0
  68. package/dist/richtext/rich-items.d.ts +42 -0
  69. package/dist/richtext/rich-items.js +68 -0
  70. package/dist/richtext/rich-text-view-host.d.ts +24 -0
  71. package/dist/richtext/rich-text-view-host.js +11 -0
  72. package/dist/richtext/toolbar-button.d.ts +16 -0
  73. package/dist/richtext/toolbar-button.js +9 -0
  74. package/dist/richtext/url-paste.d.ts +20 -0
  75. package/dist/richtext/url-paste.js +82 -0
  76. package/dist/richtext-html-entry.d.ts +5 -0
  77. package/dist/richtext-html-entry.js +11 -0
  78. package/dist/sdk-strings.d.ts +59 -0
  79. package/dist/sdk-strings.js +64 -0
  80. package/dist/service-contract.d.ts +17 -0
  81. package/dist/service-contract.js +39 -0
  82. package/dist/services.d.ts +114 -0
  83. package/dist/services.js +1 -0
  84. package/dist/structured-storage-types.d.ts +124 -4
  85. package/dist/tailwind.js +10 -5
  86. package/dist/template-reads.d.ts +16 -0
  87. package/dist/template-reads.js +21 -0
  88. package/dist/testing-entry.d.ts +38 -0
  89. package/dist/testing-entry.js +173 -0
  90. package/dist/text-entry.d.ts +1 -1
  91. package/dist/text-entry.js +3 -2
  92. package/dist/tokens/system-dark.css +1 -0
  93. package/dist/tokens/tailwind-theme.css +2 -0
  94. package/dist/tokens/tokens.css +4 -0
  95. package/dist/tokens/tokens.json +5 -1
  96. package/dist/uploads.d.ts +43 -0
  97. package/dist/uploads.js +1 -0
  98. package/dist/user-library.d.ts +51 -0
  99. package/dist/user-library.js +15 -0
  100. package/dist/view-helpers.d.ts +18 -0
  101. package/dist/view-helpers.js +64 -0
  102. package/dist/views/content-list-view.js +207 -8
  103. package/dist/views/content-picker-view.js +1 -1
  104. package/dist/views/rich-text-view.d.ts +2 -0
  105. package/dist/views/rich-text-view.js +182 -24
  106. package/dist/views/unreadable-rich-text.d.ts +17 -0
  107. package/dist/views/unreadable-rich-text.js +40 -0
  108. package/dist/visitors.d.ts +81 -0
  109. package/dist/visitors.js +1 -0
  110. package/node_modules/@kardalum/api-schemas/dist/ai-app-hosts.d.ts +21 -0
  111. package/node_modules/@kardalum/api-schemas/dist/ai-app-hosts.js +39 -0
  112. package/node_modules/@kardalum/api-schemas/dist/ai-app-redirects.d.ts +2 -0
  113. package/node_modules/@kardalum/api-schemas/dist/ai-app-redirects.js +31 -0
  114. package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.d.ts +127 -8
  115. package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.js +82 -7
  116. package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +5 -1
  117. package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +2 -2
  118. package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.d.ts +7 -0
  119. package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.js +11 -0
  120. package/node_modules/@kardalum/api-schemas/dist/capability-detail.d.ts +1 -1
  121. package/node_modules/@kardalum/api-schemas/dist/capability-detail.js +18 -0
  122. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +80 -0
  123. package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +41 -2
  124. package/node_modules/@kardalum/api-schemas/dist/content-reads.schema.d.ts +213 -0
  125. package/node_modules/@kardalum/api-schemas/dist/content-reads.schema.js +234 -0
  126. package/node_modules/@kardalum/api-schemas/dist/contribution-issues.d.ts +11 -0
  127. package/node_modules/@kardalum/api-schemas/dist/contribution-issues.js +14 -0
  128. package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +50 -13
  129. package/node_modules/@kardalum/api-schemas/dist/core-actions.js +19 -10
  130. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +77 -0
  131. package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +37 -0
  132. package/node_modules/@kardalum/api-schemas/dist/experimental-points.d.ts +19 -0
  133. package/node_modules/@kardalum/api-schemas/dist/experimental-points.js +250 -0
  134. package/node_modules/@kardalum/api-schemas/dist/form-protection-callers.d.ts +29 -0
  135. package/node_modules/@kardalum/api-schemas/dist/form-protection-callers.js +31 -0
  136. package/node_modules/@kardalum/api-schemas/dist/html-scan.d.ts +22 -0
  137. package/node_modules/@kardalum/api-schemas/dist/html-scan.js +122 -0
  138. package/node_modules/@kardalum/api-schemas/dist/html-start-tags.d.ts +48 -0
  139. package/node_modules/@kardalum/api-schemas/dist/html-start-tags.js +381 -0
  140. package/node_modules/@kardalum/api-schemas/dist/index.d.ts +52 -14
  141. package/node_modules/@kardalum/api-schemas/dist/index.js +53 -9
  142. package/node_modules/@kardalum/api-schemas/dist/json-depth.d.ts +3 -0
  143. package/node_modules/@kardalum/api-schemas/dist/json-depth.js +20 -0
  144. package/node_modules/@kardalum/api-schemas/dist/mail-rules.d.ts +4 -2
  145. package/node_modules/@kardalum/api-schemas/dist/mail-rules.js +6 -1
  146. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +178 -2
  147. package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +10 -0
  148. package/node_modules/@kardalum/api-schemas/dist/mcp-plugins.schema.d.ts +3 -3
  149. package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +16 -0
  150. package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +4 -0
  151. package/node_modules/@kardalum/api-schemas/dist/media.schema.js +4 -0
  152. package/node_modules/@kardalum/api-schemas/dist/nested-validation.d.ts +7 -0
  153. package/node_modules/@kardalum/api-schemas/dist/nested-validation.js +51 -2
  154. package/node_modules/@kardalum/api-schemas/dist/page-audience.schema.d.ts +87 -0
  155. package/node_modules/@kardalum/api-schemas/dist/page-audience.schema.js +44 -0
  156. package/node_modules/@kardalum/api-schemas/dist/plugin-admin-slots.d.ts +11 -0
  157. package/node_modules/@kardalum/api-schemas/dist/plugin-admin-slots.js +61 -0
  158. package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.d.ts +4 -2
  159. package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.js +12 -2
  160. package/node_modules/@kardalum/api-schemas/dist/plugin-content-slots.d.ts +136 -0
  161. package/node_modules/@kardalum/api-schemas/dist/plugin-content-slots.js +254 -0
  162. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-checks.d.ts +22 -0
  163. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-checks.js +66 -0
  164. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-document.d.ts +130 -0
  165. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-document.js +173 -0
  166. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-fetch.d.ts +16 -0
  167. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-fetch.js +112 -0
  168. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-schema.d.ts +70 -0
  169. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-schema.js +380 -0
  170. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-types.d.ts +3 -0
  171. package/node_modules/@kardalum/api-schemas/dist/plugin-contract-types.js +68 -0
  172. package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +18 -0
  173. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +18 -0
  174. package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +5 -2
  175. package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.d.ts +10 -2
  176. package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.js +48 -1
  177. package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.d.ts +5 -2
  178. package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.js +6 -4
  179. package/node_modules/@kardalum/api-schemas/dist/plugin-events.d.ts +24 -0
  180. package/node_modules/@kardalum/api-schemas/dist/plugin-events.js +53 -0
  181. package/node_modules/@kardalum/api-schemas/dist/plugin-guards.d.ts +112 -0
  182. package/node_modules/@kardalum/api-schemas/dist/plugin-guards.js +118 -0
  183. package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.d.ts +12 -0
  184. package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.js +3 -0
  185. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +2 -0
  186. package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +3 -0
  187. package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +67 -0
  188. package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +15 -0
  189. package/node_modules/@kardalum/api-schemas/dist/plugin-kept-parts.d.ts +138 -0
  190. package/node_modules/@kardalum/api-schemas/dist/plugin-kept-parts.js +110 -0
  191. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +80 -15
  192. package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +67 -23
  193. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +10 -3
  194. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +33 -8
  195. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +2 -1
  196. package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +7 -1
  197. package/node_modules/@kardalum/api-schemas/dist/plugin-outbound.d.ts +1 -1
  198. package/node_modules/@kardalum/api-schemas/dist/plugin-providers.d.ts +43 -7
  199. package/node_modules/@kardalum/api-schemas/dist/plugin-providers.js +36 -5
  200. package/node_modules/@kardalum/api-schemas/dist/plugin-rich-text.d.ts +638 -0
  201. package/node_modules/@kardalum/api-schemas/dist/plugin-rich-text.js +533 -0
  202. package/node_modules/@kardalum/api-schemas/dist/plugin-service-call.d.ts +36 -0
  203. package/node_modules/@kardalum/api-schemas/dist/plugin-service-call.js +32 -0
  204. package/node_modules/@kardalum/api-schemas/dist/plugin-service-connections.d.ts +193 -0
  205. package/node_modules/@kardalum/api-schemas/dist/plugin-service-connections.js +123 -0
  206. package/node_modules/@kardalum/api-schemas/dist/plugin-service-declarations.d.ts +209 -0
  207. package/node_modules/@kardalum/api-schemas/dist/plugin-service-declarations.js +372 -0
  208. package/node_modules/@kardalum/api-schemas/dist/plugin-services.d.ts +90 -0
  209. package/node_modules/@kardalum/api-schemas/dist/plugin-services.js +204 -0
  210. package/node_modules/@kardalum/api-schemas/dist/plugin-settings.d.ts +10 -0
  211. package/node_modules/@kardalum/api-schemas/dist/plugin-settings.js +10 -1
  212. package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.d.ts +171 -4
  213. package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.js +406 -42
  214. package/node_modules/@kardalum/api-schemas/dist/plugin-site-requests.d.ts +69 -0
  215. package/node_modules/@kardalum/api-schemas/dist/plugin-site-requests.js +149 -0
  216. package/node_modules/@kardalum/api-schemas/dist/plugin-styles.d.ts +5 -0
  217. package/node_modules/@kardalum/api-schemas/dist/plugin-styles.js +13 -0
  218. package/node_modules/@kardalum/api-schemas/dist/plugin-uploads.d.ts +96 -0
  219. package/node_modules/@kardalum/api-schemas/dist/plugin-uploads.js +185 -0
  220. package/node_modules/@kardalum/api-schemas/dist/plugin-user-accounts.d.ts +213 -0
  221. package/node_modules/@kardalum/api-schemas/dist/plugin-user-accounts.js +131 -0
  222. package/node_modules/@kardalum/api-schemas/dist/plugin-view-kit.d.ts +54 -0
  223. package/node_modules/@kardalum/api-schemas/dist/plugin-view-kit.js +154 -0
  224. package/node_modules/@kardalum/api-schemas/dist/plugin-visitor-points.d.ts +37 -0
  225. package/node_modules/@kardalum/api-schemas/dist/plugin-visitor-points.js +124 -0
  226. package/node_modules/@kardalum/api-schemas/dist/render-cache.d.ts +126 -0
  227. package/node_modules/@kardalum/api-schemas/dist/render-cache.js +263 -0
  228. package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +303 -0
  229. package/node_modules/@kardalum/api-schemas/dist/render-editing.js +61 -0
  230. package/node_modules/@kardalum/api-schemas/dist/rich-text-paste-hosts.d.ts +14 -0
  231. package/node_modules/@kardalum/api-schemas/dist/rich-text-paste-hosts.js +108 -0
  232. package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.d.ts +66 -1
  233. package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.js +465 -7
  234. package/node_modules/@kardalum/api-schemas/dist/rich-text-text.js +15 -118
  235. package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +110 -0
  236. package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.js +36 -0
  237. package/node_modules/@kardalum/api-schemas/dist/security-overview.schema.d.ts +64 -0
  238. package/node_modules/@kardalum/api-schemas/dist/security-overview.schema.js +38 -0
  239. package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.d.ts +9 -2
  240. package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.js +7 -2
  241. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +26 -0
  242. package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +19 -0
  243. package/node_modules/@kardalum/api-schemas/dist/sign-in-steps.d.ts +724 -0
  244. package/node_modules/@kardalum/api-schemas/dist/sign-in-steps.js +408 -0
  245. package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.d.ts +5 -3
  246. package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.js +3 -1
  247. package/node_modules/@kardalum/api-schemas/dist/site-consent.d.ts +77 -0
  248. package/node_modules/@kardalum/api-schemas/dist/site-consent.js +122 -0
  249. package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.d.ts +4 -0
  250. package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.js +28 -0
  251. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +33 -0
  252. package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +26 -1
  253. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +14 -0
  254. package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +2 -0
  255. package/node_modules/@kardalum/api-schemas/dist/visitor-accounts.d.ts +482 -0
  256. package/node_modules/@kardalum/api-schemas/dist/visitor-accounts.js +380 -0
  257. package/node_modules/@kardalum/api-schemas/dist/visitor-groups.d.ts +109 -0
  258. package/node_modules/@kardalum/api-schemas/dist/visitor-groups.js +62 -0
  259. package/node_modules/@kardalum/api-schemas/package.json +1 -0
  260. package/node_modules/@kardalum/design-tokens/dist/build-css.js +9 -1
  261. package/node_modules/@kardalum/design-tokens/dist/system-dark.css +1 -0
  262. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +2 -0
  263. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +1 -0
  264. package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
  265. package/node_modules/@kardalum/design-tokens/dist/tokens.css +4 -0
  266. package/node_modules/@kardalum/design-tokens/dist/tokens.js +6 -0
  267. package/node_modules/@kardalum/design-tokens/dist/tokens.json +5 -1
  268. package/node_modules/@kardalum/design-tokens/dist/types.d.ts +4 -0
  269. package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +17 -0
  270. package/node_modules/@kardalum/plugin-package/dist/build-reference.js +9 -0
  271. package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +1 -1
  272. package/node_modules/@kardalum/plugin-package/dist/capabilities.js +276 -19
  273. package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +1 -1
  274. package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +23 -0
  275. package/node_modules/@kardalum/plugin-package/dist/contract-fingerprint.d.ts +17 -0
  276. package/node_modules/@kardalum/plugin-package/dist/contract-fingerprint.js +39 -0
  277. package/node_modules/@kardalum/plugin-package/dist/delivery/admin-styles.d.ts +23 -0
  278. package/node_modules/@kardalum/plugin-package/dist/delivery/admin-styles.js +351 -0
  279. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.d.ts +2 -0
  280. package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +1 -1
  281. package/node_modules/@kardalum/plugin-package/dist/delivery/content-access.js +21 -8
  282. package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +1 -1
  283. package/node_modules/@kardalum/plugin-package/dist/delivery/editor-extensions.js +23 -10
  284. package/node_modules/@kardalum/plugin-package/dist/delivery/icons.js +3 -2
  285. package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +2 -0
  286. package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +2 -0
  287. package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +30 -2
  288. package/node_modules/@kardalum/plugin-package/dist/delivery/licence-check.js +6 -2
  289. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +6 -0
  290. package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +6 -0
  291. package/node_modules/@kardalum/plugin-package/dist/delivery/providers.d.ts +2 -0
  292. package/node_modules/@kardalum/plugin-package/dist/delivery/providers.js +24 -6
  293. package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +15 -0
  294. package/node_modules/@kardalum/plugin-package/dist/delivery/rich-text.d.ts +2 -0
  295. package/node_modules/@kardalum/plugin-package/dist/delivery/rich-text.js +173 -0
  296. package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +1 -1
  297. package/node_modules/@kardalum/plugin-package/dist/delivery/server-powers.js +14 -4
  298. package/node_modules/@kardalum/plugin-package/dist/delivery/services-events.d.ts +3 -0
  299. package/node_modules/@kardalum/plugin-package/dist/delivery/services-events.js +35 -0
  300. package/node_modules/@kardalum/plugin-package/dist/delivery/sign-in-steps.d.ts +3 -0
  301. package/node_modules/@kardalum/plugin-package/dist/delivery/sign-in-steps.js +71 -0
  302. package/node_modules/@kardalum/plugin-package/dist/delivery/site-extensions.js +44 -11
  303. package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +7 -0
  304. package/node_modules/@kardalum/plugin-package/dist/delivery/user-accounts.d.ts +3 -0
  305. package/node_modules/@kardalum/plugin-package/dist/delivery/user-accounts.js +36 -0
  306. package/node_modules/@kardalum/plugin-package/dist/delivery/visitor-points.d.ts +3 -0
  307. package/node_modules/@kardalum/plugin-package/dist/delivery/visitor-points.js +33 -0
  308. package/node_modules/@kardalum/plugin-package/dist/index.d.ts +4 -0
  309. package/node_modules/@kardalum/plugin-package/dist/index.js +5 -0
  310. package/node_modules/@kardalum/plugin-package/dist/public-suffix.d.ts +7 -0
  311. package/node_modules/@kardalum/plugin-package/dist/public-suffix.js +23 -0
  312. package/node_modules/@kardalum/plugin-package/dist/rich-text-summary.d.ts +1 -0
  313. package/node_modules/@kardalum/plugin-package/dist/rich-text-summary.js +27 -0
  314. package/node_modules/@kardalum/plugin-package/dist/stylesheet-load-hook.d.ts +2 -0
  315. package/node_modules/@kardalum/plugin-package/dist/stylesheet-load-hook.js +28 -0
  316. package/node_modules/@kardalum/plugin-package/package.json +4 -0
  317. package/node_modules/@kardalum/ui/dist/components/select.d.ts +6 -0
  318. package/node_modules/@kardalum/ui/dist/components/select.js +7 -0
  319. package/node_modules/@kardalum/ui/dist/components/textarea.d.ts +6 -0
  320. package/node_modules/@kardalum/ui/dist/components/textarea.js +7 -0
  321. package/node_modules/@kardalum/ui/dist/index.d.ts +2 -0
  322. package/node_modules/@kardalum/ui/dist/index.js +2 -0
  323. package/package.json +15 -3
@@ -3,6 +3,8 @@ import { isReservedRootSlug } from "./reserved-slugs.js";
3
3
  import { hasNoControlCharacter } from "./strict-url.js";
4
4
  import { PageHeadScriptOriginSchema, SITE_LOCATION_MAX } from "./plugin-https-origin.js";
5
5
  import { PluginHeldEmbedsSchema } from "./plugin-held-embeds.js";
6
+ import { CONSENT_CATEGORIES, CORE_DATA_PREFIX } from "./site-consent.js";
7
+ import { SITE_ROUTE_UPLOAD_METHODS, routeUploadsProblem } from "./plugin-uploads.js";
6
8
  export { PageHeadScriptOriginSchema, SITE_LOCATION_MAX };
7
9
  // M32 F2: the rules and limits for what a plugin adds to the public site.
8
10
  // Site routes are file addresses (GET) and form posts (POST) a plugin
@@ -19,6 +21,22 @@ export const SITE_ROUTE_SEGMENT_MAX = 100;
19
21
  export const SITE_ROUTE_BODY_LIMIT_BYTES = 65_536;
20
22
  export const SITE_ROUTE_FORM_FIELDS_MAX = 200;
21
23
  export const SITE_ROUTE_ANSWER_LIMIT_BYTES = 5_242_880;
24
+ /** M35 P3 (W18): the parameters one site route path holds at most. */
25
+ export const SITE_ROUTE_PARAMS_MAX = 4;
26
+ /** M35 P3 (W18): the longest parameter name, in characters. */
27
+ export const SITE_ROUTE_PARAM_NAME_MAX = 32;
28
+ /** M35 P3 (W18): the longest decoded segment a parameter takes; a longer one matches no pattern. */
29
+ export const SITE_ROUTE_PARAM_VALUE_MAX = 200;
30
+ /** M35 P3 (W18): the longest rest a trailing "*" takes, decoded segments joined with "/". */
31
+ export const SITE_ROUTE_REST_MAX = 1_000;
32
+ /** M35 P3 (W18): the most segments a trailing "*" takes. */
33
+ export const SITE_ROUTE_REST_SEGMENTS_MAX = 16;
34
+ /** M35 P3 (W18): the longest raw path the core reads for a pattern; a longer one matches none. */
35
+ export const SITE_ROUTE_MATCH_PATH_MAX = 2_000;
36
+ /** M35 P3 (W18): the key a trailing "*" puts its rest under in request.params. */
37
+ export const SITE_ROUTE_REST_PARAM = "*";
38
+ /** M35 P3 (W18): first segments no route that answers after the pages may take: the visitor account pages (35-U2a). */
39
+ export const SITE_ROUTE_PATTERN_RESERVED_PREFIXES = ["account"];
22
40
  export const SITE_FALLBACK_TIME_MS = 250;
23
41
  export const SITE_REDIRECT_STATUSES = [301, 302, 307, 308];
24
42
  /** M33 K34: the longest a plugin may let a browser keep its fallback redirect, one day, in seconds. */
@@ -35,6 +53,22 @@ export const TEMPLATE_DATA_DEPTH_MAX = 8;
35
53
  export const TEMPLATE_DATA_VALUES_MAX = 10_000;
36
54
  export const TEMPLATE_DATA_TEXT_MAX_BYTES = 262_144;
37
55
  export const TEMPLATE_OUTPUT_LIMIT_BYTES = 65_536;
56
+ /** M35 P3 (W19): the largest rendered body a block tag is handed, in UTF-8 bytes; a larger one is handed as null. */
57
+ export const TEMPLATE_BLOCK_BODY_MAX_BYTES = 262_144;
58
+ /** M35 P3 (W19): the longest class a block tag's wrap names, in characters. */
59
+ export const TEMPLATE_BLOCK_CLASS_MAX = 200;
60
+ /** M35 P3 (W19): the elements a block tag's wrap may put the body in. */
61
+ export const TEMPLATE_BLOCK_WRAP_ELEMENTS = ["div", "section", "span", "figure", "blockquote"];
62
+ /** M35 P3 (W19): what a block tag writes when it cannot answer: the author's body (the default) or nothing. */
63
+ export const TEMPLATE_BLOCK_ON_FAILURE = ["body", "nothing"];
64
+ /** M35 P3 (evidence 116): what a filter prints when it cannot answer: its value (the default) or nothing. */
65
+ export const TEMPLATE_FILTER_ON_FAILURE = ["value", "nothing"];
66
+ /** M35 P3 (W19): the published reads all plugin template calls of one render make together, on the render's list read budget. */
67
+ export const TEMPLATE_PLUGIN_READS_PER_RENDER_MAX = 20;
68
+ /** M35 P3 (W19): of those, the searches. */
69
+ export const TEMPLATE_PLUGIN_SEARCHES_PER_RENDER_MAX = 2;
70
+ /** M35 P3 (W19): why a template call's read was refused: a budget is spent, the call has ended, or no reader is wired. */
71
+ export const TEMPLATE_READ_REFUSALS = ["spent", "ended", "unavailable"];
38
72
  export const PAGE_HEAD_ENTRIES_MAX = 20;
39
73
  export const PAGE_HEAD_LIMIT_BYTES = 65_536;
40
74
  export const PAGE_HEAD_SCRIPT_ORIGINS_MAX = 10;
@@ -49,6 +83,20 @@ export const PAGE_HEAD_TITLE_MAX = 300;
49
83
  /** M33 K27: how much of a rendered page the core reads to find its <title> or </head>, in bytes. */
50
84
  export const PAGE_TITLE_SCAN_BYTES = 65_536;
51
85
  export const PAGE_HEAD_LINK_RELS = ["canonical", "alternate", "icon", "manifest", "preconnect", "dns-prefetch", "stylesheet"];
86
+ /** M35 P1 (W40): the longest inline snippet a head entry carries, in UTF-8 bytes. */
87
+ export const PAGE_HEAD_INLINE_TEXT_MAX_BYTES = 16_384;
88
+ /** M35 P1 (W40): the inline snippets one plugin's head writes in a render; a fifth is dropped. Counted among PAGE_HEAD_ENTRIES_MAX and PAGE_HEAD_LIMIT_BYTES. */
89
+ export const PAGE_HEAD_INLINE_SNIPPETS_MAX = 4;
90
+ /** M35 P1 (W3): the page output transforms one render runs, in plugin id order; later ones are skipped. */
91
+ export const PAGE_OUTPUT_TRANSFORMS_MAX = 8;
92
+ /** M35 P1 (W3): how long the core waits for one transform, in milliseconds. */
93
+ export const PAGE_OUTPUT_TIME_MS = 100;
94
+ /** M35 P1 (W3): how long the core waits for all transforms of one render together; its own budget, apart from the template calls'. */
95
+ export const PAGE_OUTPUT_TIME_PER_RENDER_MS = 250;
96
+ /** M35 P1 (W3): the largest page handed to transforms, in UTF-8 bytes; a larger page is served as rendered. */
97
+ export const PAGE_OUTPUT_INPUT_MAX_BYTES = 2_097_152;
98
+ /** M35 P1 (W3): how many UTF-8 bytes one transform's answer may add to the page it was handed. */
99
+ export const PAGE_OUTPUT_GROWTH_MAX_BYTES = 262_144;
52
100
  // M32 F4c (D2): `context.listPublishedPages`. A call answers at most LIMIT_MAX pages (LIMIT_DEFAULT
53
101
  // when none is asked) and reads at most BATCHES_MAX batches of `limit` rows to fill them, so a
54
102
  // tree full of drafts never makes one call unbounded.
@@ -71,7 +119,9 @@ export const RESERVED_TEMPLATE_WORDS = [
71
119
  ];
72
120
  /** M33 K71: the facts a template reads off `page` (and a listed page) ahead of a field of the same
73
121
  * id, so a field with one of these ids is reached there only as `page.fields.<id>`. The renderer
74
- * answers them by these names, and the document type editor warns on a field id among them. */
122
+ * answers them by these names, and the document type editor warns on a field id among them.
123
+ * M35 P4: `name` (`_name`) is answered on `page` only until 35-C5 adds `child._name`; on a listed
124
+ * page it reads a field of that id, which none can be. */
75
125
  export const TEMPLATE_PAGE_FACTS = {
76
126
  children: "children",
77
127
  culture: "culture",
@@ -83,11 +133,13 @@ export const TEMPLATE_PAGE_FACTS = {
83
133
  locale: "locale",
84
134
  publishedAt: "publishedAt",
85
135
  fields: "fields",
136
+ /** M35 P4 (evidence 33): the page's own published name. A field id starts with a letter, so none can be `_name`. */
137
+ name: "_name",
86
138
  };
87
139
  /** The tags Kardalum's engine adds to Liquid's own, each written with no block body. A parse-only
88
140
  * engine (the CLI's templates check) knows them by name; the server's plugin-template-binding test
89
141
  * pins the list against the engine. */
90
- export const KARDALUM_TEMPLATE_TAGS = ["list", "form_protection", "plugin_head", "search"];
142
+ export const KARDALUM_TEMPLATE_TAGS = ["list", "form_protection", "plugin_head", "search", "plugin_tag"];
91
143
  const isLower = (c) => c >= "a" && c <= "z";
92
144
  const isDigit = (c) => c >= "0" && c <= "9";
93
145
  const isUpper = (c) => c >= "A" && c <= "Z";
@@ -100,42 +152,182 @@ function everyChar(test) {
100
152
  return true;
101
153
  };
102
154
  }
103
- /** M32 F2 (D2, D3): why a declared site route path is refused, or null. */
104
- export function siteRoutePathProblem(method, path) {
155
+ /** A parameter name: a letter, then letters, digits and "_", 1 to SITE_ROUTE_PARAM_NAME_MAX. */
156
+ function isParamName(name) {
157
+ if (name.length === 0 || name.length > SITE_ROUTE_PARAM_NAME_MAX)
158
+ return false;
159
+ if (!(isLower(name[0]) || isUpper(name[0])))
160
+ return false;
161
+ for (const c of name)
162
+ if (!(isLower(c) || isUpper(c) || isDigit(c) || c === "_"))
163
+ return false;
164
+ return true;
165
+ }
166
+ /**
167
+ * M32 F2 (D2, D3), M35 P3 (W18): a declared site route path read left to right, once, into its
168
+ * segments, or the first reason it is refused. The length is checked before any segment is read.
169
+ */
170
+ export function readSiteRoutePath(method, path) {
171
+ const no = (problem) => ({ ok: false, problem });
105
172
  if (!SITE_ROUTE_METHODS.includes(method))
106
- return `method must be one of ${SITE_ROUTE_METHODS.join(", ")}`;
107
- if (path.length === 0 || path.length > SITE_ROUTE_PATH_MAX)
108
- return `path must be 1 to ${SITE_ROUTE_PATH_MAX} characters`;
173
+ return no(`method must be one of ${SITE_ROUTE_METHODS.join(", ")}`);
174
+ if (typeof path !== "string" || path.length === 0 || path.length > SITE_ROUTE_PATH_MAX)
175
+ return no(`path must be 1 to ${SITE_ROUTE_PATH_MAX} characters`);
109
176
  if (path[0] !== "/")
110
- return 'path must start with "/"';
111
- const segments = path.slice(1).split("/");
112
- if (segments.length > SITE_ROUTE_SEGMENTS_MAX)
113
- return `path has at most ${SITE_ROUTE_SEGMENTS_MAX} segments`;
177
+ return no('path must start with "/"');
178
+ const raw = path.slice(1).split("/");
179
+ if (raw.length > SITE_ROUTE_SEGMENTS_MAX)
180
+ return no(`path has at most ${SITE_ROUTE_SEGMENTS_MAX} segments`);
181
+ const segments = [];
182
+ const params = [];
114
183
  let dotted = false;
115
- for (const segment of segments) {
184
+ for (let index = 0; index < raw.length; index += 1) {
185
+ const segment = raw[index];
186
+ const last = index === raw.length - 1;
116
187
  if (segment === "")
117
- return "path has no empty segment and no trailing slash";
188
+ return no("path has no empty segment and no trailing slash");
189
+ if (segment === "*") {
190
+ if (!last)
191
+ return no('a "*" is only the last segment');
192
+ if (index === 0)
193
+ return no('the first segment is a fixed name, never a parameter or "*"');
194
+ segments.push({ kind: "rest" });
195
+ params.push(SITE_ROUTE_REST_PARAM);
196
+ continue;
197
+ }
198
+ if (segment[0] === ":") {
199
+ if (index === 0)
200
+ return no('the first segment is a fixed name, never a parameter or "*"');
201
+ const name = segment.slice(1);
202
+ if (!isParamName(name))
203
+ return no(`a parameter is ":" and a name of 1 to ${SITE_ROUTE_PARAM_NAME_MAX} letters, digits and "_", starting with a letter`);
204
+ if (params.includes(name))
205
+ return no("path names each parameter name once");
206
+ segments.push({ kind: "param", name });
207
+ params.push(name);
208
+ continue;
209
+ }
118
210
  if (segment === "." || segment === "..")
119
- return 'path has no "." or ".." segment';
211
+ return no('path has no "." or ".." segment');
120
212
  if (segment.length > SITE_ROUTE_SEGMENT_MAX)
121
- return `each segment is at most ${SITE_ROUTE_SEGMENT_MAX} characters`;
213
+ return no(`each segment is at most ${SITE_ROUTE_SEGMENT_MAX} characters`);
122
214
  for (const c of segment) {
123
215
  if (!(isLower(c) || isUpper(c) || isDigit(c) || SEGMENT_EXTRA.has(c)))
124
- return 'segments hold letters, digits, ".", "_", "~" and "-" only';
216
+ return no('segments hold letters, digits, ".", "_", "~" and "-", or are ":<name>" or a last "*"');
125
217
  }
126
218
  if (segment.includes("."))
127
219
  dotted = true;
220
+ segments.push({ kind: "literal", value: segment });
128
221
  }
129
- if (isReservedRootSlug(segments[0]))
130
- return `"/${segments[0]}" is the server's own address`;
131
- if (method === "GET" && !dotted)
132
- return 'a GET site route has a "." in some segment (a file address such as /sitemap.xml), so it is never a page address';
222
+ if (params.filter((name) => name !== SITE_ROUTE_REST_PARAM).length > SITE_ROUTE_PARAMS_MAX)
223
+ return no(`path has at most ${SITE_ROUTE_PARAMS_MAX} parameters`);
224
+ const prefix = segments[0].value;
225
+ if (isReservedRootSlug(prefix))
226
+ return no(`"/${prefix}" is the server's own address`);
133
227
  // An HTML document at a site address is a page, which the CMS or the
134
228
  // owner's public/ folder answers: a route there would answer before the
135
229
  // owner's own public/ HTML file, which the order promises wins.
136
- const last = segments[segments.length - 1].toLowerCase();
137
- if (method === "GET" && (last.endsWith(".html") || last.endsWith(".htm")))
138
- return "a GET site route is not an HTML file address (.html or .htm): a page or a public/ file answers there";
230
+ const tail = segments[segments.length - 1];
231
+ if (method === "GET" && tail.kind === "literal") {
232
+ const lower = tail.value.toLowerCase();
233
+ if (lower.endsWith(".html") || lower.endsWith(".htm"))
234
+ return no("a GET site route is not an HTML file address (.html or .htm): a page or a public/ file answers there");
235
+ }
236
+ const patterned = segments.some((segment) => segment.kind !== "literal");
237
+ const phase = patterned || (method === "GET" && !dotted) ? "afterPages" : "fixed";
238
+ if (phase === "afterPages" && SITE_ROUTE_PATTERN_RESERVED_PREFIXES.includes(prefix.toLowerCase()))
239
+ return no(`"/${prefix}" is the visitor account pages' address`);
240
+ const shape = `${method} /${segments.map((segment) => (segment.kind === "literal" ? segment.value : segment.kind === "param" ? ":" : "*")).join("/")}`;
241
+ return { ok: true, pattern: { method: method, segments, phase, prefix, shape, params } };
242
+ }
243
+ /** M32 F2 (D2, D3): why a declared site route path is refused, or null. M35 P3: over readSiteRoutePath. */
244
+ export function siteRoutePathProblem(method, path) {
245
+ const read = readSiteRoutePath(method, path);
246
+ return read.ok ? null : read.problem;
247
+ }
248
+ /**
249
+ * M35 P3 (W18): a visitor's raw path (before "?") as decoded segments, or null when it matches no
250
+ * pattern: over SITE_ROUTE_MATCH_PATH_MAX characters, not starting with "/", an empty, "." or ".."
251
+ * segment (raw or decoded), a segment that does not decode, a decoded "/" or control character, or
252
+ * more than SITE_ROUTE_SEGMENTS_MAX + SITE_ROUTE_REST_SEGMENTS_MAX segments. Split first, then each
253
+ * segment decoded once, so an encoded "/" never makes a second segment.
254
+ */
255
+ export function readAddressSegments(rawPath) {
256
+ if (typeof rawPath !== "string" || rawPath.length < 2 || rawPath.length > SITE_ROUTE_MATCH_PATH_MAX || rawPath[0] !== "/")
257
+ return null;
258
+ const raw = rawPath.slice(1).split("/");
259
+ if (raw.length > SITE_ROUTE_SEGMENTS_MAX + SITE_ROUTE_REST_SEGMENTS_MAX)
260
+ return null;
261
+ const out = [];
262
+ for (const segment of raw) {
263
+ if (segment === "" || segment === "." || segment === "..")
264
+ return null;
265
+ let decoded;
266
+ try {
267
+ decoded = decodeURIComponent(segment);
268
+ }
269
+ catch {
270
+ return null;
271
+ }
272
+ if (decoded === "" || decoded === "." || decoded === ".." || decoded.includes("/") || !hasNoControlCharacter(decoded))
273
+ return null;
274
+ out.push(decoded);
275
+ }
276
+ return out;
277
+ }
278
+ /** M35 P3 (W18): the parameters of `segments` under `pattern`, frozen with no prototype, or null. */
279
+ export function matchSiteRoutePattern(pattern, segments) {
280
+ const params = Object.create(null);
281
+ for (let index = 0; index < pattern.segments.length; index += 1) {
282
+ const segment = pattern.segments[index];
283
+ if (segment.kind === "rest") {
284
+ const rest = segments.slice(index);
285
+ if (rest.length === 0 || rest.length > SITE_ROUTE_REST_SEGMENTS_MAX)
286
+ return null;
287
+ const joined = rest.join("/");
288
+ if (joined.length > SITE_ROUTE_REST_MAX)
289
+ return null;
290
+ params[SITE_ROUTE_REST_PARAM] = joined;
291
+ return Object.freeze(params);
292
+ }
293
+ const value = segments[index];
294
+ if (value === undefined)
295
+ return null;
296
+ if (segment.kind === "literal") {
297
+ if (value !== segment.value)
298
+ return null;
299
+ continue;
300
+ }
301
+ if (value.length > SITE_ROUTE_PARAM_VALUE_MAX)
302
+ return null;
303
+ params[segment.name] = value;
304
+ }
305
+ return segments.length === pattern.segments.length ? Object.freeze(params) : null;
306
+ }
307
+ const SPECIFICITY = { literal: 0, param: 1, rest: 2 };
308
+ /** M35 P3 (W18): negative when `a` is more specific, segment by segment from the left: a literal, then a parameter, then the rest. */
309
+ export function compareSiteRouteSpecificity(a, b) {
310
+ const length = Math.max(a.segments.length, b.segments.length);
311
+ for (let index = 0; index < length; index += 1) {
312
+ const left = a.segments[index];
313
+ const right = b.segments[index];
314
+ if (left === undefined || right === undefined)
315
+ return left === undefined ? 1 : -1;
316
+ const difference = SPECIFICITY[left.kind] - SPECIFICITY[right.kind];
317
+ if (difference !== 0)
318
+ return difference;
319
+ }
320
+ return 0;
321
+ }
322
+ /** M35 P2 (W21): why a site route's `rawBody` cannot stand, or null when it can (absent, or `true` on a
323
+ * POST route): the exact bytes of a body sent to be signed. GET has no body. */
324
+ export function siteRouteRawBodyProblem(route) {
325
+ if (route.rawBody === undefined)
326
+ return null;
327
+ if (route.rawBody !== true)
328
+ return "rawBody must be true when it is given";
329
+ if (route.method !== "POST")
330
+ return `rawBody is only for a POST site route, and this route is ${typeof route.method === "string" ? route.method : "not a method"}`;
139
331
  return null;
140
332
  }
141
333
  /** Every character is printable ASCII (no space): one linear scan. */
@@ -287,6 +479,59 @@ export function templatePrefixProblem(pluginId) {
287
479
  }
288
480
  return null;
289
481
  }
482
+ /** M35 P3 (W19): the tag that closes a plugin's block tag. */
483
+ export function templateBlockEndNameOf(fullName) {
484
+ return `end${fullName}`;
485
+ }
486
+ /** M35 P3 (W19): why a block tag's wrap class is refused, or null. One scan after the length check; the reason never quotes the value. */
487
+ export function templateBlockClassProblem(value) {
488
+ if (typeof value !== "string")
489
+ return "is not text";
490
+ if (value.length === 0)
491
+ return "is empty";
492
+ if (value.length > TEMPLATE_BLOCK_CLASS_MAX)
493
+ return `is more than ${TEMPLATE_BLOCK_CLASS_MAX} characters`;
494
+ for (const c of value) {
495
+ if (!(isLower(c) || isUpper(c) || isDigit(c) || c === "-" || c === "_" || c === " "))
496
+ return 'holds a character other than letters, digits, "-", "_" and spaces';
497
+ }
498
+ return null;
499
+ }
500
+ const KEEP_KEYS = new Set(["keepBody", "before", "after", "wrap"]);
501
+ const WRAP_KEYS = new Set(["element", "class"]);
502
+ /**
503
+ * M35 P3 (W19): a block tag's `{ keepBody: true, before?, after?, wrap? }` answer read without trusting it,
504
+ * or null when it is out of shape. `before` and `after` are text the binding cleans; the binding also measures
505
+ * them against TEMPLATE_OUTPUT_LIMIT_BYTES, before and after cleaning, so a long answer is reported as too large,
506
+ * not as out of shape. `wrap` names one of TEMPLATE_BLOCK_WRAP_ELEMENTS and an optional class. No other key. A
507
+ * null `before`, `after`, `wrap` or wrap `class` is read as absent, all four alike.
508
+ */
509
+ export function readTemplateBlockKeep(answer) {
510
+ if (answer === null || typeof answer !== "object" || Array.isArray(answer) || answer.keepBody !== true)
511
+ return null;
512
+ for (const key of Object.keys(answer))
513
+ if (!KEEP_KEYS.has(key))
514
+ return null;
515
+ const before = answer.before ?? "";
516
+ const after = answer.after ?? "";
517
+ if (typeof before !== "string" || typeof after !== "string")
518
+ return null;
519
+ const rawWrap = answer.wrap ?? null;
520
+ if (rawWrap === null)
521
+ return { before, after, wrap: null };
522
+ if (typeof rawWrap !== "object" || Array.isArray(rawWrap))
523
+ return null;
524
+ for (const key of Object.keys(rawWrap))
525
+ if (!WRAP_KEYS.has(key))
526
+ return null;
527
+ const element = rawWrap.element;
528
+ if (typeof element !== "string" || !TEMPLATE_BLOCK_WRAP_ELEMENTS.includes(element))
529
+ return null;
530
+ const wrapClass = rawWrap.class ?? null;
531
+ if (wrapClass !== null && templateBlockClassProblem(wrapClass) !== null)
532
+ return null;
533
+ return { before, after, wrap: { element: element, class: wrapClass } };
534
+ }
290
535
  const noControl = { message: "holds no control character" };
291
536
  const headName = z
292
537
  .string()
@@ -328,7 +573,9 @@ const dataKey = z
328
573
  .string()
329
574
  .min(1)
330
575
  .max(40)
331
- .refine(everyChar((c) => isLower(c) || isDigit(c) || c === "-"), { message: 'lower-case letters, digits and "-" only' });
576
+ .refine(everyChar((c) => isLower(c) || isDigit(c) || c === "-"), { message: 'lower-case letters, digits and "-" only' })
577
+ // M35 P5 (P5-D6): the core's own data- prefix carries an inert script's source and flags.
578
+ .refine((key) => !key.startsWith(CORE_DATA_PREFIX), { message: 'never starts with "kardalum-"' });
332
579
  const scriptEntry = z.strictObject({
333
580
  tag: z.literal("script"),
334
581
  src: headAddress,
@@ -346,6 +593,8 @@ const scriptEntry = z.strictObject({
346
593
  .record(dataKey, controlFree(0, 500))
347
594
  .refine((data) => Object.keys(data).length <= 10, { message: "at most 10 data attributes" })
348
595
  .optional(),
596
+ /** M35 P5 (P5-D6): written inert until the visitor grants this category. */
597
+ consent: z.enum(CONSENT_CATEGORIES).optional(),
349
598
  });
350
599
  function jsonLdFits(data) {
351
600
  let text;
@@ -369,9 +618,14 @@ const titleEntry = z.strictObject({
369
618
  tag: z.literal("title"),
370
619
  text: controlFree(1, PAGE_HEAD_TITLE_MAX).refine((text) => text.trim() !== "", { message: "a title with more than whitespace" }),
371
620
  });
621
+ /** M35 P1 (W40): code written into the page itself, from a plugin that declares `pageHead.inlineSnippets`.
622
+ * The text is checked by inlineSnippetProblem in checkPageHeadEntry, never by this shape alone. */
623
+ const inlineText = z.string().min(1).max(PAGE_HEAD_INLINE_TEXT_MAX_BYTES);
624
+ const inlineScriptEntry = z.strictObject({ tag: z.literal("inlineScript"), text: inlineText, module: z.boolean().optional(), consent: z.enum(CONSENT_CATEGORIES).optional() });
625
+ const inlineStyleEntry = z.strictObject({ tag: z.literal("inlineStyle"), text: inlineText, media: controlFree(1, 200).optional() });
372
626
  /** M32 F2: one entry a plugin adds to a page's <head>. */
373
- export const PageHeadEntrySchema = z.discriminatedUnion("tag", [metaEntry, linkEntry, scriptEntry, jsonLdEntry, titleEntry]);
374
- const HEAD_ENTRY_FIELDS = new Set(["name", "property", "content", "rel", "href", "hreflang", "type", "media", "crossorigin", "src", "async", "defer", "module", "integrity", "data", "text"]);
627
+ export const PageHeadEntrySchema = z.discriminatedUnion("tag", [metaEntry, linkEntry, scriptEntry, jsonLdEntry, titleEntry, inlineScriptEntry, inlineStyleEntry]);
628
+ const HEAD_ENTRY_FIELDS = new Set(["name", "property", "content", "rel", "href", "hreflang", "type", "media", "crossorigin", "src", "async", "defer", "module", "integrity", "data", "text", "consent"]);
375
629
  /** M33 K48: the longest file path the rule accepts, in characters. */
376
630
  export const PLUGIN_PUBLIC_FILE_PATH_MAX = 200;
377
631
  /**
@@ -405,6 +659,66 @@ export function isPluginPublicFilePath(path) {
405
659
  }
406
660
  return true;
407
661
  }
662
+ /** Whether text[at, at + name.length) is `name` (lower-case ASCII) in any ASCII case. */
663
+ function asciiNameAt(text, at, name) {
664
+ if (at + name.length > text.length)
665
+ return false;
666
+ for (let index = 0; index < name.length; index += 1) {
667
+ const code = text.charCodeAt(at + index);
668
+ const lower = code >= 0x41 && code <= 0x5a ? code + 0x20 : code;
669
+ if (lower !== name.charCodeAt(index))
670
+ return false;
671
+ }
672
+ return true;
673
+ }
674
+ /**
675
+ * M35 P1 (W40): why an inline snippet's text is refused, or null. The core writes the text between
676
+ * `<script>` and `</script>` (or `<style>` and `</style>`) exactly as given, so it never holds what
677
+ * could end its element or change how the browser reads it: for a script `<!--`, `<script` and
678
+ * `</script` in any ASCII case, for a style `</style`. No control character (C0, DEL or C1, U+0080
679
+ * to U+009F) but tab, line feed and carriage return, and no lone surrogate (the bytes served must be
680
+ * the bytes hashed; plugin-head.ts serves a carriage return as a line feed, as a browser reads it). At most
681
+ * PAGE_HEAD_INLINE_TEXT_MAX_BYTES of UTF-8. The length is checked before the scan, which reads each
682
+ * code unit once. The reason never quotes the text.
683
+ */
684
+ export function inlineSnippetProblem(tag, text) {
685
+ if (typeof text !== "string" || text.length === 0)
686
+ return "holds no text";
687
+ const tooLong = `is more than ${PAGE_HEAD_INLINE_TEXT_MAX_BYTES} bytes`;
688
+ if (text.length > PAGE_HEAD_INLINE_TEXT_MAX_BYTES)
689
+ return tooLong;
690
+ let bytes = 0;
691
+ for (let index = 0; index < text.length; index += 1) {
692
+ const code = text.charCodeAt(index);
693
+ if (code >= 0xd800 && code <= 0xdbff) {
694
+ const next = index + 1 < text.length ? text.charCodeAt(index + 1) : 0;
695
+ if (next < 0xdc00 || next > 0xdfff)
696
+ return "holds a lone surrogate";
697
+ bytes += 4;
698
+ index += 1;
699
+ continue;
700
+ }
701
+ if (code >= 0xdc00 && code <= 0xdfff)
702
+ return "holds a lone surrogate";
703
+ if ((code < 0x20 && code !== 0x09 && code !== 0x0a && code !== 0x0d) || (code >= 0x7f && code <= 0x9f))
704
+ return "holds a control character";
705
+ bytes += code < 0x80 ? 1 : code < 0x800 ? 2 : 3;
706
+ if (code !== 0x3c)
707
+ continue;
708
+ if (tag === "inlineScript") {
709
+ if (text.startsWith("!--", index + 1))
710
+ return 'holds "<!--"';
711
+ if (asciiNameAt(text, index + 1, "script"))
712
+ return 'holds "<script"';
713
+ if (text.charCodeAt(index + 1) === 0x2f && asciiNameAt(text, index + 2, "script"))
714
+ return 'holds "</script"';
715
+ }
716
+ else if (text.charCodeAt(index + 1) === 0x2f && asciiNameAt(text, index + 2, "style")) {
717
+ return 'holds "</style"';
718
+ }
719
+ }
720
+ return bytes > PAGE_HEAD_INLINE_TEXT_MAX_BYTES ? tooLong : null;
721
+ }
408
722
  /** The plugin's own browser file: `/plugin-assets/<id>/<version>/public/<file>`, the address the asset mount serves a file of the package's public/ folder at. */
409
723
  function ownAssetPath(value, pluginId) {
410
724
  const prefix = `/plugin-assets/${pluginId}/`;
@@ -442,15 +756,20 @@ function fromDeclaredOrigin(value, scriptOrigins) {
442
756
  return url.protocol === "https:" && url.username === "" && url.password === "" && scriptOrigins.includes(url.origin);
443
757
  }
444
758
  /** M32 F2: a page head entry checked against the plugin that gave it. The reason never quotes the value.
445
- * M33 K27: a title entry only from a plugin whose attached declaration says `setsTitle: true`. */
759
+ * M33 K27: a title entry only from a plugin whose attached declaration says `setsTitle: true`.
760
+ * M35 P1 (W40): an inline entry only from one whose declaration says `inlineSnippets: true`. */
446
761
  export function checkPageHeadEntry(entry, scope) {
447
762
  if (entry === null || typeof entry !== "object" || Array.isArray(entry))
448
763
  return { ok: false, reason: "not an object" };
449
764
  const tag = entry.tag;
450
- if (tag !== "meta" && tag !== "link" && tag !== "script" && tag !== "jsonLd" && tag !== "title")
765
+ if (tag !== "meta" && tag !== "link" && tag !== "script" && tag !== "jsonLd" && tag !== "title" && tag !== "inlineScript" && tag !== "inlineStyle") {
451
766
  return { ok: false, reason: "unknown tag" };
767
+ }
452
768
  if (tag === "title" && scope.setsTitle !== true)
453
769
  return { ok: false, reason: "title entry from a plugin that does not declare setsTitle" };
770
+ if ((tag === "inlineScript" || tag === "inlineStyle") && scope.inlineSnippets !== true) {
771
+ return { ok: false, reason: `${tag} entry from a plugin that does not declare inlineSnippets` };
772
+ }
454
773
  const parsed = PageHeadEntrySchema.safeParse(entry);
455
774
  if (!parsed.success) {
456
775
  const issue = parsed.error.issues[0];
@@ -460,6 +779,10 @@ export function checkPageHeadEntry(entry, scope) {
460
779
  return { ok: false, reason: field !== undefined && HEAD_ENTRY_FIELDS.has(field) ? `${tag} entry with a bad ${field}` : `malformed ${tag} entry` };
461
780
  }
462
781
  const value = parsed.data;
782
+ if (value.tag === "inlineScript" || value.tag === "inlineStyle") {
783
+ const problem = inlineSnippetProblem(value.tag, value.text);
784
+ return problem === null ? { ok: true, entry: value } : { ok: false, reason: `${value.tag} entry whose text ${problem}` };
785
+ }
463
786
  if (value.tag === "meta" && value.name !== undefined && POLICY_META_NAMES.has(value.name.toLowerCase())) {
464
787
  return { ok: false, reason: "meta entry that sets a page policy" };
465
788
  }
@@ -480,17 +803,17 @@ export function checkPageHeadEntry(entry, scope) {
480
803
  }
481
804
  return { ok: true, entry: value };
482
805
  }
483
- /** M32 F2: what a plugin's site fallback answers for an address no page holds. */
484
- export const SiteFallbackAnswerSchema = z.union([
485
- z.strictObject({
486
- redirect: z.strictObject({
487
- location: z.string().refine((value) => siteLocationProblem(value) === null, { message: 'a site path starting with "/" or an http or https URL' }),
488
- status: z.literal(SITE_REDIRECT_STATUSES),
489
- maxAgeSeconds: z.number().int().min(0).max(SITE_REDIRECT_MAX_AGE_MAX).optional(),
490
- }),
806
+ /** M35 P2 (W2): a redirect a plugin answers instead of the page: the site fallback's, and a request guard's.
807
+ * A site path or an http or https URL (siteLocationProblem), one of SITE_REDIRECT_STATUSES. */
808
+ export const SiteRedirectAnswerSchema = z.strictObject({
809
+ redirect: z.strictObject({
810
+ location: z.string().refine((value) => siteLocationProblem(value) === null, { message: 'a site path starting with "/" or an http or https URL' }),
811
+ status: z.literal(SITE_REDIRECT_STATUSES),
812
+ maxAgeSeconds: z.number().int().min(0).max(SITE_REDIRECT_MAX_AGE_MAX).optional(),
491
813
  }),
492
- z.strictObject({ gone: z.literal(true) }),
493
- ]);
814
+ });
815
+ /** M32 F2: what a plugin's site fallback answers for an address no page holds. */
816
+ export const SiteFallbackAnswerSchema = z.union([SiteRedirectAnswerSchema, z.strictObject({ gone: z.literal(true) })]);
494
817
  const isRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
495
818
  function checkTemplateList(key, value, issues) {
496
819
  const at = ["contributions", key];
@@ -512,6 +835,20 @@ function checkTemplateList(key, value, issues) {
512
835
  if (seen.has(name))
513
836
  issues.push({ path: [...at, index, "name"], message: "declares each name once" });
514
837
  seen.add(name);
838
+ // M35 P3 (W19, evidence 116): a tag's block and failure choice, a filter's failure choice.
839
+ const record = entry;
840
+ if (record.block !== undefined && (key !== "templateTags" || record.block !== true)) {
841
+ issues.push({ path: [...at, index, "block"], message: key === "templateTags" ? "is true when declared" : "is for a template tag only" });
842
+ }
843
+ if (record.onFailure !== undefined) {
844
+ const allowed = key === "templateFilters" ? TEMPLATE_FILTER_ON_FAILURE : record.block === true ? TEMPLATE_BLOCK_ON_FAILURE : [];
845
+ if (typeof record.onFailure !== "string" || !allowed.includes(record.onFailure)) {
846
+ issues.push({
847
+ path: [...at, index, "onFailure"],
848
+ message: key === "templateFilters" ? `is one of ${TEMPLATE_FILTER_ON_FAILURE.join(", ")}` : record.block === true ? `is one of ${TEMPLATE_BLOCK_ON_FAILURE.join(", ")}` : "is for a block tag only (block: true)",
849
+ });
850
+ }
851
+ }
515
852
  });
516
853
  return value.length > 0;
517
854
  }
@@ -538,15 +875,24 @@ export function checkSiteExtensionDeclarations(manifest) {
538
875
  return;
539
876
  }
540
877
  const methodOk = SITE_ROUTE_METHODS.includes(route.method);
541
- const problem = siteRoutePathProblem(route.method, route.path);
542
- if (problem !== null) {
543
- issues.push({ path: [...at, methodOk ? "path" : "method"], message: problem });
878
+ const read = readSiteRoutePath(route.method, route.path);
879
+ if (!read.ok) {
880
+ issues.push({ path: [...at, methodOk ? "path" : "method"], message: read.problem });
544
881
  return;
545
882
  }
546
- const key = `${route.method} ${route.path}`;
883
+ // M35 P3 (W18): one route per method and shape, so `/shop/:id` and `/shop/:slug` cannot both stand.
884
+ const key = read.pattern.shape;
547
885
  if (seen.has(key))
548
886
  issues.push({ path: at, message: "declares each method and path once" });
549
887
  seen.add(key);
888
+ // M35 P2 (W21): the exact bytes, only on a POST route.
889
+ const rawBody = siteRouteRawBodyProblem(route);
890
+ if (rawBody !== null)
891
+ issues.push({ path: [...at, "rawBody"], message: rawBody });
892
+ // M35 B3 (W17): files, on a POST site route without rawBody, within the upload limits.
893
+ const uploads = routeUploadsProblem(route, SITE_ROUTE_UPLOAD_METHODS, "site route");
894
+ if (uploads !== null)
895
+ issues.push({ path: [...at, "uploads"], message: uploads });
550
896
  });
551
897
  }
552
898
  }
@@ -596,6 +942,10 @@ export function checkSiteExtensionDeclarations(manifest) {
596
942
  if (isRecord(head) && head.setsTitle !== undefined && head.setsTitle !== true) {
597
943
  issues.push({ path: ["contributions", "pageHead", "setsTitle"], message: "is true when declared" });
598
944
  }
945
+ // M35 P1 (W40): the one declaration that lets a plugin's head write inline code.
946
+ if (isRecord(head) && head.inlineSnippets !== undefined && head.inlineSnippets !== true) {
947
+ issues.push({ path: ["contributions", "pageHead", "inlineSnippets"], message: "is true when declared" });
948
+ }
599
949
  }
600
950
  // M33 K42: held content from other sites, by the rules of plugin-held-embeds.ts, each issue under
601
951
  // its entry's own path.
@@ -608,5 +958,19 @@ export function checkSiteExtensionDeclarations(manifest) {
608
958
  }
609
959
  }
610
960
  }
961
+ // M35 P1 (W3): the page output transform. manifest.json carries `true` (the transform is code, which the
962
+ // writer cannot keep), the live manifest an object, whose shape the SDK's manifest schema checks.
963
+ const output = contributions.pageOutput;
964
+ if (output !== undefined && output !== true && !isRecord(output)) {
965
+ issues.push({ path: ["contributions", "pageOutput"], message: "is true or an object" });
966
+ }
967
+ // M35 P2 (W2): the request guard and the response headers. manifest.json carries `true` (each is code,
968
+ // which the writer cannot keep), the live manifest an object, whose shape the SDK's manifest schema checks.
969
+ // M35 P4 (W32, W46): and the page cache and the page gate.
970
+ for (const key of ["requestGuard", "responseHeaders", "pageCache", "pageGate"]) {
971
+ const declared = contributions[key];
972
+ if (declared !== undefined && declared !== true && !isRecord(declared))
973
+ issues.push({ path: ["contributions", key], message: "is true or an object" });
974
+ }
611
975
  return issues;
612
976
  }