@hypen-space/core 0.4.3 → 0.4.11

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 (72) hide show
  1. package/README.md +1 -1
  2. package/dist/app.d.ts +79 -22
  3. package/dist/app.js +248 -155
  4. package/dist/app.js.map +5 -5
  5. package/dist/components/builtin.js +251 -158
  6. package/dist/components/builtin.js.map +6 -6
  7. package/dist/context.js +1 -1
  8. package/dist/context.js.map +1 -1
  9. package/dist/discovery.d.ts +1 -1
  10. package/dist/discovery.js +249 -156
  11. package/dist/discovery.js.map +6 -6
  12. package/dist/disposable.js +1 -1
  13. package/dist/disposable.js.map +1 -1
  14. package/dist/engine.browser.d.ts +6 -0
  15. package/dist/engine.browser.js +192 -5
  16. package/dist/engine.browser.js.map +5 -4
  17. package/dist/engine.d.ts +6 -0
  18. package/dist/engine.js +192 -5
  19. package/dist/engine.js.map +5 -4
  20. package/dist/events.js +1 -1
  21. package/dist/events.js.map +1 -1
  22. package/dist/index.browser.d.ts +1 -1
  23. package/dist/index.browser.js +248 -155
  24. package/dist/index.browser.js.map +6 -6
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.js +254 -158
  27. package/dist/index.js.map +7 -7
  28. package/dist/loader.js +1 -1
  29. package/dist/loader.js.map +1 -1
  30. package/dist/logger.js +245 -0
  31. package/dist/logger.js.map +10 -0
  32. package/dist/managed-router.d.ts +3 -4
  33. package/dist/plugin.js +1 -1
  34. package/dist/plugin.js.map +1 -1
  35. package/dist/remote/client.js +34 -2
  36. package/dist/remote/client.js.map +3 -3
  37. package/dist/remote/index.js +609 -163
  38. package/dist/remote/index.js.map +8 -7
  39. package/dist/remote/server.d.ts +46 -15
  40. package/dist/remote/server.js +609 -163
  41. package/dist/remote/server.js.map +8 -7
  42. package/dist/renderer.js +1 -1
  43. package/dist/renderer.js.map +1 -1
  44. package/dist/result.d.ts +18 -0
  45. package/dist/router.js +1 -1
  46. package/dist/router.js.map +1 -1
  47. package/dist/types.d.ts +1 -1
  48. package/dist/types.js +2 -0
  49. package/dist/types.js.map +9 -0
  50. package/package.json +1 -1
  51. package/src/app.ts +162 -41
  52. package/src/components/builtin.ts +3 -4
  53. package/src/discovery.ts +2 -2
  54. package/src/engine.browser.ts +27 -4
  55. package/src/engine.ts +27 -4
  56. package/src/index.browser.ts +0 -2
  57. package/src/index.ts +3 -2
  58. package/src/managed-router.ts +5 -6
  59. package/src/remote/server.ts +116 -21
  60. package/src/result.ts +48 -0
  61. package/src/types.ts +1 -1
  62. package/wasm-browser/hypen_engine.d.ts +3 -3
  63. package/wasm-browser/hypen_engine.js +73 -66
  64. package/wasm-browser/hypen_engine_bg.wasm +0 -0
  65. package/wasm-browser/hypen_engine_bg.wasm.d.ts +3 -3
  66. package/wasm-browser/package.json +1 -1
  67. package/wasm-node/hypen_engine.js +74 -66
  68. package/wasm-node/hypen_engine_bg.wasm +0 -0
  69. package/wasm-node/hypen_engine_bg.wasm.d.ts +3 -3
  70. package/wasm-node/package.json +1 -1
  71. package/dist/module-registry.d.ts +0 -42
  72. package/src/module-registry.ts +0 -76
package/src/engine.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  // WASM module types
7
7
  import { WasmEngine } from "../wasm-node/hypen_engine.js";
