@omote/core 0.1.0 → 0.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.mjs CHANGED
@@ -1,36 +1,22 @@
1
- // src/events/EventEmitter.ts
2
- var EventEmitter = class {
3
- constructor() {
4
- this.listeners = /* @__PURE__ */ new Map();
5
- }
6
- on(event, callback) {
7
- if (!this.listeners.has(event)) {
8
- this.listeners.set(event, /* @__PURE__ */ new Set());
9
- }
10
- this.listeners.get(event).add(callback);
11
- return () => this.off(event, callback);
12
- }
13
- off(event, callback) {
14
- this.listeners.get(event)?.delete(callback);
15
- }
16
- emit(event, data) {
17
- this.listeners.get(event)?.forEach((cb) => cb(data));
18
- }
19
- once(event, callback) {
20
- const wrapper = (data) => {
21
- this.off(event, wrapper);
22
- callback(data);
23
- };
24
- return this.on(event, wrapper);
25
- }
26
- removeAllListeners(event) {
27
- if (event) {
28
- this.listeners.delete(event);
29
- } else {
30
- this.listeners.clear();
31
- }
32
- }
33
- };
1
+ import {
2
+ EventEmitter
3
+ } from "./chunk-XK22BRG4.mjs";
4
+ import {
5
+ DEFAULT_LOGGING_CONFIG,
6
+ LOG_LEVEL_PRIORITY,
7
+ configureLogging,
8
+ createLogger,
9
+ getLoggingConfig,
10
+ noopLogger,
11
+ resetLoggingConfig,
12
+ setLogLevel,
13
+ setLoggingEnabled
14
+ } from "./chunk-ESU52TDS.mjs";
15
+ import {
16
+ env,
17
+ pipeline3
18
+ } from "./chunk-RI6UQ7WF.mjs";
19
+ import "./chunk-NSSMTXJJ.mjs";
34
20
 
35
21
  // src/audio/MicrophoneCapture.ts
