-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
146 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<template> | ||
<HeightResize v-slot="{small,large}" :reduce="5"> | ||
<Align direction="vertical"> | ||
<TextInput | ||
v-model="action.current.input" | ||
:height="small" | ||
upload="file" | ||
:allow="['base64', 'hex', 'upload', 'url']" | ||
encoding | ||
/> | ||
<TextOutput | ||
v-model="action.current.output" | ||
:allow="['text']" | ||
:content="output" | ||
:height="large" | ||
@success="action.save()" | ||
encoding | ||
/> | ||
</Align> | ||
</HeightResize> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import {useAction, initialize} from "@/store/action" | ||
import {createTextInput, createTextOutput} from "@/components/text" | ||
import Text from "@/helper/text"; | ||
import pako from "pako"; | ||
const action = useAction(await initialize({ | ||
input: createTextInput('base64'), | ||
output: createTextOutput('text'), | ||
})) | ||
const output = $computed(() => { | ||
if ( | ||
action.current.input.text.isEmpty() | ||
) { | ||
return Text.empty() | ||
} | ||
if (action.current.input.text.isError()) { | ||
return action.current.input.text | ||
} | ||
try { | ||
return Text.fromUint8Array(pako.inflate(action.current.input.text.toUint8Array())) | ||
} catch (e) { | ||
return Text.fromError($error(e)) | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<template> | ||
<HeightResize v-slot="{small,large}" :reduce="5"> | ||
<Align direction="vertical"> | ||
<Display> | ||
<TextInput | ||
v-model="action.current.input" | ||
:height="small" | ||
upload="file" | ||
encoding | ||
/> | ||
<template #extra> | ||
<Bool v-model="action.current.deflate" label="Deflate"/> | ||
</template> | ||
</Display> | ||
<TextOutput | ||
v-model="action.current.output" | ||
:allow="['base64','hex','down']" | ||
:content="output" | ||
:height="large" | ||
@success="action.save()" | ||
/> | ||
</Align> | ||
</HeightResize> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import {useAction, initialize} from "@/store/action" | ||
import {createTextInput, createTextOutput} from "@/components/text" | ||
import Text from "@/helper/text"; | ||
import pako from "pako"; | ||
const action = useAction(await initialize({ | ||
input: createTextInput('text'), | ||
deflate: false, | ||
output: createTextOutput('base64'), | ||
})) | ||
const output = $computed(() => { | ||
if ( | ||
action.current.input.text.isEmpty() | ||
) { | ||
return Text.empty() | ||
} | ||
if (action.current.input.text.isError()) { | ||
return action.current.input.text | ||
} | ||
try { | ||
if (!action.current.input.text.isText()) { | ||
throw new Error("input content must text / text file") | ||
} | ||
let result:Text | ||
if (action.current.deflate) { | ||
result = Text.fromUint8Array(pako.deflate(action.current.input.text.toUint8Array())) | ||
} | ||
else { | ||
result = Text.fromUint8Array(pako.gzip(action.current.input.text.toUint8Array())) | ||
} | ||
result.setExtension('.gz') | ||
return result; | ||
} catch (e) { | ||
return Text.fromError($error(e)) | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters