@lntvow/vite-plugin 1.1.11 → 1.1.13

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 (2) hide show
  1. package/dist/index.d.ts +50 -20
  2. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -6,7 +6,9 @@ import { Arrayable } from '@lntvow/utils';
6
6
  * It automatically writes the current build time and project version (read from package.json by default)
7
7
  * to localStorage and prints them to the console at runtime.
8
8
  *
9
- * This is useful for tracking deployment versions and build times in frontend projects.
9
+ * This is useful for tracking deployment versions and build times in frontend projects,
10
+ * making it easier to identify which version is currently deployed and when it was built.
11
+ *
10
12
  *
11
13
  * You can customize the localStorage key, version, timezone, and the entry files to inject via plugin options.
12
14
  *
@@ -18,27 +20,38 @@ import { Arrayable } from '@lntvow/utils';
18
20
  * vitePluginVersionLog(),
19
21
  * ],
20
22
  * }
23
+ *
24
+ * @remarks
25
+ * - Automatically reads version from package.json if not provided
26
+ * - Supports custom timezone for build time formatting
27
+ * - Configurable localStorage key name
28
+ * - Supports multiple entry files
21
29
  */
22
30
  declare function vitePluginVersionLog(options?: VersionLogOptions): PluginOption;
23
31
  interface VersionLogOptions {
24
32
  /**
25
- * The key used for localStorage.
33
+ * The key used for localStorage to store version information.
34
+ * The stored value will be a JSON array: [buildTime, version]
26
35
  * @default 'LNTVOW_VERSION'
27
36
  */
28
37
  name?: string;
29
38
  /**
30
- * Project version.
39
+ * Project version string.
40
+ * If not provided, the plugin will automatically read the version from package.json.
41
+ * If package.json is not found or doesn't contain a version, 'unknown' will be used.
31
42
  * @default Reads the version from package.json by default.
32
43
  */
33
44
  version?: string;
34
45
  /**
35
- * Timezone setting.
46
+ * Timezone setting for formatting the build time.
47
+ * Supports all timezone identifiers (e.g., 'UTC', 'America/New_York', 'Europe/London').
36
48
  * @default 'Asia/Shanghai'
37
49
  */
38
50
  timezone?: string;
39
51
  /**
40
- * The entry files to log.
41
- * The path is resolved from the command line working directory (process.cwd()).
52
+ * The entry files where version information will be injected.
53
+ * Can be a single file path string or an array of file paths.
54
+ * Paths are resolved from the command line working directory (process.cwd()).
42
55
  * @default ['src/main.ts', 'src/main.js']
43
56
  */
44
57
  entries?: Arrayable<string>;
@@ -46,12 +59,14 @@ interface VersionLogOptions {
46
59
 
47
60
  /**
48
61
  * This Vite plugin injects a diagonal environment ribbon into the built HTML page.
49
- * The ribbon displays the current environment (such as development, test, uat, pre.)
50
- * in the top-left or top-right corner of the page, similar to environment tags seen in some mobile app demos.
62
+ * The ribbon displays the current environment (such as development, uat, pre.)
63
+ * in the top-left or top-right corner of the page, similar to environment tags
64
+ * seen in some mobile app demos.
51
65
  *
52
- * The ribbon will NOT be injected when the current mode is 'production'.
66
+ * This is useful for quickly identifying the current environment during development
67
+ * and testing phases, helping prevent confusion between different deployment stages.
53
68
  *
54
- * You can customize the ribbon's width, height, font size, background color, text color, position, and environment label mapping via plugin options.
69
+ * The ribbon will NOT be injected when the current mode is 'production'.
55
70
  *
56
71
  * @example
57
72
  * import { vitePluginEnvRibbon } from '@lntvow/vite-plugin'
@@ -61,41 +76,56 @@ interface VersionLogOptions {
61
76
  * vitePluginEnvRibbon(),
62
77
  * ],
63
78
  * }
79
+ *
80
+ * @remarks
81
+ * - Automatically displays current environment mode
82
+ * - Customizable appearance (size, colors, position)
83
+ * - Environment label mapping support
84
+ * - Non-intrusive design (no pointer events)
85
+ * - Production-safe (automatically disabled)
64
86
  */
65
87
  declare function vitePluginEnvRibbon(options?: EnvRibbonOptions): PluginOption;
66
88
  interface EnvRibbonOptions {
67
89
  /**
68
- * The height of the banner.
69
- * @default 20
70
- */
71
- height?: number;
72
- /**
73
- * The width of the banner.
90
+ * The width of the ribbon.
74
91
  * @default 150
75
92
  */
76
93
  width?: number;
77
94
  /**
78
- * The font size of the banner text.
95
+ * The height of the ribbon.
96
+ * @default 20
97
+ */
98
+ height?: number;
99
+ /**
100
+ * The font size of the ribbon text.
79
101
  * @default 12
80
102
  */
81
103
  fontSize?: number;
82
104
  /**
83
- * The background color of the banner.
105
+ * The background color of the ribbon.
106
+ * Supports any valid CSS color value (hex, rgba, hsla, etc.).
84
107
  * @default 'hsla(0, 100%, 33%, 0.733)'
85
108
  */
86
109
  backgroundColor?: string;
87
110
  /**
88
- * The text color of the banner.
111
+ * The text color of the ribbon.
112
+ * Supports any valid CSS color value.
89
113
  * @default '#fff'
90
114
  */
91
115
  color?: string;
92
116
  /**
93
- * The position of the banner on the screen.
117
+ * The position of the ribbon on the screen.
94
118
  * @default 'top-right'
95
119
  */
96
120
  position?: 'top-right' | 'top-left';
97
121
  /**
98
122
  * The mapping of environment modes to display labels.
123
+ * The key is the Vite mode (e.g., 'development', 'staging', 'uat', 'pre'),
124
+ * and the value is the custom label to display on the ribbon.
125
+ *
126
+ * Used to customize the text shown for different environments.
127
+ * If a mode is not found in this mapping, the original mode name will be displayed.
128
+ *
99
129
  * @default {}
100
130
  */
101
131
  envMap?: Record<string, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lntvow/vite-plugin",
3
- "version": "1.1.11",
3
+ "version": "1.1.13",
4
4
  "type": "module",
5
5
  "description": "Collection of custom vite plugins",
6
6
  "keywords": [
@@ -23,13 +23,13 @@
23
23
  "import": "./dist/index.mjs"
24
24
  },
25
25
  "dependencies": {
26
- "@lntvow/utils": "^4.3.1",
26
+ "@lntvow/utils": "^4.3.4",
27
27
  "dayjs": "^1.11.13"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@commitlint/cli": "^19.8.1",
31
31
  "@commitlint/config-conventional": "^19.8.1",
32
- "@lntvow/eslint-config": "^9.29.0",
32
+ "@lntvow/eslint-config": "^9.29.1",
33
33
  "bumpp": "^10.2.0",
34
34
  "commitizen": "^4.3.1",
35
35
  "cz-conventional-changelog": "^3.3.0",