@powerlines/core 0.48.77 → 0.48.79

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.
@@ -1,9 +1,9 @@
1
1
  import { UnresolvedContext } from "../types/context.cjs";
2
2
  import { Config, ResolvedConfig, ResolvedEntryFileReference } from "../types/config.cjs";
3
- import { FileReference, FileReferenceParameter } from "@stryke/types/configuration";
3
+ import { FileReference, FileReferenceInput } from "@stryke/types/configuration";
4
4
  //#region src/lib/entry.d.ts
5
5
  declare function resolveEntryOutput<TContext extends UnresolvedContext>(context: TContext, fileReference: FileReference): string;
6
- declare function resolveInput<TContext extends UnresolvedContext>(context: TContext, fileReference: FileReference, input?: FileReferenceParameter, output?: string): ResolvedEntryFileReference;
6
+ declare function resolveInput<TContext extends UnresolvedContext>(context: TContext, fileReference: FileReference, input?: FileReferenceInput, output?: string): ResolvedEntryFileReference;
7
7
  /**
8
8
  * Resolves multiple file references into their corresponding resolved entry file references.
9
9
  *
@@ -11,7 +11,7 @@ declare function resolveInput<TContext extends UnresolvedContext>(context: TCont
11
11
  * @param fileReferences - The file references to resolve.
12
12
  * @returns A promise that resolves to an array of resolved entry file references .
13
13
  */
14
- declare function resolveInputs<TContext extends UnresolvedContext>(context: TContext, fileReferences: FileReferenceParameter | FileReferenceParameter[] | Record<string, FileReferenceParameter | FileReferenceParameter[]>): Promise<ResolvedEntryFileReference[]>;
14
+ declare function resolveInputs<TContext extends UnresolvedContext>(context: TContext, fileReferences: FileReferenceInput | FileReferenceInput[] | Record<string, FileReferenceInput | FileReferenceInput[]>): Promise<ResolvedEntryFileReference[]>;
15
15
  /**
16
16
  * Resolves multiple file references into their corresponding resolved entry file references.
17
17
  *
@@ -19,7 +19,7 @@ declare function resolveInputs<TContext extends UnresolvedContext>(context: TCon
19
19
  * @param fileReferences - The file references to resolve.
20
20
  * @returns An array of resolved entry file references.
21
21
  */
22
- declare function resolveInputsSync<TContext extends UnresolvedContext>(context: TContext, fileReferences: FileReferenceParameter | FileReferenceParameter[] | Record<string, FileReferenceParameter | FileReferenceParameter[]>): ResolvedEntryFileReference[];
22
+ declare function resolveInputsSync<TContext extends UnresolvedContext>(context: TContext, fileReferences: FileReferenceInput | FileReferenceInput[] | Record<string, FileReferenceInput | FileReferenceInput[]>): ResolvedEntryFileReference[];
23
23
  /**
24
24
  * Checks if the provided entry is a file reference.
25
25
  *
@@ -33,7 +33,7 @@ declare function isFileReference(entry: any): entry is FileReference;
33
33
  * @param entry - The entry to check.
34
34
  * @returns True if the entry is a resolved entry file reference, false otherwise.
35
35
  */
