zcw-shared 1.19.0 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1291 -65
- package/dist/functions/ag-grid/generateLicense.d.ts +5 -1
- package/dist/functions/ag-grid/generateLicense.js +3 -3
- package/dist/functions/ag-grid/generateLicense.js.map +1 -1
- package/dist/functions/android/buildProject.d.ts +9 -8
- package/dist/functions/android/buildProject.js +19 -20
- package/dist/functions/android/buildProject.js.map +1 -1
- package/dist/functions/android/detectAndroidModules.d.ts +7 -1
- package/dist/functions/android/detectAndroidModules.js +7 -7
- package/dist/functions/android/detectAndroidModules.js.map +1 -1
- package/dist/functions/android/modifyGradle.d.ts +10 -1
- package/dist/functions/android/modifyGradle.js +7 -7
- package/dist/functions/android/modifyGradle.js.map +1 -1
- package/dist/functions/android/modifyManifest.d.ts +11 -2
- package/dist/functions/android/modifyManifest.js +4 -4
- package/dist/functions/android/modifyManifest.js.map +1 -1
- package/dist/functions/android/permission.d.ts +15 -5
- package/dist/functions/android/permission.js +8 -8
- package/dist/functions/android/permission.js.map +1 -1
- package/dist/functions/array-object/deepClone.d.ts +12 -0
- package/dist/functions/array-object/deepClone.js +131 -0
- package/dist/functions/array-object/deepClone.js.map +1 -0
- package/dist/functions/array-object/flatten.d.ts +7 -0
- package/dist/functions/array-object/flatten.js +60 -0
- package/dist/functions/array-object/flatten.js.map +1 -0
- package/dist/functions/array-object/unique.d.ts +10 -0
- package/dist/functions/array-object/unique.js +85 -0
- package/dist/functions/array-object/unique.js.map +1 -0
- package/dist/functions/async/createInterruptibleTask.d.ts +37 -0
- package/dist/functions/async/createInterruptibleTask.js +180 -0
- package/dist/functions/async/createInterruptibleTask.js.map +1 -0
- package/dist/functions/color/convertColor.js +1 -1
- package/dist/functions/color/convertColor.js.map +1 -1
- package/dist/functions/data-structures/Heap.d.ts +11 -0
- package/dist/functions/data-structures/Heap.js +91 -0
- package/dist/functions/data-structures/Heap.js.map +1 -0
- package/dist/functions/data-structures/LinkedList.d.ts +18 -0
- package/dist/functions/data-structures/LinkedList.js +135 -0
- package/dist/functions/data-structures/LinkedList.js.map +1 -0
- package/dist/functions/data-structures/PriorityQueue.d.ts +14 -0
- package/dist/functions/data-structures/PriorityQueue.js +77 -0
- package/dist/functions/data-structures/PriorityQueue.js.map +1 -0
- package/dist/functions/data-structures/Queue.d.ts +10 -0
- package/dist/functions/data-structures/Queue.js +27 -0
- package/dist/functions/data-structures/Queue.js.map +1 -0
- package/dist/functions/data-structures/Stack.d.ts +10 -0
- package/dist/functions/data-structures/Stack.js +27 -0
- package/dist/functions/data-structures/Stack.js.map +1 -0
- package/dist/functions/debug/createDebugger.d.ts +14 -3
- package/dist/functions/debug/createDebugger.js +10 -35
- package/dist/functions/debug/createDebugger.js.map +1 -1
- package/dist/functions/design-tokens/buildTokens.d.ts +76 -0
- package/dist/functions/design-tokens/buildTokens.js +183 -0
- package/dist/functions/design-tokens/buildTokens.js.map +1 -0
- package/dist/functions/design-tokens/generateVariables.d.ts +7 -0
- package/dist/functions/design-tokens/generateVariables.js +135 -0
- package/dist/functions/design-tokens/generateVariables.js.map +1 -0
- package/dist/functions/design-tokens/mixColors.d.ts +1 -0
- package/dist/functions/design-tokens/mixColors.js +38 -0
- package/dist/functions/design-tokens/mixColors.js.map +1 -0
- package/dist/functions/design-tokens/parseDesignTokens.d.ts +10 -0
- package/dist/functions/design-tokens/parseDesignTokens.js +216 -0
- package/dist/functions/design-tokens/parseDesignTokens.js.map +1 -0
- package/dist/functions/dom/demonstrateResourceLoading.d.ts +32 -0
- package/dist/functions/dom/demonstrateResourceLoading.js +169 -0
- package/dist/functions/dom/demonstrateResourceLoading.js.map +1 -0
- package/dist/functions/dom/detectOverflow.d.ts +5 -1
- package/dist/functions/dom/detectOverflow.js +2 -2
- package/dist/functions/dom/detectOverflow.js.map +1 -1
- package/dist/functions/dom/getViewportRect.d.ts +5 -1
- package/dist/functions/dom/getViewportRect.js +3 -3
- package/dist/functions/dom/getViewportRect.js.map +1 -1
- package/dist/functions/functional/compose.d.ts +1 -0
- package/dist/functions/functional/compose.js +10 -0
- package/dist/functions/functional/compose.js.map +1 -0
- package/dist/functions/functional/curry.d.ts +1 -0
- package/dist/functions/functional/curry.js +13 -0
- package/dist/functions/functional/curry.js.map +1 -0
- package/dist/functions/functional/pipe.d.ts +1 -0
- package/dist/functions/functional/pipe.js +10 -0
- package/dist/functions/functional/pipe.js.map +1 -0
- package/dist/functions/image/compressToTargetSize.d.ts +8 -1
- package/dist/functions/image/compressToTargetSize.js +11 -8
- package/dist/functions/image/compressToTargetSize.js.map +1 -1
- package/dist/functions/image/generateMacIcons.d.ts +5 -1
- package/dist/functions/image/generateMacIcons.js +4 -4
- package/dist/functions/image/generateMacIcons.js.map +1 -1
- package/dist/functions/image/generateMacTrayIcon.d.ts +4 -1
- package/dist/functions/image/generateMacTrayIcon.js +2 -2
- package/dist/functions/image/generateMacTrayIcon.js.map +1 -1
- package/dist/functions/image/generatePaddedImage.d.ts +4 -1
- package/dist/functions/image/generatePaddedImage.js +3 -3
- package/dist/functions/image/generatePaddedImage.js.map +1 -1
- package/dist/functions/image/generatePwaIcons.d.ts +5 -1
- package/dist/functions/image/generatePwaIcons.js +4 -4
- package/dist/functions/image/generatePwaIcons.js.map +1 -1
- package/dist/functions/image/generateRoundedImage.d.ts +5 -1
- package/dist/functions/image/generateRoundedImage.js +4 -4
- package/dist/functions/image/generateRoundedImage.js.map +1 -1
- package/dist/functions/image/getImageDimensions.d.ts +5 -1
- package/dist/functions/image/getImageDimensions.js +3 -3
- package/dist/functions/image/getImageDimensions.js.map +1 -1
- package/dist/functions/ipc/dispatchIpcRequest.d.ts +4 -1
- package/dist/functions/ipc/dispatchIpcRequest.js +3 -3
- package/dist/functions/ipc/dispatchIpcRequest.js.map +1 -1
- package/dist/functions/performance/debounce.d.ts +5 -0
- package/dist/functions/performance/debounce.js +12 -0
- package/dist/functions/performance/debounce.js.map +1 -0
- package/dist/functions/performance/memoize.d.ts +1 -0
- package/dist/functions/performance/memoize.js +13 -0
- package/dist/functions/performance/memoize.js.map +1 -0
- package/dist/functions/performance/throttle.d.ts +1 -0
- package/dist/functions/performance/throttle.js +11 -0
- package/dist/functions/performance/throttle.js.map +1 -0
- package/dist/functions/platform/tencent-cloud/deploy.tcb.d.ts +13 -0
- package/dist/functions/platform/tencent-cloud/deploy.tcb.js +46 -0
- package/dist/functions/platform/tencent-cloud/deploy.tcb.js.map +1 -0
- package/dist/functions/platform/tencent-cloud/getSecret.d.ts +4 -0
- package/dist/functions/platform/tencent-cloud/getSecret.js +19 -0
- package/dist/functions/platform/tencent-cloud/getSecret.js.map +1 -0
- package/dist/functions/platform/uniapp/app-plus/buildAndroidApp.d.ts +27 -0
- package/dist/functions/platform/uniapp/app-plus/buildAndroidApp.js +287 -0
- package/dist/functions/platform/uniapp/app-plus/buildAndroidApp.js.map +1 -0
- package/dist/functions/platform/uniapp/build.d.ts +21 -0
- package/dist/functions/platform/uniapp/build.js +83 -0
- package/dist/functions/platform/uniapp/build.js.map +1 -0
- package/dist/functions/platform/uniapp/detectAndroidProjectStructure.d.ts +11 -0
- package/dist/functions/platform/uniapp/detectAndroidProjectStructure.js +30 -0
- package/dist/functions/platform/uniapp/detectAndroidProjectStructure.js.map +1 -0
- package/dist/functions/platform/uniapp/detectProjectType.d.ts +20 -0
- package/dist/functions/platform/uniapp/detectProjectType.js +68 -0
- package/dist/functions/platform/uniapp/detectProjectType.js.map +1 -0
- package/dist/functions/platform/uniapp/parseManifest.d.ts +18 -0
- package/dist/functions/platform/uniapp/parseManifest.js +49 -0
- package/dist/functions/platform/uniapp/parseManifest.js.map +1 -0
- package/dist/functions/platform/uniapp/waitForPages.d.ts +7 -0
- package/dist/functions/platform/uniapp/waitForPages.js +20 -0
- package/dist/functions/platform/uniapp/waitForPages.js.map +1 -0
- package/dist/functions/principles/functionBind.d.ts +4 -0
- package/dist/functions/principles/functionBind.js +33 -0
- package/dist/functions/principles/functionBind.js.map +1 -0
- package/dist/functions/principles/myInstanceof.d.ts +5 -0
- package/dist/functions/principles/myInstanceof.js +56 -0
- package/dist/functions/principles/myInstanceof.js.map +1 -0
- package/dist/functions/principles/myNew.d.ts +3 -0
- package/dist/functions/principles/myNew.js +19 -0
- package/dist/functions/principles/myNew.js.map +1 -0
- package/dist/functions/software/findSoftware.d.ts +2 -2
- package/dist/functions/software/findSoftware.js +1 -1
- package/dist/functions/software/findSoftware.js.map +1 -1
- package/dist/functions/string/base64.d.ts +4 -1
- package/dist/functions/string/base64.js +2 -2
- package/dist/functions/string/base64.js.map +1 -1
- package/dist/functions/tencent-cloud/deploy.tcb.d.ts +12 -2
- package/dist/functions/tencent-cloud/deploy.tcb.js +7 -8
- package/dist/functions/tencent-cloud/deploy.tcb.js.map +1 -1
- package/dist/functions/uniapp/app-plus/buildAndroidApp.d.ts +27 -2
- package/dist/functions/uniapp/app-plus/buildAndroidApp.js +71 -29
- package/dist/functions/uniapp/app-plus/buildAndroidApp.js.map +1 -1
- package/dist/functions/uniapp/build.d.ts +9 -8
- package/dist/functions/uniapp/build.js +8 -9
- package/dist/functions/uniapp/build.js.map +1 -1
- package/dist/functions/uniapp/detectAndroidProjectStructure.d.ts +5 -1
- package/dist/functions/uniapp/detectAndroidProjectStructure.js +5 -5
- package/dist/functions/uniapp/detectAndroidProjectStructure.js.map +1 -1
- package/dist/functions/uniapp/detectProjectType.d.ts +8 -4
- package/dist/functions/uniapp/detectProjectType.js +20 -20
- package/dist/functions/uniapp/detectProjectType.js.map +1 -1
- package/dist/functions/uniapp/parseManifest.d.ts +7 -1
- package/dist/functions/uniapp/parseManifest.js +7 -4
- package/dist/functions/uniapp/parseManifest.js.map +1 -1
- package/dist/functions/uniapp/waitForPages.d.ts +6 -2
- package/dist/functions/uniapp/waitForPages.js +3 -3
- package/dist/functions/uniapp/waitForPages.js.map +1 -1
- package/dist/functions/utils/AVLTree.d.ts +19 -0
- package/dist/functions/utils/AVLTree.js +197 -0
- package/dist/functions/utils/AVLTree.js.map +1 -0
- package/dist/functions/utils/BinarySearchTree.d.ts +19 -0
- package/dist/functions/utils/BinarySearchTree.js +150 -0
- package/dist/functions/utils/BinarySearchTree.js.map +1 -0
- package/dist/functions/utils/EventEmitter.d.ts +32 -0
- package/dist/functions/utils/EventEmitter.js +108 -0
- package/dist/functions/utils/EventEmitter.js.map +1 -0
- package/dist/functions/utils/Graph.d.ts +19 -0
- package/dist/functions/utils/Graph.js +190 -0
- package/dist/functions/utils/Graph.js.map +1 -0
- package/dist/functions/utils/HashMap.d.ts +13 -0
- package/dist/functions/utils/HashMap.js +128 -0
- package/dist/functions/utils/HashMap.js.map +1 -0
- package/dist/functions/utils/Heap.d.ts +11 -0
- package/dist/functions/utils/Heap.js +91 -0
- package/dist/functions/utils/Heap.js.map +1 -0
- package/dist/functions/utils/LRUCache.d.ts +41 -0
- package/dist/functions/utils/LRUCache.js +182 -0
- package/dist/functions/utils/LRUCache.js.map +1 -0
- package/dist/functions/utils/LinkedList.d.ts +18 -0
- package/dist/functions/utils/LinkedList.js +135 -0
- package/dist/functions/utils/LinkedList.js.map +1 -0
- package/dist/functions/utils/MyPromise.d.ts +32 -0
- package/dist/functions/utils/MyPromise.js +254 -0
- package/dist/functions/utils/MyPromise.js.map +1 -0
- package/dist/functions/utils/PriorityQueue.d.ts +14 -0
- package/dist/functions/utils/PriorityQueue.js +77 -0
- package/dist/functions/utils/PriorityQueue.js.map +1 -0
- package/dist/functions/utils/Queue.d.ts +10 -0
- package/dist/functions/utils/Queue.js +27 -0
- package/dist/functions/utils/Queue.js.map +1 -0
- package/dist/functions/utils/Stack.d.ts +10 -0
- package/dist/functions/utils/Stack.js +27 -0
- package/dist/functions/utils/Stack.js.map +1 -0
- package/dist/functions/utils/Trie.d.ts +16 -0
- package/dist/functions/utils/Trie.js +127 -0
- package/dist/functions/utils/Trie.js.map +1 -0
- package/dist/functions/utils/UnionFind.d.ts +8 -0
- package/dist/functions/utils/UnionFind.js +53 -0
- package/dist/functions/utils/UnionFind.js.map +1 -0
- package/dist/functions/utils/createI18n.d.ts +2 -0
- package/dist/functions/utils/createI18n.js +97 -0
- package/dist/functions/utils/createI18n.js.map +1 -0
- package/dist/functions/utils/createReactive.d.ts +10 -0
- package/dist/functions/utils/createReactive.js +50 -0
- package/dist/functions/utils/createReactive.js.map +1 -0
- package/dist/functions/utils/curryAdvanced.d.ts +8 -0
- package/dist/functions/utils/curryAdvanced.js +87 -0
- package/dist/functions/utils/curryAdvanced.js.map +1 -0
- package/dist/functions/utils/debounce.d.ts +5 -1
- package/dist/functions/utils/debounce.js +3 -4
- package/dist/functions/utils/debounce.js.map +1 -1
- package/dist/functions/utils/deepClone.d.ts +12 -0
- package/dist/functions/utils/deepClone.js +131 -0
- package/dist/functions/utils/deepClone.js.map +1 -0
- package/dist/functions/utils/diff.d.ts +25 -0
- package/dist/functions/utils/diff.js +316 -0
- package/dist/functions/utils/diff.js.map +1 -0
- package/dist/functions/utils/flatten.d.ts +7 -0
- package/dist/functions/utils/flatten.js +60 -0
- package/dist/functions/utils/flatten.js.map +1 -0
- package/dist/functions/utils/flattenObject.d.ts +5 -0
- package/dist/functions/utils/flattenObject.js +102 -0
- package/dist/functions/utils/flattenObject.js.map +1 -0
- package/dist/functions/utils/formatString.d.ts +5 -0
- package/dist/functions/utils/formatString.js +9 -0
- package/dist/functions/utils/formatString.js.map +1 -0
- package/dist/functions/utils/functionBind.d.ts +4 -0
- package/dist/functions/utils/functionBind.js +33 -0
- package/dist/functions/utils/functionBind.js.map +1 -0
- package/dist/functions/utils/generateExports.d.ts +16 -6
- package/dist/functions/utils/generateExports.js +11 -11
- package/dist/functions/utils/generateExports.js.map +1 -1
- package/dist/functions/utils/generatorUtils.d.ts +16 -0
- package/dist/functions/utils/generatorUtils.js +139 -0
- package/dist/functions/utils/generatorUtils.js.map +1 -0
- package/dist/functions/utils/i18n.d.ts +27 -0
- package/dist/functions/utils/i18n.js +119 -0
- package/dist/functions/utils/i18n.js.map +1 -0
- package/dist/functions/utils/myInstanceof.d.ts +5 -0
- package/dist/functions/utils/myInstanceof.js +56 -0
- package/dist/functions/utils/myInstanceof.js.map +1 -0
- package/dist/functions/utils/myNew.d.ts +3 -0
- package/dist/functions/utils/myNew.js +19 -0
- package/dist/functions/utils/myNew.js.map +1 -0
- package/dist/functions/utils/permission.d.ts +40 -0
- package/dist/functions/utils/permission.js +189 -0
- package/dist/functions/utils/permission.js.map +1 -0
- package/dist/functions/utils/pinia.d.ts +52 -0
- package/dist/functions/utils/pinia.js +183 -0
- package/dist/functions/utils/pinia.js.map +1 -0
- package/dist/functions/utils/promiseLimit.d.ts +10 -0
- package/dist/functions/utils/promiseLimit.js +125 -0
- package/dist/functions/utils/promiseLimit.js.map +1 -0
- package/dist/functions/utils/retryWithBackoff.d.ts +4 -1
- package/dist/functions/utils/retryWithBackoff.js +2 -3
- package/dist/functions/utils/retryWithBackoff.js.map +1 -1
- package/dist/functions/utils/unique.d.ts +10 -0
- package/dist/functions/utils/unique.js +85 -0
- package/dist/functions/utils/unique.js.map +1 -0
- package/dist/functions/utils/validate.d.ts +4 -1
- package/dist/functions/utils/validate.js +2 -3
- package/dist/functions/utils/validate.js.map +1 -1
- package/dist/functions/utils/walk.d.ts +8 -2
- package/dist/functions/utils/walk.js +9 -10
- package/dist/functions/utils/walk.js.map +1 -1
- package/dist/functions/vue/dynamicMount.d.ts +3 -2
- package/dist/functions/vue/dynamicMount.js +6 -6
- package/dist/functions/vue/dynamicMount.js.map +1 -1
- package/dist/functions/wechat/miniapp/downloadFile.d.ts +5 -1
- package/dist/functions/wechat/miniapp/downloadFile.js +3 -3
- package/dist/functions/wechat/miniapp/downloadFile.js.map +1 -1
- package/dist/functions/xml/modifyXml.d.ts +9 -2
- package/dist/functions/xml/modifyXml.js +4 -4
- package/dist/functions/xml/modifyXml.js.map +1 -1
- package/dist/hooks/createGlobalState.d.ts +2 -0
- package/dist/hooks/createGlobalState.js +11 -0
- package/dist/hooks/createGlobalState.js.map +1 -0
- package/dist/hooks/createInjectionState.d.ts +14 -0
- package/dist/hooks/createInjectionState.js +20 -0
- package/dist/hooks/createInjectionState.js.map +1 -0
- package/dist/hooks/createSharedComposable.d.ts +2 -0
- package/dist/hooks/createSharedComposable.js +13 -0
- package/dist/hooks/createSharedComposable.js.map +1 -0
- package/dist/hooks/injectLocal.d.ts +10 -0
- package/dist/hooks/injectLocal.js +12 -0
- package/dist/hooks/injectLocal.js.map +1 -0
- package/dist/hooks/provideLocal.d.ts +9 -0
- package/dist/hooks/provideLocal.js +7 -0
- package/dist/hooks/provideLocal.js.map +1 -0
- package/dist/hooks/useAltool.d.ts +1 -1
- package/dist/hooks/useAltool.js +13 -13
- package/dist/hooks/useAltool.js.map +1 -1
- package/dist/hooks/useAsyncState.d.ts +30 -0
- package/dist/hooks/useAsyncState.js +46 -0
- package/dist/hooks/useAsyncState.js.map +1 -0
- package/dist/hooks/useDebouncedRefHistory.d.ts +22 -0
- package/dist/hooks/useDebouncedRefHistory.js +46 -0
- package/dist/hooks/useDebouncedRefHistory.js.map +1 -0
- package/dist/hooks/useDraggable.d.ts +14 -11
- package/dist/hooks/useDraggable.js +60 -80
- package/dist/hooks/useDraggable.js.map +1 -1
- package/dist/hooks/useLocalStorage.d.ts +5 -1
- package/dist/hooks/useLocalStorage.js +5 -4
- package/dist/hooks/useLocalStorage.js.map +1 -1
- package/dist/hooks/useManualRefHistory.d.ts +26 -0
- package/dist/hooks/useManualRefHistory.js +80 -0
- package/dist/hooks/useManualRefHistory.js.map +1 -0
- package/dist/hooks/usePermission.d.ts +7 -0
- package/dist/hooks/usePermission.js +123 -0
- package/dist/hooks/usePermission.js.map +1 -0
- package/dist/hooks/useRefHistory.d.ts +21 -0
- package/dist/hooks/useRefHistory.js +41 -0
- package/dist/hooks/useRefHistory.js.map +1 -0
- package/dist/hooks/useResizable.d.ts +14 -8
- package/dist/hooks/useResizable.js +40 -31
- package/dist/hooks/useResizable.js.map +1 -1
- package/dist/hooks/useSessionStorage.d.ts +5 -1
- package/dist/hooks/useSessionStorage.js +5 -4
- package/dist/hooks/useSessionStorage.js.map +1 -1
- package/dist/hooks/useStorage.d.ts +4 -1
- package/dist/hooks/useStorage.js +4 -4
- package/dist/hooks/useStorage.js.map +1 -1
- package/dist/hooks/useStorageWithIndexedDB.d.ts +5 -1
- package/dist/hooks/useStorageWithIndexedDB.js +24 -11
- package/dist/hooks/useStorageWithIndexedDB.js.map +1 -1
- package/dist/hooks/useWebWorker.d.ts +13 -13
- package/dist/hooks/useWebWorker.js +15 -17
- package/dist/hooks/useWebWorker.js.map +1 -1
- package/dist/hooks/useWorkerFunction.d.ts +15 -11
- package/dist/hooks/useWorkerFunction.js +16 -16
- package/dist/hooks/useWorkerFunction.js.map +1 -1
- package/dist/hooks/useWorkerPool.d.ts +15 -12
- package/dist/hooks/useWorkerPool.js +18 -13
- package/dist/hooks/useWorkerPool.js.map +1 -1
- package/package.json +50 -3
- package/references/browser.d.ts +28 -2
- package/references/dom.d.ts +45 -0
- package/references/indexeddb.d.ts +1 -0
- package/references/node.d.ts +42 -7
- package/references/vue.d.ts +161 -5
- package/references/xlsx.d.ts +51 -0
- package/types/android-build.d.ts +0 -22
- package/types/reactive.d.ts +67 -0
- package/types/tencent-cloud.d.ts +1 -9
- package/types/uniapp-android-build.d.ts +0 -21
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
export function createLinkedList() {
|
|
2
|
+
let head = null;
|
|
3
|
+
let length = 0;
|
|
4
|
+
return {
|
|
5
|
+
prepend(value) {
|
|
6
|
+
const newNode = { value, next: head };
|
|
7
|
+
head = newNode;
|
|
8
|
+
length++;
|
|
9
|
+
},
|
|
10
|
+
append(value) {
|
|
11
|
+
const newNode = { value, next: null };
|
|
12
|
+
if (!head) {
|
|
13
|
+
head = newNode;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
let current = head;
|
|
17
|
+
while (current.next) {
|
|
18
|
+
current = current.next;
|
|
19
|
+
}
|
|
20
|
+
current.next = newNode;
|
|
21
|
+
}
|
|
22
|
+
length++;
|
|
23
|
+
},
|
|
24
|
+
insertAt(index, value) {
|
|
25
|
+
if (index < 0 || index > length) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (index === 0) {
|
|
29
|
+
const newNode = { value, next: head };
|
|
30
|
+
head = newNode;
|
|
31
|
+
length++;
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
let current = head;
|
|
35
|
+
let prev = null;
|
|
36
|
+
let currentIndex = 0;
|
|
37
|
+
while (currentIndex < index && current) {
|
|
38
|
+
prev = current;
|
|
39
|
+
current = current.next;
|
|
40
|
+
currentIndex++;
|
|
41
|
+
}
|
|
42
|
+
if (prev) {
|
|
43
|
+
const newNode = { value, next: current };
|
|
44
|
+
prev.next = newNode;
|
|
45
|
+
length++;
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
},
|
|
50
|
+
removeAt(index) {
|
|
51
|
+
if (index < 0 || index >= length || !head) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
if (index === 0) {
|
|
55
|
+
const value = head.value;
|
|
56
|
+
head = head.next;
|
|
57
|
+
length--;
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
let current = head;
|
|
61
|
+
let prev = null;
|
|
62
|
+
let currentIndex = 0;
|
|
63
|
+
while (currentIndex < index && current) {
|
|
64
|
+
prev = current;
|
|
65
|
+
current = current.next;
|
|
66
|
+
currentIndex++;
|
|
67
|
+
}
|
|
68
|
+
if (prev && current) {
|
|
69
|
+
prev.next = current.next;
|
|
70
|
+
length--;
|
|
71
|
+
return current.value;
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
},
|
|
75
|
+
indexOf(value) {
|
|
76
|
+
let current = head;
|
|
77
|
+
let index = 0;
|
|
78
|
+
while (current) {
|
|
79
|
+
if (current.value === value) {
|
|
80
|
+
return index;
|
|
81
|
+
}
|
|
82
|
+
current = current.next;
|
|
83
|
+
index++;
|
|
84
|
+
}
|
|
85
|
+
return -1;
|
|
86
|
+
},
|
|
87
|
+
get(index) {
|
|
88
|
+
if (index < 0 || index >= length) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
let current = head;
|
|
92
|
+
let currentIndex = 0;
|
|
93
|
+
while (current && currentIndex < index) {
|
|
94
|
+
current = current.next;
|
|
95
|
+
currentIndex++;
|
|
96
|
+
}
|
|
97
|
+
return current?.value;
|
|
98
|
+
},
|
|
99
|
+
size() {
|
|
100
|
+
return length;
|
|
101
|
+
},
|
|
102
|
+
isEmpty() {
|
|
103
|
+
return length === 0;
|
|
104
|
+
},
|
|
105
|
+
clear() {
|
|
106
|
+
head = null;
|
|
107
|
+
length = 0;
|
|
108
|
+
},
|
|
109
|
+
toArray() {
|
|
110
|
+
const result = [];
|
|
111
|
+
let current = head;
|
|
112
|
+
while (current) {
|
|
113
|
+
result.push(current.value);
|
|
114
|
+
current = current.next;
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
},
|
|
118
|
+
reverse() {
|
|
119
|
+
if (!head || !head.next) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
let prev = null;
|
|
123
|
+
let current = head;
|
|
124
|
+
let next = null;
|
|
125
|
+
while (current) {
|
|
126
|
+
next = current.next;
|
|
127
|
+
current.next = prev;
|
|
128
|
+
prev = current;
|
|
129
|
+
current = next;
|
|
130
|
+
}
|
|
131
|
+
head = prev;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=LinkedList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkedList.js","sourceRoot":"","sources":["../../../src/functions/data-structures/LinkedList.ts"],"names":[],"mappings":"AAoEA,MAAM,UAAU,gBAAgB;IAC9B,IAAI,IAAI,GAAuB,IAAI,CAAA;IACnC,IAAI,MAAM,GAAG,CAAC,CAAA;IAEd,OAAO;QACL,O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,OAAO,CAAC,IAAI,GAAG,IAAI,CAAA;gBACnB,IAAI,GAAG,OAAO,CAAA;gBACd,OAAO,GAAG,IAAI,CAAA;YAChB,CAAC;YAED,IAAI,GAAG,IAAI,CAAA;QACb,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PriorityQueueItem<T> {
|
|
2
|
+
value: T;
|
|
3
|
+
priority: number;
|
|
4
|
+
}
|
|
5
|
+
export interface PriorityQueue<T> {
|
|
6
|
+
enqueue(item: T, priority: number): void;
|
|
7
|
+
dequeue(): T | undefined;
|
|
8
|
+
peek(): T | undefined;
|
|
9
|
+
size(): number;
|
|
10
|
+
isEmpty(): boolean;
|
|
11
|
+
clear(): void;
|
|
12
|
+
toArray(): PriorityQueueItem<T>[];
|
|
13
|
+
}
|
|
14
|
+
export declare function createPriorityQueue<T>(): PriorityQueue<T>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export function createPriorityQueue() {
|
|
2
|
+
const heap = [];
|
|
3
|
+
function getParentIndex(index) {
|
|
4
|
+
return Math.floor((index - 1) / 2);
|
|
5
|
+
}
|
|
6
|
+
function getLeftChildIndex(index) {
|
|
7
|
+
return 2 * index + 1;
|
|
8
|
+
}
|
|
9
|
+
function getRightChildIndex(index) {
|
|
10
|
+
return 2 * index + 2;
|
|
11
|
+
}
|
|
12
|
+
function swap(i, j) {
|
|
13
|
+
[heap[i], heap[j]] = [heap[j], heap[i]];
|
|
14
|
+
}
|
|
15
|
+
function heapifyUp(index) {
|
|
16
|
+
while (index > 0) {
|
|
17
|
+
const parentIndex = getParentIndex(index);
|
|
18
|
+
if (heap[index].priority >= heap[parentIndex].priority) {
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
swap(index, parentIndex);
|
|
22
|
+
index = parentIndex;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function heapifyDown(index) {
|
|
26
|
+
while (true) {
|
|
27
|
+
let smallest = index;
|
|
28
|
+
const leftIndex = getLeftChildIndex(index);
|
|
29
|
+
const rightIndex = getRightChildIndex(index);
|
|
30
|
+
if (leftIndex < heap.length && heap[leftIndex].priority < heap[smallest].priority) {
|
|
31
|
+
smallest = leftIndex;
|
|
32
|
+
}
|
|
33
|
+
if (rightIndex < heap.length && heap[rightIndex].priority < heap[smallest].priority) {
|
|
34
|
+
smallest = rightIndex;
|
|
35
|
+
}
|
|
36
|
+
if (smallest === index) {
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
swap(index, smallest);
|
|
40
|
+
index = smallest;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
enqueue(item, priority) {
|
|
45
|
+
heap.push({ value: item, priority });
|
|
46
|
+
heapifyUp(heap.length - 1);
|
|
47
|
+
},
|
|
48
|
+
dequeue() {
|
|
49
|
+
if (heap.length === 0) {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
if (heap.length === 1) {
|
|
53
|
+
return heap.pop().value;
|
|
54
|
+
}
|
|
55
|
+
const root = heap[0].value;
|
|
56
|
+
heap[0] = heap.pop();
|
|
57
|
+
heapifyDown(0);
|
|
58
|
+
return root;
|
|
59
|
+
},
|
|
60
|
+
peek() {
|
|
61
|
+
return heap[0]?.value;
|
|
62
|
+
},
|
|
63
|
+
size() {
|
|
64
|
+
return heap.length;
|
|
65
|
+
},
|
|
66
|
+
isEmpty() {
|
|
67
|
+
return heap.length === 0;
|
|
68
|
+
},
|
|
69
|
+
clear() {
|
|
70
|
+
heap.length = 0;
|
|
71
|
+
},
|
|
72
|
+
toArray() {
|
|
73
|
+
return [...heap].sort((a, b) => a.priority - b.priority);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=PriorityQueue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PriorityQueue.js","sourceRoot":"","sources":["../../../src/functions/data-structures/PriorityQueue.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CAAA;QACpB,CAAC;QAED,OAAO;YACL,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAA;QAC1B,CAAC;QAED,KAAK;YACH,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;QACjB,CAAC;QAED,OAAO;YACL,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAA;QAC1D,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function createQueue() {
|
|
2
|
+
const items = [];
|
|
3
|
+
return {
|
|
4
|
+
enqueue(item) {
|
|
5
|
+
items.push(item);
|
|
6
|
+
},
|
|
7
|
+
dequeue() {
|
|
8
|
+
return items.shift();
|
|
9
|
+
},
|
|
10
|
+
peek() {
|
|
11
|
+
return items[0];
|
|
12
|
+
},
|
|
13
|
+
size() {
|
|
14
|
+
return items.length;
|
|
15
|
+
},
|
|
16
|
+
isEmpty() {
|
|
17
|
+
return items.length === 0;
|
|
18
|
+
},
|
|
19
|
+
clear() {
|
|
20
|
+
items.length = 0;
|
|
21
|
+
},
|
|
22
|
+
toArray() {
|
|
23
|
+
return [...items];
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=Queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Queue.js","sourceRoot":"","sources":["../../../src/functions/data-structures/Queue.ts"],"names":[],"mappings":"AA8CA,MAAM,UAAU,WAAW;IACzB,MAAM,KAAK,GAAQ,EAAE,CAAA;IAErB,OAAO;QACL,OAAO,CAAC,IAAO;YACb,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAClB,CAAC;QAED,OAAO;YACL,OAAO,KAAK,CAAC,KAAK,EAAE,CAAA;QACtB,CAAC;QAED,IAAI;YACF,OAAO,KAAK,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;QAED,IAAI;YACF,OAAO,KAAK,CAAC,MAAM,CAAA;QACrB,CAAC;QAED,OAAO;YACL,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAA;QAC3B,CAAC;QAED,KAAK;YACH,KAAK,CAAC,MAAM,GAAG,CAAC,CAAA;QAClB,CAAC;QAED,OAAO;YACL,OAAO,CAAC,GAAG,KAAK,CAAC,CAAA;QACnB,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function createStack() {
|
|
2
|
+
const items = [];
|
|
3
|
+
return {
|
|
4
|
+
push(item) {
|
|
5
|
+
items.push(item);
|
|
6
|
+
},
|
|
7
|
+
pop() {
|
|
8
|
+
return items.pop();
|
|
9
|
+
},
|
|
10
|
+
peek() {
|
|
11
|
+
return items[items.length - 1];
|
|
12
|
+
},
|
|
13
|
+
size() {
|
|
14
|
+
return items.length;
|
|
15
|
+
},
|
|
16
|
+
isEmpty() {
|
|
17
|
+
return items.length === 0;
|
|
18
|
+
},
|
|
19
|
+
clear() {
|
|
20
|
+
items.length = 0;
|
|
21
|
+
},
|
|
22
|
+
toArray() {
|
|
23
|
+
return [...items].reverse();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=Stack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stack.js","sourceRoot":"","sources":["../../../src/functions/data-structures/Stack.ts"],"names":[],"mappings":"AA8CA,MAAM,UAAU,WAAW;IACzB,MAAM,KAAK,GAAQ,EAAE,CAAA;IAErB,OAAO;QACL,IAAI,CAAC,IAAO;YACV,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAClB,CAAC;QAED,GAAG;YACD,OAAO,KAAK,CAAC,GAAG,EAAE,CAAA;QACpB,CAAC;QAED,IAAI;YACF,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAChC,CAAC;QAED,IAAI;YACF,OAAO,KAAK,CAAC,MAAM,CAAA;QACrB,CAAC;QAED,OAAO;YACL,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAA;QAC3B,CAAC;QAED,KAAK;YACH,KAAK,CAAC,MAAM,GAAG,CAAC,CAAA;QAClB,CAAC;QAED,OAAO;YACL,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,EAAE,CAAA;QAC7B,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Global } from '../../../references/node.d';
|
|
1
|
+
import type { Console } from '../../../references/console.d';
|
|
3
2
|
export interface DebuggerColor {
|
|
4
3
|
color: string;
|
|
5
4
|
background: string;
|
|
6
5
|
}
|
|
6
|
+
export interface DebuggerDeps {
|
|
7
|
+
log: Console['log'];
|
|
8
|
+
error: Console['error'];
|
|
9
|
+
warn: Console['warn'];
|
|
10
|
+
info: Console['info'];
|
|
11
|
+
group: Console['group'];
|
|
12
|
+
groupCollapsed: Console['groupCollapsed'];
|
|
13
|
+
groupEnd: Console['groupEnd'];
|
|
14
|
+
trace: Console['trace'];
|
|
15
|
+
isDevelopment: () => boolean;
|
|
16
|
+
getDebugFlag: (flag: string) => boolean;
|
|
17
|
+
}
|
|
7
18
|
export interface DebuggerOptions {
|
|
8
19
|
flag: string;
|
|
9
20
|
color?: DebuggerColor;
|
|
@@ -18,4 +29,4 @@ export interface Debugger {
|
|
|
18
29
|
warn: (message: string, ...args: any[]) => void;
|
|
19
30
|
info: (message: string, ...args: any[]) => void;
|
|
20
31
|
}
|
|
21
|
-
export declare function createDebugger(options: DebuggerOptions,
|
|
32
|
+
export declare function createDebugger(options: DebuggerOptions, deps: DebuggerDeps): Debugger;
|
|
@@ -1,29 +1,6 @@
|
|
|
1
|
-
export function createDebugger(options,
|
|
1
|
+
export function createDebugger(options, deps) {
|
|
2
2
|
const { flag, color, force = false } = options;
|
|
3
3
|
let debugEnabled = null;
|
|
4
|
-
const isDevelopment = () => {
|
|
5
|
-
return 'window' in env
|
|
6
|
-
? Boolean(env.__DEV__)
|
|
7
|
-
: env.process?.env.NODE_ENV === 'development' || Boolean(env.__DEV__);
|
|
8
|
-
};
|
|
9
|
-
const checkBrowserDebug = (windowEnv) => {
|
|
10
|
-
try {
|
|
11
|
-
const urlParams = new windowEnv.URLSearchParams(windowEnv.location.search);
|
|
12
|
-
if (urlParams.has(flag))
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
}
|
|
17
|
-
try {
|
|
18
|
-
return windowEnv.localStorage?.getItem(flag) === 'true';
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
const checkNodeDebug = (nodeEnv) => {
|
|
25
|
-
return nodeEnv.process?.env.DEBUG?.includes(flag) ?? false;
|
|
26
|
-
};
|
|
27
4
|
const isDebugEnabled = () => {
|
|
28
5
|
if (debugEnabled !== null)
|
|
29
6
|
return debugEnabled;
|
|
@@ -31,13 +8,11 @@ export function createDebugger(options, env) {
|
|
|
31
8
|
debugEnabled = true;
|
|
32
9
|
return true;
|
|
33
10
|
}
|
|
34
|
-
if (!isDevelopment()) {
|
|
11
|
+
if (!deps.isDevelopment()) {
|
|
35
12
|
debugEnabled = false;
|
|
36
13
|
return false;
|
|
37
14
|
}
|
|
38
|
-
debugEnabled =
|
|
39
|
-
? checkBrowserDebug(env)
|
|
40
|
-
: checkNodeDebug(env);
|
|
15
|
+
debugEnabled = deps.getDebugFlag(flag);
|
|
41
16
|
return debugEnabled;
|
|
42
17
|
};
|
|
43
18
|
const styleString = color
|
|
@@ -50,10 +25,10 @@ export function createDebugger(options, env) {
|
|
|
50
25
|
if (!isDebugEnabled())
|
|
51
26
|
return;
|
|
52
27
|
if (color) {
|
|
53
|
-
|
|
28
|
+
deps[method](styledFlagLabel, styleString, message, ...args);
|
|
54
29
|
}
|
|
55
30
|
else {
|
|
56
|
-
|
|
31
|
+
deps[method](flagLabel, message, ...args);
|
|
57
32
|
}
|
|
58
33
|
};
|
|
59
34
|
};
|
|
@@ -65,24 +40,24 @@ export function createDebugger(options, env) {
|
|
|
65
40
|
group: (title, collapsed = false) => {
|
|
66
41
|
if (!isDebugEnabled())
|
|
67
42
|
return;
|
|
68
|
-
const method = collapsed ?
|
|
43
|
+
const method = collapsed ? deps.groupCollapsed : deps.group;
|
|
69
44
|
method(`${flagLabel} ${title}`);
|
|
70
45
|
},
|
|
71
46
|
groupEnd: () => {
|
|
72
47
|
if (!isDebugEnabled())
|
|
73
48
|
return;
|
|
74
|
-
|
|
49
|
+
deps.groupEnd();
|
|
75
50
|
},
|
|
76
51
|
trace: (message) => {
|
|
77
52
|
if (!isDebugEnabled())
|
|
78
53
|
return;
|
|
79
54
|
if (color) {
|
|
80
|
-
|
|
55
|
+
deps.log(styledFlagLabel, styleString, message);
|
|
81
56
|
}
|
|
82
57
|
else {
|
|
83
|
-
|
|
58
|
+
deps.log(flagLabel, message);
|
|
84
59
|
}
|
|
85
|
-
|
|
60
|
+
deps.trace();
|
|
86
61
|
}
|
|
87
62
|
};
|
|
88
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDebugger.js","sourceRoot":"","sources":["../../../src/functions/debug/createDebugger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createDebugger.js","sourceRoot":"","sources":["../../../src/functions/debug/createDebugger.ts"],"names":[],"mappings":"AAsFA,MAAM,UAAU,cAAc,CAAC,OAAwB,EAAE,IAAkB;IACzE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,EAAE,GAAG,OAAO,CAAA;IAG9C,IAAI,YAAY,GAAmB,IAAI,CAAA;IAKvC,MAAM,cAAc,GAAG,GAAY,EAAE;QACnC,IAAI,YAAY,KAAK,IAAI;YAAE,O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,KAAK,EAAE,EAAE;YAC1C,IAAI,CAAC,cAAc,EAAE;gBAAE,OAAM;YAE7B,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAA;YAC3D,MAAM,CAAC,GAAG,SAAS,IAAI,KAAK,EAAE,CAAC,CAAA;QACjC,CAAC;QAED,QAAQ,EAAE,GAAG,EAAE;YACb,IAAI,CAAC,cAAc,EAAE;gBAAE,OAAM;YAC7B,IAAI,CAAC,QAAQ,EAAE,CAAA;QACjB,CAAC;QAED,KAAK,EAAE,CAAC,OAAe,EAAE,EAAE;YACzB,IAAI,CAAC,cAAc,EAAE;gBAAE,OAAM;YAE7B,IAAI,KAAK,EAAE,CAAC;gBACV,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;YACjD,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;YAC9B,CAAC;YACD,IAAI,CAAC,KAAK,EAAE,CAAA;QACd,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Logger } from './parseDesignTokens';
|
|
2
|
+
import type { XLSXLibrary } from '../../../references/xlsx.d';
|
|
3
|
+
import type { FileSystem, Path } from '../../../references/node.d';
|
|
4
|
+
import type { Console } from '../../../references/console.d';
|
|
5
|
+
export interface BuildTokensDeps {
|
|
6
|
+
readFileSync: FileSystem['readFileSync'];
|
|
7
|
+
writeFileSync: FileSystem['writeFileSync'];
|
|
8
|
+
existsSync: FileSystem['existsSync'];
|
|
9
|
+
mkdirSync: FileSystem['mkdirSync'];
|
|
10
|
+
join: Path['join'];
|
|
11
|
+
resolve: Path['resolve'];
|
|
12
|
+
error: Console['error'];
|
|
13
|
+
log: Console['log'];
|
|
14
|
+
mixColors: (baseColor: string, overlayColor: string, overlayOpacity: number) => string;
|
|
15
|
+
}
|
|
16
|
+
export interface BuildConfig {
|
|
17
|
+
excelPath: string;
|
|
18
|
+
outputDir: string;
|
|
19
|
+
outputs: {
|
|
20
|
+
css?: {
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
filename?: string;
|
|
23
|
+
prefix?: string;
|
|
24
|
+
outputDir?: string;
|
|
25
|
+
};
|
|
26
|
+
scss?: {
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
filename?: string;
|
|
29
|
+
prefix?: string;
|
|
30
|
+
outputDir?: string;
|
|
31
|
+
};
|
|
32
|
+
less?: {
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
filename?: string;
|
|
35
|
+
prefix?: string;
|
|
36
|
+
outputDir?: string;
|
|
37
|
+
};
|
|
38
|
+
js?: {
|
|
39
|
+
enabled: boolean;
|
|
40
|
+
filename?: string;
|
|
41
|
+
exportName?: string;
|
|
42
|
+
outputDir?: string;
|
|
43
|
+
};
|
|
44
|
+
ts?: {
|
|
45
|
+
enabled: boolean;
|
|
46
|
+
filename?: string;
|
|
47
|
+
exportName?: string;
|
|
48
|
+
typeName?: string;
|
|
49
|
+
outputDir?: string;
|
|
50
|
+
};
|
|
51
|
+
json?: {
|
|
52
|
+
enabled: boolean;
|
|
53
|
+
filename?: string;
|
|
54
|
+
indent?: number;
|
|
55
|
+
outputDir?: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
generateReadme?: boolean;
|
|
59
|
+
readmeOutputDir?: string;
|
|
60
|
+
verbose?: boolean;
|
|
61
|
+
}
|
|
62
|
+
export interface BuildResult {
|
|
63
|
+
tokenCount: number;
|
|
64
|
+
files: Array<{
|
|
65
|
+
format: string;
|
|
66
|
+
filename: string;
|
|
67
|
+
size: number;
|
|
68
|
+
path: string;
|
|
69
|
+
}>;
|
|
70
|
+
outputDir: string;
|
|
71
|
+
}
|
|
72
|
+
export declare function buildTokens(config: BuildConfig, XLSX: XLSXLibrary, deps: BuildTokensDeps, logger?: Logger): BuildResult;
|
|
73
|
+
export declare function buildTokensSimple(excelPath: string, outputDir: string, XLSX: XLSXLibrary, deps: BuildTokensDeps, logger?: Logger, options?: {
|
|
74
|
+
verbose?: boolean;
|
|
75
|
+
formats?: Array<'css' | 'scss' | 'less' | 'js' | 'ts' | 'json'>;
|
|
76
|
+
}): BuildResult;
|