hazo_ui 3.1.0 → 3.1.2

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/index.d.cts CHANGED
@@ -83,15 +83,16 @@ declare function HazoContextProvider({ correlationId, userId, children, }: HazoC
83
83
  /**
84
84
  * Logger utility for hazo_ui.
85
85
  *
86
- * Default: delegates to hazo_core's createLogger('hazo_ui'), which
87
- * auto-injects correlationId, env, and writes structured JSON via hazo_logs.
88
- * Consumers can still override with set_logger() useful for tests, or for
89
- * apps that want to route hazo_ui logs through their own sink.
86
+ * hazo_ui ships as a "use client" bundle, so we cannot statically import
87
+ * hazo_core's `createLogger` here. hazo_core's browser entry deliberately
88
+ * omits `createLogger` (it loads hazo_logs dynamically, a Node-only
89
+ * package), and Turbopack flags namespace-member access against
90
+ * statically-known missing exports — even property reads — as a bundle
91
+ * error. So the default logger writes to console.
90
92
  *
91
- * hazo_ui is primarily a client-side library; logger sites in src/ are rare.
92
- * The factory exists so when a component does need to log (e.g. a server-side
93
- * helper or a debug aid in a hook), it can do so consistently with the rest
94
- * of the workspace rather than reaching for `console`.
93
+ * Server-side consumers that want structured logs through hazo_core +
94
+ * hazo_logs should call `set_logger(createLogger("hazo_ui"))` from a server
95
+ * boot path. The override mechanism is unchanged.
95
96
  */
96
97
  interface Logger {
97
98
  info: (message: string, data?: Record<string, unknown>) => void;
@@ -100,13 +101,13 @@ interface Logger {
100
101
  error: (message: string, data?: Record<string, unknown>) => void;
101
102
  }
102
103
  /**
103
- * Set the logger instance used throughout hazo_ui.
104
- * Pass `undefined` to reset to the hazo_core default.
104
+ * Set the logger instance used throughout hazo_ui. Pass `undefined` to
105
+ * reset to the console fallback.
105
106
  */
106
107
  declare function set_logger(logger: Logger | undefined): void;
107
108
  /**
108
- * Get the current logger instance defaults to hazo_core's createLogger
109
- * on first access if no consumer override has been set.
109
+ * Get the current logger instance. Defaults to a console writer; override
110
+ * with `set_logger(...)` to plug in hazo_core's structured logger.
110
111
  */
111
112
  declare function get_logger(): Logger;
112
113
 
package/dist/index.d.ts CHANGED
@@ -83,15 +83,16 @@ declare function HazoContextProvider({ correlationId, userId, children, }: HazoC
83
83
  /**
84
84
  * Logger utility for hazo_ui.
85
85
  *
86
- * Default: delegates to hazo_core's createLogger('hazo_ui'), which
87
- * auto-injects correlationId, env, and writes structured JSON via hazo_logs.
88
- * Consumers can still override with set_logger() useful for tests, or for
89
- * apps that want to route hazo_ui logs through their own sink.
86
+ * hazo_ui ships as a "use client" bundle, so we cannot statically import
87
+ * hazo_core's `createLogger` here. hazo_core's browser entry deliberately
88
+ * omits `createLogger` (it loads hazo_logs dynamically, a Node-only
89
+ * package), and Turbopack flags namespace-member access against
90
+ * statically-known missing exports — even property reads — as a bundle
91
+ * error. So the default logger writes to console.
90
92
  *
91
- * hazo_ui is primarily a client-side library; logger sites in src/ are rare.
92
- * The factory exists so when a component does need to log (e.g. a server-side
93
- * helper or a debug aid in a hook), it can do so consistently with the rest
94
- * of the workspace rather than reaching for `console`.
93
+ * Server-side consumers that want structured logs through hazo_core +
94
+ * hazo_logs should call `set_logger(createLogger("hazo_ui"))` from a server
95
+ * boot path. The override mechanism is unchanged.
95
96
  */
96
97
  interface Logger {
97
98
  info: (message: string, data?: Record<string, unknown>) => void;
@@ -100,13 +101,13 @@ interface Logger {
100
101
  error: (message: string, data?: Record<string, unknown>) => void;
101
102
  }
102
103
  /**
103
- * Set the logger instance used throughout hazo_ui.
104
- * Pass `undefined` to reset to the hazo_core default.
104
+ * Set the logger instance used throughout hazo_ui. Pass `undefined` to
105
+ * reset to the console fallback.
105
106
  */
106
107
  declare function set_logger(logger: Logger | undefined): void;
107
108
  /**
108
- * Get the current logger instance defaults to hazo_core's createLogger
109
- * on first access if no consumer override has been set.
109
+ * Get the current logger instance. Defaults to a console writer; override
110
+ * with `set_logger(...)` to plug in hazo_core's structured logger.
110
111
  */
111
112
  declare function get_logger(): Logger;
112
113
 
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { clsx } from 'clsx';
3
3
  import { twMerge } from 'tailwind-merge';
4
4
  import * as React26 from 'react';
5
5
  import React26__default, { useRef, useState, useCallback, useEffect, useMemo, Fragment } from 'react';
6
- import { generateRequestId, createLogger } from 'hazo_core';
6
+ import { generateRequestId } from 'hazo_core';
7
7
  import { withContext, setBrowserCorrelationId } from 'hazo_core/client';
8
8
  import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
9
9
  import { Slot } from '@radix-ui/react-slot';
@@ -151,27 +151,19 @@ function HazoContextProvider({
151
151
  }, [id, userId]);
152
152
  return /* @__PURE__ */ jsx(Fragment$1, { children });
153
153
  }
154
+
155
+ // src/utils/logger.ts
154
156
  var console_logger = {
155
157
  info: (m, d) => d ? console.log(`[hazo_ui] ${m}`, d) : console.log(`[hazo_ui] ${m}`),
156
158
  debug: (m, d) => d ? console.debug(`[hazo_ui] ${m}`, d) : console.debug(`[hazo_ui] ${m}`),
157
159
  warn: (m, d) => d ? console.warn(`[hazo_ui] ${m}`, d) : console.warn(`[hazo_ui] ${m}`),
158
160
  error: (m, d) => d ? console.error(`[hazo_ui] ${m}`, d) : console.error(`[hazo_ui] ${m}`)
159
161
  };
160
- function build_default_logger() {
161
- try {
162
- return createLogger("hazo_ui");
163
- } catch {
164
- return console_logger;
165
- }
166
- }
167
- var current_logger = null;
162
+ var current_logger = console_logger;
168
163
  function set_logger(logger) {
169
- current_logger = logger ?? null;
164
+ current_logger = logger ?? console_logger;
170
165
  }
171
166
  function get_logger() {
172
- if (!current_logger) {
173
- current_logger = build_default_logger();
174
- }
175
167
  return current_logger;
176
168
  }
177
169
  function generateUUID() {