@supermousejs/zoetrope 2.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # @supermousejs/zoetrope
2
+
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - Initial v2.0.0 release
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @supermousejs/core@2.0.0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Sijibomi Olusunmbola
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Prepares text for a seamless loop by optionally appending a non-breaking space.
3
+ * This prevents the last character from touching the first character when spread is active.
4
+ *
5
+ * @param text The source text
6
+ * @param spread Whether auto-fit spreading is enabled
7
+ */
8
+ export declare function formatLoopText(text: string, spread: boolean): string;
9
+
10
+ /**
11
+ * Calculates the SVG Path data for a perfect circle starting at the top center (12 o'clock).
12
+ *
13
+ * Path moves to (0, -r), then draws two semi-circles.
14
+ * @param r Radius in pixels
15
+ */
16
+ export declare function getCirclePath(r: number): string;
17
+
18
+ /**
19
+ * Calculates the circumference of a circle.
20
+ * @param r Radius in pixels
21
+ */
22
+ export declare function getCircumference(r: number): number;
23
+
24
+ export { }
package/dist/index.mjs ADDED
@@ -0,0 +1,19 @@
1
+ function e(t) {
2
+ const r = Math.round(t * 100) / 100;
3
+ return `
4
+ M 0, -${r}
5
+ A ${r},${r} 0 1,1 0,${r}
6
+ A ${r},${r} 0 1,1 0,-${r}
7
+ `.replace(/\s+/g, " ").trim();
8
+ }
9
+ function n(t) {
10
+ return 2 * Math.PI * t;
11
+ }
12
+ function o(t, r) {
13
+ return r ? t + " " : t;
14
+ }
15
+ export {
16
+ o as formatLoopText,
17
+ e as getCirclePath,
18
+ n as getCircumference
19
+ };
@@ -0,0 +1,5 @@
1
+ (function(t,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(t=typeof globalThis<"u"?globalThis:t||self,o(t.SupermouseZoetrope={}))})(this,(function(t){"use strict";function o(n){const e=Math.round(n*100)/100;return`
2
+ M 0, -${e}
3
+ A ${e},${e} 0 1,1 0,${e}
4
+ A ${e},${e} 0 1,1 0,-${e}
5
+ `.replace(/\s+/g," ").trim()}function r(n){return 2*Math.PI*n}function i(n,e){return e?n+" ":n}t.formatLoopText=i,t.getCirclePath=o,t.getCircumference=r,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@supermousejs/zoetrope",
3
+ "version": "2.0.0",
4
+ "main": "dist/index.umd.js",
5
+ "module": "dist/index.mjs",
6
+ "types": "dist/index.d.ts",
7
+ "dependencies": {
8
+ "@supermousejs/core": "2.0.0"
9
+ },
10
+ "devDependencies": {},
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.mjs",
15
+ "require": "./dist/index.umd.js"
16
+ }
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "scripts": {
22
+ "build": "vite build"
23
+ }
24
+ }
package/src/index.ts ADDED
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Calculates the SVG Path data for a perfect circle starting at the top center (12 o'clock).
3
+ *
4
+ * Path moves to (0, -r), then draws two semi-circles.
5
+ * @param r Radius in pixels
6
+ */
7
+ export function getCirclePath(r: number): string {
8
+ // Fix floating point precision slightly to avoid rendering artifacts
9
+ const rClean = Math.round(r * 100) / 100;
10
+
11
+ return `
12
+ M 0, -${rClean}
13
+ A ${rClean},${rClean} 0 1,1 0,${rClean}
14
+ A ${rClean},${rClean} 0 1,1 0,-${rClean}
15
+ `.replace(/\s+/g, ' ').trim();
16
+ }
17
+
18
+ /**
19
+ * Calculates the circumference of a circle.
20
+ * @param r Radius in pixels
21
+ */
22
+ export function getCircumference(r: number): number {
23
+ return 2 * Math.PI * r;
24
+ }
25
+
26
+ /**
27
+ * Prepares text for a seamless loop by optionally appending a non-breaking space.
28
+ * This prevents the last character from touching the first character when spread is active.
29
+ *
30
+ * @param text The source text
31
+ * @param spread Whether auto-fit spreading is enabled
32
+ */
33
+ export function formatLoopText(text: string, spread: boolean): string {
34
+ if (!spread) return text;
35
+ // \u00A0 is &nbsp;
36
+ return text + '\u00A0';
37
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "include": [
4
+ "src"
5
+ ],
6
+ "compilerOptions": {
7
+ "outDir": "dist",
8
+ "baseUrl": ".",
9
+ "paths": {
10
+ "@supermousejs/core": [
11
+ "../core/src/index.ts"
12
+ ]
13
+ }
14
+ }
15
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { defineConfig } from 'vite';
2
+ import dts from 'vite-plugin-dts';
3
+ import path from 'path';
4
+
5
+ export default defineConfig({
6
+ build: {
7
+ lib: {
8
+ entry: path.resolve(__dirname, 'src/index.ts'),
9
+ name: 'SupermouseZoetrope',
10
+ fileName: (format) => format === 'es' ? 'index.mjs' : 'index.umd.js',
11
+ },
12
+ rollupOptions: {
13
+ external: ['@supermousejs/core'],
14
+ output: {
15
+ globals: {
16
+ '@supermousejs/core': 'SupermouseCore'
17
+ }
18
+ }
19
+ }
20
+ },
21
+ plugins: [dts({ rollupTypes: true })]
22
+ });