pagiera 0.2.0-alpha.52 → 0.2.0-alpha.53

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 (412) hide show
  1. package/AGENTS.md +286 -0
  2. package/AI-WORKSPACE.md +35 -0
  3. package/cli/main.mjs +77 -0
  4. package/dist/chunks/chunk-IFG75HHC.js +8 -0
  5. package/dist/chunks/chunk-IFG75HHC.js.map +7 -0
  6. package/dist/chunks/icons-2B5KRXQS.js +19355 -0
  7. package/dist/chunks/icons-2B5KRXQS.js.map +7 -0
  8. package/dist/chunks/icons-OFIRQRNS.js +9802 -0
  9. package/dist/chunks/icons-OFIRQRNS.js.map +7 -0
  10. package/dist/chunks/icons-VLOKOYB2.js +6348 -0
  11. package/dist/chunks/icons-VLOKOYB2.js.map +7 -0
  12. package/dist/client.d.ts +6 -0
  13. package/dist/client.d.ts.map +1 -1
  14. package/dist/client.js +3 -0
  15. package/dist/client.js.map +1 -1
  16. package/dist/data.js.map +1 -1
  17. package/dist/document.d.ts +2 -0
  18. package/dist/document.d.ts.map +1 -1
  19. package/dist/document.js.map +1 -1
  20. package/dist/full-editor.d.ts +2 -0
  21. package/dist/full-editor.js +9716 -5386
  22. package/dist/full-editor.js.map +4 -4
  23. package/dist/full.css +1268 -321
  24. package/dist/internal/app/api/ai-design/route.d.ts.map +1 -1
  25. package/dist/internal/app/api/ai-design/route.js +75 -0
  26. package/dist/internal/app/api/ai-design/route.js.map +1 -1
  27. package/dist/internal/app/p/editor/ai-panel.d.ts +6 -1
  28. package/dist/internal/app/p/editor/ai-panel.d.ts.map +1 -1
  29. package/dist/internal/app/p/editor/ai-panel.js +77 -18
  30. package/dist/internal/app/p/editor/ai-panel.js.map +1 -1
  31. package/dist/internal/app/p/editor/data-modal.js +2 -2
  32. package/dist/internal/app/p/editor/data-modal.js.map +1 -1
  33. package/dist/internal/app/p/editor/data-panel.js +1 -1
  34. package/dist/internal/app/p/editor/data-panel.js.map +1 -1
  35. package/dist/internal/app/p/editor/drop-target.d.ts +25 -1
  36. package/dist/internal/app/p/editor/drop-target.d.ts.map +1 -1
  37. package/dist/internal/app/p/editor/drop-target.js +80 -15
  38. package/dist/internal/app/p/editor/drop-target.js.map +1 -1
  39. package/dist/internal/app/p/editor/editor.d.ts +8 -0
  40. package/dist/internal/app/p/editor/editor.d.ts.map +1 -1
  41. package/dist/internal/app/p/editor/editor.js +2120 -412
  42. package/dist/internal/app/p/editor/editor.js.map +1 -1
  43. package/dist/internal/app/p/editor/fields.d.ts +18 -0
  44. package/dist/internal/app/p/editor/fields.d.ts.map +1 -1
  45. package/dist/internal/app/p/editor/fields.js +22 -6
  46. package/dist/internal/app/p/editor/fields.js.map +1 -1
  47. package/dist/internal/app/p/editor/gesture-layer.d.ts +49 -0
  48. package/dist/internal/app/p/editor/gesture-layer.d.ts.map +1 -0
  49. package/dist/internal/app/p/editor/gesture-layer.js +88 -0
  50. package/dist/internal/app/p/editor/gesture-layer.js.map +1 -0
  51. package/dist/internal/app/p/editor/history-panel.js +3 -3
  52. package/dist/internal/app/p/editor/history-panel.js.map +1 -1
  53. package/dist/internal/app/p/editor/inspector.d.ts +9 -2
  54. package/dist/internal/app/p/editor/inspector.d.ts.map +1 -1
  55. package/dist/internal/app/p/editor/inspector.js +202 -56
  56. package/dist/internal/app/p/editor/inspector.js.map +1 -1
  57. package/dist/internal/app/p/editor/library.js +4 -4
  58. package/dist/internal/app/p/editor/library.js.map +1 -1
  59. package/dist/internal/app/p/editor/parts.d.ts +38 -13
  60. package/dist/internal/app/p/editor/parts.d.ts.map +1 -1
  61. package/dist/internal/app/p/editor/parts.js +220 -127
  62. package/dist/internal/app/p/editor/parts.js.map +1 -1
  63. package/dist/internal/app/p/editor/rulers.d.ts +44 -0
  64. package/dist/internal/app/p/editor/rulers.d.ts.map +1 -0
  65. package/dist/internal/app/p/editor/rulers.js +52 -0
  66. package/dist/internal/app/p/editor/rulers.js.map +1 -0
  67. package/dist/internal/app/p/editor/shell.d.ts +43 -0
  68. package/dist/internal/app/p/editor/shell.d.ts.map +1 -0
  69. package/dist/internal/app/p/editor/shell.js +19 -0
  70. package/dist/internal/app/p/editor/shell.js.map +1 -0
  71. package/dist/internal/app/p/editor/template-preview.js +2 -2
  72. package/dist/internal/app/p/editor/template-preview.js.map +1 -1
  73. package/dist/internal/app/p/editor/templates-panel.d.ts +4 -1
  74. package/dist/internal/app/p/editor/templates-panel.d.ts.map +1 -1
  75. package/dist/internal/app/p/editor/templates-panel.js +15 -6
  76. package/dist/internal/app/p/editor/templates-panel.js.map +1 -1
  77. package/dist/internal/app/p/editor/ui/ai-changes.d.ts +8 -0
  78. package/dist/internal/app/p/editor/ui/ai-changes.d.ts.map +1 -0
  79. package/dist/internal/app/p/editor/ui/ai-changes.js +27 -0
  80. package/dist/internal/app/p/editor/ui/ai-changes.js.map +1 -0
  81. package/dist/internal/app/p/editor/ui/ai-composer.d.ts +14 -0
  82. package/dist/internal/app/p/editor/ui/ai-composer.d.ts.map +1 -0
  83. package/dist/internal/app/p/editor/ui/ai-composer.js +24 -0
  84. package/dist/internal/app/p/editor/ui/ai-composer.js.map +1 -0
  85. package/dist/internal/app/p/editor/ui/ai-mention-menu.d.ts +16 -0
  86. package/dist/internal/app/p/editor/ui/ai-mention-menu.d.ts.map +1 -0
  87. package/dist/internal/app/p/editor/ui/ai-mention-menu.js +12 -0
  88. package/dist/internal/app/p/editor/ui/ai-mention-menu.js.map +1 -0
  89. package/dist/internal/app/p/editor/ui/ai-settings.d.ts +8 -0
  90. package/dist/internal/app/p/editor/ui/ai-settings.d.ts.map +1 -0
  91. package/dist/internal/app/p/editor/ui/ai-settings.js +7 -0
  92. package/dist/internal/app/p/editor/ui/ai-settings.js.map +1 -0
  93. package/dist/internal/app/p/editor/ui/ai-welcome.d.ts +5 -0
  94. package/dist/internal/app/p/editor/ui/ai-welcome.d.ts.map +1 -0
  95. package/dist/internal/app/p/editor/ui/ai-welcome.js +11 -0
  96. package/dist/internal/app/p/editor/ui/ai-welcome.js.map +1 -0
  97. package/dist/internal/app/p/editor/ui/assets-panel.d.ts +18 -0
  98. package/dist/internal/app/p/editor/ui/assets-panel.d.ts.map +1 -0
  99. package/dist/internal/app/p/editor/ui/assets-panel.js +15 -0
  100. package/dist/internal/app/p/editor/ui/assets-panel.js.map +1 -0
  101. package/dist/internal/app/p/editor/ui/button.d.ts +33 -0
  102. package/dist/internal/app/p/editor/ui/button.d.ts.map +1 -0
  103. package/dist/internal/app/p/editor/ui/button.js +39 -0
  104. package/dist/internal/app/p/editor/ui/button.js.map +1 -0
  105. package/dist/internal/app/p/editor/ui/carousel-editor.d.ts +14 -0
  106. package/dist/internal/app/p/editor/ui/carousel-editor.d.ts.map +1 -0
  107. package/dist/internal/app/p/editor/ui/carousel-editor.js +23 -0
  108. package/dist/internal/app/p/editor/ui/carousel-editor.js.map +1 -0
  109. package/dist/internal/app/p/editor/ui/fields/choice.d.ts +38 -0
  110. package/dist/internal/app/p/editor/ui/fields/choice.d.ts.map +1 -0
  111. package/dist/internal/app/p/editor/ui/fields/choice.js +32 -0
  112. package/dist/internal/app/p/editor/ui/fields/choice.js.map +1 -0
  113. package/dist/internal/app/p/editor/ui/fields/color.d.ts +7 -0
  114. package/dist/internal/app/p/editor/ui/fields/color.d.ts.map +1 -0
  115. package/dist/internal/app/p/editor/ui/fields/color.js +12 -0
  116. package/dist/internal/app/p/editor/ui/fields/color.js.map +1 -0
  117. package/dist/internal/app/p/editor/ui/fields/group.d.ts +54 -0
  118. package/dist/internal/app/p/editor/ui/fields/group.d.ts.map +1 -0
  119. package/dist/internal/app/p/editor/ui/fields/group.js +82 -0
  120. package/dist/internal/app/p/editor/ui/fields/group.js.map +1 -0
  121. package/dist/internal/app/p/editor/ui/fields/index.d.ts +19 -0
  122. package/dist/internal/app/p/editor/ui/fields/index.d.ts.map +1 -0
  123. package/dist/internal/app/p/editor/ui/fields/index.js +19 -0
  124. package/dist/internal/app/p/editor/ui/fields/index.js.map +1 -0
  125. package/dist/internal/app/p/editor/ui/fields/number.d.ts +52 -0
  126. package/dist/internal/app/p/editor/ui/fields/number.d.ts.map +1 -0
  127. package/dist/internal/app/p/editor/ui/fields/number.js +65 -0
  128. package/dist/internal/app/p/editor/ui/fields/number.js.map +1 -0
  129. package/dist/internal/app/p/editor/ui/fields/size.d.ts +16 -0
  130. package/dist/internal/app/p/editor/ui/fields/size.d.ts.map +1 -0
  131. package/dist/internal/app/p/editor/ui/fields/size.js +31 -0
  132. package/dist/internal/app/p/editor/ui/fields/size.js.map +1 -0
  133. package/dist/internal/app/p/editor/ui/fields/style.d.ts +9 -0
  134. package/dist/internal/app/p/editor/ui/fields/style.d.ts.map +1 -0
  135. package/dist/internal/app/p/editor/ui/fields/style.js +18 -0
  136. package/dist/internal/app/p/editor/ui/fields/style.js.map +1 -0
  137. package/dist/internal/app/p/editor/ui/fields/text.d.ts +27 -0
  138. package/dist/internal/app/p/editor/ui/fields/text.d.ts.map +1 -0
  139. package/dist/internal/app/p/editor/ui/fields/text.js +26 -0
  140. package/dist/internal/app/p/editor/ui/fields/text.js.map +1 -0
  141. package/dist/internal/app/p/editor/ui/icons-panel.d.ts +6 -0
  142. package/dist/internal/app/p/editor/ui/icons-panel.d.ts.map +1 -0
  143. package/dist/internal/app/p/editor/ui/icons-panel.js +52 -0
  144. package/dist/internal/app/p/editor/ui/icons-panel.js.map +1 -0
  145. package/dist/internal/app/p/editor/ui/index.d.ts +32 -0
  146. package/dist/internal/app/p/editor/ui/index.d.ts.map +1 -0
  147. package/dist/internal/app/p/editor/ui/index.js +32 -0
  148. package/dist/internal/app/p/editor/ui/index.js.map +1 -0
  149. package/dist/internal/app/p/editor/ui/insert-menu.d.ts +7 -0
  150. package/dist/internal/app/p/editor/ui/insert-menu.d.ts.map +1 -0
  151. package/dist/internal/app/p/editor/ui/insert-menu.js +36 -0
  152. package/dist/internal/app/p/editor/ui/insert-menu.js.map +1 -0
  153. package/dist/internal/app/p/editor/ui/marquee-preview.d.ts +8 -0
  154. package/dist/internal/app/p/editor/ui/marquee-preview.d.ts.map +1 -0
  155. package/dist/internal/app/p/editor/ui/marquee-preview.js +12 -0
  156. package/dist/internal/app/p/editor/ui/marquee-preview.js.map +1 -0
  157. package/dist/internal/app/p/editor/ui/mcp-panel.d.ts +19 -0
  158. package/dist/internal/app/p/editor/ui/mcp-panel.d.ts.map +1 -0
  159. package/dist/internal/app/p/editor/ui/mcp-panel.js +37 -0
  160. package/dist/internal/app/p/editor/ui/mcp-panel.js.map +1 -0
  161. package/dist/internal/app/p/editor/ui/menu.d.ts +39 -0
  162. package/dist/internal/app/p/editor/ui/menu.d.ts.map +1 -0
  163. package/dist/internal/app/p/editor/ui/menu.js +41 -0
  164. package/dist/internal/app/p/editor/ui/menu.js.map +1 -0
  165. package/dist/internal/app/p/editor/ui/panel.d.ts +18 -0
  166. package/dist/internal/app/p/editor/ui/panel.d.ts.map +1 -0
  167. package/dist/internal/app/p/editor/ui/panel.js +18 -0
  168. package/dist/internal/app/p/editor/ui/panel.js.map +1 -0
  169. package/dist/internal/app/p/editor/ui/popup-surface.d.ts +3 -0
  170. package/dist/internal/app/p/editor/ui/popup-surface.d.ts.map +1 -0
  171. package/dist/internal/app/p/editor/ui/popup-surface.js +9 -0
  172. package/dist/internal/app/p/editor/ui/popup-surface.js.map +1 -0
  173. package/dist/internal/app/p/editor/ui/rail.d.ts +15 -0
  174. package/dist/internal/app/p/editor/ui/rail.d.ts.map +1 -0
  175. package/dist/internal/app/p/editor/ui/rail.js +16 -0
  176. package/dist/internal/app/p/editor/ui/rail.js.map +1 -0
  177. package/dist/internal/app/p/editor/ui/settings-nav.d.ts +16 -0
  178. package/dist/internal/app/p/editor/ui/settings-nav.d.ts.map +1 -0
  179. package/dist/internal/app/p/editor/ui/settings-nav.js +20 -0
  180. package/dist/internal/app/p/editor/ui/settings-nav.js.map +1 -0
  181. package/dist/internal/app/p/editor/ui/shell.d.ts +43 -0
  182. package/dist/internal/app/p/editor/ui/shell.d.ts.map +1 -0
  183. package/dist/internal/app/p/editor/ui/shell.js +19 -0
  184. package/dist/internal/app/p/editor/ui/shell.js.map +1 -0
  185. package/dist/internal/app/p/editor/ui/toolbar.d.ts +10 -0
  186. package/dist/internal/app/p/editor/ui/toolbar.d.ts.map +1 -0
  187. package/dist/internal/app/p/editor/ui/toolbar.js +21 -0
  188. package/dist/internal/app/p/editor/ui/toolbar.js.map +1 -0
  189. package/dist/internal/app/p/editor/ui/tooltip.d.ts +13 -0
  190. package/dist/internal/app/p/editor/ui/tooltip.d.ts.map +1 -0
  191. package/dist/internal/app/p/editor/ui/tooltip.js +15 -0
  192. package/dist/internal/app/p/editor/ui/tooltip.js.map +1 -0
  193. package/dist/internal/app/p/editor/ui/workspace-menu.d.ts +14 -0
  194. package/dist/internal/app/p/editor/ui/workspace-menu.d.ts.map +1 -0
  195. package/dist/internal/app/p/editor/ui/workspace-menu.js +25 -0
  196. package/dist/internal/app/p/editor/ui/workspace-menu.js.map +1 -0
  197. package/dist/internal/app/p/editor/ui/workspace-tabs.d.ts +19 -0
  198. package/dist/internal/app/p/editor/ui/workspace-tabs.d.ts.map +1 -0
  199. package/dist/internal/app/p/editor/ui/workspace-tabs.js +67 -0
  200. package/dist/internal/app/p/editor/ui/workspace-tabs.js.map +1 -0
  201. package/dist/internal/app/p/editor/use-editor.d.ts +1 -1
  202. package/dist/internal/app/p/editor/use-editor.d.ts.map +1 -1
  203. package/dist/internal/app/p/editor/use-editor.js +4 -2
  204. package/dist/internal/app/p/editor/use-editor.js.map +1 -1
  205. package/dist/internal/app/p/editor/variables-panel.d.ts.map +1 -1
  206. package/dist/internal/app/p/editor/variables-panel.js +20 -3
  207. package/dist/internal/app/p/editor/variables-panel.js.map +1 -1
  208. package/dist/internal/components/editor/chrome.d.ts +85 -0
  209. package/dist/internal/components/editor/chrome.d.ts.map +1 -0
  210. package/dist/internal/components/editor/chrome.js +83 -0
  211. package/dist/internal/components/editor/chrome.js.map +1 -0
  212. package/dist/internal/components/editor/index.d.ts +17 -0
  213. package/dist/internal/components/editor/index.d.ts.map +1 -0
  214. package/dist/internal/components/editor/index.js +17 -0
  215. package/dist/internal/components/editor/index.js.map +1 -0
  216. package/dist/internal/components/editor/menu.d.ts +38 -0
  217. package/dist/internal/components/editor/menu.d.ts.map +1 -0
  218. package/dist/internal/components/editor/menu.js +40 -0
  219. package/dist/internal/components/editor/menu.js.map +1 -0
  220. package/dist/internal/components/editor/shell.d.ts +43 -0
  221. package/dist/internal/components/editor/shell.d.ts.map +1 -0
  222. package/dist/internal/components/editor/shell.js +19 -0
  223. package/dist/internal/components/editor/shell.js.map +1 -0
  224. package/dist/internal/components/editor/ui/button.d.ts +33 -0
  225. package/dist/internal/components/editor/ui/button.d.ts.map +1 -0
  226. package/dist/internal/components/editor/ui/button.js +39 -0
  227. package/dist/internal/components/editor/ui/button.js.map +1 -0
  228. package/dist/internal/components/editor/ui/fields/choice.d.ts +38 -0
  229. package/dist/internal/components/editor/ui/fields/choice.d.ts.map +1 -0
  230. package/dist/internal/components/editor/ui/fields/choice.js +32 -0
  231. package/dist/internal/components/editor/ui/fields/choice.js.map +1 -0
  232. package/dist/internal/components/editor/ui/fields/color.d.ts +7 -0
  233. package/dist/internal/components/editor/ui/fields/color.d.ts.map +1 -0
  234. package/dist/internal/components/editor/ui/fields/color.js +12 -0
  235. package/dist/internal/components/editor/ui/fields/color.js.map +1 -0
  236. package/dist/internal/components/editor/ui/fields/group.d.ts +54 -0
  237. package/dist/internal/components/editor/ui/fields/group.d.ts.map +1 -0
  238. package/dist/internal/components/editor/ui/fields/group.js +82 -0
  239. package/dist/internal/components/editor/ui/fields/group.js.map +1 -0
  240. package/dist/internal/components/editor/ui/fields/index.d.ts +19 -0
  241. package/dist/internal/components/editor/ui/fields/index.d.ts.map +1 -0
  242. package/dist/internal/components/editor/ui/fields/index.js +19 -0
  243. package/dist/internal/components/editor/ui/fields/index.js.map +1 -0
  244. package/dist/internal/components/editor/ui/fields/number.d.ts +52 -0
  245. package/dist/internal/components/editor/ui/fields/number.d.ts.map +1 -0
  246. package/dist/internal/components/editor/ui/fields/number.js +65 -0
  247. package/dist/internal/components/editor/ui/fields/number.js.map +1 -0
  248. package/dist/internal/components/editor/ui/fields/size.d.ts +16 -0
  249. package/dist/internal/components/editor/ui/fields/size.d.ts.map +1 -0
  250. package/dist/internal/components/editor/ui/fields/size.js +31 -0
  251. package/dist/internal/components/editor/ui/fields/size.js.map +1 -0
  252. package/dist/internal/components/editor/ui/fields/style.d.ts +9 -0
  253. package/dist/internal/components/editor/ui/fields/style.d.ts.map +1 -0
  254. package/dist/internal/components/editor/ui/fields/style.js +18 -0
  255. package/dist/internal/components/editor/ui/fields/style.js.map +1 -0
  256. package/dist/internal/components/editor/ui/fields/text.d.ts +27 -0
  257. package/dist/internal/components/editor/ui/fields/text.d.ts.map +1 -0
  258. package/dist/internal/components/editor/ui/fields/text.js +26 -0
  259. package/dist/internal/components/editor/ui/fields/text.js.map +1 -0
  260. package/dist/internal/components/editor/ui/index.d.ts +30 -0
  261. package/dist/internal/components/editor/ui/index.d.ts.map +1 -0
  262. package/dist/internal/components/editor/ui/index.js +30 -0
  263. package/dist/internal/components/editor/ui/index.js.map +1 -0
  264. package/dist/internal/components/editor/ui/menu.d.ts +38 -0
  265. package/dist/internal/components/editor/ui/menu.d.ts.map +1 -0
  266. package/dist/internal/components/editor/ui/menu.js +40 -0
  267. package/dist/internal/components/editor/ui/menu.js.map +1 -0
  268. package/dist/internal/components/editor/ui/panel.d.ts +18 -0
  269. package/dist/internal/components/editor/ui/panel.d.ts.map +1 -0
  270. package/dist/internal/components/editor/ui/panel.js +18 -0
  271. package/dist/internal/components/editor/ui/panel.js.map +1 -0
  272. package/dist/internal/components/editor/ui/rail.d.ts +15 -0
  273. package/dist/internal/components/editor/ui/rail.d.ts.map +1 -0
  274. package/dist/internal/components/editor/ui/rail.js +16 -0
  275. package/dist/internal/components/editor/ui/rail.js.map +1 -0
  276. package/dist/internal/components/editor/ui/shell.d.ts +43 -0
  277. package/dist/internal/components/editor/ui/shell.d.ts.map +1 -0
  278. package/dist/internal/components/editor/ui/shell.js +19 -0
  279. package/dist/internal/components/editor/ui/shell.js.map +1 -0
  280. package/dist/internal/components/editor/ui/toolbar.d.ts +10 -0
  281. package/dist/internal/components/editor/ui/toolbar.d.ts.map +1 -0
  282. package/dist/internal/components/editor/ui/toolbar.js +21 -0
  283. package/dist/internal/components/editor/ui/toolbar.js.map +1 -0
  284. package/dist/internal/components/editor/ui/tooltip.d.ts +13 -0
  285. package/dist/internal/components/editor/ui/tooltip.d.ts.map +1 -0
  286. package/dist/internal/components/editor/ui/tooltip.js +15 -0
  287. package/dist/internal/components/editor/ui/tooltip.js.map +1 -0
  288. package/dist/internal/components/ui/menu.d.ts +38 -0
  289. package/dist/internal/components/ui/menu.d.ts.map +1 -0
  290. package/dist/internal/components/ui/menu.js +40 -0
  291. package/dist/internal/components/ui/menu.js.map +1 -0
  292. package/dist/internal/components/ui/select.js +6 -6
  293. package/dist/internal/components/ui/select.js.map +1 -1
  294. package/dist/internal/drizzle/schema.d.ts +50 -0
  295. package/dist/internal/drizzle/schema.d.ts.map +1 -1
  296. package/dist/internal/drizzle/schema.js +3 -0
  297. package/dist/internal/drizzle/schema.js.map +1 -1
  298. package/dist/internal/lib/editor/ai-scope.d.ts +5 -0
  299. package/dist/internal/lib/editor/ai-scope.d.ts.map +1 -0
  300. package/dist/internal/lib/editor/ai-scope.js +40 -0
  301. package/dist/internal/lib/editor/ai-scope.js.map +1 -0
  302. package/dist/internal/lib/editor/ai-types.d.ts +1 -0
  303. package/dist/internal/lib/editor/ai-types.d.ts.map +1 -1
  304. package/dist/internal/lib/editor/canvas-target.d.ts +3 -0
  305. package/dist/internal/lib/editor/canvas-target.d.ts.map +1 -0
  306. package/dist/internal/lib/editor/canvas-target.js +6 -0
  307. package/dist/internal/lib/editor/canvas-target.js.map +1 -0
  308. package/dist/internal/lib/editor/carousel-controls.d.ts +9 -0
  309. package/dist/internal/lib/editor/carousel-controls.d.ts.map +1 -0
  310. package/dist/internal/lib/editor/carousel-controls.js +14 -0
  311. package/dist/internal/lib/editor/carousel-controls.js.map +1 -0
  312. package/dist/internal/lib/editor/carousel.d.ts +5 -0
  313. package/dist/internal/lib/editor/carousel.d.ts.map +1 -0
  314. package/dist/internal/lib/editor/carousel.js +230 -0
  315. package/dist/internal/lib/editor/carousel.js.map +1 -0
  316. package/dist/internal/lib/editor/cascade.d.ts +20 -0
  317. package/dist/internal/lib/editor/cascade.d.ts.map +1 -1
  318. package/dist/internal/lib/editor/cascade.js +55 -0
  319. package/dist/internal/lib/editor/cascade.js.map +1 -1
  320. package/dist/internal/lib/editor/disclosure.d.ts +11 -0
  321. package/dist/internal/lib/editor/disclosure.d.ts.map +1 -0
  322. package/dist/internal/lib/editor/disclosure.js +42 -0
  323. package/dist/internal/lib/editor/disclosure.js.map +1 -0
  324. package/dist/internal/lib/editor/field-appearance.d.ts +11 -0
  325. package/dist/internal/lib/editor/field-appearance.d.ts.map +1 -0
  326. package/dist/internal/lib/editor/field-appearance.js +16 -0
  327. package/dist/internal/lib/editor/field-appearance.js.map +1 -0
  328. package/dist/internal/lib/editor/icon-library.d.ts +19 -0
  329. package/dist/internal/lib/editor/icon-library.d.ts.map +1 -0
  330. package/dist/internal/lib/editor/icon-library.js +38 -0
  331. package/dist/internal/lib/editor/icon-library.js.map +1 -0
  332. package/dist/internal/lib/editor/interactive.d.ts +33 -0
  333. package/dist/internal/lib/editor/interactive.d.ts.map +1 -0
  334. package/dist/internal/lib/editor/interactive.js +92 -0
  335. package/dist/internal/lib/editor/interactive.js.map +1 -0
  336. package/dist/internal/lib/editor/page-layout.d.ts +5 -0
  337. package/dist/internal/lib/editor/page-layout.d.ts.map +1 -0
  338. package/dist/internal/lib/editor/page-layout.js +31 -0
  339. package/dist/internal/lib/editor/page-layout.js.map +1 -0
  340. package/dist/internal/lib/editor/shaders.d.ts +52 -0
  341. package/dist/internal/lib/editor/shaders.d.ts.map +1 -0
  342. package/dist/internal/lib/editor/shaders.js +58 -0
  343. package/dist/internal/lib/editor/shaders.js.map +1 -0
  344. package/dist/internal/lib/editor/style.d.ts +10 -2
  345. package/dist/internal/lib/editor/style.d.ts.map +1 -1
  346. package/dist/internal/lib/editor/style.js +32 -12
  347. package/dist/internal/lib/editor/style.js.map +1 -1
  348. package/dist/internal/lib/editor/text-effects.d.ts +14 -0
  349. package/dist/internal/lib/editor/text-effects.d.ts.map +1 -0
  350. package/dist/internal/lib/editor/text-effects.js +9 -0
  351. package/dist/internal/lib/editor/text-effects.js.map +1 -0
  352. package/dist/internal/lib/editor/tree.d.ts +3 -14
  353. package/dist/internal/lib/editor/tree.d.ts.map +1 -1
  354. package/dist/internal/lib/editor/tree.js +15 -37
  355. package/dist/internal/lib/editor/tree.js.map +1 -1
  356. package/dist/internal/lib/editor/types.d.ts +91 -2
  357. package/dist/internal/lib/editor/types.d.ts.map +1 -1
  358. package/dist/internal/lib/editor/types.js +29 -0
  359. package/dist/internal/lib/editor/types.js.map +1 -1
  360. package/dist/internal/lib/editor/validate.d.ts.map +1 -1
  361. package/dist/internal/lib/editor/validate.js +95 -5
  362. package/dist/internal/lib/editor/validate.js.map +1 -1
  363. package/dist/internal/lib/pages.d.ts +26 -0
  364. package/dist/internal/lib/pages.d.ts.map +1 -1
  365. package/dist/internal/lib/pages.js +132 -7
  366. package/dist/internal/lib/pages.js.map +1 -1
  367. package/dist/internal/lib/render/carousel-content.d.ts +9 -0
  368. package/dist/internal/lib/render/carousel-content.d.ts.map +1 -0
  369. package/dist/internal/lib/render/carousel-content.js +27 -0
  370. package/dist/internal/lib/render/carousel-content.js.map +1 -0
  371. package/dist/internal/lib/render/css.d.ts +1 -0
  372. package/dist/internal/lib/render/css.d.ts.map +1 -1
  373. package/dist/internal/lib/render/css.js +95 -9
  374. package/dist/internal/lib/render/css.js.map +1 -1
  375. package/dist/internal/lib/render/custom.d.ts +4 -0
  376. package/dist/internal/lib/render/custom.d.ts.map +1 -1
  377. package/dist/internal/lib/render/custom.js +4 -0
  378. package/dist/internal/lib/render/custom.js.map +1 -1
  379. package/dist/internal/lib/render/disclosure.d.ts +3 -0
  380. package/dist/internal/lib/render/disclosure.d.ts.map +1 -0
  381. package/dist/internal/lib/render/disclosure.js +85 -0
  382. package/dist/internal/lib/render/disclosure.js.map +1 -0
  383. package/dist/internal/lib/render/marquee-runtime.d.ts +7 -0
  384. package/dist/internal/lib/render/marquee-runtime.d.ts.map +1 -0
  385. package/dist/internal/lib/render/marquee-runtime.js +20 -0
  386. package/dist/internal/lib/render/marquee-runtime.js.map +1 -0
  387. package/dist/internal/lib/render/marquee.d.ts +11 -0
  388. package/dist/internal/lib/render/marquee.d.ts.map +1 -0
  389. package/dist/internal/lib/render/marquee.js +81 -0
  390. package/dist/internal/lib/render/marquee.js.map +1 -0
  391. package/dist/internal/lib/render/page-render.d.ts +14 -3
  392. package/dist/internal/lib/render/page-render.d.ts.map +1 -1
  393. package/dist/internal/lib/render/page-render.js +49 -20
  394. package/dist/internal/lib/render/page-render.js.map +1 -1
  395. package/dist/internal/lib/render/text-effects.d.ts +9 -0
  396. package/dist/internal/lib/render/text-effects.d.ts.map +1 -0
  397. package/dist/internal/lib/render/text-effects.js +44 -0
  398. package/dist/internal/lib/render/text-effects.js.map +1 -0
  399. package/dist/mcp-server.d.ts +22 -0
  400. package/dist/mcp-server.d.ts.map +1 -0
  401. package/dist/mcp-server.js +41 -0
  402. package/dist/mcp-server.js.map +1 -0
  403. package/dist/page.js +1 -1
  404. package/dist/page.js.map +1 -1
  405. package/dist/runtime-marquee.js +444 -0
  406. package/dist/runtime-marquee.js.map +7 -0
  407. package/dist/runtime.js +470 -176
  408. package/dist/runtime.js.map +4 -4
  409. package/dist/server.d.ts +2 -0
  410. package/dist/server.js +843 -118
  411. package/dist/server.js.map +4 -4
  412. package/package.json +13 -1
