Skip to content

Commit

Permalink
feat(server): setup fullpath
Browse files Browse the repository at this point in the history
  • Loading branch information
nonzzz committed May 14, 2024
1 parent 8a2dcb6 commit 9295f02
Show file tree
Hide file tree
Showing 14 changed files with 558 additions and 554 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"typescript": "^5.2.2",
"unplugin-icons": "^0.18.5",
"vite": "^5.2.8",
"vite-plugin-stylex-dev": "0.7.0"
"vite-plugin-stylex-dev": "^0.7.3"
},
"license": "MIT",
"author": "kanno",
Expand Down
2 changes: 1 addition & 1 deletion src/client/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function App() {
<Text p font="12px">
path:
{' '}
{tooltipContent.id}
{tooltipContent.filename}
</Text>
</>
)}
Expand Down
6 changes: 3 additions & 3 deletions src/client/components/file-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function FileList<F extends Foam>(props: FileListProps<F>) {
const [all, ...files] = useMemo(
() => userFiles
.reduce((acc, file) => {
const meta = { name: file.id, extra: file[extra] }
const meta = { name: file.label, extra: file[extra] }
acc[0].extra += meta.extra
acc.push(meta)
return acc
Expand All @@ -43,13 +43,13 @@ export function FileList<F extends Foam>(props: FileListProps<F>) {
)

const groupValues = useMemo(() => {
if (checkAll) return userFiles.map(v => v.id)
if (checkAll) return userFiles.map(v => v.label)
return Array.from(scence)
}, [checkAll, scence, userFiles])

const handleChange = (e: CheckboxEvent) => {
const { checked } = e.target
onChange(checked ? userFiles.map(v => v.id) : [])
onChange(checked ? userFiles.map(v => v.label) : [])
}
return (
<div stylex={{
Expand Down
14 changes: 7 additions & 7 deletions src/client/components/search-modules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function SearchModules(props: SearchModulesProps) {
(module.groups?.flatMap(flatModules) || []).concat(module)

const modules = flatModules(foam)
.filter((module) => regExp.test(module.id))
.filter((module) => regExp.test(module.label))
.sort((a, b) => b[extra] - a[extra])
.reduce(
(acc, module) => {
Expand All @@ -46,7 +46,7 @@ export function SearchModules(props: SearchModulesProps) {

return {
foam,
modules: uniqBy(modules, 'id')
modules: uniqBy(modules, 'label')
}
})
.filter((find) => find.modules.length)
Expand Down Expand Up @@ -76,7 +76,7 @@ export function SearchModules(props: SearchModulesProps) {
const check = treemap.current?.check(module)
setAvailableMap({
...availableMap,
[module.id]: !!check
[module.label]: !!check
})
}

Expand Down Expand Up @@ -108,18 +108,18 @@ export function SearchModules(props: SearchModulesProps) {
{filtered.length
? (
filtered.map((find) => (
<div key={find.foam.id}>
<div key={find.foam.label}>
<ModuleItem
name={find.foam.label}
stylex={{ fontStyle: 'bold' }}
/>
<div>
{find.modules.map((module) => (
<ModuleItem
key={module.id}
name={module.id}
key={module.label}
name={module.label}
size={module[extra]}
pointer={availableMap[module.id]}
pointer={availableMap[module.label]}
onMouseEnter={() => handleMouseEnter(module)}
onClick={() => treemap.current?.zoom(module)}
stylex={{ fontStyle: 'italic' }}
Expand Down
6 changes: 3 additions & 3 deletions src/client/components/side-bar/side-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function Sidebar({ foamModule, mode: userMode = 'statSize', onModeChange
const [entrypoints, setEntrypoints] = useState<string[]>([])

const allChunks = useMemo(() => foamModule
.filter(chunk => !entrypoints.length || entrypoints.some(id => chunk.id === id || chunk.imports.includes(id)))
.filter(chunk => !entrypoints.length || entrypoints.some(id => chunk.label === id || chunk.imports.includes(id)))
.sort((a, b) => b[userMode] - a[userMode]), [foamModule, userMode, entrypoints])

const mode = useMemo<ModeType>(() => userMode === 'gzipSize' ? 'Gzipped' : userMode === 'statSize' ? 'Stat' : 'Parsed', [userMode])
Expand All @@ -42,7 +42,7 @@ export function Sidebar({ foamModule, mode: userMode = 'statSize', onModeChange
setEntrypoints(Array.isArray(entrypoint) ? entrypoint : [entrypoint])
}

useEffect(() => updateScence(() => new Set(allChunks.map(v => v.id))), [allChunks, updateScence])
useEffect(() => updateScence(() => new Set(allChunks.map(v => v.label))), [allChunks, updateScence])

return (
<>
Expand Down Expand Up @@ -101,7 +101,7 @@ export function Sidebar({ foamModule, mode: userMode = 'statSize', onModeChange
onChange={handleFilterByEntrypoints}
>
{entrypointChunks.map(chunk => (
<Select.Option key={chunk.id} value={chunk.id}>{chunk.id}</Select.Option>
<Select.Option key={chunk.label} value={chunk.label}>{chunk.label}</Select.Option>
))}
</Select>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/tree-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const TreeMap = forwardRef<TreeMapComponent, TreeMapProps>(function TreeM
check
}))

const visibleChunks = useMemo(() => foamModule.filter((v) => scence.has(v.id)).map((module) => travseVisibleModule(module, sizes, true)), [foamModule, sizes, scence])
const visibleChunks = useMemo(() => foamModule.filter((v) => scence.has(v.label)).map((module) => travseVisibleModule(module, sizes, true)), [foamModule, sizes, scence])

const chunkNamePartIndex = useMemo(() => {
const splitChunkNames = visibleChunks.map((chunk) => chunk.label.split(/[^a-z0-9]/iu))
Expand Down
Loading

0 comments on commit 9295f02

Please sign in to comment.