@adamhl8/configs 0.15.22 → 0.15.24
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/knip-preprocessor.js +7 -0
- package/dist/knip-preprocessor.js.map +1 -1
- package/dist/knip.d.ts +1155 -5
- package/dist/knip.d.ts.map +1 -1
- package/dist/knip.js.map +1 -1
- package/dist/prettier.d.ts +42 -5
- package/dist/prettier.d.ts.map +1 -1
- package/dist/prettier.js.map +1 -1
- package/dist/tsdown.d.ts +68 -8
- package/dist/tsdown.d.ts.map +1 -1
- package/dist/tsdown.js.map +1 -1
- package/dist/utils.d.ts +20 -6
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +4 -5
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/knip.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knip.d.ts","names":[],"sources":["../src/knip.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"knip.d.ts","names":[],"sources":["../src/knip.ts"],"sourcesContent":[],"mappings":";;;cAca;;;IAAA,KAAA,CAAA,EAAA,MAA2E,GAAA,MAAA,EAAA,GAAA,SAAA;IAAA,OAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA,GAAA,SAAA;;;;;;;;;;IAC6muP,MAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA,GAAA,SAAA;;;MAAoP,SAAA;;IAA0rzB,MAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA,GAAA,SAAA;IAA+G,KAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA,GAAA,SAAA;IAA8D,OAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA,GAAA,SAAA;MAAyD,SAAA;OAA4D,CAAA,EAAA,MAAA,GAAA,OAAA,GAAA,MAAA,EAAA,GAAA;;;IAD93iR,OAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA,GAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gKAC8quP;;0FAAoP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAA0rzB;;+BAA+G;mCAA8D;8BAAyD;iCAA4D"}
|
package/dist/knip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knip.js","names":[
|
|
1
|
+
{"version":3,"file":"knip.js","names":[],"sources":["../src/knip.ts"],"sourcesContent":["import type { KnipConfig } from \"knip\"\n\nimport { createMergeConfigFn } from \"./utils.ts\"\n\n// Normally, specifying the `./src/index.ts` entry would cause knip to complain about a redundant entry because it gets automatically included via the tsdown plugin.\n// However, in projects that _don't_ use tsdown, the `./src/index.ts` entry would be missing entirely.\n// To handle this, we specify it and disable the tsdown plugin. This makes knip work in both cases.\n\nconst baseConfig = {\n entry: [\"./src/index.ts\", \"**/*.test.ts\", \"./tsdown.config.ts\"],\n project: [\"**\"],\n tsdown: false,\n} as const satisfies KnipConfig\n\nexport const knipConfig = createMergeConfigFn<KnipConfig, typeof baseConfig>(baseConfig)\n"],"mappings":";AAcA,MAAa,aAAa,oBANP;CACjB,OAAO;EAAC;EAAkB;EAAgB;EAAqB;CAC/D,SAAS,CAAC,KAAK;CACf,QAAQ;CACT,CAEuF"}
|
package/dist/prettier.d.ts
CHANGED
|
@@ -1,8 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { OptionalMergeConfigFn } from "./utils.js";
|
|
2
|
+
import * as prettier0 from "prettier";
|
|
3
3
|
|
|
4
4
|
//#region src/prettier.d.ts
|
|
5
|
-
declare const
|
|
5
|
+
declare const prettierConfig: OptionalMergeConfigFn<{
|
|
6
|
+
[x: string]: unknown;
|
|
7
|
+
overrides?: Array<{
|
|
8
|
+
files: string | string[];
|
|
9
|
+
excludeFiles?: string | string[];
|
|
10
|
+
options?: prettier0.Options;
|
|
11
|
+
}>;
|
|
12
|
+
semi?: boolean;
|
|
13
|
+
singleQuote?: boolean;
|
|
14
|
+
jsxSingleQuote?: boolean;
|
|
15
|
+
trailingComma?: "none" | "es5" | "all";
|
|
16
|
+
bracketSpacing?: boolean;
|
|
17
|
+
objectWrap?: "preserve" | "collapse";
|
|
18
|
+
bracketSameLine?: boolean;
|
|
19
|
+
rangeStart?: number;
|
|
20
|
+
rangeEnd?: number;
|
|
21
|
+
parser?: prettier0.LiteralUnion<prettier0.BuiltInParserName>;
|
|
22
|
+
filepath?: string;
|
|
23
|
+
requirePragma?: boolean;
|
|
24
|
+
insertPragma?: boolean;
|
|
25
|
+
checkIgnorePragma?: boolean;
|
|
26
|
+
proseWrap?: "always" | "never" | "preserve";
|
|
27
|
+
arrowParens?: "avoid" | "always";
|
|
28
|
+
plugins?: Array<string | URL | prettier0.Plugin>;
|
|
29
|
+
htmlWhitespaceSensitivity?: "css" | "strict" | "ignore";
|
|
30
|
+
endOfLine?: "auto" | "lf" | "crlf" | "cr";
|
|
31
|
+
quoteProps?: "as-needed" | "consistent" | "preserve";
|
|
32
|
+
vueIndentScriptAndStyle?: boolean;
|
|
33
|
+
embeddedLanguageFormatting?: "auto" | "off";
|
|
34
|
+
singleAttributePerLine?: boolean;
|
|
35
|
+
experimentalOperatorPosition?: "start" | "end";
|
|
36
|
+
experimentalTernaries?: boolean;
|
|
37
|
+
jsxBracketSameLine?: boolean;
|
|
38
|
+
printWidth?: number;
|
|
39
|
+
tabWidth?: number;
|
|
40
|
+
useTabs?: boolean;
|
|
41
|
+
parentParser?: string | undefined | undefined;
|
|
42
|
+
__embeddedInHtml?: boolean | undefined | undefined;
|
|
43
|
+
}, {
|
|
6
44
|
readonly printWidth: 120;
|
|
7
45
|
readonly semi: false;
|
|
8
46
|
readonly plugins: ["@prettier/plugin-xml", "prettier-plugin-sh", "prettier-plugin-toml", "prettier-plugin-astro", "prettier-plugin-tailwindcss"];
|
|
@@ -18,8 +56,7 @@ declare const baseConfig: {
|
|
|
18
56
|
readonly parser: "astro";
|
|
19
57
|
};
|
|
20
58
|
}];
|
|
21
|
-
}
|
|
22
|
-
declare const prettierConfig: MergeConfigFn<Config, typeof baseConfig>;
|
|
59
|
+
}>;
|
|
23
60
|
//#endregion
|
|
24
61
|
export { prettierConfig };
|
|
25
62
|
//# sourceMappingURL=prettier.d.ts.map
|
package/dist/prettier.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prettier.d.ts","names":[],"sources":["../src/prettier.ts"],"sourcesContent":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"prettier.d.ts","names":[],"sources":["../src/prettier.ts"],"sourcesContent":[],"mappings":";;;;cAoCa;;;;IAAA,YAAA,CAAmF,EAAA,MAAA,GAAA,MAAA,EAAA;IAAA,OAAA,CAAA,EAAA,SAAA,CACwpP,OADxpP;;;;;;;;;EAArE,UAAA,CAAA,EAAA,MAAA"}
|
package/dist/prettier.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prettier.js","names":[
|
|
1
|
+
{"version":3,"file":"prettier.js","names":[],"sources":["../src/prettier.ts"],"sourcesContent":["import type { Config } from \"prettier\"\nimport type { Simplify } from \"type-fest\"\n\nimport { createMergeConfigFn } from \"./utils.ts\"\n\n// for some reason the Config type from prettier doesn't satisfy AnyObj unless we simplify it\ntype PrettierConfig = Simplify<Config>\n\nconst baseConfig = {\n printWidth: 120,\n semi: false,\n plugins: [\n \"@prettier/plugin-xml\",\n \"prettier-plugin-sh\",\n \"prettier-plugin-toml\",\n \"prettier-plugin-astro\",\n \"prettier-plugin-tailwindcss\",\n ],\n tailwindStylesheet: \"./src/global.css\",\n overrides: [\n {\n // https://github.com/prettier/prettier/issues/15956\n files: \"*.jsonc\",\n options: {\n trailingComma: \"none\",\n },\n },\n {\n files: \"*.astro\",\n options: {\n parser: \"astro\",\n },\n },\n ],\n} as const satisfies PrettierConfig\n\nexport const prettierConfig = createMergeConfigFn<PrettierConfig, typeof baseConfig>(baseConfig)\n"],"mappings":";AAoCA,MAAa,iBAAiB,oBA5BX;CACjB,YAAY;CACZ,MAAM;CACN,SAAS;EACP;EACA;EACA;EACA;EACA;EACD;CACD,oBAAoB;CACpB,WAAW,CACT;EAEE,OAAO;EACP,SAAS,EACP,eAAe,QAChB;EACF,EACD;EACE,OAAO;EACP,SAAS,EACP,QAAQ,SACT;EACF,CACF;CACF,CAE+F"}
|
package/dist/tsdown.d.ts
CHANGED
|
@@ -1,8 +1,70 @@
|
|
|
1
|
-
import { MergeConfigFn } from "./utils.js";
|
|
2
|
-
import
|
|
1
|
+
import { MergeConfigFn, OptionalMergeConfigFn } from "./utils.js";
|
|
2
|
+
import * as rolldown0 from "rolldown";
|
|
3
|
+
import * as tsdown0 from "tsdown";
|
|
4
|
+
import * as rolldown_plugin_dts0 from "rolldown-plugin-dts";
|
|
5
|
+
import * as publint0 from "publint";
|
|
6
|
+
import * as hookable0 from "hookable";
|
|
3
7
|
|
|
4
8
|
//#region src/tsdown.d.ts
|
|
5
|
-
declare const
|
|
9
|
+
declare const tsdownConfig: MergeConfigFn<{
|
|
10
|
+
entry?: rolldown0.InputOption;
|
|
11
|
+
external?: rolldown0.ExternalOption;
|
|
12
|
+
noExternal?: (string | RegExp | (string | RegExp)[]) | ((id: string, importer: string | undefined) => boolean | null | undefined | void);
|
|
13
|
+
skipNodeModulesBundle?: boolean;
|
|
14
|
+
alias?: Record<string, string>;
|
|
15
|
+
tsconfig?: string | boolean;
|
|
16
|
+
target?: string | string[] | false;
|
|
17
|
+
env?: Record<string, any>;
|
|
18
|
+
define?: Record<string, string>;
|
|
19
|
+
shims?: boolean;
|
|
20
|
+
treeshake?: boolean;
|
|
21
|
+
loader?: tsdown0.ModuleTypes;
|
|
22
|
+
removeNodeProtocol?: boolean;
|
|
23
|
+
nodeProtocol?: "strip" | boolean;
|
|
24
|
+
plugins?: rolldown0.RolldownPluginOption<any>;
|
|
25
|
+
inputOptions?: rolldown0.InputOptions | ((options: rolldown0.InputOptions, format: tsdown0.NormalizedFormat, context: {
|
|
26
|
+
cjsDts: boolean;
|
|
27
|
+
}) => void | rolldown0.InputOptions | Promise<void | rolldown0.InputOptions | null> | null);
|
|
28
|
+
format?: tsdown0.Format | tsdown0.Format[];
|
|
29
|
+
globalName?: string;
|
|
30
|
+
outDir?: string;
|
|
31
|
+
sourcemap?: tsdown0.Sourcemap;
|
|
32
|
+
clean?: boolean | string[];
|
|
33
|
+
minify?: boolean | "dce-only" | rolldown0.MinifyOptions;
|
|
34
|
+
footer?: tsdown0.ChunkAddon;
|
|
35
|
+
banner?: tsdown0.ChunkAddon;
|
|
36
|
+
unbundle?: boolean;
|
|
37
|
+
bundle?: boolean;
|
|
38
|
+
fixedExtension?: boolean;
|
|
39
|
+
outExtensions?: tsdown0.OutExtensionFactory;
|
|
40
|
+
hash?: boolean;
|
|
41
|
+
cjsDefault?: boolean;
|
|
42
|
+
outputOptions?: rolldown0.OutputOptions | ((options: rolldown0.OutputOptions, format: tsdown0.NormalizedFormat, context: {
|
|
43
|
+
cjsDts: boolean;
|
|
44
|
+
}) => void | rolldown0.OutputOptions | Promise<void | rolldown0.OutputOptions | null> | null);
|
|
45
|
+
cwd?: string;
|
|
46
|
+
name?: string;
|
|
47
|
+
silent?: boolean;
|
|
48
|
+
logLevel?: "silent" | ("error" | "warn" | "info");
|
|
49
|
+
failOnWarn?: boolean;
|
|
50
|
+
customLogger?: tsdown0.Logger;
|
|
51
|
+
fromVite?: boolean | "vitest";
|
|
52
|
+
watch?: boolean | (string | string[]);
|
|
53
|
+
ignoreWatch?: string | RegExp | (string | RegExp)[];
|
|
54
|
+
onSuccess?: string | ((config: tsdown0.ResolvedOptions, signal: AbortSignal) => void | Promise<void>);
|
|
55
|
+
dts?: boolean | rolldown_plugin_dts0.Options;
|
|
56
|
+
unused?: boolean | UnusedOptions;
|
|
57
|
+
publint?: boolean | publint0.Options;
|
|
58
|
+
attw?: boolean | tsdown0.AttwOptions;
|
|
59
|
+
report?: boolean | tsdown0.ReportOptions;
|
|
60
|
+
globImport?: boolean;
|
|
61
|
+
exports?: boolean | tsdown0.ExportsOptions;
|
|
62
|
+
publicDir?: tsdown0.CopyOptions | tsdown0.CopyOptionsFn;
|
|
63
|
+
copy?: tsdown0.CopyOptions | tsdown0.CopyOptionsFn;
|
|
64
|
+
hooks?: Partial<tsdown0.TsdownHooks> | ((hooks: hookable0.Hookable<tsdown0.TsdownHooks>) => void | Promise<void>);
|
|
65
|
+
workspace?: tsdown0.Workspace | (string | string[]) | true;
|
|
66
|
+
platform: "node" | "neutral" | "browser";
|
|
67
|
+
}, {
|
|
6
68
|
readonly entry: ["./src/index.ts"];
|
|
7
69
|
readonly unbundle: true;
|
|
8
70
|
readonly target: false;
|
|
@@ -20,8 +82,8 @@ declare const baseConfig: {
|
|
|
20
82
|
};
|
|
21
83
|
readonly publint: true;
|
|
22
84
|
readonly failOnWarn: true;
|
|
23
|
-
}
|
|
24
|
-
declare const
|
|
85
|
+
}>;
|
|
86
|
+
declare const tsdownBinConfig: OptionalMergeConfigFn<Omit<tsdown0.Options, "config" | "filter" | "configLoader">, {
|
|
25
87
|
readonly entry: [];
|
|
26
88
|
readonly platform: "node";
|
|
27
89
|
readonly outExtensions: () => {
|
|
@@ -37,9 +99,7 @@ declare const binConfig: {
|
|
|
37
99
|
readonly minify: "dce-only";
|
|
38
100
|
readonly hash: false;
|
|
39
101
|
readonly failOnWarn: true;
|
|
40
|
-
}
|
|
41
|
-
declare const tsdownConfig: MergeConfigFn<UserConfig, typeof baseConfig>;
|
|
42
|
-
declare const tsdownBinConfig: MergeConfigFn<UserConfig, typeof binConfig>;
|
|
102
|
+
}>;
|
|
43
103
|
//#endregion
|
|
44
104
|
export { tsdownBinConfig, tsdownConfig };
|
|
45
105
|
//# sourceMappingURL=tsdown.d.ts.map
|
package/dist/tsdown.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsdown.d.ts","names":[],"sources":["../src/tsdown.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tsdown.d.ts","names":[],"sources":["../src/tsdown.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAyCa;UAAyF,SAAA,CAAA;;;;;;;EAAzF,GAAA,CAAA,QAAA,CAAA,MAAyF,EAAA,GAAA,CAAA;EAAA,MAAA,CAAA,QAAA,CAAA,MAAA,EAAA,MAAA,CAAA;OAAA,CAAA,EAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAA7E,SAAA,MAAA,EAAA,KAAA;EACZ,SAAA,QAAA,EAAwF,SAAA;EAAA,SAAA,MAAA,EAAA,UAAA;WAAA,SAAzE,EAAA,IAAA;WAAA,IAAA,EAAA,KAAA;WAAA,GAAA,EAAA;IAAA,SAAA,UAAA,EAAA,IAAA;;;;;;;;;;cAAf,iBAAe,sBAAA,KAAyE,OAAA,CAAzE,OAAA"}
|
package/dist/tsdown.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsdown.js","names":[
|
|
1
|
+
{"version":3,"file":"tsdown.js","names":[],"sources":["../src/tsdown.ts"],"sourcesContent":["import type { NormalizedUserConfig } from \"tsdown\"\nimport type { SetRequired } from \"type-fest\"\n\nimport { createMergeConfigFn } from \"./utils.ts\"\n\n// force projects to specify platform\ntype StrictUserConfig = SetRequired<NormalizedUserConfig, \"platform\">\n\nconst baseConfig = {\n entry: [\"./src/index.ts\"],\n unbundle: true,\n target: false,\n platform: \"neutral\",\n minify: \"dce-only\",\n sourcemap: true,\n hash: false,\n dts: {\n newContext: true,\n sourcemap: true,\n },\n attw: {\n level: \"error\",\n profile: \"esmOnly\",\n },\n publint: true,\n failOnWarn: true,\n} as const satisfies StrictUserConfig\n\nconst binConfig = {\n ...baseConfig,\n entry: [],\n platform: \"node\",\n outExtensions: () => ({ js: \"\" }),\n copy: [],\n unbundle: false,\n sourcemap: false,\n dts: false,\n attw: false,\n publint: false,\n} as const satisfies NormalizedUserConfig\n\nexport const tsdownConfig = createMergeConfigFn<StrictUserConfig, typeof baseConfig, true>(baseConfig)\nexport const tsdownBinConfig = createMergeConfigFn<NormalizedUserConfig, typeof binConfig>(binConfig)\n"],"mappings":";AAQA,MAAM,aAAa;CACjB,OAAO,CAAC,iBAAiB;CACzB,UAAU;CACV,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,WAAW;CACX,MAAM;CACN,KAAK;EACH,YAAY;EACZ,WAAW;EACZ;CACD,MAAM;EACJ,OAAO;EACP,SAAS;EACV;CACD,SAAS;CACT,YAAY;CACb;AAED,MAAM,YAAY;CAChB,GAAG;CACH,OAAO,EAAE;CACT,UAAU;CACV,sBAAsB,EAAE,IAAI,IAAI;CAChC,MAAM,EAAE;CACR,UAAU;CACV,WAAW;CACX,KAAK;CACL,MAAM;CACN,SAAS;CACV;AAED,MAAa,eAAe,oBAA+D,WAAW;AACtG,MAAa,kBAAkB,oBAA4D,UAAU"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
import { MergeDeep } from "type-fest";
|
|
2
2
|
|
|
3
3
|
//#region src/utils.d.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Type representing a merge config function, where the `UserConfig` passed in is merged with `BaseConfig`.
|
|
7
|
+
*/
|
|
8
|
+
interface MergeConfigFn<UserConfig, BaseConfig> {
|
|
9
|
+
<UserConfigToMerge extends UserConfig>(userConfig: UserConfigToMerge): MergeDeep<BaseConfig, UserConfigToMerge, {
|
|
10
|
+
arrayMergeMode: "spread";
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Type representing an overloaded function signature for MergeConfigFn:
|
|
15
|
+
* - if `UserConfig` is not provided, the return type is `BaseConfig`
|
|
16
|
+
* - if `UserConfig` is provided, the return type is the merged type of `BaseConfig` and `UserConfig`.
|
|
17
|
+
*
|
|
18
|
+
* This is needed to handle the fact that the `userConfig` argument is optional.
|
|
19
|
+
*
|
|
20
|
+
* Note that this extends `MergeConfigFn`, so this type has both function signatures on it.
|
|
21
|
+
*/
|
|
22
|
+
interface OptionalMergeConfigFn<UserConfig, BaseConfig> extends MergeConfigFn<UserConfig, BaseConfig> {
|
|
8
23
|
(): BaseConfig;
|
|
9
|
-
<UserConfig extends UserConfigType>(userConfig: UserConfig): MergeDeepConcat<BaseConfig, UserConfig>;
|
|
10
24
|
}
|
|
11
25
|
//#endregion
|
|
12
|
-
export { MergeConfigFn };
|
|
26
|
+
export { MergeConfigFn, OptionalMergeConfigFn };
|
|
13
27
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","names":[],"sources":["../src/utils.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","names":[],"sources":["../src/utils.ts"],"sourcesContent":[],"mappings":";;;;;AAkBA;;AAE6B,UAFZ,aAEY,CAAA,UAAA,EAAA,UAAA,CAAA,CAAA;6BAAA,UACb,CAAA,CAAA,UAAA,EAAA,iBAAA,CAAA,EACX,SADW,CACD,UADC,EACW,iBADX,EAAA;IACD,cAAA,EAAA,QAAA;;;;AAaf;;;;;;;;UAAiB,sDAAsD,cAAc,YAAY;MAC3F"}
|
package/dist/utils.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { mergeWith } from "es-toolkit";
|
|
2
|
-
import { clone
|
|
2
|
+
import { clone } from "remeda";
|
|
3
3
|
function merge(target, source) {
|
|
4
4
|
return mergeWith(target, source, (objValue, srcValue) => Array.isArray(objValue) ? objValue.concat(srcValue) : void 0);
|
|
5
5
|
}
|
|
6
6
|
function createMergeConfigFn(baseConfig) {
|
|
7
|
-
|
|
7
|
+
const mergeConfigFn = (userConfig) => {
|
|
8
8
|
if (userConfig === void 0) return baseConfig;
|
|
9
|
-
if (!(isPlainObject(baseConfig) && isPlainObject(userConfig))) throw new Error(`target and/or source is not an object: target='${baseConfig}'\nsource='${userConfig}'`);
|
|
10
9
|
return merge(clone(baseConfig), clone(userConfig));
|
|
11
|
-
}
|
|
12
|
-
return
|
|
10
|
+
};
|
|
11
|
+
return mergeConfigFn;
|
|
13
12
|
}
|
|
14
13
|
export { createMergeConfigFn };
|
|
15
14
|
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { mergeWith } from \"es-toolkit\"\nimport { clone
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { mergeWith } from \"es-toolkit\"\nimport { clone } from \"remeda\"\nimport type { MergeDeep } from \"type-fest\"\n\ntype AnyObj = Record<PropertyKey, unknown>\n\n/**\n * A wrapper around es-toolkit's `mergeWith` with a custom merge function that concatenates arrays.\n */\nfunction merge<T extends AnyObj, S extends AnyObj>(target: T, source: S): T & S {\n return mergeWith(target, source, (objValue: unknown, srcValue: unknown) =>\n Array.isArray(objValue) ? objValue.concat(srcValue) : undefined,\n )\n}\n\n/**\n * Type representing a merge config function, where the `UserConfig` passed in is merged with `BaseConfig`.\n */\nexport interface MergeConfigFn<UserConfig, BaseConfig> {\n // biome-ignore lint/style/useShorthandFunctionType: need to use call signature type\n <UserConfigToMerge extends UserConfig>(\n userConfig: UserConfigToMerge,\n ): MergeDeep<BaseConfig, UserConfigToMerge, { arrayMergeMode: \"spread\" }>\n // instead of returning `BaseConfig & UserConfig` (from `merge`), return a more friendly type using `MergeDeep`\n}\n\n/**\n * Type representing an overloaded function signature for MergeConfigFn:\n * - if `UserConfig` is not provided, the return type is `BaseConfig`\n * - if `UserConfig` is provided, the return type is the merged type of `BaseConfig` and `UserConfig`.\n *\n * This is needed to handle the fact that the `userConfig` argument is optional.\n *\n * Note that this extends `MergeConfigFn`, so this type has both function signatures on it.\n */\nexport interface OptionalMergeConfigFn<UserConfig, BaseConfig> extends MergeConfigFn<UserConfig, BaseConfig> {\n (): BaseConfig\n}\n\n/**\n * Creates a config merge function with proper type overloads for merging with a base config.\n */\nexport function createMergeConfigFn<\n UserConfig extends AnyObj,\n BaseConfig extends UserConfig,\n Required extends boolean = false, // if true, the created merge config function requires a userConfig to be passed in\n>(baseConfig: BaseConfig) {\n // we don't care about the specific type of userConfig here because we assert mergeConfigFn as the correct type below\n const mergeConfigFn = (userConfig?: AnyObj) => {\n if (userConfig === undefined) return baseConfig\n // clone both target and source so we never mutate the original objects\n return merge(clone(baseConfig), clone(userConfig))\n }\n\n return mergeConfigFn as Required extends true // if Required is true\n ? MergeConfigFn<UserConfig, BaseConfig> // then the merge config function requires a userConfig to be passed in\n : OptionalMergeConfigFn<UserConfig, BaseConfig> // else, userConfig is optional\n}\n"],"mappings":";;AASA,SAAS,MAA0C,QAAW,QAAkB;AAC9E,QAAO,UAAU,QAAQ,SAAS,UAAmB,aACnD,MAAM,QAAQ,SAAS,GAAG,SAAS,OAAO,SAAS,GAAG,KAAA,EACvD;;AA8BH,SAAgB,oBAId,YAAwB;CAExB,MAAM,iBAAiB,eAAwB;AAC7C,MAAI,eAAe,KAAA,EAAW,QAAO;AAErC,SAAO,MAAM,MAAM,WAAW,EAAE,MAAM,WAAW,CAAC;;AAGpD,QAAO"}
|