@salty-css/core 0.0.1-alpha.302 → 0.0.1-alpha.303

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.
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const promises = require("fs/promises");
4
4
  const path = require("path");
5
- const helpers = require("../helpers-wv74jTRI.cjs");
5
+ const compiler_helpers = require("../compiler/helpers.cjs");
6
6
  const resolveDynamicConfigCache = async () => {
7
- const corePackageRoot = helpers.getCorePackageRoot();
7
+ const corePackageRoot = compiler_helpers.getCorePackageRoot();
8
8
  const coreConfigDest = path.join(corePackageRoot, "cache/config-cache.json");
9
9
  const contents = await promises.readFile(coreConfigDest, "utf8");
10
10
  if (!contents) throw new Error("Could not find config cache file");
@@ -1,6 +1,6 @@
1
1
  import { readFile } from "fs/promises";
2
2
  import { join } from "path";
3
- import { g as getCorePackageRoot } from "../helpers-DM2fbDDz.js";
3
+ import { getCorePackageRoot } from "../compiler/helpers.js";
4
4
  const resolveDynamicConfigCache = async () => {
5
5
  const corePackageRoot = getCorePackageRoot();
6
6
  const coreConfigDest = join(corePackageRoot, "cache/config-cache.json");
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const fs = require("fs");
4
+ const promises = require("fs/promises");
5
+ const path = require("path");
6
+ const getSaltyRcPath = (dirname) => {
7
+ if (!dirname || dirname === "/") throw new Error("Could not find .saltyrc.json file");
8
+ const rcPath = path.join(dirname, ".saltyrc.json");
9
+ if (!fs.existsSync(rcPath)) return getSaltyRcPath(path.join(dirname, ".."));
10
+ return rcPath;
11
+ };
12
+ const getPackageJsonPath = (dirname) => {
13
+ if (!dirname || dirname === "/") throw new Error("Could not find package.json file");
14
+ const packageJsonPath = path.join(dirname, "package.json");
15
+ if (!fs.existsSync(packageJsonPath)) return getPackageJsonPath(path.join(dirname, ".."));
16
+ return packageJsonPath;
17
+ };
18
+ const getPackageJson = async (dirname) => {
19
+ const packageJsonPath = getPackageJsonPath(dirname);
20
+ const packageJsonContent = await promises.readFile(packageJsonPath, "utf-8").then(JSON.parse).catch(() => void 0);
21
+ return packageJsonContent;
22
+ };
23
+ exports.getPackageJson = getPackageJson;
24
+ exports.getPackageJsonPath = getPackageJsonPath;
25
+ exports.getSaltyRcPath = getSaltyRcPath;
@@ -0,0 +1,25 @@
1
+ import { existsSync } from "fs";
2
+ import { readFile } from "fs/promises";
3
+ import { join } from "path";
4
+ const getSaltyRcPath = (dirname) => {
5
+ if (!dirname || dirname === "/") throw new Error("Could not find .saltyrc.json file");
6
+ const rcPath = join(dirname, ".saltyrc.json");
7
+ if (!existsSync(rcPath)) return getSaltyRcPath(join(dirname, ".."));
8
+ return rcPath;
9
+ };
10
+ const getPackageJsonPath = (dirname) => {
11
+ if (!dirname || dirname === "/") throw new Error("Could not find package.json file");
12
+ const packageJsonPath = join(dirname, "package.json");
13
+ if (!existsSync(packageJsonPath)) return getPackageJsonPath(join(dirname, ".."));
14
+ return packageJsonPath;
15
+ };
16
+ const getPackageJson = async (dirname) => {
17
+ const packageJsonPath = getPackageJsonPath(dirname);
18
+ const packageJsonContent = await readFile(packageJsonPath, "utf-8").then(JSON.parse).catch(() => void 0);
19
+ return packageJsonContent;
20
+ };
21
+ export {
22
+ getPackageJson,
23
+ getPackageJsonPath,
24
+ getSaltyRcPath
25
+ };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const ts = require("typescript");
4
+ const getFunctionRange = (contents, name) => {
5
+ return new Promise((resolve, reject) => {
6
+ const timeout = setTimeout(() => {
7
+ reject(new Error("Timeout"));
8
+ }, 100);
9
+ const sourceFile = ts.createSourceFile("temp.ts", contents, ts.ScriptTarget.Latest, true);
10
+ function visit(node) {
11
+ if (ts.isVariableDeclaration(node) && node.name.getText() === name) {
12
+ const start = node.getStart();
13
+ const end = node.getEnd();
14
+ clearTimeout(timeout);
15
+ resolve([start, end]);
16
+ }
17
+ node.forEachChild(visit);
18
+ }
19
+ visit(sourceFile);
20
+ });
21
+ };
22
+ exports.getFunctionRange = getFunctionRange;
@@ -0,0 +1,22 @@
1
+ import ts from "typescript";
2
+ const getFunctionRange = (contents, name) => {
3
+ return new Promise((resolve, reject) => {
4
+ const timeout = setTimeout(() => {
5
+ reject(new Error("Timeout"));
6
+ }, 100);
7
+ const sourceFile = ts.createSourceFile("temp.ts", contents, ts.ScriptTarget.Latest, true);
8
+ function visit(node) {
9
+ if (ts.isVariableDeclaration(node) && node.name.getText() === name) {
10
+ const start = node.getStart();
11
+ const end = node.getEnd();
12
+ clearTimeout(timeout);
13
+ resolve([start, end]);
14
+ }
15
+ node.forEachChild(visit);
16
+ }
17
+ visit(sourceFile);
18
+ });
19
+ };
20
+ export {
21
+ getFunctionRange
22
+ };
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
3
  const path = require("path");
3
4
  var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
4
5
  const getCorePackageRoot = () => {
5
- let { pathname } = new URL(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("helpers-wv74jTRI.cjs", document.baseURI).href);
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);
6
7
  while (/core\/?(src\/)?$/.test(pathname) === false) {
7
8
  pathname = path.join(pathname, "../");
8
9
  }
@@ -13,6 +13,6 @@ const resolveExportValue = async (value, maxLevel = 10, _level = 0) => {
13
13
  return value;
14
14
  };
15
15
  export {
16
- getCorePackageRoot as g,
17
- resolveExportValue as r
16
+ getCorePackageRoot,
17
+ resolveExportValue
18
18
  };
@@ -9,11 +9,12 @@ const fs = require("fs");
9
9
  const promises = require("fs/promises");
10
10
  const parseStyles = require("../parse-styles-D-p_guRO.cjs");
11
11
  const parsers_index = require("../parsers/index.cjs");
12
+ const compiler_getFiles = require("./get-files.cjs");
12
13
  const winston = require("winston");
13
14
  const css_merge = require("../css/merge.cjs");
14
15
  const defineTemplates = require("../define-templates-Deq1aCbN.cjs");
15
- const ts = require("typescript");
16
- const helpers = require("../helpers-wv74jTRI.cjs");
16
+ const compiler_getFunctionRange = require("./get-function-range.cjs");
17
+ const compiler_helpers = require("./helpers.cjs");
17
18
  var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
18
19
  function _interopNamespaceDefault(e) {
19
20
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -32,19 +33,8 @@ function _interopNamespaceDefault(e) {
32
33
  return Object.freeze(n);
33
34
  }
34
35
  const esbuild__namespace = /* @__PURE__ */ _interopNamespaceDefault(esbuild);
35
- const getPackageJsonPath = (dirname) => {
36
- if (!dirname || dirname === "/") throw new Error("Could not find package.json file");
37
- const packageJsonPath = path.join(dirname, "package.json");
38
- if (!fs.existsSync(packageJsonPath)) return getPackageJsonPath(path.join(dirname, ".."));
39
- return packageJsonPath;
40
- };
41
- const getPackageJson = async (dirname) => {
42
- const packageJsonPath = getPackageJsonPath(dirname);
43
- const packageJsonContent = await promises.readFile(packageJsonPath, "utf-8").then(JSON.parse).catch(() => void 0);
44
- return packageJsonContent;
45
- };
46
36
  const readPackageJsonModule = async (dirname) => {
47
- const packageJsonContent = await getPackageJson(dirname);
37
+ const packageJsonContent = await compiler_getFiles.getPackageJson(dirname);
48
38
  if (!packageJsonContent) return void 0;
49
39
  return packageJsonContent.type;
50
40
  };
@@ -117,24 +107,6 @@ const saltyReset = {
117
107
  lineHeight: "1.15em"
118
108
  }
119
109
  };
120
- const getFunctionRange = (contents, name) => {
121
- return new Promise((resolve, reject) => {
122
- const timeout = setTimeout(() => {
123
- reject(new Error("Timeout"));
124
- }, 100);
125
- const sourceFile = ts.createSourceFile("temp.ts", contents, ts.ScriptTarget.Latest, true);
126
- function visit(node) {
127
- if (ts.isVariableDeclaration(node) && node.name.getText() === name) {
128
- const start = node.getStart();
129
- const end = node.getEnd();
130
- clearTimeout(timeout);
131
- resolve([start, end]);
132
- }
133
- node.forEachChild(visit);
134
- }
135
- visit(sourceFile);
136
- });
137
- };
138
110
  const cache = {
139
111
  externalModules: [],
140
112
  rcFile: void 0,
@@ -337,7 +309,7 @@ const generateConfigStyles = async (dirname, configFiles) => {
337
309
  fs.writeFileSync(tsTokensPath, tsTokensTypes);
338
310
  const configCachePath = path.join(destDir, "cache/config-cache.json");
339
311
  fs.writeFileSync(configCachePath, JSON.stringify(configCacheContent, null, 2));
340
- const corePackageRoot = helpers.getCorePackageRoot();
312
+ const corePackageRoot = compiler_helpers.getCorePackageRoot();
341
313
  const configCacheSecondaryPath = path.join(corePackageRoot, "cache/config-cache.json");
342
314
  fs.writeFileSync(configCacheSecondaryPath, JSON.stringify(configCacheContent, null, 2));
343
315
  };
@@ -493,7 +465,7 @@ const generateCss = async (dirname, prod = isProduction(), clean = true) => {
493
465
  [...files].map(async (src) => {
494
466
  const { contents } = await compileSaltyFile(dirname, src, destDir);
495
467
  for (let [name, value] of Object.entries(contents)) {
496
- const resolved = await helpers.resolveExportValue(value, 1);
468
+ const resolved = await compiler_helpers.resolveExportValue(value, 1);
497
469
  if (resolved.isKeyframes) {
498
470
  generationResults.keyframes.push({
499
471
  value: resolved,
@@ -634,7 +606,7 @@ const generateFile = async (dirname, file, prod = isProduction()) => {
634
606
  const config = await getConfig(dirname);
635
607
  const { contents } = await compileSaltyFile(dirname, file, destDir);
636
608
  for (const [name, value] of Object.entries(contents)) {
637
- const resolved = await helpers.resolveExportValue(value, 1);
609
+ const resolved = await compiler_helpers.resolveExportValue(value, 1);
638
610
  if (resolved.isKeyframes && resolved.css) {
639
611
  const fileName = `a_${resolved.animationName}.css`;
640
612
  const filePath2 = `css/${fileName}`;
@@ -718,7 +690,7 @@ const minimizeFile = async (dirname, file, prod = isProduction()) => {
718
690
  const { contents } = await compileSaltyFile(dirname, file, destDir);
719
691
  let current = original;
720
692
  for (const [name, value] of Object.entries(contents)) {
721
- const resolved = await helpers.resolveExportValue(value, 1);
693
+ const resolved = await compiler_helpers.resolveExportValue(value, 1);
722
694
  if (resolved.isKeyframes) continue;
723
695
  if (!resolved.generator) continue;
724
696
  const generator = resolved.generator._withBuildContext({
@@ -726,7 +698,7 @@ const minimizeFile = async (dirname, file, prod = isProduction()) => {
726
698
  isProduction: prod,
727
699
  config
728
700
  });
729
- const [start, end] = await getFunctionRange(current, name);
701
+ const [start, end] = await compiler_getFunctionRange.getFunctionRange(current, name);
730
702
  const range = current.slice(start, end);
731
703
  if (resolved.isClassName) {
732
704
  const copy = current;
package/compiler/index.js CHANGED
@@ -7,22 +7,12 @@ import { existsSync, mkdirSync, statSync, readdirSync, readFileSync, writeFileSy
7
7
  import { readFile } from "fs/promises";
8
8
  import { p as parseAndJoinStyles, a as parseVariableTokens } from "../parse-styles-CqBQc3eQ.js";
9
9
  import { parseTemplates, getTemplateTypes } from "../parsers/index.js";
10
+ import { getPackageJson } from "./get-files.js";
10
11
  import { createLogger, transports, format } from "winston";
11
12
  import { mergeObjects, mergeFactories } from "../css/merge.js";
12
13
  import { d as defineTemplates } from "../define-templates-CVhhgPnd.js";
13
- import ts from "typescript";
14
- import { r as resolveExportValue, g as getCorePackageRoot } from "../helpers-DM2fbDDz.js";
15
- const getPackageJsonPath = (dirname) => {
16
- if (!dirname || dirname === "/") throw new Error("Could not find package.json file");
17
- const packageJsonPath = join(dirname, "package.json");
18
- if (!existsSync(packageJsonPath)) return getPackageJsonPath(join(dirname, ".."));
19
- return packageJsonPath;
20
- };
21
- const getPackageJson = async (dirname) => {
22
- const packageJsonPath = getPackageJsonPath(dirname);
23
- const packageJsonContent = await readFile(packageJsonPath, "utf-8").then(JSON.parse).catch(() => void 0);
24
- return packageJsonContent;
25
- };
14
+ import { getFunctionRange } from "./get-function-range.js";
15
+ import { resolveExportValue, getCorePackageRoot } from "./helpers.js";
26
16
  const readPackageJsonModule = async (dirname) => {
27
17
  const packageJsonContent = await getPackageJson(dirname);
28
18
  if (!packageJsonContent) return void 0;
@@ -97,24 +87,6 @@ const saltyReset = {
97
87
  lineHeight: "1.15em"
98
88
  }
99
89
  };
100
- const getFunctionRange = (contents, name) => {
101
- return new Promise((resolve, reject) => {
102
- const timeout = setTimeout(() => {
103
- reject(new Error("Timeout"));
104
- }, 100);
105
- const sourceFile = ts.createSourceFile("temp.ts", contents, ts.ScriptTarget.Latest, true);
106
- function visit(node) {
107
- if (ts.isVariableDeclaration(node) && node.name.getText() === name) {
108
- const start = node.getStart();
109
- const end = node.getEnd();
110
- clearTimeout(timeout);
111
- resolve([start, end]);
112
- }
113
- node.forEachChild(visit);
114
- }
115
- visit(sourceFile);
116
- });
117
- };
118
90
  const cache = {
119
91
  externalModules: [],
120
92
  rcFile: void 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.0.1-alpha.302",
3
+ "version": "0.0.1-alpha.303",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -51,6 +51,18 @@
51
51
  "import": "./compiler/index.js",
52
52
  "require": "./compiler/index.cjs"
53
53
  },
54
+ "./compiler/get-files": {
55
+ "import": "./compiler/get-files.js",
56
+ "require": "./compiler/get-files.cjs"
57
+ },
58
+ "./compiler/get-function-range": {
59
+ "import": "./compiler/get-function-range.js",
60
+ "require": "./compiler/get-function-range.cjs"
61
+ },
62
+ "./compiler/helpers": {
63
+ "import": "./compiler/helpers.js",
64
+ "require": "./compiler/helpers.cjs"
65
+ },
54
66
  "./factories": {
55
67
  "import": "./factories/index.js",
56
68
  "require": "./factories/index.cjs"