gonia 0.2.5 → 0.2.6
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/dist/vite/plugin.js +31 -4
- package/package.json +1 -1
package/dist/vite/plugin.js
CHANGED
|
@@ -216,6 +216,35 @@ function generateImports(directives, customDirectives, currentFile, rootDir, dir
|
|
|
216
216
|
}
|
|
217
217
|
return statements.length > 0 ? statements.join('\n') + '\n' : '';
|
|
218
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Split function parameters, respecting nested angle brackets in generics.
|
|
221
|
+
*/
|
|
222
|
+
function splitParams(paramsStr) {
|
|
223
|
+
const params = [];
|
|
224
|
+
let current = '';
|
|
225
|
+
let depth = 0;
|
|
226
|
+
for (const char of paramsStr) {
|
|
227
|
+
if (char === '<') {
|
|
228
|
+
depth++;
|
|
229
|
+
current += char;
|
|
230
|
+
}
|
|
231
|
+
else if (char === '>') {
|
|
232
|
+
depth--;
|
|
233
|
+
current += char;
|
|
234
|
+
}
|
|
235
|
+
else if (char === ',' && depth === 0) {
|
|
236
|
+
params.push(current.trim());
|
|
237
|
+
current = '';
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
current += char;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (current.trim()) {
|
|
244
|
+
params.push(current.trim());
|
|
245
|
+
}
|
|
246
|
+
return params;
|
|
247
|
+
}
|
|
219
248
|
/**
|
|
220
249
|
* Transform source code to add $inject arrays to directive functions.
|
|
221
250
|
*/
|
|
@@ -244,9 +273,7 @@ function transformInject(code) {
|
|
|
244
273
|
const paramsStr = fnMatch[1] || fnMatch[2];
|
|
245
274
|
if (!paramsStr)
|
|
246
275
|
continue;
|
|
247
|
-
const params = paramsStr
|
|
248
|
-
.split(',')
|
|
249
|
-
.map(p => p.trim())
|
|
276
|
+
const params = splitParams(paramsStr)
|
|
250
277
|
.map(p => p.replace(/\s*:.*$/, ''))
|
|
251
278
|
.map(p => p.replace(/\s*=.*$/, ''))
|
|
252
279
|
.filter(Boolean);
|
|
@@ -326,7 +353,7 @@ export function gonia(options = {}) {
|
|
|
326
353
|
},
|
|
327
354
|
transform(code, id) {
|
|
328
355
|
// Skip node_modules (except for $inject transform in gonia itself)
|
|
329
|
-
const isGoniaInternal = id.includes('gonia') && id.includes('node_modules');
|
|
356
|
+
const isGoniaInternal = id.includes('/gonia/') && (id.includes('node_modules') || id.includes('/dist/'));
|
|
330
357
|
if (id.includes('node_modules') && !isGoniaInternal)
|
|
331
358
|
return null;
|
|
332
359
|
if (!/\.(ts|js|tsx|jsx|html)$/.test(id))
|