@gramlot/gramlot 0.3.10 → 0.3.16
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/editors/__init__.py +13 -0
- package/dist/components/{editors.js → editors/assets/collection.js} +131 -246
- package/dist/components/editors/assets/index.js +2 -0
- package/dist/components/editors/commands.json +7 -0
- package/dist/components/editors/grammar.json +7045 -0
- package/dist/components/inputs/__init__.py +13 -0
- package/dist/components/{inputs.js → inputs/assets/collection.js} +287 -198
- package/dist/components/inputs/assets/index.js +2 -0
- package/dist/components/inputs/commands.json +7 -0
- package/dist/components/inputs/grammar.json +42881 -0
- package/dist/components/layout/__init__.py +13 -0
- package/dist/components/layout/assets/collection.js +25737 -0
- package/dist/components/layout/assets/index.js +2 -0
- package/dist/components/layout/commands.json +7 -0
- package/dist/components/layout/grammar.json +1798 -0
- package/dist/components/tree/__init__.py +13 -0
- package/dist/components/{tree.js → tree/assets/collection.js} +62 -175
- package/dist/components/tree/assets/index.js +2 -0
- package/dist/components/tree/commands.json +7 -0
- package/dist/components/tree/grammar.json +339 -0
- package/dist/components/typst/__init__.py +13 -0
- package/dist/components/typst/assets/collection.js +4 -0
- package/dist/components/typst/assets/index.js +2 -0
- package/dist/components/typst/commands.json +7 -0
- package/dist/components/typst/grammar.json +81 -0
- package/dist/gramlot.js +2496 -905
- package/dist/gramlot.min.js +109 -28
- package/dist/runtime-notices.json +0 -196
- package/package.json +1 -1
- package/src/binding/ask-dialog.js +1 -1
- package/src/binding/installation.js +5 -6
- package/src/binding/runtime.js +4 -2
- package/src/bootstrap.d.ts +1 -1
- package/src/bootstrap.js +52 -30
- package/src/builder/binding.json +25 -0
- package/src/builder/gramlot-builder.js +16 -3
- package/src/builder/source.js +33 -1
- package/src/collection-artifact.d.ts +11 -0
- package/src/collection-artifact.js +57 -0
- package/src/commands.d.ts +9 -0
- package/src/commands.js +36 -0
- package/src/components/bases.js +1 -1
- package/src/components/border-container.js +26 -1
- package/src/components/buttons.js +84 -161
- package/src/components/choice-editor.js +31 -10
- package/src/components/database-choices.js +110 -0
- package/src/components/inputs.js +15 -2
- package/src/components/layout.js +5 -3
- package/src/components/menus.js +346 -0
- package/src/components/popup.js +15 -2
- package/src/components/registry.js +18 -3
- package/src/components/toolbar-overflow.js +181 -0
- package/src/components/tree.js +14 -4
- package/src/components/windows.js +284 -0
- package/src/filesystem.js +1 -0
- package/src/gramlot.d.ts +2 -0
- package/src/gramlot.js +4 -2
- package/src/handlers/rpc-handler.d.ts +6 -1
- package/src/handlers/rpc-handler.js +7 -2
- package/src/handlers/source-handler.d.ts +2 -1
- package/src/handlers/source-handler.js +10 -1
- package/src/ide-documents.js +1 -1
- package/src/ide-runtime.js +3 -2
- package/src/index-page-styles.js +1 -1
- package/src/index-theme.js +1 -1
- package/src/index.d.ts +5 -0
- package/src/index.js +5 -0
- package/src/renderer/gramlot-html-renderer.js +1 -0
- package/src/renderer/gramlot-renderer.js +13 -3
- package/src/server/gramlot-file-server.d.ts +2 -0
- package/src/server/gramlot-file-server.js +45 -1
- package/src/server/gramlot-server.d.ts +20 -2
- package/src/server/gramlot-server.js +86 -6
- package/src/server/page-base.js +1 -0
- package/src/server/page.d.ts +3 -0
- package/src/view/button.js +47 -3
- package/src/view/controls.js +8 -0
- package/src/view/html.js +1 -0
- package/src/view/menu-command.js +45 -0
- package/src/view/menu.js +87 -0
- package/themes/gramlot-compact/README.md +19 -0
- package/themes/gramlot-compact/theme.css +138 -45
- package/themes/joanna/README.md +19 -0
- package/themes/joanna/theme.css +134 -78
- package/themes/mela/theme.css +184 -0
- package/themes/mimi/README.md +19 -0
- package/themes/mimi/theme.css +133 -77
- package/themes/palettes/README.md +3 -0
- package/themes/palettes/compact.css +86 -0
- package/themes/palettes/joanna.css +86 -0
- package/themes/palettes/mimi.css +86 -0
- package/tools/gramlot-tools-inspector.js +3 -3
- package/dist/components/layout.js +0 -3385
- package/dist/components/typst.js +0 -4
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from gramlot import GramlotCollection
|
|
2
|
+
|
|
3
|
+
mygramlot = GramlotCollection(
|
|
4
|
+
name="tree",
|
|
5
|
+
package=__package__,
|
|
6
|
+
grammar="grammar.json",
|
|
7
|
+
commands="commands.json",
|
|
8
|
+
module="assets/index.js",
|
|
9
|
+
css=(),
|
|
10
|
+
dependencies=(),
|
|
11
|
+
build_id="sha256:851b839f522346e7b92f46d6de8f1645b6409f28c03385b3889cff8f9d772ac3",
|
|
12
|
+
files=("assets/collection.js", "assets/index.js", "commands.json", "grammar.json",),
|
|
13
|
+
)
|
|
@@ -23,6 +23,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
23
23
|
}
|
|
24
24
|
return to;
|
|
25
25
|
};
|
|
26
|
+
var __reExport = (target, mod2, secondTarget) => (__copyProps(target, mod2, "default"), secondTarget && __copyProps(secondTarget, mod2, "default"));
|
|
26
27
|
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
|
|
27
28
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
29
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -52,7 +53,7 @@ var require_conventions = __commonJS({
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
+
function freeze3(object, oc) {
|
|
56
57
|
if (oc === void 0) {
|
|
57
58
|
oc = Object;
|
|
58
59
|
}
|
|
@@ -75,7 +76,7 @@ var require_conventions = __commonJS({
|
|
|
75
76
|
}
|
|
76
77
|
return target;
|
|
77
78
|
}
|
|
78
|
-
var HTML_BOOLEAN_ATTRIBUTES =
|
|
79
|
+
var HTML_BOOLEAN_ATTRIBUTES = freeze3({
|
|
79
80
|
allowfullscreen: true,
|
|
80
81
|
async: true,
|
|
81
82
|
autofocus: true,
|
|
@@ -104,7 +105,7 @@ var require_conventions = __commonJS({
|
|
|
104
105
|
function isHTMLBooleanAttribute(name) {
|
|
105
106
|
return hasOwn(HTML_BOOLEAN_ATTRIBUTES, name.toLowerCase());
|
|
106
107
|
}
|
|
107
|
-
var HTML_VOID_ELEMENTS =
|
|
108
|
+
var HTML_VOID_ELEMENTS = freeze3({
|
|
108
109
|
area: true,
|
|
109
110
|
base: true,
|
|
110
111
|
br: true,
|
|
@@ -123,7 +124,7 @@ var require_conventions = __commonJS({
|
|
|
123
124
|
function isHTMLVoidElement(tagName) {
|
|
124
125
|
return hasOwn(HTML_VOID_ELEMENTS, tagName.toLowerCase());
|
|
125
126
|
}
|
|
126
|
-
var HTML_RAW_TEXT_ELEMENTS =
|
|
127
|
+
var HTML_RAW_TEXT_ELEMENTS = freeze3({
|
|
127
128
|
script: false,
|
|
128
129
|
style: false,
|
|
129
130
|
textarea: true,
|
|
@@ -143,7 +144,7 @@ var require_conventions = __commonJS({
|
|
|
143
144
|
function hasDefaultHTMLNamespace(mimeType) {
|
|
144
145
|
return isHTMLMimeType(mimeType) || mimeType === MIME_TYPE.XML_XHTML_APPLICATION;
|
|
145
146
|
}
|
|
146
|
-
var MIME_TYPE =
|
|
147
|
+
var MIME_TYPE = freeze3({
|
|
147
148
|
/**
|
|
148
149
|
* `text/html`, the only mime type that triggers treating an XML document as HTML.
|
|
149
150
|
*
|
|
@@ -196,7 +197,7 @@ var require_conventions = __commonJS({
|
|
|
196
197
|
function isValidMimeType(mimeType) {
|
|
197
198
|
return _MIME_TYPES.indexOf(mimeType) > -1;
|
|
198
199
|
}
|
|
199
|
-
var NAMESPACE =
|
|
200
|
+
var NAMESPACE = freeze3({
|
|
200
201
|
/**
|
|
201
202
|
* The XHTML namespace.
|
|
202
203
|
*
|
|
@@ -224,7 +225,7 @@ var require_conventions = __commonJS({
|
|
|
224
225
|
});
|
|
225
226
|
exports.assign = assign;
|
|
226
227
|
exports.find = find;
|
|
227
|
-
exports.freeze =
|
|
228
|
+
exports.freeze = freeze3;
|
|
228
229
|
exports.HTML_BOOLEAN_ATTRIBUTES = HTML_BOOLEAN_ATTRIBUTES;
|
|
229
230
|
exports.HTML_RAW_TEXT_ELEMENTS = HTML_RAW_TEXT_ELEMENTS;
|
|
230
231
|
exports.HTML_VOID_ELEMENTS = HTML_VOID_ELEMENTS;
|
|
@@ -887,12 +888,12 @@ var require_dom = __commonJS({
|
|
|
887
888
|
i++;
|
|
888
889
|
}
|
|
889
890
|
}
|
|
890
|
-
function _nnmBucket(map, namespaceURI,
|
|
891
|
+
function _nnmBucket(map, namespaceURI, create3) {
|
|
891
892
|
if (!namespaceURI) {
|
|
892
893
|
return map._noNsIndex;
|
|
893
894
|
}
|
|
894
895
|
var bucket = map._nsIndex[namespaceURI];
|
|
895
|
-
if (!bucket &&
|
|
896
|
+
if (!bucket && create3) {
|
|
896
897
|
bucket = map._nsIndex[namespaceURI] = /* @__PURE__ */ Object.create(null);
|
|
897
898
|
}
|
|
898
899
|
return bucket;
|
|
@@ -3278,15 +3279,15 @@ var require_dom = __commonJS({
|
|
|
3278
3279
|
var require_entities = __commonJS({
|
|
3279
3280
|
"node_modules/@xmldom/xmldom/lib/entities.js"(exports) {
|
|
3280
3281
|
"use strict";
|
|
3281
|
-
var
|
|
3282
|
-
exports.XML_ENTITIES =
|
|
3282
|
+
var freeze3 = require_conventions().freeze;
|
|
3283
|
+
exports.XML_ENTITIES = freeze3({
|
|
3283
3284
|
amp: "&",
|
|
3284
3285
|
apos: "'",
|
|
3285
3286
|
gt: ">",
|
|
3286
3287
|
lt: "<",
|
|
3287
3288
|
quot: '"'
|
|
3288
3289
|
});
|
|
3289
|
-
exports.HTML_ENTITIES =
|
|
3290
|
+
exports.HTML_ENTITIES = freeze3({
|
|
3290
3291
|
Aacute: "\xC1",
|
|
3291
3292
|
aacute: "\xE1",
|
|
3292
3293
|
Abreve: "\u0102",
|
|
@@ -8491,151 +8492,22 @@ function createDOMPurify() {
|
|
|
8491
8492
|
}
|
|
8492
8493
|
var purify_default = createDOMPurify();
|
|
8493
8494
|
|
|
8494
|
-
//
|
|
8495
|
-
var
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
"font-face-format",
|
|
8503
|
-
"font-face-name",
|
|
8504
|
-
"missing-glyph"
|
|
8505
|
-
]);
|
|
8506
|
-
function webcomponentCode(attrs) {
|
|
8507
|
-
const code = attrs.code;
|
|
8508
|
-
if (typeof code !== "string" || NAME.exec(code)?.[0] !== code || !code.includes("-") || RESERVED.has(code)) {
|
|
8509
|
-
throw new TypeError("webcomponent: code must be a literal custom-element name");
|
|
8510
|
-
}
|
|
8511
|
-
return code;
|
|
8512
|
-
}
|
|
8513
|
-
|
|
8514
|
-
// src/components/registry.js
|
|
8515
|
-
function freeze3(value) {
|
|
8516
|
-
for (const child of Object.values(value)) if (child && typeof child === "object") freeze3(child);
|
|
8517
|
-
return Object.freeze(value);
|
|
8518
|
-
}
|
|
8519
|
-
function annotation(parameter) {
|
|
8520
|
-
if (typeof parameter.dtype !== "string" && !Array.isArray(parameter.dtype)) throw new TypeError("Component parameter requires dtype");
|
|
8521
|
-
const alternatives = (Array.isArray(parameter.dtype) ? parameter.dtype : [parameter.dtype]).map((dtype) => ({ kind: "dtype", dtype }));
|
|
8522
|
-
if (parameter.nullable) alternatives.push({ kind: "dtype", dtype: "NN" });
|
|
8523
|
-
if (parameter.binding && parameter.dtype !== "T") alternatives.push({
|
|
8524
|
-
kind: "annotated",
|
|
8525
|
-
base: { kind: "dtype", dtype: "T" },
|
|
8526
|
-
metadata: [{ kind: "regex", pattern: "^[\\^=].+", flags: 0 }]
|
|
8527
|
-
});
|
|
8528
|
-
return alternatives.length === 1 ? alternatives[0] : { kind: "union", items: alternatives };
|
|
8529
|
-
}
|
|
8530
|
-
function defineComponent({ name, tag: tag2, base, mixins = [], parameters: parameters2 = {}, subTags = "", presentationDefaults = [], dataScope = false, command = false, childParameters = {}, sourceContext = false, bagStore = false, dragSource = false, implementation }) {
|
|
8531
|
-
webcomponentCode({ code: tag2 });
|
|
8532
|
-
if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(name)) throw new TypeError("Invalid component authoring name");
|
|
8533
|
-
const effective = { ...base.parameters };
|
|
8534
|
-
for (const mixin of mixins) {
|
|
8535
|
-
for (const [key, spec] of Object.entries(mixin.parameters)) {
|
|
8536
|
-
if (Object.hasOwn(effective, key)) throw new Error(`Duplicate mixin parameter: ${key}`);
|
|
8537
|
-
effective[key] = spec;
|
|
8538
|
-
}
|
|
8539
|
-
}
|
|
8540
|
-
Object.assign(effective, parameters2);
|
|
8541
|
-
for (const spec of Object.values(effective)) annotation(spec);
|
|
8542
|
-
return Object.freeze({
|
|
8543
|
-
name,
|
|
8544
|
-
tag: tag2,
|
|
8545
|
-
base,
|
|
8546
|
-
subTags,
|
|
8547
|
-
presentationDefaults: Object.freeze([...presentationDefaults]),
|
|
8548
|
-
dataScope,
|
|
8549
|
-
command,
|
|
8550
|
-
bagStore,
|
|
8551
|
-
mixins: Object.freeze([...mixins]),
|
|
8552
|
-
parameters: freeze3(structuredClone(effective)),
|
|
8553
|
-
childParameters: freeze3(structuredClone(childParameters)),
|
|
8554
|
-
sourceContext,
|
|
8555
|
-
dragSource,
|
|
8556
|
-
implementation
|
|
8557
|
-
});
|
|
8558
|
-
}
|
|
8559
|
-
var ComponentCollection = class {
|
|
8560
|
-
#classes = /* @__PURE__ */ new WeakMap();
|
|
8561
|
-
constructor({ name, components }) {
|
|
8562
|
-
this.name = name;
|
|
8563
|
-
this.components = Object.freeze([...components]);
|
|
8564
|
-
const names = /* @__PURE__ */ new Set(), tags = /* @__PURE__ */ new Set();
|
|
8565
|
-
for (const component of components) {
|
|
8566
|
-
if (names.has(component.name.toLowerCase()) || tags.has(component.tag)) {
|
|
8567
|
-
throw new Error(`Duplicate component: ${component.name}`);
|
|
8568
|
-
}
|
|
8569
|
-
names.add(component.name.toLowerCase());
|
|
8570
|
-
tags.add(component.tag);
|
|
8571
|
-
}
|
|
8572
|
-
}
|
|
8573
|
-
/** Same JSON consumed by Python and JavaScript Builders. */
|
|
8574
|
-
toDocument() {
|
|
8575
|
-
return {
|
|
8576
|
-
document_format: { name: "builder_grammar", version: "1.1" },
|
|
8577
|
-
grammar: { name: this.name, version: null, title: this.name, description: null },
|
|
8578
|
-
abstracts: {},
|
|
8579
|
-
elements: Object.fromEntries(this.components.map((component) => [component.name, {
|
|
8580
|
-
doc: null,
|
|
8581
|
-
sub_tags: component.subTags,
|
|
8582
|
-
parent_tags: null,
|
|
8583
|
-
inherits_from: null,
|
|
8584
|
-
ns: null,
|
|
8585
|
-
node_label: null,
|
|
8586
|
-
collection_key: null,
|
|
8587
|
-
attributes: {
|
|
8588
|
-
parameters: [
|
|
8589
|
-
...Object.entries(component.parameters).map(([name, spec]) => ({
|
|
8590
|
-
name,
|
|
8591
|
-
kind: "keyword_only",
|
|
8592
|
-
role: "attribute",
|
|
8593
|
-
annotation: annotation(spec),
|
|
8594
|
-
has_default: true,
|
|
8595
|
-
default: spec.default ?? null
|
|
8596
|
-
})),
|
|
8597
|
-
{
|
|
8598
|
-
name: "attr",
|
|
8599
|
-
kind: "var_keyword",
|
|
8600
|
-
role: "attribute",
|
|
8601
|
-
annotation: { kind: "any" },
|
|
8602
|
-
has_default: false
|
|
8603
|
-
}
|
|
8604
|
-
],
|
|
8605
|
-
accepts_var_keyword: true,
|
|
8606
|
-
accepts_var_positional: false
|
|
8607
|
-
},
|
|
8608
|
-
_meta: { render_tag: component.tag, gramlot_component: {
|
|
8609
|
-
parameters: structuredClone(component.parameters),
|
|
8610
|
-
presentationDefaults: [...component.presentationDefaults],
|
|
8611
|
-
dataScope: component.dataScope,
|
|
8612
|
-
command: component.command,
|
|
8613
|
-
...Object.keys(component.childParameters).length ? { childParameters: structuredClone(component.childParameters) } : {},
|
|
8614
|
-
...component.sourceContext ? { sourceContext: true } : {},
|
|
8615
|
-
...component.dragSource ? { dragSource: true } : {},
|
|
8616
|
-
...component.bagStore ? { bagStore: true } : {}
|
|
8617
|
-
} }
|
|
8618
|
-
}]))
|
|
8619
|
-
};
|
|
8620
|
-
}
|
|
8621
|
-
/** Register once per document realm, only when the collection is activated. */
|
|
8622
|
-
register(window2) {
|
|
8623
|
-
if (this.#classes.has(window2)) return;
|
|
8624
|
-
const classes2 = [];
|
|
8625
|
-
for (const component of this.components) {
|
|
8626
|
-
if (window2.customElements.get(component.tag)) throw new Error(`Custom element already registered: ${component.tag}`);
|
|
8627
|
-
let Base = component.base(window2.HTMLElement);
|
|
8628
|
-
for (const mixin of component.mixins) Base = mixin(Base);
|
|
8629
|
-
const Class = component.implementation(Base);
|
|
8630
|
-
Object.defineProperty(Class, "gramlotComponent", { value: component });
|
|
8631
|
-
classes2.push([component.tag, Class]);
|
|
8632
|
-
}
|
|
8633
|
-
for (const [tag2, Class] of classes2) window2.customElements.define(tag2, Class);
|
|
8634
|
-
this.#classes.set(window2, classes2);
|
|
8635
|
-
}
|
|
8636
|
-
};
|
|
8495
|
+
// collection-authoring:@gramlot/gramlot/components
|
|
8496
|
+
var components_exports = {};
|
|
8497
|
+
__export(components_exports, {
|
|
8498
|
+
defineCollection: () => defineCollection
|
|
8499
|
+
});
|
|
8500
|
+
__reExport(components_exports, components_star);
|
|
8501
|
+
import * as components_star from "@gramlot/gramlot/components";
|
|
8502
|
+
import { defineCollection as create2 } from "@gramlot/gramlot/components";
|
|
8637
8503
|
function defineCollection(options) {
|
|
8638
|
-
|
|
8504
|
+
if (options.name !== "tree") throw new Error("Unexpected bundled collection");
|
|
8505
|
+
const css = [], assets = {};
|
|
8506
|
+
options.css?.forEach((url, index) => {
|
|
8507
|
+
url.href = css[index].href;
|
|
8508
|
+
});
|
|
8509
|
+
for (const [key, url] of Object.entries(options.assets ?? {})) url.href = assets[key].href;
|
|
8510
|
+
return create2({ ...options, css, assets });
|
|
8639
8511
|
}
|
|
8640
8512
|
|
|
8641
8513
|
// src/components/parameters.js
|
|
@@ -11014,11 +10886,11 @@ var MAX_POWER = 1e6;
|
|
|
11014
10886
|
var NE = -7;
|
|
11015
10887
|
var PE = 21;
|
|
11016
10888
|
var STRICT = false;
|
|
11017
|
-
var
|
|
11018
|
-
var INVALID =
|
|
10889
|
+
var NAME = "[big.js] ";
|
|
10890
|
+
var INVALID = NAME + "Invalid ";
|
|
11019
10891
|
var INVALID_DP = INVALID + "decimal places";
|
|
11020
10892
|
var INVALID_RM = INVALID + "rounding mode";
|
|
11021
|
-
var DIV_BY_ZERO =
|
|
10893
|
+
var DIV_BY_ZERO = NAME + "Division by zero";
|
|
11022
10894
|
var P2 = {};
|
|
11023
10895
|
var UNDEFINED = void 0;
|
|
11024
10896
|
var NUMERIC = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
|
|
@@ -11384,7 +11256,7 @@ P2.sqrt = function() {
|
|
|
11384
11256
|
var r, c, t, x = this, Big2 = x.constructor, s = x.s, e = x.e, half = new Big2("0.5");
|
|
11385
11257
|
if (!x.c[0]) return new Big2(x);
|
|
11386
11258
|
if (s < 0) {
|
|
11387
|
-
throw Error(
|
|
11259
|
+
throw Error(NAME + "No square root");
|
|
11388
11260
|
}
|
|
11389
11261
|
s = Math.sqrt(+stringify(x, true, true));
|
|
11390
11262
|
if (s === 0 || s === 1 / 0) {
|
|
@@ -11464,7 +11336,7 @@ P2[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = P2.toJSON = P2.to
|
|
|
11464
11336
|
P2.toNumber = function() {
|
|
11465
11337
|
var n = +stringify(this, true, true);
|
|
11466
11338
|
if (this.constructor.strict === true && !this.eq(n.toString())) {
|
|
11467
|
-
throw Error(
|
|
11339
|
+
throw Error(NAME + "Imprecise conversion");
|
|
11468
11340
|
}
|
|
11469
11341
|
return n;
|
|
11470
11342
|
};
|
|
@@ -11482,7 +11354,7 @@ P2.toPrecision = function(sd, rm) {
|
|
|
11482
11354
|
P2.valueOf = function() {
|
|
11483
11355
|
var x = this, Big2 = x.constructor;
|
|
11484
11356
|
if (Big2.strict === true) {
|
|
11485
|
-
throw Error(
|
|
11357
|
+
throw Error(NAME + "valueOf disallowed");
|
|
11486
11358
|
}
|
|
11487
11359
|
return stringify(x, x.e <= Big2.NE || x.e >= Big2.PE, true);
|
|
11488
11360
|
};
|
|
@@ -17818,7 +17690,7 @@ function pythonRegexPattern(pattern, flags) {
|
|
|
17818
17690
|
}
|
|
17819
17691
|
return result;
|
|
17820
17692
|
}
|
|
17821
|
-
function
|
|
17693
|
+
function annotation(desc, path, nested = false, customTypes = null) {
|
|
17822
17694
|
if (desc === null) return null;
|
|
17823
17695
|
exactKeys(desc, ["kind", "dtype", "module", "name", "origin", "arguments", "items", "values", "base", "metadata", "pattern", "flags", "ge", "le", "gt", "lt", "value"], ["kind"], path);
|
|
17824
17696
|
switch (desc.kind) {
|
|
@@ -17857,7 +17729,7 @@ function annotation2(desc, path, nested = false, customTypes = null) {
|
|
|
17857
17729
|
}
|
|
17858
17730
|
case "union": {
|
|
17859
17731
|
if (!Array.isArray(desc.items) || !desc.items.length) fail(path, "union items must be non-empty");
|
|
17860
|
-
const items = desc.items.map((v, i) =>
|
|
17732
|
+
const items = desc.items.map((v, i) => annotation(v, `${path}.items[${i}]`, true, customTypes));
|
|
17861
17733
|
return { ...desc, items, inputConstraint: items.some((x) => x.inputConstraint), test: (v) => items.some((x) => x.test && x.test(v)) };
|
|
17862
17734
|
}
|
|
17863
17735
|
case "literal":
|
|
@@ -17867,8 +17739,8 @@ function annotation2(desc, path, nested = false, customTypes = null) {
|
|
|
17867
17739
|
case "annotated": {
|
|
17868
17740
|
if (!Array.isArray(desc.metadata)) fail(path, "annotated metadata must be an array");
|
|
17869
17741
|
if (desc.metadata.some((v) => !["regex", "range", "value"].includes(v?.kind))) fail(path, "unsupported annotation metadata kind");
|
|
17870
|
-
const base =
|
|
17871
|
-
const metadata = desc.metadata.map((v, i) =>
|
|
17742
|
+
const base = annotation(desc.base, `${path}.base`, true, customTypes);
|
|
17743
|
+
const metadata = desc.metadata.map((v, i) => annotation(v, `${path}.metadata[${i}]`, true, customTypes));
|
|
17872
17744
|
return { ...desc, base, metadata, inputConstraint: base.inputConstraint, test: (v) => base.test(v) && metadata.every((x) => !x.test || x.test(v)) };
|
|
17873
17745
|
}
|
|
17874
17746
|
case "range": {
|
|
@@ -17900,12 +17772,12 @@ function annotation2(desc, path, nested = false, customTypes = null) {
|
|
|
17900
17772
|
jsonValue(desc.value, `${path}.value`);
|
|
17901
17773
|
return { ...desc };
|
|
17902
17774
|
case "generic": {
|
|
17903
|
-
const origin =
|
|
17775
|
+
const origin = annotation(desc.origin, `${path}.origin`, true, customTypes);
|
|
17904
17776
|
if (desc.origin?.kind !== "type" || desc.origin.module !== "builtins" || !["list", "dict", "tuple", "set"].includes(desc.origin.name)) {
|
|
17905
17777
|
fail(path, "only list, dict, tuple and set generic origins are supported");
|
|
17906
17778
|
}
|
|
17907
17779
|
if (!Array.isArray(desc.arguments)) fail(path, "generic arguments must be an array");
|
|
17908
|
-
const args = desc.arguments.map((v, i) =>
|
|
17780
|
+
const args = desc.arguments.map((v, i) => annotation(v, `${path}.arguments[${i}]`, true, customTypes));
|
|
17909
17781
|
return { ...desc, origin, arguments: args, inputConstraint: args.some((x) => x.inputConstraint), test: (v) => origin.test(v) && genericItems(desc.origin, args, v) };
|
|
17910
17782
|
}
|
|
17911
17783
|
case "arguments":
|
|
@@ -17990,7 +17862,7 @@ function parameters(value, path, customTypes) {
|
|
|
17990
17862
|
if (p.has_default) jsonValue(p.default, `${pp}.default`);
|
|
17991
17863
|
foundVarKeyword ||= p.kind === "var_keyword";
|
|
17992
17864
|
foundVarPositional ||= p.kind === "var_positional";
|
|
17993
|
-
return { ...p, annotation:
|
|
17865
|
+
return { ...p, annotation: annotation(p.annotation, `${pp}.annotation`, false, customTypes) };
|
|
17994
17866
|
});
|
|
17995
17867
|
if (foundVarKeyword !== value.accepts_var_keyword || foundVarPositional !== value.accepts_var_positional) {
|
|
17996
17868
|
fail(path, "variadic summary flags do not match parameters");
|
|
@@ -18132,7 +18004,7 @@ var CustomTypes = class _CustomTypes {
|
|
|
18132
18004
|
}
|
|
18133
18005
|
jsonValue(definition, `custom_types.${name}`);
|
|
18134
18006
|
const copy = structuredClone(definition);
|
|
18135
|
-
const compiled =
|
|
18007
|
+
const compiled = annotation(copy, `custom_types.${name}`);
|
|
18136
18008
|
const reference = Object.freeze({ kind: "custom", name });
|
|
18137
18009
|
Object.defineProperty(this, name, { value: reference, enumerable: true });
|
|
18138
18010
|
this.#definitions.set(name, copy);
|
|
@@ -24149,7 +24021,7 @@ BuilderBase.registerBuilder(SvgBuilder);
|
|
|
24149
24021
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
24150
24022
|
|
|
24151
24023
|
// src/components/tree.js
|
|
24152
|
-
var Tree = defineComponent({
|
|
24024
|
+
var Tree = (0, components_exports.defineComponent)({
|
|
24153
24025
|
name: "tree",
|
|
24154
24026
|
tag: "gramlot-tree",
|
|
24155
24027
|
base: Container,
|
|
@@ -24194,7 +24066,7 @@ var Tree = defineComponent({
|
|
|
24194
24066
|
style.textContent = `
|
|
24195
24067
|
.control-box{overflow:auto;padding:4px;min-height:32px}
|
|
24196
24068
|
ul{list-style:none;margin:0;padding:0} ul ul{padding-inline-start:20px}
|
|
24197
|
-
.row{display:flex;align-items:center;min-height:var(--gramlot-tree-row-height,28px);gap:
|
|
24069
|
+
.row{display:flex;align-items:center;min-height:var(--gramlot-tree-row-height,28px);gap:2px;border-radius:3px;cursor:default}
|
|
24198
24070
|
.row:hover{background:var(--gramlot-tree-hover-background,var(--gramlot-field-readonly-background,#f2f4f7))}
|
|
24199
24071
|
.canBeDropped{outline:2px solid var(--gramlot-brand-blue,#3766b5);outline-offset:-2px}
|
|
24200
24072
|
.cannotBeDropped{outline:2px dashed currentColor;outline-offset:-2px}.draggedItem{opacity:.75}
|
|
@@ -24202,8 +24074,11 @@ var Tree = defineComponent({
|
|
|
24202
24074
|
color:var(--gramlot-tree-selected-color,#214f91)}
|
|
24203
24075
|
[role=treeitem]:focus{outline:none}
|
|
24204
24076
|
[role=treeitem]:focus-visible>.row{outline:2px solid var(--gramlot-brand-blue,#3766b5);outline-offset:-2px}
|
|
24205
|
-
button{border:0;background:transparent;color:inherit;width:
|
|
24206
|
-
.
|
|
24077
|
+
button{border:0;background:transparent;color:inherit;width:max(20px,var(--gramlot-touch-target,0px));height:24px;padding:0;font:inherit;cursor:pointer}
|
|
24078
|
+
.expander{display:grid;place-items:center;flex:none}
|
|
24079
|
+
.expander svg{display:block;width:14px;height:14px;pointer-events:none}
|
|
24080
|
+
[aria-expanded=true]>.row>.expander svg{transform:rotate(90deg)}
|
|
24081
|
+
.spacer{width:max(20px,var(--gramlot-touch-target,0px));flex:none}.caption{min-width:0;overflow-wrap:anywhere}
|
|
24207
24082
|
.icon{width:16px;height:16px;flex:none;background:currentColor;opacity:.7;mask:center/contain no-repeat;
|
|
24208
24083
|
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")}
|
|
24209
24084
|
.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")}
|
|
@@ -24316,6 +24191,19 @@ var Tree = defineComponent({
|
|
|
24316
24191
|
expander.className = "expander";
|
|
24317
24192
|
expander.type = "button";
|
|
24318
24193
|
expander.tabIndex = -1;
|
|
24194
|
+
const chevron = this.ownerDocument.createElementNS(SVG_NS, "svg");
|
|
24195
|
+
chevron.setAttribute("viewBox", "0 0 24 24");
|
|
24196
|
+
chevron.setAttribute("aria-hidden", "true");
|
|
24197
|
+
chevron.setAttribute("focusable", "false");
|
|
24198
|
+
const chevronPath = this.ownerDocument.createElementNS(SVG_NS, "path");
|
|
24199
|
+
chevronPath.setAttribute("d", "m9 5 7 7-7 7");
|
|
24200
|
+
chevronPath.setAttribute("fill", "none");
|
|
24201
|
+
chevronPath.setAttribute("stroke", "currentColor");
|
|
24202
|
+
chevronPath.setAttribute("stroke-width", "1.8");
|
|
24203
|
+
chevronPath.setAttribute("stroke-linecap", "round");
|
|
24204
|
+
chevronPath.setAttribute("stroke-linejoin", "round");
|
|
24205
|
+
chevron.append(chevronPath);
|
|
24206
|
+
expander.append(chevron);
|
|
24319
24207
|
expander.addEventListener("click", (event) => {
|
|
24320
24208
|
event.stopPropagation();
|
|
24321
24209
|
toggle();
|
|
@@ -24415,7 +24303,6 @@ var Tree = defineComponent({
|
|
|
24415
24303
|
entry.classList.toggle("closed", !opened);
|
|
24416
24304
|
icon.classList.toggle("opened-icon", opened);
|
|
24417
24305
|
icon.setAttribute("part", `icon branch-icon ${opened ? "opened-icon" : "closed-icon"}`);
|
|
24418
|
-
expander.textContent = opened ? "\u25BE" : "\u25B8";
|
|
24419
24306
|
group.hidden = !opened;
|
|
24420
24307
|
present();
|
|
24421
24308
|
};
|