Removed jsrender from vendor list and importing it as npm module

canary
WolverinDEV 2020-07-19 19:05:06 +02:00
parent cc3e9134ef
commit 0aeb64ed15
9 changed files with 48 additions and 48 deletions

View File

@ -61,13 +61,6 @@ const loader_javascript = {
await loader.scripts.load_multiple(["vendor/jquery/jquery.min.js"], { cache_tag: cache_tag() }, LoaderTaskCallback(taskId));
}
await loader.scripts.load_multiple([
["vendor/jsrender/jsrender.min.js"],
], {
cache_tag: cache_tag(),
max_parallel_requests: -1
}, LoaderTaskCallback(taskId));
loader.setCurrentTaskName(taskId, "manifest");
let manifest: Manifest;
try {

47
package-lock.json generated
View File

@ -1369,6 +1369,14 @@
"integrity": "sha512-7+2BITlgjgDhH0vvwZU/HZJVyk+2XUlvxXe8dFMedNX/aMkaOq++rMAFXc0tM7ij15QaWlbdQASBR9dihi+bDQ==",
"dev": true
},
"@types/jsrender": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@types/jsrender/-/jsrender-1.0.5.tgz",
"integrity": "sha512-Fjdp5QACaBMsd5vpx9x27rggFa0nyd8zqWnuTw8Aum4+gM/NiQubb6pweE3sgfHwrjRh7BGjYydpE4WYbsB+Ow==",
"requires": {
"jsrender": "*"
}
},
"@types/loader-utils": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@types/loader-utils/-/loader-utils-1.1.3.tgz",
@ -3464,8 +3472,7 @@
"core-util-is": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
"dev": true
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
},
"create-ecdh": {
"version": "4.0.3",
@ -7189,8 +7196,7 @@
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"dev": true
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"ini": {
"version": "1.3.5",
@ -7547,8 +7553,7 @@
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
"dev": true
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"isexe": {
"version": "2.0.0",
@ -7694,6 +7699,25 @@
"verror": "1.10.0"
}
},
"jsrender": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/jsrender/-/jsrender-1.0.7.tgz",
"integrity": "sha512-+zFdpE2/yy076rbnfGKVTom+qY3McZ6IeWK/8WAB/3O4SMel3Ad4DrW6KeNApPhRyIeH83oEl8vH8RxsrpoapA==",
"requires": {
"through2": "^3.0.1"
},
"dependencies": {
"through2": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/through2/-/through2-3.0.2.tgz",
"integrity": "sha512-enaDQ4MUyP2W6ZyT6EsMzqBPZaM/avg8iuo+l2d3QCs0J+6RaqkHV/2/lOwDTueBHeJ/2LG9lrLW3d5rWPucuQ==",
"requires": {
"inherits": "^2.0.4",
"readable-stream": "2 || 3"
}
}
}
},
"just-debounce": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/just-debounce/-/just-debounce-1.0.0.tgz",
@ -9738,8 +9762,7 @@
"process-nextick-args": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
"dev": true
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
},
"promise-inflight": {
"version": "1.0.1",
@ -10008,7 +10031,6 @@
"version": "2.3.7",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
"integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
"dev": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
@ -10766,8 +10788,7 @@
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"dev": true
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"safe-regex": {
"version": "1.1.0",
@ -11747,7 +11768,6 @@
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"dev": true,
"requires": {
"safe-buffer": "~5.1.0"
}
@ -12841,8 +12861,7 @@
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
"dev": true
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"util.promisify": {
"version": "1.0.0",

View File

@ -88,11 +88,13 @@
},
"homepage": "https://www.teaspeak.de",
"dependencies": {
"@types/jsrender": "^1.0.5",
"detect-browser": "^5.1.1",
"dompurify": "^2.0.8",
"emoji-mart": "git+https://github.com/WolverinDEV/emoji-mart.git",
"emoji-regex": "^9.0.0",
"highlight.js": "^10.1.1",
"jsrender": "^1.0.7",
"moment": "^2.24.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",

View File

@ -88,14 +88,14 @@ const group_mode: GroupMode = GroupMode.PREFIX;
//Level Example A: <url>?log.level.trace.enabled=0
//Level Example B: <url>?log.level=0
export function initialize(default_level: LogType) {
for(const category of Object.keys(LogCategory).map(parseInt).filter(e => !isNaN(e))) {
for(const category of Object.keys(LogCategory).map(e => parseInt(e)).filter(e => !isNaN(e))) {
const categoryName = LogCategory[category].toLowerCase();
enabled_mapping.set(category, settings.static_global(Settings.FN_LOG_ENABLED(categoryName), enabled_mapping.get(category)));
}
const base_level = settings.static_global(Settings.KEY_LOG_LEVEL, default_level);
for(const level of Object.keys(LogType).map(parseInt).filter(e => !isNaN(e))) {
for(const level of Object.keys(LogType).map(e => parseInt(e)).filter(e => !isNaN(e))) {
const levelName = LogType[level].toLowerCase();
level_mapping.set(level, settings.static_global(Settings.FN_LOG_LEVEL_ENABLED(levelName), level >= base_level));
}

View File

@ -41,8 +41,6 @@ import "./ui/elements/ContextDivider";
import "./ui/elements/Tab";
import "./connection/CommandHandler"; /* else it might not get bundled because only the backends are accessing it */
const js_render = window.jsrender || $;
declare global {
interface Window {
open_connected_question: () => Promise<boolean>;
@ -102,32 +100,28 @@ function setup_close() {
}
function setup_jsrender() : boolean {
if(!js_render) {
loader.critical_error("Missing jsrender extension!");
return false;
}
if(!js_render.views) {
if(!$.views) {
loader.critical_error("Missing jsrender viewer extension!");
return false;
}
js_render.views.settings.allowCode(true);
js_render.views.tags("rnd", (argument) => {
$.views.settings.allowCode(true);
$.views.tags("rnd", (argument) => {
let min = parseInt(argument.substr(0, argument.indexOf('~')));
let max = parseInt(argument.substr(argument.indexOf('~') + 1));
return (Math.round(Math.random() * (min + max + 1) - min)).toString();
});
js_render.views.tags("fmt_date", (...args) => {
$.views.tags("fmt_date", (...args) => {
return moment(args[0]).format(args[1]);
});
js_render.views.tags("tr", (...args) => {
$.views.tags("tr", (...args) => {
return /* @tr-ignore */ tr(args[0]);
});
$(".jsrender-template").each((idx, _entry) => {
if(!js_render.templates(_entry.id, _entry.innerHTML)) {
if(!$.templates(_entry.id, _entry.innerHTML)) {
log.error(LogCategory.GENERAL, tr("Failed to setup cache for js renderer template %s!"), _entry.id);
} else
log.info(LogCategory.GENERAL, tr("Successfully loaded jsrender template %s"), _entry.id);

View File

@ -1,5 +1,9 @@
//Used by CertAccept popup
/* setup jsrenderer */
import * as jsrenderInit from "jsrender";
const jsrender = jsrenderInit($);
declare global {
function setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
function setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number;
@ -19,7 +23,6 @@ declare global {
type JQueryScrollType = "height" | "width";
interface JQuery<TElement = HTMLElement> {
render(values?: any) : string;
renderTag(values?: any) : JQuery<TElement>;
hasScrollBar(direction?: JQueryScrollType) : boolean;
@ -33,7 +36,6 @@ declare global {
interface JQueryStatic<TElement extends Node = HTMLElement> {
spawn<K extends keyof HTMLElementTagNameMap>(tagName: K): JQuery<HTMLElementTagNameMap[K]>;
views: any;
}
interface Window {
@ -43,7 +45,6 @@ declare global {
readonly webkitOfflineAudioContext: typeof OfflineAudioContext;
readonly RTCPeerConnection: typeof RTCPeerConnection;
readonly Pointer_stringify: any;
readonly jsrender: any;
readonly require: typeof require;
}
@ -170,7 +171,7 @@ if(typeof ($) !== "undefined") {
if(this.render) {
result = $(this.render(values));
} else {
const template = window.jsrender.render[this.attr("id")];
const template = jsrender.render[this.attr("id")];
if(!template) {
console.error("Tried to render template %o, but template is not available!", this.attr("id"));
throw "missing template " + this.attr("id");

View File

@ -6,7 +6,6 @@ import {spawnYesNo} from "tc-shared/ui/modal/ModalYesNo";
import {ClientEntry} from "tc-shared/ui/client";
import * as log from "tc-shared/log";
import * as moment from "moment";
import {media_image_type} from "tc-shared/file/ImageCache";
const avatar_to_uid = (id: string) => {
const buffer = new Uint8Array(id.length / 2);

View File

@ -1,7 +1,3 @@
/// <reference path="../../ui/elements/modal.ts" />
/// <reference path="../../ConnectionHandler.ts" />
/// <reference path="../../proto.ts" />
import PermissionType from "tc-shared/permission/PermissionType";
import {ConnectionHandler} from "tc-shared/ConnectionHandler";
import {createModal} from "tc-shared/ui/elements/Modal";

File diff suppressed because one or more lines are too long