@hybridly/vite 0.6.0 → 0.6.1

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
@@ -51,7 +51,7 @@ function determineDevelopmentEnvironmentConfigPath() {
51
51
  function resolveDevelopmentEnvironmentHost(configPath) {
52
52
  const configFile = path__default.resolve(configPath, "config.json");
53
53
  if (!fs__default.existsSync(configFile)) {
54
- throw new Error(`Unable to find the configuration file [${configFile}]. You will need to manually specify the host in the \`detectTls\` configuration option.`);
54
+ return;
55
55
  }
56
56
  const config = JSON.parse(fs__default.readFileSync(configFile, "utf-8"));
57
57
  return `${path__default.basename(process.cwd())}.${config.tld}`;
@@ -59,6 +59,9 @@ function resolveDevelopmentEnvironmentHost(configPath) {
59
59
  function resolveDevelopmentEnvironmentServerConfig() {
60
60
  const configPath = determineDevelopmentEnvironmentConfigPath();
61
61
  const host = resolveDevelopmentEnvironmentHost(configPath);
62
+ if (!host) {
63
+ return;
64
+ }
62
65
  const keyPath = path__default.resolve(configPath, "Certificates", `${host}.key`);
63
66
  const certPath = path__default.resolve(configPath, "Certificates", `${host}.crt`);
64
67
  if (!fs__default.existsSync(keyPath) || !fs__default.existsSync(certPath)) {
@@ -491,7 +494,7 @@ function didViewsOrLayoutsChange(updatedConfig, previousConfig) {
491
494
  }
492
495
 
493
496
  const TEMPLATE_LAYOUT_REGEX = /<template +layout(?: *= *['"]((?:[\w\/\-_,:](?:,\ )?)+)['"] *)?>/;
494
- const TYPESCRIPT_REGEX = /lang=['"]ts['"]/;
497
+ const LANG_REGEX = /lang=['"](\w+)['"]/;
495
498
  const layout = (options, config) => {
496
499
  const defaultLayoutName = options?.layout?.defaultLayoutName?.replace(".vue", "") ?? "default";
497
500
  const templateRegExp = options?.layout?.templateRegExp ?? TEMPLATE_LAYOUT_REGEX;
@@ -507,7 +510,7 @@ const layout = (options, config) => {
507
510
  }
508
511
  const source = new MagicString__default(code);
509
512
  const updatedCode = source.replace(templateRegExp, (_, layoutName) => {
510
- const isTypeScript = TYPESCRIPT_REGEX.test(code);
513
+ const [hasLang, lang] = code.match(LANG_REGEX) ?? [];
511
514
  const layouts = layoutName?.toString()?.replaceAll(" ", "").split(",") ?? [defaultLayoutName];
512
515
  const importName = (i) => `__hybridly_layout_${i}`;
513
516
  const exports = layouts.map((_2, i) => importName(i));
@@ -521,7 +524,7 @@ const layout = (options, config) => {
521
524
  imports
522
525
  });
523
526
  return `
524
- <script${isTypeScript ? ' lang="ts"' : ""}>
527
+ <script${hasLang ? ` lang="${lang}"` : ""}>
525
528
  ${imports}
526
529
  export default { layout: [${exports.join(", ")}] }
527
530
  <\/script>
package/dist/index.mjs CHANGED
@@ -32,7 +32,7 @@ function determineDevelopmentEnvironmentConfigPath() {
32
32
  function resolveDevelopmentEnvironmentHost(configPath) {
33
33
  const configFile = path.resolve(configPath, "config.json");
34
34
  if (!fs.existsSync(configFile)) {
35
- throw new Error(`Unable to find the configuration file [${configFile}]. You will need to manually specify the host in the \`detectTls\` configuration option.`);
35
+ return;
36
36
  }
37
37
  const config = JSON.parse(fs.readFileSync(configFile, "utf-8"));
38
38
  return `${path.basename(process.cwd())}.${config.tld}`;
@@ -40,6 +40,9 @@ function resolveDevelopmentEnvironmentHost(configPath) {
40
40
  function resolveDevelopmentEnvironmentServerConfig() {
41
41
  const configPath = determineDevelopmentEnvironmentConfigPath();
42
42
  const host = resolveDevelopmentEnvironmentHost(configPath);
43
+ if (!host) {
44
+ return;
45
+ }
43
46
  const keyPath = path.resolve(configPath, "Certificates", `${host}.key`);
44
47
  const certPath = path.resolve(configPath, "Certificates", `${host}.crt`);
45
48
  if (!fs.existsSync(keyPath) || !fs.existsSync(certPath)) {
@@ -472,7 +475,7 @@ function didViewsOrLayoutsChange(updatedConfig, previousConfig) {
472
475
  }
473
476
 
474
477
  const TEMPLATE_LAYOUT_REGEX = /<template +layout(?: *= *['"]((?:[\w\/\-_,:](?:,\ )?)+)['"] *)?>/;
475
- const TYPESCRIPT_REGEX = /lang=['"]ts['"]/;
478
+ const LANG_REGEX = /lang=['"](\w+)['"]/;
476
479
  const layout = (options, config) => {
477
480
  const defaultLayoutName = options?.layout?.defaultLayoutName?.replace(".vue", "") ?? "default";
478
481
  const templateRegExp = options?.layout?.templateRegExp ?? TEMPLATE_LAYOUT_REGEX;
@@ -488,7 +491,7 @@ const layout = (options, config) => {
488
491
  }
489
492
  const source = new MagicString(code);
490
493
  const updatedCode = source.replace(templateRegExp, (_, layoutName) => {
491
- const isTypeScript = TYPESCRIPT_REGEX.test(code);
494
+ const [hasLang, lang] = code.match(LANG_REGEX) ?? [];
492
495
  const layouts = layoutName?.toString()?.replaceAll(" ", "").split(",") ?? [defaultLayoutName];
493
496
  const importName = (i) => `__hybridly_layout_${i}`;
494
497
  const exports = layouts.map((_2, i) => importName(i));
@@ -502,7 +505,7 @@ const layout = (options, config) => {
502
505
  imports
503
506
  });
504
507
  return `
505
- <script${isTypeScript ? ' lang="ts"' : ""}>
508
+ <script${hasLang ? ` lang="${lang}"` : ""}>
506
509
  ${imports}
507
510
  export default { layout: [${exports.join(", ")}] }
508
511
  <\/script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hybridly/vite",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Vite plugin for Hybridly",
5
5
  "keywords": [
6
6
  "hybridly",
@@ -51,7 +51,7 @@
51
51
  "unplugin-icons": "^0.18.1",
52
52
  "unplugin-vue-components": "^0.26.0",
53
53
  "vite-plugin-run": "^0.5.1",
54
- "@hybridly/core": "0.6.0"
54
+ "@hybridly/core": "0.6.1"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@iconify/json": "^2.2.163",