@fuzdev/fuz_ui 0.206.7 → 0.206.9
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/README.md +3 -3
- package/dist/Alert.svelte +21 -25
- package/dist/Alert.svelte.d.ts.map +1 -1
- package/dist/ApiDeclarationList.svelte +2 -2
- package/dist/ApiDeclarationList.svelte.d.ts.map +1 -1
- package/dist/ApiIndex.svelte +4 -4
- package/dist/ApiIndex.svelte.d.ts.map +1 -1
- package/dist/ApiModule.svelte +13 -10
- package/dist/ApiModule.svelte.d.ts.map +1 -1
- package/dist/ApiModulesList.svelte +2 -2
- package/dist/ApiModulesList.svelte.d.ts.map +1 -1
- package/dist/Breadcrumb.svelte +31 -19
- package/dist/Breadcrumb.svelte.d.ts.map +1 -1
- package/dist/Card.svelte +17 -17
- package/dist/Card.svelte.d.ts.map +1 -1
- package/dist/ColorSchemeInput.svelte +6 -6
- package/dist/ColorSchemeInput.svelte.d.ts.map +1 -1
- package/dist/Contextmenu.svelte +6 -4
- package/dist/Contextmenu.svelte.d.ts.map +1 -1
- package/dist/ContextmenuEntry.svelte +8 -8
- package/dist/ContextmenuEntry.svelte.d.ts.map +1 -1
- package/dist/ContextmenuIcon.svelte +3 -3
- package/dist/ContextmenuIcon.svelte.d.ts.map +1 -1
- package/dist/ContextmenuLinkEntry.svelte +14 -14
- package/dist/ContextmenuLinkEntry.svelte.d.ts.map +1 -1
- package/dist/ContextmenuMenu.svelte +10 -10
- package/dist/ContextmenuMenu.svelte.d.ts.map +1 -1
- package/dist/ContextmenuRoot.svelte +7 -7
- package/dist/ContextmenuRootForSafariCompatibility.svelte +15 -15
- package/dist/ContextmenuSeparator.svelte +2 -2
- package/dist/ContextmenuSubmenu.svelte +15 -12
- package/dist/ContextmenuSubmenu.svelte.d.ts.map +1 -1
- package/dist/ContextmenuTextEntry.svelte +4 -4
- package/dist/ContextmenuTextEntry.svelte.d.ts.map +1 -1
- package/dist/CopyToClipboard.svelte +7 -7
- package/dist/CopyToClipboard.svelte.d.ts.map +1 -1
- package/dist/DeclarationDetail.svelte +35 -28
- package/dist/DeclarationDetail.svelte.d.ts.map +1 -1
- package/dist/DeclarationLink.svelte +7 -7
- package/dist/DeclarationLink.svelte.d.ts.map +1 -1
- package/dist/Details.svelte +3 -3
- package/dist/Details.svelte.d.ts.map +1 -1
- package/dist/Dialog.svelte +7 -7
- package/dist/Dialog.svelte.d.ts.map +1 -1
- package/dist/DialogContent.svelte +6 -6
- package/dist/DialogContent.svelte.d.ts.map +1 -1
- package/dist/Docs.svelte +14 -12
- package/dist/Docs.svelte.d.ts.map +1 -1
- package/dist/DocsContent.svelte +4 -4
- package/dist/DocsContent.svelte.d.ts.map +1 -1
- package/dist/DocsFooter.svelte +7 -8
- package/dist/DocsFooter.svelte.d.ts.map +1 -1
- package/dist/DocsLink.svelte +24 -21
- package/dist/DocsLink.svelte.d.ts.map +1 -1
- package/dist/DocsList.svelte +3 -3
- package/dist/DocsList.svelte.d.ts.map +1 -1
- package/dist/DocsMenu.svelte +13 -10
- package/dist/DocsMenu.svelte.d.ts.map +1 -1
- package/dist/DocsMenuHeader.svelte +2 -2
- package/dist/DocsMenuHeader.svelte.d.ts.map +1 -1
- package/dist/DocsPageLinks.svelte +9 -7
- package/dist/DocsPageLinks.svelte.d.ts.map +1 -1
- package/dist/DocsPrimaryNav.svelte +5 -5
- package/dist/DocsPrimaryNav.svelte.d.ts.map +1 -1
- package/dist/DocsSearch.svelte +3 -3
- package/dist/DocsSearch.svelte.d.ts.map +1 -1
- package/dist/DocsSecondaryNav.svelte +3 -3
- package/dist/DocsSecondaryNav.svelte.d.ts.map +1 -1
- package/dist/DocsTertiaryNav.svelte +8 -8
- package/dist/DocsTertiaryNav.svelte.d.ts.map +1 -1
- package/dist/EcosystemLinks.svelte +3 -3
- package/dist/EcosystemLinks.svelte.d.ts.map +1 -1
- package/dist/EcosystemLinksPanel.svelte +2 -2
- package/dist/EcosystemLinksPanel.svelte.d.ts.map +1 -1
- package/dist/GithubLink.svelte +10 -10
- package/dist/GithubLink.svelte.d.ts.map +1 -1
- package/dist/Glyph.svelte +4 -2
- package/dist/Glyph.svelte.d.ts.map +1 -1
- package/dist/Hashlink.svelte +5 -5
- package/dist/Hashlink.svelte.d.ts.map +1 -1
- package/dist/HueInput.svelte +5 -5
- package/dist/HueInput.svelte.d.ts.map +1 -1
- package/dist/ImgOrSvg.svelte +20 -20
- package/dist/ImgOrSvg.svelte.d.ts.map +1 -1
- package/dist/LibraryDetail.svelte +16 -16
- package/dist/LibraryDetail.svelte.d.ts.map +1 -1
- package/dist/LibrarySummary.svelte +10 -8
- package/dist/LibrarySummary.svelte.d.ts.map +1 -1
- package/dist/MdnLink.svelte +8 -8
- package/dist/MdnLink.svelte.d.ts.map +1 -1
- package/dist/ModuleLink.svelte +5 -5
- package/dist/ModuleLink.svelte.d.ts.map +1 -1
- package/dist/PasteFromClipboard.svelte +1 -1
- package/dist/PasteFromClipboard.svelte.d.ts.map +1 -1
- package/dist/PendingAnimation.svelte +12 -11
- package/dist/PendingAnimation.svelte.d.ts.map +1 -1
- package/dist/PendingButton.svelte +3 -3
- package/dist/PendingButton.svelte.d.ts.map +1 -1
- package/dist/ProjectActivityChart.svelte +137 -0
- package/dist/ProjectActivityChart.svelte.d.ts +30 -0
- package/dist/ProjectActivityChart.svelte.d.ts.map +1 -0
- package/dist/ProjectLinks.svelte +29 -48
- package/dist/ProjectLinks.svelte.d.ts.map +1 -1
- package/dist/Redirect.svelte +12 -8
- package/dist/Redirect.svelte.d.ts.map +1 -1
- package/dist/Sparkline.svelte +131 -0
- package/dist/Sparkline.svelte.d.ts +42 -0
- package/dist/Sparkline.svelte.d.ts.map +1 -0
- package/dist/Spiders.svelte +5 -5
- package/dist/Spiders.svelte.d.ts.map +1 -1
- package/dist/StyleVariableButton.svelte +6 -6
- package/dist/StyleVariableButton.svelte.d.ts.map +1 -1
- package/dist/Svg.svelte +5 -5
- package/dist/Svg.svelte.d.ts.map +1 -1
- package/dist/Teleport.svelte +2 -2
- package/dist/Teleport.svelte.d.ts.map +1 -1
- package/dist/ThemeInput.svelte +10 -8
- package/dist/ThemeInput.svelte.d.ts.map +1 -1
- package/dist/ThemeRoot.svelte +10 -11
- package/dist/ThemeRoot.svelte.d.ts.map +1 -1
- package/dist/TomeContent.svelte +11 -11
- package/dist/TomeContent.svelte.d.ts.map +1 -1
- package/dist/TomeHeader.svelte +6 -6
- package/dist/TomeLink.svelte +7 -7
- package/dist/TomeLink.svelte.d.ts.map +1 -1
- package/dist/TomeSection.svelte +8 -8
- package/dist/TomeSection.svelte.d.ts.map +1 -1
- package/dist/TomeSectionHeader.svelte +12 -12
- package/dist/TomeSectionHeader.svelte.d.ts.map +1 -1
- package/dist/TypeLink.svelte +11 -11
- package/dist/TypeLink.svelte.d.ts.map +1 -1
- package/dist/alert.js +1 -1
- package/dist/api_search.svelte.d.ts.map +1 -1
- package/dist/api_search.svelte.js +5 -7
- package/dist/autofocus.svelte.d.ts.map +1 -1
- package/dist/context_helpers.js +1 -1
- package/dist/contextmenu_helpers.d.ts.map +1 -1
- package/dist/contextmenu_helpers.js +3 -3
- package/dist/contextmenu_state.svelte.d.ts.map +1 -1
- package/dist/contextmenu_state.svelte.js +4 -4
- package/dist/csp.d.ts.map +1 -1
- package/dist/csp.js +27 -27
- package/dist/csp_of_fuzdev.d.ts.map +1 -1
- package/dist/csp_of_fuzdev.js +1 -1
- package/dist/declaration.svelte.d.ts +44 -256
- package/dist/declaration.svelte.d.ts.map +1 -1
- package/dist/declaration.svelte.js +132 -52
- package/dist/declaration_contextmenu.d.ts.map +1 -1
- package/dist/declaration_contextmenu.js +2 -2
- package/dist/docs_helpers.svelte.d.ts.map +1 -1
- package/dist/icons.js +200 -200
- package/dist/intersect.svelte.d.ts.map +1 -1
- package/dist/library.svelte.d.ts +31 -18
- package/dist/library.svelte.d.ts.map +1 -1
- package/dist/library.svelte.js +76 -21
- package/dist/logos.js +42 -42
- package/dist/module.svelte.d.ts +30 -37
- package/dist/module.svelte.d.ts.map +1 -1
- package/dist/module.svelte.js +88 -35
- package/dist/module_contextmenu.d.ts.map +1 -1
- package/dist/module_contextmenu.js +2 -2
- package/dist/project_stats.d.ts +121 -0
- package/dist/project_stats.d.ts.map +1 -0
- package/dist/project_stats.js +153 -0
- package/dist/project_stats_data.d.ts +3 -0
- package/dist/project_stats_data.d.ts.map +1 -0
- package/dist/project_stats_data.js +469 -0
- package/dist/project_stats_update.task.d.ts +4 -0
- package/dist/project_stats_update.task.d.ts.map +1 -0
- package/dist/project_stats_update.task.js +50 -0
- package/dist/projects.d.ts +17 -0
- package/dist/projects.d.ts.map +1 -0
- package/dist/projects.js +20 -0
- package/dist/publish.task.d.ts +3 -0
- package/dist/publish.task.d.ts.map +1 -0
- package/dist/publish.task.js +23 -0
- package/dist/site.svelte.d.ts.map +1 -1
- package/dist/sparkline.d.ts +102 -0
- package/dist/sparkline.d.ts.map +1 -0
- package/dist/sparkline.js +63 -0
- package/dist/style_variable_helpers.svelte.d.ts.map +1 -1
- package/dist/svg.d.ts.map +1 -1
- package/dist/theme_state.svelte.d.ts.map +1 -1
- package/dist/theme_state.svelte.js +1 -1
- package/dist/tome.d.ts.map +1 -1
- package/dist/tome.js +1 -1
- package/dist/vite_plugin_pkg_json.d.ts.map +1 -1
- package/dist/vite_plugin_pkg_json.js +1 -1
- package/package.json +3 -22
- package/src/lib/alert.ts +3 -3
- package/src/lib/api_search.svelte.ts +9 -11
- package/src/lib/autofocus.svelte.ts +2 -2
- package/src/lib/context_helpers.ts +2 -2
- package/src/lib/contextmenu_helpers.ts +21 -21
- package/src/lib/contextmenu_state.svelte.ts +32 -34
- package/src/lib/csp.ts +42 -54
- package/src/lib/csp_of_fuzdev.ts +2 -2
- package/src/lib/declaration.svelte.ts +157 -62
- package/src/lib/declaration_contextmenu.ts +5 -5
- package/src/lib/dialog.ts +1 -1
- package/src/lib/docs_helpers.svelte.ts +9 -9
- package/src/lib/icons.ts +205 -205
- package/src/lib/intersect.svelte.ts +5 -5
- package/src/lib/library.svelte.ts +103 -36
- package/src/lib/library_helpers.ts +2 -2
- package/src/lib/logos.ts +43 -43
- package/src/lib/module.svelte.ts +98 -49
- package/src/lib/module_contextmenu.ts +4 -4
- package/src/lib/project_stats.ts +220 -0
- package/src/lib/project_stats_data.ts +472 -0
- package/src/lib/project_stats_update.task.ts +53 -0
- package/src/lib/projects.ts +49 -0
- package/src/lib/publish.task.ts +22 -0
- package/src/lib/site.svelte.ts +5 -5
- package/src/lib/sparkline.ts +173 -0
- package/src/lib/storage.ts +2 -2
- package/src/lib/style_variable_helpers.svelte.ts +2 -2
- package/src/lib/svg.ts +2 -2
- package/src/lib/theme_state.svelte.ts +8 -8
- package/src/lib/tome.ts +8 -8
- package/src/lib/vite_plugin_pkg_json.ts +8 -8
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure geometry helpers behind `Sparkline` and `ProjectActivityChart`.
|
|
3
|
+
*
|
|
4
|
+
* Computes polyline points, alpha-fade gradient stops, and the end-dot
|
|
5
|
+
* position for a series of values, so components stay thin and the math is
|
|
6
|
+
* testable and reusable outside Svelte.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Vertical scale for a sparkline's geometry. The nonlinear options compress
|
|
13
|
+
* the top of the range so small values stay legible under a large shared
|
|
14
|
+
* max — increasingly so from `'sqrt'` to smaller power exponents (a number
|
|
15
|
+
* in `(0, 1]`, where `1` is linear and `1 / 3` is cube root) to `'log'`.
|
|
16
|
+
*/
|
|
17
|
+
export type SparklineScale = 'linear' | 'sqrt' | 'log' | number;
|
|
18
|
+
|
|
19
|
+
export interface SparklineOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Width of the drawing area in px.
|
|
22
|
+
*/
|
|
23
|
+
width: number;
|
|
24
|
+
/**
|
|
25
|
+
* Height of the drawing area in px.
|
|
26
|
+
*/
|
|
27
|
+
height: number;
|
|
28
|
+
/**
|
|
29
|
+
* The value rendered at full height and full alpha.
|
|
30
|
+
* Pass a shared max across sparklines for comparable scales.
|
|
31
|
+
* Defaults to the local max of the values.
|
|
32
|
+
*/
|
|
33
|
+
max?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Vertical scale for the line's geometry. The alpha fade always tracks
|
|
36
|
+
* the linear ratio regardless of `scale`.
|
|
37
|
+
*
|
|
38
|
+
* @default 'linear'
|
|
39
|
+
*/
|
|
40
|
+
scale?: SparklineScale;
|
|
41
|
+
/**
|
|
42
|
+
* @default 2
|
|
43
|
+
*/
|
|
44
|
+
stroke_width?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Alpha at a value of 0, scaling linearly to 1 at the max.
|
|
47
|
+
*
|
|
48
|
+
* @default 0.4
|
|
49
|
+
*/
|
|
50
|
+
alpha_floor?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Reserve padding for an end dot of radius `stroke_width` at the final point.
|
|
53
|
+
*
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
end_dot?: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A gradient stop for the per-point alpha fade.
|
|
61
|
+
*/
|
|
62
|
+
export interface SparklineStop {
|
|
63
|
+
/**
|
|
64
|
+
* Gradient offset in `[0, 1]`.
|
|
65
|
+
*/
|
|
66
|
+
offset: number;
|
|
67
|
+
/**
|
|
68
|
+
* Stop opacity in `[alpha_floor, 1]`.
|
|
69
|
+
*/
|
|
70
|
+
opacity: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface SparklineGeometry {
|
|
74
|
+
/**
|
|
75
|
+
* SVG polyline `points` string.
|
|
76
|
+
*/
|
|
77
|
+
points: string;
|
|
78
|
+
/**
|
|
79
|
+
* Alpha-fade gradient stops, thinned to runs' boundaries so long flat
|
|
80
|
+
* stretches (like all-zero history) cost a constant number of stops.
|
|
81
|
+
*/
|
|
82
|
+
stops: Array<SparklineStop>;
|
|
83
|
+
/**
|
|
84
|
+
* X coordinate of the final point.
|
|
85
|
+
*/
|
|
86
|
+
end_x: number;
|
|
87
|
+
/**
|
|
88
|
+
* Y coordinate of the final point.
|
|
89
|
+
*/
|
|
90
|
+
end_y: number;
|
|
91
|
+
/**
|
|
92
|
+
* Alpha of the final point.
|
|
93
|
+
*/
|
|
94
|
+
end_alpha: number;
|
|
95
|
+
/**
|
|
96
|
+
* Radius for an end dot, equal to the stroke width.
|
|
97
|
+
*/
|
|
98
|
+
dot_radius: number;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const round = (n: number): number => Math.round(n * 100) / 100;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Computes the rendering geometry for a sparkline of `values`.
|
|
105
|
+
*
|
|
106
|
+
* Returns `null` when `values` has fewer than 2 points, which cannot form a line.
|
|
107
|
+
*/
|
|
108
|
+
export const sparkline_geometry = (
|
|
109
|
+
values: Array<number>,
|
|
110
|
+
options: SparklineOptions
|
|
111
|
+
): SparklineGeometry | null => {
|
|
112
|
+
if (values.length < 2) return null;
|
|
113
|
+
const {
|
|
114
|
+
width,
|
|
115
|
+
height,
|
|
116
|
+
max,
|
|
117
|
+
scale = 'linear',
|
|
118
|
+
stroke_width = 2,
|
|
119
|
+
alpha_floor = 0.4,
|
|
120
|
+
end_dot = false
|
|
121
|
+
} = options;
|
|
122
|
+
const local_max = max ?? Math.max(0, ...values);
|
|
123
|
+
const scale_max = local_max > 0 ? local_max : 1;
|
|
124
|
+
const dot_radius = stroke_width;
|
|
125
|
+
// inset by half the stroke (or the dot radius) so the extremes aren't clipped
|
|
126
|
+
const pad = end_dot ? Math.max(stroke_width / 2, dot_radius) : stroke_width / 2;
|
|
127
|
+
const x_coord = (index: number): number =>
|
|
128
|
+
pad + (index * (width - 2 * pad)) / (values.length - 1);
|
|
129
|
+
const y_coord = (value: number): number => {
|
|
130
|
+
const clamped = Math.min(value, scale_max);
|
|
131
|
+
const ratio = clamped / scale_max;
|
|
132
|
+
const scaled =
|
|
133
|
+
scale === 'linear'
|
|
134
|
+
? ratio
|
|
135
|
+
: scale === 'sqrt'
|
|
136
|
+
? Math.sqrt(ratio)
|
|
137
|
+
: scale === 'log'
|
|
138
|
+
? Math.log1p(clamped) / Math.log1p(scale_max)
|
|
139
|
+
: ratio ** scale;
|
|
140
|
+
return height - pad - scaled * (height - 2 * pad);
|
|
141
|
+
};
|
|
142
|
+
const alpha = (value: number): number =>
|
|
143
|
+
alpha_floor + (1 - alpha_floor) * (Math.min(value, scale_max) / scale_max);
|
|
144
|
+
|
|
145
|
+
const points = values
|
|
146
|
+
.map((value, index) => `${round(x_coord(index))},${round(y_coord(value))}`)
|
|
147
|
+
.join(' ');
|
|
148
|
+
|
|
149
|
+
const opacities = values.map((value) => round(alpha(value)));
|
|
150
|
+
const stops: Array<SparklineStop> = [];
|
|
151
|
+
for (let i = 0; i < values.length; i++) {
|
|
152
|
+
const opacity = opacities[i]!;
|
|
153
|
+
// keep the first and last stops and each run's boundaries; drop run interiors
|
|
154
|
+
if (
|
|
155
|
+
i > 0 &&
|
|
156
|
+
i < values.length - 1 &&
|
|
157
|
+
opacity === opacities[i - 1] &&
|
|
158
|
+
opacity === opacities[i + 1]
|
|
159
|
+
) {
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
stops.push({ offset: round(x_coord(i) / width), opacity });
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
points,
|
|
167
|
+
stops,
|
|
168
|
+
end_x: round(x_coord(values.length - 1)),
|
|
169
|
+
end_y: round(y_coord(values[values.length - 1]!)),
|
|
170
|
+
end_alpha: opacities[values.length - 1]!,
|
|
171
|
+
dot_radius
|
|
172
|
+
};
|
|
173
|
+
};
|
package/src/lib/storage.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {BROWSER} from 'esm-env';
|
|
1
|
+
import { BROWSER } from 'esm-env';
|
|
2
2
|
|
|
3
3
|
// TODO more than just localStorage, maybe rework the module
|
|
4
4
|
|
|
@@ -26,7 +26,7 @@ export const save_to_storage = (key: string, value: any, is_json = false): void
|
|
|
26
26
|
export const load_from_storage = <T>(
|
|
27
27
|
key: string,
|
|
28
28
|
is_json = false,
|
|
29
|
-
parse_fn?: (value: unknown) => T | null
|
|
29
|
+
parse_fn?: (value: unknown) => T | null
|
|
30
30
|
): T | null => {
|
|
31
31
|
if (!BROWSER) return null;
|
|
32
32
|
try {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {StyleVariable} from '@fuzdev/fuz_css/variable.ts';
|
|
1
|
+
import type { StyleVariable } from '@fuzdev/fuz_css/variable.ts';
|
|
2
2
|
|
|
3
|
-
import {create_context} from './context_helpers.ts';
|
|
3
|
+
import { create_context } from './context_helpers.ts';
|
|
4
4
|
|
|
5
5
|
export const selected_variable_context = create_context(() => new SelectedStyleVariable(null));
|
|
6
6
|
|
package/src/lib/svg.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {SvelteHTMLElements} from 'svelte/elements';
|
|
1
|
+
import type { SvelteHTMLElements } from 'svelte/elements';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A structured icon definition rendered by `Svg.svelte`. Rendering is purely
|
|
@@ -11,7 +11,7 @@ export interface SvgData {
|
|
|
11
11
|
* List of svg `path` attribute objects, spread onto each `path` element. The
|
|
12
12
|
* `d` attribute is required; a per-path `fill` overrides the resolved `fill`.
|
|
13
13
|
*/
|
|
14
|
-
paths?: Array<{d: string} & SvelteHTMLElements['path']> | null;
|
|
14
|
+
paths?: Array<{ d: string } & SvelteHTMLElements['path']> | null;
|
|
15
15
|
/**
|
|
16
16
|
* Inline `style` applied to the root `svg` element, merged with any `style`
|
|
17
17
|
* passed as a component prop. Travels with the icon definition - per-instance
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {color_schemes, type ColorScheme, type Theme} from '@fuzdev/fuz_css/theme.ts';
|
|
2
|
-
import {default_themes} from '@fuzdev/fuz_css/themes.ts';
|
|
3
|
-
import {BROWSER} from 'esm-env';
|
|
1
|
+
import { color_schemes, type ColorScheme, type Theme } from '@fuzdev/fuz_css/theme.ts';
|
|
2
|
+
import { default_themes } from '@fuzdev/fuz_css/themes.ts';
|
|
3
|
+
import { BROWSER } from 'esm-env';
|
|
4
4
|
|
|
5
|
-
import {create_context} from './context_helpers.ts';
|
|
6
|
-
import {load_from_storage, save_to_storage} from './storage.ts';
|
|
5
|
+
import { create_context } from './context_helpers.ts';
|
|
6
|
+
import { load_from_storage, save_to_storage } from './storage.ts';
|
|
7
7
|
|
|
8
8
|
export interface ThemeStateJson {
|
|
9
9
|
theme: Theme;
|
|
@@ -29,7 +29,7 @@ export class ThemeState {
|
|
|
29
29
|
toJSON(): ThemeStateJson {
|
|
30
30
|
return {
|
|
31
31
|
theme: this.theme,
|
|
32
|
-
color_scheme: this.color_scheme
|
|
32
|
+
color_scheme: this.color_scheme
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -49,14 +49,14 @@ export const THEME_STORAGE_KEY = 'fuz:theme';
|
|
|
49
49
|
|
|
50
50
|
export const save_color_scheme = (
|
|
51
51
|
color_scheme: ColorScheme | null,
|
|
52
|
-
key = COLOR_SCHEME_STORAGE_KEY
|
|
52
|
+
key = COLOR_SCHEME_STORAGE_KEY
|
|
53
53
|
): void => {
|
|
54
54
|
save_to_storage(key, color_scheme);
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
export const load_color_scheme = (
|
|
58
58
|
fallback: ColorScheme = 'auto',
|
|
59
|
-
key = COLOR_SCHEME_STORAGE_KEY
|
|
59
|
+
key = COLOR_SCHEME_STORAGE_KEY
|
|
60
60
|
): ColorScheme => load_from_storage(key, false, parse_color_scheme) ?? fallback;
|
|
61
61
|
|
|
62
62
|
export const save_theme = (theme: Theme | null, key = THEME_STORAGE_KEY): void => {
|
package/src/lib/tome.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {resolve} from '$app/paths';
|
|
2
|
-
import type {Component} from 'svelte';
|
|
3
|
-
import {z} from 'zod';
|
|
4
|
-
import {ensure_start} from '@fuzdev/fuz_util/string.ts';
|
|
1
|
+
import { resolve } from '$app/paths';
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { ensure_start } from '@fuzdev/fuz_util/string.ts';
|
|
5
5
|
|
|
6
|
-
import {create_context} from './context_helpers.ts';
|
|
7
|
-
import {DOCS_PATH_DEFAULT} from './docs_helpers.svelte.ts';
|
|
6
|
+
import { create_context } from './context_helpers.ts';
|
|
7
|
+
import { DOCS_PATH_DEFAULT } from './docs_helpers.svelte.ts';
|
|
8
8
|
|
|
9
9
|
export const tomes_context = create_context<() => Map<string, Tome>>();
|
|
10
10
|
|
|
@@ -29,7 +29,7 @@ export const Tome = z.object({
|
|
|
29
29
|
Component: z.custom<Component<any, any>>(),
|
|
30
30
|
related_tomes: z.array(z.string()),
|
|
31
31
|
related_modules: z.array(z.string()),
|
|
32
|
-
related_declarations: z.array(z.string())
|
|
32
|
+
related_declarations: z.array(z.string())
|
|
33
33
|
});
|
|
34
34
|
export type Tome = z.infer<typeof Tome>;
|
|
35
35
|
|
|
@@ -39,7 +39,7 @@ export type Tome = z.infer<typeof Tome>;
|
|
|
39
39
|
export const tome_to_pathname = (
|
|
40
40
|
item: Tome | string,
|
|
41
41
|
docs_path = DOCS_PATH_DEFAULT,
|
|
42
|
-
hash?: string
|
|
42
|
+
hash?: string
|
|
43
43
|
): string => {
|
|
44
44
|
const slug = typeof item === 'string' ? item : item.slug;
|
|
45
45
|
const path = docs_path + '/' + slug;
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
* @module
|
|
45
45
|
*/
|
|
46
46
|
|
|
47
|
-
import {readFileSync} from 'node:fs';
|
|
48
|
-
import {join} from 'node:path';
|
|
49
|
-
import type {Plugin, Rollup} from 'vite';
|
|
50
|
-
import type {PackageJson} from '@fuzdev/fuz_util/package_json.ts';
|
|
51
|
-
import {pkg_json_from_package_json, pkg_json_keys} from '@fuzdev/fuz_util/pkg_json.ts';
|
|
47
|
+
import { readFileSync } from 'node:fs';
|
|
48
|
+
import { join } from 'node:path';
|
|
49
|
+
import type { Plugin, Rollup } from 'vite';
|
|
50
|
+
import type { PackageJson } from '@fuzdev/fuz_util/package_json.ts';
|
|
51
|
+
import { pkg_json_from_package_json, pkg_json_keys } from '@fuzdev/fuz_util/pkg_json.ts';
|
|
52
52
|
|
|
53
53
|
const VIRTUAL_ID = 'virtual:pkg.json';
|
|
54
54
|
/**
|
|
@@ -81,7 +81,7 @@ export interface VitePluginPkgJsonOptions {
|
|
|
81
81
|
* the publish-safe field set defaults to `pkg_json_keys`; widen it via `keys`.
|
|
82
82
|
*/
|
|
83
83
|
export const vite_plugin_pkg_json = (options: VitePluginPkgJsonOptions = {}): Plugin => {
|
|
84
|
-
const {keys = pkg_json_keys} = options;
|
|
84
|
+
const { keys = pkg_json_keys } = options;
|
|
85
85
|
let root = '';
|
|
86
86
|
let is_dev = false;
|
|
87
87
|
/** Curated JSON cached for build; left `null` in dev so `load` re-reads. */
|
|
@@ -106,7 +106,7 @@ export const vite_plugin_pkg_json = (options: VitePluginPkgJsonOptions = {}): Pl
|
|
|
106
106
|
return ctx.error(
|
|
107
107
|
`vite_plugin_pkg_json: failed to read or parse ${package_json_path}: ${
|
|
108
108
|
(err as Error).message
|
|
109
|
-
}
|
|
109
|
+
}`
|
|
110
110
|
);
|
|
111
111
|
}
|
|
112
112
|
if (raw.name === undefined) {
|
|
@@ -139,6 +139,6 @@ export const vite_plugin_pkg_json = (options: VitePluginPkgJsonOptions = {}): Pl
|
|
|
139
139
|
load(id) {
|
|
140
140
|
if (id !== RESOLVED_VIRTUAL_ID) return undefined;
|
|
141
141
|
return cached ?? read_curated(this);
|
|
142
|
-
}
|
|
142
|
+
}
|
|
143
143
|
};
|
|
144
144
|
};
|