@hypen-space/core 0.4.24 → 0.4.26

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.
Files changed (47) hide show
  1. package/dist/app.js +1 -16
  2. package/dist/app.js.map +2 -2
  3. package/dist/components/builtin.js +1 -16
  4. package/dist/components/builtin.js.map +2 -2
  5. package/dist/context.js +1 -16
  6. package/dist/context.js.map +2 -2
  7. package/dist/discovery.js +1 -16
  8. package/dist/discovery.js.map +2 -2
  9. package/dist/disposable.js +1 -16
  10. package/dist/disposable.js.map +2 -2
  11. package/dist/engine.browser.js +1 -16
  12. package/dist/engine.browser.js.map +2 -2
  13. package/dist/engine.js +1 -16
  14. package/dist/engine.js.map +2 -2
  15. package/dist/events.js +1 -16
  16. package/dist/events.js.map +2 -2
  17. package/dist/index.browser.js +1 -16
  18. package/dist/index.browser.js.map +2 -2
  19. package/dist/index.js +1 -16
  20. package/dist/index.js.map +2 -2
  21. package/dist/loader.js +1 -16
  22. package/dist/loader.js.map +2 -2
  23. package/dist/logger.js +1 -16
  24. package/dist/logger.js.map +2 -2
  25. package/dist/plugin.js +4 -19
  26. package/dist/plugin.js.map +3 -3
  27. package/dist/remote/client.js +1 -16
  28. package/dist/remote/client.js.map +2 -2
  29. package/dist/remote/index.js +37 -19
  30. package/dist/remote/index.js.map +4 -4
  31. package/dist/remote/server.d.ts +15 -0
  32. package/dist/remote/server.js +37 -19
  33. package/dist/remote/server.js.map +4 -4
  34. package/dist/renderer.js +1 -16
  35. package/dist/renderer.js.map +2 -2
  36. package/dist/resolver.js +4 -19
  37. package/dist/resolver.js.map +3 -3
  38. package/dist/router.js +1 -16
  39. package/dist/router.js.map +2 -2
  40. package/dist/state.js +1 -16
  41. package/dist/state.js.map +2 -2
  42. package/package.json +1 -1
  43. package/src/remote/server.ts +54 -0
  44. package/wasm-browser/hypen_engine_bg.wasm +0 -0
  45. package/wasm-browser/package.json +1 -1
  46. package/wasm-node/hypen_engine_bg.wasm +0 -0
  47. package/wasm-node/package.json +1 -1
