Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions app/components/Package/TimelineChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,34 @@ const seriesDependencies = computed(() => {
}
})

const activeTab = shallowRef<TimelineChartMetric>('totalSize')
const timelineChartMetrics = new Set<TimelineChartMetric>([
'totalSize',
'dependencyCount',
'dependencySize',
])

const activeTab = usePermalink<TimelineChartMetric>('metric', 'totalSize', {
permanent: true,
})

watch(
activeTab,
value => {
if (!timelineChartMetrics.has(value)) {
activeTab.value = 'totalSize'
}
},
{ immediate: true },
)

const shouldPauseChartAnimations = shallowRef(true)

const { start: startChartAnimationPauseTimer } = useTimeoutFn(
() => {
shouldPauseChartAnimations.value = false
},
1000,
{ immediate: false },
300,
{ immediate: true },
)

function pauseChartAnimations() {
Expand Down Expand Up @@ -859,7 +877,7 @@ const timelineMetricTabs = computed(() => [
<div
style="width: 100%"
class="font-mono border-b border-border"
:class="{ loaded: shouldPauseChartAnimations }"
:class="{ loading: shouldPauseChartAnimations || loading }"
id="timeline-chart"
>
<div class="mt-4 flex flex-row flex-wrap items-center justify-between gap-4">
Expand Down Expand Up @@ -967,7 +985,7 @@ const timelineMetricTabs = computed(() => [
:markersNegative="getNegativeDatapointPlots(svg.data[0], svg.slicer.start)"
:colors
:gradientColors="E18E_GRADIENT_COLORS"
:pauseAnimations="shouldPauseChartAnimations"
:pauseAnimations="shouldPauseChartAnimations || loading"
/>
</template>

Expand Down Expand Up @@ -1040,6 +1058,10 @@ const timelineMetricTabs = computed(() => [
:dataset="datasets.dependencySize"
:config="stackbarConfig"
:selected-x-index="indexSelection"
:style="{
opacity: shouldPauseChartAnimations || loading ? 0 : 1,
transition: 'opacity 0.15s',
}"
ref="chartRef"
>
<!-- Injecting custom svg elements -->
Expand All @@ -1058,7 +1080,7 @@ const timelineMetricTabs = computed(() => [
"
:activeVersionPlot="getActiveVersionDatapointBar(svg.data, svg.barWidth)"
:colors
:pauseAnimations="shouldPauseChartAnimations"
:pauseAnimations="shouldPauseChartAnimations || loading"
/>
</template>

Expand Down Expand Up @@ -1112,7 +1134,10 @@ const timelineMetricTabs = computed(() => [
</VueUiStackbar>

<template #fallback>
<SkeletonBlock class="flex place-items-center justify-center aspect-[1152/254.59]">
<SkeletonBlock
class="flex place-items-center justify-center"
:class="[activeTab === 'dependencySize' ? 'aspect-[1152/466.4]' : 'aspect-[1152/254.59]']"
>
<span class="i-lucide:chart-line w-10 h-10 text-fg-muted" aria-hidden="true" />
</SkeletonBlock>
</template>
Expand Down Expand Up @@ -1198,9 +1223,9 @@ const timelineMetricTabs = computed(() => [
animation: indeterminate 1.5s ease-in-out infinite;
}

.loaded :deep(.vue-data-ui-component .serie_line_0 path),
.loaded :deep(.vdui-shape-circle),
.loaded :deep(.vue-ui-stackbar rect) {
.loading :deep(.vue-data-ui-component .serie_line_0 path),
.loading :deep(.vdui-shape-circle),
.loading :deep(.vue-ui-stackbar rect) {
transition: none !important;
animation: none !important;
}
Expand Down
1 change: 1 addition & 0 deletions app/pages/package-timeline/[[org]]/[packageName].vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type { TimelineSizeCacheValue } from '~/utils/charts'
definePageMeta({
name: 'timeline',
path: '/package-timeline/:org?/:packageName/v/:version',
preserveScrollOnQuery: true,
})
const { t } = useI18n()
Expand Down
34 changes: 32 additions & 2 deletions app/utils/package-content-hints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ const POSSIBLY_UNNECESSARY_FILES: ReadonlySet<string> = new Set([
'.editorconfig',
'.prettierignore',
'.eslintignore',
'.jshintignore',
'.npmignore',
'.gitignore',
'.gitattributes',
'.travis.yml',
'.verb.md',
'Makefile',
'tsconfig.json',
'jsconfig.json',
'.node-version',
'.nvmrc',
'mise.toml',
Expand All @@ -27,6 +33,18 @@ const POSSIBLY_UNNECESSARY_FILES: ReadonlySet<string> = new Set([
'.env.production.local',
'.nycrc',
'nyc.json',
'.DS_Store',
'AUTHORS',
'test.js',
'test.ts',
'tests.js',
'tests.ts',
'bench.js',
'benchmark.js',
'yarn.lock',
'bun.lock',
'bun.lockb',
'package-lock.json',
])

const POSSIBLY_UNNECESSARY_DIRECTORIES: ReadonlySet<string> = new Set([
Expand All @@ -35,11 +53,16 @@ const POSSIBLY_UNNECESSARY_DIRECTORIES: ReadonlySet<string> = new Set([
'.github',
'.idea',
'.zed',
'.yarn',
'.husky',
'.changeset',
'test',
'tests',
'__tests__',
'spec',
'specs',
'example',
'examples',
'benchmark',
])

const POSSIBLY_UNNECESSARY_DIRECTORY_PATTERNS: readonly RegExp[] = [/^__.+__$/]
Expand All @@ -53,11 +76,18 @@ const POSSIBLY_UNNECESSARY_PATTERNS: readonly RegExp[] = [
/^\.oxlintrc(?:\.(?:json|js|cjs|yml|yaml))?$/,
/^oxfmt\.config\.(?:js|cjs|mjs|ts|mts|cts)$/,
/^\.oxfmtrc(?:\.(?:json|js|cjs|yml|yaml))?$/,
/^jest\.config\.(?:js|cjs|mjs|ts|mts|cts)$/,
// Match common dot-prefixed config files without flagging all dotfiles;
// files like .npmrc, .npmignore, and .gitkeep can be intentional artifacts.
// files like .npmrc can be intentional artifacts.
/^\.(?!npmrc$)[a-z][a-z0-9_-]*rc$/,
/^\.(?!npmrc\.)[a-z][a-z0-9_-]*rc\.(?:json|js|cjs|mjs|yml|yaml|toml)$/,
/^\.[a-z][a-z0-9_-]*\.config\.(?:js|cjs|mjs|ts|mts|cts)$/,
// Match files ending in .test.js, .test.ts, .spec.js, .spec.ts, etc.
/\.(?:test|spec)\.(?:j|t)s$/,
// Match CHANGELOG.md, etc
/^(?:changelog|releasenotes|release-notes|history|contributing|contribute|news|collaborators)\.(?:md|markdown|txt)$/i,
// Match example.mjs, examples.js, stc
/^examples?\.(?:js|cjs|mjs|ts|mts|cts)$/,
]

export function isPossiblyUnnecessaryContent(name: string, type: 'file' | 'directory'): boolean {
Expand Down
Loading
Loading