@gramlot/gramlot 0.3.27 → 0.3.31
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/chart.svg +1 -0
- package/dist/components/audio/__init__.py +13 -0
- package/dist/components/audio/assets/collection.js +3 -0
- package/dist/components/audio/assets/index.js +3 -0
- package/dist/components/audio/commands.json +7 -0
- package/dist/components/audio/grammar.json +335 -0
- package/dist/components/charts/__init__.py +13 -0
- package/dist/components/charts/assets/collection.js +47 -0
- package/dist/components/charts/assets/files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt +29 -0
- package/dist/components/charts/assets/files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt +27 -0
- package/dist/components/charts/assets/files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt +21 -0
- package/dist/components/charts/assets/files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt +21 -0
- package/dist/components/charts/assets/files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt +23 -0
- package/dist/components/charts/assets/index.js +3 -0
- package/dist/components/charts/assets/modules/chunk-2CCTLZE7.js +76 -0
- package/dist/components/charts/assets/modules/chunk-RMRBEYTI.js +1 -0
- package/dist/components/charts/assets/modules/echarts-gl-CXVTZA6G.js +4409 -0
- package/dist/components/charts/assets/modules/plotly.min-4LB7HE7P.js +3596 -0
- package/dist/components/charts/assets/modules/uPlot.esm-5JJNHHRF.js +3 -0
- package/dist/components/charts/assets/modules/uPlot.min-N3E3FA74.js +1 -0
- package/dist/components/charts/assets/modules/vega.module-2QCOVQ3A.js +13 -0
- package/dist/components/charts/commands.json +7 -0
- package/dist/components/charts/grammar.json +1113 -0
- package/dist/components/chat/__init__.py +1 -1
- package/dist/components/chat/assets/collection.js +3 -3
- package/dist/components/chat/assets/index.js +1 -1
- package/dist/components/drawing/__init__.py +15 -0
- package/dist/components/drawing/assets/collection.js +28 -0
- package/dist/components/drawing/assets/index.js +3 -0
- package/dist/components/drawing/commands.json +7 -0
- package/dist/components/drawing/grammar.json +110 -0
- package/dist/components/editors/__init__.py +2 -2
- package/dist/components/editors/assets/collection.js +18 -18
- package/dist/components/editors/assets/index.js +1 -1
- package/dist/components/editors/assets/modules/{prose-mirror-engine-GMZPJPNN.js → prose-mirror-engine-DQEAEIMV.js} +2 -2
- package/dist/components/editors/grammar.json +150 -0
- package/dist/components/grid/__init__.py +2 -2
- package/dist/components/grid/assets/collection.js +71 -34
- package/dist/components/grid/assets/files/0a1df3a083d0c010560aa342e87959c8c1070e6fd54545741f083f22d0c8b551-fflate.txt +21 -0
- package/dist/components/grid/assets/files/8cf9b31947daf7adb4a7a00a037459e58241af050cd0a603bfcf1756e533f75e-write-excel-file.txt +21 -0
- package/dist/components/grid/assets/index.js +1 -1
- package/dist/components/grid/assets/modules/browser-LVJHKBBV.js +19 -0
- package/dist/components/grid/assets/modules/chunk-RMRBEYTI.js +1 -0
- package/dist/components/grid/commands.json +42 -1
- package/dist/components/grid/grammar.json +650 -10
- package/dist/components/grouplets/__init__.py +1 -1
- package/dist/components/grouplets/assets/collection.js +3 -3
- package/dist/components/grouplets/assets/index.js +1 -1
- package/dist/components/inputs/__init__.py +3 -2
- package/dist/components/inputs/assets/collection.js +38 -23
- package/dist/components/inputs/assets/index.js +1 -1
- package/dist/components/inputs/grammar.json +1533 -321
- package/dist/components/layout/__init__.py +1 -1
- package/dist/components/layout/assets/collection.js +27 -23
- package/dist/components/layout/assets/index.js +1 -1
- package/dist/components/layout/grammar.json +85 -0
- package/dist/components/selection_trial/__init__.py +1 -1
- package/dist/components/selection_trial/assets/collection.js +3 -3
- package/dist/components/selection_trial/assets/index.js +1 -1
- package/dist/components/tree/__init__.py +1 -1
- package/dist/components/tree/assets/collection.js +11 -11
- package/dist/components/tree/assets/index.js +1 -1
- package/dist/components/tree/grammar.json +126 -0
- package/dist/components/typst/__init__.py +1 -1
- package/dist/components/typst/assets/collection.js +2 -2
- package/dist/components/typst/assets/index.js +1 -1
- package/dist/components/uploads/__init__.py +1 -1
- package/dist/components/uploads/assets/collection.js +8 -8
- package/dist/components/uploads/assets/index.js +1 -1
- package/dist/components/vizabi/__init__.py +13 -0
- package/dist/components/vizabi/assets/collection.js +22 -0
- package/dist/components/vizabi/assets/index.js +3 -0
- package/dist/components/vizabi/commands.json +7 -0
- package/dist/components/vizabi/grammar.json +128 -0
- package/dist/gramlot.js +944 -193
- package/dist/gramlot.min.js +85 -53
- package/dist/standard-collections.js +2 -0
- package/package.json +13 -4
- package/src/binding/grid-struct.js +5 -2
- package/src/binding/runtime.js +12 -1
- package/src/bootstrap.js +1 -1
- package/src/builder/gramlot-builder.d.ts +15 -2
- package/src/builder/gramlot-builder.js +116 -8
- package/src/builder/source.js +42 -1
- package/src/components/audio-analysis-session.js +65 -0
- package/src/components/audio.js +44 -0
- package/src/components/bases.js +6 -4
- package/src/components/border-container.js +6 -3
- package/src/components/buttons.js +47 -3
- package/src/components/chart-bar3d-options.js +30 -0
- package/src/components/chart-controls.js +83 -0
- package/src/components/chart-data-view.js +52 -0
- package/src/components/chart-data.js +42 -0
- package/src/components/chart-domains.js +46 -0
- package/src/components/chart-engines/echarts-options.js +50 -0
- package/src/components/chart-engines/echarts.js +82 -0
- package/src/components/chart-engines/index.js +22 -0
- package/src/components/chart-engines/plotly-map.js +34 -0
- package/src/components/chart-engines/plotly-spatial.js +35 -0
- package/src/components/chart-engines/plotly.js +138 -0
- package/src/components/chart-engines/uplot.js +57 -0
- package/src/components/chart-engines/vega.js +101 -0
- package/src/components/chart-fields.js +110 -0
- package/src/components/chart-geographic-options.js +47 -0
- package/src/components/chart-geojson.js +60 -0
- package/src/components/chart-geometry.js +11 -0
- package/src/components/chart-map-anchors.js +24 -0
- package/src/components/chart-map-bar3d-options.js +41 -0
- package/src/components/chart-map-data.js +25 -0
- package/src/components/chart-map-labels.js +8 -0
- package/src/components/chart-map-options.js +20 -0
- package/src/components/chart-pane.js +91 -0
- package/src/components/chart-renderer.js +58 -0
- package/src/components/chart-sample-view.js +32 -0
- package/src/components/chart-spatial-options.js +40 -0
- package/src/components/chart-time.js +84 -0
- package/src/components/chart-timeline.js +70 -0
- package/src/components/chart-types/area.js +2 -0
- package/src/components/chart-types/bar.js +2 -0
- package/src/components/chart-types/bar3D.js +2 -0
- package/src/components/chart-types/donut.js +2 -0
- package/src/components/chart-types/horizontalBar.js +2 -0
- package/src/components/chart-types/index.js +26 -0
- package/src/components/chart-types/line.js +2 -0
- package/src/components/chart-types/line3D.js +2 -0
- package/src/components/chart-types/lines3D.js +2 -0
- package/src/components/chart-types/map.js +2 -0
- package/src/components/chart-types/map3D.js +2 -0
- package/src/components/chart-types/mapBar3D.js +2 -0
- package/src/components/chart-types/pie.js +2 -0
- package/src/components/chart-types/polygons3D.js +2 -0
- package/src/components/chart-types/scatter.js +2 -0
- package/src/components/chart-types/scatter3D.js +2 -0
- package/src/components/chart-types/stackedArea.js +2 -0
- package/src/components/chart-types/stackedBar.js +2 -0
- package/src/components/chart-types/surface.js +2 -0
- package/src/components/charts.js +152 -0
- package/src/components/check-box-text-editor.js +88 -0
- package/src/components/check-box-text.js +193 -0
- package/src/components/check-box-tree.js +62 -0
- package/src/components/choice-editor.js +7 -5
- package/src/components/choice-field-styles.js +14 -0
- package/src/components/choices.js +5 -0
- package/src/components/drawing.js +199 -0
- package/src/components/grid-check-sets.js +98 -0
- package/src/components/grid-column-filters.js +198 -0
- package/src/components/grid-footer.js +120 -0
- package/src/components/grid-formulas.js +403 -0
- package/src/components/grid-grammar.json +131 -2
- package/src/components/grid-header-interaction.js +3 -1
- package/src/components/grid-rows.js +2 -2
- package/src/components/grid-search-box.js +38 -22
- package/src/components/grid-search-styles.js +13 -14
- package/src/components/grid-search.js +8 -1
- package/src/components/grid-selection.js +118 -0
- package/src/components/grid-structure.js +36 -5
- package/src/components/grid-styles.js +37 -1
- package/src/components/grid-tools.js +229 -0
- package/src/components/grid.js +223 -15
- package/src/components/image-uploader.js +2 -2
- package/src/components/inputs.js +19 -10
- package/src/components/labelbox.js +5 -1
- package/src/components/licenses/claygl.txt +23 -0
- package/src/components/licenses/echarts-gl.txt +29 -0
- package/src/components/licenses/fflate.txt +21 -0
- package/src/components/licenses/plotly.txt +21 -0
- package/src/components/licenses/uplot.txt +21 -0
- package/src/components/licenses/vega.txt +27 -0
- package/src/components/licenses/write-excel-file.txt +21 -0
- package/src/components/menus.js +19 -11
- package/src/components/toolbar-overflow.js +12 -8
- package/src/components/tree.js +30 -8
- package/src/components/typed-editor.js +14 -3
- package/src/components/vizabi-session.js +66 -0
- package/src/components/vizabi.js +66 -0
- package/src/components/window-surface.js +20 -9
- package/src/components/windows.js +1 -1
- package/src/editing-session.d.ts +2 -0
- package/src/editing-session.js +35 -3
- package/src/gramlot.d.ts +1 -0
- package/src/gramlot.js +2 -0
- package/src/handlers/device-handler.js +32 -32
- package/src/handlers/source-handler.d.ts +2 -2
- package/src/ide-documents.js +19 -3
- package/src/ide-runtime.d.ts +1 -0
- package/src/ide-runtime.js +45 -31
- package/src/index.d.ts +1 -0
- package/src/renderer/drag-drop.js +1 -0
- package/src/renderer/gramlot-renderer.d.ts +2 -0
- package/src/renderer/gramlot-renderer.js +5 -4
- package/src/server/assets.d.ts +3 -0
- package/src/server/assets.js +9 -0
- package/src/server/gramlot-server.d.ts +1 -1
- package/src/server/gramlot-server.js +2 -1
- package/src/server/index.d.ts +1 -1
- package/src/server/index.js +1 -1
- package/src/server/visual-editor.js +17 -17
- package/src/stores/bag-collection-store.js +14 -5
- package/src/stores/bag-collection-view.js +80 -18
- package/src/stores/collection-filter.js +2 -1
- package/src/stores/column-filter.js +49 -0
- package/src/stores/id-set.js +10 -0
- package/src/view/controls.js +8 -0
- package/src/view/html.js +10 -1
- package/src/view/label-menu.js +61 -0
- package/src/view/labelbox.js +15 -2
- package/themes/gramlot-base/theme.css +6 -0
- package/tools/gramlot-tools-inspector.js +169 -505
|
@@ -6,7 +6,7 @@ export class WindowSurface {
|
|
|
6
6
|
#context; #observer; #scheduled = false; #live = false;
|
|
7
7
|
#open = false; #collapsed = false; #maximized = false; #pending = null; #generation = 0;
|
|
8
8
|
#geometry = null; #gesture = null; #previousFocus = null;
|
|
9
|
-
#resize = () => { if (this.#open) this.#fit(); };
|
|
9
|
+
#resize = () => { if (this.#open && !this.parameters.docked) this.#fit(); };
|
|
10
10
|
constructor(host, root, {modal, validateContent}) {
|
|
11
11
|
this.host = host; this.root = root; this.modal = modal;
|
|
12
12
|
this.validateContent = validateContent;
|
|
@@ -20,6 +20,10 @@ export class WindowSurface {
|
|
|
20
20
|
background:var(--gramlot-surface,Canvas);box-shadow:0 2px 6px #00000014,0 16px 36px #00000029;overflow:hidden;
|
|
21
21
|
max-width:calc(100vw - 16px);max-height:calc(100dvh - 16px)}
|
|
22
22
|
.window-surface dialog[open]{display:flex;flex-direction:column}
|
|
23
|
+
.window-surface dialog[data-docked]{position:relative!important;inset:0!important;width:100%!important;height:100%!important;
|
|
24
|
+
min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;
|
|
25
|
+
border:0;border-radius:0;box-shadow:none;z-index:auto!important}
|
|
26
|
+
.window-surface dialog[data-docked] .titlebar,.window-surface dialog[data-docked] .resize{display:none!important}
|
|
23
27
|
.window-surface dialog[data-maximized]{max-width:100vw;max-height:100dvh;border-radius:0}
|
|
24
28
|
.window-surface dialog::backdrop{background:var(--gramlot-window-backdrop,#0006)}
|
|
25
29
|
.window-surface .titlebar{display:flex;align-items:center;gap:4px;flex:none;min-height:max(32px,var(--gramlot-tab-height,32px));padding:3px 5px 3px 12px;
|
|
@@ -104,7 +108,7 @@ export class WindowSurface {
|
|
|
104
108
|
this.#cancelGesture();this.#geometry=null;this.#collapsed=false;this.#maximized=false;
|
|
105
109
|
}
|
|
106
110
|
if(previous.open!==this.parameters.open) { this.#generation++;this.#pending=null; }
|
|
107
|
-
if(previous.movable!==this.parameters.movable || previous.resizable!==this.parameters.resizable)this.#cancelGesture();
|
|
111
|
+
if(previous.movable!==this.parameters.movable || previous.resizable!==this.parameters.resizable || previous.docked!==this.parameters.docked)this.#cancelGesture();
|
|
108
112
|
}
|
|
109
113
|
this.#schedule();
|
|
110
114
|
}
|
|
@@ -118,14 +122,16 @@ export class WindowSurface {
|
|
|
118
122
|
this.heading.textContent=p.title;this.shell.setAttribute('aria-label',p.title);
|
|
119
123
|
this.closeButton.hidden=!p.closable;this.closeButton.disabled=Boolean(this.#pending);
|
|
120
124
|
this.collapseButton.hidden=!p.collapsible;this.maximizeButton.hidden=!p.maximizable;
|
|
125
|
+
this.shell.toggleAttribute('data-docked', p.docked === true);
|
|
121
126
|
if(!p.open) { this.#close(false);return; }
|
|
122
127
|
if(!this.#open) {
|
|
123
128
|
this.#previousFocus=this.#activeElement();
|
|
124
129
|
this.#collapsed=false;this.#maximized=false;this.body.hidden=false;this.shell.removeAttribute('data-collapsed');
|
|
125
130
|
if(this.modal)this.shell.showModal();else this.shell.show();
|
|
126
|
-
this.#open=true;this.#applySize();this.#fit();this.#raise();
|
|
131
|
+
this.#open=true;if(!p.docked){this.#applySize();this.#fit();this.#raise();}
|
|
127
132
|
this.#context.publish('opened',{});
|
|
128
|
-
} else if(!this.#geometry) { this.#applySize();this.#fit(); }
|
|
133
|
+
} else if(!p.docked && !this.#geometry) { this.#applySize();this.#fit(); }
|
|
134
|
+
if(p.docked) { this.body.hidden=false;this.resizeButton.hidden=true;return; }
|
|
129
135
|
this.#setMaximized(p.maximizable&&p.maximized,false);
|
|
130
136
|
this.#setCollapsed(p.collapsible&&p.collapsed,false);
|
|
131
137
|
if(!p.maximizable && p.maximized)this.#context.writeParameter('maximized',false);
|
|
@@ -156,7 +162,7 @@ export class WindowSurface {
|
|
|
156
162
|
}
|
|
157
163
|
#paint(rect) { for(const key of ['left','top','width','height'])this.shell.style[key]=`${rect[key]}px`; }
|
|
158
164
|
#raise() {
|
|
159
|
-
if(this.modal||!this.#open)return;
|
|
165
|
+
if(this.modal||!this.#open||this.parameters.docked)return;
|
|
160
166
|
// Reserve the page's low stacking levels for layout chrome (splitters/drawers).
|
|
161
167
|
// Modal dialogs and menu popovers remain above these nonmodal windows in the top layer.
|
|
162
168
|
const base=100;
|
|
@@ -175,7 +181,7 @@ export class WindowSurface {
|
|
|
175
181
|
this.#paint(rect);
|
|
176
182
|
const movable=this.parameters.movable&&!this.#maximized;
|
|
177
183
|
this.titlebar.toggleAttribute('data-movable',movable);this.titlebar.tabIndex=movable?0:-1;
|
|
178
|
-
this.titlebar.setAttribute('aria-label',movable?'Move window: use arrow keys':this.parameters.title);
|
|
184
|
+
this.titlebar.setAttribute('aria-label',movable?'Move window: use arrow keys, Home to reset':this.parameters.title);
|
|
179
185
|
this.resizeButton.hidden=this.#collapsed||this.#maximized||!this.parameters.resizable;
|
|
180
186
|
}
|
|
181
187
|
#setMaximized(value,write) {
|
|
@@ -233,7 +239,7 @@ export class WindowSurface {
|
|
|
233
239
|
this.#context.publish('closed',{});
|
|
234
240
|
}
|
|
235
241
|
#startGesture(event,kind) {
|
|
236
|
-
if(event.button!==0||!this.#open||this.#maximized||kind==='move'&&!this.parameters.movable||kind==='resize'&&(!this.parameters.resizable||this.#collapsed))return;
|
|
242
|
+
if(event.button!==0||!this.#open||this.parameters.docked||this.#maximized||kind==='move'&&!this.parameters.movable||kind==='resize'&&(!this.parameters.resizable||this.#collapsed))return;
|
|
237
243
|
if(kind==='move'&&event.target.closest('button'))return;
|
|
238
244
|
event.preventDefault();this.#cancelGesture();
|
|
239
245
|
const r=this.shell.getBoundingClientRect();
|
|
@@ -271,10 +277,15 @@ export class WindowSurface {
|
|
|
271
277
|
}
|
|
272
278
|
}
|
|
273
279
|
#keyGeometry(event,kind) {
|
|
274
|
-
if(event.target!==event.currentTarget||!['ArrowLeft','ArrowRight','ArrowUp','ArrowDown'].includes(event.key))return;
|
|
275
|
-
if(this.#maximized||kind==='move'&&!this.parameters.movable||kind==='resize'&&(!this.parameters.resizable||this.#collapsed))return;
|
|
280
|
+
if(event.target!==event.currentTarget||!['ArrowLeft','ArrowRight','ArrowUp','ArrowDown','Home'].includes(event.key))return;
|
|
281
|
+
if(this.parameters.docked||this.#maximized||kind==='move'&&!this.parameters.movable||kind==='resize'&&(!this.parameters.resizable||this.#collapsed)||event.key==='Home'&&kind!=='move')return;
|
|
276
282
|
event.preventDefault();event.stopPropagation();
|
|
277
283
|
const r=this.shell.getBoundingClientRect(),step=event.shiftKey?1:10;
|
|
284
|
+
if(event.key==='Home') {
|
|
285
|
+
const x=parseFloat(this.parameters.left),y=parseFloat(this.parameters.top);
|
|
286
|
+
this.#adjust({left:r.left,top:r.top,width:r.width,height:r.height},(Number.isFinite(x)?x:8)-r.left,(Number.isFinite(y)?y:8)-r.top,kind);
|
|
287
|
+
this.#commitGeometry(kind);return;
|
|
288
|
+
}
|
|
278
289
|
this.#adjust({left:r.left,top:r.top,width:r.width,height:r.height},event.key==='ArrowLeft'?-step:event.key==='ArrowRight'?step:0,event.key==='ArrowUp'?-step:event.key==='ArrowDown'?step:0,kind);
|
|
279
290
|
this.#commitGeometry(kind);
|
|
280
291
|
}
|
|
@@ -52,4 +52,4 @@ WindowShell.parameters={
|
|
|
52
52
|
};
|
|
53
53
|
export const Dialog=defineComponent({name:'dialog',tag:'gramlot-dialog',base:WindowShell,sourceContext:true,subTags:'framePane',implementation:Base=>class extends Base{}});
|
|
54
54
|
export const FloatingPane=defineComponent({name:'floatingPane',tag:'gramlot-floating-pane',base:WindowShell,sourceContext:true,subTags:'framePane',
|
|
55
|
-
parameters:{movable:bool(true),resizable:bool(true),collapsible:bool(true)},implementation:Base=>class extends Base{}});
|
|
55
|
+
parameters:{movable:bool(true),resizable:bool(true),collapsible:bool(true),docked:bool(false)},implementation:Base=>class extends Base{}});
|
package/src/editing-session.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export class EditingSession {
|
|
|
19
19
|
readonly changeEntries: ReadonlyArray<{path: string; previous: unknown; current: unknown; existed: boolean; exists: boolean}>;
|
|
20
20
|
focusField(path: string): boolean;
|
|
21
21
|
registerNavigator(navigate: (path: string) => boolean): () => void;
|
|
22
|
+
/** Declare derived values (grid formula results, totals) that are never changes; returns the release. */
|
|
23
|
+
registerDerived(match: (path: string) => boolean): () => void;
|
|
22
24
|
load(data: Bag): void;
|
|
23
25
|
validate(): Promise<boolean>;
|
|
24
26
|
accept(): boolean;
|
package/src/editing-session.js
CHANGED
|
@@ -33,6 +33,8 @@ export class EditingSession {
|
|
|
33
33
|
this.validationRevision = 0;
|
|
34
34
|
this.validatedRevision = -1;
|
|
35
35
|
this.fullValidation = null;
|
|
36
|
+
this.derived = new Set(); // predicates of derived paths, never changes
|
|
37
|
+
|
|
36
38
|
if (!(this.data instanceof Bag)) throw new TypeError('A form requires a Bag at its datapath.');
|
|
37
39
|
this.registers.setItem('baseline', copy(this.data));
|
|
38
40
|
for (const name of ['changes', 'errors', 'pending', 'drafts']) this.registers.setItem(name, new Bag());
|
|
@@ -55,6 +57,32 @@ export class EditingSession {
|
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
get data() { return this.runtime.gramlot.data.getItem(this.path); }
|
|
60
|
+
/**
|
|
61
|
+
* Declare derived values (grid formula results, published totals): `match(path)` receives a path
|
|
62
|
+
* relative to the session, `<path>?<attribute>` for an attribute. Derived values are never changes.
|
|
63
|
+
* Returns the release.
|
|
64
|
+
*/
|
|
65
|
+
registerDerived(match) {
|
|
66
|
+
this.derived.add(match);
|
|
67
|
+
this.updateChanges();
|
|
68
|
+
// Releasing recomputes nothing: later Data events reconcile only their own subtree.
|
|
69
|
+
return () => { this.derived.delete(match); };
|
|
70
|
+
}
|
|
71
|
+
isDerived(path) {
|
|
72
|
+
for (const match of this.derived) if (match(path)) return true;
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
/** The attributes of the node at `path` that are not derived. */
|
|
76
|
+
ownAttributes(node, path) {
|
|
77
|
+
return Object.fromEntries(Object.entries(node.attr).filter(([name]) => !this.isDerived(`${path}?${name}`)));
|
|
78
|
+
}
|
|
79
|
+
/** A node, possibly absent, that holds only derived values. */
|
|
80
|
+
onlyDerived(node, path) {
|
|
81
|
+
if (!node) return true;
|
|
82
|
+
if (Object.keys(this.ownAttributes(node, path)).length) return false;
|
|
83
|
+
if (node.value instanceof Bag) return node.value.getNodes().every(child => this.onlyDerived(child, path ? `${path}.${child.label}` : child.label));
|
|
84
|
+
return this.isDerived(path);
|
|
85
|
+
}
|
|
58
86
|
subscribe(listener) { this.listeners.add(listener); return () => this.listeners.delete(listener); }
|
|
59
87
|
/** Read-only reports derived from the canonical registers, never a second journal. */
|
|
60
88
|
get errorEntries() {
|
|
@@ -398,13 +426,17 @@ export class EditingSession {
|
|
|
398
426
|
const relative = changedPath === this.path ? '' : changedPath?.startsWith(this.path + '.')
|
|
399
427
|
? changedPath.slice(this.path.length + 1).split('?')[0] : '';
|
|
400
428
|
const visit = (a, b, path) => {
|
|
401
|
-
if (
|
|
429
|
+
if (path && this.isDerived(path)) return;
|
|
430
|
+
const attrsA = a && this.ownAttributes(a, path), attrsB = b && this.ownAttributes(b, path);
|
|
431
|
+
if (a && b && a.value instanceof Bag && b.value instanceof Bag && same(attrsA,attrsB)) {
|
|
402
432
|
const labels = new Set([...a.value.getNodes(), ...b.value.getNodes()].map(n => n.label));
|
|
403
433
|
for (const label of labels) visit(a.value.getNode(label), b.value.getNode(label), path ? path + '.' + label : label);
|
|
404
|
-
} else if (
|
|
434
|
+
} else if (a && b ? !same([a.value,attrsA],[b.value,attrsB])
|
|
435
|
+
// A node appearing or disappearing with derived values only is not an edit.
|
|
436
|
+
: !(this.onlyDerived(a, path) && this.onlyDerived(b, path))) {
|
|
405
437
|
changes.setItem(encoded(path), new Bag({path, existed:Boolean(a), exists:Boolean(b),
|
|
406
438
|
previous:a ? copy(a.value) : null, current:b ? copy(b.value) : null,
|
|
407
|
-
previousAttributes:a ? copy(
|
|
439
|
+
previousAttributes:a ? copy(attrsA) : null, currentAttributes:b ? copy(attrsB) : null}));
|
|
408
440
|
}
|
|
409
441
|
};
|
|
410
442
|
const baseline = this.registers.getItem('baseline');
|
package/src/gramlot.d.ts
CHANGED
|
@@ -118,6 +118,7 @@ export class Gramlot {
|
|
|
118
118
|
publish(topic: Publication, payload?: Record<string, unknown>): void | Promise<'ok'>;
|
|
119
119
|
/** Subscribe to a local page topic, synchronously in registration order. */
|
|
120
120
|
registerDocument(document:Document):void;
|
|
121
|
+
getCollection(name:string): {readonly name:string; toDocument():unknown; register(window:Window):void} | undefined;
|
|
121
122
|
subscribe(topic: string, callback: (payload: Record<string, unknown>, metadata: {pageId?: string}) => unknown): SubscriptionHandle;
|
|
122
123
|
/** Remove a registration; repeating removal of an owned handle is harmless. */
|
|
123
124
|
unsubscribe(registration: SubscriptionHandle): void;
|
package/src/gramlot.js
CHANGED
|
@@ -71,6 +71,8 @@ export class Gramlot {
|
|
|
71
71
|
registerDocument(document) {
|
|
72
72
|
for (const collection of this.#collections) collection.register(document.defaultView);
|
|
73
73
|
}
|
|
74
|
+
/** The prepared collection already activated by this page. */
|
|
75
|
+
getCollection(name) { return this.#collections.find(collection => collection.name === name); }
|
|
74
76
|
subscribe(topic, callback) { return this._subscriptions.subscribe(topic, callback); }
|
|
75
77
|
unsubscribe(registration) { this._subscriptions.unsubscribe(registration); }
|
|
76
78
|
format(value, options) { return formatValue(value, options, {locale: this.locale, timeZone: this.timeZone}); }
|
|
@@ -43,17 +43,17 @@ export class DeviceHandler extends Handler {
|
|
|
43
43
|
|
|
44
44
|
installData() {
|
|
45
45
|
const {gramlot} = this;
|
|
46
|
-
gramlot.data.setItem('
|
|
47
|
-
gramlot.data.setItem('
|
|
46
|
+
gramlot.data.setItem('_gramlot.device.database', null, {status: 'idle', error: null});
|
|
47
|
+
gramlot.data.setItem('_gramlot.device.orientation', null, {status: 'idle', error: null, listening: false});
|
|
48
48
|
for (const name of ['gyroscope', 'accelerometer']) {
|
|
49
|
-
gramlot.data.setItem(`
|
|
49
|
+
gramlot.data.setItem(`_gramlot.device.${name}`, null,
|
|
50
50
|
{enabled: false, watching: false, status: 'idle', error: null});
|
|
51
|
-
gramlot.data.getNode(`
|
|
52
|
-
this.#sensors.set(name, {node: gramlot.data.getNode(`
|
|
51
|
+
gramlot.data.getNode(`_gramlot.device.${name}`).setAttr({error: null}, false, true, false);
|
|
52
|
+
this.#sensors.set(name, {node: gramlot.data.getNode(`_gramlot.device.${name}`),
|
|
53
53
|
stream: null, cleanup: Promise.resolve()});
|
|
54
54
|
}
|
|
55
55
|
for (const name of NAMES) {
|
|
56
|
-
const path = `
|
|
56
|
+
const path = `_gramlot.device.${name}`;
|
|
57
57
|
const attrs = {status: 'idle', error: null, cacheTime: name === 'appinfo' ? -1 : 5};
|
|
58
58
|
if (name === 'location') Object.assign(attrs, {enabled: false, watching: false});
|
|
59
59
|
gramlot.data.setItem(path, null);
|
|
@@ -63,45 +63,45 @@ export class DeviceHandler extends Handler {
|
|
|
63
63
|
node.resolver = resolver;
|
|
64
64
|
this.resolvers.set(name, resolver);
|
|
65
65
|
}
|
|
66
|
-
gramlot.data.setItem('
|
|
66
|
+
gramlot.data.setItem('_gramlot.device.clipboard', null,
|
|
67
67
|
{status: 'idle', error: null, text: '', copy: null, paste: null, operation: null});
|
|
68
|
-
const clipboard = gramlot.data.getNode('
|
|
69
|
-
gramlot.data.setItem('
|
|
70
|
-
const camera = gramlot.data.getNode('
|
|
71
|
-
gramlot.data.setItem('
|
|
72
|
-
const barcode = gramlot.data.getNode('
|
|
73
|
-
gramlot.data.setItem('
|
|
74
|
-
const biometrics = gramlot.data.getNode('
|
|
68
|
+
const clipboard = gramlot.data.getNode('_gramlot.device.clipboard');
|
|
69
|
+
gramlot.data.setItem('_gramlot.device.camera', null, {status: 'idle', error: null, capture: null, choose: null});
|
|
70
|
+
const camera = gramlot.data.getNode('_gramlot.device.camera');
|
|
71
|
+
gramlot.data.setItem('_gramlot.device.barcode', null, {status: 'idle', error: null, scan: null});
|
|
72
|
+
const barcode = gramlot.data.getNode('_gramlot.device.barcode');
|
|
73
|
+
gramlot.data.setItem('_gramlot.device.biometrics', null, {status: 'idle', error: null, verify: null});
|
|
74
|
+
const biometrics = gramlot.data.getNode('_gramlot.device.biometrics');
|
|
75
75
|
const notifications = new Bag();
|
|
76
76
|
notifications.setItem('request', new Bag());
|
|
77
77
|
for (const name of ['scheduled', 'received', 'action']) notifications.setItem(name, null);
|
|
78
|
-
gramlot.data.setItem('
|
|
78
|
+
gramlot.data.setItem('_gramlot.device.notifications', notifications,
|
|
79
79
|
{status: 'idle', error: null, schedule: null, listening: false, listenerError: null});
|
|
80
|
-
const notificationNode = gramlot.data.getNode('
|
|
80
|
+
const notificationNode = gramlot.data.getNode('_gramlot.device.notifications');
|
|
81
81
|
const push = new Bag();
|
|
82
82
|
for (const name of ['registration', 'received', 'action']) push.setItem(name, null);
|
|
83
|
-
gramlot.data.setItem('
|
|
83
|
+
gramlot.data.setItem('_gramlot.device.push', push,
|
|
84
84
|
{status: 'idle', error: null, register: null, listening: false, listenerError: null});
|
|
85
|
-
const pushNode = gramlot.data.getNode('
|
|
85
|
+
const pushNode = gramlot.data.getNode('_gramlot.device.push');
|
|
86
86
|
const links = new Bag();
|
|
87
87
|
links.setItem('request', null);
|
|
88
|
-
gramlot.data.setItem('
|
|
88
|
+
gramlot.data.setItem('_gramlot.device.links', links, {listening: false, listenerError: null});
|
|
89
89
|
const shortcuts = new Bag();
|
|
90
90
|
shortcuts.setItem('request', null);
|
|
91
|
-
gramlot.data.setItem('
|
|
92
|
-
gramlot.data.setItem('
|
|
91
|
+
gramlot.data.setItem('_gramlot.device.shortcuts', shortcuts, {listening: false, listenerError: null});
|
|
92
|
+
gramlot.data.setItem('_gramlot.device.network', null, {status: 'idle', error: null, listening: false});
|
|
93
93
|
const lifecycle = new Bag();
|
|
94
94
|
lifecycle.setItem('active', null);
|
|
95
95
|
lifecycle.setItem('event', null);
|
|
96
96
|
lifecycle.setItem('sequence', 0);
|
|
97
|
-
gramlot.data.setItem('
|
|
98
|
-
gramlot.data.setItem('
|
|
97
|
+
gramlot.data.setItem('_gramlot.device.lifecycle', lifecycle, {status: 'idle', error: null, listening: false});
|
|
98
|
+
gramlot.data.setItem('_gramlot.device.haptics', null,
|
|
99
99
|
{status: 'idle', error: null, impact: null, style: 'medium', vibrate: null, duration: 600});
|
|
100
|
-
const haptics = gramlot.data.getNode('
|
|
101
|
-
gramlot.data.setItem('
|
|
100
|
+
const haptics = gramlot.data.getNode('_gramlot.device.haptics');
|
|
101
|
+
gramlot.data.setItem('_gramlot.device.audio', null,
|
|
102
102
|
{status: 'idle', error: null, recording: false, start: null, stop: null, cancel: null,
|
|
103
103
|
share: null, shareStatus: 'idle', shareError: null, shareActivity: null});
|
|
104
|
-
const audio = gramlot.data.getNode('
|
|
104
|
+
const audio = gramlot.data.getNode('_gramlot.device.audio');
|
|
105
105
|
gramlot.data.subscribe('gramlot.device', {update: event => {
|
|
106
106
|
if (this.disposed) return;
|
|
107
107
|
for (const [name, sensor] of this.#sensors) {
|
|
@@ -199,16 +199,16 @@ export class DeviceHandler extends Handler {
|
|
|
199
199
|
node.setAttr({status: 'success', error: null}, true, true, false);
|
|
200
200
|
});
|
|
201
201
|
if (provider.capabilities.includes('links')) {
|
|
202
|
-
this.#startLinkEvents(this.gramlot.data.getNode('
|
|
202
|
+
this.#startLinkEvents(this.gramlot.data.getNode('_gramlot.device.links'));
|
|
203
203
|
}
|
|
204
204
|
if (provider.capabilities.includes('shortcuts')) {
|
|
205
|
-
this.#startShortcutEvents(this.gramlot.data.getNode('
|
|
205
|
+
this.#startShortcutEvents(this.gramlot.data.getNode('_gramlot.device.shortcuts'));
|
|
206
206
|
}
|
|
207
207
|
if (provider.capabilities.includes('push')) {
|
|
208
|
-
this.#startPushEvents(this.gramlot.data.getNode('
|
|
208
|
+
this.#startPushEvents(this.gramlot.data.getNode('_gramlot.device.push'));
|
|
209
209
|
}
|
|
210
210
|
if (provider.capabilities.includes('notifications')) {
|
|
211
|
-
this.#startNotificationEvents(this.gramlot.data.getNode('
|
|
211
|
+
this.#startNotificationEvents(this.gramlot.data.getNode('_gramlot.device.notifications'));
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
|
|
@@ -251,7 +251,7 @@ export class DeviceHandler extends Handler {
|
|
|
251
251
|
|
|
252
252
|
// Page-owned state streams share lifetime/error handling, never public dispatch.
|
|
253
253
|
#startStateEvents(name, start, accept) {
|
|
254
|
-
const node = this.gramlot.data.getNode(`
|
|
254
|
+
const node = this.gramlot.data.getNode(`_gramlot.device.${name}`);
|
|
255
255
|
if (!this.provider.capabilities.includes(name)) {
|
|
256
256
|
node.setAttr(failureAttributes({code: 'UNAVAILABLE', message: `${name} is unavailable`}), true, true, false);
|
|
257
257
|
return;
|
|
@@ -913,7 +913,7 @@ export class DeviceHandler extends Handler {
|
|
|
913
913
|
this.assertLive();
|
|
914
914
|
if (!/^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(name) || typeof name !== 'string') throw new TypeError('Invalid database name');
|
|
915
915
|
if (this.#database) throw new Error('This page already owns a database connection');
|
|
916
|
-
const node = this.gramlot.data.getNode('
|
|
916
|
+
const node = this.gramlot.data.getNode('_gramlot.device.database');
|
|
917
917
|
const state = (status, error = null) => {
|
|
918
918
|
if (!this.disposed) node.setAttr({status, error}, true, true, false);
|
|
919
919
|
};
|
|
@@ -7,7 +7,7 @@ import type {Bag} from '@genrojs/bag';
|
|
|
7
7
|
import type {SourceBag, SourceBagNode} from '@genrojs/builders';
|
|
8
8
|
import type {DomElement} from '../dom.d.ts';
|
|
9
9
|
import type {Gramlot} from '../gramlot.js';
|
|
10
|
-
import type {GramlotBuilder} from '../builder/gramlot-builder.js';
|
|
10
|
+
import type {GramlotBuilder, GramlotSourceBag} from '../builder/gramlot-builder.js';
|
|
11
11
|
import type {NameSyntax} from '../builder/name-syntax.js';
|
|
12
12
|
import type {GramlotRenderer} from '../renderer/gramlot-renderer.js';
|
|
13
13
|
import {Handler} from './handler.js';
|
|
@@ -24,7 +24,7 @@ export class SourceHandler extends Handler {
|
|
|
24
24
|
/** The binding runtime of the page. */
|
|
25
25
|
binding: unknown;
|
|
26
26
|
/** The Source Bag observed by the renderer. */
|
|
27
|
-
source:
|
|
27
|
+
source: GramlotSourceBag;
|
|
28
28
|
/** The live renderer of the page. */
|
|
29
29
|
renderer: GramlotRenderer;
|
|
30
30
|
/**
|
package/src/ide-documents.js
CHANGED
|
@@ -14,6 +14,8 @@ export class IdeDocuments {
|
|
|
14
14
|
get state() { return this.source.getRelativeData('.'); }
|
|
15
15
|
get documents() { return this.state.getItem('documents'); }
|
|
16
16
|
async open(root, path) {
|
|
17
|
+
// Only registered IDE document types may create an editor tab.
|
|
18
|
+
if (!/\.(?:py|js|mjs|ts|json|html|css|xml|md|markdown|sql|typ|txt|png|jpg|jpeg|webp)$/i.test(path)) return null;
|
|
17
19
|
const key = documentKey(root, path);
|
|
18
20
|
const existing = this.documents.getNodes().find(node => !node.value.getItem('isNew') && node.value.getItem('root') === root && node.value.getItem('path') === path);
|
|
19
21
|
if (existing) return existing.label;
|
|
@@ -22,7 +24,13 @@ export class IdeDocuments {
|
|
|
22
24
|
const promise = this.gramlot.rpc.call('data', 'document_read', {root,path}, {signal:request.signal}).then(result => {
|
|
23
25
|
if (this.disposed || request.signal.aborted) return null;
|
|
24
26
|
const document = new Bag();
|
|
25
|
-
|
|
27
|
+
const content = result.language === 'image' ? result.content.toTytx() : result.content;
|
|
28
|
+
for (const [name,value] of Object.entries({...result, content, root, saved:content, busy:false})) document.setItem(name,value);
|
|
29
|
+
if (result.language === 'image') {
|
|
30
|
+
const annotations = result.content;
|
|
31
|
+
document.setItem('annotations',annotations);
|
|
32
|
+
annotations.subscribe('ide-annotations',{any:()=>document.setItem('content',annotations.toTytx())});
|
|
33
|
+
}
|
|
26
34
|
this.documents.setItem(key, document);
|
|
27
35
|
return key;
|
|
28
36
|
}).finally(() => this.pending.delete(key));
|
|
@@ -104,8 +112,12 @@ export class IdeDocuments {
|
|
|
104
112
|
if (!doc || doc.getItem('isNew') || !this.dirty(key) || !doc.getItem('writable') || this.pending.has(key)) return false;
|
|
105
113
|
const content = doc.getItem('content'), request = new AbortController();
|
|
106
114
|
doc.setItem('busy',true);
|
|
107
|
-
const
|
|
108
|
-
|
|
115
|
+
const image = doc.getItem('language') === 'image';
|
|
116
|
+
const path = image ? doc.getItem('annotationPath') : doc.getItem('path');
|
|
117
|
+
const creating = image && doc.getItem('revision') === null;
|
|
118
|
+
const promise = this.gramlot.rpc.call('data',creating ? 'document_create' : 'document_save', {
|
|
119
|
+
root:doc.getItem('root'), path, content:image ? Bag.fromTytx(content) : content,
|
|
120
|
+
...(creating ? {} : {revision:doc.getItem('revision')})
|
|
109
121
|
}, {signal:request.signal}).then(result => {
|
|
110
122
|
if (this.disposed || request.signal.aborted) return false;
|
|
111
123
|
doc.setItem('revision',result.revision);
|
|
@@ -119,6 +131,10 @@ export class IdeDocuments {
|
|
|
119
131
|
const doc = this.documents.getItem(key);
|
|
120
132
|
if (!doc || !this.dirty(key) || this.pending.has(key)) return false;
|
|
121
133
|
doc.setItem('content',doc.getItem('saved'));
|
|
134
|
+
if (doc.getItem('language') === 'image') {
|
|
135
|
+
doc.getItem('annotations').replace(Bag.fromTytx(doc.getItem('saved')));
|
|
136
|
+
doc.setItem('content',doc.getItem('saved'));
|
|
137
|
+
}
|
|
122
138
|
return true;
|
|
123
139
|
}
|
|
124
140
|
canClose(key, discard = false) {
|
package/src/ide-runtime.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export class IdeLogic {
|
|
|
9
9
|
fileSystemOpen(node:SourceBagNode,args:{root:string|null}):Promise<string|null>|undefined;
|
|
10
10
|
ideMount(node:SourceBagNode):void;
|
|
11
11
|
ideOpenWorkspace(node:SourceBagNode):void;
|
|
12
|
+
ideUploadCompleted(node:SourceBagNode,args:{result:{root:string,path:string}}):Promise<void>;
|
|
12
13
|
ideDocumentState(node:SourceBagNode,key:string):void;
|
|
13
14
|
ideOpenDocument(node:SourceBagNode,root:string,path:string):Promise<void>;
|
|
14
15
|
ideNew(node:SourceBagNode):void;
|
package/src/ide-runtime.js
CHANGED
|
@@ -65,6 +65,16 @@ export class IdeLogic {
|
|
|
65
65
|
const root = state.getItem('workspace');
|
|
66
66
|
if (root && root !== state.getItem('browser.root')) state.setItem('browser.requestedRoot',root);
|
|
67
67
|
}
|
|
68
|
+
async ideUploadCompleted(node, {result}) {
|
|
69
|
+
const context=ideContext(node), state=context.scope.getRelativeData('.');
|
|
70
|
+
if (state.getItem('browser.root') !== result.root) return;
|
|
71
|
+
state.setItem('upload.open',false);
|
|
72
|
+
const controller=context.scope.value.getNode('frame.left.browser').fileSystemController;
|
|
73
|
+
if (controller.request) return;
|
|
74
|
+
const opened=await controller.open(result.root);
|
|
75
|
+
if (opened === result.root && !context.documents.disposed && state.getItem('browser.root') === result.root)
|
|
76
|
+
await this.ideOpenDocument(context.scope,result.root,result.path);
|
|
77
|
+
}
|
|
68
78
|
ideDocumentState(node, key) {
|
|
69
79
|
const context = ideContext(node), {documents} = context;
|
|
70
80
|
const doc = documents.documents.getItem(key);
|
|
@@ -147,38 +157,42 @@ export class IdeLogic {
|
|
|
147
157
|
form.button('Create file',{disabled:'^.busy'}).dataController({func:'ideCreate',documentKey:key});
|
|
148
158
|
form.button('Cancel',{disabled:'^.busy',class:'button--quiet'}).dataController({func:'ideCancelCreate',documentKey:key});
|
|
149
159
|
const editorArea = target.div({flex:'1',min_height:0});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
height:'100%',
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
previewPane.
|
|
160
|
+
if (doc.getItem('language') === 'image') {
|
|
161
|
+
editorArea.drawingPane({image:`^.documents.${key}.image`,annotations:`^.documents.${key}.annotations`,height:'100%'});
|
|
162
|
+
} else {
|
|
163
|
+
const html = doc.getItem('language') === 'html';
|
|
164
|
+
const markdown = doc.getItem('language') === 'markdown';
|
|
165
|
+
const rich = html || markdown;
|
|
166
|
+
const typst = doc.getItem('language') === 'typst';
|
|
167
|
+
const preview = rich || typst || recipe;
|
|
168
|
+
const views = preview ? editorArea.tabContainer({height:'100%',selectedPage:`^.documents.${key}.view`}) : null;
|
|
169
|
+
const code = preview ? views.contentPane({title:'Code',pageName:'code',height:'100%'}) : editorArea;
|
|
170
|
+
codeMirrorWithOptions(code,{datapath:`.documents.${key}`,value:'^.content',language:doc.getItem('language'),
|
|
171
|
+
height:'100%', readonly:'^.readonly',nodeId:`${context.editorPrefix}_editor_${key}`,
|
|
172
|
+
editorView:'code',selfsubscribe_historyChanged:'ideHistoryChanged'});
|
|
173
|
+
target.dataController({func:'ideSave',documentKey:key,[`subscribe_${context.editorPrefix}_editor_${key}_save`]:true});
|
|
174
|
+
if (typst) views.contentPane({title:'Preview',pageName:'preview',height:'100%'}).typstPreview({value:`^.documents.${key}.content`,filename:`^.documents.${key}.pdfFilename`,height:'100%'});
|
|
175
|
+
if (recipe) {
|
|
176
|
+
const output = views.contentPane({title:'Preview',pageName:'preview',height:'100%',display:'flex',flex_direction:'column'});
|
|
177
|
+
output.div(`^.documents.${key}.renderStatus`,{role:'status',padding:'8px 12px',white_space:'pre-wrap',overflow:'auto',max_height:'30%'});
|
|
178
|
+
output.typstPreview({value:`^.documents.${key}.typstSource`,filename:`^.documents.${key}.pdfFilename`,
|
|
179
|
+
hidden:`^.documents.${key}.previewHidden`,flex:'1',min_height:0});
|
|
180
|
+
views.contentPane({title:'Generated Typst',pageName:'generated',height:'100%'})
|
|
181
|
+
.codeMirror({value:`^.documents.${key}.typstSource`,language:'typst',readonly:true,height:'100%'});
|
|
182
|
+
}
|
|
183
|
+
if (rich) {
|
|
184
|
+
const previewPane = views.contentPane({title:'Preview',pageName:'preview',height:'100%',display:'flex',flex_direction:'column'});
|
|
185
|
+
if (markdown) {
|
|
186
|
+
doc.setItem('allowHtml',false);
|
|
187
|
+
previewPane.checkbox({value:`^.documents.${key}.allowHtml`,label:'Allow embedded HTML',class:'gramlot-ide-allow-html',padding:'8px 12px',flex_shrink:0});
|
|
188
|
+
}
|
|
189
|
+
previewPane[html ? 'htmlPreview' : 'markdownPreview']({value:`^.documents.${key}.content`,flex:'1',min_height:0,
|
|
190
|
+
...(markdown ? {allowHtml:`^.documents.${key}.allowHtml`} : {})});
|
|
191
|
+
views.contentPane({title:'Rich text',pageName:'rich',height:'100%'})[html ? 'htmlEditor' : 'markdownEditor']({
|
|
192
|
+
datapath:`.documents.${key}`,value:'^.content',readonly:'^.readonly',height:'100%',
|
|
193
|
+
nodeId:`${context.editorPrefix}_rich_editor_${key}`,editorView:'rich',selfsubscribe_historyChanged:'ideHistoryChanged'});
|
|
194
|
+
target.dataController({func:'ideSave',documentKey:key,[`subscribe_${context.editorPrefix}_rich_editor_${key}_save`]:true});
|
|
175
195
|
}
|
|
176
|
-
previewPane[html ? 'htmlPreview' : 'markdownPreview']({value:`^.documents.${key}.content`,flex:'1',min_height:0,
|
|
177
|
-
...(markdown ? {allowHtml:`^.documents.${key}.allowHtml`} : {})});
|
|
178
|
-
views.contentPane({title:'Rich text',pageName:'rich',height:'100%'})[html ? 'htmlEditor' : 'markdownEditor']({
|
|
179
|
-
datapath:`.documents.${key}`,value:'^.content',readonly:'^.readonly',height:'100%',
|
|
180
|
-
nodeId:`${context.editorPrefix}_rich_editor_${key}`,editorView:'rich',selfsubscribe_historyChanged:'ideHistoryChanged'});
|
|
181
|
-
target.dataController({func:'ideSave',documentKey:key,[`subscribe_${context.editorPrefix}_rich_editor_${key}_save`]:true});
|
|
182
196
|
}
|
|
183
197
|
}
|
|
184
198
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export {PageBootstrap} from './bootstrap.js';
|
|
|
16
16
|
export type {PageBootstrapOptions, PageResources} from './bootstrap.js';
|
|
17
17
|
export {Exposed, Page, codeMirrorWithOptions} from './server/page.js';
|
|
18
18
|
export {GramlotBuilder} from './builder/gramlot-builder.js';
|
|
19
|
+
export type {GramlotSourceNode, GramlotSourceBag} from './builder/gramlot-builder.js';
|
|
19
20
|
export {GramlotRenderer} from './renderer/gramlot-renderer.js';
|
|
20
21
|
export {GramlotHtmlRenderer} from './renderer/gramlot-html-renderer.js';
|
|
21
22
|
export {GramlotSvgRenderer} from './renderer/gramlot-svg-renderer.js';
|
|
@@ -107,6 +107,7 @@ export class DragDrop {
|
|
|
107
107
|
type.startsWith('text/') ? session.wires.get(type) : fromTytx(session.wires.get(type))]));
|
|
108
108
|
const context = {dropValues, item: row.item, path: row.path, source: {...session.source},
|
|
109
109
|
selfdrop: record === session.record, dropEffect: policy.dropEffect, dataAvailable: true};
|
|
110
|
+
if (row.placement !== undefined) context.placement = row.placement;
|
|
110
111
|
const accepted = policy.accepted && this.#renderer.checkDropTarget(record.node, context)
|
|
111
112
|
&& this.#renderer.records.get(record.node) === record && row.element.isConnected;
|
|
112
113
|
return {record, element: row.element, accepted, context};
|
|
@@ -41,12 +41,14 @@ export class GramlotRenderer extends GramlotHtmlRenderer {
|
|
|
41
41
|
dropValues: Record<string, unknown>; item: unknown; path: string | undefined;
|
|
42
42
|
source: Record<string, unknown>; selfdrop: boolean;
|
|
43
43
|
dropEffect: 'copy' | 'move' | 'link'; dataAvailable: boolean;
|
|
44
|
+
placement?: 'before' | 'inside' | 'after';
|
|
44
45
|
}): boolean;
|
|
45
46
|
/** Invoke the general onDrop action on already accepted data not consumed by typed actions. */
|
|
46
47
|
invokeDrop(node: SourceBagNode, context: {
|
|
47
48
|
dropValues: Record<string, unknown>; item: unknown; path: string | undefined;
|
|
48
49
|
source: Record<string, unknown>; selfdrop: boolean;
|
|
49
50
|
dropEffect: 'copy' | 'move' | 'link'; dataAvailable: boolean;
|
|
51
|
+
placement?: 'before' | 'inside' | 'after';
|
|
50
52
|
}): Promise<void>;
|
|
51
53
|
/** Origin callback, followed by local endDrag publication even if the callback fails. */
|
|
52
54
|
endDrag(node: SourceBagNode, context: {source: Record<string, unknown>; dropEffect: string}, topic: string): Promise<void>;
|
|
@@ -78,21 +78,21 @@ export class GramlotRenderer extends GramlotHtmlRenderer {
|
|
|
78
78
|
/** Prepare a local payload snapshot: no DataTransfer writes or native gesture commit. */
|
|
79
79
|
prepareDrag(node, event) { return this.dragPreparation.prepare(node, event); }
|
|
80
80
|
/** Dynamic eligibility only; cannot replace the independent type/tag/effect policy. */
|
|
81
|
-
checkDropTarget(node, {dropValues, item, path, source, selfdrop, dropEffect, dataAvailable}) {
|
|
81
|
+
checkDropTarget(node, {dropValues, item, path, source, selfdrop, dropEffect, dataAvailable, placement}) {
|
|
82
82
|
const record = this.records.get(node);
|
|
83
83
|
if (!record) return false;
|
|
84
84
|
if (!record.resolved.dropTargetCb) return true;
|
|
85
85
|
const allowed = this.html.callLogic(node, record.resolved.dropTargetCb,
|
|
86
|
-
{dropValues, item, path, source, selfdrop, dropEffect, dataAvailable});
|
|
86
|
+
{dropValues, item, path, source, selfdrop, dropEffect, dataAvailable, ...(placement === undefined ? {} : {placement})});
|
|
87
87
|
if (typeof allowed !== 'boolean') throw new TypeError('dropTargetCb must return a boolean synchronously');
|
|
88
88
|
return allowed;
|
|
89
89
|
}
|
|
90
90
|
/** Invoke only the general action, after acceptance and removal of data handled by typed actions. */
|
|
91
|
-
async invokeDrop(node, {dropValues, item, path, source, selfdrop, dropEffect, dataAvailable}) {
|
|
91
|
+
async invokeDrop(node, {dropValues, item, path, source, selfdrop, dropEffect, dataAvailable, placement}) {
|
|
92
92
|
const record = this.records.get(node);
|
|
93
93
|
if (!record || !record.resolved.onDrop || Object.keys(dropValues).length === 0) return;
|
|
94
94
|
await this.html.callLogic(node, record.resolved.onDrop,
|
|
95
|
-
{dropValues, item, path, source, selfdrop, dropEffect, dataAvailable});
|
|
95
|
+
{dropValues, item, path, source, selfdrop, dropEffect, dataAvailable, ...(placement === undefined ? {} : {placement})});
|
|
96
96
|
}
|
|
97
97
|
/** Notify origin completion independently of application-operation success. */
|
|
98
98
|
async endDrag(node, {source, dropEffect}, topic) {
|
|
@@ -206,6 +206,7 @@ export class GramlotRenderer extends GramlotHtmlRenderer {
|
|
|
206
206
|
...this.html.create(node, document, tag, attrs, resolved.visible ?? null),
|
|
207
207
|
};
|
|
208
208
|
this.html.compose(record, text, children);
|
|
209
|
+
if (record.labelbox) record.cleanup.push(() => record.labelbox.menu?.dispose());
|
|
209
210
|
record.shape = ControlAdapter.shape(record.element, resolved);
|
|
210
211
|
// Registered before any listener: a failed first projection leaves a record the failed-build
|
|
211
212
|
// cleanup removes, listeners included (ASTRA-06).
|
package/src/server/assets.d.ts
CHANGED
|
@@ -10,3 +10,6 @@ export function gramlotDev(): 'YES' | 'DEBUG' | null;
|
|
|
10
10
|
* URL from JSR (read with `fetch`). Without a name, the runtime to serve at the runtime URL: `gramlot.js`
|
|
11
11
|
* when `GRAMLOT_DEV=DEBUG`, `gramlot.min.js` otherwise. Another name throws a `TypeError`. */
|
|
12
12
|
export function runtimeAsset(name?: 'gramlot.js' | 'gramlot.min.js' | 'gramlot-markdown.js' | 'runtime-notices.json' | null): URL;
|
|
13
|
+
|
|
14
|
+
/** Packaged standard collection entry points for host artifact verification. */
|
|
15
|
+
export function standardCollectionAssets(): Array<{url: string; file: URL}>;
|
package/src/server/assets.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* @ts-self-types="./assets.d.ts" */
|
|
2
|
+
import {standardCollections} from '../../dist/standard-collections.js';
|
|
2
3
|
/**
|
|
3
4
|
* Development mode and the runtime file to serve. `gramlotDev` imports nothing from Node.js, so the
|
|
4
5
|
* neutral `GramlotServer` can read it in a serverless Worker, where it is null without `process`.
|
|
@@ -28,3 +29,11 @@ export function runtimeAsset(name = null) {
|
|
|
28
29
|
if (!RUNTIME_ASSETS.includes(name)) throw new TypeError(`Unknown Gramlot runtime asset: ${name}`);
|
|
29
30
|
return new URL(`../../dist/${name}`, import.meta.url);
|
|
30
31
|
}
|
|
32
|
+
|
|
33
|
+
/** Standard collection entry points; hosts verify their complete artifact inventories. */
|
|
34
|
+
export function standardCollectionAssets() {
|
|
35
|
+
return standardCollections.map(collection => ({
|
|
36
|
+
url: collection.module,
|
|
37
|
+
file: new URL(`../../dist/components/${collection.name}/assets/index.js`, import.meta.url),
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
@@ -72,7 +72,7 @@ export interface GramlotServerOptions {
|
|
|
72
72
|
pageTtl?: number;
|
|
73
73
|
/** Maximum number of registered pages. */
|
|
74
74
|
maxPages?: number;
|
|
75
|
-
/**
|
|
75
|
+
/** Custom collections added to the packaged standards: Builder grammar and root-relative module URL. */
|
|
76
76
|
collections?: PreparedCollection[];
|
|
77
77
|
/** Enable upload control only when the adapter provides a binary transport. */
|
|
78
78
|
uploadsEnabled?: boolean;
|