maptastic 3.1.0 → 3.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/README.md CHANGED
@@ -45,6 +45,8 @@ import { Maptastic } from 'maptastic';
45
45
  const map = new Maptastic("so-simple");
46
46
  ```
47
47
 
48
+ TypeScript definitions are included in the package, so no `@types` package is needed.
49
+
48
50
  ## Controls
49
51
 
50
52
  Since the idea is to have a projector aimed all crazy-like, the controls are all keyboard and mouse based since any UI would either get in the way, or would be impossible to see in most cases anyway.
@@ -186,15 +188,20 @@ npx playwright install
186
188
  npm run test:browser
187
189
  ```
188
190
 
189
- `dist/` is committed; CI fails if it doesn't match a fresh `npm run build`.
191
+ `dist/` is not committed. Run `npm run build` before opening the files in `example/`, which load `../dist/maptastic.js`.
190
192
 
191
193
  ### Releasing
192
194
 
193
- Releases are staged to npm from GitHub Actions ([`publish.yml`](.github/workflows/publish.yml)) via
194
- [trusted publishing](https://docs.npmjs.com/trusted-publishers), so no npm token is stored anywhere,
195
- and go live only after a maintainer approves them ([staged publishing](https://docs.npmjs.com/staged-publishing)).
196
-
197
- 1. Bump the version: `npm version <patch|minor|major>` (commits and creates the `vX.Y.Z` tag).
198
- 2. Push the commit and tag: `git push --follow-tags`.
199
- 3. Once the workflow finishes, approve the release with 2FA: `npm stage list maptastic`, then
200
- `npm stage approve <stage-id>` (or use the Staged Packages tab on npmjs.com).
195
+ Releases are made by [semantic-release](https://github.com/semantic-release/semantic-release) from GitHub Actions
196
+ ([`publish.yml`](.github/workflows/publish.yml)). Commits build up on `master`; when you want a release, run the
197
+ Publish workflow from the Actions tab (or `gh workflow run publish.yml`), optionally with `dry_run` checked to preview
198
+ the next version first. Write commit messages in the
199
+ [Conventional Commits](https://www.conventionalcommits.org/) format: `fix:` makes a patch release, `feat:` a minor
200
+ release, and a `!` after the type (or a `BREAKING CHANGE:` footer) a major release. Other types, such as `docs:`,
201
+ `test:`, and `ci:`, do not release. Do not bump the version in `package.json` by hand.
202
+
203
+ When there are releasable commits since the last tag, the workflow commits the new version and `CHANGELOG.md` back to
204
+ `master`, tags the release, creates the GitHub release (with the built `dist/maptastic.js` and its source map
205
+ attached), and stages the package on npm via [trusted publishing](https://docs.npmjs.com/trusted-publishers), so no npm token is stored anywhere.
206
+ The release goes live only after a maintainer approves it with 2FA ([staged publishing](https://docs.npmjs.com/staged-publishing)):
207
+ run `npm stage list maptastic`, then `npm stage approve <stage-id>` (or use the Staged Packages tab on npmjs.com).
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "maptastic",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "main": "dist/maptastic.js",
5
+ "types": "types/maptastic.d.ts",
5
6
  "license": "SEE LICENSE IN license.txt",
6
7
  "author": "ben purdy (https://github.com/benpurdy)",
7
8
  "contributors": [
@@ -11,14 +12,16 @@
11
12
  "files": [
12
13
  "license.txt",
13
14
  "src/**/*",
14
- "dist/**/*"
15
+ "dist/**/*",
16
+ "types/maptastic.d.ts"
15
17
  ],
16
18
  "scripts": {
17
19
  "build": "rollup --config",
18
20
  "clean": "rimraf dist",
19
21
  "prepublishOnly": "npm run clean && npm run build",
20
22
  "pretest": "npm run build",
21
- "test": "node --test",
23
+ "test": "node --test \"test/**/*.test.js\"",
24
+ "test:types": "tsc -p types/test",
22
25
  "pretest:browser": "npm run build",
23
26
  "test:browser": "playwright test"
24
27
  },
@@ -28,9 +31,14 @@
28
31
  "@playwright/test": "^1.64.1",
29
32
  "@rollup/plugin-babel": "^7.1.0",
30
33
  "@rollup/plugin-terser": "^1.0.0",
34
+ "@semantic-release/changelog": "^7.0.0",
35
+ "@semantic-release/exec": "^7.1.0",
36
+ "@semantic-release/git": "^11.0.1",
31
37
  "jsdom": "^30.1.3",
32
38
  "rimraf": "^6.1.3",
33
- "rollup": "^4.64.7"
39
+ "rollup": "^4.64.7",
40
+ "semantic-release": "^25.0.9",
41
+ "typescript": "^7.0.2"
34
42
  },
35
43
  "repository": {
36
44
  "type": "git",
@@ -0,0 +1,54 @@
1
+ /** An `[x, y]` coordinate in pixels. */
2
+ export type Point = [number, number];
3
+
4
+ /** An element, or the ID of an element, to map. */
5
+ export type Target = string | HTMLElement;
6
+
7
+ /** The mapping of a single layer, as returned by `getLayout` and accepted by `setLayout`. */
8
+ export interface Layout {
9
+ /** ID of the layer element. */
10
+ id: string;
11
+ /** Four corner points of the layer on screen. */
12
+ targetPoints: Point[];
13
+ /** Four corner points of the layer's original, unmapped rectangle. */
14
+ sourcePoints: Point[];
15
+ }
16
+
17
+ export interface Config {
18
+ /** Elements or element IDs to use as layers. */
19
+ layers?: Target[];
20
+ /** Called whenever the layout changes. */
21
+ onchange?: () => void;
22
+ /** Show crosshairs in edit mode. Default `false`. */
23
+ crosshairs?: boolean;
24
+ /** Show element IDs in edit mode. Default `true`. */
25
+ labels?: boolean;
26
+ /** Show the display bounds in edit mode. Default `false`. */
27
+ screenbounds?: boolean;
28
+ /** Save layer positions to local storage on change. Default `true`. */
29
+ autoSave?: boolean;
30
+ /** Load layer positions from local storage on creation. Default `true`. */
31
+ autoLoad?: boolean;
32
+ }
33
+
34
+ export class Maptastic {
35
+ constructor(config: Config, ...targets: Target[]);
36
+ constructor(...targets: Target[]);
37
+
38
+ /** Returns the current mapping of every layer. */
39
+ getLayout(): Layout[];
40
+
41
+ /** Applies a layout, adding layers for any IDs that are not mapped yet. */
42
+ setLayout(layout: Layout[]): void;
43
+
44
+ /** Maps a new element, optionally starting from the given corner points. */
45
+ addLayer(target: Target, targetPoints?: Point[]): void;
46
+
47
+ /** Stops mapping an element. The element is left in the page. */
48
+ removeLayer(element: HTMLElement): void;
49
+
50
+ /** Turns edit mode on or off. */
51
+ setConfigEnabled(enabled: boolean): void;
52
+ }
53
+
54
+ export as namespace maptastic;