cbs-block 1.0.7 â 1.0.9
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/README.md +55 -26
- package/bin/cbs-block.js +64 -0
- package/package.json +2 -2
- package/preview_web.html +50 -0
package/README.md
CHANGED
|
@@ -1,55 +1,84 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ð CodeBlock Studio SDK (CLI)
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The professional toolkit for building, testing, and sharing **CodeBlock Studio** extensions.
|
|
4
|
+
|
|
5
|
+
Built for performance. Designed for developers.
|
|
6
|
+
|
|
7
|
+
---
|
|
4
8
|
|
|
5
9
|
## ðĶ Installation
|
|
6
10
|
|
|
7
|
-
Install
|
|
11
|
+
Install globally to use the `cbs-block` command anywhere:
|
|
8
12
|
|
|
9
13
|
```bash
|
|
10
14
|
npm install cbs-block -g
|
|
11
15
|
```
|
|
12
16
|
|
|
17
|
+
## ð ïļ Feature Highlights
|
|
18
|
+
|
|
19
|
+
* **Code-First Workflow**: Build complex blocks with full folder structures, supporting `index.js/ts`, `package.json`, and local `node_modules`.
|
|
20
|
+
* **Integrated Unit Testing**: Run logic tests instantly with `cbs-block test`.
|
|
21
|
+
* **Micro-Benchmarking**: Performance-test your logic with `cbs-block bench` (100k iteration analysis).
|
|
22
|
+
* **Integrated Tutorials**: Every new project includes a beautiful, CSS-rich `tutorial.html`. View it via `cbs-block tutorial`.
|
|
23
|
+
* **VSIX-Style Packaging**: Bundle your workspace into a professional `.cbsext` extension with one command.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
13
27
|
## ð Quick Start
|
|
14
28
|
|
|
15
29
|
### 1. Initialize a Project
|
|
16
30
|
Create a new workspace for your block library:
|
|
17
31
|
```bash
|
|
18
|
-
cbs-block init
|
|
19
|
-
cd
|
|
32
|
+
cbs-block init MyAwesomePack
|
|
33
|
+
cd MyAwesomePack
|
|
20
34
|
```
|
|
21
35
|
|
|
22
|
-
### 2. Create
|
|
23
|
-
Generate a
|
|
36
|
+
### 2. Create a Block
|
|
37
|
+
Generate a professional directory-based block:
|
|
24
38
|
```bash
|
|
25
|
-
cbs-block create
|
|
39
|
+
cbs-block create MyBlock
|
|
26
40
|
```
|
|
27
41
|
|
|
28
|
-
### 3.
|
|
29
|
-
|
|
42
|
+
### 3. Develop & Test
|
|
43
|
+
Open `index.js`, write your logic, and test it:
|
|
30
44
|
```bash
|
|
31
45
|
cbs-block build
|
|
46
|
+
cbs-block test myblock.cbsblock
|
|
32
47
|
```
|
|
33
48
|
|
|
49
|
+
### 4. Pack & Share
|
|
50
|
+
Bundle your workspace into a professional extension:
|
|
51
|
+
```bash
|
|
52
|
+
cbs-block pack
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
34
57
|
## ð ïļ Command Reference
|
|
35
58
|
|
|
36
59
|
| Command | Description |
|
|
37
60
|
| --- | --- |
|
|
38
|
-
| `init
|
|
39
|
-
| `create
|
|
40
|
-
| `
|
|
41
|
-
| `
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
44
|
-
| `
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
| `init [name]` | Initialize a new block project workspace. |
|
|
62
|
+
| `create [name]` | Scaffold a new block (supports Directory or Single-File mode). |
|
|
63
|
+
| `build [dir]` | Compile a directory block into a production `.cbsblock`. |
|
|
64
|
+
| `pack` | Bundle your workspace into a professional `.cbsext` extension. |
|
|
65
|
+
| `test <file>` | Run logic unit tests with mock data. |
|
|
66
|
+
| `bench <file>` | Benchmark block logic performance (iterations & Ξs). |
|
|
67
|
+
| `tutorial` | Open the integrated developer guide in your browser. |
|
|
68
|
+
| `link` | Link local blocks to your CodeBlock Studio installation. |
|
|
69
|
+
| `publish` | Deploys your package to the global CBS Marketplace. |
|
|
70
|
+
| `site` | Generate a themed documentation website for your project. |
|
|
71
|
+
| `doc <file>` | Generate a markdown README for a specific block. |
|
|
72
|
+
| `lint` | Validate block definitions for schema compliance. |
|
|
73
|
+
| `status` | Check SDK version and environment health. |
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## ð§Đ The .cbsext Format
|
|
78
|
+
Professional extensions are packaged as ZIP-based `.cbsext` files. This allows for:
|
|
79
|
+
- **Rich Assets**: Bundle icons, helper scripts, and HTML tutorials into one file.
|
|
80
|
+
- **Enterprise Metadata**: Verified publisher IDs and display names.
|
|
81
|
+
- **Dependency Isolation**: Fully bundled logic with optimized execution.
|
|
53
82
|
|
|
54
83
|
---
|
|
55
|
-
**Build the future of visual coding with CodeBlock Studio.**
|
|
84
|
+
**Build the future of visual coding with [CodeBlock Studio](https://codeblockstudio.web.app).**
|
package/bin/cbs-block.js
CHANGED
|
@@ -307,6 +307,69 @@ async function main() {
|
|
|
307
307
|
fs.writeFileSync(path.join(docsDir, 'index.html'), html);
|
|
308
308
|
console.log(chalk.green(`\nâ Site generated at docs/index.html`));
|
|
309
309
|
|
|
310
|
+
} else if (command === 'web' && target) {
|
|
311
|
+
if (!fs.existsSync(target)) return console.error(chalk.red(`Error: File ${target} not found.`));
|
|
312
|
+
const block = JSON.parse(fs.readFileSync(target, 'utf8'));
|
|
313
|
+
console.log(chalk.cyan(`Launching Web Preview for: ${block.name}...`));
|
|
314
|
+
|
|
315
|
+
const previewHtml = `<!DOCTYPE html>
|
|
316
|
+
<html>
|
|
317
|
+
<head>
|
|
318
|
+
<title>CBS Block Preview - ${block.name}</title>
|
|
319
|
+
<style>
|
|
320
|
+
body { background: #0f0f12; color: #eee; font-family: 'Segoe UI', system-ui; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; margin: 0; }
|
|
321
|
+
.block-preview {
|
|
322
|
+
background: linear-gradient(135deg, ${block.color || '#4CAF50'}, ${block.color ? block.color + 'CC' : '#45a049'});
|
|
323
|
+
padding: 20px; border-radius: 12px; min-width: 200px;
|
|
324
|
+
box-shadow: 0 10px 30px rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.2);
|
|
325
|
+
position: relative;
|
|
326
|
+
}
|
|
327
|
+
.header { font-weight: bold; margin-bottom: 20px; font-size: 1.1em; border-bottom: 1px solid rgba(255,255,255,0.2); padding-bottom: 5px; }
|
|
328
|
+
.port { width: 12px; height: 12px; background: #fff; border-radius: 50%; position: absolute; }
|
|
329
|
+
.port-flow { width: 16px; border-radius: 2px; }
|
|
330
|
+
.controls { margin-top: 40px; background: #1a1a20; padding: 20px; border-radius: 8px; border: 1px solid #333; }
|
|
331
|
+
button { background: #007acc; color: white; border: none; padding: 8px 20px; border-radius: 4px; cursor: pointer; font-weight: bold; }
|
|
332
|
+
button:hover { background: #0062a3; }
|
|
333
|
+
pre { background: #000; padding: 10px; border-radius: 4px; color: #4CAF50; font-size: 0.9em; }
|
|
334
|
+
</style>
|
|
335
|
+
</head>
|
|
336
|
+
<body>
|
|
337
|
+
<h1>CodeBlock Studio Simulator</h1>
|
|
338
|
+
<div class="block-preview">
|
|
339
|
+
<div class="header">${block.name}</div>
|
|
340
|
+
<div style="font-size: 0.8em; opacity: 0.7;">Category: ${block.category}</div>
|
|
341
|
+
<div style="margin-top: 20px;">
|
|
342
|
+
${block.ports.map(p => `<div style="font-size: 0.8em; margin: 5px 0;">â ${p.name} (${p.type})</div>`).join('')}
|
|
343
|
+
</div>
|
|
344
|
+
</div>
|
|
345
|
+
<div class="controls">
|
|
346
|
+
<h3>Logic Test</h3>
|
|
347
|
+
<button onclick="runTest()">Run Logic</button>
|
|
348
|
+
<p>Results:</p>
|
|
349
|
+
<pre id="output">Ready...</pre>
|
|
350
|
+
</div>
|
|
351
|
+
<script>
|
|
352
|
+
const logic = \`${block.logic.replace(/`/g, '\\`').replace(/\$/g, '\\$')}\`;
|
|
353
|
+
function runTest() {
|
|
354
|
+
try {
|
|
355
|
+
const runFunc = new Function('inputs', logic + '\\nreturn run(inputs);');
|
|
356
|
+
const result = runFunc({ input1: "Web Test Value" });
|
|
357
|
+
document.getElementById('output').textContent = "Output: " + JSON.stringify(result, null, 2);
|
|
358
|
+
} catch (e) {
|
|
359
|
+
document.getElementById('output').textContent = "Error: " + e.message;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
</script>
|
|
363
|
+
</body>
|
|
364
|
+
</html>`;
|
|
365
|
+
|
|
366
|
+
const outPath = path.join(process.cwd(), 'preview_web.html');
|
|
367
|
+
fs.writeFileSync(outPath, previewHtml);
|
|
368
|
+
console.log(chalk.green(`â Preview generated: ${outPath}`));
|
|
369
|
+
|
|
370
|
+
const start = process.platform === 'win32' ? 'start' : process.platform === 'darwin' ? 'open' : 'xdg-open';
|
|
371
|
+
exec(`${start} ${outPath}`);
|
|
372
|
+
|
|
310
373
|
} else if (command === 'version' && target === '--bump') {
|
|
311
374
|
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
|
312
375
|
const [major, minor, patch] = pkg.version.split('.').map(Number);
|
|
@@ -331,6 +394,7 @@ async function main() {
|
|
|
331
394
|
console.log(` ${chalk.bold('doc <file>')} - Generate markdown documentation`);
|
|
332
395
|
console.log(` ${chalk.bold('link')} - Link blocks to main CodeBlock Studio app`);
|
|
333
396
|
console.log(` ${chalk.bold('lint')} - Validate block definitions`);
|
|
397
|
+
console.log(` ${chalk.bold('web <file>')} - Preview block in a high-fidelity web simulator`);
|
|
334
398
|
console.log(` ${chalk.bold('status')} - Show SDK & environment status`);
|
|
335
399
|
}
|
|
336
400
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cbs-block",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "SDK for creating CodeBlock Studio blocks",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"cbs-block": "
|
|
7
|
+
"cbs-block": "bin/cbs-block.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1"
|
package/preview_web.html
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>CBS Block Preview - MyBlock</title>
|
|
5
|
+
<style>
|
|
6
|
+
body { background: #0f0f12; color: #eee; font-family: 'Segoe UI', system-ui; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; margin: 0; }
|
|
7
|
+
.block-preview {
|
|
8
|
+
background: linear-gradient(135deg, #4CAF50, #45a049);
|
|
9
|
+
padding: 20px; border-radius: 12px; min-width: 200px;
|
|
10
|
+
box-shadow: 0 10px 30px rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.2);
|
|
11
|
+
position: relative;
|
|
12
|
+
}
|
|
13
|
+
.header { font-weight: bold; margin-bottom: 20px; font-size: 1.1em; border-bottom: 1px solid rgba(255,255,255,0.2); padding-bottom: 5px; }
|
|
14
|
+
.port { width: 12px; height: 12px; background: #fff; border-radius: 50%; position: absolute; }
|
|
15
|
+
.port-flow { width: 16px; border-radius: 2px; }
|
|
16
|
+
.controls { margin-top: 40px; background: #1a1a20; padding: 20px; border-radius: 8px; border: 1px solid #333; }
|
|
17
|
+
button { background: #007acc; color: white; border: none; padding: 8px 20px; border-radius: 4px; cursor: pointer; font-weight: bold; }
|
|
18
|
+
button:hover { background: #0062a3; }
|
|
19
|
+
pre { background: #000; padding: 10px; border-radius: 4px; color: #4CAF50; font-size: 0.9em; }
|
|
20
|
+
</style>
|
|
21
|
+
</head>
|
|
22
|
+
<body>
|
|
23
|
+
<h1>CodeBlock Studio Simulator</h1>
|
|
24
|
+
<div class="block-preview">
|
|
25
|
+
<div class="header">MyBlock</div>
|
|
26
|
+
<div style="font-size: 0.8em; opacity: 0.7;">Category: Custom</div>
|
|
27
|
+
<div style="margin-top: 20px;">
|
|
28
|
+
<div style="font-size: 0.8em; margin: 5px 0;">â input1 (Input)</div><div style="font-size: 0.8em; margin: 5px 0;">â output1 (Output)</div>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
<div class="controls">
|
|
32
|
+
<h3>Logic Test</h3>
|
|
33
|
+
<button onclick="runTest()">Run Logic</button>
|
|
34
|
+
<p>Results:</p>
|
|
35
|
+
<pre id="output">Ready...</pre>
|
|
36
|
+
</div>
|
|
37
|
+
<script>
|
|
38
|
+
const logic = `function run(inputs) { return inputs.input1; }`;
|
|
39
|
+
function runTest() {
|
|
40
|
+
try {
|
|
41
|
+
const runFunc = new Function('inputs', logic + '\nreturn run(inputs);');
|
|
42
|
+
const result = runFunc({ input1: "Web Test Value" });
|
|
43
|
+
document.getElementById('output').textContent = "Output: " + JSON.stringify(result, null, 2);
|
|
44
|
+
} catch (e) {
|
|
45
|
+
document.getElementById('output').textContent = "Error: " + e.message;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
49
|
+
</body>
|
|
50
|
+
</html>
|