@sprig-and-prose/sprig-ui-csr 0.1.2 → 0.2.0
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.
- package/package.json +1 -1
- package/src/App.svelte +30 -7
- package/src/lib/components/GlobalSearch.svelte +17 -1
- package/src/lib/data/universeStore.js +4 -3
- package/src/lib/router.js +12 -0
- package/src/pages/ConceptPage.svelte +146 -296
- package/src/pages/ReferencePage.svelte +104 -0
- package/src/pages/SeriesPage.svelte +146 -296
- package/src/lib/references/isWildcardPath.js +0 -9
- package/src/lib/references/linkForPath.js +0 -65
- package/src/lib/references/linkForRepository.js +0 -42
package/package.json
CHANGED
package/src/App.svelte
CHANGED
|
@@ -9,11 +9,26 @@
|
|
|
9
9
|
import SeriesPage from './pages/SeriesPage.svelte';
|
|
10
10
|
import AnthologyPage from './pages/AnthologyPage.svelte';
|
|
11
11
|
import ConceptPage from './pages/ConceptPage.svelte';
|
|
12
|
+
import ReferencePage from './pages/ReferencePage.svelte';
|
|
12
13
|
|
|
13
14
|
let loading = true;
|
|
15
|
+
/** @type {string | null} */
|
|
14
16
|
let error = null;
|
|
15
17
|
let currentRoute = getCurrentRoute();
|
|
16
18
|
|
|
19
|
+
$: seriesParams = currentRoute?.route === 'series'
|
|
20
|
+
? /** @type {{ universe: string, series: string }} */ (currentRoute.params)
|
|
21
|
+
: null;
|
|
22
|
+
$: anthologyParams = currentRoute?.route === 'anthology'
|
|
23
|
+
? /** @type {{ universe: string, anthology: string }} */ (currentRoute.params)
|
|
24
|
+
: null;
|
|
25
|
+
$: conceptParams = currentRoute?.route === 'concept'
|
|
26
|
+
? /** @type {{ universe: string, id: string }} */ (currentRoute.params)
|
|
27
|
+
: null;
|
|
28
|
+
$: referenceParams = currentRoute?.route === 'reference'
|
|
29
|
+
? /** @type {{ universe: string, id: string }} */ (currentRoute.params)
|
|
30
|
+
: null;
|
|
31
|
+
|
|
17
32
|
// Reactively auto-select first universe when on home route and graph is loaded
|
|
18
33
|
// This runs whenever universeGraph or currentRoute changes
|
|
19
34
|
$: if ($universeGraph && currentRoute?.route === 'home') {
|
|
@@ -48,7 +63,8 @@
|
|
|
48
63
|
describeRenderMode.set(mode);
|
|
49
64
|
}
|
|
50
65
|
} catch (err) {
|
|
51
|
-
|
|
66
|
+
const message = err instanceof Error ? err.message : 'Failed to load manifest';
|
|
67
|
+
error = message;
|
|
52
68
|
console.error('Error loading manifest:', err);
|
|
53
69
|
} finally {
|
|
54
70
|
loading = false;
|
|
@@ -61,7 +77,11 @@
|
|
|
61
77
|
}
|
|
62
78
|
|
|
63
79
|
// Intercept link clicks for client-side navigation
|
|
80
|
+
/**
|
|
81
|
+
* @param {MouseEvent} event
|
|
82
|
+
*/
|
|
64
83
|
function handleLinkClick(event) {
|
|
84
|
+
if (!(event.target instanceof HTMLElement)) return;
|
|
65
85
|
const link = event.target.closest('a');
|
|
66
86
|
if (!link) return;
|
|
67
87
|
|
|
@@ -88,6 +108,7 @@
|
|
|
88
108
|
document.addEventListener('click', handleLinkClick);
|
|
89
109
|
|
|
90
110
|
// Set up Server-Sent Events for manifest updates
|
|
111
|
+
/** @type {EventSource | null} */
|
|
91
112
|
let eventSource = null;
|
|
92
113
|
|
|
93
114
|
onMount(() => {
|
|
@@ -149,12 +170,14 @@
|
|
|
149
170
|
{:else if currentRoute}
|
|
150
171
|
{#if currentRoute.route === 'home'}
|
|
151
172
|
<HomePage />
|
|
152
|
-
{:else if currentRoute.route === 'series'}
|
|
153
|
-
<SeriesPage params={
|
|
154
|
-
{:else if currentRoute.route === 'anthology'}
|
|
155
|
-
<AnthologyPage params={
|
|
156
|
-
{:else if currentRoute.route === 'concept'}
|
|
157
|
-
<ConceptPage params={
|
|
173
|
+
{:else if currentRoute.route === 'series' && seriesParams}
|
|
174
|
+
<SeriesPage params={seriesParams} />
|
|
175
|
+
{:else if currentRoute.route === 'anthology' && anthologyParams}
|
|
176
|
+
<AnthologyPage params={anthologyParams} />
|
|
177
|
+
{:else if currentRoute.route === 'concept' && conceptParams}
|
|
178
|
+
<ConceptPage params={conceptParams} />
|
|
179
|
+
{:else if currentRoute.route === 'reference' && referenceParams}
|
|
180
|
+
<ReferencePage params={referenceParams} />
|
|
158
181
|
{:else}
|
|
159
182
|
<div class="error">Unknown route: {currentRoute.route}</div>
|
|
160
183
|
{/if}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* @typedef {import('../data/universeStore.js').UniverseGraph} UniverseGraph
|
|
10
10
|
* @typedef {import('../data/universeStore.js').NodeModel} NodeModel
|
|
11
|
-
* @typedef {{ node: NodeModel, name: string, kind: string, id: string, route: string, context: string | null }} SearchItem
|
|
11
|
+
* @typedef {{ node: NodeModel | any, name: string, kind: string, id: string, route: string, context: string | null }} SearchItem
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
/** @type {HTMLInputElement | null} */
|
|
@@ -112,6 +112,22 @@
|
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
if (graph.references) {
|
|
116
|
+
for (const ref of Object.values(graph.references)) {
|
|
117
|
+
if (!ref || !ref.id) continue;
|
|
118
|
+
const universeName = ref.id.split(':')[0];
|
|
119
|
+
const route = `/universes/${universeName}/reference/${encodeURIComponent(ref.id)}`;
|
|
120
|
+
items.push({
|
|
121
|
+
node: ref,
|
|
122
|
+
name: ref.title || ref.name,
|
|
123
|
+
kind: 'reference',
|
|
124
|
+
id: ref.id,
|
|
125
|
+
route,
|
|
126
|
+
context: null,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
115
131
|
return items;
|
|
116
132
|
}
|
|
117
133
|
|
|
@@ -4,10 +4,11 @@ import { writable, derived, get } from 'svelte/store';
|
|
|
4
4
|
* @typedef {{ line:number, col:number, offset:number }} Pos
|
|
5
5
|
* @typedef {{ file:string, start:Pos, end:Pos }} SourceSpan
|
|
6
6
|
* @typedef {{ raw:string, normalized?:string, source:SourceSpan }} TextBlock
|
|
7
|
-
* @typedef {{
|
|
8
|
-
* @typedef {{ id:string,
|
|
7
|
+
* @typedef {{ id:string, name:string, url:string, title?:string, describe?:TextBlock, note?:TextBlock }} RepositoryModel
|
|
8
|
+
* @typedef {{ id:string, name:string, kind?:string, title?:string, describe?:TextBlock, note?:TextBlock, urls:string[], repositoryRef?:string, paths?:string[] }} ReferenceModel
|
|
9
|
+
* @typedef {{ id:string, kind:'universe'|'anthology'|'series'|'book'|'chapter'|'concept'|'relates', name:string, title?:string, parent?:string, children:string[], container?:string, describe?:TextBlock, endpoints?:string[], from?:Record<string, any>, references?:string[] }} NodeModel
|
|
9
10
|
* @typedef {{ name:string, root:string }} UniverseModel
|
|
10
|
-
* @typedef {{ version:1, universes:Record<string, UniverseModel>, nodes:Record<string, NodeModel>, edges:Record<string, any>, diagnostics:any[], repositories?:Record<string,
|
|
11
|
+
* @typedef {{ version:1, universes:Record<string, UniverseModel>, nodes:Record<string, NodeModel>, edges:Record<string, any>, diagnostics:any[], repositories?:Record<string, RepositoryModel>, references?:Record<string, ReferenceModel>, generatedAt?:string }} UniverseGraph
|
|
11
12
|
*/
|
|
12
13
|
|
|
13
14
|
export const universeGraph = writable(/** @type {UniverseGraph|null} */ (null));
|
package/src/lib/router.js
CHANGED
|
@@ -52,6 +52,18 @@ export function parseRoute(pathname) {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
// Match /universes/:universe/reference/:id
|
|
56
|
+
const referenceMatch = path.match(/^universes\/([^/]+)\/reference\/(.+)$/);
|
|
57
|
+
if (referenceMatch) {
|
|
58
|
+
return {
|
|
59
|
+
route: 'reference',
|
|
60
|
+
params: {
|
|
61
|
+
universe: referenceMatch[1],
|
|
62
|
+
id: referenceMatch[2],
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
55
67
|
// Unknown route
|
|
56
68
|
return null;
|
|
57
69
|
}
|