@hypen-space/core 0.4.2 → 0.4.3
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/dist/app.d.ts +322 -0
- package/dist/components/builtin.d.ts +50 -0
- package/dist/context.d.ts +90 -0
- package/dist/discovery.d.ts +90 -0
- package/dist/discovery.js +10 -5
- package/dist/discovery.js.map +3 -3
- package/dist/disposable.d.ts +122 -0
- package/dist/engine.browser.d.ts +95 -0
- package/dist/engine.d.ts +79 -0
- package/dist/events.d.ts +78 -0
- package/dist/hypen.d.ts +127 -0
- package/dist/index.browser.d.ts +25 -0
- package/dist/index.browser.js +6 -2
- package/dist/index.browser.js.map +3 -3
- package/dist/index.d.ts +76 -0
- package/dist/index.js +238 -1196
- package/dist/index.js.map +7 -12
- package/dist/loader.d.ts +51 -0
- package/dist/logger.d.ts +141 -0
- package/dist/managed-router.d.ts +60 -0
- package/dist/module-registry.d.ts +42 -0
- package/dist/plugin.d.ts +39 -0
- package/dist/remote/client.d.ts +154 -0
- package/dist/remote/index.d.ts +13 -0
- package/dist/remote/server.d.ts +142 -0
- package/dist/remote/session.d.ts +115 -0
- package/dist/remote/types.d.ts +98 -0
- package/dist/renderer.d.ts +54 -0
- package/dist/renderer.js +6 -2
- package/dist/renderer.js.map +3 -3
- package/dist/resolver.d.ts +95 -0
- package/dist/result.d.ts +116 -0
- package/dist/retry.d.ts +150 -0
- package/dist/router.d.ts +94 -0
- package/dist/state.d.ts +42 -0
- package/dist/types.d.ts +30 -0
- package/package.json +2 -1
- package/wasm-browser/hypen_engine_bg.wasm +0 -0
- package/wasm-node/package.json +4 -2
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Management for Remote UI
|
|
3
|
+
*
|
|
4
|
+
* Manages session lifecycle including:
|
|
5
|
+
* - Creating new sessions
|
|
6
|
+
* - Suspending sessions on disconnect (pending reconnection)
|
|
7
|
+
* - Resuming sessions on reconnect
|
|
8
|
+
* - Expiring sessions after TTL
|
|
9
|
+
* - Handling concurrent connections
|
|
10
|
+
*/
|
|
11
|
+
import type { Session, SessionConfig } from "./types.js";
|
|
12
|
+
/**
|
|
13
|
+
* Internal representation of a pending (disconnected) session
|
|
14
|
+
*/
|
|
15
|
+
interface PendingSession {
|
|
16
|
+
session: Session;
|
|
17
|
+
savedState: unknown;
|
|
18
|
+
expiryTimer: ReturnType<typeof setTimeout>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Callback invoked when a session expires
|
|
22
|
+
*/
|
|
23
|
+
export type SessionExpireCallback = (session: Session) => void | Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Manages session lifecycle for remote UI connections
|
|
26
|
+
*/
|
|
27
|
+
export declare class SessionManager {
|
|
28
|
+
/** Active sessions (currently connected) */
|
|
29
|
+
private activeSessions;
|
|
30
|
+
/** Pending sessions (disconnected, waiting for reconnect within TTL) */
|
|
31
|
+
private pendingSessions;
|
|
32
|
+
/** Maps session ID to connected WebSocket(s) for concurrent handling */
|
|
33
|
+
private sessionConnections;
|
|
34
|
+
/** Resolved configuration with defaults */
|
|
35
|
+
private config;
|
|
36
|
+
constructor(config?: SessionConfig);
|
|
37
|
+
/**
|
|
38
|
+
* Get the configured TTL in seconds
|
|
39
|
+
*/
|
|
40
|
+
getTtl(): number;
|
|
41
|
+
/**
|
|
42
|
+
* Get the concurrent connection policy
|
|
43
|
+
*/
|
|
44
|
+
getConcurrentPolicy(): "kick-old" | "reject-new" | "allow-multiple";
|
|
45
|
+
/**
|
|
46
|
+
* Create a new session
|
|
47
|
+
*/
|
|
48
|
+
createSession(props?: Record<string, any>): Session;
|
|
49
|
+
/**
|
|
50
|
+
* Get an active (connected) session by ID
|
|
51
|
+
*/
|
|
52
|
+
getActiveSession(id: string): Session | null;
|
|
53
|
+
/**
|
|
54
|
+
* Get a pending (disconnected) session by ID
|
|
55
|
+
*/
|
|
56
|
+
getPendingSession(id: string): PendingSession | null;
|
|
57
|
+
/**
|
|
58
|
+
* Check if a session exists (either active or pending)
|
|
59
|
+
*/
|
|
60
|
+
hasSession(id: string): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Suspend a session when client disconnects
|
|
63
|
+
* Moves from active to pending with a TTL timer
|
|
64
|
+
*
|
|
65
|
+
* @param sessionId - The session to suspend
|
|
66
|
+
* @param savedState - State snapshot to restore on reconnect
|
|
67
|
+
* @param onExpire - Callback when TTL expires
|
|
68
|
+
*/
|
|
69
|
+
suspendSession(sessionId: string, savedState: unknown, onExpire: SessionExpireCallback): void;
|
|
70
|
+
/**
|
|
71
|
+
* Resume a pending session when client reconnects
|
|
72
|
+
*
|
|
73
|
+
* @param sessionId - The session to resume
|
|
74
|
+
* @returns Session and saved state, or null if not found/expired
|
|
75
|
+
*/
|
|
76
|
+
resumeSession(sessionId: string): {
|
|
77
|
+
session: Session;
|
|
78
|
+
savedState: unknown;
|
|
79
|
+
} | null;
|
|
80
|
+
/**
|
|
81
|
+
* Destroy a session completely (both active and pending)
|
|
82
|
+
*/
|
|
83
|
+
destroySession(sessionId: string): void;
|
|
84
|
+
/**
|
|
85
|
+
* Track a WebSocket connection for a session
|
|
86
|
+
* Used for concurrent connection handling
|
|
87
|
+
*/
|
|
88
|
+
trackConnection(sessionId: string, ws: unknown): void;
|
|
89
|
+
/**
|
|
90
|
+
* Untrack a WebSocket connection
|
|
91
|
+
*/
|
|
92
|
+
untrackConnection(sessionId: string, ws: unknown): void;
|
|
93
|
+
/**
|
|
94
|
+
* Get all connections for a session
|
|
95
|
+
*/
|
|
96
|
+
getConnections(sessionId: string): Set<unknown> | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* Get connection count for a session
|
|
99
|
+
*/
|
|
100
|
+
getConnectionCount(sessionId: string): number;
|
|
101
|
+
/**
|
|
102
|
+
* Get stats about current sessions
|
|
103
|
+
*/
|
|
104
|
+
getStats(): {
|
|
105
|
+
activeSessions: number;
|
|
106
|
+
pendingSessions: number;
|
|
107
|
+
totalConnections: number;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Clean up all sessions and timers
|
|
111
|
+
* Call this when shutting down the server
|
|
112
|
+
*/
|
|
113
|
+
destroy(): void;
|
|
114
|
+
}
|
|
115
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote UI Protocol Types
|
|
3
|
+
*/
|
|
4
|
+
import type { Patch } from "../types.js";
|
|
5
|
+
export type RemoteMessage = InitialTreeMessage | PatchMessage | StateUpdateMessage | DispatchActionMessage | HelloMessage | SessionAckMessage | SessionExpiredMessage;
|
|
6
|
+
export interface InitialTreeMessage {
|
|
7
|
+
type: "initialTree";
|
|
8
|
+
module: string;
|
|
9
|
+
state: any;
|
|
10
|
+
patches: Patch[];
|
|
11
|
+
revision: number;
|
|
12
|
+
}
|
|
13
|
+
export interface PatchMessage {
|
|
14
|
+
type: "patch";
|
|
15
|
+
module: string;
|
|
16
|
+
patches: Patch[];
|
|
17
|
+
revision: number;
|
|
18
|
+
}
|
|
19
|
+
export interface StateUpdateMessage {
|
|
20
|
+
type: "stateUpdate";
|
|
21
|
+
module: string;
|
|
22
|
+
state: any;
|
|
23
|
+
revision: number;
|
|
24
|
+
}
|
|
25
|
+
export interface DispatchActionMessage {
|
|
26
|
+
type: "dispatchAction";
|
|
27
|
+
module: string;
|
|
28
|
+
action: string;
|
|
29
|
+
payload?: any;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Client → Server: First message after WebSocket opens
|
|
33
|
+
* Used to establish or resume a session
|
|
34
|
+
*/
|
|
35
|
+
export interface HelloMessage {
|
|
36
|
+
type: "hello";
|
|
37
|
+
/** Session ID to resume (omit for new session) */
|
|
38
|
+
sessionId?: string;
|
|
39
|
+
/** Client metadata (platform, version, userId, etc.) */
|
|
40
|
+
props?: Record<string, any>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Server → Client: Response to HelloMessage
|
|
44
|
+
* Confirms session establishment
|
|
45
|
+
*/
|
|
46
|
+
export interface SessionAckMessage {
|
|
47
|
+
type: "sessionAck";
|
|
48
|
+
/** The session ID (generated or resumed) */
|
|
49
|
+
sessionId: string;
|
|
50
|
+
/** True if this is a new session */
|
|
51
|
+
isNew: boolean;
|
|
52
|
+
/** True if state was restored from a previous session */
|
|
53
|
+
isRestored: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Server → Client: Session termination notification
|
|
57
|
+
* Sent when session is kicked or expires
|
|
58
|
+
*/
|
|
59
|
+
export interface SessionExpiredMessage {
|
|
60
|
+
type: "sessionExpired";
|
|
61
|
+
sessionId: string;
|
|
62
|
+
reason: "ttl" | "kicked" | "manual";
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Session information passed to lifecycle hooks
|
|
66
|
+
*/
|
|
67
|
+
export interface Session {
|
|
68
|
+
/** Unique session identifier */
|
|
69
|
+
id: string;
|
|
70
|
+
/** Time-to-live in seconds */
|
|
71
|
+
ttl: number;
|
|
72
|
+
/** When the session was first created */
|
|
73
|
+
createdAt: Date;
|
|
74
|
+
/** When the client last connected */
|
|
75
|
+
lastConnectedAt: Date;
|
|
76
|
+
/** Client-provided metadata */
|
|
77
|
+
props?: Record<string, any>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Configuration for session management
|
|
81
|
+
*/
|
|
82
|
+
export interface SessionConfig {
|
|
83
|
+
/** Session TTL in seconds (default: 3600 = 1 hour) */
|
|
84
|
+
ttl?: number;
|
|
85
|
+
/** How to handle concurrent connections with same sessionId */
|
|
86
|
+
concurrent?: "kick-old" | "reject-new" | "allow-multiple";
|
|
87
|
+
/** Custom session ID generator */
|
|
88
|
+
generateId?: () => string;
|
|
89
|
+
}
|
|
90
|
+
export interface RemoteClient {
|
|
91
|
+
id: string;
|
|
92
|
+
socket: any;
|
|
93
|
+
connectedAt: Date;
|
|
94
|
+
}
|
|
95
|
+
export interface RemoteServerConfig {
|
|
96
|
+
port?: number;
|
|
97
|
+
hostname?: string;
|
|
98
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renderer abstraction interface
|
|
3
|
+
*
|
|
4
|
+
* Renderers are pluggable and can be implemented for different platforms
|
|
5
|
+
* (DOM, Canvas, Native, etc.)
|
|
6
|
+
*/
|
|
7
|
+
import type { Patch } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Renderer interface that all platform renderers must implement
|
|
10
|
+
*/
|
|
11
|
+
export interface Renderer {
|
|
12
|
+
/**
|
|
13
|
+
* Apply a batch of patches to the render tree
|
|
14
|
+
*/
|
|
15
|
+
applyPatches(patches: Patch[]): void;
|
|
16
|
+
/**
|
|
17
|
+
* Get a node by its ID (optional, for debugging)
|
|
18
|
+
*/
|
|
19
|
+
getNode?(id: string): any;
|
|
20
|
+
/**
|
|
21
|
+
* Clear the entire render tree
|
|
22
|
+
*/
|
|
23
|
+
clear?(): void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Base renderer class with common utilities
|
|
27
|
+
*/
|
|
28
|
+
export declare abstract class BaseRenderer implements Renderer {
|
|
29
|
+
protected nodes: Map<string, any>;
|
|
30
|
+
abstract applyPatches(patches: Patch[]): void;
|
|
31
|
+
getNode(id: string): any;
|
|
32
|
+
clear(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Apply a single patch
|
|
35
|
+
*/
|
|
36
|
+
protected applyPatch(patch: Patch): void;
|
|
37
|
+
/**
|
|
38
|
+
* Platform-specific patch handlers
|
|
39
|
+
*/
|
|
40
|
+
protected abstract onCreate(id: string, elementType: string, props: Record<string, any>): void;
|
|
41
|
+
protected abstract onSetProp(id: string, name: string, value: any): void;
|
|
42
|
+
protected abstract onSetText(id: string, text: string): void;
|
|
43
|
+
protected abstract onInsert(parentId: string, id: string, beforeId?: string): void;
|
|
44
|
+
protected abstract onMove(parentId: string, id: string, beforeId?: string): void;
|
|
45
|
+
protected abstract onRemove(id: string): void;
|
|
46
|
+
protected abstract onAttachEvent(id: string, eventName: string): void;
|
|
47
|
+
protected abstract onDetachEvent(id: string, eventName: string): void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Console/Debug renderer that logs patches
|
|
51
|
+
*/
|
|
52
|
+
export declare class ConsoleRenderer implements Renderer {
|
|
53
|
+
applyPatches(patches: Patch[]): void;
|
|
54
|
+
}
|
package/dist/renderer.js
CHANGED
|
@@ -270,7 +270,11 @@ class BaseRenderer {
|
|
|
270
270
|
|
|
271
271
|
class ConsoleRenderer {
|
|
272
272
|
applyPatches(patches) {
|
|
273
|
-
|
|
273
|
+
console.group("Hypen Patches");
|
|
274
|
+
for (const patch of patches) {
|
|
275
|
+
console.log(patch);
|
|
276
|
+
}
|
|
277
|
+
console.groupEnd();
|
|
274
278
|
}
|
|
275
279
|
}
|
|
276
280
|
export {
|
|
@@ -278,4 +282,4 @@ export {
|
|
|
278
282
|
BaseRenderer
|
|
279
283
|
};
|
|
280
284
|
|
|
281
|
-
//# debugId=
|
|
285
|
+
//# debugId=1A339EED8B6121F964756E2164756E21
|
package/dist/renderer.js.map
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
"sources": ["../src/logger.ts", "../src/renderer.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"/**\n * Configurable Debug Logger\n *\n * Provides environment-aware logging that can be disabled in production.\n * Supports log levels, tagged output, and performance timing.\n */\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\" | \"none\";\n\nexport interface LoggerConfig {\n /** Minimum log level (default: \"debug\" in dev, \"error\" in prod) */\n level: LogLevel;\n /** Enable colored output (default: true) */\n colors: boolean;\n /** Include timestamps (default: false) */\n timestamps: boolean;\n /** Custom log handler (default: console) */\n handler?: LogHandler;\n}\n\nexport interface LogHandler {\n debug(tag: string, ...args: unknown[]): void;\n info(tag: string, ...args: unknown[]): void;\n warn(tag: string, ...args: unknown[]): void;\n error(tag: string, ...args: unknown[]): void;\n}\n\n// ============================================================================\n// Constants\n// ============================================================================\n\nconst LOG_LEVEL_ORDER: Record<LogLevel, number> = {\n debug: 0,\n info: 1,\n warn: 2,\n error: 3,\n none: 4,\n};\n\nconst LOG_LEVEL_COLORS: Record<Exclude<LogLevel, \"none\">, string> = {\n debug: \"\\x1b[36m\", // Cyan\n info: \"\\x1b[32m\", // Green\n warn: \"\\x1b[33m\", // Yellow\n error: \"\\x1b[31m\", // Red\n};\n\nconst RESET_COLOR = \"\\x1b[0m\";\n\n// ============================================================================\n// Global Configuration\n// ============================================================================\n\n/**\n * Detect if running in production environment\n */\nfunction isProduction(): boolean {\n if (typeof process !== \"undefined\" && process.env) {\n return process.env.NODE_ENV === \"production\";\n }\n return false;\n}\n\n/**\n * Default configuration\n */\nlet config: LoggerConfig = {\n level: isProduction() ? \"error\" : \"debug\",\n colors: true,\n timestamps: false,\n};\n\n// ============================================================================\n// Configuration API\n// ============================================================================\n\n/**\n * Set the global log level\n */\nexport function setLogLevel(level: LogLevel): void {\n config.level = level;\n}\n\n/**\n * Get the current log level\n */\nexport function getLogLevel(): LogLevel {\n return config.level;\n}\n\n/**\n * Configure the logger\n */\nexport function configureLogger(options: Partial<LoggerConfig>): void {\n config = { ...config, ...options };\n}\n\n/**\n * Enable all logging (sets level to \"debug\")\n */\nexport function enableLogging(): void {\n config.level = \"debug\";\n}\n\n/**\n * Disable all logging (sets level to \"none\")\n */\nexport function disableLogging(): void {\n config.level = \"none\";\n}\n\n/**\n * Enable debug mode - alias for enableLogging()\n * Call this at app startup to see all debug logs\n *\n * @example\n * ```typescript\n * import { setDebugMode } from \"@hypen-space/core\";\n * setDebugMode(true);\n * ```\n */\nexport function setDebugMode(enabled: boolean): void {\n config.level = enabled ? \"debug\" : \"error\";\n}\n\n/**\n * Check if debug mode is enabled\n */\nexport function isDebugMode(): boolean {\n return config.level === \"debug\";\n}\n\n// ============================================================================\n// Utility Functions\n// ============================================================================\n\nfunction shouldLog(level: LogLevel): boolean {\n return LOG_LEVEL_ORDER[level] >= LOG_LEVEL_ORDER[config.level];\n}\n\nfunction formatTag(tag: string, level: LogLevel): string {\n const timestamp = config.timestamps ? `${new Date().toISOString()} ` : \"\";\n\n if (config.colors && level !== \"none\") {\n const color = LOG_LEVEL_COLORS[level as Exclude<LogLevel, \"none\">];\n return `${timestamp}${color}[${tag}]${RESET_COLOR}`;\n }\n\n return `${timestamp}[${tag}]`;\n}\n\n// ============================================================================\n// Logger Class\n// ============================================================================\n\n/**\n * Tagged logger instance\n *\n * @example\n * ```typescript\n * const log = createLogger(\"MyComponent\");\n * log.debug(\"initialized with\", { props });\n * log.error(\"failed to load\", error);\n * ```\n */\nexport class Logger {\n private readonly tag: string;\n\n constructor(tag: string) {\n this.tag = tag;\n }\n\n debug(...args: unknown[]): void {\n if (!shouldLog(\"debug\")) return;\n\n if (config.handler) {\n config.handler.debug(this.tag, ...args);\n } else {\n console.log(formatTag(this.tag, \"debug\"), ...args);\n }\n }\n\n info(...args: unknown[]): void {\n if (!shouldLog(\"info\")) return;\n\n if (config.handler) {\n config.handler.info(this.tag, ...args);\n } else {\n console.info(formatTag(this.tag, \"info\"), ...args);\n }\n }\n\n warn(...args: unknown[]): void {\n if (!shouldLog(\"warn\")) return;\n\n if (config.handler) {\n config.handler.warn(this.tag, ...args);\n } else {\n console.warn(formatTag(this.tag, \"warn\"), ...args);\n }\n }\n\n error(...args: unknown[]): void {\n if (!shouldLog(\"error\")) return;\n\n if (config.handler) {\n config.handler.error(this.tag, ...args);\n } else {\n console.error(formatTag(this.tag, \"error\"), ...args);\n }\n }\n\n /**\n * Time a function execution\n */\n time<T>(label: string, fn: () => T): T {\n if (!shouldLog(\"debug\")) {\n return fn();\n }\n\n const start = performance.now();\n try {\n return fn();\n } finally {\n const duration = performance.now() - start;\n this.debug(`${label}: ${duration.toFixed(2)}ms`);\n }\n }\n\n /**\n * Time an async function execution\n */\n async timeAsync<T>(label: string, fn: () => Promise<T>): Promise<T> {\n if (!shouldLog(\"debug\")) {\n return fn();\n }\n\n const start = performance.now();\n try {\n return await fn();\n } finally {\n const duration = performance.now() - start;\n this.debug(`${label}: ${duration.toFixed(2)}ms`);\n }\n }\n\n /**\n * Create a child logger with additional context\n */\n child(subTag: string): Logger {\n return new Logger(`${this.tag}:${subTag}`);\n }\n\n /**\n * Conditionally log based on a condition\n */\n debugIf(condition: boolean, ...args: unknown[]): void {\n if (condition) this.debug(...args);\n }\n\n warnIf(condition: boolean, ...args: unknown[]): void {\n if (condition) this.warn(...args);\n }\n\n errorIf(condition: boolean, ...args: unknown[]): void {\n if (condition) this.error(...args);\n }\n\n /**\n * Log once (useful for deprecation warnings)\n */\n private loggedOnce = new Set<string>();\n\n warnOnce(key: string, ...args: unknown[]): void {\n if (this.loggedOnce.has(key)) return;\n this.loggedOnce.add(key);\n this.warn(...args);\n }\n\n debugOnce(key: string, ...args: unknown[]): void {\n if (this.loggedOnce.has(key)) return;\n this.loggedOnce.add(key);\n this.debug(...args);\n }\n}\n\n// ============================================================================\n// Factory Functions\n// ============================================================================\n\n/**\n * Create a tagged logger\n *\n * @example\n * ```typescript\n * const log = createLogger(\"Router\");\n * log.info(\"navigating to\", path);\n * ```\n */\nexport function createLogger(tag: string): Logger {\n return new Logger(tag);\n}\n\n// ============================================================================\n// Default Logger Instance\n// ============================================================================\n\n/**\n * Default logger for general use\n */\nexport const logger = createLogger(\"Hypen\");\n\n// ============================================================================\n// Shorthand Functions (untagged)\n// ============================================================================\n\n/**\n * Shorthand logging functions for quick use\n * Prefer createLogger() for component-specific logging\n */\nexport const log = {\n debug: (tag: string, ...args: unknown[]): void => {\n if (!shouldLog(\"debug\")) return;\n console.log(formatTag(tag, \"debug\"), ...args);\n },\n\n info: (tag: string, ...args: unknown[]): void => {\n if (!shouldLog(\"info\")) return;\n console.info(formatTag(tag, \"info\"), ...args);\n },\n\n warn: (tag: string, ...args: unknown[]): void => {\n if (!shouldLog(\"warn\")) return;\n console.warn(formatTag(tag, \"warn\"), ...args);\n },\n\n error: (tag: string, ...args: unknown[]): void => {\n if (!shouldLog(\"error\")) return;\n console.error(formatTag(tag, \"error\"), ...args);\n },\n};\n\n// ============================================================================\n// Predefined Loggers for Framework Components\n// ============================================================================\n\nexport const frameworkLoggers = {\n hypen: createLogger(\"Hypen\"),\n engine: createLogger(\"Engine\"),\n router: createLogger(\"Router\"),\n state: createLogger(\"State\"),\n events: createLogger(\"Events\"),\n remote: createLogger(\"Remote\"),\n renderer: createLogger(\"Renderer\"),\n module: createLogger(\"Module\"),\n lifecycle: createLogger(\"Lifecycle\"),\n loader: createLogger(\"Loader\"),\n context: createLogger(\"Context\"),\n discovery: createLogger(\"Discovery\"),\n plugin: createLogger(\"Plugin\"),\n canvas: createLogger(\"Canvas\"),\n debug: createLogger(\"Debug\"),\n};\n",
|
|
6
|
-
"/**\n * Renderer abstraction interface\n *\n * Renderers are pluggable and can be implemented for different platforms\n * (DOM, Canvas, Native, etc.)\n */\n\nimport type { Patch } from \"./types.js\";\nimport { frameworkLoggers } from \"./logger.js\";\n\nconst log = frameworkLoggers.renderer;\n\n/**\n * Renderer interface that all platform renderers must implement\n */\nexport interface Renderer {\n /**\n * Apply a batch of patches to the render tree\n */\n applyPatches(patches: Patch[]): void;\n\n /**\n * Get a node by its ID (optional, for debugging)\n */\n getNode?(id: string): any;\n\n /**\n * Clear the entire render tree\n */\n clear?(): void;\n}\n\n/**\n * Base renderer class with common utilities\n */\nexport abstract class BaseRenderer implements Renderer {\n protected nodes: Map<string, any> = new Map();\n\n abstract applyPatches(patches: Patch[]): void;\n\n getNode(id: string): any {\n return this.nodes.get(id);\n }\n\n clear(): void {\n this.nodes.clear();\n }\n\n /**\n * Apply a single patch\n */\n protected applyPatch(patch: Patch): void {\n switch (patch.type) {\n case \"create\":\n this.onCreate(patch.id!, patch.elementType!, patch.props || {});\n break;\n case \"setProp\":\n this.onSetProp(patch.id!, patch.name!, patch.value);\n break;\n case \"setText\":\n this.onSetText(patch.id!, patch.text!);\n break;\n case \"insert\":\n this.onInsert(patch.parentId!, patch.id!, patch.beforeId);\n break;\n case \"move\":\n this.onMove(patch.parentId!, patch.id!, patch.beforeId);\n break;\n case \"remove\":\n this.onRemove(patch.id!);\n break;\n case \"attachEvent\":\n this.onAttachEvent(patch.id!, patch.eventName!);\n break;\n case \"detachEvent\":\n this.onDetachEvent(patch.id!, patch.eventName!);\n break;\n }\n }\n\n /**\n * Platform-specific patch handlers\n */\n protected abstract onCreate(id: string, elementType: string, props: Record<string, any>): void;\n protected abstract onSetProp(id: string, name: string, value: any): void;\n protected abstract onSetText(id: string, text: string): void;\n protected abstract onInsert(parentId: string, id: string, beforeId?: string): void;\n protected abstract onMove(parentId: string, id: string, beforeId?: string): void;\n protected abstract onRemove(id: string): void;\n protected abstract onAttachEvent(id: string, eventName: string): void;\n protected abstract onDetachEvent(id: string, eventName: string): void;\n}\n\n/**\n * Console/Debug renderer that logs patches\n */\nexport class ConsoleRenderer implements Renderer {\n applyPatches(patches: Patch[]): void {\n
|
|
6
|
+
"/**\n * Renderer abstraction interface\n *\n * Renderers are pluggable and can be implemented for different platforms\n * (DOM, Canvas, Native, etc.)\n */\n\nimport type { Patch } from \"./types.js\";\nimport { frameworkLoggers } from \"./logger.js\";\n\nconst log = frameworkLoggers.renderer;\n\n/**\n * Renderer interface that all platform renderers must implement\n */\nexport interface Renderer {\n /**\n * Apply a batch of patches to the render tree\n */\n applyPatches(patches: Patch[]): void;\n\n /**\n * Get a node by its ID (optional, for debugging)\n */\n getNode?(id: string): any;\n\n /**\n * Clear the entire render tree\n */\n clear?(): void;\n}\n\n/**\n * Base renderer class with common utilities\n */\nexport abstract class BaseRenderer implements Renderer {\n protected nodes: Map<string, any> = new Map();\n\n abstract applyPatches(patches: Patch[]): void;\n\n getNode(id: string): any {\n return this.nodes.get(id);\n }\n\n clear(): void {\n this.nodes.clear();\n }\n\n /**\n * Apply a single patch\n */\n protected applyPatch(patch: Patch): void {\n switch (patch.type) {\n case \"create\":\n this.onCreate(patch.id!, patch.elementType!, patch.props || {});\n break;\n case \"setProp\":\n this.onSetProp(patch.id!, patch.name!, patch.value);\n break;\n case \"setText\":\n this.onSetText(patch.id!, patch.text!);\n break;\n case \"insert\":\n this.onInsert(patch.parentId!, patch.id!, patch.beforeId);\n break;\n case \"move\":\n this.onMove(patch.parentId!, patch.id!, patch.beforeId);\n break;\n case \"remove\":\n this.onRemove(patch.id!);\n break;\n case \"attachEvent\":\n this.onAttachEvent(patch.id!, patch.eventName!);\n break;\n case \"detachEvent\":\n this.onDetachEvent(patch.id!, patch.eventName!);\n break;\n }\n }\n\n /**\n * Platform-specific patch handlers\n */\n protected abstract onCreate(id: string, elementType: string, props: Record<string, any>): void;\n protected abstract onSetProp(id: string, name: string, value: any): void;\n protected abstract onSetText(id: string, text: string): void;\n protected abstract onInsert(parentId: string, id: string, beforeId?: string): void;\n protected abstract onMove(parentId: string, id: string, beforeId?: string): void;\n protected abstract onRemove(id: string): void;\n protected abstract onAttachEvent(id: string, eventName: string): void;\n protected abstract onDetachEvent(id: string, eventName: string): void;\n}\n\n/**\n * Console/Debug renderer that logs patches\n */\nexport class ConsoleRenderer implements Renderer {\n applyPatches(patches: Patch[]): void {\n console.group(\"Hypen Patches\");\n for (const patch of patches) {\n console.log(patch);\n }\n console.groupEnd();\n }\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,SAAS,YAAY,GAAY;AAAA,EAC/B,IAAI,OAAO,YAAY,eAAe,QAAQ,KAAK;AAAA,IACjD,OAAO;AAAA,EACT;AAAA,EACA,OAAO;AAAA;AAmBF,SAAS,WAAW,CAAC,OAAuB;AAAA,EACjD,OAAO,QAAQ;AAAA;AAMV,SAAS,WAAW,GAAa;AAAA,EACtC,OAAO,OAAO;AAAA;AAMT,SAAS,eAAe,CAAC,SAAsC;AAAA,EACpE,SAAS,KAAK,WAAW,QAAQ;AAAA;AAM5B,SAAS,a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0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Resolver
|
|
3
|
+
* Resolves component imports from local paths or web URLs
|
|
4
|
+
*/
|
|
5
|
+
export interface ImportStatement {
|
|
6
|
+
clause: ImportClause;
|
|
7
|
+
source: ImportSource;
|
|
8
|
+
}
|
|
9
|
+
export type ImportClause = {
|
|
10
|
+
type: "named";
|
|
11
|
+
names: string[];
|
|
12
|
+
} | {
|
|
13
|
+
type: "default";
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
16
|
+
export type ImportSource = {
|
|
17
|
+
type: "local";
|
|
18
|
+
path: string;
|
|
19
|
+
} | {
|
|
20
|
+
type: "url";
|
|
21
|
+
url: string;
|
|
22
|
+
};
|
|
23
|
+
export interface ComponentDefinition {
|
|
24
|
+
module: any;
|
|
25
|
+
template: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ResolverOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Base directory for resolving relative local paths
|
|
30
|
+
* Defaults to current working directory
|
|
31
|
+
*/
|
|
32
|
+
baseDir?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Cache resolved components to avoid re-fetching
|
|
35
|
+
* Defaults to true
|
|
36
|
+
*/
|
|
37
|
+
cache?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Custom fetch function for URL imports
|
|
40
|
+
* Useful for adding authentication, custom headers, etc.
|
|
41
|
+
*/
|
|
42
|
+
customFetch?: (url: string) => Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Module registry for looking up pre-registered module definitions.
|
|
45
|
+
* When set, the resolver will check the registry before doing file I/O.
|
|
46
|
+
*/
|
|
47
|
+
moduleRegistry?: {
|
|
48
|
+
has: (name: string) => boolean;
|
|
49
|
+
get: (name: string) => any;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Component Resolver
|
|
54
|
+
* Resolves and loads components from local files or remote URLs
|
|
55
|
+
*/
|
|
56
|
+
export declare class ComponentResolver {
|
|
57
|
+
private cache;
|
|
58
|
+
private options;
|
|
59
|
+
private moduleRegistry?;
|
|
60
|
+
constructor(options?: ResolverOptions);
|
|
61
|
+
/**
|
|
62
|
+
* Resolve a component from an import statement.
|
|
63
|
+
* Checks the module registry first (if available), then falls back to file I/O.
|
|
64
|
+
*/
|
|
65
|
+
resolve(importStmt: ImportStatement): Promise<Record<string, ComponentDefinition>>;
|
|
66
|
+
/**
|
|
67
|
+
* Resolve a component from a local file path
|
|
68
|
+
*/
|
|
69
|
+
private resolveLocal;
|
|
70
|
+
/**
|
|
71
|
+
* Resolve a component from a URL
|
|
72
|
+
*/
|
|
73
|
+
private resolveUrl;
|
|
74
|
+
/**
|
|
75
|
+
* Default fetch implementation
|
|
76
|
+
*/
|
|
77
|
+
private defaultFetch;
|
|
78
|
+
/**
|
|
79
|
+
* Extract the requested components based on the import clause
|
|
80
|
+
*/
|
|
81
|
+
private extractComponents;
|
|
82
|
+
/**
|
|
83
|
+
* Get the source path as a string (for caching)
|
|
84
|
+
*/
|
|
85
|
+
private getSourcePath;
|
|
86
|
+
/**
|
|
87
|
+
* Clear the component cache
|
|
88
|
+
*/
|
|
89
|
+
clearCache(): void;
|
|
90
|
+
/**
|
|
91
|
+
* Parse import statements from Hypen DSL text
|
|
92
|
+
* This is a simple parser that extracts import statements
|
|
93
|
+
*/
|
|
94
|
+
static parseImports(text: string): ImportStatement[];
|
|
95
|
+
}
|
package/dist/result.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result Type for Error Handling
|
|
3
|
+
*
|
|
4
|
+
* A lightweight Result type for explicit error handling without exceptions.
|
|
5
|
+
* Provides type-safe error propagation and composition.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Represents either a successful value or an error
|
|
9
|
+
*/
|
|
10
|
+
export type Result<T, E = Error> = {
|
|
11
|
+
readonly ok: true;
|
|
12
|
+
readonly value: T;
|
|
13
|
+
} | {
|
|
14
|
+
readonly ok: false;
|
|
15
|
+
readonly error: E;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Create a successful Result
|
|
19
|
+
*/
|
|
20
|
+
export declare function Ok<T>(value: T): Result<T, never>;
|
|
21
|
+
/**
|
|
22
|
+
* Create a failed Result
|
|
23
|
+
*/
|
|
24
|
+
export declare function Err<E>(error: E): Result<never, E>;
|
|
25
|
+
/**
|
|
26
|
+
* Check if a Result is Ok
|
|
27
|
+
*/
|
|
28
|
+
export declare function isOk<T, E>(result: Result<T, E>): result is {
|
|
29
|
+
ok: true;
|
|
30
|
+
value: T;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Check if a Result is Err
|
|
34
|
+
*/
|
|
35
|
+
export declare function isErr<T, E>(result: Result<T, E>): result is {
|
|
36
|
+
ok: false;
|
|
37
|
+
error: E;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Wrap a Promise in a Result, catching any thrown errors
|
|
41
|
+
*/
|
|
42
|
+
export declare function fromPromise<T, E = Error>(promise: Promise<T>, mapError?: (e: unknown) => E): Promise<Result<T, E>>;
|
|
43
|
+
/**
|
|
44
|
+
* Wrap a synchronous function in a Result, catching any thrown errors
|
|
45
|
+
*/
|
|
46
|
+
export declare function fromTry<T, E = Error>(fn: () => T, mapError?: (e: unknown) => E): Result<T, E>;
|
|
47
|
+
/**
|
|
48
|
+
* Map over a successful Result value
|
|
49
|
+
*/
|
|
50
|
+
export declare function map<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E>;
|
|
51
|
+
/**
|
|
52
|
+
* Map over a failed Result error
|
|
53
|
+
*/
|
|
54
|
+
export declare function mapErr<T, E, F>(result: Result<T, E>, fn: (error: E) => F): Result<T, F>;
|
|
55
|
+
/**
|
|
56
|
+
* Chain Results together (flatMap)
|
|
57
|
+
*/
|
|
58
|
+
export declare function flatMap<T, U, E>(result: Result<T, E>, fn: (value: T) => Result<U, E>): Result<U, E>;
|
|
59
|
+
/**
|
|
60
|
+
* Unwrap a Result, throwing if it's an error
|
|
61
|
+
*/
|
|
62
|
+
export declare function unwrap<T, E>(result: Result<T, E>): T;
|
|
63
|
+
/**
|
|
64
|
+
* Unwrap a Result with a default value
|
|
65
|
+
*/
|
|
66
|
+
export declare function unwrapOr<T, E>(result: Result<T, E>, defaultValue: T): T;
|
|
67
|
+
/**
|
|
68
|
+
* Unwrap a Result with a lazy default value
|
|
69
|
+
*/
|
|
70
|
+
export declare function unwrapOrElse<T, E>(result: Result<T, E>, fn: (error: E) => T): T;
|
|
71
|
+
/**
|
|
72
|
+
* Match on a Result, providing handlers for both cases
|
|
73
|
+
*/
|
|
74
|
+
export declare function match<T, E, U>(result: Result<T, E>, handlers: {
|
|
75
|
+
ok: (value: T) => U;
|
|
76
|
+
err: (error: E) => U;
|
|
77
|
+
}): U;
|
|
78
|
+
/**
|
|
79
|
+
* Combine multiple Results into a single Result containing an array
|
|
80
|
+
* Returns the first error encountered, or Ok with all values
|
|
81
|
+
*/
|
|
82
|
+
export declare function all<T, E>(results: Result<T, E>[]): Result<T[], E>;
|
|
83
|
+
/**
|
|
84
|
+
* Base class for typed errors with context
|
|
85
|
+
*/
|
|
86
|
+
export declare class HypenError extends Error {
|
|
87
|
+
readonly code: string;
|
|
88
|
+
readonly context?: Record<string, unknown>;
|
|
89
|
+
readonly cause?: Error;
|
|
90
|
+
constructor(code: string, message: string, options?: {
|
|
91
|
+
context?: Record<string, unknown>;
|
|
92
|
+
cause?: Error;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Error thrown when an action handler fails
|
|
97
|
+
*/
|
|
98
|
+
export declare class ActionError extends HypenError {
|
|
99
|
+
readonly actionName: string;
|
|
100
|
+
constructor(actionName: string, cause?: unknown);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Error thrown when a connection fails
|
|
104
|
+
*/
|
|
105
|
+
export declare class ConnectionError extends HypenError {
|
|
106
|
+
readonly url: string;
|
|
107
|
+
readonly attempt?: number;
|
|
108
|
+
constructor(url: string, cause?: unknown, attempt?: number);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Error thrown when state operations fail
|
|
112
|
+
*/
|
|
113
|
+
export declare class StateError extends HypenError {
|
|
114
|
+
readonly path?: string;
|
|
115
|
+
constructor(message: string, path?: string, cause?: unknown);
|
|
116
|
+
}
|