5htp 0.3.2-1 → 0.3.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "5htp",
3
3
  "description": "Convenient TypeScript framework designed for Performance and Productivity.",
4
- "version": "0.3.2-1",
4
+ "version": "0.3.3",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp.git",
7
7
  "license": "MIT",
@@ -33,6 +33,8 @@ function Plugin (babel) {
33
33
 
34
34
  const plugin: PluginObj<{
35
35
  referencerIcone: (nomBrut: string) => string | null,
36
+ setNodeAsProcessed: (node: types.Node) => types.Node;
37
+ hasBeenProcessed: (node: types.Node) => boolean | undefined,
36
38
  fichier: string,
37
39
  traiter: boolean,
38
40
  iconeTrouvee: boolean,
@@ -85,6 +87,14 @@ function Plugin (babel) {
85
87
  return this.icones[ cheminIconeBrut ].id;
86
88
  }
87
89
 
90
+ this.setNodeAsProcessed = (node: types.Node) => {
91
+ node.innerComments = [{ type: 'CommentBlock', 'value': '@iconId' }]
92
+ return node;
93
+ }
94
+
95
+ this.hasBeenProcessed = (node: types.Node) =>
96
+ node.innerComments?.some( c => c.value === '@iconId' )
97
+
88
98
  },
89
99
  visitor: {
90
100
  Program: {
@@ -106,6 +116,8 @@ function Plugin (babel) {
106
116
  path.node.leadingComments.length !== 0
107
117
  &&
108
118
  path.node.leadingComments[0].value === ' @icon '
119
+ &&
120
+ !this.hasBeenProcessed( path.node )
109
121
  ) {
110
122
 
111
123
  // Remplacement par id
@@ -114,7 +126,9 @@ function Plugin (babel) {
114
126
  return;
115
127
 
116
128
  path.replaceWith(
117
- t.stringLiteral(idIcone)
129
+ this.setNodeAsProcessed(
130
+ t.stringLiteral(idIcone)
131
+ )
118
132
  );
119
133
 
120
134
  path.skip();
@@ -130,17 +144,24 @@ function Plugin (babel) {
130
144
  path.node.key.name === 'icon'
131
145
  &&
132
146
  path.node.value?.type === 'StringLiteral'
147
+ &&
148
+ !this.hasBeenProcessed( path.node )
133
149
  ) {
134
150
 
151
+ if (this.fichier.includes("award"))
152
+ console.log( path.node.value.value, path.node.innerComments,path.node.leadingComments, path.node.trailingComments );
153
+
135
154
  // Remplacement par id
136
155
  const idIcone = this.referencerIcone(path.node.value.value);
137
156
  if (idIcone === null)
138
157
  return;
139
158
 
140
159
  path.replaceWith(
141
- t.objectProperty(
142
- t.identifier('icon'),
143
- t.stringLiteral( idIcone )
160
+ this.setNodeAsProcessed(
161
+ t.objectProperty(
162
+ t.identifier('icon'),
163
+ t.stringLiteral( idIcone ),
164
+ )
144
165
  )
145
166
  );
146
167
 
@@ -158,6 +179,8 @@ function Plugin (babel) {
158
179
  path.node.name.name.startsWith("icon")
159
180
  &&
160
181
  path.node.value
182
+ &&
183
+ !this.hasBeenProcessed( path.node )
161
184
  ) {
162
185
 
163
186
  const nomAttr = path.node.name.name;
@@ -199,10 +222,12 @@ function Plugin (babel) {
199
222
  } else
200
223
  return;
201
224
 
202
- path.replaceWith(
203
- t.jsxAttribute(
204
- t.jsxIdentifier( nomAttr ),
205
- remplacement
225
+ path.replaceWith(
226
+ this.setNodeAsProcessed(
227
+ t.jsxAttribute(
228
+ t.jsxIdentifier( nomAttr ),
229
+ remplacement
230
+ )
206
231
  )
207
232
  );
208
233
 
@@ -224,6 +249,8 @@ function Plugin (babel) {
224
249
  path.node.openingElement.name.type === 'JSXIdentifier'
225
250
  &&
226
251
  path.node.openingElement.name.name === 'i'
252
+ &&
253
+ !this.hasBeenProcessed( path.node )
227
254
  ) {
228
255
 
229
256
  // Extraction des attributs src et class
@@ -291,7 +318,7 @@ function Plugin (babel) {
291
318
  ? attrs.class.expression
292
319
  : null
293
320
 
294
- path.replaceWith(
321
+ path.replaceWith( this.setNodeAsProcessed(
295
322
 
296
323
  // Balise <i>
297
324
  t.jsxElement(
@@ -330,7 +357,7 @@ function Plugin (babel) {
330
357
  path.node.children,
331
358
  path.node.selfClosing
332
359
  )
333
- );
360
+ ));
334
361
  }
335
362
  }
336
363
  },
@@ -90,12 +90,14 @@ export default class IconesSVG extends Indexeur {
90
90
 
91
91
  let maj = false;
92
92
 
93
+ //console.log('======maj', Object.keys( donneesMeta ));
94
+
93
95
  // Pour chacune d'entre elles
94
96
  for (const cheminIcone in donneesMeta) {
95
97
 
96
98
  // Verif si existante
97
99
  if (!this.iconesExistantes.includes( cheminIcone ))
98
- console.error(`L'icone ${donneesMeta[cheminIcone].nom} (${cheminIcone}) utilisée dans le fichier ${fichier} n'existe pas.`);
100
+ console.error(`The icon you made reference to "${donneesMeta[cheminIcone].nom}" (${cheminIcone}) in the file ${fichier} doesn't exists.`);
99
101
  // Verif si déjà référencée
100
102
  else if (this.icones[ cheminIcone ] === undefined) {
101
103
  // Sinon, référencement