UNPKG

lingo3d

Version:

Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor

27 lines 1.17 kB
import store, { merge } from "@lincode/reactivity"; import { set, traverse } from "@lincode/utils"; import { setFileBrowserDir } from "./useFileBrowserDir"; import { getFiles } from "./useFiles"; import { pathObjMap } from "../collections/pathCollections"; import { firstFolderNamePtr } from "../pointers/firstFolderNamePtr"; export const [setFileStructure, getFileStructure] = store({}); export const mergeFileStructure = merge(setFileStructure, getFileStructure); export const setPathMap = (fileStructure) => traverse(fileStructure, (key, child, parent) => { let path = ""; if (pathObjMap.has(parent)) path = pathObjMap.get(parent) + "/" + key; typeof child === "object" && pathObjMap.set(child, path); }); getFiles((files) => { const fileStructure = {}; firstFolderNamePtr[0] = ""; if (files) { for (const file of files) set(fileStructure, file.webkitRelativePath.split("/"), file); firstFolderNamePtr[0] = Object.keys(fileStructure)[0]; setPathMap(fileStructure); } setFileBrowserDir(firstFolderNamePtr[0]); setFileStructure(fileStructure); }); //# sourceMappingURL=useFileStructure.js.map