@hybridly/vite 0.0.1-alpha.12 → 0.0.1-alpha.13
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 +15 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +15 -9
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -31,16 +31,22 @@ const TEMPLATE_LAYOUT_REGEX = /<template +layout(?: *= *['"]((?:[\w\/\-_,:](?:,\
|
|
|
31
31
|
const TYPESCRIPT_REGEX = /lang=['"]ts['"]/;
|
|
32
32
|
const layout = (options = {}) => {
|
|
33
33
|
const defaultLayoutName = options?.defaultLayoutName?.replace(".vue", "") ?? "default";
|
|
34
|
-
const
|
|
34
|
+
const layoutsDirectory = options?.directory ?? path__default.resolve(process.cwd(), "resources", "views", "layouts");
|
|
35
35
|
const templateRegExp = options?.templateRegExp ?? TEMPLATE_LAYOUT_REGEX;
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
const resolveLayoutPath = (layoutName) => {
|
|
37
|
+
const [domain, layout] = layoutName.includes(":") ? layoutName.split(":") : [void 0, layoutName];
|
|
38
|
+
const resolve = options?.resolve ?? ((layout2, domain2) => {
|
|
39
|
+
if (!domain2) {
|
|
40
|
+
return path__default.resolve(layoutsDirectory, `${layout2}.vue`);
|
|
41
|
+
}
|
|
42
|
+
return path__default.resolve(process.cwd(), "resources", "domains", domain2, "layouts", `${layout2}.vue`);
|
|
43
|
+
});
|
|
44
|
+
return vite.normalizePath(resolve(layout, domain)).replaceAll("\\", "/");
|
|
45
|
+
};
|
|
46
|
+
debug.layout("Resolved options:", {
|
|
47
|
+
defaultLayoutName,
|
|
48
|
+
layoutsDirectory
|
|
42
49
|
});
|
|
43
|
-
debug.layout("Registered layout path:", base);
|
|
44
50
|
return {
|
|
45
51
|
name: LAYOUT_PLUGIN_NAME,
|
|
46
52
|
transform: (code, id) => {
|
|
@@ -54,7 +60,7 @@ const layout = (options = {}) => {
|
|
|
54
60
|
const exports = layouts.map((_2, i) => importName(i));
|
|
55
61
|
const imports = layouts.reduce((imports2, layoutName2, i) => `
|
|
56
62
|
${imports2}
|
|
57
|
-
import ${importName(i)} from '${
|
|
63
|
+
import ${importName(i)} from '${resolveLayoutPath(layoutName2)}';
|
|
58
64
|
`, "").trim();
|
|
59
65
|
debug.layout(`Resolved layouts "${layouts.join(", ")}":`, {
|
|
60
66
|
sourceFile: id,
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ interface LayoutOptions {
|
|
|
14
14
|
/** The directory in which layouts are stored. */
|
|
15
15
|
directory?: string;
|
|
16
16
|
/** Function that resolves the layout path given its name. */
|
|
17
|
-
resolve?: (layout: string) => string;
|
|
17
|
+
resolve?: (layout: string, domain?: string) => string;
|
|
18
18
|
}
|
|
19
19
|
interface RouterOptions {
|
|
20
20
|
/** Path to the PHP executable. */
|
package/dist/index.mjs
CHANGED
|
@@ -21,16 +21,22 @@ const TEMPLATE_LAYOUT_REGEX = /<template +layout(?: *= *['"]((?:[\w\/\-_,:](?:,\
|
|
|
21
21
|
const TYPESCRIPT_REGEX = /lang=['"]ts['"]/;
|
|
22
22
|
const layout = (options = {}) => {
|
|
23
23
|
const defaultLayoutName = options?.defaultLayoutName?.replace(".vue", "") ?? "default";
|
|
24
|
-
const
|
|
24
|
+
const layoutsDirectory = options?.directory ?? path.resolve(process.cwd(), "resources", "views", "layouts");
|
|
25
25
|
const templateRegExp = options?.templateRegExp ?? TEMPLATE_LAYOUT_REGEX;
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
const resolveLayoutPath = (layoutName) => {
|
|
27
|
+
const [domain, layout] = layoutName.includes(":") ? layoutName.split(":") : [void 0, layoutName];
|
|
28
|
+
const resolve = options?.resolve ?? ((layout2, domain2) => {
|
|
29
|
+
if (!domain2) {
|
|
30
|
+
return path.resolve(layoutsDirectory, `${layout2}.vue`);
|
|
31
|
+
}
|
|
32
|
+
return path.resolve(process.cwd(), "resources", "domains", domain2, "layouts", `${layout2}.vue`);
|
|
33
|
+
});
|
|
34
|
+
return normalizePath(resolve(layout, domain)).replaceAll("\\", "/");
|
|
35
|
+
};
|
|
36
|
+
debug.layout("Resolved options:", {
|
|
37
|
+
defaultLayoutName,
|
|
38
|
+
layoutsDirectory
|
|
32
39
|
});
|
|
33
|
-
debug.layout("Registered layout path:", base);
|
|
34
40
|
return {
|
|
35
41
|
name: LAYOUT_PLUGIN_NAME,
|
|
36
42
|
transform: (code, id) => {
|
|
@@ -44,7 +50,7 @@ const layout = (options = {}) => {
|
|
|
44
50
|
const exports = layouts.map((_2, i) => importName(i));
|
|
45
51
|
const imports = layouts.reduce((imports2, layoutName2, i) => `
|
|
46
52
|
${imports2}
|
|
47
|
-
import ${importName(i)} from '${
|
|
53
|
+
import ${importName(i)} from '${resolveLayoutPath(layoutName2)}';
|
|
48
54
|
`, "").trim();
|
|
49
55
|
debug.layout(`Resolved layouts "${layouts.join(", ")}":`, {
|
|
50
56
|
sourceFile: id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hybridly/vite",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.13",
|
|
4
4
|
"description": "A solution to develop server-driven, client-rendered applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hybridly",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"vue": "^3.2.33"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@hybridly/core": "0.0.1-alpha.
|
|
42
|
+
"@hybridly/core": "0.0.1-alpha.13",
|
|
43
43
|
"throttle-debounce": "^5.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|