@hypen-space/core 0.4.3 → 0.4.5
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 +1 -1
- package/dist/app.d.ts +79 -22
- package/dist/app.js +111 -18
- package/dist/app.js.map +4 -4
- package/dist/components/builtin.js +114 -21
- package/dist/components/builtin.js.map +5 -5
- package/dist/discovery.d.ts +1 -1
- package/dist/discovery.js +112 -19
- package/dist/discovery.js.map +5 -5
- package/dist/engine.browser.d.ts +6 -0
- package/dist/engine.browser.js +192 -5
- package/dist/engine.browser.js.map +5 -4
- package/dist/engine.d.ts +6 -0
- package/dist/engine.js +192 -5
- package/dist/engine.js.map +5 -4
- package/dist/index.browser.d.ts +1 -1
- package/dist/index.browser.js +111 -18
- package/dist/index.browser.js.map +5 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +117 -21
- package/dist/index.js.map +6 -6
- package/dist/managed-router.d.ts +3 -4
- package/dist/remote/client.js +34 -2
- package/dist/remote/client.js.map +3 -3
- package/dist/remote/index.js +472 -26
- package/dist/remote/index.js.map +8 -7
- package/dist/remote/server.d.ts +46 -15
- package/dist/remote/server.js +472 -26
- package/dist/remote/server.js.map +8 -7
- package/dist/result.d.ts +18 -0
- package/package.json +1 -1
- package/src/app.ts +162 -41
- package/src/components/builtin.ts +3 -4
- package/src/discovery.ts +2 -2
- package/src/engine.browser.ts +27 -4
- package/src/engine.ts +27 -4
- package/src/index.browser.ts +0 -2
- package/src/index.ts +3 -2
- package/src/managed-router.ts +5 -6
- package/src/remote/server.ts +116 -21
- package/src/result.ts +48 -0
- package/wasm-browser/hypen_engine_bg.wasm +0 -0
- package/wasm-browser/package.json +1 -1
- package/wasm-node/hypen_engine_bg.wasm +0 -0
- package/wasm-node/package.json +1 -1
- package/dist/module-registry.d.ts +0 -42
- package/src/module-registry.ts +0 -76
package/dist/remote/server.d.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* RemoteServer - Stream Hypen apps over WebSocket with Session Management
|
|
3
3
|
*
|
|
4
|
-
* Usage:
|
|
4
|
+
* Usage with inline UI:
|
|
5
5
|
* ```typescript
|
|
6
6
|
* import { RemoteServer, app } from "@hypen-space/core";
|
|
7
7
|
*
|
|
8
8
|
* const counter = app
|
|
9
9
|
* .defineState({ count: 0 })
|
|
10
10
|
* .onAction("increment", ({ state }) => state.count++)
|
|
11
|
-
* .onDisconnect(async ({ state, session }) => {
|
|
12
|
-
* await redis.set(`session:${session.id}`, JSON.stringify(state));
|
|
13
|
-
* })
|
|
14
|
-
* .onReconnect(async ({ session, restore }) => {
|
|
15
|
-
* const saved = await redis.get(`session:${session.id}`);
|
|
16
|
-
* if (saved) restore(JSON.parse(saved));
|
|
17
|
-
* })
|
|
18
|
-
* .onExpire(async ({ session }) => {
|
|
19
|
-
* await redis.del(`session:${session.id}`);
|
|
20
|
-
* })
|
|
21
11
|
* .build();
|
|
22
12
|
*
|
|
23
13
|
* new RemoteServer()
|
|
24
14
|
* .module("Counter", counter)
|
|
25
15
|
* .ui(`Column { Text("Count: \${state.count}") }`)
|
|
26
|
-
* .session({ ttl: 3600, concurrent: "kick-old" })
|
|
27
16
|
* .listen(3000);
|
|
28
17
|
* ```
|
|
18
|
+
*
|
|
19
|
+
* Usage with directory-based discovery (auto-resolves imports):
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { RemoteServer } from "@hypen-space/core";
|
|
22
|
+
* import chatModule from "./apps/chat/Chat/component.js";
|
|
23
|
+
*
|
|
24
|
+
* await new RemoteServer()
|
|
25
|
+
* .source("./apps/chat")
|
|
26
|
+
* .module("Chat", chatModule)
|
|
27
|
+
* .listen(3001);
|
|
28
|
+
* ```
|
|
29
29
|
*/
|
|
30
30
|
import type { HypenModule } from "../app.js";
|
|
31
31
|
import type { RemoteMessage, RemoteClient, RemoteServerConfig, SessionConfig } from "./types.js";
|
|
@@ -36,6 +36,8 @@ export declare class RemoteServer {
|
|
|
36
36
|
private _module;
|
|
37
37
|
private _moduleName;
|
|
38
38
|
private _ui;
|
|
39
|
+
private _sourceDir;
|
|
40
|
+
private _discoveredComponents;
|
|
39
41
|
private _config;
|
|
40
42
|
private _sessionConfig;
|
|
41
43
|
private _onConnectionCallbacks;
|
|
@@ -52,6 +54,22 @@ export declare class RemoteServer {
|
|
|
52
54
|
* Set the UI DSL string
|
|
53
55
|
*/
|
|
54
56
|
ui(dsl: string): this;
|
|
57
|
+
/**
|
|
58
|
+
* Set a source directory for automatic component discovery.
|
|
59
|
+
*
|
|
60
|
+
* All .hypen and .ts components in the directory (and subdirectories) are
|
|
61
|
+
* discovered automatically. The entry component's template is used as the
|
|
62
|
+
* UI, so calling .ui() is optional when .source() is set.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* new RemoteServer()
|
|
67
|
+
* .source("./apps/chat")
|
|
68
|
+
* .module("Chat", chatModule)
|
|
69
|
+
* .listen(3001);
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
source(dir: string): this;
|
|
55
73
|
/**
|
|
56
74
|
* Set server configuration
|
|
57
75
|
*/
|
|
@@ -71,7 +89,7 @@ export declare class RemoteServer {
|
|
|
71
89
|
/**
|
|
72
90
|
* Start the WebSocket server
|
|
73
91
|
*/
|
|
74
|
-
listen(port?: number): this
|
|
92
|
+
listen(port?: number): Promise<this>;
|
|
75
93
|
/**
|
|
76
94
|
* Stop the server
|
|
77
95
|
*/
|
|
@@ -80,6 +98,18 @@ export declare class RemoteServer {
|
|
|
80
98
|
* Get the server URL
|
|
81
99
|
*/
|
|
82
100
|
get url(): string | null;
|
|
101
|
+
/**
|
|
102
|
+
* Discover components from the source directory.
|
|
103
|
+
* Populates _discoveredComponents and sets _ui from the entry component
|
|
104
|
+
* if not already set via .ui().
|
|
105
|
+
*/
|
|
106
|
+
private discoverFromSource;
|
|
107
|
+
/**
|
|
108
|
+
* Set up a component resolver on a client engine so that imports
|
|
109
|
+
* and component references in templates are resolved from discovered
|
|
110
|
+
* components.
|
|
111
|
+
*/
|
|
112
|
+
private setupComponentResolver;
|
|
83
113
|
/**
|
|
84
114
|
* Handle new WebSocket connection
|
|
85
115
|
* Waits for hello message before fully initializing
|
|
@@ -133,10 +163,11 @@ export declare class RemoteServer {
|
|
|
133
163
|
export declare function serve(options: {
|
|
134
164
|
module: HypenModule<any>;
|
|
135
165
|
moduleName?: string;
|
|
136
|
-
ui
|
|
166
|
+
ui?: string;
|
|
167
|
+
source?: string;
|
|
137
168
|
port?: number;
|
|
138
169
|
hostname?: string;
|
|
139
170
|
session?: SessionConfig;
|
|
140
171
|
onConnection?: (client: RemoteClient) => void;
|
|
141
172
|
onDisconnection?: (client: RemoteClient) => void;
|
|
142
|
-
}): RemoteServer
|
|
173
|
+
}): Promise<RemoteServer>;
|