@hpcc-js/observablehq-compiler 1.5.0 → 1.5.1
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/LICENSE +43 -43
- package/README.md +105 -105
- package/bin/ojscc.mjs +73 -73
- package/dist/index.esm.js +49 -49
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.js +49 -49
- package/dist/index.js.map +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +3 -3
- package/src/__package__.ts +3 -3
- package/src/__tests__/File Attachments.ts +894 -894
- package/src/__tests__/Introduction to Imports.ts +748 -748
- package/src/__tests__/Observable TimeChart.ts +771 -771
- package/src/__tests__/index.ts +13 -13
- package/src/__tests__/m1.mjs +3 -3
- package/src/__tests__/node.ts +199 -199
- package/src/compiler.md +234 -234
- package/src/compiler.ts +311 -311
- package/src/cst.ts +178 -178
- package/src/index.css +459 -459
- package/src/index.ts +6 -6
- package/src/util.md +113 -113
- package/src/util.ts +175 -175
- package/src/writer.ts +80 -80
package/dist/index.js
CHANGED
|
@@ -827,10 +827,10 @@
|
|
|
827
827
|
// to its body instead of creating a new node.
|
|
828
828
|
|
|
829
829
|
pp$8.parseTopLevel = function(node) {
|
|
830
|
-
var exports = Object.create(null);
|
|
830
|
+
var exports$1 = Object.create(null);
|
|
831
831
|
if (!node.body) { node.body = []; }
|
|
832
832
|
while (this.type !== types$1.eof) {
|
|
833
|
-
var stmt = this.parseStatement(null, true, exports);
|
|
833
|
+
var stmt = this.parseStatement(null, true, exports$1);
|
|
834
834
|
node.body.push(stmt);
|
|
835
835
|
}
|
|
836
836
|
if (this.inModule)
|
|
@@ -937,7 +937,7 @@
|
|
|
937
937
|
// `if (foo) /blah/.exec(foo)`, where looking at the previous token
|
|
938
938
|
// does not help.
|
|
939
939
|
|
|
940
|
-
pp$8.parseStatement = function(context, topLevel, exports) {
|
|
940
|
+
pp$8.parseStatement = function(context, topLevel, exports$1) {
|
|
941
941
|
var starttype = this.type, node = this.startNode(), kind;
|
|
942
942
|
|
|
943
943
|
if (this.isLet(context)) {
|
|
@@ -992,7 +992,7 @@
|
|
|
992
992
|
if (!this.inModule)
|
|
993
993
|
{ this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); }
|
|
994
994
|
}
|
|
995
|
-
return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports)
|
|
995
|
+
return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports$1)
|
|
996
996
|
|
|
997
997
|
// If the statement does not start with a statement keyword or a
|
|
998
998
|
// brace, it's an ExpressionStatement or LabeledStatement. We
|
|
@@ -1748,11 +1748,11 @@
|
|
|
1748
1748
|
|
|
1749
1749
|
// Parses module export declaration.
|
|
1750
1750
|
|
|
1751
|
-
pp$8.parseExportAllDeclaration = function(node, exports) {
|
|
1751
|
+
pp$8.parseExportAllDeclaration = function(node, exports$1) {
|
|
1752
1752
|
if (this.options.ecmaVersion >= 11) {
|
|
1753
1753
|
if (this.eatContextual("as")) {
|
|
1754
1754
|
node.exported = this.parseModuleExportName();
|
|
1755
|
-
this.checkExport(exports, node.exported, this.lastTokStart);
|
|
1755
|
+
this.checkExport(exports$1, node.exported, this.lastTokStart);
|
|
1756
1756
|
} else {
|
|
1757
1757
|
node.exported = null;
|
|
1758
1758
|
}
|
|
@@ -1766,14 +1766,14 @@
|
|
|
1766
1766
|
return this.finishNode(node, "ExportAllDeclaration")
|
|
1767
1767
|
};
|
|
1768
1768
|
|
|
1769
|
-
pp$8.parseExport = function(node, exports) {
|
|
1769
|
+
pp$8.parseExport = function(node, exports$1) {
|
|
1770
1770
|
this.next();
|
|
1771
1771
|
// export * from '...'
|
|
1772
1772
|
if (this.eat(types$1.star)) {
|
|
1773
|
-
return this.parseExportAllDeclaration(node, exports)
|
|
1773
|
+
return this.parseExportAllDeclaration(node, exports$1)
|
|
1774
1774
|
}
|
|
1775
1775
|
if (this.eat(types$1._default)) { // export default ...
|
|
1776
|
-
this.checkExport(exports, "default", this.lastTokStart);
|
|
1776
|
+
this.checkExport(exports$1, "default", this.lastTokStart);
|
|
1777
1777
|
node.declaration = this.parseExportDefaultDeclaration();
|
|
1778
1778
|
return this.finishNode(node, "ExportDefaultDeclaration")
|
|
1779
1779
|
}
|
|
@@ -1781,16 +1781,16 @@
|
|
|
1781
1781
|
if (this.shouldParseExportStatement()) {
|
|
1782
1782
|
node.declaration = this.parseExportDeclaration(node);
|
|
1783
1783
|
if (node.declaration.type === "VariableDeclaration")
|
|
1784
|
-
{ this.checkVariableExport(exports, node.declaration.declarations); }
|
|
1784
|
+
{ this.checkVariableExport(exports$1, node.declaration.declarations); }
|
|
1785
1785
|
else
|
|
1786
|
-
{ this.checkExport(exports, node.declaration.id, node.declaration.id.start); }
|
|
1786
|
+
{ this.checkExport(exports$1, node.declaration.id, node.declaration.id.start); }
|
|
1787
1787
|
node.specifiers = [];
|
|
1788
1788
|
node.source = null;
|
|
1789
1789
|
if (this.options.ecmaVersion >= 16)
|
|
1790
1790
|
{ node.attributes = []; }
|
|
1791
1791
|
} else { // export { x, y as z } [from '...']
|
|
1792
1792
|
node.declaration = null;
|
|
1793
|
-
node.specifiers = this.parseExportSpecifiers(exports);
|
|
1793
|
+
node.specifiers = this.parseExportSpecifiers(exports$1);
|
|
1794
1794
|
if (this.eatContextual("from")) {
|
|
1795
1795
|
if (this.type !== types$1.string) { this.unexpected(); }
|
|
1796
1796
|
node.source = this.parseExprAtom();
|
|
@@ -1840,47 +1840,47 @@
|
|
|
1840
1840
|
}
|
|
1841
1841
|
};
|
|
1842
1842
|
|
|
1843
|
-
pp$8.checkExport = function(exports, name, pos) {
|
|
1844
|
-
if (!exports) { return }
|
|
1843
|
+
pp$8.checkExport = function(exports$1, name, pos) {
|
|
1844
|
+
if (!exports$1) { return }
|
|
1845
1845
|
if (typeof name !== "string")
|
|
1846
1846
|
{ name = name.type === "Identifier" ? name.name : name.value; }
|
|
1847
|
-
if (hasOwn(exports, name))
|
|
1847
|
+
if (hasOwn(exports$1, name))
|
|
1848
1848
|
{ this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); }
|
|
1849
|
-
exports[name] = true;
|
|
1849
|
+
exports$1[name] = true;
|
|
1850
1850
|
};
|
|
1851
1851
|
|
|
1852
|
-
pp$8.checkPatternExport = function(exports, pat) {
|
|
1852
|
+
pp$8.checkPatternExport = function(exports$1, pat) {
|
|
1853
1853
|
var type = pat.type;
|
|
1854
1854
|
if (type === "Identifier")
|
|
1855
|
-
{ this.checkExport(exports, pat, pat.start); }
|
|
1855
|
+
{ this.checkExport(exports$1, pat, pat.start); }
|
|
1856
1856
|
else if (type === "ObjectPattern")
|
|
1857
1857
|
{ for (var i = 0, list = pat.properties; i < list.length; i += 1)
|
|
1858
1858
|
{
|
|
1859
1859
|
var prop = list[i];
|
|
1860
1860
|
|
|
1861
|
-
this.checkPatternExport(exports, prop);
|
|
1861
|
+
this.checkPatternExport(exports$1, prop);
|
|
1862
1862
|
} }
|
|
1863
1863
|
else if (type === "ArrayPattern")
|
|
1864
1864
|
{ for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
|
|
1865
1865
|
var elt = list$1[i$1];
|
|
1866
1866
|
|
|
1867
|
-
if (elt) { this.checkPatternExport(exports, elt); }
|
|
1867
|
+
if (elt) { this.checkPatternExport(exports$1, elt); }
|
|
1868
1868
|
} }
|
|
1869
1869
|
else if (type === "Property")
|
|
1870
|
-
{ this.checkPatternExport(exports, pat.value); }
|
|
1870
|
+
{ this.checkPatternExport(exports$1, pat.value); }
|
|
1871
1871
|
else if (type === "AssignmentPattern")
|
|
1872
|
-
{ this.checkPatternExport(exports, pat.left); }
|
|
1872
|
+
{ this.checkPatternExport(exports$1, pat.left); }
|
|
1873
1873
|
else if (type === "RestElement")
|
|
1874
|
-
{ this.checkPatternExport(exports, pat.argument); }
|
|
1874
|
+
{ this.checkPatternExport(exports$1, pat.argument); }
|
|
1875
1875
|
};
|
|
1876
1876
|
|
|
1877
|
-
pp$8.checkVariableExport = function(exports, decls) {
|
|
1878
|
-
if (!exports) { return }
|
|
1877
|
+
pp$8.checkVariableExport = function(exports$1, decls) {
|
|
1878
|
+
if (!exports$1) { return }
|
|
1879
1879
|
for (var i = 0, list = decls; i < list.length; i += 1)
|
|
1880
1880
|
{
|
|
1881
1881
|
var decl = list[i];
|
|
1882
1882
|
|
|
1883
|
-
this.checkPatternExport(exports, decl.id);
|
|
1883
|
+
this.checkPatternExport(exports$1, decl.id);
|
|
1884
1884
|
}
|
|
1885
1885
|
};
|
|
1886
1886
|
|
|
@@ -1895,13 +1895,13 @@
|
|
|
1895
1895
|
|
|
1896
1896
|
// Parses a comma-separated list of module exports.
|
|
1897
1897
|
|
|
1898
|
-
pp$8.parseExportSpecifier = function(exports) {
|
|
1898
|
+
pp$8.parseExportSpecifier = function(exports$1) {
|
|
1899
1899
|
var node = this.startNode();
|
|
1900
1900
|
node.local = this.parseModuleExportName();
|
|
1901
1901
|
|
|
1902
1902
|
node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local;
|
|
1903
1903
|
this.checkExport(
|
|
1904
|
-
exports,
|
|
1904
|
+
exports$1,
|
|
1905
1905
|
node.exported,
|
|
1906
1906
|
node.exported.start
|
|
1907
1907
|
);
|
|
@@ -1909,7 +1909,7 @@
|
|
|
1909
1909
|
return this.finishNode(node, "ExportSpecifier")
|
|
1910
1910
|
};
|
|
1911
1911
|
|
|
1912
|
-
pp$8.parseExportSpecifiers = function(exports) {
|
|
1912
|
+
pp$8.parseExportSpecifiers = function(exports$1) {
|
|
1913
1913
|
var nodes = [], first = true;
|
|
1914
1914
|
// export { x, y as z } [from '...']
|
|
1915
1915
|
this.expect(types$1.braceL);
|
|
@@ -1919,7 +1919,7 @@
|
|
|
1919
1919
|
if (this.afterTrailingComma(types$1.braceR)) { break }
|
|
1920
1920
|
} else { first = false; }
|
|
1921
1921
|
|
|
1922
|
-
nodes.push(this.parseExportSpecifier(exports));
|
|
1922
|
+
nodes.push(this.parseExportSpecifier(exports$1));
|
|
1923
1923
|
}
|
|
1924
1924
|
return nodes
|
|
1925
1925
|
};
|
|
@@ -7869,23 +7869,23 @@
|
|
|
7869
7869
|
this._functionUid = 0;
|
|
7870
7870
|
}
|
|
7871
7871
|
toString() {
|
|
7872
|
-
return `\
|
|
7873
|
-
${this._imports.join("\n")}
|
|
7874
|
-
|
|
7875
|
-
${this._functions.join("\n").split("\n) {").join("){")}
|
|
7876
|
-
|
|
7877
|
-
export default function define(runtime, observer) {
|
|
7878
|
-
const main = runtime.module();
|
|
7879
|
-
|
|
7880
|
-
function toString() { return this.url; }
|
|
7881
|
-
const fileAttachments = new Map([
|
|
7882
|
-
${this._files.map(f => `["${f.name}", { url: new URL("${f.url}"), mimeType: ${JSON.stringify(f.mime_type)}, toString }]`).join(",\n ")}
|
|
7883
|
-
]);
|
|
7884
|
-
main.builtin("FileAttachment", runtime.fileAttachments(name => fileAttachments.get(name)));
|
|
7885
|
-
|
|
7886
|
-
${this._defines.join("\n ")}
|
|
7887
|
-
|
|
7888
|
-
return main;
|
|
7872
|
+
return `\
|
|
7873
|
+
${this._imports.join("\n")}
|
|
7874
|
+
|
|
7875
|
+
${this._functions.join("\n").split("\n) {").join("){")}
|
|
7876
|
+
|
|
7877
|
+
export default function define(runtime, observer) {
|
|
7878
|
+
const main = runtime.module();
|
|
7879
|
+
|
|
7880
|
+
function toString() { return this.url; }
|
|
7881
|
+
const fileAttachments = new Map([
|
|
7882
|
+
${this._files.map(f => `["${f.name}", { url: new URL("${f.url}"), mimeType: ${JSON.stringify(f.mime_type)}, toString }]`).join(",\n ")}
|
|
7883
|
+
]);
|
|
7884
|
+
main.builtin("FileAttachment", runtime.fileAttachments(name => fileAttachments.get(name)));
|
|
7885
|
+
|
|
7886
|
+
${this._defines.join("\n ")}
|
|
7887
|
+
|
|
7888
|
+
return main;
|
|
7889
7889
|
}\n`;
|
|
7890
7890
|
}
|
|
7891
7891
|
files(files) {
|
|
@@ -8042,8 +8042,8 @@ export default function define(runtime, observer) {
|
|
|
8042
8042
|
v = module.variable(inspector(name, node.id));
|
|
8043
8043
|
try {
|
|
8044
8044
|
v.define(undefined, ["md"], md => {
|
|
8045
|
-
return md `\`\`\`js
|
|
8046
|
-
${node.value}
|
|
8045
|
+
return md `\`\`\`js
|
|
8046
|
+
${node.value}
|
|
8047
8047
|
\`\`\``;
|
|
8048
8048
|
});
|
|
8049
8049
|
}
|