@brightbase/blocks 0.1.1 → 0.1.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.
Files changed (2) hide show
  1. package/index.mjs +21 -2
  2. package/package.json +2 -2
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
- const closingBrace = source.lastIndexOf('}')
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightbase/blocks",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "CLI for installing blocks from the bbai-blocks registry into a bbai project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,6 +22,6 @@
22
22
  "license": "UNLICENSED",
23
23
  "private": false,
24
24
  "publishConfig": {
25
- "access": "restricted"
25
+ "access": "public"
26
26
  }
27
27
  }