36
- declare function isResolvedEntryFileReference(entry: FileReferenceParameter | ResolvedEntryFileReference): entry is ResolvedEntryFileReference;
36
+ declare function isResolvedEntryFileReference(entry: FileReferenceInput | ResolvedEntryFileReference): entry is ResolvedEntryFileReference;
37
37
  /**
38
38
  * Get unique inputs from the provided list.
39
39
  *
@@ -1 +1 @@
1
- {"version":3,"file":"entry.d.cts","names":[],"sources":["../../src/lib/entry.ts"],"mappings":";;;;iBAyCgB,mBAAmB,iBAAiB,mBAClD,SAAS,UACT,eAAe;iBAsBD,aAAa,iBAAiB,mBAC5C,SAAS,UACT,eAAe,eACf,QAAQ,wBACR,kBACC;;;;;;;;iBAemB,cAAc,iBAAiB,mBACnD,SAAS,UACT,gBACI,yBACA,2BACA,eAAe,yBAAyB,4BAC3C,QAAQ;;;;;;;;iBAyEK,kBAAkB,iBAAiB,mBACjD,SAAS,UACT,gBACI,yBACA,2BACA,eAAe,yBAAyB,4BAC3C;;;;;;;iBAwDa,gBAAgB,aAAa,SAAS;;;;;;;iBAUtC,6BACd,OAAO,yBAAyB,6BAC/B,SAAS;;;;;;;iBAaI,gBACd,SAAQ,kBACP"}
1
+ {"version":3,"file":"entry.d.cts","names":[],"sources":["../../src/lib/entry.ts"],"mappings":";;;;iBAyCgB,mBAAmB,iBAAiB,mBAClD,SAAS,UACT,eAAe;iBAsBD,aAAa,iBAAiB,mBAC5C,SAAS,UACT,eAAe,eACf,QAAQ,oBACR,kBACC;;;;;;;;iBAemB,cAAc,iBAAiB,mBACnD,SAAS,UACT,gBACI,qBACA,uBACA,eAAe,qBAAqB,wBACvC,QAAQ;;;;;;;;iBAyEK,kBAAkB,iBAAiB,mBACjD,SAAS,UACT,gBACI,qBACA,uBACA,eAAe,qBAAqB,wBACvC;;;;;;;iBAwDa,gBAAgB,aAAa,SAAS;;;;;;;iBAUtC,6BACd,OAAO,qBAAqB,6BAC3B,SAAS;;;;;;;iBAaI,gBACd,SAAQ,kBACP"}
@@ -1,9 +1,9 @@
1
1
  import { UnresolvedContext } from "../types/context.mjs";
2
2
  import { Config, ResolvedConfig, ResolvedEntryFileReference } from "../types/config.mjs";
3
- import { FileReference, FileReferenceParameter } from "@stryke/types/configuration";
3
+ import { FileReference, FileReferenceInput } from "@stryke/types/configuration";
4
4
  //#region src/lib/entry.d.ts
5
5
  declare function resolveEntryOutput<TContext extends UnresolvedContext>(context: TContext, fileReference: FileReference): string;
6
- declare function resolveInput<TContext extends UnresolvedContext>(context: TContext, fileReference: FileReference, input?: FileReferenceParameter, output?: string): ResolvedEntryFileReference;
6
+ declare function resolveInput<TContext extends UnresolvedContext>(context: TContext, fileReference: FileReference, input?: FileReferenceInput, output?: string): ResolvedEntryFileReference;
7
7
  /**
8
8
  * Resolves multiple file references into their corresponding resolved entry file references.
9
9
  *
@@ -11,7 +11,7 @@ declare function resolveInput<TContext extends UnresolvedContext>(context: TCont
11
11
  * @param fileReferences - The file references to resolve.
12
12
  * @returns A promise that resolves to an array of resolved entry file references .
13
13
  */
14
- declare function resolveInputs<TContext extends UnresolvedContext>(context: TContext, fileReferences: FileReferenceParameter | FileReferenceParameter[] | Record<string, FileReferenceParameter | FileReferenceParameter[]>): Promise<ResolvedEntryFileReference[]>;
14
+ declare function resolveInputs<TContext extends UnresolvedContext>(context: TContext, fileReferences: FileReferenceInput | FileReferenceInput[] | Record<string, FileReferenceInput | FileReferenceInput[]>): Promise<ResolvedEntryFileReference[]>;
15
15
  /**
16
16
  * Resolves multiple file references into their corresponding resolved entry file references.
17
17
  *
@@ -19,7 +19,7 @@ declare function resolveInputs<TContext extends UnresolvedContext>(context: TCon
19
19
  * @param fileReferences - The file references to resolve.
20
20
  * @returns An array of resolved entry file references.
21
21
  */
