@hanzogui/helpers-node 2.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Nate Wienert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,37 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var getDefaultGuiOptions_exports = {};
22
+ __export(getDefaultGuiOptions_exports, {
23
+ getDefaultGuiOptions: () => getDefaultGuiOptions
24
+ });
25
+ module.exports = __toCommonJS(getDefaultGuiOptions_exports);
26
+ var import_getGuiDefaultPath = require("./getGuiDefaultPath.cjs");
27
+ async function getDefaultGuiOptions({
28
+ cwd = "."
29
+ }) {
30
+ return {
31
+ platform: "native",
32
+ components: ["@hanzo/gui"],
33
+ config: await (0, import_getGuiDefaultPath.getDefaultGuiConfigPath)({
34
+ cwd
35
+ })
36
+ };
37
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: !0
22
+ }), mod);
23
+ var getDefaultGuiOptions_exports = {};
24
+ __export(getDefaultGuiOptions_exports, {
25
+ getDefaultGuiOptions: () => getDefaultGuiOptions
26
+ });
27
+ module.exports = __toCommonJS(getDefaultGuiOptions_exports);
28
+ var import_getGuiDefaultPath = require("./getGuiDefaultPath.native.js");
29
+ async function getDefaultGuiOptions(param) {
30
+ var {
31
+ cwd = "."
32
+ } = param;
33
+ return {
34
+ platform: "native",
35
+ components: ["@hanzo/gui"],
36
+ config: await (0, import_getGuiDefaultPath.getDefaultGuiConfigPath)({
37
+ cwd
38
+ })
39
+ };
40
+ }
41
+ //# sourceMappingURL=getDefaultGuiOptions.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","getDefaultGuiOptions_exports","__export","getDefaultGuiOptions","module","exports","import_getGuiDefaultPath","require","param","cwd","platform","components","config","getDefaultGuiConfigPath"],"sources":["../src/getDefaultGuiOptions.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,4BAAA;AAAAC,QAAA,CAAAD,4BAAA;EAAAE,oBAAA,EAAAA,CAAA,KAAAA;AAAA;AAEAC,MAAA,CAAAC,OAAA,GAAAT,YAAA,CAAAK,4BAAwC;AAExC,IAAAK,wBAAsB,GAAAC,OAAqB;AAAA,eACnCJ,qBAAAK,KAAA;EACR,IAEwB;IAAAC,GAAA;EAAA,IAAAD,KAAA;EACtB,OAAO;IACLE,QAAA,EAAU;IACVC,UAAA,EAAY,CACZ,YAAQ,CACV;IACFC,MAAA,YAAAN,wBAAA,CAAAO,uBAAA","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var getGuiDefaultPath_exports = {};
22
+ __export(getGuiDefaultPath_exports, {
23
+ getDefaultGuiConfigPath: () => getDefaultGuiConfigPath
24
+ });
25
+ module.exports = __toCommonJS(getGuiDefaultPath_exports);
26
+ var import_node_path = require("node:path"),
27
+ import_fs_extra = require("fs-extra");
28
+ let cachedPath = "";
29
+ async function getDefaultGuiConfigPath({
30
+ cwd = ".",
31
+ cache = !0
32
+ }) {
33
+ if (cache && cachedPath) return cachedPath;
34
+ const defaultPaths = ["gui.config.ts", (0, import_node_path.join)("src", "gui.config.ts")].map(p => (0, import_node_path.join)(cwd, p)),
35
+ existing = (await Promise.all(defaultPaths.map(path => (0, import_fs_extra.pathExists)(path)))).findIndex(x => !!x),
36
+ found = defaultPaths[existing];
37
+ if (!found) throw new Error("No found gui.config.ts");
38
+ return cachedPath = found, found;
39
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: !0
22
+ }), mod);
23
+ var getGuiDefaultPath_exports = {};
24
+ __export(getGuiDefaultPath_exports, {
25
+ getDefaultGuiConfigPath: () => getDefaultGuiConfigPath
26
+ });
27
+ module.exports = __toCommonJS(getGuiDefaultPath_exports);
28
+ var import_path = require("path"),
29
+ import_fs_extra = require("fs-extra"),
30
+ cachedPath = "";
31
+ async function getDefaultGuiConfigPath(param) {
32
+ var {
33
+ cwd = ".",
34
+ cache = !0
35
+ } = param;
36
+ if (cache && cachedPath) return cachedPath;
37
+ var defaultPaths = ["gui.config.ts", (0, import_path.join)("src", "gui.config.ts")].map(function (p) {
38
+ return (0, import_path.join)(cwd, p);
39
+ }),
40
+ existing = (await Promise.all(defaultPaths.map(function (path) {
41
+ return (0, import_fs_extra.pathExists)(path);
42
+ }))).findIndex(function (x) {
43
+ return !!x;
44
+ }),
45
+ found = defaultPaths[existing];
46
+ if (!found) throw new Error("No found gui.config.ts");
47
+ return cachedPath = found, found;
48
+ }
49
+ //# sourceMappingURL=getGuiDefaultPath.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","getGuiDefaultPath_exports","__export","getDefaultGuiConfigPath","module","exports","import_path","require","import_fs_extra","cachedPath","param","cwd","cache","defaultPaths","join","map","p","existing","Promise","all","path","pathExists","findIndex","x"],"sources":["../src/getGuiDefaultPath.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,yBAAA;AAAAC,QAAA,CAAAD,yBAAA;EAAAE,uBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAqB,CAAAK,yBAErB;AAEA,IAAIK,WAAA,GAAaC,OAAA;EAAAC,eAAA,GAAAD,OAAA;EAAAE,UAAA;AAEjB,eAAsBN,wBAAwBO,KAAA;EAC5C;IAAMC,GAAA;IAAAC,KAAA;EAAA,IAAAF,KAAA;EACN,IAAAE,KAAQ,IAAAH,UAAA,EAKU,OAAAA,UAAA;EAClB,IAAII,YAAS,IACX,eAAO,EAGT,IAAMP,WAAA,CAAAQ,IAAgB,wBAAiB,EAA8B,CAAIC,GAAC,WACxEC,CAAA;MACF,OACM,IAAAV,WACE,CAAAQ,IAAQ,EAAAH,GAAI,EAAAK,CAAA;IAGpB;IAAIC,QAAC,UAAAC,OAAA,CAAAC,GAAA,CAAAN,YAAA,CAAAE,GAAA,WAAAK,IAAA;MACH,OAAM,IAAIZ,eAAM,CAAAa,UAAA,EAAAD,IAAwB;IAG1C,KAAAE,SAAA,WAAaC,CAAA,EACN;MACT,SAAAA,CAAA","ignoreList":[]}
@@ -0,0 +1,33 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var getGuiOptions_exports = {};
22
+ __export(getGuiOptions_exports, {
23
+ getGuiOptions: () => getGuiOptions
24
+ });
25
+ module.exports = __toCommonJS(getGuiOptions_exports);
26
+ var import_readGuiOptions = require("./readGuiOptions.cjs");
27
+ async function getGuiOptions({
28
+ cwd = "."
29
+ }) {
30
+ return (await (0, import_readGuiOptions.readGuiOptions)({
31
+ cwd
32
+ })).options;
33
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: !0
22
+ }), mod);
23
+ var getGuiOptions_exports = {};
24
+ __export(getGuiOptions_exports, {
25
+ getGuiOptions: () => getGuiOptions
26
+ });
27
+ module.exports = __toCommonJS(getGuiOptions_exports);
28
+ var import_readGuiOptions = require("./readGuiOptions.native.js");
29
+ async function getGuiOptions(param) {
30
+ var {
31
+ cwd = "."
32
+ } = param;
33
+ return (await (0, import_readGuiOptions.readGuiOptions)({
34
+ cwd
35
+ })).options;
36
+ }
37
+ //# sourceMappingURL=getGuiOptions.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","getGuiOptions_exports","__export","getGuiOptions","module","exports","import_readGuiOptions","require","param","cwd","readGuiOptions"],"sources":["../src/getGuiOptions.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,qBAAA;AAAAC,QAAA,CAAAD,qBAAA;EAAAE,aAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAA+B,CAAAK,qBAAA;AAE/B,IAAAK,qBAAsB,GAAAC,OAAc;AAAA,eAC5BJ,cAAAK,KAAA;EACR,IAEwD;IAAAC,GAAA;EAAA,IAAAD,KAAA;EACtD,QAAQ,UAAMF,qBAAA,CAAAI,cAAA,EAAe;IAC/BD","ignoreList":[]}
package/dist/index.cjs ADDED
@@ -0,0 +1,20 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
7
+ get: () => from[key],
8
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ });
10
+ return to;
11
+ },
12
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
+ value: !0
15
+ }), mod);
16
+ var index_exports = {};
17
+ module.exports = __toCommonJS(index_exports);
18
+ __reExport(index_exports, require("./readGuiOptions.cjs"), module.exports);
19
+ __reExport(index_exports, require("./getGuiDefaultPath.cjs"), module.exports);
20
+ __reExport(index_exports, require("./getGuiOptions.cjs"), module.exports);
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
9
+ get: () => from[key],
10
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
11
+ });
12
+ return to;
13
+ },
14
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
16
+ value: !0
17
+ }), mod);
18
+ var index_exports = {};
19
+ module.exports = __toCommonJS(index_exports);
20
+ __reExport(index_exports, require("./readGuiOptions.native.js"), module.exports);
21
+ __reExport(index_exports, require("./getGuiDefaultPath.native.js"), module.exports);
22
+ __reExport(index_exports, require("./getGuiOptions.native.js"), module.exports);
23
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports","__reExport","require"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA;AACdG,UAAA,CAAAH,aAAA,EAAcI,OAAA,gCAAAH,MADd,CAAAC,OAAA;AAEAC,UAAA,CAAAH,aAAA,EAAcI,OAAA,gCAFd,GAAAH,MAAA,CAAAC,OAAA","ignoreList":[]}
@@ -0,0 +1,59 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: !0
9
+ });
10
+ },
11
+ __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
13
+ get: () => from[key],
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ return to;
17
+ };
18
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
19
+ value: !0
20
+ }), mod);
21
+ var readGuiOptions_exports = {};
22
+ __export(readGuiOptions_exports, {
23
+ readGuiOptions: () => readGuiOptions
24
+ });
25
+ module.exports = __toCommonJS(readGuiOptions_exports);
26
+ var import_node_path = require("node:path"),
27
+ import_fs_extra = require("fs-extra"),
28
+ import_getDefaultGuiOptions = require("./getDefaultGuiOptions.cjs");
29
+ async function readGuiOptions({
30
+ cwd = "."
31
+ }) {
32
+ const filePath = (0, import_node_path.join)(cwd, "gui.json");
33
+ if (!(await (0, import_fs_extra.pathExists)(filePath))) return {
34
+ exists: !1,
35
+ options: await (0, import_getDefaultGuiOptions.getDefaultGuiOptions)({
36
+ cwd
37
+ })
38
+ };
39
+ try {
40
+ const options = await (0, import_fs_extra.readJSON)(filePath);
41
+ if (!Array.isArray(options.components)) throw new Error("Invalid components: not string[]");
42
+ return {
43
+ exists: !0,
44
+ options: {
45
+ ...(!options.config && (await (0, import_getDefaultGuiOptions.getDefaultGuiOptions)({
46
+ cwd
47
+ }))),
48
+ ...options
49
+ }
50
+ };
51
+ } catch (err) {
52
+ return console.error(`Error reading gui.json: ${err.message} ${err.stack}`), {
53
+ exists: !1,
54
+ options: await (0, import_getDefaultGuiOptions.getDefaultGuiOptions)({
55
+ cwd
56
+ })
57
+ };
58
+ }
59
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: !0
11
+ });
12
+ },
13
+ __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
+ value: !0
22
+ }), mod);
23
+ var readGuiOptions_exports = {};
24
+ __export(readGuiOptions_exports, {
25
+ readGuiOptions: () => readGuiOptions
26
+ });
27
+ module.exports = __toCommonJS(readGuiOptions_exports);
28
+ var import_path = require("path"),
29
+ import_fs_extra = require("fs-extra"),
30
+ import_getDefaultGuiOptions = require("./getDefaultGuiOptions.native.js");
31
+ async function readGuiOptions(param) {
32
+ var {
33
+ cwd = "."
34
+ } = param,
35
+ filePath = (0, import_path.join)(cwd, "gui.json");
36
+ if (!(await (0, import_fs_extra.pathExists)(filePath))) return {
37
+ exists: !1,
38
+ options: await (0, import_getDefaultGuiOptions.getDefaultGuiOptions)({
39
+ cwd
40
+ })
41
+ };
42
+ try {
43
+ var options = await (0, import_fs_extra.readJSON)(filePath);
44
+ if (!Array.isArray(options.components)) throw new Error("Invalid components: not string[]");
45
+ return {
46
+ exists: !0,
47
+ options: {
48
+ ...(!options.config && (await (0, import_getDefaultGuiOptions.getDefaultGuiOptions)({
49
+ cwd
50
+ }))),
51
+ ...options
52
+ }
53
+ };
54
+ } catch (err) {
55
+ return console.error(`Error reading gui.json: ${err.message} ${err.stack}`), {
56
+ exists: !1,
57
+ options: await (0, import_getDefaultGuiOptions.getDefaultGuiOptions)({
58
+ cwd
59
+ })
60
+ };
61
+ }
62
+ }
63
+ //# sourceMappingURL=readGuiOptions.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","readGuiOptions_exports","__export","readGuiOptions","module","exports","import_path","require","import_fs_extra","import_getDefaultGuiOptions","param","cwd","filePath","join","pathExists","exists","options","getDefaultGuiOptions","readJSON","Array","isArray","components","Error","config","err","console","error","message","stack"],"sources":["../src/readGuiOptions.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,sBAAA;AAAAC,QAAA,CAAAD,sBAAA;EAAAE,cAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAqB,CAAAK,sBAGrB;AAIA,IAAAK,WAAsB,GAAAC,OAAA,OAAiB;EAAAC,eAGpC,GAAAD,OAAA;EAAAE,2BAAA,GAAAF,OAAA;AACD,eAAMJ,cAAWA,CAAAO,KAAA;EAEjB,IAAI;MAAEC,GAAA;IAAM,IAAAD,KAAA;IAAAE,QAAA,OAAAN,WAAmB,CAAAO,IAAA,EAAAF,GAAA;EAC7B,YAAO,IAAAH,eAAA,CAAAM,UAAA,EAAAF,QAAA,WACL;IACAG,MAAA,GAAS;IACXC,OAAA,YAAAP,2BAAA,CAAAQ,oBAAA;MAGEN;IACF;EAEA;EACE;IAGF,IAAAK,OAAO,aAAAR,eAAA,CAAAU,QAAA,EAAAN,QAAA;IAAA,IACL,CAAAO,KAAQ,CAAAC,OAAA,CAAAJ,OAAA,CAAAK,UAAA,GACR,UAASC,KAAA;IAAA,OACH;MAAsDP,MACvD;MACLC,OAAA;QACF,KAAAA,OAAA,CAAAO,MAAA,eAAAd,2BAAA,CAAAQ,oBAAA;UACFN;QACE;QAGE,GAAAK;MACA;IACF;EACF,SAAAQ,GAAA;IACF,OAAAC,OAAA,CAAAC,KAAA,4BAAAF,GAAA,CAAAG,OAAA,IAAAH,GAAA,CAAAI,KAAA","ignoreList":[]}
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@hanzogui/helpers-node",
3
+ "version": "2.0.0",
4
+ "source": "src/index.ts",
5
+ "files": [
6
+ "src",
7
+ "types",
8
+ "dist"
9
+ ],
10
+ "sideEffects": false,
11
+ "main": "./dist",
12
+ "types": "./types/index.d.ts",
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "scripts": {
17
+ "build": "hanzo-gui-build",
18
+ "watch": "hanzo-gui-build --watch",
19
+ "clean": "hanzo-gui-build clean",
20
+ "clean:build": "hanzo-gui-build clean:build"
21
+ },
22
+ "dependencies": {
23
+ "@hanzogui/types": "workspace:*"
24
+ },
25
+ "devDependencies": {
26
+ "@hanzogui/build": "workspace:*",
27
+ "fs-extra": "^11.2.0"
28
+ }
29
+ }
@@ -0,0 +1,15 @@
1
+ import type { GuiOptions } from '@hanzogui/types'
2
+
3
+ import { getDefaultGuiConfigPath } from './getGuiDefaultPath'
4
+
5
+ export async function getDefaultGuiOptions({
6
+ cwd = '.',
7
+ }: {
8
+ cwd: string
9
+ }): Promise<GuiOptions> {
10
+ return {
11
+ platform: 'native',
12
+ components: ['@hanzo/gui'],
13
+ config: await getDefaultGuiConfigPath({ cwd }),
14
+ }
15
+ }
@@ -0,0 +1,32 @@
1
+ import { join } from 'node:path'
2
+
3
+ import { pathExists } from 'fs-extra'
4
+
5
+ let cachedPath = ''
6
+
7
+ export async function getDefaultGuiConfigPath({
8
+ cwd = '.',
9
+ cache = true,
10
+ }: {
11
+ cwd?: string
12
+ // TODO this isn't passed down / could avoid
13
+ cache?: boolean
14
+ }): Promise<string> {
15
+ if (cache && cachedPath) {
16
+ return cachedPath
17
+ }
18
+
19
+ const defaultPaths = ['gui.config.ts', join('src', 'gui.config.ts')].map((p) =>
20
+ join(cwd, p)
21
+ )
22
+ const existing = (
23
+ await Promise.all(defaultPaths.map((path) => pathExists(path)))
24
+ ).findIndex((x) => !!x)
25
+ const found = defaultPaths[existing]
26
+ if (!found) {
27
+ throw new Error(`No found gui.config.ts`)
28
+ }
29
+
30
+ cachedPath = found
31
+ return found
32
+ }
@@ -0,0 +1,9 @@
1
+ import { readGuiOptions } from './readGuiOptions'
2
+
3
+ export async function getGuiOptions({
4
+ cwd = '.',
5
+ }: {
6
+ cwd?: string
7
+ }): Promise<import('@hanzogui/types/types').GuiOptions> {
8
+ return (await readGuiOptions({ cwd })).options
9
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './readGuiOptions'
2
+ export * from './getGuiDefaultPath'
3
+ export * from './getGuiOptions'
@@ -0,0 +1,43 @@
1
+ import { join } from 'node:path'
2
+
3
+ import type { GuiOptions } from '@hanzogui/types'
4
+ import { pathExists, readJSON } from 'fs-extra'
5
+
6
+ import { getDefaultGuiOptions } from './getDefaultGuiOptions'
7
+
8
+ export async function readGuiOptions({ cwd = '.' }: { cwd: string }): Promise<{
9
+ exists: boolean
10
+ options: GuiOptions
11
+ }> {
12
+ const filePath = join(cwd, 'gui.json')
13
+
14
+ if (!(await pathExists(filePath))) {
15
+ return {
16
+ exists: false,
17
+ options: await getDefaultGuiOptions({ cwd }),
18
+ }
19
+ }
20
+
21
+ try {
22
+ const options = (await readJSON(filePath)) as GuiOptions
23
+
24
+ if (!Array.isArray(options.components)) {
25
+ throw new Error(`Invalid components: not string[]`)
26
+ }
27
+
28
+ return {
29
+ exists: true,
30
+ options: {
31
+ ...(!options.config && (await getDefaultGuiOptions({ cwd }))),
32
+ ...options,
33
+ },
34
+ }
35
+ } catch (err: any) {
36
+ console.error(`Error reading gui.json: ${err.message} ${err.stack}`)
37
+
38
+ return {
39
+ exists: false,
40
+ options: await getDefaultGuiOptions({ cwd }),
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,6 @@
1
+ import type { GuiOptions } from "@hanzogui/types";
2
+ export declare function getDefaultGuiOptions({ cwd }: {
3
+ cwd: string;
4
+ }): Promise<GuiOptions>;
5
+
6
+ //# sourceMappingURL=getDefaultGuiOptions.d.ts.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "mappings": "AAAA,cAAc,kBAAkB;AAIhC,OAAO,iBAAe,qBAAqB,EACzC,OACC;CACD;IACE,QAAQ",
3
+ "names": [],
4
+ "sources": [
5
+ "src/getDefaultGuiOptions.ts"
6
+ ],
7
+ "version": 3,
8
+ "sourcesContent": [
9
+ "import type { GuiOptions } from '@hanzogui/types'\n\nimport { getDefaultGuiConfigPath } from './getGuiDefaultPath'\n\nexport async function getDefaultGuiOptions({\n cwd = '.',\n}: {\n cwd: string\n}): Promise<GuiOptions> {\n return {\n platform: 'native',\n components: ['@hanzo/gui'],\n config: await getDefaultGuiConfigPath({ cwd }),\n }\n}\n"
10
+ ]
11
+ }
@@ -0,0 +1,6 @@
1
+ export declare function getDefaultGuiConfigPath({ cwd, cache }: {
2
+ cwd?: string;
3
+ cache?: boolean;
4
+ }): Promise<string>;
5
+
6
+ //# sourceMappingURL=getGuiDefaultPath.d.ts.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "mappings": "AAMA,OAAO,iBAAe,wBAAwB,EAC5C,KACA,SACC;CACD;CAEA;IACE",
3
+ "names": [],
4
+ "sources": [
5
+ "src/getGuiDefaultPath.ts"
6
+ ],
7
+ "version": 3,
8
+ "sourcesContent": [
9
+ "import { join } from 'node:path'\n\nimport { pathExists } from 'fs-extra'\n\nlet cachedPath = ''\n\nexport async function getDefaultGuiConfigPath({\n cwd = '.',\n cache = true,\n}: {\n cwd?: string\n // TODO this isn't passed down / could avoid\n cache?: boolean\n}): Promise<string> {\n if (cache && cachedPath) {\n return cachedPath\n }\n\n const defaultPaths = ['gui.config.ts', join('src', 'gui.config.ts')].map((p) =>\n join(cwd, p)\n )\n const existing = (\n await Promise.all(defaultPaths.map((path) => pathExists(path)))\n ).findIndex((x) => !!x)\n const found = defaultPaths[existing]\n if (!found) {\n throw new Error(`No found gui.config.ts`)\n }\n\n cachedPath = found\n return found\n}\n"
10
+ ]
11
+ }
@@ -0,0 +1,5 @@
1
+ export declare function getGuiOptions({ cwd }: {
2
+ cwd?: string;
3
+ }): Promise<import("@hanzogui/types/types").GuiOptions>;
4
+
5
+ //# sourceMappingURL=getGuiOptions.d.ts.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "mappings": "AAEA,OAAO,iBAAe,cAAc,EAClC,OACC;CACD;IACE,eAAe",
3
+ "names": [],
4
+ "sources": [
5
+ "src/getGuiOptions.ts"
6
+ ],
7
+ "version": 3,
8
+ "sourcesContent": [
9
+ "import { readGuiOptions } from './readGuiOptions'\n\nexport async function getGuiOptions({\n cwd = '.',\n}: {\n cwd?: string\n}): Promise<import('@hanzogui/types/types').GuiOptions> {\n return (await readGuiOptions({ cwd })).options\n}\n"
10
+ ]
11
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./readGuiOptions";
2
+ export * from "./getGuiDefaultPath";
3
+ export * from "./getGuiOptions";
4
+
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc",
3
+ "names": [],
4
+ "sources": [
5
+ "src/index.ts"
6
+ ],
7
+ "version": 3,
8
+ "sourcesContent": [
9
+ "export * from './readGuiOptions'\nexport * from './getGuiDefaultPath'\nexport * from './getGuiOptions'\n"
10
+ ]
11
+ }
@@ -0,0 +1,9 @@
1
+ import type { GuiOptions } from "@hanzogui/types";
2
+ export declare function readGuiOptions({ cwd }: {
3
+ cwd: string;
4
+ }): Promise<{
5
+ exists: boolean;
6
+ options: GuiOptions;
7
+ }>;
8
+
9
+ //# sourceMappingURL=readGuiOptions.d.ts.map
@@ -0,0 +1,11 @@
1
+ {
2
+ "mappings": "AAEA,cAAc,kBAAkB;AAKhC,OAAO,iBAAe,eAAe,EAAE,OAAa;CAAE;IAAgB,QAAQ;CAC5E;CACA,SAAS",
3
+ "names": [],
4
+ "sources": [
5
+ "src/readGuiOptions.ts"
6
+ ],
7
+ "version": 3,
8
+ "sourcesContent": [
9
+ "import { join } from 'node:path'\n\nimport type { GuiOptions } from '@hanzogui/types'\nimport { pathExists, readJSON } from 'fs-extra'\n\nimport { getDefaultGuiOptions } from './getDefaultGuiOptions'\n\nexport async function readGuiOptions({ cwd = '.' }: { cwd: string }): Promise<{\n exists: boolean\n options: GuiOptions\n}> {\n const filePath = join(cwd, 'gui.json')\n\n if (!(await pathExists(filePath))) {\n return {\n exists: false,\n options: await getDefaultGuiOptions({ cwd }),\n }\n }\n\n try {\n const options = (await readJSON(filePath)) as GuiOptions\n\n if (!Array.isArray(options.components)) {\n throw new Error(`Invalid components: not string[]`)\n }\n\n return {\n exists: true,\n options: {\n ...(!options.config && (await getDefaultGuiOptions({ cwd }))),\n ...options,\n },\n }\n } catch (err: any) {\n console.error(`Error reading gui.json: ${err.message} ${err.stack}`)\n\n return {\n exists: false,\n options: await getDefaultGuiOptions({ cwd }),\n }\n }\n}\n"
10
+ ]
11
+ }