package/AGENTS.md ADDED
@@ -0,0 +1,286 @@
1
+ # Build and launch websites with Pagiera
2
+
3
+ This guide is for coding agents integrating the installed `pagiera` package
4
+ into a user's application and designing editable websites with it. Follow the
5
+ user's project instructions and explicit scope. Read the bundled [README](./README.md)
6
+ for complete Next.js route examples before writing integration code.
7
+
8
+ ## Understand the request
9
+
10
+ - **Integrate the editor:** add the package, backend, protected studio and preview routes, and public rendering routes.
11
+ - **Design a website:** create real Pagiera document elements that the user can edit in the studio. Do not substitute an unrelated hardcoded React landing page or a single HTML Embed for the design.
12
+ - **Edit an existing site:** load its latest draft, preserve unrelated content, and update only the requested elements or breakpoint.
13
+ - **Activate/publish:** save the reviewed draft, publish the requested page, then verify its public route. Saving a draft is not publishing. Publishing content is not deploying the host application.
14
+
15
+ For a new design, establish the destination page, audience, brand direction,
16
+ content, and desired interactions. Use reasonable defaults for minor visual
17
+ choices. Do not overwrite an existing home page just because a new design was
18
+ requested. If the user explicitly requests `/`, work on the `home` page rather
19
+ than inventing a `/showcase` destination.
20
+
21
+ ## 1. Install and configure
22
+
23
+ The full integration uses Next.js App Router, Node.js 20+, React 18.3+,
24
+ PostgreSQL and Redis. In the consuming app, use its existing package manager:
25
+
26
+ ```sh
27
+ npm install pagiera
28
+ # or: bun add pagiera
29
+ ```
30
+
31
+ Set server-only environment variables:
32
+
33
+ ```dotenv
34
+ PAGIERA_POSTGRES_URL=postgresql://USER:PASSWORD@HOST:5432/DATABASE
35
+ PAGIERA_REDIS_URL=redis://HOST:6379
36
+ OPENROUTER_API_KEY=YOUR_SERVER_SIDE_KEY
37
+ OPENROUTER_MODEL=YOUR_AVAILABLE_MODEL_ID
38
+ ```
39
+
40
+ AI generation needs a configured OpenRouter key and available model; manual
41
+ document design does not require making AI requests. Never use `NEXT_PUBLIC_`
42
+ for these secrets. Read the installed server declarations for configuration
43
+ requirements rather than assuming another version's behavior.
44
+
45
+ Import `pagiera/full.css` in the app's global stylesheet. Use `PagieraProvider`
46
+ from `pagiera/provider` to expose the host's fonts; the README includes a
47
+ `next/font` example. Use `pagiera/styles.css` only for the lightweight editor.
48
+
49
+ ## 2. Wire the server and studio
50
+
51
+ Create the backend route:
52
+
53
+ ```ts
54
+ // app/api/pagiera/[...path]/route.ts
55
+ import { createPagieraRouteHandlers, pagieraConfigFromEnv } from "pagiera/server";
56
+
57
+ export const runtime = "nodejs";
58
+ export const dynamic = "force-dynamic";
59
+ const handlers = createPagieraRouteHandlers(pagieraConfigFromEnv());
60
+ export const { GET, POST, PUT, PATCH, DELETE } = handlers;
61
+ ```
62
+
63
+ Protect the editor, preview, diagnostics, and administrative API with the
64
+ host's authentication and authorization before exposing them publicly.
65
+ Pagiera is not a replacement for the host's access-control system. Apply the
66
+ host's CSRF protections to cookie-authenticated mutations as appropriate.
67
+
68
+ On the server, obtain the bootstrap:
69
+
70
+ ```ts
71
+ import { getPagieraServer, pagieraConfigFromEnv } from "pagiera/server";
72
+
73
+ const server = await getPagieraServer(pagieraConfigFromEnv());
74
+ const initial = await server.getEditorBootstrap(pageId);
75
+ if (!initial) throw new Error("Page not found");
76
+ ```
77
+
78
+ Mount the default export from `pagiera/full` in a client component with
79
+ `page`, `pages`, `library`, `initialPanel`, and adapters. Create the adapters
80
+ with `createPagieraClient()` from `pagiera`. See the README's complete client
81
+ wrapper: it also wires page navigation, bootstrap refresh, preview links and
82
+ published links. Do not omit navigation or keep stale bootstrap state when
83
+ switching pages.
84
+
85
+ Expected routes:
86
+
87
+ - `/editor` loads the bootstrap and redirects using `editorPath(page.id)`.
88
+ - `/editor/[pageId]/[panel]` validates the panel with `editorPanel`, loads the page, and passes `initialPanel` to the studio.
89
+ - `/preview/[pageId]` renders the protected draft through `getPreviewPage` and `RenderedPage`.
90
+ - `/` renders the published `home` page.
91
+ - A public catch-all route renders other published slugs without replacing existing application routes.
92
+
93
+ Only import `pagiera/server` in server code. Use public package exports, not
94
+ deep imports into package source or generated internal bundle paths.
95
+
96
+ ## 3. Design an editable website
97
+
98
+ Read the current document before changing it. Prefer native Frames, Sections,
99
+ Stacks, text, images, buttons and other supported blocks. Build a clear page
100
+ hierarchy with meaningful layer names and reusable components/layouts for
101
+ repeated navigation and footer content. Preserve existing component IDs and
102
+ links; inspect an existing studio-created document before authoring advanced
103
+ component, layout, shader or interactive configuration. Do not invent fields
104
+ that the installed version may silently discard.
105
+
106
+ The public document helpers are available from `pagiera`:
107
+
108
+ ```ts
109
+ import { createDocument, type PagieraDocument } from "pagiera";
110
+
111
+ const document: PagieraDocument = createDocument();
112
+ document.rootStyle = {
113
+ ...document.rootStyle,
114
+ bg: "#121212",
115
+ layout: "stack",
116
+ direction: "column",
117
+ };
118
+ document.elements = [
119
+ {
120
+ id: crypto.randomUUID(),
121
+ type: "Heading",
122
+ name: "Hero heading",
123
+ z: 0,
124
+ content: "Build something worth sharing.",
125
+ base: {
126
+ position: "static",
127
+ widthMode: "fill",
128
+ heightMode: "auto",
129
+ color: "#ffffff",
130
+ fontSize: 64,
131
+ fontWeight: "700",
132
+ padT: 64,
133
+ padR: 24,
134
+ padB: 64,
135
+ padL: 24,
136
+ },
137
+ overrides: {
138
+ tablet: { fontSize: 48 },
139
+ mobile: { fontSize: 36, padT: 32, padB: 32 },
140
+ },
141
+ },
142
+ ];
143
+ ```
144
+
145
+ This is a minimal document example, not a complete website. For a finished
146
+ design, add appropriate content sections, navigation, imagery, calls to action
147
+ and footer, with a consistent type scale, spacing and colors. Use licensed or
148
+ user-provided assets; do not invent testimonials or business claims.
149
+
150
+ Document conventions:
151
+
152
+ - `elements` is a flat array; `parentId` links children to their parent IDs.
153
+ - IDs must be unique and stable across edits. Preserve unmodified elements.
154
+ - `base` holds shared styles; `overrides` holds breakpoint-specific patches.
155
+ - Use the document's actual breakpoint IDs; do not assume custom documents use the defaults.
156
+ - Prefer flow layouts, fill widths and automatic content heights for responsive content. Use absolute placement intentionally.
157
+ - `createDocument` performs a shallow top-level merge. Spread existing `rootStyle` when changing a few fields.
158
+ - `document.version` is a schema version, not the page's optimistic concurrency version.
159
+ - Preserve `dataSources`, root settings and unsupported-to-you fields when editing an existing document. Never reconstruct it from only the fields you happen to need.
160
+
161
+ Use the studio for advanced blocks when their public schema is insufficiently
162
+ documented. Read back the saved document to ensure normalization did not drop
163
+ important settings. Check desktop, tablet and mobile, text wrapping, keyboard
164
+ navigation, form labels, contrast, and reduced-motion behavior.
165
+
166
+ ## 4. Save safely and preview
167
+
168
+ ### Command-line workflow
169
+
170
+ The package includes the `pagiera` executable. Run `npx pagiera help` for JSON
171
+ usage information. Set `PAGIERA_URL` to the host's full API base URL (for
172
+ example `http://localhost:3000/api/pagiera`). `PAGIERA_TOKEN`, when provided,
173
+ is sent as a Bearer token; the host must implement authorization for it.
174
+ The CLI does not create credentials or bypass host authentication.
175
+
176
+ ```sh
177
+ npx pagiera inspect
178
+ npx pagiera schema
179
+ npx pagiera page get PAGE_ID
180
+ npx pagiera page validate --file document.json
181
+ npx pagiera page create --name Portfolio --slug portfolio --file document.json
182
+ npx pagiera page update PAGE_ID --file document.json --expected-version 3
183
+ npx pagiera page preview PAGE_ID
184
+ ```
185
+
186
+ Use actual page IDs from inspect/get, not slugs. The file contains the complete
187
+ version-1 document, not a patch or a page response envelope. Preserve the loaded
188
+ page version and pass it explicitly on update. Never substitute a newly fetched
189
+ version onto an old document after a conflict. Saves return the read-back page.
190
+ Structural validation checks IDs and parent links; the server still normalizes
191
+ styles, so inspect the saved document and preview it visually.
192
+
193
+ `page preview` returns the conventional `/preview/PAGE_ID` URL; hosts with custom
194
+ routes should adapt it. `page publish PAGE_ID` is a separate explicit command,
195
+ used only when publication was requested. CLI results are JSON on stdout; errors
196
+ are JSON on stderr with a nonzero exit code. No model request is made by the CLI:
197
+ the coding agent authors the document using the schema and existing page data.
198
+
199
+ The client API exposes these signatures:
200
+
201
+ ```ts
202
+ const client = createPagieraClient({ baseUrl: "/api/pagiera" });
203
+ await client.bootstrap(pageId);
204
+ await client.loadPage(pageId);
205
+ await client.adapters.createPage("About", "about");
206
+ await client.adapters.save(pageId, document, expectedVersion);
207
+ ```
208
+
209
+ The calls above illustrate separate operations, not a script to blindly run
210
+ on every request. Obtain `pageId` and `expectedVersion` from the actual loaded
211
+ page response. Inspect the response shape/types for the installed version.
212
+ Never use `document.version` as `expectedVersion`. A save replaces the supplied
213
+ document content: merge your targeted edits into the complete latest draft.
214
+
215
+ On a version conflict, reload and reconcile rather than forcing a stale save.
216
+ Keep a recoverable copy or revision before significant authorized edits. Do
217
+ not write directly to PostgreSQL to bypass validation, revisioning or cache
218
+ invalidation. After saving, open `/preview/{pageId}` and verify both the visual
219
+ result and interactive behavior before offering publication.
220
+
221
+ AI-assisted editing is optional. In the studio, select a layer or use `@` to
222
+ target a layer/component/breakpoint, describe a specific change, inspect the
223
+ old/new values, then apply. Current capabilities vary by version; do not
224
+ promise arbitrary deletion, whole-site regeneration or automatic MCP tool
225
+ execution. AI output is a proposal, not authorization to publish. MCP discovery
226
+ requires host-configured servers and authorization; never expose server
227
+ credentials in the chat or browser.
228
+
229
+ ## 5. Publish / activate the website
230
+
231
+ Only publish when requested or approved. Save and review first, then:
232
+
233
+ ```ts
234
+ await client.adapters.publishPage(pageId);
235
+ // To take this page offline when requested:
236
+ // await client.adapters.unpublishPage(pageId);
237
+ ```
238
+
239
+ Render published content with the runtime rather than rendering the draft:
240
+
241
+ ```tsx
242
+ // Server Component; adapt slug to the route being served.
243
+ import { notFound } from "next/navigation";
244
+ import { RenderedPage } from "pagiera/runtime";
245
+ import { getPagieraServer, pagieraConfigFromEnv } from "pagiera/server";
246
+
247
+ export default async function HomePage() {
248
+ const server = await getPagieraServer(pagieraConfigFromEnv());
249
+ const page = await server.getPublishedPage("home");
250
+ if (!page) notFound();
251
+ return <RenderedPage elements={page.elements} rootStyle={page.rootStyle} data={page.data} />;
252
+ }
253
+ ```
254
+
255
+ Use the README's context-aware renderer when the page uses query parameters,
256
+ dynamic route parameters or Request/Repeat data blocks. Resolve data on the
257
+ server; do not replace it with client-only fetching when SSR is required.
258
+
259
+ Verify `/` for `home`, or the requested public slug for another page. Check
260
+ that visitors see the published revision, not just the editor preview. Draft
261
+ changes need another publish before becoming public. Deploying the Next.js
262
+ application, configuring a domain/TLS and provisioning production services are
263
+ separate host tasks; use the user's chosen deployment provider and approval.
264
+
265
+ ## Example user request an agent should fulfill
266
+
267
+ > Integrate Pagiera into my Next.js app and design a modern dark portfolio on
268
+ > the home page. Use editable native blocks, purple accents, a responsive hero,
269
+ > project sections and a reusable footer. Preserve unrelated routes. Show me
270
+ > the draft preview first; publish it at `/` only after I approve.
271
+
272
+ The deliverable is a working integration **and a saved editable Pagiera
273
+ document**, not merely instructions, an image mockup, or an unrelated JSX page.
274
+ Report the editor URL, preview URL, saved/published status, checks performed,
275
+ and any missing credentials or deployment steps. Never claim publication or
276
+ successful AI generation without verifying it.
277
+
278
+ ## Verification and troubleshooting
279
+
280
+ - Follow the consuming app's install, typecheck, build and dev scripts.
281
+ - In this monorepo, `bun run check` runs package checks/build and example typecheck; `bun run dev` builds the package and starts the example.
282
+ - Check the protected `/api/pagiera/health` endpoint for backend connectivity.
283
+ - Verify the installed version with `node -p "require('pagiera/package.json').version"` when examples and exports disagree.
284
+ - If workspace source changes are invisible, rebuild the package and restart the relevant dev process if it cached old server modules.
285
+ - Do not terminate an unidentified process because a port is occupied.
286
+ - Never run paid AI generation, destructive template installation, data resets or publication merely to test the integration without authorization.
@@ -0,0 +1,35 @@
1
+ # AI workspace
2
+
3
+ ## Implemented
4
+
5
+ - Type `@` in a Luma conversation to choose a layer/component or breakpoint.
6
+ - Breakpoint requests produce layout-only updates to existing layers; content and structure stay shared.
7
+ - Plans wait for Apply / Discard. Applying a stale plan is refused if the document has changed.
8
+ - `/mcp` opens approved-server discovery. HTTP, legacy SSE and stdio are supported.
9
+ - No MCP tool is automatically executed.
10
+
11
+ ## Host configuration
12
+
13
+ Add `mcpServers` and `authorizeMcp(request)` to the same Pagiera server configuration used by every route/bootstrap entrypoint.
14
+ The authorization callback must verify the application's signed-in administrator, not simply return true in production.
15
+ The editor's client adapter supplies `mcp` automatically.
16
+
17
+ ```ts
18
+ {
19
+ mcpServers: [
20
+ { id: "remote", name: "Design library", transport: "http", url: "https://your-server.example/mcp",
21
+ headers: { Authorization: `Bearer ${process.env.DESIGN_MCP_TOKEN}` } },
22
+ { id: "local", name: "Local tools", transport: "stdio", command: "/absolute/path/to/node",
23
+ args: ["/absolute/path/to/server.mjs"], env: { TOOL_TOKEN: process.env.TOOL_TOKEN! } }
24
+ ],
25
+ authorizeMcp: async request => Boolean(await verifyAdministratorSession(request))
26
+ }
27
+ ```
28
+
29
+ Local means the machine hosting Pagiera, not a remote visitor's computer. Never accept arbitrary executable paths, environment variables, or credentials from a model. Only configure trusted endpoints/processes. stdio does not provide an OS sandbox. Serverless hosts may prohibit persistent child processes.
30
+
31
+ Connections are short-lived, rate-limited, and bounded by a 15-second timeout. The browser only receives server names, transport types, and tool descriptions. Connection errors do not disclose credentials.
32
+
33
+ ## Not yet implemented
34
+
35
+ Multi-page site orchestration/transactional site backup, automatic MCP tool use with approval, browser OAuth enrollment, visual diff preview, and adding arbitrary server definitions through the editor. The current workflow edits the open document and discovers operator-configured tools; it is not a fully autonomous whole-site agent.
package/cli/main.mjs ADDED
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env node
2
+ import { readFile } from 'node:fs/promises';
3
+ import { pathToFileURL } from 'node:url';
4
+
5
+ export function validate(document) {
6
+ const object = value => value && typeof value === 'object' && !Array.isArray(value);
7
+ if (!object(document) || document.version !== 1 || !Array.isArray(document.elements) || !object(document.rootStyle) || !Array.isArray(document.dataSources)) throw new Error('Expected a version:1 document with elements, rootStyle and dataSources.');
8
+ const ids = new Map();
9
+ for (const element of document.elements) {
10
+ if (!object(element) || typeof element.id !== 'string' || !element.id || ids.has(element.id) || typeof element.type !== 'string' || !object(element.base) || !Number.isFinite(element.z)) throw new Error('Each element needs a unique id, type, numeric z and base styles.');
11
+ ids.set(element.id, element);
12
+ }
13
+ for (const element of ids.values()) {
14
+ const seen = new Set([element.id]);
15
+ let parent = element.parentId;
16
+ while (parent) {
17
+ if (!ids.has(parent)) throw new Error(`Unknown parentId: ${parent}`);
18
+ if (seen.has(parent)) throw new Error(`Parent cycle at ${parent}`);
19
+ seen.add(parent); parent = ids.get(parent).parentId;
20
+ }
21
+ }
22
+ return document;
23
+ }
24
+
25
+ export async function run(args, env = process.env) {
26
+ const positional = []; const options = {};
27
+ for (let i = 0; i < args.length; i++) {
28
+ if (!args[i].startsWith('--')) { positional.push(args[i]); continue; }
29
+ const key = args[i].slice(2);
30
+ if (!['file', 'url', 'name', 'slug', 'expected-version'].includes(key)) throw new Error(`Unknown option --${key}`);
31
+ if (!args[i + 1] || args[i + 1].startsWith('--')) throw new Error(`Missing value for --${key}`);
32
+ options[key] = args[++i];
33
+ }
34
+ const [command, action, id] = positional;
35
+ if (!command || command === 'help') return { commands: ['inspect', 'schema', 'page get ID', 'page create --name NAME --slug SLUG --file document.json', 'page update ID --file document.json --expected-version N', 'page validate --file document.json', 'page preview ID', 'page publish ID'], configuration: 'PAGIERA_URL or --url is the full API base URL. Optional PAGIERA_TOKEN is sent as a Bearer token; the host must authorize it.', output: 'JSON; errors go to stderr with exit code 1.' };
36
+ if (command === 'schema') return { description: 'Public document TypeScript contract; validation checks structure and parent links, server normalization remains authoritative.', types: await readFile(new URL('../dist/document.d.ts', import.meta.url), 'utf8'), example: (await import('../dist/document.js')).createDocument() };
37
+ const allowed = ['get', 'create', 'update', 'validate', 'preview', 'publish'];
38
+ if (command !== 'inspect' && (command !== 'page' || !allowed.includes(action))) throw new Error('Unknown command. Run pagiera help.');
39
+ let document;
40
+ if (['create', 'update', 'validate'].includes(action)) {
41
+ if (!options.file) throw new Error('--file is required');
42
+ document = validate(JSON.parse(await readFile(options.file, 'utf8')));
43
+ if (action === 'validate') return { valid: true, elements: document.elements.length, scope: 'Structural validation; not a full style-schema validator.' };
44
+ }
45
+ if (command === 'page' && !['create', 'validate'].includes(action) && !id) throw new Error('Page ID required (use inspect to discover IDs).');
46
+ if (action === 'create' && (!options.name || !options.slug)) throw new Error('--name and --slug are required');
47
+ const expectedVersion = Number(options['expected-version']);
48
+ if (action === 'update' && (!Number.isInteger(expectedVersion) || expectedVersion < 0)) throw new Error('--expected-version must be the loaded page version, not document.version');
49
+ const base = new URL(options.url || env.PAGIERA_URL || 'http://localhost:3000/api/pagiera');
50
+ if (!['http:', 'https:'].includes(base.protocol) || base.username || base.password || base.search || base.hash) throw new Error('Invalid API base URL');
51
+ if (env.PAGIERA_TOKEN && base.protocol !== 'https:' && !['localhost', '127.0.0.1', '[::1]'].includes(base.hostname)) throw new Error('Bearer authentication requires HTTPS outside localhost');
52
+ const request = async (path, body) => {
53
+ const response = await fetch(base.href.replace(/\/$/, '') + path, { method: body === undefined ? 'GET' : 'POST', redirect: 'error', signal: AbortSignal.timeout(30000), headers: { 'Content-Type': 'application/json', ...(env.PAGIERA_TOKEN ? { Authorization: `Bearer ${env.PAGIERA_TOKEN}` } : {}) }, body: body === undefined ? undefined : JSON.stringify(body) });
54
+ if (!response.ok) throw new Error(`API request failed (${response.status})`);
55
+ return response.json();
56
+ };
57
+ if (command === 'inspect') return request('/bootstrap');
58
+ const pagePath = `/pages/${encodeURIComponent(id)}`;
59
+ if (action === 'get') return request(pagePath);
60
+ if (action === 'preview') { await request(pagePath); return { previewUrl: new URL(`/preview/${encodeURIComponent(id)}`, base).href, note: 'Default host preview route; requires host authentication.' }; }
61
+ if (action === 'publish') return request(`${pagePath}/publish`, {});
62
+ const save = async (pageId, version) => {
63
+ const result = await request(`/pages/${encodeURIComponent(pageId)}/save`, { document, expectedVersion: version });
64
+ if (result.status !== 'saved') throw new Error(`Save rejected: ${result.status}. Reload and reconcile; do not force a stale save.`);
65
+ return { ...result, pageId, page: await request(`/pages/${encodeURIComponent(pageId)}`) };
66
+ };
67
+ if (action === 'update') return save(id, expectedVersion);
68
+ const created = await request('/pages', { name: options.name, slug: options.slug });
69
+ try {
70
+ const page = await request(`/pages/${encodeURIComponent(created.pageId)}`);
71
+ return await save(created.pageId, page.version);
72
+ } catch (error) { throw new Error(`Page ${created.pageId} was created but saving failed: ${error.message}`); }
73
+ }
74
+
75
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
76
+ run(process.argv.slice(2)).then(result => process.stdout.write(JSON.stringify(result, null, 2) + '\n')).catch(error => { process.stderr.write(JSON.stringify({ error: error.message }) + '\n'); process.exitCode = 1; });
77
+ }
@@ -0,0 +1,8 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+
5
+ export {
6
+ __publicField
7
+ };
8
+ //# sourceMappingURL=chunk-IFG75HHC.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }