SILENT KILLERPanel

Current Path: > home > codekrsu > > shopceylon.store > wp-content > plugins > code-snippets > js > utils


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: /home/codekrsu//shopceylon.store/wp-content/plugins/code-snippets/js/utils

NameTypeSizeLast ModifiedActions
Linter.ts File 4545 bytes February 14 2025 13:16:14.
errors.ts File 80 bytes November 27 2024 21:52:46.
files.ts File 1110 bytes November 27 2024 21:28:50.
general.ts File 249 bytes November 27 2024 21:28:50.
restAPI.ts File 793 bytes February 14 2025 13:16:14.
shortcodes.ts File 346 bytes May 19 2023 18:41:32.
snippets.ts File 968 bytes November 27 2024 21:28:50.
text.ts File 623 bytes February 14 2025 13:16:14.

Reading File: /home/codekrsu//shopceylon.store/wp-content/plugins/code-snippets/js/utils/files.ts

import { getSnippetType } from './snippets'
import type { Snippet } from '../types/Snippet'

const SECOND_IN_MS = 1000
const TIMEOUT_SECONDS = 40

const MIME_INFO = <const> {
	php: ['php', 'text/php'],
	html: ['php', 'text/php'],
	css: ['css', 'text/css'],
	js: ['js', 'text/javascript'],
	json: ['json', 'application/json']
}

export const downloadAsFile = (content: BlobPart, filename: string, type: string) => {
	const link = document.createElement('a')
	link.download = filename
	link.href = URL.createObjectURL(new Blob([content], { type }))

	setTimeout(() => URL.revokeObjectURL(link.href), TIMEOUT_SECONDS * SECOND_IN_MS)
	setTimeout(() => link.click(), 0)
}

export const downloadSnippetExportFile = (
	content: BlobPart,
	{ id, name, scope }: Snippet,
	type?: keyof typeof MIME_INFO
) => {
	const [ext, mimeType] = MIME_INFO[type ?? getSnippetType(scope)]

	const sanitizedName = name.toLowerCase().replace(/[^\w-]+/g, '-').trim()

	const title = '' === sanitizedName ? `snippet-${id}` : sanitizedName
	const filename = `${title}.code-snippets.${ext}`

	downloadAsFile(content, filename, mimeType)
}

SILENT KILLER Tool