Cleanup/code cleanup 2026 03 (#45)
* chore: cleanup of unused exports and stuff * fix: media and languages was broken for english media * fix: embedding model load was broken on standalone --------- Co-authored-by: hugo <hugoms@me.com>
This commit is contained in:
@@ -17,7 +17,8 @@
|
|||||||
"Bash(grep -n \"templateSlug\\\\|postTemplateSlug\" /Users/gb/Projects/bDS/src/main/engine/*.ts)",
|
"Bash(grep -n \"templateSlug\\\\|postTemplateSlug\" /Users/gb/Projects/bDS/src/main/engine/*.ts)",
|
||||||
"Bash(npm test -- tests/renderer/i18nLocaleCompleteness.test.ts)",
|
"Bash(npm test -- tests/renderer/i18nLocaleCompleteness.test.ts)",
|
||||||
"WebFetch(domain:ricmac.org)",
|
"WebFetch(domain:ricmac.org)",
|
||||||
"WebFetch(domain:docs.mistral.ai)"
|
"WebFetch(domain:docs.mistral.ai)",
|
||||||
|
"Bash(npm uninstall dropbox date-fns @testing-library/user-event @types/dagre electron-store memfs)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
55
knip.json
Normal file
55
knip.json
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://unpkg.com/knip@5/schema.json",
|
||||||
|
"entry": [
|
||||||
|
"src/main/main.ts",
|
||||||
|
"src/main/preload.ts",
|
||||||
|
"src/cli/bds-mcp.ts",
|
||||||
|
"src/main/engine/generation.worker.ts",
|
||||||
|
"src/main/engine/pythonMacro.worker.ts",
|
||||||
|
"src/main/engine/blogmarkPython.worker.ts"
|
||||||
|
],
|
||||||
|
"project": [
|
||||||
|
"src/**/*.{ts,tsx}"
|
||||||
|
],
|
||||||
|
"ignoreDependencies": [
|
||||||
|
"@ai-sdk/provider",
|
||||||
|
"@electron/notarize",
|
||||||
|
"@floating-ui/dom",
|
||||||
|
"@milkdown/plugin-block",
|
||||||
|
"@milkdown/plugin-clipboard",
|
||||||
|
"@milkdown/plugin-cursor",
|
||||||
|
"@milkdown/plugin-history",
|
||||||
|
"@milkdown/plugin-indent",
|
||||||
|
"@milkdown/plugin-listener",
|
||||||
|
"@milkdown/plugin-trailing",
|
||||||
|
"@milkdown/theme-nord",
|
||||||
|
"d3-cloud",
|
||||||
|
"highlight.js",
|
||||||
|
"lightbox2",
|
||||||
|
"marked",
|
||||||
|
"mdast",
|
||||||
|
"unified",
|
||||||
|
"unist-util-visit",
|
||||||
|
"vanilla-calendar-pro"
|
||||||
|
],
|
||||||
|
"vitest": {
|
||||||
|
"config": ["vitest.config.ts"],
|
||||||
|
"entry": [
|
||||||
|
"tests/**/*.test.{ts,tsx}",
|
||||||
|
"src/**/*.test.{ts,tsx}",
|
||||||
|
"tests/setup.ts"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"eslint": {
|
||||||
|
"config": ["eslint.config.mjs"]
|
||||||
|
},
|
||||||
|
"vite": {
|
||||||
|
"config": ["vite.config.ts", "vite.config.cli.ts"]
|
||||||
|
},
|
||||||
|
"drizzle": {
|
||||||
|
"config": ["drizzle.config.ts"]
|
||||||
|
},
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["src/renderer/*"]
|
||||||
|
}
|
||||||
|
}
|
||||||
847
package-lock.json
generated
847
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -41,9 +41,7 @@
|
|||||||
"@electron/notarize": "^3.1.0",
|
"@electron/notarize": "^3.1.0",
|
||||||
"@testing-library/jest-dom": "^6.9.1",
|
"@testing-library/jest-dom": "^6.9.1",
|
||||||
"@testing-library/react": "^16.3.2",
|
"@testing-library/react": "^16.3.2",
|
||||||
"@testing-library/user-event": "^14.6.1",
|
|
||||||
"@types/chokidar": "^1.7.5",
|
"@types/chokidar": "^1.7.5",
|
||||||
"@types/dagre": "^0.7.54",
|
|
||||||
"@types/node": "^25.2.3",
|
"@types/node": "^25.2.3",
|
||||||
"@types/react": "^19.2.14",
|
"@types/react": "^19.2.14",
|
||||||
"@types/react-dom": "^19.2.3",
|
"@types/react-dom": "^19.2.3",
|
||||||
@@ -58,11 +56,9 @@
|
|||||||
"drizzle-kit": "^0.31.9",
|
"drizzle-kit": "^0.31.9",
|
||||||
"electron": "^40.4.0",
|
"electron": "^40.4.0",
|
||||||
"electron-builder": "^26.7.0",
|
"electron-builder": "^26.7.0",
|
||||||
"electron-store": "^11.0.2",
|
|
||||||
"eslint": "^9.39.3",
|
"eslint": "^9.39.3",
|
||||||
"eslint-plugin-i18next": "^6.1.3",
|
"eslint-plugin-i18next": "^6.1.3",
|
||||||
"jsdom": "^28.0.0",
|
"jsdom": "^28.0.0",
|
||||||
"memfs": "^4.6.0",
|
|
||||||
"png-to-ico": "^3.0.1",
|
"png-to-ico": "^3.0.1",
|
||||||
"tsx": "^4.6.0",
|
"tsx": "^4.6.0",
|
||||||
"typescript": "^5.3.0",
|
"typescript": "^5.3.0",
|
||||||
@@ -98,9 +94,7 @@
|
|||||||
"ai": "^6.0.105",
|
"ai": "^6.0.105",
|
||||||
"chokidar": "^5.0.0",
|
"chokidar": "^5.0.0",
|
||||||
"d3-cloud": "^1.2.8",
|
"d3-cloud": "^1.2.8",
|
||||||
"date-fns": "^4.1.0",
|
|
||||||
"drizzle-orm": "^0.45.1",
|
"drizzle-orm": "^0.45.1",
|
||||||
"dropbox": "^10.34.0",
|
|
||||||
"fast-xml-parser": "^5.3.8",
|
"fast-xml-parser": "^5.3.8",
|
||||||
"gray-matter": "^4.0.3",
|
"gray-matter": "^4.0.3",
|
||||||
"lightbox2": "^2.11.5",
|
"lightbox2": "^2.11.5",
|
||||||
@@ -136,6 +130,10 @@
|
|||||||
"appId": "com.bds.blogging-desktop-server",
|
"appId": "com.bds.blogging-desktop-server",
|
||||||
"productName": "Blogging Desktop Server",
|
"productName": "Blogging Desktop Server",
|
||||||
"asar": true,
|
"asar": true,
|
||||||
|
"asarUnpack": [
|
||||||
|
"node_modules/onnxruntime-node/**",
|
||||||
|
"node_modules/usearch/**"
|
||||||
|
],
|
||||||
"afterSign": "scripts/notarize.mjs",
|
"afterSign": "scripts/notarize.mjs",
|
||||||
"directories": {
|
"directories": {
|
||||||
"output": "release"
|
"output": "release"
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export interface MacroConfig {
|
|||||||
* Registry of known macro configurations.
|
* Registry of known macro configurations.
|
||||||
* Add new macros here to enable validation during import analysis.
|
* Add new macros here to enable validation during import analysis.
|
||||||
*/
|
*/
|
||||||
export const macroConfigs: MacroConfig[] = [
|
const macroConfigs: MacroConfig[] = [
|
||||||
{
|
{
|
||||||
name: 'youtube',
|
name: 'youtube',
|
||||||
description: 'Embeds a YouTube video player',
|
description: 'Embeds a YouTube video player',
|
||||||
@@ -105,43 +105,3 @@ export function getMacroConfigMap(): Map<string, MacroConfig> {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate macro parameters against known configurations.
|
|
||||||
*
|
|
||||||
* @param macroName - The macro name
|
|
||||||
* @param params - The macro parameters
|
|
||||||
* @returns Error message if invalid, undefined if valid or macro is unknown
|
|
||||||
*/
|
|
||||||
export function validateMacroParams(
|
|
||||||
macroName: string,
|
|
||||||
params: Record<string, string>
|
|
||||||
): { valid: boolean; error?: string; known: boolean } {
|
|
||||||
const config = getMacroConfigMap().get(macroName.toLowerCase());
|
|
||||||
|
|
||||||
if (!config) {
|
|
||||||
return { valid: false, known: false };
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check required parameters
|
|
||||||
if (config.requiredParams) {
|
|
||||||
for (const param of config.requiredParams) {
|
|
||||||
if (!params[param]) {
|
|
||||||
return {
|
|
||||||
valid: false,
|
|
||||||
known: true,
|
|
||||||
error: `Missing required parameter: ${param}`
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Run custom validation if provided
|
|
||||||
if (config.validate) {
|
|
||||||
const error = config.validate(params);
|
|
||||||
if (error) {
|
|
||||||
return { valid: false, known: true, error };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return { valid: true, known: true };
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -43,11 +43,11 @@ export function urlPathToHtmlIndexPath(htmlDir: string, urlPath: string): string
|
|||||||
return path.join(htmlDir, normalizedPath.slice(1), 'index.html');
|
return path.join(htmlDir, normalizedPath.slice(1), 'index.html');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function computeContentHash(content: string): string {
|
function computeContentHash(content: string): string {
|
||||||
return crypto.createHash('sha256').update(content).digest('hex');
|
return crypto.createHash('sha256').update(content).digest('hex');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function computeBufferHash(content: Buffer): string {
|
function computeBufferHash(content: Buffer): string {
|
||||||
return crypto.createHash('sha256').update(content).digest('hex');
|
return crypto.createHash('sha256').update(content).digest('hex');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ export interface DuplicatePair {
|
|||||||
export interface EmbeddingEngineDeps {
|
export interface EmbeddingEngineDeps {
|
||||||
/** Return the path to the USearch index file for a project */
|
/** Return the path to the USearch index file for a project */
|
||||||
getIndexPath: (projectId: string) => string;
|
getIndexPath: (projectId: string) => string;
|
||||||
|
/** Writable directory for caching downloaded models (must be outside app.asar) */
|
||||||
|
modelCacheDir: string;
|
||||||
/** Create the embedding pipeline (dependency-injected for tests) */
|
/** Create the embedding pipeline (dependency-injected for tests) */
|
||||||
createPipeline?: () => Promise<EmbeddingPipeline>;
|
createPipeline?: () => Promise<EmbeddingPipeline>;
|
||||||
}
|
}
|
||||||
@@ -104,8 +106,9 @@ export class EmbeddingEngine extends EventEmitter {
|
|||||||
// Dynamic import to avoid loading heavy ONNX runtime at startup
|
// Dynamic import to avoid loading heavy ONNX runtime at startup
|
||||||
const { pipeline, env } = await import('@huggingface/transformers');
|
const { pipeline, env } = await import('@huggingface/transformers');
|
||||||
|
|
||||||
// Configure cache for Electron -- use ~/.cache/huggingface
|
// Configure cache for Electron -- point to writable userData dir (not app.asar)
|
||||||
env.useFSCache = true;
|
env.useFSCache = true;
|
||||||
|
env.cacheDir = this.deps.modelCacheDir;
|
||||||
|
|
||||||
const extractor = await pipeline('feature-extraction', this.MODEL_ID, {
|
const extractor = await pipeline('feature-extraction', this.MODEL_ID, {
|
||||||
dtype: 'fp32',
|
dtype: 'fp32',
|
||||||
|
|||||||
@@ -144,19 +144,9 @@ function normalizeProjectMetadata(metadata: ProjectMetadata): ProjectMetadata {
|
|||||||
/**
|
/**
|
||||||
* Default categories for new projects (from VISION.md)
|
* Default categories for new projects (from VISION.md)
|
||||||
*/
|
*/
|
||||||
export const DEFAULT_CATEGORIES = ['article', 'picture', 'aside', 'page'];
|
const DEFAULT_CATEGORIES = ['article', 'picture', 'aside', 'page'];
|
||||||
|
|
||||||
export function getDefaultCategorySettings(): Record<string, CategoryRenderSettings> {
|
function getDefaultCategoryMetadata(): Record<string, CategoryMetadata> {
|
||||||
const defaults = getDefaultCategoryMetadata();
|
|
||||||
return Object.fromEntries(
|
|
||||||
Object.entries(defaults).map(([category, value]) => [
|
|
||||||
category,
|
|
||||||
{ renderInLists: value.renderInLists, showTitle: value.showTitle },
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getDefaultCategoryMetadata(): Record<string, CategoryMetadata> {
|
|
||||||
return {
|
return {
|
||||||
article: { renderInLists: true, showTitle: true, title: 'article' },
|
article: { renderInLists: true, showTitle: true, title: 'article' },
|
||||||
picture: { renderInLists: true, showTitle: true, title: 'picture' },
|
picture: { renderInLists: true, showTitle: true, title: 'picture' },
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ export interface TagUsageEntry {
|
|||||||
|
|
||||||
export type TagCloudOrientationMode = 'horizontal' | 'mixed-hv' | 'mixed-diagonal';
|
export type TagCloudOrientationMode = 'horizontal' | 'mixed-hv' | 'mixed-diagonal';
|
||||||
|
|
||||||
export function normalizeTagCloudOrientation(value: string | undefined): TagCloudOrientationMode {
|
function normalizeTagCloudOrientation(value: string | undefined): TagCloudOrientationMode {
|
||||||
const normalized = (value || '').trim().toLowerCase();
|
const normalized = (value || '').trim().toLowerCase();
|
||||||
|
|
||||||
if (normalized === 'mixed_hv' || normalized === 'mixed-hv' || normalized === 'hv' || normalized === 'horizontal_vertical') {
|
if (normalized === 'mixed_hv' || normalized === 'mixed-hv' || normalized === 'hv' || normalized === 'horizontal_vertical') {
|
||||||
@@ -376,7 +376,7 @@ export function resolvePageTitle(metadata: { description?: string; name?: string
|
|||||||
return 'Blog Preview';
|
return 'Blog Preview';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function escapeHtml(value: string): string {
|
function escapeHtml(value: string): string {
|
||||||
return value
|
return value
|
||||||
.replace(/&/g, '&')
|
.replace(/&/g, '&')
|
||||||
.replace(/</g, '<')
|
.replace(/</g, '<')
|
||||||
@@ -385,7 +385,7 @@ export function escapeHtml(value: string): string {
|
|||||||
.replace(/'/g, ''');
|
.replace(/'/g, ''');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseMacroParams(paramString: string | undefined): Record<string, string> {
|
function parseMacroParams(paramString: string | undefined): Record<string, string> {
|
||||||
if (!paramString) return {};
|
if (!paramString) return {};
|
||||||
|
|
||||||
const params: Record<string, string> = {};
|
const params: Record<string, string> = {};
|
||||||
@@ -399,7 +399,7 @@ export function parseMacroParams(paramString: string | undefined): Record<string
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseIntegerParam(value: string | undefined): number | null {
|
function parseIntegerParam(value: string | undefined): number | null {
|
||||||
if (!value) return null;
|
if (!value) return null;
|
||||||
const parsed = Number.parseInt(value, 10);
|
const parsed = Number.parseInt(value, 10);
|
||||||
return Number.isInteger(parsed) ? parsed : null;
|
return Number.isInteger(parsed) ? parsed : null;
|
||||||
@@ -514,13 +514,13 @@ function renderMacroTemplate(templateName: string, context: Record<string, unkno
|
|||||||
return macroLiquid.parseAndRenderSync(readMacroTemplateSource(templateName), context);
|
return macroLiquid.parseAndRenderSync(readMacroTemplateSource(templateName), context);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildCanonicalMediaPath(media: MediaData): string {
|
function buildCanonicalMediaPath(media: MediaData): string {
|
||||||
const year = media.createdAt.getFullYear();
|
const year = media.createdAt.getFullYear();
|
||||||
const month = String(media.createdAt.getMonth() + 1).padStart(2, '0');
|
const month = String(media.createdAt.getMonth() + 1).padStart(2, '0');
|
||||||
return `/media/${year}/${month}/${media.filename}`;
|
return `/media/${year}/${month}/${media.filename}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isRenderableImage(media: MediaData): boolean {
|
function isRenderableImage(media: MediaData): boolean {
|
||||||
if (media.mimeType?.toLowerCase().startsWith('image/')) {
|
if (media.mimeType?.toLowerCase().startsWith('image/')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -529,7 +529,7 @@ export function isRenderableImage(media: MediaData): boolean {
|
|||||||
return ['.jpg', '.jpeg', '.png', '.gif', '.webp', '.svg', '.bmp', '.avif'].includes(extension);
|
return ['.jpg', '.jpeg', '.png', '.gif', '.webp', '.svg', '.bmp', '.avif'].includes(extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildPhotoArchiveBuckets(
|
function buildPhotoArchiveBuckets(
|
||||||
mediaItems: MediaData[],
|
mediaItems: MediaData[],
|
||||||
params: Record<string, string>,
|
params: Record<string, string>,
|
||||||
): Array<{ year: number; month: number; media: MediaData[] }> {
|
): Array<{ year: number; month: number; media: MediaData[] }> {
|
||||||
@@ -580,7 +580,7 @@ export function buildPhotoArchiveBuckets(
|
|||||||
return orderedBuckets;
|
return orderedBuckets;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function renderGalleryMacro(
|
function renderGalleryMacro(
|
||||||
params: Record<string, string>,
|
params: Record<string, string>,
|
||||||
postId: string,
|
postId: string,
|
||||||
mediaItems: MediaData[],
|
mediaItems: MediaData[],
|
||||||
@@ -621,7 +621,7 @@ export function renderGalleryMacro(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function renderPhotoArchiveMacro(
|
function renderPhotoArchiveMacro(
|
||||||
params: Record<string, string>,
|
params: Record<string, string>,
|
||||||
mediaItems: MediaData[],
|
mediaItems: MediaData[],
|
||||||
renderLanguage: string,
|
renderLanguage: string,
|
||||||
@@ -678,7 +678,7 @@ export function renderPhotoArchiveMacro(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function renderTagCloudMacro(params: Record<string, string>, tagUsage: TagUsageEntry[], renderLanguage: string): string {
|
function renderTagCloudMacro(params: Record<string, string>, tagUsage: TagUsageEntry[], renderLanguage: string): string {
|
||||||
const language = resolveRenderLanguageFromProjectPreferences(renderLanguage);
|
const language = resolveRenderLanguageFromProjectPreferences(renderLanguage);
|
||||||
const widthParam = parseIntegerParam(params.width);
|
const widthParam = parseIntegerParam(params.width);
|
||||||
const heightParam = parseIntegerParam(params.height);
|
const heightParam = parseIntegerParam(params.height);
|
||||||
@@ -727,14 +727,14 @@ export function renderTagCloudMacro(params: Record<string, string>, tagUsage: Ta
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isExternalOrSpecialUrl(value: string): boolean {
|
function isExternalOrSpecialUrl(value: string): boolean {
|
||||||
const normalized = value.trim();
|
const normalized = value.trim();
|
||||||
if (!normalized) return false;
|
if (!normalized) return false;
|
||||||
if (normalized.startsWith('#') || normalized.startsWith('//')) return true;
|
if (normalized.startsWith('#') || normalized.startsWith('//')) return true;
|
||||||
return /^[a-z][a-z0-9+.-]*:/i.test(normalized);
|
return /^[a-z][a-z0-9+.-]*:/i.test(normalized);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function splitPathSuffix(value: string): { pathPart: string; suffix: string } {
|
function splitPathSuffix(value: string): { pathPart: string; suffix: string } {
|
||||||
const match = value.match(/^([^?#]*)([?#].*)?$/);
|
const match = value.match(/^([^?#]*)([?#].*)?$/);
|
||||||
return {
|
return {
|
||||||
pathPart: match?.[1] ?? value,
|
pathPart: match?.[1] ?? value,
|
||||||
@@ -802,7 +802,7 @@ export function normalizePreviewHref(rawHref: string, rewriteContext: HtmlRewrit
|
|||||||
return rawHref;
|
return rawHref;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function normalizePreviewSrc(rawSrc: string, rewriteContext: HtmlRewriteContext): string {
|
function normalizePreviewSrc(rawSrc: string, rewriteContext: HtmlRewriteContext): string {
|
||||||
if (!rawSrc || isExternalOrSpecialUrl(rawSrc)) {
|
if (!rawSrc || isExternalOrSpecialUrl(rawSrc)) {
|
||||||
return rawSrc;
|
return rawSrc;
|
||||||
}
|
}
|
||||||
@@ -891,7 +891,7 @@ export function isBuiltInMacro(name: string): boolean {
|
|||||||
return JS_BUILTIN_MACROS.has(normalizeMacroName(name));
|
return JS_BUILTIN_MACROS.has(normalizeMacroName(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function serializePostDataForMacro(post: PostData): Record<string, unknown> {
|
function serializePostDataForMacro(post: PostData): Record<string, unknown> {
|
||||||
return {
|
return {
|
||||||
id: post.id,
|
id: post.id,
|
||||||
projectId: post.projectId,
|
projectId: post.projectId,
|
||||||
@@ -1019,21 +1019,21 @@ export function buildCanonicalPostPath(post: PostData): string {
|
|||||||
return `/${year}/${month}/${day}/${post.slug}`;
|
return `/${year}/${month}/${day}/${post.slug}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatArchiveDate(date: Date): string {
|
function formatArchiveDate(date: Date): string {
|
||||||
const day = String(date.getDate()).padStart(2, '0');
|
const day = String(date.getDate()).padStart(2, '0');
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
const year = String(date.getFullYear());
|
const year = String(date.getFullYear());
|
||||||
return `${day}.${month}.${year}`;
|
return `${day}.${month}.${year}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getArchiveDateKey(date: Date): string {
|
function getArchiveDateKey(date: Date): string {
|
||||||
const year = String(date.getFullYear());
|
const year = String(date.getFullYear());
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
const day = String(date.getDate()).padStart(2, '0');
|
const day = String(date.getDate()).padStart(2, '0');
|
||||||
return `${year}-${month}-${day}`;
|
return `${year}-${month}-${day}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toDateParts(date: Date): { day: number; month: number; year: number } {
|
function toDateParts(date: Date): { day: number; month: number; year: number } {
|
||||||
return {
|
return {
|
||||||
day: date.getDate(),
|
day: date.getDate(),
|
||||||
month: date.getMonth() + 1,
|
month: date.getMonth() + 1,
|
||||||
@@ -1041,7 +1041,7 @@ export function toDateParts(date: Date): { day: number; month: number; year: num
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildPaginationHref(basePathname: string, page: number): string {
|
function buildPaginationHref(basePathname: string, page: number): string {
|
||||||
const base = basePathname === '/' ? '' : basePathname;
|
const base = basePathname === '/' ? '' : basePathname;
|
||||||
if (page <= 1) {
|
if (page <= 1) {
|
||||||
return basePathname === '/' ? '/' : `${basePathname}/`;
|
return basePathname === '/' ? '/' : `${basePathname}/`;
|
||||||
@@ -1072,7 +1072,7 @@ export function mapToRecord(map: Map<string, string>): Record<string, string> {
|
|||||||
return Object.fromEntries(map.entries());
|
return Object.fromEntries(map.entries());
|
||||||
}
|
}
|
||||||
|
|
||||||
export function recordToMap(record: unknown): Map<string, string> {
|
function recordToMap(record: unknown): Map<string, string> {
|
||||||
if (!record || typeof record !== 'object') {
|
if (!record || typeof record !== 'object') {
|
||||||
return new Map<string, string>();
|
return new Map<string, string>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ import type { ChatModel } from '../../shared/electronApi';
|
|||||||
// Constants
|
// Constants
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
export const ZEN_BASE_URL = 'https://opencode.ai/zen/v1';
|
const ZEN_BASE_URL = 'https://opencode.ai/zen/v1';
|
||||||
export const ZEN_MODELS_URL = 'https://opencode.ai/zen/v1/models';
|
const ZEN_MODELS_URL = 'https://opencode.ai/zen/v1/models';
|
||||||
export const MISTRAL_MODELS_URL = 'https://api.mistral.ai/v1/models';
|
const MISTRAL_MODELS_URL = 'https://api.mistral.ai/v1/models';
|
||||||
export const OLLAMA_BASE_URL = 'http://localhost:11434/v1';
|
export const OLLAMA_BASE_URL = 'http://localhost:11434/v1';
|
||||||
export const OLLAMA_TAGS_URL = 'http://localhost:11434/api/tags';
|
export const OLLAMA_TAGS_URL = 'http://localhost:11434/api/tags';
|
||||||
export const LMSTUDIO_BASE_URL = 'http://localhost:1234/v1';
|
export const LMSTUDIO_BASE_URL = 'http://localhost:1234/v1';
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
export { TaskManager, taskManager, type Task, type TaskProgress, type TaskStatus } from './TaskManager';
|
|
||||||
export { PostEngine, type PostData, type PostFilter, type SearchResult, type PaginatedResult, type PaginationOptions } from './PostEngine';
|
|
||||||
export { MediaEngine, type MediaData } from './MediaEngine';
|
|
||||||
export { PostMediaEngine, type PostMediaLinkData } from './PostMediaEngine';
|
|
||||||
export { ProjectEngine, type ProjectData } from './ProjectEngine';
|
|
||||||
export { MetaEngine, type ProjectMetadata, DEFAULT_CATEGORIES } from './MetaEngine';
|
|
||||||
export {
|
|
||||||
TagEngine,
|
|
||||||
type TagData,
|
|
||||||
type TagWithCount,
|
|
||||||
type CreateTagInput,
|
|
||||||
type UpdateTagInput,
|
|
||||||
type DeleteTagResult,
|
|
||||||
type MergeTagsResult,
|
|
||||||
type RenameTagResult,
|
|
||||||
type SyncTagsResult,
|
|
||||||
} from './TagEngine';
|
|
||||||
export {
|
|
||||||
stemText,
|
|
||||||
stemWord,
|
|
||||||
stemQuery,
|
|
||||||
prepareForFTS,
|
|
||||||
getSupportedLanguages,
|
|
||||||
isoToStemmerLanguage,
|
|
||||||
type SupportedLanguage,
|
|
||||||
} from './stemmer';
|
|
||||||
export {
|
|
||||||
ChatEngine,
|
|
||||||
type ChatConversationData,
|
|
||||||
type ChatMessageData,
|
|
||||||
type CreateConversationInput,
|
|
||||||
} from './ChatEngine';
|
|
||||||
export {
|
|
||||||
WxrParser,
|
|
||||||
type WxrData,
|
|
||||||
type WxrPost,
|
|
||||||
type WxrMedia,
|
|
||||||
type WxrSiteInfo,
|
|
||||||
type WxrCategory,
|
|
||||||
type WxrTag,
|
|
||||||
} from './WxrParser';
|
|
||||||
export {
|
|
||||||
ImportAnalysisEngine,
|
|
||||||
type ImportAnalysisReport,
|
|
||||||
type AnalyzedPost,
|
|
||||||
type AnalyzedMedia,
|
|
||||||
type AnalyzedCategory,
|
|
||||||
type AnalyzedTag,
|
|
||||||
type PostAnalysisStatus,
|
|
||||||
type MediaAnalysisStatus,
|
|
||||||
type ImportConflictResolution,
|
|
||||||
} from './ImportAnalysisEngine';
|
|
||||||
export {
|
|
||||||
ImportDefinitionEngine,
|
|
||||||
type ImportDefinitionData,
|
|
||||||
} from './ImportDefinitionEngine';
|
|
||||||
export {
|
|
||||||
readPostFile,
|
|
||||||
type PostFileData,
|
|
||||||
} from './postFileUtils';
|
|
||||||
export {
|
|
||||||
MetadataDiffEngine,
|
|
||||||
type PostMetadataDiff,
|
|
||||||
type DiffGroup,
|
|
||||||
type DiffField,
|
|
||||||
type ScanResult,
|
|
||||||
type TableStats,
|
|
||||||
} from './MetadataDiffEngine';
|
|
||||||
export {
|
|
||||||
GitEngine,
|
|
||||||
type GitAvailability,
|
|
||||||
type RepoState,
|
|
||||||
type GitStatusDto,
|
|
||||||
type GitDiffDto,
|
|
||||||
type GitDiffContentDto,
|
|
||||||
type GitHistoryEntry,
|
|
||||||
type GitStatusFile,
|
|
||||||
type GitStatusCounts,
|
|
||||||
type GitInitResult,
|
|
||||||
} from './GitEngine';
|
|
||||||
export {
|
|
||||||
BlogGenerationEngine,
|
|
||||||
resolvePublicBaseUrl,
|
|
||||||
type BlogGenerationOptions,
|
|
||||||
type BlogGenerationResult,
|
|
||||||
} from './BlogGenerationEngine';
|
|
||||||
export {
|
|
||||||
MenuEngine,
|
|
||||||
type MenuItemData,
|
|
||||||
type MenuDocument,
|
|
||||||
type MenuItemKind,
|
|
||||||
} from './MenuEngine';
|
|
||||||
export {
|
|
||||||
ScriptEngine,
|
|
||||||
type ScriptData,
|
|
||||||
type ScriptKind,
|
|
||||||
type CreateScriptInput,
|
|
||||||
type UpdateScriptInput,
|
|
||||||
} from './ScriptEngine';
|
|
||||||
export {
|
|
||||||
PublishEngine,
|
|
||||||
type PublishCredentials,
|
|
||||||
type DirectoryUploadResult,
|
|
||||||
} from './PublishEngine';
|
|
||||||
@@ -245,14 +245,15 @@ export function registerBlogHandlers(safeHandle: SafeHandle, bundle: EngineBundl
|
|||||||
const seenMediaLang = new Set<string>();
|
const seenMediaLang = new Set<string>();
|
||||||
for (let i = 0; i < publishedPosts.length; i++) {
|
for (let i = 0; i < publishedPosts.length; i++) {
|
||||||
const post = publishedPosts[i];
|
const post = publishedPosts[i];
|
||||||
const postLang = post.language || mainLang;
|
|
||||||
const links = await bundle.postMediaEngine.getLinkedMediaForPost(post.id);
|
const links = await bundle.postMediaEngine.getLinkedMediaForPost(post.id);
|
||||||
for (const link of links) {
|
for (const link of links) {
|
||||||
|
const mediaItem = await bundle.mediaEngine.getMedia(link.mediaId);
|
||||||
|
const mediaLang = mediaItem?.language || mainLang;
|
||||||
const mediaTranslations = await bundle.mediaEngine.getMediaTranslations(link.mediaId);
|
const mediaTranslations = await bundle.mediaEngine.getMediaTranslations(link.mediaId);
|
||||||
const existingLangs = new Set(mediaTranslations.map((t) => t.language));
|
const existingLangs = new Set(mediaTranslations.map((t) => t.language));
|
||||||
for (const lang of blogLanguages) {
|
for (const lang of blogLanguages) {
|
||||||
const key = `${link.mediaId}:${lang}`;
|
const key = `${link.mediaId}:${lang}`;
|
||||||
if (lang !== postLang && !existingLangs.has(lang) && !seenMediaLang.has(key)) {
|
if (lang !== mediaLang && !existingLangs.has(lang) && !seenMediaLang.has(key)) {
|
||||||
seenMediaLang.add(key);
|
seenMediaLang.add(key);
|
||||||
mediaItems.push({ mediaId: link.mediaId, targetLang: lang });
|
mediaItems.push({ mediaId: link.mediaId, targetLang: lang });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
export { registerIpcHandlers, registerEventForwarding, startEmbeddingIndexTask, startDuplicateSearchTask, startRebuildEmbeddingIndexTask } from './handlers';
|
export { registerIpcHandlers, registerEventForwarding, startEmbeddingIndexTask, startRebuildEmbeddingIndexTask } from './handlers';
|
||||||
export { registerChatHandlers, initializeChatHandlers, cleanupChatHandlers } from './chatHandlers';
|
export { registerChatHandlers, initializeChatHandlers, cleanupChatHandlers } from './chatHandlers';
|
||||||
|
|||||||
@@ -943,6 +943,7 @@ app.whenReady().then(async () => {
|
|||||||
const embeddingEngine = new EmbeddingEngine({
|
const embeddingEngine = new EmbeddingEngine({
|
||||||
getIndexPath: (projectId: string) =>
|
getIndexPath: (projectId: string) =>
|
||||||
path.join(userData, 'projects', projectId, 'embeddings.usearch'),
|
path.join(userData, 'projects', projectId, 'embeddings.usearch'),
|
||||||
|
modelCacheDir: path.join(userData, 'model-cache'),
|
||||||
});
|
});
|
||||||
const appApiAdapter = new AppApiAdapter(projectEngine);
|
const appApiAdapter = new AppApiAdapter(projectEngine);
|
||||||
const publishApiAdapter = new PublishApiAdapter(projectEngine, publishEngine, taskManager);
|
const publishApiAdapter = new PublishApiAdapter(projectEngine, publishEngine, taskManager);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export const PICO_THEME_NAMES = [
|
|||||||
export type PicoThemeName = (typeof PICO_THEME_NAMES)[number];
|
export type PicoThemeName = (typeof PICO_THEME_NAMES)[number];
|
||||||
export type PicoThemeMode = 'auto' | 'light' | 'dark';
|
export type PicoThemeMode = 'auto' | 'light' | 'dark';
|
||||||
|
|
||||||
export function isPicoThemeName(value: unknown): value is PicoThemeName {
|
function isPicoThemeName(value: unknown): value is PicoThemeName {
|
||||||
return typeof value === 'string' && (PICO_THEME_NAMES as readonly string[]).includes(value);
|
return typeof value === 'string' && (PICO_THEME_NAMES as readonly string[]).includes(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ export function sanitizePicoThemeMode(value: unknown): PicoThemeMode | undefined
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPicoStylesheetAssetName(theme: PicoThemeName | undefined): string {
|
function getPicoStylesheetAssetName(theme: PicoThemeName | undefined): string {
|
||||||
if (!theme) {
|
if (!theme) {
|
||||||
return 'pico.min.css';
|
return 'pico.min.css';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -517,7 +517,3 @@ export function listPythonApiMethodNames(): string[] {
|
|||||||
export function getPythonApiMethodContract(methodName: string): PythonApiMethodContractV1 | undefined {
|
export function getPythonApiMethodContract(methodName: string): PythonApiMethodContractV1 | undefined {
|
||||||
return BDS_PYTHON_API_CONTRACT_V1.methods.find((entry) => entry.method === methodName);
|
return BDS_PYTHON_API_CONTRACT_V1.methods.find((entry) => entry.method === methodName);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPythonApiDataStructureContracts(): PythonApiDataStructureContractV1[] {
|
|
||||||
return BDS_PYTHON_API_CONTRACT_V1.dataStructures;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ function getNodeColor(depth: number): string {
|
|||||||
|
|
||||||
/* ── Constants ──────────────────────────────────────────────── */
|
/* ── Constants ──────────────────────────────────────────────── */
|
||||||
|
|
||||||
export const FONT_SIZE = 13;
|
const FONT_SIZE = 13;
|
||||||
export const CHAR_WIDTH = 7.8;
|
const CHAR_WIDTH = 7.8;
|
||||||
export const LINE_HEIGHT = 18;
|
export const LINE_HEIGHT = 18;
|
||||||
const NODE_PADDING_X = 14;
|
const NODE_PADDING_X = 14;
|
||||||
const NODE_PADDING_Y = 8;
|
const NODE_PADDING_Y = 8;
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
export { A2UIText } from './A2UIText';
|
|
||||||
export { A2UIButton } from './A2UIButton';
|
|
||||||
export { A2UICard } from './A2UICard';
|
|
||||||
export { A2UIChart } from './A2UIChart';
|
|
||||||
export { A2UITable } from './A2UITable';
|
|
||||||
export { A2UIForm } from './A2UIForm';
|
|
||||||
export { A2UITextField } from './A2UITextField';
|
|
||||||
export { A2UICheckBox } from './A2UICheckBox';
|
|
||||||
export { A2UIDateTimeInput } from './A2UIDateTimeInput';
|
|
||||||
export { A2UIChoicePicker } from './A2UIChoicePicker';
|
|
||||||
export { A2UIImage } from './A2UIImage';
|
|
||||||
export { A2UITabs } from './A2UITabs';
|
|
||||||
export { A2UIMetric } from './A2UIMetric';
|
|
||||||
export { A2UIList } from './A2UIList';
|
|
||||||
export { A2UIRow } from './A2UIRow';
|
|
||||||
export { A2UIColumn } from './A2UIColumn';
|
|
||||||
export { A2UIDivider } from './A2UIDivider';
|
|
||||||
@@ -302,5 +302,3 @@ export const AssistantSidebar: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AssistantSidebar;
|
|
||||||
|
|||||||
@@ -171,62 +171,3 @@ export function useMarkdownImages(content: string): LightboxImage[] {
|
|||||||
}, [content]);
|
}, [content]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Component to render images with lightbox support
|
|
||||||
interface ImageGalleryProps {
|
|
||||||
images: LightboxImage[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export const ImageGallery: React.FC<ImageGalleryProps> = ({ images }) => {
|
|
||||||
const [lightboxOpen, setLightboxOpen] = useState(false);
|
|
||||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
||||||
|
|
||||||
if (images.length === 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const openLightbox = (index: number) => {
|
|
||||||
setSelectedIndex(index);
|
|
||||||
setLightboxOpen(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (images.length === 1) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<div className="single-image" onClick={() => openLightbox(0)}>
|
|
||||||
<img src={images[0].src} alt={images[0].alt || ''} />
|
|
||||||
{images[0].caption && <p className="image-caption">{images[0].caption}</p>}
|
|
||||||
</div>
|
|
||||||
<Lightbox
|
|
||||||
images={images}
|
|
||||||
initialIndex={selectedIndex}
|
|
||||||
isOpen={lightboxOpen}
|
|
||||||
onClose={() => setLightboxOpen(false)}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<div className={`image-gallery gallery-${Math.min(images.length, 4)}`}>
|
|
||||||
{images.map((image, index) => (
|
|
||||||
<div
|
|
||||||
key={index}
|
|
||||||
className="gallery-item"
|
|
||||||
onClick={() => openLightbox(index)}
|
|
||||||
>
|
|
||||||
<img src={image.src} alt={image.alt || ''} />
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
<Lightbox
|
|
||||||
images={images}
|
|
||||||
initialIndex={selectedIndex}
|
|
||||||
isOpen={lightboxOpen}
|
|
||||||
onClose={() => setLightboxOpen(false)}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Lightbox;
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export { Lightbox, ImageGallery, useMarkdownImages } from './Lightbox';
|
export { Lightbox, useMarkdownImages } from './Lightbox';
|
||||||
|
|||||||
@@ -345,5 +345,3 @@ export const LinkedMediaPanel: React.FC<LinkedMediaPanelProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default LinkedMediaPanel;
|
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
export { LinkedMediaPanel } from './LinkedMediaPanel';
|
export { LinkedMediaPanel } from './LinkedMediaPanel';
|
||||||
export { default } from './LinkedMediaPanel';
|
|
||||||
|
|||||||
@@ -391,5 +391,3 @@ const MilkdownProviderInner: React.FC<MilkdownEditorProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MilkdownEditor;
|
|
||||||
|
|||||||
@@ -116,5 +116,3 @@ export const PostLinks: React.FC<PostLinksProps> = ({ postId, onPostClick, updat
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default PostLinks;
|
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
export { PostLinks } from './PostLinks';
|
export { PostLinks } from './PostLinks';
|
||||||
export { default } from './PostLinks';
|
|
||||||
|
|||||||
@@ -1,130 +0,0 @@
|
|||||||
.post-search-modal-backdrop {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
background: rgba(0, 0, 0, 0.6);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
z-index: 10000;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-search-modal {
|
|
||||||
background: var(--color-bg-secondary, #1e1e1e);
|
|
||||||
border: 1px solid var(--color-border, #3c3c3c);
|
|
||||||
border-radius: 8px;
|
|
||||||
width: 600px;
|
|
||||||
max-height: 500px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-search-header {
|
|
||||||
border-bottom: 1px solid var(--color-border, #3c3c3c);
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-search-input {
|
|
||||||
width: 100%;
|
|
||||||
padding: 16px 20px;
|
|
||||||
font-size: 16px;
|
|
||||||
background: transparent;
|
|
||||||
border: none;
|
|
||||||
color: var(--color-text, #ccc);
|
|
||||||
outline: none;
|
|
||||||
font-family: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-search-input::placeholder {
|
|
||||||
color: var(--color-text-muted, #888);
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-search-results {
|
|
||||||
flex: 1;
|
|
||||||
overflow-y: auto;
|
|
||||||
padding: 8px;
|
|
||||||
min-height: 200px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-search-loading,
|
|
||||||
.post-search-empty {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 40px 20px;
|
|
||||||
color: var(--color-text-muted, #888);
|
|
||||||
font-size: 14px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-search-result-item {
|
|
||||||
padding: 12px 16px;
|
|
||||||
border-radius: 4px;
|
|
||||||
cursor: pointer;
|
|
||||||
margin-bottom: 4px;
|
|
||||||
transition: background-color 0.15s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-search-result-item:hover,
|
|
||||||
.post-search-result-item.selected {
|
|
||||||
background: var(--color-bg-tertiary, #2a2a2a);
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-search-result-item.selected {
|
|
||||||
border-left: 3px solid var(--color-primary, #0e639c);
|
|
||||||
padding-left: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-search-result-title {
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--color-text, #fff);
|
|
||||||
margin-bottom: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-search-result-excerpt {
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--color-text-muted, #888);
|
|
||||||
line-height: 1.4;
|
|
||||||
margin-bottom: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-search-result-slug {
|
|
||||||
font-size: 11px;
|
|
||||||
color: var(--color-text-muted, #666);
|
|
||||||
font-family: 'Cascadia Code', 'Consolas', 'Courier New', monospace;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-search-footer {
|
|
||||||
border-top: 1px solid var(--color-border, #3c3c3c);
|
|
||||||
padding: 8px 16px;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-search-hint {
|
|
||||||
font-size: 11px;
|
|
||||||
color: var(--color-text-muted, #888);
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Scrollbar styling */
|
|
||||||
.post-search-results::-webkit-scrollbar {
|
|
||||||
width: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-search-results::-webkit-scrollbar-track {
|
|
||||||
background: var(--color-bg-secondary, #1e1e1e);
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-search-results::-webkit-scrollbar-thumb {
|
|
||||||
background: var(--color-border, #3c3c3c);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.post-search-results::-webkit-scrollbar-thumb:hover {
|
|
||||||
background: var(--color-text-muted, #555);
|
|
||||||
}
|
|
||||||
@@ -1,166 +0,0 @@
|
|||||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
||||||
import { useI18n } from '../../i18n';
|
|
||||||
import './PostSearchModal.css';
|
|
||||||
|
|
||||||
interface SearchResult {
|
|
||||||
id: string;
|
|
||||||
title: string;
|
|
||||||
slug: string;
|
|
||||||
excerpt?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PostSearchModalProps {
|
|
||||||
onSelect: (post: SearchResult) => void;
|
|
||||||
onClose: () => void;
|
|
||||||
initialQuery?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const PostSearchModal: React.FC<PostSearchModalProps> = ({
|
|
||||||
onSelect,
|
|
||||||
onClose,
|
|
||||||
initialQuery = ''
|
|
||||||
}) => {
|
|
||||||
const { t } = useI18n();
|
|
||||||
const [query, setQuery] = useState(initialQuery);
|
|
||||||
const [results, setResults] = useState<SearchResult[]>([]);
|
|
||||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
||||||
const [isSearching, setIsSearching] = useState(false);
|
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
|
||||||
|
|
||||||
// Focus search input on mount
|
|
||||||
useEffect(() => {
|
|
||||||
inputRef.current?.focus();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// Debounced search effect
|
|
||||||
useEffect(() => {
|
|
||||||
if (query.length < 2) {
|
|
||||||
setResults([]);
|
|
||||||
setSelectedIndex(0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const timeoutId = setTimeout(async () => {
|
|
||||||
setIsSearching(true);
|
|
||||||
try {
|
|
||||||
const searchResults = await window.electronAPI.posts.search(query);
|
|
||||||
setResults(searchResults || []);
|
|
||||||
setSelectedIndex(0);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Search failed:', error);
|
|
||||||
setResults([]);
|
|
||||||
} finally {
|
|
||||||
setIsSearching(false);
|
|
||||||
}
|
|
||||||
}, 300);
|
|
||||||
|
|
||||||
return () => clearTimeout(timeoutId);
|
|
||||||
}, [query]);
|
|
||||||
|
|
||||||
// Keyboard navigation handler
|
|
||||||
const handleKeyDown = useCallback((e: React.KeyboardEvent) => {
|
|
||||||
switch (e.key) {
|
|
||||||
case 'Escape':
|
|
||||||
e.preventDefault();
|
|
||||||
onClose();
|
|
||||||
break;
|
|
||||||
case 'ArrowDown':
|
|
||||||
e.preventDefault();
|
|
||||||
setSelectedIndex(prev => Math.min(prev + 1, results.length - 1));
|
|
||||||
break;
|
|
||||||
case 'ArrowUp':
|
|
||||||
e.preventDefault();
|
|
||||||
setSelectedIndex(prev => Math.max(prev - 1, 0));
|
|
||||||
break;
|
|
||||||
case 'Enter':
|
|
||||||
e.preventDefault();
|
|
||||||
if (results[selectedIndex]) {
|
|
||||||
onSelect(results[selectedIndex]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}, [results, selectedIndex, onClose, onSelect]);
|
|
||||||
|
|
||||||
// Backdrop click handler
|
|
||||||
const handleBackdropClick = useCallback((e: React.MouseEvent) => {
|
|
||||||
if (e.target === e.currentTarget) {
|
|
||||||
onClose();
|
|
||||||
}
|
|
||||||
}, [onClose]);
|
|
||||||
|
|
||||||
// Result click handler
|
|
||||||
const handleResultClick = useCallback((post: SearchResult) => {
|
|
||||||
onSelect(post);
|
|
||||||
}, [onSelect]);
|
|
||||||
|
|
||||||
// Scroll selected item into view
|
|
||||||
useEffect(() => {
|
|
||||||
const selectedElement = document.querySelector('.post-search-result-item.selected');
|
|
||||||
if (selectedElement) {
|
|
||||||
selectedElement.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
|
||||||
}
|
|
||||||
}, [selectedIndex]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="post-search-modal-backdrop" onClick={handleBackdropClick}>
|
|
||||||
<div className="post-search-modal" onKeyDown={handleKeyDown}>
|
|
||||||
<div className="post-search-header">
|
|
||||||
<input
|
|
||||||
ref={inputRef}
|
|
||||||
type="text"
|
|
||||||
className="post-search-input"
|
|
||||||
placeholder={t('postSearch.placeholder')}
|
|
||||||
value={query}
|
|
||||||
onChange={(e) => setQuery(e.target.value)}
|
|
||||||
autoComplete="off"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="post-search-results">
|
|
||||||
{isSearching && (
|
|
||||||
<div className="post-search-loading">
|
|
||||||
{t('postSearch.searching')}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!isSearching && query.length < 2 && (
|
|
||||||
<div className="post-search-empty">
|
|
||||||
{t('postSearch.typeMore')}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!isSearching && query.length >= 2 && results.length === 0 && (
|
|
||||||
<div className="post-search-empty">
|
|
||||||
{t('postSearch.noResults', { query })}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!isSearching && results.length > 0 && results.map((post, index) => (
|
|
||||||
<div
|
|
||||||
key={post.id}
|
|
||||||
className={`post-search-result-item ${index === selectedIndex ? 'selected' : ''}`}
|
|
||||||
onClick={() => handleResultClick(post)}
|
|
||||||
onMouseEnter={() => setSelectedIndex(index)}
|
|
||||||
>
|
|
||||||
<div className="post-search-result-title">{post.title}</div>
|
|
||||||
{post.excerpt && (
|
|
||||||
<div className="post-search-result-excerpt">
|
|
||||||
{post.excerpt.length > 120
|
|
||||||
? post.excerpt.substring(0, 120) + '...'
|
|
||||||
: post.excerpt}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div className="post-search-result-slug">/posts/{post.slug}</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="post-search-footer">
|
|
||||||
<span className="post-search-hint">
|
|
||||||
{t('postSearch.hint')}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { PostSearchModal } from './PostSearchModal';
|
|
||||||
@@ -387,5 +387,3 @@ export const ProjectSelector: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ProjectSelector;
|
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
export { ProjectSelector } from './ProjectSelector';
|
export { ProjectSelector } from './ProjectSelector';
|
||||||
export { default } from './ProjectSelector';
|
|
||||||
|
|||||||
@@ -119,5 +119,3 @@ export const ResizablePanel: React.FC<ResizablePanelProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ResizablePanel;
|
|
||||||
|
|||||||
@@ -2246,5 +2246,3 @@ export const SettingsView: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SettingsView;
|
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
export { SettingsView, scrollToSettingsSection } from './SettingsView';
|
export { SettingsView } from './SettingsView';
|
||||||
export type { SettingsCategory } from './SettingsView';
|
|
||||||
|
|||||||
@@ -136,5 +136,3 @@ export const StyleView: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default StyleView;
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
export { StyleView } from './StyleView';
|
|
||||||
@@ -839,5 +839,3 @@ export const TabBar: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default TabBar;
|
|
||||||
|
|||||||
@@ -221,5 +221,3 @@ export const TaskPopup: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default TaskPopup;
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
export { TaskPopup } from './TaskPopup';
|
|
||||||
@@ -2,11 +2,8 @@ import React from 'react';
|
|||||||
import { Toaster, toast } from 'react-hot-toast';
|
import { Toaster, toast } from 'react-hot-toast';
|
||||||
import './Toast.css';
|
import './Toast.css';
|
||||||
|
|
||||||
// Re-export toast for use throughout the app
|
|
||||||
export { toast };
|
|
||||||
|
|
||||||
// Toast types
|
// Toast types
|
||||||
export type ToastType = 'success' | 'error' | 'loading' | 'info';
|
type ToastType = 'success' | 'error' | 'loading' | 'info';
|
||||||
|
|
||||||
// Custom toast functions
|
// Custom toast functions
|
||||||
export const showToast = {
|
export const showToast = {
|
||||||
@@ -84,5 +81,3 @@ export const ToastContainer: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ToastContainer;
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export { ToastContainer, toast, showToast, type ToastType } from './Toast';
|
export { ToastContainer, showToast } from './Toast';
|
||||||
|
|||||||
@@ -505,6 +505,4 @@ export const WindowTitleBar: React.FC = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default WindowTitleBar;
|
|
||||||
@@ -4,26 +4,7 @@ export { Editor } from './Editor';
|
|||||||
export { StatusBar } from './StatusBar';
|
export { StatusBar } from './StatusBar';
|
||||||
export { Panel } from './Panel';
|
export { Panel } from './Panel';
|
||||||
export { TabBar } from './TabBar';
|
export { TabBar } from './TabBar';
|
||||||
export { ToastContainer, toast, showToast, type ToastType } from './Toast';
|
export { ToastContainer, showToast } from './Toast';
|
||||||
export { ProjectSelector } from './ProjectSelector';
|
|
||||||
export { MilkdownEditor } from './MilkdownEditor';
|
|
||||||
export { Lightbox, ImageGallery, useMarkdownImages } from './Lightbox';
|
|
||||||
export { TaskPopup } from './TaskPopup';
|
|
||||||
export { ResizablePanel } from './ResizablePanel';
|
export { ResizablePanel } from './ResizablePanel';
|
||||||
export { SettingsView } from './SettingsView';
|
|
||||||
export { StyleView } from './StyleView';
|
|
||||||
export { TagsView, scrollToTagsSection, type TagsCategory } from './TagsView';
|
|
||||||
export { TagInput } from './TagInput';
|
|
||||||
export { PostLinks } from './PostLinks';
|
|
||||||
export { LinkedMediaPanel } from './LinkedMediaPanel';
|
|
||||||
export { ErrorModal, type ErrorDetails } from './ErrorModal';
|
|
||||||
export { ConfirmDeleteModal, type ConfirmDeleteDetails, type DeleteReference } from './ConfirmDeleteModal';
|
|
||||||
export { AISuggestionsModal, type AISuggestions, type CurrentValues } from './AISuggestionsModal/AISuggestionsModal';
|
|
||||||
export { ChatPanel } from './ChatPanel';
|
|
||||||
export { ImportAnalysisView } from './ImportAnalysisView';
|
|
||||||
export { InsertModal } from './InsertModal';
|
|
||||||
export { WindowTitleBar } from './WindowTitleBar';
|
export { WindowTitleBar } from './WindowTitleBar';
|
||||||
export { DocumentationView } from './DocumentationView/DocumentationView';
|
|
||||||
export { SiteValidationView } from './SiteValidationView';
|
|
||||||
export { ScriptsView } from './ScriptsView/ScriptsView';
|
|
||||||
export { AssistantSidebar } from './AssistantSidebar';
|
export { AssistantSidebar } from './AssistantSidebar';
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export type UiLanguage = 'en' | 'de' | 'fr' | 'it' | 'es';
|
|||||||
|
|
||||||
export const UI_LANGUAGE_STORAGE_KEY = 'bds-ui-language';
|
export const UI_LANGUAGE_STORAGE_KEY = 'bds-ui-language';
|
||||||
|
|
||||||
export const SUPPORTED_UI_LANGUAGES: UiLanguage[] = ['en', 'de', 'fr', 'it', 'es'];
|
const SUPPORTED_UI_LANGUAGES: UiLanguage[] = ['en', 'de', 'fr', 'it', 'es'];
|
||||||
|
|
||||||
type TranslationTable = Record<string, string>;
|
type TranslationTable = Record<string, string>;
|
||||||
|
|
||||||
|
|||||||
@@ -74,5 +74,3 @@ const galleryMacro: MacroDefinition = {
|
|||||||
|
|
||||||
// Self-register
|
// Self-register
|
||||||
registerMacro(galleryMacro);
|
registerMacro(galleryMacro);
|
||||||
|
|
||||||
export default galleryMacro;
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ function getMonthName(month: number): string {
|
|||||||
return MONTH_NAMES[month - 1] || 'Unknown';
|
return MONTH_NAMES[month - 1] || 'Unknown';
|
||||||
}
|
}
|
||||||
|
|
||||||
const photoArchiveMacro: MacroDefinition = {
|
export const photoArchiveMacro: MacroDefinition = {
|
||||||
name: 'photo_archive',
|
name: 'photo_archive',
|
||||||
description: 'Creates a photo archive gallery organized by year and month',
|
description: 'Creates a photo archive gallery organized by year and month',
|
||||||
|
|
||||||
@@ -125,5 +125,3 @@ const photoArchiveMacro: MacroDefinition = {
|
|||||||
// Self-register
|
// Self-register
|
||||||
registerMacro(photoArchiveMacro);
|
registerMacro(photoArchiveMacro);
|
||||||
|
|
||||||
export default photoArchiveMacro;
|
|
||||||
export { getMonthName, MONTH_NAMES };
|
|
||||||
|
|||||||
@@ -72,5 +72,3 @@ const vimeoMacro: MacroDefinition = {
|
|||||||
|
|
||||||
// Self-register
|
// Self-register
|
||||||
registerMacro(vimeoMacro);
|
registerMacro(vimeoMacro);
|
||||||
|
|
||||||
export default vimeoMacro;
|
|
||||||
|
|||||||
@@ -85,5 +85,3 @@ const youtubeMacro: MacroDefinition = {
|
|||||||
|
|
||||||
// Self-register
|
// Self-register
|
||||||
registerMacro(youtubeMacro);
|
registerMacro(youtubeMacro);
|
||||||
|
|
||||||
export default youtubeMacro;
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
/**
|
/**
|
||||||
* Macros Module
|
* Macros Module
|
||||||
*
|
*
|
||||||
* Provides a simple extension system for rendering custom content blocks
|
* Provides a simple extension system for rendering custom content blocks
|
||||||
* in markdown using [[macro param="value"]] syntax.
|
* in markdown using [[macro param="value"]] syntax.
|
||||||
*
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
* 1. Import this module to register all macros
|
* 1. Import this module to register all macros
|
||||||
* 2. Use the registry functions to render macros
|
* 2. Use the registry functions to render macros
|
||||||
*
|
*
|
||||||
* Adding new macros:
|
* Adding new macros:
|
||||||
* 1. Create a file in ./definitions/ (e.g., myMacro.ts)
|
* 1. Create a file in ./definitions/ (e.g., myMacro.ts)
|
||||||
* 2. Implement MacroDefinition interface
|
* 2. Implement MacroDefinition interface
|
||||||
@@ -18,31 +18,8 @@
|
|||||||
// Import all macro definitions so they register
|
// Import all macro definitions so they register
|
||||||
import './definitions';
|
import './definitions';
|
||||||
|
|
||||||
// Re-export types
|
// Re-export registry functions used by app
|
||||||
export type {
|
|
||||||
MacroDefinition,
|
|
||||||
MacroParams,
|
|
||||||
MacroRenderContext,
|
|
||||||
ParsedMacro,
|
|
||||||
PythonMacroInfo,
|
|
||||||
PythonMacroResolver,
|
|
||||||
PythonMacroRendererFn,
|
|
||||||
} from './types';
|
|
||||||
|
|
||||||
// Re-export registry functions
|
|
||||||
export {
|
export {
|
||||||
registerMacro,
|
|
||||||
getMacro,
|
|
||||||
hasMacro,
|
|
||||||
getMacroNames,
|
|
||||||
getAllMacros,
|
|
||||||
clearMacros,
|
|
||||||
parseParams,
|
|
||||||
parseMacros,
|
|
||||||
renderMacro,
|
|
||||||
renderAllMacros,
|
|
||||||
getEditorPreview,
|
|
||||||
setPythonMacroResolver,
|
|
||||||
refreshPythonMacroSlugs,
|
refreshPythonMacroSlugs,
|
||||||
} from './registry';
|
} from './registry';
|
||||||
|
|
||||||
|
|||||||
@@ -1,164 +0,0 @@
|
|||||||
import { z } from 'zod';
|
|
||||||
|
|
||||||
const textElementSchema = z.object({
|
|
||||||
type: z.literal('text'),
|
|
||||||
text: z.string().min(1),
|
|
||||||
});
|
|
||||||
|
|
||||||
const metricElementSchema = z.object({
|
|
||||||
type: z.literal('metric'),
|
|
||||||
label: z.string().min(1),
|
|
||||||
value: z.string().min(1),
|
|
||||||
});
|
|
||||||
|
|
||||||
const listElementSchema = z.object({
|
|
||||||
type: z.literal('list'),
|
|
||||||
title: z.string().optional(),
|
|
||||||
items: z.array(z.string().min(1)).min(1),
|
|
||||||
});
|
|
||||||
|
|
||||||
const tableElementSchema = z.object({
|
|
||||||
type: z.literal('table'),
|
|
||||||
columns: z.array(z.string().min(1)).min(1),
|
|
||||||
rows: z.array(z.array(z.string())).min(1),
|
|
||||||
});
|
|
||||||
|
|
||||||
const actionElementSchema = z.object({
|
|
||||||
type: z.literal('action'),
|
|
||||||
label: z.string().min(1),
|
|
||||||
action: z.string().min(1),
|
|
||||||
payload: z.record(z.string(), z.unknown()).optional(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const segmentSchema = z.object({
|
|
||||||
label: z.string().min(1),
|
|
||||||
value: z.number(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const chartElementSchema = z.object({
|
|
||||||
type: z.literal('chart'),
|
|
||||||
chartType: z.enum(['bar', 'stacked-bar', 'line', 'area', 'pie', 'donut', 'heatmap']),
|
|
||||||
title: z.string().min(1).optional(),
|
|
||||||
series: z.array(
|
|
||||||
z.object({
|
|
||||||
label: z.string().min(1),
|
|
||||||
value: z.number(),
|
|
||||||
segments: z.array(segmentSchema).optional(),
|
|
||||||
}),
|
|
||||||
).min(1),
|
|
||||||
});
|
|
||||||
|
|
||||||
const inputTypeSchema = z.enum(['text', 'textarea', 'select', 'checkbox', 'date', 'number']);
|
|
||||||
|
|
||||||
const inputOptionSchema = z.object({
|
|
||||||
label: z.string().min(1),
|
|
||||||
value: z.string(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const inputElementSchema = z.object({
|
|
||||||
type: z.literal('input'),
|
|
||||||
key: z.string().min(1),
|
|
||||||
label: z.string().min(1),
|
|
||||||
inputType: inputTypeSchema,
|
|
||||||
placeholder: z.string().optional(),
|
|
||||||
defaultValue: z.union([z.string(), z.number(), z.boolean()]).optional(),
|
|
||||||
options: z.array(inputOptionSchema).optional(),
|
|
||||||
action: z.string().min(1).optional(),
|
|
||||||
submitLabel: z.string().min(1).optional(),
|
|
||||||
payload: z.record(z.string(), z.unknown()).optional(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const datePickerElementSchema = z.object({
|
|
||||||
type: z.literal('datePicker'),
|
|
||||||
key: z.string().min(1),
|
|
||||||
label: z.string().min(1),
|
|
||||||
defaultValue: z.string().optional(),
|
|
||||||
min: z.string().optional(),
|
|
||||||
max: z.string().optional(),
|
|
||||||
action: z.string().min(1).optional(),
|
|
||||||
submitLabel: z.string().min(1).optional(),
|
|
||||||
payload: z.record(z.string(), z.unknown()).optional(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const formFieldSchema = z.object({
|
|
||||||
key: z.string().min(1),
|
|
||||||
label: z.string().min(1),
|
|
||||||
inputType: inputTypeSchema,
|
|
||||||
placeholder: z.string().optional(),
|
|
||||||
defaultValue: z.union([z.string(), z.number(), z.boolean()]).optional(),
|
|
||||||
options: z.array(inputOptionSchema).optional(),
|
|
||||||
required: z.boolean().optional(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const formElementSchema = z.object({
|
|
||||||
type: z.literal('form'),
|
|
||||||
formId: z.string().min(1),
|
|
||||||
title: z.string().optional(),
|
|
||||||
submitLabel: z.string().min(1),
|
|
||||||
action: z.string().min(1),
|
|
||||||
payload: z.record(z.string(), z.unknown()).optional(),
|
|
||||||
fields: z.array(formFieldSchema).min(1),
|
|
||||||
});
|
|
||||||
|
|
||||||
const cardActionSchema = z.object({
|
|
||||||
label: z.string().min(1),
|
|
||||||
action: z.string().min(1),
|
|
||||||
payload: z.record(z.string(), z.unknown()).optional(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const cardElementSchema = z.object({
|
|
||||||
type: z.literal('card'),
|
|
||||||
title: z.string().min(1),
|
|
||||||
body: z.string().min(1),
|
|
||||||
subtitle: z.string().optional(),
|
|
||||||
actions: z.array(cardActionSchema).optional(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const imageElementSchema = z.object({
|
|
||||||
type: z.literal('image'),
|
|
||||||
src: z.string().min(1),
|
|
||||||
alt: z.string().optional(),
|
|
||||||
caption: z.string().optional(),
|
|
||||||
action: z.string().min(1).optional(),
|
|
||||||
payload: z.record(z.string(), z.unknown()).optional(),
|
|
||||||
});
|
|
||||||
|
|
||||||
let assistantPanelElementSchemaRef: z.ZodTypeAny;
|
|
||||||
|
|
||||||
const tabsElementSchema: z.ZodTypeAny = z.lazy(() => z.object({
|
|
||||||
type: z.literal('tabs'),
|
|
||||||
widgetId: z.string().min(1).optional(),
|
|
||||||
defaultTabId: z.string().min(1).optional(),
|
|
||||||
tabs: z.array(
|
|
||||||
z.object({
|
|
||||||
id: z.string().min(1),
|
|
||||||
label: z.string().min(1),
|
|
||||||
elements: z.array(assistantPanelElementSchemaRef).min(1),
|
|
||||||
}),
|
|
||||||
).min(1),
|
|
||||||
}));
|
|
||||||
|
|
||||||
assistantPanelElementSchemaRef = z.union([
|
|
||||||
textElementSchema,
|
|
||||||
metricElementSchema,
|
|
||||||
listElementSchema,
|
|
||||||
tableElementSchema,
|
|
||||||
actionElementSchema,
|
|
||||||
chartElementSchema,
|
|
||||||
inputElementSchema,
|
|
||||||
formElementSchema,
|
|
||||||
datePickerElementSchema,
|
|
||||||
cardElementSchema,
|
|
||||||
imageElementSchema,
|
|
||||||
tabsElementSchema,
|
|
||||||
]);
|
|
||||||
|
|
||||||
export const assistantPanelElementSchema = assistantPanelElementSchemaRef;
|
|
||||||
|
|
||||||
export const assistantPanelSpecSchema = z.object({
|
|
||||||
specVersion: z.literal('1'),
|
|
||||||
elements: z.array(assistantPanelElementSchema).min(1),
|
|
||||||
});
|
|
||||||
|
|
||||||
export type AssistantPanelElement = z.infer<typeof assistantPanelElementSchema>;
|
|
||||||
export type AssistantPanelSpec = z.infer<typeof assistantPanelSpecSchema>;
|
|
||||||
@@ -133,11 +133,11 @@ export function openTemplateTab(
|
|||||||
openTab(getTemplateTabSpec(templateId, intent));
|
openTab(getTemplateTabSpec(templateId, intent));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getGitDiffFileTabId(filePath: string): string {
|
function getGitDiffFileTabId(filePath: string): string {
|
||||||
return `git-diff:${filePath}`;
|
return `git-diff:${filePath}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getGitDiffCommitTabId(commitHash: string): string {
|
function getGitDiffCommitTabId(commitHash: string): string {
|
||||||
return `git-diff:commit:${commitHash}`;
|
return `git-diff:commit:${commitHash}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,5 +147,3 @@ export const imageResolverPlugin = $prose(() => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
export default imageResolverPlugin;
|
|
||||||
|
|||||||
@@ -84,12 +84,12 @@ const remarkMacroParser: Plugin<[], Root> = () => {
|
|||||||
/**
|
/**
|
||||||
* Remark plugin registration for Milkdown
|
* Remark plugin registration for Milkdown
|
||||||
*/
|
*/
|
||||||
export const remarkMacro = $remark('remarkMacro', () => remarkMacroParser);
|
const remarkMacro = $remark('remarkMacro', () => remarkMacroParser);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ProseMirror node schema for macros
|
* ProseMirror node schema for macros
|
||||||
*/
|
*/
|
||||||
export const macroNode = $node('macro', () => ({
|
const macroNode = $node('macro', () => ({
|
||||||
group: 'inline',
|
group: 'inline',
|
||||||
inline: true,
|
inline: true,
|
||||||
atom: true, // Treated as a single unit, not editable as text
|
atom: true, // Treated as a single unit, not editable as text
|
||||||
@@ -154,7 +154,7 @@ export const macroNode = $node('macro', () => ({
|
|||||||
* Input rule to convert typed [[macro...]] to macro node
|
* Input rule to convert typed [[macro...]] to macro node
|
||||||
* Triggers when user types ]] to close a macro
|
* Triggers when user types ]] to close a macro
|
||||||
*/
|
*/
|
||||||
export const macroInputRule = $inputRule(() => {
|
const macroInputRule = $inputRule(() => {
|
||||||
// Match [[macroName param="value"]] when user types the closing ]]
|
// Match [[macroName param="value"]] when user types the closing ]]
|
||||||
return new InputRule(
|
return new InputRule(
|
||||||
/\[\[(\w+)(?:\s+([^\]]+))?\]\]$/,
|
/\[\[(\w+)(?:\s+([^\]]+))?\]\]$/,
|
||||||
@@ -185,5 +185,3 @@ export const macroPlugin = [
|
|||||||
macroNode,
|
macroNode,
|
||||||
macroInputRule,
|
macroInputRule,
|
||||||
].flat();
|
].flat();
|
||||||
|
|
||||||
export default macroPlugin;
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ export {
|
|||||||
BDS_PYTHON_API_CONTRACT_V1,
|
BDS_PYTHON_API_CONTRACT_V1,
|
||||||
listPythonApiMethodNames,
|
listPythonApiMethodNames,
|
||||||
getPythonApiMethodContract,
|
getPythonApiMethodContract,
|
||||||
getPythonApiDataStructureContracts,
|
|
||||||
} from '../../main/shared/pythonApiContractV1';
|
} from '../../main/shared/pythonApiContractV1';
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
export { AutoSaveManager, type AutoSaveConfig } from './autoSave';
|
export { AutoSaveManager } from './autoSave';
|
||||||
export { getContrastColor } from './color';
|
export { getContrastColor } from './color';
|
||||||
export { unescapeMacroSyntax } from './markdownEscape';
|
export { groupPostsByStatus } from './postGrouping';
|
||||||
export { groupPostsByStatus, type GroupedPosts, type PostStatus } from './postGrouping';
|
|
||||||
export { loadTabsForProject, saveTabsForProject } from './tabPersistence';
|
export { loadTabsForProject, saveTabsForProject } from './tabPersistence';
|
||||||
export { buildTagColorMap, loadTagColorMap } from './tagColors';
|
export { loadTagColorMap } from './tagColors';
|
||||||
export { BDS_EVENT_SCRIPTS_CHANGED, BDS_EVENT_TEMPLATES_CHANGED, addWindowEventListener, dispatchWindowEvent, type BdsWindowEventName } from './windowEvents';
|
export { BDS_EVENT_SCRIPTS_CHANGED, BDS_EVENT_TEMPLATES_CHANGED, addWindowEventListener, dispatchWindowEvent, type BdsWindowEventName } from './windowEvents';
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ function createMockPipeline(): EmbeddingPipeline {
|
|||||||
function makeEngine(tmpDir: string): EmbeddingEngine {
|
function makeEngine(tmpDir: string): EmbeddingEngine {
|
||||||
return new EmbeddingEngine({
|
return new EmbeddingEngine({
|
||||||
getIndexPath: (projectId: string) => path.join(tmpDir, `${projectId}.usearch`),
|
getIndexPath: (projectId: string) => path.join(tmpDir, `${projectId}.usearch`),
|
||||||
|
modelCacheDir: path.join(tmpDir, 'model-cache'),
|
||||||
createPipeline: async () => createMockPipeline(),
|
createPipeline: async () => createMockPipeline(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -339,8 +339,13 @@ vi.mock('fs/promises', () => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
let mockOfflineMode = false;
|
let mockOfflineMode = false;
|
||||||
|
const mockAutoTranslatePost = vi.fn().mockResolvedValue({ success: true });
|
||||||
|
const mockAutoTranslateMediaMetadata = vi.fn().mockResolvedValue({ success: true });
|
||||||
|
|
||||||
vi.mock('../../src/main/ipc/chatHandlers', () => ({
|
vi.mock('../../src/main/ipc/chatHandlers', () => ({
|
||||||
isOfflineModeActive: vi.fn(() => mockOfflineMode),
|
isOfflineModeActive: vi.fn(() => mockOfflineMode),
|
||||||
|
autoTranslatePost: (...args: any[]) => mockAutoTranslatePost(...args),
|
||||||
|
autoTranslateMediaMetadata: (...args: any[]) => mockAutoTranslateMediaMetadata(...args),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Helper to invoke a registered handler
|
// Helper to invoke a registered handler
|
||||||
@@ -3022,6 +3027,45 @@ describe('IPC Handlers', () => {
|
|||||||
expect(result).toEqual({ taskStarted: true });
|
expect(result).toEqual({ taskStarted: true });
|
||||||
expect(onProgress).toHaveBeenCalledWith(100, 'All translations are up to date');
|
expect(onProgress).toHaveBeenCalledWith(100, 'All translations are up to date');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should use media canonical language, not post language, to determine target languages', async () => {
|
||||||
|
// Scenario: blog has en + de. An English media item is linked to a German post.
|
||||||
|
// The media is missing a German translation, NOT an English one.
|
||||||
|
const mockProject = createMockProject({ id: 'test-project', dataPath: '/mock/data' });
|
||||||
|
mockProjectEngine.getActiveProject.mockResolvedValue(mockProject);
|
||||||
|
mockProjectEngine.getDataDir.mockReturnValue('/mock/data/dir');
|
||||||
|
mockMetaEngine.getProjectMetadata.mockResolvedValue({
|
||||||
|
mainLanguage: 'de',
|
||||||
|
blogLanguages: ['de', 'en'],
|
||||||
|
});
|
||||||
|
|
||||||
|
const post1 = createMockPost({ id: 'post-1', title: 'German Post', language: 'de', status: 'published' });
|
||||||
|
// No posts missing post translations
|
||||||
|
mockPostEngine.getPostsFiltered.mockImplementation(async (filter: any) => {
|
||||||
|
if (filter.missingTranslationLanguage) return [];
|
||||||
|
return [post1]; // all published
|
||||||
|
});
|
||||||
|
|
||||||
|
// Post links to an English-language media item
|
||||||
|
mockPostMediaEngine.getLinkedMediaForPost.mockResolvedValue([{ mediaId: 'media-en-1', sortOrder: 0 }]);
|
||||||
|
mockMediaEngine.getMedia.mockResolvedValue(createMockMedia({ id: 'media-en-1', language: 'en' }));
|
||||||
|
mockMediaEngine.getMediaTranslations.mockResolvedValue([]); // no translations yet
|
||||||
|
|
||||||
|
const onProgress = vi.fn();
|
||||||
|
let taskDone: Promise<void> | undefined;
|
||||||
|
mockTaskManager.runTask.mockImplementation((task: any) => {
|
||||||
|
taskDone = task.execute(onProgress);
|
||||||
|
return taskDone;
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await invokeHandler('blog:fillMissingTranslations');
|
||||||
|
await taskDone;
|
||||||
|
|
||||||
|
expect(result).toEqual({ taskStarted: true });
|
||||||
|
// Should translate to German (the missing language), NOT to English (the media's own language)
|
||||||
|
expect(mockAutoTranslateMediaMetadata).toHaveBeenCalledTimes(1);
|
||||||
|
expect(mockAutoTranslateMediaMetadata).toHaveBeenCalledWith('media-en-1', 'de');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('blog:applyValidation', () => {
|
describe('blog:applyValidation', () => {
|
||||||
|
|||||||
@@ -11,15 +11,6 @@ function read(relativePath: string): string {
|
|||||||
describe('Phase 1 i18n hardcoded literals', () => {
|
describe('Phase 1 i18n hardcoded literals', () => {
|
||||||
it('does not keep known hardcoded user-facing literals in renderer components', () => {
|
it('does not keep known hardcoded user-facing literals in renderer components', () => {
|
||||||
const checks: Array<{ file: string; literals: string[] }> = [
|
const checks: Array<{ file: string; literals: string[] }> = [
|
||||||
{
|
|
||||||
file: 'src/renderer/components/PostSearchModal/PostSearchModal.tsx',
|
|
||||||
literals: [
|
|
||||||
'Search posts by title or content...',
|
|
||||||
'Searching...',
|
|
||||||
'Type at least 2 characters to search',
|
|
||||||
'Use ↑↓ to navigate, Enter to select, Esc to close',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
file: 'src/renderer/components/StatusBar/StatusBar.tsx',
|
file: 'src/renderer/components/StatusBar/StatusBar.tsx',
|
||||||
literals: ['<span>{totalPosts} posts</span>', '<span>{media.length} media</span>', 'Theme: {activeTheme}', 'aria-label="UI language"'],
|
literals: ['<span>{totalPosts} posts</span>', '<span>{media.length} media</span>', 'Theme: {activeTheme}', 'aria-label="UI language"'],
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
import { describe, it, expect, beforeEach } from 'vitest';
|
import { describe, it, expect, beforeEach } from 'vitest';
|
||||||
import { clearMacros, getMacro, registerMacro } from '../../../src/renderer/macros/registry';
|
import { clearMacros, getMacro, registerMacro } from '../../../src/renderer/macros/registry';
|
||||||
import type { MacroParams, MacroRenderContext } from '../../../src/renderer/macros/types';
|
import type { MacroParams, MacroRenderContext } from '../../../src/renderer/macros/types';
|
||||||
import photoArchiveMacro from '../../../src/renderer/macros/definitions/photo_archive';
|
import { photoArchiveMacro } from '../../../src/renderer/macros/definitions/photo_archive';
|
||||||
|
|
||||||
describe('photo_archive macro', () => {
|
describe('photo_archive macro', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export default defineConfig({
|
|||||||
return 'react-vendor';
|
return 'react-vendor';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id.includes('node_modules/zustand') || id.includes('node_modules/date-fns')) {
|
if (id.includes('node_modules/zustand')) {
|
||||||
return 'app-vendor';
|
return 'app-vendor';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user