22
- declare function resolveInputsSync<TContext extends UnresolvedContext>(context: TContext, fileReferences: FileReferenceParameter | FileReferenceParameter[] | Record<string, FileReferenceParameter | FileReferenceParameter[]>): ResolvedEntryFileReference[];
22
+ declare function resolveInputsSync<TContext extends UnresolvedContext>(context: TContext, fileReferences: FileReferenceInput | FileReferenceInput[] | Record<string, FileReferenceInput | FileReferenceInput[]>): ResolvedEntryFileReference[];
23
23
  /**
24
24
  * Checks if the provided entry is a file reference.
25
25
  *
@@ -33,7 +33,7 @@ declare function isFileReference(entry: any): entry is FileReference;
33
33
  * @param entry - The entry to check.
34
34
  * @returns True if the entry is a resolved entry file reference, false otherwise.
35
35
  */
36
- declare function isResolvedEntryFileReference(entry: FileReferenceParameter | ResolvedEntryFileReference): entry is ResolvedEntryFileReference;
36
+ declare function isResolvedEntryFileReference(entry: FileReferenceInput | ResolvedEntryFileReference): entry is ResolvedEntryFileReference;
37
37
  /**
38
38
  * Get unique inputs from the provided list.
39
39
  *
@@ -1 +1 @@
1
- {"version":3,"file":"entry.d.mts","names":[],"sources":["../../src/lib/entry.ts"],"mappings":";;;;iBAyCgB,mBAAmB,iBAAiB,mBAClD,SAAS,UACT,eAAe;iBAsBD,aAAa,iBAAiB,mBAC5C,SAAS,UACT,eAAe,eACf,QAAQ,wBACR,kBACC;;;;;;;;iBAemB,cAAc,iBAAiB,mBACnD,SAAS,UACT,gBACI,yBACA,2BACA,eAAe,yBAAyB,4BAC3C,QAAQ;;;;;;;;iBAyEK,kBAAkB,iBAAiB,mBACjD,SAAS,UACT,gBACI,yBACA,2BACA,eAAe,yBAAyB,4BAC3C;;;;;;;iBAwDa,gBAAgB,aAAa,SAAS;;;;;;;iBAUtC,6BACd,OAAO,yBAAyB,6BAC/B,SAAS;;;;;;;iBAaI,gBACd,SAAQ,kBACP"}
1
+ {"version":3,"file":"entry.d.mts","names":[],"sources":["../../src/lib/entry.ts"],"mappings":";;;;iBAyCgB,mBAAmB,iBAAiB,mBAClD,SAAS,UACT,eAAe;iBAsBD,aAAa,iBAAiB,mBAC5C,SAAS,UACT,eAAe,eACf,QAAQ,oBACR,kBACC;;;;;;;;iBAemB,cAAc,iBAAiB,mBACnD,SAAS,UACT,gBACI,qBACA,uBACA,eAAe,qBAAqB,wBACvC,QAAQ;;;;;;;;iBAyEK,kBAAkB,iBAAiB,mBACjD,SAAS,UACT,gBACI,qBACA,uBACA,eAAe,qBAAqB,wBACvC;;;;;;;iBAwDa,gBAAgB,aAAa,SAAS;;;;;;;iBAUtC,6BACd,OAAO,qBAAqB,6BAC3B,SAAS;;;;;;;iBAaI,gBACd,SAAQ,kBACP"}
@@ -1 +1 @@
1
- {"version":3,"file":"entry.mjs","names":[],"sources":["../../src/lib/entry.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { extractFileReference } from \"@stryke/convert/extract-file-reference\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { murmurhash } from \"@stryke/hash\";\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type {\n FileReference,\n FileReferenceParameter\n} from \"@stryke/types/configuration\";\nimport { replacePathTokens } from \"../plugin-utils/paths\";\nimport {\n Config,\n ResolvedConfig,\n ResolvedEntryFileReference\n} from \"../types/config\";\nimport type { UnresolvedContext } from \"../types/context\";\n\nexport function resolveEntryOutput<TContext extends UnresolvedContext>(\n context: TContext,\n fileReference: FileReference\n): string {\n return replaceExtension(\n replacePath(\n replacePath(\n replacePath(\n replacePath(\n replacePath(\n fileReference.file,\n joinPaths(context.config.cwd, context.config.root, \"src\")\n ),\n joinPaths(context.config.cwd, context.config.root)\n ),\n joinPaths(context.config.root, \"src\")\n ),\n context.config.root\n ),\n \"src\"\n )\n );\n}\n\nexport function resolveInput<TContext extends UnresolvedContext>(\n context: TContext,\n fileReference: FileReference,\n input?: FileReferenceParameter,\n output?: string\n): ResolvedEntryFileReference {\n return {\n ...fileReference,\n input: isSetString(input) ? { file: String(input) } : fileReference,\n output: output || resolveEntryOutput(context, fileReference)\n };\n}\n\n/**\n * Resolves multiple file references into their corresponding resolved entry file references.\n *\n * @param context - The current context\n * @param fileReferences - The file references to resolve.\n * @returns A promise that resolves to an array of resolved entry file references .\n */\nexport async function resolveInputs<TContext extends UnresolvedContext>(\n context: TContext,\n fileReferences:\n | FileReferenceParameter\n | FileReferenceParameter[]\n | Record<string, FileReferenceParameter | FileReferenceParameter[]>\n): Promise<ResolvedEntryFileReference[]> {\n return (\n await Promise.all(\n (isObject(fileReferences) && !isFileReference(fileReferences)\n ? Object.values(fileReferences).flat()\n : toArray(fileReferences)\n )\n .map(async entry => {\n if (isResolvedEntryFileReference(entry)) {\n return {\n ...entry,\n output: entry.output\n ? replacePathTokens(context, entry.output)\n : undefined,\n file: replacePathTokens(context, entry.file)\n };\n }\n\n let typeDefinition: FileReference;\n if (isString(entry)) {\n typeDefinition = extractFileReference(\n replacePathTokens(context, entry)\n )!;\n } else {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(\n context,\n typeDefinition.file\n );\n }\n\n const filePath = isAbsolutePath(typeDefinition.file)\n ? typeDefinition.file\n : appendPath(typeDefinition.file, context.config.root);\n if (await context.fs.isFile(filePath)) {\n return resolveInput(\n context,\n {\n file: replacePath(filePath, context.config.root),\n export: typeDefinition.export\n },\n (entry as ResolvedEntryFileReference).input,\n (entry as ResolvedEntryFileReference).output\n );\n }\n\n return (\n await context.fs.glob(appendPath(filePath, context.config.cwd))\n ).map(file =>\n resolveInput(\n context,\n {\n file: replacePath(file, context.config.root),\n export: typeDefinition.export\n },\n (entry as ResolvedEntryFileReference).input,\n (entry as ResolvedEntryFileReference).output\n )\n );\n })\n .flat()\n .filter(Boolean)\n )\n ).flat();\n}\n\n/**\n * Resolves multiple file references into their corresponding resolved entry file references.\n *\n * @param context - The current context\n * @param fileReferences - The file references to resolve.\n * @returns An array of resolved entry file references.\n */\nexport function resolveInputsSync<TContext extends UnresolvedContext>(\n context: TContext,\n fileReferences:\n | FileReferenceParameter\n | FileReferenceParameter[]\n | Record<string, FileReferenceParameter | FileReferenceParameter[]>\n): ResolvedEntryFileReference[] {\n return (\n isObject(fileReferences) && !isFileReference(fileReferences)\n ? Object.values(fileReferences).flat()\n : toArray(fileReferences)\n )\n .map(entry => {\n if (isResolvedEntryFileReference(entry)) {\n return {\n ...entry,\n output: entry.output\n ? replacePathTokens(context, entry.output)\n : undefined,\n file: replacePathTokens(context, entry.file)\n };\n }\n\n let typeDefinition: FileReference;\n if (isString(entry)) {\n typeDefinition = extractFileReference(\n replacePathTokens(context, entry)\n )!;\n } else {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(context, typeDefinition.file);\n }\n\n const filePath = isAbsolutePath(typeDefinition.file)\n ? typeDefinition.file\n : appendPath(typeDefinition.file, context.config.root);\n if (context.fs.isFileSync(filePath)) {\n return resolveInput(context, {\n file: appendPath(filePath, context.config.cwd),\n export: typeDefinition.export\n });\n }\n\n return context.fs\n .globSync(appendPath(filePath, context.config.cwd))\n .map(file =>\n resolveInput(context, {\n file,\n export: typeDefinition.export\n })\n );\n })\n .flat()\n .filter(Boolean);\n}\n\n/**\n * Checks if the provided entry is a file reference.\n *\n * @param entry - The entry to check.\n * @returns True if the entry is a file reference, false otherwise.\n */\nexport function isFileReference(entry: any): entry is FileReference {\n return !isString(entry) && entry.file !== undefined;\n}\n\n/**\n * Checks if the provided entry is a resolved entry file reference.\n *\n * @param entry - The entry to check.\n * @returns True if the entry is a resolved entry file reference, false otherwise.\n */\nexport function isResolvedEntryFileReference(\n entry: FileReferenceParameter | ResolvedEntryFileReference\n): entry is ResolvedEntryFileReference {\n return (\n isFileReference(entry) &&\n (entry as ResolvedEntryFileReference).output !== undefined\n );\n}\n\n/**\n * Get unique inputs from the provided list.\n *\n * @param inputs - The entry points to process.\n * @returns An array of unique inputs (by file path or content hash).\n */\nexport function getUniqueInputs(\n inputs: Config[\"input\"] = []\n): ResolvedConfig[\"input\"] {\n return isObject(inputs)\n ? inputs\n : getUniqueBy(toArray(inputs), (item: FileReferenceParameter) =>\n isSetString(item) ? item : murmurhash(item ?? {}, { maxLength: 24 })\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAyCA,SAAgB,mBACd,SACA,eACQ;CACR,OAAO,iBACL,YACE,YACE,YACE,YACE,YACE,cAAc,MACd,UAAU,QAAQ,OAAO,KAAK,QAAQ,OAAO,MAAM,KAAK,CAC1D,GACA,UAAU,QAAQ,OAAO,KAAK,QAAQ,OAAO,IAAI,CACnD,GACA,UAAU,QAAQ,OAAO,MAAM,KAAK,CACtC,GACA,QAAQ,OAAO,IACjB,GACA,KACF,CACF;AACF;AAEA,SAAgB,aACd,SACA,eACA,OACA,QAC4B;CAC5B,OAAO;EACL,GAAG;EACH,OAAO,YAAY,KAAK,IAAI,EAAE,MAAM,OAAO,KAAK,EAAE,IAAI;EACtD,QAAQ,UAAU,mBAAmB,SAAS,aAAa;CAC7D;A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IAAI,6BAA6B,KAAK,GACpC,OAAO;GACL,GAAG;GACH,QAAQ,MAAM,SACV,kBAAkB,SAAS,MAAM,MAAM,IACvC;GACJ,MAAM,kBAAkB,SAAS,MAAM,IAAI;EAC7C;EAGF,IAAI;EACJ,IAAI,SAAS,KAAK,GAChB,iBAAiB,qBACf,kBAAkB,SAAS,KAAK,CAClC;OACK;GACL,iBAAiB;GACjB,eAAe,OAAO,kBAAkB,SAAS,eAAe,IAAI;EACtE;EAEA,MAAM,WAAW,eAAe,eAAe,IAAI,IAC/C,eAAe,OACf,WAAW,eAAe,MAAM,QAAQ,OAAO,IAAI;EACvD,IAAI,QAAQ,GAAG,WAAW,QAAQ,GAChC,OAAO,aAAa,SAAS;GAC3B,MAAM,WAAW,UAAU,QAAQ,OAAO,GAAG;GAC7C,QAAQ,eAAe;EACzB,CAAC;EAGH,OAAO,QAAQ,GACZ,SAAS,WAAW,UAAU,QAAQ,OAAO,GAAG,CAAC,CAAC,CAClD,KAAI,SACH,aAAa,SAAS;GACpB;GACA,QAAQ,eAAe;EACzB,CAAC,CACH;CACJ,CAAC,CAAC,CACD,KAAK,CAAC,CACN,OAAO,OAAO;AACnB;;;;;;;AAQA,SAAgB,gBAAgB,OAAoC;CAClE,OAAO,CAAC,SAAS,KAAK,KAAK,MAAM,SAAS;AAC5C;;;;;;;AAQA,SAAgB,6BACd,OACqC;CACrC,OACE,gBAAgB,KAAK,KACpB,MAAqC,WAAW;AAErD;;;;;;;AAQA,SAAgB,gBACd,SAA0B,CAAC,GACF;CACzB,OAAO,SAAS,MAAM,IAClB,SACA,YAAY,QAAQ,MAAM,IAAI,SAC5B,YAAY,IAAI,IAAI,OAAO,WAAW,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,CAAC,CACrE;AACN"}
1
+ {"version":3,"file":"entry.mjs","names":[],"sources":["../../src/lib/entry.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n 🗲 Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { extractFileReference } from \"@stryke/convert/extract-file-reference\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { murmurhash } from \"@stryke/hash\";\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type {\n FileReference,\n FileReferenceInput\n} from \"@stryke/types/configuration\";\nimport { replacePathTokens } from \"../plugin-utils/paths\";\nimport {\n Config,\n ResolvedConfig,\n ResolvedEntryFileReference\n} from \"../types/config\";\nimport type { UnresolvedContext } from \"../types/context\";\n\nexport function resolveEntryOutput<TContext extends UnresolvedContext>(\n context: TContext,\n fileReference: FileReference\n): string {\n return replaceExtension(\n replacePath(\n replacePath(\n replacePath(\n replacePath(\n replacePath(\n fileReference.file,\n joinPaths(context.config.cwd, context.config.root, \"src\")\n ),\n joinPaths(context.config.cwd, context.config.root)\n ),\n joinPaths(context.config.root, \"src\")\n ),\n context.config.root\n ),\n \"src\"\n )\n );\n}\n\nexport function resolveInput<TContext extends UnresolvedContext>(\n context: TContext,\n fileReference: FileReference,\n input?: FileReferenceInput,\n output?: string\n): ResolvedEntryFileReference {\n return {\n ...fileReference,\n input: isSetString(input) ? { file: String(input) } : fileReference,\n output: output || resolveEntryOutput(context, fileReference)\n };\n}\n\n/**\n * Resolves multiple file references into their corresponding resolved entry file references.\n *\n * @param context - The current context\n * @param fileReferences - The file references to resolve.\n * @returns A promise that resolves to an array of resolved entry file references .\n */\nexport async function resolveInputs<TContext extends UnresolvedContext>(\n context: TContext,\n fileReferences:\n | FileReferenceInput\n | FileReferenceInput[]\n | Record<string, FileReferenceInput | FileReferenceInput[]>\n): Promise<ResolvedEntryFileReference[]> {\n return (\n await Promise.all(\n (isObject(fileReferences) && !isFileReference(fileReferences)\n ? Object.values(fileReferences).flat()\n : toArray(fileReferences)\n )\n .map(async entry => {\n if (isResolvedEntryFileReference(entry)) {\n return {\n ...entry,\n output: entry.output\n ? replacePathTokens(context, entry.output)\n : undefined,\n file: replacePathTokens(context, entry.file)\n };\n }\n\n let typeDefinition: FileReference;\n if (isString(entry)) {\n typeDefinition = extractFileReference(\n replacePathTokens(context, entry)\n )!;\n } else {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(\n context,\n typeDefinition.file\n );\n }\n\n const filePath = isAbsolutePath(typeDefinition.file)\n ? typeDefinition.file\n : appendPath(typeDefinition.file, context.config.root);\n if (await context.fs.isFile(filePath)) {\n return resolveInput(\n context,\n {\n file: replacePath(filePath, context.config.root),\n export: typeDefinition.export\n },\n (entry as ResolvedEntryFileReference).input,\n (entry as ResolvedEntryFileReference).output\n );\n }\n\n return (\n await context.fs.glob(appendPath(filePath, context.config.cwd))\n ).map(file =>\n resolveInput(\n context,\n {\n file: replacePath(file, context.config.root),\n export: typeDefinition.export\n },\n (entry as ResolvedEntryFileReference).input,\n (entry as ResolvedEntryFileReference).output\n )\n );\n })\n .flat()\n .filter(Boolean)\n )\n ).flat();\n}\n\n/**\n * Resolves multiple file references into their corresponding resolved entry file references.\n *\n * @param context - The current context\n * @param fileReferences - The file references to resolve.\n * @returns An array of resolved entry file references.\n */\nexport function resolveInputsSync<TContext extends UnresolvedContext>(\n context: TContext,\n fileReferences:\n | FileReferenceInput\n | FileReferenceInput[]\n | Record<string, FileReferenceInput | FileReferenceInput[]>\n): ResolvedEntryFileReference[] {\n return (\n isObject(fileReferences) && !isFileReference(fileReferences)\n ? Object.values(fileReferences).flat()\n : toArray(fileReferences)\n )\n .map(entry => {\n if (isResolvedEntryFileReference(entry)) {\n return {\n ...entry,\n output: entry.output\n ? replacePathTokens(context, entry.output)\n : undefined,\n file: replacePathTokens(context, entry.file)\n };\n }\n\n let typeDefinition: FileReference;\n if (isString(entry)) {\n typeDefinition = extractFileReference(\n replacePathTokens(context, entry)\n )!;\n } else {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(context, typeDefinition.file);\n }\n\n const filePath = isAbsolutePath(typeDefinition.file)\n ? typeDefinition.file\n : appendPath(typeDefinition.file, context.config.root);\n if (context.fs.isFileSync(filePath)) {\n return resolveInput(context, {\n file: appendPath(filePath, context.config.cwd),\n export: typeDefinition.export\n });\n }\n\n return context.fs\n .globSync(appendPath(filePath, context.config.cwd))\n .map(file =>\n resolveInput(context, {\n file,\n export: typeDefinition.export\n })\n );\n })\n .flat()\n .filter(Boolean);\n}\n\n/**\n * Checks if the provided entry is a file reference.\n *\n * @param entry - The entry to check.\n * @returns True if the entry is a file reference, false otherwise.\n */\nexport function isFileReference(entry: any): entry is FileReference {\n return !isString(entry) && entry.file !== undefined;\n}\n\n/**\n * Checks if the provided entry is a resolved entry file reference.\n *\n * @param entry - The entry to check.\n * @returns True if the entry is a resolved entry file reference, false otherwise.\n */\nexport function isResolvedEntryFileReference(\n entry: FileReferenceInput | ResolvedEntryFileReference\n): entry is ResolvedEntryFileReference {\n return (\n isFileReference(entry) &&\n (entry as ResolvedEntryFileReference).output !== undefined\n );\n}\n\n/**\n * Get unique inputs from the provided list.\n *\n * @param inputs - The entry points to process.\n * @returns An array of unique inputs (by file path or content hash).\n */\nexport function getUniqueInputs(\n inputs: Config[\"input\"] = []\n): ResolvedConfig[\"input\"] {\n return isObject(inputs)\n ? inputs\n : getUniqueBy(toArray(inputs), (item: FileReferenceInput) =>\n isSetString(item) ? item : mur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AAO,OAAO;AACnB;;;;;;;AAQA,SAAgB,gBAAgB,OAAoC;CAClE,OAAO,CAAC,SAAS,KAAK,KAAK,MAAM,SAAS;AAC5C;;;;;;;AAQA,SAAgB,6BACd,OACqC;CACrC,OACE,gBAAgB,KAAK,KACpB,MAAqC,WAAW;AAErD;;;;;;;AAQA,SAAgB,gBACd,SAA0B,CAAC,GACF;CACzB,OAAO,SAAS,MAAM,IAClB,SACA,YAAY,QAAQ,MAAM,IAAI,SAC5B,YAAY,IAAI,IAAI,OAAO,WAAW,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,CAAC,CACrE;AACN"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/core",
3
- "version": "0.48.77",
3
+ "version": "0.48.79",
4
4
  "private": false,
5
5
  "description": "An internal core package for Powerlines - please use the `powerlines` package for public usage.",
6
6
  "homepage": "https://stormsoftware.com",
@@ -378,5 +378,5 @@
378
378
  "undici-types": "^7.29.0"
379
379
  },
380
380
  "publishConfig": { "access": "public" },
381
- "gitHead": "6e0e8863a426ffc8c3fab201d88493ba5142648b"
381
+ "gitHead": "dfffbcdd727e7f32670c46a3f28d14817411f28a"
382
382
  }