5htp 0.6.2 → 0.6.3-2
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/app/index.ts +4 -1
- package/compiler/client/index.ts +2 -2
- package/compiler/common/babel/index.ts +0 -10
- package/compiler/common/babel/plugins/services.ts +263 -13
- package/compiler/common/babel/routes/routes.ts +199 -7
- package/compiler/common/files/autres.ts +1 -1
- package/compiler/common/files/style.ts +24 -7
- package/compiler/common/index.ts +0 -9
- package/compiler/index.ts +24 -11
- package/package.json +8 -3
- package/compiler/common/babel/plugins/form.ts +0 -191
- package/compiler/common/babel/plugins/icones-svg.ts +0 -376
- package/compiler/common/babel/plugins/injection-dependances/index.ts +0 -225
- package/compiler/common/babel/plugins/injection-dependances/remplacerFonction.ts +0 -226
- package/compiler/common/babel/plugins/queries/index.ts +0 -166
- package/compiler/common/plugins/indexage/_utils/Stringify.ts +0 -72
- package/compiler/common/plugins/indexage/_utils/annotations.ts +0 -88
- package/compiler/common/plugins/indexage/_utils/iterateur.ts +0 -52
- package/compiler/common/plugins/indexage/icones-svg/index.ts +0 -207
- package/compiler/common/plugins/indexage/index.ts +0 -134
- package/compiler/common/plugins/indexage/indexeur.ts +0 -13
- package/compiler/common/plugins/indexage/injection-dependances/index.ts +0 -68
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
/*----------------------------------
|
|
2
|
-
- DEPENDANCES
|
|
3
|
-
----------------------------------*/
|
|
4
|
-
|
|
5
|
-
// Npm
|
|
6
|
-
import fs from 'fs-extra';
|
|
7
|
-
import webfont from 'webfont';
|
|
8
|
-
import defaultMetadataProvider from 'svgicons2svgfont/src/metadata';
|
|
9
|
-
|
|
10
|
-
// Libs
|
|
11
|
-
import Indexeur from '../indexeur';
|
|
12
|
-
import cli from '@cli';
|
|
13
|
-
|
|
14
|
-
// Types
|
|
15
|
-
import type { TIndexIcones } from '../../../babel/plugins/icones-svg';
|
|
16
|
-
import type { App } from '../../../../../app';
|
|
17
|
-
|
|
18
|
-
/*----------------------------------
|
|
19
|
-
- UTILS
|
|
20
|
-
----------------------------------*/
|
|
21
|
-
|
|
22
|
-
/*----------------------------------
|
|
23
|
-
- PLUGIN
|
|
24
|
-
----------------------------------*/
|
|
25
|
-
export default class IconesSVG extends Indexeur {
|
|
26
|
-
|
|
27
|
-
private icones: TIndexIcones = {};
|
|
28
|
-
private iconesExistantes: string[] = [];
|
|
29
|
-
|
|
30
|
-
private formats = ['woff2'];
|
|
31
|
-
private dossierIcones: string;
|
|
32
|
-
private dossierSortie: string;
|
|
33
|
-
|
|
34
|
-
private cacheTypes: string;
|
|
35
|
-
private cacheIndex: string;
|
|
36
|
-
|
|
37
|
-
public constructor( private app: App, private debug?: boolean ) {
|
|
38
|
-
super();
|
|
39
|
-
|
|
40
|
-
this.formats = ['woff2'];
|
|
41
|
-
this.dossierIcones = cli.paths.core.root + '/client/assets/icons/';
|
|
42
|
-
this.dossierSortie = app.paths.bin + '/public/';
|
|
43
|
-
|
|
44
|
-
this.cacheTypes = cli.paths.core.root + '/types/icons.d.ts';
|
|
45
|
-
this.cacheIndex = this.dossierIcones + 'index.json';
|
|
46
|
-
|
|
47
|
-
if (fs.existsSync(this.cacheIndex)) {
|
|
48
|
-
|
|
49
|
-
this.debug && console.log('[icones] Getting icons list from cache ...');
|
|
50
|
-
this.iconesExistantes = fs.readJSONSync(this.cacheIndex);
|
|
51
|
-
|
|
52
|
-
} else {
|
|
53
|
-
|
|
54
|
-
this.debug && console.log('[icones] Référencement des icones existantes ...');
|
|
55
|
-
this.iconesExistantes = this.refExistant('');
|
|
56
|
-
fs.outputJSONSync(this.cacheIndex, this.iconesExistantes);
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
this.debug && console.log('[icones] ' + this.iconesExistantes.length + ' icones référencées');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private refExistant = (dir: string): string[] => {
|
|
64
|
-
|
|
65
|
-
let filelist: string[] = [];
|
|
66
|
-
|
|
67
|
-
let files = fs.readdirSync(this.dossierIcones + dir);
|
|
68
|
-
for (const file of files)
|
|
69
|
-
if (fs.statSync(this.dossierIcones + dir + file).isDirectory())
|
|
70
|
-
filelist = [
|
|
71
|
-
...filelist,
|
|
72
|
-
...this.refExistant(dir + file + '/')
|
|
73
|
-
];
|
|
74
|
-
else if (file.endsWith('.svg'))
|
|
75
|
-
filelist.push(dir + file.substring(0, file.length - 4));
|
|
76
|
-
|
|
77
|
-
return filelist;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/*----------------------------------
|
|
81
|
-
- EVENTS
|
|
82
|
-
----------------------------------*/
|
|
83
|
-
public Init() {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
public Maj( donneesMeta: TIndexIcones, fichier: string): boolean {
|
|
90
|
-
|
|
91
|
-
let maj = false;
|
|
92
|
-
|
|
93
|
-
//console.log('======maj', Object.keys( donneesMeta ));
|
|
94
|
-
|
|
95
|
-
// Pour chacune d'entre elles
|
|
96
|
-
for (const cheminIcone in donneesMeta) {
|
|
97
|
-
|
|
98
|
-
// Verif si existante
|
|
99
|
-
if (!this.iconesExistantes.includes( cheminIcone ))
|
|
100
|
-
console.error(`The icon you made reference to "${donneesMeta[cheminIcone].nom}" (${cheminIcone}) in the file ${fichier} doesn't exists.`);
|
|
101
|
-
// Verif si déjà référencée
|
|
102
|
-
else if (this.icones[ cheminIcone ] === undefined) {
|
|
103
|
-
// Sinon, référencement
|
|
104
|
-
this.icones[ cheminIcone ] = donneesMeta[ cheminIcone ];
|
|
105
|
-
|
|
106
|
-
//console.log('Nouvelle icone', donneesMeta[ cheminIcone ].nom);
|
|
107
|
-
maj = true;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return maj;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
public async Enregistrer() {
|
|
115
|
-
|
|
116
|
-
//return []
|
|
117
|
-
|
|
118
|
-
let cheminIcones: {[chemin: string]: string} = {};
|
|
119
|
-
let typeIcones: string[] = [];
|
|
120
|
-
for (const id in this.icones) {
|
|
121
|
-
const icone = this.icones[id]
|
|
122
|
-
cheminIcones[ this.dossierIcones + icone.fichier ] = icone.id;
|
|
123
|
-
typeIcones.push('"' + icone.nom + '"');
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
this.debug && console.log('[icones] Création police avec ' + typeIcones.length +' icones ...');
|
|
127
|
-
//console.log('[icones] Liste des icones rféérencées: ', cheminIcones);
|
|
128
|
-
|
|
129
|
-
const optionsMetadata = {
|
|
130
|
-
// Options par défaut de webfont
|
|
131
|
-
// https://github.com/itgalaxy/webfont/blob/cc4412f0ff1f811bb7d38b5da75e128c270d4e6b/src/standalone.js#L203
|
|
132
|
-
// RAPPEL: startUnicode sera incrémenté dans defaultMetadataProvider (https://github.com/nfroidure/svgicons2svgfont/blob/master/src/metadata.js#L61),
|
|
133
|
-
// c'est pourquoi on déclare les options dans un objet
|
|
134
|
-
prependUnicode: false,
|
|
135
|
-
startUnicode: 0xea01
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const result = await webfont({
|
|
139
|
-
files: Object.keys(cheminIcones),
|
|
140
|
-
fontName: "icons", // Force efresh icons woff on app update
|
|
141
|
-
template: this.dossierIcones + 'template.css',
|
|
142
|
-
// @ts-ignore
|
|
143
|
-
formats: this.formats,
|
|
144
|
-
templateClassName: 'svg',
|
|
145
|
-
glyphTransformFn: (obj) => {
|
|
146
|
-
|
|
147
|
-
// Nom classe css = via id
|
|
148
|
-
const icone = this.icones[obj.path]
|
|
149
|
-
if (icone !== undefined)
|
|
150
|
-
obj.name = icone.id;
|
|
151
|
-
|
|
152
|
-
return obj;
|
|
153
|
-
},
|
|
154
|
-
// Par défaut, le nom des icones est déterminé via le nom du fichier uniquement
|
|
155
|
-
// Ici, onrefixe le nom des glyphs de leur set (solid, regular) afin de pouvoir utiliser plusieurs sets pour une même icone
|
|
156
|
-
// ex: solid/home et regular/home
|
|
157
|
-
metadataProvider: (file, callback) => {
|
|
158
|
-
|
|
159
|
-
// BUG: Quand defaultMetadataProvider est appellé manuellement, l'unicode est toujours le même peu importe l'icone
|
|
160
|
-
// Incmrémenter l'unicde manuellement ? https://stackoverflow.com/questions/12504042/what-is-a-method-that-can-be-used-to-increment-letters
|
|
161
|
-
defaultMetadataProvider(optionsMetadata)(file, (err, defaultMetas) => {
|
|
162
|
-
|
|
163
|
-
const idIcone = cheminIcones[ file ];
|
|
164
|
-
if (idIcone === undefined)
|
|
165
|
-
console.warn("Impossible de retrouver l'id de l'icone " + file);
|
|
166
|
-
else
|
|
167
|
-
defaultMetas.name = idIcone;
|
|
168
|
-
|
|
169
|
-
callback(err, defaultMetas);
|
|
170
|
-
|
|
171
|
-
optionsMetadata.startUnicode++;
|
|
172
|
-
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}).catch(error => {
|
|
176
|
-
console.error("Erreur lors de la création de la police d'icones", error);
|
|
177
|
-
throw error;
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
this.debug && console.log('[icones] Enregistrement de la police avec ' + typeIcones.length +' icones ...');
|
|
181
|
-
|
|
182
|
-
// Enregistrement fichiers
|
|
183
|
-
for (const format of this.formats)
|
|
184
|
-
fs.outputFileSync(this.dossierSortie + 'icons.' + format, result[ format ]);
|
|
185
|
-
fs.outputFileSync(this.dossierSortie + 'icons.css', result.template?.replace('icons.woff2', 'icons.woff2?' + this.app.buildId));
|
|
186
|
-
|
|
187
|
-
fs.outputFileSync(this.cacheTypes, 'export type TIcones = ' + typeIcones.join('|') );
|
|
188
|
-
|
|
189
|
-
this.debug && console.log("[icones] Police enregistrée.");
|
|
190
|
-
|
|
191
|
-
return [
|
|
192
|
-
/*{
|
|
193
|
-
fichier: dossierSortie + 'index.css',
|
|
194
|
-
donnees: result.template
|
|
195
|
-
},
|
|
196
|
-
...formats.map((format) => ({
|
|
197
|
-
fichier: dossierSortie + 'icones.' + format,
|
|
198
|
-
donnees: result[ format ]
|
|
199
|
-
}))*/
|
|
200
|
-
];
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/*----------------------------------
|
|
205
|
-
- OUTILS
|
|
206
|
-
----------------------------------*/
|
|
207
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import Indexeur from './indexeur';
|
|
2
|
-
|
|
3
|
-
import { Compiler, NormalModule } from 'webpack';
|
|
4
|
-
|
|
5
|
-
type TListeIndexeurs = {[nom: string]: Indexeur}
|
|
6
|
-
|
|
7
|
-
const debug = false;
|
|
8
|
-
|
|
9
|
-
export default class SelecteursApiPlugin {
|
|
10
|
-
|
|
11
|
-
public static metadataContextFunctionName = "metadataSelecteursApiPlugin";
|
|
12
|
-
|
|
13
|
-
private indexeurs: TListeIndexeurs;
|
|
14
|
-
|
|
15
|
-
public constructor(config: TListeIndexeurs) {
|
|
16
|
-
|
|
17
|
-
this.indexeurs = config;
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
apply(compiler: Compiler) {
|
|
22
|
-
|
|
23
|
-
const nomCompileur = compiler.options.name;
|
|
24
|
-
|
|
25
|
-
for (const nomIndexeur in this.indexeurs) {
|
|
26
|
-
debug && console.log(`[indexage][${nomCompileur}][${nomIndexeur}] Init`);
|
|
27
|
-
this.indexeurs[nomIndexeur].Init();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
compiler.hooks.compilation.tap("SelecteursApiPlugin", (compilation) => {
|
|
31
|
-
//console.log("The compiler is starting a new compilation...");
|
|
32
|
-
|
|
33
|
-
NormalModule.getCompilationHooks(compilation).loader.tap("SelecteursApiPlugin", (context, module) => {
|
|
34
|
-
|
|
35
|
-
// Fonction de récupération des métadatas
|
|
36
|
-
context["metadataSelecteursApiPlugin"] = (metadata) => {
|
|
37
|
-
|
|
38
|
-
//console.log(`[selecteurs-api] Meta reçues ` + module.resource, metadata);
|
|
39
|
-
|
|
40
|
-
for (const nomIndexeur in this.indexeurs)
|
|
41
|
-
if (metadata[nomIndexeur] !== undefined) {
|
|
42
|
-
|
|
43
|
-
const majOk = this.indexeurs[nomIndexeur].Maj(metadata[nomIndexeur], module.resource);
|
|
44
|
-
|
|
45
|
-
if (majOk) {
|
|
46
|
-
|
|
47
|
-
/*if (this.indexeurs[ nomIndexeur ].compile[ module.resource ] !== undefined) {
|
|
48
|
-
console.log(`[indexage][${nomCompileur}][${nomIndexeur}] Màj via le fichier ${module.resource}`);
|
|
49
|
-
}*/
|
|
50
|
-
|
|
51
|
-
this.indexeurs[nomIndexeur].compile[module.resource] = true;
|
|
52
|
-
this.indexeurs[nomIndexeur].derniereModif = new Date().getTime();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
// A partir de finishModules, webpack n'accepte plus les modifs de modules
|
|
62
|
-
// https://webpack.js.org/api/compilation-hooks/#seal
|
|
63
|
-
// https://github.com/webpack/webpack/issues/8830
|
|
64
|
-
compiler.hooks.thisCompilation.tap("SelecteursApiPlugin", (compilation) => {
|
|
65
|
-
compilation.hooks.finishModules.tapAsync("SelecteursApiPlugin", async (modules, callback) => {
|
|
66
|
-
|
|
67
|
-
for (const nomIndexeur in this.indexeurs) {
|
|
68
|
-
try {
|
|
69
|
-
if (this.indexeurs[nomIndexeur].derniereModif > this.indexeurs[nomIndexeur].derniereMaj) {
|
|
70
|
-
|
|
71
|
-
debug && console.log(`[indexage][${nomCompileur}][${nomIndexeur}] Enregistrement des modifications`);
|
|
72
|
-
|
|
73
|
-
this.indexeurs[nomIndexeur].derniereMaj = this.indexeurs[nomIndexeur].derniereModif;
|
|
74
|
-
const aEnregistrer = await this.indexeurs[nomIndexeur].Enregistrer();
|
|
75
|
-
/*for (const { fichier, donnees } of aEnregistrer) {
|
|
76
|
-
|
|
77
|
-
console.info("TODO: indexag weback")
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
TODO:
|
|
81
|
-
const moduleAmaj = Array.from(modules).find(
|
|
82
|
-
// m.id peut êtreun nombre ou null. Pour rechercher via le chemin, m.resource
|
|
83
|
-
(m) => m.resource && m.resource.endsWith(fichier)
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
if (!moduleAmaj) {
|
|
87
|
-
console.warn(`[indexage][${nomCompileur}][${nomIndexeur}] Impossible de retrouver le module correspondant au fichier ${fichier}`);
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
console.log(`[indexage][${nomCompileur}][${nomIndexeur}] Màj & recompilation du module ${moduleAmaj.resource} ...`);
|
|
92
|
-
|
|
93
|
-
moduleAmaj._source._value = donnees;
|
|
94
|
-
|
|
95
|
-
// Recompile immédiatement et sans devoir changer le fichier
|
|
96
|
-
moduleAmaj.parser.parse(
|
|
97
|
-
moduleAmaj._source.source(),
|
|
98
|
-
{
|
|
99
|
-
current: moduleAmaj,
|
|
100
|
-
module: moduleAmaj,
|
|
101
|
-
compilation: compilation,
|
|
102
|
-
options: compilation.options
|
|
103
|
-
}
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
// ALTERNATIVE: Rien ne se passe
|
|
107
|
-
//compiler.hooks.invalid.call(moduleAmaj.resource, Date.now());
|
|
108
|
-
compilation.rebuildModule( moduleAmaj, (e) => {
|
|
109
|
-
|
|
110
|
-
if (e) console.error(e);
|
|
111
|
-
else {
|
|
112
|
-
|
|
113
|
-
callback();
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
}*/
|
|
120
|
-
}
|
|
121
|
-
} catch (e) {
|
|
122
|
-
|
|
123
|
-
console.error(`Erreur lors de l'enregistrement des sélecteurs api: `, e);
|
|
124
|
-
throw e;
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
callback();
|
|
130
|
-
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
type DonneesAenregistrer = { fichier: string, donnees: string }
|
|
2
|
-
|
|
3
|
-
export default abstract class Indexeur {
|
|
4
|
-
|
|
5
|
-
public compile = {};
|
|
6
|
-
public derniereMaj = 0;
|
|
7
|
-
public derniereModif = 0;
|
|
8
|
-
|
|
9
|
-
public abstract Init(): void;
|
|
10
|
-
public abstract Maj( donneesMetas: any, fichier: string ): boolean;
|
|
11
|
-
public abstract Enregistrer(): Promise< DonneesAenregistrer[] >;
|
|
12
|
-
|
|
13
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/*----------------------------------
|
|
2
|
-
- DEPENDANCES
|
|
3
|
-
----------------------------------*/
|
|
4
|
-
|
|
5
|
-
// Npm
|
|
6
|
-
import fs from 'fs-extra';
|
|
7
|
-
|
|
8
|
-
// Libs
|
|
9
|
-
import Indexeur from '../indexeur';
|
|
10
|
-
import Stringify from '../_utils/Stringify';
|
|
11
|
-
import cli from '@cli';
|
|
12
|
-
|
|
13
|
-
const fichierSortie = app.paths.cache + '/serveur/services.ts';
|
|
14
|
-
|
|
15
|
-
/*----------------------------------
|
|
16
|
-
- TYPES
|
|
17
|
-
----------------------------------*/
|
|
18
|
-
type TService = {
|
|
19
|
-
classe?: any,
|
|
20
|
-
dependances: string[]
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
type TListeServices = {[idService: string]: TService};
|
|
24
|
-
|
|
25
|
-
/*----------------------------------
|
|
26
|
-
- PLUGIN
|
|
27
|
-
----------------------------------*/
|
|
28
|
-
export default class SelecteursApi extends Indexeur {
|
|
29
|
-
|
|
30
|
-
private dependances: TListeServices = {};
|
|
31
|
-
|
|
32
|
-
/*----------------------------------
|
|
33
|
-
- EVENTS
|
|
34
|
-
----------------------------------*/
|
|
35
|
-
public Init() {
|
|
36
|
-
|
|
37
|
-
// Autrement, erreur compilation comme quoi que le module n'existe pas
|
|
38
|
-
// En effet, le dossier cache est vidé avant la compilation
|
|
39
|
-
// Et le fichierd'index des déps n'est généré qu'à la fin de la compilation
|
|
40
|
-
fs.outputFileSync(fichierSortie, 'export default {}');
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public Maj(nouveauxServices: TListeServices, fichier: string): boolean {
|
|
45
|
-
|
|
46
|
-
let maj = false;
|
|
47
|
-
|
|
48
|
-
for (const idService in nouveauxServices) {
|
|
49
|
-
|
|
50
|
-
maj = true;
|
|
51
|
-
|
|
52
|
-
this.dependances[idService] = nouveauxServices[idService];
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return maj;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public async Enregistrer() {
|
|
60
|
-
|
|
61
|
-
console.log('enregistrer dépendances', this.dependances);
|
|
62
|
-
|
|
63
|
-
fs.outputFileSync(fichierSortie, 'export default ' + Stringify(this.dependances, ['classe']));
|
|
64
|
-
|
|
65
|
-
return [];
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
}
|