yaxa-svelte 2.7.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -21
- package/dist/auth/index.d.ts +7 -1
- package/dist/auth/index.js +3 -0
- package/dist/components/ai/ai.test.js +68 -1
- package/dist/components/ai/index.d.ts +2 -0
- package/dist/components/ai/index.js +1 -0
- package/dist/components/ai/useAiChat.svelte.d.ts +68 -0
- package/dist/components/ai/useAiChat.svelte.js +258 -0
- package/dist/components/blocks/FAQ.svelte +11 -0
- package/dist/components/blocks/FAQ.svelte.d.ts +1 -0
- package/dist/components/blocks/FAQ.test.js +20 -0
- package/dist/components/saas/AuthCard.svelte +16 -12
- package/dist/components/saas/AuthCard.svelte.d.ts +3 -3
- package/dist/components/saas/ResetPasswordCard.svelte +13 -0
- package/dist/components/saas/ResetPasswordCard.svelte.d.ts +5 -0
- package/dist/components/saas/SignInCard.svelte +13 -0
- package/dist/components/saas/SignInCard.svelte.d.ts +5 -0
- package/dist/components/saas/SignUpCard.svelte +13 -0
- package/dist/components/saas/SignUpCard.svelte.d.ts +5 -0
- package/dist/components/saas/auth-cards.test.d.ts +1 -0
- package/dist/components/saas/auth-cards.test.js +42 -0
- package/dist/components/seo/Seo.svelte +16 -9
- package/dist/index.d.ts +21 -2
- package/dist/index.js +12 -1
- package/dist/server/ai/index.d.ts +2 -0
- package/dist/server/ai/index.js +1 -0
- package/dist/server/ai/stream.d.ts +24 -0
- package/dist/server/ai/stream.js +178 -0
- package/dist/server/ai/stream.test.d.ts +1 -0
- package/dist/server/ai/stream.test.js +83 -0
- package/dist/server/ai/types.d.ts +43 -0
- package/dist/server/ai/types.js +1 -0
- package/dist/server/index.d.ts +6 -0
- package/dist/server/index.js +4 -0
- package/dist/site/context.svelte.d.ts +3 -0
- package/dist/site/context.svelte.js +7 -0
- package/dist/site/hook.d.ts +5 -1
- package/dist/site/hook.js +11 -1
- package/dist/site/index.d.ts +26 -0
- package/dist/site/index.js +25 -0
- package/dist/site/llms.d.ts +27 -0
- package/dist/site/llms.js +58 -0
- package/dist/site/schema.d.ts +45 -0
- package/dist/site/schema.js +43 -0
- package/dist/site/seo-helpers.d.ts +1 -0
- package/dist/site/site-export.test.d.ts +1 -0
- package/dist/site/site-export.test.js +193 -0
- package/dist/site/skill.d.ts +26 -0
- package/dist/site/skill.js +69 -0
- package/dist/site/useSeo.svelte.d.ts +23 -0
- package/dist/site/useSeo.svelte.js +40 -0
- package/dist/site/useSeo.test.d.ts +1 -0
- package/dist/site/useSeo.test.js +35 -0
- package/package.json +5 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { createAiStreamHandler } from './stream';
|
|
3
|
+
describe('createAiStreamHandler (Server-Side AI Stream Bridge)', () => {
|
|
4
|
+
it('handles mock AI streaming with thought deltas and text chunks', async () => {
|
|
5
|
+
const handler = createAiStreamHandler({
|
|
6
|
+
mock: { delayMs: 1 }
|
|
7
|
+
});
|
|
8
|
+
const req = new Request('http://localhost/api/ai/chat', {
|
|
9
|
+
method: 'POST',
|
|
10
|
+
headers: { 'Content-Type': 'application/json' },
|
|
11
|
+
body: JSON.stringify({
|
|
12
|
+
messages: [{ id: '1', role: 'user', content: 'What is Yaxa?' }]
|
|
13
|
+
})
|
|
14
|
+
});
|
|
15
|
+
const res = (await handler({ request: req, locals: {} }));
|
|
16
|
+
expect(res.headers.get('Content-Type')).toContain('text/event-stream');
|
|
17
|
+
expect(res.headers.get('Cache-Control')).toContain('no-cache');
|
|
18
|
+
const bodyText = await res.text();
|
|
19
|
+
expect(bodyText).toContain('data:');
|
|
20
|
+
expect(bodyText).toContain('"type":"thought"');
|
|
21
|
+
expect(bodyText).toContain('"type":"text"');
|
|
22
|
+
expect(bodyText).toContain('"type":"done"');
|
|
23
|
+
expect(bodyText).toContain('createAiStreamHandler');
|
|
24
|
+
});
|
|
25
|
+
it('executes custom async stream handlers with provider chunks', async () => {
|
|
26
|
+
const handler = createAiStreamHandler({
|
|
27
|
+
handler: async function* ({ messages }) {
|
|
28
|
+
yield {
|
|
29
|
+
type: 'thought',
|
|
30
|
+
thought: { running: true, text: 'Custom provider thinking...' }
|
|
31
|
+
};
|
|
32
|
+
yield {
|
|
33
|
+
type: 'tool_call',
|
|
34
|
+
tool: { name: 'calculator', status: 'success', result: { answer: 42 } }
|
|
35
|
+
};
|
|
36
|
+
yield {
|
|
37
|
+
type: 'text',
|
|
38
|
+
delta: `Hello from custom LLM: ${messages[0].content}`
|
|
39
|
+
};
|
|
40
|
+
yield { type: 'done' };
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const req = new Request('http://localhost/api/ai/chat', {
|
|
44
|
+
method: 'POST',
|
|
45
|
+
headers: { 'Content-Type': 'application/json' },
|
|
46
|
+
body: JSON.stringify({
|
|
47
|
+
messages: [{ id: '1', role: 'user', content: 'Calculate answer' }]
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
const res = (await handler({ request: req, locals: {} }));
|
|
51
|
+
const bodyText = await res.text();
|
|
52
|
+
expect(bodyText).toContain('"name":"calculator"');
|
|
53
|
+
expect(bodyText).toContain('"answer":42');
|
|
54
|
+
expect(bodyText).toContain('Hello from custom LLM: Calculate answer');
|
|
55
|
+
});
|
|
56
|
+
it('enforces guards before executing stream pipeline', async () => {
|
|
57
|
+
const guard = vi.fn().mockResolvedValue(false);
|
|
58
|
+
const handler = createAiStreamHandler({
|
|
59
|
+
guards: [guard]
|
|
60
|
+
});
|
|
61
|
+
const req = new Request('http://localhost/api/ai/chat', {
|
|
62
|
+
method: 'POST',
|
|
63
|
+
headers: { 'Content-Type': 'application/json' },
|
|
64
|
+
body: JSON.stringify({ messages: [] })
|
|
65
|
+
});
|
|
66
|
+
const res = (await handler({ request: req, locals: {} }));
|
|
67
|
+
expect(res.status).toBe(403);
|
|
68
|
+
const json = await res.json();
|
|
69
|
+
expect(json.title).toBe('Forbidden');
|
|
70
|
+
});
|
|
71
|
+
it('returns RFC 7807 problem details on invalid request body', async () => {
|
|
72
|
+
const handler = createAiStreamHandler();
|
|
73
|
+
const req = new Request('http://localhost/api/ai/chat', {
|
|
74
|
+
method: 'POST',
|
|
75
|
+
headers: { 'Content-Type': 'application/json' },
|
|
76
|
+
body: 'invalid-json'
|
|
77
|
+
});
|
|
78
|
+
const res = (await handler({ request: req, locals: {} }));
|
|
79
|
+
expect(res.status).toBe(400);
|
|
80
|
+
const json = await res.json();
|
|
81
|
+
expect(json.title).toBe('Bad Request');
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { RequestEvent } from '@sveltejs/kit';
|
|
2
|
+
import type { Guard } from '../endpoint/types';
|
|
3
|
+
import type { AiMessage, AiMessageThought, AiMessageTool } from '../../components/ai/AiChat.svelte';
|
|
4
|
+
export type { AiMessage, AiMessageThought, AiMessageTool };
|
|
5
|
+
export interface AiStreamChunk {
|
|
6
|
+
type: 'text' | 'thought' | 'tool_call' | 'error' | 'done';
|
|
7
|
+
delta?: string;
|
|
8
|
+
thought?: AiMessageThought;
|
|
9
|
+
tool?: AiMessageTool;
|
|
10
|
+
error?: string;
|
|
11
|
+
meta?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export interface AiStreamContext {
|
|
14
|
+
event: RequestEvent;
|
|
15
|
+
messages: AiMessage[];
|
|
16
|
+
user?: unknown;
|
|
17
|
+
send: (chunk: AiStreamChunk) => void;
|
|
18
|
+
signal: AbortSignal;
|
|
19
|
+
}
|
|
20
|
+
export type AiStreamHandlerFn = (ctx: AiStreamContext) => Promise<void> | AsyncIterable<AiStreamChunk> | void;
|
|
21
|
+
export interface CreateAiStreamHandlerOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Custom handler logic to generate stream chunks.
|
|
24
|
+
* Can invoke any LLM provider (Gemini, Anthropic, OpenAI, local Ollama).
|
|
25
|
+
*/
|
|
26
|
+
handler?: AiStreamHandlerFn;
|
|
27
|
+
/**
|
|
28
|
+
* Guards to secure the endpoint (e.g. `requireAuth()`, `requireRole('member')`, `rateLimit()`).
|
|
29
|
+
*/
|
|
30
|
+
guards?: Guard[];
|
|
31
|
+
/**
|
|
32
|
+
* Realistic mock streamer for development, testing, and zero-config demos.
|
|
33
|
+
* Default: true if handler is omitted, false otherwise.
|
|
34
|
+
*/
|
|
35
|
+
mock?: boolean | {
|
|
36
|
+
delayMs?: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Optional lifecycle hooks.
|
|
40
|
+
*/
|
|
41
|
+
onStart?: (event: RequestEvent) => Promise<void> | void;
|
|
42
|
+
onError?: (error: unknown, event: RequestEvent) => Promise<void> | void;
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/server/index.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ export { createSitemapXslHandler, generateSitemapXsl } from '../site/sitemap-xsl
|
|
|
8
8
|
export { createOgImageHandler, generateOgSvg } from '../site/og';
|
|
9
9
|
export type { OgImageOptions } from '../site/og';
|
|
10
10
|
export { createManifestHandler } from '../site/manifest';
|
|
11
|
+
export { createLlmsTxtHandler, generateLlmsTxt } from '../site/llms';
|
|
12
|
+
export type { LlmsTxtOptions, LlmsSection, LlmsLink } from '../site/llms';
|
|
13
|
+
export { createSkillHandler, generateSkillMd } from '../site/skill';
|
|
14
|
+
export type { SkillOptions, SkillAction } from '../site/skill';
|
|
11
15
|
export { getDb, schemaPg, schemaSqlite } from './db/index';
|
|
12
16
|
export type { DbConfig, DbDriver, SaasUser, OrgRole, SaasOrganization, SaasMember, SaasInvitation, SaasSubscription, SubscriptionStatus, PricingTier, PricingFeature } from './db/index';
|
|
13
17
|
export { parseDataTableQuery, createDataTableResponse } from './db/pagination';
|
|
@@ -30,3 +34,5 @@ export { enqueueJob, defineWorker, createJobRunner, eventBus, EventBus, parseJob
|
|
|
30
34
|
export type { JobRecord, JobDelay, EnqueueJobOptions, WorkerContext, WorkerHandler, WorkerDefinition, JobRunnerOptions, JobBatchResult, JobRunner, EventHandler, EventSubscription, IEventBus } from './jobs/index';
|
|
31
35
|
export { yaxaSSE, formatSSEFrame, broadcast, createBroadcaster, globalBroadcaster, MemoryBroadcaster } from './realtime/index';
|
|
32
36
|
export type { SSEMessage, SSEClientContext, YaxaSSEOptions, BroadcastMessage, BroadcastSubscriber, Broadcaster } from './realtime/index';
|
|
37
|
+
export { createAiStreamHandler } from './ai/index';
|
|
38
|
+
export type { AiStreamChunk, AiStreamContext, AiStreamHandlerFn, CreateAiStreamHandlerOptions } from './ai/index';
|
package/dist/server/index.js
CHANGED
|
@@ -6,6 +6,8 @@ export { createSitemapHandler } from '../site/sitemap';
|
|
|
6
6
|
export { createSitemapXslHandler, generateSitemapXsl } from '../site/sitemap-xsl';
|
|
7
7
|
export { createOgImageHandler, generateOgSvg } from '../site/og';
|
|
8
8
|
export { createManifestHandler } from '../site/manifest';
|
|
9
|
+
export { createLlmsTxtHandler, generateLlmsTxt } from '../site/llms';
|
|
10
|
+
export { createSkillHandler, generateSkillMd } from '../site/skill';
|
|
9
11
|
// Database, Drizzle ORM & Server Pagination
|
|
10
12
|
export { getDb, schemaPg, schemaSqlite } from './db/index';
|
|
11
13
|
export { parseDataTableQuery, createDataTableResponse } from './db/pagination';
|
|
@@ -26,3 +28,5 @@ export { generateOpenApiSpec, createApiDocsHandler, createApiRegistry, globalApi
|
|
|
26
28
|
export { enqueueJob, defineWorker, createJobRunner, eventBus, EventBus, parseJobDelay } from './jobs/index';
|
|
27
29
|
// Adapter-Agnostic Real-Time Abstractions & Server-Sent Events (Milestone 5)
|
|
28
30
|
export { yaxaSSE, formatSSEFrame, broadcast, createBroadcaster, globalBroadcaster, MemoryBroadcaster } from './realtime/index';
|
|
31
|
+
// AI Streaming & Real-Time Reasoning Engine
|
|
32
|
+
export { createAiStreamHandler } from './ai/index';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type SiteConfig } from './config';
|
|
2
|
+
import type { PageSeoConfig } from './seo-helpers';
|
|
2
3
|
export interface AuthUserContext {
|
|
3
4
|
id?: string;
|
|
4
5
|
name?: string | null;
|
|
@@ -17,6 +18,8 @@ export declare class YaxaState {
|
|
|
17
18
|
constructor(configGetter?: () => SiteConfig, userGetter?: () => AuthUserContext | null);
|
|
18
19
|
get config(): SiteConfig;
|
|
19
20
|
get user(): AuthUserContext | null;
|
|
21
|
+
get pageSeo(): PageSeoConfig | null;
|
|
22
|
+
setPageSeo(seo: PageSeoConfig | null): void;
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
22
25
|
* Initializes and binds the reactive YaxaState instance to the current Svelte component tree context.
|
|
@@ -6,6 +6,7 @@ import { DEFAULT_SITE_CONFIG } from './config';
|
|
|
6
6
|
export class YaxaState {
|
|
7
7
|
#configGetter;
|
|
8
8
|
#userGetter;
|
|
9
|
+
#pageSeo = $state(null);
|
|
9
10
|
constructor(configGetter = () => DEFAULT_SITE_CONFIG, userGetter = () => null) {
|
|
10
11
|
this.#configGetter = configGetter;
|
|
11
12
|
this.#userGetter = userGetter;
|
|
@@ -16,6 +17,12 @@ export class YaxaState {
|
|
|
16
17
|
get user() {
|
|
17
18
|
return this.#userGetter() ?? null;
|
|
18
19
|
}
|
|
20
|
+
get pageSeo() {
|
|
21
|
+
return this.#pageSeo;
|
|
22
|
+
}
|
|
23
|
+
setPageSeo(seo) {
|
|
24
|
+
this.#pageSeo = seo;
|
|
25
|
+
}
|
|
19
26
|
}
|
|
20
27
|
const [getYaxaContext, setYaxaContext] = createContext();
|
|
21
28
|
/**
|
package/dist/site/hook.d.ts
CHANGED
|
@@ -2,14 +2,18 @@ import type { Handle } from '@sveltejs/kit/hooks';
|
|
|
2
2
|
import type { SiteConfig } from './config';
|
|
3
3
|
import { type RobotsOptions } from './robots';
|
|
4
4
|
import { type SitemapOptions } from './sitemap';
|
|
5
|
+
import { type LlmsTxtOptions } from './llms';
|
|
6
|
+
import { type SkillOptions } from './skill';
|
|
5
7
|
export interface YaxaHookOptions {
|
|
6
8
|
config: SiteConfig;
|
|
7
9
|
robots?: RobotsOptions;
|
|
8
10
|
sitemap?: SitemapOptions;
|
|
11
|
+
llms?: LlmsTxtOptions;
|
|
12
|
+
skill?: SkillOptions;
|
|
9
13
|
}
|
|
10
14
|
/**
|
|
11
15
|
* Creates an all-in-one SvelteKit Server Handle Hook that automatically routes
|
|
12
|
-
* /robots.txt, /sitemap.xml, /sitemap.xsl, /site.webmanifest,
|
|
16
|
+
* /robots.txt, /sitemap.xml, /sitemap.xsl, /site.webmanifest, /api/og, /llms.txt, and /skill.md
|
|
13
17
|
* directly from your site.config.ts with zero route files required!
|
|
14
18
|
*/
|
|
15
19
|
export declare function createYaxaHook(optionsOrConfig: SiteConfig | YaxaHookOptions): Handle;
|
package/dist/site/hook.js
CHANGED
|
@@ -3,9 +3,11 @@ import { createSitemapHandler } from './sitemap';
|
|
|
3
3
|
import { createSitemapXslHandler } from './sitemap-xsl';
|
|
4
4
|
import { createManifestHandler } from './manifest';
|
|
5
5
|
import { createOgImageHandler } from './og';
|
|
6
|
+
import { createLlmsTxtHandler } from './llms';
|
|
7
|
+
import { createSkillHandler } from './skill';
|
|
6
8
|
/**
|
|
7
9
|
* Creates an all-in-one SvelteKit Server Handle Hook that automatically routes
|
|
8
|
-
* /robots.txt, /sitemap.xml, /sitemap.xsl, /site.webmanifest,
|
|
10
|
+
* /robots.txt, /sitemap.xml, /sitemap.xsl, /site.webmanifest, /api/og, /llms.txt, and /skill.md
|
|
9
11
|
* directly from your site.config.ts with zero route files required!
|
|
10
12
|
*/
|
|
11
13
|
export function createYaxaHook(optionsOrConfig) {
|
|
@@ -16,6 +18,8 @@ export function createYaxaHook(optionsOrConfig) {
|
|
|
16
18
|
const sitemapXslHandler = createSitemapXslHandler({ config });
|
|
17
19
|
const manifestHandler = createManifestHandler({ config });
|
|
18
20
|
const ogHandler = createOgImageHandler({ config });
|
|
21
|
+
const llmsTxtHandler = createLlmsTxtHandler(options.llms || { config });
|
|
22
|
+
const skillHandler = createSkillHandler(options.skill || { config });
|
|
19
23
|
return async ({ event, resolve }) => {
|
|
20
24
|
const pathname = event.url.pathname;
|
|
21
25
|
if (pathname === '/robots.txt') {
|
|
@@ -33,6 +37,12 @@ export function createYaxaHook(optionsOrConfig) {
|
|
|
33
37
|
if (pathname === '/api/og') {
|
|
34
38
|
return ogHandler(event);
|
|
35
39
|
}
|
|
40
|
+
if (pathname === '/llms.txt') {
|
|
41
|
+
return llmsTxtHandler(event);
|
|
42
|
+
}
|
|
43
|
+
if (pathname === '/skill.md' || pathname === '/.well-known/skill.md') {
|
|
44
|
+
return skillHandler(event);
|
|
45
|
+
}
|
|
36
46
|
return resolve(event);
|
|
37
47
|
};
|
|
38
48
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { default as Seo } from '../components/seo/Seo.svelte';
|
|
2
|
+
export { default as Favicons } from '../components/seo/Favicons.svelte';
|
|
3
|
+
export { useSeo } from './useSeo.svelte.js';
|
|
4
|
+
export { defineSiteConfig, computeProjectBadge, DEFAULT_SITE_CONFIG } from './config.js';
|
|
5
|
+
export type { SiteConfig, ProjectLicense, ProjectType, PricingModel, ProjectConfig, AuthorConfig, NavItem, CompanyConfig, LegalConfig, LegalLinksConfig } from './config.js';
|
|
6
|
+
export { createRobotsHandler } from './robots.js';
|
|
7
|
+
export type { RobotsOptions } from './robots.js';
|
|
8
|
+
export { createSitemapHandler } from './sitemap.js';
|
|
9
|
+
export type { SitemapRoute, SitemapImage, SitemapOptions } from './sitemap.js';
|
|
10
|
+
export { createSitemapXslHandler, generateSitemapXsl } from './sitemap-xsl.js';
|
|
11
|
+
export { createManifestHandler } from './manifest.js';
|
|
12
|
+
export type { ManifestOptions } from './manifest.js';
|
|
13
|
+
export { createOgImageHandler, generateOgSvg } from './og.js';
|
|
14
|
+
export type { OgImageOptions } from './og.js';
|
|
15
|
+
export { createLlmsTxtHandler, generateLlmsTxt } from './llms.js';
|
|
16
|
+
export type { LlmsTxtOptions, LlmsSection, LlmsLink } from './llms.js';
|
|
17
|
+
export { createSkillHandler, generateSkillMd } from './skill.js';
|
|
18
|
+
export type { SkillOptions, SkillAction } from './skill.js';
|
|
19
|
+
export { generateWebSiteSchema, generateOrganizationSchema, generateSoftwareApplicationSchema, generateSoftwareSourceCodeSchema, generatePersonSchema, generateArticleSchema, generateBreadcrumbSchema, generateFaqSchema, generateProductSchema } from './schema.js';
|
|
20
|
+
export type { SchemaType, BreadcrumbItem, ArticleSchemaData, FaqItem, ProductSchemaData } from './schema.js';
|
|
21
|
+
export { definePageSeo } from './seo-helpers.js';
|
|
22
|
+
export type { PageSeoConfig } from './seo-helpers.js';
|
|
23
|
+
export { createYaxaHook } from './hook.js';
|
|
24
|
+
export type { YaxaHookOptions } from './hook.js';
|
|
25
|
+
export { YaxaState, initYaxaState, useYaxa, useSiteConfig, useAuthUser } from './context.js';
|
|
26
|
+
export type { AuthUserContext } from './context.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Yaxa SEO & Site Metadata Subpath (yaxa-svelte/seo)
|
|
2
|
+
// Pure, zero-dependency SEO engine compatible with @sveltejs/adapter-static
|
|
3
|
+
// Svelte SEO Components
|
|
4
|
+
export { default as Seo } from '../components/seo/Seo.svelte';
|
|
5
|
+
export { default as Favicons } from '../components/seo/Favicons.svelte';
|
|
6
|
+
// Reactive Svelte 5 Runes Composable
|
|
7
|
+
export { useSeo } from './useSeo.svelte.js';
|
|
8
|
+
// Configuration & Types
|
|
9
|
+
export { defineSiteConfig, computeProjectBadge, DEFAULT_SITE_CONFIG } from './config.js';
|
|
10
|
+
// Turnkey Server & Static Request Handlers
|
|
11
|
+
export { createRobotsHandler } from './robots.js';
|
|
12
|
+
export { createSitemapHandler } from './sitemap.js';
|
|
13
|
+
export { createSitemapXslHandler, generateSitemapXsl } from './sitemap-xsl.js';
|
|
14
|
+
export { createManifestHandler } from './manifest.js';
|
|
15
|
+
export { createOgImageHandler, generateOgSvg } from './og.js';
|
|
16
|
+
export { createLlmsTxtHandler, generateLlmsTxt } from './llms.js';
|
|
17
|
+
export { createSkillHandler, generateSkillMd } from './skill.js';
|
|
18
|
+
// Schema.org Structured Data (JSON-LD)
|
|
19
|
+
export { generateWebSiteSchema, generateOrganizationSchema, generateSoftwareApplicationSchema, generateSoftwareSourceCodeSchema, generatePersonSchema, generateArticleSchema, generateBreadcrumbSchema, generateFaqSchema, generateProductSchema } from './schema.js';
|
|
20
|
+
// Page-Level SEO Helpers
|
|
21
|
+
export { definePageSeo } from './seo-helpers.js';
|
|
22
|
+
// SvelteKit Server Hook (All-in-one SEO routing)
|
|
23
|
+
export { createYaxaHook } from './hook.js';
|
|
24
|
+
// Reactive Site Context Runes (Safe for SSR and CSR)
|
|
25
|
+
export { YaxaState, initYaxaState, useYaxa, useSiteConfig, useAuthUser } from './context.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RequestHandler } from '@sveltejs/kit';
|
|
2
|
+
import type { SiteConfig } from './config.js';
|
|
3
|
+
export interface LlmsLink {
|
|
4
|
+
title: string;
|
|
5
|
+
url: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LlmsSection {
|
|
9
|
+
title: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
links: LlmsLink[];
|
|
12
|
+
}
|
|
13
|
+
export interface LlmsTxtOptions {
|
|
14
|
+
config: SiteConfig;
|
|
15
|
+
sections?: LlmsSection[];
|
|
16
|
+
notes?: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Generates an llms.txt standard markdown document (https://llmstxt.org/)
|
|
20
|
+
* providing structured, token-efficient context for AI search engines (Perplexity, ChatGPT, Claude, Cursor).
|
|
21
|
+
*/
|
|
22
|
+
export declare function generateLlmsTxt(optionsOrConfig: SiteConfig | LlmsTxtOptions): string;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a SvelteKit RequestHandler for serving /llms.txt.
|
|
25
|
+
* Compatible with pure static site generation (@sveltejs/adapter-static) via `export const prerender = true`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createLlmsTxtHandler(optionsOrConfig: SiteConfig | LlmsTxtOptions): RequestHandler;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates an llms.txt standard markdown document (https://llmstxt.org/)
|
|
3
|
+
* providing structured, token-efficient context for AI search engines (Perplexity, ChatGPT, Claude, Cursor).
|
|
4
|
+
*/
|
|
5
|
+
export function generateLlmsTxt(optionsOrConfig) {
|
|
6
|
+
const options = 'config' in optionsOrConfig ? optionsOrConfig : { config: optionsOrConfig };
|
|
7
|
+
const { config, sections = [], notes = [] } = options;
|
|
8
|
+
const baseUrl = (config.url || '').replace(/\/$/, '');
|
|
9
|
+
let text = `# ${config.title || config.name}\n\n`;
|
|
10
|
+
if (config.description) {
|
|
11
|
+
text += `> ${config.description}\n\n`;
|
|
12
|
+
}
|
|
13
|
+
if (sections.length > 0) {
|
|
14
|
+
for (const section of sections) {
|
|
15
|
+
text += `## ${section.title}\n\n`;
|
|
16
|
+
if (section.description) {
|
|
17
|
+
text += `${section.description}\n\n`;
|
|
18
|
+
}
|
|
19
|
+
for (const link of section.links) {
|
|
20
|
+
const fullUrl = link.url.startsWith('http') ? link.url : `${baseUrl}${link.url}`;
|
|
21
|
+
const desc = link.description ? `: ${link.description}` : '';
|
|
22
|
+
text += `- [${link.title}](${fullUrl})${desc}\n`;
|
|
23
|
+
}
|
|
24
|
+
text += '\n';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
text += `## Overview\n\n`;
|
|
29
|
+
text += `- [Homepage](${baseUrl}): Official website\n`;
|
|
30
|
+
if (config.project?.repositoryUrl) {
|
|
31
|
+
text += `- [Source Repository](${config.project.repositoryUrl}): Project source code and issues\n`;
|
|
32
|
+
}
|
|
33
|
+
text += '\n';
|
|
34
|
+
}
|
|
35
|
+
if (notes.length > 0) {
|
|
36
|
+
text += `## Optional\n\n`;
|
|
37
|
+
for (const note of notes) {
|
|
38
|
+
text += `- ${note}\n`;
|
|
39
|
+
}
|
|
40
|
+
text += '\n';
|
|
41
|
+
}
|
|
42
|
+
return text.trimEnd() + '\n';
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates a SvelteKit RequestHandler for serving /llms.txt.
|
|
46
|
+
* Compatible with pure static site generation (@sveltejs/adapter-static) via `export const prerender = true`.
|
|
47
|
+
*/
|
|
48
|
+
export function createLlmsTxtHandler(optionsOrConfig) {
|
|
49
|
+
return async () => {
|
|
50
|
+
const body = generateLlmsTxt(optionsOrConfig);
|
|
51
|
+
return new Response(body, {
|
|
52
|
+
headers: {
|
|
53
|
+
'Content-Type': 'text/plain; charset=utf-8',
|
|
54
|
+
'Cache-Control': 'public, max-age=86400'
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
}
|
package/dist/site/schema.d.ts
CHANGED
|
@@ -4,6 +4,21 @@ export interface BreadcrumbItem {
|
|
|
4
4
|
name: string;
|
|
5
5
|
url: string;
|
|
6
6
|
}
|
|
7
|
+
export interface FaqItem {
|
|
8
|
+
question: string;
|
|
9
|
+
answer: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ProductSchemaData {
|
|
12
|
+
name: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
image?: string;
|
|
15
|
+
price: number | string;
|
|
16
|
+
currency?: string;
|
|
17
|
+
inStock?: boolean;
|
|
18
|
+
brand?: string;
|
|
19
|
+
sku?: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
}
|
|
7
22
|
export interface ArticleSchemaData {
|
|
8
23
|
title: string;
|
|
9
24
|
description: string;
|
|
@@ -124,3 +139,33 @@ export declare function generateBreadcrumbSchema(config: SiteConfig, items: Brea
|
|
|
124
139
|
item: string;
|
|
125
140
|
}[];
|
|
126
141
|
};
|
|
142
|
+
export declare function generateFaqSchema(items: FaqItem[]): {
|
|
143
|
+
'@context': string;
|
|
144
|
+
'@type': string;
|
|
145
|
+
mainEntity: {
|
|
146
|
+
'@type': string;
|
|
147
|
+
name: string;
|
|
148
|
+
acceptedAnswer: {
|
|
149
|
+
'@type': string;
|
|
150
|
+
text: string;
|
|
151
|
+
};
|
|
152
|
+
}[];
|
|
153
|
+
};
|
|
154
|
+
export declare function generateProductSchema(config: SiteConfig, product: ProductSchemaData): {
|
|
155
|
+
'@context': string;
|
|
156
|
+
'@type': string;
|
|
157
|
+
name: string;
|
|
158
|
+
description: string;
|
|
159
|
+
image: string | undefined;
|
|
160
|
+
brand: {
|
|
161
|
+
'@type': string;
|
|
162
|
+
name: string;
|
|
163
|
+
};
|
|
164
|
+
offers: {
|
|
165
|
+
'@type': string;
|
|
166
|
+
price: string;
|
|
167
|
+
priceCurrency: string;
|
|
168
|
+
availability: string;
|
|
169
|
+
url: string;
|
|
170
|
+
};
|
|
171
|
+
};
|
package/dist/site/schema.js
CHANGED
|
@@ -161,3 +161,46 @@ export function generateBreadcrumbSchema(config, items) {
|
|
|
161
161
|
}))
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
|
+
export function generateFaqSchema(items) {
|
|
165
|
+
return {
|
|
166
|
+
'@context': 'https://schema.org',
|
|
167
|
+
'@type': 'FAQPage',
|
|
168
|
+
mainEntity: items.map((item) => ({
|
|
169
|
+
'@type': 'Question',
|
|
170
|
+
name: item.question,
|
|
171
|
+
acceptedAnswer: {
|
|
172
|
+
'@type': 'Answer',
|
|
173
|
+
text: item.answer
|
|
174
|
+
}
|
|
175
|
+
}))
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
export function generateProductSchema(config, product) {
|
|
179
|
+
const baseUrl = (config.url || '').replace(/\/$/, '');
|
|
180
|
+
return {
|
|
181
|
+
'@context': 'https://schema.org',
|
|
182
|
+
'@type': 'Product',
|
|
183
|
+
name: product.name,
|
|
184
|
+
description: product.description || config.description,
|
|
185
|
+
image: product.image
|
|
186
|
+
? product.image.startsWith('http')
|
|
187
|
+
? product.image
|
|
188
|
+
: `${baseUrl}${product.image}`
|
|
189
|
+
: undefined,
|
|
190
|
+
brand: {
|
|
191
|
+
'@type': 'Brand',
|
|
192
|
+
name: product.brand || config.name
|
|
193
|
+
},
|
|
194
|
+
offers: {
|
|
195
|
+
'@type': 'Offer',
|
|
196
|
+
price: String(product.price),
|
|
197
|
+
priceCurrency: product.currency || 'USD',
|
|
198
|
+
availability: product.inStock !== false ? 'https://schema.org/InStock' : 'https://schema.org/OutOfStock',
|
|
199
|
+
url: product.url
|
|
200
|
+
? product.url.startsWith('http')
|
|
201
|
+
? product.url
|
|
202
|
+
: `${baseUrl}${product.url}`
|
|
203
|
+
: baseUrl
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|