@stacksjs/stx 0.2.143 → 0.2.145

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.
@@ -510,7 +510,7 @@ export function isCompleteImport(statement) {
510
510
  return quote === null && braces === 0 && closedSpecifier;
511
511
  }
512
512
  export function convertToCommonJS(scriptContent, filePath) {
513
- const templateDir = filePath ? path.dirname(filePath) : process.cwd(), lines = scriptContent.split(`
513
+ const templateDir = filePath ? path.dirname(filePath) : process.cwd(), projectRoot = process.cwd(), lines = scriptContent.split(`
514
514
  `), convertedLines = [];
515
515
  let i = 0;
516
516
  while (i < lines.length) {
@@ -581,6 +581,8 @@ export function convertToCommonJS(scriptContent, filePath) {
581
581
  const defaultImportMatch = statement.match(/^import\s+(\w+)\s+from\s+['"](.+?)['"]/), namedImportMatch = statement.match(/^import\s+\{([^}]*)\}\s+from\s+['"](.+?)['"]/), sideEffectMatch = statement.match(/^import\s+['"](.+?)['"]/), line_ = statement, resolveSource = (source) => {
582
582
  if (source.startsWith("."))
583
583
  return path.resolve(templateDir, source);
584
+ if (source.startsWith("~/") || source.startsWith("@/"))
585
+ return path.resolve(projectRoot, source.slice(2));
584
586
  return source;
585
587
  };
586
588
  if (defaultImportMatch) {
@@ -673,9 +675,9 @@ export function convertToCommonJS(scriptContent, filePath) {
673
675
  i++;
674
676
  }
675
677
  return resolveDynamicImports(convertedLines.join(`
676
- `), templateDir);
678
+ `), templateDir, projectRoot);
677
679
  }
678
- function resolveDynamicImports(source, templateDir) {
680
+ function resolveDynamicImports(source, templateDir, projectRoot) {
679
681
  const len = source.length;
680
682
  let out = "", i = 0, inString = null, inLineComment = !1, inBlockComment = !1, inTemplateExpr = 0;
681
683
  while (i < len) {
@@ -755,8 +757,8 @@ function resolveDynamicImports(source, templateDir) {
755
757
  const match = matchDynamicImportAt(source, i);
756
758
  if (match) {
757
759
  const { quote, path: importPath, end } = match;
758
- if (importPath.startsWith(".")) {
759
- const resolved = path.resolve(templateDir, importPath);
760
+ if (importPath.startsWith(".") || importPath.startsWith("~/") || importPath.startsWith("@/")) {
761
+ const resolved = importPath.startsWith(".") ? path.resolve(templateDir, importPath) : path.resolve(projectRoot, importPath.slice(2));
760
762
  out += `await import(${quote}${resolved}${quote})`;
761
763
  i = end;
762
764
  continue;
@@ -134,7 +134,7 @@ function findNextOpenTag(html, startFrom) {
134
134
  const match = tagRegex.exec(html);
135
135
  if (!match)
136
136
  return null;
137
- const selfClosing = /\/\s*>$/.test(match[0]) || VOID_ELEMENTS.has(match[1].toLowerCase()), attrs = selfClosing ? match[2].replace(/\/\s*$/, "") : match[2];
137
+ const selfClosing = /\/\s*>$/.test(match[0]) || match[1] === match[1].toLowerCase() && VOID_ELEMENTS.has(match[1]), attrs = selfClosing ? match[2].replace(/\/\s*$/, "") : match[2];
138
138
  return {
139
139
  full: match[0],
140
140
  tag: match[1],
@@ -355,7 +355,7 @@ function transformVModel(html) {
355
355
  searchFrom = tag.end;
356
356
  continue;
357
357
  }
358
- if (NATIVE_ELEMENTS.has(tag.tag.toLowerCase())) {
358
+ if (NATIVE_ELEMENTS.has(tag.tag)) {
359
359
  const newAttrs = tag.attrs.replace(/\s*v-model="[^"]*"/g, "") + ` @model="${modelValue}"`, range = getElementRange(result, tag), element = result.slice(range.outerStart, range.outerEnd), newElement = replaceTagAttrs(element, {
360
360
  ...tag,
361
361
  start: 0,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.143",
4
+ "version": "0.2.145",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -117,12 +117,12 @@
117
117
  "dependencies": {
118
118
  "@cwcss/crosswind": "^0.2.14",
119
119
  "@stacksjs/clapp": "^0.2.0",
120
- "@stacksjs/desktop": "0.2.143",
121
- "@stacksjs/sanitizer": "0.2.143",
120
+ "@stacksjs/desktop": "0.2.145",
121
+ "@stacksjs/sanitizer": "0.2.145",
122
122
  "@stacksjs/ts-i18n": "^0.1.11",
123
- "bun-plugin-stx": "0.2.143",
123
+ "bun-plugin-stx": "0.2.145",
124
124
  "bunfig": "^0.15.15",
125
- "stx-router": "0.2.143",
125
+ "stx-router": "0.2.145",
126
126
  "ts-broadcasting": "^0.0.9",
127
127
  "ts-images": "^0.1.9",
128
128
  "ts-syntax-highlighter": "^0.2.1"