@salty-css/core 0.0.1-alpha.99 → 0.1.0-alpha.0
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/.saltyrc.schema.json +11 -3
- package/README.md +415 -47
- package/bin/index.cjs +3 -1
- package/bin/index.js +2 -2
- package/bin/main.cjs +448 -11
- package/bin/main.js +411 -209
- package/cache/resolve-dynamic-config-cache.cjs +24 -0
- package/cache/resolve-dynamic-config-cache.d.ts +1 -0
- package/cache/resolve-dynamic-config-cache.js +24 -0
- package/class-name-generator-B2Pb2obX.cjs +74 -0
- package/class-name-generator-YeSQe_Ik.js +75 -0
- package/compiler/get-files.cjs +25 -0
- package/compiler/get-files.js +25 -0
- package/compiler/get-function-range.cjs +22 -0
- package/compiler/get-function-range.d.ts +1 -0
- package/compiler/get-function-range.js +22 -0
- package/compiler/helpers.cjs +25 -0
- package/compiler/helpers.d.ts +5 -0
- package/compiler/helpers.js +24 -0
- package/compiler/salty-compiler.cjs +707 -0
- package/compiler/salty-compiler.d.ts +57 -0
- package/compiler/salty-compiler.js +689 -0
- package/config/define-config.d.ts +1 -1
- package/config/index.cjs +16 -1
- package/config/index.d.ts +2 -1
- package/config/index.js +14 -2
- package/css/index.cjs +12 -1
- package/css/index.d.ts +4 -1
- package/css/index.js +10 -2
- package/css/keyframes.cjs +49 -0
- package/css/keyframes.d.ts +22 -0
- package/css/keyframes.js +49 -0
- package/css/media.cjs +93 -0
- package/css/media.d.ts +87 -0
- package/css/media.js +93 -0
- package/css/merge.cjs +15 -0
- package/css/merge.d.ts +7 -0
- package/css/merge.js +15 -0
- package/css/token.cjs +4 -0
- package/css/token.d.ts +1 -0
- package/css/token.js +4 -0
- package/dash-case-DIwKaYgE.cjs +9 -0
- package/dash-case-DblXvymC.js +10 -0
- package/define-templates-CVhhgPnd.js +60 -0
- package/define-templates-Deq1aCbN.cjs +59 -0
- package/factories/define-global-styles.d.ts +7 -0
- package/factories/define-media-query.d.ts +8 -0
- package/factories/define-templates.d.ts +27 -0
- package/factories/define-variables.d.ts +12 -0
- package/factories/index.cjs +37 -0
- package/factories/index.d.ts +4 -0
- package/factories/index.js +37 -0
- package/generators/class-name-generator.d.ts +7 -0
- package/generators/index.cjs +57 -0
- package/generators/index.d.ts +2 -0
- package/generators/index.js +58 -0
- package/generators/styled-generator.d.ts +20 -0
- package/generators/styles-generator.d.ts +22 -0
- package/helpers/color.d.ts +18 -0
- package/helpers/index.cjs +53 -0
- package/helpers/index.d.ts +2 -0
- package/helpers/index.js +53 -0
- package/helpers/viewport-clamp.d.ts +9 -0
- package/index-ByR0nfaf.cjs +4 -0
- package/index-DKz1QXqs.js +4 -0
- package/instances/classname-instance.cjs +31 -0
- package/instances/classname-instance.d.ts +10 -0
- package/instances/classname-instance.js +31 -0
- package/package.json +71 -8
- package/parse-styles-BTIoYnBr.js +232 -0
- package/parse-styles-CA3TP5n1.cjs +231 -0
- package/parsers/index.cjs +58 -0
- package/parsers/index.d.ts +5 -0
- package/parsers/index.js +59 -0
- package/parsers/parse-modifiers.d.ts +3 -0
- package/parsers/parse-styles.d.ts +13 -0
- package/parsers/parse-templates.d.ts +4 -0
- package/parsers/parse-tokens.d.ts +3 -0
- package/parsers/parser-types.d.ts +8 -0
- package/parsers/property-name-check.d.ts +1 -0
- package/parsers/unit-check.d.ts +7 -0
- package/pascal-case-By_l58S-.cjs +7 -0
- package/pascal-case-F3Usi5Wf.js +8 -0
- package/{react-styled-file-CGVf5n1B.js → react-styled-file-B99mwk0w.js} +2 -2
- package/react-styled-file-U02jek-B.cjs +11 -0
- package/react-vanilla-file-Bj6XC8GS.cjs +18 -0
- package/{react-vanilla-file-CCXbsjIb.js → react-vanilla-file-D9px70iK.js} +2 -2
- package/runtime/index.cjs +11 -0
- package/runtime/index.d.ts +7 -0
- package/runtime/index.js +11 -0
- package/salty.config-DjosWdPw.js +4 -0
- package/salty.config-cqavVm2t.cjs +4 -0
- package/server/index.cjs +4 -0
- package/server/index.d.ts +1 -0
- package/server/index.js +4 -0
- package/server/should-restart.d.ts +1 -0
- package/should-restart-CQsyHls3.cjs +17 -0
- package/should-restart-CXIO0jxY.js +18 -0
- package/templates/salty-reset.d.ts +2 -0
- package/to-hash-C05Y906F.cjs +24 -0
- package/to-hash-DAN2LcHK.js +25 -0
- package/types/cli-types.d.ts +10 -0
- package/types/config-types.d.ts +85 -0
- package/types/index.d.ts +44 -23
- package/util/dot-case.d.ts +1 -0
- package/util/index.cjs +14 -1
- package/util/index.js +11 -8
- package/viewport-clamp-CEmzmcSj.cjs +10 -0
- package/viewport-clamp-K553uXu3.js +11 -0
- package/compiler/index.cjs +0 -1
- package/compiler/index.d.ts +0 -16
- package/compiler/index.js +0 -18
- package/config/config-types.d.ts +0 -65
- package/dash-case-DKzpenwY.cjs +0 -1
- package/dash-case-DMQMcCO6.js +0 -19
- package/generator/index.cjs +0 -1
- package/generator/index.d.ts +0 -1
- package/generator/index.js +0 -65
- package/generator/parse-modifiers.d.ts +0 -3
- package/generator/parse-styles.d.ts +0 -2
- package/generator/parse-templates.d.ts +0 -2
- package/generator/parse-tokens.d.ts +0 -2
- package/generator/parser-types.d.ts +0 -4
- package/generator/style-generator.d.ts +0 -33
- package/index-84Wroia-.cjs +0 -1
- package/index-BGaLvshf.js +0 -232
- package/index-BKoD9apd.cjs +0 -11
- package/index-D_732b92.js +0 -4
- package/parse-templates-DUUSaubj.js +0 -96
- package/parse-templates-DVK3iZIl.cjs +0 -8
- package/pascal-case-BQpR5PdN.js +0 -6
- package/pascal-case-iWoaJWwT.cjs +0 -1
- package/react-styled-file-Dkubsz-U.cjs +0 -8
- package/react-vanilla-file-CG_WJLam.cjs +0 -15
- package/salty.config-BhBY_oOk.js +0 -10
- package/salty.config-Dk6ZcCxI.cjs +0 -7
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const promises = require("fs/promises");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const resolveDynamicConfigCache = async () => {
|
|
6
|
+
const currentDir = process.cwd();
|
|
7
|
+
const filename = "config-cache.json";
|
|
8
|
+
const patterns = ["", "saltygen", "src", "src/saltygen", "cache", "src/cache", "saltygen/cache", "src/saltygen/cache"];
|
|
9
|
+
let contents = "";
|
|
10
|
+
for (const pattern of patterns) {
|
|
11
|
+
const potentialPath = path.join(currentDir, pattern, filename);
|
|
12
|
+
try {
|
|
13
|
+
contents = await promises.readFile(potentialPath, "utf8");
|
|
14
|
+
break;
|
|
15
|
+
} catch {
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (!contents) {
|
|
19
|
+
console.warn(`Could not find config cache file (${filename}) in any of the expected locations.`);
|
|
20
|
+
return {};
|
|
21
|
+
}
|
|
22
|
+
return JSON.parse(contents);
|
|
23
|
+
};
|
|
24
|
+
exports.resolveDynamicConfigCache = resolveDynamicConfigCache;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const resolveDynamicConfigCache: () => Promise<any>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { readFile } from "fs/promises";
|
|
2
|
+
import { join } from "path";
|
|
3
|
+
const resolveDynamicConfigCache = async () => {
|
|
4
|
+
const currentDir = process.cwd();
|
|
5
|
+
const filename = "config-cache.json";
|
|
6
|
+
const patterns = ["", "saltygen", "src", "src/saltygen", "cache", "src/cache", "saltygen/cache", "src/saltygen/cache"];
|
|
7
|
+
let contents = "";
|
|
8
|
+
for (const pattern of patterns) {
|
|
9
|
+
const potentialPath = join(currentDir, pattern, filename);
|
|
10
|
+
try {
|
|
11
|
+
contents = await readFile(potentialPath, "utf8");
|
|
12
|
+
break;
|
|
13
|
+
} catch {
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (!contents) {
|
|
17
|
+
console.warn(`Could not find config cache file (${filename}) in any of the expected locations.`);
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
return JSON.parse(contents);
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
resolveDynamicConfigCache
|
|
24
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
const parseStyles = require("./parse-styles-CA3TP5n1.cjs");
|
|
6
|
+
const dashCase = require("./dash-case-DIwKaYgE.cjs");
|
|
7
|
+
const toHash = require("./to-hash-C05Y906F.cjs");
|
|
8
|
+
class StylesGenerator {
|
|
9
|
+
constructor(params) {
|
|
10
|
+
__publicField(this, "buildContext", {});
|
|
11
|
+
this.params = params;
|
|
12
|
+
}
|
|
13
|
+
get priority() {
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
16
|
+
get isRoot() {
|
|
17
|
+
return this.priority === 0;
|
|
18
|
+
}
|
|
19
|
+
get hash() {
|
|
20
|
+
const { base, variants, compoundVariants, anyOfVariants } = this.params;
|
|
21
|
+
return toHash.toHash({ base, variants, compoundVariants, anyOfVariants });
|
|
22
|
+
}
|
|
23
|
+
get cssClassName() {
|
|
24
|
+
return this.hash;
|
|
25
|
+
}
|
|
26
|
+
get classNames() {
|
|
27
|
+
const classNames = /* @__PURE__ */ new Set([this.cssClassName]);
|
|
28
|
+
const { className } = this.params;
|
|
29
|
+
if (typeof className == "string") classNames.add(className);
|
|
30
|
+
if (typeof className == "object") className.forEach((c) => classNames.add(c));
|
|
31
|
+
this.getTemplateClasses().forEach((c) => classNames.add(c));
|
|
32
|
+
if (this.buildContext.classNames) this.buildContext.classNames.forEach((c) => classNames.add(c));
|
|
33
|
+
return [...classNames].join(" ");
|
|
34
|
+
}
|
|
35
|
+
get cssFileName() {
|
|
36
|
+
const { callerName } = this.buildContext;
|
|
37
|
+
if (callerName) {
|
|
38
|
+
const dasherized = dashCase.dashCase(callerName);
|
|
39
|
+
return `cl_${dasherized}-${this.hash}.css`;
|
|
40
|
+
}
|
|
41
|
+
return `${this.hash}.css`;
|
|
42
|
+
}
|
|
43
|
+
get css() {
|
|
44
|
+
const { base = {}, variants = {}, compoundVariants = [], anyOfVariants = [] } = this.params;
|
|
45
|
+
const { config } = this.buildContext;
|
|
46
|
+
const combinedStyles = { ...base, variants, compoundVariants, anyOfVariants };
|
|
47
|
+
const css = parseStyles.parseAndJoinStyles(combinedStyles, `.${this.cssClassName}`, config, this.isRoot);
|
|
48
|
+
return css;
|
|
49
|
+
}
|
|
50
|
+
getTemplateClasses(config = this.buildContext.config) {
|
|
51
|
+
if (!(config == null ? void 0 : config.templates) || !this.params.base || this.priority > 0) return [];
|
|
52
|
+
const templateKeys = Object.keys(config.templates);
|
|
53
|
+
return Object.entries(this.params.base).reduce((acc, [key, value]) => {
|
|
54
|
+
if (templateKeys.includes(key)) acc.push("t_" + toHash.toHash(dashCase.dashCase(`${key}-${value}`), 4));
|
|
55
|
+
return acc;
|
|
56
|
+
}, []);
|
|
57
|
+
}
|
|
58
|
+
_withBuildContext(context) {
|
|
59
|
+
this.buildContext = context;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
class ClassNameGenerator extends StylesGenerator {
|
|
64
|
+
constructor(_params) {
|
|
65
|
+
super(_params);
|
|
66
|
+
this._params = _params;
|
|
67
|
+
}
|
|
68
|
+
get priority() {
|
|
69
|
+
if (this.params.priority) return this.params.priority;
|
|
70
|
+
return 0;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.ClassNameGenerator = ClassNameGenerator;
|
|
74
|
+
exports.StylesGenerator = StylesGenerator;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import { p as parseAndJoinStyles } from "./parse-styles-BTIoYnBr.js";
|
|
5
|
+
import { d as dashCase } from "./dash-case-DblXvymC.js";
|
|
6
|
+
import { t as toHash } from "./to-hash-DAN2LcHK.js";
|
|
7
|
+
class StylesGenerator {
|
|
8
|
+
constructor(params) {
|
|
9
|
+
__publicField(this, "buildContext", {});
|
|
10
|
+
this.params = params;
|
|
11
|
+
}
|
|
12
|
+
get priority() {
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
get isRoot() {
|
|
16
|
+
return this.priority === 0;
|
|
17
|
+
}
|
|
18
|
+
get hash() {
|
|
19
|
+
const { base, variants, compoundVariants, anyOfVariants } = this.params;
|
|
20
|
+
return toHash({ base, variants, compoundVariants, anyOfVariants });
|
|
21
|
+
}
|
|
22
|
+
get cssClassName() {
|
|
23
|
+
return this.hash;
|
|
24
|
+
}
|
|
25
|
+
get classNames() {
|
|
26
|
+
const classNames = /* @__PURE__ */ new Set([this.cssClassName]);
|
|
27
|
+
const { className } = this.params;
|
|
28
|
+
if (typeof className == "string") classNames.add(className);
|
|
29
|
+
if (typeof className == "object") className.forEach((c) => classNames.add(c));
|
|
30
|
+
this.getTemplateClasses().forEach((c) => classNames.add(c));
|
|
31
|
+
if (this.buildContext.classNames) this.buildContext.classNames.forEach((c) => classNames.add(c));
|
|
32
|
+
return [...classNames].join(" ");
|
|
33
|
+
}
|
|
34
|
+
get cssFileName() {
|
|
35
|
+
const { callerName } = this.buildContext;
|
|
36
|
+
if (callerName) {
|
|
37
|
+
const dasherized = dashCase(callerName);
|
|
38
|
+
return `cl_${dasherized}-${this.hash}.css`;
|
|
39
|
+
}
|
|
40
|
+
return `${this.hash}.css`;
|
|
41
|
+
}
|
|
42
|
+
get css() {
|
|
43
|
+
const { base = {}, variants = {}, compoundVariants = [], anyOfVariants = [] } = this.params;
|
|
44
|
+
const { config } = this.buildContext;
|
|
45
|
+
const combinedStyles = { ...base, variants, compoundVariants, anyOfVariants };
|
|
46
|
+
const css = parseAndJoinStyles(combinedStyles, `.${this.cssClassName}`, config, this.isRoot);
|
|
47
|
+
return css;
|
|
48
|
+
}
|
|
49
|
+
getTemplateClasses(config = this.buildContext.config) {
|
|
50
|
+
if (!(config == null ? void 0 : config.templates) || !this.params.base || this.priority > 0) return [];
|
|
51
|
+
const templateKeys = Object.keys(config.templates);
|
|
52
|
+
return Object.entries(this.params.base).reduce((acc, [key, value]) => {
|
|
53
|
+
if (templateKeys.includes(key)) acc.push("t_" + toHash(dashCase(`${key}-${value}`), 4));
|
|
54
|
+
return acc;
|
|
55
|
+
}, []);
|
|
56
|
+
}
|
|
57
|
+
_withBuildContext(context) {
|
|
58
|
+
this.buildContext = context;
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
class ClassNameGenerator extends StylesGenerator {
|
|
63
|
+
constructor(_params) {
|
|
64
|
+
super(_params);
|
|
65
|
+
this._params = _params;
|
|
66
|
+
}
|
|
67
|
+
get priority() {
|
|
68
|
+
if (this.params.priority) return this.params.priority;
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
ClassNameGenerator as C,
|
|
74
|
+
StylesGenerator as S
|
|
75
|
+
};
|
|
@@ -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 @@
|
|
|
1
|
+
export declare const getFunctionRange: (contents: string, name: string) => Promise<[number, number]>;
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const path = require("path");
|
|
4
|
+
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
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
|
+
while (/core\/?(src\/)?$/.test(pathname) === false) {
|
|
8
|
+
pathname = path.join(pathname, "../");
|
|
9
|
+
}
|
|
10
|
+
return pathname;
|
|
11
|
+
};
|
|
12
|
+
const resolveExportValue = async (value, maxLevel = 10, _level = 0) => {
|
|
13
|
+
if (_level >= maxLevel) return value;
|
|
14
|
+
if (value instanceof Promise) return await resolveExportValue(await value, _level + 1, maxLevel);
|
|
15
|
+
if (typeof value === "function" && "_shouldResolve" in value) return await resolveExportValue(await value(), _level + 1, maxLevel);
|
|
16
|
+
return value;
|
|
17
|
+
};
|
|
18
|
+
const saltyFileExtensions = ["salty", "css", "styles", "styled"];
|
|
19
|
+
const saltyFileRegExp = (additional = []) => new RegExp(`\\.(${[...saltyFileExtensions, ...additional].join("|")})\\.`);
|
|
20
|
+
const isSaltyFile = (file, additional = []) => saltyFileRegExp(additional).test(file);
|
|
21
|
+
exports.getCorePackageRoot = getCorePackageRoot;
|
|
22
|
+
exports.isSaltyFile = isSaltyFile;
|
|
23
|
+
exports.resolveExportValue = resolveExportValue;
|
|
24
|
+
exports.saltyFileExtensions = saltyFileExtensions;
|
|
25
|
+
exports.saltyFileRegExp = saltyFileRegExp;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const getCorePackageRoot: () => string;
|
|
2
|
+
export declare const resolveExportValue: <T>(value: unknown, maxLevel?: number, _level?: number) => Promise<T>;
|
|
3
|
+
export declare const saltyFileExtensions: string[];
|
|
4
|
+
export declare const saltyFileRegExp: (additional?: string[]) => RegExp;
|
|
5
|
+
export declare const isSaltyFile: (file: string, additional?: string[]) => boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { join } from "path";
|
|
2
|
+
const getCorePackageRoot = () => {
|
|
3
|
+
let { pathname } = new URL(import.meta.url);
|
|
4
|
+
while (/core\/?(src\/)?$/.test(pathname) === false) {
|
|
5
|
+
pathname = join(pathname, "../");
|
|
6
|
+
}
|
|
7
|
+
return pathname;
|
|
8
|
+
};
|
|
9
|
+
const resolveExportValue = async (value, maxLevel = 10, _level = 0) => {
|
|
10
|
+
if (_level >= maxLevel) return value;
|
|
11
|
+
if (value instanceof Promise) return await resolveExportValue(await value, _level + 1, maxLevel);
|
|
12
|
+
if (typeof value === "function" && "_shouldResolve" in value) return await resolveExportValue(await value(), _level + 1, maxLevel);
|
|
13
|
+
return value;
|
|
14
|
+
};
|
|
15
|
+
const saltyFileExtensions = ["salty", "css", "styles", "styled"];
|
|
16
|
+
const saltyFileRegExp = (additional = []) => new RegExp(`\\.(${[...saltyFileExtensions, ...additional].join("|")})\\.`);
|
|
17
|
+
const isSaltyFile = (file, additional = []) => saltyFileRegExp(additional).test(file);
|
|
18
|
+
export {
|
|
19
|
+
getCorePackageRoot,
|
|
20
|
+
isSaltyFile,
|
|
21
|
+
resolveExportValue,
|
|
22
|
+
saltyFileExtensions,
|
|
23
|
+
saltyFileRegExp
|
|
24
|
+
};
|