@townco/core 0.0.50 → 0.0.52

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/logger.js CHANGED
@@ -4,12 +4,12 @@
4
4
  * Also captures logs to a global store for in-app viewing
5
5
  * In Node.js environment with logsDir option, also writes to .logs/ directory
6
6
  */
7
- import * as fs from "node:fs";
8
- import * as path from "node:path";
9
7
  import { context, trace } from "@opentelemetry/api";
10
8
  import { logs, SeverityNumber } from "@opentelemetry/api-logs";
11
9
  // Check if running in Node.js
12
10
  const isNode = typeof process !== "undefined" && process.versions?.node;
11
+ let nodeFs = null;
12
+ let nodePath = null;
13
13
  // Global logs directory configuration (set once at app startup for TUI)
14
14
  let globalLogsDir;
15
15
  // Global log store
@@ -105,12 +105,20 @@ export class Logger {
105
105
  if (!isNode || !globalLogsDir)
106
106
  return;
107
107
  try {
108
- // Dynamic import for Node.js modules
108
+ // Lazy load Node.js modules so bundlers don't pull them into browsers
109
+ if (!nodeFs) {
110
+ nodeFs = require("node:fs");
111
+ }
112
+ if (!nodePath) {
113
+ nodePath = require("node:path");
114
+ }
115
+ if (!nodeFs || !nodePath)
116
+ return;
109
117
  this.logsDir = globalLogsDir;
110
- this.logFilePath = path.join(this.logsDir, `${this.service}.log`);
118
+ this.logFilePath = nodePath.join(this.logsDir, `${this.service}.log`);
111
119
  // Create logs directory if it doesn't exist
112
- if (!fs.existsSync(this.logsDir)) {
113
- fs.mkdirSync(this.logsDir, { recursive: true });
120
+ if (!nodeFs.existsSync(this.logsDir)) {
121
+ nodeFs.mkdirSync(this.logsDir, { recursive: true });
114
122
  }
115
123
  }
116
124
  catch (_error) {
package/dist/path.d.ts CHANGED
@@ -1 +1,4 @@
1
- export declare const findRoot: (dir?: string, rootMarker?: string) => Promise<string>;
1
+ export declare const findRoot: ({ dir, rootMarker, }?: {
2
+ dir?: string;
3
+ rootMarker?: string;
4
+ }) => Promise<string>;
package/dist/path.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  const ROOT_MARKER = ".root";
4
- export const findRoot = async (dir = process.cwd(), rootMarker = ROOT_MARKER) => {
4
+ export const findRoot = async ({ dir = process.cwd(), rootMarker = ROOT_MARKER, } = {}) => {
5
5
  const rootMarkerPath = path.join(dir, rootMarker);
6
6
  if ((await fs.exists(rootMarkerPath)) &&
7
7
  (await fs.stat(rootMarkerPath).then((stat) => stat.isFile())))
8
8
  return dir;
9
9
  if (dir === "/")
10
10
  throw new Error(`Could not find root directory with marker '${rootMarker}'`);
11
- return await findRoot(path.dirname(dir), rootMarker);
11
+ return await findRoot({ dir: path.dirname(dir), rootMarker });
12
12
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@townco/core",
3
3
  "type": "module",
4
- "version": "0.0.50",
4
+ "version": "0.0.52",
5
5
  "description": "core",
6
6
  "license": "UNLICENSED",
7
7
  "main": "./dist/index.js",
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "devDependencies": {
28
28
  "typescript": "^5.9.3",
29
- "@townco/tsconfig": "0.1.69"
29
+ "@townco/tsconfig": "0.1.71"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "tsc",