From 18393112447c0bf41469c8ba682a9d000ec81087 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sat, 11 Apr 2026 18:15:11 +0000
Subject: [PATCH] Add multi-format build targets, exports map, and headless
Node.js entry point
Agent-Logs-Url: https://github.com/mvanderkamp/westures/sessions/7aa07059-36ca-4eac-9a48-c037e5c1a03f
Co-authored-by: mvanderkamp <40647401+mvanderkamp@users.noreply.github.com>
---
CHANGELOG.md | 18 ++++++++++++++++
README.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++-
index.headless.js | 23 ++++++++++++++++++++
package.json | 46 +++++++++++++++++++++++++++++++++++++++-
4 files changed, 138 insertions(+), 2 deletions(-)
create mode 100644 index.headless.js
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b5a4376..daaa9fc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,23 @@
# Changelog
+## 1.2.0
+
+- Add multi-format build targets (CJS, ESM, UMD) via Parcel 2, replacing the
+ single `dist/index.js` bundle.
+- Add `"module"` field (`dist/westures.esm.js`) for tree-shaking with modern
+ bundlers (webpack 5, Rollup, Vite, esbuild).
+- Add `"browser"` field (`dist/westures.umd.js`) for direct `
+
+```
+
+### Node.js — headless / server-side
+
+When you `require` or `import` westures in a Node.js process, you
+automatically get the **headless** build. In headless mode the `Region` does
+not attach DOM event listeners; instead, you feed events to it manually via
+`Region.arbitrate(event)`, `Region.cancel(event)`, and
+`Region.handleKeyboardEvent(event)`. This makes westures usable in JSDOM,
+testing frameworks, and server-side gesture processing.
+
+```javascript
+// CommonJS — headless mode is the default in Node.js
+const { Region, Pan } = require('westures');
+
+// ES module in Node.js — same headless default
+import { Region, Pan } from 'westures';
+```
+
+You can still opt out of headless mode on a per-region basis by passing
+`{ headless: false }` to the `Region` constructor.
+
+
- [Declaring a Region](#declaring-a-region)
- [Instantiating a Gesture](#instantiating-a-gesture)
diff --git a/index.headless.js b/index.headless.js
new file mode 100644
index 0000000..4bb2183
--- /dev/null
+++ b/index.headless.js
@@ -0,0 +1,23 @@
+'use strict';
+
+/**
+ * Headless entry point for Westures. Re-exports everything from the main
+ * module but provides a Region subclass that defaults `headless: true`.
+ *
+ * When imported via the `"node"` condition (i.e. `require('westures')` or
+ * `import ... from 'westures'` in a Node.js process), consumers get this
+ * build automatically. They can still override headless mode by passing
+ * `{ headless: false }` explicitly.
+ *
+ * @module westures/headless
+ */
+
+const base = require('./index.js');
+
+class Region extends base.Region {
+ constructor(element, options = {}) {
+ super(element, { headless: true, ...options });
+ }
+}
+
+module.exports = { ...base, Region };
diff --git a/package.json b/package.json
index 128c273..0bc6827 100644
--- a/package.json
+++ b/package.json
@@ -22,7 +22,51 @@
"pointer"
],
"source": "index.js",
- "main": "dist/index.js",
+ "main": "dist/westures.cjs.js",
+ "module": "dist/westures.esm.js",
+ "browser": "dist/westures.umd.js",
+ "nodeHeadless": "dist/westures.node.cjs.js",
+ "exports": {
+ ".": {
+ "node": "./dist/westures.node.cjs.js",
+ "import": "./dist/westures.esm.js",
+ "require": "./dist/westures.cjs.js",
+ "browser": "./dist/westures.umd.js"
+ }
+ },
+ "targets": {
+ "main": {
+ "outputFormat": "commonjs",
+ "isLibrary": true,
+ "optimize": true,
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "module": {
+ "outputFormat": "esmodule",
+ "isLibrary": true,
+ "optimize": true
+ },
+ "browser": {
+ "outputFormat": "global",
+ "global": "westures",
+ "isLibrary": true,
+ "optimize": true,
+ "engines": {
+ "browsers": "> 0.5%, last 2 versions"
+ }
+ },
+ "nodeHeadless": {
+ "source": "index.headless.js",
+ "outputFormat": "commonjs",
+ "isLibrary": true,
+ "optimize": true,
+ "engines": {
+ "node": ">=12"
+ }
+ }
+ },
"directories": {
"test": "test"
},