@gramlot/gramlot 0.3.41 → 0.5.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 (358) hide show
  1. package/assets/icons/align-center.svg +4 -0
  2. package/assets/icons/align-justify.svg +4 -0
  3. package/assets/icons/align-left.svg +4 -0
  4. package/assets/icons/align-right.svg +4 -0
  5. package/assets/icons/applications.svg +4 -0
  6. package/assets/icons/archive.svg +4 -0
  7. package/assets/icons/attachment.svg +4 -0
  8. package/assets/icons/bold.svg +4 -0
  9. package/assets/icons/book.svg +4 -0
  10. package/assets/icons/bookmark.svg +4 -0
  11. package/assets/icons/calendar.svg +4 -0
  12. package/assets/icons/cancel.svg +4 -0
  13. package/assets/icons/chart.svg +4 -1
  14. package/assets/icons/chat.svg +4 -0
  15. package/assets/icons/clock.svg +4 -0
  16. package/assets/icons/code.svg +4 -0
  17. package/assets/icons/collapse.svg +4 -0
  18. package/assets/icons/columns.svg +4 -0
  19. package/assets/icons/confirm.svg +4 -0
  20. package/assets/icons/copy.svg +4 -0
  21. package/assets/icons/cut.svg +4 -0
  22. package/assets/icons/database.svg +4 -0
  23. package/assets/icons/delete.svg +4 -0
  24. package/assets/icons/detach.svg +4 -0
  25. package/assets/icons/document.svg +4 -0
  26. package/assets/icons/download.svg +4 -0
  27. package/assets/icons/duplicate.svg +4 -0
  28. package/assets/icons/edit.svg +4 -0
  29. package/assets/icons/eraser.svg +4 -0
  30. package/assets/icons/expand.svg +4 -0
  31. package/assets/icons/export.svg +4 -0
  32. package/assets/icons/eye.svg +4 -0
  33. package/assets/icons/filter.svg +4 -0
  34. package/assets/icons/first.svg +4 -0
  35. package/assets/icons/folder.svg +4 -0
  36. package/assets/icons/group.svg +4 -0
  37. package/assets/icons/help.svg +4 -0
  38. package/assets/icons/home.svg +4 -0
  39. package/assets/icons/horizontal-rule.svg +4 -0
  40. package/assets/icons/image.svg +4 -0
  41. package/assets/icons/import.svg +4 -0
  42. package/assets/icons/indent.svg +4 -0
  43. package/assets/icons/info.svg +4 -0
  44. package/assets/icons/inspector.svg +4 -0
  45. package/assets/icons/italic.svg +4 -0
  46. package/assets/icons/last.svg +4 -0
  47. package/assets/icons/layers.svg +4 -0
  48. package/assets/icons/link.svg +4 -0
  49. package/assets/icons/list-bulleted.svg +4 -0
  50. package/assets/icons/list-numbered.svg +4 -0
  51. package/assets/icons/list.svg +4 -0
  52. package/assets/icons/lock.svg +4 -0
  53. package/assets/icons/logout.svg +4 -0
  54. package/assets/icons/navigation.svg +4 -0
  55. package/assets/icons/new.svg +4 -0
  56. package/assets/icons/next.svg +4 -0
  57. package/assets/icons/open.svg +4 -0
  58. package/assets/icons/outdent.svg +4 -0
  59. package/assets/icons/palette.svg +4 -0
  60. package/assets/icons/panel-bottom.svg +4 -0
  61. package/assets/icons/panel-left.svg +4 -0
  62. package/assets/icons/panel-right.svg +4 -0
  63. package/assets/icons/panel-top.svg +4 -0
  64. package/assets/icons/paragraph.svg +4 -0
  65. package/assets/icons/paste.svg +4 -0
  66. package/assets/icons/pause.svg +4 -0
  67. package/assets/icons/pin.svg +4 -0
  68. package/assets/icons/play.svg +4 -0
  69. package/assets/icons/previous.svg +4 -0
  70. package/assets/icons/print.svg +4 -0
  71. package/assets/icons/redo.svg +4 -0
  72. package/assets/icons/refresh.svg +4 -0
  73. package/assets/icons/save.svg +4 -0
  74. package/assets/icons/search.svg +4 -0
  75. package/assets/icons/select-all.svg +4 -0
  76. package/assets/icons/send.svg +4 -0
  77. package/assets/icons/settings.svg +4 -0
  78. package/assets/icons/sort-ascending.svg +4 -0
  79. package/assets/icons/sort-descending.svg +4 -0
  80. package/assets/icons/stop.svg +4 -0
  81. package/assets/icons/strikethrough.svg +4 -0
  82. package/assets/icons/table.svg +4 -0
  83. package/assets/icons/tree.svg +4 -0
  84. package/assets/icons/underline.svg +4 -0
  85. package/assets/icons/undo.svg +4 -0
  86. package/assets/icons/unlock.svg +4 -0
  87. package/assets/icons/upload.svg +4 -0
  88. package/assets/icons/user.svg +4 -0
  89. package/assets/icons/warning.svg +4 -0
  90. package/assets/icons/zoom-in.svg +4 -0
  91. package/assets/icons/zoom-out.svg +4 -0
  92. package/dist/components/charts/__init__.py +1 -1
  93. package/dist/components/charts/assets/index.js +1 -1
  94. package/dist/components/charts/assets/libraries/vega.js +11 -11
  95. package/dist/components/charts/grammar.json +2032 -72
  96. package/dist/components/editors/__init__.py +1 -1
  97. package/dist/components/editors/assets/collection.js +1 -1
  98. package/dist/components/editors/assets/index.js +1 -1
  99. package/dist/components/editors/assets/libraries/codemirror.js +30 -31
  100. package/dist/components/editors/assets/libraries/jodit.js +453 -447
  101. package/dist/components/editors/commands.json +113 -1
  102. package/dist/components/editors/grammar.json +12 -5
  103. package/dist/components/grid/__init__.py +1 -1
  104. package/dist/components/grid/assets/index.js +1 -1
  105. package/dist/components/grid/commands.json +4 -6
  106. package/dist/components/grid/grammar.json +112 -0
  107. package/dist/components/inputs/__init__.py +1 -1
  108. package/dist/components/inputs/assets/index.js +1 -1
  109. package/dist/components/inputs/grammar.json +5165 -359
  110. package/dist/components/layout/__init__.py +1 -1
  111. package/dist/components/layout/assets/collection.js +1 -0
  112. package/dist/components/layout/assets/index.js +1 -1
  113. package/dist/components/layout/grammar.json +433 -4
  114. package/dist/components/tree/__init__.py +1 -1
  115. package/dist/components/tree/assets/index.js +1 -1
  116. package/dist/components/tree/grammar.json +51 -0
  117. package/dist/components/typst/__init__.py +1 -1
  118. package/dist/components/typst/assets/collection.js +6 -6
  119. package/dist/components/typst/assets/index.js +1 -1
  120. package/dist/components/uploads/__init__.py +1 -1
  121. package/dist/components/uploads/assets/index.js +1 -1
  122. package/dist/components/uploads/grammar.json +66 -0
  123. package/dist/declared-collections.js +1 -1
  124. package/dist/gramlot.js +5486 -2029
  125. package/dist/gramlot.min.js +361 -138
  126. package/dist/libraries.json +6 -4
  127. package/dist/standard-collections.js +1 -1
  128. package/dist/standard-grammar.js +1 -1
  129. package/package.json +6 -2
  130. package/src/binding/ask-dialog.js +17 -3
  131. package/src/binding/providers.js +3 -2
  132. package/src/binding/remote.js +41 -6
  133. package/src/binding/runtime.js +30 -3
  134. package/src/builder/gramlot-builder.d.ts +3 -1
  135. package/src/builder/gramlot-builder.js +77 -26
  136. package/src/builder/source.js +78 -15
  137. package/src/builder/xml-recipe.js +144 -0
  138. package/src/chat-file-types.js +13 -0
  139. package/src/chat.d.ts +1 -0
  140. package/src/chat.js +35 -25
  141. package/src/commands.d.ts +1 -1
  142. package/src/commands.js +1 -1
  143. package/src/components/border-container.js +64 -6
  144. package/src/components/buttons.js +26 -31
  145. package/src/components/chart-bar3d-options.js +0 -1
  146. package/src/components/chart-boxplot-options.js +1 -1
  147. package/src/components/chart-candlestick-options.js +1 -1
  148. package/src/components/chart-engines/echarts-options.js +6 -5
  149. package/src/components/chart-engines/echarts.js +27 -10
  150. package/src/components/chart-engines/plotly-map.js +1 -1
  151. package/src/components/chart-engines/plotly.js +21 -14
  152. package/src/components/chart-engines/uplot.js +17 -11
  153. package/src/components/chart-engines/vega.js +17 -11
  154. package/src/components/chart-funnel-options.js +1 -1
  155. package/src/components/chart-geographic-options.js +2 -2
  156. package/src/components/chart-heatmap-options.js +1 -1
  157. package/src/components/chart-map-bar3d-options.js +2 -2
  158. package/src/components/chart-map-options.js +2 -2
  159. package/src/components/chart-pane.js +5 -5
  160. package/src/components/chart-parallel-options.js +1 -1
  161. package/src/components/chart-radar-options.js +1 -1
  162. package/src/components/chart-renderer.js +6 -1
  163. package/src/components/chart-sankey-options.js +1 -1
  164. package/src/components/chart-spatial-options.js +6 -2
  165. package/src/components/chart-sunburst-options.js +13 -1
  166. package/src/components/chart-theme.js +14 -0
  167. package/src/components/chart-treemap-options.js +1 -1
  168. package/src/components/chart-type-data.js +24 -4
  169. package/src/components/charts.js +7 -6
  170. package/src/components/check-box-text-editor.js +1 -0
  171. package/src/components/check-box-text.js +2 -0
  172. package/src/components/check-box-tree.js +1 -1
  173. package/src/components/choice-editor.js +5 -4
  174. package/src/components/choice-field-styles.js +9 -1
  175. package/src/components/code-mirror-engine.js +19 -5
  176. package/src/components/code-mirror-gramlot.js +85 -0
  177. package/src/components/code-mirror.js +3 -2
  178. package/src/components/drawing.js +43 -14
  179. package/src/components/editor-commands.js +69 -0
  180. package/src/components/editor-options.js +1 -1
  181. package/src/components/editors.js +5 -3
  182. package/src/components/form-tray-pane.js +18 -0
  183. package/src/components/graphical-ranges.js +190 -0
  184. package/src/components/grid-check-sets.js +39 -3
  185. package/src/components/grid-footer.js +6 -1
  186. package/src/components/grid-header-interaction.js +3 -3
  187. package/src/components/grid-styles.js +30 -5
  188. package/src/components/grid-tools.js +15 -7
  189. package/src/components/grid.js +109 -15
  190. package/src/components/html-editor-commands.js +61 -0
  191. package/src/components/html-editor.js +18 -3
  192. package/src/components/inputs.js +94 -23
  193. package/src/components/jodit-engine.js +110 -7
  194. package/src/components/layout.js +3 -2
  195. package/src/components/menus.js +89 -26
  196. package/src/components/numeric-range.js +39 -0
  197. package/src/components/selected-container.js +123 -64
  198. package/src/components/tab-bar.js +389 -0
  199. package/src/components/toolbar-icon-style.js +22 -0
  200. package/src/components/toolbar-overflow.js +74 -12
  201. package/src/components/tray-base.js +528 -0
  202. package/src/components/tray-pane.js +41 -518
  203. package/src/components/tree.js +56 -4
  204. package/src/components/typed-editor.js +5 -2
  205. package/src/components/typst-preview.js +3 -3
  206. package/src/components/upload-blocks.js +88 -0
  207. package/src/components/upload-engine.js +21 -31
  208. package/src/components/uploader.js +168 -47
  209. package/src/editing-session.js +2 -1
  210. package/src/gramlot.js +6 -3
  211. package/src/handlers/dom-handler.d.ts +2 -0
  212. package/src/handlers/dom-handler.js +9 -0
  213. package/src/handlers/rpc-handler.d.ts +1 -1
  214. package/src/handlers/rpc-handler.js +2 -0
  215. package/src/handlers/source-handler.d.ts +5 -3
  216. package/src/handlers/source-handler.js +31 -13
  217. package/src/icons.js +84 -0
  218. package/src/ide-runtime.js +3 -1
  219. package/src/index-page-runtime.js +20 -5
  220. package/src/index-page-styles.js +1 -1
  221. package/src/index-theme.js +210 -3
  222. package/src/index.d.ts +7 -2
  223. package/src/index.js +7 -2
  224. package/src/libraries.js +4 -4
  225. package/src/object-extract.d.ts +7 -0
  226. package/src/object-extract.js +31 -0
  227. package/src/renderer/attributes.js +1 -1
  228. package/src/renderer/gramlot-renderer.d.ts +2 -2
  229. package/src/renderer/gramlot-renderer.js +4 -1
  230. package/src/server/chat-attachments.js +139 -0
  231. package/src/server/chat.d.ts +33 -0
  232. package/src/server/chat.js +168 -0
  233. package/src/server/database-selectors.d.ts +6 -0
  234. package/src/server/database-selectors.js +13 -0
  235. package/src/server/gramlot-file-server.js +6 -1
  236. package/src/server/gramlot-server.d.ts +19 -3
  237. package/src/server/gramlot-server.js +149 -19
  238. package/src/server/index-page.d.ts +10 -0
  239. package/src/server/index-page.js +92 -8
  240. package/src/server/index.d.ts +1 -1
  241. package/src/server/index.js +1 -1
  242. package/src/server/page-base.js +4 -0
  243. package/src/server/page-store.d.ts +21 -0
  244. package/src/server/page-store.js +219 -0
  245. package/src/server/page.d.ts +6 -1
  246. package/src/server/page.js +5 -1
  247. package/src/server/store-recipe.js +102 -0
  248. package/src/server/toolbar-icon-name.d.ts +93 -0
  249. package/src/server/upload.d.ts +2 -0
  250. package/src/server/upload.js +36 -18
  251. package/src/server/visual-editor.js +4 -2
  252. package/src/tree-store.d.ts +5 -1
  253. package/src/tree-store.js +11 -2
  254. package/src/view/choice-focus.js +17 -0
  255. package/src/view/html.js +21 -1
  256. package/src/view/labelbox.js +6 -1
  257. package/src/view/menu.js +9 -3
  258. package/src/visual-editor.d.ts +1 -0
  259. package/src/visual-editor.js +10 -5
  260. package/themes/gramlot-base/theme.css +60 -28
  261. package/themes/gramlot-compact/theme.css +2 -0
  262. package/themes/gramlot-index/icons/align-center.svg +4 -0
  263. package/themes/gramlot-index/icons/align-justify.svg +4 -0
  264. package/themes/gramlot-index/icons/align-left.svg +4 -0
  265. package/themes/gramlot-index/icons/align-right.svg +4 -0
  266. package/themes/gramlot-index/icons/applications.svg +4 -0
  267. package/themes/gramlot-index/icons/archive.svg +4 -0
  268. package/themes/gramlot-index/icons/attachment.svg +4 -0
  269. package/themes/gramlot-index/icons/bold.svg +4 -0
  270. package/themes/gramlot-index/icons/book.svg +4 -0
  271. package/themes/gramlot-index/icons/bookmark.svg +4 -0
  272. package/themes/gramlot-index/icons/calendar.svg +4 -0
  273. package/themes/gramlot-index/icons/cancel.svg +4 -0
  274. package/themes/gramlot-index/icons/chart.svg +4 -0
  275. package/themes/gramlot-index/icons/chat.svg +4 -0
  276. package/themes/gramlot-index/icons/clock.svg +4 -0
  277. package/themes/gramlot-index/icons/code.svg +4 -0
  278. package/themes/gramlot-index/icons/collapse.svg +4 -0
  279. package/themes/gramlot-index/icons/columns.svg +4 -0
  280. package/themes/gramlot-index/icons/confirm.svg +4 -0
  281. package/themes/gramlot-index/icons/copy.svg +4 -0
  282. package/themes/gramlot-index/icons/cut.svg +4 -0
  283. package/themes/gramlot-index/icons/database.svg +4 -0
  284. package/themes/gramlot-index/icons/delete.svg +4 -0
  285. package/themes/gramlot-index/icons/detach.svg +4 -0
  286. package/themes/gramlot-index/icons/document.svg +4 -0
  287. package/themes/gramlot-index/icons/download.svg +4 -0
  288. package/themes/gramlot-index/icons/duplicate.svg +4 -0
  289. package/themes/gramlot-index/icons/edit.svg +4 -0
  290. package/themes/gramlot-index/icons/eraser.svg +4 -0
  291. package/themes/gramlot-index/icons/expand.svg +4 -0
  292. package/themes/gramlot-index/icons/export.svg +4 -0
  293. package/themes/gramlot-index/icons/eye.svg +4 -0
  294. package/themes/gramlot-index/icons/filter.svg +4 -0
  295. package/themes/gramlot-index/icons/first.svg +4 -0
  296. package/themes/gramlot-index/icons/folder.svg +4 -0
  297. package/themes/gramlot-index/icons/group.svg +4 -0
  298. package/themes/gramlot-index/icons/help.svg +4 -0
  299. package/themes/gramlot-index/icons/home.svg +4 -0
  300. package/themes/gramlot-index/icons/horizontal-rule.svg +4 -0
  301. package/themes/gramlot-index/icons/image.svg +4 -0
  302. package/themes/gramlot-index/icons/import.svg +4 -0
  303. package/themes/gramlot-index/icons/indent.svg +4 -0
  304. package/themes/gramlot-index/icons/info.svg +4 -0
  305. package/themes/gramlot-index/icons/inspector.svg +4 -0
  306. package/themes/gramlot-index/icons/italic.svg +4 -0
  307. package/themes/gramlot-index/icons/last.svg +4 -0
  308. package/themes/gramlot-index/icons/layers.svg +4 -0
  309. package/themes/gramlot-index/icons/link.svg +4 -0
  310. package/themes/gramlot-index/icons/list-bulleted.svg +4 -0
  311. package/themes/gramlot-index/icons/list-numbered.svg +4 -0
  312. package/themes/gramlot-index/icons/list.svg +4 -0
  313. package/themes/gramlot-index/icons/lock.svg +4 -0
  314. package/themes/gramlot-index/icons/logout.svg +4 -0
  315. package/themes/gramlot-index/icons/navigation.svg +4 -0
  316. package/themes/gramlot-index/icons/new.svg +4 -0
  317. package/themes/gramlot-index/icons/next.svg +4 -0
  318. package/themes/gramlot-index/icons/open.svg +4 -0
  319. package/themes/gramlot-index/icons/outdent.svg +4 -0
  320. package/themes/gramlot-index/icons/palette.svg +4 -0
  321. package/themes/gramlot-index/icons/panel-bottom.svg +4 -0
  322. package/themes/gramlot-index/icons/panel-left.svg +4 -0
  323. package/themes/gramlot-index/icons/panel-right.svg +4 -0
  324. package/themes/gramlot-index/icons/panel-top.svg +4 -0
  325. package/themes/gramlot-index/icons/paragraph.svg +4 -0
  326. package/themes/gramlot-index/icons/paste.svg +4 -0
  327. package/themes/gramlot-index/icons/pause.svg +4 -0
  328. package/themes/gramlot-index/icons/pin.svg +4 -0
  329. package/themes/gramlot-index/icons/play.svg +4 -0
  330. package/themes/gramlot-index/icons/previous.svg +4 -0
  331. package/themes/gramlot-index/icons/print.svg +4 -0
  332. package/themes/gramlot-index/icons/redo.svg +4 -0
  333. package/themes/gramlot-index/icons/refresh.svg +4 -0
  334. package/themes/gramlot-index/icons/save.svg +4 -0
  335. package/themes/gramlot-index/icons/search.svg +4 -0
  336. package/themes/gramlot-index/icons/select-all.svg +4 -0
  337. package/themes/gramlot-index/icons/send.svg +4 -0
  338. package/themes/gramlot-index/icons/settings.svg +4 -0
  339. package/themes/gramlot-index/icons/sort-ascending.svg +4 -0
  340. package/themes/gramlot-index/icons/sort-descending.svg +4 -0
  341. package/themes/gramlot-index/icons/stop.svg +4 -0
  342. package/themes/gramlot-index/icons/strikethrough.svg +4 -0
  343. package/themes/gramlot-index/icons/table.svg +4 -0
  344. package/themes/gramlot-index/icons/tree.svg +4 -0
  345. package/themes/gramlot-index/icons/underline.svg +4 -0
  346. package/themes/gramlot-index/icons/undo.svg +4 -0
  347. package/themes/gramlot-index/icons/unlock.svg +4 -0
  348. package/themes/gramlot-index/icons/upload.svg +4 -0
  349. package/themes/gramlot-index/icons/user.svg +4 -0
  350. package/themes/gramlot-index/icons/warning.svg +4 -0
  351. package/themes/gramlot-index/icons/zoom-in.svg +4 -0
  352. package/themes/gramlot-index/icons/zoom-out.svg +4 -0
  353. package/themes/gramlot-index/icons.json +93 -0
  354. package/themes/gramlot-index/theme.css +24 -0
  355. package/themes/joanna/theme.css +2 -0
  356. package/themes/mela/theme.css +2 -0
  357. package/themes/mimi/theme.css +2 -0
  358. package/tools/gramlot-tools-inspector.js +11 -3
