@salty-css/core 0.0.1-alpha.325 → 0.0.1-alpha.327

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.
@@ -5,6 +5,7 @@ const path = require("path");
5
5
  const compiler_helpers = require("../compiler/helpers.cjs");
6
6
  const resolveDynamicConfigCache = async () => {
7
7
  const corePackageRoot = compiler_helpers.getCorePackageRoot();
8
+ if (!corePackageRoot) throw new Error("Could not resolve core package root");
8
9
  const coreConfigDest = path.join(corePackageRoot, "cache/config-cache.json");
9
10
  const contents = await promises.readFile(coreConfigDest, "utf8");
10
11
  if (!contents) throw new Error(`Could not find config cache file at ${coreConfigDest}`);
@@ -3,6 +3,7 @@ import { join } from "path";
3
3
  import { getCorePackageRoot } from "../compiler/helpers.js";
4
4
  const resolveDynamicConfigCache = async () => {
5
5
  const corePackageRoot = getCorePackageRoot();
6
+ if (!corePackageRoot) throw new Error("Could not resolve core package root");
6
7
  const coreConfigDest = join(corePackageRoot, "cache/config-cache.json");
7
8
  const contents = await readFile(coreConfigDest, "utf8");
8
9
  if (!contents) throw new Error(`Could not find config cache file at ${coreConfigDest}`);
@@ -3,12 +3,21 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const path = require("path");
4
4
  var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
5
5
  const getCorePackageRoot = () => {
6
- let { pathname } = new URL(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("compiler/helpers.cjs", document.baseURI).href);
7
- console.log("getCorePackageRoot pathname start:", pathname);
8
- while (/core\/?(src\/)?$/.test(pathname) === false) {
9
- pathname = path.join(pathname, "../");
6
+ try {
7
+ console.log("getCorePackageRoot import.meta.url:", typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("compiler/helpers.cjs", document.baseURI).href);
8
+ console.log("getCorePackageRoot process.cwd():", process.cwd());
9
+ const currentDir = (typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("compiler/helpers.cjs", document.baseURI).href) || process.cwd();
10
+ console.log("getCorePackageRoot currentDir:", currentDir);
11
+ let { pathname } = new URL(currentDir);
12
+ console.log("getCorePackageRoot pathname start:", pathname);
13
+ while (/core\/?(src\/)?$/.test(pathname) === false) {
14
+ pathname = path.join(pathname, "../");
15
+ }
16
+ return pathname;
17
+ } catch (error) {
18
+ console.error("Error in getCorePackageRoot:", error);
19
+ return void 0;
10
20
  }
11
- return pathname;
12
21
  };
13
22
  const resolveExportValue = async (value, maxLevel = 10, _level = 0) => {
14
23
  if (_level >= maxLevel) return value;
@@ -1,4 +1,4 @@
1
- export declare const getCorePackageRoot: () => string;
1
+ export declare const getCorePackageRoot: () => string | undefined;
2
2
  export declare const resolveExportValue: <T>(value: unknown, maxLevel?: number, _level?: number) => Promise<T>;
3
3
  export declare const saltyFileExtensions: string[];
4
4
  export declare const saltyFileRegExp: (additional?: string[]) => RegExp;
@@ -1,11 +1,20 @@
1
1
  import { join } from "path";
2
2
  const getCorePackageRoot = () => {
3
- let { pathname } = new URL(import.meta.url);
4
- console.log("getCorePackageRoot pathname start:", pathname);
5
- while (/core\/?(src\/)?$/.test(pathname) === false) {
6
- pathname = join(pathname, "../");
3
+ try {
4
+ console.log("getCorePackageRoot import.meta.url:", import.meta.url);
5
+ console.log("getCorePackageRoot process.cwd():", process.cwd());
6
+ const currentDir = import.meta.url || process.cwd();
7
+ console.log("getCorePackageRoot currentDir:", currentDir);
8
+ let { pathname } = new URL(currentDir);
9
+ console.log("getCorePackageRoot pathname start:", pathname);
10
+ while (/core\/?(src\/)?$/.test(pathname) === false) {
11
+ pathname = join(pathname, "../");
12
+ }
13
+ return pathname;
14
+ } catch (error) {
15
+ console.error("Error in getCorePackageRoot:", error);
16
+ return void 0;
7
17
  }
8
- return pathname;
9
18
  };
10
19
  const resolveExportValue = async (value, maxLevel = 10, _level = 0) => {
11
20
  if (_level >= maxLevel) return value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.325",
3
+ "version": "0.0.1-alpha.327",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",