@hybridly/vite 0.5.4 → 0.5.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/index.cjs +11 -3
- package/dist/index.mjs +10 -3
- package/package.json +9 -8
package/dist/index.cjs
CHANGED
|
@@ -8,6 +8,7 @@ const fs = require('node:fs');
|
|
|
8
8
|
const makeDebugger = require('debug');
|
|
9
9
|
const localPkg = require('local-pkg');
|
|
10
10
|
const node_child_process = require('node:child_process');
|
|
11
|
+
const MagicString = require('magic-string');
|
|
11
12
|
const run = require('vite-plugin-run');
|
|
12
13
|
const utils = require('@hybridly/utils');
|
|
13
14
|
const autoimport = require('unplugin-auto-import/vite');
|
|
@@ -24,6 +25,7 @@ const laravel__default = /*#__PURE__*/_interopDefaultCompat(laravel);
|
|
|
24
25
|
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
25
26
|
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
26
27
|
const makeDebugger__default = /*#__PURE__*/_interopDefaultCompat(makeDebugger);
|
|
28
|
+
const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString);
|
|
27
29
|
const run__default = /*#__PURE__*/_interopDefaultCompat(run);
|
|
28
30
|
const autoimport__default = /*#__PURE__*/_interopDefaultCompat(autoimport);
|
|
29
31
|
const vueComponents__default = /*#__PURE__*/_interopDefaultCompat(vueComponents);
|
|
@@ -284,7 +286,8 @@ const layout = (options, config) => {
|
|
|
284
286
|
if (!templateRegExp.test(code)) {
|
|
285
287
|
return;
|
|
286
288
|
}
|
|
287
|
-
|
|
289
|
+
const source = new MagicString__default(code);
|
|
290
|
+
const updatedCode = source.replace(templateRegExp, (_, layoutName) => {
|
|
288
291
|
const isTypeScript = TYPESCRIPT_REGEX.test(code);
|
|
289
292
|
const layouts = layoutName?.toString()?.replaceAll(" ", "").split(",") ?? [defaultLayoutName];
|
|
290
293
|
const importName = (i) => `__hybridly_layout_${i}`;
|
|
@@ -306,6 +309,10 @@ const layout = (options, config) => {
|
|
|
306
309
|
<template>
|
|
307
310
|
`;
|
|
308
311
|
});
|
|
312
|
+
return {
|
|
313
|
+
map: updatedCode.generateMap(),
|
|
314
|
+
code: updatedCode.toString()
|
|
315
|
+
};
|
|
309
316
|
}
|
|
310
317
|
};
|
|
311
318
|
};
|
|
@@ -364,7 +371,8 @@ const HybridlyImports = {
|
|
|
364
371
|
"defineLayout",
|
|
365
372
|
"defineLayoutProperties",
|
|
366
373
|
"registerHook",
|
|
367
|
-
"useRoute"
|
|
374
|
+
"useRoute",
|
|
375
|
+
"useQueryParameters"
|
|
368
376
|
],
|
|
369
377
|
"hybridly": [
|
|
370
378
|
"router",
|
|
@@ -376,7 +384,7 @@ function getAutoImportsOptions(options, config) {
|
|
|
376
384
|
if (options.autoImports === false) {
|
|
377
385
|
return;
|
|
378
386
|
}
|
|
379
|
-
const presets = ["@vueuse/core", "
|
|
387
|
+
const presets = ["@vueuse/core", "vue-i18n"];
|
|
380
388
|
const custom = {
|
|
381
389
|
"@unhead/vue": [
|
|
382
390
|
"useHead",
|
package/dist/index.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import fs from 'node:fs';
|
|
|
4
4
|
import makeDebugger from 'debug';
|
|
5
5
|
import { isPackageExists } from 'local-pkg';
|
|
6
6
|
import { execSync } from 'node:child_process';
|
|
7
|
+
import MagicString from 'magic-string';
|
|
7
8
|
import run from 'vite-plugin-run';
|
|
8
9
|
import { merge } from '@hybridly/utils';
|
|
9
10
|
import autoimport from 'unplugin-auto-import/vite';
|
|
@@ -267,7 +268,8 @@ const layout = (options, config) => {
|
|
|
267
268
|
if (!templateRegExp.test(code)) {
|
|
268
269
|
return;
|
|
269
270
|
}
|
|
270
|
-
|
|
271
|
+
const source = new MagicString(code);
|
|
272
|
+
const updatedCode = source.replace(templateRegExp, (_, layoutName) => {
|
|
271
273
|
const isTypeScript = TYPESCRIPT_REGEX.test(code);
|
|
272
274
|
const layouts = layoutName?.toString()?.replaceAll(" ", "").split(",") ?? [defaultLayoutName];
|
|
273
275
|
const importName = (i) => `__hybridly_layout_${i}`;
|
|
@@ -289,6 +291,10 @@ const layout = (options, config) => {
|
|
|
289
291
|
<template>
|
|
290
292
|
`;
|
|
291
293
|
});
|
|
294
|
+
return {
|
|
295
|
+
map: updatedCode.generateMap(),
|
|
296
|
+
code: updatedCode.toString()
|
|
297
|
+
};
|
|
292
298
|
}
|
|
293
299
|
};
|
|
294
300
|
};
|
|
@@ -347,7 +353,8 @@ const HybridlyImports = {
|
|
|
347
353
|
"defineLayout",
|
|
348
354
|
"defineLayoutProperties",
|
|
349
355
|
"registerHook",
|
|
350
|
-
"useRoute"
|
|
356
|
+
"useRoute",
|
|
357
|
+
"useQueryParameters"
|
|
351
358
|
],
|
|
352
359
|
"hybridly": [
|
|
353
360
|
"router",
|
|
@@ -359,7 +366,7 @@ function getAutoImportsOptions(options, config) {
|
|
|
359
366
|
if (options.autoImports === false) {
|
|
360
367
|
return;
|
|
361
368
|
}
|
|
362
|
-
const presets = ["@vueuse/core", "
|
|
369
|
+
const presets = ["@vueuse/core", "vue-i18n"];
|
|
363
370
|
const custom = {
|
|
364
371
|
"@unhead/vue": [
|
|
365
372
|
"useHead",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hybridly/vite",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "Vite plugin for Hybridly",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hybridly",
|
|
@@ -40,22 +40,23 @@
|
|
|
40
40
|
"vue": "^3.2.45"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@vitejs/plugin-vue": "^4.
|
|
43
|
+
"@vitejs/plugin-vue": "^4.4.0",
|
|
44
44
|
"fast-glob": "^3.3.1",
|
|
45
45
|
"laravel-vite-plugin": "^0.8.1",
|
|
46
46
|
"local-pkg": "^0.4.3",
|
|
47
|
+
"magic-string": "^0.30.5",
|
|
47
48
|
"throttle-debounce": "^5.0.0",
|
|
48
49
|
"unplugin-auto-import": "^0.16.6",
|
|
49
|
-
"unplugin-icons": "^0.17.
|
|
50
|
+
"unplugin-icons": "^0.17.1",
|
|
50
51
|
"unplugin-vue-components": "^0.25.2",
|
|
51
52
|
"vite-plugin-run": "^0.5.1",
|
|
52
|
-
"@hybridly/core": "0.5.
|
|
53
|
+
"@hybridly/core": "0.5.6"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
|
-
"@iconify/json": "^2.2.
|
|
56
|
-
"rollup": "^3.29.
|
|
57
|
-
"vite": "^4.
|
|
58
|
-
"vue": "^3.3.
|
|
56
|
+
"@iconify/json": "^2.2.133",
|
|
57
|
+
"rollup": "^3.29.4",
|
|
58
|
+
"vite": "^4.5.0",
|
|
59
|
+
"vue": "^3.3.7"
|
|
59
60
|
},
|
|
60
61
|
"scripts": {
|
|
61
62
|
"build": "unbuild",
|