Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Bug report
description: Something doesn't work as documented.
labels: [bug]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to report a bug. Security issues must be reported privately; see SECURITY.md.
- type: dropdown
id: package
attributes:
label: Package
multiple: true
options:
- '@spatialkit/core'
- '@spatialkit/svg'
- '@spatialkit/react'
- Not sure
validations:
required: true
- type: input
id: version
attributes:
label: Package version
placeholder: '0.2.0'
validations:
required: true
- type: textarea
id: description
attributes:
label: What happened?
description: What did you expect to happen, and what happened instead?
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: Reproduction
description: Minimal code or a link to a repository or sandbox that reproduces the problem.
render: ts
validations:
required: true
- type: textarea
id: environment
attributes:
label: Environment
description: Browser and version, OS, framework version (React, bundler) if relevant.
placeholder: |
Browser: Chrome 140
OS: macOS 15
React: 19.1
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Report a security vulnerability
url: https://github.com/spatialkit/spatial/security/advisories/new
about: Please report security issues privately, not as public issues.
40 changes: 40 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Feature request
description: Suggest a new feature or an improvement.
labels: [enhancement]
body:
- type: dropdown
id: package
attributes:
label: Package
multiple: true
options:
- '@spatialkit/core'
- '@spatialkit/svg'
- '@spatialkit/react'
- New package
- Not sure
validations:
required: true
- type: textarea
id: problem
attributes:
label: Problem
description: What are you trying to build, and what is missing or hard today?
validations:
required: true
- type: textarea
id: proposal
attributes:
label: Proposed solution
description: How could the API look? Code sketches are welcome.
- type: textarea
id: alternatives
attributes:
label: Alternatives and workarounds
description: Anything you tried or considered.
- type: checkboxes
id: contribute
attributes:
label: Contribution
options:
- label: I'd like to work on this.
17 changes: 17 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## What does this change?

<!-- A short description of the change and why it is needed. -->

Closes #

## How was it tested?

<!-- New or updated tests, manual checks in the examples, etc. -->

## Checklist

- [ ] `pnpm typecheck && pnpm test && pnpm lint && pnpm build` pass locally
- [ ] Tests added or updated
- [ ] Docs (READMEs) updated if the public API changed
- [ ] Changeset added (`pnpm changeset`) if a published package changed
- [ ] No new production dependencies
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Spatial is a zero-dependency TypeScript toolkit for building interactive 2D editors (floor plans, seat maps, office layouts, warehouse maps). It exposes low-level primitives for pan/zoom/selection/picking and ships pluggable renderers.

**Repo:** `github.com/spatialkit/spatial`
**Status:** v0.0.0 — core stable, SVG renderer complete, React adapter in progress
**Status:** v0.x — core, SVG renderer and React adapter are functional; the API may still change between minor versions

> Detailed per-package guides: [`packages/core/CLAUDE.md`](packages/core/CLAUDE.md) · [`packages/svg/CLAUDE.md`](packages/svg/CLAUDE.md)

Expand Down Expand Up @@ -34,7 +34,7 @@ Adapters live under `packages/adapters/` — add new framework adapters (e.g. `v
```bash
pnpm test # run all tests once (vitest)
pnpm test:watch # vitest in watch mode
pnpm typecheck # tsc -b --verbose (all packages)
pnpm typecheck # tsc --noEmit (all packages)
pnpm build # tsup build for all packages
pnpm lint # eslint on all .ts/.tsx
pnpm dev # dev server (packages/examples)
Expand Down
84 changes: 84 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement privately through the repository's [private reporting form](https://github.com/spatialkit/spatial/security/advisories/new) (start the title with "Code of Conduct"), or by contacting the maintainer, [@lucasfelixs](https://github.com/lucasfelixs), on GitHub. All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of actions.

**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].

Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC].

For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations].

