@bagelink/blox 1.11.9 → 1.12.3

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.
@@ -1076,6 +1076,7 @@ function bloxPlugin() {
1076
1076
  transform(code, id) {
1077
1077
  if (!id.endsWith(".vue")) return;
1078
1078
  if (!code.includes("defineBlock")) return;
1079
+ console.log("[vite-plugin-blox] transforming:", id);
1079
1080
  const setupRe = /(<script\s([^>]*\bsetup\b[^>]*)>)([\s\S]*?)(<\/script>)/;
1080
1081
  const setupMatch = setupRe.exec(code);
1081
1082
  if (!setupMatch) return;
@@ -1098,12 +1099,13 @@ function bloxPlugin() {
1098
1099
  }
1099
1100
  if (remaining[i] === "\n") i++;
1100
1101
  const callExpr = remaining.slice(callStart, i).trimEnd();
1101
- const nameMatch = callExpr.match(/name\s*:\s*['"](\w+)['"]/);
1102
+ const nameMatch = callExpr.match(/name\s*:\s*['"]([\w-]+)['"]/);
1102
1103
  if (!nameMatch) {
1103
1104
  console.warn("[vite-plugin-blox] defineBlock() missing `name` — skipping");
1104
1105
  return;
1105
1106
  }
1106
1107
  const blockName = nameMatch[1];
1108
+ const exportName = blockName.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
1107
1109
  remaining = remaining.slice(0, callStart) + remaining.slice(i);
1108
1110
  const identifiers = /* @__PURE__ */ new Set();
1109
1111
  const identRe = /\b([a-z_$][\w$]*)\b/gi;
@@ -1137,17 +1139,17 @@ function bloxPlugin() {
1137
1139
  }
1138
1140
  const hoistedImports = [];
1139
1141
  const importRe = /^[ \t]*import\s[^\n]+from\s+['"](?:@bagelink\/blox|@bagelink\/vue)['"]\s*/gm;
1140
- let importMatch;
1141
- while ((importMatch = importRe.exec(remaining)) !== null) {
1142
- hoistedImports.push(importMatch[0].trimEnd());
1143
- }
1142
+ remaining = remaining.replace(importRe, (match) => {
1143
+ hoistedImports.push(match.trimEnd());
1144
+ return "";
1145
+ });
1144
1146
  const langMatch = attrs.match(/lang="([^"]+)"/);
1145
1147
  const lang = langMatch ? ` lang="${langMatch[1]}"` : "";
1146
1148
  const nonSetupBlock = [
1147
1149
  `<script${lang}>`,
1148
1150
  ...hoistedImports,
1149
1151
  ...hoistedDecls,
1150
- `export const ${blockName} = ${callExpr.trimStart()}`,
1152
+ `export const ${exportName} = ${callExpr.trimStart()}`,
1151
1153
  `<\/script>`
1152
1154
  ].join("\n");
1153
1155
  const newBlock = `${nonSetupBlock}
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAGlC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,UAAU,IAAI,MAAM,CA6HnC"}
1
+ {"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAGlC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,UAAU,IAAI,MAAM,CA+HnC"}
@@ -1074,6 +1074,7 @@ function bloxPlugin() {
1074
1074
  transform(code, id) {
1075
1075
  if (!id.endsWith(".vue")) return;
1076
1076
  if (!code.includes("defineBlock")) return;
1077
+ console.log("[vite-plugin-blox] transforming:", id);
1077
1078
  const setupRe = /(<script\s([^>]*\bsetup\b[^>]*)>)([\s\S]*?)(<\/script>)/;
1078
1079
  const setupMatch = setupRe.exec(code);
1079
1080
  if (!setupMatch) return;
@@ -1096,12 +1097,13 @@ function bloxPlugin() {
1096
1097
  }
1097
1098
  if (remaining[i] === "\n") i++;
1098
1099
  const callExpr = remaining.slice(callStart, i).trimEnd();
1099
- const nameMatch = callExpr.match(/name\s*:\s*['"](\w+)['"]/);
1100
+ const nameMatch = callExpr.match(/name\s*:\s*['"]([\w-]+)['"]/);
1100
1101
  if (!nameMatch) {
1101
1102
  console.warn("[vite-plugin-blox] defineBlock() missing `name` — skipping");
1102
1103
  return;
1103
1104
  }
1104
1105
  const blockName = nameMatch[1];
1106
+ const exportName = blockName.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
1105
1107
  remaining = remaining.slice(0, callStart) + remaining.slice(i);
1106
1108
  const identifiers = /* @__PURE__ */ new Set();
1107
1109
  const identRe = /\b([a-z_$][\w$]*)\b/gi;
@@ -1135,17 +1137,17 @@ function bloxPlugin() {
1135
1137
  }
1136
1138
  const hoistedImports = [];
1137
1139
  const importRe = /^[ \t]*import\s[^\n]+from\s+['"](?:@bagelink\/blox|@bagelink\/vue)['"]\s*/gm;
1138
- let importMatch;
1139
- while ((importMatch = importRe.exec(remaining)) !== null) {
1140
- hoistedImports.push(importMatch[0].trimEnd());
1141
- }
1140
+ remaining = remaining.replace(importRe, (match) => {
1141
+ hoistedImports.push(match.trimEnd());
1142
+ return "";
1143
+ });
1142
1144
  const langMatch = attrs.match(/lang="([^"]+)"/);
1143
1145
  const lang = langMatch ? ` lang="${langMatch[1]}"` : "";
1144
1146
  const nonSetupBlock = [
1145
1147
  `<script${lang}>`,
1146
1148
  ...hoistedImports,
1147
1149
  ...hoistedDecls,
1148
- `export const ${blockName} = ${callExpr.trimStart()}`,
1150
+ `export const ${exportName} = ${callExpr.trimStart()}`,
1149
1151
  `<\/script>`
1150
1152
  ].join("\n");
1151
1153
  const newBlock = `${nonSetupBlock}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/blox",
3
3
  "type": "module",
4
- "version": "1.11.9",
4
+ "version": "1.12.3",
5
5
  "description": "Blox page builder library for drag-and-drop page building and static data management",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
@@ -80,9 +80,9 @@
80
80
  },
81
81
  "peerDependencies": {
82
82
  "@bagelink/vue": "*",
83
+ "vite": ">=5.0.0",
83
84
  "vue": "^3.3.0",
84
- "vue-router": "^4.0.0",
85
- "vite": ">=5.0.0"
85
+ "vue-router": "^4.0.0"
86
86
  },
87
87
  "peerDependenciesMeta": {
88
88
  "vite": {
@@ -97,6 +97,7 @@
97
97
  "vite": "^5.0.0",
98
98
  "vite-plugin-dts": "^4.0.0",
99
99
  "vite-tsconfig-paths": "^5.0.0",
100
+ "vitest": "^3.2.4",
100
101
  "vue": "^3.5.16",
101
102
  "vue-router": "^4.6.3",
102
103
  "vue-tsc": "^2.0.0"