@gramlot/gramlot 0.3.41 → 0.4.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.
- package/assets/icons/applications.svg +4 -0
- package/assets/icons/archive.svg +4 -0
- package/assets/icons/attachment.svg +4 -0
- package/assets/icons/book.svg +4 -0
- package/assets/icons/bookmark.svg +4 -0
- package/assets/icons/calendar.svg +4 -0
- package/assets/icons/cancel.svg +4 -0
- package/assets/icons/chart.svg +4 -1
- package/assets/icons/chat.svg +4 -0
- package/assets/icons/clock.svg +4 -0
- package/assets/icons/code.svg +4 -0
- package/assets/icons/collapse.svg +4 -0
- package/assets/icons/columns.svg +4 -0
- package/assets/icons/confirm.svg +4 -0
- package/assets/icons/copy.svg +4 -0
- package/assets/icons/cut.svg +4 -0
- package/assets/icons/database.svg +4 -0
- package/assets/icons/delete.svg +4 -0
- package/assets/icons/detach.svg +4 -0
- package/assets/icons/document.svg +4 -0
- package/assets/icons/download.svg +4 -0
- package/assets/icons/duplicate.svg +4 -0
- package/assets/icons/edit.svg +4 -0
- package/assets/icons/expand.svg +4 -0
- package/assets/icons/export.svg +4 -0
- package/assets/icons/eye.svg +4 -0
- package/assets/icons/filter.svg +4 -0
- package/assets/icons/first.svg +4 -0
- package/assets/icons/folder.svg +4 -0
- package/assets/icons/group.svg +4 -0
- package/assets/icons/help.svg +4 -0
- package/assets/icons/home.svg +4 -0
- package/assets/icons/import.svg +4 -0
- package/assets/icons/info.svg +4 -0
- package/assets/icons/inspector.svg +4 -0
- package/assets/icons/last.svg +4 -0
- package/assets/icons/layers.svg +4 -0
- package/assets/icons/link.svg +4 -0
- package/assets/icons/list.svg +4 -0
- package/assets/icons/lock.svg +4 -0
- package/assets/icons/logout.svg +4 -0
- package/assets/icons/navigation.svg +4 -0
- package/assets/icons/new.svg +4 -0
- package/assets/icons/next.svg +4 -0
- package/assets/icons/open.svg +4 -0
- package/assets/icons/palette.svg +4 -0
- package/assets/icons/panel-bottom.svg +4 -0
- package/assets/icons/panel-left.svg +4 -0
- package/assets/icons/panel-right.svg +4 -0
- package/assets/icons/panel-top.svg +4 -0
- package/assets/icons/paste.svg +4 -0
- package/assets/icons/pause.svg +4 -0
- package/assets/icons/pin.svg +4 -0
- package/assets/icons/play.svg +4 -0
- package/assets/icons/previous.svg +4 -0
- package/assets/icons/print.svg +4 -0
- package/assets/icons/redo.svg +4 -0
- package/assets/icons/refresh.svg +4 -0
- package/assets/icons/save.svg +4 -0
- package/assets/icons/search.svg +4 -0
- package/assets/icons/send.svg +4 -0
- package/assets/icons/settings.svg +4 -0
- package/assets/icons/sort-ascending.svg +4 -0
- package/assets/icons/sort-descending.svg +4 -0
- package/assets/icons/stop.svg +4 -0
- package/assets/icons/table.svg +4 -0
- package/assets/icons/tree.svg +4 -0
- package/assets/icons/undo.svg +4 -0
- package/assets/icons/unlock.svg +4 -0
- package/assets/icons/upload.svg +4 -0
- package/assets/icons/user.svg +4 -0
- package/assets/icons/warning.svg +4 -0
- package/assets/icons/zoom-in.svg +4 -0
- package/assets/icons/zoom-out.svg +4 -0
- package/dist/components/charts/__init__.py +1 -1
- package/dist/components/charts/assets/index.js +1 -1
- package/dist/components/charts/assets/libraries/vega.js +11 -11
- package/dist/components/editors/__init__.py +1 -1
- package/dist/components/editors/assets/index.js +1 -1
- package/dist/components/editors/assets/libraries/codemirror.js +30 -31
- package/dist/components/editors/assets/libraries/jodit.js +3 -1
- package/dist/components/editors/grammar.json +6 -1
- package/dist/components/grid/__init__.py +1 -1
- package/dist/components/grid/assets/index.js +1 -1
- package/dist/components/grid/commands.json +4 -6
- package/dist/components/grid/grammar.json +51 -0
- package/dist/components/inputs/__init__.py +1 -1
- package/dist/components/inputs/assets/index.js +1 -1
- package/dist/components/inputs/grammar.json +4987 -216
- package/dist/components/layout/__init__.py +1 -1
- package/dist/components/layout/assets/index.js +1 -1
- package/dist/components/layout/grammar.json +69 -4
- package/dist/components/tree/__init__.py +1 -1
- package/dist/components/tree/assets/index.js +1 -1
- package/dist/components/tree/grammar.json +16 -0
- package/dist/components/typst/__init__.py +1 -1
- package/dist/components/typst/assets/collection.js +6 -6
- package/dist/components/typst/assets/index.js +1 -1
- package/dist/components/uploads/__init__.py +1 -1
- package/dist/components/uploads/assets/index.js +1 -1
- package/dist/components/uploads/grammar.json +66 -0
- package/dist/declared-collections.js +1 -1
- package/dist/gramlot.js +3961 -1249
- package/dist/gramlot.min.js +329 -131
- package/dist/libraries.json +1 -0
- package/dist/standard-collections.js +1 -1
- package/dist/standard-grammar.js +1 -1
- package/package.json +3 -1
- package/src/binding/ask-dialog.js +17 -3
- package/src/binding/providers.js +1 -1
- package/src/binding/runtime.js +6 -3
- package/src/builder/chart-icon.js +2 -0
- package/src/builder/gramlot-builder.d.ts +3 -1
- package/src/builder/gramlot-builder.js +26 -9
- package/src/builder/source.js +12 -3
- package/src/builder/xml-recipe.js +144 -0
- package/src/chat-file-types.js +13 -0
- package/src/chat.js +23 -25
- package/src/commands.d.ts +1 -1
- package/src/commands.js +1 -1
- package/src/components/border-container.js +64 -6
- package/src/components/buttons.js +26 -31
- package/src/components/chart-geographic-options.js +1 -1
- package/src/components/chart-pane.js +5 -5
- package/src/components/chart-spatial-options.js +5 -1
- package/src/components/check-box-text-editor.js +1 -0
- package/src/components/check-box-text.js +2 -0
- package/src/components/choice-editor.js +3 -2
- package/src/components/choice-field-styles.js +9 -1
- package/src/components/code-mirror-engine.js +18 -5
- package/src/components/code-mirror-gramlot.js +85 -0
- package/src/components/code-mirror.js +3 -2
- package/src/components/drawing.js +43 -14
- package/src/components/editor-options.js +1 -1
- package/src/components/graphical-ranges.js +177 -0
- package/src/components/grid-footer.js +6 -1
- package/src/components/grid-styles.js +11 -2
- package/src/components/grid-tools.js +15 -7
- package/src/components/grid.js +69 -8
- package/src/components/inputs.js +93 -23
- package/src/components/jodit-engine.js +3 -1
- package/src/components/menus.js +83 -25
- package/src/components/numeric-range.js +39 -0
- package/src/components/selected-container.js +109 -63
- package/src/components/tab-bar.js +371 -0
- package/src/components/toolbar-icon-style.js +22 -0
- package/src/components/toolbar-overflow.js +74 -12
- package/src/components/tree.js +12 -3
- package/src/components/typst-preview.js +3 -3
- package/src/components/upload-blocks.js +88 -0
- package/src/components/upload-engine.js +21 -31
- package/src/components/uploader.js +168 -47
- package/src/gramlot.js +6 -3
- package/src/handlers/dom-handler.d.ts +2 -0
- package/src/handlers/dom-handler.js +9 -0
- package/src/handlers/rpc-handler.d.ts +1 -1
- package/src/handlers/rpc-handler.js +2 -0
- package/src/handlers/source-handler.d.ts +5 -3
- package/src/handlers/source-handler.js +31 -13
- package/src/icons.js +84 -0
- package/src/index-page-runtime.js +9 -2
- package/src/index-page-styles.js +1 -1
- package/src/index-theme.js +210 -3
- package/src/index.d.ts +5 -1
- package/src/index.js +5 -1
- package/src/libraries.js +1 -1
- package/src/renderer/gramlot-renderer.js +4 -1
- package/src/server/chat-attachments.js +139 -0
- package/src/server/chat.d.ts +31 -0
- package/src/server/chat.js +157 -0
- package/src/server/database-selectors.d.ts +6 -0
- package/src/server/database-selectors.js +13 -0
- package/src/server/gramlot-file-server.js +6 -1
- package/src/server/gramlot-server.d.ts +19 -3
- package/src/server/gramlot-server.js +144 -18
- package/src/server/index-page.d.ts +10 -0
- package/src/server/index-page.js +73 -8
- package/src/server/index.d.ts +1 -1
- package/src/server/index.js +1 -1
- package/src/server/page-base.js +4 -0
- package/src/server/page-store.d.ts +21 -0
- package/src/server/page-store.js +219 -0
- package/src/server/page.d.ts +6 -1
- package/src/server/page.js +5 -1
- package/src/server/store-recipe.js +102 -0
- package/src/server/toolbar-icon-name.d.ts +76 -0
- package/src/server/upload.d.ts +2 -0
- package/src/server/upload.js +36 -18
- package/src/server/visual-editor.js +4 -2
- package/src/tree-store.d.ts +5 -1
- package/src/tree-store.js +11 -2
- package/src/view/choice-focus.js +17 -0
- package/src/view/html.js +21 -1
- package/src/view/menu.js +9 -3
- package/src/visual-editor.js +6 -2
- package/themes/gramlot-base/theme.css +53 -28
- package/themes/gramlot-compact/theme.css +2 -0
- package/themes/gramlot-index/icons/applications.svg +4 -0
- package/themes/gramlot-index/icons/archive.svg +4 -0
- package/themes/gramlot-index/icons/attachment.svg +4 -0
- package/themes/gramlot-index/icons/book.svg +4 -0
- package/themes/gramlot-index/icons/bookmark.svg +4 -0
- package/themes/gramlot-index/icons/calendar.svg +4 -0
- package/themes/gramlot-index/icons/cancel.svg +4 -0
- package/themes/gramlot-index/icons/chart.svg +4 -0
- package/themes/gramlot-index/icons/chat.svg +4 -0
- package/themes/gramlot-index/icons/clock.svg +4 -0
- package/themes/gramlot-index/icons/code.svg +4 -0
- package/themes/gramlot-index/icons/collapse.svg +4 -0
- package/themes/gramlot-index/icons/columns.svg +4 -0
- package/themes/gramlot-index/icons/confirm.svg +4 -0
- package/themes/gramlot-index/icons/copy.svg +4 -0
- package/themes/gramlot-index/icons/cut.svg +4 -0
- package/themes/gramlot-index/icons/database.svg +4 -0
- package/themes/gramlot-index/icons/delete.svg +4 -0
- package/themes/gramlot-index/icons/detach.svg +4 -0
- package/themes/gramlot-index/icons/document.svg +4 -0
- package/themes/gramlot-index/icons/download.svg +4 -0
- package/themes/gramlot-index/icons/duplicate.svg +4 -0
- package/themes/gramlot-index/icons/edit.svg +4 -0
- package/themes/gramlot-index/icons/expand.svg +4 -0
- package/themes/gramlot-index/icons/export.svg +4 -0
- package/themes/gramlot-index/icons/eye.svg +4 -0
- package/themes/gramlot-index/icons/filter.svg +4 -0
- package/themes/gramlot-index/icons/first.svg +4 -0
- package/themes/gramlot-index/icons/folder.svg +4 -0
- package/themes/gramlot-index/icons/group.svg +4 -0
- package/themes/gramlot-index/icons/help.svg +4 -0
- package/themes/gramlot-index/icons/home.svg +4 -0
- package/themes/gramlot-index/icons/import.svg +4 -0
- package/themes/gramlot-index/icons/info.svg +4 -0
- package/themes/gramlot-index/icons/inspector.svg +4 -0
- package/themes/gramlot-index/icons/last.svg +4 -0
- package/themes/gramlot-index/icons/layers.svg +4 -0
- package/themes/gramlot-index/icons/link.svg +4 -0
- package/themes/gramlot-index/icons/list.svg +4 -0
- package/themes/gramlot-index/icons/lock.svg +4 -0
- package/themes/gramlot-index/icons/logout.svg +4 -0
- package/themes/gramlot-index/icons/navigation.svg +4 -0
- package/themes/gramlot-index/icons/new.svg +4 -0
- package/themes/gramlot-index/icons/next.svg +4 -0
- package/themes/gramlot-index/icons/open.svg +4 -0
- package/themes/gramlot-index/icons/palette.svg +4 -0
- package/themes/gramlot-index/icons/panel-bottom.svg +4 -0
- package/themes/gramlot-index/icons/panel-left.svg +4 -0
- package/themes/gramlot-index/icons/panel-right.svg +4 -0
- package/themes/gramlot-index/icons/panel-top.svg +4 -0
- package/themes/gramlot-index/icons/paste.svg +4 -0
- package/themes/gramlot-index/icons/pause.svg +4 -0
- package/themes/gramlot-index/icons/pin.svg +4 -0
- package/themes/gramlot-index/icons/play.svg +4 -0
- package/themes/gramlot-index/icons/previous.svg +4 -0
- package/themes/gramlot-index/icons/print.svg +4 -0
- package/themes/gramlot-index/icons/redo.svg +4 -0
- package/themes/gramlot-index/icons/refresh.svg +4 -0
- package/themes/gramlot-index/icons/save.svg +4 -0
- package/themes/gramlot-index/icons/search.svg +4 -0
- package/themes/gramlot-index/icons/send.svg +4 -0
- package/themes/gramlot-index/icons/settings.svg +4 -0
- package/themes/gramlot-index/icons/sort-ascending.svg +4 -0
- package/themes/gramlot-index/icons/sort-descending.svg +4 -0
- package/themes/gramlot-index/icons/stop.svg +4 -0
- package/themes/gramlot-index/icons/table.svg +4 -0
- package/themes/gramlot-index/icons/tree.svg +4 -0
- package/themes/gramlot-index/icons/undo.svg +4 -0
- package/themes/gramlot-index/icons/unlock.svg +4 -0
- package/themes/gramlot-index/icons/upload.svg +4 -0
- package/themes/gramlot-index/icons/user.svg +4 -0
- package/themes/gramlot-index/icons/warning.svg +4 -0
- package/themes/gramlot-index/icons/zoom-in.svg +4 -0
- package/themes/gramlot-index/icons/zoom-out.svg +4 -0
- package/themes/gramlot-index/icons.json +76 -0
- package/themes/gramlot-index/theme.css +21 -0
- package/themes/joanna/theme.css +2 -0
- package/themes/mela/theme.css +2 -0
- package/themes/mimi/theme.css +2 -0
|
@@ -60,12 +60,16 @@ export interface PreparedCollection {
|
|
|
60
60
|
libraries?: Record<string, string>;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
import type {PageStore} from './page-store.js';
|
|
64
|
+
|
|
63
65
|
/** The options of a `GramlotServer`. */
|
|
64
66
|
export interface GramlotServerOptions {
|
|
65
67
|
/** URL of the runtime bundle. */
|
|
66
68
|
runtimeUrl?: string;
|
|
67
69
|
/** URL of the request envelopes. */
|
|
68
70
|
rpcUrl?: string;
|
|
71
|
+
websocketUrl?: string | null;
|
|
72
|
+
uploadUrl?: string | null;
|
|
69
73
|
/** URL of the page close endpoint. */
|
|
70
74
|
closeUrl?: string;
|
|
71
75
|
/** Id of the root element of the page. */
|
|
@@ -120,6 +124,8 @@ export class GramlotServer {
|
|
|
120
124
|
readonly markdownUrl: string;
|
|
121
125
|
/** URL of the request envelopes. */
|
|
122
126
|
rpcUrl: string;
|
|
127
|
+
websocketUrl: string | null;
|
|
128
|
+
uploadUrl: string | null;
|
|
123
129
|
/** URL of the page close endpoint. */
|
|
124
130
|
closeUrl: string;
|
|
125
131
|
/** Id of the root element of the page. */
|
|
@@ -170,14 +176,15 @@ export class GramlotServer {
|
|
|
170
176
|
/** The file of a `/themes/<path>` URL path whose real path is a file of the core themes, or null. Node.js and Bun only. */
|
|
171
177
|
themeFile(path: string): Promise<string | null>;
|
|
172
178
|
/** Register a page independently of its HTTP or Worker transport; `<path>/index.html` registers `<path>/`. */
|
|
173
|
-
|
|
179
|
+
openChatImage(pageId: string, ref: string, options: {owner: unknown}): Promise<{bytes: Uint8Array; type: string} | null>;
|
|
180
|
+
registerPage(path: string, options?: {owner?: unknown; prefix?: string; websocketUrl?: string | null}): Promise<RegisteredPage>;
|
|
174
181
|
/** Register the page and return its bootstrap; `prefix` is the mount prefix added to root-relative URLs. */
|
|
175
|
-
openPage(path: string, options?: {owner?: unknown; prefix?: string}): Promise<OpenedPage>;
|
|
182
|
+
openPage(path: string, options?: {owner?: unknown; prefix?: string; websocketUrl?: string | null}): Promise<OpenedPage>;
|
|
176
183
|
/** The text of a request body: UTF-8, a leading byte order mark removed; other bytes throw `InvalidRequest`. */
|
|
177
184
|
decodeBody(data: ArrayBuffer | ArrayBufferView): string;
|
|
178
185
|
/** Answer the request envelope `text` (TYTX) with the response envelope (TYTX); throws only `InvalidRequest`. `identity` is the trusted identity of this call, supplied to the fresh Page and `evaluateAuth`. */
|
|
179
186
|
call(text: string, options?: {owner?: unknown; identity?: unknown}): Promise<string>;
|
|
180
|
-
/** Admit
|
|
187
|
+
/** Admit the next block after owner and operation authorization checks. */
|
|
181
188
|
admitUpload(options: {pageId: string; transferId: string; authorization: string; owner?: unknown; identity?: unknown}): UploadTransfer;
|
|
182
189
|
/** Close the page named by the close message `text` (`{"pageId": string}` as JSON) when `owner` owns it; throws `InvalidRequest`. */
|
|
183
190
|
close(text: string, options?: {owner?: unknown}): void;
|
|
@@ -185,4 +192,13 @@ export class GramlotServer {
|
|
|
185
192
|
closePage(pageId: string, options?: {owner?: unknown}): void;
|
|
186
193
|
/** Forget every registered page; adapters call it on shutdown. */
|
|
187
194
|
closeAll(): void;
|
|
195
|
+
resolvePageStore(PageClass: typeof Page, path: string): typeof PageStore | Promise<typeof PageStore>;
|
|
196
|
+
createPageStore(StoreClass: typeof PageStore, context: {pageId: string; owner: unknown}): PageStore;
|
|
197
|
+
pageStore(pageId: string, context: {owner: unknown}): PageStore;
|
|
198
|
+
connectPageChannel(pageId: string, send: (wire: string) => void, context: {owner: unknown}): void;
|
|
199
|
+
disconnectPageChannel(pageId: string, context: {owner: unknown}): void;
|
|
200
|
+
sharedStore<T extends PageStore>(key: string[], factory: () => T): T;
|
|
201
|
+
closeSharedStore(key: string[]): void;
|
|
202
|
+
preparePublish(text: string, context: {owner: unknown}): [string, (() => void) | null];
|
|
203
|
+
publishToPage(topic: string, payload: Record<string, unknown>, context: {sourcePageId: string; pageId: string; owner: unknown}): void;
|
|
188
204
|
}
|
|
@@ -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.
|
|
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
|
-
|
|
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';
|
|
@@ -487,6 +605,8 @@ export class GramlotServer {
|
|
|
487
605
|
this.loadCollections(builder, this.pageCollections(record.PageClass));
|
|
488
606
|
const result = await callable.call(instance, builder.root, params);
|
|
489
607
|
if (result !== undefined && result !== null) throw new TypeError('Source methods populate root and return no value');
|
|
608
|
+
const icons = page._icons.definitions();
|
|
609
|
+
if (Object.keys(icons).length) response.icons = icons;
|
|
490
610
|
return builder.toTytx();
|
|
491
611
|
}
|
|
492
612
|
|
|
@@ -535,7 +655,7 @@ export class GramlotServer {
|
|
|
535
655
|
if (!['status','cancel'].includes(name) || Object.keys(params).join(',') !== 'transferId') throw new TypeError('Invalid upload control');
|
|
536
656
|
const record = this.uploads.record(params.transferId, pageId, owner);
|
|
537
657
|
this.#uploadOperation(page, record.operation, owner, identity);
|
|
538
|
-
return name === 'status' ? record.transfer.
|
|
658
|
+
return name === 'status' ? record.transfer.checkpoint() : record.transfer.abort();
|
|
539
659
|
}
|
|
540
660
|
|
|
541
661
|
/** Admit a single binary upload; adapters provide the current request identity. */
|
|
@@ -546,10 +666,13 @@ export class GramlotServer {
|
|
|
546
666
|
if (!record || record.owner !== owner) throw new PageExpired('Unknown, expired or unowned page');
|
|
547
667
|
const page = new record.PageClass();
|
|
548
668
|
page.pageId = pageId;
|
|
669
|
+
if (record.store instanceof ChatPageStore) page.chat_files = record.store.attachments;
|
|
549
670
|
Object.defineProperty(page, 'requestIdentity', {value:identity, writable:false});
|
|
550
671
|
const upload = this.uploads.record(transferId, pageId, owner);
|
|
551
672
|
this.#uploadOperation(page, upload.operation, owner, identity);
|
|
552
|
-
|
|
673
|
+
const transfer = this.uploads.admit(transferId, pageId, owner, authorization);
|
|
674
|
+
record.expires = this.#expiry();
|
|
675
|
+
return transfer;
|
|
553
676
|
}
|
|
554
677
|
|
|
555
678
|
/** Close the page named by the close message `text`, `{"pageId": string}` as JSON, when `owner`
|
|
@@ -569,16 +692,19 @@ export class GramlotServer {
|
|
|
569
692
|
}
|
|
570
693
|
|
|
571
694
|
closePage(pageId, {owner = null} = {}) {
|
|
572
|
-
|
|
695
|
+
const record = this.pages.get(pageId);
|
|
696
|
+
if (record && record.owner === owner) {
|
|
573
697
|
this.pages.delete(pageId);
|
|
698
|
+
record.store?.close();
|
|
574
699
|
void this.uploads?.closePage(pageId, owner);
|
|
575
700
|
}
|
|
576
701
|
}
|
|
577
702
|
|
|
578
703
|
/** Forget every registered page; adapters call it on shutdown. */
|
|
579
704
|
closeAll() {
|
|
580
|
-
for (const [pageId, record] of this.pages)
|
|
581
|
-
|
|
705
|
+
for (const [pageId, record] of this.pages) this.closePage(pageId, {owner:record.owner});
|
|
706
|
+
for (const store of this.sharedStores.values()) store.close();
|
|
707
|
+
this.sharedStores.clear();
|
|
582
708
|
}
|
|
583
709
|
|
|
584
710
|
}
|
|
@@ -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;
|
package/src/server/index-page.js
CHANGED
|
@@ -8,23 +8,88 @@ export class IndexPage extends FramePage {
|
|
|
8
8
|
static shellId = 'index';
|
|
9
9
|
static datapath = 'index';
|
|
10
10
|
static navigation = null;
|
|
11
|
+
static navigationSelection = null;
|
|
12
|
+
static logoUrl = null;
|
|
13
|
+
static sidebarTools = ['navigation', 'toolbar', 'settings'];
|
|
14
|
+
static settingsId = null;
|
|
15
|
+
static themeGroup = null;
|
|
16
|
+
static css = ['/themes/gramlot-index/theme.css'];
|
|
11
17
|
|
|
12
18
|
main(root) {
|
|
13
|
-
const {navigation, datapath} = this.constructor;
|
|
19
|
+
const {navigation, datapath, shellId, navigationSelection, themeGroup} = this.constructor;
|
|
14
20
|
if (!(navigation instanceof Bag)) throw new TypeError('IndexPage.navigation must be a Bag');
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
root.
|
|
19
|
-
|
|
21
|
+
if (themeGroup !== null && (typeof themeGroup !== 'string' || !themeGroup.trim())) {
|
|
22
|
+
throw new TypeError('IndexPage.themeGroup must be nonempty text');
|
|
23
|
+
}
|
|
24
|
+
const frame = root.framePane({id:`${shellId}-frame`, class:'gramlot-index-frame', height:'100%', min_height:0});
|
|
25
|
+
for (const [destination_path,value] of Object.entries({
|
|
26
|
+
'.navigation':navigation, '.navigationSelection':navigationSelection,
|
|
27
|
+
'.active':null, '.opened':new Bag(), '.navigationOpen':true,
|
|
28
|
+
'.settingsOpen':false, '.themeGroup':themeGroup,
|
|
29
|
+
})) frame.dataSetter({datapath,destination_path,value});
|
|
30
|
+
this.commandBar(frame);
|
|
31
|
+
super.main(frame.center);
|
|
32
|
+
const settings = frame.center.floatingPane({id:`${shellId}-settings`, title:'Settings', datapath,
|
|
33
|
+
open:'^.settingsOpen', width:'390px', height:'420px'});
|
|
34
|
+
settings.frame.center.setAttr({padding:'12px', overflow:'auto'});
|
|
35
|
+
this.settings(settings.frame.center);
|
|
36
|
+
}
|
|
37
|
+
commandBar(frame) {
|
|
38
|
+
const {shellId, datapath, sidebarTools} = this.constructor;
|
|
39
|
+
if (!sidebarTools.length) return;
|
|
40
|
+
const region = frame.left;
|
|
41
|
+
region.setAttr({id:`${shellId}-rail-region`, width:'42px', class:'gramlot-index-rail-region', datapath});
|
|
42
|
+
const rail = region.menu({id:`${shellId}-rail`, class:'gramlot-index-rail',
|
|
43
|
+
presentation:'bar', orientation:'vertical', labelPosition:'tooltip', icon_size:24,
|
|
44
|
+
width:'100%', height:'100%', aria_label:'Application tools'});
|
|
45
|
+
for (const tool of sidebarTools) {
|
|
46
|
+
if (tool && typeof tool === 'object' && !Array.isArray(tool)) {
|
|
47
|
+
rail.menuline(tool);
|
|
48
|
+
} else if (tool === 'toolbar') {
|
|
49
|
+
this.toolbar(rail);
|
|
50
|
+
} else if (tool === 'navigation') {
|
|
51
|
+
rail.menuline({id:`${shellId}-navigation-button`, caption:'Navigation', icon:'navigation',
|
|
52
|
+
checked:'^.navigationOpen', action:"this.SET('.navigationOpen', !this.GET('.navigationOpen'))"});
|
|
53
|
+
} else if (tool === 'settings') {
|
|
54
|
+
rail.menuline({id:`${shellId}-settings-button`, caption:'Settings', icon:'settings',
|
|
55
|
+
checked:'^.settingsOpen', action:"this.SET('.settingsOpen', !this.GET('.settingsOpen'))"});
|
|
56
|
+
} else {
|
|
57
|
+
throw new TypeError(`Unknown IndexPage sidebar tool: ${tool}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
toolbar(rail) { rail.spacer({flex:1}); }
|
|
62
|
+
top(pane) {
|
|
63
|
+
pane.setAttr({height:'42px'});
|
|
64
|
+
this.header(pane);
|
|
65
|
+
}
|
|
66
|
+
header(pane) {
|
|
67
|
+
const header = pane.header({class:'gramlot-index-header'});
|
|
68
|
+
if (this.constructor.logoUrl) header.img({src:this.constructor.logoUrl, alt:''});
|
|
69
|
+
header.h1(this.constructor.title);
|
|
70
|
+
return header;
|
|
71
|
+
}
|
|
72
|
+
settings(pane) {
|
|
73
|
+
const fields = pane.formlet({columns:1, lbl_position:'L', lbl_text_align:'right',
|
|
74
|
+
box_c_width:'100%', gap:'8px 12px'});
|
|
75
|
+
const prefix = this.constructor.settingsId ?? this.constructor.shellId;
|
|
76
|
+
for (const [name,lbl,values] of [
|
|
77
|
+
['appearance','Theme','base:Base,compact:Compact,mimi:Mimi,joanna:Joanna,mela:Mela'],
|
|
78
|
+
['palette','Colors','default:Theme default,compact:Blue & slate,mimi:Sage & green,joanna:Warm gray & blue'],
|
|
79
|
+
['theme','Color mode','auto:System,light:Light,dark:Dark'],
|
|
80
|
+
]) fields.filteringSelect({id:`${prefix}-${name}`, lbl, value:`^.${name}`, values, validate_notnull:true});
|
|
81
|
+
return fields;
|
|
20
82
|
}
|
|
21
83
|
left(pane) {
|
|
22
|
-
pane.setAttr({width: '240px', splitter: true,
|
|
84
|
+
pane.setAttr({width: '240px', splitter: true, nodeId:`${this.constructor.shellId}Navigation`,
|
|
85
|
+
drawer: "^.navigationOpen:={} ? true : 'close'", drawer_label: 'Navigation'});
|
|
86
|
+
pane.dataController({script: "this.SET('.navigationOpen', open)",
|
|
87
|
+
[`subscribe_${this.constructor.shellId}Navigation_closable_change`]: true});
|
|
23
88
|
pane.tree({node_label: 'tree', storepath: '.navigation',
|
|
24
89
|
labelAttribute: 'title', hideValues: true, selectedPath: '^.navigationSelection'});
|
|
25
90
|
}
|
|
26
91
|
center(pane) {
|
|
27
|
-
pane.tabContainer({node_label: 'tabs', height: '100%', selectedPage: '^.active'});
|
|
92
|
+
pane.tabContainer({node_label: 'tabs', tabMode: 'tabBar', height: '100%', selectedPage: '^.active'});
|
|
28
93
|
}
|
|
29
94
|
behavior(shell) {
|
|
30
95
|
shell.dataController({func: 'indexMount', _onStart: true});
|
package/src/server/index.d.ts
CHANGED
|
@@ -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';
|
package/src/server/index.js
CHANGED
|
@@ -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';
|
package/src/server/page-base.js
CHANGED
|
@@ -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
|
+
}
|