diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 0000000..43cb860 --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,74 @@ +name: Publish npm + +on: + push: + tags: + - "v*.*.*" + +permissions: + contents: read + id-token: write + +jobs: + publish: + name: Publish @flowscape-ui/core-sdk + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Setup Node + uses: actions/setup-node@v6 + with: + node-version: "24" + registry-url: "https://registry.npmjs.org" + package-manager-cache: false + + - name: Verify runtime versions + run: | + node --version + npm --version + bun --version + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Check formatting + run: bun run format:check + + - name: Lint + run: bun run lint + + - name: Typecheck + run: bun run typecheck + + - name: Build + run: bun run build + + - name: Verify release version + shell: bash + run: | + TAG_VERSION="${GITHUB_REF_NAME#v}" + PACKAGE_VERSION=$(node -p "require('./packages/engine/package.json').version") + + echo "Tag version: $TAG_VERSION" + echo "Package version: $PACKAGE_VERSION" + + if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then + echo "::error::Git tag v$TAG_VERSION does not match packages/engine/package.json version $PACKAGE_VERSION" + exit 1 + fi + + - name: Inspect npm package + working-directory: packages/engine + run: npm pack --dry-run + + - name: Publish package + working-directory: packages/engine + run: npm publish --access public \ No newline at end of file diff --git a/package.json b/package.json index 7b6cb42..c9ead00 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,10 @@ "dev:playground": "turbo run dev --filter=@flowscape-ui/playground", "dev:docs": "turbo run dev --filter=@flowscape-ui/docs", "build:playground": "turbo run build --filter=@flowscape-ui/playground", - "build:docs": "turbo run build --filter=@flowscape-ui/docs" + "build:docs": "turbo run build --filter=@flowscape-ui/docs", + "version:patch": "cd packages/engine && bun pm version patch --no-git-tag-version && cd ../.. && bun install --lockfile-only", + "version:minor": "cd packages/engine && bun pm version minor --no-git-tag-version && cd ../.. && bun install --lockfile-only", + "version:major": "cd packages/engine && bun pm version major --no-git-tag-version && cd ../.. && bun install --lockfile-only" }, "devDependencies": { "prettier": "^3.7.4", diff --git a/packages/engine/README.md b/packages/engine/README.md new file mode 100644 index 0000000..92b01ba --- /dev/null +++ b/packages/engine/README.md @@ -0,0 +1,477 @@ +
+ +Flowscape + +# Flowscape + +### A framework-agnostic 2D graphics engine for infinite canvases, editors and visual tools. + +**Scenes · Nodes · Rendering · Gradients · Hit Testing · Transforms · Infinite Canvas** + +`@flowscape-ui/core-sdk` + +[![Open Playground](https://img.shields.io/badge/Open_Playground-111827?style=for-the-badge&logo=codepen&logoColor=white)](https://flowscape-ui.github.io/core-sdk/playground/) +[![Read Documentation](https://img.shields.io/badge/Read_Documentation-7C3AED?style=for-the-badge&logo=readthedocs&logoColor=white)](https://flowscape-ui.github.io/core-sdk/) + +
+ +[![npm version](https://img.shields.io/npm/v/@flowscape-ui/core-sdk)](https://www.npmjs.com/package/@flowscape-ui/core-sdk) +[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) +[![Bundle Size](https://img.shields.io/bundlephobia/minzip/@flowscape-ui/core-sdk)](https://bundlephobia.com/package/@flowscape-ui/core-sdk) +[![X](https://img.shields.io/badge/X-@FlowscapeUI-000000?logo=x&logoColor=white)](https://x.com/FlowscapeUI) + +
+ +

+ + Flowscape 2D graphics engine demo + +

+ +

+ Click the demo to open the live Playground. +

+ +--- + +## Build the editor. Don't rebuild the engine. + +Flowscape provides the **2D graphics, scene, rendering, and interaction foundation** behind sophisticated editor-like applications. + +Build design tools, whiteboards, diagram editors, visual builders, node editors, CAD-like interfaces, and custom infinite-canvas experiences without rebuilding the same engine infrastructure every time. + +**You build the product. Flowscape powers the canvas.** + +--- + +## Engine capabilities + +| Scene graph | Rendering | Interaction | +| --- | --- | --- | +| Layered scenes | Canvas renderer | Hit testing | +| Node hierarchy | Gradient paints | Selection foundations | +| Groups and transforms | Renderer abstraction | Transform overlays | +| Bounds and coordinates | Demand-driven invalidation | Pan and zoom | +| Background / World / Overlay / UI | Render-host architecture | Editor-style controllers | + +
+🎨 Paint system + +
+ +- Solid colors +- Linear gradients +- Radial gradients +- Conic gradients +- Diamond gradients +- Mesh gradients +- Fill and stroke rendering + +
+ +
+🧩 Built-in node types + +
+ +- Rect +- Ellipse +- Polygon +- Star +- Line +- Path +- Text +- Image +- Video +- Group + +
+ +
+🧭 Editor foundations + +
+ +- Infinite canvas camera +- Pan and zoom +- Bounds and hit testing +- Selection overlays +- Transform handles +- Layered rendering +- Renderer-independent scene state + +
+ +--- + +## What is Flowscape? + +Flowscape is a framework-agnostic 2D engine for building complex graphical applications. + +It sits between low-level rendering libraries and full products, providing a reusable engine layer for scenes, nodes, transforms, rendering, interaction systems, overlays, and infinite-canvas workflows. + +It is **not** a UI framework and it does not dictate how your application should look. + +Your application owns the UI and product logic. Flowscape owns the graphics engine underneath it. + +Flowscape is designed for products such as: + +- Figma-like design tools +- Infinite canvas applications +- Whiteboards and diagram editors +- Visual and page builders +- Node-based editors +- CAD-like 2D interfaces +- Internal graphical editor tools + +--- + +## Installation + +Using Bun: + +```bash +bun add @flowscape-ui/core-sdk +``` + +Using pnpm: + +```bash +pnpm add @flowscape-ui/core-sdk +``` + +Using npm: + +```bash +npm install @flowscape-ui/core-sdk +``` + +Using Yarn: + +```bash +yarn add @flowscape-ui/core-sdk +``` + +--- + +## Quick Start + +Create a container: + +```html +
+``` + +Give it a visible size: + +```css +html, +body, +#app { + width: 100%; + height: 100%; + margin: 0; +} +``` + +Then create a scene: + +```ts +import { + Scene, + LayerBackground, + LayerWorld, + LayerOverlay, + RendererLayerBackgroundCanvas, + RendererLayerWorldCanvas, + RendererLayerOverlayCanvas, + CanvasRendererHost, + NodeRect, +} from "@flowscape-ui/core-sdk"; + +const container = document.getElementById("app"); + +if (!container) { + throw new Error("Container #app not found"); +} + +const scene = new Scene(container.clientWidth, container.clientHeight); + +const background = new LayerBackground(); +const world = new LayerWorld(); +const overlay = new LayerOverlay(world); + +scene.addLayer(background); +scene.addLayer(world); +scene.addLayer(overlay); + +scene.bindLayerRenderer(background, new RendererLayerBackgroundCanvas()); +scene.bindLayerRenderer(world, new RendererLayerWorldCanvas()); +scene.bindLayerRenderer(overlay, new RendererLayerOverlayCanvas()); + +const host = new CanvasRendererHost(container, -1); +scene.addHost(host); + +background.setFill("#101010"); + +const rect = new NodeRect(1); +rect.setPosition(300, 220); +rect.setSize(220, 140); +rect.setFill("#3b82f6"); + +world.addNode(rect); +scene.invalidate(); +``` + +For input controllers, selection, transformations, camera controls, and advanced editor workflows, see the [documentation](https://flowscape-ui.github.io/core-sdk/). + +--- + +## Usage + +### ES Modules + +```ts +import { + Scene, + NodeRect, + LayerWorld, + CanvasRendererHost, +} from "@flowscape-ui/core-sdk"; +``` + +### Browser Script + +Flowscape can also be used directly in the browser without a bundler. + +```html + + + +``` + +The standalone build exposes the public API through the global `Flowscape` object. + +```js +const rect = new Flowscape.NodeRect(1); +``` + +--- + +## Architecture + +Flowscape separates **scene state**, **rendering**, and **interaction logic**. + +```text + Flowscape + │ + ┌─────────────┼─────────────┐ + │ │ │ + Scene Nodes Controllers + │ │ │ + Layers Transform Input + │ │ │ + └─────────────┼─────────────┘ + │ + Renderer API + │ + Canvas backend + │ + Browser +``` + +The scene is organized into dedicated layers: + +```text +Scene +├── Background Layer +├── World Layer +│ └── Nodes +├── Overlay Layer +│ └── Handles / Selection / Transformations +└── UI Layer +``` + +This separation allows rendering implementations to evolve without requiring editor-level product logic to be rewritten. + +--- + +## Why Flowscape? + +Most canvas libraries provide rendering primitives. + +Flowscape aims to provide the **engine layer above those primitives**. + +Instead of rebuilding the same infrastructure for every graphical product, developers can start with reusable foundations for: + +- scene organization +- node hierarchy +- coordinate systems +- camera behavior +- rendering +- hit testing +- selection +- transformation +- interaction systems +- editor overlays + +Flowscape is closer in philosophy to an engine for graphical applications than to a component library or ready-made editor. + +--- + +## Repository Structure + +Flowscape is developed as a Turborepo monorepo. + +```text +flowscape/ +├── apps/ +│ ├── docs/ +│ └── playground/ +│ +├── packages/ +│ └── engine/ +│ +├── package.json +├── turbo.json +└── bun.lock +``` + +### `apps/docs` + +The Flowscape documentation application. + +### `apps/playground` + +The interactive development environment and public engine showcase. + +### `packages/engine` + +The core Flowscape engine, published as: + +```text +@flowscape-ui/core-sdk +``` + +--- + +## Development + +Flowscape uses Bun, Turborepo, TypeScript, and tsdown. + +Clone the repository and install dependencies: + +```bash +bun install +``` + +Run the Playground: + +```bash +bun run dev:playground +``` + +Run the documentation: + +```bash +bun run dev:docs +``` + +Build the monorepo: + +```bash +bun run build +``` + +Run type checking: + +```bash +bun run typecheck +``` + +Run linting: + +```bash +bun run lint +``` + +More information about contributing can be found in [`CONTRIBUTING.md`](./CONTRIBUTING.md). + +--- + +## Public API Policy + +Applications should import Flowscape exclusively through the public package API: + +```ts +import { Scene, NodeRect } from "@flowscape-ui/core-sdk"; +``` + +Do not import internal modules directly: + +```ts +// ❌ Do not do this +import { Scene } from "@flowscape-ui/core-sdk/src/scene"; +``` + +Internal project structure may change between releases. + +Only exports available through `@flowscape-ui/core-sdk` should be considered part of the public API. + +--- + +## Project Status + +Flowscape is under active development. + +The architecture and internal implementation continue to evolve as the engine expands toward more advanced rendering, interaction, and editor systems. + +Public API stability is treated as a priority, but major releases may introduce intentional breaking changes when necessary for the long-term architecture of the engine. + +See [`CHANGELOG.md`](./CHANGELOG.md) for release history. + +--- + +## Links + +- [Documentation](https://flowscape-ui.github.io/core-sdk/) +- [Playground](https://flowscape-ui.github.io/core-sdk/playground/) +- [npm Package](https://www.npmjs.com/package/@flowscape-ui/core-sdk) +- [GitHub Issues](https://github.com/Flowscape-UI/core-sdk/issues) +- [Changelog](./CHANGELOG.md) + +--- + +## Contributing + +Contributions, bug reports, and feature proposals are welcome. + +Before contributing, please read [`CONTRIBUTING.md`](./CONTRIBUTING.md). + +For bugs and feature requests, use the project's GitHub Issues. + +--- + +## Authors + +See [`AUTHORS.md`](./AUTHORS.md). + +--- + +## Support Flowscape + +Flowscape is developed as an open-source project. + +If Flowscape is useful to you or your team, you can support its continued development. + +[❤️ Sponsor Flowscape](https://github.com/sponsors/Flowscape-UI) + +--- + +## License + +Flowscape is released under the [MIT License](./LICENSE). + +© Flowscape UI Team diff --git a/packages/engine/assets/brand/logo.svg b/packages/engine/assets/brand/logo.svg new file mode 100644 index 0000000..8bf7289 --- /dev/null +++ b/packages/engine/assets/brand/logo.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/packages/engine/assets/media/flowscape-demo.gif b/packages/engine/assets/media/flowscape-demo.gif new file mode 100644 index 0000000..168242f Binary files /dev/null and b/packages/engine/assets/media/flowscape-demo.gif differ diff --git a/packages/engine/eslint.config.ts b/packages/engine/eslint.config.ts deleted file mode 100644 index d90d685..0000000 --- a/packages/engine/eslint.config.ts +++ /dev/null @@ -1,2 +0,0 @@ -import base from "../eslint-config/base"; -export default base; diff --git a/packages/engine/package.json b/packages/engine/package.json index 5a6e5b8..0bcc83c 100644 --- a/packages/engine/package.json +++ b/packages/engine/package.json @@ -1,23 +1,47 @@ { "name": "@flowscape-ui/core-sdk", - "version": "2.0.2", - "description": "Engine for building infinite canvas editors, design tools, and visual builders.", + "version": "2.0.3", + "description": "Framework-agnostic 2D graphics engine for infinite canvases, editors, design tools, and visual applications.", "license": "MIT", - "type": "module", "sideEffects": false, - "main": "./dist/index.cjs", + "type": "module", + "main": "./dist/index.js", "module": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js", - "require": "./dist/index.cjs" + "default": "./dist/index.js" } }, "files": [ "dist" ], + "repository": { + "type": "git", + "url": "git+https://github.com/Flowscape-UI/core-sdk.git", + "directory": "packages/engine" + }, + "homepage": "https://flowscape-ui.github.io/core-sdk/", + "bugs": { + "url": "https://github.com/Flowscape-UI/core-sdk/issues" + }, + "keywords": [ + "2d", + "canvas", + "graphics", + "graphics-engine", + "rendering", + "infinite-canvas", + "editor", + "design-tools", + "typescript" + ], + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, "scripts": { "build": "tsdown", "typecheck": "tsc --noEmit", @@ -30,9 +54,8 @@ "konva": "^10.0.12" }, "devDependencies": { - "@typescript/native-preview": "^7.0.0-dev.20260707.2", "tsdown": "^0.22.9", - "typescript": "^5.6.2", + "typescript": "^5.9.2", "vitest": "^2.1.9" } }