global.d.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright (c) 2024 LangChat. TyCoding All Rights Reserved.
  3. *
  4. * Licensed under the GNU Affero General Public License, Version 3 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * https://www.gnu.org/licenses/agpl-3.0.html
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import type {
  17. ComponentPublicInstance,
  18. ComponentRenderProxy,
  19. FunctionalComponent,
  20. PropType as VuePropType,
  21. VNode,
  22. VNodeChild,
  23. } from 'vue';
  24. declare global {
  25. const __APP_INFO__: {
  26. pkg: {
  27. name: string;
  28. version: string;
  29. dependencies: Recordable<string>;
  30. devDependencies: Recordable<string>;
  31. };
  32. lastBuildTime: string;
  33. };
  34. // declare interface Window {
  35. // // Global vue app instance
  36. // __APP__: App<Element>;
  37. // }
  38. // vue
  39. declare type PropType<T> = VuePropType<T>;
  40. declare type VueNode = VNodeChild | JSX.Element;
  41. export type Writable<T> = {
  42. -readonly [P in keyof T]: T[P];
  43. };
  44. declare type Nullable<T> = T | null;
  45. declare type NonNullable<T> = T extends null | undefined ? never : T;
  46. declare type Recordable<T = any> = Record<string, T>;
  47. declare type ReadonlyRecordable<T = any> = {
  48. readonly [key: string]: T;
  49. };
  50. declare type Indexable<T = any> = {
  51. [key: string]: T;
  52. };
  53. declare type DeepPartial<T> = {
  54. [P in keyof T]?: DeepPartial<T[P]>;
  55. };
  56. declare type TimeoutHandle = ReturnType<typeof setTimeout>;
  57. declare type IntervalHandle = ReturnType<typeof setInterval>;
  58. declare interface ChangeEvent extends Event {
  59. target: HTMLInputElement;
  60. }
  61. declare interface WheelEvent {
  62. path?: EventTarget[];
  63. }
  64. interface ImportMetaEnv extends ViteEnv {
  65. __: unknown;
  66. }
  67. declare interface ViteEnv {
  68. VITE_PORT: number;
  69. VITE_PUBLIC_PATH: string;
  70. VITE_GLOB_APP_TITLE: string;
  71. VITE_GLOB_APP_SHORT_NAME: string;
  72. VITE_DROP_CONSOLE: boolean;
  73. VITE_GLOB_IMG_URL: string;
  74. VITE_PROXY: [string, string][];
  75. VITE_BUILD_COMPRESS: 'gzip' | 'brotli' | 'none';
  76. VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE: boolean;
  77. }
  78. declare function parseInt(s: string | number, radix?: number): number;
  79. declare function parseFloat(string: string | number): number;
  80. namespace JSX {
  81. // tslint:disable no-empty-interface
  82. type Element = VNode;
  83. // tslint:disable no-empty-interface
  84. type ElementClass = ComponentRenderProxy;
  85. interface ElementAttributesProperty {
  86. $props: any;
  87. }
  88. interface IntrinsicElements {
  89. [elem: string]: any;
  90. }
  91. interface IntrinsicAttributes {
  92. [elem: string]: any;
  93. }
  94. }
  95. }
  96. declare module 'vue' {
  97. export type JSXComponent<Props = any> =
  98. | { new (): ComponentPublicInstance<Props> }
  99. | FunctionalComponent<Props>;
  100. }