@alliance-droid/svelte-docs-system 0.0.2 → 0.1.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.
- package/README.md +155 -23
- package/dist/components/APITable.svelte.d.ts +21 -0
- package/dist/components/Breadcrumbs.svelte.d.ts +14 -0
- package/dist/components/Callout.svelte.d.ts +15 -0
- package/dist/components/CodeBlock.svelte.d.ts +12 -0
- package/{src/lib → dist}/components/DocLayout.svelte +18 -6
- package/dist/components/DocLayout.svelte.d.ts +18 -0
- package/dist/components/DocsPage.svelte +39 -0
- package/dist/components/DocsPage.svelte.d.ts +8 -0
- package/dist/components/Documentation.svelte +639 -0
- package/dist/components/Footer.svelte.d.ts +10 -0
- package/dist/components/Image.svelte.d.ts +15 -0
- package/{src/lib → dist}/components/Navbar.svelte +4 -4
- package/dist/components/Navbar.svelte.d.ts +10 -0
- package/{src/lib → dist}/components/Search.svelte +2 -2
- package/dist/components/Search.svelte.d.ts +6 -0
- package/{template-starter/src/lib → dist}/components/Sidebar.svelte +2 -2
- package/dist/components/Sidebar.svelte.d.ts +9 -0
- package/dist/components/Tabs.svelte.d.ts +16 -0
- package/dist/config.d.ts +93 -0
- package/dist/config.js +89 -0
- package/dist/configLoader.d.ts +48 -0
- package/dist/configLoader.js +187 -0
- package/dist/configParser.d.ts +27 -0
- package/dist/configParser.js +208 -0
- package/{template-starter/src/lib/index.ts → dist/index.d.ts} +6 -7
- package/dist/index.js +18 -0
- package/dist/navigationBuilder.d.ts +64 -0
- package/dist/navigationBuilder.js +225 -0
- package/dist/plugin.d.ts +30 -0
- package/dist/plugin.js +172 -0
- package/dist/routing.d.ts +48 -0
- package/dist/routing.js +92 -0
- package/dist/stores/i18n.d.ts +20 -0
- package/dist/stores/i18n.js +119 -0
- package/dist/stores/nav.d.ts +20 -0
- package/dist/stores/nav.js +15 -0
- package/dist/stores/search.d.ts +49 -0
- package/dist/stores/search.js +127 -0
- package/dist/stores/theme.d.ts +7 -0
- package/dist/stores/theme.js +152 -0
- package/dist/stores/version.d.ts +18 -0
- package/dist/stores/version.js +93 -0
- package/dist/themeCustomization.d.ts +46 -0
- package/dist/themeCustomization.js +188 -0
- package/dist/utils/highlight.d.ts +13 -0
- package/dist/utils/highlight.js +83 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/markdown.d.ts +40 -0
- package/dist/utils/markdown.js +165 -0
- package/package.json +45 -23
- package/COMPONENTS.md +0 -365
- package/COVERAGE_REPORT.md +0 -663
- package/SEARCH_VERIFICATION.md +0 -229
- package/TEST_SUMMARY.md +0 -344
- package/bin/init.js +0 -821
- package/docs/COMPONENT_LIBRARY_INTEGRATION_REPORT.md +0 -153
- package/docs/DARK_MODE_AUDIT_REPORT.md +0 -403
- package/docs/E2E_TESTS.md +0 -354
- package/docs/TESTING.md +0 -754
- package/docs/THEME_INHERITANCE.md +0 -192
- package/docs/de/index.md +0 -41
- package/docs/en/COMPONENTS.md +0 -443
- package/docs/en/api/examples.md +0 -100
- package/docs/en/api/overview.md +0 -69
- package/docs/en/components/index.md +0 -622
- package/docs/en/config/navigation.md +0 -505
- package/docs/en/config/theme-and-colors.md +0 -395
- package/docs/en/getting-started/integration.md +0 -406
- package/docs/en/guides/common-setups.md +0 -651
- package/docs/en/index.md +0 -243
- package/docs/en/markdown.md +0 -102
- package/docs/en/routing.md +0 -64
- package/docs/en/setup.md +0 -52
- package/docs/en/troubleshooting.md +0 -704
- package/docs/es/index.md +0 -41
- package/docs/fr/index.md +0 -41
- package/docs/ja/index.md +0 -41
- package/pagefind.toml +0 -8
- package/postcss.config.js +0 -5
- package/src/app.css +0 -119
- package/src/app.d.ts +0 -13
- package/src/app.html +0 -11
- package/src/lib/components/APITable.test.ts +0 -153
- package/src/lib/components/Breadcrumbs.test.ts +0 -148
- package/src/lib/components/Callout.test.ts +0 -100
- package/src/lib/components/CodeBlock.test.ts +0 -133
- package/src/lib/components/Image.test.ts +0 -163
- package/src/lib/components/Sidebar.svelte +0 -110
- package/src/lib/components/Tabs.test.ts +0 -102
- package/src/lib/config.test.ts +0 -140
- package/src/lib/config.ts +0 -179
- package/src/lib/configIntegration.test.ts +0 -272
- package/src/lib/configLoader.ts +0 -231
- package/src/lib/configParser.test.ts +0 -217
- package/src/lib/configParser.ts +0 -234
- package/src/lib/index.ts +0 -37
- package/src/lib/integration.test.ts +0 -426
- package/src/lib/navigationBuilder.test.ts +0 -338
- package/src/lib/navigationBuilder.ts +0 -268
- package/src/lib/performance.test.ts +0 -369
- package/src/lib/routing.test.ts +0 -202
- package/src/lib/routing.ts +0 -127
- package/src/lib/search-functionality.test.ts +0 -493
- package/src/lib/stores/i18n.test.ts +0 -180
- package/src/lib/stores/i18n.ts +0 -143
- package/src/lib/stores/nav.ts +0 -36
- package/src/lib/stores/search.test.ts +0 -140
- package/src/lib/stores/search.ts +0 -162
- package/src/lib/stores/theme.test.ts +0 -117
- package/src/lib/stores/theme.ts +0 -167
- package/src/lib/stores/version.test.ts +0 -139
- package/src/lib/stores/version.ts +0 -111
- package/src/lib/themeCustomization.test.ts +0 -223
- package/src/lib/themeCustomization.ts +0 -212
- package/src/lib/utils/highlight.test.ts +0 -136
- package/src/lib/utils/highlight.ts +0 -100
- package/src/lib/utils/index.ts +0 -7
- package/src/lib/utils/markdown.test.ts +0 -357
- package/src/lib/utils/markdown.ts +0 -77
- package/src/routes/+layout.server.ts +0 -1
- package/src/routes/+layout.svelte +0 -29
- package/src/routes/+page.svelte +0 -165
- package/src/routes/quote-demo/+page.svelte +0 -141
- package/static/robots.txt +0 -3
- package/svelte.config.js +0 -15
- package/tailwind.config.ts +0 -55
- package/template-starter/.github/workflows/build.yml +0 -40
- package/template-starter/.github/workflows/deploy-github-pages.yml +0 -47
- package/template-starter/.github/workflows/deploy-netlify.yml +0 -41
- package/template-starter/.github/workflows/deploy-vercel.yml +0 -64
- package/template-starter/NPM-PACKAGE-SETUP.md +0 -233
- package/template-starter/README.md +0 -320
- package/template-starter/docs/_config.json +0 -39
- package/template-starter/docs/api/components.md +0 -257
- package/template-starter/docs/api/overview.md +0 -169
- package/template-starter/docs/guides/configuration.md +0 -145
- package/template-starter/docs/guides/github-pages-deployment.md +0 -254
- package/template-starter/docs/guides/netlify-deployment.md +0 -159
- package/template-starter/docs/guides/vercel-deployment.md +0 -131
- package/template-starter/docs/index.md +0 -49
- package/template-starter/docs/setup.md +0 -149
- package/template-starter/package.json +0 -31
- package/template-starter/pagefind.toml +0 -3
- package/template-starter/postcss.config.js +0 -5
- package/template-starter/src/app.css +0 -34
- package/template-starter/src/app.d.ts +0 -13
- package/template-starter/src/app.html +0 -11
- package/template-starter/src/lib/components/APITable.svelte +0 -120
- package/template-starter/src/lib/components/APITable.test.ts +0 -96
- package/template-starter/src/lib/components/Breadcrumbs.svelte +0 -85
- package/template-starter/src/lib/components/Breadcrumbs.test.ts +0 -82
- package/template-starter/src/lib/components/Callout.svelte +0 -60
- package/template-starter/src/lib/components/Callout.test.ts +0 -91
- package/template-starter/src/lib/components/CodeBlock.svelte +0 -68
- package/template-starter/src/lib/components/CodeBlock.test.ts +0 -62
- package/template-starter/src/lib/components/DocLayout.svelte +0 -84
- package/template-starter/src/lib/components/Footer.svelte +0 -78
- package/template-starter/src/lib/components/Image.svelte +0 -100
- package/template-starter/src/lib/components/Image.test.ts +0 -81
- package/template-starter/src/lib/components/Navbar.svelte +0 -141
- package/template-starter/src/lib/components/Search.svelte +0 -248
- package/template-starter/src/lib/components/Tabs.svelte +0 -48
- package/template-starter/src/lib/components/Tabs.test.ts +0 -89
- package/template-starter/src/routes/+layout.svelte +0 -28
- package/template-starter/src/routes/+page.svelte +0 -92
- package/template-starter/svelte.config.js +0 -17
- package/template-starter/tailwind.config.ts +0 -17
- package/template-starter/tsconfig.json +0 -13
- package/template-starter/vite.config.ts +0 -6
- package/tests/e2e/example.spec.ts +0 -345
- package/tsconfig.json +0 -20
- package/vite.config.ts +0 -6
- package/vitest.config.ts +0 -33
- package/vitest.setup.ts +0 -21
- /package/{src/lib → dist}/assets/favicon.svg +0 -0
- /package/{src/lib → dist}/components/APITable.svelte +0 -0
- /package/{src/lib → dist}/components/Breadcrumbs.svelte +0 -0
- /package/{src/lib → dist}/components/Callout.svelte +0 -0
- /package/{src/lib → dist}/components/CodeBlock.svelte +0 -0
- /package/{src/lib → dist}/components/Footer.svelte +0 -0
- /package/{src/lib → dist}/components/Image.svelte +0 -0
- /package/{src/lib → dist}/components/Tabs.svelte +0 -0
- /package/{src/lib → dist}/svelte-component-library.d.ts +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type Language = 'en' | 'fr' | 'es' | 'de' | 'ja';
|
|
2
|
+
export interface LanguageMetadata {
|
|
3
|
+
code: Language;
|
|
4
|
+
label: string;
|
|
5
|
+
nativeLabel: string;
|
|
6
|
+
direction: 'ltr' | 'rtl';
|
|
7
|
+
isDefault?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface I18nConfig {
|
|
10
|
+
currentLanguage: Language;
|
|
11
|
+
availableLanguages: LanguageMetadata[];
|
|
12
|
+
defaultLanguage: Language;
|
|
13
|
+
}
|
|
14
|
+
export declare const i18n: {
|
|
15
|
+
subscribe: (this: void, run: import("svelte/store").Subscriber<I18nConfig>, invalidate?: () => void) => import("svelte/store").Unsubscriber;
|
|
16
|
+
setLanguage: (language: Language) => void;
|
|
17
|
+
addLanguage: (metadata: LanguageMetadata) => void;
|
|
18
|
+
removeLanguage: (language: Language) => void;
|
|
19
|
+
getLanguageMetadata: (language: Language) => LanguageMetadata | undefined;
|
|
20
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { writable } from 'svelte/store';
|
|
2
|
+
function createI18nStore() {
|
|
3
|
+
// Default language configuration
|
|
4
|
+
const defaultConfig = {
|
|
5
|
+
currentLanguage: 'en',
|
|
6
|
+
defaultLanguage: 'en',
|
|
7
|
+
availableLanguages: [
|
|
8
|
+
{
|
|
9
|
+
code: 'en',
|
|
10
|
+
label: 'English',
|
|
11
|
+
nativeLabel: 'English',
|
|
12
|
+
direction: 'ltr',
|
|
13
|
+
isDefault: true,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
code: 'fr',
|
|
17
|
+
label: 'Français',
|
|
18
|
+
nativeLabel: 'Français',
|
|
19
|
+
direction: 'ltr',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
code: 'es',
|
|
23
|
+
label: 'Español',
|
|
24
|
+
nativeLabel: 'Español',
|
|
25
|
+
direction: 'ltr',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
code: 'de',
|
|
29
|
+
label: 'Deutsch',
|
|
30
|
+
nativeLabel: 'Deutsch',
|
|
31
|
+
direction: 'ltr',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
code: 'ja',
|
|
35
|
+
label: '日本語',
|
|
36
|
+
nativeLabel: '日本語',
|
|
37
|
+
direction: 'ltr',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
const getInitialLanguage = () => {
|
|
42
|
+
if (typeof window === 'undefined') {
|
|
43
|
+
return defaultConfig.defaultLanguage;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
// Check localStorage for stored language preference
|
|
47
|
+
const stored = localStorage?.getItem?.('docs-language');
|
|
48
|
+
if (stored && defaultConfig.availableLanguages.some((l) => l.code === stored)) {
|
|
49
|
+
return stored;
|
|
50
|
+
}
|
|
51
|
+
// Check browser language preference
|
|
52
|
+
const browserLang = navigator?.language?.split('-')[0].toLowerCase();
|
|
53
|
+
const matchedLang = defaultConfig.availableLanguages.find((l) => l.code === browserLang);
|
|
54
|
+
if (matchedLang) {
|
|
55
|
+
return matchedLang.code;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
// localStorage or navigator may not be available in some environments
|
|
60
|
+
}
|
|
61
|
+
return defaultConfig.defaultLanguage;
|
|
62
|
+
};
|
|
63
|
+
const { subscribe, set, update } = writable({
|
|
64
|
+
...defaultConfig,
|
|
65
|
+
currentLanguage: getInitialLanguage(),
|
|
66
|
+
});
|
|
67
|
+
return {
|
|
68
|
+
subscribe,
|
|
69
|
+
setLanguage: (language) => {
|
|
70
|
+
update((config) => {
|
|
71
|
+
if (config.availableLanguages.some((l) => l.code === language)) {
|
|
72
|
+
if (typeof window !== 'undefined') {
|
|
73
|
+
try {
|
|
74
|
+
localStorage?.setItem?.('docs-language', language);
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
// localStorage may not be available
|
|
78
|
+
}
|
|
79
|
+
// Update document lang attribute
|
|
80
|
+
if (document?.documentElement) {
|
|
81
|
+
document.documentElement.lang = language;
|
|
82
|
+
// Update document dir attribute
|
|
83
|
+
const metadata = config.availableLanguages.find((l) => l.code === language);
|
|
84
|
+
if (metadata) {
|
|
85
|
+
document.documentElement.dir = metadata.direction;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return { ...config, currentLanguage: language };
|
|
90
|
+
}
|
|
91
|
+
return config;
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
addLanguage: (metadata) => {
|
|
95
|
+
update((config) => ({
|
|
96
|
+
...config,
|
|
97
|
+
availableLanguages: [
|
|
98
|
+
...config.availableLanguages.filter((l) => l.code !== metadata.code),
|
|
99
|
+
metadata,
|
|
100
|
+
],
|
|
101
|
+
}));
|
|
102
|
+
},
|
|
103
|
+
removeLanguage: (language) => {
|
|
104
|
+
update((config) => ({
|
|
105
|
+
...config,
|
|
106
|
+
availableLanguages: config.availableLanguages.filter((l) => l.code !== language),
|
|
107
|
+
}));
|
|
108
|
+
},
|
|
109
|
+
getLanguageMetadata: (language) => {
|
|
110
|
+
let metadata;
|
|
111
|
+
const unsubscribe = subscribe((config) => {
|
|
112
|
+
metadata = config.availableLanguages.find((l) => l.code === language);
|
|
113
|
+
});
|
|
114
|
+
unsubscribe();
|
|
115
|
+
return metadata;
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
export const i18n = createI18nStore();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface NavItem {
|
|
2
|
+
label: string;
|
|
3
|
+
href?: string;
|
|
4
|
+
children?: NavItem[];
|
|
5
|
+
icon?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface NavConfig {
|
|
8
|
+
title: string;
|
|
9
|
+
sections: NavSection[];
|
|
10
|
+
}
|
|
11
|
+
export interface NavSection {
|
|
12
|
+
title: string;
|
|
13
|
+
items: NavItem[];
|
|
14
|
+
}
|
|
15
|
+
export declare const nav: {
|
|
16
|
+
subscribe: (this: void, run: import("svelte/store").Subscriber<NavConfig>, invalidate?: () => void) => import("svelte/store").Unsubscriber;
|
|
17
|
+
setNav: (config: NavConfig) => void;
|
|
18
|
+
updateNav: (fn: (nav: NavConfig) => NavConfig) => void;
|
|
19
|
+
};
|
|
20
|
+
export declare const sidebarOpen: import("svelte/store").Writable<boolean>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { writable } from 'svelte/store';
|
|
2
|
+
function createNavStore() {
|
|
3
|
+
const { subscribe, set, update } = writable({
|
|
4
|
+
title: 'Documentation',
|
|
5
|
+
sections: [],
|
|
6
|
+
});
|
|
7
|
+
return {
|
|
8
|
+
subscribe,
|
|
9
|
+
setNav: (config) => set(config),
|
|
10
|
+
updateNav: (fn) => update(fn),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export const nav = createNavStore();
|
|
14
|
+
// Store for mobile sidebar visibility
|
|
15
|
+
export const sidebarOpen = writable(false);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type Writable, type Readable } from 'svelte/store';
|
|
2
|
+
export interface SearchResult {
|
|
3
|
+
id: string;
|
|
4
|
+
url: string;
|
|
5
|
+
title: string;
|
|
6
|
+
content: string;
|
|
7
|
+
excerpt?: string;
|
|
8
|
+
meta?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
interface SearchFilters {
|
|
11
|
+
limit?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Initialize Pagefind when the client loads
|
|
15
|
+
*/
|
|
16
|
+
export declare function initPagefind(): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Perform a search query
|
|
19
|
+
*/
|
|
20
|
+
export declare function performSearch(query: string, filters?: SearchFilters): Promise<SearchResult[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Get reactive search results
|
|
23
|
+
*/
|
|
24
|
+
export declare const results: Readable<SearchResult[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Get reactive search query
|
|
27
|
+
*/
|
|
28
|
+
export declare const query: Writable<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Get reactive loading state
|
|
31
|
+
*/
|
|
32
|
+
export declare const loading: Writable<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* Computed derived store for result count
|
|
35
|
+
*/
|
|
36
|
+
export declare const resultCount: Readable<number>;
|
|
37
|
+
/**
|
|
38
|
+
* Clear search results and query
|
|
39
|
+
*/
|
|
40
|
+
export declare function clearSearch(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Update search query and perform search
|
|
43
|
+
*/
|
|
44
|
+
export declare function updateSearch(newQuery: string, filters?: SearchFilters): Promise<SearchResult[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Subscribe to search query changes with debouncing
|
|
47
|
+
*/
|
|
48
|
+
export declare function subscribeToSearch(callback: (query: string) => Promise<void>, delayMs?: number): () => void;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import { writable, derived } from 'svelte/store';
|
|
10
|
+
// Main search query store
|
|
11
|
+
const searchQuery = writable('');
|
|
12
|
+
// Search results store
|
|
13
|
+
const searchResults = writable([]);
|
|
14
|
+
// Loading state store
|
|
15
|
+
const isSearching = writable(false);
|
|
16
|
+
// Pagefind index reference
|
|
17
|
+
let pagefindIndex = null;
|
|
18
|
+
/**
|
|
19
|
+
* Initialize Pagefind when the client loads
|
|
20
|
+
*/
|
|
21
|
+
export async function initPagefind() {
|
|
22
|
+
if (typeof window === 'undefined') {
|
|
23
|
+
console.warn('Pagefind can only be initialized on the client side');
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
// Check if pagefind is already available globally (from build output)
|
|
28
|
+
if (window.pagefind) {
|
|
29
|
+
pagefindIndex = window.pagefind;
|
|
30
|
+
console.log('Pagefind initialized successfully (from global)');
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
// Dynamically import Pagefind from the build output
|
|
34
|
+
// Use string concatenation to prevent Vite from resolving this at build time
|
|
35
|
+
const pagefindPath = '/' + 'pagefind' + '/' + 'pagefind.js';
|
|
36
|
+
const pagefind = await import(__rewriteRelativeImportExtension(/* @vite-ignore */ pagefindPath, true));
|
|
37
|
+
pagefindIndex = pagefind;
|
|
38
|
+
console.log('Pagefind initialized successfully (from dynamic import)');
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
console.error('Failed to initialize Pagefind:', error);
|
|
42
|
+
console.warn('Search functionality will not work. Make sure to run `npm run build` to generate search index.');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Perform a search query
|
|
47
|
+
*/
|
|
48
|
+
export async function performSearch(query, filters) {
|
|
49
|
+
if (!query.trim()) {
|
|
50
|
+
searchResults.set([]);
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
if (!pagefindIndex) {
|
|
54
|
+
console.warn('Pagefind not yet initialized');
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
isSearching.set(true);
|
|
58
|
+
try {
|
|
59
|
+
const results = await pagefindIndex.search(query);
|
|
60
|
+
const limit = filters?.limit || 20;
|
|
61
|
+
// Convert Pagefind results to our SearchResult format
|
|
62
|
+
const formattedResults = results.results
|
|
63
|
+
.slice(0, limit)
|
|
64
|
+
.map((result) => ({
|
|
65
|
+
id: result.id,
|
|
66
|
+
url: result.url,
|
|
67
|
+
title: result.meta?.title || 'Untitled',
|
|
68
|
+
content: result.meta?.content || '',
|
|
69
|
+
excerpt: result.excerpt || '',
|
|
70
|
+
meta: result.meta || {}
|
|
71
|
+
}));
|
|
72
|
+
searchResults.set(formattedResults);
|
|
73
|
+
return formattedResults;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error('Search error:', error);
|
|
77
|
+
searchResults.set([]);
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
isSearching.set(false);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get reactive search results
|
|
86
|
+
*/
|
|
87
|
+
export const results = derived(searchResults, ($results) => $results);
|
|
88
|
+
/**
|
|
89
|
+
* Get reactive search query
|
|
90
|
+
*/
|
|
91
|
+
export const query = searchQuery;
|
|
92
|
+
/**
|
|
93
|
+
* Get reactive loading state
|
|
94
|
+
*/
|
|
95
|
+
export const loading = isSearching;
|
|
96
|
+
/**
|
|
97
|
+
* Computed derived store for result count
|
|
98
|
+
*/
|
|
99
|
+
export const resultCount = derived(searchResults, ($results) => $results.length);
|
|
100
|
+
/**
|
|
101
|
+
* Clear search results and query
|
|
102
|
+
*/
|
|
103
|
+
export function clearSearch() {
|
|
104
|
+
searchQuery.set('');
|
|
105
|
+
searchResults.set([]);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Update search query and perform search
|
|
109
|
+
*/
|
|
110
|
+
export async function updateSearch(newQuery, filters) {
|
|
111
|
+
searchQuery.set(newQuery);
|
|
112
|
+
return performSearch(newQuery, filters);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Subscribe to search query changes with debouncing
|
|
116
|
+
*/
|
|
117
|
+
export function subscribeToSearch(callback, delayMs = 300) {
|
|
118
|
+
let timeout;
|
|
119
|
+
const unsubscribe = searchQuery.subscribe((query) => {
|
|
120
|
+
clearTimeout(timeout);
|
|
121
|
+
timeout = setTimeout(() => callback(query), delayMs);
|
|
122
|
+
});
|
|
123
|
+
return () => {
|
|
124
|
+
clearTimeout(timeout);
|
|
125
|
+
unsubscribe();
|
|
126
|
+
};
|
|
127
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type Theme = 'light' | 'dark';
|
|
2
|
+
export declare const theme: {
|
|
3
|
+
subscribe: (this: void, run: import("svelte/store").Subscriber<Theme>, invalidate?: () => void) => import("svelte/store").Unsubscriber;
|
|
4
|
+
set: (theme: Theme) => void;
|
|
5
|
+
toggle: () => void;
|
|
6
|
+
};
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { writable } from 'svelte/store';
|
|
2
|
+
/**
|
|
3
|
+
* Detects if this app is embedded in a parent app by checking if window.parent exists
|
|
4
|
+
* and is different from the current window.
|
|
5
|
+
*/
|
|
6
|
+
function isEmbedded() {
|
|
7
|
+
if (typeof window === 'undefined')
|
|
8
|
+
return false;
|
|
9
|
+
try {
|
|
10
|
+
return window.parent !== window && window.parent !== null;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Attempts to detect the parent app's theme by checking the parent window's
|
|
18
|
+
* document.documentElement classList for the 'dark' class.
|
|
19
|
+
*/
|
|
20
|
+
function getParentTheme() {
|
|
21
|
+
if (!isEmbedded())
|
|
22
|
+
return null;
|
|
23
|
+
try {
|
|
24
|
+
// Try to access parent's document to check for dark class
|
|
25
|
+
if (window.parent &&
|
|
26
|
+
window.parent.document &&
|
|
27
|
+
window.parent.document.documentElement) {
|
|
28
|
+
const hasDarkClass = window.parent.document.documentElement.classList.contains('dark');
|
|
29
|
+
return hasDarkClass ? 'dark' : 'light';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
// Cross-origin or other access errors - fall back to other methods
|
|
34
|
+
console.debug('Unable to detect parent theme via document inspection:', e);
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
function createThemeStore() {
|
|
39
|
+
/**
|
|
40
|
+
* Initializes theme by:
|
|
41
|
+
* 1. Checking if embedded in parent app and inheriting parent's theme
|
|
42
|
+
* 2. Falling back to localStorage preference
|
|
43
|
+
* 3. Falling back to system preference
|
|
44
|
+
* 4. Defaulting to 'light'
|
|
45
|
+
*/
|
|
46
|
+
const getInitialTheme = () => {
|
|
47
|
+
if (typeof window === 'undefined') {
|
|
48
|
+
return 'light'; // SSR default
|
|
49
|
+
}
|
|
50
|
+
// Priority 1: Check parent app theme if embedded
|
|
51
|
+
const parentTheme = getParentTheme();
|
|
52
|
+
if (parentTheme) {
|
|
53
|
+
return parentTheme;
|
|
54
|
+
}
|
|
55
|
+
// Priority 2: Check localStorage (user preference in standalone mode)
|
|
56
|
+
try {
|
|
57
|
+
const stored = localStorage?.getItem?.('theme');
|
|
58
|
+
if (stored) {
|
|
59
|
+
return stored;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
// localStorage may not be available in some environments
|
|
64
|
+
}
|
|
65
|
+
// Priority 3: Check system preference
|
|
66
|
+
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
67
|
+
return 'dark';
|
|
68
|
+
}
|
|
69
|
+
return 'light';
|
|
70
|
+
};
|
|
71
|
+
const { subscribe, set, update } = writable(getInitialTheme());
|
|
72
|
+
// Set up listener for parent theme changes when embedded
|
|
73
|
+
if (typeof window !== 'undefined' && isEmbedded()) {
|
|
74
|
+
try {
|
|
75
|
+
const observer = new MutationObserver((mutations) => {
|
|
76
|
+
mutations.forEach((mutation) => {
|
|
77
|
+
if (mutation.type === 'attributes' &&
|
|
78
|
+
mutation.attributeName === 'class' &&
|
|
79
|
+
mutation.target === window.parent?.document?.documentElement) {
|
|
80
|
+
// Parent's dark class changed, update our theme
|
|
81
|
+
const parentTheme = getParentTheme();
|
|
82
|
+
if (parentTheme) {
|
|
83
|
+
const currentTheme = parentTheme;
|
|
84
|
+
applyTheme(currentTheme);
|
|
85
|
+
set(currentTheme);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
// Watch for class changes on parent's documentElement
|
|
91
|
+
if (window.parent?.document?.documentElement) {
|
|
92
|
+
observer.observe(window.parent.document.documentElement, {
|
|
93
|
+
attributes: true,
|
|
94
|
+
attributeFilter: ['class'],
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
console.debug('Could not set up parent theme listener (may be cross-origin):', e);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Applies theme to the document by adding/removing the 'dark' class
|
|
104
|
+
*/
|
|
105
|
+
const applyTheme = (theme) => {
|
|
106
|
+
if (typeof window === 'undefined')
|
|
107
|
+
return;
|
|
108
|
+
if (theme === 'dark') {
|
|
109
|
+
document.documentElement.classList.add('dark');
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
document.documentElement.classList.remove('dark');
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
return {
|
|
116
|
+
subscribe,
|
|
117
|
+
set: (theme) => {
|
|
118
|
+
if (typeof window !== 'undefined') {
|
|
119
|
+
// Only save to localStorage if not embedded (standalone mode)
|
|
120
|
+
if (!isEmbedded()) {
|
|
121
|
+
try {
|
|
122
|
+
localStorage?.setItem?.('theme', theme);
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
// localStorage may not be available
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
applyTheme(theme);
|
|
129
|
+
}
|
|
130
|
+
set(theme);
|
|
131
|
+
},
|
|
132
|
+
toggle: () => {
|
|
133
|
+
update((theme) => {
|
|
134
|
+
const newTheme = theme === 'dark' ? 'light' : 'dark';
|
|
135
|
+
if (typeof window !== 'undefined') {
|
|
136
|
+
// Only save to localStorage if not embedded (standalone mode)
|
|
137
|
+
if (!isEmbedded()) {
|
|
138
|
+
try {
|
|
139
|
+
localStorage?.setItem?.('theme', newTheme);
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
// localStorage may not be available
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
applyTheme(newTheme);
|
|
146
|
+
}
|
|
147
|
+
return newTheme;
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
export const theme = createThemeStore();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface VersionMetadata {
|
|
2
|
+
version: string;
|
|
3
|
+
label: string;
|
|
4
|
+
isLatest: boolean;
|
|
5
|
+
releaseDate?: string;
|
|
6
|
+
status?: 'stable' | 'beta' | 'deprecated';
|
|
7
|
+
}
|
|
8
|
+
export interface VersionConfig {
|
|
9
|
+
current: string;
|
|
10
|
+
availableVersions: VersionMetadata[];
|
|
11
|
+
}
|
|
12
|
+
export declare const version: {
|
|
13
|
+
subscribe: (this: void, run: import("svelte/store").Subscriber<VersionConfig>, invalidate?: () => void) => import("svelte/store").Unsubscriber;
|
|
14
|
+
setVersion: (version: string) => void;
|
|
15
|
+
addVersion: (metadata: VersionMetadata) => void;
|
|
16
|
+
removeVersion: (version: string) => void;
|
|
17
|
+
getVersionMetadata: (version: string) => VersionMetadata | undefined;
|
|
18
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { writable } from 'svelte/store';
|
|
2
|
+
function createVersionStore() {
|
|
3
|
+
// Default version configuration
|
|
4
|
+
const defaultConfig = {
|
|
5
|
+
current: '2.0',
|
|
6
|
+
availableVersions: [
|
|
7
|
+
{
|
|
8
|
+
version: '2.0',
|
|
9
|
+
label: 'v2.0 (Latest)',
|
|
10
|
+
isLatest: true,
|
|
11
|
+
releaseDate: '2026-02-04',
|
|
12
|
+
status: 'stable',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
version: '1.5',
|
|
16
|
+
label: 'v1.5',
|
|
17
|
+
isLatest: false,
|
|
18
|
+
releaseDate: '2025-12-01',
|
|
19
|
+
status: 'stable',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
version: '1.0',
|
|
23
|
+
label: 'v1.0 (Archive)',
|
|
24
|
+
isLatest: false,
|
|
25
|
+
releaseDate: '2025-10-01',
|
|
26
|
+
status: 'deprecated',
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
const getInitialVersion = () => {
|
|
31
|
+
if (typeof window === 'undefined') {
|
|
32
|
+
return defaultConfig.current;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
// Check localStorage for stored version preference
|
|
36
|
+
const stored = localStorage?.getItem?.('docs-version');
|
|
37
|
+
if (stored) {
|
|
38
|
+
return stored;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
// localStorage may not be available in some environments
|
|
43
|
+
}
|
|
44
|
+
return defaultConfig.current;
|
|
45
|
+
};
|
|
46
|
+
const { subscribe, set, update } = writable({
|
|
47
|
+
...defaultConfig,
|
|
48
|
+
current: getInitialVersion(),
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
subscribe,
|
|
52
|
+
setVersion: (version) => {
|
|
53
|
+
update((config) => {
|
|
54
|
+
if (config.availableVersions.some((v) => v.version === version)) {
|
|
55
|
+
if (typeof window !== 'undefined') {
|
|
56
|
+
try {
|
|
57
|
+
localStorage?.setItem?.('docs-version', version);
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
// localStorage may not be available
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return { ...config, current: version };
|
|
64
|
+
}
|
|
65
|
+
return config;
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
addVersion: (metadata) => {
|
|
69
|
+
update((config) => ({
|
|
70
|
+
...config,
|
|
71
|
+
availableVersions: [
|
|
72
|
+
...config.availableVersions.filter((v) => v.version !== metadata.version),
|
|
73
|
+
metadata,
|
|
74
|
+
],
|
|
75
|
+
}));
|
|
76
|
+
},
|
|
77
|
+
removeVersion: (version) => {
|
|
78
|
+
update((config) => ({
|
|
79
|
+
...config,
|
|
80
|
+
availableVersions: config.availableVersions.filter((v) => v.version !== version),
|
|
81
|
+
}));
|
|
82
|
+
},
|
|
83
|
+
getVersionMetadata: (version) => {
|
|
84
|
+
let metadata;
|
|
85
|
+
const unsubscribe = subscribe((config) => {
|
|
86
|
+
metadata = config.availableVersions.find((v) => v.version === version);
|
|
87
|
+
});
|
|
88
|
+
unsubscribe();
|
|
89
|
+
return metadata;
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export const version = createVersionStore();
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme customization system
|
|
3
|
+
* Generates CSS variables from theme configuration
|
|
4
|
+
*/
|
|
5
|
+
import type { ThemeConfig } from './config';
|
|
6
|
+
export interface CSSVariables {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Generate CSS custom properties (variables) from theme config
|
|
11
|
+
* These can be injected into the document or stylesheet
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateCSSVariables(theme: ThemeConfig): CSSVariables;
|
|
14
|
+
/**
|
|
15
|
+
* Apply CSS variables to the document root
|
|
16
|
+
*/
|
|
17
|
+
export declare function applyCSSVariables(vars: CSSVariables): void;
|
|
18
|
+
/**
|
|
19
|
+
* Create a stylesheet string from CSS variables
|
|
20
|
+
* Useful for injecting into <style> tags
|
|
21
|
+
*/
|
|
22
|
+
export declare function createCSSVariablesStylesheet(vars: CSSVariables): string;
|
|
23
|
+
/**
|
|
24
|
+
* Parse a color value and validate it
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseColor(color: string): {
|
|
27
|
+
valid: boolean;
|
|
28
|
+
value?: string;
|
|
29
|
+
error?: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Validate theme configuration
|
|
33
|
+
*/
|
|
34
|
+
export declare function validateTheme(theme: ThemeConfig): {
|
|
35
|
+
valid: boolean;
|
|
36
|
+
errors: string[];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Merge theme configs, with priority to the first argument
|
|
40
|
+
*/
|
|
41
|
+
export declare function mergeThemes(primary: ThemeConfig, secondary: ThemeConfig): ThemeConfig;
|
|
42
|
+
/**
|
|
43
|
+
* Get a predefined theme template
|
|
44
|
+
*/
|
|
45
|
+
export type ThemeTemplate = 'default' | 'dark' | 'minimal' | 'colorful';
|
|
46
|
+
export declare function getThemeTemplate(template?: ThemeTemplate): ThemeConfig;
|