@bagelink/blox 1.15.269 → 1.15.271

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.
@@ -265,7 +265,7 @@ function bloxPlugin(options = {}) {
265
265
  const blockName = nameMatch[1];
266
266
  const exportName = blockName.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
267
267
  remaining = remaining.slice(0, callStart) + remaining.slice(i);
268
- const scannable = callExpr.replace(/'(?:\\.|[^'\\])*'/g, "''").replace(/"(?:\\.|[^"\\])*"/g, '""').replace(/`(?:\\.|[^`\\])*`/g, "``").replace(/([a-z_$][\w$]*)\s*:/gi, ":");
268
+ const scannable = callExpr.replace(/'(?:\\.|[^'\\])*'/g, "''").replace(/"(?:\\.|[^"\\])*"/g, '""').replace(/`(?:\\.|[^`\\])*`/g, "``").replace(/\.\s*[a-z_$][\w$]*/gi, "").replace(/([a-z_$][\w$]*)\s*:/gi, ":");
269
269
  const identifiers = /* @__PURE__ */ new Set();
270
270
  const identRe = /\b([a-z_$][\w$]*)\b/gi;
271
271
  let identMatch;
@@ -280,8 +280,21 @@ function bloxPlugin(options = {}) {
280
280
  while ((identMatch = identRe.exec(scannable)) !== null) {
281
281
  if (!SKIP_IDENTS.has(identMatch[1])) identifiers.add(identMatch[1]);
282
282
  }
283
- for (const ident of identifiers) {
284
- if (ident === "defineBlock") continue;
283
+ const declaredIdents = /* @__PURE__ */ new Set();
284
+ const queue = [...identifiers].filter((id2) => id2 !== "defineBlock");
285
+ const refsIn = (src) => {
286
+ const scan = src.replace(/'(?:\\.|[^'\\])*'/g, "''").replace(/"(?:\\.|[^"\\])*"/g, '""').replace(/`(?:\\.|[^`\\])*`/g, "``").replace(/\.\s*[a-z_$][\w$]*/gi, "").replace(/([a-z_$][\w$]*)\s*:/gi, ":");
287
+ const out = [];
288
+ let m;
289
+ const re = /\b([a-z_$][\w$]*)\b/gi;
290
+ while ((m = re.exec(scan)) !== null) {
291
+ if (!SKIP_IDENTS.has(m[1])) out.push(m[1]);
292
+ }
293
+ return out;
294
+ };
295
+ while (queue.length) {
296
+ const ident = queue.shift();
297
+ if (ident === "defineBlock" || declaredIdents.has(ident)) continue;
285
298
  const declRe = new RegExp(`^([ \\t]*const\\s+${ident}\\s*=\\s*)`, "m");
286
299
  const declMatch = declRe.exec(remaining);
287
300
  if (!declMatch) continue;
@@ -302,8 +315,13 @@ function bloxPlugin(options = {}) {
302
315
  j++;
303
316
  }
304
317
  const fullDecl = remaining.slice(declStart, j).trimEnd();
305
- hoistedDecls.push(fullDecl);
318
+ hoistedDecls.unshift(fullDecl);
319
+ declaredIdents.add(ident);
306
320
  remaining = remaining.slice(0, declStart) + remaining.slice(j);
321
+ for (const ref of refsIn(fullDecl.slice(declMatch[0].length))) {
322
+ identifiers.add(ref);
323
+ if (!declaredIdents.has(ref)) queue.push(ref);
324
+ }
307
325
  }
308
326
  const hoistedImports = [];
309
327
  const importRe = /^[ \t]*import\s+(\{[^}]*\})\s+from\s+(['"](?:@bagelink\/blox|@bagelink\/vue)['"])\s*;?[ \t]*$/gm;
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,MAAM,CAAA;AAM9C,MAAM,WAAW,iBAAiB;IACjC;;;;;OAKG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM,EAAE,CAibpE"}
1
+ {"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,MAAM,CAAA;AAM9C,MAAM,WAAW,iBAAiB;IACjC;;;;;OAKG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM,EAAE,CA8dpE"}
@@ -241,7 +241,7 @@ function bloxPlugin(options = {}) {
241
241
  const blockName = nameMatch[1];
242
242
  const exportName = blockName.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
243
243
  remaining = remaining.slice(0, callStart) + remaining.slice(i);
244
- const scannable = callExpr.replace(/'(?:\\.|[^'\\])*'/g, "''").replace(/"(?:\\.|[^"\\])*"/g, '""').replace(/`(?:\\.|[^`\\])*`/g, "``").replace(/([a-z_$][\w$]*)\s*:/gi, ":");
244
+ const scannable = callExpr.replace(/'(?:\\.|[^'\\])*'/g, "''").replace(/"(?:\\.|[^"\\])*"/g, '""').replace(/`(?:\\.|[^`\\])*`/g, "``").replace(/\.\s*[a-z_$][\w$]*/gi, "").replace(/([a-z_$][\w$]*)\s*:/gi, ":");
245
245
  const identifiers = /* @__PURE__ */ new Set();
246
246
  const identRe = /\b([a-z_$][\w$]*)\b/gi;
247
247
  let identMatch;
@@ -256,8 +256,21 @@ function bloxPlugin(options = {}) {
256
256
  while ((identMatch = identRe.exec(scannable)) !== null) {
257
257
  if (!SKIP_IDENTS.has(identMatch[1])) identifiers.add(identMatch[1]);
258
258
  }
259
- for (const ident of identifiers) {
260
- if (ident === "defineBlock") continue;
259
+ const declaredIdents = /* @__PURE__ */ new Set();
260
+ const queue = [...identifiers].filter((id2) => id2 !== "defineBlock");
261
+ const refsIn = (src) => {
262
+ const scan = src.replace(/'(?:\\.|[^'\\])*'/g, "''").replace(/"(?:\\.|[^"\\])*"/g, '""').replace(/`(?:\\.|[^`\\])*`/g, "``").replace(/\.\s*[a-z_$][\w$]*/gi, "").replace(/([a-z_$][\w$]*)\s*:/gi, ":");
263
+ const out = [];
264
+ let m;
265
+ const re = /\b([a-z_$][\w$]*)\b/gi;
266
+ while ((m = re.exec(scan)) !== null) {
267
+ if (!SKIP_IDENTS.has(m[1])) out.push(m[1]);
268
+ }
269
+ return out;
270
+ };
271
+ while (queue.length) {
272
+ const ident = queue.shift();
273
+ if (ident === "defineBlock" || declaredIdents.has(ident)) continue;
261
274
  const declRe = new RegExp(`^([ \\t]*const\\s+${ident}\\s*=\\s*)`, "m");
262
275
  const declMatch = declRe.exec(remaining);
263
276
  if (!declMatch) continue;
@@ -278,8 +291,13 @@ function bloxPlugin(options = {}) {
278
291
  j++;
279
292
  }
280
293
  const fullDecl = remaining.slice(declStart, j).trimEnd();
281
- hoistedDecls.push(fullDecl);
294
+ hoistedDecls.unshift(fullDecl);
295
+ declaredIdents.add(ident);
282
296
  remaining = remaining.slice(0, declStart) + remaining.slice(j);
297
+ for (const ref of refsIn(fullDecl.slice(declMatch[0].length))) {
298
+ identifiers.add(ref);
299
+ if (!declaredIdents.has(ref)) queue.push(ref);
300
+ }
283
301
  }
284
302
  const hoistedImports = [];
285
303
  const importRe = /^[ \t]*import\s+(\{[^}]*\})\s+from\s+(['"](?:@bagelink\/blox|@bagelink\/vue)['"])\s*;?[ \t]*$/gm;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/blox",
3
3
  "type": "module",
4
- "version": "1.15.269",
4
+ "version": "1.15.271",
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",