From 6f20a0f132187874de24c4589290bd8de28eb5ac Mon Sep 17 00:00:00 2001 From: Luca Ban Date: Tue, 23 May 2023 11:21:01 +0900 Subject: [PATCH] fix: exports --- dist/cjs/index.cjs | 83 ++++ .../Iteration.d.ts => cjs/index.d.cts} | 169 ++++++- dist/index.cjs | 122 ----- dist/index.d.ts | 416 ++++++++++++++++++ dist/index.es.js | 117 ----- dist/index.js | 78 ++++ dist/types/extensions.d.ts | 1 - dist/types/index.d.ts | 2 - dist/types/merge.d.ts | 17 - dist/types/typeUtils/Assign.d.ts | 50 --- dist/types/typeUtils/List.d.ts | 29 -- dist/types/typeUtils/MergeDeep.d.ts | 57 --- dist/types/typeUtils/PrettyPrint.d.ts | 6 - package-lock.json | 363 ++++++++------- package.json | 28 +- rollup.config.js | 45 ++ scripts/build.js | 18 - 17 files changed, 976 insertions(+), 625 deletions(-) create mode 100644 dist/cjs/index.cjs rename dist/{types/typeUtils/Iteration.d.ts => cjs/index.d.cts} (58%) delete mode 100644 dist/index.cjs create mode 100644 dist/index.d.ts delete mode 100644 dist/index.es.js create mode 100644 dist/index.js delete mode 100644 dist/types/extensions.d.ts delete mode 100644 dist/types/index.d.ts delete mode 100644 dist/types/merge.d.ts delete mode 100644 dist/types/typeUtils/Assign.d.ts delete mode 100644 dist/types/typeUtils/List.d.ts delete mode 100644 dist/types/typeUtils/MergeDeep.d.ts delete mode 100644 dist/types/typeUtils/PrettyPrint.d.ts create mode 100644 rollup.config.js delete mode 100644 scripts/build.js diff --git a/dist/cjs/index.cjs b/dist/cjs/index.cjs new file mode 100644 index 0000000..08a83df --- /dev/null +++ b/dist/cjs/index.cjs @@ -0,0 +1,83 @@ +'use strict'; + +const isWhat = require('is-what'); + +function concatArrays(originVal, newVal) { + if (isWhat.isArray(originVal) && isWhat.isArray(newVal)) { + return originVal.concat(newVal); + } + return newVal; +} + +function assignProp(carry, key, newVal, originalObject) { + const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable"; + if (propType === "enumerable") + carry[key] = newVal; + if (propType === "nonenumerable") { + Object.defineProperty(carry, key, { + value: newVal, + enumerable: false, + writable: true, + configurable: true + }); + } +} +function mergeRecursively(origin, newComer, compareFn) { + if (!isWhat.isPlainObject(newComer)) + return newComer; + let newObject = {}; + if (isWhat.isPlainObject(origin)) { + const props2 = Object.getOwnPropertyNames(origin); + const symbols2 = Object.getOwnPropertySymbols(origin); + newObject = [...props2, ...symbols2].reduce((carry, key) => { + const targetVal = origin[key]; + if (!isWhat.isSymbol(key) && !Object.getOwnPropertyNames(newComer).includes(key) || isWhat.isSymbol(key) && !Object.getOwnPropertySymbols(newComer).includes(key)) { + assignProp( + carry, + key, + targetVal, + origin + ); + } + return carry; + }, {}); + } + const props = Object.getOwnPropertyNames(newComer); + const symbols = Object.getOwnPropertySymbols(newComer); + const result = [...props, ...symbols].reduce((carry, key) => { + let newVal = newComer[key]; + const targetVal = isWhat.isPlainObject(origin) ? origin[key] : void 0; + if (targetVal !== void 0 && isWhat.isPlainObject(newVal)) { + newVal = mergeRecursively(targetVal, newVal, compareFn); + } + const propToAssign = compareFn ? compareFn(targetVal, newVal, key) : newVal; + assignProp( + carry, + key, + propToAssign, + newComer + ); + return carry; + }, newObject); + return result; +} +function merge(object, ...otherObjects) { + return otherObjects.reduce((result, newComer) => { + return mergeRecursively(result, newComer); + }, object); +} +function mergeAndCompare(compareFn, object, ...otherObjects) { + return otherObjects.reduce((result, newComer) => { + return mergeRecursively(result, newComer, compareFn); + }, object); +} +function mergeAndConcat(object, ...otherObjects) { + return otherObjects.reduce((result, newComer) => { + return mergeRecursively(result, newComer, concatArrays); + }, object); +} + +exports.concatArrays = concatArrays; +exports.merge = merge; +exports.mergeAndCompare = mergeAndCompare; +exports.mergeAndConcat = mergeAndConcat; diff --git a/dist/types/typeUtils/Iteration.d.ts b/dist/cjs/index.d.cts similarity index 58% rename from dist/types/typeUtils/Iteration.d.ts rename to dist/cjs/index.d.cts index 001e671..f2cd12d 100644 --- a/dist/types/typeUtils/Iteration.d.ts +++ b/dist/cjs/index.d.cts @@ -1,14 +1,71 @@ +/** + * Get the keys of `O` that are optional + * @param O + * @returns [[Key]] + * @example + * ```ts + * ``` + */ +type OptionalKeys = O extends unknown ? { + [K in keyof O]-?: {} extends Pick ? K : never; +}[keyof O] : never; +/** + * Get the keys of `O` that are required + * @param O + * @returns [[Key]] + * @example + * ```ts + * ``` + */ +type RequiredKeys = O extends unknown ? { + [K in keyof O]-?: {} extends Pick ? never : K; +}[keyof O] : never; +type MergeObjectDeeply, O1 extends Record> = { + [K in keyof (O & O1)]: K extends RequiredKeys ? MergeObjectsOrReturnFallback : K extends OptionalKeys ? K extends OptionalKeys ? MergeObjectsOrReturnFallback, Exclude, Exclude | Exclude> : K extends RequiredKeys ? Exclude extends O[K] ? O[K] : MergeObjectsOrReturnFallback, O[K] | Exclude> : O1[K] : O[K]; +}; +type MergeObjectsOrReturnFallback = O extends Record ? O1 extends Record ? MergeObjectDeeply : Fallback : Fallback; +/** + * Accurately merge the fields of `O` with the ones of `O1`. It is + * equivalent to the spread operator in JavaScript. [[Union]]s and [[Optional]] + * fields will be handled gracefully. + * + * (⚠️ needs `--strictNullChecks` enabled) + * @param O to complete + * @param O1 to copy from + * @returns [[Object]] + * @example + * ```ts + * import { PrettyPrint } from './PrettyPrint' + * + * type A1 = { a: number; b?: number; d?: number; e?: number; x: string; y?: number; z: string; } // prettier-ignore + * type A2 = { a?: number; c?: number; d?: number; e: number; x: number | undefined; y?: string; z?: number; } // prettier-ignore + * + * type Result = PrettyPrint> + * { + * a: number; + * b?: number | undefined; + * c?: number | undefined; + * d?: number | undefined; + * e: number; + * x: number | undefined; + * y?: string | number | undefined; + * z: string | number; + * } + * ``` + */ +type MergeDeep, O1 extends Record> = O extends unknown ? (O1 extends unknown ? MergeObjectDeeply : never) : never; + /** * An entry of `IterationMap` */ -export type Iteration = [ +type Iteration = [ value: number, sign: '-' | '0' | '+', prev: keyof IterationMap, next: keyof IterationMap, oppo: keyof IterationMap ]; -export type IterationMap = { +type IterationMap = { '__': [number, '-' | '0' | '+', '__', '__', '__']; '-100': [-100, '-', '__', '-99', '100']; '-99': [-99, '-', '-100', '-98', '99']; @@ -228,7 +285,7 @@ export type IterationMap = { * type nprev = Pos // -1 * ``` */ -export type IterationOf = `${N}` extends keyof IterationMap ? IterationMap[`${N}`] : IterationMap['__']; +type IterationOf = `${N}` extends keyof IterationMap ? IterationMap[`${N}`] : IterationMap['__']; /** * Get the position of `I` (**number**) * @param I to query @@ -241,7 +298,7 @@ export type IterationOf = `${N}` extends keyof IterationMap ? * type test1 = Pos> // 21 * ``` */ -export type Pos = I[0]; +type Pos = I[0]; /** * Move `I`'s position forward * @param I to move @@ -254,4 +311,106 @@ export type Pos = I[0]; * type test1 = Pos> // 21 * ``` */ -export type Next = IterationMap[I[3]]; +type Next = IterationMap[I[3]]; + +/** + * A [[List]] + * @param T its type + * @returns [[List]] + * @example + * ```ts + * type list0 = [1, 2, 3] + * type list1 = number[] + * ``` + */ +type List = readonly T[]; +/** + * Get the length of `L` + * @param L to get length + * @returns [[String]] or `number` + * @example + * ```ts + * ``` + */ +type Length = L['length']; +/** + * Return the last item out of a [[List]] + * @param L + * @returns [[List]] + * @example + * ```ts + * ``` + */ +type Pop = L extends readonly [] ? never : L extends [...unknown[], infer Last] ? Last : L extends (infer T)[] ? T : never; + +/** + * Ask TS to re-check that `A1` extends `A2`. + * And if it fails, `A2` will be enforced anyway. + * Can also be used to add constraints on parameters. + * @param A1 to check against + * @param A2 to cast to + * @returns `A1 | A2` + * @example + * ```ts + * type test0 = Cast<'42', string> // '42' + * type test1 = Cast<'42', number> // number + * ``` + */ +type Cast = A1 extends A2 ? A1 : A2; +/** + * Check whether `A1` is part of `A2` or not. The difference with + * `extends` is that it forces a [[Boolean]] return. + * @param A1 + * @param A2 + * @returns [[Boolean]] + * @example + * ```ts + * type test0 = Extends<'a' | 'b', 'b'> // Boolean + * type test1 = Extends<'a', 'a' | 'b'> // True + * + * type test2 = Extends<{a: string}, {a: any}> // True + * type test3 = Extends<{a: any}, {a: any, b: any}> // False + * + * type test4 = Extends // False + * /// Nothing cannot extend nothing, use `Equals` + * ``` + */ +type Extends = [A1] extends [never] ? 0 : A1 extends A2 ? 1 : 0; +type __Assign, Os extends List>, I extends Iteration = IterationOf<0>> = Extends, Length> extends 1 ? O : __Assign]>, Os, Next>; +type _Assign, Os extends List>> = __Assign extends infer X ? Cast> : never; +/** + * Assign a list of [[Object]] into `O` with [[MergeDeep]]. Merges from right to + * left, first items get overridden by the next ones (last-in overrides). + * @param O to assign to + * @param Os to assign + * @returns [[Object]] + * @example + * ```ts + * ``` + */ +type Assign, Os extends List>> = O extends unknown ? (Os extends unknown ? _Assign : never) : never; + +type Has = [U1] extends [U] ? 1 : 0; +type If = B extends 1 ? Then : Else; +type PrettyPrint = If, A, A extends Record ? { + [K in keyof A]: PrettyPrint; +} & unknown : A>; + +/** + * The return type of `merge()`. It reflects the type that is returned by JavaScript. + * + * This TS Utility can be used as standalone as well + */ +type Merge = T extends Record ? Ts extends Record[] ? PrettyPrint> : Pop : Pop; +/** + * Merge anything recursively. + * Objects get merged, special objects (classes etc.) are re-assigned "as is". + * Basic types overwrite objects or other basic types. + */ +declare function merge(object: T, ...otherObjects: Tn): Merge; +declare function mergeAndCompare(compareFn: (prop1: any, prop2: any, propName: string | symbol) => any, object: T, ...otherObjects: Tn): Merge; +declare function mergeAndConcat(object: T, ...otherObjects: Tn): Merge; + +declare function concatArrays(originVal: any, newVal: any): any | any[]; + +export { Merge, concatArrays, merge, mergeAndCompare, mergeAndConcat }; diff --git a/dist/index.cjs b/dist/index.cjs deleted file mode 100644 index 5ee7883..0000000 --- a/dist/index.cjs +++ /dev/null @@ -1,122 +0,0 @@ -'use strict'; - -var isWhat = require('is-what'); - -function concatArrays(originVal, newVal) { - if (isWhat.isArray(originVal) && isWhat.isArray(newVal)) { - // concat logic - return originVal.concat(newVal); - } - return newVal; // always return newVal as fallback!! -} - -function assignProp(carry, key, newVal, originalObject) { - const propType = {}.propertyIsEnumerable.call(originalObject, key) - ? 'enumerable' - : 'nonenumerable'; - if (propType === 'enumerable') - carry[key] = newVal; - if (propType === 'nonenumerable') { - Object.defineProperty(carry, key, { - value: newVal, - enumerable: false, - writable: true, - configurable: true, - }); - } -} -function mergeRecursively(origin, newComer, compareFn) { - // always return newComer if its not an object - if (!isWhat.isPlainObject(newComer)) - return newComer; - // define newObject to merge all values upon - let newObject = {}; - if (isWhat.isPlainObject(origin)) { - const props = Object.getOwnPropertyNames(origin); - const symbols = Object.getOwnPropertySymbols(origin); - newObject = [...props, ...symbols].reduce((carry, key) => { - const targetVal = origin[key]; - if ((!isWhat.isSymbol(key) && !Object.getOwnPropertyNames(newComer).includes(key)) || - (isWhat.isSymbol(key) && !Object.getOwnPropertySymbols(newComer).includes(key))) { - assignProp(carry, key, targetVal, origin); - } - return carry; - }, {}); - } - // newObject has all properties that newComer hasn't - const props = Object.getOwnPropertyNames(newComer); - const symbols = Object.getOwnPropertySymbols(newComer); - const result = [...props, ...symbols].reduce((carry, key) => { - // re-define the origin and newComer as targetVal and newVal - let newVal = newComer[key]; - const targetVal = isWhat.isPlainObject(origin) ? origin[key] : undefined; - // When newVal is an object do the merge recursively - if (targetVal !== undefined && isWhat.isPlainObject(newVal)) { - newVal = mergeRecursively(targetVal, newVal, compareFn); - } - const propToAssign = compareFn ? compareFn(targetVal, newVal, key) : newVal; - assignProp(carry, key, propToAssign, newComer); - return carry; - }, newObject); - return result; -} -/** - * Merge anything recursively. - * Objects get merged, special objects (classes etc.) are re-assigned "as is". - * Basic types overwrite objects or other basic types. - */ -function merge(object, ...otherObjects) { - return otherObjects.reduce((result, newComer) => { - return mergeRecursively(result, newComer); - }, object); -} -function mergeAndCompare(compareFn, object, ...otherObjects) { - return otherObjects.reduce((result, newComer) => { - return mergeRecursively(result, newComer, compareFn); - }, object); -} -function mergeAndConcat(object, ...otherObjects) { - return otherObjects.reduce((result, newComer) => { - return mergeRecursively(result, newComer, concatArrays); - }, object); -} -// import { Timestamp } from '../test/Timestamp' -// type T1 = { date: Timestamp } -// type T2 = [{ b: string[] }, { b: number[] }, { date: Timestamp }] -// type TestT = Merge -// type A1 = { arr: string[] } -// type A2 = { arr: number[] } -// type A3 = { arr: boolean[] } -// type TestA = Merge -// interface I1 { -// date: Timestamp -// } -// interface I2 { -// date: Timestamp -// } -// const _a: I2 = { date: '' } as unknown as I2 -// type TestI = Merge -// // ReturnType<(typeof merge)> -// const a = merge(_a, [_a]) -// interface Arguments extends Record { -// key: string; -// } -// const aa1: Arguments = { key: "value1" } -// const aa2: Arguments = { key: "value2" } -// const aa = merge(a1, a2); -// interface Barguments { -// key: string -// } -// const ba1: Barguments = { key: 'value1' } -// const ba2: Barguments = { key: 'value2' } -// const ba = merge(ba1, ba2) -// interface Carguments { -// key: string -// } -// const ca = merge({ key: 'value1' }, { key: 'value2' }) -// type P = Pop - -exports.concatArrays = concatArrays; -exports.merge = merge; -exports.mergeAndCompare = mergeAndCompare; -exports.mergeAndConcat = mergeAndConcat; diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..f2cd12d --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,416 @@ +/** + * Get the keys of `O` that are optional + * @param O + * @returns [[Key]] + * @example + * ```ts + * ``` + */ +type OptionalKeys = O extends unknown ? { + [K in keyof O]-?: {} extends Pick ? K : never; +}[keyof O] : never; +/** + * Get the keys of `O` that are required + * @param O + * @returns [[Key]] + * @example + * ```ts + * ``` + */ +type RequiredKeys = O extends unknown ? { + [K in keyof O]-?: {} extends Pick ? never : K; +}[keyof O] : never; +type MergeObjectDeeply, O1 extends Record> = { + [K in keyof (O & O1)]: K extends RequiredKeys ? MergeObjectsOrReturnFallback : K extends OptionalKeys ? K extends OptionalKeys ? MergeObjectsOrReturnFallback, Exclude, Exclude | Exclude> : K extends RequiredKeys ? Exclude extends O[K] ? O[K] : MergeObjectsOrReturnFallback, O[K] | Exclude> : O1[K] : O[K]; +}; +type MergeObjectsOrReturnFallback = O extends Record ? O1 extends Record ? MergeObjectDeeply : Fallback : Fallback; +/** + * Accurately merge the fields of `O` with the ones of `O1`. It is + * equivalent to the spread operator in JavaScript. [[Union]]s and [[Optional]] + * fields will be handled gracefully. + * + * (⚠️ needs `--strictNullChecks` enabled) + * @param O to complete + * @param O1 to copy from + * @returns [[Object]] + * @example + * ```ts + * import { PrettyPrint } from './PrettyPrint' + * + * type A1 = { a: number; b?: number; d?: number; e?: number; x: string; y?: number; z: string; } // prettier-ignore + * type A2 = { a?: number; c?: number; d?: number; e: number; x: number | undefined; y?: string; z?: number; } // prettier-ignore + * + * type Result = PrettyPrint> + * { + * a: number; + * b?: number | undefined; + * c?: number | undefined; + * d?: number | undefined; + * e: number; + * x: number | undefined; + * y?: string | number | undefined; + * z: string | number; + * } + * ``` + */ +type MergeDeep, O1 extends Record> = O extends unknown ? (O1 extends unknown ? MergeObjectDeeply : never) : never; + +/** + * An entry of `IterationMap` + */ +type Iteration = [ + value: number, + sign: '-' | '0' | '+', + prev: keyof IterationMap, + next: keyof IterationMap, + oppo: keyof IterationMap +]; +type IterationMap = { + '__': [number, '-' | '0' | '+', '__', '__', '__']; + '-100': [-100, '-', '__', '-99', '100']; + '-99': [-99, '-', '-100', '-98', '99']; + '-98': [-98, '-', '-99', '-97', '98']; + '-97': [-97, '-', '-98', '-96', '97']; + '-96': [-96, '-', '-97', '-95', '96']; + '-95': [-95, '-', '-96', '-94', '95']; + '-94': [-94, '-', '-95', '-93', '94']; + '-93': [-93, '-', '-94', '-92', '93']; + '-92': [-92, '-', '-93', '-91', '92']; + '-91': [-91, '-', '-92', '-90', '91']; + '-90': [-90, '-', '-91', '-89', '90']; + '-89': [-89, '-', '-90', '-88', '89']; + '-88': [-88, '-', '-89', '-87', '88']; + '-87': [-87, '-', '-88', '-86', '87']; + '-86': [-86, '-', '-87', '-85', '86']; + '-85': [-85, '-', '-86', '-84', '85']; + '-84': [-84, '-', '-85', '-83', '84']; + '-83': [-83, '-', '-84', '-82', '83']; + '-82': [-82, '-', '-83', '-81', '82']; + '-81': [-81, '-', '-82', '-80', '81']; + '-80': [-80, '-', '-81', '-79', '80']; + '-79': [-79, '-', '-80', '-78', '79']; + '-78': [-78, '-', '-79', '-77', '78']; + '-77': [-77, '-', '-78', '-76', '77']; + '-76': [-76, '-', '-77', '-75', '76']; + '-75': [-75, '-', '-76', '-74', '75']; + '-74': [-74, '-', '-75', '-73', '74']; + '-73': [-73, '-', '-74', '-72', '73']; + '-72': [-72, '-', '-73', '-71', '72']; + '-71': [-71, '-', '-72', '-70', '71']; + '-70': [-70, '-', '-71', '-69', '70']; + '-69': [-69, '-', '-70', '-68', '69']; + '-68': [-68, '-', '-69', '-67', '68']; + '-67': [-67, '-', '-68', '-66', '67']; + '-66': [-66, '-', '-67', '-65', '66']; + '-65': [-65, '-', '-66', '-64', '65']; + '-64': [-64, '-', '-65', '-63', '64']; + '-63': [-63, '-', '-64', '-62', '63']; + '-62': [-62, '-', '-63', '-61', '62']; + '-61': [-61, '-', '-62', '-60', '61']; + '-60': [-60, '-', '-61', '-59', '60']; + '-59': [-59, '-', '-60', '-58', '59']; + '-58': [-58, '-', '-59', '-57', '58']; + '-57': [-57, '-', '-58', '-56', '57']; + '-56': [-56, '-', '-57', '-55', '56']; + '-55': [-55, '-', '-56', '-54', '55']; + '-54': [-54, '-', '-55', '-53', '54']; + '-53': [-53, '-', '-54', '-52', '53']; + '-52': [-52, '-', '-53', '-51', '52']; + '-51': [-51, '-', '-52', '-50', '51']; + '-50': [-50, '-', '-51', '-49', '50']; + '-49': [-49, '-', '-50', '-48', '49']; + '-48': [-48, '-', '-49', '-47', '48']; + '-47': [-47, '-', '-48', '-46', '47']; + '-46': [-46, '-', '-47', '-45', '46']; + '-45': [-45, '-', '-46', '-44', '45']; + '-44': [-44, '-', '-45', '-43', '44']; + '-43': [-43, '-', '-44', '-42', '43']; + '-42': [-42, '-', '-43', '-41', '42']; + '-41': [-41, '-', '-42', '-40', '41']; + '-40': [-40, '-', '-41', '-39', '40']; + '-39': [-39, '-', '-40', '-38', '39']; + '-38': [-38, '-', '-39', '-37', '38']; + '-37': [-37, '-', '-38', '-36', '37']; + '-36': [-36, '-', '-37', '-35', '36']; + '-35': [-35, '-', '-36', '-34', '35']; + '-34': [-34, '-', '-35', '-33', '34']; + '-33': [-33, '-', '-34', '-32', '33']; + '-32': [-32, '-', '-33', '-31', '32']; + '-31': [-31, '-', '-32', '-30', '31']; + '-30': [-30, '-', '-31', '-29', '30']; + '-29': [-29, '-', '-30', '-28', '29']; + '-28': [-28, '-', '-29', '-27', '28']; + '-27': [-27, '-', '-28', '-26', '27']; + '-26': [-26, '-', '-27', '-25', '26']; + '-25': [-25, '-', '-26', '-24', '25']; + '-24': [-24, '-', '-25', '-23', '24']; + '-23': [-23, '-', '-24', '-22', '23']; + '-22': [-22, '-', '-23', '-21', '22']; + '-21': [-21, '-', '-22', '-20', '21']; + '-20': [-20, '-', '-21', '-19', '20']; + '-19': [-19, '-', '-20', '-18', '19']; + '-18': [-18, '-', '-19', '-17', '18']; + '-17': [-17, '-', '-18', '-16', '17']; + '-16': [-16, '-', '-17', '-15', '16']; + '-15': [-15, '-', '-16', '-14', '15']; + '-14': [-14, '-', '-15', '-13', '14']; + '-13': [-13, '-', '-14', '-12', '13']; + '-12': [-12, '-', '-13', '-11', '12']; + '-11': [-11, '-', '-12', '-10', '11']; + '-10': [-10, '-', '-11', '-9', '10']; + '-9': [-9, '-', '-10', '-8', '9']; + '-8': [-8, '-', '-9', '-7', '8']; + '-7': [-7, '-', '-8', '-6', '7']; + '-6': [-6, '-', '-7', '-5', '6']; + '-5': [-5, '-', '-6', '-4', '5']; + '-4': [-4, '-', '-5', '-3', '4']; + '-3': [-3, '-', '-4', '-2', '3']; + '-2': [-2, '-', '-3', '-1', '2']; + '-1': [-1, '-', '-2', '0', '1']; + '0': [0, '0', '-1', '1', '0']; + '1': [1, '+', '0', '2', '-1']; + '2': [2, '+', '1', '3', '-2']; + '3': [3, '+', '2', '4', '-3']; + '4': [4, '+', '3', '5', '-4']; + '5': [5, '+', '4', '6', '-5']; + '6': [6, '+', '5', '7', '-6']; + '7': [7, '+', '6', '8', '-7']; + '8': [8, '+', '7', '9', '-8']; + '9': [9, '+', '8', '10', '-9']; + '10': [10, '+', '9', '11', '-10']; + '11': [11, '+', '10', '12', '-11']; + '12': [12, '+', '11', '13', '-12']; + '13': [13, '+', '12', '14', '-13']; + '14': [14, '+', '13', '15', '-14']; + '15': [15, '+', '14', '16', '-15']; + '16': [16, '+', '15', '17', '-16']; + '17': [17, '+', '16', '18', '-17']; + '18': [18, '+', '17', '19', '-18']; + '19': [19, '+', '18', '20', '-19']; + '20': [20, '+', '19', '21', '-20']; + '21': [21, '+', '20', '22', '-21']; + '22': [22, '+', '21', '23', '-22']; + '23': [23, '+', '22', '24', '-23']; + '24': [24, '+', '23', '25', '-24']; + '25': [25, '+', '24', '26', '-25']; + '26': [26, '+', '25', '27', '-26']; + '27': [27, '+', '26', '28', '-27']; + '28': [28, '+', '27', '29', '-28']; + '29': [29, '+', '28', '30', '-29']; + '30': [30, '+', '29', '31', '-30']; + '31': [31, '+', '30', '32', '-31']; + '32': [32, '+', '31', '33', '-32']; + '33': [33, '+', '32', '34', '-33']; + '34': [34, '+', '33', '35', '-34']; + '35': [35, '+', '34', '36', '-35']; + '36': [36, '+', '35', '37', '-36']; + '37': [37, '+', '36', '38', '-37']; + '38': [38, '+', '37', '39', '-38']; + '39': [39, '+', '38', '40', '-39']; + '40': [40, '+', '39', '41', '-40']; + '41': [41, '+', '40', '42', '-41']; + '42': [42, '+', '41', '43', '-42']; + '43': [43, '+', '42', '44', '-43']; + '44': [44, '+', '43', '45', '-44']; + '45': [45, '+', '44', '46', '-45']; + '46': [46, '+', '45', '47', '-46']; + '47': [47, '+', '46', '48', '-47']; + '48': [48, '+', '47', '49', '-48']; + '49': [49, '+', '48', '50', '-49']; + '50': [50, '+', '49', '51', '-50']; + '51': [51, '+', '50', '52', '-51']; + '52': [52, '+', '51', '53', '-52']; + '53': [53, '+', '52', '54', '-53']; + '54': [54, '+', '53', '55', '-54']; + '55': [55, '+', '54', '56', '-55']; + '56': [56, '+', '55', '57', '-56']; + '57': [57, '+', '56', '58', '-57']; + '58': [58, '+', '57', '59', '-58']; + '59': [59, '+', '58', '60', '-59']; + '60': [60, '+', '59', '61', '-60']; + '61': [61, '+', '60', '62', '-61']; + '62': [62, '+', '61', '63', '-62']; + '63': [63, '+', '62', '64', '-63']; + '64': [64, '+', '63', '65', '-64']; + '65': [65, '+', '64', '66', '-65']; + '66': [66, '+', '65', '67', '-66']; + '67': [67, '+', '66', '68', '-67']; + '68': [68, '+', '67', '69', '-68']; + '69': [69, '+', '68', '70', '-69']; + '70': [70, '+', '69', '71', '-70']; + '71': [71, '+', '70', '72', '-71']; + '72': [72, '+', '71', '73', '-72']; + '73': [73, '+', '72', '74', '-73']; + '74': [74, '+', '73', '75', '-74']; + '75': [75, '+', '74', '76', '-75']; + '76': [76, '+', '75', '77', '-76']; + '77': [77, '+', '76', '78', '-77']; + '78': [78, '+', '77', '79', '-78']; + '79': [79, '+', '78', '80', '-79']; + '80': [80, '+', '79', '81', '-80']; + '81': [81, '+', '80', '82', '-81']; + '82': [82, '+', '81', '83', '-82']; + '83': [83, '+', '82', '84', '-83']; + '84': [84, '+', '83', '85', '-84']; + '85': [85, '+', '84', '86', '-85']; + '86': [86, '+', '85', '87', '-86']; + '87': [87, '+', '86', '88', '-87']; + '88': [88, '+', '87', '89', '-88']; + '89': [89, '+', '88', '90', '-89']; + '90': [90, '+', '89', '91', '-90']; + '91': [91, '+', '90', '92', '-91']; + '92': [92, '+', '91', '93', '-92']; + '93': [93, '+', '92', '94', '-93']; + '94': [94, '+', '93', '95', '-94']; + '95': [95, '+', '94', '96', '-95']; + '96': [96, '+', '95', '97', '-96']; + '97': [97, '+', '96', '98', '-97']; + '98': [98, '+', '97', '99', '-98']; + '99': [99, '+', '98', '100', '-99']; + '100': [100, '+', '99', '__', '-100']; +}; +/** + * Transform a number into an [[Iteration]] + * (to use [[Prev]], [[Next]], & [[Pos]]) + * @param N to transform + * @returns [[Iteration]] + * @example + * ```ts + * type i = IterationOf<0> // ["-1", "1", "0", 0, "0"] + * + * type next = Next // ["0", "2", "1", 1, "+"] + * type prev = Prev // ["-2", "0", "-1", -1, "-"] + * + * type nnext = Pos // +1 + * type nprev = Pos // -1 + * ``` + */ +type IterationOf = `${N}` extends keyof IterationMap ? IterationMap[`${N}`] : IterationMap['__']; +/** + * Get the position of `I` (**number**) + * @param I to query + * @returns `number` + * @example + * ```ts + * type i = IterationOf<'20'> + * + * type test0 = Pos // 20 + * type test1 = Pos> // 21 + * ``` + */ +type Pos = I[0]; +/** + * Move `I`'s position forward + * @param I to move + * @returns [[Iteration]] + * @example + * ```ts + * type i = IterationOf<'20'> + * + * type test0 = Pos // 20 + * type test1 = Pos> // 21 + * ``` + */ +type Next = IterationMap[I[3]]; + +/** + * A [[List]] + * @param T its type + * @returns [[List]] + * @example + * ```ts + * type list0 = [1, 2, 3] + * type list1 = number[] + * ``` + */ +type List = readonly T[]; +/** + * Get the length of `L` + * @param L to get length + * @returns [[String]] or `number` + * @example + * ```ts + * ``` + */ +type Length = L['length']; +/** + * Return the last item out of a [[List]] + * @param L + * @returns [[List]] + * @example + * ```ts + * ``` + */ +type Pop = L extends readonly [] ? never : L extends [...unknown[], infer Last] ? Last : L extends (infer T)[] ? T : never; + +/** + * Ask TS to re-check that `A1` extends `A2`. + * And if it fails, `A2` will be enforced anyway. + * Can also be used to add constraints on parameters. + * @param A1 to check against + * @param A2 to cast to + * @returns `A1 | A2` + * @example + * ```ts + * type test0 = Cast<'42', string> // '42' + * type test1 = Cast<'42', number> // number + * ``` + */ +type Cast = A1 extends A2 ? A1 : A2; +/** + * Check whether `A1` is part of `A2` or not. The difference with + * `extends` is that it forces a [[Boolean]] return. + * @param A1 + * @param A2 + * @returns [[Boolean]] + * @example + * ```ts + * type test0 = Extends<'a' | 'b', 'b'> // Boolean + * type test1 = Extends<'a', 'a' | 'b'> // True + * + * type test2 = Extends<{a: string}, {a: any}> // True + * type test3 = Extends<{a: any}, {a: any, b: any}> // False + * + * type test4 = Extends // False + * /// Nothing cannot extend nothing, use `Equals` + * ``` + */ +type Extends = [A1] extends [never] ? 0 : A1 extends A2 ? 1 : 0; +type __Assign, Os extends List>, I extends Iteration = IterationOf<0>> = Extends, Length> extends 1 ? O : __Assign]>, Os, Next>; +type _Assign, Os extends List>> = __Assign extends infer X ? Cast> : never; +/** + * Assign a list of [[Object]] into `O` with [[MergeDeep]]. Merges from right to + * left, first items get overridden by the next ones (last-in overrides). + * @param O to assign to + * @param Os to assign + * @returns [[Object]] + * @example + * ```ts + * ``` + */ +type Assign, Os extends List>> = O extends unknown ? (Os extends unknown ? _Assign : never) : never; + +type Has = [U1] extends [U] ? 1 : 0; +type If = B extends 1 ? Then : Else; +type PrettyPrint = If, A, A extends Record ? { + [K in keyof A]: PrettyPrint; +} & unknown : A>; + +/** + * The return type of `merge()`. It reflects the type that is returned by JavaScript. + * + * This TS Utility can be used as standalone as well + */ +type Merge = T extends Record ? Ts extends Record[] ? PrettyPrint> : Pop : Pop; +/** + * Merge anything recursively. + * Objects get merged, special objects (classes etc.) are re-assigned "as is". + * Basic types overwrite objects or other basic types. + */ +declare function merge(object: T, ...otherObjects: Tn): Merge; +declare function mergeAndCompare(compareFn: (prop1: any, prop2: any, propName: string | symbol) => any, object: T, ...otherObjects: Tn): Merge; +declare function mergeAndConcat(object: T, ...otherObjects: Tn): Merge; + +declare function concatArrays(originVal: any, newVal: any): any | any[]; + +export { Merge, concatArrays, merge, mergeAndCompare, mergeAndConcat }; diff --git a/dist/index.es.js b/dist/index.es.js deleted file mode 100644 index f72ec42..0000000 --- a/dist/index.es.js +++ /dev/null @@ -1,117 +0,0 @@ -import { isArray, isPlainObject, isSymbol } from 'is-what'; - -function concatArrays(originVal, newVal) { - if (isArray(originVal) && isArray(newVal)) { - // concat logic - return originVal.concat(newVal); - } - return newVal; // always return newVal as fallback!! -} - -function assignProp(carry, key, newVal, originalObject) { - const propType = {}.propertyIsEnumerable.call(originalObject, key) - ? 'enumerable' - : 'nonenumerable'; - if (propType === 'enumerable') - carry[key] = newVal; - if (propType === 'nonenumerable') { - Object.defineProperty(carry, key, { - value: newVal, - enumerable: false, - writable: true, - configurable: true, - }); - } -} -function mergeRecursively(origin, newComer, compareFn) { - // always return newComer if its not an object - if (!isPlainObject(newComer)) - return newComer; - // define newObject to merge all values upon - let newObject = {}; - if (isPlainObject(origin)) { - const props = Object.getOwnPropertyNames(origin); - const symbols = Object.getOwnPropertySymbols(origin); - newObject = [...props, ...symbols].reduce((carry, key) => { - const targetVal = origin[key]; - if ((!isSymbol(key) && !Object.getOwnPropertyNames(newComer).includes(key)) || - (isSymbol(key) && !Object.getOwnPropertySymbols(newComer).includes(key))) { - assignProp(carry, key, targetVal, origin); - } - return carry; - }, {}); - } - // newObject has all properties that newComer hasn't - const props = Object.getOwnPropertyNames(newComer); - const symbols = Object.getOwnPropertySymbols(newComer); - const result = [...props, ...symbols].reduce((carry, key) => { - // re-define the origin and newComer as targetVal and newVal - let newVal = newComer[key]; - const targetVal = isPlainObject(origin) ? origin[key] : undefined; - // When newVal is an object do the merge recursively - if (targetVal !== undefined && isPlainObject(newVal)) { - newVal = mergeRecursively(targetVal, newVal, compareFn); - } - const propToAssign = compareFn ? compareFn(targetVal, newVal, key) : newVal; - assignProp(carry, key, propToAssign, newComer); - return carry; - }, newObject); - return result; -} -/** - * Merge anything recursively. - * Objects get merged, special objects (classes etc.) are re-assigned "as is". - * Basic types overwrite objects or other basic types. - */ -function merge(object, ...otherObjects) { - return otherObjects.reduce((result, newComer) => { - return mergeRecursively(result, newComer); - }, object); -} -function mergeAndCompare(compareFn, object, ...otherObjects) { - return otherObjects.reduce((result, newComer) => { - return mergeRecursively(result, newComer, compareFn); - }, object); -} -function mergeAndConcat(object, ...otherObjects) { - return otherObjects.reduce((result, newComer) => { - return mergeRecursively(result, newComer, concatArrays); - }, object); -} -// import { Timestamp } from '../test/Timestamp' -// type T1 = { date: Timestamp } -// type T2 = [{ b: string[] }, { b: number[] }, { date: Timestamp }] -// type TestT = Merge -// type A1 = { arr: string[] } -// type A2 = { arr: number[] } -// type A3 = { arr: boolean[] } -// type TestA = Merge -// interface I1 { -// date: Timestamp -// } -// interface I2 { -// date: Timestamp -// } -// const _a: I2 = { date: '' } as unknown as I2 -// type TestI = Merge -// // ReturnType<(typeof merge)> -// const a = merge(_a, [_a]) -// interface Arguments extends Record { -// key: string; -// } -// const aa1: Arguments = { key: "value1" } -// const aa2: Arguments = { key: "value2" } -// const aa = merge(a1, a2); -// interface Barguments { -// key: string -// } -// const ba1: Barguments = { key: 'value1' } -// const ba2: Barguments = { key: 'value2' } -// const ba = merge(ba1, ba2) -// interface Carguments { -// key: string -// } -// const ca = merge({ key: 'value1' }, { key: 'value2' }) -// type P = Pop - -export { concatArrays, merge, mergeAndCompare, mergeAndConcat }; diff --git a/dist/index.js b/dist/index.js new file mode 100644 index 0000000..a57ec56 --- /dev/null +++ b/dist/index.js @@ -0,0 +1,78 @@ +import { isArray, isPlainObject, isSymbol } from 'is-what'; + +function concatArrays(originVal, newVal) { + if (isArray(originVal) && isArray(newVal)) { + return originVal.concat(newVal); + } + return newVal; +} + +function assignProp(carry, key, newVal, originalObject) { + const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable"; + if (propType === "enumerable") + carry[key] = newVal; + if (propType === "nonenumerable") { + Object.defineProperty(carry, key, { + value: newVal, + enumerable: false, + writable: true, + configurable: true + }); + } +} +function mergeRecursively(origin, newComer, compareFn) { + if (!isPlainObject(newComer)) + return newComer; + let newObject = {}; + if (isPlainObject(origin)) { + const props2 = Object.getOwnPropertyNames(origin); + const symbols2 = Object.getOwnPropertySymbols(origin); + newObject = [...props2, ...symbols2].reduce((carry, key) => { + const targetVal = origin[key]; + if (!isSymbol(key) && !Object.getOwnPropertyNames(newComer).includes(key) || isSymbol(key) && !Object.getOwnPropertySymbols(newComer).includes(key)) { + assignProp( + carry, + key, + targetVal, + origin + ); + } + return carry; + }, {}); + } + const props = Object.getOwnPropertyNames(newComer); + const symbols = Object.getOwnPropertySymbols(newComer); + const result = [...props, ...symbols].reduce((carry, key) => { + let newVal = newComer[key]; + const targetVal = isPlainObject(origin) ? origin[key] : void 0; + if (targetVal !== void 0 && isPlainObject(newVal)) { + newVal = mergeRecursively(targetVal, newVal, compareFn); + } + const propToAssign = compareFn ? compareFn(targetVal, newVal, key) : newVal; + assignProp( + carry, + key, + propToAssign, + newComer + ); + return carry; + }, newObject); + return result; +} +function merge(object, ...otherObjects) { + return otherObjects.reduce((result, newComer) => { + return mergeRecursively(result, newComer); + }, object); +} +function mergeAndCompare(compareFn, object, ...otherObjects) { + return otherObjects.reduce((result, newComer) => { + return mergeRecursively(result, newComer, compareFn); + }, object); +} +function mergeAndConcat(object, ...otherObjects) { + return otherObjects.reduce((result, newComer) => { + return mergeRecursively(result, newComer, concatArrays); + }, object); +} + +export { concatArrays, merge, mergeAndCompare, mergeAndConcat }; diff --git a/dist/types/extensions.d.ts b/dist/types/extensions.d.ts deleted file mode 100644 index db6e464..0000000 --- a/dist/types/extensions.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function concatArrays(originVal: any, newVal: any): any | any[]; diff --git a/dist/types/index.d.ts b/dist/types/index.d.ts deleted file mode 100644 index c756609..0000000 --- a/dist/types/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './merge.js'; -export * from './extensions.js'; diff --git a/dist/types/merge.d.ts b/dist/types/merge.d.ts deleted file mode 100644 index 8610626..0000000 --- a/dist/types/merge.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -import type { Assign } from './typeUtils/Assign.js'; -import type { Pop } from './typeUtils/List.js'; -import type { PrettyPrint } from './typeUtils/PrettyPrint.js'; -/** - * The return type of `merge()`. It reflects the type that is returned by JavaScript. - * - * This TS Utility can be used as standalone as well - */ -export type Merge = T extends Record ? Ts extends Record[] ? PrettyPrint> : Pop : Pop; -/** - * Merge anything recursively. - * Objects get merged, special objects (classes etc.) are re-assigned "as is". - * Basic types overwrite objects or other basic types. - */ -export declare function merge(object: T, ...otherObjects: Tn): Merge; -export declare function mergeAndCompare(compareFn: (prop1: any, prop2: any, propName: string | symbol) => any, object: T, ...otherObjects: Tn): Merge; -export declare function mergeAndConcat(object: T, ...otherObjects: Tn): Merge; diff --git a/dist/types/typeUtils/Assign.d.ts b/dist/types/typeUtils/Assign.d.ts deleted file mode 100644 index b678c9d..0000000 --- a/dist/types/typeUtils/Assign.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -import type { MergeDeep } from './MergeDeep.js'; -import type { Iteration, IterationOf, Pos, Next } from './Iteration.js'; -import type { Length, List } from './List.js'; -/** - * Ask TS to re-check that `A1` extends `A2`. - * And if it fails, `A2` will be enforced anyway. - * Can also be used to add constraints on parameters. - * @param A1 to check against - * @param A2 to cast to - * @returns `A1 | A2` - * @example - * ```ts - * type test0 = Cast<'42', string> // '42' - * type test1 = Cast<'42', number> // number - * ``` - */ -type Cast = A1 extends A2 ? A1 : A2; -/** - * Check whether `A1` is part of `A2` or not. The difference with - * `extends` is that it forces a [[Boolean]] return. - * @param A1 - * @param A2 - * @returns [[Boolean]] - * @example - * ```ts - * type test0 = Extends<'a' | 'b', 'b'> // Boolean - * type test1 = Extends<'a', 'a' | 'b'> // True - * - * type test2 = Extends<{a: string}, {a: any}> // True - * type test3 = Extends<{a: any}, {a: any, b: any}> // False - * - * type test4 = Extends // False - * /// Nothing cannot extend nothing, use `Equals` - * ``` - */ -type Extends = [A1] extends [never] ? 0 : A1 extends A2 ? 1 : 0; -type __Assign, Os extends List>, I extends Iteration = IterationOf<0>> = Extends, Length> extends 1 ? O : __Assign]>, Os, Next>; -type _Assign, Os extends List>> = __Assign extends infer X ? Cast> : never; -/** - * Assign a list of [[Object]] into `O` with [[MergeDeep]]. Merges from right to - * left, first items get overridden by the next ones (last-in overrides). - * @param O to assign to - * @param Os to assign - * @returns [[Object]] - * @example - * ```ts - * ``` - */ -export type Assign, Os extends List>> = O extends unknown ? (Os extends unknown ? _Assign : never) : never; -export {}; diff --git a/dist/types/typeUtils/List.d.ts b/dist/types/typeUtils/List.d.ts deleted file mode 100644 index fe2e407..0000000 --- a/dist/types/typeUtils/List.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * A [[List]] - * @param T its type - * @returns [[List]] - * @example - * ```ts - * type list0 = [1, 2, 3] - * type list1 = number[] - * ``` - */ -export type List = readonly T[]; -/** - * Get the length of `L` - * @param L to get length - * @returns [[String]] or `number` - * @example - * ```ts - * ``` - */ -export type Length = L['length']; -/** - * Return the last item out of a [[List]] - * @param L - * @returns [[List]] - * @example - * ```ts - * ``` - */ -export type Pop = L extends readonly [] ? never : L extends [...unknown[], infer Last] ? Last : L extends (infer T)[] ? T : never; diff --git a/dist/types/typeUtils/MergeDeep.d.ts b/dist/types/typeUtils/MergeDeep.d.ts deleted file mode 100644 index 77774b0..0000000 --- a/dist/types/typeUtils/MergeDeep.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Get the keys of `O` that are optional - * @param O - * @returns [[Key]] - * @example - * ```ts - * ``` - */ -type OptionalKeys = O extends unknown ? { - [K in keyof O]-?: {} extends Pick ? K : never; -}[keyof O] : never; -/** - * Get the keys of `O` that are required - * @param O - * @returns [[Key]] - * @example - * ```ts - * ``` - */ -type RequiredKeys = O extends unknown ? { - [K in keyof O]-?: {} extends Pick ? never : K; -}[keyof O] : never; -type MergeObjectDeeply, O1 extends Record> = { - [K in keyof (O & O1)]: K extends RequiredKeys ? MergeObjectsOrReturnFallback : K extends OptionalKeys ? K extends OptionalKeys ? MergeObjectsOrReturnFallback, Exclude, Exclude | Exclude> : K extends RequiredKeys ? Exclude extends O[K] ? O[K] : MergeObjectsOrReturnFallback, O[K] | Exclude> : O1[K] : O[K]; -}; -type MergeObjectsOrReturnFallback = O extends Record ? O1 extends Record ? MergeObjectDeeply : Fallback : Fallback; -/** - * Accurately merge the fields of `O` with the ones of `O1`. It is - * equivalent to the spread operator in JavaScript. [[Union]]s and [[Optional]] - * fields will be handled gracefully. - * - * (⚠️ needs `--strictNullChecks` enabled) - * @param O to complete - * @param O1 to copy from - * @returns [[Object]] - * @example - * ```ts - * import { PrettyPrint } from './PrettyPrint' - * - * type A1 = { a: number; b?: number; d?: number; e?: number; x: string; y?: number; z: string; } // prettier-ignore - * type A2 = { a?: number; c?: number; d?: number; e: number; x: number | undefined; y?: string; z?: number; } // prettier-ignore - * - * type Result = PrettyPrint> - * { - * a: number; - * b?: number | undefined; - * c?: number | undefined; - * d?: number | undefined; - * e: number; - * x: number | undefined; - * y?: string | number | undefined; - * z: string | number; - * } - * ``` - */ -export type MergeDeep, O1 extends Record> = O extends unknown ? (O1 extends unknown ? MergeObjectDeeply : never) : never; -export {}; diff --git a/dist/types/typeUtils/PrettyPrint.d.ts b/dist/types/typeUtils/PrettyPrint.d.ts deleted file mode 100644 index 2b46bf4..0000000 --- a/dist/types/typeUtils/PrettyPrint.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -type Has = [U1] extends [U] ? 1 : 0; -type If = B extends 1 ? Then : Else; -export type PrettyPrint = If, A, A extends Record ? { - [K in keyof A]: PrettyPrint; -} & unknown : A>; -export {}; diff --git a/package-lock.json b/package-lock.json index 8575374..87ce9de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,8 +20,9 @@ "eslint-plugin-tree-shaking": "^1.10.0", "np": "^7.7.0", "prettier": "^2.8.8", - "rollup": "^3.21.5", - "rollup-plugin-typescript2": "^0.34.1", + "rollup": "^3.23.0", + "rollup-plugin-dts": "^5.3.0", + "rollup-plugin-esbuild": "^5.0.0", "typescript": "^5.0.4", "vitest": "^0.31.0" }, @@ -33,29 +34,38 @@ } }, "node_modules/@babel/code-frame": { - "version": "7.12.11", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", - "integrity": "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.21.4.tgz", + "integrity": "sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==", "dev": true, "dependencies": { - "@babel/highlight": "^7.10.4" + "@babel/highlight": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.12.11", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.12.11.tgz", - "integrity": "sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw==", - "dev": true + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", + "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } }, "node_modules/@babel/highlight": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.12.13.tgz", - "integrity": "sha512-kocDQvIbgMKlWxXe9fof3TQ+gkIPOUSEYhJjqUjvKMez3krV7vbzYCDq39Oj11UAVK7JqPVGQPlgE85dPNlQww==", + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", + "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", "dev": true, "dependencies": { - "@babel/helper-validator-identifier": "^7.12.11", + "@babel/helper-validator-identifier": "^7.18.6", "chalk": "^2.0.0", "js-tokens": "^4.0.0" + }, + "engines": { + "node": ">=6.9.0" } }, "node_modules/@babel/highlight/node_modules/ansi-styles": { @@ -87,7 +97,7 @@ "node_modules/@babel/highlight/node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true, "engines": { "node": ">=4" @@ -587,19 +597,6 @@ "node": ">= 8" } }, - "node_modules/@rollup/pluginutils": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", - "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", - "dev": true, - "dependencies": { - "estree-walker": "^2.0.1", - "picomatch": "^2.2.2" - }, - "engines": { - "node": ">= 8.0.0" - } - }, "node_modules/@samverschueren/stream-to-observable": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.1.tgz", @@ -680,6 +677,12 @@ "@types/chai": "*" } }, + "node_modules/@types/estree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.1.tgz", + "integrity": "sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==", + "dev": true + }, "node_modules/@types/http-cache-semantics": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz", @@ -1641,12 +1644,6 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, - "node_modules/commondir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", - "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", - "dev": true - }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -2291,6 +2288,12 @@ "is-arrayish": "^0.2.1" } }, + "node_modules/es-module-lexer": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.2.1.tgz", + "integrity": "sha512-9978wrXM50Y4rTMmW5kXIC09ZdXQZqkE4mxhwkd8VbzsGkXGPgV4zWuqQJgCEzYngdo2dYDa0l8xhX4fkSwJSg==", + "dev": true + }, "node_modules/esbuild": { "version": "0.17.18", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.18.tgz", @@ -2709,23 +2712,6 @@ "node": ">=8" } }, - "node_modules/find-cache-dir": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", - "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", - "dev": true, - "dependencies": { - "commondir": "^1.0.1", - "make-dir": "^3.0.2", - "pkg-dir": "^4.1.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/avajs/find-cache-dir?sponsor=1" - } - }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -2770,20 +2756,6 @@ "integrity": "sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==", "dev": true }, - "node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -3707,6 +3679,15 @@ "node": ">=10" } }, + "node_modules/joycon": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz", + "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/js-sdsl": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.1.5.tgz", @@ -3770,18 +3751,6 @@ "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", "dev": true }, - "node_modules/jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, "node_modules/keyv": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.3.tgz", @@ -5880,9 +5849,9 @@ } }, "node_modules/rollup": { - "version": "3.21.5", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.21.5.tgz", - "integrity": "sha512-a4NTKS4u9PusbUJcfF4IMxuqjFzjm6ifj76P54a7cKnvVzJaG12BLVR+hgU2YDGHzyMMQNxLAZWuALsn8q2oQg==", + "version": "3.23.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.23.0.tgz", + "integrity": "sha512-h31UlwEi7FHihLe1zbk+3Q7z1k/84rb9BSwmBSr/XjOCEaBJ2YyedQDuM0t/kfOS0IxM+vk1/zI9XxYj9V+NJQ==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -5895,21 +5864,69 @@ "fsevents": "~2.3.2" } }, - "node_modules/rollup-plugin-typescript2": { - "version": "0.34.1", - "resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.34.1.tgz", - "integrity": "sha512-P4cHLtGikESmqi1CA+tdMDUv8WbQV48mzPYt77TSTOPJpERyZ9TXdDgjSDix8Fkqce6soYz3+fa4lrC93IEkcw==", + "node_modules/rollup-plugin-dts": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-5.3.0.tgz", + "integrity": "sha512-8FXp0ZkyZj1iU5klkIJYLjIq/YZSwBoERu33QBDxm/1yw5UU4txrEtcmMkrq+ZiKu3Q4qvPCNqc3ovX6rjqzbQ==", "dev": true, "dependencies": { - "@rollup/pluginutils": "^4.1.2", - "find-cache-dir": "^3.3.2", - "fs-extra": "^10.0.0", - "semver": "^7.3.7", - "tslib": "^2.4.0" + "magic-string": "^0.30.0" + }, + "engines": { + "node": ">=v14" + }, + "funding": { + "url": "https://github.com/sponsors/Swatinem" + }, + "optionalDependencies": { + "@babel/code-frame": "^7.18.6" + }, + "peerDependencies": { + "rollup": "^3.0.0", + "typescript": "^4.1 || ^5.0" + } + }, + "node_modules/rollup-plugin-esbuild": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-esbuild/-/rollup-plugin-esbuild-5.0.0.tgz", + "integrity": "sha512-1cRIOHAPh8WQgdQQyyvFdeOdxuiyk+zB5zJ5+YOwrZP4cJ0MT3Fs48pQxrZeyZHcn+klFherytILVfE4aYrneg==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "debug": "^4.3.4", + "es-module-lexer": "^1.0.5", + "joycon": "^3.1.1", + "jsonc-parser": "^3.2.0" + }, + "engines": { + "node": ">=14.18.0", + "npm": ">=8.0.0" }, "peerDependencies": { - "rollup": ">=1.26.3", - "typescript": ">=2.4.0" + "esbuild": ">=0.10.1", + "rollup": "^1.20.0 || ^2.0.0 || ^3.0.0" + } + }, + "node_modules/rollup-plugin-esbuild/node_modules/@rollup/pluginutils": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.2.tgz", + "integrity": "sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } } }, "node_modules/run-async": { @@ -6340,12 +6357,6 @@ "node": ">=8" } }, - "node_modules/tslib": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", - "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", - "dev": true - }, "node_modules/tsutils": { "version": "3.21.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", @@ -6437,15 +6448,6 @@ "node": ">=8" } }, - "node_modules/universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true, - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/update-notifier": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-5.1.0.tgz", @@ -6895,27 +6897,27 @@ }, "dependencies": { "@babel/code-frame": { - "version": "7.12.11", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", - "integrity": "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==", + "version": "7.21.4", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.21.4.tgz", + "integrity": "sha512-LYvhNKfwWSPpocw8GI7gpK2nq3HSDuEPC/uSYaALSJu9xjsalaaYFOq0Pwt5KmVqwEbZlDu81aLXwBOmD/Fv9g==", "dev": true, "requires": { - "@babel/highlight": "^7.10.4" + "@babel/highlight": "^7.18.6" } }, "@babel/helper-validator-identifier": { - "version": "7.12.11", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.12.11.tgz", - "integrity": "sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw==", + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", + "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", "dev": true }, "@babel/highlight": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.12.13.tgz", - "integrity": "sha512-kocDQvIbgMKlWxXe9fof3TQ+gkIPOUSEYhJjqUjvKMez3krV7vbzYCDq39Oj11UAVK7JqPVGQPlgE85dPNlQww==", + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", + "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.12.11", + "@babel/helper-validator-identifier": "^7.18.6", "chalk": "^2.0.0", "js-tokens": "^4.0.0" }, @@ -6943,7 +6945,7 @@ "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true }, "supports-color": { @@ -7204,16 +7206,6 @@ "fastq": "^1.6.0" } }, - "@rollup/pluginutils": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", - "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", - "dev": true, - "requires": { - "estree-walker": "^2.0.1", - "picomatch": "^2.2.2" - } - }, "@samverschueren/stream-to-observable": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.1.tgz", @@ -7273,6 +7265,12 @@ "@types/chai": "*" } }, + "@types/estree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.1.tgz", + "integrity": "sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==", + "dev": true + }, "@types/http-cache-semantics": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz", @@ -7953,12 +7951,6 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, - "commondir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", - "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", - "dev": true - }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -8402,6 +8394,12 @@ "is-arrayish": "^0.2.1" } }, + "es-module-lexer": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.2.1.tgz", + "integrity": "sha512-9978wrXM50Y4rTMmW5kXIC09ZdXQZqkE4mxhwkd8VbzsGkXGPgV4zWuqQJgCEzYngdo2dYDa0l8xhX4fkSwJSg==", + "dev": true + }, "esbuild": { "version": "0.17.18", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.18.tgz", @@ -8718,17 +8716,6 @@ "to-regex-range": "^5.0.1" } }, - "find-cache-dir": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", - "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", - "dev": true, - "requires": { - "commondir": "^1.0.1", - "make-dir": "^3.0.2", - "pkg-dir": "^4.1.0" - } - }, "find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -8763,17 +8750,6 @@ "integrity": "sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==", "dev": true }, - "fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -9453,6 +9429,12 @@ "integrity": "sha512-0RHjbtw9QXeSYnIEY5Yrp2QZrdtz21xBDV9C/GIlY2POmgoS6a7qjkYS5siRKXScnuAj5/SPv1C3YForNCHTJA==", "dev": true }, + "joycon": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz", + "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==", + "dev": true + }, "js-sdsl": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.1.5.tgz", @@ -9510,16 +9492,6 @@ "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==", "dev": true }, - "jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^2.0.0" - } - }, "keyv": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.3.tgz", @@ -11089,25 +11061,48 @@ } }, "rollup": { - "version": "3.21.5", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.21.5.tgz", - "integrity": "sha512-a4NTKS4u9PusbUJcfF4IMxuqjFzjm6ifj76P54a7cKnvVzJaG12BLVR+hgU2YDGHzyMMQNxLAZWuALsn8q2oQg==", + "version": "3.23.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.23.0.tgz", + "integrity": "sha512-h31UlwEi7FHihLe1zbk+3Q7z1k/84rb9BSwmBSr/XjOCEaBJ2YyedQDuM0t/kfOS0IxM+vk1/zI9XxYj9V+NJQ==", "dev": true, "requires": { "fsevents": "~2.3.2" } }, - "rollup-plugin-typescript2": { - "version": "0.34.1", - "resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.34.1.tgz", - "integrity": "sha512-P4cHLtGikESmqi1CA+tdMDUv8WbQV48mzPYt77TSTOPJpERyZ9TXdDgjSDix8Fkqce6soYz3+fa4lrC93IEkcw==", + "rollup-plugin-dts": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-5.3.0.tgz", + "integrity": "sha512-8FXp0ZkyZj1iU5klkIJYLjIq/YZSwBoERu33QBDxm/1yw5UU4txrEtcmMkrq+ZiKu3Q4qvPCNqc3ovX6rjqzbQ==", "dev": true, "requires": { - "@rollup/pluginutils": "^4.1.2", - "find-cache-dir": "^3.3.2", - "fs-extra": "^10.0.0", - "semver": "^7.3.7", - "tslib": "^2.4.0" + "@babel/code-frame": "^7.18.6", + "magic-string": "^0.30.0" + } + }, + "rollup-plugin-esbuild": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-esbuild/-/rollup-plugin-esbuild-5.0.0.tgz", + "integrity": "sha512-1cRIOHAPh8WQgdQQyyvFdeOdxuiyk+zB5zJ5+YOwrZP4cJ0MT3Fs48pQxrZeyZHcn+klFherytILVfE4aYrneg==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^5.0.1", + "debug": "^4.3.4", + "es-module-lexer": "^1.0.5", + "joycon": "^3.1.1", + "jsonc-parser": "^3.2.0" + }, + "dependencies": { + "@rollup/pluginutils": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.2.tgz", + "integrity": "sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==", + "dev": true, + "requires": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + } + } } }, "run-async": { @@ -11429,12 +11424,6 @@ "integrity": "sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==", "dev": true }, - "tslib": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", - "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", - "dev": true - }, "tsutils": { "version": "3.21.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", @@ -11503,12 +11492,6 @@ "crypto-random-string": "^2.0.0" } }, - "universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true - }, "update-notifier": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-5.1.0.tgz", diff --git a/package.json b/package.json index 4f3174c..3b3d758 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,22 @@ { "name": "merge-anything", "version": "5.1.6", - "sideEffects": false, - "type": "module", "description": "Merge objects & other types recursively. A simple & small integration.", - "module": "./dist/index.es.js", - "main": "./dist/index.cjs", - "types": "./dist/types/index.d.ts", + "type": "module", + "sideEffects": false, + "types": "./dist/index.d.ts", + "module": "./dist/index.js", + "main": "./dist/index.js", "exports": { ".": { - "types": "./dist/types/index.d.ts", - "import": "./dist/index.es.js", - "require": "./dist/index.cjs" + "require": { + "types": "./dist/cjs/index.d.cts", + "default": "./dist/cjs/index.cjs" + }, + "import": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + } } }, "files": [ @@ -23,7 +28,7 @@ "scripts": { "lint": "tsc --noEmit && eslint ./src --ext .ts", "test": "vitest run", - "build": "rollup --bundleConfigAsCjs -c ./scripts/build.js", + "build": "rollup -c ./rollup.config.js", "release": "npm run lint && del dist && npm run build && np" }, "repository": { @@ -71,8 +76,9 @@ "eslint-plugin-tree-shaking": "^1.10.0", "np": "^7.7.0", "prettier": "^2.8.8", - "rollup": "^3.21.5", - "rollup-plugin-typescript2": "^0.34.1", + "rollup": "^3.23.0", + "rollup-plugin-dts": "^5.3.0", + "rollup-plugin-esbuild": "^5.0.0", "typescript": "^5.0.4", "vitest": "^0.31.0" }, diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..64e8d75 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,45 @@ +/* eslint-disable */ +import dts from 'rollup-plugin-dts' +import esbuild from 'rollup-plugin-esbuild' +import pkg from './package.json' assert { type: 'json' } + +export default [ + { + input: 'src/index.ts', + output: [ + { + file: pkg.exports['.'].import.default, + format: 'esm', + generatedCode: { constBindings: true }, + }, + { + file: pkg.exports['.'].require.default, + format: 'cjs', + generatedCode: { constBindings: true }, + }, + ], + plugins: [ + esbuild({ + sourceMap: false, + target: 'esnext', + loaders: { '.json': 'json' }, + }), + ], + }, + { + input: 'src/index.ts', + output: [ + { + file: pkg.exports['.'].import.types, + format: 'esm', + generatedCode: { constBindings: true }, + }, + { + file: pkg.exports['.'].require.types, + format: 'cjs', + generatedCode: { constBindings: true }, + }, + ], + plugins: [dts()], + }, +] diff --git a/scripts/build.js b/scripts/build.js deleted file mode 100644 index 2959638..0000000 --- a/scripts/build.js +++ /dev/null @@ -1,18 +0,0 @@ -/* eslint-disable */ - -// npm i -D rollup rollup-plugin-typescript2 typescript -import typescript from 'rollup-plugin-typescript2' - -const pkg = require('../package.json') - -export default { - input: 'src/index.ts', - output: [ - { file: 'dist/index.cjs', format: 'cjs' }, - { file: 'dist/index.es.js', format: 'esm' }, - ], - plugins: [ - typescript({ useTsconfigDeclarationDir: true, tsconfigOverride: { exclude: ['test/**/*'] } }), - ], - external: Object.keys(pkg.dependencies || []), -}