From ee01cdfcc3120f2b422f9d72986cfa76823efe97 Mon Sep 17 00:00:00 2001 From: Palash Bansal Date: Mon, 1 Jan 2024 15:16:29 +0530 Subject: [PATCH] Remove uuid dependency, add generateUiConfig return type --- package-lock.json | 14 +++++++------- package.json | 6 ++---- src/UiConfigMethods.ts | 5 ++--- src/decorator_utils.ts | 9 ++++----- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3558b82..06ebb86 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ "rollup-plugin-delete": "^2.0.0", "rollup-plugin-license": "^3.0.1", "rollup-plugin-multi-input": "^1.3.3", - "ts-browser-helpers": "^0.5.0", + "ts-browser-helpers": "^0.11.0", "tslib": "^2.5.0", "typedoc": "^0.23.26", "typescript": "^4.9.5", @@ -5115,9 +5115,9 @@ } }, "node_modules/ts-browser-helpers": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/ts-browser-helpers/-/ts-browser-helpers-0.5.0.tgz", - "integrity": "sha512-seKCLyEIzNfjaVSYMMhYvvQlj0OHfgHbtbeOJNrFufhalmQOJcj5NP/PSMCcIU1qrKgcXNYuAolgtTmsPG6Aaw==", + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/ts-browser-helpers/-/ts-browser-helpers-0.11.0.tgz", + "integrity": "sha512-ECz/LexfnUWK7uFMjY04r+auG1sm1MK+C23we+K4sgkXkZCRIaSqcP8H7kUU5xUoLr03sgHOCd3RTzTOWFXMjw==", "dev": true, "dependencies": { "@types/wicg-file-system-access": "^2020.9.5" @@ -8820,9 +8820,9 @@ "dev": true }, "ts-browser-helpers": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/ts-browser-helpers/-/ts-browser-helpers-0.5.0.tgz", - "integrity": "sha512-seKCLyEIzNfjaVSYMMhYvvQlj0OHfgHbtbeOJNrFufhalmQOJcj5NP/PSMCcIU1qrKgcXNYuAolgtTmsPG6Aaw==", + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/ts-browser-helpers/-/ts-browser-helpers-0.11.0.tgz", + "integrity": "sha512-ECz/LexfnUWK7uFMjY04r+auG1sm1MK+C23we+K4sgkXkZCRIaSqcP8H7kUU5xUoLr03sgHOCd3RTzTOWFXMjw==", "dev": true, "requires": { "@types/wicg-file-system-access": "^2020.9.5" diff --git a/package.json b/package.json index ce33ec0..e120ffb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uiconfig.js", - "version": "0.0.9", + "version": "0.0.10", "description": "A framework for building user interface layouts with JSON configuration.", "main": "src/index.ts", "module": "dist/index.mjs", @@ -65,7 +65,6 @@ "@rollup/plugin-node-resolve": "^15.0.1", "@rollup/plugin-terser": "^0.4.0", "@rollup/plugin-typescript": "^11.0.0", - "@types/uuid": "^9.0.0", "@typescript-eslint/eslint-plugin": "^5.53.0", "eslint": "^8.34.0", "eslint-plugin-deprecation": "^1.3.3", @@ -77,10 +76,9 @@ "rollup-plugin-delete": "^2.0.0", "rollup-plugin-license": "^3.0.1", "rollup-plugin-multi-input": "^1.3.3", - "ts-browser-helpers": "^0.5.0", + "ts-browser-helpers": "^0.11.0", "tslib": "^2.5.0", "typescript": "^4.9.5", - "uuid": "^9.0.0", "typedoc": "^0.23.26", "rimraf": "^5.0.1" }, diff --git a/src/UiConfigMethods.ts b/src/UiConfigMethods.ts index f28e844..2a1b80e 100644 --- a/src/UiConfigMethods.ts +++ b/src/UiConfigMethods.ts @@ -1,7 +1,6 @@ import {ChangeArgs, ChangeEvent, UiObjectConfig} from './types' -import {Fof, getOrCall, safeSetProperty} from 'ts-browser-helpers' +import {Fof, getOrCall, safeSetProperty, uuidV4} from 'ts-browser-helpers' import {UiConfigRendererBase} from './UiConfigRendererBase' -import {v4} from 'uuid' export class UiConfigMethods { constructor(protected _renderer: UiConfigRendererBase) { @@ -122,7 +121,7 @@ export class UiConfigMethods { console.warn('No type for config', config) config.type = 'input' } - if (!config.uuid) config.uuid = v4() + if (!config.uuid) config.uuid = uuidV4() if (config.property === undefined) { if (config.binding) config.property = config.binding diff --git a/src/decorator_utils.ts b/src/decorator_utils.ts index 06f3c58..68a9034 100644 --- a/src/decorator_utils.ts +++ b/src/decorator_utils.ts @@ -1,6 +1,5 @@ import {UiObjectConfig} from './types' -import {v4} from 'uuid' -import {Fof} from 'ts-browser-helpers' +import {Fof, uuidV4} from 'ts-browser-helpers' export class UiConfigTypeMap { static Map = new Map() @@ -28,12 +27,12 @@ export function generateValueConfig(obj: any, key: string | number, label?: stri return result } -export function generateUiConfig(obj: any): UiObjectConfig[] { +export function generateUiConfig(obj: any): UiObjectConfig['children'] { if (!obj) return [] let type = obj.constructor || Object if (type === Array) type = Object - const result: UiObjectConfig[] = [] + const result: UiObjectConfig['children'] = [] const types: any[] = [] while (type && type !== Object) { types.push(type) @@ -94,7 +93,7 @@ export function generateUiFolder(label: string, obj: any, params: any = {}, type return { type, label, children: generateUiConfig(obj), - uuid: v4(), + uuid: uuidV4(), ...params, } }