@breadstone-infrastructure/vite 0.0.170 → 0.0.171
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/CHANGELOG.md +188 -1
- package/package.json +3 -3
- package/2/plugins/LiveReloadPlugin.d.ts +0 -30
- package/2/plugins/LiveReloadPlugin.d.ts.map +0 -1
- package/2/plugins/LiveReloadPlugin.js +0 -57
- package/2/plugins/LiveReloadPlugin.js.map +0 -1
- package/2/plugins/LocalizatorPlugin.d.ts +0 -23
- package/2/plugins/LocalizatorPlugin.d.ts.map +0 -1
- package/2/plugins/LocalizatorPlugin.js +0 -93
- package/2/plugins/LocalizatorPlugin.js.map +0 -1
- package/2/plugins/StaticContentPlugin.d.ts +0 -37
- package/2/plugins/StaticContentPlugin.d.ts.map +0 -1
- package/2/plugins/StaticContentPlugin.js +0 -229
- package/2/plugins/StaticContentPlugin.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,190 @@
|
|
|
1
|
+
## 0.0.170 (2025-10-28)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- **release:** update release version to 0.0.169 ([77c58d1eea](https://github.com/RueDeRennes/mosaik/commit/77c58d1eea))
|
|
6
|
+
|
|
7
|
+
## 0.0.169 (2025-10-28)
|
|
8
|
+
|
|
9
|
+
### 🚀 Features
|
|
10
|
+
|
|
11
|
+
- **chat:** add author property to chat messages and update templates ([6e22d26e1d](https://github.com/RueDeRennes/mosaik/commit/6e22d26e1d))
|
|
12
|
+
|
|
13
|
+
### 🩹 Fixes
|
|
14
|
+
|
|
15
|
+
- **release:** update release version to 0.0.168 ([1434c7a9fd](https://github.com/RueDeRennes/mosaik/commit/1434c7a9fd))
|
|
16
|
+
|
|
17
|
+
## 0.0.168 (2025-10-26)
|
|
18
|
+
|
|
19
|
+
This was a version bump only for vite-plugins to align it with other projects, there were no code changes.
|
|
20
|
+
|
|
21
|
+
## 0.0.167 (2025-10-26)
|
|
22
|
+
|
|
23
|
+
This was a version bump only for vite-plugins to align it with other projects, there were no code changes.
|
|
24
|
+
|
|
25
|
+
## 0.0.166 (2025-10-26)
|
|
26
|
+
|
|
27
|
+
### 🩹 Fixes
|
|
28
|
+
|
|
29
|
+
- **package:** add missing newline at end of file ([4aa435a5b6](https://github.com/RueDeRennes/mosaik/commit/4aa435a5b6))
|
|
30
|
+
|
|
31
|
+
## 0.0.165 (2025-10-24)
|
|
32
|
+
|
|
33
|
+
### 🚀 Features
|
|
34
|
+
|
|
35
|
+
- **List:** add orientation property and update styles for flexible layout ([44aa6a89cb](https://github.com/RueDeRennes/mosaik/commit/44aa6a89cb))
|
|
36
|
+
|
|
37
|
+
## 0.0.164 (2025-10-24)
|
|
38
|
+
|
|
39
|
+
This was a version bump only for vite-plugins to align it with other projects, there were no code changes.
|
|
40
|
+
|
|
41
|
+
## 0.0.163 (2025-10-22)
|
|
42
|
+
|
|
43
|
+
### 🚀 Features
|
|
44
|
+
|
|
45
|
+
- add DateAgo and TimeAgo pipes, directives, and services for time-based formatting ([40c3e551ba](https://github.com/RueDeRennes/mosaik/commit/40c3e551ba))
|
|
46
|
+
|
|
47
|
+
## 0.0.162 (2025-10-22)
|
|
48
|
+
|
|
49
|
+
This was a version bump only for vite-plugins to align it with other projects, there were no code changes.
|
|
50
|
+
|
|
51
|
+
## 0.0.161 (2025-10-22)
|
|
52
|
+
|
|
53
|
+
This was a version bump only for vite-plugins to align it with other projects, there were no code changes.
|
|
54
|
+
|
|
55
|
+
## 0.0.160 (2025-10-21)
|
|
56
|
+
|
|
57
|
+
This was a version bump only for vite-plugins to align it with other projects, there were no code changes.
|
|
58
|
+
|
|
59
|
+
## 0.0.159 (2025-10-21)
|
|
60
|
+
|
|
61
|
+
### 🩹 Fixes
|
|
62
|
+
|
|
63
|
+
- correct typo in TODO comment in TemplateType.ts and adjust formatting in ModelKind.ts and ModelKindRegistry.ts ([c8bcbb7a65](https://github.com/RueDeRennes/mosaik/commit/c8bcbb7a65))
|
|
64
|
+
|
|
65
|
+
## 0.0.158 (2025-10-21)
|
|
66
|
+
|
|
67
|
+
### 🚀 Features
|
|
68
|
+
|
|
69
|
+
- add options for ListElement and update release version to 0.0.157 ([0a28367587](https://github.com/RueDeRennes/mosaik/commit/0a28367587))
|
|
70
|
+
|
|
71
|
+
### 🩹 Fixes
|
|
72
|
+
|
|
73
|
+
- correct typos in interface comments and update default configuration values ([dc58b1a35c](https://github.com/RueDeRennes/mosaik/commit/dc58b1a35c))
|
|
74
|
+
|
|
75
|
+
## 0.0.157 (2025-10-19)
|
|
76
|
+
|
|
77
|
+
### 🩹 Fixes
|
|
78
|
+
|
|
79
|
+
- add newline at end of file in package.json ([d0e684e967](https://github.com/RueDeRennes/mosaik/commit/d0e684e967))
|
|
80
|
+
|
|
81
|
+
## 0.0.156 (2025-10-17)
|
|
82
|
+
|
|
83
|
+
### 🩹 Fixes
|
|
84
|
+
|
|
85
|
+
- update release version to 0.0.156 in package.json ([323d1588b7](https://github.com/RueDeRennes/mosaik/commit/323d1588b7))
|
|
86
|
+
- update release version to 0.0.155 in package.json ([1f1946594c](https://github.com/RueDeRennes/mosaik/commit/1f1946594c))
|
|
87
|
+
|
|
88
|
+
## 0.0.155 (2025-10-16)
|
|
89
|
+
|
|
90
|
+
### 🩹 Fixes
|
|
91
|
+
|
|
92
|
+
- update release version to 0.0.154 in package.json ([d894b6b4a1](https://github.com/RueDeRennes/mosaik/commit/d894b6b4a1))
|
|
93
|
+
|
|
94
|
+
## 0.0.154 (2025-10-16)
|
|
95
|
+
|
|
96
|
+
### 🩹 Fixes
|
|
97
|
+
|
|
98
|
+
- remove deprecated -webkit-backdrop-filter from transition properties in theme styles refactor: simplify AutoCompleteBox styles for better maintainability chore: update release script to version 0.0.153 ([a7af7fe240](https://github.com/RueDeRennes/mosaik/commit/a7af7fe240))
|
|
99
|
+
|
|
100
|
+
## 0.0.153 (2025-10-15)
|
|
101
|
+
|
|
102
|
+
### 🩹 Fixes
|
|
103
|
+
|
|
104
|
+
- remove deprecated -webkit-backdrop-filter from transition properties in theme styles refactor: simplify AutoCompleteBox styles for better maintainability chore: update release script to version 0.0.153 ([a7af7fe240](https://github.com/RueDeRennes/mosaik/commit/a7af7fe240))
|
|
105
|
+
|
|
106
|
+
## 0.0.152 (2025-10-15)
|
|
107
|
+
|
|
108
|
+
This was a version bump only for vite-plugins to align it with other projects, there were no code changes.
|
|
109
|
+
|
|
110
|
+
## 0.0.151 (2025-09-29)
|
|
111
|
+
|
|
112
|
+
### 🚀 Features
|
|
113
|
+
|
|
114
|
+
- add wrap property to StackElement for flexible layout handling ([181634aa81](https://github.com/RueDeRennes/mosaik/commit/181634aa81))
|
|
115
|
+
|
|
116
|
+
## 0.0.150 (2025-09-29)
|
|
117
|
+
|
|
118
|
+
### 🩹 Fixes
|
|
119
|
+
|
|
120
|
+
- update release script version to 0.0.149 and adjust enum handling in modelClass function ([826e15bdf2](https://github.com/RueDeRennes/mosaik/commit/826e15bdf2))
|
|
121
|
+
|
|
122
|
+
## 0.0.149 (2025-09-25)
|
|
123
|
+
|
|
124
|
+
This was a version bump only for vite-plugins to align it with other projects, there were no code changes.
|
|
125
|
+
|
|
126
|
+
## 0.0.148 (2025-09-25)
|
|
127
|
+
|
|
128
|
+
This was a version bump only for vite-plugins to align it with other projects, there were no code changes.
|
|
129
|
+
|
|
130
|
+
## 0.0.147 (2025-09-25)
|
|
131
|
+
|
|
132
|
+
### 🩹 Fixes
|
|
133
|
+
|
|
134
|
+
- correct spelling of 'schema' in OpenApiParser logging ([1a75e6c62b](https://github.com/RueDeRennes/mosaik/commit/1a75e6c62b))
|
|
135
|
+
|
|
136
|
+
## 0.0.146 (2025-09-16)
|
|
137
|
+
|
|
138
|
+
### 🩹 Fixes
|
|
139
|
+
|
|
140
|
+
- update release script version to 0.0.145 and enhance logging output in TemplateBuilder ([c77501d259](https://github.com/RueDeRennes/mosaik/commit/c77501d259))
|
|
141
|
+
|
|
142
|
+
## 0.0.145 (2025-09-16)
|
|
143
|
+
|
|
144
|
+
### 🩹 Fixes
|
|
145
|
+
|
|
146
|
+
- update release version to 0.0.144 and improve type annotations in TemplateEngine ([c99a28f6b6](https://github.com/RueDeRennes/mosaik/commit/c99a28f6b6))
|
|
147
|
+
|
|
148
|
+
## 0.0.144 (2025-09-16)
|
|
149
|
+
|
|
150
|
+
### 🩹 Fixes
|
|
151
|
+
|
|
152
|
+
- correct spelling of 'preferred' in TemplateBuilder and related files ([5862673dc4](https://github.com/RueDeRennes/mosaik/commit/5862673dc4))
|
|
153
|
+
|
|
154
|
+
## 0.0.143 (2025-09-16)
|
|
155
|
+
|
|
156
|
+
### 🩹 Fixes
|
|
157
|
+
|
|
158
|
+
- update release script version to 0.0.142 ([b558893804](https://github.com/RueDeRennes/mosaik/commit/b558893804))
|
|
159
|
+
|
|
160
|
+
## 0.0.142 (2025-09-15)
|
|
161
|
+
|
|
162
|
+
This was a version bump only for vite-plugins to align it with other projects, there were no code changes.
|
|
163
|
+
|
|
164
|
+
## 0.0.141 (2025-09-14)
|
|
165
|
+
|
|
166
|
+
### 🚀 Features
|
|
167
|
+
|
|
168
|
+
- add comprehensive guidelines for code quality checks and testing standards across backend, frontend, and testing instructions ([9d9bcf13f9](https://github.com/RueDeRennes/mosaik/commit/9d9bcf13f9))
|
|
169
|
+
|
|
170
|
+
### 🩹 Fixes
|
|
171
|
+
|
|
172
|
+
- add missing newline at end of package.json ([3309d1ee97](https://github.com/RueDeRennes/mosaik/commit/3309d1ee97))
|
|
173
|
+
|
|
174
|
+
## 0.0.140 (2025-09-10)
|
|
175
|
+
|
|
176
|
+
This was a version bump only for vite-plugins to align it with other projects, there were no code changes.
|
|
177
|
+
|
|
178
|
+
## 0.0.139 (2025-09-08)
|
|
179
|
+
|
|
180
|
+
### 🚀 Features
|
|
181
|
+
|
|
182
|
+
- add reorderable and resizable properties to TileListItemElement and update related styles ([84672caf3a](https://github.com/RueDeRennes/mosaik/commit/84672caf3a))
|
|
183
|
+
|
|
184
|
+
## 0.0.138 (2025-09-07)
|
|
185
|
+
|
|
186
|
+
This was a version bump only for vite-plugins to align it with other projects, there were no code changes.
|
|
187
|
+
|
|
1
188
|
## 0.0.137 (2025-09-05)
|
|
2
189
|
|
|
3
190
|
### 🚀 Features
|
|
@@ -32,7 +219,7 @@
|
|
|
32
219
|
### 🚀 Features
|
|
33
220
|
|
|
34
221
|
- Add ThemeService for managing theme application and properties ([a3cb9be861](https://github.com/RueDeRennes/mosaik/commit/a3cb9be861))
|
|
35
|
-
- Add new Map and Thumbnail components with Cosmopolitan, Joy, and
|
|
222
|
+
- Add new Map and Thumbnail components with Cosmopolitan, Joy, and Memphis themes ([5142fee885](https://github.com/RueDeRennes/mosaik/commit/5142fee885))
|
|
36
223
|
- add serve scripts for app and API in package.json ([1ad4faa834](https://github.com/RueDeRennes/mosaik/commit/1ad4faa834))
|
|
37
224
|
|
|
38
225
|
## 0.0.132 (2025-08-24)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@breadstone-infrastructure/vite",
|
|
3
3
|
"description": "Vite configuration and plugins",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.171",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "andre.wehlert <awehlert@breadstone.de> (https://www.breadstone.de)",
|
|
7
7
|
"repository": {
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"module": "./Index.js",
|
|
13
13
|
"types": "./Index.d.ts",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@breadstone-infrastructure/utilities": "^0.0.
|
|
16
|
-
"@breadstone-tools/localizator-core": "^0.0.
|
|
15
|
+
"@breadstone-infrastructure/utilities": "^0.0.171",
|
|
16
|
+
"@breadstone-tools/localizator-core": "^0.0.171",
|
|
17
17
|
"gray-matter": "^4.0.3"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from 'vite';
|
|
2
|
-
/**
|
|
3
|
-
* Plugin configuration.
|
|
4
|
-
*/
|
|
5
|
-
export interface ILiveReloadPluginOptions {
|
|
6
|
-
/**
|
|
7
|
-
* File paths or glob patterns to watch.
|
|
8
|
-
*/
|
|
9
|
-
paths: string | Array<string>;
|
|
10
|
-
/**
|
|
11
|
-
* Whether the page should be reloaded regardless of which file is modified.
|
|
12
|
-
* @default false
|
|
13
|
-
*/
|
|
14
|
-
alwaysReload?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Whether to log when a file change triggered a live reload.
|
|
17
|
-
* @default true
|
|
18
|
-
*/
|
|
19
|
-
log?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* File paths will be resolved against this directory.
|
|
22
|
-
* @default ViteDevServer.root
|
|
23
|
-
*/
|
|
24
|
-
root?: string;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Live reload Vite plugin using `FileSystemWatcher`.
|
|
28
|
-
*/
|
|
29
|
-
export declare const liveReloadPlugin: (options: ILiveReloadPluginOptions) => Plugin;
|
|
30
|
-
//# sourceMappingURL=LiveReloadPlugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LiveReloadPlugin.d.ts","sourceRoot":"","sources":["../../../src/2/plugins/LiveReloadPlugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAMlD;;GAEG;AACH,MAAM,WAAW,wBAAwB;IAErC;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAE9B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,wBAAwB,KAAG,MA+CnE,CAAC"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// #region Imports
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { FileSystemWatcher } from '@breadstone-infrastructure/utilities';
|
|
4
|
-
/**
|
|
5
|
-
* Live reload Vite plugin using `FileSystemWatcher`.
|
|
6
|
-
*/
|
|
7
|
-
export const liveReloadPlugin = (options) => ({
|
|
8
|
-
name: 'vite-plugin-live-reload',
|
|
9
|
-
configureServer({ ws, config: { root: viteRoot, logger } }) {
|
|
10
|
-
const root = options.root ?? viteRoot;
|
|
11
|
-
if (!options.root) {
|
|
12
|
-
logger.info(`[vite-plugin-live-reload] No root specified, using Vite's root: ${viteRoot}`, {
|
|
13
|
-
clear: true,
|
|
14
|
-
timestamp: true
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
logger.info(`[vite-plugin-live-reload] Using root: ${root}`, {
|
|
19
|
-
clear: true,
|
|
20
|
-
timestamp: true
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
const logChanges = options.log ?? true;
|
|
24
|
-
const reload = (filePath) => {
|
|
25
|
-
ws.send({
|
|
26
|
-
type: 'full-reload',
|
|
27
|
-
path: options.alwaysReload ? '*' : filePath
|
|
28
|
-
});
|
|
29
|
-
if (logChanges) {
|
|
30
|
-
logger.info(`[vite-plugin-live-reload] Page reload ${getShortName(filePath, root)}`, {
|
|
31
|
-
clear: true,
|
|
32
|
-
timestamp: true
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
const watcher = new FileSystemWatcher({
|
|
37
|
-
path: root,
|
|
38
|
-
includeSubdirectories: true,
|
|
39
|
-
filter: options.paths
|
|
40
|
-
});
|
|
41
|
-
watcher.on('created', reload);
|
|
42
|
-
watcher.on('changed', reload);
|
|
43
|
-
watcher.on('deleted', reload);
|
|
44
|
-
watcher.start();
|
|
45
|
-
ws.on('close', () => watcher.stop());
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
/**
|
|
49
|
-
* Get the short name of the file relative to the root directory.
|
|
50
|
-
* @param file - The file path.
|
|
51
|
-
* @param root - The root directory.
|
|
52
|
-
* @returns The relative file path.
|
|
53
|
-
*/
|
|
54
|
-
function getShortName(file, root) {
|
|
55
|
-
return file.startsWith(`${root}/`) ? path.posix.relative(root, file) : file;
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=LiveReloadPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LiveReloadPlugin.js","sourceRoot":"","sources":["../../../src/2/plugins/LiveReloadPlugin.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAGlB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAiCzE;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAiC,EAAU,EAAE,CAAC,CAAC;IAC5E,IAAI,EAAE,yBAAyB;IAE/B,eAAe,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAiB;QACrE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,QAAQ,CAAC;QAEtC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAChB,MAAM,CAAC,IAAI,CAAC,mEAAmE,QAAQ,EAAE,EAAE;gBACvF,KAAK,EAAE,IAAI;gBACX,SAAS,EAAE,IAAI;aAClB,CAAC,CAAC;QACP,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,IAAI,CAAC,yCAAyC,IAAI,EAAE,EAAE;gBACzD,KAAK,EAAE,IAAI;gBACX,SAAS,EAAE,IAAI;aAClB,CAAC,CAAC;QACP,CAAC;QAED,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC;QAEvC,MAAM,MAAM,GAAG,CAAC,QAAgB,EAAQ,EAA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
export declare const VIRTUAL_MODULE_KEY = "virtual:localizator.ts";
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export interface ILocalizatorPluginOptions {
|
|
10
|
-
/**
|
|
11
|
-
* Directory containing resource files.
|
|
12
|
-
*/
|
|
13
|
-
paths: string | Array<string>;
|
|
14
|
-
verbose?: boolean;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Vite plugin to scan and transform resource files (e.g., `.resx`) into TypeScript components.
|
|
18
|
-
* To debug/view the generated components, navigate to `http://localhost:8080/@id/virtual:localizator.ts`.
|
|
19
|
-
*
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
export declare function localizatorPlugin(options: ILocalizatorPluginOptions): Plugin;
|
|
23
|
-
//# sourceMappingURL=LocalizatorPlugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalizatorPlugin.d.ts","sourceRoot":"","sources":["../../../src/2/plugins/LocalizatorPlugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqD,KAAK,MAAM,EAAE,MAAM,MAAM,CAAC;AAKtF;;GAEG;AACH,eAAO,MAAM,kBAAkB,2BAA2B,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,yBAAyB;IAEtC;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAE9B,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,yBAAyB,GAAG,MAAM,CAwF5E"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
// #region Imports
|
|
2
|
-
import { blue, Path, yellow, FileSystem } from '@breadstone-infrastructure/utilities';
|
|
3
|
-
import { createLogger } from 'vite';
|
|
4
|
-
import { ResourceMode, ResourceReader, ResourceTransformer } from '@breadstone-tools/localizator-core';
|
|
5
|
-
// #endregion
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export const VIRTUAL_MODULE_KEY = 'virtual:localizator.ts';
|
|
10
|
-
/**
|
|
11
|
-
* Vite plugin to scan and transform resource files (e.g., `.resx`) into TypeScript components.
|
|
12
|
-
* To debug/view the generated components, navigate to `http://localhost:8080/@id/virtual:localizator.ts`.
|
|
13
|
-
*
|
|
14
|
-
* @public
|
|
15
|
-
*/
|
|
16
|
-
export function localizatorPlugin(options) {
|
|
17
|
-
const logger = createLogger(undefined, { console: console });
|
|
18
|
-
const fileSystem = new FileSystem();
|
|
19
|
-
const reader = new ResourceReader(console, fileSystem);
|
|
20
|
-
const transformer = new ResourceTransformer(console);
|
|
21
|
-
return {
|
|
22
|
-
name: 'vite-plugin-localizator',
|
|
23
|
-
handleHotUpdate(ctx) {
|
|
24
|
-
if (ctx.file.endsWith('.resx')) {
|
|
25
|
-
const module = ctx.server.moduleGraph.getModuleById(VIRTUAL_MODULE_KEY);
|
|
26
|
-
logger.warn(`${yellow('[vite-plugin-localizator]:')} Virtual module: ${module?.id ?? 'not found'}`);
|
|
27
|
-
if (module) {
|
|
28
|
-
ctx.server.moduleGraph.invalidateModule(module);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
logger.warn(`${yellow('[vite-plugin-localizator]:')} Virtual module not found`);
|
|
32
|
-
}
|
|
33
|
-
ctx.server.ws.send({
|
|
34
|
-
type: 'full-reload',
|
|
35
|
-
path: '*'
|
|
36
|
-
});
|
|
37
|
-
logger.info(`${blue('[vite-plugin-localizator]:')} File updated: ${ctx.file}`);
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
configureServer(server) {
|
|
41
|
-
server.watcher.on('change', (path) => {
|
|
42
|
-
console.log(`[vite-plugin-localizator]: File changed: ${path}`);
|
|
43
|
-
});
|
|
44
|
-
const paths = Array.isArray(options.paths)
|
|
45
|
-
? options.paths
|
|
46
|
-
: [options.paths];
|
|
47
|
-
for (const globPattern of paths) {
|
|
48
|
-
const resolvedFiles = Path.glob(globPattern);
|
|
49
|
-
for (const file of resolvedFiles) {
|
|
50
|
-
server.watcher.add(file);
|
|
51
|
-
logger.info(`[vite-plugin-localizator]: Watching: ${file}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
resolveId(source) {
|
|
56
|
-
return source === VIRTUAL_MODULE_KEY
|
|
57
|
-
? source
|
|
58
|
-
: null;
|
|
59
|
-
},
|
|
60
|
-
load(id) {
|
|
61
|
-
if (id !== VIRTUAL_MODULE_KEY) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
const resxFiles = Path.glob(options.paths)
|
|
65
|
-
.filter((file) => file.endsWith('.resx'));
|
|
66
|
-
const contents = resxFiles.map((file) => {
|
|
67
|
-
logger.info(`[vite-plugin-localizator]: Found resource file: ${file}`);
|
|
68
|
-
const resource = reader.scanFile(file, ResourceMode.Resx);
|
|
69
|
-
if (!resource) {
|
|
70
|
-
logger.warn(`[vite-plugin-localizator]: Resource file not found or invalid: ${file}`);
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
logger.info(`[vite-plugin-localizator]: Scanned resource: ${resource.name} (${resource.locale})`);
|
|
74
|
-
const models = transformer.transform(resource);
|
|
75
|
-
const resourceInfo = transformer.serialize(models, {
|
|
76
|
-
locale: resource.locale,
|
|
77
|
-
name: '',
|
|
78
|
-
path: '',
|
|
79
|
-
target: 'ts'
|
|
80
|
-
});
|
|
81
|
-
return resourceInfo;
|
|
82
|
-
}).filter((x) => x !== null);
|
|
83
|
-
return `
|
|
84
|
-
${contents.map((x) => x.toString()).join('\n\n')}
|
|
85
|
-
|
|
86
|
-
export const translations = {
|
|
87
|
-
${contents.map((c) => `'${c.locale}': _${c.locale}`).join(',\n')},
|
|
88
|
-
};
|
|
89
|
-
`;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=LocalizatorPlugin.js.map
|
|
@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,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;;aAEnE,CAAC;QACN,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { type Plugin } from 'vite';
|
|
2
|
-
/**
|
|
3
|
-
* @public
|
|
4
|
-
*/
|
|
5
|
-
export declare const VIRTUAL_MODULE_KEY = "virtual:static-content.ts";
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export interface IStaticContentPluginOptions {
|
|
10
|
-
/**
|
|
11
|
-
* The current working directory.
|
|
12
|
-
*/
|
|
13
|
-
cwd?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Directory containing markdown files.
|
|
16
|
-
*/
|
|
17
|
-
paths: string | Array<string>;
|
|
18
|
-
/**
|
|
19
|
-
* Optional prefix for component selectors.
|
|
20
|
-
*/
|
|
21
|
-
prefix?: string;
|
|
22
|
-
/**
|
|
23
|
-
* Optional function to transform paths to URLs.
|
|
24
|
-
*/
|
|
25
|
-
pathTransform?: (path: string) => string;
|
|
26
|
-
verbose?: boolean;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Vite plugin to process Markdown files and expose a component registry, including subfolders.
|
|
30
|
-
* To debug/view the generated components, navigate to `http://localhost:8080/@id/virtual:static-content.ts`.
|
|
31
|
-
*
|
|
32
|
-
* @public
|
|
33
|
-
* @param options - Plugin options.
|
|
34
|
-
* @returns Vite plugin.
|
|
35
|
-
*/
|
|
36
|
-
export declare function staticContentPlugin(options: IStaticContentPluginOptions): Plugin;
|
|
37
|
-
//# sourceMappingURL=StaticContentPlugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StaticContentPlugin.d.ts","sourceRoot":"","sources":["../../../src/2/plugins/StaticContentPlugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgC,KAAK,MAAM,EAAoC,MAAM,MAAM,CAAC;AAKnG;;GAEG;AACH,eAAO,MAAM,kBAAkB,8BAA8B,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAExC;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAE9B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAEzC,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,2BAA2B,GAAG,MAAM,CA2HhF"}
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
// #region Imports
|
|
2
|
-
import { Path, File, red } from '@breadstone-infrastructure/utilities';
|
|
3
|
-
import { createLogger } from 'vite';
|
|
4
|
-
import matter from 'gray-matter';
|
|
5
|
-
// #endregion
|
|
6
|
-
/**
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export const VIRTUAL_MODULE_KEY = 'virtual:static-content.ts';
|
|
10
|
-
/**
|
|
11
|
-
* Vite plugin to process Markdown files and expose a component registry, including subfolders.
|
|
12
|
-
* To debug/view the generated components, navigate to `http://localhost:8080/@id/virtual:static-content.ts`.
|
|
13
|
-
*
|
|
14
|
-
* @public
|
|
15
|
-
* @param options - Plugin options.
|
|
16
|
-
* @returns Vite plugin.
|
|
17
|
-
*/
|
|
18
|
-
export function staticContentPlugin(options) {
|
|
19
|
-
const logger = createLogger();
|
|
20
|
-
return {
|
|
21
|
-
name: 'vite-plugin-static-content',
|
|
22
|
-
handleHotUpdate(ctx) {
|
|
23
|
-
if (ctx.file.endsWith('.md')) {
|
|
24
|
-
const module = ctx.server.moduleGraph.getModuleById(VIRTUAL_MODULE_KEY);
|
|
25
|
-
logger.warn(`[vite-plugin-static-content]: Virtual module: ${module?.id ?? 'not found'}`);
|
|
26
|
-
if (module) {
|
|
27
|
-
ctx.server.moduleGraph.invalidateModule(module);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
logger.warn('[vite-plugin-static-content]: Virtual module not found');
|
|
31
|
-
}
|
|
32
|
-
ctx.server.ws.send({
|
|
33
|
-
type: 'full-reload',
|
|
34
|
-
path: '*'
|
|
35
|
-
});
|
|
36
|
-
logger.info(`[vite-plugin-static-content]: File updated: ${ctx.file}`);
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
configureServer(server) {
|
|
40
|
-
server.watcher.on('change', (path) => {
|
|
41
|
-
if (options.verbose) {
|
|
42
|
-
console.log('[vite-plugin-static-content] Changed:', path);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
const paths = Array.isArray(options.paths) ? options.paths : [options.paths];
|
|
46
|
-
for (const globPattern of paths) {
|
|
47
|
-
const resolvedFiles = Path.glob(globPattern);
|
|
48
|
-
for (const file of resolvedFiles) {
|
|
49
|
-
server.watcher.add(file);
|
|
50
|
-
logger.info(`[vite-plugin-static-content]: Watching: ${file}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
resolveId(source) {
|
|
55
|
-
return source === VIRTUAL_MODULE_KEY
|
|
56
|
-
? source
|
|
57
|
-
: null;
|
|
58
|
-
},
|
|
59
|
-
load(id) {
|
|
60
|
-
if (id === VIRTUAL_MODULE_KEY) {
|
|
61
|
-
const mdFiles = Path.glob(options.paths)
|
|
62
|
-
.filter((file) => file.endsWith('.md'));
|
|
63
|
-
const sharedImports = `
|
|
64
|
-
import { html, LitElement } from 'lit';
|
|
65
|
-
import { customElement } from 'lit/decorators.js';
|
|
66
|
-
import { dateFormat, animate, Animate } from '@breadstone/mosaik-elements-foundation';
|
|
67
|
-
import { BlogBaseElement } from './src/Views/Blog/Abstracts/BlogBase';
|
|
68
|
-
import { Memoize } from './src/Decorators/MemoizeDecorator';
|
|
69
|
-
`.trim();
|
|
70
|
-
let componentsRegistry = 'const components = new Map();';
|
|
71
|
-
const components = mdFiles.map((x, i) => {
|
|
72
|
-
const cwd = options.cwd ?? process.cwd();
|
|
73
|
-
const relativeFilePath = Path.relative(cwd, x);
|
|
74
|
-
const componentName = generateComponentName(relativeFilePath, logger, options);
|
|
75
|
-
const content = File.readAllText(relativeFilePath, 'utf-8');
|
|
76
|
-
const meta = tryGetContentMeta(content, logger, options);
|
|
77
|
-
const contentWithoutMeta = removeMetadata(content);
|
|
78
|
-
const routePath = options.pathTransform
|
|
79
|
-
? options.pathTransform(relativeFilePath)
|
|
80
|
-
: relativeFilePath.replace(/\\/g, '/').replace(/\.md$/, '');
|
|
81
|
-
if (options.verbose) {
|
|
82
|
-
logger.info(`[vite-plugin-static-content]: File transformed: ${relativeFilePath} -> ${routePath}`, {
|
|
83
|
-
timestamp: true,
|
|
84
|
-
clear: true
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
const displayName = generateDisplayName(Path.getFileName(relativeFilePath));
|
|
88
|
-
const breadcrumbParts = routePath.split('/');
|
|
89
|
-
const componentCode = `
|
|
90
|
-
class MarkdownComponent${i} extends BlogBaseElement {
|
|
91
|
-
@Memoize()
|
|
92
|
-
protected get description(): ISampleDescription<AnchorElement> {
|
|
93
|
-
return {
|
|
94
|
-
title: '${displayName}',
|
|
95
|
-
breadcrumb: [${breadcrumbParts.map((part, idx) => `{
|
|
96
|
-
label: '${generateDisplayName(part)}',
|
|
97
|
-
href: '/${breadcrumbParts.slice(0, idx + 1).join('/')}'
|
|
98
|
-
}`).join(',\n')}],
|
|
99
|
-
estimatedReadTime: ${estimateReadTime(contentWithoutMeta)},
|
|
100
|
-
meta: components.get('${componentName}')?.meta,
|
|
101
|
-
content: \`${escapeStringForTemplate(contentWithoutMeta)}\`,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
customElements.define('${componentName}', MarkdownComponent${i});
|
|
107
|
-
`;
|
|
108
|
-
componentsRegistry += `
|
|
109
|
-
components.set('${componentName}', {
|
|
110
|
-
name: 'MarkdownComponent${i}',
|
|
111
|
-
displayName: '${typeof meta.title === 'string' ? escapeStringForTemplate(meta.title) : displayName}',
|
|
112
|
-
path: '${typeof meta.path === 'string' ? meta.path : `/${routePath}`}',
|
|
113
|
-
selector: '${componentName}',
|
|
114
|
-
meta: ${JSON.stringify(meta)}
|
|
115
|
-
});
|
|
116
|
-
`;
|
|
117
|
-
return componentCode;
|
|
118
|
-
}).join('\n');
|
|
119
|
-
return `
|
|
120
|
-
${sharedImports}
|
|
121
|
-
${componentsRegistry}
|
|
122
|
-
${components}
|
|
123
|
-
export default components;
|
|
124
|
-
`.trim();
|
|
125
|
-
}
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Generates a valid Lit component name, applying an optional prefix.
|
|
132
|
-
*
|
|
133
|
-
* @private
|
|
134
|
-
* @param fileName - The file name of the Markdown file
|
|
135
|
-
* @returns A valid component selector name.
|
|
136
|
-
*/
|
|
137
|
-
function generateComponentName(fileName, logger, options) {
|
|
138
|
-
// if (options.verbose) {
|
|
139
|
-
// logger.info(`[vite-plugin-static-content]: Generating component name for file: ${fileName}`);
|
|
140
|
-
// }
|
|
141
|
-
const baseName = fileName
|
|
142
|
-
.replace(/-md$/, '-doc') // Replace `.md` with `-doc`
|
|
143
|
-
.replace(/^(\.\.\/)+/, '') // Remove relative path indicators
|
|
144
|
-
.replace(/[^a-zA-Z0-9]/g, '-') // Replace unsupported characters with dashes
|
|
145
|
-
.toLowerCase();
|
|
146
|
-
// if (options.verbose) {
|
|
147
|
-
// logger.info(`[vite-plugin-static-content]: Generated component name: ${prefix}${baseName}`);
|
|
148
|
-
// }
|
|
149
|
-
return `${options.prefix ?? ''}${baseName}`;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Escapes special characters in a string to make it TypeScript string-safe.
|
|
153
|
-
*
|
|
154
|
-
* @private
|
|
155
|
-
* @param content - The string content to escape.
|
|
156
|
-
* @returns The escaped string.
|
|
157
|
-
*/
|
|
158
|
-
function escapeStringForTemplate(content) {
|
|
159
|
-
return content
|
|
160
|
-
.replace(/\\/g, '\\\\')
|
|
161
|
-
.replace(/`/g, '\\`')
|
|
162
|
-
.replace(/\${/g, '\\${')
|
|
163
|
-
.replace(/'/g, "\\'")
|
|
164
|
-
.replace(/"/g, '\\"');
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Converts a file or folder name to a user-friendly display name.
|
|
168
|
-
*
|
|
169
|
-
* @private
|
|
170
|
-
* @param segment - The file or folder name to convert.
|
|
171
|
-
* @returns A user-friendly display name.
|
|
172
|
-
*/
|
|
173
|
-
function generateDisplayName(segment) {
|
|
174
|
-
return segment
|
|
175
|
-
.replace(/-/g, ' ') // Replace dashes with spaces
|
|
176
|
-
.replace(/_/g, ' ') // Replace underscores with spaces
|
|
177
|
-
.replace(/\.[^/.]+$/, '') // Remove file extensions
|
|
178
|
-
.replace(/\b\w/g, (char) => char.toUpperCase()); // Capitalize the first letter of each word
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* @private
|
|
182
|
-
*/
|
|
183
|
-
function tryGetContentMeta(content, logger, options) {
|
|
184
|
-
try {
|
|
185
|
-
const parsed = matter(content);
|
|
186
|
-
// if (options.verbose) {
|
|
187
|
-
// logger.info(`[vite-plugin-static-content]: Parsed content meta: ${JSON.stringify(parsed.data)}`);
|
|
188
|
-
// }
|
|
189
|
-
return parsed.data;
|
|
190
|
-
}
|
|
191
|
-
catch (error) {
|
|
192
|
-
logger.error(`[vite-plugin-static-content]: ${red(`Failed to parse content meta: ${String(error)}`)}`);
|
|
193
|
-
return {};
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* @private
|
|
198
|
-
*/
|
|
199
|
-
function removeMetadata(content) {
|
|
200
|
-
const matterMatch = (/---\n([\s\S]*?)\n---/).exec(content);
|
|
201
|
-
if (matterMatch) {
|
|
202
|
-
return content.replace(matterMatch[0], '').trim();
|
|
203
|
-
}
|
|
204
|
-
return content.trim();
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Calculates estimated reading time for a given Markdown text.
|
|
208
|
-
*
|
|
209
|
-
* @private
|
|
210
|
-
* @param markdown - The Markdown content.
|
|
211
|
-
* @param wordsPerMinute - The average reading speed in words per minute (default: 200).
|
|
212
|
-
* @returns Estimated reading time in minutes.
|
|
213
|
-
*/
|
|
214
|
-
function estimateReadTime(markdown, wordsPerMinute = 100) {
|
|
215
|
-
if (!markdown) {
|
|
216
|
-
return 0;
|
|
217
|
-
}
|
|
218
|
-
// Strip out code blocks, front matter, and HTML tags
|
|
219
|
-
const textOnly = markdown
|
|
220
|
-
// .replace(/`{3}[\s\S]*?`{3}/g, '') // Remove code blocks
|
|
221
|
-
// .replace(/`[^`]*`/g, '') // Remove inline code
|
|
222
|
-
// .replace(/<[^>]+>/g, '') // Remove HTML tags
|
|
223
|
-
.replace(/---[\s\S]*?---/g, '') // Remove front matter
|
|
224
|
-
.replace(/\s+/g, ' ') // Normalize whitespace
|
|
225
|
-
.trim();
|
|
226
|
-
const wordCount = textOnly.split(' ').filter((word) => word.length > 0).length;
|
|
227
|
-
return Math.max(1, Math.ceil(wordCount / wordsPerMinute));
|
|
228
|
-
}
|
|
229
|
-
//# sourceMappingURL=StaticContentPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StaticContentPlugin.js","sourceRoot":"","sources":["../../../src/2/plugins/StaticContentPlugin.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAElB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAiE,YAAY,EAAE,MAAM,MA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