@@ -13,6 +13,8 @@ import {GramlotBuilder} from '../builder/gramlot-builder.js';
13
13
  import {NAME_SYNTAX} from '../builder/name-syntax.js';
14
14
  import {gramlotDev} from './assets.js';
15
15
  import {ENDPOINT_METHOD, Page, SOURCE_METHOD, UPLOAD_METHOD, resolveDeclared} from './page.js';
16
+ import {PageStore} from './page-store.js';
17
+ import {ChatPageStore} from './chat.js';
16
18
  import {UploadRegistry, UploadTarget} from './upload.js';
17
19
  import {InvalidResourceName, SEGMENT, loadOrder} from './resources.js';
18
20
  import {libraries} from '../libraries.js';
@@ -116,9 +118,9 @@ const prefixed = (prefix, url) => url.startsWith('/') && !url.startsWith('//') ?
116
118
  export class GramlotServer {
117
119
  get markdownUrl() { return this.runtimeUrl.replace(/[^/]+$/, 'gramlot-markdown.js'); }
118
120
 
119
- constructor({runtimeUrl = '/assets/gramlot.js', rpcUrl = '/gramlot/rpc', closeUrl = '/gramlot/close',
121
+ constructor({runtimeUrl = '/assets/gramlot.js', rpcUrl = '/gramlot/rpc', closeUrl = '/gramlot/close', uploadUrl = null,
120
122
  rootId = 'gramlot-root', pageTtl = 1800, maxPages = 1000, collections = [], uploadsEnabled = false,
121
- cssTheme = 'gramlot-base', librarySource = 'cdn'} = {}) {
123
+ cssTheme = 'gramlot-base', librarySource = 'cdn', websocketUrl = null} = {}) {
122
124
  if (!['cdn', 'local'].includes(librarySource)) {
123
125
  throw new TypeError(`The library source must be 'cdn' or 'local', not ${JSON.stringify(librarySource)}`);
124
126
  }
@@ -130,9 +132,10 @@ export class GramlotServer {
130
132
  !Number.isSafeInteger(maxPages) || maxPages < 1) {
131
133
  throw new TypeError('Page TTL must be finite and positive; capacity must be a positive safe integer');
132
134
  }
133
- Object.assign(this, {runtimeUrl, rpcUrl, closeUrl, rootId, pageTtl, maxPages, cssTheme, librarySource});
135
+ Object.assign(this, {runtimeUrl, rpcUrl, closeUrl, rootId, pageTtl, maxPages, cssTheme, librarySource, websocketUrl, uploadUrl});
134
136
  this.libraries = libraries;
135
137
  this.pages = new Map();
138
+ this.sharedStores = new Map();
136
139
  this.uploads = uploadsEnabled ? new UploadRegistry() : null;
137
140
  this.collections = this.collectionGraph([...standardCollections, ...collections]);
138
141
  this.preparedGrammars = new WeakMap();
@@ -243,9 +246,100 @@ export class GramlotServer {
243
246
  /** Optional initial Data Bag for this page path; no companion in the neutral server. */
244
247
  async resolveData(path) { return null; }
245
248
 
249
+ resolvePageStore(PageClass, path) { return PageStore; }
250
+
251
+ createPageStore(StoreClass, {pageId, owner}) { return new StoreClass(); }
252
+
253
+ /** Resolve and renew the store only within its page owner's session. */
254
+ pageStore(pageId, {owner} = {}) {
255
+ this.prune();
256
+ const record = this.pages.get(pageId);
257
+ if (!record?.store || owner == null || record.owner !== owner) throw new PageExpired('Unknown, expired or unowned page');
258
+ record.expires = this.#expiry();
259
+ return record.store;
260
+ }
261
+
262
+ async openChatImage(pageId, ref, {owner}) {
263
+ const store = this.pageStore(pageId, {owner});
264
+ return store instanceof ChatPageStore ? store.attachments.openImage(ref) : null;
265
+ }
266
+
267
+ connectPageChannel(pageId, send, {owner}) {
268
+ this.pageStore(pageId, {owner});
269
+ if (typeof send !== 'function') throw new TypeError('Page channel requires a send callback');
270
+ const record = this.pages.get(pageId);
271
+ if (record.send) throw new Error('Page already has a channel');
272
+ record.send = send;
273
+ }
274
+
275
+ disconnectPageChannel(pageId, {owner}) {
276
+ const record = this.pages.get(pageId);
277
+ if (record && record.owner === owner) delete record.send;
278
+ }
279
+
280
+ sharedStore(key, factory) {
281
+ if (!Array.isArray(key) || !key.length || key.some(part => typeof part !== 'string' || !part)) {
282
+ throw new TypeError('Shared store keys must be nonempty arrays of nonempty strings');
283
+ }
284
+ const encoded = JSON.stringify(key);
285
+ if (!this.sharedStores.has(encoded)) {
286
+ if (this.sharedStores.size >= this.maxPages) throw new ServerCapacity('Shared store registry capacity reached');
287
+ const store = factory();
288
+ if (!(store instanceof PageStore)) throw new TypeError('Shared stores must subclass PageStore');
289
+ store.start();
290
+ this.sharedStores.set(encoded, store);
291
+ }
292
+ return this.sharedStores.get(encoded);
293
+ }
294
+
295
+ closeSharedStore(key) {
296
+ const encoded = JSON.stringify(key);
297
+ const store = this.sharedStores.get(encoded);
298
+ if (store) { this.sharedStores.delete(encoded); store.close(); }
299
+ }
300
+
301
+ publishToPage(topic, payload, {sourcePageId, pageId, owner}) {
302
+ if (typeof pageId !== 'string' || !pageId || typeof topic !== 'string' || !topic || !isMapping(payload)) {
303
+ throw new InvalidRequest('Publication requires a destination, topic and named payload');
304
+ }
305
+ this.pageStore(sourcePageId, {owner});
306
+ this.pageStore(pageId, {owner});
307
+ const {send} = this.pages.get(pageId);
308
+ if (!send) throw new PageExpired('Page has no connected channel');
309
+ send(toTytx({op:'publish', pageId, topic, payload, metadata:{pageId:sourcePageId}}));
310
+ }
311
+
312
+ /** The adapter sends the acceptance before invoking the returned dispatch. */
313
+ preparePublish(text, {owner}) {
314
+ let message;
315
+ try { message = fromTytx(text); } catch (cause) { throw new InvalidRequest('Publication is not TYTX text', {cause}); }
316
+ if (!isMapping(message) || message.op !== 'publish' || typeof message.id !== 'string' || !message.id) {
317
+ throw new InvalidRequest('Expected a publication envelope with a nonempty id');
318
+ }
319
+ const response = {id:message.id, contentType:'data'};
320
+ let dispatch = null;
321
+ try {
322
+ const {pageId, targetPageId = pageId, topic, payload} = message;
323
+ if (Object.keys(message).some(key => !['op','id','pageId','targetPageId','topic','payload'].includes(key)) ||
324
+ [pageId,targetPageId,topic].some(value => typeof value !== 'string' || !value) || !isMapping(payload)) {
325
+ throw new InvalidRequest('Invalid publication fields');
326
+ }
327
+ this.pageStore(pageId, {owner});
328
+ const destination = this.pageStore(targetPageId, {owner});
329
+ dispatch = () => destination.publish(topic, payload, {metadata:{pageId}});
330
+ response.value = 'ok';
331
+ } catch (error) {
332
+ response.error = {code:error instanceof InvalidRequest ? 'invalid_request' :
333
+ OUTCOME_CODES.get(error.constructor) ?? 'application_error', name:error.name, message:error.message};
334
+ if (gramlotDev() === 'DEBUG') response.error.details = error.stack;
335
+ }
336
+ return [toTytx(response), dispatch];
337
+ }
338
+
246
339
  /** The capabilities announced in the bootstrap; none in the base server. */
247
340
  get capabilities() {
248
- return [];
341
+ if (!this.uploads) return [];
342
+ return this.websocketUrl ? ['upload', 'pageStoreReconnect'] : ['upload'];
249
343
  }
250
344
 
251
345
  /** The NameSyntax of the method names a request may carry, announced in the bootstrap
@@ -288,8 +382,7 @@ export class GramlotServer {
288
382
  prune() {
289
383
  const now = performance.now();
290
384
  for (const [id, record] of this.pages) if (record.expires <= now) {
291
- this.pages.delete(id);
292
- void this.uploads?.closePage(id, record.owner);
385
+ this.closePage(id, {owner:record.owner});
293
386
  }
294
387
  }
295
388
 
@@ -328,12 +421,13 @@ export class GramlotServer {
328
421
  * `<path>/index.html` registers the page `<path>/` and `/index.html` the index. The CSS of the
329
422
  * page is its theme (themeCss), then the CSS of resolveResources, each URL once in its last
330
423
  * position. */
331
- async registerPage(path, {owner = null} = {}) {
424
+ async registerPage(path, {owner = null, prefix = '', websocketUrl = this.websocketUrl} = {}) {
332
425
  if (path.endsWith('/index.html')) path = path.slice(0, -'index.html'.length);
333
426
  let PageClass = await this.resolvePage(path);
334
427
  if (typeof PageClass !== 'function' || !(PageClass.prototype instanceof Page)) {
335
428
  throw new TypeError('Page modules must export a subclass of Page');
336
429
  }
430
+ const StoreClass = await this.resolvePageStore(PageClass, path);
337
431
  PageClass = this.environmentPage(PageClass);
338
432
  const selected = this.pageCollections(PageClass);
339
433
  const resolved = await this.resolveResources(path, PageClass);
@@ -347,7 +441,26 @@ export class GramlotServer {
347
441
  this.prune();
348
442
  if (this.pages.size >= this.maxPages) throw new ServerCapacity('Page registry capacity reached');
349
443
  const pageId = crypto.randomUUID().replaceAll('-', '');
350
- this.pages.set(pageId, {PageClass, path, owner, expires: this.#expiry()});
444
+ const record = {PageClass, path, owner, expires:this.#expiry()};
445
+ this.pages.set(pageId, record);
446
+ try {
447
+ if (websocketUrl !== null || StoreClass !== PageStore) {
448
+ if (StoreClass !== PageStore && !(StoreClass?.prototype instanceof PageStore)) {
449
+ throw new TypeError('PageStore must subclass gramlot.PageStore');
450
+ }
451
+ const store = this.createPageStore(StoreClass, {pageId, owner});
452
+ record.store = store;
453
+ if (store instanceof ChatPageStore) store.attachments.url = prefix + '/gramlot/attachment/' + pageId + '/';
454
+ store._sourceBuilder = () => {
455
+ const builder = new PageClass.sourceBuilder(null, {nameSyntax:this.nameSyntax});
456
+ this.loadCollections(builder, selected);
457
+ return builder;
458
+ };
459
+ store._sharedStore = (key, factory) => this.sharedStore(key, factory);
460
+ store._publishToPage = (topic, payload, target) => this.publishToPage(topic, payload, {sourcePageId:pageId, pageId:target, owner});
461
+ store.start();
462
+ }
463
+ } catch (error) { this.closePage(pageId, {owner}); throw error; }
351
464
  return {pageId, title: PageClass.title, resources, nameSyntax: this.nameSyntax.toJSON(),
352
465
  ...(PageClass.devices.length ? {devices: [...PageClass.devices]} : {}),
353
466
  ...(PageClass.locale == null ? {} : {locale: PageClass.locale}),
@@ -356,15 +469,17 @@ export class GramlotServer {
356
469
 
357
470
  /** Register the page (registerPage) and return its bootstrap. prefix is the mount prefix chosen
358
471
  * by the adapter, added once to the root-relative bootstrap URLs. */
359
- async openPage(path, {owner = null, prefix = ''} = {}) {
472
+ async openPage(path, {owner = null, prefix = '', websocketUrl = this.websocketUrl} = {}) {
360
473
  if (typeof prefix !== 'string') throw new TypeError('Mount prefix must be a string');
361
- const {pageId, title, resources, nameSyntax, locale, timeZone, devices} = await this.registerPage(path, {owner});
474
+ const {pageId, title, resources, nameSyntax, locale, timeZone, devices} = await this.registerPage(path, {owner, prefix, websocketUrl});
362
475
  try {
363
476
  const nonce = createNonce();
364
477
  // The CSS links and the JS modules reach the page through PageBootstrap (§4.12, D9).
365
478
  const bootstrap = scriptJson({
366
479
  config: {pageId, rpcUrl: prefixed(prefix, this.rpcUrl), closeUrl: prefixed(prefix, this.closeUrl),
367
480
  rootId: this.rootId, capabilities: this.capabilities, nameSyntax,
481
+ ...(websocketUrl !== null ? {websocketUrl:prefixed(prefix, websocketUrl)} : {}),
482
+ ...(this.uploadUrl !== null ? {uploadUrl:prefixed(prefix,this.uploadUrl)} : {}),
368
483
  ...(devices === undefined ? {} : {devices}),
369
484
  ...(locale === undefined ? {} : {locale}), ...(timeZone === undefined ? {} : {timeZone})},
370
485
  resources: {...(resources.collections ? {collections: resources.collections.map(record => ({...record,url:prefixed(prefix,record.url)}))} : {}),
@@ -373,7 +488,8 @@ export class GramlotServer {
373
488
  ...(resources.serverAdapter ? {serverAdapter: prefixed(prefix, resources.serverAdapter)} : {})},
374
489
  });
375
490
  const document = new GramlotBuilder();
376
- const root = document.root.html({'data-gramlot-library-source': this.librarySource});
491
+ const root = document.root.html({'data-gramlot-library-source': this.librarySource,
492
+ 'data-gramlot-theme-root': prefixed(prefix, '/themes/')});
377
493
  const head = root.head();
378
494
  head.meta({charset: 'utf-8'});
379
495
  head.meta({name: 'viewport', content: 'width=device-width,initial-scale=1'});
@@ -427,7 +543,7 @@ export class GramlotServer {
427
543
  const request = parseRequest(text);
428
544
  const response = {id: request.id, contentType: request.contentType};
429
545
  try {
430
- response.value = (await this.#run(request, owner, identity)) ?? null;
546
+ response.value = (await this.#run(request, owner, identity, response)) ?? null;
431
547
  if (request.contentType === 'source' && request.name === 'main') {
432
548
  const data = await this.resolveData(this.pages.get(request.pageId).path);
433
549
  if (data !== null) {
@@ -439,6 +555,7 @@ export class GramlotServer {
439
555
  } catch (error) {
440
556
  delete response.value;
441
557
  delete response.data;
558
+ delete response.icons;
442
559
  response.error = {code: OUTCOME_CODES.get(error?.constructor) ?? 'application_error',
443
560
  name: error?.name ?? 'Error', message: error?.message ?? String(error)};
444
561
  if (gramlotDev() === 'DEBUG') response.error.details = error?.stack;
@@ -453,13 +570,14 @@ export class GramlotServer {
453
570
  * owner that has not expired renews the page, whatever the outcome of the method; any other call renews
454
571
  * nothing (GC-230 §010).
455
572
  */
456
- async #run({pageId, contentType, name, params}, owner, identity) {
573
+ async #run({pageId, contentType, name, params}, owner, identity, response) {
457
574
  this.prune();
458
575
  const record = this.pages.get(pageId);
459
576
  if (!record || record.owner !== owner) throw new PageExpired('Unknown, expired or unowned page');
460
577
  record.expires = this.#expiry();
461
578
  const page = new record.PageClass();
462
579
  page.pageId = pageId;
580
+ if (record.store instanceof ChatPageStore) page.chat_files = record.store.attachments;
463
581
  Object.defineProperty(page, 'requestIdentity', {value:identity, writable:false});
464
582
  if (contentType === 'upload') return this.#uploadControl(page, pageId, owner, identity, name, params);
465
583
  const source = contentType === 'source';
@@ -482,11 +600,17 @@ export class GramlotServer {
482
600
  throw new Refusal(`Access refused: ${name}`);
483
601
  }
484
602
  if (!source) return callable.call(instance, params);
603
+ const {_inheritedAttributes: inherited, ...sourceParams} = params;
485
604
  const builder = new record.PageClass.sourceBuilder(name,
486
605
  {auth: elementRule => this.#authOutcome(elementRule, owner, identity), nameSyntax: this.nameSyntax});
606
+ // remote with sendInheritedAttributes: the _root_ node above the fragment carries them, so every
607
+ // node of the fragment inherits them, as the root_wrapper of legacy makeRoot.
608
+ if (inherited !== undefined) builder.source.parentNode.setAttr(inherited, false);
487
609
  this.loadCollections(builder, this.pageCollections(record.PageClass));
488
- const result = await callable.call(instance, builder.root, params);
610
+ const result = await callable.call(instance, builder.root, sourceParams);
489
611
  if (result !== undefined && result !== null) throw new TypeError('Source methods populate root and return no value');
612
+ const icons = page._icons.definitions();
613
+ if (Object.keys(icons).length) response.icons = icons;
490
614
  return builder.toTytx();
491
615
  }
492
616
 
@@ -535,7 +659,7 @@ export class GramlotServer {
535
659
  if (!['status','cancel'].includes(name) || Object.keys(params).join(',') !== 'transferId') throw new TypeError('Invalid upload control');
536
660
  const record = this.uploads.record(params.transferId, pageId, owner);
537
661
  this.#uploadOperation(page, record.operation, owner, identity);
538
- return name === 'status' ? record.transfer.status() : record.transfer.abort();
662
+ return name === 'status' ? record.transfer.checkpoint() : record.transfer.abort();
539
663
  }
540
664
 
541
665
  /** Admit a single binary upload; adapters provide the current request identity. */
@@ -546,10 +670,13 @@ export class GramlotServer {
546
670
  if (!record || record.owner !== owner) throw new PageExpired('Unknown, expired or unowned page');
547
671
  const page = new record.PageClass();
548
672
  page.pageId = pageId;
673
+ if (record.store instanceof ChatPageStore) page.chat_files = record.store.attachments;
549
674
  Object.defineProperty(page, 'requestIdentity', {value:identity, writable:false});
550
675
  const upload = this.uploads.record(transferId, pageId, owner);
551
676
  this.#uploadOperation(page, upload.operation, owner, identity);
552
- return this.uploads.admit(transferId, pageId, owner, authorization);
677
+ const transfer = this.uploads.admit(transferId, pageId, owner, authorization);
678
+ record.expires = this.#expiry();
679
+ return transfer;
553
680
  }
554
681
 
555
682
  /** Close the page named by the close message `text`, `{"pageId": string}` as JSON, when `owner`
@@ -569,16 +696,19 @@ export class GramlotServer {
569
696
  }
570
697
 
571
698
  closePage(pageId, {owner = null} = {}) {
572
- if (this.pages.get(pageId)?.owner === owner) {
699
+ const record = this.pages.get(pageId);
700
+ if (record && record.owner === owner) {
573
701
  this.pages.delete(pageId);
702
+ record.store?.close();
574
703
  void this.uploads?.closePage(pageId, owner);
575
704
  }
576
705
  }
577
706
 
578
707
  /** Forget every registered page; adapters call it on shutdown. */
579
708
  closeAll() {
580
- for (const [pageId, record] of this.pages) void this.uploads?.closePage(pageId, record.owner);
581
- this.pages = new Map();
709
+ for (const [pageId, record] of this.pages) this.closePage(pageId, {owner:record.owner});
710
+ for (const store of this.sharedStores.values()) store.close();
711
+ this.sharedStores.clear();
582
712
  }
583
713
 
584
714
  }
@@ -4,6 +4,16 @@ import type {Bag, BagNode} from '@genrojs/bag';
4
4
  export class IndexPage extends FramePage {
5
5
  static navigation: Bag;
6
6
  static datapath: string;
7
+ static navigationSelection: string | null;
8
+ static logoUrl: string | null;
9
+ static sidebarTools: ReadonlyArray<'navigation' | 'toolbar' | 'settings' | Record<string, unknown>>;
10
+ static settingsId: string | null;
11
+ static themeGroup: string | null;
12
+ commandBar(frame: any): void;
13
+ toolbar(rail: any): void;
14
+ top(pane: any): void;
15
+ header(pane: any): any;
16
+ settings(pane: any): any;
7
17
  left(pane: any): void;
8
18
  center(pane: any): void;
9
19
  panel(pane: any, node: BagNode): void;
@@ -3,28 +3,112 @@
3
3
  import {Bag} from '@genrojs/bag';
4
4
  import {FramePage} from './frame-page.js';
5
5
 
6
+ // Built-in texts by language of the page locale; English when the language has none.
7
+ const TEXTS = {
8
+ en: {navigation:'Navigation', settings:'Settings', tools:'Application tools',
9
+ appearance:'Theme', palette:'Colors', theme:'Color mode',
10
+ palettes:'default:Theme default,compact:Blue & slate,mimi:Sage & green,joanna:Warm gray & blue',
11
+ themes:'auto:System,light:Light,dark:Dark'},
12
+ it: {navigation:'Navigazione', settings:'Impostazioni', tools:"Strumenti dell'applicazione",
13
+ appearance:'Tema', palette:'Colori', theme:'Modalità colore',
14
+ palettes:'default:Predefiniti del tema,compact:Blu e ardesia,mimi:Salvia e verde,joanna:Grigio caldo e blu',
15
+ themes:'auto:Sistema,light:Chiaro,dark:Scuro'},
16
+ };
17
+
6
18
  export class IndexPage extends FramePage {
7
19
  static title = 'Application';
8
20
  static shellId = 'index';
9
21
  static datapath = 'index';
10
22
  static navigation = null;
23
+ static navigationSelection = null;
24
+ static logoUrl = null;
25
+ static sidebarTools = ['navigation', 'toolbar', 'settings'];
26
+ static settingsId = null;
27
+ static themeGroup = null;
28
+ static css = ['/themes/gramlot-index/theme.css'];
29
+
30
+ #language() {
31
+ const language = (this.constructor.locale ?? '').split('-')[0].toLowerCase();
32
+ return TEXTS[language] ? language : 'en';
33
+ }
34
+ #texts() { return TEXTS[this.#language()]; }
11
35
 
12
36
  main(root) {
13
- const {navigation, datapath} = this.constructor;
37
+ const {navigation, datapath, shellId, navigationSelection, themeGroup} = this.constructor;
14
38
  if (!(navigation instanceof Bag)) throw new TypeError('IndexPage.navigation must be a Bag');
15
- root.dataSetter({destination_path: `${datapath}.navigation`, value: navigation});
16
- root.dataSetter({destination_path: `${datapath}.navigationSelection`, value: null});
17
- root.dataSetter({destination_path: `${datapath}.active`, value: null});
18
- root.dataSetter({destination_path: `${datapath}.opened`, value: new Bag()});
19
- super.main(root);
39
+ if (themeGroup !== null && (typeof themeGroup !== 'string' || !themeGroup.trim())) {
40
+ throw new TypeError('IndexPage.themeGroup must be nonempty text');
41
+ }
42
+ const frame = root.framePane({id:`${shellId}-frame`, class:'gramlot-index-frame', height:'100%', min_height:0});
43
+ for (const [destination_path,value] of Object.entries({
44
+ '.navigation':navigation, '.navigationSelection':navigationSelection,
45
+ '.active':null, '.opened':new Bag(), '.navigationOpen':true,
46
+ '.settingsOpen':false, '.themeGroup':themeGroup,
47
+ })) frame.dataSetter({datapath,destination_path,value});
48
+ this.commandBar(frame);
49
+ super.main(frame.center);
50
+ const settings = frame.center.floatingPane({id:`${shellId}-settings`, title:this.#texts().settings, datapath,
51
+ open:'^.settingsOpen', width:'390px', height:'420px'});
52
+ settings.frame.center.setAttr({padding:'12px', overflow:'auto'});
53
+ this.settings(settings.frame.center);
54
+ }
55
+ commandBar(frame) {
56
+ const {shellId, datapath, sidebarTools} = this.constructor;
57
+ if (!sidebarTools.length) return;
58
+ const region = frame.left;
59
+ region.setAttr({id:`${shellId}-rail-region`, width:'42px', class:'gramlot-index-rail-region', datapath});
60
+ const rail = region.menu({id:`${shellId}-rail`, class:'gramlot-index-rail',
61
+ presentation:'bar', orientation:'vertical', labelPosition:'tooltip', icon_size:24,
62
+ width:'100%', height:'100%', aria_label:this.#texts().tools});
63
+ for (const tool of sidebarTools) {
64
+ if (tool && typeof tool === 'object' && !Array.isArray(tool)) {
65
+ rail.menuline(tool);
66
+ } else if (tool === 'toolbar') {
67
+ this.toolbar(rail);
68
+ } else if (tool === 'navigation') {
69
+ rail.menuline({id:`${shellId}-navigation-button`, caption:this.#texts().navigation, icon:'navigation',
70
+ checked:'^.navigationOpen', action:"this.SET('.navigationOpen', !this.GET('.navigationOpen'))"});
71
+ } else if (tool === 'settings') {
72
+ rail.menuline({id:`${shellId}-settings-button`, caption:this.#texts().settings, icon:'settings',
73
+ checked:'^.settingsOpen', action:"this.SET('.settingsOpen', !this.GET('.settingsOpen'))"});
74
+ } else {
75
+ throw new TypeError(`Unknown IndexPage sidebar tool: ${tool}`);
76
+ }
77
+ }
78
+ }
79
+ toolbar(rail) { rail.spacer({flex:1}); }
80
+ top(pane) {
81
+ pane.setAttr({height:'42px'});
82
+ this.header(pane);
83
+ }
84
+ header(pane) {
85
+ const header = pane.header({class:'gramlot-index-header'});
86
+ if (this.constructor.logoUrl) header.img({src:this.constructor.logoUrl, alt:''});
87
+ header.h1(this.constructor.title);
88
+ return header;
89
+ }
90
+ settings(pane) {
91
+ const fields = pane.formlet({columns:1, lbl_position:'L', lbl_text_align:'right',
92
+ box_c_width:'100%', gap:'8px 12px'});
93
+ const prefix = this.constructor.settingsId ?? this.constructor.shellId;
94
+ const texts = this.#texts();
95
+ for (const [name,lbl,values] of [
96
+ ['appearance',texts.appearance,'base:Base,compact:Compact,mimi:Mimi,joanna:Joanna,mela:Mela'],
97
+ ['palette',texts.palette,texts.palettes],
98
+ ['theme',texts.theme,texts.themes],
99
+ ]) fields.filteringSelect({id:`${prefix}-${name}`, lbl, value:`^.${name}`, values, validate_notnull:true});
100
+ return fields;
20
101
  }
21
102
  left(pane) {
22
- pane.setAttr({width: '240px', splitter: true, drawer: true, drawer_label: 'Navigation'});
103
+ pane.setAttr({width: '240px', splitter: true, nodeId:`${this.constructor.shellId}Navigation`,
104
+ drawer: "^.navigationOpen:={} ? true : 'close'", drawer_label: this.#texts().navigation});
105
+ pane.dataController({script: "this.SET('.navigationOpen', open)",
106
+ [`subscribe_${this.constructor.shellId}Navigation_closable_change`]: true});
23
107
  pane.tree({node_label: 'tree', storepath: '.navigation',
24
108
  labelAttribute: 'title', hideValues: true, selectedPath: '^.navigationSelection'});
25
109
  }
26
110
  center(pane) {
27
- pane.tabContainer({node_label: 'tabs', height: '100%', selectedPage: '^.active'});
111
+ pane.tabContainer({node_label: 'tabs', tabMode: 'tabBar', height: '100%', selectedPage: '^.active'});
28
112
  }
29
113
  behavior(shell) {
30
114
  shell.dataController({func: 'indexMount', _onStart: true});
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @module
6
6
  */
7
- export {Exposed, Page} from './page.js';
7
+ export {Exposed, Page, PageStore} from './page.js';
8
8
  export {GramlotServer, EndpointNotFound, InvalidRequest, NotAuthenticated, NotAuthorized, PageExpired, PageNotFound,
9
9
  SourceNotFound, ServerCapacity} from './gramlot-server.js';
10
10
  export type {GramlotServerOptions, OpenedPage, RegisteredPage} from './gramlot-server.js';
@@ -6,7 +6,7 @@
6
6
  * @module
7
7
  */
8
8
  // Server entry point: deliberately not re-exported by the browser entry point.
9
- export {Exposed, Page} from './page.js';
9
+ export {Exposed, Page, PageStore} from './page.js';
10
10
  export {GramlotServer, EndpointNotFound, InvalidRequest, NotAuthenticated, NotAuthorized, PageExpired, PageNotFound,
11
11
  SourceNotFound, ServerCapacity} from './gramlot-server.js';
12
12
  export {GramlotBuilder} from '../builder/gramlot-builder.js';
@@ -1,3 +1,4 @@
1
+ import {IconRegistry} from '../icons.js';
1
2
  /* @ts-self-types="./page.d.ts" */
2
3
  /**
3
4
  * Server-side page base class, the `Exposed` base of the classes reached by a method path, and the
@@ -109,6 +110,9 @@ export class Exposed {
109
110
 
110
111
  /** Server-side page base; unrelated to browser view components. */
111
112
  export class Page extends Exposed {
113
+ _icons = new IconRegistry();
114
+ addIcon(name, asset) { this._icons.add(name, asset); }
115
+
112
116
  static gramlots = [];
113
117
  static title = 'Gramlot';
114
118
  static devices = [];
@@ -0,0 +1,21 @@
1
+ import type {Bag} from '@genrojs/bag';
2
+ import type {GramlotBuilder} from '../builder/gramlot-builder.js';
3
+
4
+ export class PageStore {
5
+ readonly builder: GramlotBuilder;
6
+ readonly data: Bag;
7
+ readonly closed: boolean;
8
+ main(root: GramlotBuilder['root']): void;
9
+ start(): void;
10
+ close(): void;
11
+ sourceBuilder(): GramlotBuilder;
12
+ sharedStore<T extends PageStore>(key: string[], factory: () => T): T;
13
+ bindPath(path: string, target: PageStore, targetPath: string, options: {authorize: () => boolean; writable?: boolean}): string;
14
+ isPathBound(path: string): boolean;
15
+ unbindPath(path: string): void;
16
+ unbindPaths(): void;
17
+ subscribe(binderId: string, path: string, send: (wire: string) => void): void;
18
+ unsubscribe(binderId: string): void;
19
+ change(binderId: string, message: {path: string; evt: string; value?: unknown; attr?: Record<string, unknown>; index?: number | null; fired?: boolean}): void;
20
+ publish(topic: string, payload?: Record<string, unknown>, options?: {metadata?: Record<string, unknown>; pageId?: string}): void;
21
+ }