@gramlot/gramlot 0.2.4 → 0.2.6
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/gramlot.d.ts +8 -0
- package/dist/gramlot.js +287 -132
- package/package.json +4 -4
- package/src/adapters/file-host.d.ts +29 -0
- package/src/adapters/file-host.js +18 -4
- package/src/adapters/host.d.ts +101 -0
- package/src/adapters/host.js +9 -0
- package/src/adapters/index.d.ts +13 -0
- package/src/adapters/index.js +7 -0
- package/src/adapters/page.d.ts +33 -0
- package/src/adapters/page.js +6 -0
- package/src/adapters/resources.d.ts +28 -0
- package/src/adapters/resources.js +3 -0
- package/src/binding/inline.js +1 -1
- package/src/binding/logic.js +2 -2
- package/src/bootstrap.d.ts +48 -0
- package/src/bootstrap.js +6 -0
- package/src/builder/gramlot-builder.d.ts +50 -0
- package/src/builder/gramlot-builder.js +6 -0
- package/src/dom.d.ts +25 -0
- package/src/gramlot.d.ts +99 -0
- package/src/gramlot.js +8 -0
- package/src/index.d.ts +23 -0
- package/src/index.js +11 -0
- package/src/inout.d.ts +45 -0
- package/src/inout.js +135 -0
- package/src/references.d.ts +33 -0
- package/src/references.js +6 -1
- package/src/renderer/gramlot-html-renderer.d.ts +37 -0
- package/src/renderer/gramlot-html-renderer.js +6 -0
- package/src/renderer/gramlot-renderer.d.ts +75 -0
- package/src/renderer/gramlot-renderer.js +6 -0
- package/src/renderer/gramlot-svg-renderer.d.ts +27 -0
- package/src/renderer/gramlot-svg-renderer.js +6 -0
- package/src/transport.d.ts +34 -0
- package/src/transport.js +7 -1
package/dist/gramlot.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/* @ts-self-types="./gramlot.d.ts" */
|
|
2
|
+
/**
|
|
3
|
+
* The Gramlot browser runtime as one ES module: the same exports as the `@gramlot/gramlot` entry
|
|
4
|
+
* point (`Gramlot`, `PageBootstrap`, the builder, the renderers, `Bag` and the rest), bundled with
|
|
5
|
+
* its dependencies.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
1
9
|
var __create = Object.create;
|
|
2
10
|
var __defProp = Object.defineProperty;
|
|
3
11
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -64,13 +72,13 @@ var require_conventions = __commonJS({
|
|
|
64
72
|
function hasOwn(object, key) {
|
|
65
73
|
return Object.prototype.hasOwnProperty.call(object, key);
|
|
66
74
|
}
|
|
67
|
-
function assign(target,
|
|
75
|
+
function assign(target, source2) {
|
|
68
76
|
if (target === null || typeof target !== "object") {
|
|
69
77
|
throw new TypeError("target is not an object");
|
|
70
78
|
}
|
|
71
|
-
for (var key in
|
|
72
|
-
if (hasOwn(
|
|
73
|
-
target[key] =
|
|
79
|
+
for (var key in source2) {
|
|
80
|
+
if (hasOwn(source2, key)) {
|
|
81
|
+
target[key] = source2[key];
|
|
74
82
|
}
|
|
75
83
|
}
|
|
76
84
|
return target;
|
|
@@ -5442,18 +5450,18 @@ var require_sax = __commonJS({
|
|
|
5442
5450
|
function XMLReader() {
|
|
5443
5451
|
}
|
|
5444
5452
|
XMLReader.prototype = {
|
|
5445
|
-
parse: function(
|
|
5453
|
+
parse: function(source2, defaultNSMap, entityMap) {
|
|
5446
5454
|
var domBuilder = this.domBuilder;
|
|
5447
5455
|
domBuilder.startDocument();
|
|
5448
5456
|
_copy(defaultNSMap, defaultNSMap = /* @__PURE__ */ Object.create(null));
|
|
5449
|
-
parse2(
|
|
5457
|
+
parse2(source2, defaultNSMap, entityMap, domBuilder, this.errorHandler);
|
|
5450
5458
|
domBuilder.endDocument();
|
|
5451
5459
|
}
|
|
5452
5460
|
};
|
|
5453
5461
|
var ENTITY_REG = /&#?\w+;?/g;
|
|
5454
|
-
function parse2(
|
|
5462
|
+
function parse2(source2, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
|
|
5455
5463
|
var isHTML = isHTMLMimeType(domBuilder.mimeType);
|
|
5456
|
-
if (
|
|
5464
|
+
if (source2.indexOf(g.UNICODE_REPLACEMENT_CHARACTER) >= 0) {
|
|
5457
5465
|
errorHandler.warning("Unicode replacement character detected, source encoding issues?");
|
|
5458
5466
|
}
|
|
5459
5467
|
function fixedFromCharCode(code) {
|
|
@@ -5488,7 +5496,7 @@ var require_sax = __commonJS({
|
|
|
5488
5496
|
}
|
|
5489
5497
|
function appendText(end2) {
|
|
5490
5498
|
if (end2 > start) {
|
|
5491
|
-
var xt =
|
|
5499
|
+
var xt = source2.substring(start, end2).replace(ENTITY_REG, entityReplacer);
|
|
5492
5500
|
locator && position(start);
|
|
5493
5501
|
domBuilder.characters(xt, 0, end2 - start);
|
|
5494
5502
|
start = end2;
|
|
@@ -5499,7 +5507,7 @@ var require_sax = __commonJS({
|
|
|
5499
5507
|
var linePattern = /\r\n?|\n|$/g;
|
|
5500
5508
|
var locator = domBuilder.locator;
|
|
5501
5509
|
function position(p, m) {
|
|
5502
|
-
while (p >= lineEnd && (m = linePattern.exec(
|
|
5510
|
+
while (p >= lineEnd && (m = linePattern.exec(source2))) {
|
|
5503
5511
|
lineStart = lineEnd;
|
|
5504
5512
|
lineEnd = m.index + m[0].length;
|
|
5505
5513
|
locator.lineNumber++;
|
|
@@ -5511,14 +5519,14 @@ var require_sax = __commonJS({
|
|
|
5511
5519
|
var start = 0;
|
|
5512
5520
|
while (true) {
|
|
5513
5521
|
try {
|
|
5514
|
-
var tagStart =
|
|
5522
|
+
var tagStart = source2.indexOf("<", start);
|
|
5515
5523
|
if (tagStart < 0) {
|
|
5516
5524
|
if (!isHTML && unclosedTags.length > 0) {
|
|
5517
5525
|
return errorHandler.fatalError("unclosed xml tag(s): " + unclosedTags.join(", "));
|
|
5518
5526
|
}
|
|
5519
|
-
if (!
|
|
5527
|
+
if (!source2.substring(start).match(/^\s*$/)) {
|
|
5520
5528
|
var doc = domBuilder.doc;
|
|
5521
|
-
var text = doc.createTextNode(
|
|
5529
|
+
var text = doc.createTextNode(source2.substring(start));
|
|
5522
5530
|
if (doc.documentElement) {
|
|
5523
5531
|
return errorHandler.error("Extra content at the end of the document");
|
|
5524
5532
|
}
|
|
@@ -5528,17 +5536,17 @@ var require_sax = __commonJS({
|
|
|
5528
5536
|
return;
|
|
5529
5537
|
}
|
|
5530
5538
|
if (tagStart > start) {
|
|
5531
|
-
var fromSource =
|
|
5539
|
+
var fromSource = source2.substring(start, tagStart);
|
|
5532
5540
|
if (!isHTML && unclosedTags.length === 0) {
|
|
5533
5541
|
fromSource = fromSource.replace(new RegExp(g.S_OPT.source, "g"), "");
|
|
5534
5542
|
fromSource && errorHandler.error("Unexpected content outside root element: '" + fromSource + "'");
|
|
5535
5543
|
}
|
|
5536
5544
|
appendText(tagStart);
|
|
5537
5545
|
}
|
|
5538
|
-
switch (
|
|
5546
|
+
switch (source2.charAt(tagStart + 1)) {
|
|
5539
5547
|
case "/":
|
|
5540
|
-
var end =
|
|
5541
|
-
var tagNameRaw =
|
|
5548
|
+
var end = source2.indexOf(">", tagStart + 2);
|
|
5549
|
+
var tagNameRaw = source2.substring(tagStart + 2, end > 0 ? end : void 0);
|
|
5542
5550
|
if (!tagNameRaw) {
|
|
5543
5551
|
return errorHandler.fatalError("end tag name missing");
|
|
5544
5552
|
}
|
|
@@ -5589,17 +5597,17 @@ var require_sax = __commonJS({
|
|
|
5589
5597
|
// end element
|
|
5590
5598
|
case "?":
|
|
5591
5599
|
locator && position(tagStart);
|
|
5592
|
-
end = parseProcessingInstruction(
|
|
5600
|
+
end = parseProcessingInstruction(source2, tagStart, domBuilder, errorHandler);
|
|
5593
5601
|
break;
|
|
5594
5602
|
case "!":
|
|
5595
5603
|
locator && position(tagStart);
|
|
5596
|
-
end = parseDoctypeCommentOrCData(
|
|
5604
|
+
end = parseDoctypeCommentOrCData(source2, tagStart, domBuilder, errorHandler, isHTML);
|
|
5597
5605
|
break;
|
|
5598
5606
|
default:
|
|
5599
5607
|
locator && position(tagStart);
|
|
5600
5608
|
var el = new ElementAttributes();
|
|
5601
5609
|
var currentNSMap = parseStack[parseStack.length - 1].currentNSMap;
|
|
5602
|
-
var end = parseElementStartPart(
|
|
5610
|
+
var end = parseElementStartPart(source2, tagStart, el, currentNSMap, entityReplacer, errorHandler, isHTML);
|
|
5603
5611
|
var len = el.length;
|
|
5604
5612
|
if (!el.closed) {
|
|
5605
5613
|
if (isHTML && conventions.isHTMLVoidElement(el.tagName)) {
|
|
@@ -5626,7 +5634,7 @@ var require_sax = __commonJS({
|
|
|
5626
5634
|
}
|
|
5627
5635
|
}
|
|
5628
5636
|
if (isHTML && !el.closed) {
|
|
5629
|
-
end = parseHtmlSpecialContent(
|
|
5637
|
+
end = parseHtmlSpecialContent(source2, end, el.tagName, entityReplacer, domBuilder);
|
|
5630
5638
|
} else {
|
|
5631
5639
|
end++;
|
|
5632
5640
|
}
|
|
@@ -5652,7 +5660,7 @@ var require_sax = __commonJS({
|
|
|
5652
5660
|
t.columnNumber = f.columnNumber;
|
|
5653
5661
|
return t;
|
|
5654
5662
|
}
|
|
5655
|
-
function parseElementStartPart(
|
|
5663
|
+
function parseElementStartPart(source2, start, el, currentNSMap, entityReplacer, errorHandler, isHTML) {
|
|
5656
5664
|
function addAttribute(qname, value2, startIndex) {
|
|
5657
5665
|
if (hasOwn(el.attributeNames, qname)) {
|
|
5658
5666
|
return errorHandler.fatalError("Attribute " + qname + " redefined");
|
|
@@ -5675,14 +5683,14 @@ var require_sax = __commonJS({
|
|
|
5675
5683
|
var p = ++start;
|
|
5676
5684
|
var s = S_TAG;
|
|
5677
5685
|
while (true) {
|
|
5678
|
-
var c =
|
|
5686
|
+
var c = source2.charAt(p);
|
|
5679
5687
|
if (s === S_TAG && c === "<") {
|
|
5680
|
-
throw new Error("unexpected < in tag name: " +
|
|
5688
|
+
throw new Error("unexpected < in tag name: " + source2.slice(start, p));
|
|
5681
5689
|
}
|
|
5682
5690
|
switch (c) {
|
|
5683
5691
|
case "=":
|
|
5684
5692
|
if (s === S_ATTR) {
|
|
5685
|
-
attrName =
|
|
5693
|
+
attrName = source2.slice(start, p);
|
|
5686
5694
|
s = S_EQ;
|
|
5687
5695
|
} else if (s === S_ATTR_SPACE) {
|
|
5688
5696
|
s = S_EQ;
|
|
@@ -5695,19 +5703,19 @@ var require_sax = __commonJS({
|
|
|
5695
5703
|
if (s === S_EQ || s === S_ATTR) {
|
|
5696
5704
|
if (s === S_ATTR) {
|
|
5697
5705
|
errorHandler.warning('attribute value must after "="');
|
|
5698
|
-
attrName =
|
|
5706
|
+
attrName = source2.slice(start, p);
|
|
5699
5707
|
}
|
|
5700
5708
|
start = p + 1;
|
|
5701
|
-
p =
|
|
5709
|
+
p = source2.indexOf(c, start);
|
|
5702
5710
|
if (p > 0) {
|
|
5703
|
-
value =
|
|
5711
|
+
value = source2.slice(start, p);
|
|
5704
5712
|
addAttribute(attrName, value, start - 1);
|
|
5705
5713
|
s = S_ATTR_END;
|
|
5706
5714
|
} else {
|
|
5707
5715
|
throw new Error("attribute value no end '" + c + "' match");
|
|
5708
5716
|
}
|
|
5709
5717
|
} else if (s == S_ATTR_NOQUOT_VALUE) {
|
|
5710
|
-
value =
|
|
5718
|
+
value = source2.slice(start, p);
|
|
5711
5719
|
addAttribute(attrName, value, start);
|
|
5712
5720
|
errorHandler.warning('attribute "' + attrName + '" missed start quot(' + c + ")!!");
|
|
5713
5721
|
start = p + 1;
|
|
@@ -5719,7 +5727,7 @@ var require_sax = __commonJS({
|
|
|
5719
5727
|
case "/":
|
|
5720
5728
|
switch (s) {
|
|
5721
5729
|
case S_TAG:
|
|
5722
|
-
el.setTagName(
|
|
5730
|
+
el.setTagName(source2.slice(start, p));
|
|
5723
5731
|
case S_ATTR_END:
|
|
5724
5732
|
case S_TAG_SPACE:
|
|
5725
5733
|
case S_TAG_CLOSE:
|
|
@@ -5739,13 +5747,13 @@ var require_sax = __commonJS({
|
|
|
5739
5747
|
case "":
|
|
5740
5748
|
errorHandler.error("unexpected end of input");
|
|
5741
5749
|
if (s == S_TAG) {
|
|
5742
|
-
el.setTagName(
|
|
5750
|
+
el.setTagName(source2.slice(start, p));
|
|
5743
5751
|
}
|
|
5744
5752
|
return p;
|
|
5745
5753
|
case ">":
|
|
5746
5754
|
switch (s) {
|
|
5747
5755
|
case S_TAG:
|
|
5748
|
-
el.setTagName(
|
|
5756
|
+
el.setTagName(source2.slice(start, p));
|
|
5749
5757
|
case S_ATTR_END:
|
|
5750
5758
|
case S_TAG_SPACE:
|
|
5751
5759
|
case S_TAG_CLOSE:
|
|
@@ -5754,7 +5762,7 @@ var require_sax = __commonJS({
|
|
|
5754
5762
|
case S_ATTR_NOQUOT_VALUE:
|
|
5755
5763
|
//Compatible state
|
|
5756
5764
|
case S_ATTR:
|
|
5757
|
-
value =
|
|
5765
|
+
value = source2.slice(start, p);
|
|
5758
5766
|
if (value.slice(-1) === "/") {
|
|
5759
5767
|
el.closed = true;
|
|
5760
5768
|
value = value.slice(0, -1);
|
|
@@ -5786,15 +5794,15 @@ var require_sax = __commonJS({
|
|
|
5786
5794
|
if (c <= " ") {
|
|
5787
5795
|
switch (s) {
|
|
5788
5796
|
case S_TAG:
|
|
5789
|
-
el.setTagName(
|
|
5797
|
+
el.setTagName(source2.slice(start, p));
|
|
5790
5798
|
s = S_TAG_SPACE;
|
|
5791
5799
|
break;
|
|
5792
5800
|
case S_ATTR:
|
|
5793
|
-
attrName =
|
|
5801
|
+
attrName = source2.slice(start, p);
|
|
5794
5802
|
s = S_ATTR_SPACE;
|
|
5795
5803
|
break;
|
|
5796
5804
|
case S_ATTR_NOQUOT_VALUE:
|
|
5797
|
-
var value =
|
|
5805
|
+
var value = source2.slice(start, p);
|
|
5798
5806
|
errorHandler.warning('attribute "' + value + '" missed quot(")!!');
|
|
5799
5807
|
addAttribute(attrName, value, start);
|
|
5800
5808
|
case S_ATTR_END:
|
|
@@ -5898,17 +5906,17 @@ var require_sax = __commonJS({
|
|
|
5898
5906
|
return true;
|
|
5899
5907
|
}
|
|
5900
5908
|
}
|
|
5901
|
-
function parseHtmlSpecialContent(
|
|
5909
|
+
function parseHtmlSpecialContent(source2, elStartEnd, tagName, entityReplacer, domBuilder) {
|
|
5902
5910
|
var isEscapableRaw = isHTMLEscapableRawTextElement(tagName);
|
|
5903
5911
|
if (isEscapableRaw || isHTMLRawTextElement(tagName)) {
|
|
5904
5912
|
var closeTag = new RegExp("</" + tagName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + ">", "ig");
|
|
5905
5913
|
closeTag.lastIndex = elStartEnd;
|
|
5906
|
-
var match = closeTag.exec(
|
|
5914
|
+
var match = closeTag.exec(source2);
|
|
5907
5915
|
var elEndStart = match ? match.index : -1;
|
|
5908
5916
|
if (elEndStart < 0) {
|
|
5909
5917
|
return elStartEnd + 1;
|
|
5910
5918
|
}
|
|
5911
|
-
var text =
|
|
5919
|
+
var text = source2.substring(elStartEnd + 1, elEndStart);
|
|
5912
5920
|
if (isEscapableRaw) {
|
|
5913
5921
|
text = text.replace(ENTITY_REG, entityReplacer);
|
|
5914
5922
|
}
|
|
@@ -5917,18 +5925,18 @@ var require_sax = __commonJS({
|
|
|
5917
5925
|
}
|
|
5918
5926
|
return elStartEnd + 1;
|
|
5919
5927
|
}
|
|
5920
|
-
function _copy(
|
|
5921
|
-
for (var n in
|
|
5922
|
-
if (hasOwn(
|
|
5923
|
-
target[n] =
|
|
5928
|
+
function _copy(source2, target) {
|
|
5929
|
+
for (var n in source2) {
|
|
5930
|
+
if (hasOwn(source2, n)) {
|
|
5931
|
+
target[n] = source2[n];
|
|
5924
5932
|
}
|
|
5925
5933
|
}
|
|
5926
5934
|
}
|
|
5927
|
-
function parseUtils(
|
|
5935
|
+
function parseUtils(source2, start) {
|
|
5928
5936
|
var index = start;
|
|
5929
5937
|
function char(n) {
|
|
5930
5938
|
n = n || 0;
|
|
5931
|
-
return
|
|
5939
|
+
return source2.charAt(index + n);
|
|
5932
5940
|
}
|
|
5933
5941
|
function skip(n) {
|
|
5934
5942
|
n = n || 1;
|
|
@@ -5936,7 +5944,7 @@ var require_sax = __commonJS({
|
|
|
5936
5944
|
}
|
|
5937
5945
|
function skipBlanks() {
|
|
5938
5946
|
var blanks = 0;
|
|
5939
|
-
while (index <
|
|
5947
|
+
while (index < source2.length) {
|
|
5940
5948
|
var c = char();
|
|
5941
5949
|
if (c !== " " && c !== "\n" && c !== " " && c !== "\r") {
|
|
5942
5950
|
return blanks;
|
|
@@ -5947,13 +5955,13 @@ var require_sax = __commonJS({
|
|
|
5947
5955
|
return -1;
|
|
5948
5956
|
}
|
|
5949
5957
|
function substringFromIndex() {
|
|
5950
|
-
return
|
|
5958
|
+
return source2.substring(index);
|
|
5951
5959
|
}
|
|
5952
5960
|
function substringStartsWith(text) {
|
|
5953
|
-
return
|
|
5961
|
+
return source2.substring(index, index + text.length) === text;
|
|
5954
5962
|
}
|
|
5955
5963
|
function substringStartsWithCaseInsensitive(text) {
|
|
5956
|
-
return
|
|
5964
|
+
return source2.substring(index, index + text.length).toUpperCase() === text.toUpperCase();
|
|
5957
5965
|
}
|
|
5958
5966
|
function getMatch(args) {
|
|
5959
5967
|
var expr = g.reg("^", args);
|
|
@@ -5971,7 +5979,7 @@ var require_sax = __commonJS({
|
|
|
5971
5979
|
},
|
|
5972
5980
|
getMatch,
|
|
5973
5981
|
getSource: function() {
|
|
5974
|
-
return
|
|
5982
|
+
return source2;
|
|
5975
5983
|
},
|
|
5976
5984
|
skip,
|
|
5977
5985
|
skipBlanks,
|
|
@@ -5994,14 +6002,14 @@ var require_sax = __commonJS({
|
|
|
5994
6002
|
p2.skip(match[0].length);
|
|
5995
6003
|
return match[0];
|
|
5996
6004
|
}
|
|
5997
|
-
var
|
|
6005
|
+
var source2 = p.getSource();
|
|
5998
6006
|
if (p.char() === "[") {
|
|
5999
6007
|
p.skip(1);
|
|
6000
6008
|
var intSubsetStart = p.getIndex();
|
|
6001
|
-
while (p.getIndex() <
|
|
6009
|
+
while (p.getIndex() < source2.length) {
|
|
6002
6010
|
p.skipBlanks();
|
|
6003
6011
|
if (p.char() === "]") {
|
|
6004
|
-
var internalSubset =
|
|
6012
|
+
var internalSubset = source2.substring(intSubsetStart, p.getIndex());
|
|
6005
6013
|
p.skip(1);
|
|
6006
6014
|
return internalSubset;
|
|
6007
6015
|
}
|
|
@@ -6039,8 +6047,8 @@ var require_sax = __commonJS({
|
|
|
6039
6047
|
return errorHandler.fatalError("doctype internal subset is not well-formed, missing ]");
|
|
6040
6048
|
}
|
|
6041
6049
|
}
|
|
6042
|
-
function parseDoctypeCommentOrCData(
|
|
6043
|
-
var p = parseUtils(
|
|
6050
|
+
function parseDoctypeCommentOrCData(source2, start, domBuilder, errorHandler, isHTML) {
|
|
6051
|
+
var p = parseUtils(source2, start);
|
|
6044
6052
|
switch (isHTML ? p.char(2).toUpperCase() : p.char(2)) {
|
|
6045
6053
|
case "-":
|
|
6046
6054
|
var comment = p.getMatch(g.Comment);
|
|
@@ -6131,8 +6139,8 @@ var require_sax = __commonJS({
|
|
|
6131
6139
|
return errorHandler.fatalError('Not well-formed XML starting with "<!" at position ' + start);
|
|
6132
6140
|
}
|
|
6133
6141
|
}
|
|
6134
|
-
function parseProcessingInstruction(
|
|
6135
|
-
var match =
|
|
6142
|
+
function parseProcessingInstruction(source2, start, domBuilder, errorHandler) {
|
|
6143
|
+
var match = source2.substring(start).match(g.PI);
|
|
6136
6144
|
if (!match) {
|
|
6137
6145
|
return errorHandler.fatalError("Invalid processing instruction starting at position " + start);
|
|
6138
6146
|
}
|
|
@@ -6142,7 +6150,7 @@ var require_sax = __commonJS({
|
|
|
6142
6150
|
"processing instruction at position " + start + " is an xml declaration which is only at the start of the document"
|
|
6143
6151
|
);
|
|
6144
6152
|
}
|
|
6145
|
-
if (!g.XMLDecl.test(
|
|
6153
|
+
if (!g.XMLDecl.test(source2.substring(start))) {
|
|
6146
6154
|
return errorHandler.fatalError("xml declaration is not well-formed");
|
|
6147
6155
|
}
|
|
6148
6156
|
}
|
|
@@ -6236,7 +6244,7 @@ var require_dom_parser = __commonJS({
|
|
|
6236
6244
|
this.locator = !!options.locator;
|
|
6237
6245
|
this.xmlns = this.assign(/* @__PURE__ */ Object.create(null), options.xmlns);
|
|
6238
6246
|
}
|
|
6239
|
-
DOMParser4.prototype.parseFromString = function(
|
|
6247
|
+
DOMParser4.prototype.parseFromString = function(source2, mimeType) {
|
|
6240
6248
|
if (!isValidMimeType(mimeType)) {
|
|
6241
6249
|
throw new TypeError('DOMParser.parseFromString: the provided mimeType "' + mimeType + '" is not valid.');
|
|
6242
6250
|
}
|
|
@@ -6264,10 +6272,10 @@ var require_dom_parser = __commonJS({
|
|
|
6264
6272
|
sax2.errorHandler = domBuilder;
|
|
6265
6273
|
sax2.domBuilder = domBuilder;
|
|
6266
6274
|
var isXml = !conventions.isHTMLMimeType(mimeType);
|
|
6267
|
-
if (isXml && typeof
|
|
6275
|
+
if (isXml && typeof source2 !== "string") {
|
|
6268
6276
|
sax2.errorHandler.fatalError("source is not a string");
|
|
6269
6277
|
}
|
|
6270
|
-
sax2.parse(this.normalizeLineEndings(String(
|
|
6278
|
+
sax2.parse(this.normalizeLineEndings(String(source2)), defaultNSMap, entityMap);
|
|
6271
6279
|
if (!domBuilder.doc.documentElement) {
|
|
6272
6280
|
sax2.errorHandler.fatalError("missing root element");
|
|
6273
6281
|
}
|
|
@@ -12832,6 +12840,15 @@ function* serializationNodes(bag, prefix = "") {
|
|
|
12832
12840
|
if (!node.resolver && value instanceof Bag) yield* serializationNodes(value, path);
|
|
12833
12841
|
}
|
|
12834
12842
|
}
|
|
12843
|
+
function xmlDateText(value) {
|
|
12844
|
+
const iso = value.toISOString();
|
|
12845
|
+
const isEpochDate = value.getUTCFullYear() === 1970 && value.getUTCMonth() === 0 && value.getUTCDate() === 1;
|
|
12846
|
+
const isMidnight = value.getUTCHours() === 0 && value.getUTCMinutes() === 0 && value.getUTCSeconds() === 0 && value.getUTCMilliseconds() === 0;
|
|
12847
|
+
if (isMidnight && !isEpochDate) return iso.slice(0, iso.indexOf("T"));
|
|
12848
|
+
const timestamp = iso.replace(/\.000Z$/, "Z");
|
|
12849
|
+
if (isEpochDate && !isMidnight) return timestamp.slice(timestamp.indexOf("T") + 1);
|
|
12850
|
+
return timestamp;
|
|
12851
|
+
}
|
|
12835
12852
|
var Bag = class _Bag {
|
|
12836
12853
|
static tytxSuffix = "X";
|
|
12837
12854
|
/**
|
|
@@ -12839,7 +12856,7 @@ var Bag = class _Bag {
|
|
|
12839
12856
|
*
|
|
12840
12857
|
* @param {Object} [source=null] - Optional dict to initialize from.
|
|
12841
12858
|
*/
|
|
12842
|
-
constructor(
|
|
12859
|
+
constructor(source2 = null) {
|
|
12843
12860
|
this._nodes = new BagNodeContainer();
|
|
12844
12861
|
this._backref = false;
|
|
12845
12862
|
this._parent = null;
|
|
@@ -12848,8 +12865,8 @@ var Bag = class _Bag {
|
|
|
12848
12865
|
this._updSubscribers = {};
|
|
12849
12866
|
this._insSubscribers = {};
|
|
12850
12867
|
this._delSubscribers = {};
|
|
12851
|
-
if (
|
|
12852
|
-
this._loadSource(
|
|
12868
|
+
if (source2) {
|
|
12869
|
+
this._loadSource(source2);
|
|
12853
12870
|
}
|
|
12854
12871
|
}
|
|
12855
12872
|
// -------------------------------------------------------------------------
|
|
@@ -14206,10 +14223,10 @@ var Bag = class _Bag {
|
|
|
14206
14223
|
* @param {boolean} [ignoreNone=false] - Optional extension: preserve existing
|
|
14207
14224
|
* values when the incoming value is null. It is not the mode argument.
|
|
14208
14225
|
*/
|
|
14209
|
-
update(
|
|
14210
|
-
if (!(
|
|
14211
|
-
for (const label in
|
|
14212
|
-
const value =
|
|
14226
|
+
update(source2, mode = null, reason = null, ignoreNone = false) {
|
|
14227
|
+
if (!(source2 instanceof _Bag)) {
|
|
14228
|
+
for (const label in source2) {
|
|
14229
|
+
const value = source2[label];
|
|
14213
14230
|
if (!ignoreNone || value !== null || !this._nodes.has(label)) {
|
|
14214
14231
|
this.setItem(
|
|
14215
14232
|
label,
|
|
@@ -14226,7 +14243,7 @@ var Bag = class _Bag {
|
|
|
14226
14243
|
}
|
|
14227
14244
|
return;
|
|
14228
14245
|
}
|
|
14229
|
-
for (const incoming of [...
|
|
14246
|
+
for (const incoming of [...source2]) {
|
|
14230
14247
|
const label = incoming.label;
|
|
14231
14248
|
const resolver = mode === "static" ? incoming.resolver : null;
|
|
14232
14249
|
const value = resolver ? null : incoming.getValue();
|
|
@@ -14348,13 +14365,13 @@ var Bag = class _Bag {
|
|
|
14348
14365
|
* bag.replace(other);
|
|
14349
14366
|
* // bag now has only 'x' = 10
|
|
14350
14367
|
*/
|
|
14351
|
-
_loadSource(
|
|
14352
|
-
if (
|
|
14368
|
+
_loadSource(source2) {
|
|
14369
|
+
if (source2 == null) return this;
|
|
14353
14370
|
const prepared = this.createChildBag();
|
|
14354
|
-
if (
|
|
14355
|
-
prepared._fillFromBag(
|
|
14356
|
-
} else if (typeof
|
|
14357
|
-
prepared._fillFromDict(
|
|
14371
|
+
if (source2 instanceof _Bag) {
|
|
14372
|
+
prepared._fillFromBag(source2);
|
|
14373
|
+
} else if (typeof source2 === "object" && !Array.isArray(source2)) {
|
|
14374
|
+
prepared._fillFromDict(source2);
|
|
14358
14375
|
} else {
|
|
14359
14376
|
return this;
|
|
14360
14377
|
}
|
|
@@ -14592,6 +14609,7 @@ var Bag = class _Bag {
|
|
|
14592
14609
|
* Serialize Bag to XML format.
|
|
14593
14610
|
*
|
|
14594
14611
|
* All values are converted to strings without type information.
|
|
14612
|
+
* Date values use ISO 8601 text in UTC (date, time, or datetime).
|
|
14595
14613
|
* For type-preserving serialization, use toTytx() instead.
|
|
14596
14614
|
*
|
|
14597
14615
|
* @param {Object} [options={}] - Serialization options.
|
|
@@ -14669,7 +14687,8 @@ ${" ".repeat(depth)}</${tag2}>`;
|
|
|
14669
14687
|
}
|
|
14670
14688
|
return `<${tag2}${attrsStr}></${tag2}>`;
|
|
14671
14689
|
}
|
|
14672
|
-
const
|
|
14690
|
+
const scalar = value instanceof Date && !Number.isNaN(value.getTime()) ? xmlDateText(value) : String(value);
|
|
14691
|
+
const text = this._escapeXml(scalar);
|
|
14673
14692
|
return `<${tag2}${attrsStr}>${text}</${tag2}>`;
|
|
14674
14693
|
}
|
|
14675
14694
|
/**
|
|
@@ -14702,19 +14721,19 @@ ${" ".repeat(depth)}</${tag2}>`;
|
|
|
14702
14721
|
* @param {string} [options.tagAttribute=null] - If set, save XML tag name as this attribute on each node.
|
|
14703
14722
|
* @returns {Bag} Reconstructed Bag hierarchy.
|
|
14704
14723
|
*/
|
|
14705
|
-
static fromXml(
|
|
14724
|
+
static fromXml(source2, options = {}) {
|
|
14706
14725
|
const { tagAttribute = null } = options;
|
|
14707
14726
|
let doc;
|
|
14708
14727
|
if (typeof DOMParser !== "undefined") {
|
|
14709
14728
|
const parser = new DOMParser();
|
|
14710
|
-
doc = parser.parseFromString(
|
|
14729
|
+
doc = parser.parseFromString(source2, "application/xml");
|
|
14711
14730
|
const parseError = doc.querySelector("parsererror");
|
|
14712
14731
|
if (parseError) {
|
|
14713
14732
|
throw new Error(`XML parse error: ${parseError.textContent}`);
|
|
14714
14733
|
}
|
|
14715
14734
|
} else {
|
|
14716
14735
|
const parser = new import_xmldom2.DOMParser();
|
|
14717
|
-
doc = parser.parseFromString(
|
|
14736
|
+
doc = parser.parseFromString(source2, "application/xml");
|
|
14718
14737
|
}
|
|
14719
14738
|
return this._xmlElementToBag(doc.documentElement, tagAttribute);
|
|
14720
14739
|
}
|
|
@@ -14848,14 +14867,14 @@ ${" ".repeat(depth)}</${tag2}>`;
|
|
|
14848
14867
|
* @param {string} [listJoiner=null] - If provided, join string arrays with this separator.
|
|
14849
14868
|
* @returns {Bag} Deserialized Bag.
|
|
14850
14869
|
*/
|
|
14851
|
-
static fromJson(
|
|
14852
|
-
if (typeof
|
|
14853
|
-
|
|
14870
|
+
static fromJson(source2, listJoiner = null) {
|
|
14871
|
+
if (typeof source2 === "string") {
|
|
14872
|
+
source2 = fromTytx(source2);
|
|
14854
14873
|
}
|
|
14855
|
-
if (!Array.isArray(
|
|
14856
|
-
|
|
14874
|
+
if (!Array.isArray(source2) && typeof source2 !== "object") {
|
|
14875
|
+
source2 = { value: source2 };
|
|
14857
14876
|
}
|
|
14858
|
-
return _Bag._fromJsonRecursive(
|
|
14877
|
+
return _Bag._fromJsonRecursive(source2, listJoiner);
|
|
14859
14878
|
}
|
|
14860
14879
|
/**
|
|
14861
14880
|
* Recursively convert JSON data to Bag (internal).
|
|
@@ -15317,8 +15336,8 @@ var SourceBagNode = class extends BagNode {
|
|
|
15317
15336
|
}
|
|
15318
15337
|
};
|
|
15319
15338
|
var SourceBag = class _SourceBag extends Bag {
|
|
15320
|
-
constructor(
|
|
15321
|
-
super(
|
|
15339
|
+
constructor(source2 = null, builder = null) {
|
|
15340
|
+
super(source2);
|
|
15322
15341
|
this._builder = builder;
|
|
15323
15342
|
this._insertingBuilder = null;
|
|
15324
15343
|
}
|
|
@@ -15453,11 +15472,11 @@ function elementCall(builder, target, tag2, onBag) {
|
|
|
15453
15472
|
};
|
|
15454
15473
|
}
|
|
15455
15474
|
function sourceBagFromTytx(payload, builder, { transport = "json" } = {}) {
|
|
15456
|
-
const
|
|
15457
|
-
if (!(
|
|
15475
|
+
const source2 = fromTytx(payload, transport === "json" ? null : transport);
|
|
15476
|
+
if (!(source2 instanceof SourceBag)) {
|
|
15458
15477
|
throw new TypeError("TYTX payload did not decode to SourceBag");
|
|
15459
15478
|
}
|
|
15460
|
-
return
|
|
15479
|
+
return source2.bindBuilder(builder);
|
|
15461
15480
|
}
|
|
15462
15481
|
|
|
15463
15482
|
// node_modules/@genrojs/builders/src/grammar-loader.js
|
|
@@ -15968,8 +15987,8 @@ var RendererBase = class {
|
|
|
15968
15987
|
return this.render(roots[0], expansionOpts);
|
|
15969
15988
|
}
|
|
15970
15989
|
/** Normalize the source before the top-level walk. Identity by default. */
|
|
15971
|
-
preprocess(
|
|
15972
|
-
return
|
|
15990
|
+
preprocess(source2) {
|
|
15991
|
+
return source2;
|
|
15973
15992
|
}
|
|
15974
15993
|
/** Dialect-specific fragment for `node`. Concrete renderers override. */
|
|
15975
15994
|
renderedItem(_node, _item, _runtimeAttrs, _opts) {
|
|
@@ -16727,8 +16746,8 @@ var BuilderBase = class _BuilderBase {
|
|
|
16727
16746
|
if (typeof func !== "string") {
|
|
16728
16747
|
throw new Error("data-element func must be a name or a function");
|
|
16729
16748
|
}
|
|
16730
|
-
for (const
|
|
16731
|
-
const holder = typeof
|
|
16749
|
+
for (const source2 of this.dataLogic) {
|
|
16750
|
+
const holder = typeof source2 === "function" ? source2 : source2.constructor;
|
|
16732
16751
|
const fn = holder[func];
|
|
16733
16752
|
if (typeof fn === "function") {
|
|
16734
16753
|
return fn;
|
|
@@ -23947,14 +23966,14 @@ var Provider = class {
|
|
|
23947
23966
|
* `_triggerpars`, `_reason`, the click arguments (undefined for any other trigger), then the author
|
|
23948
23967
|
* attributes; a body (`formula`, `script`, or `_else` in their place) has `_kwargs` first, `_if` has not.
|
|
23949
23968
|
*/
|
|
23950
|
-
#inline(attr, code,
|
|
23969
|
+
#inline(attr, code, source2, kwargs, body) {
|
|
23951
23970
|
const names = [
|
|
23952
23971
|
...body ? ["_kwargs"] : [],
|
|
23953
23972
|
...TRIGGER_FIELDS,
|
|
23954
23973
|
...CLICK_FIELDS,
|
|
23955
23974
|
...Object.keys(authorArguments(kwargs))
|
|
23956
23975
|
];
|
|
23957
|
-
return this.binding.runtime.inlineCompiler.compile(this.node, attr, code, names,
|
|
23976
|
+
return this.binding.runtime.inlineCompiler.compile(this.node, attr, code, names, source2)({ ...kwargs, _kwargs: kwargs });
|
|
23958
23977
|
}
|
|
23959
23978
|
#closeRegistrations() {
|
|
23960
23979
|
for (const registration of this.#registrations.splice(0)) registration.close();
|
|
@@ -24068,8 +24087,8 @@ var InlineCompiler = class {
|
|
|
24068
24087
|
* The legacy macros of `source` translated to the node methods, `$n` to `arguments[n-1]`, as in
|
|
24069
24088
|
* `gnrlang.js`. A translated declaration gets one deprecation warning; `PUBLISH` is an error.
|
|
24070
24089
|
*/
|
|
24071
|
-
preprocess(node, attr,
|
|
24072
|
-
const text =
|
|
24090
|
+
preprocess(node, attr, source2) {
|
|
24091
|
+
const text = source2.trim();
|
|
24073
24092
|
if (PUBLISH.test(text)) throw new Error(`${declaration2(node, attr)}: the PUBLISH macro is excluded from Gramlot 0.2.0`);
|
|
24074
24093
|
let result = text.replace(/\$(\d+)/g, (_token, n) => `arguments[${parseInt(n, 10) - 1}]`);
|
|
24075
24094
|
for (const [separator, macro, target] of MACROS) {
|
|
@@ -24091,7 +24110,7 @@ var InlineCompiler = class {
|
|
|
24091
24110
|
* compile again; the entry is released when its attribute changes or is removed, and when the
|
|
24092
24111
|
* node's NodeBinding closes.
|
|
24093
24112
|
*/
|
|
24094
|
-
compile(node, attr, code, argNames,
|
|
24113
|
+
compile(node, attr, code, argNames, source2 = code) {
|
|
24095
24114
|
if (node.activatedCode(attr) !== code) {
|
|
24096
24115
|
throw new Error(`${declaration2(node, attr)}: inline code runs only as received with the Source (main or a remote Source); a text written later is not run: use named logic`);
|
|
24097
24116
|
}
|
|
@@ -24102,8 +24121,8 @@ var InlineCompiler = class {
|
|
|
24102
24121
|
this.runtime.bindingFor(node).track(() => this.release(node));
|
|
24103
24122
|
}
|
|
24104
24123
|
let entry = entries.get(attr);
|
|
24105
|
-
if (entry?.source !==
|
|
24106
|
-
entry = { source, text: this.preprocess(node, attr,
|
|
24124
|
+
if (entry?.source !== source2) {
|
|
24125
|
+
entry = { source: source2, text: this.preprocess(node, attr, source2), key: null, run: null };
|
|
24107
24126
|
entries.set(attr, entry);
|
|
24108
24127
|
}
|
|
24109
24128
|
const params = argNames.filter(isIdentifier);
|
|
@@ -24174,7 +24193,7 @@ function create(node, attr, text, params) {
|
|
|
24174
24193
|
`);
|
|
24175
24194
|
} catch (error) {
|
|
24176
24195
|
if (error instanceof EvalError) {
|
|
24177
|
-
throw new EvalError(`${declaration2(node, attr)}: inline code blocked by the Content Security Policy of the page (no 'unsafe-eval'); move the code to named logic (a method of the page
|
|
24196
|
+
throw new EvalError(`${declaration2(node, attr)}: inline code blocked by the Content Security Policy of the page (no 'unsafe-eval'); move the code to named logic (a method of the page's class Logic) or serve the page with the permissive CSP profile, which allows 'unsafe-eval'`, { cause: error });
|
|
24178
24197
|
}
|
|
24179
24198
|
throw new SyntaxError(`${declaration2(node, attr)}: ${error.message} in the inline code:
|
|
24180
24199
|
${text}`, { cause: error });
|
|
@@ -24625,19 +24644,19 @@ var GramlotRenderer = class extends GramlotHtmlRenderer {
|
|
|
24625
24644
|
// The resolved projection that `project` hands to the rebuild of a control whose shape changed.
|
|
24626
24645
|
#rebuildAttributes = /* @__PURE__ */ new WeakMap();
|
|
24627
24646
|
/** The live renderer of one Gramlot page: `binding` is the page's BindingRuntime (§4.3). */
|
|
24628
|
-
constructor(builder,
|
|
24647
|
+
constructor(builder, source2, destination, { binding } = {}) {
|
|
24629
24648
|
super(builder);
|
|
24630
|
-
if (!(builder instanceof BuilderBase) || !(
|
|
24649
|
+
if (!(builder instanceof BuilderBase) || !(source2 instanceof GramlotBuilderBag) || destination?.nodeType !== 1) {
|
|
24631
24650
|
throw new TypeError("GramlotRenderer requires a BuilderBase, GramlotBuilderBag and HTML destination");
|
|
24632
24651
|
}
|
|
24633
24652
|
if (!(binding instanceof BindingRuntime)) throw new TypeError("GramlotRenderer requires a BindingRuntime");
|
|
24634
|
-
if (!(
|
|
24653
|
+
if (!(source2._builder instanceof BuilderBase)) throw new TypeError("SourceBag requires builder ownership");
|
|
24635
24654
|
this._binding = binding;
|
|
24636
|
-
this.source =
|
|
24655
|
+
this.source = source2;
|
|
24637
24656
|
this.destination = destination;
|
|
24638
24657
|
this.html = new HtmlElement({ metadataAttributes: ["__ref"] });
|
|
24639
24658
|
this.records = /* @__PURE__ */ new Map();
|
|
24640
|
-
this.references = new References(
|
|
24659
|
+
this.references = new References(source2);
|
|
24641
24660
|
this.pending = [];
|
|
24642
24661
|
this.building = false;
|
|
24643
24662
|
this.disposed = false;
|
|
@@ -24645,7 +24664,7 @@ var GramlotRenderer = class extends GramlotHtmlRenderer {
|
|
|
24645
24664
|
this.instanceId = crypto.randomUUID();
|
|
24646
24665
|
this.radioGroups = new RadioGroups(this);
|
|
24647
24666
|
this.subscription = `html-source-renderer-${this.instanceId}`;
|
|
24648
|
-
|
|
24667
|
+
source2.subscribe(this.subscription, { any: (event) => this.receive(event) });
|
|
24649
24668
|
}
|
|
24650
24669
|
get binding() {
|
|
24651
24670
|
return this._binding;
|
|
@@ -25249,10 +25268,10 @@ function regexStarts(previous) {
|
|
|
25249
25268
|
if (/^[\w$]/.test(previous)) return REGEX_AFTER_WORDS.has(previous);
|
|
25250
25269
|
return previous !== ")" && previous !== "]";
|
|
25251
25270
|
}
|
|
25252
|
-
function regexEnd(
|
|
25271
|
+
function regexEnd(source2, start) {
|
|
25253
25272
|
let inClass = false;
|
|
25254
|
-
for (let index = start + 1; index <
|
|
25255
|
-
const char =
|
|
25273
|
+
for (let index = start + 1; index < source2.length; index++) {
|
|
25274
|
+
const char = source2[index];
|
|
25256
25275
|
if (char === "\n") return -1;
|
|
25257
25276
|
if (char === "\\") {
|
|
25258
25277
|
index++;
|
|
@@ -25264,26 +25283,26 @@ function regexEnd(source, start) {
|
|
|
25264
25283
|
}
|
|
25265
25284
|
return -1;
|
|
25266
25285
|
}
|
|
25267
|
-
function declaresConstructor(
|
|
25286
|
+
function declaresConstructor(source2) {
|
|
25268
25287
|
let depth = 0;
|
|
25269
25288
|
let members = "";
|
|
25270
25289
|
let previous = "";
|
|
25271
|
-
for (let index =
|
|
25272
|
-
const char =
|
|
25273
|
-
if (char === "/" &&
|
|
25274
|
-
index =
|
|
25290
|
+
for (let index = source2.indexOf("{"); index < source2.length; index++) {
|
|
25291
|
+
const char = source2[index];
|
|
25292
|
+
if (char === "/" && source2[index + 1] === "/") {
|
|
25293
|
+
index = source2.indexOf("\n", index);
|
|
25275
25294
|
if (index < 0) break;
|
|
25276
25295
|
continue;
|
|
25277
25296
|
}
|
|
25278
|
-
if (char === "/" &&
|
|
25279
|
-
const close =
|
|
25297
|
+
if (char === "/" && source2[index + 1] === "*") {
|
|
25298
|
+
const close = source2.indexOf("*/", index + 2);
|
|
25280
25299
|
if (close >= 0) {
|
|
25281
25300
|
index = close + 1;
|
|
25282
25301
|
continue;
|
|
25283
25302
|
}
|
|
25284
25303
|
}
|
|
25285
25304
|
if (char === "/" && regexStarts(previous)) {
|
|
25286
|
-
const close = regexEnd(
|
|
25305
|
+
const close = regexEnd(source2, index);
|
|
25287
25306
|
if (close >= 0) {
|
|
25288
25307
|
index = close;
|
|
25289
25308
|
previous = ")";
|
|
@@ -25292,17 +25311,17 @@ function declaresConstructor(source) {
|
|
|
25292
25311
|
}
|
|
25293
25312
|
if (char === '"' || char === "'" || char === "`") {
|
|
25294
25313
|
let end = index + 1;
|
|
25295
|
-
while (end <
|
|
25296
|
-
if (depth === 1) members +=
|
|
25314
|
+
while (end < source2.length && source2[end] !== char) end += source2[end] === "\\" ? 2 : 1;
|
|
25315
|
+
if (depth === 1) members += source2.slice(index + 1, end) === "constructor" ? " constructor" : ' ""';
|
|
25297
25316
|
index = end;
|
|
25298
25317
|
previous = ")";
|
|
25299
25318
|
continue;
|
|
25300
25319
|
}
|
|
25301
25320
|
if (/[\w$]/.test(char)) {
|
|
25302
25321
|
let end = index + 1;
|
|
25303
|
-
while (end <
|
|
25304
|
-
if (depth === 1) members +=
|
|
25305
|
-
previous =
|
|
25322
|
+
while (end < source2.length && /[\w$]/.test(source2[end])) end++;
|
|
25323
|
+
if (depth === 1) members += source2.slice(index, end);
|
|
25324
|
+
previous = source2.slice(index, end);
|
|
25306
25325
|
index = end - 1;
|
|
25307
25326
|
continue;
|
|
25308
25327
|
}
|
|
@@ -25391,7 +25410,7 @@ var LogicRegistry = class {
|
|
|
25391
25410
|
}
|
|
25392
25411
|
/**
|
|
25393
25412
|
* Copy the methods of `logicClass` into the group `group` (a `js_requires` name, `a/b` nested,
|
|
25394
|
-
* or null for the page
|
|
25413
|
+
* or null for the page logic), creating the groups on the way. On an equal method name in
|
|
25395
25414
|
* the same group the last registration wins.
|
|
25396
25415
|
*/
|
|
25397
25416
|
register(logicClass, { group = null, resource }) {
|
|
@@ -25492,6 +25511,120 @@ var MainTransport = class {
|
|
|
25492
25511
|
}
|
|
25493
25512
|
};
|
|
25494
25513
|
|
|
25514
|
+
// src/inout.js
|
|
25515
|
+
var MAILTO_LIMIT = 2e3;
|
|
25516
|
+
function leafText(value) {
|
|
25517
|
+
if (!(value instanceof Date)) return String(value ?? "");
|
|
25518
|
+
const text = value.toISOString();
|
|
25519
|
+
return text.endsWith("T00:00:00.000Z") ? text.slice(0, 10) : text;
|
|
25520
|
+
}
|
|
25521
|
+
var InOut = class {
|
|
25522
|
+
constructor(gramlot, document) {
|
|
25523
|
+
this.gramlot = gramlot;
|
|
25524
|
+
this.document = document;
|
|
25525
|
+
}
|
|
25526
|
+
/** The Bag at path in the Data. */
|
|
25527
|
+
branch(path) {
|
|
25528
|
+
const value = this.gramlot.data.getItem(path);
|
|
25529
|
+
if (!(value instanceof Bag)) throw new Error(`gramlot.inout: no data Bag at '${path}'`);
|
|
25530
|
+
return value;
|
|
25531
|
+
}
|
|
25532
|
+
/** One `relative.path: value` line per leaf of the branch at path. */
|
|
25533
|
+
mailText(path) {
|
|
25534
|
+
const lines = [];
|
|
25535
|
+
const walk2 = (bag, prefix) => {
|
|
25536
|
+
for (const node of bag.getNodes()) {
|
|
25537
|
+
const label = prefix + node.label;
|
|
25538
|
+
if (node.value instanceof Bag) walk2(node.value, `${label}.`);
|
|
25539
|
+
else lines.push(`${label}: ${leafText(node.value)}`);
|
|
25540
|
+
}
|
|
25541
|
+
};
|
|
25542
|
+
walk2(this.branch(path), "");
|
|
25543
|
+
return lines.join("\n");
|
|
25544
|
+
}
|
|
25545
|
+
/** The mailto: URL of sendMail; longer than MAILTO_LIMIT raises an Error. */
|
|
25546
|
+
mailtoUrl(path, email) {
|
|
25547
|
+
const url = `mailto:${encodeURIComponent(email)}?subject=${encodeURIComponent(this.document.title)}&body=${encodeURIComponent(this.mailText(path))}`;
|
|
25548
|
+
if (url.length > MAILTO_LIMIT) {
|
|
25549
|
+
throw new Error(`gramlot.inout.sendMail: the email of '${path}' is ${url.length} characters long, over the mailto: limit of ${MAILTO_LIMIT}; send it with sendHttp or save it as a file`);
|
|
25550
|
+
}
|
|
25551
|
+
return url;
|
|
25552
|
+
}
|
|
25553
|
+
/** Prepare an email to email in the mail program of the user, with the data at path as text lines. */
|
|
25554
|
+
sendMail(path, email) {
|
|
25555
|
+
this.open(this.mailtoUrl(path, email));
|
|
25556
|
+
}
|
|
25557
|
+
/** POST the data at path as a JSON object to url; resolves with the Response, rejects on a status out of 2xx. */
|
|
25558
|
+
async sendHttp(path, url) {
|
|
25559
|
+
const body = JSON.stringify(this.branch(path).asDict(false, false, true));
|
|
25560
|
+
const response = await this.document.defaultView.fetch(url, {
|
|
25561
|
+
method: "POST",
|
|
25562
|
+
headers: { "Content-Type": "application/json" },
|
|
25563
|
+
body
|
|
25564
|
+
});
|
|
25565
|
+
if (!response.ok) throw new Error(`gramlot.inout.sendHttp: ${url} answered ${response.status}`);
|
|
25566
|
+
return response;
|
|
25567
|
+
}
|
|
25568
|
+
/** Save the data at path as a TYTX file, which restore reads back with its exact types. */
|
|
25569
|
+
save(path, filename) {
|
|
25570
|
+
this.saveText(this.branch(path).toTytx(), filename, "application/json");
|
|
25571
|
+
}
|
|
25572
|
+
/** Read a TYTX file chosen by the user into path; resolves with the restored Bag. Needs a user gesture. */
|
|
25573
|
+
restore(path) {
|
|
25574
|
+
const input = this.document.createElement("input");
|
|
25575
|
+
input.type = "file";
|
|
25576
|
+
input.accept = ".json,application/json";
|
|
25577
|
+
return new Promise((resolve, reject) => {
|
|
25578
|
+
input.addEventListener("change", async () => {
|
|
25579
|
+
try {
|
|
25580
|
+
const bag = Bag.fromTytx(await input.files[0].text());
|
|
25581
|
+
this.gramlot.data.setItem(path, bag);
|
|
25582
|
+
resolve(bag);
|
|
25583
|
+
} catch (error) {
|
|
25584
|
+
reject(new Error(
|
|
25585
|
+
`gramlot.inout.restore: the file is not a saved Gramlot branch: ${error.message}`,
|
|
25586
|
+
{ cause: error }
|
|
25587
|
+
));
|
|
25588
|
+
}
|
|
25589
|
+
}, { once: true });
|
|
25590
|
+
input.click();
|
|
25591
|
+
});
|
|
25592
|
+
}
|
|
25593
|
+
/** Export the data at path as 'json' (Bag.toJson) or 'xml' (Bag.toXml, inside one root element named
|
|
25594
|
+
* after the last segment of path); types become text. */
|
|
25595
|
+
download(path, filename, format) {
|
|
25596
|
+
if (!["json", "xml"].includes(format)) {
|
|
25597
|
+
throw new Error(`gramlot.inout.download: format '${format}' is not 'json' or 'xml'`);
|
|
25598
|
+
}
|
|
25599
|
+
const bag = this.branch(path);
|
|
25600
|
+
if (format === "json") {
|
|
25601
|
+
this.saveText(bag.toJson(false), filename, "application/json");
|
|
25602
|
+
} else {
|
|
25603
|
+
const root = path.split(".").at(-1);
|
|
25604
|
+
this.saveText(
|
|
25605
|
+
`<?xml version='1.0' encoding='UTF-8'?>
|
|
25606
|
+
<${root}>${bag.toXml()}</${root}>`,
|
|
25607
|
+
filename,
|
|
25608
|
+
"application/xml"
|
|
25609
|
+
);
|
|
25610
|
+
}
|
|
25611
|
+
}
|
|
25612
|
+
/** Hand text to the browser as a file named filename. */
|
|
25613
|
+
saveText(text, filename, type) {
|
|
25614
|
+
const window2 = this.document.defaultView;
|
|
25615
|
+
const url = window2.URL.createObjectURL(new window2.Blob([text], { type }));
|
|
25616
|
+
this.open(url, filename);
|
|
25617
|
+
window2.setTimeout(() => window2.URL.revokeObjectURL(url), 1e3);
|
|
25618
|
+
}
|
|
25619
|
+
/** Follow url through a link, as a download when filename is given. */
|
|
25620
|
+
open(url, filename = null) {
|
|
25621
|
+
const link = this.document.createElement("a");
|
|
25622
|
+
link.href = url;
|
|
25623
|
+
if (filename !== null) link.download = filename;
|
|
25624
|
+
link.click();
|
|
25625
|
+
}
|
|
25626
|
+
};
|
|
25627
|
+
|
|
25495
25628
|
// src/gramlot.js
|
|
25496
25629
|
var Gramlot = class {
|
|
25497
25630
|
constructor({
|
|
@@ -25511,6 +25644,7 @@ var Gramlot = class {
|
|
|
25511
25644
|
this.binding = new BindingRuntime(this);
|
|
25512
25645
|
this.builder.binding = this.binding;
|
|
25513
25646
|
this.data = this.builder.data;
|
|
25647
|
+
this.inout = new InOut(this, document);
|
|
25514
25648
|
this.binding.attach();
|
|
25515
25649
|
this.source = this.builder.source;
|
|
25516
25650
|
const destination = element ?? document.getElementById(rootId);
|
|
@@ -25567,10 +25701,10 @@ var Gramlot = class {
|
|
|
25567
25701
|
* NodeBindings (P12, no rollback).
|
|
25568
25702
|
*/
|
|
25569
25703
|
mountMainSource(wire) {
|
|
25570
|
-
const
|
|
25571
|
-
this.renderer.validateCandidate(
|
|
25704
|
+
const source2 = this.prepareSource(wire);
|
|
25705
|
+
this.renderer.validateCandidate(source2);
|
|
25572
25706
|
try {
|
|
25573
|
-
this.source.setItem("main",
|
|
25707
|
+
this.source.setItem("main", source2);
|
|
25574
25708
|
} catch (error) {
|
|
25575
25709
|
if (!this.binding.bindingFor(this.source.getNode("main"))) this.source.popNode("main");
|
|
25576
25710
|
throw error;
|
|
@@ -25589,9 +25723,9 @@ var Gramlot = class {
|
|
|
25589
25723
|
if (!(wire instanceof GramlotBuilderBag)) throw new TypeError("Source values must be GramlotBuilderBags");
|
|
25590
25724
|
return wire.bindBuilder(builder).activateCode();
|
|
25591
25725
|
}
|
|
25592
|
-
const
|
|
25593
|
-
if (!(
|
|
25594
|
-
return
|
|
25726
|
+
const source2 = sourceBagFromTytx(wire, builder);
|
|
25727
|
+
if (!(source2 instanceof GramlotBuilderBag)) throw new TypeError("Source values must be GramlotBuilderBags");
|
|
25728
|
+
return source2.activateCode();
|
|
25595
25729
|
}
|
|
25596
25730
|
/**
|
|
25597
25731
|
* Replace one Source node's children only after incoming Source validation.
|
|
@@ -25716,6 +25850,24 @@ var PageBootstrap = class {
|
|
|
25716
25850
|
new MainTransport(mainUrl, void 0, sourceUrl, closeUrl, this.document.defaultView.navigator).close(pageId, { beacon: true });
|
|
25717
25851
|
}
|
|
25718
25852
|
};
|
|
25853
|
+
|
|
25854
|
+
// src/adapters/page.js
|
|
25855
|
+
var SOURCE_METHOD = /* @__PURE__ */ Symbol("gramlot.source");
|
|
25856
|
+
function source(method) {
|
|
25857
|
+
if (typeof method !== "function") throw new TypeError("source requires a method");
|
|
25858
|
+
method[SOURCE_METHOD] = true;
|
|
25859
|
+
return method;
|
|
25860
|
+
}
|
|
25861
|
+
var Page = class {
|
|
25862
|
+
static title = "Gramlot";
|
|
25863
|
+
static css = [];
|
|
25864
|
+
static css_requires = "";
|
|
25865
|
+
static js_requires = "";
|
|
25866
|
+
static sourceBuilder = GramlotBuilder;
|
|
25867
|
+
main(root) {
|
|
25868
|
+
throw new Error("Page.main(root) must be implemented");
|
|
25869
|
+
}
|
|
25870
|
+
};
|
|
25719
25871
|
export {
|
|
25720
25872
|
Bag,
|
|
25721
25873
|
BagNode,
|
|
@@ -25724,7 +25876,10 @@ export {
|
|
|
25724
25876
|
GramlotHtmlRenderer,
|
|
25725
25877
|
GramlotRenderer,
|
|
25726
25878
|
GramlotSvgRenderer,
|
|
25879
|
+
InOut,
|
|
25727
25880
|
MainTransport,
|
|
25881
|
+
Page,
|
|
25728
25882
|
PageBootstrap,
|
|
25729
|
-
References
|
|
25883
|
+
References,
|
|
25884
|
+
source
|
|
25730
25885
|
};
|