Skip to content

Commit

Permalink
0.1.4: support hiding paths
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj committed Sep 28, 2023
1 parent 71580d6 commit c353cc7
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@libreservice/wasm-code",
"version": "0.1.3",
"version": "0.1.4",
"main": "dist/index.js",
"type": "module",
"files": [
Expand All @@ -22,24 +22,24 @@
},
"sideEffects": false,
"devDependencies": {
"@babel/runtime": "^7.22.11",
"@codemirror/language": "^6.9.0",
"@babel/runtime": "^7.23.1",
"@codemirror/language": "^6.9.1",
"@codemirror/state": "^6.2.1",
"@codemirror/view": "^6.16.0",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@uiw/codemirror-theme-vscode": "^4.21.10",
"@codemirror/view": "^6.20.2",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@uiw/codemirror-theme-vscode": "^4.21.18",
"@vicons/material": "^0.12.0",
"@vitejs/plugin-vue": "^4.3.3",
"@vitejs/plugin-vue": "^4.3.4",
"client-zip": "^2.4.4",
"codemirror": "^6.0.1",
"eslint": "^8.48.0",
"eslint": "^8.50.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-vue": "^9.17.0",
"naive-ui": "^2.34.4",
"typescript": "^5.2.2",
"vite": "^4.4.9",
"vue": "^3.3.4",
"vue-tsc": "^1.8.8"
"vue-tsc": "^1.8.15"
},
"peerDependencies": {
"vue": "^3.2.0",
Expand Down
5 changes: 5 additions & 0 deletions src/FileManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
const props = defineProps<{
fs: ASYNC_FS
height: string
hidePath?: HidePath
onOpenFile: HandlerZeroAction
onNewFile: HandlerOneAction
onNewFolder: HandlerOneAction
Expand All @@ -24,6 +25,7 @@ const props = defineProps<{
const {
fs,
hidePath,
onOpenFile,
onNewFile,
onNewFolder,
Expand Down Expand Up @@ -312,6 +314,9 @@ async function handleLoad (node: TreeOption) {
const names = await lsDir(fs, path)
for (const name of names) {
const subPath = path + name
if (hidePath && hidePath(subPath)) {
continue
}
const option: TreeOption = {
label: name
}
Expand Down
6 changes: 5 additions & 1 deletion src/WasmCode.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { computed, ref, toRefs } from 'vue'
import { computed, ref, toRefs, toRaw } from 'vue'
import { NDialogProvider, NMessageProvider, NConfigProvider, useOsTheme, darkTheme } from 'naive-ui'
import { StreamParser } from '@codemirror/language'
import WasmCodeWrapper from './WasmCodeWrapper.vue'
Expand All @@ -10,17 +10,20 @@ interface Props {
theme?: 'light' | 'dark' | undefined
langParserMap?: {[key: string]: StreamParser<any>}
extLangMap?: {[key: string]: string}
hidePath?: HidePath
}
</script>

<script setup lang="ts">
const props = withDefaults(defineProps<Props>(), {
theme: undefined,
hidePath: undefined,
langParserMap: () => ({}),
extLangMap: () => ({})
})
const { theme } = toRefs(props)
const { hidePath } = toRaw(props)
const osTheme = useOsTheme()
const _theme = computed(() => theme.value || osTheme.value!)
Expand All @@ -47,6 +50,7 @@ defineExpose({
:height="height"
:lang-parser-map="langParserMap"
:ext-lang-map="extLangMap"
:hide-path="hidePath"
/>
</n-message-provider>
</n-dialog-provider>
Expand Down
4 changes: 4 additions & 0 deletions src/WasmCodeCore.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface Props {
fs: ASYNC_FS
langParserMap?: {[key: string]: StreamParser<any>}
extLangMap?: {[key: string]: string}
hidePath?: HidePath
onCloseUnsaved: HandlerTwoActions
onErrorOpenFile?: HandlerZeroAction
onErrorNonText?: HandlerZeroAction
Expand All @@ -31,6 +32,7 @@ const props = withDefaults(defineProps<Props>(), {
theme: undefined,
langParserMap: () => ({}),
extLangMap: () => ({}),
hidePath: undefined,
onErrorOpenFile: undefined,
onErrorNonText: undefined,
onErrorSaveFile: undefined,
Expand All @@ -42,6 +44,7 @@ const props = withDefaults(defineProps<Props>(), {
const {
fs,
hidePath,
onCloseUnsaved,
onErrorOpenFile,
onErrorNonText,
Expand Down Expand Up @@ -97,6 +100,7 @@ defineExpose({
ref="fm"
:fs="fs"
:height="height"
:hide-path="hidePath"
:on-open-file="onOpenFile"
:on-new-file="onNewFile"
:on-new-folder="onNewFolder"
Expand Down
8 changes: 6 additions & 2 deletions src/WasmCodeWrapper.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<script setup lang="ts">
import { ref, h } from 'vue'
import { ref, h, toRaw } from 'vue'
import { NInput, NUpload, NUploadDragger, UploadFileInfo, useDialog, useMessage } from 'naive-ui'
import { StreamParser } from '@codemirror/language'
import WasmCodeCore from './WasmCodeCore.vue'
defineProps<{
const props = defineProps<{
fs: ASYNC_FS
height: string
theme: 'light' | 'dark'
langParserMap: {[key: string]: StreamParser<any>}
extLangMap: {[key: string]: string}
hidePath?: HidePath
}>()
const { hidePath } = toRaw(props)
const wcc = ref<InstanceType<typeof WasmCodeCore>>()
const dialog = useDialog()
Expand Down Expand Up @@ -149,6 +152,7 @@ defineExpose({
:height="height"
:lang-parser-map="langParserMap"
:ext-lang-map="extLangMap"
:hide-path="hidePath"
:on-close-unsaved="onCloseUnsaved"
:on-error-open-file="onErrorOpenFile"
:on-error-non-text="onErrorNonText"
Expand Down
1 change: 1 addition & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ASYNC_FS as _ASYNC_FS } from './async-fs'

declare global {
type HidePath = (path: string) => boolean
type HandlerZeroAction = (path: string) => void | Promise<void>
type HandlerOneAction = (path: string, action: (path: string) => Promise<void>) => void | Promise<void>
type HandlerTwoActions = (path: string, positiveAction: () => Promise<void>, negativeAction: () => void) => void | Promise<void>
Expand Down

0 comments on commit c353cc7

Please sign in to comment.