diff --git a/.gitignore b/.gitignore
index 8bea256..eb79dd5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,2 @@
node_modules
.idea
-dist
diff --git a/dist/code-highlighter.js b/dist/code-highlighter.js
new file mode 100644
index 0000000..320f668
--- /dev/null
+++ b/dist/code-highlighter.js
@@ -0,0 +1,85 @@
+"use strict";
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+const onigasm_1 = require("onigasm");
+const codemirror_textmate_1 = require("codemirror-textmate");
+const CodeMirror = require("codemirror");
+/**
+ *
+ */
+class CodeHighlighter {
+ constructor(theme) {
+ this.theme = theme;
+ }
+ /**
+ *
+ * @param shadowRoot
+ * @param element
+ */
+ init(shadowRoot, element) {
+ return __awaiter(this, void 0, void 0, function* () {
+ codemirror_textmate_1.setRoot(shadowRoot);
+ yield onigasm_1.loadWASM(
+ // webpack has been configured to resolve `.wasm` files to actual 'paths" as opposed to using the built-in wasm-loader
+ // oniguruma is a low-level library and stock wasm-loader isn't equipped with advanced low-level API's to interact with libonig
+ require('onigasm/lib/onigasm.wasm'));
+ const grammars = {
+ 'source.func': {
+ loader: () => Promise.resolve().then(() => require('./tm/grammar/func.tmLanguage.json')),
+ language: 'func',
+ priority: 'now'
+ }
+ };
+ // To avoid FOUC, await for high priority languages to get ready (loading/compiling takes time, and it's an async process for which CM won't wait)
+ yield Promise.all(Object.keys(grammars).map((scopeName) => __awaiter(this, void 0, void 0, function* () {
+ const { loader, language, priority } = grammars[scopeName];
+ codemirror_textmate_1.addGrammar(scopeName, loader);
+ if (language) {
+ const prom = codemirror_textmate_1.activateLanguage(scopeName, language, priority);
+ // We must "wait" for high priority languages to load/compile before we render editor to avoid FOUC (Flash of Unstyled Content)
+ if (priority === 'now') {
+ yield prom;
+ }
+ // 'asap' although "awaitable", is a medium priority, and doesn't need to be waited for
+ // 'defer' doesn't support awaiting at all
+ return;
+ }
+ })));
+ this.editor = CodeMirror.fromTextArea(element, {
+ lineNumbers: true,
+ // If you know in advance a language is going to be set on CodeMirror editor and it isn't preloaded by setting the third argument
+ // to `activateLanguage` to 'now', the contents of the editor would start of and remain as unhighlighted text, until loading is complete
+ mode: 'func'
+ });
+ // Using Textmate theme in CodeMirror
+ let cmTheme = yield Promise.resolve().then(() => require(this.theme === 'dark' ? './tm/themes/dark.tmTheme.json' : './tm/themes/light.tmTheme.json'));
+ const themeX = Object.assign(Object.assign({}, cmTheme), { gutterSettings: cmTheme.gutterSettings });
+ codemirror_textmate_1.addTheme(themeX);
+ this.editor.setOption('theme', themeX.name);
+ // Grammar injections, example code below will highlight css-in-js (styled-components, emotion)
+ // injections are "injections", they are not standalone-grammars, therefore no `activateLanguage`
+ codemirror_textmate_1.addGrammar('source.func', () => Promise.resolve().then(() => require('./tm/grammar/func.tmLanguage.json')));
+ const affectedLanguages = yield codemirror_textmate_1.linkInjections('source.func', ['source.func']);
+ console.log(affectedLanguages);
+ // You must re-trigger tokenization to apply the update above (if applicable)
+ const activeMode = this.editor.getOption('mode');
+ if (affectedLanguages.indexOf(activeMode.toString()) > -1) {
+ // Resetting cm's mode re-triggers tokenization of entire document
+ this.editor.setOption('mode', activeMode);
+ }
+ });
+ }
+ setCode(value) {
+ this.editor.setValue(value);
+ }
+}
+exports.default = CodeHighlighter;
+//# sourceMappingURL=code-highlighter.js.map
\ No newline at end of file
diff --git a/dist/code-highlighter.js.map b/dist/code-highlighter.js.map
new file mode 100644
index 0000000..16ed2b1
--- /dev/null
+++ b/dist/code-highlighter.js.map
@@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,WAAW,EAAE,IAAI;gBACjB,iIAAiI;gBACjI,wIAAwI;gBACxI,IAAI,EAAE,MAAM;aACf,CAAC,CAAA;YAEF,qCAAqC;YACrC,IAAI,OAAO,GAAG,2CACV,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,gCAAgC,EACzF,CAAA;YAEL,MAAM,MAAM,mCACL,OAAO,KACV,cAAc,EAAE,OAAO,CAAC,cAAc,GACzC,CAAA;YAED,8BAAQ,CAAC,MAAM,CAAC,CAAA;YAEhB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;YAE3C,+FAA+F;YAC/F,iGAAiG;YACjG,gCAAU,CAAC,aAAa,EAAE,GAAG,EAAE,CAAC,qCAAO,mCAAmC,EAAQ,CAAC,CAAA;YAEnF,MAAM,iBAAiB,GAAG,MAAM,oCAAc,CAAC,aAAa,EAAE,CAAC,aAAa,CAAC,CAAC,CAAA;YAE9E,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;YAC9B,6EAA6E;YAC7E,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;YAChD,IAAI,iBAAiB,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE;gBACvD,kEAAkE;gBAClE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;aAC5C;QACL,CAAC;KAAA;IAED,OAAO,CAAC,KAAK;QAET,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAE/B,CAAC;CAEJ;AA/FD,kCA+FC"}
\ No newline at end of file
diff --git a/dist/index.js b/dist/index.js
new file mode 100644
index 0000000..0f2f2f0
--- /dev/null
+++ b/dist/index.js
@@ -0,0 +1,196 @@
+"use strict";
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+const code_highlighter_1 = require("./code-highlighter");
+const codeMirrorCss = require("codemirror/lib/codemirror.css").toString();
+const style = require("./style.css");
+const template = document.createElement('template');
+/**
+ *
+ */
+class TSVWidgetElement extends HTMLElement {
+ /**
+ *
+ */
+ constructor() {
+ super();
+ this.sources = {};
+ this.selectedFile = null;
+ this.ipfsProvider = this.getAttribute('ipfs-provider');
+ this.verifiedContractUrl = this.getAttribute('verified-contract-url');
+ this.theme = this.getAttribute('theme');
+ this.layout = this.getAttribute('layout');
+ this.attachShadow({ mode: 'open' });
+ }
+ /**
+ * Runs each time the element is appended to or moved in the DOM
+ */
+ connectedCallback() {
+ return __awaiter(this, void 0, void 0, function* () {
+ console.log('connected!', this);
+ this.ch = new code_highlighter_1.default(this.theme);
+ yield this.buildContainer();
+ yield this.fetchSources();
+ yield this.buildTabs();
+ this.selectFile(this.selectedFile);
+ });
+ }
+ /**
+ * fetch sources from the verified contract json url
+ */
+ fetchSources() {
+ return __awaiter(this, void 0, void 0, function* () {
+ let url = this.ipfsProvider + '/ipfs/' + this.verifiedContractUrl.replace('ipfs://', '');
+ this.verifiedContract = yield (yield fetch(url)).json();
+ yield Promise.all(this.verifiedContract.sources.map((source) => __awaiter(this, void 0, void 0, function* () {
+ url = this.ipfsProvider + '/ipfs/' + source.url.replace('ipfs://', '');
+ const resp = yield fetch(url);
+ this.sources[source.fileName] = yield resp.text();
+ })));
+ this.loadingCurtain.classList.remove('visible');
+ });
+ }
+ /**
+ * builds the external container element and appends it to the shadow root
+ */
+ buildContainer() {
+ return __awaiter(this, void 0, void 0, function* () {
+ template.innerHTML = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ `;
+ this.shadowRoot.appendChild(template.content.cloneNode(true));
+ });
+ }
+ /**
+ * builds the html tabs
+ */
+ buildTabs() {
+ return __awaiter(this, void 0, void 0, function* () {
+ let tabsButtons = '';
+ let index = 0;
+ for (const sourceMetadata of this.verifiedContract.sources) {
+ const fileName = sourceMetadata.fileName;
+ tabsButtons += `
+ ${fileName}
+
`;
+ if (index === 0) {
+ this.selectedFile = fileName;
+ }
+ index++;
+ }
+ this.tabsButtons.innerHTML = tabsButtons;
+ yield this.ch.init(this.shadowRoot, this.cmHost);
+ const tabButtonsElements = this.shadowRoot.querySelectorAll("div.nav-tabs div.tab-button ");
+ for (const tabButtonsElement of tabButtonsElements) {
+ tabButtonsElement.addEventListener("click", () => {
+ for (const _tabButtonsElement of tabButtonsElements) {
+ if (_tabButtonsElement !== tabButtonsElement) {
+ _tabButtonsElement.classList.remove('active');
+ }
+ }
+ tabButtonsElement.classList.add('active');
+ this.selectFile(tabButtonsElement.getAttribute('file-name'));
+ });
+ }
+ });
+ }
+ /**
+ * select a specific file and corresponding tab
+ *
+ * @param fileName
+ */
+ selectFile(fileName) {
+ this.selectedFile = this.sources[fileName];
+ this.ch.setCode(this.selectedFile);
+ }
+ /**
+ * Runs when the element is removed from the DOM
+ */
+ disconnectedCallback() {
+ console.log('disconnected', this);
+ }
+ /**
+ *
+ */
+ get tabsButtons() {
+ return this.shadowRoot.getElementById('tabs-buttons');
+ }
+ /**
+ *
+ */
+ get loadingCurtain() {
+ return this.shadowRoot.getElementById('loading-curtain');
+ }
+ /**
+ *
+ */
+ get cmHost() {
+ return this.shadowRoot.getElementById('cm-host');
+ }
+}
+exports.default = TSVWidgetElement;
+// Define the new web component
+if ('customElements' in window) {
+ window.customElements.define('tsv-widget', TSVWidgetElement);
+}
+//# sourceMappingURL=index.js.map
\ No newline at end of file
diff --git a/dist/index.js.map b/dist/index.js.map
new file mode 100644
index 0000000..cc4d2e8
--- /dev/null
+++ b/dist/index.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,yDAAiD;AAEjD,MAAM,aAAa,GAAG,OAAO,CAAC,+BAA+B,CAAC,CAAC,QAAQ,EAAE,CAAA;AACzE,MAAM,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAEpC,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;AAEnD;;GAEG;AACH,MAAqB,gBAAiB,SAAQ,WAAW;IAWrD;;OAEG;IACH;QAEI,KAAK,EAAE,CAAA;QAbH,YAAO,GAAQ,EAAE,CAAA;QACjB,iBAAY,GAAW,IAAI,CAAA;QAc/B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,CAAA;QACtD,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,YAAY,CAAC,uBAAuB,CAAC,CAAA;QACrE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;QACvC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;QAEzC,IAAI,CAAC,YAAY,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC,CAAA;IAGrC,CAAC;IAED;;OAEG;IACG,iBAAiB;;YAEnB,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;YAEhC,IAAI,CAAC,EAAE,GAAG,IAAI,0BAAe,CACzB,IAAI,CAAC,KAAK,CACb,CAAA;YAED,MAAM,IAAI,CAAC,cAAc,EAAE,CAAA;YAE3B,MAAM,IAAI,CAAC,YAAY,EAAE,CAAA;YAEzB,MAAM,IAAI,CAAC,SAAS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,CAAA;gBAChE,CAAC,CAAC,CAAA;aAEL;QAEL,CAAC;KAAA;IAED;;;;OAIG;IACH,UAAU,CAAC,QAAQ;QAEf,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QAE1C,IAAI,CAAC,EAAE,CAAC,OAAO,CACX,IAAI,CAAC,YAAY,CACpB,CAAA;IAEL,CAAC;IAED;;OAEG;IACH,oBAAoB;QAChB,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;IACrC,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,cAAc,CAAmB,CAAC;IAC5E,CAAC;IAED;;OAEG;IACH,IAAI,cAAc;QACd,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,iBAAiB,CAAmB,CAAC;IAC/E,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,SAAS,CAAwB,CAAC;IAC5E,CAAC;CAEJ;AA9OD,mCA8OC;AAED,+BAA+B;AAC/B,IAAI,gBAAgB,IAAI,MAAM,EAAE;IAC5B,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAA;CAC/D"}
\ No newline at end of file
diff --git a/dist/tm/grammar/func.tmLanguage.json b/dist/tm/grammar/func.tmLanguage.json
new file mode 100644
index 0000000..5257588
--- /dev/null
+++ b/dist/tm/grammar/func.tmLanguage.json
@@ -0,0 +1,107 @@
+{
+ "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
+ "name": "FunC",
+ "foldingStartMarker": "\\{\\s*$",
+ "foldingStopMarker": "^\\s*\\}",
+ "patterns": [
+ {
+ "include": "#keywords"
+ },
+ {
+ "include": "#strings"
+ },
+ {
+ "include": "#directives"
+ },
+ {
+ "include": "#numeric"
+ },
+ {
+ "include": "#comments"
+ },
+ {
+ "include": "#storage"
+ },
+ {
+ "include": "#functions"
+ },
+ {
+ "include": "#variables"
+ }
+ ],
+ "repository": {
+ "keywords": {
+ "patterns": [{
+ "name": "keyword.control.",
+ "match": "\\b(if|ifnot|else|elseif|elseifnot|while|do|until|repeat|return|impure|method_id|forall|asm|inline|inline_ref)\\b"
+ }, {
+ "name": "keyword.operator",
+ "match": "(?<=\\s)(<=>|>=|<=|!=|==|\\^>>|\\~>>|>>|<<|\\/%|\\^%|\\~%|\\^\\/|\\~\\/|\\+=|-=|\\*=|\\/=|~\\/=|\\^\\/=|%=|\\^%=|<<=|>>=|~>>=|\\^>>=|&=|\\|=|\\^=|\\^|=|~|\\/|%|-|\\*|\\+|>|<|&|\\||:|\\?)(?=\\s)"
+ }, {
+ "name": "keyword.other",
+ "match": "\\b(false|true)\\b"
+ }]
+ },
+ "directives": {
+ "name": "storage.modifier.import",
+ "begin": "#include|#pragma",
+ "end": ";",
+ "patterns": [{
+ "begin": "\"",
+ "end": "\"",
+ "name": "string.quoted.double"
+ }, {
+ "match": "(>=|<=|=|>|<|\\^)?([0-9]+)(.[0-9]+)?(.[0-9]+)?",
+ "name": "constant.numeric"
+ }]
+ },
+ "strings": {
+ "name": "string.quoted.double.",
+ "begin": "\"",
+ "end": "\"(H|h|c|u|s|a)?"
+ },
+ "numeric": {
+ "name": "constant.numeric",
+ "match": "(-?([\\d]+|0x[\\da-fA-F]+))\\b"
+ },
+ "comments": {
+ "patterns": [
+ {
+ "name": "comment.line",
+ "match": ";;(.*)"
+ },
+ {
+ "name": "comment.block",
+ "begin": "{-",
+ "end": "-}"
+ }
+ ]
+ },
+ "storage": {
+ "patterns": [{
+ "name": "storage.type",
+ "match": "\\b(var|int|slice|tuple|cell|builder|cont|_)(?=[\\s\\),\\[\\]])"
+ }, {
+ "name": "storage.modifier",
+ "match": "\\b(global|const)\\s"
+ }]
+ },
+ "variables": {
+ "patterns": [
+ {
+ "match": "(?!\")(`([^`]+)`|((?=_)_|(?={){|(?=})}|(?![_`{}]))([^;,\\[\\]\\(\\)\\s~.]+))",
+ "name": "variable.name"
+ }
+ ]
+ },
+ "functions": {
+ "patterns": [
+ {
+ "match": "(?!\")(`([^`]+)`|(\\.|~)?((?=_)_|(?={){|(?=})}|(?![_`{}]))([^;,\\[\\]\\(\\)\\s~.]+))(?=[\\(])",
+ "name": "entity.name.function"
+ }
+ ]
+ }
+ },
+ "scopeName": "source.func"
+}
diff --git a/dist/typings/code-highlighter.d.ts b/dist/typings/code-highlighter.d.ts
new file mode 100644
index 0000000..b5c6b6e
--- /dev/null
+++ b/dist/typings/code-highlighter.d.ts
@@ -0,0 +1,15 @@
+/**
+ *
+ */
+export default class CodeHighlighter {
+ private editor;
+ private readonly theme;
+ constructor(theme: string);
+ /**
+ *
+ * @param shadowRoot
+ * @param element
+ */
+ init(shadowRoot: ShadowRoot, element: HTMLTextAreaElement): Promise;
+ setCode(value: any): void;
+}
diff --git a/dist/typings/index.d.ts b/dist/typings/index.d.ts
new file mode 100644
index 0000000..4393c61
--- /dev/null
+++ b/dist/typings/index.d.ts
@@ -0,0 +1,55 @@
+/**
+ *
+ */
+export default class TSVWidgetElement extends HTMLElement {
+ private ch;
+ private sources;
+ private selectedFile;
+ private readonly ipfsProvider;
+ private verifiedContractUrl;
+ private verifiedContract;
+ private readonly theme;
+ private readonly layout;
+ /**
+ *
+ */
+ constructor();
+ /**
+ * Runs each time the element is appended to or moved in the DOM
+ */
+ connectedCallback(): Promise;
+ /**
+ * fetch sources from the verified contract json url
+ */
+ fetchSources(): Promise;
+ /**
+ * builds the external container element and appends it to the shadow root
+ */
+ buildContainer(): Promise;
+ /**
+ * builds the html tabs
+ */
+ buildTabs(): Promise;
+ /**
+ * select a specific file and corresponding tab
+ *
+ * @param fileName
+ */
+ selectFile(fileName: any): void;
+ /**
+ * Runs when the element is removed from the DOM
+ */
+ disconnectedCallback(): void;
+ /**
+ *
+ */
+ get tabsButtons(): HTMLDivElement;
+ /**
+ *
+ */
+ get loadingCurtain(): HTMLDivElement;
+ /**
+ *
+ */
+ get cmHost(): HTMLTextAreaElement;
+}
diff --git a/package.json b/package.json
index 8fc1d4f..eca5765 100644
--- a/package.json
+++ b/package.json
@@ -1,12 +1,12 @@
{
"name": "@orbs-network/tsv-widget",
"version": "0.0.1",
- "description": "Javascript Minimal Starter Kit for building libraries",
+ "description": "Ton contract code viewer for func with code highlighting ",
"main": "dist/index.js",
"scripts": {
"start": "yarn run build && webpack-dev-server --content-base . --hot --inline",
"build": "tsc --build tsconfig.json",
- "npm-publish" : "npm publish"
+ "npm-publish" : "npm publish --access=public"
},
"repository": {
"type": "git",