canvas-globe 0.1.3 → 0.1.5
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 +19 -0
- package/README.md +39 -6
- package/codemeta.json +1 -1
- package/package.json +17 -2
- package/src/element.js +1 -1
- package/src/react.js +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,25 @@ All notable changes to this package are documented here. The format follows
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.1.5] - 2026-09-15
|
|
10
|
+
|
|
11
|
+
- Added an animated README demo, Storybook stories, framework starters, a
|
|
12
|
+
shadcn registry component, Context7 metadata, and a reusable coding-agent
|
|
13
|
+
skill.
|
|
14
|
+
- Added publishable `react-canvas-globe` and `create-canvas-globe` companion
|
|
15
|
+
packages for package-name discovery and project scaffolding.
|
|
16
|
+
- Fixed React client-component compatibility and forwarded-ref lifecycle
|
|
17
|
+
updates, plus safe cleanup for asynchronously loaded Svelte integrations.
|
|
18
|
+
- Improved README capture portability and pinned the Chromatic workflow action
|
|
19
|
+
to an immutable release commit.
|
|
20
|
+
|
|
21
|
+
## [0.1.4] - 2026-09-14
|
|
22
|
+
|
|
23
|
+
- Published the browser-safe package entry points to JSR under
|
|
24
|
+
`@swiftools/canvas-globe`.
|
|
25
|
+
- Made generated UMD builds deterministic across Windows and Linux.
|
|
26
|
+
- Corrected the custom-element render event and world-data type contracts.
|
|
27
|
+
|
|
9
28
|
## [0.1.3] - 2026-09-14
|
|
10
29
|
|
|
11
30
|
- Added JSR package configuration and tokenless GitHub publishing workflow.
|
package/README.md
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
[](LICENSE)
|
|
8
8
|
[](types/index.d.ts)
|
|
9
9
|
[](package.json)
|
|
10
|
+
[](https://skills.sh/Shree-hari/canvas-globe)
|
|
10
11
|
|
|
11
|
-
[](https://canvasglobe.swiftools.com/playground)
|
|
12
13
|
|
|
13
14
|
[**Open the live playground**](https://canvasglobe.swiftools.com/playground) ·
|
|
14
15
|
[Examples](https://canvasglobe.swiftools.com/examples) ·
|
|
@@ -20,6 +21,10 @@
|
|
|
20
21
|
[](https://stackblitz.com/github/Shree-hari/canvas-globe?startScript=start)
|
|
21
22
|
[](https://codesandbox.io/p/github/Shree-hari/canvas-globe)
|
|
22
23
|
|
|
24
|
+
**Start with your stack:** [Vanilla JS](starters/vanilla-vite) | [React + Vite](starters/react-vite) | [Next.js](starters/nextjs-app-router) | [Vue](starters/vue-vite) | [SvelteKit](starters/sveltekit) | [Web Component](starters/web-component-vite)
|
|
25
|
+
|
|
26
|
+
**Install with shadcn:** `npx shadcn@latest add https://canvasglobe.swiftools.com/r/canvas-globe.json`
|
|
27
|
+
|
|
23
28
|
`canvas-globe` is a zero-dependency JavaScript library for an interactive
|
|
24
29
|
**3D globe** and **flat world map** on Canvas 2D. It works with
|
|
25
30
|
vanilla JavaScript, React, or a Web Component and requires no WebGL, map API
|
|
@@ -107,7 +112,7 @@ npx jsr add @swiftools/canvas-globe
|
|
|
107
112
|
You can also import the JSR release directly in Deno:
|
|
108
113
|
|
|
109
114
|
```js
|
|
110
|
-
import { createGlobe } from "jsr:@swiftools/canvas-globe@0.1.
|
|
115
|
+
import { createGlobe } from "jsr:@swiftools/canvas-globe@0.1.5";
|
|
111
116
|
```
|
|
112
117
|
|
|
113
118
|
The React entry point remains on npm so React's peer dependency is resolved by
|
|
@@ -118,19 +123,19 @@ your existing application rather than installing a second React copy.
|
|
|
118
123
|
For a plain `<script>` installation, use the versioned UMD build:
|
|
119
124
|
|
|
120
125
|
```html
|
|
121
|
-
<script src="https://cdn.jsdelivr.net/npm/canvas-globe@0.1.
|
|
126
|
+
<script src="https://cdn.jsdelivr.net/npm/canvas-globe@0.1.5/dist/canvas-globe.umd.js"></script>
|
|
122
127
|
```
|
|
123
128
|
|
|
124
129
|
The same npm release is also available from UNPKG:
|
|
125
130
|
|
|
126
131
|
```html
|
|
127
|
-
<script src="https://unpkg.com/canvas-globe@0.1.
|
|
132
|
+
<script src="https://unpkg.com/canvas-globe@0.1.5/dist/canvas-globe.umd.js"></script>
|
|
128
133
|
```
|
|
129
134
|
|
|
130
135
|
Modern browsers can import the package through an ESM CDN:
|
|
131
136
|
|
|
132
137
|
```js
|
|
133
|
-
import { createGlobe } from "https://esm.sh/canvas-globe@0.1.
|
|
138
|
+
import { createGlobe } from "https://esm.sh/canvas-globe@0.1.5";
|
|
134
139
|
```
|
|
135
140
|
|
|
136
141
|
Pin an exact version in production so a future release cannot change a deployed page unexpectedly.
|
|
@@ -150,7 +155,7 @@ import { createGlobe } from "canvas-globe";
|
|
|
150
155
|
Or drop the UMD build on a page with no build step at all:
|
|
151
156
|
|
|
152
157
|
```html
|
|
153
|
-
<script src="https://cdn.jsdelivr.net/npm/canvas-globe@0.1.
|
|
158
|
+
<script src="https://cdn.jsdelivr.net/npm/canvas-globe@0.1.5/dist/canvas-globe.umd.js"></script>
|
|
154
159
|
<canvas id="globe" style="width:520px;aspect-ratio:1"></canvas>
|
|
155
160
|
<script>
|
|
156
161
|
CanvasGlobe.createGlobe(document.getElementById("globe"), {
|
|
@@ -227,6 +232,29 @@ export function Visitors({ markers }) {
|
|
|
227
232
|
|
|
228
233
|
React is an optional peer dependency: only the `/react` entry point needs it.
|
|
229
234
|
|
|
235
|
+
For a dedicated React package name, install the thin companion entry point:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
npm install react-canvas-globe
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
To scaffold a complete starter for React, Next.js, Vue, SvelteKit, Vanilla
|
|
242
|
+
JavaScript, or Web Components, run:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
npm create canvas-globe@latest my-globe
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### AI-assisted setup
|
|
249
|
+
|
|
250
|
+
Install the repository's CanvasGlobe skill for compatible coding agents:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
npx skills add https://github.com/Shree-hari/canvas-globe --skill canvas-globe
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Or copy the maintained prompt from the [AI-assisted setup guide](https://canvasglobe.swiftools.com/getting-started/ai-assisted-setup). The skill and prompt select the correct framework entry point, include cleanup and accessibility, and require a real license key before shipping. Proprietary projects are directed to [commercial pricing](https://canvasglobe.swiftools.com/pricing); GPLv3-compatible projects are directed to the [GPL licensing path](https://canvasglobe.swiftools.com/licensing).
|
|
257
|
+
|
|
230
258
|
## Options
|
|
231
259
|
|
|
232
260
|
| Option | Default | Description |
|
|
@@ -700,8 +728,13 @@ npm test # node --test, no test framework to install
|
|
|
700
728
|
npm run build # dist/canvas-globe.umd.js, with a gzipped size budget
|
|
701
729
|
npm run example # demo at http://localhost:8099
|
|
702
730
|
npm run release:check # tests, types, build and packed-artifact validation
|
|
731
|
+
npm run capture:readme # regenerate the animated README demo with Chrome or Chromium
|
|
703
732
|
```
|
|
704
733
|
|
|
734
|
+
The README capture script detects common Chrome and Chromium locations. If the
|
|
735
|
+
browser is installed elsewhere, set `CANVAS_GLOBE_CHROME` to its executable
|
|
736
|
+
path before running `npm run capture:readme`.
|
|
737
|
+
|
|
705
738
|
The product website and documentation are maintained separately at
|
|
706
739
|
[canvasglobe.swiftools.com](https://canvasglobe.swiftools.com/).
|
|
707
740
|
|
package/codemeta.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"identifier": "canvas-globe",
|
|
6
6
|
"description": "Zero-dependency JavaScript and React library for interactive 3D globes and flat world maps rendered with Canvas 2D, with no WebGL or API-key requirement.",
|
|
7
7
|
"url": "https://canvasglobe.swiftools.com/",
|
|
8
|
-
"version": "0.1.
|
|
8
|
+
"version": "0.1.5",
|
|
9
9
|
"codeRepository": "https://github.com/Shree-hari/canvas-globe",
|
|
10
10
|
"issueTracker": "https://github.com/Shree-hari/canvas-globe/issues",
|
|
11
11
|
"downloadUrl": "https://www.npmjs.com/package/canvas-globe",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "canvas-globe",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Zero-dependency JavaScript and React library for interactive 3D globes and flat world maps rendered with Canvas 2D. No WebGL or API key.",
|
|
5
5
|
"license": "GPL-3.0-only",
|
|
6
6
|
"author": {
|
|
@@ -92,10 +92,16 @@
|
|
|
92
92
|
"build": "node scripts/build.mjs",
|
|
93
93
|
"data": "node scripts/generate-data.mjs && node scripts/generate-timezones.mjs",
|
|
94
94
|
"example": "node scripts/serve.mjs",
|
|
95
|
+
"storybook": "storybook dev -p 6006",
|
|
96
|
+
"build-storybook": "storybook build",
|
|
97
|
+
"build:registry": "shadcn build --output .registry-build",
|
|
98
|
+
"capture:readme": "node scripts/capture-readme-demo.mjs",
|
|
95
99
|
"test": "node --test",
|
|
100
|
+
"test:ecosystem": "npm run build:registry && node scripts/validate-ecosystem.mjs && npm --prefix packages/create-canvas-globe test",
|
|
96
101
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
102
|
+
"typecheck:ecosystem": "tsc --noEmit -p tsconfig.ecosystem.json",
|
|
97
103
|
"smoke:package": "node scripts/package-smoke.mjs",
|
|
98
|
-
"release:check": "npm run test && npm run typecheck && npm run build && node scripts/release-check.mjs && npm run smoke:package",
|
|
104
|
+
"release:check": "npm run test && npm run typecheck && npm run typecheck:ecosystem && npm run test:ecosystem && npm run build && node scripts/release-check.mjs && npm run smoke:package",
|
|
99
105
|
"prepublishOnly": "npm run test && npm run typecheck && npm run build && node scripts/release-check.mjs"
|
|
100
106
|
},
|
|
101
107
|
"peerDependencies": {
|
|
@@ -107,7 +113,16 @@
|
|
|
107
113
|
}
|
|
108
114
|
},
|
|
109
115
|
"devDependencies": {
|
|
116
|
+
"@storybook/addon-a11y": "^10.6.0",
|
|
117
|
+
"@storybook/html-vite": "^10.6.0",
|
|
118
|
+
"@types/react": "^19.3.0",
|
|
119
|
+
"chromatic": "^18.8.1",
|
|
120
|
+
"gifenc": "^1.0.3",
|
|
121
|
+
"playwright-core": "^1.63.0",
|
|
122
|
+
"pngjs": "^7.0.0",
|
|
110
123
|
"polygon-clipping": "^0.15.7",
|
|
124
|
+
"shadcn": "^4.21.0",
|
|
125
|
+
"storybook": "^10.6.0",
|
|
111
126
|
"topojson-client": "^3.1.0",
|
|
112
127
|
"typescript": "^5.5.0"
|
|
113
128
|
},
|
package/src/element.js
CHANGED
package/src/react.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
1
3
|
/* @ts-self-types="../types/react.d.ts" */
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* React binding. `import { Globe } from "canvas-globe/react"`.
|
|
5
7
|
* React is a peer dependency and is only required by this entry point.
|
|
6
8
|
*/
|
|
7
|
-
import { createElement, forwardRef, useEffect, useImperativeHandle, useRef } from "react";
|
|
9
|
+
import { createElement, forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
8
10
|
import { GeoGlobe } from "./geo-globe.js";
|
|
9
11
|
import { mapAspect } from "./geo.js";
|
|
10
12
|
|
|
@@ -17,6 +19,7 @@ export const Globe = forwardRef(function Globe(props, ref) {
|
|
|
17
19
|
|
|
18
20
|
const canvasRef = useRef(null);
|
|
19
21
|
const globeRef = useRef(null);
|
|
22
|
+
const [globe, setGlobe] = useState(null);
|
|
20
23
|
const handlers = useRef(props);
|
|
21
24
|
const previous = useRef(null);
|
|
22
25
|
const initial = useRef(options);
|
|
@@ -27,6 +30,7 @@ export const Globe = forwardRef(function Globe(props, ref) {
|
|
|
27
30
|
for (const name of CALLBACKS) bound[name] = (...args) => handlers.current[name]?.(...args);
|
|
28
31
|
const globe = new GeoGlobe(canvasRef.current, { ...initial.current, ...bound });
|
|
29
32
|
globeRef.current = globe;
|
|
33
|
+
setGlobe(globe);
|
|
30
34
|
previous.current = initial.current;
|
|
31
35
|
return () => {
|
|
32
36
|
globe.destroy();
|
|
@@ -49,7 +53,7 @@ export const Globe = forwardRef(function Globe(props, ref) {
|
|
|
49
53
|
if (changed) globe.setOptions(patch);
|
|
50
54
|
});
|
|
51
55
|
|
|
52
|
-
useImperativeHandle(ref, () =>
|
|
56
|
+
useImperativeHandle(ref, () => globe, [globe]);
|
|
53
57
|
|
|
54
58
|
const aspect = options.mode === "map" ? 1 / mapAspect(options.latRange, options.projection) : 1;
|
|
55
59
|
return createElement("canvas", {
|