3d-spinner 0.9.1 → 0.9.2

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
@@ -5,8 +5,9 @@
5
5
  [![license](https://img.shields.io/github/license/runelaang/3d-spinner)](LICENSE)
6
6
 
7
7
  A zero-dependency 3D spinner, loader, and progress indicator for the browser. It renders to a
8
- canvas and ships as ES modules split across separate import paths, so a consumer loads only the
9
- animation, motion path, and rendering backend they actually use - nothing else is pulled in.
8
+ canvas and ships primarily as ES modules split across separate import paths, so a consumer loads
9
+ only the animation, motion path, and rendering backend they actually use - nothing else is pulled
10
+ in. CommonJS and a browser-global build are also published; see [Module formats](#module-formats).
10
11
 
11
12
  ## Install
12
13
 
@@ -175,17 +176,39 @@ directly:
175
176
 
176
177
  Each has no dependencies of its own.
177
178
 
178
- ## Module format
179
+ ## Module formats
179
180
 
180
- ES modules only, for the browser. Use a bundler or native `<script type="module">`; the engine
181
- draws to a canvas, so there is no server-side rendering. ES modules do not load over `file://`,
182
- so serve the page over HTTP rather than opening the file directly.
181
+ Every example above is **ES modules** - the primary, tree-shakeable format. Use a bundler or native `<script type="module">`; the engine draws to a canvas, so
182
+ there is no server-side rendering. ES modules do not load over `file://`, so serve the page over
183
+ HTTP rather than opening the file directly.
184
+
185
+ Two other formats are published for cases where ESM isn't an option:
186
+
187
+ **CommonJS** (`require`), for older Node tooling:
188
+
189
+ ```js
190
+ const { createSpinner } = require("3d-spinner");
191
+ const { SpinAnimation } = require("3d-spinner/animations/spin");
192
+ ```
193
+
194
+ **Browser global** (IIFE), for a plain `<script>` tag with no bundler or module loader. This build
195
+ bundles the whole public API onto one `window.Spinner3D` object:
196
+
197
+ ```html
198
+ <script src="https://unpkg.com/3d-spinner"></script>
199
+ <script>
200
+ const spinner = Spinner3D.createSpinner(document.getElementById("app"), {
201
+ type: "indeterminate",
202
+ animation: new Spinner3D.SpinAnimation(),
203
+ });
204
+ </script>
205
+ ```
183
206
 
184
207
  ## Development
185
208
 
186
209
  ```sh
187
210
  npm install
188
- npm run build # compile src/ to dist/ (ESM + type declarations)
211
+ npm run build # compile src/ to dist/ (ESM + type declarations, CJS, and a browser-global build)
189
212
  npm test # build, then run the unit tests
190
213
  npm run dev # serve this folder; open /examples/index.html
191
214
  ```