@hybridly/vite 0.0.1-alpha.11 → 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 CHANGED
@@ -27,14 +27,26 @@ const debug = {
27
27
  layout: makeDebugger__default(LAYOUT_PLUGIN_NAME)
28
28
  };
29
29
 
30
- const TEMPLATE_LAYOUT_REGEX = /<template +layout(?: *= *['"]((?:[\w\/-_,](?:,\ )?)+)['"] *)?>/;
30
+ 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 base = options?.directory ?? path__default.resolve(process.cwd(), "resources", "views", "layouts");
34
+ const layoutsDirectory = options?.directory ?? path__default.resolve(process.cwd(), "resources", "views", "layouts");
35
35
  const templateRegExp = options?.templateRegExp ?? TEMPLATE_LAYOUT_REGEX;
36
- const getLayoutPath = options?.resolve ?? ((layoutName) => vite.normalizePath(path__default.resolve(base, `${layoutName}.vue`)).replaceAll("\\", "/"));
37
- debug.layout("Registered layout path:", base);
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
49
+ });
38
50
  return {
39
51
  name: LAYOUT_PLUGIN_NAME,
40
52
  transform: (code, id) => {
@@ -48,7 +60,7 @@ const layout = (options = {}) => {
48
60
  const exports = layouts.map((_2, i) => importName(i));
49
61
  const imports = layouts.reduce((imports2, layoutName2, i) => `
50
62
  ${imports2}
51
- import ${importName(i)} from '${getLayoutPath(layoutName2)}';
63
+ import ${importName(i)} from '${resolveLayoutPath(layoutName2)}';
52
64
  `, "").trim();
53
65
  debug.layout(`Resolved layouts "${layouts.join(", ")}":`, {
54
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
@@ -17,14 +17,26 @@ const debug = {
17
17
  layout: makeDebugger(LAYOUT_PLUGIN_NAME)
18
18
  };
19
19
 
20
- const TEMPLATE_LAYOUT_REGEX = /<template +layout(?: *= *['"]((?:[\w\/-_,](?:,\ )?)+)['"] *)?>/;
20
+ 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 base = options?.directory ?? path.resolve(process.cwd(), "resources", "views", "layouts");
24
+ const layoutsDirectory = options?.directory ?? path.resolve(process.cwd(), "resources", "views", "layouts");
25
25
  const templateRegExp = options?.templateRegExp ?? TEMPLATE_LAYOUT_REGEX;
26
- const getLayoutPath = options?.resolve ?? ((layoutName) => normalizePath(path.resolve(base, `${layoutName}.vue`)).replaceAll("\\", "/"));
27
- debug.layout("Registered layout path:", base);
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
39
+ });
28
40
  return {
29
41
  name: LAYOUT_PLUGIN_NAME,
30
42
  transform: (code, id) => {
@@ -38,7 +50,7 @@ const layout = (options = {}) => {
38
50
  const exports = layouts.map((_2, i) => importName(i));
39
51
  const imports = layouts.reduce((imports2, layoutName2, i) => `
40
52
  ${imports2}
41
- import ${importName(i)} from '${getLayoutPath(layoutName2)}';
53
+ import ${importName(i)} from '${resolveLayoutPath(layoutName2)}';
42
54
  `, "").trim();
43
55
  debug.layout(`Resolved layouts "${layouts.join(", ")}":`, {
44
56
  sourceFile: id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hybridly/vite",
3
- "version": "0.0.1-alpha.11",
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.11",
42
+ "@hybridly/core": "0.0.1-alpha.13",
43
43
  "throttle-debounce": "^5.0.0"
44
44
  },
45
45
  "devDependencies": {