[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations

106 changes: 106 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Contributing to Spatial

Thanks for your interest in contributing. This guide covers how to set up the project, the conventions the code follows, and how changes get released.

By participating, you agree to follow the [Code of Conduct](./CODE_OF_CONDUCT.md).

## Ways to contribute

- **Report a bug**: open an issue using the bug report template. Include a minimal reproduction.
- **Suggest a feature**: open an issue using the feature request template before writing code, so the design can be discussed first.
- **Improve the docs**: fixes to READMEs and examples are always welcome.
- **Pick an issue**: issues labeled [`good first issue`](https://github.com/spatialkit/spatial/labels/good%20first%20issue) or [`help wanted`](https://github.com/spatialkit/spatial/labels/help%20wanted) are a good place to start. Comment on the issue before starting, so work isn't duplicated.

Security issues must not be reported in public issues. See [SECURITY.md](./SECURITY.md).

## Development setup

**Prerequisites:** Node.js 22 (see [`.nvmrc`](./.nvmrc)) and pnpm 10.

```bash
git clone https://github.com/<your-username>/spatial.git
cd spatial
pnpm install
pnpm test
```

| Command | Description |
|---------|-------------|
| `pnpm test` | Run all tests once (Vitest) |
| `pnpm test:watch` | Run tests in watch mode |
| `pnpm typecheck` | Type-check all packages |
| `pnpm lint` | Run ESLint |
| `pnpm build` | Build the publishable packages (ESM + CJS + types) |
| `pnpm dev` | Start the vanilla JS example (Vite) |
| `pnpm dev:react` | Start the React example (Vite) |

## Repository layout

```
packages/
core/ @spatialkit/core — scene engine, viewport, selection, events, picking
svg/ @spatialkit/svg — SVG renderer + DOM event handlers
adapters/
react/ @spatialkit/react — React adapter (hooks + SpatialCanvas)
examples/
js-vanilla/ vanilla JS example (not published)
react/ React example (not published)
```

Each package README documents its public API.

## Code conventions

- **No production dependencies** in `@spatialkit/core`, `@spatialkit/svg` or `@spatialkit/react`. Peer dependencies on other `@spatialkit/*` packages and on React are the only exceptions.
- **`@spatialkit/core` stays framework-agnostic**: no DOM, no browser APIs.
- **TypeScript strict**: no `any`, no unused variables (prefix intentionally unused arguments with `_`).
- **Branded ids**: use `EntityId` and `LayerId`, never plain `string`.
- **Immutable selection**: never mutate the `Set` returned by `applySelection`.
- **Factory functions over classes** (`createCore`, `createEmptyScene`).
- **Comments** only when the *why* is not obvious from the code.
- **Formatting**: Prettier (single quotes, semicolons, 100-character lines). Run `npx prettier --write <files>` on what you changed.

## Tests

- Tests live in `src/__tests__/*.test.ts(x)` inside each package.
- `core` tests run in Node; `svg` and `react` tests run in jsdom.
- jsdom returns a zero rect from `getBoundingClientRect` and does not implement `setPointerCapture` or `ResizeObserver`. Mock them in tests that depend on them.
- New features and bug fixes need tests. A bug fix should include a test that fails without the fix.

## Pull requests

1. Fork the repository and create a branch from `main` (for example `fix/pinch-zoom-origin` or `feat/rubber-band-selection`).
2. Make the change, with tests and docs.
3. Add a changeset if the change affects a published package (see below).
4. Make sure everything passes locally:

```bash
pnpm typecheck && pnpm test && pnpm lint && pnpm build
```

5. Open the pull request against `main` and fill in the template. Keep it focused on one change.

CI runs the same checks on every pull request. A maintainer will review it; please be patient and responsive to feedback.

## Changesets and releases

Versioning and changelogs are managed with [Changesets](https://github.com/changesets/changesets). If your change affects a published package, run:

```bash
pnpm changeset
```

Pick the affected packages and the bump type, and write a short summary for the changelog. Commit the generated file in `.changeset/` with your pull request.

While the packages are on `0.x`:

- `patch`: bug fixes and internal changes
- `minor`: new features **and** breaking changes

Changes to docs, tests, examples or tooling don't need a changeset.

After merge, a bot opens a "version packages" pull request. When a maintainer merges it, the packages are published to npm automatically.

## License

By contributing, you agree that your contributions will be licensed under the [MIT License](./LICENSE).
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2025 spatialkit
Copyright (c) 2025 Lucas Felix

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading
Loading