36
22
  var MicrophoneCapture = class {
@@ -2038,270 +2024,6 @@ function formatBytes(bytes) {
2038
2024
  return `${(bytes / 1024 / 1024 / 1024).toFixed(1)} GB`;
2039
2025
  }
2040
2026
 
2041
- // src/logging/types.ts
2042
- var LOG_LEVEL_PRIORITY = {
2043
- error: 0,
2044
- warn: 1,
2045
- info: 2,
2046
- debug: 3,
2047
- trace: 4,
2048
- verbose: 5
2049
- };
2050
- var DEFAULT_LOGGING_CONFIG = {
2051
- level: "info",
2052
- enabled: true,
2053
- format: "pretty",
2054
- timestamps: true,
2055
- includeModule: true
2056
- };
2057
-
2058
- // src/logging/formatters.ts
2059
- var COLORS = {
2060
- reset: "\x1B[0m",
2061
- red: "\x1B[31m",
2062
- yellow: "\x1B[33m",
2063
- blue: "\x1B[34m",
2064
- cyan: "\x1B[36m",
2065
- gray: "\x1B[90m",
2066
- white: "\x1B[37m",
2067
- magenta: "\x1B[35m"
2068
- };
2069
- var LEVEL_COLORS = {
2070
- error: COLORS.red,
2071
- warn: COLORS.yellow,
2072
- info: COLORS.blue,
2073
- debug: COLORS.cyan,
2074
- trace: COLORS.magenta,
2075
- verbose: COLORS.gray
2076
- };
2077
- var LEVEL_NAMES = {
2078
- error: "ERROR ",
2079
- warn: "WARN ",
2080
- info: "INFO ",
2081
- debug: "DEBUG ",
2082
- trace: "TRACE ",
2083
- verbose: "VERBOSE"
2084
- };
2085
- var isBrowser = typeof window !== "undefined";
2086
- function formatTimestamp(timestamp) {
2087
- const date = new Date(timestamp);
2088
- return date.toISOString().substring(11, 23);
2089
- }
2090
- function safeStringify(data) {
2091
- const seen = /* @__PURE__ */ new WeakSet();
2092
- return JSON.stringify(data, (key, value) => {
2093
- if (typeof value === "object" && value !== null) {
2094
- if (seen.has(value)) {
2095
- return "[Circular]";
2096
- }
2097
- seen.add(value);
2098
- }
2099
- if (value instanceof Error) {
2100
- return {
2101
- name: value.name,
2102
- message: value.message,
2103
- stack: value.stack
2104
- };
2105
- }
2106
- if (value instanceof Float32Array || value instanceof Int16Array) {
2107
- return `${value.constructor.name}(${value.length})`;
2108
- }
2109
- if (ArrayBuffer.isView(value)) {
2110
- return `${value.constructor.name}(${value.byteLength})`;
2111
- }
2112
- return value;
2113
- });
2114
- }
2115
- var jsonFormatter = (entry) => {
2116
- const output = {
2117
- timestamp: entry.timestamp,
2118
- level: entry.level,
2119
- module: entry.module,
2120
- message: entry.message
2121
- };
2122
- if (entry.data && Object.keys(entry.data).length > 0) {
2123
- output.data = entry.data;
2124
- }
2125
- if (entry.error) {
2126
- output.error = {
2127
- name: entry.error.name,
2128
- message: entry.error.message,
2129
- stack: entry.error.stack
2130
- };
2131
- }
2132
- return safeStringify(output);
2133
- };
2134
- var prettyFormatter = (entry) => {
2135
- const time = formatTimestamp(entry.timestamp);
2136
- const level = LEVEL_NAMES[entry.level];
2137
- const module = entry.module;
2138
- const message = entry.message;
2139
- let output;
2140
- if (isBrowser) {
2141
- output = `${time} ${level} [${module}] ${message}`;
2142
- } else {
2143
- const color = LEVEL_COLORS[entry.level];
2144
- output = `${COLORS.gray}${time}${COLORS.reset} ${color}${level}${COLORS.reset} ${COLORS.cyan}[${module}]${COLORS.reset} ${message}`;
2145
- }
2146
- if (entry.data && Object.keys(entry.data).length > 0) {
2147
- const dataStr = safeStringify(entry.data);
2148
- if (dataStr.length > 80) {
2149
- output += "\n " + JSON.stringify(entry.data, null, 2).replace(/\n/g, "\n ");
2150
- } else {
2151
- output += " " + dataStr;
2152
- }
2153
- }
2154
- if (entry.error) {
2155
- output += `
2156
- ${entry.error.name}: ${entry.error.message}`;
2157
- if (entry.error.stack) {
2158
- const stackLines = entry.error.stack.split("\n").slice(1, 4);
2159
- output += "\n " + stackLines.join("\n ");
2160
- }
2161
- }
2162
- return output;
2163
- };
2164
- function getFormatter(format) {
2165
- return format === "json" ? jsonFormatter : prettyFormatter;
2166
- }
2167
- function createBrowserConsoleArgs(entry) {
2168
- const time = formatTimestamp(entry.timestamp);
2169
- const level = entry.level.toUpperCase().padEnd(7);
2170
- const module = entry.module;
2171
- const message = entry.message;
2172
- const styles = {
2173
- time: "color: gray;",
2174
- error: "color: red; font-weight: bold;",
2175
- warn: "color: orange; font-weight: bold;",
2176
- info: "color: blue;",
2177
- debug: "color: cyan;",
2178
- trace: "color: magenta;",
2179
- verbose: "color: gray;",
2180
- module: "color: teal; font-weight: bold;",
2181
- message: "color: inherit;"
2182
- };
2183
- let formatStr = "%c%s %c%s %c[%s]%c %s";
2184
- const args = [
2185
- styles.time,
2186
- time,
2187
- styles[entry.level],
2188
- level,
2189
- styles.module,
2190
- module,
2191
- styles.message,
2192
- message
2193
- ];
2194
- if (entry.data && Object.keys(entry.data).length > 0) {
2195
- formatStr += " %o";
2196
- args.push(entry.data);
2197
- }
2198
- return [formatStr, ...args];
2199
- }
2200
-
2201
- // src/logging/Logger.ts
2202
- var isBrowser2 = typeof window !== "undefined";
2203
- var globalConfig = { ...DEFAULT_LOGGING_CONFIG };
2204
- function configureLogging(config) {
2205
- globalConfig = { ...globalConfig, ...config };
2206
- }
2207
- function getLoggingConfig() {
2208
- return { ...globalConfig };
2209
- }
2210
- function resetLoggingConfig() {
2211
- globalConfig = { ...DEFAULT_LOGGING_CONFIG };
2212
- }
2213
- function setLogLevel(level) {
2214
- globalConfig.level = level;
2215
- }
2216
- function setLoggingEnabled(enabled) {
2217
- globalConfig.enabled = enabled;
2218
- }
2219
- var consoleSink = (entry) => {
2220
- const consoleMethod = entry.level === "error" ? "error" : entry.level === "warn" ? "warn" : "log";
2221
- if (globalConfig.format === "pretty" && isBrowser2) {
2222
- const args = createBrowserConsoleArgs(entry);
2223
- console[consoleMethod](...args);
2224
- } else {
2225
- const formatter = getFormatter(globalConfig.format);
2226
- const formatted = formatter(entry);
2227
- console[consoleMethod](formatted);
2228
- }
2229
- };
2230
- function getActiveSink() {
2231
- return globalConfig.sink || consoleSink;
2232
- }
2233
- function shouldLog(level) {
2234
- if (!globalConfig.enabled) return false;
2235
- return LOG_LEVEL_PRIORITY[level] <= LOG_LEVEL_PRIORITY[globalConfig.level];
2236
- }
2237
- var Logger = class _Logger {
2238
- constructor(module) {
2239
- this.module = module;
2240
- }
2241
- log(level, message, data) {
2242
- if (!shouldLog(level)) return;
2243
- const entry = {
2244
- timestamp: Date.now(),
2245
- level,
2246
- module: this.module,
2247
- message,
2248
- data
2249
- };
2250
- if (data?.error instanceof Error) {
2251
- entry.error = data.error;
2252
- const { error, ...rest } = data;
2253
- entry.data = Object.keys(rest).length > 0 ? rest : void 0;
2254
- }
2255
- getActiveSink()(entry);
2256
- }
2257
- error(message, data) {
2258
- this.log("error", message, data);
2259
- }
2260
- warn(message, data) {
2261
- this.log("warn", message, data);
2262
- }
2263
- info(message, data) {
2264
- this.log("info", message, data);
2265
- }
2266
- debug(message, data) {
2267
- this.log("debug", message, data);
2268
- }
2269
- trace(message, data) {
2270
- this.log("trace", message, data);
2271
- }
2272
- verbose(message, data) {
2273
- this.log("verbose", message, data);
2274
- }
2275
- child(subModule) {
2276
- return new _Logger(`${this.module}.${subModule}`);
2277
- }
2278
- };
2279
- var loggerCache = /* @__PURE__ */ new Map();
2280
- function createLogger(module) {
2281
- let logger12 = loggerCache.get(module);
2282
- if (!logger12) {
2283
- logger12 = new Logger(module);
2284
- loggerCache.set(module, logger12);
2285
- }
2286
- return logger12;
2287
- }
2288
- var noopLogger = {
2289
- module: "noop",
2290
- error: () => {
2291
- },
2292
- warn: () => {
2293
- },
2294
- info: () => {
2295
- },
2296
- debug: () => {
2297
- },
2298
- trace: () => {
2299
- },
2300
- verbose: () => {
2301
- },
2302
- child: () => noopLogger
2303
- };
2304
-
2305
2027
  // src/utils/runtime.ts
2306
2028
  function isIOSSafari() {
2307
2029
  if (typeof navigator === "undefined") return false;
@@ -2931,7 +2653,6 @@ LAM_BLENDSHAPES.forEach((name, index) => {
2931
2653
  var UPPER_FACE_SET = new Set(UPPER_FACE_BLENDSHAPES);
2932
2654
 
2933
2655
  // src/inference/WhisperInference.ts
2934
- import { pipeline, env } from "@huggingface/transformers";
2935
2656
  var logger4 = createLogger("Whisper");
2936
2657
  var WhisperInference = class _WhisperInference {
2937
2658
  constructor(config = {}) {
@@ -3026,7 +2747,7 @@ var WhisperInference = class _WhisperInference {
3026
2747
  };
3027
2748
  logger4.info("Forcing WebGPU execution providers");
3028
2749
  }
3029
- this.pipeline = await pipeline(
2750
+ this.pipeline = await pipeline3(
3030
2751
  "automatic-speech-recognition",
3031
2752
  modelName,
3032
2753
  pipelineOptions
@@ -4529,9 +4250,8 @@ Emotion2VecInference.isWebGPUAvailable = isWebGPUAvailable;
4529
4250
 
4530
4251
  // src/inference/ChatterboxTurboInference.ts
4531
4252
  import ort from "onnxruntime-web/webgpu";
4532
- import { AutoTokenizer, env as env2 } from "@huggingface/transformers";
4533
4253
  var logger9 = createLogger("ChatterboxTurbo");
4534
- env2.allowLocalModels = true;
4254
+ env.allowLocalModels = true;
4535
4255
  ort.env.wasm.wasmPaths = "https://cdn.jsdelivr.net/npm/onnxruntime-web@1.23.2/dist/";
4536
4256
 
4537
4257
  // src/inference/SafariSpeechRecognition.ts
@@ -6424,8 +6144,8 @@ async function nukeBrowserCaches(preventRecreation = false) {
6424
6144
  totalDeleted: deletedCount
6425
6145
  });
6426
6146
  if (preventRecreation) {
6427
- const { env: env3 } = await import("@huggingface/transformers");
6428
- env3.useBrowserCache = false;
6147
+ const { env: env2 } = await import("./transformers.web-ALDLCPHT.mjs");
6148
+ env2.useBrowserCache = false;
6429
6149
  logger11.warn("Browser cache creation disabled (env.useBrowserCache = false)");
6430
6150
  }
6431
6151
  return deletedCount;