@gramlot/gramlot 0.3.32 → 0.3.34
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/dist/components/audio/__init__.py +1 -1
- package/dist/components/audio/assets/collection.js +2 -2
- package/dist/components/audio/assets/index.js +1 -1
- package/dist/components/charts/__init__.py +2 -2
- package/dist/components/charts/assets/collection.js +24 -43
- package/dist/components/charts/assets/index.js +1 -1
- package/dist/components/charts/assets/modules/chunk-USZCUBTC.js +1 -0
- package/dist/components/charts/assets/modules/echarts-gl.min-N6L67H2M.js +4282 -0
- package/dist/components/charts/assets/modules/echarts.esm.min-VHLRZDVQ.js +61 -0
- package/dist/components/charts/assets/modules/{plotly.min-4LB7HE7P.js → plotly.min-SSDU2DOH.js} +1 -1
- package/dist/components/charts/assets/modules/{uPlot.esm-5JJNHHRF.js → uPlot.esm-Q2UYUQHJ.js} +1 -1
- package/dist/components/charts/assets/modules/{uPlot.min-N3E3FA74.js → uPlot.min-XXHNQFXH.js} +1 -1
- package/dist/components/charts/assets/modules/{vega.module-2QCOVQ3A.js → vega.module-Y5CWNSZO.js} +1 -1
- package/dist/components/charts/grammar.json +15482 -232
- 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 +1 -1
- package/dist/components/drawing/assets/collection.js +3 -24
- package/dist/components/drawing/assets/index.js +1 -1
- package/dist/components/editors/__init__.py +2 -2
- package/dist/components/editors/assets/collection.js +2 -47
- package/dist/components/editors/assets/index.js +1 -1
- package/dist/components/editors/assets/modules/{jodit-engine-MTSA4GZ3.js → jodit-engine-CXRSFV47.js} +6 -6
- package/dist/components/grid/__init__.py +2 -2
- package/dist/components/grid/assets/collection.js +6 -28
- package/dist/components/grid/assets/index.js +1 -1
- package/dist/components/grid/assets/modules/{browser-LVJHKBBV.js → browser-Y2BRNI3P.js} +1 -1
- package/dist/components/grid/assets/modules/chunk-BLMUM44K.js +1 -0
- 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 +1 -1
- package/dist/components/inputs/assets/collection.js +8 -65
- package/dist/components/inputs/assets/index.js +1 -1
- package/dist/components/layout/__init__.py +1 -1
- package/dist/components/layout/assets/collection.js +9 -30
- package/dist/components/layout/assets/index.js +1 -1
- 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 +6 -27
- package/dist/components/tree/assets/index.js +1 -1
- package/dist/components/typst/__init__.py +1 -1
- package/dist/components/typst/assets/collection.js +3 -3
- package/dist/components/typst/assets/index.js +1 -1
- package/dist/components/uploads/__init__.py +1 -1
- package/dist/components/uploads/assets/collection.js +3 -30
- package/dist/components/uploads/assets/index.js +1 -1
- package/dist/components/vizabi/__init__.py +1 -1
- package/dist/components/vizabi/assets/collection.js +3 -21
- package/dist/components/vizabi/assets/index.js +1 -1
- package/dist/gramlot.js +1599 -59
- package/dist/gramlot.min.js +49 -48
- package/dist/libraries.json +126 -0
- package/dist/runtime-notices.json +4 -0
- package/dist/standard-collections.js +1 -1
- package/package.json +2 -2
- package/src/components/chart-boxplot-options.js +22 -0
- package/src/components/chart-candlestick-options.js +27 -0
- package/src/components/chart-controls.js +28 -6
- package/src/components/chart-domains.js +1 -1
- package/src/components/chart-engines/echarts.js +28 -4
- package/src/components/chart-engines/plotly.js +3 -2
- package/src/components/chart-engines/uplot.js +5 -3
- package/src/components/chart-engines/vega.js +2 -1
- package/src/components/chart-fields.js +11 -1
- package/src/components/chart-funnel-options.js +19 -0
- package/src/components/chart-gauge-options.js +98 -0
- package/src/components/chart-gauge.js +109 -0
- package/src/components/chart-heatmap-options.js +29 -0
- package/src/components/chart-notice.js +126 -0
- package/src/components/chart-pane.js +7 -1
- package/src/components/chart-parallel-options.js +24 -0
- package/src/components/chart-radar-options.js +29 -0
- package/src/components/chart-renderer.js +3 -9
- package/src/components/chart-sankey-options.js +43 -0
- package/src/components/chart-sunburst-options.js +12 -0
- package/src/components/chart-syntax.js +82 -0
- package/src/components/chart-time.js +2 -1
- package/src/components/chart-treemap-options.js +16 -0
- package/src/components/chart-type-data.js +62 -0
- package/src/components/chart-types/area.js +6 -1
- package/src/components/chart-types/bar.js +6 -1
- package/src/components/chart-types/bar3D.js +7 -1
- package/src/components/chart-types/boxplot.js +11 -0
- package/src/components/chart-types/candlestick.js +10 -0
- package/src/components/chart-types/donut.js +6 -1
- package/src/components/chart-types/funnel.js +7 -0
- package/src/components/chart-types/heatmap.js +8 -0
- package/src/components/chart-types/horizontalBar.js +6 -1
- package/src/components/chart-types/index.js +21 -1
- package/src/components/chart-types/line.js +6 -1
- package/src/components/chart-types/line3D.js +7 -1
- package/src/components/chart-types/lines3D.js +7 -1
- package/src/components/chart-types/map.js +7 -1
- package/src/components/chart-types/map3D.js +6 -1
- package/src/components/chart-types/mapBar3D.js +6 -1
- package/src/components/chart-types/parallel.js +7 -0
- package/src/components/chart-types/pie.js +6 -1
- package/src/components/chart-types/polygons3D.js +7 -1
- package/src/components/chart-types/radar.js +7 -0
- package/src/components/chart-types/sankey.js +8 -0
- package/src/components/chart-types/scatter.js +6 -1
- package/src/components/chart-types/scatter3D.js +7 -1
- package/src/components/chart-types/stackedArea.js +6 -1
- package/src/components/chart-types/stackedBar.js +6 -1
- package/src/components/chart-types/sunburst.js +7 -0
- package/src/components/chart-types/surface.js +7 -1
- package/src/components/chart-types/treemap.js +7 -0
- package/src/components/charts.js +60 -13
- package/src/components/code-mirror.js +2 -1
- package/src/components/grid-tools.js +2 -1
- package/src/components/html-editor.js +2 -1
- package/src/components/markdown-editor.js +2 -1
- package/src/components/registry.js +9 -5
- package/src/components/typst-preview.js +2 -1
- package/src/index.d.ts +16 -0
- package/src/index.js +5 -0
- package/src/libraries.js +83 -0
- package/src/page-store-connection.js +15 -5
- package/src/server/gramlot-server.d.ts +8 -0
- package/src/server/gramlot-server.js +40 -4
- package/src/shared-modules.js +79 -0
- package/dist/components/charts/assets/modules/chunk-2CCTLZE7.js +0 -76
- package/dist/components/charts/assets/modules/chunk-RMRBEYTI.js +0 -1
- package/dist/components/charts/assets/modules/echarts-gl-CXVTZA6G.js +0 -4409
- package/dist/components/grid/assets/modules/chunk-RMRBEYTI.js +0 -1
|
@@ -14,6 +14,7 @@ import {gramlotDev} from './assets.js';
|
|
|
14
14
|
import {ENDPOINT_METHOD, Page, SOURCE_METHOD, UPLOAD_METHOD, resolveDeclared} from './page.js';
|
|
15
15
|
import {UploadRegistry, UploadTarget} from './upload.js';
|
|
16
16
|
import {InvalidResourceName, SEGMENT, loadOrder} from './resources.js';
|
|
17
|
+
import {libraries} from '../libraries.js';
|
|
17
18
|
|
|
18
19
|
export class PageExpired extends Error { name = 'PageExpired'; }
|
|
19
20
|
export class PageNotFound extends Error { name = 'PageNotFound'; }
|
|
@@ -105,13 +106,21 @@ const prefixed = (prefix, url) => url.startsWith('/') && !url.startsWith('//') ?
|
|
|
105
106
|
*
|
|
106
107
|
* A page expires `pageTtl` seconds after its last use: opening it and every call that names it for its
|
|
107
108
|
* owner move the expiry to now plus `pageTtl` (GC-230 §010).
|
|
109
|
+
*
|
|
110
|
+
* `librarySource` says where the pages take the third-party libraries of the components: `'cdn'` (jsDelivr,
|
|
111
|
+
* at the exact version of the manifest) or `'local'` (the copies served with the collections). With `'cdn'`
|
|
112
|
+
* the import map of the bootstrap carries the integrity of each CDN module and contentSecurityPolicy adds the
|
|
113
|
+
* CDN origin to the policy (GC-325 §160).
|
|
108
114
|
*/
|
|
109
115
|
export class GramlotServer {
|
|
110
116
|
get markdownUrl() { return this.runtimeUrl.replace(/[^/]+$/, 'gramlot-markdown.js'); }
|
|
111
117
|
|
|
112
118
|
constructor({runtimeUrl = '/assets/gramlot.js', rpcUrl = '/gramlot/rpc', closeUrl = '/gramlot/close',
|
|
113
119
|
rootId = 'gramlot-root', pageTtl = 1800, maxPages = 1000, collections = [], uploadsEnabled = false,
|
|
114
|
-
cssTheme = 'gramlot-base'} = {}) {
|
|
120
|
+
cssTheme = 'gramlot-base', librarySource = 'cdn'} = {}) {
|
|
121
|
+
if (!['cdn', 'local'].includes(librarySource)) {
|
|
122
|
+
throw new TypeError(`The library source must be 'cdn' or 'local', not ${JSON.stringify(librarySource)}`);
|
|
123
|
+
}
|
|
115
124
|
if (cssTheme !== false && !isThemeName(cssTheme)) {
|
|
116
125
|
throw new TypeError(`The base theme must be a theme name or false, not ${JSON.stringify(cssTheme)}`);
|
|
117
126
|
}
|
|
@@ -120,7 +129,8 @@ export class GramlotServer {
|
|
|
120
129
|
!Number.isSafeInteger(maxPages) || maxPages < 1) {
|
|
121
130
|
throw new TypeError('Page TTL must be finite and positive; capacity must be a positive safe integer');
|
|
122
131
|
}
|
|
123
|
-
Object.assign(this, {runtimeUrl, rpcUrl, closeUrl, rootId, pageTtl, maxPages, cssTheme});
|
|
132
|
+
Object.assign(this, {runtimeUrl, rpcUrl, closeUrl, rootId, pageTtl, maxPages, cssTheme, librarySource});
|
|
133
|
+
this.libraries = libraries;
|
|
124
134
|
this.pages = new Map();
|
|
125
135
|
this.uploads = uploadsEnabled ? new UploadRegistry() : null;
|
|
126
136
|
this.collections = this.collectionGraph([...standardCollections, ...collections]);
|
|
@@ -128,6 +138,30 @@ export class GramlotServer {
|
|
|
128
138
|
this.environmentPages = new WeakMap();
|
|
129
139
|
}
|
|
130
140
|
|
|
141
|
+
/** The origins the pages load third-party libraries from: the CDN origin with `'cdn'`, else none. */
|
|
142
|
+
get libraryOrigins() {
|
|
143
|
+
if (this.librarySource === 'local') return [];
|
|
144
|
+
return [...new Set(Object.values(this.libraries).filter(entry => entry.url !== null)
|
|
145
|
+
.map(entry => entry.url.split('/').slice(0, 3).join('/')))];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** The `Content-Security-Policy` header of one page: `policy` with `{nonce}` replaced by the nonce of its
|
|
149
|
+
* bootstrap and the library origins added to the directive that governs scripts (`script-src`, else
|
|
150
|
+
* `default-src`) and to the one that governs connections (`connect-src`, else `default-src`); a policy
|
|
151
|
+
* without such a directive leaves that kind unrestricted (GC-101 §140). */
|
|
152
|
+
contentSecurityPolicy(policy, nonce) {
|
|
153
|
+
const directives = policy.replaceAll('{nonce}', nonce).split(';').filter(part => part.trim())
|
|
154
|
+
.map(part => part.trim().split(/\s+/));
|
|
155
|
+
const names = directives.map(directive => directive[0]);
|
|
156
|
+
for (const kind of ['script-src', 'connect-src']) {
|
|
157
|
+
const name = names.includes(kind) ? kind : names.includes('default-src') ? 'default-src' : null;
|
|
158
|
+
if (name === null) continue;
|
|
159
|
+
const directive = directives[names.indexOf(name)];
|
|
160
|
+
directive.push(...this.libraryOrigins.filter(origin => !directive.includes(origin)));
|
|
161
|
+
}
|
|
162
|
+
return directives.map(directive => directive.join(' ')).join('; ');
|
|
163
|
+
}
|
|
164
|
+
|
|
131
165
|
/** The Page class of path, or PageNotFound. */
|
|
132
166
|
async resolvePage(path) { throw new PageNotFound(`Page not found: ${path}`); }
|
|
133
167
|
|
|
@@ -325,7 +359,7 @@ export class GramlotServer {
|
|
|
325
359
|
...(resources.serverAdapter ? {serverAdapter: prefixed(prefix, resources.serverAdapter)} : {})},
|
|
326
360
|
});
|
|
327
361
|
const document = new GramlotBuilder();
|
|
328
|
-
const root = document.root.html();
|
|
362
|
+
const root = document.root.html({'data-gramlot-library-source': this.librarySource});
|
|
329
363
|
const head = root.head();
|
|
330
364
|
head.meta({charset: 'utf-8'});
|
|
331
365
|
head.meta({name: 'viewport', content: 'width=device-width,initial-scale=1'});
|
|
@@ -338,7 +372,9 @@ export class GramlotServer {
|
|
|
338
372
|
'@gramlot/gramlot': prefixed(prefix, this.runtimeUrl),
|
|
339
373
|
'@gramlot/gramlot/components':prefixed(prefix,this.runtimeUrl),
|
|
340
374
|
'@gramlot/gramlot/markdown':prefixed(prefix,this.markdownUrl),
|
|
341
|
-
...Object.fromEntries((resources.collections ?? []).map(({name,url})=>[`@gramlot/collections/${encodeURIComponent(name)}`,prefixed(prefix,url)]))}
|
|
375
|
+
...Object.fromEntries((resources.collections ?? []).map(({name,url})=>[`@gramlot/collections/${encodeURIComponent(name)}`,prefixed(prefix,url)]))},
|
|
376
|
+
...(this.librarySource === 'cdn' ? {integrity: Object.fromEntries(Object.values(this.libraries)
|
|
377
|
+
.filter(entry => entry.url !== null && entry.format !== 'style').map(entry => [entry.url, entry.integrity]))} : {})}),
|
|
342
378
|
{type: 'importmap', nonce});
|
|
343
379
|
const body = root.body();
|
|
344
380
|
body.div({id: this.rootId});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The modules that the runtime shares with prepared collections.
|
|
3
|
+
*
|
|
4
|
+
* The collection generator keeps every module of this table out of a collection bundle: an import of
|
|
5
|
+
* one of them becomes a read of this table from `@gramlot/gramlot`. A page therefore holds one copy
|
|
6
|
+
* of each module, and its classes keep their identity across the runtime and the collections
|
|
7
|
+
* (`instanceof Bag` holds for a Bag created by a collection).
|
|
8
|
+
*
|
|
9
|
+
* A key is the import specifier: the package name for a library, the path relative to this
|
|
10
|
+
* directory for a runtime module. The generator refuses a collection that would bundle a module of
|
|
11
|
+
* the runtime missing from this table.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import * as genrojsBag from '@genrojs/bag';
|
|
16
|
+
import * as genrojsBuilders from '@genrojs/builders';
|
|
17
|
+
import * as genrojsToolbox from '@genrojs/toolbox';
|
|
18
|
+
import * as genrojsTytx from '@genrojs/tytx';
|
|
19
|
+
import * as xmldom from '@xmldom/xmldom';
|
|
20
|
+
import * as decimal from 'decimal.js';
|
|
21
|
+
import * as big from 'big.js';
|
|
22
|
+
import * as msgpack from '@msgpack/msgpack';
|
|
23
|
+
import * as dompurify from 'dompurify';
|
|
24
|
+
import * as randomId from './random-id.js';
|
|
25
|
+
import * as format from './format.js';
|
|
26
|
+
import * as librariesModule from './libraries.js';
|
|
27
|
+
import * as mediaFrame from './media-frame.js';
|
|
28
|
+
import * as validationRun from './validation-run.js';
|
|
29
|
+
import * as rendererAttributes from './renderer/attributes.js';
|
|
30
|
+
import * as viewLabelbox from './view/labelbox.js';
|
|
31
|
+
import * as columnFilter from './stores/column-filter.js';
|
|
32
|
+
import * as collectionFilter from './stores/collection-filter.js';
|
|
33
|
+
import * as idSet from './stores/id-set.js';
|
|
34
|
+
import * as bagCollectionStore from './stores/bag-collection-store.js';
|
|
35
|
+
import * as bagCollectionView from './stores/bag-collection-view.js';
|
|
36
|
+
import * as bases from './components/bases.js';
|
|
37
|
+
import * as choices from './components/choices.js';
|
|
38
|
+
import * as choiceFieldStyles from './components/choice-field-styles.js';
|
|
39
|
+
import * as fieldState from './components/field-state.js';
|
|
40
|
+
import * as gridFormulas from './components/grid-formulas.js';
|
|
41
|
+
import * as gridStructure from './components/grid-structure.js';
|
|
42
|
+
import * as labelbox from './components/labelbox.js';
|
|
43
|
+
import * as parameters from './components/parameters.js';
|
|
44
|
+
import * as popup from './components/popup.js';
|
|
45
|
+
import * as validation from './components/validation.js';
|
|
46
|
+
|
|
47
|
+
export const sharedModules = Object.freeze({
|
|
48
|
+
'@genrojs/bag': genrojsBag,
|
|
49
|
+
'@genrojs/builders': genrojsBuilders,
|
|
50
|
+
'@genrojs/toolbox': genrojsToolbox,
|
|
51
|
+
'@genrojs/tytx': genrojsTytx,
|
|
52
|
+
'@xmldom/xmldom': xmldom,
|
|
53
|
+
'decimal.js': decimal,
|
|
54
|
+
'big.js': big,
|
|
55
|
+
'@msgpack/msgpack': msgpack,
|
|
56
|
+
'dompurify': dompurify,
|
|
57
|
+
'./random-id.js': randomId,
|
|
58
|
+
'./format.js': format,
|
|
59
|
+
'./libraries.js': librariesModule,
|
|
60
|
+
'./media-frame.js': mediaFrame,
|
|
61
|
+
'./validation-run.js': validationRun,
|
|
62
|
+
'./renderer/attributes.js': rendererAttributes,
|
|
63
|
+
'./view/labelbox.js': viewLabelbox,
|
|
64
|
+
'./stores/column-filter.js': columnFilter,
|
|
65
|
+
'./stores/collection-filter.js': collectionFilter,
|
|
66
|
+
'./stores/id-set.js': idSet,
|
|
67
|
+
'./stores/bag-collection-store.js': bagCollectionStore,
|
|
68
|
+
'./stores/bag-collection-view.js': bagCollectionView,
|
|
69
|
+
'./components/bases.js': bases,
|
|
70
|
+
'./components/choices.js': choices,
|
|
71
|
+
'./components/choice-field-styles.js': choiceFieldStyles,
|
|
72
|
+
'./components/field-state.js': fieldState,
|
|
73
|
+
'./components/grid-formulas.js': gridFormulas,
|
|
74
|
+
'./components/grid-structure.js': gridStructure,
|
|
75
|
+
'./components/labelbox.js': labelbox,
|
|
76
|
+
'./components/parameters.js': parameters,
|
|
77
|
+
'./components/popup.js': popup,
|
|
78
|
+
'./components/validation.js': validation,
|
|
79
|
+
});
|