@intlayer/config 8.1.2 → 8.1.3
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/cjs/_virtual/_rolldown/runtime.cjs +1 -43
- package/dist/cjs/built.cjs +1 -7
- package/dist/cjs/built.cjs.map +1 -1
- package/dist/cjs/client.cjs +1 -40
- package/dist/cjs/configFile/buildConfigurationFields.cjs +1 -188
- package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
- package/dist/cjs/configFile/getConfiguration.cjs +1 -70
- package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
- package/dist/cjs/configFile/index.cjs +1 -10
- package/dist/cjs/configFile/loadConfigurationFile.cjs +1 -33
- package/dist/cjs/configFile/loadConfigurationFile.cjs.map +1 -1
- package/dist/cjs/configFile/searchConfigurationFile.cjs +1 -51
- package/dist/cjs/configFile/searchConfigurationFile.cjs.map +1 -1
- package/dist/cjs/defaultValues/build.cjs +1 -29
- package/dist/cjs/defaultValues/build.cjs.map +1 -1
- package/dist/cjs/defaultValues/compiler.cjs +1 -24
- package/dist/cjs/defaultValues/compiler.cjs.map +1 -1
- package/dist/cjs/defaultValues/content.cjs +1 -56
- package/dist/cjs/defaultValues/content.cjs.map +1 -1
- package/dist/cjs/defaultValues/dictionary.cjs +1 -26
- package/dist/cjs/defaultValues/dictionary.cjs.map +1 -1
- package/dist/cjs/defaultValues/editor.cjs +1 -41
- package/dist/cjs/defaultValues/editor.cjs.map +1 -1
- package/dist/cjs/defaultValues/index.cjs +1 -78
- package/dist/cjs/defaultValues/internationalization.cjs +1 -27
- package/dist/cjs/defaultValues/internationalization.cjs.map +1 -1
- package/dist/cjs/defaultValues/log.cjs +1 -21
- package/dist/cjs/defaultValues/log.cjs.map +1 -1
- package/dist/cjs/defaultValues/routing.cjs +1 -35
- package/dist/cjs/defaultValues/routing.cjs.map +1 -1
- package/dist/cjs/defaultValues/system.cjs +1 -47
- package/dist/cjs/defaultValues/system.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -81
- package/dist/cjs/loadEnvFile.cjs +1 -36
- package/dist/cjs/loadEnvFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/bundleFile.cjs +1 -71
- package/dist/cjs/loadExternalFile/bundleFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/bundleJSFile.cjs +2 -0
- package/dist/cjs/loadExternalFile/bundleJSFile.cjs.map +1 -0
- package/dist/cjs/loadExternalFile/index.cjs +1 -0
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs +1 -79
- package/dist/cjs/loadExternalFile/loadExternalFile.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/parseFileContent.cjs +1 -77
- package/dist/cjs/loadExternalFile/parseFileContent.cjs.map +1 -1
- package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs +1 -63
- package/dist/cjs/loadExternalFile/transpileTSToCJS.cjs.map +1 -1
- package/dist/cjs/logger.cjs +1 -150
- package/dist/cjs/logger.cjs.map +1 -1
- package/dist/cjs/node.cjs +1 -0
- package/dist/cjs/utils/ESMxCJSHelpers.cjs +1 -27
- package/dist/cjs/utils/ESMxCJSHelpers.cjs.map +1 -1
- package/dist/cjs/utils/alias.cjs +2 -0
- package/dist/cjs/utils/alias.cjs.map +1 -0
- package/dist/cjs/utils/cacheDisk.cjs +1 -162
- package/dist/cjs/utils/cacheDisk.cjs.map +1 -1
- package/dist/cjs/utils/cacheMemory.cjs +1 -269
- package/dist/cjs/utils/cacheMemory.cjs.map +1 -1
- package/dist/cjs/utils/clearModuleCache.cjs +1 -26
- package/dist/cjs/utils/clearModuleCache.cjs.map +1 -1
- package/dist/cjs/utils/compareVersions.cjs +1 -38
- package/dist/cjs/utils/compareVersions.cjs.map +1 -1
- package/dist/cjs/utils/extractErrorMessage.cjs +1 -95
- package/dist/cjs/utils/extractErrorMessage.cjs.map +1 -1
- package/dist/cjs/utils/getExtension.cjs +1 -14
- package/dist/cjs/utils/getExtension.cjs.map +1 -1
- package/dist/cjs/utils/getPackageJsonPath.cjs +1 -35
- package/dist/cjs/utils/getPackageJsonPath.cjs.map +1 -1
- package/dist/cjs/utils/index.cjs +1 -0
- package/dist/cjs/utils/logStack.cjs +1 -16
- package/dist/cjs/utils/logStack.cjs.map +1 -1
- package/dist/cjs/utils/normalizePath.cjs +1 -17
- package/dist/cjs/utils/normalizePath.cjs.map +1 -1
- package/dist/cjs/utils/retryManager.cjs +2 -0
- package/dist/cjs/utils/retryManager.cjs.map +1 -0
- package/dist/cjs/utils/stringFormatter/camelCaseToKebabCase.cjs +1 -13
- package/dist/cjs/utils/stringFormatter/camelCaseToKebabCase.cjs.map +1 -1
- package/dist/cjs/utils/stringFormatter/camelCaseToSentence.cjs +1 -16
- package/dist/cjs/utils/stringFormatter/camelCaseToSentence.cjs.map +1 -1
- package/dist/cjs/utils/stringFormatter/index.cjs +1 -10
- package/dist/cjs/utils/stringFormatter/kebabCaseToCamelCase.cjs +1 -14
- package/dist/cjs/utils/stringFormatter/kebabCaseToCamelCase.cjs.map +1 -1
- package/dist/cjs/utils/stringFormatter/toLowerCamelCase.cjs +1 -19
- package/dist/cjs/utils/stringFormatter/toLowerCamelCase.cjs.map +1 -1
- package/dist/esm/_virtual/_rolldown/runtime.mjs +1 -22
- package/dist/esm/built.mjs +1 -7
- package/dist/esm/built.mjs.map +1 -1
- package/dist/esm/client.mjs +1 -11
- package/dist/esm/configFile/buildConfigurationFields.mjs +1 -186
- package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
- package/dist/esm/configFile/getConfiguration.mjs +1 -67
- package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
- package/dist/esm/configFile/index.mjs +1 -5
- package/dist/esm/configFile/loadConfigurationFile.mjs +1 -32
- package/dist/esm/configFile/loadConfigurationFile.mjs.map +1 -1
- package/dist/esm/configFile/searchConfigurationFile.mjs +1 -48
- package/dist/esm/configFile/searchConfigurationFile.mjs.map +1 -1
- package/dist/esm/defaultValues/build.mjs +1 -18
- package/dist/esm/defaultValues/build.mjs.map +1 -1
- package/dist/esm/defaultValues/compiler.mjs +1 -19
- package/dist/esm/defaultValues/compiler.mjs.map +1 -1
- package/dist/esm/defaultValues/content.mjs +1 -43
- package/dist/esm/defaultValues/content.mjs.map +1 -1
- package/dist/esm/defaultValues/dictionary.mjs +1 -16
- package/dist/esm/defaultValues/dictionary.mjs.map +1 -1
- package/dist/esm/defaultValues/editor.mjs +1 -26
- package/dist/esm/defaultValues/editor.mjs.map +1 -1
- package/dist/esm/defaultValues/index.mjs +1 -24
- package/dist/esm/defaultValues/internationalization.mjs +1 -17
- package/dist/esm/defaultValues/internationalization.mjs.map +1 -1
- package/dist/esm/defaultValues/log.mjs +1 -13
- package/dist/esm/defaultValues/log.mjs.map +1 -1
- package/dist/esm/defaultValues/routing.mjs +1 -22
- package/dist/esm/defaultValues/routing.mjs.map +1 -1
- package/dist/esm/defaultValues/system.mjs +1 -30
- package/dist/esm/defaultValues/system.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -28
- package/dist/esm/loadEnvFile.mjs +1 -32
- package/dist/esm/loadEnvFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/bundleFile.mjs +1 -67
- package/dist/esm/loadExternalFile/bundleFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/bundleJSFile.mjs +2 -0
- package/dist/esm/loadExternalFile/bundleJSFile.mjs.map +1 -0
- package/dist/esm/loadExternalFile/index.mjs +1 -0
- package/dist/esm/loadExternalFile/loadExternalFile.mjs +1 -75
- package/dist/esm/loadExternalFile/loadExternalFile.mjs.map +1 -1
- package/dist/esm/loadExternalFile/parseFileContent.mjs +1 -73
- package/dist/esm/loadExternalFile/parseFileContent.mjs.map +1 -1
- package/dist/esm/loadExternalFile/transpileTSToCJS.mjs +1 -60
- package/dist/esm/loadExternalFile/transpileTSToCJS.mjs.map +1 -1
- package/dist/esm/logger.mjs +1 -133
- package/dist/esm/logger.mjs.map +1 -1
- package/dist/esm/node.mjs +1 -0
- package/dist/esm/utils/ESMxCJSHelpers.mjs +1 -24
- package/dist/esm/utils/ESMxCJSHelpers.mjs.map +1 -1
- package/dist/esm/utils/alias.mjs +2 -0
- package/dist/esm/utils/alias.mjs.map +1 -0
- package/dist/esm/utils/cacheDisk.mjs +1 -159
- package/dist/esm/utils/cacheDisk.mjs.map +1 -1
- package/dist/esm/utils/cacheMemory.mjs +1 -261
- package/dist/esm/utils/cacheMemory.mjs.map +1 -1
- package/dist/esm/utils/clearModuleCache.mjs +1 -25
- package/dist/esm/utils/clearModuleCache.mjs.map +1 -1
- package/dist/esm/utils/compareVersions.mjs +1 -36
- package/dist/esm/utils/compareVersions.mjs.map +1 -1
- package/dist/esm/utils/extractErrorMessage.mjs +1 -93
- package/dist/esm/utils/extractErrorMessage.mjs.map +1 -1
- package/dist/esm/utils/getExtension.mjs +1 -12
- package/dist/esm/utils/getExtension.mjs.map +1 -1
- package/dist/esm/utils/getPackageJsonPath.mjs +1 -32
- package/dist/esm/utils/getPackageJsonPath.mjs.map +1 -1
- package/dist/esm/utils/index.mjs +1 -0
- package/dist/esm/utils/logStack.mjs +1 -15
- package/dist/esm/utils/logStack.mjs.map +1 -1
- package/dist/esm/utils/normalizePath.mjs +1 -15
- package/dist/esm/utils/normalizePath.mjs.map +1 -1
- package/dist/esm/utils/retryManager.mjs +2 -0
- package/dist/esm/utils/retryManager.mjs.map +1 -0
- package/dist/esm/utils/stringFormatter/camelCaseToKebabCase.mjs +1 -11
- package/dist/esm/utils/stringFormatter/camelCaseToKebabCase.mjs.map +1 -1
- package/dist/esm/utils/stringFormatter/camelCaseToSentence.mjs +1 -14
- package/dist/esm/utils/stringFormatter/camelCaseToSentence.mjs.map +1 -1
- package/dist/esm/utils/stringFormatter/index.mjs +1 -6
- package/dist/esm/utils/stringFormatter/kebabCaseToCamelCase.mjs +1 -12
- package/dist/esm/utils/stringFormatter/kebabCaseToCamelCase.mjs.map +1 -1
- package/dist/esm/utils/stringFormatter/toLowerCamelCase.mjs +1 -17
- package/dist/esm/utils/stringFormatter/toLowerCamelCase.mjs.map +1 -1
- package/dist/types/index.d.ts +15 -9
- package/dist/types/{bundleJSFile.d.ts → loadExternalFile/bundleJSFile.d.ts} +1 -1
- package/dist/types/loadExternalFile/bundleJSFile.d.ts.map +1 -0
- package/dist/types/loadExternalFile/index.d.ts +6 -0
- package/dist/types/loadExternalFile/loadExternalFile.d.ts +2 -3
- package/dist/types/loadExternalFile/loadExternalFile.d.ts.map +1 -1
- package/dist/types/loadExternalFile/transpileTSToCJS.d.ts +2 -3
- package/dist/types/loadExternalFile/transpileTSToCJS.d.ts.map +1 -1
- package/dist/types/node.d.ts +5 -0
- package/dist/types/{alias.d.ts → utils/alias.d.ts} +1 -1
- package/dist/types/utils/alias.d.ts.map +1 -0
- package/dist/types/utils/getPackageJsonPath.d.ts +1 -2
- package/dist/types/utils/getPackageJsonPath.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +17 -0
- package/dist/types/{retryManager.d.ts → utils/retryManager.d.ts} +1 -1
- package/dist/types/utils/retryManager.d.ts.map +1 -0
- package/package.json +42 -10
- package/dist/cjs/alias.cjs +0 -30
- package/dist/cjs/alias.cjs.map +0 -1
- package/dist/cjs/bundleJSFile.cjs +0 -34
- package/dist/cjs/bundleJSFile.cjs.map +0 -1
- package/dist/cjs/retryManager.cjs +0 -46
- package/dist/cjs/retryManager.cjs.map +0 -1
- package/dist/esm/alias.mjs +0 -28
- package/dist/esm/alias.mjs.map +0 -1
- package/dist/esm/bundleJSFile.mjs +0 -32
- package/dist/esm/bundleJSFile.mjs.map +0 -1
- package/dist/esm/retryManager.mjs +0 -45
- package/dist/esm/retryManager.mjs.map +0 -1
- package/dist/types/alias.d.ts.map +0 -1
- package/dist/types/bundleJSFile.d.ts.map +0 -1
- package/dist/types/retryManager.d.ts.map +0 -1
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Locales } from "@intlayer/types";
|
|
3
|
-
|
|
4
|
-
//#region src/defaultValues/internationalization.ts
|
|
5
|
-
var internationalization_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
-
DEFAULT_LOCALE: () => DEFAULT_LOCALE,
|
|
7
|
-
LOCALES: () => LOCALES,
|
|
8
|
-
REQUIRED_LOCALES: () => REQUIRED_LOCALES,
|
|
9
|
-
STRICT_MODE: () => STRICT_MODE
|
|
10
|
-
});
|
|
11
|
-
const LOCALES = [Locales.ENGLISH];
|
|
12
|
-
const REQUIRED_LOCALES = [];
|
|
13
|
-
const DEFAULT_LOCALE = Locales.ENGLISH;
|
|
14
|
-
const STRICT_MODE = "inclusive";
|
|
15
|
-
|
|
16
|
-
//#endregion
|
|
17
|
-
export { DEFAULT_LOCALE, LOCALES, REQUIRED_LOCALES, STRICT_MODE, internationalization_exports };
|
|
1
|
+
import{__exportAll as e}from"../_virtual/_rolldown/runtime.mjs";import{Locales as t}from"@intlayer/types";var n=e({DEFAULT_LOCALE:()=>a,LOCALES:()=>r,REQUIRED_LOCALES:()=>i,STRICT_MODE:()=>o});const r=[t.ENGLISH],i=[],a=t.ENGLISH,o=`inclusive`;export{a as DEFAULT_LOCALE,r as LOCALES,i as REQUIRED_LOCALES,o as STRICT_MODE,n as internationalization_exports};
|
|
18
2
|
//# sourceMappingURL=internationalization.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internationalization.mjs","names":[],"sources":["../../../src/defaultValues/internationalization.ts"],"sourcesContent":["import { type Locale, Locales, type StrictMode } from '@intlayer/types';\n\nexport const LOCALES: Locale[] = [Locales.ENGLISH];\n\nexport const REQUIRED_LOCALES: Locale[] = [];\n\nexport const DEFAULT_LOCALE: Locale = Locales.ENGLISH;\n\nexport const STRICT_MODE: StrictMode = 'inclusive';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"internationalization.mjs","names":[],"sources":["../../../src/defaultValues/internationalization.ts"],"sourcesContent":["import { type Locale, Locales, type StrictMode } from '@intlayer/types';\n\nexport const LOCALES: Locale[] = [Locales.ENGLISH];\n\nexport const REQUIRED_LOCALES: Locale[] = [];\n\nexport const DEFAULT_LOCALE: Locale = Locales.ENGLISH;\n\nexport const STRICT_MODE: StrictMode = 'inclusive';\n"],"mappings":"iMAEA,MAAa,EAAoB,CAAC,EAAQ,QAAQ,CAErC,EAA6B,EAAE,CAE/B,EAAyB,EAAQ,QAEjC,EAA0B"}
|
|
@@ -1,14 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ANSIColors } from "../logger.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/defaultValues/log.ts
|
|
5
|
-
var log_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
-
MODE: () => MODE,
|
|
7
|
-
PREFIX: () => PREFIX
|
|
8
|
-
});
|
|
9
|
-
const MODE = "default";
|
|
10
|
-
const PREFIX = `${ANSIColors.GREY_DARK}[intlayer] ${ANSIColors.RESET}`;
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
export { MODE, PREFIX, log_exports };
|
|
1
|
+
import{__exportAll as e}from"../_virtual/_rolldown/runtime.mjs";import{ANSIColors as t}from"../logger.mjs";var n=e({MODE:()=>r,PREFIX:()=>i});const r=`default`,i=`${t.GREY_DARK}[intlayer] ${t.RESET}`;export{r as MODE,i as PREFIX,n as log_exports};
|
|
14
2
|
//# sourceMappingURL=log.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.mjs","names":[],"sources":["../../../src/defaultValues/log.ts"],"sourcesContent":["import { ANSIColors } from '../logger';\n\nexport const MODE = 'default';\n\nexport const PREFIX = `${ANSIColors.GREY_DARK}[intlayer] ${ANSIColors.RESET}`;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"log.mjs","names":[],"sources":["../../../src/defaultValues/log.ts"],"sourcesContent":["import { ANSIColors } from '../logger';\n\nexport const MODE = 'default';\n\nexport const PREFIX = `${ANSIColors.GREY_DARK}[intlayer] ${ANSIColors.RESET}`;\n"],"mappings":"8IAEA,MAAa,EAAO,UAEP,EAAS,GAAG,EAAW,UAAU,aAAa,EAAW"}
|
|
@@ -1,23 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/defaultValues/routing.ts
|
|
4
|
-
var routing_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
-
BASE_PATH: () => BASE_PATH,
|
|
6
|
-
COOKIE_NAME: () => COOKIE_NAME,
|
|
7
|
-
HEADER_NAME: () => HEADER_NAME,
|
|
8
|
-
LOCALE_STORAGE_NAME: () => LOCALE_STORAGE_NAME,
|
|
9
|
-
ROUTING_MODE: () => ROUTING_MODE,
|
|
10
|
-
SERVER_SET_COOKIE: () => SERVER_SET_COOKIE,
|
|
11
|
-
STORAGE: () => STORAGE
|
|
12
|
-
});
|
|
13
|
-
const HEADER_NAME = "x-intlayer-locale";
|
|
14
|
-
const COOKIE_NAME = "INTLAYER_LOCALE";
|
|
15
|
-
const LOCALE_STORAGE_NAME = "INTLAYER_LOCALE";
|
|
16
|
-
const BASE_PATH = "";
|
|
17
|
-
const SERVER_SET_COOKIE = "always";
|
|
18
|
-
const ROUTING_MODE = "prefix-no-default";
|
|
19
|
-
const STORAGE = ["cookie", "header"];
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
export { BASE_PATH, COOKIE_NAME, HEADER_NAME, LOCALE_STORAGE_NAME, ROUTING_MODE, SERVER_SET_COOKIE, STORAGE, routing_exports };
|
|
1
|
+
import{__exportAll as e}from"../_virtual/_rolldown/runtime.mjs";var t=e({BASE_PATH:()=>a,COOKIE_NAME:()=>r,HEADER_NAME:()=>n,LOCALE_STORAGE_NAME:()=>i,ROUTING_MODE:()=>s,SERVER_SET_COOKIE:()=>o,STORAGE:()=>c});const n=`x-intlayer-locale`,r=`INTLAYER_LOCALE`,i=`INTLAYER_LOCALE`,a=``,o=`always`,s=`prefix-no-default`,c=[`cookie`,`header`];export{a as BASE_PATH,r as COOKIE_NAME,n as HEADER_NAME,i as LOCALE_STORAGE_NAME,s as ROUTING_MODE,o as SERVER_SET_COOKIE,c as STORAGE,t as routing_exports};
|
|
23
2
|
//# sourceMappingURL=routing.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.mjs","names":[],"sources":["../../../src/defaultValues/routing.ts"],"sourcesContent":["import type { RoutingConfig } from '@intlayer/types';\n\nexport const HEADER_NAME = 'x-intlayer-locale';\n\nexport const COOKIE_NAME = 'INTLAYER_LOCALE';\nexport const LOCALE_STORAGE_NAME = 'INTLAYER_LOCALE';\n\nexport const BASE_PATH = '';\n\nexport const SERVER_SET_COOKIE = 'always';\n\nexport const ROUTING_MODE = 'prefix-no-default';\n\nexport const STORAGE: RoutingConfig['storage'] = ['cookie', 'header'];\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"routing.mjs","names":[],"sources":["../../../src/defaultValues/routing.ts"],"sourcesContent":["import type { RoutingConfig } from '@intlayer/types';\n\nexport const HEADER_NAME = 'x-intlayer-locale';\n\nexport const COOKIE_NAME = 'INTLAYER_LOCALE';\nexport const LOCALE_STORAGE_NAME = 'INTLAYER_LOCALE';\n\nexport const BASE_PATH = '';\n\nexport const SERVER_SET_COOKIE = 'always';\n\nexport const ROUTING_MODE = 'prefix-no-default';\n\nexport const STORAGE: RoutingConfig['storage'] = ['cookie', 'header'];\n"],"mappings":"kNAEA,MAAa,EAAc,oBAEd,EAAc,kBACd,EAAsB,kBAEtB,EAAY,GAEZ,EAAoB,SAEpB,EAAe,oBAEf,EAAoC,CAAC,SAAU,SAAS"}
|
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/defaultValues/system.ts
|
|
4
|
-
var system_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
-
CACHE_DIR: () => CACHE_DIR,
|
|
6
|
-
CONFIG_DIR: () => CONFIG_DIR,
|
|
7
|
-
DICTIONARIES_DIR: () => DICTIONARIES_DIR,
|
|
8
|
-
DYNAMIC_DICTIONARIES_DIR: () => DYNAMIC_DICTIONARIES_DIR,
|
|
9
|
-
FETCH_DICTIONARIES_DIR: () => FETCH_DICTIONARIES_DIR,
|
|
10
|
-
MAIN_DIR: () => MAIN_DIR,
|
|
11
|
-
MASKS_DIR: () => MASKS_DIR,
|
|
12
|
-
MODULE_AUGMENTATION_DIR: () => MODULE_AUGMENTATION_DIR,
|
|
13
|
-
REMOTE_DICTIONARIES_DIR: () => REMOTE_DICTIONARIES_DIR,
|
|
14
|
-
TYPES_DIR: () => TYPES_DIR,
|
|
15
|
-
UNMERGED_DICTIONARIES_DIR: () => UNMERGED_DICTIONARIES_DIR
|
|
16
|
-
});
|
|
17
|
-
const MAIN_DIR = ".intlayer/main";
|
|
18
|
-
const DICTIONARIES_DIR = ".intlayer/dictionary";
|
|
19
|
-
const MASKS_DIR = ".intlayer/mask";
|
|
20
|
-
const REMOTE_DICTIONARIES_DIR = ".intlayer/remote_dictionary";
|
|
21
|
-
const UNMERGED_DICTIONARIES_DIR = ".intlayer/unmerged_dictionary";
|
|
22
|
-
const DYNAMIC_DICTIONARIES_DIR = ".intlayer/dynamic_dictionary";
|
|
23
|
-
const FETCH_DICTIONARIES_DIR = ".intlayer/fetch_dictionary";
|
|
24
|
-
const TYPES_DIR = ".intlayer/types";
|
|
25
|
-
const MODULE_AUGMENTATION_DIR = ".intlayer/types";
|
|
26
|
-
const CONFIG_DIR = ".intlayer/config";
|
|
27
|
-
const CACHE_DIR = ".intlayer/cache";
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
export { CACHE_DIR, CONFIG_DIR, DICTIONARIES_DIR, DYNAMIC_DICTIONARIES_DIR, FETCH_DICTIONARIES_DIR, MAIN_DIR, MASKS_DIR, MODULE_AUGMENTATION_DIR, REMOTE_DICTIONARIES_DIR, TYPES_DIR, UNMERGED_DICTIONARIES_DIR, system_exports };
|
|
1
|
+
import{__exportAll as e}from"../_virtual/_rolldown/runtime.mjs";var t=e({CACHE_DIR:()=>f,CONFIG_DIR:()=>d,DICTIONARIES_DIR:()=>r,DYNAMIC_DICTIONARIES_DIR:()=>s,FETCH_DICTIONARIES_DIR:()=>c,MAIN_DIR:()=>n,MASKS_DIR:()=>i,MODULE_AUGMENTATION_DIR:()=>u,REMOTE_DICTIONARIES_DIR:()=>a,TYPES_DIR:()=>l,UNMERGED_DICTIONARIES_DIR:()=>o});const n=`.intlayer/main`,r=`.intlayer/dictionary`,i=`.intlayer/mask`,a=`.intlayer/remote_dictionary`,o=`.intlayer/unmerged_dictionary`,s=`.intlayer/dynamic_dictionary`,c=`.intlayer/fetch_dictionary`,l=`.intlayer/types`,u=`.intlayer/types`,d=`.intlayer/config`,f=`.intlayer/cache`;export{f as CACHE_DIR,d as CONFIG_DIR,r as DICTIONARIES_DIR,s as DYNAMIC_DICTIONARIES_DIR,c as FETCH_DICTIONARIES_DIR,n as MAIN_DIR,i as MASKS_DIR,u as MODULE_AUGMENTATION_DIR,a as REMOTE_DICTIONARIES_DIR,l as TYPES_DIR,o as UNMERGED_DICTIONARIES_DIR,t as system_exports};
|
|
31
2
|
//# sourceMappingURL=system.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.mjs","names":[],"sources":["../../../src/defaultValues/system.ts"],"sourcesContent":["export const MAIN_DIR = '.intlayer/main';\n\nexport const DICTIONARIES_DIR = '.intlayer/dictionary';\n\nexport const MASKS_DIR = '.intlayer/mask';\n\nexport const REMOTE_DICTIONARIES_DIR = '.intlayer/remote_dictionary';\n\nexport const UNMERGED_DICTIONARIES_DIR = '.intlayer/unmerged_dictionary';\n\nexport const DYNAMIC_DICTIONARIES_DIR = '.intlayer/dynamic_dictionary';\n\nexport const FETCH_DICTIONARIES_DIR = '.intlayer/fetch_dictionary';\n\nexport const TYPES_DIR = '.intlayer/types';\n\nexport const MODULE_AUGMENTATION_DIR = '.intlayer/types';\n\nexport const CONFIG_DIR = '.intlayer/config';\n\nexport const CACHE_DIR = '.intlayer/cache';\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"system.mjs","names":[],"sources":["../../../src/defaultValues/system.ts"],"sourcesContent":["export const MAIN_DIR = '.intlayer/main';\n\nexport const DICTIONARIES_DIR = '.intlayer/dictionary';\n\nexport const MASKS_DIR = '.intlayer/mask';\n\nexport const REMOTE_DICTIONARIES_DIR = '.intlayer/remote_dictionary';\n\nexport const UNMERGED_DICTIONARIES_DIR = '.intlayer/unmerged_dictionary';\n\nexport const DYNAMIC_DICTIONARIES_DIR = '.intlayer/dynamic_dictionary';\n\nexport const FETCH_DICTIONARIES_DIR = '.intlayer/fetch_dictionary';\n\nexport const TYPES_DIR = '.intlayer/types';\n\nexport const MODULE_AUGMENTATION_DIR = '.intlayer/types';\n\nexport const CONFIG_DIR = '.intlayer/config';\n\nexport const CACHE_DIR = '.intlayer/cache';\n"],"mappings":"0UAAA,MAAa,EAAW,iBAEX,EAAmB,uBAEnB,EAAY,iBAEZ,EAA0B,8BAE1B,EAA4B,gCAE5B,EAA2B,+BAE3B,EAAyB,6BAEzB,EAAY,kBAEZ,EAA0B,kBAE1B,EAAa,mBAEb,EAAY"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,28 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { normalizePath } from "./utils/normalizePath.mjs";
|
|
3
|
-
import { getAlias } from "./alias.mjs";
|
|
4
|
-
import { ANSIColors, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, getAppLogger, getPrefix, logger, removeColor, setPrefix, spinnerFrames, v, x } from "./logger.mjs";
|
|
5
|
-
import { cacheMemory } from "./utils/cacheMemory.mjs";
|
|
6
|
-
import { getPackageJsonPath } from "./utils/getPackageJsonPath.mjs";
|
|
7
|
-
import { buildConfigurationFields } from "./configFile/buildConfigurationFields.mjs";
|
|
8
|
-
import { getEnvFilePath, loadEnvFile } from "./loadEnvFile.mjs";
|
|
9
|
-
import { configESMxCJSRequire, getProjectRequire, isESModule } from "./utils/ESMxCJSHelpers.mjs";
|
|
10
|
-
import { parseFileContent } from "./loadExternalFile/parseFileContent.mjs";
|
|
11
|
-
import { bundleJSFile } from "./bundleJSFile.mjs";
|
|
12
|
-
import { configurationFilesCandidates, searchConfigurationFile } from "./configFile/searchConfigurationFile.mjs";
|
|
13
|
-
import { defaultValues_exports } from "./defaultValues/index.mjs";
|
|
14
|
-
import { bundleFile, bundleFileSync } from "./loadExternalFile/bundleFile.mjs";
|
|
15
|
-
import { extractErrorMessage } from "./utils/extractErrorMessage.mjs";
|
|
16
|
-
import { retryManager } from "./retryManager.mjs";
|
|
17
|
-
import { cacheDisk } from "./utils/cacheDisk.mjs";
|
|
18
|
-
import { clearModuleCache } from "./utils/clearModuleCache.mjs";
|
|
19
|
-
import { compareVersions } from "./utils/compareVersions.mjs";
|
|
20
|
-
import { logStack } from "./utils/logStack.mjs";
|
|
21
|
-
import { camelCaseToKebabCase } from "./utils/stringFormatter/camelCaseToKebabCase.mjs";
|
|
22
|
-
import { camelCaseToSentence } from "./utils/stringFormatter/camelCaseToSentence.mjs";
|
|
23
|
-
import { kebabCaseToCamelCase } from "./utils/stringFormatter/kebabCaseToCamelCase.mjs";
|
|
24
|
-
import { toLowerCamelCase } from "./utils/stringFormatter/toLowerCamelCase.mjs";
|
|
25
|
-
import { loadExternalFile, loadExternalFileSync } from "./loadExternalFile/loadExternalFile.mjs";
|
|
26
|
-
import { getConfiguration, getConfigurationAndFilePath } from "./configFile/getConfiguration.mjs";
|
|
27
|
-
|
|
28
|
-
export { ANSIColors, defaultValues_exports as DefaultValues, buildConfigurationFields, bundleFile, bundleFileSync, bundleJSFile, cacheDisk, cacheMemory, camelCaseToKebabCase, camelCaseToSentence, clearModuleCache, clock, colon, colorize, colorizeKey, colorizeLocales, colorizeNumber, colorizePath, compareVersions, configESMxCJSRequire, configurationFilesCandidates, extractErrorMessage, getAlias, getAppLogger, getConfiguration, getConfigurationAndFilePath, getEnvFilePath, getExtension, getPackageJsonPath, getPrefix, getProjectRequire, isESModule, kebabCaseToCamelCase, loadEnvFile, loadExternalFile, loadExternalFileSync, logStack, logger, normalizePath, parseFileContent, removeColor, retryManager, searchConfigurationFile, setPrefix, spinnerFrames, toLowerCamelCase, v, x };
|
|
1
|
+
import{ANSIColors as e,clock as t,colon as n,colorize as r,colorizeKey as i,colorizeLocales as a,colorizeNumber as o,colorizePath as s,getAppLogger as c,getPrefix as l,logger as u,removeColor as d,setPrefix as f,spinnerFrames as p,v as m,x as h}from"./logger.mjs";import{cacheMemory as g,clearAllCache as _,clearCache as v,computeKeyId as y,getCache as b,setCache as x,stableStringify as S}from"./utils/cacheMemory.mjs";import{getPackageJsonPath as C}from"./utils/getPackageJsonPath.mjs";import{normalizePath as w}from"./utils/normalizePath.mjs";import{buildConfigurationFields as T}from"./configFile/buildConfigurationFields.mjs";import{getEnvFilePath as E,loadEnvFile as D}from"./loadEnvFile.mjs";import{configESMxCJSRequire as O,getProjectRequire as k,isESModule as A}from"./utils/ESMxCJSHelpers.mjs";import{getSandBoxContext as j,parseFileContent as M}from"./loadExternalFile/parseFileContent.mjs";import{bundleFile as N,bundleFileSync as P,getLoader as F}from"./loadExternalFile/bundleFile.mjs";import{transpileTSToCJS as I,transpileTSToCJSSync as L}from"./loadExternalFile/transpileTSToCJS.mjs";import{loadExternalFile as R,loadExternalFileSync as z}from"./loadExternalFile/loadExternalFile.mjs";import{configurationFilesCandidates as B,searchConfigurationFile as V}from"./configFile/searchConfigurationFile.mjs";import{getConfiguration as H,getConfigurationAndFilePath as U}from"./configFile/getConfiguration.mjs";import{defaultValues_exports as W}from"./defaultValues/index.mjs";import{extractErrorMessage as G}from"./utils/extractErrorMessage.mjs";import{logStack as K}from"./utils/logStack.mjs";import{camelCaseToKebabCase as q}from"./utils/stringFormatter/camelCaseToKebabCase.mjs";import{camelCaseToSentence as J}from"./utils/stringFormatter/camelCaseToSentence.mjs";import{kebabCaseToCamelCase as Y}from"./utils/stringFormatter/kebabCaseToCamelCase.mjs";import{toLowerCamelCase as X}from"./utils/stringFormatter/toLowerCamelCase.mjs";import{bundleJSFile as Z}from"./loadExternalFile/bundleJSFile.mjs";import{getExtension as Q}from"./utils/getExtension.mjs";import{getAlias as $}from"./utils/alias.mjs";import{cacheDisk as ee}from"./utils/cacheDisk.mjs";import{clearModuleCache as te}from"./utils/clearModuleCache.mjs";import{compareVersions as ne}from"./utils/compareVersions.mjs";import{retryManager as re}from"./utils/retryManager.mjs";export{e as ANSIColors,W as DefaultValues,T as buildConfigurationFields,N as bundleFile,P as bundleFileSync,Z as bundleJSFile,ee as cacheDisk,g as cacheMemory,q as camelCaseToKebabCase,J as camelCaseToSentence,_ as clearAllCache,v as clearCache,te as clearModuleCache,t as clock,n as colon,r as colorize,i as colorizeKey,a as colorizeLocales,o as colorizeNumber,s as colorizePath,ne as compareVersions,y as computeKeyId,O as configESMxCJSRequire,B as configurationFilesCandidates,G as extractErrorMessage,$ as getAlias,c as getAppLogger,b as getCache,H as getConfiguration,U as getConfigurationAndFilePath,E as getEnvFilePath,Q as getExtension,F as getLoader,C as getPackageJsonPath,l as getPrefix,k as getProjectRequire,j as getSandBoxContext,A as isESModule,Y as kebabCaseToCamelCase,D as loadEnvFile,R as loadExternalFile,z as loadExternalFileSync,K as logStack,u as logger,w as normalizePath,M as parseFileContent,d as removeColor,re as retryManager,V as searchConfigurationFile,x as setCache,f as setPrefix,p as spinnerFrames,S as stableStringify,X as toLowerCamelCase,I as transpileTSToCJS,L as transpileTSToCJSSync,m as v,h as x};
|
package/dist/esm/loadEnvFile.mjs
CHANGED
|
@@ -1,33 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import dotenv from "dotenv";
|
|
3
|
-
|
|
4
|
-
//#region src/loadEnvFile.ts
|
|
5
|
-
const DEFAULT_ENV = "development";
|
|
6
|
-
const getEnvFilePath = (env = "development", envFile) => {
|
|
7
|
-
return (envFile ? [envFile] : [
|
|
8
|
-
`.env.${env}.local`,
|
|
9
|
-
`.env.${env}`,
|
|
10
|
-
".env.local",
|
|
11
|
-
".env"
|
|
12
|
-
]).find(existsSync);
|
|
13
|
-
};
|
|
14
|
-
const loadEnvFile = (options) => {
|
|
15
|
-
const env = options?.env ?? DEFAULT_ENV;
|
|
16
|
-
const envFiles = options?.envFile ? [options.envFile] : [
|
|
17
|
-
`.env.${env}.local`,
|
|
18
|
-
`.env.${env}`,
|
|
19
|
-
".env.local",
|
|
20
|
-
".env"
|
|
21
|
-
];
|
|
22
|
-
const result = {};
|
|
23
|
-
dotenv.config({
|
|
24
|
-
path: envFiles,
|
|
25
|
-
processEnv: result,
|
|
26
|
-
quiet: true
|
|
27
|
-
});
|
|
28
|
-
return result;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
//#endregion
|
|
32
|
-
export { getEnvFilePath, loadEnvFile };
|
|
1
|
+
import{existsSync as e}from"node:fs";import t from"dotenv";const n=(t=`production`,n)=>(n?[n]:[`.env.${t}.local`,`.env.${t}`,`.env.local`,`.env`]).find(e),r=e=>{let n=e?.env??`production`,r=e?.envFile?[e.envFile]:[`.env.${n}.local`,`.env.${n}`,`.env.local`,`.env`],i={};return t.config({path:r,processEnv:i,quiet:!0}),i};export{n as getEnvFilePath,r as loadEnvFile};
|
|
33
2
|
//# sourceMappingURL=loadEnvFile.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadEnvFile.mjs","names":[],"sources":["../../src/loadEnvFile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport dotenv from 'dotenv';\n\nconst DEFAULT_ENV = process.env.NODE_ENV ?? 'development';\n\nexport type LoadEnvFileOptions = {\n env?: string;\n envFile?: string;\n};\n\nexport const getEnvFilePath = (\n env: string = process.env.NODE_ENV ?? 'development',\n envFile?: string\n): string | undefined => {\n const envFiles = envFile\n ? [envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n return envFiles.find(existsSync); // Returns the first existing env file\n};\n\nexport const loadEnvFile = (options?: Partial<LoadEnvFileOptions>) => {\n const env = options?.env ?? DEFAULT_ENV;\n\n const envFiles = options?.envFile\n ? [options.envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n const result = {};\n\n dotenv.config({\n path: envFiles,\n processEnv: result,\n quiet: true,\n });\n\n return result; // Return the parsed env object\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"loadEnvFile.mjs","names":[],"sources":["../../src/loadEnvFile.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport dotenv from 'dotenv';\n\nconst DEFAULT_ENV = process.env.NODE_ENV ?? 'development';\n\nexport type LoadEnvFileOptions = {\n env?: string;\n envFile?: string;\n};\n\nexport const getEnvFilePath = (\n env: string = process.env.NODE_ENV ?? 'development',\n envFile?: string\n): string | undefined => {\n const envFiles = envFile\n ? [envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n return envFiles.find(existsSync); // Returns the first existing env file\n};\n\nexport const loadEnvFile = (options?: Partial<LoadEnvFileOptions>) => {\n const env = options?.env ?? DEFAULT_ENV;\n\n const envFiles = options?.envFile\n ? [options.envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n const result = {};\n\n dotenv.config({\n path: envFiles,\n processEnv: result,\n quiet: true,\n });\n\n return result; // Return the parsed env object\n};\n"],"mappings":"2DAGA,MAOa,GACX,EAAA,aACA,KAEiB,EACb,CAAC,EAAQ,CACT,CAAC,QAAQ,EAAI,QAAS,QAAQ,IAAO,aAAc,OAAO,EAE9C,KAAK,EAAW,CAGrB,EAAe,GAA0C,CACpE,IAAM,EAAM,GAAS,KAAO,aAEtB,EAAW,GAAS,QACtB,CAAC,EAAQ,QAAQ,CACjB,CAAC,QAAQ,EAAI,QAAS,QAAQ,IAAO,aAAc,OAAO,CAExD,EAAS,EAAE,CAQjB,OANA,EAAO,OAAO,CACZ,KAAM,EACN,WAAY,EACZ,MAAO,GACR,CAAC,CAEK"}
|
|
@@ -1,68 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { build, buildSync } from "esbuild";
|
|
3
|
-
import { pathToFileURL } from "node:url";
|
|
4
|
-
|
|
5
|
-
//#region src/loadExternalFile/bundleFile.ts
|
|
6
|
-
const getLoader = (extension) => {
|
|
7
|
-
switch (extension) {
|
|
8
|
-
case ".js": return "js";
|
|
9
|
-
case ".jsx": return "jsx";
|
|
10
|
-
case ".mjs": return "js";
|
|
11
|
-
case ".ts": return "ts";
|
|
12
|
-
case ".tsx": return "tsx";
|
|
13
|
-
case ".cjs": return "js";
|
|
14
|
-
case ".json": return "json";
|
|
15
|
-
case ".md": return "text";
|
|
16
|
-
case ".mdx": return "text";
|
|
17
|
-
default: return "js";
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
const getTransformationOptions = (filePath) => ({
|
|
21
|
-
loader: {
|
|
22
|
-
".js": "js",
|
|
23
|
-
".jsx": "jsx",
|
|
24
|
-
".mjs": "js",
|
|
25
|
-
".ts": "ts",
|
|
26
|
-
".tsx": "tsx",
|
|
27
|
-
".cjs": "js",
|
|
28
|
-
".json": "json",
|
|
29
|
-
".md": "text",
|
|
30
|
-
".mdx": "text"
|
|
31
|
-
},
|
|
32
|
-
format: "cjs",
|
|
33
|
-
target: "node16",
|
|
34
|
-
platform: "neutral",
|
|
35
|
-
write: false,
|
|
36
|
-
packages: "bundle",
|
|
37
|
-
external: ["esbuild"],
|
|
38
|
-
bundle: true,
|
|
39
|
-
define: { "import.meta.url": JSON.stringify(pathToFileURL(filePath).href) }
|
|
40
|
-
});
|
|
41
|
-
const bundleFileSync = (code, filePath, options) => {
|
|
42
|
-
return buildSync({
|
|
43
|
-
stdin: {
|
|
44
|
-
contents: code,
|
|
45
|
-
loader: getLoader(extname(filePath)),
|
|
46
|
-
resolveDir: dirname(filePath),
|
|
47
|
-
sourcefile: filePath
|
|
48
|
-
},
|
|
49
|
-
...getTransformationOptions(filePath),
|
|
50
|
-
...options
|
|
51
|
-
}).outputFiles?.[0].text;
|
|
52
|
-
};
|
|
53
|
-
const bundleFile = async (code, filePath, options) => {
|
|
54
|
-
return (await build({
|
|
55
|
-
stdin: {
|
|
56
|
-
contents: code,
|
|
57
|
-
loader: getLoader(extname(filePath)),
|
|
58
|
-
resolveDir: dirname(filePath),
|
|
59
|
-
sourcefile: filePath
|
|
60
|
-
},
|
|
61
|
-
...getTransformationOptions(filePath),
|
|
62
|
-
...options
|
|
63
|
-
})).outputFiles?.[0].text;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
//#endregion
|
|
67
|
-
export { bundleFile, bundleFileSync, getLoader };
|
|
1
|
+
import{dirname as e,extname as t}from"node:path";import{build as n,buildSync as r}from"esbuild";import{pathToFileURL as i}from"node:url";const a=e=>{switch(e){case`.js`:return`js`;case`.jsx`:return`jsx`;case`.mjs`:return`js`;case`.ts`:return`ts`;case`.tsx`:return`tsx`;case`.cjs`:return`js`;case`.json`:return`json`;case`.md`:return`text`;case`.mdx`:return`text`;default:return`js`}},o=e=>({loader:{".js":`js`,".jsx":`jsx`,".mjs":`js`,".ts":`ts`,".tsx":`tsx`,".cjs":`js`,".json":`json`,".md":`text`,".mdx":`text`},format:`cjs`,target:`node16`,platform:`neutral`,write:!1,packages:`bundle`,external:[`esbuild`],bundle:!0,define:{"import.meta.url":JSON.stringify(i(e).href)}}),s=(n,i,s)=>r({stdin:{contents:n,loader:a(t(i)),resolveDir:e(i),sourcefile:i},...o(i),...s}).outputFiles?.[0].text,c=async(r,i,s)=>(await n({stdin:{contents:r,loader:a(t(i)),resolveDir:e(i),sourcefile:i},...o(i),...s})).outputFiles?.[0].text;export{c as bundleFile,s as bundleFileSync,a as getLoader};
|
|
68
2
|
//# sourceMappingURL=bundleFile.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleFile.mjs","names":[],"sources":["../../../src/loadExternalFile/bundleFile.ts"],"sourcesContent":["import { dirname, extname } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n type BuildOptions,\n type BuildResult,\n build,\n buildSync,\n type Loader,\n type Plugin,\n} from 'esbuild';\n\nexport type ESBuildPlugin = Plugin;\n\nexport const getLoader = (extension: string): Loader => {\n switch (extension) {\n case '.js':\n return 'js';\n case '.jsx':\n return 'jsx';\n case '.mjs':\n return 'js';\n case '.ts':\n return 'ts';\n case '.tsx':\n return 'tsx';\n case '.cjs':\n return 'js';\n case '.json':\n return 'json';\n case '.md':\n return 'text';\n case '.mdx':\n return 'text';\n default:\n return 'js';\n }\n};\n\nconst getTransformationOptions = (filePath: string): BuildOptions => ({\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n '.md': 'text',\n '.mdx': 'text',\n },\n format: 'cjs',\n target: 'node16',\n platform: 'neutral',\n write: false,\n packages: 'bundle',\n external: ['esbuild'],\n bundle: true,\n define: {\n 'import.meta.url': JSON.stringify(pathToFileURL(filePath).href),\n },\n});\n\nexport const bundleFileSync = (\n code: string,\n filePath: string,\n options?: BuildOptions\n): string | undefined => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = buildSync({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n\nexport const bundleFile = async (\n code: string,\n filePath: string,\n options?: BuildOptions\n): Promise<string | undefined> => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = await build({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"bundleFile.mjs","names":[],"sources":["../../../src/loadExternalFile/bundleFile.ts"],"sourcesContent":["import { dirname, extname } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport {\n type BuildOptions,\n type BuildResult,\n build,\n buildSync,\n type Loader,\n type Plugin,\n} from 'esbuild';\n\nexport type ESBuildPlugin = Plugin;\n\nexport const getLoader = (extension: string): Loader => {\n switch (extension) {\n case '.js':\n return 'js';\n case '.jsx':\n return 'jsx';\n case '.mjs':\n return 'js';\n case '.ts':\n return 'ts';\n case '.tsx':\n return 'tsx';\n case '.cjs':\n return 'js';\n case '.json':\n return 'json';\n case '.md':\n return 'text';\n case '.mdx':\n return 'text';\n default:\n return 'js';\n }\n};\n\nconst getTransformationOptions = (filePath: string): BuildOptions => ({\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n '.md': 'text',\n '.mdx': 'text',\n },\n format: 'cjs',\n target: 'node16',\n platform: 'neutral',\n write: false,\n packages: 'bundle',\n external: ['esbuild'],\n bundle: true,\n define: {\n 'import.meta.url': JSON.stringify(pathToFileURL(filePath).href),\n },\n});\n\nexport const bundleFileSync = (\n code: string,\n filePath: string,\n options?: BuildOptions\n): string | undefined => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = buildSync({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n\nexport const bundleFile = async (\n code: string,\n filePath: string,\n options?: BuildOptions\n): Promise<string | undefined> => {\n const extension = extname(filePath);\n const loader = getLoader(extension);\n\n const moduleResult: BuildResult = await build({\n stdin: {\n contents: code,\n loader,\n resolveDir: dirname(filePath), // Add resolveDir to resolve imports relative to the file's location\n sourcefile: filePath, // Add sourcefile for better error messages\n },\n ...getTransformationOptions(filePath),\n ...options,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n return moduleResultString;\n};\n"],"mappings":"yIAaA,MAAa,EAAa,GAA8B,CACtD,OAAQ,EAAR,CACE,IAAK,MACH,MAAO,KACT,IAAK,OACH,MAAO,MACT,IAAK,OACH,MAAO,KACT,IAAK,MACH,MAAO,KACT,IAAK,OACH,MAAO,MACT,IAAK,OACH,MAAO,KACT,IAAK,QACH,MAAO,OACT,IAAK,MACH,MAAO,OACT,IAAK,OACH,MAAO,OACT,QACE,MAAO,OAIP,EAA4B,IAAoC,CACpE,OAAQ,CACN,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,QAAS,OACT,MAAO,OACP,OAAQ,OACT,CACD,OAAQ,MACR,OAAQ,SACR,SAAU,UACV,MAAO,GACP,SAAU,SACV,SAAU,CAAC,UAAU,CACrB,OAAQ,GACR,OAAQ,CACN,kBAAmB,KAAK,UAAU,EAAc,EAAS,CAAC,KAAK,CAChE,CACF,EAEY,GACX,EACA,EACA,IAKkC,EAAU,CAC1C,MAAO,CACL,SAAU,EACV,OALW,EADG,EAAQ,EAAS,CACA,CAM/B,WAAY,EAAQ,EAAS,CAC7B,WAAY,EACb,CACD,GAAG,EAAyB,EAAS,CACrC,GAAG,EACJ,CAAC,CAEsC,cAAc,GAAG,KAK9C,EAAa,MACxB,EACA,EACA,KAKkC,MAAM,EAAM,CAC5C,MAAO,CACL,SAAU,EACV,OALW,EADG,EAAQ,EAAS,CACA,CAM/B,WAAY,EAAQ,EAAS,CAC7B,WAAY,EACb,CACD,GAAG,EAAyB,EAAS,CACrC,GAAG,EACJ,CAAC,EAEsC,cAAc,GAAG"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{build as e}from"esbuild";const t={bundle:!0,format:`cjs`,platform:`node`,target:`es2019`,sourcemap:!1,logLevel:`silent`,write:!0,packages:`external`,loader:{".js":`js`,".jsx":`jsx`,".mjs":`js`,".ts":`ts`,".tsx":`tsx`,".cjs":`js`,".json":`json`,".md":`text`,".mdx":`text`}},n=async n=>await e({...t,...n});export{n as bundleJSFile};
|
|
2
|
+
//# sourceMappingURL=bundleJSFile.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundleJSFile.mjs","names":[],"sources":["../../../src/loadExternalFile/bundleJSFile.ts"],"sourcesContent":["import { type BuildOptions, build } from 'esbuild';\n\nconst commonBuildOptions = {\n bundle: true,\n format: 'cjs',\n platform: 'node',\n target: 'es2019',\n sourcemap: false,\n logLevel: 'silent',\n write: true,\n // Bundle relative/local files, but keep bare module imports external\n packages: 'external',\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n '.md': 'text',\n '.mdx': 'text',\n },\n} as const;\n\nexport const bundleJSFile = async (buildOptions: BuildOptions) =>\n await build({\n ...commonBuildOptions,\n ...buildOptions,\n });\n"],"mappings":"gCAEA,MAAM,EAAqB,CACzB,OAAQ,GACR,OAAQ,MACR,SAAU,OACV,OAAQ,SACR,UAAW,GACX,SAAU,SACV,MAAO,GAEP,SAAU,WACV,OAAQ,CACN,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,MAAO,KACP,OAAQ,MACR,OAAQ,KACR,QAAS,OACT,MAAO,OACP,OAAQ,OACT,CACF,CAEY,EAAe,KAAO,IACjC,MAAM,EAAM,CACV,GAAG,EACH,GAAG,EACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getSandBoxContext as e,parseFileContent as t}from"./parseFileContent.mjs";import{bundleFile as n,bundleFileSync as r,getLoader as i}from"./bundleFile.mjs";import{transpileTSToCJS as a,transpileTSToCJSSync as o}from"./transpileTSToCJS.mjs";import{loadExternalFile as s,loadExternalFileSync as c}from"./loadExternalFile.mjs";import{bundleJSFile as l}from"./bundleJSFile.mjs";export{n as bundleFile,r as bundleFileSync,l as bundleJSFile,i as getLoader,e as getSandBoxContext,s as loadExternalFile,c as loadExternalFileSync,t as parseFileContent,a as transpileTSToCJS,o as transpileTSToCJSSync};
|
|
@@ -1,76 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { parseFileContent } from "./parseFileContent.mjs";
|
|
3
|
-
import { transpileTSToCJS, transpileTSToCJSSync } from "./transpileTSToCJS.mjs";
|
|
4
|
-
import { extname } from "node:path";
|
|
5
|
-
import { readFileSync } from "node:fs";
|
|
6
|
-
import { readFile } from "node:fs/promises";
|
|
7
|
-
import JSON5 from "json5";
|
|
8
|
-
|
|
9
|
-
//#region src/loadExternalFile/loadExternalFile.ts
|
|
10
|
-
/**
|
|
11
|
-
* Load the content declaration from the given path
|
|
12
|
-
*
|
|
13
|
-
* Accepts JSON, JS, MJS and TS files as configuration
|
|
14
|
-
*/
|
|
15
|
-
const loadExternalFileSync = (filePath, options) => {
|
|
16
|
-
const fileExtension = extname(filePath) || ".json";
|
|
17
|
-
try {
|
|
18
|
-
if (fileExtension === ".json" || fileExtension === ".json5" || fileExtension === ".jsonc") return JSON5.parse(readFileSync(filePath, "utf-8"));
|
|
19
|
-
const moduleResultString = transpileTSToCJSSync(readFileSync(filePath, "utf-8"), filePath);
|
|
20
|
-
if (!moduleResultString) {
|
|
21
|
-
logger("File could not be loaded.", { level: "error" });
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const fileContent = parseFileContent(moduleResultString, {
|
|
25
|
-
projectRequire: options?.projectRequire,
|
|
26
|
-
envVarOptions: options?.envVarOptions,
|
|
27
|
-
additionalEnvVars: options?.additionalEnvVars,
|
|
28
|
-
mocks: options?.mocks,
|
|
29
|
-
aliases: options?.aliases
|
|
30
|
-
});
|
|
31
|
-
if (typeof fileContent === "undefined") {
|
|
32
|
-
logger(`File could not be loaded. Path : ${filePath}`);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
return fileContent;
|
|
36
|
-
} catch (error) {
|
|
37
|
-
logger([`Error: ${error.message} - `, JSON.stringify(error.stack, null, 2)], { level: "error" });
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Load the content declaration from the given path
|
|
42
|
-
*
|
|
43
|
-
* Accepts JSON, JS, MJS and TS files as configuration
|
|
44
|
-
*/
|
|
45
|
-
const loadExternalFile = async (filePath, options) => {
|
|
46
|
-
const fileExtension = extname(filePath);
|
|
47
|
-
try {
|
|
48
|
-
if (fileExtension === ".json" || fileExtension === ".json5" || fileExtension === ".jsonc") {
|
|
49
|
-
const fileContent = await readFile(filePath, "utf-8");
|
|
50
|
-
return JSON5.parse(fileContent);
|
|
51
|
-
}
|
|
52
|
-
const moduleResultString = await transpileTSToCJS(await readFile(filePath, "utf-8"), filePath, options?.buildOptions);
|
|
53
|
-
if (!moduleResultString) {
|
|
54
|
-
logger("File could not be loaded.", { level: "error" });
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const fileContent = parseFileContent(moduleResultString, {
|
|
58
|
-
projectRequire: options?.projectRequire,
|
|
59
|
-
envVarOptions: options?.envVarOptions,
|
|
60
|
-
additionalEnvVars: options?.additionalEnvVars,
|
|
61
|
-
mocks: options?.mocks,
|
|
62
|
-
aliases: options?.aliases
|
|
63
|
-
});
|
|
64
|
-
if (typeof fileContent === "undefined") {
|
|
65
|
-
logger(`File could not be loaded. Path : ${colorizePath(filePath)}`);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
return fileContent;
|
|
69
|
-
} catch (error) {
|
|
70
|
-
logger([`Error: ${error.message} - `, JSON.stringify(error.stack, null, 2)], { level: "error" });
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
//#endregion
|
|
75
|
-
export { loadExternalFile, loadExternalFileSync };
|
|
1
|
+
import{colorizePath as e,logger as t}from"../logger.mjs";import{parseFileContent as n}from"./parseFileContent.mjs";import{transpileTSToCJS as r,transpileTSToCJSSync as i}from"./transpileTSToCJS.mjs";import{extname as a}from"node:path";import{readFileSync as o}from"node:fs";import{readFile as s}from"node:fs/promises";import c from"json5";const l=(e,r)=>{let s=a(e)||`.json`;try{if(s===`.json`||s===`.json5`||s===`.jsonc`)return c.parse(o(e,`utf-8`));let a=i(o(e,`utf-8`),e);if(!a){t(`File could not be loaded.`,{level:`error`});return}let l=n(a,{projectRequire:r?.projectRequire,envVarOptions:r?.envVarOptions,additionalEnvVars:r?.additionalEnvVars,mocks:r?.mocks,aliases:r?.aliases});if(l===void 0){t(`File could not be loaded. Path : ${e}`);return}return l}catch(e){t([`Error: ${e.message} - `,JSON.stringify(e.stack,null,2)],{level:`error`})}},u=async(i,o)=>{let l=a(i);try{if(l===`.json`||l===`.json5`||l===`.jsonc`){let e=await s(i,`utf-8`);return c.parse(e)}let a=await r(await s(i,`utf-8`),i,o?.buildOptions);if(!a){t(`File could not be loaded.`,{level:`error`});return}let u=n(a,{projectRequire:o?.projectRequire,envVarOptions:o?.envVarOptions,additionalEnvVars:o?.additionalEnvVars,mocks:o?.mocks,aliases:o?.aliases});if(u===void 0){t(`File could not be loaded. Path : ${e(i)}`);return}return u}catch(e){t([`Error: ${e.message} - `,JSON.stringify(e.stack,null,2)],{level:`error`})}};export{u as loadExternalFile,l as loadExternalFileSync};
|
|
76
2
|
//# sourceMappingURL=loadExternalFile.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadExternalFile.mjs","names":[],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport type { BuildOptions
|
|
1
|
+
{"version":3,"file":"loadExternalFile.mjs","names":[],"sources":["../../../src/loadExternalFile/loadExternalFile.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport { extname } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport type { BuildOptions } from 'esbuild';\nimport JSON5 from 'json5';\nimport { colorizePath, logger } from '../logger';\nimport {\n parseFileContent,\n type SandBoxContextOptions,\n} from './parseFileContent';\nimport { transpileTSToCJS, transpileTSToCJSSync } from './transpileTSToCJS';\n\nexport type LoadExternalFileOptions = {\n configuration?: IntlayerConfig;\n buildOptions?: BuildOptions;\n} & SandBoxContextOptions;\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFileSync = (\n filePath: string,\n options?: LoadExternalFileOptions\n): any | undefined => {\n const fileExtension = extname(filePath) || '.json';\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Assume JSON\n return JSON5.parse(readFileSync(filePath, 'utf-8'));\n }\n\n // Rest is JS, MJS or TS\n const code = readFileSync(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = transpileTSToCJSSync(\n code,\n filePath\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = async (\n filePath: string,\n options?: LoadExternalFileOptions\n): Promise<any | undefined> => {\n const fileExtension = extname(filePath);\n\n try {\n if (\n fileExtension === '.json' ||\n fileExtension === '.json5' ||\n fileExtension === '.jsonc'\n ) {\n // Remove cache to force getting fresh content\n const fileContent = await readFile(filePath, 'utf-8');\n return JSON5.parse(fileContent);\n }\n\n // Rest is JS, MJS or TS\n const code = await readFile(filePath, 'utf-8');\n\n const moduleResultString: string | undefined = await transpileTSToCJS(\n code,\n filePath,\n options?.buildOptions\n );\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const fileContent = parseFileContent(moduleResultString, {\n projectRequire: options?.projectRequire,\n envVarOptions: options?.envVarOptions,\n additionalEnvVars: options?.additionalEnvVars,\n mocks: options?.mocks,\n aliases: options?.aliases,\n });\n\n if (typeof fileContent === 'undefined') {\n logger(`File could not be loaded. Path : ${colorizePath(filePath)}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n [\n `Error: ${(error as Error).message} - `,\n JSON.stringify((error as Error).stack, null, 2),\n ],\n {\n level: 'error',\n }\n );\n }\n};\n"],"mappings":"mVAuBA,MAAa,GACX,EACA,IACoB,CACpB,IAAM,EAAgB,EAAQ,EAAS,EAAI,QAE3C,GAAI,CACF,GACE,IAAkB,SAClB,IAAkB,UAClB,IAAkB,SAGlB,OAAO,EAAM,MAAM,EAAa,EAAU,QAAQ,CAAC,CAMrD,IAAM,EAAyC,EAFlC,EAAa,EAAU,QAAQ,CAI1C,EACD,CAED,GAAI,CAAC,EAAoB,CACvB,EAAO,4BAA6B,CAAE,MAAO,QAAS,CAAC,CACvD,OAGF,IAAM,EAAc,EAAiB,EAAoB,CACvD,eAAgB,GAAS,eACzB,cAAe,GAAS,cACxB,kBAAmB,GAAS,kBAC5B,MAAO,GAAS,MAChB,QAAS,GAAS,QACnB,CAAC,CAEF,GAAW,IAAgB,OAAa,CACtC,EAAO,oCAAoC,IAAW,CACtD,OAGF,OAAO,QACA,EAAO,CACd,EACE,CACE,UAAW,EAAgB,QAAQ,KACnC,KAAK,UAAW,EAAgB,MAAO,KAAM,EAAE,CAChD,CACD,CACE,MAAO,QACR,CACF,GASQ,EAAmB,MAC9B,EACA,IAC6B,CAC7B,IAAM,EAAgB,EAAQ,EAAS,CAEvC,GAAI,CACF,GACE,IAAkB,SAClB,IAAkB,UAClB,IAAkB,SAClB,CAEA,IAAM,EAAc,MAAM,EAAS,EAAU,QAAQ,CACrD,OAAO,EAAM,MAAM,EAAY,CAMjC,IAAM,EAAyC,MAAM,EAFxC,MAAM,EAAS,EAAU,QAAQ,CAI5C,EACA,GAAS,aACV,CAED,GAAI,CAAC,EAAoB,CACvB,EAAO,4BAA6B,CAAE,MAAO,QAAS,CAAC,CACvD,OAGF,IAAM,EAAc,EAAiB,EAAoB,CACvD,eAAgB,GAAS,eACzB,cAAe,GAAS,cACxB,kBAAmB,GAAS,kBAC5B,MAAO,GAAS,MAChB,QAAS,GAAS,QACnB,CAAC,CAEF,GAAW,IAAgB,OAAa,CACtC,EAAO,oCAAoC,EAAa,EAAS,GAAG,CACpE,OAGF,OAAO,QACA,EAAO,CACd,EACE,CACE,UAAW,EAAgB,QAAQ,KACnC,KAAK,UAAW,EAAgB,MAAO,KAAM,EAAE,CAChD,CACD,CACE,MAAO,QACR,CACF"}
|
|
@@ -1,74 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getProjectRequire } from "../utils/ESMxCJSHelpers.mjs";
|
|
3
|
-
import { runInNewContext } from "node:vm";
|
|
4
|
-
import * as esbuild from "esbuild";
|
|
5
|
-
|
|
6
|
-
//#region src/loadExternalFile/parseFileContent.ts
|
|
7
|
-
const getSandBoxContext = (options) => {
|
|
8
|
-
const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } = options ?? {};
|
|
9
|
-
let additionalGlobalVar = {};
|
|
10
|
-
const baseRequire = typeof projectRequire === "function" ? projectRequire : getProjectRequire();
|
|
11
|
-
const mockedRequire = (() => {
|
|
12
|
-
const mockTable = Object.assign({ esbuild }, mocks);
|
|
13
|
-
const aliasTable = Object.assign({}, aliases);
|
|
14
|
-
const wrappedRequire = function mockableRequire(id) {
|
|
15
|
-
const target = aliasTable?.[id] ? aliasTable[id] : id;
|
|
16
|
-
if (mockTable && Object.hasOwn(mockTable, target)) return mockTable[target];
|
|
17
|
-
if (target !== id && mockTable && Object.hasOwn(mockTable, id)) return mockTable[id];
|
|
18
|
-
return baseRequire(target);
|
|
19
|
-
};
|
|
20
|
-
wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);
|
|
21
|
-
wrappedRequire.main = baseRequire.main;
|
|
22
|
-
wrappedRequire.extensions = baseRequire.extensions;
|
|
23
|
-
wrappedRequire.cache = baseRequire.cache;
|
|
24
|
-
return wrappedRequire;
|
|
25
|
-
})();
|
|
26
|
-
try {
|
|
27
|
-
additionalGlobalVar = { React: baseRequire("react") };
|
|
28
|
-
} catch (_err) {
|
|
29
|
-
additionalGlobalVar = { React: {
|
|
30
|
-
createElement: (type, props, ...children) => ({
|
|
31
|
-
type,
|
|
32
|
-
props: {
|
|
33
|
-
...props,
|
|
34
|
-
children: children.length <= 1 ? children[0] : children
|
|
35
|
-
}
|
|
36
|
-
}),
|
|
37
|
-
Fragment: Symbol.for("react.fragment")
|
|
38
|
-
} };
|
|
39
|
-
}
|
|
40
|
-
const sandboxContext = {
|
|
41
|
-
exports: { default: {} },
|
|
42
|
-
module: { exports: {} },
|
|
43
|
-
process: {
|
|
44
|
-
...process,
|
|
45
|
-
env: {
|
|
46
|
-
...process.env,
|
|
47
|
-
...loadEnvFile(envVarOptions),
|
|
48
|
-
...additionalEnvVars
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
console,
|
|
52
|
-
require: mockedRequire,
|
|
53
|
-
...additionalGlobalVar
|
|
54
|
-
};
|
|
55
|
-
Object.getOwnPropertyNames(globalThis).forEach((key) => {
|
|
56
|
-
if (!(key in sandboxContext)) sandboxContext[key] = globalThis[key];
|
|
57
|
-
});
|
|
58
|
-
return sandboxContext;
|
|
59
|
-
};
|
|
60
|
-
const parseFileContent = (fileContentString, options) => {
|
|
61
|
-
const sandboxContext = getSandBoxContext(options);
|
|
62
|
-
runInNewContext(`"use strict";\n${fileContentString}`, sandboxContext);
|
|
63
|
-
const candidates = [
|
|
64
|
-
sandboxContext.exports?.default,
|
|
65
|
-
sandboxContext.module?.exports?.defaults,
|
|
66
|
-
sandboxContext.module?.exports?.default,
|
|
67
|
-
sandboxContext.module?.exports
|
|
68
|
-
];
|
|
69
|
-
for (const candidate of candidates) if (candidate && typeof candidate === "object" && Object.keys(candidate).length > 0) return candidate;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
//#endregion
|
|
73
|
-
export { getSandBoxContext, parseFileContent };
|
|
1
|
+
import{loadEnvFile as e}from"../loadEnvFile.mjs";import{getProjectRequire as t}from"../utils/ESMxCJSHelpers.mjs";import{runInNewContext as n}from"node:vm";import*as r from"esbuild";const i=n=>{let{envVarOptions:i,projectRequire:a,additionalEnvVars:o,mocks:s,aliases:c}=n??{},l={},u=typeof a==`function`?a:t(),d=(()=>{let e=Object.assign({esbuild:r},s),t=Object.assign({},c),n=function(n){let r=t?.[n]?t[n]:n;return e&&Object.hasOwn(e,r)?e[r]:r!==n&&e&&Object.hasOwn(e,n)?e[n]:u(r)};return n.resolve=u.resolve.bind(u),n.main=u.main,n.extensions=u.extensions,n.cache=u.cache,n})();try{l={React:u(`react`)}}catch{l={React:{createElement:(e,t,...n)=>({type:e,props:{...t,children:n.length<=1?n[0]:n}}),Fragment:Symbol.for(`react.fragment`)}}}let f={exports:{default:{}},module:{exports:{}},process:{...process,env:{...process.env,...e(i),...o}},console,require:d,...l};return Object.getOwnPropertyNames(globalThis).forEach(e=>{e in f||(f[e]=globalThis[e])}),f},a=(e,t)=>{let r=i(t);n(`"use strict";\n${e}`,r);let a=[r.exports?.default,r.module?.exports?.defaults,r.module?.exports?.default,r.module?.exports];for(let e of a)if(e&&typeof e==`object`&&Object.keys(e).length>0)return e};export{i as getSandBoxContext,a as parseFileContent};
|
|
74
2
|
//# sourceMappingURL=parseFileContent.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseFileContent.mjs","names":[],"sources":["../../../src/loadExternalFile/parseFileContent.ts"],"sourcesContent":["import { type Context, runInNewContext } from 'node:vm';\nimport * as esbuild from 'esbuild';\nimport { type LoadEnvFileOptions, loadEnvFile } from '../loadEnvFile';\nimport { getProjectRequire } from '../utils/ESMxCJSHelpers';\n\nexport type SandBoxContextOptions = {\n envVarOptions?: LoadEnvFileOptions;\n projectRequire?: NodeJS.Require;\n additionalEnvVars?: Record<string, string>;\n /**\n * Map of specifier -> mocked export to be returned when code in the VM calls require(specifier).\n * Example:\n * mocks: {\n * '@intlayer/config/built': { getConfig: () => ({}), Locales: {} }\n * }\n */\n mocks?: Record<string, any>;\n /**\n * Optional alias map if you want to redirect specifiers.\n * Useful when user code imports a subpath you want to collapse.\n * Example:\n * aliases: { '@intlayer/config/built': '@intlayer/config' }\n */\n aliases?: Record<string, string>;\n};\n\nexport const getSandBoxContext = (options?: SandBoxContextOptions): Context => {\n const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } =\n options ?? {};\n\n let additionalGlobalVar = {};\n\n const baseRequire: NodeJS.Require =\n typeof projectRequire === 'function' ? projectRequire : getProjectRequire();\n\n // Wrap require to honor mocks and aliases inside the VM\n const mockedRequire: NodeJS.Require = (() => {\n const mockTable = Object.assign(\n {\n esbuild,\n },\n mocks\n );\n const aliasTable = Object.assign({}, aliases);\n\n const wrappedRequire = function mockableRequire(id: string) {\n const target = aliasTable?.[id] ? aliasTable[id] : id;\n\n if (mockTable && Object.hasOwn(mockTable, target)) {\n return mockTable[target];\n }\n\n // If the original id was aliased, allow mocks to be defined on either key.\n if (target !== id && mockTable && Object.hasOwn(mockTable, id)) {\n return mockTable[id];\n }\n\n return baseRequire(target);\n } as NodeJS.Require;\n\n // Mirror NodeJS.Require properties\n wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);\n wrappedRequire.main = baseRequire.main;\n wrappedRequire.extensions = baseRequire.extensions;\n wrappedRequire.cache = baseRequire.cache;\n\n return wrappedRequire;\n })();\n\n try {\n // Dynamically try to require React if it's installed in the project\n additionalGlobalVar = {\n React: baseRequire('react'),\n };\n } catch (_err) {\n // React is not installed, so we inject a dummy React object to capture JSX elements\n // This allows using JSX in content declarations even if React is not installed (e.g. in Solid.js or Vue projects)\n // because esbuild's tsx loader defaults to React.createElement.\n additionalGlobalVar = {\n React: {\n createElement: (type: any, props: any, ...children: any[]) => ({\n type,\n props: {\n ...props,\n children: children.length <= 1 ? children[0] : children,\n },\n }),\n Fragment: Symbol.for('react.fragment'),\n },\n };\n }\n\n const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n process: {\n ...process,\n env: {\n ...process.env,\n ...loadEnvFile(envVarOptions),\n ...additionalEnvVars,\n },\n },\n console,\n require: mockedRequire,\n ...additionalGlobalVar,\n };\n\n // Dynamically inject all global variables\n Object.getOwnPropertyNames(globalThis).forEach((key) => {\n if (!(key in sandboxContext)) {\n sandboxContext[key] = globalThis[key as keyof typeof globalThis];\n }\n });\n\n return sandboxContext;\n};\n\nexport const parseFileContent = <T>(\n fileContentString: string,\n options?: SandBoxContextOptions\n): T | undefined => {\n const sandboxContext = getSandBoxContext(options);\n\n // Force strict mode so illegal writes throw instead of silently failing.\n runInNewContext(`\"use strict\";\\n${fileContentString}`, sandboxContext);\n\n const candidates: unknown[] = [\n sandboxContext.exports?.default,\n sandboxContext.module?.exports?.defaults,\n sandboxContext.module?.exports?.default,\n sandboxContext.module?.exports,\n ];\n\n for (const candidate of candidates) {\n if (\n candidate &&\n typeof candidate === 'object' &&\n Object.keys(candidate as object).length > 0\n ) {\n return candidate as T;\n }\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"parseFileContent.mjs","names":[],"sources":["../../../src/loadExternalFile/parseFileContent.ts"],"sourcesContent":["import { type Context, runInNewContext } from 'node:vm';\nimport * as esbuild from 'esbuild';\nimport { type LoadEnvFileOptions, loadEnvFile } from '../loadEnvFile';\nimport { getProjectRequire } from '../utils/ESMxCJSHelpers';\n\nexport type SandBoxContextOptions = {\n envVarOptions?: LoadEnvFileOptions;\n projectRequire?: NodeJS.Require;\n additionalEnvVars?: Record<string, string>;\n /**\n * Map of specifier -> mocked export to be returned when code in the VM calls require(specifier).\n * Example:\n * mocks: {\n * '@intlayer/config/built': { getConfig: () => ({}), Locales: {} }\n * }\n */\n mocks?: Record<string, any>;\n /**\n * Optional alias map if you want to redirect specifiers.\n * Useful when user code imports a subpath you want to collapse.\n * Example:\n * aliases: { '@intlayer/config/built': '@intlayer/config' }\n */\n aliases?: Record<string, string>;\n};\n\nexport const getSandBoxContext = (options?: SandBoxContextOptions): Context => {\n const { envVarOptions, projectRequire, additionalEnvVars, mocks, aliases } =\n options ?? {};\n\n let additionalGlobalVar = {};\n\n const baseRequire: NodeJS.Require =\n typeof projectRequire === 'function' ? projectRequire : getProjectRequire();\n\n // Wrap require to honor mocks and aliases inside the VM\n const mockedRequire: NodeJS.Require = (() => {\n const mockTable = Object.assign(\n {\n esbuild,\n },\n mocks\n );\n const aliasTable = Object.assign({}, aliases);\n\n const wrappedRequire = function mockableRequire(id: string) {\n const target = aliasTable?.[id] ? aliasTable[id] : id;\n\n if (mockTable && Object.hasOwn(mockTable, target)) {\n return mockTable[target];\n }\n\n // If the original id was aliased, allow mocks to be defined on either key.\n if (target !== id && mockTable && Object.hasOwn(mockTable, id)) {\n return mockTable[id];\n }\n\n return baseRequire(target);\n } as NodeJS.Require;\n\n // Mirror NodeJS.Require properties\n wrappedRequire.resolve = baseRequire.resolve.bind(baseRequire);\n wrappedRequire.main = baseRequire.main;\n wrappedRequire.extensions = baseRequire.extensions;\n wrappedRequire.cache = baseRequire.cache;\n\n return wrappedRequire;\n })();\n\n try {\n // Dynamically try to require React if it's installed in the project\n additionalGlobalVar = {\n React: baseRequire('react'),\n };\n } catch (_err) {\n // React is not installed, so we inject a dummy React object to capture JSX elements\n // This allows using JSX in content declarations even if React is not installed (e.g. in Solid.js or Vue projects)\n // because esbuild's tsx loader defaults to React.createElement.\n additionalGlobalVar = {\n React: {\n createElement: (type: any, props: any, ...children: any[]) => ({\n type,\n props: {\n ...props,\n children: children.length <= 1 ? children[0] : children,\n },\n }),\n Fragment: Symbol.for('react.fragment'),\n },\n };\n }\n\n const sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n process: {\n ...process,\n env: {\n ...process.env,\n ...loadEnvFile(envVarOptions),\n ...additionalEnvVars,\n },\n },\n console,\n require: mockedRequire,\n ...additionalGlobalVar,\n };\n\n // Dynamically inject all global variables\n Object.getOwnPropertyNames(globalThis).forEach((key) => {\n if (!(key in sandboxContext)) {\n sandboxContext[key] = globalThis[key as keyof typeof globalThis];\n }\n });\n\n return sandboxContext;\n};\n\nexport const parseFileContent = <T>(\n fileContentString: string,\n options?: SandBoxContextOptions\n): T | undefined => {\n const sandboxContext = getSandBoxContext(options);\n\n // Force strict mode so illegal writes throw instead of silently failing.\n runInNewContext(`\"use strict\";\\n${fileContentString}`, sandboxContext);\n\n const candidates: unknown[] = [\n sandboxContext.exports?.default,\n sandboxContext.module?.exports?.defaults,\n sandboxContext.module?.exports?.default,\n sandboxContext.module?.exports,\n ];\n\n for (const candidate of candidates) {\n if (\n candidate &&\n typeof candidate === 'object' &&\n Object.keys(candidate as object).length > 0\n ) {\n return candidate as T;\n }\n }\n};\n"],"mappings":"qLA0BA,MAAa,EAAqB,GAA6C,CAC7E,GAAM,CAAE,gBAAe,iBAAgB,oBAAmB,QAAO,WAC/D,GAAW,EAAE,CAEX,EAAsB,EAAE,CAEtB,EACJ,OAAO,GAAmB,WAAa,EAAiB,GAAmB,CAGvE,OAAuC,CAC3C,IAAM,EAAY,OAAO,OACvB,CACE,UACD,CACD,EACD,CACK,EAAa,OAAO,OAAO,EAAE,CAAE,EAAQ,CAEvC,EAAiB,SAAyB,EAAY,CAC1D,IAAM,EAAS,IAAa,GAAM,EAAW,GAAM,EAWnD,OATI,GAAa,OAAO,OAAO,EAAW,EAAO,CACxC,EAAU,GAIf,IAAW,GAAM,GAAa,OAAO,OAAO,EAAW,EAAG,CACrD,EAAU,GAGZ,EAAY,EAAO,EAS5B,MALA,GAAe,QAAU,EAAY,QAAQ,KAAK,EAAY,CAC9D,EAAe,KAAO,EAAY,KAClC,EAAe,WAAa,EAAY,WACxC,EAAe,MAAQ,EAAY,MAE5B,KACL,CAEJ,GAAI,CAEF,EAAsB,CACpB,MAAO,EAAY,QAAQ,CAC5B,MACY,CAIb,EAAsB,CACpB,MAAO,CACL,eAAgB,EAAW,EAAY,GAAG,KAAqB,CAC7D,OACA,MAAO,CACL,GAAG,EACH,SAAU,EAAS,QAAU,EAAI,EAAS,GAAK,EAChD,CACF,EACD,SAAU,OAAO,IAAI,iBAAiB,CACvC,CACF,CAGH,IAAM,EAA0B,CAC9B,QAAS,CACP,QAAS,EAAE,CACZ,CACD,OAAQ,CACN,QAAS,EAAE,CACZ,CACD,QAAS,CACP,GAAG,QACH,IAAK,CACH,GAAG,QAAQ,IACX,GAAG,EAAY,EAAc,CAC7B,GAAG,EACJ,CACF,CACD,QACA,QAAS,EACT,GAAG,EACJ,CASD,OANA,OAAO,oBAAoB,WAAW,CAAC,QAAS,GAAQ,CAChD,KAAO,IACX,EAAe,GAAO,WAAW,KAEnC,CAEK,GAGI,GACX,EACA,IACkB,CAClB,IAAM,EAAiB,EAAkB,EAAQ,CAGjD,EAAgB,kBAAkB,IAAqB,EAAe,CAEtE,IAAM,EAAwB,CAC5B,EAAe,SAAS,QACxB,EAAe,QAAQ,SAAS,SAChC,EAAe,QAAQ,SAAS,QAChC,EAAe,QAAQ,QACxB,CAED,IAAK,IAAM,KAAa,EACtB,GACE,GACA,OAAO,GAAc,UACrB,OAAO,KAAK,EAAoB,CAAC,OAAS,EAE1C,OAAO"}
|
|
@@ -1,61 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getLoader } from "./bundleFile.mjs";
|
|
3
|
-
import { dirname, extname, join } from "node:path";
|
|
4
|
-
import { existsSync } from "node:fs";
|
|
5
|
-
import { build, buildSync } from "esbuild";
|
|
6
|
-
import { pathToFileURL } from "node:url";
|
|
7
|
-
|
|
8
|
-
//#region src/loadExternalFile/transpileTSToCJS.ts
|
|
9
|
-
const getTsConfigPath = (filePath) => {
|
|
10
|
-
const tsconfigPath = join(getPackageJsonPath(dirname(filePath)).baseDir, "tsconfig.json");
|
|
11
|
-
return existsSync(tsconfigPath) ? tsconfigPath : void 0;
|
|
12
|
-
};
|
|
13
|
-
const getTransformationOptions = (filePath) => ({
|
|
14
|
-
loader: {
|
|
15
|
-
".js": "js",
|
|
16
|
-
".jsx": "jsx",
|
|
17
|
-
".mjs": "js",
|
|
18
|
-
".ts": "ts",
|
|
19
|
-
".tsx": "tsx",
|
|
20
|
-
".cjs": "js",
|
|
21
|
-
".json": "json",
|
|
22
|
-
".md": "text",
|
|
23
|
-
".mdx": "text"
|
|
24
|
-
},
|
|
25
|
-
format: "cjs",
|
|
26
|
-
target: "node20",
|
|
27
|
-
platform: "node",
|
|
28
|
-
write: false,
|
|
29
|
-
packages: "external",
|
|
30
|
-
bundle: true,
|
|
31
|
-
tsconfig: getTsConfigPath(filePath),
|
|
32
|
-
define: { "import.meta.url": JSON.stringify(pathToFileURL(filePath).href) }
|
|
33
|
-
});
|
|
34
|
-
const transpileTSToCJSSync = (code, filePath, options) => {
|
|
35
|
-
return buildSync({
|
|
36
|
-
stdin: {
|
|
37
|
-
contents: code,
|
|
38
|
-
loader: getLoader(extname(filePath)),
|
|
39
|
-
resolveDir: dirname(filePath),
|
|
40
|
-
sourcefile: filePath
|
|
41
|
-
},
|
|
42
|
-
...getTransformationOptions(filePath),
|
|
43
|
-
...options
|
|
44
|
-
}).outputFiles?.[0].text;
|
|
45
|
-
};
|
|
46
|
-
const transpileTSToCJS = async (code, filePath, options) => {
|
|
47
|
-
return (await build({
|
|
48
|
-
stdin: {
|
|
49
|
-
contents: code,
|
|
50
|
-
loader: getLoader(extname(filePath)),
|
|
51
|
-
resolveDir: dirname(filePath),
|
|
52
|
-
sourcefile: filePath
|
|
53
|
-
},
|
|
54
|
-
...getTransformationOptions(filePath),
|
|
55
|
-
...options
|
|
56
|
-
})).outputFiles?.[0].text;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
//#endregion
|
|
60
|
-
export { transpileTSToCJS, transpileTSToCJSSync };
|
|
1
|
+
import{getPackageJsonPath as e}from"../utils/getPackageJsonPath.mjs";import{getLoader as t}from"./bundleFile.mjs";import{dirname as n,extname as r,join as i}from"node:path";import{existsSync as a}from"node:fs";import{build as o,buildSync as s}from"esbuild";import{pathToFileURL as c}from"node:url";const l=t=>{let r=i(e(n(t)).baseDir,`tsconfig.json`);return a(r)?r:void 0},u=e=>({loader:{".js":`js`,".jsx":`jsx`,".mjs":`js`,".ts":`ts`,".tsx":`tsx`,".cjs":`js`,".json":`json`,".md":`text`,".mdx":`text`},format:`cjs`,target:`node20`,platform:`node`,write:!1,packages:`external`,bundle:!0,tsconfig:l(e),define:{"import.meta.url":JSON.stringify(c(e).href)}}),d=(e,i,a)=>s({stdin:{contents:e,loader:t(r(i)),resolveDir:n(i),sourcefile:i},...u(i),...a}).outputFiles?.[0].text,f=async(e,i,a)=>(await o({stdin:{contents:e,loader:t(r(i)),resolveDir:n(i),sourcefile:i},...u(i),...a})).outputFiles?.[0].text;export{f as transpileTSToCJS,d as transpileTSToCJSSync};
|
|
61
2
|
//# sourceMappingURL=transpileTSToCJS.mjs.map
|