@@ -46,6 +46,7 @@ export declare class RemoteServer {
46
46
  private nextClientId;
47
47
  private server;
48
48
  private sessionManager;
49
+ private _syncActions;
49
50
  /**
50
51
  * Set the module for this app
51
52
  */
@@ -78,6 +79,12 @@ export declare class RemoteServer {
78
79
  * Configure session management
79
80
  */
80
81
  session(config: SessionConfig): this;
82
+ /**
83
+ * Enable action synchronization across all connected clients.
84
+ * When enabled, an action dispatched by any client is also dispatched
85
+ * to every other client's engine, keeping all clients in sync.
86
+ */
87
+ syncActions(): this;
81
88
  /**
82
89
  * Register connection callback
83
90
  */
@@ -140,6 +147,14 @@ export declare class RemoteServer {
140
147
  * Handle WebSocket close - suspend session instead of destroying
141
148
  */
142
149
  private handleClose;
150
+ /**
151
+ * Reload components from the source directory and re-render all connected clients.
152
+ * Call this when source files change to implement hot reload.
153
+ *
154
+ * The engine's reconciler diffs the old tree against the new one, producing
155
+ * minimal patches (Create/Remove/SetProp) that are streamed to clients.
156
+ */
157
+ reload(): Promise<void>;
143
158
  /**
144
159
  * Get current client count
145
160
  */
@@ -1,19 +1,4 @@
1
- var __create = Object.create;
2
- var __getProtoOf = Object.getPrototypeOf;
3
1
  var __defProp = Object.defineProperty;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __toESM = (mod, isNodeMode, target) => {
7
- target = mod != null ? __create(__getProtoOf(mod)) : {};
8
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
9
- for (let key of __getOwnPropNames(mod))
10
- if (!__hasOwnProp.call(to, key))
11
- __defProp(to, key, {
12
- get: () => mod[key],
13
- enumerable: true
14
- });
15
- return to;
16
- };
17
2
  var __export = (target, all) => {
18
3
  for (var name in all)
19
4
  __defProp(target, name, {
@@ -891,7 +876,7 @@ __export(exports_path, {
891
876
  });
892
877
  function assertPath(path) {
893
878
  if (typeof path !== "string")
894
- throw new TypeError("Path must be a string. Received " + JSON.stringify(path));
879
+ throw TypeError("Path must be a string. Received " + JSON.stringify(path));
895
880
  }
896
881
  function normalizeStringPosix(path, allowAboveRoot) {
897
882
  var res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, code;
@@ -1081,7 +1066,7 @@ function dirname(path) {
1081
1066
  }
1082
1067
  function basename(path, ext) {
1083
1068
  if (ext !== undefined && typeof ext !== "string")
1084
- throw new TypeError('"ext" argument must be a string');
1069
+ throw TypeError('"ext" argument must be a string');
1085
1070
  assertPath(path);
1086
1071
  var start = 0, end = -1, matchedSlash = true, i;
1087
1072
  if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
@@ -1153,7 +1138,7 @@ function extname(path) {
1153
1138
  }
1154
1139
  function format(pathObject) {
1155
1140
  if (pathObject === null || typeof pathObject !== "object")
1156
- throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
1141
+ throw TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
1157
1142
  return _format("/", pathObject);
1158
1143
  }
1159
1144
  function parse(path) {
@@ -1652,6 +1637,7 @@ class RemoteServer {
1652
1637
  nextClientId = 1;
1653
1638
  server = null;
1654
1639
  sessionManager = null;
1640
+ _syncActions = false;
1655
1641
  module(name, module) {
1656
1642
  this._moduleName = name;
1657
1643
  this._module = module;
@@ -1673,6 +1659,10 @@ class RemoteServer {
1673
1659
  this._sessionConfig = config2;
1674
1660
  return this;
1675
1661
  }
1662
+ syncActions() {
1663
+ this._syncActions = true;
1664
+ return this;
1665
+ }
1676
1666
  onConnection(callback) {
1677
1667
  this._onConnectionCallbacks.push(callback);
1678
1668
  return this;
@@ -1975,6 +1965,13 @@ class RemoteServer {
1975
1965
  case "dispatchAction": {
1976
1966
  const actionMsg = msg;
1977
1967
  clientData.engine.dispatchAction(actionMsg.action, actionMsg.payload);
1968
+ if (this._syncActions) {
1969
+ for (const [otherWs, otherClient] of this.clients) {
1970
+ if (otherWs === ws || !otherClient.helloReceived)
1971
+ continue;
1972
+ otherClient.engine.dispatchAction(actionMsg.action, actionMsg.payload);
1973
+ }
1974
+ }
1978
1975
  break;
1979
1976
  }
1980
1977
  default:
@@ -2023,6 +2020,27 @@ class RemoteServer {
2023
2020
  };
2024
2021
  this._onDisconnectionCallbacks.forEach((cb) => cb(client));
2025
2022
  }
2023
+ async reload() {
2024
+ if (this._sourceDir) {
2025
+ this._ui = "";
2026
+ await this.discoverFromSource();
2027
+ }
2028
+ if (!this._ui) {
2029
+ log4.warn("Reload skipped: no UI template available");
2030
+ return;
2031
+ }
2032
+ for (const [ws, clientData] of this.clients) {
2033
+ if (!clientData.helloReceived)
2034
+ continue;
2035
+ this.setupComponentResolver(clientData.engine);
2036
+ try {
2037
+ clientData.engine.renderSource(this._ui);
2038
+ log4.info(`Hot-reloaded client ${clientData.id}`);
2039
+ } catch (e) {
2040
+ log4.error(`Failed to hot-reload client ${clientData.id}:`, e);
2041
+ }
2042
+ }
2043
+ }
2026
2044
  getClientCount() {
2027
2045
  return this.clients.size;
2028
2046
  }
@@ -2070,4 +2088,4 @@ export {
2070
2088
  RemoteServer
2071
2089
  };
2072
2090
 
2073
- //# debugId=EB14C82B43F72D2C64756E2164756E21
2091
+ //# debugId=258422296EF2F70264756E2164756E21