@taiga-ui/cdk 3.25.0-dev.main-6e585e7 → 3.25.0-dev.main-c3bbfaa

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.
Files changed (30) hide show
  1. package/bundles/taiga-ui-cdk-services.umd.js +28 -28
  2. package/bundles/taiga-ui-cdk-services.umd.js.map +1 -1
  3. package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.js +12 -0
  4. package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.js.map +1 -1
  5. package/esm2015/services/static-request.service.js +27 -28
  6. package/esm2015/utils/miscellaneous/index.js +2 -1
  7. package/esm2015/utils/miscellaneous/is-valid-url.js +11 -0
  8. package/fesm2015/taiga-ui-cdk-services.js +24 -27
  9. package/fesm2015/taiga-ui-cdk-services.js.map +1 -1
  10. package/fesm2015/taiga-ui-cdk-utils-miscellaneous.js +12 -1
  11. package/fesm2015/taiga-ui-cdk-utils-miscellaneous.js.map +1 -1
  12. package/package.json +1 -1
  13. package/schematics/constants/file-globs.js +1 -0
  14. package/schematics/ng-add/constants/modules.d.ts +5 -1
  15. package/schematics/ng-add/constants/modules.js +9 -11
  16. package/schematics/ng-add/steps/add-taiga-modules.js +85 -15
  17. package/schematics/ng-add/steps/wrap-with-tui-root.js +21 -8
  18. package/schematics/utils/add-import-to-component.d.ts +4 -0
  19. package/schematics/utils/add-import-to-component.js +12 -0
  20. package/schematics/utils/get-component-from-identifier.d.ts +2 -0
  21. package/schematics/utils/get-component-from-identifier.js +16 -0
  22. package/schematics/utils/get-named-import-references.d.ts +1 -1
  23. package/schematics/utils/get-named-import-references.js +2 -2
  24. package/schematics/utils/get-standalone-bootstrap-function.d.ts +2 -0
  25. package/schematics/utils/get-standalone-bootstrap-function.js +13 -0
  26. package/schematics/utils/push-to-array-property.d.ts +5 -0
  27. package/schematics/utils/push-to-array-property.js +26 -0
  28. package/services/static-request.service.d.ts +3 -0
  29. package/utils/miscellaneous/index.d.ts +1 -0
  30. package/utils/miscellaneous/is-valid-url.d.ts +1 -0
@@ -99,6 +99,17 @@ function tuiIsPresent(value) {
99
99
  return value !== null && value !== undefined;
100
100
  }
101
101
 
