@bagelink/blox 1.12.1 → 1.12.5
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/vite-plugin.cjs
CHANGED
|
@@ -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;
|
|
@@ -1147,7 +1149,7 @@ function bloxPlugin() {
|
|
|
1147
1149
|
`<script${lang}>`,
|
|
1148
1150
|
...hoistedImports,
|
|
1149
1151
|
...hoistedDecls,
|
|
1150
|
-
`export const ${
|
|
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,
|
|
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"}
|
package/dist/vite-plugin.mjs
CHANGED
|
@@ -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;
|
|
@@ -1145,7 +1147,7 @@ function bloxPlugin() {
|
|
|
1145
1147
|
`<script${lang}>`,
|
|
1146
1148
|
...hoistedImports,
|
|
1147
1149
|
...hoistedDecls,
|
|
1148
|
-
`export const ${
|
|
1150
|
+
`export const ${exportName} = ${callExpr.trimStart()}`,
|
|
1149
1151
|
`<\/script>`
|
|
1150
1152
|
].join("\n");
|
|
1151
1153
|
const newBlock = `${nonSetupBlock}
|
package/package.json
CHANGED