@affectively/aeon-pages-runtime 0.5.2 → 0.7.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 +399 -0
- package/dist/chunk-439mqgjz.js +667 -0
- package/dist/chunk-7zbxm162.js +5251 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +26 -2
- package/dist/router/esi-react.d.ts +2 -0
- package/dist/router/esi-translate-observer.d.ts +153 -0
- package/dist/router/esi-translate-react.d.ts +155 -0
- package/dist/router/index.d.ts +8 -1
- package/dist/router/index.js +64 -2
- package/dist/router/merkle-capability.d.ts +145 -0
- package/dist/server.js +2 -2
- package/dist/types.d.ts +80 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export { EncryptedOfflineQueue, getOfflineQueue, createOfflineQueue, resetOfflin
|
|
|
49
49
|
export { ConflictResolver, getConflictResolver, createConflictResolver, resetConflictResolver, type ConflictResolverConfig, type ConflictStats as ConflictResolverStats, } from './sync/conflict-resolver';
|
|
50
50
|
export { SyncCoordinator, getSyncCoordinator, createSyncCoordinator, resetSyncCoordinator, type SyncStats, } from './sync/coordinator';
|
|
51
51
|
export { handlePush, handleNotificationClick, handleNotificationClose, handleSync, handleMessage, registerPushHandlers, registerSyncHandlers, registerMessageHandlers, urlBase64ToUint8Array, serializePushSubscription, type PushNotificationData, type PushHandlerConfig, type ServiceWorkerMessage, } from './service-worker-push';
|
|
52
|
-
export type { AeonConfig, AeonOptions, SyncOptions, VersioningOptions, PresenceOptions, OfflineOptions, PushOptions, InstallOptions, SkeletonOptions, ComponentOptions, OutputOptions, RouteDefinition, RouteMatch, RouteMetadata, RouteOperation, SerializedComponent, PageSession, PresenceInfo, PresenceUser, AeonCapability, SkeletonShape, SkeletonSource, SkeletonDimensions, SkeletonMetadata, SkeletonHint, HttpMethod, AeonEnv, AeonContext, ExecutionContext, ApiRouteHandler, ApiRouteModule, ApiRoute, ApiRouteMatch, ApiRouteSegment, ServerRouteModule, ServerLoaderResult, ServerActionResult, D1Database, D1PreparedStatement, D1Result, D1ExecResult, KVNamespace, DurableObjectNamespace, DurableObjectId, DurableObjectStub, Ai, } from './types';
|
|
53
|
-
export { DEFAULT_ROUTER_CONFIG, DEFAULT_ESI_CONFIG, HeuristicAdapter, EdgeWorkersESIProcessor, extractUserContext, createContextMiddleware, setContextCookies, addSpeculationHeaders, esiInfer, esiEmbed, esiEmotion, esiVision, esiWithContext, } from './router/index';
|
|
54
|
-
export type { EmotionState, Viewport, ConnectionType, UserTier, UserContext, ThemeMode, LayoutDensity, LayoutType, SkeletonHints, RouteDecision, ComponentNode, ComponentTree, ComponentTreeSchema, RouterAdapter, HeuristicAdapterConfig, TierFeatures, SignalProcessor, ContextExtractorOptions, AIRouterConfig, SpeculationConfig, PersonalizationConfig, RouterConfig, RouterConfigWithESI, ESIModel, ESIContentType, ESIParams, ESIContent, ESIDirective, ESIResult, ESIProcessor, ESIConfig, } from './router/index';
|
|
52
|
+
export type { AeonConfig, AeonOptions, SyncOptions, VersioningOptions, PresenceOptions, OfflineOptions, PushOptions, InstallOptions, SkeletonOptions, ComponentOptions, OutputOptions, RouteDefinition, RouteMatch, RouteMetadata, RouteOperation, SerializedComponent, PageSession, PresenceInfo, PresenceUser, AeonCapability, AeonCapabilityAction, AeonNodeCapability, AeonNodeCapabilityAction, AeonCapabilityActionType, AeonAnyCapability, AeonResourceType, ParsedResource, MerkleAccessRequest, SkeletonShape, SkeletonSource, SkeletonDimensions, SkeletonMetadata, SkeletonHint, HttpMethod, AeonEnv, AeonContext, ExecutionContext, ApiRouteHandler, ApiRouteModule, ApiRoute, ApiRouteMatch, ApiRouteSegment, ServerRouteModule, ServerLoaderResult, ServerActionResult, D1Database, D1PreparedStatement, D1Result, D1ExecResult, KVNamespace, DurableObjectNamespace, DurableObjectId, DurableObjectStub, Ai, } from './types';
|
|
53
|
+
export { DEFAULT_ROUTER_CONFIG, DEFAULT_ESI_CONFIG, HeuristicAdapter, EdgeWorkersESIProcessor, extractUserContext, createContextMiddleware, setContextCookies, addSpeculationHeaders, esiInfer, esiEmbed, esiEmotion, esiVision, esiWithContext, parseResource, formatResource, capabilityGrantsAccess, createNodeCapabilityVerifier, createNodeReadCapability, createNodeWriteCapability, createTreeCapability, createPathCapability, createWildcardNodeCapability, checkNodeAccess, filterAccessibleNodes, getMostSpecificCapability, } from './router/index';
|
|
54
|
+
export type { EmotionState, Viewport, ConnectionType, UserTier, UserContext, ThemeMode, LayoutDensity, LayoutType, SkeletonHints, RouteDecision, ComponentNode, ComponentTree, ComponentTreeSchema, RouterAdapter, HeuristicAdapterConfig, TierFeatures, SignalProcessor, ContextExtractorOptions, AIRouterConfig, SpeculationConfig, PersonalizationConfig, RouterConfig, RouterConfigWithESI, ESIModel, ESIContentType, ESIParams, ESIContent, ESIDirective, ESIResult, ESIProcessor, ESIConfig, NodeCapabilityVerifier, NodeVerifierOptions, } from './router/index';
|
|
55
55
|
export declare const VERSION = "1.0.0";
|
package/dist/index.js
CHANGED
|
@@ -2,22 +2,34 @@ import {
|
|
|
2
2
|
AeonRouteRegistry,
|
|
3
3
|
AeonRouter,
|
|
4
4
|
createAeonServer
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-439mqgjz.js";
|
|
6
6
|
import {
|
|
7
7
|
DEFAULT_ESI_CONFIG,
|
|
8
8
|
DEFAULT_ROUTER_CONFIG,
|
|
9
9
|
EdgeWorkersESIProcessor,
|
|
10
10
|
HeuristicAdapter,
|
|
11
11
|
addSpeculationHeaders,
|
|
12
|
+
capabilityGrantsAccess,
|
|
13
|
+
checkNodeAccess,
|
|
12
14
|
createContextMiddleware,
|
|
15
|
+
createNodeCapabilityVerifier,
|
|
16
|
+
createNodeReadCapability,
|
|
17
|
+
createNodeWriteCapability,
|
|
18
|
+
createPathCapability,
|
|
19
|
+
createTreeCapability,
|
|
20
|
+
createWildcardNodeCapability,
|
|
13
21
|
esiEmbed,
|
|
14
22
|
esiEmotion,
|
|
15
23
|
esiInfer,
|
|
16
24
|
esiVision,
|
|
17
25
|
esiWithContext,
|
|
18
26
|
extractUserContext,
|
|
27
|
+
filterAccessibleNodes,
|
|
28
|
+
formatResource,
|
|
29
|
+
getMostSpecificCapability,
|
|
30
|
+
parseResource,
|
|
19
31
|
setContextCookies
|
|
20
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-7zbxm162.js";
|
|
21
33
|
import"./chunk-e71hvfe9.js";
|
|
22
34
|
import {
|
|
23
35
|
__require
|
|
@@ -4296,6 +4308,7 @@ export {
|
|
|
4296
4308
|
registerMessageHandlers,
|
|
4297
4309
|
redirect,
|
|
4298
4310
|
rateLimit,
|
|
4311
|
+
parseResource,
|
|
4299
4312
|
notFound,
|
|
4300
4313
|
json,
|
|
4301
4314
|
isSkeletonVisible,
|
|
@@ -4315,12 +4328,15 @@ export {
|
|
|
4315
4328
|
getOfflineQueue,
|
|
4316
4329
|
getNavigator,
|
|
4317
4330
|
getNavigationCache,
|
|
4331
|
+
getMostSpecificCapability,
|
|
4318
4332
|
getConflictResolver,
|
|
4319
4333
|
generateSkeletonPageStructure,
|
|
4320
4334
|
generateSkeletonInitScript,
|
|
4321
4335
|
generateOperationId,
|
|
4322
4336
|
generateAsyncSwapScript,
|
|
4337
|
+
formatResource,
|
|
4323
4338
|
forbidden,
|
|
4339
|
+
filterAccessibleNodes,
|
|
4324
4340
|
extractUserContext,
|
|
4325
4341
|
estimateEncryptedSize,
|
|
4326
4342
|
esiWithContext,
|
|
@@ -4329,9 +4345,15 @@ export {
|
|
|
4329
4345
|
esiEmotion,
|
|
4330
4346
|
esiEmbed,
|
|
4331
4347
|
error,
|
|
4348
|
+
createWildcardNodeCapability,
|
|
4349
|
+
createTreeCapability,
|
|
4332
4350
|
createSyncCoordinator,
|
|
4333
4351
|
createStorageAdapter,
|
|
4352
|
+
createPathCapability,
|
|
4334
4353
|
createOfflineQueue,
|
|
4354
|
+
createNodeWriteCapability,
|
|
4355
|
+
createNodeReadCapability,
|
|
4356
|
+
createNodeCapabilityVerifier,
|
|
4335
4357
|
createContextMiddleware,
|
|
4336
4358
|
createConflictResolver,
|
|
4337
4359
|
createApiRouter,
|
|
@@ -4339,6 +4361,8 @@ export {
|
|
|
4339
4361
|
createAeonServer,
|
|
4340
4362
|
cors,
|
|
4341
4363
|
composeMiddleware,
|
|
4364
|
+
checkNodeAccess,
|
|
4365
|
+
capabilityGrantsAccess,
|
|
4342
4366
|
badRequest,
|
|
4343
4367
|
addSpeculationHeaders,
|
|
4344
4368
|
adaptRouteModule,
|
|
@@ -353,6 +353,8 @@ export declare const ESI: {
|
|
|
353
353
|
Embed: FC<ESIEmbedProps>;
|
|
354
354
|
Emotion: FC<ESIEmotionProps>;
|
|
355
355
|
Vision: FC<ESIVisionProps>;
|
|
356
|
+
Translate: FC<import("./esi-translate-react").ESITranslateProps>;
|
|
357
|
+
TranslationProvider: FC<import("./esi-translate-react").TranslationProviderProps>;
|
|
356
358
|
Structured: typeof ESIStructured;
|
|
357
359
|
If: typeof ESIIf;
|
|
358
360
|
Show: typeof ESIShow;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESI Translation Observer
|
|
3
|
+
*
|
|
4
|
+
* MutationObserver-based system for automatically translating elements
|
|
5
|
+
* decorated with data-translate attribute.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```html
|
|
9
|
+
* <!-- Basic translation -->
|
|
10
|
+
* <p data-translate data-target-lang="es">Hello world</p>
|
|
11
|
+
*
|
|
12
|
+
* <!-- With source language hint -->
|
|
13
|
+
* <span data-translate data-source-lang="en" data-target-lang="fr">Welcome</span>
|
|
14
|
+
*
|
|
15
|
+
* <!-- With translation context -->
|
|
16
|
+
* <p data-translate data-translate-context="formal, business">
|
|
17
|
+
* Please review the attached document.
|
|
18
|
+
* </p>
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* // React hook usage
|
|
24
|
+
* function App() {
|
|
25
|
+
* useTranslationObserver({
|
|
26
|
+
* translateAttribute: 'data-translate',
|
|
27
|
+
* batchSize: 10,
|
|
28
|
+
* debounceMs: 100,
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* return <div data-translate data-target-lang="es">Hello</div>;
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
import type { TranslationResult } from './types';
|
|
36
|
+
export interface TranslationObserverConfig {
|
|
37
|
+
/** Root element to observe (defaults to document.body) */
|
|
38
|
+
root?: Element;
|
|
39
|
+
/** Attribute that marks elements for translation (default: 'data-translate') */
|
|
40
|
+
translateAttribute?: string;
|
|
41
|
+
/** Batch translations for efficiency (default: 10) */
|
|
42
|
+
batchSize?: number;
|
|
43
|
+
/** Debounce time for mutations in ms (default: 100) */
|
|
44
|
+
debounceMs?: number;
|
|
45
|
+
/** AI Gateway endpoint */
|
|
46
|
+
endpoint?: string;
|
|
47
|
+
/** Default target language if not specified on element */
|
|
48
|
+
defaultTargetLanguage?: string;
|
|
49
|
+
/** Cache TTL in seconds (default: 86400 = 24 hours) */
|
|
50
|
+
cacheTtl?: number;
|
|
51
|
+
/** Callback when element is translated */
|
|
52
|
+
onTranslate?: (element: Element, result: TranslationResult) => void;
|
|
53
|
+
/** Callback on translation error */
|
|
54
|
+
onError?: (element: Element, error: string) => void;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* TranslationObserver - Watches DOM for translatable elements
|
|
58
|
+
*
|
|
59
|
+
* Uses MutationObserver to detect elements with data-translate attribute
|
|
60
|
+
* and automatically translates them using the AI Gateway.
|
|
61
|
+
*/
|
|
62
|
+
export declare class TranslationObserver {
|
|
63
|
+
private observer;
|
|
64
|
+
private config;
|
|
65
|
+
private translationQueue;
|
|
66
|
+
private isProcessing;
|
|
67
|
+
private debounceTimer;
|
|
68
|
+
private translatedElements;
|
|
69
|
+
constructor(config?: TranslationObserverConfig);
|
|
70
|
+
/**
|
|
71
|
+
* Start observing for translatable elements
|
|
72
|
+
*/
|
|
73
|
+
observe(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Stop observing
|
|
76
|
+
*/
|
|
77
|
+
disconnect(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Manually translate all current elements
|
|
80
|
+
*/
|
|
81
|
+
translateAll(): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Translate a specific element
|
|
84
|
+
*/
|
|
85
|
+
translateElement(element: Element): Promise<TranslationResult | null>;
|
|
86
|
+
/**
|
|
87
|
+
* Handle DOM mutations
|
|
88
|
+
*/
|
|
89
|
+
private handleMutations;
|
|
90
|
+
/**
|
|
91
|
+
* Queue an element for translation
|
|
92
|
+
*/
|
|
93
|
+
private queueElement;
|
|
94
|
+
/**
|
|
95
|
+
* Debounced queue processing
|
|
96
|
+
*/
|
|
97
|
+
private debouncedProcessQueue;
|
|
98
|
+
/**
|
|
99
|
+
* Process queued translations
|
|
100
|
+
*/
|
|
101
|
+
private processQueue;
|
|
102
|
+
/**
|
|
103
|
+
* Get target language for an element
|
|
104
|
+
*/
|
|
105
|
+
private getTargetLanguage;
|
|
106
|
+
/**
|
|
107
|
+
* Get source language for an element
|
|
108
|
+
*/
|
|
109
|
+
private getSourceLanguage;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* React hook for translation observer
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```tsx
|
|
116
|
+
* function App() {
|
|
117
|
+
* useTranslationObserver({
|
|
118
|
+
* translateAttribute: 'data-translate',
|
|
119
|
+
* onTranslate: (element, result) => {
|
|
120
|
+
* console.log('Translated:', result.translated);
|
|
121
|
+
* },
|
|
122
|
+
* });
|
|
123
|
+
*
|
|
124
|
+
* return (
|
|
125
|
+
* <div>
|
|
126
|
+
* <p data-translate data-target-lang="es">Hello world</p>
|
|
127
|
+
* <p data-translate data-target-lang="fr">Goodbye</p>
|
|
128
|
+
* </div>
|
|
129
|
+
* );
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export declare function useTranslationObserver(config?: TranslationObserverConfig): React.RefObject<TranslationObserver | null>;
|
|
134
|
+
/**
|
|
135
|
+
* Auto-initialize translation observer when DOM is ready
|
|
136
|
+
*
|
|
137
|
+
* Call this in your app's entry point to automatically translate
|
|
138
|
+
* all elements with data-translate attribute.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```tsx
|
|
142
|
+
* // In your app entry point
|
|
143
|
+
* import { initTranslationObserver } from '@affectively/aeon-flux';
|
|
144
|
+
*
|
|
145
|
+
* initTranslationObserver({
|
|
146
|
+
* defaultTargetLanguage: 'es',
|
|
147
|
+
* onTranslate: (element, result) => {
|
|
148
|
+
* console.log('Translated:', result.translated);
|
|
149
|
+
* },
|
|
150
|
+
* });
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export declare function initTranslationObserver(config?: TranslationObserverConfig): TranslationObserver;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESI Translation React Components
|
|
3
|
+
*
|
|
4
|
+
* Provides React components for automatic translation in aeon-flux applications.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* // Basic usage with explicit target language
|
|
9
|
+
* <ESI.Translate targetLanguage="es">
|
|
10
|
+
* Hello, welcome to our platform!
|
|
11
|
+
* </ESI.Translate>
|
|
12
|
+
*
|
|
13
|
+
* // Using TranslationProvider for app-wide language
|
|
14
|
+
* <TranslationProvider defaultLanguage="es">
|
|
15
|
+
* <ESI.Translate>Hello world</ESI.Translate>
|
|
16
|
+
* </TranslationProvider>
|
|
17
|
+
*
|
|
18
|
+
* // Programmatic translation
|
|
19
|
+
* const { translate, language } = useTranslation();
|
|
20
|
+
* const translated = await translate('Hello world');
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
import { type ReactNode, type FC } from 'react';
|
|
24
|
+
import type { TranslationResult, SupportedLanguageCode } from './types';
|
|
25
|
+
import { normalizeLanguageCode, getSupportedLanguages, getLanguageName } from './esi-translate';
|
|
26
|
+
export interface TranslationContextValue {
|
|
27
|
+
/** Current target language (ISO 639-1 code) */
|
|
28
|
+
language: string;
|
|
29
|
+
/** Set the target language */
|
|
30
|
+
setLanguage: (lang: string) => void;
|
|
31
|
+
/** Translate text programmatically */
|
|
32
|
+
translate: (text: string, options?: {
|
|
33
|
+
targetLanguage?: string;
|
|
34
|
+
sourceLanguage?: string;
|
|
35
|
+
context?: string;
|
|
36
|
+
}) => Promise<TranslationResult>;
|
|
37
|
+
/** Is translation currently loading */
|
|
38
|
+
isTranslating: boolean;
|
|
39
|
+
/** List of supported languages */
|
|
40
|
+
supportedLanguages: SupportedLanguageCode[];
|
|
41
|
+
/** Translation endpoint */
|
|
42
|
+
endpoint: string;
|
|
43
|
+
/** Cache TTL in seconds */
|
|
44
|
+
cacheTtl: number;
|
|
45
|
+
}
|
|
46
|
+
declare const TranslationContext: import("react").Context<TranslationContextValue | null>;
|
|
47
|
+
export interface TranslationProviderProps {
|
|
48
|
+
children: ReactNode;
|
|
49
|
+
/** Default target language (ISO 639-1 code or language name) */
|
|
50
|
+
defaultLanguage?: string;
|
|
51
|
+
/** AI Gateway endpoint for translation */
|
|
52
|
+
endpoint?: string;
|
|
53
|
+
/** Cache TTL in seconds (default: 86400 = 24 hours) */
|
|
54
|
+
cacheTtl?: number;
|
|
55
|
+
/** Fallback language if translation fails */
|
|
56
|
+
fallbackLanguage?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* TranslationProvider - Provides translation context to the component tree
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```tsx
|
|
63
|
+
* function App() {
|
|
64
|
+
* return (
|
|
65
|
+
* <TranslationProvider defaultLanguage="es" endpoint="https://ai-gateway.example.com">
|
|
66
|
+
* <MyComponent />
|
|
67
|
+
* </TranslationProvider>
|
|
68
|
+
* );
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare const TranslationProvider: FC<TranslationProviderProps>;
|
|
73
|
+
/**
|
|
74
|
+
* Hook to access translation context
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```tsx
|
|
78
|
+
* function MyComponent() {
|
|
79
|
+
* const { translate, language, setLanguage } = useTranslation();
|
|
80
|
+
*
|
|
81
|
+
* const handleTranslate = async () => {
|
|
82
|
+
* const result = await translate('Hello world');
|
|
83
|
+
* console.log(result.translated);
|
|
84
|
+
* };
|
|
85
|
+
*
|
|
86
|
+
* return (
|
|
87
|
+
* <button onClick={handleTranslate}>
|
|
88
|
+
* Translate (current: {language})
|
|
89
|
+
* </button>
|
|
90
|
+
* );
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare function useTranslation(): TranslationContextValue;
|
|
95
|
+
/**
|
|
96
|
+
* Hook to access translation context (optional - returns null if not available)
|
|
97
|
+
*/
|
|
98
|
+
export declare function useTranslationOptional(): TranslationContextValue | null;
|
|
99
|
+
export interface ESITranslateProps {
|
|
100
|
+
/** Content to translate */
|
|
101
|
+
children?: ReactNode;
|
|
102
|
+
/** Explicit text to translate (overrides children) */
|
|
103
|
+
text?: string;
|
|
104
|
+
/** Target language (ISO 639-1 code or language name) */
|
|
105
|
+
targetLanguage?: string;
|
|
106
|
+
/** Source language (ISO 639-1 code, or 'auto' for auto-detect) */
|
|
107
|
+
sourceLanguage?: string;
|
|
108
|
+
/** Additional context for better translation quality */
|
|
109
|
+
context?: string;
|
|
110
|
+
/** Fallback content if translation fails */
|
|
111
|
+
fallback?: ReactNode;
|
|
112
|
+
/** Loading content */
|
|
113
|
+
loading?: ReactNode;
|
|
114
|
+
/** Cache TTL in seconds (default: 86400 = 24 hours) */
|
|
115
|
+
cacheTtl?: number;
|
|
116
|
+
/** Enable streaming translation */
|
|
117
|
+
stream?: boolean;
|
|
118
|
+
/** Custom render function */
|
|
119
|
+
render?: (result: TranslationResult) => ReactNode;
|
|
120
|
+
/** Class name for wrapper */
|
|
121
|
+
className?: string;
|
|
122
|
+
/** HTML element to render as */
|
|
123
|
+
as?: 'span' | 'div' | 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
124
|
+
/** Callback when translation completes */
|
|
125
|
+
onComplete?: (result: TranslationResult) => void;
|
|
126
|
+
/** Callback on error */
|
|
127
|
+
onError?: (error: string) => void;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* ESI Translation Component
|
|
131
|
+
*
|
|
132
|
+
* Translates text to the specified language using AI inference.
|
|
133
|
+
* Uses TranslationProvider context if available, otherwise falls back
|
|
134
|
+
* to detecting language from various sources.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```tsx
|
|
138
|
+
* // Basic usage
|
|
139
|
+
* <ESI.Translate targetLanguage="es">
|
|
140
|
+
* Hello, how are you?
|
|
141
|
+
* </ESI.Translate>
|
|
142
|
+
*
|
|
143
|
+
* // With context for better translation
|
|
144
|
+
* <ESI.Translate targetLanguage="ja" context="emotional wellness app">
|
|
145
|
+
* We're here to help you understand your feelings.
|
|
146
|
+
* </ESI.Translate>
|
|
147
|
+
*
|
|
148
|
+
* // Using language from context
|
|
149
|
+
* <ESI.Translate>
|
|
150
|
+
* Welcome to our platform
|
|
151
|
+
* </ESI.Translate>
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
export declare const ESITranslate: FC<ESITranslateProps>;
|
|
155
|
+
export { TranslationContext, normalizeLanguageCode, getSupportedLanguages, getLanguageName, };
|
package/dist/router/index.d.ts
CHANGED
|
@@ -7,11 +7,16 @@
|
|
|
7
7
|
* - Edge Side Inference (ESI)
|
|
8
8
|
* - Pluggable adapters (heuristic, AI, hybrid)
|
|
9
9
|
*/
|
|
10
|
-
export type { EmotionState, Viewport, ConnectionType, UserTier, UserContext, ThemeMode, LayoutDensity, LayoutType, SkeletonHints, RouteDecision, ComponentNode, ComponentTree, ComponentTreeSchema, RouterAdapter, AIRouterConfig, SpeculationConfig, PersonalizationConfig, RouterConfig, RouterConfigWithESI, ESIModel, ESIContentType, ESIParams, ESIContent, ESIDirective, ESIResult, ESIProcessor, ESIConfig, } from './types';
|
|
10
|
+
export type { EmotionState, Viewport, ConnectionType, UserTier, UserContext, ThemeMode, LayoutDensity, LayoutType, SkeletonHints, RouteDecision, ComponentNode, ComponentTree, ComponentTreeSchema, RouterAdapter, AIRouterConfig, SpeculationConfig, PersonalizationConfig, RouterConfig, RouterConfigWithESI, ESIModel, ESIContentType, ESIParams, ESIContent, ESIDirective, ESIResult, ESIProcessor, ESIConfig, TranslationResult, TranslationProviderConfig, SupportedLanguageCode, } from './types';
|
|
11
11
|
export { DEFAULT_ROUTER_CONFIG, DEFAULT_ESI_CONFIG } from './types';
|
|
12
12
|
export { EdgeWorkersESIProcessor, esiInfer, esiEmbed, esiEmotion, esiVision, esiWithContext, } from './esi';
|
|
13
|
+
export { esiTranslate, generateTranslationCacheKey, getCachedTranslation, setCachedTranslation, clearTranslationCache, readHeadTranslationConfig, normalizeLanguageCode, getLanguageName, getSupportedLanguages, detectTargetLanguage, translateWithAIGateway, } from './esi-translate';
|
|
13
14
|
export { ESI, ESIProvider, ESIInfer, ESIEmbed, ESIEmotion, ESIVision, useESI, useESIInfer, useGlobalESIState, useESIFeature, useESITier, useESIEmotionState, useESIPreferences, updateGlobalESIState, } from './esi-react';
|
|
14
15
|
export type { ESIProviderProps, ESIInferProps, ESIEmbedProps, ESIEmotionProps, ESIVisionProps, UseESIInferOptions, GlobalESIState, } from './esi-react';
|
|
16
|
+
export { ESITranslate, TranslationProvider, TranslationContext, useTranslation, useTranslationOptional, } from './esi-translate-react';
|
|
17
|
+
export type { ESITranslateProps, TranslationProviderProps, TranslationContextValue, } from './esi-translate-react';
|
|
18
|
+
export { TranslationObserver, useTranslationObserver, initTranslationObserver, } from './esi-translate-observer';
|
|
19
|
+
export type { TranslationObserverConfig, } from './esi-translate-observer';
|
|
15
20
|
export { HeuristicAdapter } from './heuristic-adapter';
|
|
16
21
|
export type { HeuristicAdapterConfig, TierFeatures, SignalProcessor, } from './heuristic-adapter';
|
|
17
22
|
export { extractUserContext, createContextMiddleware, setContextCookies, addSpeculationHeaders, serializeToESIState, generateESIStateScript, generateESIStateScriptFromContext, } from './context-extractor';
|
|
@@ -24,3 +29,5 @@ export { ESIControl, ESIStructured, ESIIf, ESIShow, ESIHide, ESIWhen, ESIUnless,
|
|
|
24
29
|
export type { ESIStructuredProps, ESIIfProps, ESIShowProps, ESIHideProps, ESIWhenProps, ESIUnlessProps, ESIMatchProps, ESICaseProps, ESIDefaultProps, ESIFirstProps, ESITierGateProps, ESIEmotionGateProps, ESITimeGateProps, ESIForEachProps, ESISelectProps, ESIABTestProps, ESIClampProps, ESIScoreProps, ESICollaborativeProps, ESIReflectProps, ESIOptimizeProps, ESIAutoProps, OptimizeMeta, } from './esi-control-react';
|
|
25
30
|
export { esiContext, esiCyrano, esiHalo, evaluateTrigger, createExhaustEntry, getToolSuggestions, CYRANO_TOOL_SUGGESTIONS, } from './esi-cyrano';
|
|
26
31
|
export type { SessionContext, EmotionContext, BehaviorContext, EnvironmentContext, BiometricContext, CyranoWhisperConfig, CyranoIntent, CyranoTone, CyranoTrigger, HaloInsightConfig, HaloObservation, HaloAction, ChatExhaustType, ChatExhaustEntry, ESIWhisperResult, } from './esi-cyrano';
|
|
32
|
+
export { parseResource, formatResource, capabilityGrantsAccess, createNodeCapabilityVerifier, createNodeReadCapability, createNodeWriteCapability, createTreeCapability, createPathCapability, createWildcardNodeCapability, checkNodeAccess, filterAccessibleNodes, getMostSpecificCapability, } from './merkle-capability';
|
|
33
|
+
export type { NodeCapabilityVerifier, NodeVerifierOptions } from './merkle-capability';
|
package/dist/router/index.js
CHANGED
|
@@ -28,18 +28,32 @@ import {
|
|
|
28
28
|
ESIStructured,
|
|
29
29
|
ESITierGate,
|
|
30
30
|
ESITimeGate,
|
|
31
|
+
ESITranslate,
|
|
31
32
|
ESIUnless,
|
|
32
33
|
ESIVision,
|
|
33
34
|
ESIWhen,
|
|
34
35
|
EdgeWorkersESIProcessor,
|
|
35
36
|
HeuristicAdapter,
|
|
36
37
|
SpeculationManager,
|
|
38
|
+
TranslationContext,
|
|
39
|
+
TranslationObserver,
|
|
40
|
+
TranslationProvider,
|
|
37
41
|
addSpeculationHeaders,
|
|
38
42
|
autoInitSpeculation,
|
|
43
|
+
capabilityGrantsAccess,
|
|
44
|
+
checkNodeAccess,
|
|
45
|
+
clearTranslationCache,
|
|
39
46
|
createContextMiddleware,
|
|
40
47
|
createControlProcessor,
|
|
41
48
|
createExhaustEntry,
|
|
49
|
+
createNodeCapabilityVerifier,
|
|
50
|
+
createNodeReadCapability,
|
|
51
|
+
createNodeWriteCapability,
|
|
52
|
+
createPathCapability,
|
|
42
53
|
createSpeculationHook,
|
|
54
|
+
createTreeCapability,
|
|
55
|
+
createWildcardNodeCapability,
|
|
56
|
+
detectTargetLanguage,
|
|
43
57
|
esiContext,
|
|
44
58
|
esiCyrano,
|
|
45
59
|
esiEmbed,
|
|
@@ -48,19 +62,33 @@ import {
|
|
|
48
62
|
esiIf,
|
|
49
63
|
esiInfer,
|
|
50
64
|
esiMatch,
|
|
65
|
+
esiTranslate,
|
|
51
66
|
esiVision,
|
|
52
67
|
esiWithContext,
|
|
53
68
|
evaluateTrigger,
|
|
54
69
|
extractUserContext,
|
|
70
|
+
filterAccessibleNodes,
|
|
71
|
+
formatResource,
|
|
55
72
|
generateESIStateScript,
|
|
56
73
|
generateESIStateScriptFromContext,
|
|
57
74
|
generateSchemaPrompt,
|
|
75
|
+
generateTranslationCacheKey,
|
|
76
|
+
getCachedTranslation,
|
|
77
|
+
getLanguageName,
|
|
78
|
+
getMostSpecificCapability,
|
|
79
|
+
getSupportedLanguages,
|
|
58
80
|
getToolSuggestions,
|
|
81
|
+
initTranslationObserver,
|
|
82
|
+
normalizeLanguageCode,
|
|
83
|
+
parseResource,
|
|
59
84
|
parseWithSchema,
|
|
85
|
+
readHeadTranslationConfig,
|
|
60
86
|
serializeToESIState,
|
|
87
|
+
setCachedTranslation,
|
|
61
88
|
setContextCookies,
|
|
62
89
|
supportsLinkPrefetch,
|
|
63
90
|
supportsSpeculationRules,
|
|
91
|
+
translateWithAIGateway,
|
|
64
92
|
updateGlobalESIState,
|
|
65
93
|
useESI,
|
|
66
94
|
useESIEmotionState,
|
|
@@ -68,10 +96,16 @@ import {
|
|
|
68
96
|
useESIInfer,
|
|
69
97
|
useESIPreferences,
|
|
70
98
|
useESITier,
|
|
71
|
-
useGlobalESIState
|
|
72
|
-
|
|
99
|
+
useGlobalESIState,
|
|
100
|
+
useTranslation,
|
|
101
|
+
useTranslationObserver,
|
|
102
|
+
useTranslationOptional
|
|
103
|
+
} from "../chunk-7zbxm162.js";
|
|
73
104
|
import"../chunk-tgx0r0vn.js";
|
|
74
105
|
export {
|
|
106
|
+
useTranslationOptional,
|
|
107
|
+
useTranslationObserver,
|
|
108
|
+
useTranslation,
|
|
75
109
|
useGlobalESIState,
|
|
76
110
|
useESITier,
|
|
77
111
|
useESIPreferences,
|
|
@@ -80,19 +114,33 @@ export {
|
|
|
80
114
|
useESIEmotionState,
|
|
81
115
|
useESI,
|
|
82
116
|
updateGlobalESIState,
|
|
117
|
+
translateWithAIGateway,
|
|
83
118
|
supportsSpeculationRules,
|
|
84
119
|
supportsLinkPrefetch,
|
|
85
120
|
setContextCookies,
|
|
121
|
+
setCachedTranslation,
|
|
86
122
|
serializeToESIState,
|
|
123
|
+
readHeadTranslationConfig,
|
|
87
124
|
parseWithSchema,
|
|
125
|
+
parseResource,
|
|
126
|
+
normalizeLanguageCode,
|
|
127
|
+
initTranslationObserver,
|
|
88
128
|
getToolSuggestions,
|
|
129
|
+
getSupportedLanguages,
|
|
130
|
+
getMostSpecificCapability,
|
|
131
|
+
getLanguageName,
|
|
132
|
+
getCachedTranslation,
|
|
133
|
+
generateTranslationCacheKey,
|
|
89
134
|
generateSchemaPrompt,
|
|
90
135
|
generateESIStateScriptFromContext,
|
|
91
136
|
generateESIStateScript,
|
|
137
|
+
formatResource,
|
|
138
|
+
filterAccessibleNodes,
|
|
92
139
|
extractUserContext,
|
|
93
140
|
evaluateTrigger,
|
|
94
141
|
esiWithContext,
|
|
95
142
|
esiVision,
|
|
143
|
+
esiTranslate,
|
|
96
144
|
esiMatch,
|
|
97
145
|
esiInfer,
|
|
98
146
|
esiIf,
|
|
@@ -101,18 +149,32 @@ export {
|
|
|
101
149
|
esiEmbed,
|
|
102
150
|
esiCyrano,
|
|
103
151
|
esiContext,
|
|
152
|
+
detectTargetLanguage,
|
|
153
|
+
createWildcardNodeCapability,
|
|
154
|
+
createTreeCapability,
|
|
104
155
|
createSpeculationHook,
|
|
156
|
+
createPathCapability,
|
|
157
|
+
createNodeWriteCapability,
|
|
158
|
+
createNodeReadCapability,
|
|
159
|
+
createNodeCapabilityVerifier,
|
|
105
160
|
createExhaustEntry,
|
|
106
161
|
createControlProcessor,
|
|
107
162
|
createContextMiddleware,
|
|
163
|
+
clearTranslationCache,
|
|
164
|
+
checkNodeAccess,
|
|
165
|
+
capabilityGrantsAccess,
|
|
108
166
|
autoInitSpeculation,
|
|
109
167
|
addSpeculationHeaders,
|
|
168
|
+
TranslationProvider,
|
|
169
|
+
TranslationObserver,
|
|
170
|
+
TranslationContext,
|
|
110
171
|
SpeculationManager,
|
|
111
172
|
HeuristicAdapter,
|
|
112
173
|
EdgeWorkersESIProcessor,
|
|
113
174
|
ESIWhen,
|
|
114
175
|
ESIVision,
|
|
115
176
|
ESIUnless,
|
|
177
|
+
ESITranslate,
|
|
116
178
|
ESITimeGate,
|
|
117
179
|
ESITierGate,
|
|
118
180
|
ESIStructured,
|