102
+ function tuiIsValidUrl(url) {
103
+ const pattern = new RegExp(`^([a-zA-Z]+:\\/\\/)?` + // protocol
104
+ `((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|localhost|` + // domain name
105
+ `((\\d{1,3}\\.){3}\\d{1,3}))` + // OR IP (v4) address
106
+ `(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*` + // port and path
107
+ `(\\?[;&a-z\\d%_.~+=-]*)?` + // query string
108
+ `(\\#[-a-z\\d_]*)?$`, // fragment locator
109
+ `i`);
110
+ return pattern.test(url);
111
+ }
112
+
102
113
  function tuiMarkControlAsTouchedAndValidate(control) {
103
114
  if (control instanceof FormArray) {
104
115
  control.controls.forEach(nestedControl => {
@@ -154,5 +165,5 @@ function tuiUniqBy(array, key) {
154
165
  * Generated bundle index. Do not edit.
155
166
  */
156
167
 
157
- export { tuiArrayRemove, tuiArrayShallowEquals, tuiArrayToggle, tuiCleanObject, tuiDefaultSort, tuiDistanceBetweenTouches, tuiEaseInOutQuad, tuiFlatLength, tuiGetOriginalArrayFromQueryList, tuiGetSwipeDirection, tuiIsFalsy, tuiIsNumber, tuiIsObject, tuiIsPresent, tuiIsString, tuiMarkControlAsTouchedAndValidate, tuiNullableSame, tuiObjectFromEntries, tuiUniqBy };
168
+ export { tuiArrayRemove, tuiArrayShallowEquals, tuiArrayToggle, tuiCleanObject, tuiDefaultSort, tuiDistanceBetweenTouches, tuiEaseInOutQuad, tuiFlatLength, tuiGetOriginalArrayFromQueryList, tuiGetSwipeDirection, tuiIsFalsy, tuiIsNumber, tuiIsObject, tuiIsPresent, tuiIsString, tuiIsValidUrl, tuiMarkControlAsTouchedAndValidate, tuiNullableSame, tuiObjectFromEntries, tuiUniqBy };
158
169
  //# sourceMappingURL=taiga-ui-cdk-utils-miscellaneous.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"taiga-ui-cdk-utils-miscellaneous.js","sources":["../../../projects/cdk/utils/miscellaneous/array-remove.ts","../../../projects/cdk/utils/miscellaneous/array-shallow-equals.ts","../../../projects/cdk/utils/miscellaneous/array-toggle.ts","../../../projects/cdk/utils/miscellaneous/is-string.ts","../../../projects/cdk/utils/miscellaneous/clean-object.ts","../../../projects/cdk/utils/miscellaneous/default-sort.ts","../../../projects/cdk/utils/miscellaneous/distance-between-touches.ts","../../../projects/cdk/utils/miscellaneous/ease-in-out-quad.ts","../../../projects/cdk/utils/miscellaneous/flat-length.ts","../../../projects/cdk/utils/miscellaneous/get-original-array-from-query-list.ts","../../../projects/cdk/utils/miscellaneous/get-swipe-direction.ts","../../../projects/cdk/utils/miscellaneous/is-falsy.ts","../../../projects/cdk/utils/miscellaneous/is-number.ts","../../../projects/cdk/utils/miscellaneous/is-object.ts","../../../projects/cdk/utils/miscellaneous/is-present.ts","../../../projects/cdk/utils/miscellaneous/mark-control-as-touched-and-validate.ts","../../../projects/cdk/utils/miscellaneous/nullable-same.ts","../../../projects/cdk/utils/miscellaneous/object-from-entries.ts","../../../projects/cdk/utils/miscellaneous/uniq-by.ts","../../../projects/cdk/utils/miscellaneous/taiga-ui-cdk-utils-miscellaneous.ts"],"sourcesContent":["export function tuiArrayRemove<T>(array: readonly T[], index: number): T[] {\n return array.slice(0, Math.max(index, 0)).concat(array.slice(Math.max(index + 1, 0)));\n}\n","export function tuiArrayShallowEquals<T>(a: readonly T[], b: readonly T[]): boolean {\n return a.length === b.length && a.every((item, index) => item === b[index]);\n}\n","import {tuiArrayRemove} from './array-remove';\n\nexport function tuiArrayToggle<T>(array: readonly T[], item: T): T[] {\n const index = array.indexOf(item);\n\n return index === -1 ? [...array, item] : tuiArrayRemove(array, index);\n}\n","export function tuiIsString(value: unknown): value is string {\n // eslint-disable-next-line @taiga-ui/no-typeof\n return typeof value === `string`;\n}\n","import {TuiDeepPartial} from '@taiga-ui/cdk/types';\n\nimport {tuiIsString} from './is-string';\n\nexport function tuiCleanObject<T>(object: T): TuiDeepPartial<T> {\n return JSON.parse(\n JSON.stringify(object, (_key: string, value: unknown) =>\n checkValueIsEmpty(value) ? undefined : value,\n ),\n );\n}\n\ntype EmptyValue = '' | null | undefined;\n\nfunction checkValueIsEmpty<T>(value: EmptyValue | T): value is EmptyValue {\n const nextValue: any = tuiIsString(value) ? value.trim() : value;\n\n return [undefined, null, NaN, ``].includes(nextValue);\n}\n","import {TuiDay} from '@taiga-ui/cdk/date-time';\n\nimport {tuiIsString} from './is-string';\n\nexport function tuiDefaultSort<T>(x: T, y: T): number {\n const a = x instanceof TuiDay ? Number(x.toUtcNativeDate()) : x;\n const b = y instanceof TuiDay ? Number(y.toUtcNativeDate()) : y;\n\n if (a === b) {\n return 0;\n }\n\n if (tuiIsString(a) && tuiIsString(b)) {\n return a.localeCompare(b);\n }\n\n return a > b ? 1 : -1;\n}\n","export function tuiDistanceBetweenTouches({touches}: TouchEvent): number {\n return Math.hypot(\n touches[0].clientX - touches[1].clientX,\n touches[0].clientY - touches[1].clientY,\n );\n}\n","import {tuiAssert} from '@taiga-ui/cdk/classes';\n\nexport function tuiEaseInOutQuad(t: number): number {\n ngDevMode &&\n tuiAssert.assert(\n t >= 0 && t <= 1,\n `Input must be between 0 and 1 inclusive but received `,\n t,\n );\n\n return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;\n}\n","/**\n * Flattens two-dimensional array and calculates resulting length\n *\n * @param array twi dimensional array\n */\nexport function tuiFlatLength(array: ReadonlyArray<readonly unknown[]>): number {\n return array.reduce((count, section) => count + section.length, 0);\n}\n","import {QueryList} from '@angular/core';\n\n/**\n * Extracts original array from {@link QueryList} rather than\n * creating a copy like {@link QueryList.toArray} does.\n * @param queryList\n * @returns original array from {@link QueryList}.\n */\nexport function tuiGetOriginalArrayFromQueryList<T>(\n queryList: QueryList<T>,\n): readonly T[] {\n let array: readonly T[] = [];\n\n queryList.find((_item, _index, originalArray) => {\n array = originalArray;\n\n return true;\n });\n\n return array;\n}\n","import {TuiSwipeDirection} from '@taiga-ui/cdk/interfaces';\n\nexport function tuiGetSwipeDirection(deltaX: number, deltaY: number): TuiSwipeDirection {\n if (Math.abs(deltaY) > Math.abs(deltaX)) {\n return deltaY > 0 ? `top` : `bottom`;\n }\n\n return deltaX > 0 ? `left` : `right`;\n}\n","export function tuiIsFalsy(value: unknown): boolean {\n return !value;\n}\n","export function tuiIsNumber(value: unknown): value is number {\n // eslint-disable-next-line @taiga-ui/no-typeof\n return typeof value === `number`;\n}\n","export function tuiIsObject<T extends Record<string, any>>(\n value: unknown,\n): value is NonNullable<T> {\n // eslint-disable-next-line @taiga-ui/no-typeof\n return typeof value === `object` && !!value;\n}\n","export function tuiIsPresent<T>(value?: T | null): value is T {\n return value !== null && value !== undefined;\n}\n","import {AbstractControl, FormArray, FormGroup} from '@angular/forms';\n\nexport function tuiMarkControlAsTouchedAndValidate(control: AbstractControl): void {\n if (control instanceof FormArray) {\n control.controls.forEach(nestedControl => {\n tuiMarkControlAsTouchedAndValidate(nestedControl);\n });\n }\n\n if (control instanceof FormGroup) {\n Object.values(control.controls).forEach(nestedControl => {\n tuiMarkControlAsTouchedAndValidate(nestedControl);\n });\n }\n\n control.markAsTouched();\n control.updateValueAndValidity();\n}\n","import {TuiIdentityMatcher} from '@taiga-ui/cdk/types';\n\n/**\n * Checks identity for nullable elements.\n *\n * @param a element a\n * @param b element b\n * @param handler called if both elements are not null\n * @return true if either both are null or they pass identity handler\n */\nexport function tuiNullableSame<T>(\n a: T | null,\n b: T | null,\n handler: TuiIdentityMatcher<T>,\n): boolean {\n if (a === null) {\n return b === null;\n }\n\n if (b === null) {\n return false;\n }\n\n return handler(a, b);\n}\n","/**\n * @deprecated use `Object.fromEntries` instead\n * (check browser support first https://caniuse.com/mdn-javascript_builtins_object_fromentries)\n * ___\n * TODO: after we bump Firefox to 63+ replace this function with `Object.fromEntries`.\n * TODO: Add `es2019.object` to `tsconfig.json` => `compilerOptions.lib`.\n *\n */\nexport function tuiObjectFromEntries<K extends number | string, V>(\n keyValuePairs: Array<[K, V]>,\n): Record<K, V> {\n return keyValuePairs.reduce(\n (obj, [key, val]) => ({...obj, [key]: val}),\n {} as Record<K, V>,\n );\n}\n","export function tuiUniqBy<T extends Record<string, any>>(\n array: readonly T[],\n key: keyof T,\n): readonly T[] {\n return Array.from(\n array\n .reduce(\n (map, item) => (map.has(item[key]) ? map : map.set(item[key], item)),\n new Map<T[keyof T], T>(),\n )\n .values(),\n );\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAgB,SAAA,cAAc,CAAI,KAAmB,EAAE,KAAa,EAAA;AAChE,IAAA,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1F;;ACFgB,SAAA,qBAAqB,CAAI,CAAe,EAAE,CAAe,EAAA;IACrE,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAChF;;ACAgB,SAAA,cAAc,CAAI,KAAmB,EAAE,IAAO,EAAA;IAC1D,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAElC,OAAO,KAAK,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,EAAE,IAAI,CAAC,GAAG,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC1E;;ACNM,SAAU,WAAW,CAAC,KAAc,EAAA;;AAEtC,IAAA,OAAO,OAAO,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A,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACzB;;ACxBA;;;;;;;AAOG;AACG,SAAU,oBAAoB,CAChC,aAA4B,EAAA;IAE5B,OAAO,aAAa,CAAC,MAAM,CACvB,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,MAAU,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,GAAG,CAAE,EAAA,EAAA,CAAC,GAAG,GAAG,GAAG,EAAE,CAAA,CAAA,EAC3C,EAAkB,CACrB,CAAC;AACN;;ACfgB,SAAA,SAAS,CACrB,KAAmB,EACnB,GAAY,EAAA;AAEZ,IAAA,OAAO,KAAK,CAAC,IAAI,CACb,KAAK;AACA,SAAA,MAAM,CACH,CAAC,GAAG,EAAE,IAAI,MAAM,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,EACpE,IAAI,GAAG,EAAiB,CAC3B;SACA,MAAM,EAAE,CAChB,CAAC;AACN;;ACZA;;AAEG;;;;"}
1
+ {"version":3,"file":"taiga-ui-cdk-utils-miscellaneous.js","sources":["../../../projects/cdk/utils/miscellaneous/array-remove.ts","../../../projects/cdk/utils/miscellaneous/array-shallow-equals.ts","../../../projects/cdk/utils/miscellaneous/array-toggle.ts","../../../projects/cdk/utils/miscellaneous/is-string.ts","../../../projects/cdk/utils/miscellaneous/clean-object.ts","../../../projects/cdk/utils/miscellaneous/default-sort.ts","../../../projects/cdk/utils/miscellaneous/distance-between-touches.ts","../../../projects/cdk/utils/miscellaneous/ease-in-out-quad.ts","../../../projects/cdk/utils/miscellaneous/flat-length.ts","../../../projects/cdk/utils/miscellaneous/get-original-array-from-query-list.ts","../../../projects/cdk/utils/miscellaneous/get-swipe-direction.ts","../../../projects/cdk/utils/miscellaneous/is-falsy.ts","../../../projects/cdk/utils/miscellaneous/is-number.ts","../../../projects/cdk/utils/miscellaneous/is-object.ts","../../../projects/cdk/utils/miscellaneous/is-present.ts","../../../projects/cdk/utils/miscellaneous/is-valid-url.ts","../../../projects/cdk/utils/miscellaneous/mark-control-as-touched-and-validate.ts","../../../projects/cdk/utils/miscellaneous/nullable-same.ts","../../../projects/cdk/utils/miscellaneous/object-from-entries.ts","../../../projects/cdk/utils/miscellaneous/uniq-by.ts","../../../projects/cdk/utils/miscellaneous/taiga-ui-cdk-utils-miscellaneous.ts"],"sourcesContent":["export function tuiArrayRemove<T>(array: readonly T[], index: number): T[] {\n return array.slice(0, Math.max(index, 0)).concat(array.slice(Math.max(index + 1, 0)));\n}\n","export function tuiArrayShallowEquals<T>(a: readonly T[], b: readonly T[]): boolean {\n return a.length === b.length && a.every((item, index) => item === b[index]);\n}\n","import {tuiArrayRemove} from './array-remove';\n\nexport function tuiArrayToggle<T>(array: readonly T[], item: T): T[] {\n const index = array.indexOf(item);\n\n return index === -1 ? [...array, item] : tuiArrayRemove(array, index);\n}\n","export function tuiIsString(value: unknown): value is string {\n // eslint-disable-next-line @taiga-ui/no-typeof\n return typeof value === `string`;\n}\n","import {TuiDeepPartial} from '@taiga-ui/cdk/types';\n\nimport {tuiIsString} from './is-string';\n\nexport function tuiCleanObject<T>(object: T): TuiDeepPartial<T> {\n return JSON.parse(\n JSON.stringify(object, (_key: string, value: unknown) =>\n checkValueIsEmpty(value) ? undefined : value,\n ),\n );\n}\n\ntype EmptyValue = '' | null | undefined;\n\nfunction checkValueIsEmpty<T>(value: EmptyValue | T): value is EmptyValue {\n const nextValue: any = tuiIsString(value) ? value.trim() : value;\n\n return [undefined, null, NaN, ``].includes(nextValue);\n}\n","import {TuiDay} from '@taiga-ui/cdk/date-time';\n\nimport {tuiIsString} from './is-string';\n\nexport function tuiDefaultSort<T>(x: T, y: T): number {\n const a = x instanceof TuiDay ? Number(x.toUtcNativeDate()) : x;\n const b = y instanceof TuiDay ? Number(y.toUtcNativeDate()) : y;\n\n if (a === b) {\n return 0;\n }\n\n if (tuiIsString(a) && tuiIsString(b)) {\n return a.localeCompare(b);\n }\n\n return a > b ? 1 : -1;\n}\n","export function tuiDistanceBetweenTouches({touches}: TouchEvent): number {\n return Math.hypot(\n touches[0].clientX - touches[1].clientX,\n touches[0].clientY - touches[1].clientY,\n );\n}\n","import {tuiAssert} from '@taiga-ui/cdk/classes';\n\nexport function tuiEaseInOutQuad(t: number): number {\n ngDevMode &&\n tuiAssert.assert(\n t >= 0 && t <= 1,\n `Input must be between 0 and 1 inclusive but received `,\n t,\n );\n\n return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;\n}\n","/**\n * Flattens two-dimensional array and calculates resulting length\n *\n * @param array twi dimensional array\n */\nexport function tuiFlatLength(array: ReadonlyArray<readonly unknown[]>): number {\n return array.reduce((count, section) => count + section.length, 0);\n}\n","import {QueryList} from '@angular/core';\n\n/**\n * Extracts original array from {@link QueryList} rather than\n * creating a copy like {@link QueryList.toArray} does.\n * @param queryList\n * @returns original array from {@link QueryList}.\n */\nexport function tuiGetOriginalArrayFromQueryList<T>(\n queryList: QueryList<T>,\n): readonly T[] {\n let array: readonly T[] = [];\n\n queryList.find((_item, _index, originalArray) => {\n array = originalArray;\n\n return true;\n });\n\n return array;\n}\n","import {TuiSwipeDirection} from '@taiga-ui/cdk/interfaces';\n\nexport function tuiGetSwipeDirection(deltaX: number, deltaY: number): TuiSwipeDirection {\n if (Math.abs(deltaY) > Math.abs(deltaX)) {\n return deltaY > 0 ? `top` : `bottom`;\n }\n\n return deltaX > 0 ? `left` : `right`;\n}\n","export function tuiIsFalsy(value: unknown): boolean {\n return !value;\n}\n","export function tuiIsNumber(value: unknown): value is number {\n // eslint-disable-next-line @taiga-ui/no-typeof\n return typeof value === `number`;\n}\n","export function tuiIsObject<T extends Record<string, any>>(\n value: unknown,\n): value is NonNullable<T> {\n // eslint-disable-next-line @taiga-ui/no-typeof\n return typeof value === `object` && !!value;\n}\n","export function tuiIsPresent<T>(value?: T | null): value is T {\n return value !== null && value !== undefined;\n}\n","export function tuiIsValidUrl(url: string): boolean {\n const pattern = new RegExp(\n `^([a-zA-Z]+:\\\\/\\\\/)?` + // protocol\n `((([a-z\\\\d]([a-z\\\\d-]*[a-z\\\\d])*)\\\\.)+[a-z]{2,}|localhost|` + // domain name\n `((\\\\d{1,3}\\\\.){3}\\\\d{1,3}))` + // OR IP (v4) address\n `(\\\\:\\\\d+)?(\\\\/[-a-z\\\\d%_.~+]*)*` + // port and path\n `(\\\\?[;&a-z\\\\d%_.~+=-]*)?` + // query string\n `(\\\\#[-a-z\\\\d_]*)?$`, // fragment locator\n `i`,\n );\n\n return pattern.test(url);\n}\n","import {AbstractControl, FormArray, FormGroup} from '@angular/forms';\n\nexport function tuiMarkControlAsTouchedAndValidate(control: AbstractControl): void {\n if (control instanceof FormArray) {\n control.controls.forEach(nestedControl => {\n tuiMarkControlAsTouchedAndValidate(nestedControl);\n });\n }\n\n if (control instanceof FormGroup) {\n Object.values(control.controls).forEach(nestedControl => {\n tuiMarkControlAsTouchedAndValidate(nestedControl);\n });\n }\n\n control.markAsTouched();\n control.updateValueAndValidity();\n}\n","import {TuiIdentityMatcher} from '@taiga-ui/cdk/types';\n\n/**\n * Checks identity for nullable elements.\n *\n * @param a element a\n * @param b element b\n * @param handler called if both elements are not null\n * @return true if either both are null or they pass identity handler\n */\nexport function tuiNullableSame<T>(\n a: T | null,\n b: T | null,\n handler: TuiIdentityMatcher<T>,\n): boolean {\n if (a === null) {\n return b === null;\n }\n\n if (b === null) {\n return false;\n }\n\n return handler(a, b);\n}\n","/**\n * @deprecated use `Object.fromEntries` instead\n * (check browser support first https://caniuse.com/mdn-javascript_builtins_object_fromentries)\n * ___\n * TODO: after we bump Firefox to 63+ replace this function with `Object.fromEntries`.\n * TODO: Add `es2019.object` to `tsconfig.json` => `compilerOptions.lib`.\n *\n */\nexport function tuiObjectFromEntries<K extends number | string, V>(\n keyValuePairs: Array<[K, V]>,\n): Record<K, V> {\n return keyValuePairs.reduce(\n (obj, [key, val]) => ({...obj, [key]: val}),\n {} as Record<K, V>,\n );\n}\n","export function tuiUniqBy<T extends Record<string, any>>(\n array: readonly T[],\n key: keyof T,\n): readonly T[] {\n return Array.from(\n array\n .reduce(\n (map, item) => (map.has(item[key]) ? map : map.set(item[key], item)),\n new Map<T[keyof T], T>(),\n )\n .values(),\n );\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAgB,SAAA,cAAc,CAAI,KAAmB,EAAE,KAAa,EAAA;AAChE,IAAA,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1F;;ACFgB,SAAA,qBAAqB,CAAI,CAAe,EAAE,CAAe,EAAA;IACrE,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AAChF;;ACAgB,SAAA,cAAc,CAAI,KAAmB,EAAE,IAAO,EAAA;IAC1D,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAElC,OAAO,KAAK,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,EAAE,IAAI,CAAC,GAAG,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC1E;;ACNM,SAAU,WAAW,CAAC,KAAc,EAAA;;AAEtC,IAAA,OAAO,OAAO,KAAK,KAAK,CAAA,MAAA,CAAQ,CAAC;AACrC;;ACCM,SAAU,cAAc,CAAI,MAAS,EAAA;A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AE,CAAC;IACxB,OAAO,CAAC,sBAAsB,EAAE,CAAC;AACrC;;ACfA;;;;;;;AAOG;SACa,eAAe,CAC3B,CAAW,EACX,CAAW,EACX,OAA8B,EAAA;IAE9B,IAAI,CAAC,KAAK,IAAI,EAAE;QACZ,OAAO,CAAC,KAAK,IAAI,CAAC;AACrB,KAAA;IAED,IAAI,CAAC,KAAK,IAAI,EAAE;AACZ,QAAA,OAAO,KAAK,CAAC;AAChB,KAAA;AAED,IAAA,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACzB;;ACxBA;;;;;;;AAOG;AACG,SAAU,oBAAoB,CAChC,aAA4B,EAAA;IAE5B,OAAO,aAAa,CAAC,MAAM,CACvB,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,MAAU,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,GAAG,CAAE,EAAA,EAAA,CAAC,GAAG,GAAG,GAAG,EAAE,CAAA,CAAA,EAC3C,EAAkB,CACrB,CAAC;AACN;;ACfgB,SAAA,SAAS,CACrB,KAAmB,EACnB,GAAY,EAAA;AAEZ,IAAA,OAAO,KAAK,CAAC,IAAI,CACb,KAAK;AACA,SAAA,MAAM,CACH,CAAC,GAAG,EAAE,IAAI,MAAM,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,EACpE,IAAI,GAAG,EAAiB,CAC3B;SACA,MAAM,EAAE,CAChB,CAAC;AACN;;ACZA;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taiga-ui/cdk",
3
- "version": "3.25.0-dev.main-6e585e7",
3
+ "version": "3.25.0-dev.main-c3bbfaa",
4
4
  "description": "Base library for creating Angular components and applications using Taiga UI principles regarding of actual visual appearance",
5
5
  "keywords": [
6
6
  "angular",
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ALL_FILES = exports.ALL_TS_FILES = void 0;
4
4
  const EXCLUDE_DIRECTORIES = [
5
+ `e2e`,
5
6
  // compiled
6
7
  `scripts`,
7
8
  `dist`,
@@ -2,7 +2,11 @@ export interface ImportingModule {
2
2
  name: string;
3
3
  packageName: string;
4
4
  }
5
- export declare const MAIN_MODULES: readonly ImportingModule[];
5
+ export declare const MAIN_MODULE: ImportingModule;
6
+ export declare const BROWSER_ANIMATION_MODULE: {
7
+ name: string;
8
+ packageName: string;
9
+ };
6
10
  export declare const DIALOG_MODULES: readonly ImportingModule[];
7
11
  export declare const ALERT_MODULES: readonly ImportingModule[];
8
12
  export declare const SANITIZER_MODULES: readonly ImportingModule[];
@@ -1,16 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SANITIZER_MODULES = exports.ALERT_MODULES = exports.DIALOG_MODULES = exports.MAIN_MODULES = void 0;
4
- exports.MAIN_MODULES = [
5
- {
6
- name: `BrowserAnimationsModule`,
7
- packageName: `@angular/platform-browser/animations`,
8
- },
9
- {
10
- name: `TuiRootModule`,
11
- packageName: `@taiga-ui/core`,
12
- },
13
- ];
3
+ exports.SANITIZER_MODULES = exports.ALERT_MODULES = exports.DIALOG_MODULES = exports.BROWSER_ANIMATION_MODULE = exports.MAIN_MODULE = void 0;
4
+ exports.MAIN_MODULE = {
5
+ name: `TuiRootModule`,
6
+ packageName: `@taiga-ui/core`,
7
+ };
8
+ exports.BROWSER_ANIMATION_MODULE = {
9
+ name: `BrowserAnimationsModule`,
10
+ packageName: `@angular/platform-browser/animations`,
11
+ };
14
12
  exports.DIALOG_MODULES = [
15
13
  {
16
14
  name: `TuiDialogModule`,
@@ -4,9 +4,14 @@ exports.addTaigaModules = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const workspace_1 = require("@schematics/angular/utility/workspace");
6
6
  const ng_morph_1 = require("ng-morph");
7
+ const constants_1 = require("../../constants");
8
+ const add_import_to_component_1 = require("../../utils/add-import-to-component");
7
9
  const add_unique_import_1 = require("../../utils/add-unique-import");
10
+ const get_component_from_identifier_1 = require("../../utils/get-component-from-identifier");
8
11
  const get_project_target_options_1 = require("../../utils/get-project-target-options");
9
12
  const get_projects_1 = require("../../utils/get-projects");
13
+ const get_standalone_bootstrap_function_1 = require("../../utils/get-standalone-bootstrap-function");
14
+ const push_to_array_property_1 = require("../../utils/push-to-array-property");
10
15
  const modules_1 = require("../constants/modules");
11
16
  function addTaigaModules(options) {
12
17
  return (tree, context) => tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -17,33 +22,98 @@ function addTaigaModules(options) {
17
22
  return;
18
23
  }
19
24
  const buildOptions = get_project_target_options_1.getProjectTargetOptions(project, `build`);
20
- ng_morph_1.setActiveProject(ng_morph_1.createProject(tree, `/`, [`**/*.ts`, `**/*.json`]));
21
- const mainModule = ng_morph_1.getMainModule(buildOptions.main);
22
- addTuiModules(mainModule, options, context);
23
- addTuiProviders(mainModule, options);
25
+ const mainFilePath = buildOptions.main;
26
+ if (!mainFilePath) {
27
+ context.logger.error(`[ERROR]: Could not find the project main file`);
28
+ return;
29
+ }
30
+ ng_morph_1.setActiveProject(ng_morph_1.createProject(tree, `/`, constants_1.ALL_FILES));
31
+ const bootstrapFunction = get_standalone_bootstrap_function_1.getStandaloneBootstrapFunction(mainFilePath);
32
+ if (bootstrapFunction) {
33
+ addTuiEntitiesToStandalone({
34
+ bootstrapFunction,
35
+ options,
36
+ context,
37
+ });
38
+ }
39
+ else {
40
+ const mainClass = ng_morph_1.getMainModule(mainFilePath);
41
+ addTuiModules({ mainClass, options, context });
42
+ addExtraTuiProvidersToRootComponent({ mainClass, options });
43
+ }
24
44
  ng_morph_1.saveActiveProject();
25
45
  });
26
46
  }
27
47
  exports.addTaigaModules = addTaigaModules;
28
- function addTuiModules(mainModule, options, context) {
29
- const modules = [
30
- ...modules_1.MAIN_MODULES,
31
- ...(options.addDialogsModule ? modules_1.DIALOG_MODULES : []),
32
- ...(options.addAlertModule ? modules_1.ALERT_MODULES : []),
33
- ];
34
- const mainModulePath = mainModule.getSourceFile().getFilePath();
48
+ function addTuiModules({ mainClass, options, context, }) {
49
+ const modules = getModules(options, [modules_1.BROWSER_ANIMATION_MODULE]);
50
+ const mainModulePath = mainClass.getSourceFile().getFilePath();
35
51
  modules.forEach(module => {
36
- ng_morph_1.addImportToNgModule(mainModule, module.name, { unique: true });
52
+ ng_morph_1.addImportToNgModule(mainClass, module.name, { unique: true });
37
53
  add_unique_import_1.addUniqueImport(mainModulePath, module.name, module.packageName);
38
54
  });
39
55
  context.logger.info(`${modules.map(module => module.name)} was added to ${mainModulePath}`);
40
56
  }
41
- function addTuiProviders(mainModule, options) {
57
+ function addExtraTuiProvidersToRootComponent({ mainClass, options, standalone = false, }) {
42
58
  if (!options.addSanitizer) {
43
59
  return;
44
60
  }
45
- ng_morph_1.addProviderToNgModule(mainModule, `{provide: TUI_SANITIZER, useClass: NgDompurifySanitizer}`, { unique: true });
61
+ const provider = `{provide: TUI_SANITIZER, useClass: NgDompurifySanitizer}`;
62
+ if (standalone) {
63
+ ng_morph_1.addProviderToComponent(mainClass, provider, { unique: true });
64
+ }
65
+ else {
66
+ ng_morph_1.addProviderToNgModule(mainClass, provider, { unique: true });
67
+ }
46
68
  modules_1.SANITIZER_MODULES.forEach(module => {
47
- add_unique_import_1.addUniqueImport(mainModule.getSourceFile().getFilePath(), module.name, module.packageName);
69
+ add_unique_import_1.addUniqueImport(mainClass.getSourceFile().getFilePath(), module.name, module.packageName);
48
70
  });
49
71
  }
72
+ function addTuiEntitiesToStandalone({ bootstrapFunction, options, context, }) {
73
+ const [rootComponentIdentifier, bootstrapOptions = bootstrapFunction.addArgument(`{providers}: []`),] = bootstrapFunction.getArguments();
74
+ const mainClass = get_component_from_identifier_1.getComponentFromIdentifier(rootComponentIdentifier);
75
+ if (mainClass) {
76
+ addMainModuleToRootComponent({ mainClass, options, context });
77
+ addRootTuiProvidersToBootstrapFn(bootstrapOptions);
78
+ addExtraTuiProvidersToRootComponent({ mainClass, options, standalone: true });
79
+ }
80
+ }
81
+ function addRootTuiProvidersToBootstrapFn(bootstrapOptions) {
82
+ const property = bootstrapOptions.getProperty(`providers`);
83
+ const initializer = property.getInitializer();
84
+ const providerFrom = initializer
85
+ .getElements()
86
+ .find(el => ng_morph_1.Node.isCallExpression(el) &&
87
+ el.getExpression().getText() === `importProvidersFrom`);
88
+ const modules = [modules_1.MAIN_MODULE, modules_1.BROWSER_ANIMATION_MODULE];
89
+ if (ng_morph_1.Node.isCallExpression(providerFrom)) {
90
+ const existing = providerFrom.getArguments();
91
+ const moduleNames = modules
92
+ .map(({ name }) => name)
93
+ .filter(module => !existing.some(existingModule => existingModule.getText() === module));
94
+ providerFrom.addArguments(moduleNames);
95
+ }
96
+ else {
97
+ push_to_array_property_1.pushToObjectArrayProperty(bootstrapOptions, `providers`, `importProvidersFrom(TuiRootModule, BrowserAnimationsModule)`);
98
+ }
99
+ [...modules, { name: `importProvidersFrom`, packageName: `@angular/core` }].forEach(({ name, packageName }) => {
100
+ add_unique_import_1.addUniqueImport(bootstrapOptions.getSourceFile().getFilePath(), name, packageName);
101
+ });
102
+ }
103
+ function addMainModuleToRootComponent({ mainClass, options, context, }) {
104
+ const rootComponentPath = mainClass.getSourceFile().getFilePath();
105
+ const modules = getModules(options);
106
+ modules.forEach(({ name, packageName }) => {
107
+ add_import_to_component_1.addImportToComponent(mainClass, name);
108
+ add_unique_import_1.addUniqueImport(rootComponentPath, name, packageName);
109
+ });
110
+ context.logger.info(`${modules.map(({ name }) => name)} was added to ${rootComponentPath}`);
111
+ }
112
+ function getModules(options, extraModules) {
113
+ return [
114
+ ...(extraModules || []),
115
+ modules_1.MAIN_MODULE,
116
+ ...(options.addDialogsModule ? modules_1.DIALOG_MODULES : []),
117
+ ...(options.addAlertModule ? modules_1.ALERT_MODULES : []),
118
+ ];
119
+ }
@@ -4,8 +4,11 @@ exports.wrapWithTuiRootComponent = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const workspace_1 = require("@schematics/angular/utility/workspace");
6
6
  const ng_morph_1 = require("ng-morph");
7
+ const constants_1 = require("../../constants");
8
+ const get_component_from_identifier_1 = require("../../utils/get-component-from-identifier");
7
9
  const get_project_target_options_1 = require("../../utils/get-project-target-options");
8
10
  const get_projects_1 = require("../../utils/get-projects");
11
+ const get_standalone_bootstrap_function_1 = require("../../utils/get-standalone-bootstrap-function");
9
12
  function wrapWithTuiRootComponent(options) {
10
13
  return (tree, context) => tslib_1.__awaiter(this, void 0, void 0, function* () {
11
14
  const workspace = yield workspace_1.getWorkspace(tree);
@@ -14,7 +17,9 @@ function wrapWithTuiRootComponent(options) {
14
17
  return;
15
18
  }
16
19
  const buildOptions = get_project_target_options_1.getProjectTargetOptions(project, `build`);
17
- const appTemplatePath = getAppTemplatePath(tree, buildOptions.main);
20
+ ng_morph_1.setActiveProject(ng_morph_1.createProject(tree, `/`, constants_1.ALL_FILES));
21
+ const appTemplatePath = getAppTemplatePath(buildOptions.main);
22
+ ng_morph_1.saveActiveProject();
18
23
  if (!appTemplatePath) {
19
24
  context.logger.error(`Could not find the default main template file for this project.`);
20
25
  context.logger.info(`Consider manually wrapping content of your app with tui-root`);
@@ -44,24 +49,32 @@ function addTuiRootComponent(filePath, context, tree) {
44
49
  tree.commitUpdate(recorder);
45
50
  context.logger.info(`Content of the app was wrapped with tui-root component in ${filePath}`);
46
51
  }
47
- function getAppTemplatePath(tree, mainPath) {
48
- ng_morph_1.setActiveProject(ng_morph_1.createProject(tree, `/`, [`**/*.ts`, `**/*.json`]));
52
+ function getAppTemplatePath(mainPath) {
53
+ const stansdaloneBootstrapFunction = get_standalone_bootstrap_function_1.getStandaloneBootstrapFunction(mainPath);
54
+ if (stansdaloneBootstrapFunction) {
55
+ const [componentIdentifier] = stansdaloneBootstrapFunction.getArguments();
56
+ const component = get_component_from_identifier_1.getComponentFromIdentifier(componentIdentifier);
57
+ return component && getTemplatePathFromComponent(component);
58
+ }
49
59
  const mainModule = ng_morph_1.getMainModule(mainPath);
50
- const mainInitializer = getInitializer(mainModule, `NgModule`, `declarations`);
60
+ const mainInitializer = getTemplateInitializer(mainModule, `NgModule`, `declarations`);
51
61
  if (!ng_morph_1.Node.isArrayLiteralExpression(mainInitializer)) {
52
62
  return;
53
63
  }
54
64
  const appIdentifier = mainInitializer.getElements()[0];
55
65
  const appComponent = appIdentifier.getDefinitionNodes()[0];
56
- const templateInitializer = getInitializer(appComponent, `Component`, `templateUrl`);
57
- const appComponentPath = appComponent.getSourceFile().getFilePath().split(`/`);
66
+ const templateUrlPath = getTemplatePathFromComponent(appComponent);
67
+ return templateUrlPath;
68
+ }
69
+ function getTemplatePathFromComponent(component) {
70
+ const templateInitializer = getTemplateInitializer(component, `Component`, `templateUrl`);
71
+ const appComponentPath = component.getSourceFile().getFilePath().split(`/`);
58
72
  const templateUrlPath = `${appComponentPath
59
73
  .splice(0, appComponentPath.length - 1)
60
74
  .join(`/`)}/${templateInitializer === null || templateInitializer === void 0 ? void 0 : templateInitializer.getText().replace(/['"]/g, ``)}`;
61
- ng_morph_1.saveActiveProject();
62
75
  return templateUrlPath;
63
76
  }
64
- function getInitializer(classDeclaration, decoratorName, propertyName) {
77
+ function getTemplateInitializer(classDeclaration, decoratorName, propertyName) {
65
78
  const decorator = classDeclaration.getDecorator(decoratorName);
66
79
  if (!decorator) {
67
80
  return;
@@ -0,0 +1,4 @@
1
+ import { ClassDeclaration } from 'ng-morph';
2
+ export declare function addImportToComponent(classDeclaration: ClassDeclaration, moduleName: string, { unique }?: {
3
+ unique?: boolean;
4
+ }): void;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addImportToComponent = void 0;
4
+ const push_to_array_property_1 = require("ng-morph/ng/helpers/push-to-array-property");
5
+ // TODO: delete after adding to ng-morph
6
+ function addImportToComponent(classDeclaration, moduleName, { unique = true } = {}) {
7
+ push_to_array_property_1.pushToArrayProperty(classDeclaration, `Component`, `imports`, moduleName, {
8
+ unique,
9
+ forceToArray: true,
10
+ });
11
+ }
12
+ exports.addImportToComponent = addImportToComponent;
@@ -0,0 +1,2 @@
1
+ import { ClassDeclaration, Node } from 'ng-morph';
2
+ export declare function getComponentFromIdentifier(identifier: Node): ClassDeclaration | undefined;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getComponentFromIdentifier = void 0;
4
+ const ng_morph_1 = require("ng-morph");
5
+ const ng_component_1 = require("./angular/ng-component");
6
+ function getComponentFromIdentifier(identifier) {
7
+ var _a;
8
+ const rootImportDeclaration = ng_morph_1.getImports(identifier.getSourceFile().getFilePath(), {
9
+ namedImports: [identifier.getText()],
10
+ })[0];
11
+ const rootComponentPath = ((_a = rootImportDeclaration.getModuleSpecifierSourceFile()) === null || _a === void 0 ? void 0 : _a.getFilePath()) || ``;
12
+ return ng_component_1.getNgComponents(rootComponentPath, {
13
+ name: identifier.getText(),
14
+ })[0];
15
+ }
16
+ exports.getComponentFromIdentifier = getComponentFromIdentifier;
@@ -1,2 +1,2 @@
1
1
  import { Node } from 'ng-morph';
2
- export declare function getNamedImportReferences(namedImport: string, moduleSpecifier?: string[] | string): Node[];
2
+ export declare function getNamedImportReferences(namedImport: string, moduleSpecifier?: string[] | string, files?: import("ng-morph").Pattern): Node[];
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNamedImportReferences = void 0;
4
4
  const ng_morph_1 = require("ng-morph");
5
5
  const constants_1 = require("../constants");
6
- function getNamedImportReferences(namedImport, moduleSpecifier = `**/**`) {
7
- const importDeclarations = ng_morph_1.getImports(constants_1.ALL_TS_FILES, {
6
+ function getNamedImportReferences(namedImport, moduleSpecifier = `**/**`, files = constants_1.ALL_TS_FILES) {
7
+ const importDeclarations = ng_morph_1.getImports(files, {
8
8
  namedImports: [namedImport],
9
9
  moduleSpecifier,
10
10
  });
@@ -0,0 +1,2 @@
1
+ import { CallExpression } from 'ng-morph';
2
+ export declare function getStandaloneBootstrapFunction(path: string): CallExpression | null;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getStandaloneBootstrapFunction = void 0;
4
+ const ng_morph_1 = require("ng-morph");
5
+ const get_named_import_references_1 = require("./get-named-import-references");
6
+ function getStandaloneBootstrapFunction(path) {
7
+ const stansdaloneBootstrapIdentifier = get_named_import_references_1.getNamedImportReferences(`bootstrapApplication`, `@angular/platform-browser`, path)
8
+ .map(ref => ref.getParent())
9
+ .filter(node => ng_morph_1.Node.isCallExpression(node))[0];
10
+ const stansdaloneBootstrapFunction = stansdaloneBootstrapIdentifier;
11
+ return stansdaloneBootstrapFunction || null;
12
+ }
13
+ exports.getStandaloneBootstrapFunction = getStandaloneBootstrapFunction;
@@ -0,0 +1,5 @@
1
+ import { ObjectLiteralExpression } from 'ng-morph';
2
+ export declare function pushToObjectArrayProperty(objectExpression: ObjectLiteralExpression, propertyName: string, initializer: string, { unique, forceToArray, }?: {
3
+ unique?: boolean;
4
+ forceToArray?: boolean;
5
+ }): void;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pushToObjectArrayProperty = void 0;
4
+ const ng_morph_1 = require("ng-morph");
5
+ function pushToObjectArrayProperty(objectExpression, propertyName, initializer, { unique = false, forceToArray = false, } = {}) {
6
+ var _a, _b;
7
+ const property = (_a = objectExpression.getProperty(propertyName)) !== null && _a !== void 0 ? _a : objectExpression.addProperty(`${propertyName}: []`);
8
+ if (!ng_morph_1.Node.isPropertyAssignment(property)) {
9
+ return;
10
+ }
11
+ if (forceToArray && !ng_morph_1.Node.isArrayLiteralExpression(property.getInitializer())) {
12
+ property.setInitializer(`[${(_b = property === null || property === void 0 ? void 0 : property.getInitializer()) === null || _b === void 0 ? void 0 : _b.getText()}]`);
13
+ }
14
+ const importsInitializer = property.getInitializer();
15
+ if (!ng_morph_1.Node.isArrayLiteralExpression(importsInitializer)) {
16
+ return;
17
+ }
18
+ if (unique &&
19
+ importsInitializer
20
+ .getElements()
21
+ .some(element => element.getText() === initializer)) {
22
+ return;
23
+ }
24
+ importsInitializer.addElement(initializer);
25
+ }
26
+ exports.pushToObjectArrayProperty = pushToObjectArrayProperty;
@@ -1,7 +1,10 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import * as i0 from "@angular/core";
3
3
  export declare class TuiStaticRequestService {
4
+ private readonly win;
5
+ private readonly platformId;
4
6
  private readonly cache;
7
+ constructor(win: Window, platformId: Record<string, unknown>);
5
8
  request(url: string): Observable<string>;
6
9
  static ɵfac: i0.ɵɵFactoryDeclaration<TuiStaticRequestService, never>;
7
10
  static ɵprov: i0.ɵɵInjectableDeclaration<TuiStaticRequestService>;
@@ -13,6 +13,7 @@ export * from './is-number';
13
13
  export * from './is-object';
14
14
  export * from './is-present';
15
15
  export * from './is-string';
16
+ export * from './is-valid-url';
16
17
  export * from './mark-control-as-touched-and-validate';
17
18
  export * from './nullable-same';
18
19
  export * from './object-from-entries';
@@ -0,0 +1 @@
1
+ export declare function tuiIsValidUrl(url: string): boolean;