@sprig-and-prose/sprig-ui-csr 0.1.2 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +0,0 @@
1
- /**
2
- * Checks if a path contains a wildcard pattern
3
- * @param {string} path - File path to check
4
- * @returns {boolean} - True if path contains '*'
5
- */
6
- export function isWildcardPath(path) {
7
- return typeof path === 'string' && path.includes('*');
8
- }
9
-
@@ -1,65 +0,0 @@
1
- import { get } from 'svelte/store';
2
- import { universeGraph } from '../data/universeStore.js';
3
- import { isWildcardPath } from './isWildcardPath.js';
4
-
5
- /**
6
- * Builds a URL for a file path in a repository
7
- * @param {string} repository - Repository key (e.g., "amaranthine")
8
- * @param {string} path - File path (e.g., "/backends/api/src/routers/players.js" or "/data/actions/*.yaml")
9
- * @returns {string | null} - Full URL to the file/folder, or null if repository is unconfigured
10
- */
11
- export function linkForPath(repository, path) {
12
- const graph = get(universeGraph);
13
- if (!graph?.repositories) {
14
- return null;
15
- }
16
-
17
- const repoConfig = graph.repositories[repository];
18
- if (!repoConfig) {
19
- return null;
20
- }
21
-
22
- const { kind, options } = repoConfig;
23
- const defaultBranch = options?.defaultBranch || 'main';
24
-
25
- // Handle GitHub repositories
26
- if (kind === 'sprig-repository-github') {
27
- // Prefer url if available, otherwise build from owner/repo
28
- let baseUrl;
29
- if (options?.url) {
30
- baseUrl = options.url;
31
- } else {
32
- const owner = options?.owner;
33
- const repo = options?.repo;
34
- if (!owner || !repo) {
35
- return null;
36
- }
37
- baseUrl = `https://github.com/${owner}/${repo}`;
38
- }
39
-
40
- const normalizedBaseUrl = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
41
-
42
- // Ensure path begins with /
43
- const normalizedPath = path.startsWith('/') ? path : `/${path}`;
44
-
45
- // Handle wildcard paths - link to folder view
46
- if (isWildcardPath(path)) {
47
- // Derive folder by taking everything up to the last '/'
48
- // e.g., "/data/actions/*.yaml" -> "/data/actions"
49
- const lastSlashIndex = normalizedPath.lastIndexOf('/');
50
- if (lastSlashIndex > 0) {
51
- const folderPath = normalizedPath.slice(0, lastSlashIndex);
52
- // Build GitHub tree URL: baseUrl/tree/branch/folder
53
- return `${normalizedBaseUrl}/tree/${defaultBranch}${folderPath}`;
54
- }
55
- // Fallback: if no slash, link to repo root
56
- return `${normalizedBaseUrl}/tree/${defaultBranch}`;
57
- }
58
-
59
- // Build GitHub blob URL: baseUrl/blob/branch/path
60
- return `${normalizedBaseUrl}/blob/${defaultBranch}${normalizedPath}`;
61
- }
62
-
63
- return null;
64
- }
65
-
@@ -1,42 +0,0 @@
1
- import { get } from 'svelte/store';
2
- import { universeGraph } from '../data/universeStore.js';
3
-
4
- /**
5
- * Builds a URL for a repository root
6
- * @param {string} repository - Repository key (e.g., "amaranthine")
7
- * @returns {string | null} - Full URL to the repository root, or null if repository is unconfigured
8
- */
9
- export function linkForRepository(repository) {
10
- const graph = get(universeGraph);
11
- if (!graph?.repositories) {
12
- return null;
13
- }
14
-
15
- const repoConfig = graph.repositories[repository];
16
- if (!repoConfig) {
17
- return null;
18
- }
19
-
20
- const { kind, options } = repoConfig;
21
-
22
- // Handle GitHub repositories
23
- if (kind === 'sprig-repository-github') {
24
- // Prefer url if available, otherwise build from owner/repo
25
- if (options?.url) {
26
- const baseUrl = options.url;
27
- // Remove trailing slash if present
28
- return baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
29
- }
30
-
31
- const owner = options?.owner;
32
- const repo = options?.repo;
33
- if (owner && repo) {
34
- const baseUrl = `https://github.com/${owner}/${repo}`;
35
- // Remove trailing slash if present
36
- return baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
37
- }
38
- }
39
-
40
- return null;
41
- }
42
-
package/tsconfig.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "ES2020",
5
- "moduleResolution": "bundler",
6
- "allowJs": true,
7
- "checkJs": true,
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true
12
- },
13
- "include": ["src/**/*"],
14
- "exclude": ["node_modules", "dist"]
15
- }
16
-
package/vite.config.js DELETED
@@ -1,10 +0,0 @@
1
- import { svelte } from '@sveltejs/vite-plugin-svelte';
2
- import { defineConfig } from 'vite';
3
-
4
- export default defineConfig({
5
- plugins: [svelte()],
6
- build: {
7
- outDir: 'dist',
8
- },
9
- base: '/_ui/',
10
- });