ver bump V1.1.0

This commit is contained in:
networkmastered 2025-03-11 00:27:05 +00:00
parent 56657f92f7
commit 4d2bac86c0
4 changed files with 90 additions and 4 deletions

3
.gitignore vendored
View file

@ -20,3 +20,6 @@ data.json
# Exclude macOS Finder (System Explorer) View States
.DS_Store
util/dictionaryBIGUnusedWiki.json
util/temp.js

74
archive/testchecks.js Normal file
View file

@ -0,0 +1,74 @@
const { encodeSafe, decodeSafe } = require("../util/runlength")
const LZ = require("../util/runlengthMatch")
const { netcompress, netdecompress } = require("../util/networkmastercompression")
const funcs = [netcompress, netdecompress, encodeSafe, decodeSafe, LZ.compress, LZ.decompress]
const names = ["netcompress", "netdecompress", "encodeSafe", "decodeSafe", "LZcompress", "LZdecompress"]
const tests = [
{ type: 0, inputs: ["hi", "type1"], output: "gAfoE" },
{ type: 0, inputs: ["hi,", "type1"], output: "gAundefined" },
{ type: 0, inputs: ["abcdefg formats", "type2"], output: "ABfUBiQDRURGdESBcEUT5kQVRF" },
{ type: 0, inputs: ["master file true", "type3"], output: "gBfoOabmMbXmNdL31dZA" },
{ type: 0, inputs: ["zygote", "type3"], output: "gBf8_D" },
{ type: 0, inputs: ["zygotezygote", "type3"], output: "gBf8_z_P" },
{ type: 0, inputs: ["hello World", "type4"], output: "ACfhello World" },
{ type: 0, inputs: ["test test test test test", "type5"], output: "gCfgw2AhtBCbDE2GIsB" },
{ type: 1, inputs: ["gAfoE"], output: "hi" },
{ type: 1, inputs: ["ACfhello World"], output: "hello World" },
{ type: 1, inputs: ["gCfgw2AhtBCbDE2GIsB"], output: "test test test test test" },
{ type: 2, inputs: ["A"], output: "A" },
{ type: 2, inputs: ["AA"], output: "AA" },
{ type: 2, inputs: ["AAA"], output: "óA" },
{ type: 2, inputs: ["AAAA"], output: "úA" },
{ type: 2, inputs: ["AAAAA"], output: "üA" },
{ type: 2, inputs: ["AAAAAA"], output: "ñA" },
{ type: 2, inputs: ["AAAAAAA"], output: "çA" },
{ type: 2, inputs: ["AAAAAAAA"], output: "¿A" },
{ type: 2, inputs: ["AAAAAAAAA"], output: "¡A" },
{ type: 2, inputs: ["AAAAAAAAAA"], output: "éáA" },
{ type: 2, inputs: ["AAAAAAAAAAA"], output: "ééA" },
{ type: 2, inputs: ["AAAAAAAAAAAA"], output: "éíA" },
{ type: 3, inputs: ["A"], output: "A" },
{ type: 3, inputs: ["AA"], output: "AA" },
{ type: 3, inputs: ["óA"], output: "AAA" },
{ type: 3, inputs: ["úA"], output: "AAAA" },
{ type: 3, inputs: ["üA"], output: "AAAAA" },
{ type: 3, inputs: ["ñA"], output: "AAAAAA" },
{ type: 3, inputs: ["çA"], output: "AAAAAAA" },
{ type: 3, inputs: ["¿A"], output: "AAAAAAAA" },
{ type: 3, inputs: ["¡A"], output: "AAAAAAAAA" },
{ type: 3, inputs: ["éáA"], output: "AAAAAAAAAA" },
{ type: 3, inputs: ["ééA"], output: "AAAAAAAAAAA" },
{ type: 3, inputs: ["éíA"], output: "AAAAAAAAAAAA" },
// { type: 0, inputs: ["hi"], output: "" },
]
var pass = 0
var fail = 0
for (let idx = 0; idx < tests.length; idx++) {
let test = tests[idx]
var name = names[test.type]
var func = funcs[test.type]
var out = ""
try {
out = func(...test.inputs)
} catch (err) {
throw new Error(err)
}
if (test.output == out) {
console.log(`\u001b[32mTest ${name} ${idx + 1}. Passed ✔\u001b[30m`)
pass++
} else {
console.log(`\u001b[31mTest ${name} ${idx + 1}. Failed ❌(${out} ~= ${test.output})\u001b[30m`)
fail++
}
}
console.log(`Finished. \u001b[32m${pass} have passed\u001b[31m ${fail} have failed \u001b[32m${pass}\u001b[30m/\u001b[31m${fail}\u001b[30m`)
if (fail > 0) {
throw new Error("failed")
}

13
main.ts
View file

@ -44,7 +44,8 @@ export default class compressorPlugin extends Plugin {
hook.editor.refresh = () => { }
globalLeafs.push(["ctxt", file.path, hook])
this.app.vault.read(file).then((data) => {
if (file && data && (!data.includes("\n") && !data.includes(" "))) {
// if (file && data && (!data.includes("\n") && !data.includes(" "))) {
if (file && data && checkCompFile(data)) {
new Notice("Attempting to load.")
setTimeout(() => {
let decompress = null
@ -81,7 +82,8 @@ export default class compressorPlugin extends Plugin {
if (file2 && file2.extension == "ctxt") {
this.app.vault.read(file2).then((data) => {
if (statusBarItemEl2 && this.settings.FileSize) statusBarItemEl2.setText(data.length + "B")
if (file2 && data && (data.includes("\n") || data.includes(" "))) {
// if (file2 && data && (data.includes("\n") || data.includes(" "))) {
if (file2 && data && checkCompFile(data)) {
let compress = null
try {
NoticePool.forEach((n) => {
@ -343,6 +345,13 @@ function decompressfile(data: string, notice?: boolean) {
if (result == "" || !result) throw new Error("Empty")
return result
}
function checkCompFile(data: string) {
var state = false
try {
state = netdecompress(data) == ""
} catch (_) { }
return state
}
class compressorSettings extends PluginSettingTab {
plugin: compressorPlugin;

View file

@ -1,11 +1,11 @@
{
"name": "compress",
"version": "1.0.0",
"version": "1.1.0",
"description": "Make your files smaller with compression!",
"main": "main.js",
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"build": "node archive/testchecks.js && tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"version": "node version-bump.mjs && git add manifest.json versions.json"
},
"keywords": [],