@massimo-cassandro/minimo 1.41.3 → 1.41.5
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 +12 -12
- package/charts/src/node-helpers/create-svg-canvas-node.mjs +2 -2
- package/charts/src/node-helpers/svg-text-to-path.js +9 -9
- package/charts/src/rating-display/index.js +1 -1
- package/charts/src/rating-display/ratindDisplayAnimation.js +3 -3
- package/design-tokens/README.md +2 -2
- package/design-tokens/_src/_readme.md +26 -26
- package/dev-tools/README.md +16 -16
- package/dev-tools/create-favicons/README.md +31 -31
- package/dev-tools/create-favicons/src/create-ico.mjs +2 -2
- package/dev-tools/create-favicons/src/default-params.mjs +1 -1
- package/dev-tools/create-favicons/src/init.mjs +1 -1
- package/dev-tools/design-tokens-builder/README.md +102 -102
- package/dev-tools/design-tokens-builder/build-tokens-src/build-source-modes.mjs +85 -73
- package/dev-tools/design-tokens-builder/build-tokens-src/config.mjs +109 -85
- package/dev-tools/design-tokens-builder/build-tokens-src/formats/css.mjs +113 -90
- package/dev-tools/design-tokens-builder/build-tokens-src/formats/json.mjs +107 -95
- package/dev-tools/design-tokens-builder/build-tokens-src/legacy-tokens-parser.mjs +71 -64
- package/dev-tools/design-tokens-builder/build-tokens-src/light-dark.mjs +75 -65
- package/dev-tools/design-tokens-builder/build-tokens-src/merge-css.mjs +113 -102
- package/dev-tools/design-tokens-builder/build-tokens-src/platforms.mjs +36 -30
- package/dev-tools/design-tokens-builder/build-tokens-src/resolve-source-paths.mjs +15 -13
- package/dev-tools/design-tokens-builder/build-tokens-src/source-prefixes.mjs +44 -42
- package/dev-tools/design-tokens-builder/build-tokens-src/source-transforms.mjs +89 -83
- package/dev-tools/design-tokens-builder/build-tokens-src/token-rename-parser.mjs +99 -86
- package/dev-tools/design-tokens-builder/build-tokens-src/transforms.mjs +64 -48
- package/dev-tools/design-tokens-builder/build-tokens.mjs +80 -68
- package/dev-tools/design-tokens-builder/check-unresolved-custom-props.mjs +103 -77
- package/dev-tools/design-tokens-builder/tokens-config-sample.mjs +275 -238
- package/dev-tools/find-orphan-css-classes/find-orphan-css-classes.mjs +2 -2
- package/dev-tools/starter-kit/source_files/app/CLAUDE.md +4 -2
- package/dev-tools/starter-kit/source_files/app/index.css +10 -0
- package/dev-tools/starter-kit/source_files/app/index.js +1 -1
- package/dev-tools/starter-kit/source_files/root/_sf/controller/ImgViewerController.php +3 -3
- package/dev-tools/starter-kit/source_files/root/_sf/controller/ViewerController.php +2 -2
- package/dev-tools/starter-kit/source_files/root/stylelint.config.mjs +1 -1
- package/dev-tools/starter-kit/source_files/root/webpack-config-modules/css-rules.mjs +1 -1
- package/dev-tools/starter-kit/starter-install.sh +2 -2
- package/dev-tools/stylelint-config/README.md +7 -7
- package/dev-tools/svg-icons-tools/README.md +32 -32
- package/dev-tools/svg-icons-tools/src/config-manager.mjs +1 -1
- package/dev-tools/svg-icons-tools/src/default-config.mjs +118 -118
- package/dev-tools/svg-icons-tools/src/jsx-icon-file-builder.mjs +24 -24
- package/dev-tools/svg-icons-tools/src/parse-svg-filename.mjs +3 -3
- package/dev-tools/svg-icons-tools/src/parse-svg-files.mjs +1 -1
- package/dev-tools/svg-icons-tools/src/parse-svg-markup.mjs +4 -4
- package/dev-tools/svg-icons-tools/src/svg-to-jsx.mjs +2 -2
- package/dev-tools/svg-icons-tools/src/svg-to-optimized.mjs +2 -2
- package/dev-tools/svg-icons-tools/src/svg-to-symbols.mjs +2 -2
- package/dev-tools/upd@m/README.md +1 -1
- package/dev-tools/upd@m/index.mjs +1 -1
- package/dev-tools/update-version/README.md +9 -9
- package/index.js +1 -0
- package/package.json +3 -1
- package/snippets/unsplash-browser-app/README.md +1 -1
- package/snippets/unsplash-browser-app/unsplash-utilities.js +9 -9
- package/src/components/autocomplete/README.md +3 -3
- package/src/components/autocomplete/autocomplete-engine.js +75 -63
- package/src/components/autocomplete/check-autocomplete.js +3 -3
- package/src/components/dismiss-alerts.js +3 -3
- package/src/components/form-reset-submit.js +6 -6
- package/src/components/inner-nav/inner-nav.js +2 -2
- package/src/components/modal-alert/modal-alert.js +67 -65
- package/src/components/modal-alert/modal-alert.minimo.tokens.mjs +1 -1
- package/src/components/modal-popup/modal-popup.js +56 -56
- package/src/components/overlay/overlay.js +3 -3
- package/src/components/sf-macro/readme.md +1 -1
- package/src/components/sf-macro/sf-macro.js +27 -23
- package/src/components/slide-up-down-toggle/slide-up-down-toggle.js +83 -79
- package/src/components/slide-up-down-toggle/slide-up-down-toggle.module.css +44 -44
- package/src/components/snackbar/snackbar.js +19 -19
- package/src/components/spinner/spinner.js +3 -3
- package/src/components/unsplash-page/README.md +8 -8
- package/src/components/unsplash-page/fetch-unsplash-data.js +3 -3
- package/src/components/unsplash-page/unsplash-page.js +33 -33
- package/src/components/unsplash-page/unsplash-page.module.css +1 -1
- package/src/css/alerts.css +2 -2
- package/src/css/forms/forms.css +4 -4
- package/src/css/forms/validation.css +1 -1
- package/src/css/margin-padding-media.css +4 -4
- package/src/css/margin-padding.css +4 -4
- package/src/css/reset.css +11 -11
- package/src/icons/read-me.md +1 -1
- package/src/minimo.css +3 -9
- package/src/utilities/better-text-with-places.js +105 -105
- package/src/utilities/better-text.js +42 -35
- package/src/utilities/classnames.js +8 -8
- package/src/utilities/cookies.js +6 -6
- package/src/utilities/create-id.js +3 -3
- package/src/utilities/disable-btns-on-submit.js +2 -2
- package/src/utilities/dom-builder/dom-builder.js +89 -86
- package/src/utilities/dom-builder/domBuilderBasicSetup.js +9 -9
- package/src/utilities/dom-builder/parseDomString.js +23 -23
- package/src/utilities/dom-builder-helpers/README.md +2 -2
- package/src/utilities/dom-builder-helpers/form-tags.js +100 -100
- package/src/utilities/dom-builder-helpers/picture-tag.js +39 -39
- package/src/utilities/enable-submit-btns.js +1 -1
- package/src/utilities/escape-html.js +2 -2
- package/src/utilities/generate-pwd.js +4 -4
- package/src/utilities/linked-dates.js +13 -13
- package/src/utilities/parse-file-size.js +6 -6
- package/src/utilities/random-id.js +3 -3
- package/src/utilities/relative-date.js +40 -40
- package/src/utilities/sentence-case.js +1 -1
- package/src/utilities/strip-tags.js +1 -1
- package/src/utilities/title-case.js +1 -1
- package/src/utilities/truncate-string.js +5 -5
- package/src/utilities/validation-error-class.js +12 -12
- package/src/web-components/json-table/json-table-component.js +123 -121
- package/src/web-components/json-table/json-table-component.module.css +6 -6
- package/src/web-components/json-table/json-table.minimo.tokens.mjs +6 -6
- package/src/web-components/json-table/readme.md +76 -110
- package/src/web-components/json-table/src/cell-content.js +25 -25
- package/src/web-components/json-table/src/content-utils.js +21 -21
- package/src/web-components/json-table/src/data-types.js +32 -32
- package/src/web-components/json-table/src/defaults.js +230 -191
- package/src/web-components/json-table/src/get-data.js +55 -38
- package/src/web-components/json-table/src/icons.js +17 -17
- package/src/web-components/json-table/src/info-section.js +18 -18
- package/src/web-components/json-table/src/main-builder.js +45 -45
- package/src/web-components/json-table/src/pagination.js +32 -32
- package/src/web-components/json-table/src/parse-cols.js +18 -18
- package/src/web-components/json-table/src/parse-rows.js +17 -17
- package/src/web-components/json-table/src/resolve-params.js +53 -41
- package/src/web-components/json-table/src/search.js +13 -13
- package/src/web-components/json-table/src/sorting.js +20 -20
- package/src/web-components/json-table/src/table-body.js +13 -13
- package/src/web-components/json-table/src/table-builder.js +34 -34
- package/src/web-components/json-table/src/table-tfoot.js +8 -8
- package/src/web-components/json-table/src/table-thead.js +21 -21
- package/src/web-components/json-table/src/update-info.js +11 -11
- package/types/classes.d.ts +2 -2
- package/types/global.d.ts +18 -12
|
@@ -2,21 +2,23 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/* eslint-disable no-console */
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
/*
|
|
6
|
+
build-tokens.mjs
|
|
7
|
+
Entry point: importa i moduli, esegue la build, esegue il lint dell'output CSS, stampa il log.
|
|
8
|
+
|
|
9
|
+
Struttura del progetto:
|
|
10
|
+
build-tokens.mjs <- questo file
|
|
11
|
+
build-tokens-src/config.mjs <- legge il flag --config e risolve tutti i percorsi
|
|
12
|
+
build-tokens-src/transforms.mjs <- registra le transform personalizzate di Style Dictionary
|
|
13
|
+
build-tokens-src/formats/css.mjs <- registra il format css/variables-sorted
|
|
14
|
+
build-tokens-src/formats/json.mjs <- registra il format json/tokens, esporta gli helper
|
|
15
|
+
build-tokens-src/platforms.mjs <- costruisce l'oggetto platforms (css + json opzionale)
|
|
16
|
+
build-tokens-src/build-source-modes.mjs <- percorso di build alternativo usato quando sourceModes è impostato
|
|
17
|
+
build-tokens-src/merge-css.mjs <- supporta l'opzione mergeCustomProps (flat e per modalità)
|
|
18
|
+
build-tokens-src/source-prefixes.mjs <- supporta le voci `{ src, prefix }` in source/sourceModes
|
|
19
|
+
build-tokens-src/source-transforms.mjs <- supporta le voci `{ src, transform }` in source/sourceModes
|
|
20
|
+
build-tokens-src/token-rename-parser.mjs <- parser che applica le mappe di rinomina `transform`
|
|
21
|
+
*/
|
|
20
22
|
|
|
21
23
|
import StyleDictionary from 'style-dictionary';
|
|
22
24
|
import * as path from 'node:path';
|
|
@@ -25,7 +27,7 @@ import { homedir } from 'node:os';
|
|
|
25
27
|
import stylelint from 'stylelint';
|
|
26
28
|
import { pathToFileURL } from 'node:url';
|
|
27
29
|
|
|
28
|
-
// ── 1.
|
|
30
|
+
// ── 1. Configurazione (argomenti + percorsi risolti) ────────────────────────
|
|
29
31
|
import {
|
|
30
32
|
configAbsPath,
|
|
31
33
|
buildPath,
|
|
@@ -48,29 +50,33 @@ import {
|
|
|
48
50
|
customPropsSelector,
|
|
49
51
|
} from './build-tokens-src/config.mjs';
|
|
50
52
|
|
|
51
|
-
// ── 2.
|
|
53
|
+
// ── 2. Transform personalizzate ──────────────────────────────────────────────
|
|
52
54
|
import './build-tokens-src/transforms.mjs';
|
|
53
55
|
|
|
54
|
-
// ── 2b.
|
|
55
|
-
//
|
|
56
|
-
// DTCG v5
|
|
56
|
+
// ── 2b. Bridge per la sintassi legacy dei token ──────────────────────────────
|
|
57
|
+
// Converte i file sorgente .json/.jsonc legacy (non DTCG, ad es. Open Props) alla
|
|
58
|
+
// sintassi DTCG v5 in fase di parsing — vedi build-tokens-src/legacy-tokens-parser.mjs.
|
|
57
59
|
import { LEGACY_TOKENS_PARSER_NAME, registerLegacyTokensParser } from './build-tokens-src/legacy-tokens-parser.mjs';
|
|
58
60
|
registerLegacyTokensParser();
|
|
59
61
|
|
|
60
|
-
// ── 2c.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
// ── 2c. Prefissi delle custom properties per sorgente ────────────────────────
|
|
63
|
+
/*
|
|
64
|
+
Espande le voci `{ src, prefix }` di source/sourceModes nella mappa file ->
|
|
65
|
+
prefisso letta dalla transform name/kebab-prefixed (richiede il parser legacy
|
|
66
|
+
qui sopra, per caricare le sorgenti .json legacy) — vedi source-prefixes.mjs.
|
|
67
|
+
*/
|
|
64
68
|
import { registerSourcePrefixes } from './build-tokens-src/source-prefixes.mjs';
|
|
65
69
|
await registerSourcePrefixes(prefixedSources);
|
|
66
70
|
|
|
67
|
-
// ── 2d.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
// ── 2d. Mappe di rinomina dei token per sorgente ─────────────────────────────
|
|
72
|
+
/*
|
|
73
|
+
Espande le voci `{ src, transform }` di source/sourceModes nella mappa
|
|
74
|
+
file -> rinomina letta dal parser di rinomina dei token, e registra quel
|
|
75
|
+
parser (solo se almeno un file ha effettivamente una transform) — vedi
|
|
76
|
+
source-transforms.mjs / token-rename-parser.mjs. `parserNames` viene riutilizzato
|
|
77
|
+
più sotto e passato a buildSourceModes() in modo che ogni istanza di
|
|
78
|
+
Style Dictionary lo adotti in modo coerente.
|
|
79
|
+
*/
|
|
74
80
|
import { registerSourceTransforms, transformedFilesPattern, hasRegisteredTransforms } from './build-tokens-src/source-transforms.mjs';
|
|
75
81
|
import {
|
|
76
82
|
TOKEN_RENAME_PARSER_NAME,
|
|
@@ -83,34 +89,36 @@ const tokenRenamePattern = transformedFilesPattern();
|
|
|
83
89
|
if (tokenRenamePattern) registerTokenRenameParser(tokenRenamePattern);
|
|
84
90
|
registerTokenRenamePreprocessor();
|
|
85
91
|
const parserNames = [LEGACY_TOKENS_PARSER_NAME, ...(hasRegisteredTransforms() ? [TOKEN_RENAME_PARSER_NAME] : [])];
|
|
86
|
-
//
|
|
87
|
-
//
|
|
92
|
+
// Riscrive i {riferimenti} al VECCHIO percorso di ogni token rinominato, in tutto l'albero,
|
|
93
|
+
// una volta uniti tutti i file (vedi registerTokenRenamePreprocessor() qui sopra).
|
|
88
94
|
const preprocessorNames = hasRegisteredTransforms() ? [TOKEN_RENAME_PREPROCESSOR_NAME] : [];
|
|
89
95
|
|
|
90
|
-
// ── 3. CSS
|
|
91
|
-
// customPropsCount
|
|
92
|
-
// loadExistingCustomProps
|
|
96
|
+
// ── 3. Format CSS ─────────────────────────────────────────────────────────────
|
|
97
|
+
// customPropsCount viene aggiornato dal format al momento del rendering
|
|
98
|
+
// loadExistingCustomProps supporta l'opzione mergeCustomProps (vedi sotto)
|
|
93
99
|
import { customPropsCount } from './build-tokens-src/formats/css.mjs';
|
|
94
100
|
import { loadExistingCustomProps } from './build-tokens-src/merge-css.mjs';
|
|
95
101
|
|
|
96
|
-
// ── 4. JSON
|
|
102
|
+
// ── 4. Format JSON ────────────────────────────────────────────────────────────
|
|
97
103
|
import { buildJsonFiles, collectConcreteFilePaths } from './build-tokens-src/formats/json.mjs';
|
|
98
104
|
|
|
99
|
-
// ── 5.
|
|
105
|
+
// ── 5. Builder delle platform ─────────────────────────────────────────────────
|
|
100
106
|
import { buildPlatforms } from './build-tokens-src/platforms.mjs';
|
|
101
107
|
|
|
102
|
-
// ── 5b. sourceModes
|
|
108
|
+
// ── 5b. Builder sourceModes (alternativa alla build a sorgente singola più sotto) ──
|
|
103
109
|
import { buildSourceModes } from './build-tokens-src/build-source-modes.mjs';
|
|
104
110
|
|
|
105
|
-
// ── 6.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
// ── 6. Pulizia della directory di output json ────────────────────────────────
|
|
112
|
+
/*
|
|
113
|
+
Rimuove solo i file *.json/*.jsonc generati in precedenza, in modo che i token
|
|
114
|
+
rimossi dalla sorgente non restino come artefatti obsoleti, lasciando intatto
|
|
115
|
+
ogni altro file inserito dall'utente in jsonBuildPath (ad es. un README). I file
|
|
116
|
+
vengono scritti nella stessa cartella jsonBuildPath (senza sottocartelle), quindi
|
|
117
|
+
viene analizzato solo il suo primo livello. Viene eseguito a prescindere da sourceModes.
|
|
118
|
+
*/
|
|
111
119
|
if (jsonBuildPath) {
|
|
112
|
-
//
|
|
113
|
-
//
|
|
120
|
+
// Costante locale: il narrowing del binding importato `jsonBuildPath` si perde
|
|
121
|
+
// dentro la callback .map() qui sotto.
|
|
114
122
|
const jsonDir = jsonBuildPath;
|
|
115
123
|
const { readdir, rm, mkdir } = await import('fs/promises');
|
|
116
124
|
const existingEntries = await readdir(jsonDir, { withFileTypes: true }).catch(() => []);
|
|
@@ -123,15 +131,15 @@ if (jsonBuildPath) {
|
|
|
123
131
|
}
|
|
124
132
|
|
|
125
133
|
// ── 7. Build ──────────────────────────────────────────────────────────────────
|
|
126
|
-
// concreteFilePaths / modeResult
|
|
134
|
+
// concreteFilePaths / modeResult sono usati più sotto nella sezione di log (10).
|
|
127
135
|
/** @type {string[]} */
|
|
128
136
|
let concreteFilePaths = [];
|
|
129
137
|
/** @type {Awaited<ReturnType<typeof buildSourceModes>>|null} */
|
|
130
138
|
let modeResult = null;
|
|
131
139
|
|
|
132
140
|
if (sourceModes) {
|
|
133
|
-
// sourceModes
|
|
134
|
-
//
|
|
141
|
+
// Build con sourceModes: un'istanza di StyleDictionary per modalità, composte in
|
|
142
|
+
// un unico destFile — vedi build-tokens-src/build-source-modes.mjs.
|
|
135
143
|
modeResult = await buildSourceModes({
|
|
136
144
|
sourceModes,
|
|
137
145
|
baseMode: sourceModesBase,
|
|
@@ -152,28 +160,32 @@ if (sourceModes) {
|
|
|
152
160
|
});
|
|
153
161
|
|
|
154
162
|
} else {
|
|
155
|
-
//
|
|
163
|
+
// Build a sorgente singola (default).
|
|
156
164
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
165
|
+
/*
|
|
166
|
+
Custom properties preesistenti (opzione mergeCustomProps): lette prima
|
|
167
|
+
che Style Dictionary venga eseguito, perché sovrascrive il file di destinazione. Il
|
|
168
|
+
format css/variables-sorted (formats/css.mjs) vi unisce questi valori —
|
|
169
|
+
i valori preesistenti hanno priorità — subito prima di serializzare l'output
|
|
170
|
+
CSS finale. Vedi merge-css.mjs.
|
|
171
|
+
*/
|
|
162
172
|
if (mergeCustomProps) {
|
|
163
173
|
loadExistingCustomProps(path.join(buildPath, destFile), mergeCustomProps);
|
|
164
174
|
}
|
|
165
175
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
176
|
+
/*
|
|
177
|
+
Raccoglie i percorsi dei file sorgente concreti (solo modalità JSON multi-file). Le
|
|
178
|
+
voci di source possono essere pattern glob. SD li espande internamente e memorizza il
|
|
179
|
+
percorso concreto in token.filePath. Servono questi percorsi concreti per costruire
|
|
180
|
+
i descrittori per file per la platform json.
|
|
181
|
+
|
|
182
|
+
SD v5 carica le sorgenti in modo lazy: `await sd.hasInitialized` attiva il caricamento;
|
|
183
|
+
dopo, sd.allTokens è un normale array sincrono con filePath popolato.
|
|
184
|
+
|
|
185
|
+
In modalità file singolo (jsonDestFile è impostato) questo passaggio viene saltato del tutto.
|
|
186
|
+
source è null solo quando sourceModes è impostato (vedi config.mjs); questo
|
|
187
|
+
ramo viene eseguito esclusivamente quando sourceModes non è impostato.
|
|
188
|
+
*/
|
|
177
189
|
const singleSource = /** @type {string[]} */ (source);
|
|
178
190
|
|
|
179
191
|
if (jsonBuildPath && !jsonDestFile) {
|
|
@@ -210,7 +222,7 @@ if (sourceModes) {
|
|
|
210
222
|
await sd.buildAllPlatforms();
|
|
211
223
|
}
|
|
212
224
|
|
|
213
|
-
// ── 8. CSS
|
|
225
|
+
// ── 8. Lint CSS ───────────────────────────────────────────────────────────────
|
|
214
226
|
const stylelintConfig = await import(pathToFileURL(stylelintConfigPath).href).then(m => m.default);
|
|
215
227
|
|
|
216
228
|
|
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
|
|
4
4
|
/* eslint-disable no-console */
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
/*
|
|
7
|
+
check-unresolved-custom-props.mjs
|
|
8
|
+
Analizza i file CSS nella directory configurata e segnala:
|
|
9
|
+
- proprietà non risolte: riferimenti a custom properties (var(--...)) che
|
|
10
|
+
non sono definite nel file dei token generato
|
|
11
|
+
- proprietà non usate: custom properties definite nel file dei token
|
|
12
|
+
generato ma mai referenziate tramite var() in alcun file CSS analizzato
|
|
13
|
+
|
|
14
|
+
Utilizzo: node check-unresolved-custom-props.mjs --config ./path/to/config.mjs
|
|
15
|
+
*/
|
|
14
16
|
|
|
15
17
|
|
|
16
18
|
/* globals process */
|
|
@@ -57,30 +59,34 @@ if (!configArgPath) {
|
|
|
57
59
|
const absoluteConfigPath = path.resolve(process.cwd(), configArgPath);
|
|
58
60
|
const configDir = path.dirname(absoluteConfigPath);
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
/*
|
|
63
|
+
---------------------------------------------------------------------------
|
|
64
|
+
2. Main
|
|
65
|
+
---------------------------------------------------------------------------
|
|
66
|
+
*/
|
|
63
67
|
async function run() {
|
|
64
68
|
try {
|
|
65
69
|
const { default: config } = await import(pathToFileURL(absoluteConfigPath).href);
|
|
66
70
|
|
|
67
|
-
//
|
|
71
|
+
// Percorso del file CSS generato che contiene tutte le definizioni delle custom properties
|
|
68
72
|
const custom_prop_file_path = path.resolve(configDir, path.join(config.buildPath, config.destFile));
|
|
69
73
|
|
|
70
|
-
// Directory
|
|
74
|
+
// Directory in cui cercare i file CSS
|
|
71
75
|
const checkdir = path.resolve(configDir, config.dirToCheck);
|
|
72
76
|
|
|
73
|
-
//
|
|
77
|
+
// Pattern delle custom properties da escludere dal controllo delle non risolte
|
|
74
78
|
/** @type {RegExp[]} */
|
|
75
79
|
const exclude = config.excludePattern ?? [];
|
|
76
80
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
/*
|
|
82
|
+
Raccoglie tutti i file .css nella directory da analizzare, escludendo ogni file sotto una
|
|
83
|
+
directory il cui nome inizia con "TODO" (cartelle in lavorazione).
|
|
84
|
+
Il file dei token stesso (custom_prop_file_path) è volutamente incluso:
|
|
85
|
+
le custom properties sono spesso composte da altre custom properties
|
|
86
|
+
(ad es. `--malert-box-shadow: ... var(--malert-box-shadow-color) ...`)
|
|
87
|
+
e quei riferimenti var() interni devono contare come utilizzo, altrimenti la
|
|
88
|
+
proprietà referenziata viene segnalata erroneamente come non usata.
|
|
89
|
+
*/
|
|
84
90
|
const files = [];
|
|
85
91
|
for await (const entry of glob(path.join(checkdir, '/**/*.css'))) {
|
|
86
92
|
const relDirSegments = path.relative(checkdir, path.dirname(entry)).split(path.sep);
|
|
@@ -95,27 +101,33 @@ async function run() {
|
|
|
95
101
|
throw new Error(`Token CSS file not found: ${custom_prop_file_path}`);
|
|
96
102
|
}
|
|
97
103
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
104
|
+
/*
|
|
105
|
+
---------------------------------------------------------------------------
|
|
106
|
+
3. Costruisce l'elenco delle custom properties definite
|
|
107
|
+
---------------------------------------------------------------------------
|
|
108
|
+
*/
|
|
101
109
|
const definitionRegex = /--([a-z0-9-]+)(?=\s*:)/g;
|
|
102
110
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
111
|
+
/*
|
|
112
|
+
defined_props conserva anche le informazioni su file/riga, così che le proprietà non usate (sezione 6)
|
|
113
|
+
possano essere segnalate con un link alla loro definizione. Con sourceModes
|
|
114
|
+
(vedi build-tokens-src/config.mjs), lo stesso nome di proprietà può legittimamente
|
|
115
|
+
comparire una volta per modalità con un valore diverso — `mode` indica
|
|
116
|
+
di quale si tratta, così la sezione 5 risolve ognuna nel file sorgente corretto
|
|
117
|
+
della propria modalità invece di confonderle (vedi findMediaModeBlocks
|
|
118
|
+
in build-tokens-src/merge-css.mjs).
|
|
119
|
+
*/
|
|
110
120
|
/** @type {{file: string, line: number, prop: string, mode: string|null}[]} */
|
|
111
121
|
const defined_props = [];
|
|
112
122
|
|
|
113
123
|
const cssContent = fs.readFileSync(custom_prop_file_path, 'utf-8');
|
|
114
124
|
const custom_prop_relpath = path.relative(configDir, custom_prop_file_path);
|
|
115
125
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
126
|
+
/*
|
|
127
|
+
sourceModesBase replica la logica di risoluzione del default di
|
|
128
|
+
build-tokens-src/config.mjs: il sourceModesBase configurato se è
|
|
129
|
+
effettivamente una chiave di sourceModes, altrimenti la prima chiave.
|
|
130
|
+
*/
|
|
119
131
|
const sourceModeNames = config.sourceModes ? Object.keys(config.sourceModes) : [];
|
|
120
132
|
const sourceModesBase = sourceModeNames.includes(config.sourceModesBase)
|
|
121
133
|
? config.sourceModesBase
|
|
@@ -134,8 +146,8 @@ async function run() {
|
|
|
134
146
|
defined_props.push({ file: custom_prop_relpath, line, prop: `--${m[1]}`, mode: modeAtIndex(m.index) });
|
|
135
147
|
});
|
|
136
148
|
|
|
137
|
-
//
|
|
138
|
-
//
|
|
149
|
+
// Include anche gli eventuali file CSS extra dichiarati in extraCustomPropsFiles.
|
|
150
|
+
// Sono file semplici (non sourceModes), quindi mode è sempre null.
|
|
139
151
|
for (const extraFile of (config.extraCustomPropsFiles ?? [])) {
|
|
140
152
|
const extraFilePath = path.resolve(configDir, extraFile);
|
|
141
153
|
const extraContent = fs.readFileSync(extraFilePath, 'utf-8');
|
|
@@ -148,9 +160,11 @@ async function run() {
|
|
|
148
160
|
|
|
149
161
|
const propertyNamesList = defined_props.map(item => item.prop);
|
|
150
162
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
163
|
+
/*
|
|
164
|
+
---------------------------------------------------------------------------
|
|
165
|
+
4. Analizza i file alla ricerca di riferimenti var() non risolti
|
|
166
|
+
---------------------------------------------------------------------------
|
|
167
|
+
*/
|
|
154
168
|
const usageRegex = /var\(\s*(--[a-z0-9-]+)\s*(,.*?)?\)/g;
|
|
155
169
|
/** @type {{file: string, line: number, prop: string}[]} */
|
|
156
170
|
const unresolved_props = [];
|
|
@@ -177,44 +191,52 @@ async function run() {
|
|
|
177
191
|
|
|
178
192
|
unresolved_props.sort((a, b) => a.file.localeCompare(b.file));
|
|
179
193
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
194
|
+
/*
|
|
195
|
+
Il censimento delle proprietà non usate è opt-in (config.checkUnused: true) perché
|
|
196
|
+
riesegue la pipeline di trasformazione di Style Dictionary sui sorgenti dei token
|
|
197
|
+
solo per risalire ai file sorgente, con un costo apprezzabile.
|
|
198
|
+
*/
|
|
183
199
|
const checkUnused = config.checkUnused === true;
|
|
184
200
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
201
|
+
/*
|
|
202
|
+
Se true (default), le proprietà provenienti da un file token sotto
|
|
203
|
+
node_modules (ad es. un pacchetto di token di terze parti) non vengono mai segnalate
|
|
204
|
+
come non usate — il progetto che le usa non è tenuto a ripulirle.
|
|
205
|
+
*/
|
|
188
206
|
const ignoreUnusedInNodeModules = config.ignoreUnusedInNodeModules !== false;
|
|
189
207
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
208
|
+
/*
|
|
209
|
+
---------------------------------------------------------------------------
|
|
210
|
+
5. Best-effort: risale al file sorgente .mjs dei token per ogni proprietà
|
|
211
|
+
definita, eseguendo la stessa pipeline di trasformazione usata per generare il
|
|
212
|
+
CSS (vedi build-tokens-src/formats/css.mjs) sui sorgenti dei token
|
|
213
|
+
dichiarati in config.source. Le proprietà che esistono solo nel CSS generato
|
|
214
|
+
(o in una voce di extraCustomPropsFiles) — ad es. aggiunte manuali conservate
|
|
215
|
+
tra una build e l'altra tramite l'opzione mergeCustomProps — non hanno un
|
|
216
|
+
sorgente token e vengono segnalate solo per nome.
|
|
217
|
+
|
|
218
|
+
Con sourceModes, la risoluzione viene eseguita una volta PER MODALITÀ, indicizzata per nome
|
|
219
|
+
della modalità in sourceFileByPropByMode: lo stesso nome di proprietà può essere definito da un
|
|
220
|
+
file sorgente diverso in ogni modalità (vedi l'esempio `dead: {...}` in
|
|
221
|
+
un file token light e in uno dark), quindi una singola mappa nome -> file
|
|
222
|
+
appiattita punterebbe in silenzio alcune voci al file della modalità sbagliata.
|
|
223
|
+
sourceFileByProp (mode: null) copre il caso senza sourceModes e le voci di
|
|
224
|
+
extraCustomPropsFiles.
|
|
225
|
+
---------------------------------------------------------------------------
|
|
226
|
+
*/
|
|
207
227
|
/** @type {Map<string, string>} */
|
|
208
228
|
const sourceFileByProp = new Map();
|
|
209
229
|
/** @type {Map<string, Map<string, string>>} */
|
|
210
230
|
const sourceFileByPropByMode = new Map();
|
|
211
231
|
|
|
212
|
-
// includeEntries: base
|
|
213
|
-
//
|
|
232
|
+
// includeEntries: sorgenti della modalità base, passate come `include` per le
|
|
233
|
+
// modalità non base così che i riferimenti tra modalità vengano risolti (come in build-source-modes.mjs).
|
|
214
234
|
/** @param {Parameters<typeof splitSourceEntries>[0]} sourceEntries @param {Parameters<typeof splitSourceEntries>[0]} [includeEntries] @returns {Promise<Map<string,string>>} */
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
235
|
+
/*
|
|
236
|
+
Le voci possono essere stringhe od oggetti `{ src, prefix, transform }` (vedi
|
|
237
|
+
build-tokens-src/source-prefixes.mjs): entrambi vengono registrati prima che la
|
|
238
|
+
pipeline di trasformazione venga eseguita, così i nomi dei token corrispondono al CSS generato.
|
|
239
|
+
*/
|
|
218
240
|
const resolveSourceFileMap = async (sourceEntries, includeEntries = []) => {
|
|
219
241
|
/** @type {Map<string, string>} */
|
|
220
242
|
const map = new Map();
|
|
@@ -243,7 +265,7 @@ async function run() {
|
|
|
243
265
|
if (token.filePath && token.isSource !== false) map.set(`--${token.name}`, token.filePath);
|
|
244
266
|
}
|
|
245
267
|
} catch {
|
|
246
|
-
// Non
|
|
268
|
+
// Non bloccante: le proprietà non usate verranno segnalate solo per nome.
|
|
247
269
|
}
|
|
248
270
|
return map;
|
|
249
271
|
};
|
|
@@ -264,12 +286,14 @@ async function run() {
|
|
|
264
286
|
? sourceFileByPropByMode.get(item.mode)?.get(item.prop)
|
|
265
287
|
: sourceFileByProp.get(item.prop);
|
|
266
288
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
289
|
+
/*
|
|
290
|
+
---------------------------------------------------------------------------
|
|
291
|
+
6. Costruisce l'elenco delle custom properties non usate (definite ma mai
|
|
292
|
+
referenziate tramite var() in alcun file CSS analizzato) — il controllo opposto
|
|
293
|
+
a quello della sezione 4. Le proprietà provenienti da node_modules vengono saltate quando
|
|
294
|
+
ignoreUnusedInNodeModules è true (default).
|
|
295
|
+
---------------------------------------------------------------------------
|
|
296
|
+
*/
|
|
273
297
|
const unused_props = checkUnused
|
|
274
298
|
? defined_props
|
|
275
299
|
.filter(item => !used_props_set.has(item.prop))
|
|
@@ -282,9 +306,11 @@ async function run() {
|
|
|
282
306
|
.sort((a, b) => a.prop.localeCompare(b.prop))
|
|
283
307
|
: [];
|
|
284
308
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
309
|
+
/*
|
|
310
|
+
---------------------------------------------------------------------------
|
|
311
|
+
7. Scrive il report
|
|
312
|
+
---------------------------------------------------------------------------
|
|
313
|
+
*/
|
|
288
314
|
const result_file = path.resolve(configDir, 'unresolved-unused-props.md');
|
|
289
315
|
|
|
290
316
|
const logParts = [`${unresolved_props.length} unresolved custom properties found`];
|