@hypen-space/core 0.4.0 → 0.4.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypen-space/core",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Hypen core engine - Platform-agnostic reactive UI runtime",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -135,6 +135,12 @@
135
135
  "bun": "./src/types.ts",
136
136
  "import": "./dist/types.js",
137
137
  "default": "./dist/types.js"
138
+ },
139
+ "./logger": {
140
+ "types": "./dist/logger.d.ts",
141
+ "bun": "./src/logger.ts",
142
+ "import": "./dist/logger.js",
143
+ "default": "./dist/logger.js"
138
144
  }
139
145
  },
140
146
  "files": [
package/src/discovery.ts CHANGED
@@ -11,7 +11,7 @@
11
11
  */
12
12
 
13
13
  import { existsSync, readdirSync, readFileSync, watch } from "fs";
14
- import { join, basename, resolve } from "path";
14
+ import { join, basename, resolve, relative } from "path";
15
15
  import type { HypenModuleDefinition } from "./app.js";
16
16
  import { frameworkLoggers } from "./logger.js";
17
17
 
@@ -468,10 +468,11 @@ export function watchComponents(
468
468
  */
469
469
  export async function generateComponentsCode(
470
470
  baseDir: string,
471
- options: DiscoveryOptions = {}
471
+ options: DiscoveryOptions & { outputDir?: string } = {}
472
472
  ): Promise<string> {
473
473
  const components = await discoverComponents(baseDir, options);
474
474
  const resolvedDir = resolve(baseDir);
475
+ const outputBase = options.outputDir ? resolve(options.outputDir) : resolvedDir;
475
476
 
476
477
  let code = `/**
477
478
  * Auto-generated component imports
@@ -481,15 +482,15 @@ export async function generateComponentsCode(
481
482
  `;
482
483
 
483
484
  for (const component of components) {
484
- const relativePath = component.modulePath
485
- ? "./" +
486
- component.modulePath
487
- .replace(resolvedDir + "/", "")
488
- .replace(/\.ts$/, ".js")
489
- : null;
490
-
491
- if (relativePath) {
492
- code += `import ${component.name}Module from "${relativePath}";\n`;
485
+ let importPath: string | null = null;
486
+ if (component.modulePath) {
487
+ const rel = relative(outputBase, component.modulePath)
488
+ .replace(/\.ts$/, ".js");
489
+ importPath = rel.startsWith(".") ? rel : "./" + rel;
490
+ }
491
+
492
+ if (importPath) {
493
+ code += `import ${component.name}Module from "${importPath}";\n`;
493
494
  }
494
495
  }
495
496
 
package/src/index.ts CHANGED
@@ -149,7 +149,7 @@ export type { ModuleReference } from "./context.js";
149
149
  // REMOTE UI
150
150
  // ============================================================================
151
151
 
152
- // Client
152
+ // Client (browser-safe)
153
153
  export { RemoteEngine } from "./remote/client.js";
154
154
  export type {
155
155
  RemoteConnectionState,
@@ -158,8 +158,9 @@ export type {
158
158
  SessionInfo,
159
159
  } from "./remote/client.js";
160
160
 
161
- // Server
162
- export { RemoteServer, serve } from "./remote/server.js";
161
+ // NOTE: RemoteServer and serve are NOT exported from the barrel because they
162
+ // import the Node.js WASM engine. Import them from the subpath instead:
163
+ // import { RemoteServer, serve } from "@hypen-space/core/remote/server"
163
164
 
164
165
  // Session Management
165
166
  export { SessionManager } from "./remote/session.js";
@@ -182,14 +183,7 @@ export type {
182
183
  } from "./remote/types.js";
183
184
 
184
185
  // ============================================================================
185
- // COMPONENT LOADER
186
- // ============================================================================
187
-
188
- export { ComponentLoader, componentLoader } from "./loader.js";
189
- export type { ComponentDefinition } from "./loader.js";
190
-
191
- // ============================================================================
192
- // COMPONENT RESOLVER
186
+ // COMPONENT RESOLVER (browser-safe, no fs dependency)
193
187
  // ============================================================================
194
188
 
195
189
  export { ComponentResolver } from "./resolver.js";
@@ -202,26 +196,24 @@ export type {
202
196
  } from "./resolver.js";
203
197
 
204
198
  // ============================================================================
205
- // COMPONENT DISCOVERY
199
+ // NODE-ONLY MODULES (NOT exported from barrel — use subpath imports)
206
200
  // ============================================================================
201
+ //
202
+ // These modules use Node.js APIs (fs.readFileSync) and must NOT be in the
203
+ // browser-safe barrel. Import them from their subpaths instead:
204
+ //
205
+ // import { ComponentLoader, componentLoader } from "@hypen-space/core/loader"
206
+ // import { discoverComponents, ... } from "@hypen-space/core/discovery"
207
+ // import { hypenPlugin, ... } from "@hypen-space/core/plugin"
208
+ //
207
209
 
208
- export {
209
- discoverComponents,
210
- loadDiscoveredComponents,
211
- watchComponents,
212
- generateComponentsCode,
213
- } from "./discovery.js";
210
+ // Re-export types only (types are always safe)
211
+ export type { ComponentDefinition } from "./loader.js";
214
212
  export type {
215
213
  DiscoveredComponent,
216
214
  DiscoveryOptions,
217
215
  WatchOptions,
218
216
  } from "./discovery.js";
219
-
220
- // ============================================================================
221
- // PLUGIN
222
- // ============================================================================
223
-
224
- export { hypenPlugin, registerHypenPlugin, defaultHypenPlugin } from "./plugin.js";
225
217
  export type { HypenPluginOptions } from "./plugin.js";
226
218
 
227
219
  // ============================================================================
package/src/renderer.ts CHANGED
@@ -96,6 +96,10 @@ export abstract class BaseRenderer implements Renderer {
96
96
  */
97
97
  export class ConsoleRenderer implements Renderer {
98
98
  applyPatches(patches: Patch[]): void {
99
- log.debug("Patches:", patches);
99
+ console.group("Hypen Patches");
100
+ for (const patch of patches) {
101
+ console.log(patch);
102
+ }
103
+ console.groupEnd();
100
104
  }
101
105
  }