@gramlot/gramlot 0.3.41 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/icons/align-center.svg +4 -0
- package/assets/icons/align-justify.svg +4 -0
- package/assets/icons/align-left.svg +4 -0
- package/assets/icons/align-right.svg +4 -0
- package/assets/icons/applications.svg +4 -0
- package/assets/icons/archive.svg +4 -0
- package/assets/icons/attachment.svg +4 -0
- package/assets/icons/bold.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/eraser.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/horizontal-rule.svg +4 -0
- package/assets/icons/image.svg +4 -0
- package/assets/icons/import.svg +4 -0
- package/assets/icons/indent.svg +4 -0
- package/assets/icons/info.svg +4 -0
- package/assets/icons/inspector.svg +4 -0
- package/assets/icons/italic.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-bulleted.svg +4 -0
- package/assets/icons/list-numbered.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/outdent.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/paragraph.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/select-all.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/strikethrough.svg +4 -0
- package/assets/icons/table.svg +4 -0
- package/assets/icons/tree.svg +4 -0
- package/assets/icons/underline.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/charts/grammar.json +2032 -72
- package/dist/components/editors/__init__.py +1 -1
- package/dist/components/editors/assets/collection.js +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 +453 -447
- package/dist/components/editors/commands.json +113 -1
- package/dist/components/editors/grammar.json +12 -5
- 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 +112 -0
- package/dist/components/inputs/__init__.py +1 -1
- package/dist/components/inputs/assets/index.js +1 -1
- package/dist/components/inputs/grammar.json +5165 -359
- package/dist/components/layout/__init__.py +1 -1
- package/dist/components/layout/assets/collection.js +1 -0
- package/dist/components/layout/assets/index.js +1 -1
- package/dist/components/layout/grammar.json +433 -4
- package/dist/components/tree/__init__.py +1 -1
- package/dist/components/tree/assets/index.js +1 -1
- package/dist/components/tree/grammar.json +51 -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 +5486 -2029
- package/dist/gramlot.min.js +361 -138
- package/dist/libraries.json +6 -4
- package/dist/standard-collections.js +1 -1
- package/dist/standard-grammar.js +1 -1
- package/package.json +6 -2
- package/src/binding/ask-dialog.js +17 -3
- package/src/binding/providers.js +3 -2
- package/src/binding/remote.js +41 -6
- package/src/binding/runtime.js +30 -3
- package/src/builder/gramlot-builder.d.ts +3 -1
- package/src/builder/gramlot-builder.js +77 -26
- package/src/builder/source.js +78 -15
- package/src/builder/xml-recipe.js +144 -0
- package/src/chat-file-types.js +13 -0
- package/src/chat.d.ts +1 -0
- package/src/chat.js +35 -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-bar3d-options.js +0 -1
- package/src/components/chart-boxplot-options.js +1 -1
- package/src/components/chart-candlestick-options.js +1 -1
- package/src/components/chart-engines/echarts-options.js +6 -5
- package/src/components/chart-engines/echarts.js +27 -10
- package/src/components/chart-engines/plotly-map.js +1 -1
- package/src/components/chart-engines/plotly.js +21 -14
- package/src/components/chart-engines/uplot.js +17 -11
- package/src/components/chart-engines/vega.js +17 -11
- package/src/components/chart-funnel-options.js +1 -1
- package/src/components/chart-geographic-options.js +2 -2
- package/src/components/chart-heatmap-options.js +1 -1
- package/src/components/chart-map-bar3d-options.js +2 -2
- package/src/components/chart-map-options.js +2 -2
- package/src/components/chart-pane.js +5 -5
- package/src/components/chart-parallel-options.js +1 -1
- package/src/components/chart-radar-options.js +1 -1
- package/src/components/chart-renderer.js +6 -1
- package/src/components/chart-sankey-options.js +1 -1
- package/src/components/chart-spatial-options.js +6 -2
- package/src/components/chart-sunburst-options.js +13 -1
- package/src/components/chart-theme.js +14 -0
- package/src/components/chart-treemap-options.js +1 -1
- package/src/components/chart-type-data.js +24 -4
- package/src/components/charts.js +7 -6
- package/src/components/check-box-text-editor.js +1 -0
- package/src/components/check-box-text.js +2 -0
- package/src/components/check-box-tree.js +1 -1
- package/src/components/choice-editor.js +5 -4
- package/src/components/choice-field-styles.js +9 -1
- package/src/components/code-mirror-engine.js +19 -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-commands.js +69 -0
- package/src/components/editor-options.js +1 -1
- package/src/components/editors.js +5 -3
- package/src/components/form-tray-pane.js +18 -0
- package/src/components/graphical-ranges.js +190 -0
- package/src/components/grid-check-sets.js +39 -3
- package/src/components/grid-footer.js +6 -1
- package/src/components/grid-header-interaction.js +3 -3
- package/src/components/grid-styles.js +30 -5
- package/src/components/grid-tools.js +15 -7
- package/src/components/grid.js +109 -15
- package/src/components/html-editor-commands.js +61 -0
- package/src/components/html-editor.js +18 -3
- package/src/components/inputs.js +94 -23
- package/src/components/jodit-engine.js +110 -7
- package/src/components/layout.js +3 -2
- package/src/components/menus.js +89 -26
- package/src/components/numeric-range.js +39 -0
- package/src/components/selected-container.js +123 -64
- package/src/components/tab-bar.js +389 -0
- package/src/components/toolbar-icon-style.js +22 -0
- package/src/components/toolbar-overflow.js +74 -12
- package/src/components/tray-base.js +528 -0
- package/src/components/tray-pane.js +41 -518
- package/src/components/tree.js +56 -4
- package/src/components/typed-editor.js +5 -2
- 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/editing-session.js +2 -1
- 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/ide-runtime.js +3 -1
- package/src/index-page-runtime.js +20 -5
- package/src/index-page-styles.js +1 -1
- package/src/index-theme.js +210 -3
- package/src/index.d.ts +7 -2
- package/src/index.js +7 -2
- package/src/libraries.js +4 -4
- package/src/object-extract.d.ts +7 -0
- package/src/object-extract.js +31 -0
- package/src/renderer/attributes.js +1 -1
- package/src/renderer/gramlot-renderer.d.ts +2 -2
- package/src/renderer/gramlot-renderer.js +4 -1
- package/src/server/chat-attachments.js +139 -0
- package/src/server/chat.d.ts +33 -0
- package/src/server/chat.js +168 -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 +149 -19
- package/src/server/index-page.d.ts +10 -0
- package/src/server/index-page.js +92 -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 +93 -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/labelbox.js +6 -1
- package/src/view/menu.js +9 -3
- package/src/visual-editor.d.ts +1 -0
- package/src/visual-editor.js +10 -5
- package/themes/gramlot-base/theme.css +60 -28
- package/themes/gramlot-compact/theme.css +2 -0
- package/themes/gramlot-index/icons/align-center.svg +4 -0
- package/themes/gramlot-index/icons/align-justify.svg +4 -0
- package/themes/gramlot-index/icons/align-left.svg +4 -0
- package/themes/gramlot-index/icons/align-right.svg +4 -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/bold.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/eraser.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/horizontal-rule.svg +4 -0
- package/themes/gramlot-index/icons/image.svg +4 -0
- package/themes/gramlot-index/icons/import.svg +4 -0
- package/themes/gramlot-index/icons/indent.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/italic.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-bulleted.svg +4 -0
- package/themes/gramlot-index/icons/list-numbered.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/outdent.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/paragraph.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/select-all.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/strikethrough.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/underline.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 +93 -0
- package/themes/gramlot-index/theme.css +24 -0
- package/themes/joanna/theme.css +2 -0
- package/themes/mela/theme.css +2 -0
- package/themes/mimi/theme.css +2 -0
- package/tools/gramlot-tools-inspector.js +11 -3
package/src/components/tree.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {iconSource} from '../icons.js';
|
|
1
2
|
/** Bag hierarchy, lazy branch expansion, captions and path selection. */
|
|
2
3
|
import {Bag} from '@genrojs/bag';
|
|
3
4
|
import createDOMPurify from 'dompurify';
|
|
@@ -64,6 +65,7 @@ export const Tree = defineComponent({
|
|
|
64
65
|
getLabel: {dtype: 'T', nullable: true, default: null},
|
|
65
66
|
labelState: {dtype: 'X', nullable: true, default: null, binding: 'read'},
|
|
66
67
|
getLabelClass: {dtype: 'T', nullable: true, default: null},
|
|
68
|
+
icon: {dtype:'T', default:'', binding:'read'},
|
|
67
69
|
getIconClass: {dtype: 'T', nullable: true, default: null},
|
|
68
70
|
selectedLabelClass: {dtype: 'T', default: '', binding: 'read'},
|
|
69
71
|
searchText: {dtype: 'T', default: '', binding: 'read'},
|
|
@@ -77,6 +79,7 @@ export const Tree = defineComponent({
|
|
|
77
79
|
onChecked: {dtype: ['B', 'T'], nullable: true, default: null},
|
|
78
80
|
checkedPaths: {dtype: 'T', nullable: true, default: null, binding: 'twoWay'},
|
|
79
81
|
checkedPaths_joiner: {dtype: 'T', default: ','},
|
|
82
|
+
eagerCheck: {dtype: 'B', default: false, binding: 'read'},
|
|
80
83
|
checkChildren: {dtype: 'B', default: true, binding: 'read'}
|
|
81
84
|
},
|
|
82
85
|
implementation: Base => class extends Base {
|
|
@@ -93,6 +96,7 @@ export const Tree = defineComponent({
|
|
|
93
96
|
#selectedPath = null;
|
|
94
97
|
#scheduled = false;
|
|
95
98
|
#checksEnabled = false;
|
|
99
|
+
#checkQueue = Promise.resolve();
|
|
96
100
|
#pathsEnabled = false;
|
|
97
101
|
// `checked_<attribute>` addresses, legacy syntax `path[:joiner]`, by attribute name.
|
|
98
102
|
#checkedAttributes = new Map();
|
|
@@ -148,7 +152,7 @@ export const Tree = defineComponent({
|
|
|
148
152
|
height:16px;padding:0 3px;border-radius:3px;font-size:10px;line-height:1;
|
|
149
153
|
background:var(--gramlot-tree-badge-background,#e7eaf0);color:var(--gramlot-tree-badge-color,#394452)}
|
|
150
154
|
.badge[data-colored]{color:var(--gramlot-tree-colored-badge-color,white)}
|
|
151
|
-
.icon{width:16px;height:16px;flex:none;background:currentColor;opacity
|
|
155
|
+
.icon{width:var(--gramlot-icon-size,16px);height:var(--gramlot-icon-size,16px);flex:none;background:var(--gramlot-icon-color,currentColor);opacity:var(--gramlot-icon-opacity,.7);mask:center/contain no-repeat;
|
|
152
156
|
mask-image:url("data:image/svg+xml,%3Csvg xmlns='${SVG_NS}' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='1.7' d='M5 3h9l5 5v13H5zM14 3v6h5M8 13h8M8 17h8'/%3E%3C/svg%3E")}
|
|
153
157
|
.branch-icon{mask-image:url("data:image/svg+xml,%3Csvg xmlns='${SVG_NS}' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='1.7' d='M3 7V4h7l3 3h8v13H3z'/%3E%3C/svg%3E")}
|
|
154
158
|
.opened-icon{mask-image:url("data:image/svg+xml,%3Csvg xmlns='${SVG_NS}' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='1.7' d='M3 19V4h7l3 3h8v3M3 20l3-9h16l-3 9z'/%3E%3C/svg%3E")}
|
|
@@ -360,6 +364,7 @@ export const Tree = defineComponent({
|
|
|
360
364
|
const scalar = children === null && !this.parameters.hideValues && (node.resolver === null || !node.resolver.expired);
|
|
361
365
|
const branch = children !== null ? children.length > 0
|
|
362
366
|
: scalar || (node.resolver !== null && this.parameters.resolveLazy && node.attr.child_count !== 0);
|
|
367
|
+
const section = branch && node.attr.section === true;
|
|
363
368
|
const entry = this.ownerDocument.createElement('li');
|
|
364
369
|
entry.className = `node ${branch ? 'branch' : 'leaf'}`;
|
|
365
370
|
entry.setAttribute('part', `node ${branch ? 'branch' : 'leaf'}`);
|
|
@@ -401,6 +406,7 @@ export const Tree = defineComponent({
|
|
|
401
406
|
caption.setAttribute('part', 'caption');
|
|
402
407
|
const icon = this.ownerDocument.createElement('span');
|
|
403
408
|
icon.className = `icon ${branch ? 'branch-icon' : 'leaf-icon'}`;
|
|
409
|
+
icon.setAttribute('iconslot', 'row');
|
|
404
410
|
icon.setAttribute('aria-hidden', 'true');
|
|
405
411
|
icon.setAttribute('part', `icon ${branch ? 'branch-icon' : 'leaf-icon'}`);
|
|
406
412
|
|
|
@@ -416,10 +422,20 @@ export const Tree = defineComponent({
|
|
|
416
422
|
if (result instanceof Promise) throw new TypeError('tree onChecked must be synchronous');
|
|
417
423
|
if (result === false) { this.#schedule(); return; }
|
|
418
424
|
}
|
|
419
|
-
this
|
|
425
|
+
if (this.parameters.eagerCheck && this.parameters.checkChildren && this.parameters.resolveLazy) {
|
|
426
|
+
this.#checkQueue = this.#checkQueue.then(() => this.#eagerCheck(path)).catch(error => {
|
|
427
|
+
this.#errors.set(path, error);
|
|
428
|
+
this.#schedule();
|
|
429
|
+
});
|
|
430
|
+
} else {
|
|
431
|
+
this.#toggleCheck(path);
|
|
432
|
+
}
|
|
420
433
|
});
|
|
421
434
|
}
|
|
422
|
-
row.append(expander
|
|
435
|
+
row.append(expander);
|
|
436
|
+
if (check) row.append(check);
|
|
437
|
+
else if (!section) row.append(icon);
|
|
438
|
+
row.append(badge, caption); entry.append(row);
|
|
423
439
|
const group = branch ? (children ? build(children, path, entry) : this.ownerDocument.createElement('ul')) : null;
|
|
424
440
|
if (group) { group.className = 'group'; group.setAttribute('role', 'group'); group.setAttribute('part', 'group'); }
|
|
425
441
|
if (group) entry.append(group);
|
|
@@ -486,7 +502,9 @@ export const Tree = defineComponent({
|
|
|
486
502
|
: [branch ? 'branch-icon' : 'leaf-icon', ...(branch ? [opened ? 'opened-icon' : 'closed-icon'] : [])];
|
|
487
503
|
icon.className = ['icon', ...iconClasses].join(' ');
|
|
488
504
|
icon.setAttribute('part', ['icon', ...iconClasses].join(' '));
|
|
489
|
-
|
|
505
|
+
const asset = iconSource(this, node.attr.icon ?? this.parameters.icon);
|
|
506
|
+
icon.style.maskImage = asset ? 'url(' + JSON.stringify(asset) + ')' : '';
|
|
507
|
+
icon.hidden = !asset && customIcon && iconClasses.length === 0;
|
|
490
508
|
if (check) {
|
|
491
509
|
const value = checks.get(path);
|
|
492
510
|
check.checked = value === true || value === 'disabled:on';
|
|
@@ -809,6 +827,40 @@ export const Tree = defineComponent({
|
|
|
809
827
|
}
|
|
810
828
|
return states;
|
|
811
829
|
}
|
|
830
|
+
/** Resolve only the clicked subtree. Commit once, after all editable descendants are available. */
|
|
831
|
+
async #eagerCheck(path) {
|
|
832
|
+
const store = this.storeBag;
|
|
833
|
+
const original = this.#rowNode(path);
|
|
834
|
+
if (!original || !this.isConnected) return;
|
|
835
|
+
const before = this.#checkLists();
|
|
836
|
+
const current = () => this.isConnected && this.parameters.eagerCheck && this.parameters.checkChildren
|
|
837
|
+
&& this.parameters.resolveLazy && this.storeBag === store && this.#rowNode(path) === original;
|
|
838
|
+
const load = async (key, ancestors) => {
|
|
839
|
+
const node = this.#rowNode(key);
|
|
840
|
+
if (!current() || !node) return false;
|
|
841
|
+
if (node.attr.checked === 'disabled:on' || node.attr.checked === 'disabled:off') return true;
|
|
842
|
+
if (node.resolver !== null && node.resolver.expired) {
|
|
843
|
+
// An explicit click can open a loop. Do not follow another loop recursively.
|
|
844
|
+
if (key !== path && node.attr.loop === true) {
|
|
845
|
+
throw new Error(`Cannot enumerate the leaves of the loop at ${key}`);
|
|
846
|
+
}
|
|
847
|
+
await this.#resolve(node, key);
|
|
848
|
+
if (!current() || this.#rowNode(key) !== node || this.#errors.has(key)) return false;
|
|
849
|
+
}
|
|
850
|
+
const children = this.#childBag(node);
|
|
851
|
+
if (!children) return true;
|
|
852
|
+
if (ancestors.has(children)) throw new TypeError('tree requires an acyclic Bag store');
|
|
853
|
+
const next = new Set(ancestors).add(children);
|
|
854
|
+
for (const child of children.getNodes()) {
|
|
855
|
+
if (!await load(key + '.' + child.label, next)) return false;
|
|
856
|
+
}
|
|
857
|
+
return true;
|
|
858
|
+
};
|
|
859
|
+
if (!await load(path, new Set()) || !current()) return;
|
|
860
|
+
const lists = this.#checkLists();
|
|
861
|
+
if (before.length === lists.length && before.every((list, i) =>
|
|
862
|
+
list.name === lists[i].name && list.value === lists[i].value)) this.#toggleCheck(path);
|
|
863
|
+
}
|
|
812
864
|
/**
|
|
813
865
|
* Toggle the check at `path` as the legacy click (a checked or mixed node unchecks) and write
|
|
814
866
|
* every list. With checkChildren a branch counts as checked when any leaf the click changes is
|
|
@@ -28,12 +28,15 @@ export function TypedEditor(HTMLElement) {
|
|
|
28
28
|
super();
|
|
29
29
|
this.control.addEventListener('focus', () => {
|
|
30
30
|
this.#focused = true;
|
|
31
|
-
|
|
31
|
+
// select() applies its selection after the focus event in Chromium (#147).
|
|
32
|
+
// Show the editing text after the current script, then read the final selection.
|
|
33
|
+
queueMicrotask(() => {
|
|
34
|
+
if (!this.#focused || this.#dirty) return;
|
|
32
35
|
const start = this.control.selectionStart, end = this.control.selectionEnd;
|
|
33
36
|
const all = start === 0 && end === this.control.value.length;
|
|
34
37
|
this.#policy = this.context(); this.display();
|
|
35
38
|
this.control.setSelectionRange(start, all ? this.control.value.length : end);
|
|
36
|
-
}
|
|
39
|
+
});
|
|
37
40
|
});
|
|
38
41
|
this.control.addEventListener('input', () => {
|
|
39
42
|
if (!this.#selecting) this.#selection = null;
|
|
@@ -16,9 +16,9 @@ function PreviewElement(HTMLElement){
|
|
|
16
16
|
const style=doc.createElement('style');
|
|
17
17
|
style.textContent=`:host{display:block;height:100%;min-height:0;color:var(--gramlot-ink,CanvasText)}
|
|
18
18
|
.preview{display:flex;flex-direction:column;height:100%;background:var(--gramlot-surface-subtle,Canvas)}
|
|
19
|
-
.tools{display:flex;gap:16px;align-items:center;padding:8px 12px;font:inherit}
|
|
20
|
-
a{color:var(--gramlot-
|
|
21
|
-
a:hover{background:var(--gramlot-selected
|
|
19
|
+
.tools{display:flex;gap:16px;align-items:center;padding:8px 12px;font:inherit;background:var(--gramlot-surface,Canvas)}
|
|
20
|
+
a{color:var(--gramlot-action,LinkText);border-radius:var(--gramlot-radius-sm,4px);padding:4px 8px;text-decoration:underline;white-space:nowrap}
|
|
21
|
+
a[href]:hover{color:var(--gramlot-action-hover,LinkText);background:var(--gramlot-selected,Canvas)}
|
|
22
22
|
a:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight)}
|
|
23
23
|
a[aria-disabled=true]{opacity:.45;pointer-events:none}
|
|
24
24
|
.status{white-space:pre-wrap;font-size:.9em;overflow:auto;max-height:8em}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {fromTytx} from '@genrojs/tytx';
|
|
2
|
+
|
|
3
|
+
const blockSize = 256 * 1024;
|
|
4
|
+
|
|
5
|
+
function waitForRetry(signal, delay) {
|
|
6
|
+
signal?.throwIfAborted();
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
const abort = () => { clearTimeout(timer); reject(signal.reason); };
|
|
9
|
+
const timer = setTimeout(() => {
|
|
10
|
+
signal?.removeEventListener('abort', abort);
|
|
11
|
+
resolve();
|
|
12
|
+
}, delay);
|
|
13
|
+
signal?.addEventListener('abort', abort, {once:true});
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function postBlock(window, url, headers, block, signal) {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
const xhr = new window.XMLHttpRequest();
|
|
20
|
+
xhr.open('POST', url);
|
|
21
|
+
xhr.setRequestHeader('Content-Type', 'application/octet-stream');
|
|
22
|
+
for (const [name, value] of Object.entries(headers)) xhr.setRequestHeader(name, value);
|
|
23
|
+
const abort = () => xhr.abort();
|
|
24
|
+
const finish = fn => () => { signal?.removeEventListener('abort', abort); fn(); };
|
|
25
|
+
xhr.addEventListener('load', finish(() => {
|
|
26
|
+
try {
|
|
27
|
+
if (xhr.status !== 200) throw new Error(`Upload HTTP ${xhr.status}`);
|
|
28
|
+
resolve(fromTytx(xhr.responseText));
|
|
29
|
+
} catch (error) { reject(error); }
|
|
30
|
+
}));
|
|
31
|
+
xhr.addEventListener('error', finish(() => reject(new TypeError('Upload connection failed'))));
|
|
32
|
+
xhr.addEventListener('abort', finish(() => reject(new Error('Upload cancelled'))));
|
|
33
|
+
signal?.addEventListener('abort', abort, {once:true});
|
|
34
|
+
xhr.send(block);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function readBlock(window, blob) {
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
const reader = new window.FileReader();
|
|
41
|
+
reader.onload = () => resolve(new Uint8Array(reader.result));
|
|
42
|
+
reader.onerror = () => reject(reader.error);
|
|
43
|
+
reader.readAsArrayBuffer(blob);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** One checkpoint per complete block. A lost response is reconciled before another write. */
|
|
48
|
+
export async function sendUploadBlocks(page, file, grant, {window, offset = 0, signal, progress = () => {}}) {
|
|
49
|
+
const {pageId, rpc, uploadUrl} = page;
|
|
50
|
+
const {transferId, authorization} = grant;
|
|
51
|
+
let delay = 250;
|
|
52
|
+
for (;;) {
|
|
53
|
+
signal?.throwIfAborted();
|
|
54
|
+
const end = Math.min(offset + blockSize, file.size);
|
|
55
|
+
const block = file.slice(offset, end);
|
|
56
|
+
let outcome;
|
|
57
|
+
try {
|
|
58
|
+
outcome = uploadUrl ? await postBlock(window, uploadUrl, {
|
|
59
|
+
'X-Gramlot-Page-Id':pageId, 'X-Gramlot-Transfer-Id':transferId,
|
|
60
|
+
'X-Gramlot-Upload-Token':authorization, 'X-Gramlot-Upload-Offset':String(offset),
|
|
61
|
+
}, block, signal) : await rpc.transport.upload({pageId, transferId, authorization, offset, block:await readBlock(window, block)}, progress, signal);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
for (;;) {
|
|
64
|
+
signal?.throwIfAborted();
|
|
65
|
+
try {
|
|
66
|
+
outcome = await rpc.call('upload', 'status', {transferId}, {signal});
|
|
67
|
+
break;
|
|
68
|
+
} catch (statusError) {
|
|
69
|
+
if (statusError.name !== 'TypeError' && !page._pageStore?.reconnecting) throw statusError;
|
|
70
|
+
await waitForRetry(signal, delay);
|
|
71
|
+
delay = Math.min(delay * 2, 5000);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (outcome.state === 'pending' && outcome.offset === offset) {
|
|
75
|
+
if (!(error instanceof TypeError)) throw error;
|
|
76
|
+
await waitForRetry(signal, delay);
|
|
77
|
+
delay = Math.min(delay * 2, 5000);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (outcome.state === 'completed') progress(file.size);
|
|
82
|
+
if (outcome.state !== 'pending' || outcome.offset === undefined) return outcome;
|
|
83
|
+
if (outcome.offset !== end || end === offset || end === file.size) throw new Error('Invalid upload checkpoint');
|
|
84
|
+
offset = end;
|
|
85
|
+
progress(offset);
|
|
86
|
+
delay = 250;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** One browser queue, independent of its presentation. Files and grants stay private. */
|
|
2
2
|
import {Bag} from '@genrojs/bag';
|
|
3
|
-
import {
|
|
3
|
+
import {sendUploadBlocks} from './upload-blocks.js';
|
|
4
4
|
import {randomId} from '../random-id.js';
|
|
5
5
|
|
|
6
6
|
/** Read the optional shared context at preparation time, independently of file fields. */
|
|
@@ -53,7 +53,7 @@ export class UploadEngine {
|
|
|
53
53
|
if (!this.gramlot.capabilities.includes('upload')) {
|
|
54
54
|
this.#update(id, {status:'failed', error:'Upload is unavailable in this environment'}); return;
|
|
55
55
|
}
|
|
56
|
-
const state = {
|
|
56
|
+
const state = {controller:new AbortController(), transferId:null, cancelled:false};
|
|
57
57
|
this.#active.set(id, state);
|
|
58
58
|
this.#update(id, {status:'preparing', error:null});
|
|
59
59
|
try {
|
|
@@ -61,13 +61,13 @@ export class UploadEngine {
|
|
|
61
61
|
metadata:{name:file.name, size:file.size, mediaType:file.type || '',
|
|
62
62
|
fields:row.getItem('metadata').asDict(false, false, true), context:this.getContext()}});
|
|
63
63
|
state.transferId = grant.transferId;
|
|
64
|
-
this.#transfers.set(id, grant
|
|
64
|
+
this.#transfers.set(id, grant);
|
|
65
65
|
if (state.cancelled || this.#closed) {
|
|
66
66
|
const outcome = await this.gramlot.rpc.call('upload', 'cancel', {transferId:state.transferId});
|
|
67
67
|
await this.#apply(id, outcome, true); return;
|
|
68
68
|
}
|
|
69
69
|
this.#update(id, {status:'uploading'});
|
|
70
|
-
const result = await this
|
|
70
|
+
const result = await sendUploadBlocks(this.gramlot, file, grant, {window:this.window, signal:state.controller.signal, progress:loaded => this.#update(id, {loaded})});
|
|
71
71
|
await this.#apply(id, result, state.cancelled);
|
|
72
72
|
} catch (error) {
|
|
73
73
|
if (state.transferId) {
|
|
@@ -83,28 +83,6 @@ export class UploadEngine {
|
|
|
83
83
|
this.#active.delete(id);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
#send(file, state, token, id) {
|
|
87
|
-
if (!this.gramlot.uploadUrl) {
|
|
88
|
-
return this.gramlot.rpc.transport.upload({pageId:this.gramlot.pageId, transferId:state.transferId,
|
|
89
|
-
authorization:token, file}, loaded => this.#update(id, {loaded}), state.controller.signal);
|
|
90
|
-
}
|
|
91
|
-
return new Promise((resolve, reject) => {
|
|
92
|
-
const request = state.xhr = new this.window.XMLHttpRequest();
|
|
93
|
-
request.open('POST', this.gramlot.uploadUrl, true);
|
|
94
|
-
request.setRequestHeader('Content-Type', 'application/octet-stream');
|
|
95
|
-
request.setRequestHeader('X-Gramlot-Page-Id', this.gramlot.pageId);
|
|
96
|
-
request.setRequestHeader('X-Gramlot-Transfer-Id', state.transferId);
|
|
97
|
-
request.setRequestHeader('X-Gramlot-Upload-Token', token);
|
|
98
|
-
request.upload.addEventListener('progress', event => this.#update(id, {loaded:event.loaded}));
|
|
99
|
-
request.addEventListener('load', () => {
|
|
100
|
-
if (request.status !== 200) { reject(new Error(`Upload HTTP ${request.status}`)); return; }
|
|
101
|
-
try { resolve(fromTytx(request.responseText)); } catch (error) { reject(error); }
|
|
102
|
-
}, {once:true});
|
|
103
|
-
request.addEventListener('error', () => reject(new Error('Upload connection failed')), {once:true});
|
|
104
|
-
request.addEventListener('abort', () => reject(new Error('Upload cancelled')), {once:true});
|
|
105
|
-
request.send(file);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
86
|
async #apply(id, outcome, cancelled = false) {
|
|
109
87
|
if (outcome.state === 'completed') {
|
|
110
88
|
this.#update(id, {status:'completed', result:outcome.result, error:null});
|
|
@@ -132,15 +110,28 @@ export class UploadEngine {
|
|
|
132
110
|
return true;
|
|
133
111
|
}
|
|
134
112
|
async reconcile(id) {
|
|
135
|
-
const
|
|
136
|
-
if (!
|
|
113
|
+
const grant = this.#transfers.get(id);
|
|
114
|
+
if (!grant || this.#closed || this.#active.has(id) || this.#checking.has(id)) return;
|
|
137
115
|
this.#checking.add(id);
|
|
116
|
+
const state = {transferId:grant.transferId, controller:new AbortController(), cancelled:false};
|
|
138
117
|
try {
|
|
139
|
-
|
|
118
|
+
this.#active.set(id, state);
|
|
119
|
+
let outcome = await this.gramlot.rpc.call('upload', 'status', {transferId:grant.transferId});
|
|
120
|
+
if (outcome.state === 'pending' && Number.isSafeInteger(outcome.offset)) {
|
|
121
|
+
outcome = await sendUploadBlocks(this.gramlot, this.#files.get(id), grant, {
|
|
122
|
+
window:this.window, offset:outcome.offset, signal:state.controller.signal, progress:loaded => this.#update(id, {loaded}),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
140
125
|
await this.#apply(id, outcome);
|
|
141
126
|
} catch (error) {
|
|
142
|
-
|
|
127
|
+
if (state.cancelled) {
|
|
128
|
+
try {
|
|
129
|
+
const outcome = await this.gramlot.rpc.call('upload', 'cancel', {transferId:grant.transferId});
|
|
130
|
+
await this.#apply(id, outcome, true);
|
|
131
|
+
} catch (recoveryError) { this.#update(id, {status:'uncertain', error:recoveryError.message}); }
|
|
132
|
+
} else this.#update(id, {status:'uncertain', error:error.message});
|
|
143
133
|
} finally {
|
|
134
|
+
this.#active.delete(id);
|
|
144
135
|
this.#checking.delete(id);
|
|
145
136
|
}
|
|
146
137
|
}
|
|
@@ -154,7 +145,6 @@ export class UploadEngine {
|
|
|
154
145
|
if (!state) return;
|
|
155
146
|
state.cancelled = true;
|
|
156
147
|
state.controller.abort();
|
|
157
|
-
state.xhr?.abort();
|
|
158
148
|
}
|
|
159
149
|
dispose() {
|
|
160
150
|
this.#closed = true;
|