blueprintsjs 0.0.0-stage → 0.2.0
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/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +165 -2
- package/dist/blueprintsjs.umd.cjs +325 -0
- package/dist/blueprintsjs.umd.cjs.map +1 -0
- package/dist/chunks/validate-DHOIGyop.js +860 -0
- package/dist/chunks/validate-DHOIGyop.js.map +1 -0
- package/dist/chunks/validate-Ddbqd8bD.cjs +859 -0
- package/dist/chunks/validate-Ddbqd8bD.cjs.map +1 -0
- package/dist/core/build.d.cts +33 -0
- package/dist/core/build.d.ts +33 -0
- package/dist/core/compile.d.cts +27 -0
- package/dist/core/compile.d.ts +27 -0
- package/dist/core/helpers.d.cts +13 -0
- package/dist/core/helpers.d.ts +13 -0
- package/dist/core/layout.d.cts +19 -0
- package/dist/core/layout.d.ts +19 -0
- package/dist/core/registry.d.cts +23 -0
- package/dist/core/registry.d.ts +23 -0
- package/dist/core/schema.d.cts +14 -0
- package/dist/core/schema.d.ts +14 -0
- package/dist/core/types.d.cts +215 -0
- package/dist/core/types.d.ts +215 -0
- package/dist/core/validate.d.cts +9 -0
- package/dist/core/validate.d.ts +9 -0
- package/dist/editor/GraphEditor.d.cts +181 -0
- package/dist/editor/GraphEditor.d.ts +181 -0
- package/dist/editor/details.d.cts +23 -0
- package/dist/editor/details.d.ts +23 -0
- package/dist/editor/dom.d.cts +20 -0
- package/dist/editor/dom.d.ts +20 -0
- package/dist/editor/highlight.d.cts +7 -0
- package/dist/editor/highlight.d.ts +7 -0
- package/dist/editor/index.d.cts +13 -0
- package/dist/editor/index.d.ts +13 -0
- package/dist/editor/state.d.cts +113 -0
- package/dist/editor/state.d.ts +113 -0
- package/dist/editor/styles.d.cts +7 -0
- package/dist/editor/styles.d.ts +7 -0
- package/dist/editor.cjs +2196 -0
- package/dist/editor.cjs.map +1 -0
- package/dist/editor.js +2196 -0
- package/dist/editor.js.map +1 -0
- package/dist/index.cjs +1251 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +1252 -0
- package/dist/index.js.map +1 -0
- package/dist/locales/index.d.cts +15 -0
- package/dist/locales/index.d.ts +15 -0
- package/dist/locales/ru.d.cts +3 -0
- package/dist/locales/ru.d.ts +3 -0
- package/dist/locales/uk.d.cts +3 -0
- package/dist/locales/uk.d.ts +3 -0
- package/dist/locales.cjs +579 -0
- package/dist/locales.cjs.map +1 -0
- package/dist/locales.js +579 -0
- package/dist/locales.js.map +1 -0
- package/dist/nodes/data.d.cts +26 -0
- package/dist/nodes/data.d.ts +26 -0
- package/dist/nodes/dom.d.cts +27 -0
- package/dist/nodes/dom.d.ts +27 -0
- package/dist/nodes/events.d.cts +11 -0
- package/dist/nodes/events.d.ts +11 -0
- package/dist/nodes/flow.d.cts +10 -0
- package/dist/nodes/flow.d.ts +10 -0
- package/dist/nodes/index.d.cts +11 -0
- package/dist/nodes/index.d.ts +11 -0
- package/dist/nodes/lib.d.cts +7 -0
- package/dist/nodes/lib.d.ts +7 -0
- package/dist/umd.d.cts +5 -0
- package/dist/umd.d.ts +5 -0
- package/dist/version.d.cts +2 -0
- package/dist/version.d.ts +2 -0
- package/docs/compiler.md +149 -0
- package/docs/custom-nodes.md +119 -0
- package/docs/editor.md +166 -0
- package/docs/guide.md +79 -0
- package/docs/nodes.md +494 -0
- package/docs/nodes.ru.md +494 -0
- package/docs/schema.md +64 -0
- package/examples/index.html +110 -0
- package/package.json +107 -4
- package/schema/blueprint.schema.json +102 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0 — 2026-11-17
|
|
4
|
+
|
|
5
|
+
- Read-only viewer: `GraphEditor` options `readonly`, `movable`, `onNodeClick`, `nodeClass`, `showCode`, `autoLayout`; methods `layout()` and `refresh()`. Nodes and links cannot be changed; pan, zoom, fit, minimap and selection work.
|
|
6
|
+
- Node instances: optional `title`, `lines` and `color`.
|
|
7
|
+
- Display-only node types: `compile` is optional; compiling one yields a warning and no code.
|
|
8
|
+
- `autoLayout(bp, options)` in the core: layered layout (longest path, back edges ignored, barycentre sweeps).
|
|
9
|
+
|
|
10
|
+
## 0.1.0 — 2026-11-17
|
|
11
|
+
|
|
12
|
+
First release, extracted from the `grapesjs-scripts` GrapesJS plugin so other apps can use it.
|
|
13
|
+
|
|
14
|
+
- Core (`blueprintsjs`): blueprint model and JSON Schema, node registry with typed pins and dynamic pins, validation with stable diagnostic codes, compiler to ES5 with on-demand runtime helpers, page/preview/component builds with `dispose`.
|
|
15
|
+
- 63 built-in nodes: events, flow, DOM, data, variables, math, logic, global libraries, custom JavaScript.
|
|
16
|
+
- Editor (`blueprintsjs/editor`): full-window graph editor (palette, typed wires, search, comments, minimap, undo/redo, clipboard, inline values, details panel, problems, JavaScript view), `embedded` mode that fills a parent element (tabs, split views), `GraphState` editing model, `createText` for translations.
|
|
17
|
+
- Locales (`blueprintsjs/locales`): Russian and Ukrainian.
|
|
18
|
+
- Builds: ESM, CommonJS, UMD (`window.Blueprints`), TypeScript declarations for both module systems.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 shibisty
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,166 @@
|
|
|
1
|
-
#
|
|
1
|
+
# blueprintsjs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Visual scripting for the web. Build behaviour from **node graphs** — "blueprints", in the spirit of Unreal Engine 5 Blueprints and n8n — and compile them to **plain, dependency-free JavaScript** that runs on any page.
|
|
4
|
+
|
|
5
|
+
- **Graph → JavaScript compiler.** ES5 output, no runtime library: only the few helpers a graph uses are inlined. Every blueprint returns a `dispose` function that removes its listeners and timers.
|
|
6
|
+
- **63 built-in nodes**: events (element, page, timer, keyboard, custom), flow (branch, sequence, delay, debounce, throttle, do-once, for-each, switch), DOM, data, variables, math, logic, global libraries (`gsap.to`, `new Swiper(…)`), and a **custom JavaScript node** for everything else.
|
|
7
|
+
- **Embeddable graph editor**: drag-and-drop palette, typed wires, node search, comments, minimap, undo/redo, copy/paste, inline values, problems list and a live JavaScript view. Framework-free (DOM + SVG).
|
|
8
|
+
- **Extensible**: a node is data (pins, settings) plus a `compile` function — the built-ins use the same API.
|
|
9
|
+
- **Plain JSON** blueprints with a [JSON Schema](schema/blueprint.schema.json).
|
|
10
|
+
- **Typed** (TypeScript), ESM + CommonJS + a `<script>` build, no dependencies. The core runs without a DOM (Node, workers, build steps).
|
|
11
|
+
- Editor translations: English built in, Russian and Ukrainian included.
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
On element event (.js-open, click) ──exec──▶ Add class (#popup, is-open)
|
|
15
|
+
On element event (.js-close, click) ─exec──▶ Remove class (#popup, is-open)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
compiles to (comments trimmed):
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
(function () {
|
|
22
|
+
'use strict';
|
|
23
|
+
var blueprints = [{ id: "bp_popup", when: null, run: function (root, ctx) {
|
|
24
|
+
var __d = [];
|
|
25
|
+
__bp_delegate(__d, root, "click", ".js-open", function (event, self) {
|
|
26
|
+
__bp_q(root, "#popup").forEach(function (el) { el.classList.add("is-open"); });
|
|
27
|
+
});
|
|
28
|
+
__bp_delegate(__d, root, "click", ".js-close", function (event, self) {
|
|
29
|
+
__bp_q(root, "#popup").forEach(function (el) { el.classList.remove("is-open"); });
|
|
30
|
+
});
|
|
31
|
+
return function () { __d.splice(0).forEach(function (f) { try { f(); } catch (e) {} }); };
|
|
32
|
+
} }];
|
|
33
|
+
function start(doc) { /* runs every blueprint, collects their dispose functions */ }
|
|
34
|
+
// Runtime helpers — only the ones used
|
|
35
|
+
function __bp_delegate(d, root, type, sel, fn) { /* … */ }
|
|
36
|
+
function __bp_q(root, sel, mode, from) { /* … */ }
|
|
37
|
+
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', function () { start(document); });
|
|
38
|
+
else start(document);
|
|
39
|
+
})();
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
npm install blueprintsjs
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Or without a bundler:
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<script src="https://cdn.jsdelivr.net/npm/blueprintsjs@0.1/dist/blueprintsjs.umd.cjs"></script>
|
|
52
|
+
<script>
|
|
53
|
+
const { createRegistry, buildScript, GraphEditor, createText, locales } = window.Blueprints;
|
|
54
|
+
</script>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
| Import | What | DOM |
|
|
58
|
+
|---|---|---|
|
|
59
|
+
| `blueprintsjs` | model, registry, built-in nodes, validation, compiler | not needed |
|
|
60
|
+
| `blueprintsjs/editor` | `GraphEditor`, `GraphState`, `createText`, syntax highlighter | needed |
|
|
61
|
+
| `blueprintsjs/locales` | editor translations (`ru`, `uk`) | not needed |
|
|
62
|
+
| `blueprintsjs/schema.json` | JSON Schema of a blueprint | — |
|
|
63
|
+
| `blueprintsjs/umd` | everything in one file for `<script>` (`window.Blueprints`) | — |
|
|
64
|
+
|
|
65
|
+
## Quick start
|
|
66
|
+
|
|
67
|
+
### Compile a blueprint
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
import { createRegistry, createBlueprint, buildScript } from 'blueprintsjs';
|
|
71
|
+
|
|
72
|
+
const registry = createRegistry(); // the built-in nodes (+ your own: createRegistry([myNode]))
|
|
73
|
+
|
|
74
|
+
const popup = createBlueprint({
|
|
75
|
+
name: 'Popup',
|
|
76
|
+
kind: 'global',
|
|
77
|
+
nodes: [
|
|
78
|
+
{ id: 'open', type: 'event.element', pos: [40, 40], props: { selector: '.js-open', event: 'click' } },
|
|
79
|
+
{ id: 'show', type: 'dom.addClass', pos: [360, 40], props: { target: '#popup', className: 'is-open' } },
|
|
80
|
+
{ id: 'close', type: 'event.element', pos: [40, 240], props: { selector: '.js-close', event: 'click' } },
|
|
81
|
+
{ id: 'hide', type: 'dom.removeClass', pos: [360, 240], props: { target: '#popup', className: 'is-open' } },
|
|
82
|
+
],
|
|
83
|
+
links: [
|
|
84
|
+
{ from: ['open', 'then'], to: ['show', 'exec'] },
|
|
85
|
+
{ from: ['close', 'then'], to: ['hide', 'exec'] },
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const { code, diagnostics, hasErrors } = buildScript([popup], registry);
|
|
90
|
+
// code: a self-starting script — save it as a .js file or put it in a <script>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Edit it visually
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
import { GraphEditor, createText } from 'blueprintsjs/editor';
|
|
97
|
+
import { ru } from 'blueprintsjs/locales';
|
|
98
|
+
|
|
99
|
+
const editor = new GraphEditor({
|
|
100
|
+
blueprint: popup,
|
|
101
|
+
registry,
|
|
102
|
+
t: createText(ru), // omit for English
|
|
103
|
+
onChange: (bp) => save(bp), // after every edit
|
|
104
|
+
onClose: (bp) => save(bp), // "Done" button
|
|
105
|
+
}).mount(); // full-window overlay; or { embedded: true } + mount(panel)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Show a generated graph read-only (statuses, clicks, automatic layout): `new GraphEditor({ blueprint, registry, readonly: true, autoLayout: true, onNodeClick })` — see [the editor guide](docs/editor.md#read-only-viewer).
|
|
109
|
+
|
|
110
|
+
### Run and stop it (preview)
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
const { code } = buildScript([popup], registry, { target: 'preview' });
|
|
114
|
+
const start = (0, eval)(code); // → function start(document) → dispose
|
|
115
|
+
const dispose = start(document);
|
|
116
|
+
// …
|
|
117
|
+
dispose(); // listeners and timers removed
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Concepts
|
|
121
|
+
|
|
122
|
+
- **Kinds.** `global` runs on every page. `template` runs only where `target.when` (a CSS selector) matches — your host decides which pages get it via `target.pages`. `component` compiles to `function (root, ctx) → dispose`, run once per component instance, with `ctx.params`.
|
|
123
|
+
- **Pins.** White `exec` pins set the order of execution; data pins carry values: `string`, `number`, `boolean`, `element`, `elements`, `event`, `object`, `any`. A text typed on an element pin is a CSS selector.
|
|
124
|
+
- **Events start chains.** Element events are delegated to the document, so they work for elements added later.
|
|
125
|
+
- **Pure nodes** (no exec pins — math, compare, concat…) are evaluated where their value is used. Outputs of action nodes keep their last value, like in UE5.
|
|
126
|
+
- **Variables** belong to a blueprint and live as long as it runs.
|
|
127
|
+
|
|
128
|
+
More in the [guide](docs/guide.md).
|
|
129
|
+
|
|
130
|
+
## Documentation
|
|
131
|
+
|
|
132
|
+
- [Guide](docs/guide.md) — concepts, execution model, kinds of blueprints, integration in a host app.
|
|
133
|
+
- [Compiler and runtime](docs/compiler.md) — `buildScript`, `buildStandalone`, `compileBlueprint`, output format, diagnostics.
|
|
134
|
+
- [Editor](docs/editor.md) — `GraphEditor` options and methods, controls, styling, translations, `GraphState`.
|
|
135
|
+
- [Writing nodes](docs/custom-nodes.md) — `defineNode`, the compile context, runtime helpers, testing.
|
|
136
|
+
- [Blueprint format](docs/schema.md) — the JSON, its schema and normalization.
|
|
137
|
+
- Node reference: [English](docs/nodes.md), [Русский](docs/nodes.ru.md) — generated from the registry.
|
|
138
|
+
- [Changelog](CHANGELOG.md).
|
|
139
|
+
|
|
140
|
+
A runnable demo (UMD build, popup + editor) is in [examples/index.html](examples/index.html): `npm run build`, then serve the package folder and open it.
|
|
141
|
+
|
|
142
|
+
## Used by
|
|
143
|
+
|
|
144
|
+
- [grapesjs-scripts](https://www.npmjs.com/package/grapesjs-scripts) — a GrapesJS plugin: a "Scripts" panel with this editor, element picker, live preview on the canvas, export, CDN libraries and component blocks.
|
|
145
|
+
|
|
146
|
+
## Compatibility
|
|
147
|
+
|
|
148
|
+
- Generated code: ES5 + `classList`/`closest`/`matches` (every current browser).
|
|
149
|
+
- Editor: current Chrome, Firefox, Safari, Edge.
|
|
150
|
+
- Core: Node 18+, any bundler; TypeScript `moduleResolution` `bundler`, `node16`/`nodenext` and `node10` are supported.
|
|
151
|
+
|
|
152
|
+
## Development
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
npm install
|
|
156
|
+
npm test # vitest (jsdom + a Node-only suite for the core)
|
|
157
|
+
npm run typecheck
|
|
158
|
+
npm run build # dist/: ESM, CJS, UMD, .d.ts/.d.cts
|
|
159
|
+
npm run docs:nodes # docs/nodes*.md from the registry (after build)
|
|
160
|
+
npm run check:pack # publint + are-the-types-wrong on the packed tarball
|
|
161
|
+
npm run e2e # the demo page in headless Chrome (CHROME=path/to/chrome)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
MIT
|