elcrm 1.1.12 → 1.1.14
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.
|
@@ -50,7 +50,7 @@ export declare function replaceCssVarToken(
|
|
|
50
50
|
to: string,
|
|
51
51
|
): string;
|
|
52
52
|
|
|
53
|
-
/** Имена
|
|
53
|
+
/** Имена из `var(--token)` в CSS. Не селекторы BEM. */
|
|
54
54
|
export declare function collectCssVarNames(texts: string[]): string[];
|
|
55
55
|
|
|
56
56
|
/** Один словарь: длинные `--*` первыми, граница токена (CSS и JS). */
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// src/vite/minify-css-vars.ts
|
|
2
|
-
var
|
|
3
|
-
var VAR_IN_JS_RE = /var\(\s*(--[a-zA-Z_][\w-]*)|["'](--[a-zA-Z_][\w-]*)["']|(?<![\w-])(--[a-zA-Z_][\w-]*)\s*:/g;
|
|
2
|
+
var VAR_USE_RE = /var\(\s*(--[a-zA-Z_][\w-]*)/g;
|
|
4
3
|
var CLASS_SEL_RE = /\.(-?[_a-zA-Z]+[_a-zA-Z0-9-]*)/g;
|
|
5
4
|
var LETTERS = "abcdefghijklmnopqrstuvwxyz";
|
|
6
5
|
function collect(texts, re) {
|
|
@@ -15,21 +14,6 @@ function collect(texts, re) {
|
|
|
15
14
|
}
|
|
16
15
|
return set;
|
|
17
16
|
}
|
|
18
|
-
function collectJsVars(texts) {
|
|
19
|
-
const set = new Set;
|
|
20
|
-
for (const text of texts) {
|
|
21
|
-
if (!text)
|
|
22
|
-
continue;
|
|
23
|
-
VAR_IN_JS_RE.lastIndex = 0;
|
|
24
|
-
let m;
|
|
25
|
-
while (m = VAR_IN_JS_RE.exec(text)) {
|
|
26
|
-
const name = m[1] ?? m[2] ?? m[3];
|
|
27
|
-
if (name && !/^--[a-zA-Z_]{1,3}$/.test(name))
|
|
28
|
-
set.add(name);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return set;
|
|
32
|
-
}
|
|
33
17
|
function toIndex(value, fallback = 0) {
|
|
34
18
|
const n = typeof value === "number" ? value : Number(value);
|
|
35
19
|
if (!Number.isFinite(n) || n < 0)
|
|
@@ -112,7 +96,7 @@ function replaceCssVarToken(text, from, to) {
|
|
|
112
96
|
return text.replace(new RegExp(`(?<![\\w-])${escapeRe(from)}(?![\\w-])`, "g"), to);
|
|
113
97
|
}
|
|
114
98
|
function collectCssVarNames(texts) {
|
|
115
|
-
return [...collect(texts,
|
|
99
|
+
return [...collect(texts, VAR_USE_RE)].sort();
|
|
116
100
|
}
|
|
117
101
|
function applyVarDictionary(text, map) {
|
|
118
102
|
const entries = [...map].sort((a, b) => b[0].length - a[0].length || a[0].localeCompare(b[0]));
|
|
@@ -199,13 +183,9 @@ function minifyCssVars(options) {
|
|
|
199
183
|
files.push({ item, fileName, raw, isCss, isJs });
|
|
200
184
|
}
|
|
201
185
|
const cssTexts = files.filter((f) => f.isCss).map((f) => f.raw);
|
|
202
|
-
const jsTexts = files.filter((f) => f.isJs && !isVendorJsChunk(f.raw)).map((f) => f.raw);
|
|
203
186
|
const varMap = new Map;
|
|
204
187
|
if (opt.vars) {
|
|
205
|
-
const names =
|
|
206
|
-
...collect(cssTexts, VAR_RE),
|
|
207
|
-
...collectJsVars(jsTexts)
|
|
208
|
-
]);
|
|
188
|
+
const names = collect(cssTexts, VAR_USE_RE);
|
|
209
189
|
const remap = [];
|
|
210
190
|
const reserved = new Set;
|
|
211
191
|
for (const name of names) {
|
package/package.json
CHANGED
|
@@ -92,17 +92,16 @@ elcrm test --front|--server|--no-scripts
|
|
|
92
92
|
|
|
93
93
|
### Vite-плагины из пакета `elcrm`
|
|
94
94
|
|
|
95
|
-
Нужен **elcrm ≥ 1.1.
|
|
95
|
+
Нужен **elcrm ≥ 1.1.13** в `devDependencies` приложения (не только глобальный `bun i -g`).
|
|
96
96
|
|
|
97
97
|
```js
|
|
98
98
|
import { minifyCssVars } from "elcrm/vite/minify-css-vars";
|
|
99
99
|
|
|
100
|
-
// только command === "build";
|
|
100
|
+
// только command === "build"; словарь из CSS `var(--name)`, замена от длинных к коротким
|
|
101
101
|
minifyCssVars({ var: 2 })
|
|
102
|
-
// classes: true — только если нет className={\`foo--${x}\`}
|
|
103
102
|
```
|
|
104
103
|
|
|
105
|
-
|
|
104
|
+
Словарь: только `var(--name)` в `.css`. Потом `--name` → `--aa` в CSS и в JS (тот же список), **сначала длинные** (`--eeerere-pading-sdsdwwe` → … → `--eeerere`). Граница токена: `.account--wide` не `--wide`. JSZip не трогаем. **`classes: true` нельзя** при `foo--${x}`.
|
|
106
105
|
|
|
107
106
|
Короткие имена **уникальны и подряд**: `--aa`, `--ab`, `--ac`… Занятые слоты пропускаются; `--field` не затирает `--field-border`. Чанки JSZip не минифицируются (декремент `--n`). Если слотов нет — сборка падает.
|
|
108
107
|
|
|
@@ -39,8 +39,10 @@ Env: `TOKEN` / `JWT_SECRET`, `CORS_ORIGINS` (origins **без path**, через
|
|
|
39
39
|
| `@elcrm/db` `@elcrm/jwt` `@elcrm/cron` `@elcrm/tb` | `@elcrm/server/db` `/jwt` `/cron` `/tb` |
|
|
40
40
|
| `createServerFromEnv` | `createServer()` |
|
|
41
41
|
| `createJwtFromEnv` / `createCronFromEnv` / `createTbFromEnv` | `createJWT` / `createCron` / `createTb` |
|
|
42
|
-
| `createWsHub` / `serverConnect` | `createSocket("ws").use(…)` |
|
|
42
|
+
| `createWsHub` / `serverConnect` / `createServer({ websocket: { handlers } })` | `createSocket("ws").use(…)` до `createServer` |
|
|
43
43
|
| `hub.sendListen` | `sendSocket` |
|
|
44
|
+
| свой `fetch` на `api.telegram.org` | `tb.sendMessage` / `tb.use` |
|
|
45
|
+
| `CORS_ORIGINS` для origins из БД | `cors({ resolveOrigin })` |
|
|
44
46
|
| `Cron.useJob` / namespace `Cron` | `cron.use` |
|
|
45
47
|
| REST `path === "/api/…"` / `handle*(ctx): Promise<Response>` | `createRouter().use()` |
|
|
46
48
|
| `nodemailer` / `web-push` | `@elcrm/server/mail` / `notifications` |
|