|
1 | 1 | <script lang="ts"> |
| 2 | + import { onDestroy } from 'svelte'; |
2 | 3 | import { base } from '$app/paths'; |
3 | 4 | import Icon from '$lib/components/common/Icon.svelte'; |
4 | 5 | import Tooltip, { tooltip } from '$lib/components/common/Tooltip.svelte'; |
5 | 6 | import NotebookCell from '$lib/components/common/NotebookCell.svelte'; |
6 | 7 | import { packages, type PackageId, type InstallOption } from '$lib/config/packages'; |
7 | 8 | import { copyToClipboard } from '$lib/utils/clipboard'; |
8 | 9 | import { type PackageManifest, versionHasExamples } from '$lib/api/versions'; |
| 10 | + import { packageVersionsStore } from '$lib/stores/packageVersionsStore'; |
9 | 11 |
|
10 | 12 | /** |
11 | 13 | * Compare semantic version strings (without 'v' prefix). |
|
34 | 36 | let pkg = $derived(packages[packageId]); |
35 | 37 | let featureCols = $derived(pkg.features.length > 4 ? 'cols-3' : 'cols-2'); |
36 | 38 |
|
| 39 | + // Set package config for Pyodide so quickstart cells can execute |
| 40 | + $effect(() => { |
| 41 | + if (pkg.quickstart && pkg.pyodidePackages.length > 0) { |
| 42 | + const versionNumber = selectedTag?.replace(/^v/, ''); |
| 43 | + const pipName = pkg.installation.find((i) => i.name.toLowerCase() === 'pip')?.command.split(' ').pop() || packageId; |
| 44 | + const versions: Record<string, string> = versionNumber ? { [pipName]: versionNumber } : {}; |
| 45 | +
|
| 46 | + packageVersionsStore.set({ |
| 47 | + packages: pkg.pyodidePackages, |
| 48 | + versions |
| 49 | + }); |
| 50 | + } |
| 51 | +
|
| 52 | + return () => { |
| 53 | + packageVersionsStore.clear(); |
| 54 | + }; |
| 55 | + }); |
| 56 | +
|
| 57 | + onDestroy(() => { |
| 58 | + packageVersionsStore.clear(); |
| 59 | + }); |
| 60 | +
|
37 | 61 | // Track copy state for each install option |
38 | 62 | let copiedStates = $state<Record<string, boolean>>({}); |
39 | 63 |
|
|
0 commit comments