mirror of
https://github.com/divkit/divkit.git
synced 2026-05-07 20:02:32 +00:00
Fix site checks
This commit is contained in:
@@ -14713,6 +14713,7 @@
|
||||
"site/client/src/schema/root.json":"divkit/public/site/client/src/schema/root.json",
|
||||
"site/client/src/styles/monaco-fixes.css":"divkit/public/site/client/src/styles/monaco-fixes.css",
|
||||
"site/client/src/types/monacoEnv.d.ts":"divkit/public/site/client/src/types/monacoEnv.d.ts",
|
||||
"site/client/src/types/webpack.d.ts":"divkit/public/site/client/src/types/webpack.d.ts",
|
||||
"site/client/src/utils/capitalize.ts":"divkit/public/site/client/src/utils/capitalize.ts",
|
||||
"site/client/src/utils/const.ts":"divkit/public/site/client/src/utils/const.ts",
|
||||
"site/client/src/utils/debounce.ts":"divkit/public/site/client/src/utils/debounce.ts",
|
||||
@@ -14722,6 +14723,7 @@
|
||||
"site/client/src/utils/shortcut.ts":"divkit/public/site/client/src/utils/shortcut.ts",
|
||||
"site/client/src/utils/shortcuts.ts":"divkit/public/site/client/src/utils/shortcuts.ts",
|
||||
"site/client/src/utils/templatesCheck.ts":"divkit/public/site/client/src/utils/templatesCheck.ts",
|
||||
"site/client/src/utils/truthy.ts":"divkit/public/site/client/src/utils/truthy.ts",
|
||||
"site/client/src/utils/useShortcuts.ts":"divkit/public/site/client/src/utils/useShortcuts.ts",
|
||||
"site/client/tsconfig.json":"divkit/public/site/client/tsconfig.json",
|
||||
"site/client/webpack.config.js":"divkit/public/site/client/webpack.config.js",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import Header from './Header.svelte';
|
||||
import Main from './Main.svelte';
|
||||
import { setContext } from 'svelte';
|
||||
import { derived, get, Writable, writable } from 'svelte/store';
|
||||
import { derived, get, writable } from 'svelte/store';
|
||||
import { LANGUAGE_CTX, LanguageContext } from '../data/languageContext';
|
||||
import translations from '../auto/lang.json';
|
||||
import PointingPopup from './PointingPopup.svelte';
|
||||
@@ -11,6 +11,7 @@
|
||||
import { isInitialLoading, isLoadError } from '../data/session';
|
||||
import Loader from './Loader.svelte';
|
||||
import ErrorPage from './ErrorPage.svelte';
|
||||
import type langObj from '../auto/lang.json';
|
||||
|
||||
let langVal = (location.pathname.match(/(\w+)\/playground/) || [])[1] || 'en';
|
||||
if (langVal !== 'ru' && langVal !== 'en') {
|
||||
@@ -18,7 +19,8 @@
|
||||
}
|
||||
let lang = writable(langVal);
|
||||
const l10n = derived(lang, lang => {
|
||||
return (key: string, overrideLang?: string) =>
|
||||
return (key: keyof typeof langObj['en'], overrideLang?: string) =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(translations as any)[overrideLang || lang]?.[key] || '';
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script lang="ts" context="module">
|
||||
import * as monaco from 'monaco-editor';
|
||||
//@ts-ignore
|
||||
import tsBuilderTypes from '../../artifacts/jsonbuilder.d.ts?inline';
|
||||
|
||||
const jsonModelUri = monaco.Uri.parse('a://b/divview.json');
|
||||
@@ -76,14 +75,18 @@
|
||||
|
||||
const {l10n} = getContext<LanguageContext>(LANGUAGE_CTX);
|
||||
|
||||
const LANGUAGE_NAMES = {
|
||||
type Language = 'json' | 'ts';
|
||||
|
||||
const LANGUAGE_NAMES: Record<Language, string> = {
|
||||
json: 'JSON',
|
||||
ts: 'TypeScript'
|
||||
};
|
||||
|
||||
const LANGUAGE_KEYS: Language[] = ['json', 'ts'];
|
||||
|
||||
let editor: monaco.editor.IStandaloneCodeEditor | null = null;
|
||||
let node: HTMLElement;
|
||||
let currentLanguage = '';
|
||||
let currentLanguage: Language = 'json';
|
||||
let isRunning = false;
|
||||
let runButton: HTMLElement;
|
||||
|
||||
@@ -215,7 +218,7 @@
|
||||
<PanelHeader>
|
||||
<Select
|
||||
bind:value={currentLanguage}
|
||||
items={['json', 'ts'].map(value => ({value, name: LANGUAGE_NAMES[value]}))}
|
||||
items={LANGUAGE_KEYS.map(value => ({value, name: LANGUAGE_NAMES[value]}))}
|
||||
toggledClass="editor__toggled-select" slot="left"
|
||||
on:change={onLanguageChange}
|
||||
>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
export let name = '';
|
||||
export let comma = false;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export let json: any;
|
||||
export let level = 0;
|
||||
export let expanded = false;
|
||||
@@ -26,10 +27,12 @@
|
||||
{#if Array.isArray(json)}
|
||||
{#if expanded}
|
||||
<div class="json-view__row">
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div class="json-view__collapse" on:click={() => expanded = false} title={$l10n('collapse')}></div>
|
||||
{'['}
|
||||
</div>
|
||||
{:else}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div class="json-view__toggler" on:click={() => expanded = true} title={$l10n('expand')}>
|
||||
{`[ ${json.length} item${json.length > 1 ? 's' : ''} ]`}
|
||||
</div>
|
||||
@@ -37,10 +40,12 @@
|
||||
{:else if json && typeof json === 'object'}
|
||||
{#if expanded}
|
||||
<div class="json-view__row">
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div class="json-view__collapse" on:click={() => expanded = false} title={$l10n('collapse')}></div>
|
||||
{'{'}
|
||||
</div>
|
||||
{:else}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div class="json-view__toggler" on:click={() => expanded = true}>
|
||||
{'{...}'}
|
||||
</div>
|
||||
|
||||
@@ -17,25 +17,21 @@
|
||||
let alreadySaved = Boolean($session.uuid);
|
||||
let promise: Promise<void>;
|
||||
let linkToEdit = '';
|
||||
let linkToPreview = '';
|
||||
// let linkToPreview = '';
|
||||
let linkToJSON = '';
|
||||
let qr = '';
|
||||
|
||||
function setUuid(res: {
|
||||
async function setUuid(res: {
|
||||
uuid: string;
|
||||
linkToEdit: string;
|
||||
linkToPreview: string;
|
||||
linkToJSON: string;
|
||||
}) {
|
||||
return Promise.resolve().then(() => {
|
||||
linkToEdit = res.linkToEdit;
|
||||
linkToPreview = res.linkToPreview;
|
||||
linkToJSON = res.linkToJSON;
|
||||
linkToEdit = res.linkToEdit;
|
||||
// linkToPreview = res.linkToPreview;
|
||||
linkToJSON = res.linkToJSON;
|
||||
|
||||
return QRCode.toDataURL(linkToJSON);
|
||||
}).then(url => {
|
||||
qr = url;
|
||||
});
|
||||
qr = await QRCode.toDataURL(linkToJSON);
|
||||
}
|
||||
|
||||
function onCancel(): void {
|
||||
@@ -59,7 +55,7 @@
|
||||
{#if alreadySaved}
|
||||
{#await promise}
|
||||
<div class="links-popup__loading"></div>
|
||||
{:then res}
|
||||
{:then _res}
|
||||
<div class="links-popup__content">
|
||||
<div class="links-popup__row">
|
||||
<label class="links-popup__label">
|
||||
@@ -108,7 +104,7 @@
|
||||
</div>
|
||||
<img class="links-popup__qr" src={qr} alt={$l10n('qrCode')}>
|
||||
</div>
|
||||
{:catch err}
|
||||
{:catch _err}
|
||||
<div class="links-popup__content">
|
||||
{$l10n('loadError')}
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
import { onMount } from 'svelte';
|
||||
import type { Platform, DivkitInstance, DivExtensionClass } from '../../../../client/web/divkit/typings/common';
|
||||
import { jsonStore } from '../data/jsonStore';
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
import { render as divkitRender, SizeProvider, lottieExtensionBuilder } from '../../artifacts/client-devtool.mjs';
|
||||
import '../../artifacts/client.css';
|
||||
import Lottie from 'lottie-web/build/player/lottie_light';
|
||||
@@ -11,6 +13,7 @@
|
||||
let rootPreview: HTMLElement;
|
||||
let divBlock: DivkitInstance | null = null;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function rerender(json: any): void {
|
||||
if (!rootPreview) {
|
||||
return;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import Viewer from './Viewer.svelte';
|
||||
import { isSamples } from '../data/session';
|
||||
import Samples from './Samples.svelte';
|
||||
import { Truthy } from '../utils/truthy';
|
||||
|
||||
$: components = [$isSamples && {
|
||||
component: Samples,
|
||||
@@ -15,7 +16,7 @@
|
||||
component: Viewer,
|
||||
weight: 3,
|
||||
minWidth: 450
|
||||
}].filter(Boolean);
|
||||
}].filter(Truthy);
|
||||
</script>
|
||||
|
||||
<main class="main">
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
<div class="pointing-popup__content">
|
||||
{msg}
|
||||
</div>
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div class="pointing-popup__close" on:click={onCloseClick}></div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -32,9 +32,10 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div
|
||||
class={'select' + (popupShown && toggledClass ? ' ' + toggledClass : '')}
|
||||
on:сдшсл={onMouseEnterOrClick}
|
||||
on:click={onMouseEnterOrClick}
|
||||
on:mouseenter={onMouseEnterOrClick}
|
||||
on:mouseleave={onMouseLeave}
|
||||
>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script lang="ts">
|
||||
import type { SvelteComponent } from 'svelte';
|
||||
import type { ComponentType } from 'svelte';
|
||||
|
||||
export let components: {
|
||||
component: typeof SvelteComponent;
|
||||
component: ComponentType;
|
||||
weight: number;
|
||||
minWidth?: number;
|
||||
}[];
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
</script>
|
||||
|
||||
<div class="structure-current">
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div class="structure-current__title" on:click={toggle}>
|
||||
{$l10n('currentComponent')}
|
||||
</div>
|
||||
|
||||
@@ -13,9 +13,11 @@
|
||||
$: origJson = $selectedLeaf?.props.origJson;
|
||||
let jsonList: {
|
||||
title: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
json: any;
|
||||
}[] = [];
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function updateJsonList(origJson: any) {
|
||||
jsonList = [];
|
||||
|
||||
@@ -52,6 +54,7 @@
|
||||
</script>
|
||||
|
||||
<div class="structure-templates">
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div class="structure-templates__title" on:click={toggle}>
|
||||
{$l10n('appliedTemplates')}
|
||||
</div>
|
||||
|
||||
@@ -173,6 +173,7 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
||||
<div class="tree" tabindex="0" on:keydown={onKeydown} bind:this={rootNode}>
|
||||
{#if showRoot}
|
||||
<TreeLeafView leaf={root} on:selected={onChildSelect} on:hovered={onChildHover} />
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div
|
||||
class="tree-leaf"
|
||||
class:tree-leaf_alternate-hovered={alternateHover}
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
|
||||
<ViewerPanels
|
||||
type={isWebViewer(currentViewerObj) ? 'web' : 'external'}
|
||||
errors={isWebViewer(currentViewerObj) ? $webViewerErrors : currentViewerObj.lastState?.errors}
|
||||
errors={isWebViewer(currentViewerObj) ? $webViewerErrors : currentViewerObj.lastState?.errors || []}
|
||||
/>
|
||||
<!-- <ErrorView errors={$convertToJsonStore.length ? $convertToJsonStore : currentViewerObj.lastState?.errors} />-->
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
<script lang="ts">
|
||||
import { getContext } from 'svelte';
|
||||
import { LANGUAGE_CTX, LanguageContext } from '../data/languageContext';
|
||||
import Select from './Select.svelte';
|
||||
|
||||
// const {l10n} = getContext<LanguageContext>(LANGUAGE_CTX);
|
||||
@@ -38,8 +36,8 @@
|
||||
|
||||
export let value = '';
|
||||
let selectVal = '';
|
||||
let customWidth = '200';
|
||||
let customHeight = '200';
|
||||
// let customWidth = '200';
|
||||
// let customHeight = '200';
|
||||
|
||||
$: {
|
||||
if (!value) {
|
||||
@@ -48,21 +46,21 @@
|
||||
throw Error('No default variant');
|
||||
}
|
||||
value = selectVal = def.value;
|
||||
const parts = value.split('x');
|
||||
/* const parts = value.split('x');
|
||||
if (parts.length === 2) {
|
||||
customWidth = parts[0];
|
||||
customHeight = parts[1];
|
||||
}
|
||||
} */
|
||||
}
|
||||
}
|
||||
|
||||
function onChange(): void {
|
||||
if (selectVal !== 'custom') {
|
||||
const parts = selectVal.split('x');
|
||||
/* const parts = selectVal.split('x');
|
||||
if (parts.length === 2) {
|
||||
customWidth = parts[0];
|
||||
customHeight = parts[1];
|
||||
}
|
||||
} */
|
||||
value = selectVal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
import { getContext, onDestroy, onMount } from 'svelte';
|
||||
import { get } from 'svelte/store';
|
||||
import type { DivkitInstance, DivExtensionClass } from '../../../../client/web/divkit/typings/common';
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
import { render as divkitRender, SizeProvider, lottieExtensionBuilder } from '../../artifacts/client-devtool.mjs';
|
||||
import '../../artifacts/client.css';
|
||||
import ViewportSelect from './ViewportSelect.svelte';
|
||||
@@ -24,10 +26,10 @@
|
||||
import { sampleWarningStore } from '../data/sampleWarningStore';
|
||||
import { templatesCheck } from '../utils/templatesCheck';
|
||||
import Lottie from 'lottie-web/build/player/lottie_light';
|
||||
import type { ComponentProps } from '../data/webStructure';
|
||||
|
||||
const {l10n} = getContext<LanguageContext>(LANGUAGE_CTX);
|
||||
|
||||
let json;
|
||||
let viewport = '';
|
||||
let platform: 'desktop' | 'touch' | 'auto' = 'auto';
|
||||
$: splitted = viewport.split('x');
|
||||
@@ -98,6 +100,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function rerender(json: any, platform: 'desktop' | 'touch' | 'auto'): void {
|
||||
if (!rootPreview) {
|
||||
return;
|
||||
@@ -120,7 +123,12 @@
|
||||
['size_provider', SizeProvider],
|
||||
['lottie', lottieExtensionBuilder(Lottie.loadAnimation)],
|
||||
]),
|
||||
onError(event) {
|
||||
onError(event: {
|
||||
error: Error & {
|
||||
level: 'error' | 'warn';
|
||||
additional?: Record<string, unknown>;
|
||||
};
|
||||
}) {
|
||||
const additional = event.error.additional || {};
|
||||
|
||||
let args = Object.keys(additional).reduce((acc: string[], item: string) => {
|
||||
@@ -137,7 +145,10 @@
|
||||
}
|
||||
];
|
||||
},
|
||||
onComponent(event) {
|
||||
onComponent(event: ComponentProps & {
|
||||
type: 'mount' | 'destroy';
|
||||
node: HTMLElement;
|
||||
}) {
|
||||
++count;
|
||||
if (event.type === 'mount') {
|
||||
components.set(event.node, event);
|
||||
@@ -236,6 +247,7 @@
|
||||
{#if $highlightMode}
|
||||
<div class="web-viewer__content-highlight-overlay-wrapper">
|
||||
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div
|
||||
class="web-viewer__content-highlight-overlay"
|
||||
on:mousemove={onHighlightOverlayMove}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import WebViewer from './WebViewer.svelte';
|
||||
import WebViewerSidebar from './WebViewerSidebar.svelte';
|
||||
import { panelStructure } from '../data/panels';
|
||||
import { Truthy } from '../utils/truthy';
|
||||
|
||||
$: components = [{
|
||||
component: WebViewer,
|
||||
@@ -12,7 +13,7 @@
|
||||
component: WebViewerSidebar,
|
||||
weight: 3,
|
||||
minWidth: 50
|
||||
}].filter(Boolean);
|
||||
}].filter(Truthy);
|
||||
</script>
|
||||
|
||||
<main class="web-viewer-wrapper">
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { Writable } from 'svelte/store';
|
||||
|
||||
export interface TreeLeaf {
|
||||
id: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
props: any;
|
||||
parent?: TreeLeaf;
|
||||
childs: TreeLeaf[];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { get, writable } from 'svelte/store';
|
||||
import { session } from './session';
|
||||
import { addListener, wsPromise } from './ws';
|
||||
import { /* get, */ writable } from 'svelte/store';
|
||||
/* import { session } from './session';
|
||||
import { addListener, wsPromise } from './ws'; */
|
||||
|
||||
export interface Device {
|
||||
/** @deprecated -> os_name */
|
||||
@@ -47,7 +47,7 @@ export interface ViewerError {
|
||||
level?: 'error' | 'warn';
|
||||
}
|
||||
|
||||
let currentViewers: ExternalViewer[] = [];
|
||||
const currentViewers: ExternalViewer[] = [];
|
||||
export const externalViewers = writable(currentViewers);
|
||||
|
||||
/*let prevListen: string | null = null;
|
||||
|
||||
@@ -4,6 +4,7 @@ import { valueStore } from './valueStore';
|
||||
import { editorMode } from './editorMode';
|
||||
|
||||
export const convertToJsonErrorsStore = writable<ViewerError[]>([]);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export const jsonStore = writable<any>({});
|
||||
|
||||
function updateJson(): void {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import type { Readable } from 'svelte/store';
|
||||
import type lang from '../auto/lang.json';
|
||||
|
||||
export const LANGUAGE_CTX = Symbol('language');
|
||||
|
||||
export interface LanguageContext {
|
||||
lang: Readable<string>;
|
||||
getLanguage(): string;
|
||||
setLanguage(name: string): void;
|
||||
languagesList(): string[];
|
||||
l10n(key: keyof typeof lang['en'], overrideLang?: string): string;
|
||||
l10n: Readable<(key: keyof typeof lang['en'], overrideLang?: string) => string>;
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ import { savedStore } from './savedStore';
|
||||
import { editorMode } from './editorMode';
|
||||
import { jsonStore } from './jsonStore';
|
||||
// import { viewModeStore } from './viewModeStore';
|
||||
import { addListener, wsPromise } from './ws';
|
||||
// import { addListener, wsPromise } from './ws';
|
||||
// import { listenToDevices } from './externalViewers';
|
||||
import { getLs, setLs } from '../utils/localStorage';
|
||||
|
||||
function listenJsonForPreview(uuid: string): void {
|
||||
/* function listenJsonForPreview(uuid: string): void {
|
||||
wsPromise.then(ws => {
|
||||
ws.send(JSON.stringify({
|
||||
type: 'listen',
|
||||
@@ -25,15 +25,15 @@ function listenJsonForPreview(uuid: string): void {
|
||||
jsonStore.set(msg.message.json);
|
||||
}
|
||||
});
|
||||
}
|
||||
} */
|
||||
|
||||
let mode = '';
|
||||
// let mode = '';
|
||||
|
||||
async function init() {
|
||||
const params = new URLSearchParams(location.search);
|
||||
|
||||
const uuid = params.get('uuid');
|
||||
mode = params.get('mode') || '';
|
||||
// mode = params.get('mode') || '';
|
||||
|
||||
const samples = params.get('samples') === '1';
|
||||
|
||||
@@ -80,7 +80,7 @@ async function init() {
|
||||
editorMode.set(res.language);
|
||||
|
||||
isInitialLoading.set(false);
|
||||
}).catch(_err => {
|
||||
}).catch(() => {
|
||||
isLoadError.set(true);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,19 +2,21 @@ import { serverHostPath, isProd } from '../utils/const';
|
||||
|
||||
// todo reconnect
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
type Listener = (msg: any) => void;
|
||||
const listeners: Listener[] = [];
|
||||
|
||||
export const wsPromise = new Promise<WebSocket>(resolve => {
|
||||
const ws = new WebSocket((isProd ? 'wss://' : 'ws://') + serverHostPath);
|
||||
let connected = false;
|
||||
// let connected = false;
|
||||
|
||||
ws.onopen = () => {
|
||||
connected = true;
|
||||
// connected = true;
|
||||
resolve(ws);
|
||||
};
|
||||
|
||||
ws.onmessage = msg => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let json: any;
|
||||
try {
|
||||
json = JSON.parse(msg.data);
|
||||
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
declare module '*?inline' {
|
||||
const content: string;
|
||||
export = content;
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export function debounce<F extends (...args: any[]) => any>(func: F, wait: number): F {
|
||||
let timeout: ReturnType<typeof setTimeout>;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return ((...args: any[]) => {
|
||||
clearTimeout(timeout);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ function getTemplateProps(part: unknown): string[] {
|
||||
|
||||
if (part && typeof part === 'object') {
|
||||
for (const key in part) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const val = (part as any)[key];
|
||||
if (key.startsWith('$')) {
|
||||
if (typeof val === 'string') {
|
||||
@@ -21,6 +22,7 @@ function getTemplateProps(part: unknown): string[] {
|
||||
return res;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export function templatesCheck(json: any): ViewerError[] {
|
||||
if (!(json.templates && typeof json.templates === 'object')) {
|
||||
return [];
|
||||
@@ -33,6 +35,7 @@ export function templatesCheck(json: any): ViewerError[] {
|
||||
const template = json.templates[key];
|
||||
const props = getTemplateProps((template));
|
||||
templateProps.set(key, props);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (err: any) {
|
||||
return [{
|
||||
message: err.message,
|
||||
@@ -46,6 +49,7 @@ export function templatesCheck(json: any): ViewerError[] {
|
||||
|
||||
const templateDeps = new Map<string, string[]>();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const procTemplate = (name: string, template: any): string[] => {
|
||||
if (!template || !('type' in template)) {
|
||||
throw new Error('Cannot process template without "type"');
|
||||
@@ -64,6 +68,7 @@ export function templatesCheck(json: any): ViewerError[] {
|
||||
try {
|
||||
const template = json.templates[key];
|
||||
templateDeps.set(key, procTemplate(key, template));
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (err: any) {
|
||||
return [{
|
||||
message: err.message,
|
||||
@@ -73,6 +78,7 @@ export function templatesCheck(json: any): ViewerError[] {
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const checkTemplate = (name: string, template: any) => {
|
||||
const parent = template.type;
|
||||
const deps = templateDeps.get(parent);
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export const Truthy = Boolean as unknown as <T>(x: T | null | 0 | '' | false | undefined) => x is T;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
const fs = require('fs');
|
||||
// const fs = require('fs');
|
||||
|
||||
const WebSocket = require('ws');
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const Redis = require("ioredis");
|
||||
const Redis = require('ioredis');
|
||||
|
||||
module.exports = {
|
||||
publishJsonUpdate,
|
||||
@@ -19,7 +19,7 @@ const hostsDesc = hosts.map(host => ({host, port}));
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
connectOptions = [{
|
||||
sentinels: hostsDesc,
|
||||
name: "divview-message-queue",
|
||||
name: 'divview-message-queue',
|
||||
password,
|
||||
family: 6
|
||||
}];
|
||||
@@ -84,7 +84,7 @@ async function subscribeJsonUpdate(uuid, fn) {
|
||||
subscribers[uuid] = fn;
|
||||
clusterForSubscribe.subscribe(updateJsonChannel + ':' + uuid, (err, count) => {
|
||||
if (err) {
|
||||
console.error("Failed to subscribe: %s", err.message);
|
||||
console.error('Failed to subscribe: %s', err.message);
|
||||
} else {
|
||||
console.log(
|
||||
`Redis subscribed to ${uuid} successfully! This client is currently subscribed to ${count} channels.`
|
||||
|
||||
Reference in New Issue
Block a user