8
8
  import { frameworkLoggers } from "./logger.js";
9
+ import { classifyEngineError } from "./result.js";
9
10
  import type { Patch, Action, RenderCallback, ActionHandler, ResolvedComponent, ComponentResolver } from "./types.js";
10
11
 
11
12
  // Re-export types so existing consumers of "./engine.js" still work
@@ -89,10 +90,16 @@ export class Engine {
89
90
 
90
91
  /**
91
92
  * Parse and render Hypen DSL source code
93
+ * @throws {ParseError} if the source fails to parse
94
+ * @throws {RenderError} if rendering fails
92
95
  */
93
96
  renderSource(source: string): void {
94
97
  const engine = this.ensureInitialized();
95
- engine.renderSource(source);
98
+ try {
99
+ engine.renderSource(source);
100
+ } catch (err) {
101
+ throw classifyEngineError(err);
102
+ }
96
103
  }
97
104
 
98
105
  /**
@@ -105,14 +112,21 @@ export class Engine {
105
112
 
106
113
  /**
107
114
  * Render a component into a specific parent node (subtree rendering)
115
+ * @throws {ParseError} if the source fails to parse
116
+ * @throws {RenderError} if the parent node is not found or rendering fails
108
117
  */
109
118
  renderInto(source: string, parentNodeId: string, state: Record<string, any>): void {
110
119
  const engine = this.ensureInitialized();
111
- engine.renderInto(source, parentNodeId, unwrapForWasm(state));
120
+ try {
121
+ engine.renderInto(source, parentNodeId, unwrapForWasm(state));
122
+ } catch (err) {
123
+ throw classifyEngineError(err);
124
+ }
112
125
  }
113
126
 
114
127
  /**
115
128
  * Notify the engine of state changes using sparse updates
129
+ * @throws {StateError} if the state patch is invalid
116
130
  */
117
131
  notifyStateChange(paths: string[], values: Record<string, any>): void {
118
132
  const engine = this.ensureInitialized();
@@ -121,7 +135,11 @@ export class Engine {
121
135
  return;
122
136
  }
123
137
 
124
- engine.updateStateSparse(paths, unwrapForWasm(values));
138
+ try {
139
+ engine.updateStateSparse(paths, unwrapForWasm(values));
140
+ } catch (err) {
141
+ throw classifyEngineError(err);
142
+ }
125
143
  log.debug("State changed (sparse):", paths);
126
144
  }
127
145
 
@@ -149,10 +167,15 @@ export class Engine {
149
167
 
150
168
  /**
151
169
  * Dispatch an action
170
+ * @throws {HypenError} if the action dispatch fails
152
171
  */
153
172
  dispatchAction(name: string, payload?: any): void {
154
173
  const engine = this.ensureInitialized();
155
- engine.dispatchAction(name, payload ?? null);
174
+ try {
175
+ engine.dispatchAction(name, payload ?? null);
176
+ } catch (err) {
177
+ throw classifyEngineError(err);
178
+ }
156
179
  }
157
180
 
158
181
  /**
@@ -28,9 +28,7 @@ export type {
28
28
  export { app, HypenApp, HypenAppBuilder, HypenModuleInstance } from "./app.js";
29
29
  export type {
30
30
  IEngine,
31
- RouterContext,
32
31
  ActionContext,
33
- ActionNext,
34
32
  GlobalContext,
35
33
  LifecycleHandler,
36
34
  ActionHandlerContext,
package/src/index.ts CHANGED
@@ -74,9 +74,7 @@ export type { StateProxy, ItemProxy } from "./hypen.js";
74
74
 
75
75
  export type {
76
76
  IEngine,
77
- RouterContext,
78
77
  ActionContext,
79
- ActionNext,
80
78
  GlobalContext,
81
79
  LifecycleHandler,
82
80
  ActionHandlerContext,
@@ -245,6 +243,9 @@ export {
245
243
  ActionError,
246
244
  ConnectionError,
247
245
  StateError,
246
+ ParseError,
247
+ RenderError,
248
+ classifyEngineError,
248
249
  } from "./result.js";
249
250
  export type { Result } from "./result.js";
250
251
 
@@ -9,10 +9,9 @@
9
9
  */
10
10
 
11
11
  import type { IEngine, HypenModuleDefinition } from "./app.js";
12
- import { HypenModuleInstance } from "./app.js";
12
+ import { HypenModuleInstance, HypenApp } from "./app.js";
13
13
  import type { HypenRouter, RouteState } from "./router.js";
14
14
  import type { HypenGlobalContext } from "./context.js";
15
- import { ModuleRegistry } from "./module-registry.js";
16
15
  import { createLogger } from "./logger.js";
17
16
 
18
17
  const log = createLogger("ManagedRouter");
@@ -20,7 +19,7 @@ const log = createLogger("ManagedRouter");
20
19
  export interface RouteDefinition {
21
20
  /** Route path pattern (e.g., "/", "/profile/:id") */
22
21
  path: string;
23
- /** Component name — used to look up in ModuleRegistry */
22
+ /** Component name — used to look up in app registry */
24
23
  component: string;
25
24
  /** Inline module definition (alternative to registry lookup) */
26
25
  module?: HypenModuleDefinition;
@@ -29,7 +28,7 @@ export interface RouteDefinition {
29
28
  export class ManagedRouter {
30
29
  private router: HypenRouter;
31
30
  private engine: IEngine;
32
- private registry: ModuleRegistry;
31
+ private registry: HypenApp;
33
32
  private globalContext: HypenGlobalContext;
34
33
  private routes: RouteDefinition[] = [];
35
34
  private activeModule: HypenModuleInstance | null = null;
@@ -41,7 +40,7 @@ export class ManagedRouter {
41
40
  constructor(
42
41
  router: HypenRouter,
43
42
  engine: IEngine,
44
- registry: ModuleRegistry,
43
+ registry: HypenApp,
45
44
  globalContext: HypenGlobalContext
46
45
  ) {
47
46
  this.router = router;
@@ -161,7 +160,7 @@ export class ManagedRouter {
161
160
  const instance = new HypenModuleInstance(
162
161
  this.engine,
163
162
  namedDef as HypenModuleDefinition<object>,
164
- { root: this.router },
163
+ this.router,
165
164
  this.globalContext
166
165
  );
167
166
 
@@ -1,36 +1,36 @@
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
 
31
31
  import { Engine } from "../engine.js";
32
32
  import { HypenModuleInstance } from "../app.js";
33
- import type { HypenModule } from "../app.js";
33
+ import type { HypenModule, HypenModuleDefinition } from "../app.js";
34
34
  import type {
35
35
  RemoteMessage,
36
36
  RemoteClient,
@@ -44,10 +44,15 @@ import type {
44
44
  Session,
45
45
  SessionConfig,
46
46
  } from "./types.js";
47
- import type { Patch } from "../types.js";
47
+ import type { Patch, ResolvedComponent } from "../types.js";
48
48
  import type { ServerWebSocket } from "bun";
49
49
  import { SessionManager } from "./session.js";
50
50
  import { frameworkLoggers } from "../logger.js";
51
+ import {
52
+ discoverComponents,
53
+ loadDiscoveredComponents,
54
+ type DiscoveredComponent,
55
+ } from "../discovery.js";
51
56
 
52
57
  const log = frameworkLoggers.remote;
53
58
 
@@ -72,6 +77,8 @@ export class RemoteServer {
72
77
  private _module: HypenModule<any> | null = null;
73
78
  private _moduleName: string = "App";
74
79
  private _ui: string = "";
80
+ private _sourceDir: string | null = null;
81
+ private _discoveredComponents: Map<string, { template: string; module?: HypenModuleDefinition<any> }> = new Map();
75
82
  private _config: RemoteServerConfig = {};
76
83
  private _sessionConfig: SessionConfig = {};
77
84
  private _onConnectionCallbacks: Array<(client: RemoteClient) => void> = [];
@@ -98,6 +105,26 @@ export class RemoteServer {
98
105
  return this;
99
106
  }
100
107
 
108
+ /**
109
+ * Set a source directory for automatic component discovery.
110
+ *
111
+ * All .hypen and .ts components in the directory (and subdirectories) are
112
+ * discovered automatically. The entry component's template is used as the
113
+ * UI, so calling .ui() is optional when .source() is set.
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * new RemoteServer()
118
+ * .source("./apps/chat")
119
+ * .module("Chat", chatModule)
120
+ * .listen(3001);
121
+ * ```
122
+ */
123
+ source(dir: string): this {
124
+ this._sourceDir = dir;
125
+ return this;
126
+ }
127
+
101
128
  /**
102
129
  * Set server configuration
103
130
  */
@@ -133,13 +160,20 @@ export class RemoteServer {
133
160
  /**
134
161
  * Start the WebSocket server
135
162
  */
136
- listen(port?: number): this {
163
+ async listen(port?: number): Promise<this> {
137
164
  if (!this._module) {
138
165
  throw new Error("Module not set. Call .module() before .listen()");
139
166
  }
140
167
 
168
+ // Run component discovery if source directory is set
169
+ if (this._sourceDir) {
170
+ await this.discoverFromSource();
171
+ }
172
+
141
173
  if (!this._ui) {
142
- throw new Error("UI not set. Call .ui() before .listen()");
174
+ throw new Error(
175
+ "UI not set. Call .ui() or .source() before .listen()"
176
+ );
143
177
  }
144
178
 
145
179
  // Initialize session manager
@@ -214,6 +248,56 @@ export class RemoteServer {
214
248
  return `ws://${hostname}:${port}`;
215
249
  }
216
250
 
251
+ /**
252
+ * Discover components from the source directory.
253
+ * Populates _discoveredComponents and sets _ui from the entry component
254
+ * if not already set via .ui().
255
+ */
256
+ private async discoverFromSource(): Promise<void> {
257
+ const dir = this._sourceDir!;
258
+ log.info(`Discovering components from ${dir}...`);
259
+
260
+ const discovered = await discoverComponents(dir);
261
+ const loaded = await loadDiscoveredComponents(discovered);
262
+
263
+ for (const [name, { module, template }] of loaded) {
264
+ this._discoveredComponents.set(name, { template, module });
265
+ }
266
+
267
+ log.info(
268
+ `Discovered ${this._discoveredComponents.size} components: ${Array.from(this._discoveredComponents.keys()).join(", ")}`
269
+ );
270
+
271
+ // If .ui() was not called, use the entry component's template
272
+ if (!this._ui) {
273
+ const entry = this._discoveredComponents.get(this._moduleName);
274
+ if (entry) {
275
+ this._ui = entry.template;
276
+ }
277
+ }
278
+ }
279
+
280
+ /**
281
+ * Set up a component resolver on a client engine so that imports
282
+ * and component references in templates are resolved from discovered
283
+ * components.
284
+ */
285
+ private setupComponentResolver(engine: Engine): void {
286
+ if (this._discoveredComponents.size === 0) return;
287
+
288
+ engine.setComponentResolver(
289
+ (componentName: string, _contextPath: string | null) => {
290
+ const comp = this._discoveredComponents.get(componentName);
291
+ if (!comp) return null;
292
+
293
+ return {
294
+ source: comp.template,
295
+ path: componentName,
296
+ };
297
+ }
298
+ );
299
+ }
300
+
217
301
  /**
218
302
  * Handle new WebSocket connection
219
303
  * Waits for hello message before fully initializing
@@ -227,6 +311,9 @@ export class RemoteServer {
227
311
  const engine = new Engine();
228
312
  await engine.init();
229
313
 
314
+ // Wire up component resolver if we have discovered components
315
+ this.setupComponentResolver(engine);
316
+
230
317
  // Create module instance
231
318
  const moduleInstance = new HypenModuleInstance(engine, this._module!);
232
319
 
@@ -618,19 +705,27 @@ export class RemoteServer {
618
705
  /**
619
706
  * Convenience function to create and start a RemoteServer
620
707
  */
621
- export function serve(options: {
708
+ export async function serve(options: {
622
709
  module: HypenModule<any>;
623
710
  moduleName?: string;
624
- ui: string;
711
+ ui?: string;
712
+ source?: string;
625
713
  port?: number;
626
714
  hostname?: string;
627
715
  session?: SessionConfig;
628
716
  onConnection?: (client: RemoteClient) => void;
629
717
  onDisconnection?: (client: RemoteClient) => void;
630
- }): RemoteServer {
718
+ }): Promise<RemoteServer> {
631
719
  const server = new RemoteServer()
632
- .module(options.moduleName ?? "App", options.module)
633
- .ui(options.ui);
720
+ .module(options.moduleName ?? "App", options.module);
721
+
722
+ if (options.source) {
723
+ server.source(options.source);
724
+ }
725
+
726
+ if (options.ui) {
727
+ server.ui(options.ui);
728
+ }
634
729
 
635
730
  if (options.port || options.hostname) {
636
731
  server.config({
package/src/result.ts CHANGED
@@ -258,3 +258,51 @@ export class StateError extends HypenError {
258
258
  this.path = path;
259
259
  }
260
260
  }
261
+
262
+ /**
263
+ * Error thrown when parsing Hypen DSL source fails
264
+ */
265
+ export class ParseError extends HypenError {
266
+ readonly source?: string;
267
+
268
+ constructor(message: string, source?: string, cause?: unknown) {
269
+ super('PARSE_ERROR', message, {
270
+ context: { source },
271
+ cause: cause instanceof Error ? cause : undefined,
272
+ });
273
+ this.name = 'ParseError';
274
+ this.source = source;
275
+ }
276
+ }
277
+
278
+ /**
279
+ * Error thrown when rendering fails
280
+ */
281
+ export class RenderError extends HypenError {
282
+ constructor(message: string, cause?: unknown) {
283
+ super('RENDER_ERROR', message, {
284
+ cause: cause instanceof Error ? cause : undefined,
285
+ });
286
+ this.name = 'RenderError';
287
+ }
288
+ }
289
+
290
+ /**
291
+ * Classify a WASM engine error string into the appropriate HypenError subclass.
292
+ * The engine returns JsValue error strings with known prefixes.
293
+ */
294
+ export function classifyEngineError(err: unknown): HypenError {
295
+ const message = err instanceof Error ? err.message : String(err);
296
+
297
+ if (message.startsWith('Parse error:')) {
298
+ return new ParseError(message);
299
+ }
300
+ if (message.startsWith('Invalid state:') || message.startsWith('Invalid state patch:')) {
301
+ return new StateError(message);
302
+ }
303
+ if (message.startsWith('Parent node not found:')) {
304
+ return new RenderError(message);
305
+ }
306
+
307
+ return new RenderError(message);
308
+ }
package/src/types.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  export type Patch = {
9
- type: "create" | "setProp" | "setText" | "insert" | "move" | "remove" | "attachEvent" | "detachEvent";
9
+ type: "create" | "setProp" | "removeProp" | "setText" | "insert" | "move" | "remove" | "attachEvent" | "detachEvent";
10
10
  id?: string;
11
11
  elementType?: string;
12
12
  props?: Record<string, any>;
@@ -120,11 +120,11 @@ export interface InitOutput {
120
120
  readonly parseToJson: (a: number, b: number) => [number, number, number, number];
121
121
  readonly main: () => void;
122
122
  readonly wasmengine_renderSource: (a: number, b: number, c: number) => [number, number];
123
- readonly __wbindgen_exn_store: (a: number) => void;
124
- readonly __externref_table_alloc: () => number;
125
- readonly __wbindgen_export_2: WebAssembly.Table;
126
123
  readonly __wbindgen_malloc: (a: number, b: number) => number;
127
124
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
125
+ readonly __wbindgen_exn_store: (a: number) => void;
126
+ readonly __externref_table_alloc: () => number;
127
+ readonly __wbindgen_export_4: WebAssembly.Table;
128
128
  readonly __externref_table_dealloc: (a: number) => void;
129
129
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
130
130
  readonly __wbindgen_start: () => void;
@@ -30,9 +30,72 @@ function getStringFromWasm0(ptr, len) {
30
30
  return decodeText(ptr, len);
31
31
  }
32
32
 
33
+ let WASM_VECTOR_LEN = 0;
34
+
35
+ const cachedTextEncoder = new TextEncoder();
36
+
37
+ if (!('encodeInto' in cachedTextEncoder)) {
38
+ cachedTextEncoder.encodeInto = function (arg, view) {
39
+ const buf = cachedTextEncoder.encode(arg);
40
+ view.set(buf);
41
+ return {
42
+ read: arg.length,
43
+ written: buf.length
44
+ };
45
+ }
46
+ }
47
+
48
+ function passStringToWasm0(arg, malloc, realloc) {
49
+
50
+ if (realloc === undefined) {
51
+ const buf = cachedTextEncoder.encode(arg);
52
+ const ptr = malloc(buf.length, 1) >>> 0;
53
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
54
+ WASM_VECTOR_LEN = buf.length;
55
+ return ptr;
56
+ }
57
+
58
+ let len = arg.length;
59
+ let ptr = malloc(len, 1) >>> 0;
60
+
61
+ const mem = getUint8ArrayMemory0();
62
+
63
+ let offset = 0;
64
+
65
+ for (; offset < len; offset++) {
66
+ const code = arg.charCodeAt(offset);
67
+ if (code > 0x7F) break;
68
+ mem[ptr + offset] = code;
69
+ }
70
+
71
+ if (offset !== len) {
72
+ if (offset !== 0) {
73
+ arg = arg.slice(offset);
74
+ }
75
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
76
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
77
+ const ret = cachedTextEncoder.encodeInto(arg, view);
78
+
79
+ offset += ret.written;
80
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
81
+ }
82
+
83
+ WASM_VECTOR_LEN = offset;
84
+ return ptr;
85
+ }
86
+
87
+ let cachedDataViewMemory0 = null;
88
+
89
+ function getDataViewMemory0() {
90
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
91
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
92
+ }
93
+ return cachedDataViewMemory0;
94
+ }
95
+
33
96
  function addToExternrefTable0(obj) {
34
97
  const idx = wasm.__externref_table_alloc();
35
- wasm.__wbindgen_export_2.set(idx, obj);
98
+ wasm.__wbindgen_export_4.set(idx, obj);
36
99
  return idx;
37
100
  }
38
101
 
@@ -54,15 +117,6 @@ function isLikeNone(x) {
54
117
  return x === undefined || x === null;
55
118
  }
56
119
 
57
- let cachedDataViewMemory0 = null;
58
-
59
- function getDataViewMemory0() {
60
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
61
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
62
- }
63
- return cachedDataViewMemory0;
64
- }
65
-
66
120
  function debugString(val) {
67
121
  // primitive types
68
122
  const type = typeof val;
@@ -128,62 +182,8 @@ function debugString(val) {
128
182
  return className;
129
183
  }
130
184
 
131
- let WASM_VECTOR_LEN = 0;
132
-
133
- const cachedTextEncoder = new TextEncoder();
134
-
135
- if (!('encodeInto' in cachedTextEncoder)) {
136
- cachedTextEncoder.encodeInto = function (arg, view) {
137
- const buf = cachedTextEncoder.encode(arg);
138
- view.set(buf);
139
- return {
140
- read: arg.length,
141
- written: buf.length
142
- };
143
- }
144
- }
145
-
146
- function passStringToWasm0(arg, malloc, realloc) {
147
-
148
- if (realloc === undefined) {
149
- const buf = cachedTextEncoder.encode(arg);
150
- const ptr = malloc(buf.length, 1) >>> 0;
151
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
152
- WASM_VECTOR_LEN = buf.length;
153
- return ptr;
154
- }
155
-
156
- let len = arg.length;
157
- let ptr = malloc(len, 1) >>> 0;
158
-
159
- const mem = getUint8ArrayMemory0();
160
-
161
- let offset = 0;
162
-
163
- for (; offset < len; offset++) {
164
- const code = arg.charCodeAt(offset);
165
- if (code > 0x7F) break;
166
- mem[ptr + offset] = code;
167
- }
168
-
169
- if (offset !== len) {
170
- if (offset !== 0) {
171
- arg = arg.slice(offset);
172
- }
173
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
174
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
175
- const ret = cachedTextEncoder.encodeInto(arg, view);
176
-
177
- offset += ret.written;
178
- ptr = realloc(ptr, len, offset, 1) >>> 0;
179
- }
180
-
181
- WASM_VECTOR_LEN = offset;
182
- return ptr;
183
- }
184
-
185
185
  function takeFromExternrefTable0(idx) {
186
- const value = wasm.__wbindgen_export_2.get(idx);
186
+ const value = wasm.__wbindgen_export_4.get(idx);
187
187
  wasm.__externref_table_dealloc(idx);
188
188
  return value;
189
189
  }
@@ -509,6 +509,13 @@ function __wbg_get_imports() {
509
509
  const ret = Error(getStringFromWasm0(arg0, arg1));
510
510
  return ret;
511
511
  };
512
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
513
+ const ret = String(arg1);
514
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
515
+ const len1 = WASM_VECTOR_LEN;
516
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
517
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
518
+ };
512
519
  imports.wbg.__wbg_call_13410aac570ffff7 = function() { return handleError(function (arg0, arg1) {
513
520
  const ret = arg0.call(arg1);
514
521
  return ret;
@@ -727,7 +734,7 @@ function __wbg_get_imports() {
727
734
  return ret;
728
735
  };
729
736
  imports.wbg.__wbindgen_init_externref_table = function() {
730
- const table = wasm.__wbindgen_export_2;
737
+ const table = wasm.__wbindgen_export_4;
731
738
  const offset = table.grow(4);
732
739
  table.set(0, undefined);
733
740
  table.set(offset + 0, undefined);
Binary file
@@ -20,11 +20,11 @@ export const patchesToJson: (a: any) => [number, number, number, number];
20
20
  export const parseToJson: (a: number, b: number) => [number, number, number, number];
21
21
  export const main: () => void;
22
22
  export const wasmengine_renderSource: (a: number, b: number, c: number) => [number, number];
23
- export const __wbindgen_exn_store: (a: number) => void;
24
- export const __externref_table_alloc: () => number;
25
- export const __wbindgen_export_2: WebAssembly.Table;
26
23
  export const __wbindgen_malloc: (a: number, b: number) => number;
27
24
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
25
+ export const __wbindgen_exn_store: (a: number) => void;
26
+ export const __externref_table_alloc: () => number;
27
+ export const __wbindgen_export_4: WebAssembly.Table;
28
28
  export const __externref_table_dealloc: (a: number) => void;
29
29
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
30
30
  export const __wbindgen_start: () => void;
@@ -5,7 +5,7 @@
5
5
  "Hypen Contributors"
6
6
  ],
7
7
  "description": "A Rust implementation of the Hypen engine",
8
- "version": "0.4.1",
8
+ "version": "0.4.11",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",