@brightbase/blocks 0.1.1 → 0.1.2
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/index.mjs +21 -2
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -150,9 +150,28 @@ async function wirePreviewRegistry(slug, exportName, installPath) {
|
|
|
150
150
|
|
|
151
151
|
const entry = ` '${slug}': () => import('${importPath}').then(m => m.${exportName}),\n`
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
// Find `previewRegistry`'s opening, then match its closing `}` with a
|
|
154
|
+
// brace-depth scan. `lastIndexOf('}')` would grab the closing brace of
|
|
155
|
+
// whichever const happens to be declared last in the file (typically
|
|
156
|
+
// `samplePropsRegistry`), leaving the new entry in the wrong export.
|
|
157
|
+
const declMatch = source.match(/export\s+const\s+previewRegistry\b[^{]*\{/)
|
|
158
|
+
if (!declMatch) {
|
|
159
|
+
console.error(' Could not find `export const previewRegistry` — add entry manually')
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
const openBraceIdx = declMatch.index + declMatch[0].length - 1
|
|
163
|
+
let depth = 1
|
|
164
|
+
let closingBrace = -1
|
|
165
|
+
for (let i = openBraceIdx + 1; i < source.length; i++) {
|
|
166
|
+
const c = source[i]
|
|
167
|
+
if (c === '{') depth++
|
|
168
|
+
else if (c === '}') {
|
|
169
|
+
depth--
|
|
170
|
+
if (depth === 0) { closingBrace = i; break }
|
|
171
|
+
}
|
|
172
|
+
}
|
|
154
173
|
if (closingBrace === -1) {
|
|
155
|
-
console.error(' Could not find closing brace — add entry manually')
|
|
174
|
+
console.error(' Could not find closing brace for previewRegistry — add entry manually')
|
|
156
175
|
return
|
|
157
176
|
}
|
|
158
177
|
|