@emasoft/svg-matrix 1.0.10 → 1.0.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emasoft/svg-matrix",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "Arbitrary-precision matrix, vector and affine transformation library for JavaScript using decimal.js",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Test script for postinstall.js Unicode and ASCII fallback support.
4
+ * This tests various terminal environment configurations to ensure
5
+ * proper rendering of box characters.
6
+ */
7
+
8
+ import { spawn } from 'child_process';
9
+
10
+ console.log('\n=== Testing postinstall.js Unicode/ASCII support ===\n');
11
+
12
+ const tests = [
13
+ {
14
+ name: 'Unicode mode (UTF-8 locale)',
15
+ env: { LANG: 'en_US.UTF-8' },
16
+ expectUnicode: true,
17
+ },
18
+ {
19
+ name: 'ASCII fallback (C locale)',
20
+ env: { LANG: 'C' },
21
+ expectUnicode: false,
22
+ },
23
+ {
24
+ name: 'UTF-8 in LC_CTYPE',
25
+ env: { LC_CTYPE: 'en_US.UTF-8', LANG: '' },
26
+ expectUnicode: true,
27
+ },
28
+ ];
29
+
30
+ let passed = 0;
31
+ let failed = 0;
32
+
33
+ async function runTest(test) {
34
+ return new Promise((resolve) => {
35
+ console.log(`▸ Testing: ${test.name}`);
36
+
37
+ // Prepare environment
38
+ const env = { ...process.env, ...test.env };
39
+
40
+ const child = spawn('node', ['scripts/postinstall.js'], {
41
+ env,
42
+ stdio: 'pipe',
43
+ });
44
+
45
+ let output = '';
46
+
47
+ child.stdout.on('data', (data) => {
48
+ output += data.toString();
49
+ });
50
+
51
+ child.on('close', () => {
52
+ // Check for Unicode or ASCII box characters
53
+ const hasUnicodeBox = /[╭╮╰╯─│]/.test(output);
54
+ const hasAsciiBox = /[+\-|]/.test(output);
55
+
56
+ if (test.expectUnicode && hasUnicodeBox) {
57
+ console.log(` ✓ PASS: Unicode box characters detected\n`);
58
+ resolve(true);
59
+ } else if (!test.expectUnicode && hasAsciiBox && !hasUnicodeBox) {
60
+ console.log(` ✓ PASS: ASCII fallback characters detected\n`);
61
+ resolve(true);
62
+ } else {
63
+ console.log(` ✗ FAIL: Expected ${test.expectUnicode ? 'Unicode' : 'ASCII'} but got different output\n`);
64
+ resolve(false);
65
+ }
66
+ });
67
+
68
+ child.on('error', (error) => {
69
+ console.log(` ✗ FAIL: ${error.message}\n`);
70
+ resolve(false);
71
+ });
72
+ });
73
+ }
74
+
75
+ async function runAllTests() {
76
+ for (const test of tests) {
77
+ const result = await runTest(test);
78
+ if (result) {
79
+ passed++;
80
+ } else {
81
+ failed++;
82
+ }
83
+ }
84
+
85
+ console.log('=== Test Results ===');
86
+ console.log(`Passed: ${passed}`);
87
+ console.log(`Failed: ${failed}`);
88
+ console.log(`Total: ${passed + failed}\n`);
89
+
90
+ process.exit(failed > 0 ? 1 : 0);
91
+ }
92
+
93
+ runAllTests();
package/src/index.js CHANGED
@@ -5,15 +5,16 @@
5
5
  * SVG path conversion, and 2D/3D affine transformations using Decimal.js.
6
6
  *
7
7
  * @module @emasoft/svg-matrix
8
- * @version 1.0.6
8
+ * @version 1.0.11
9
9
  * @license MIT
10
10
  *
11
11
  * @example
12
12
  * // ES Module import
13
13
  * import { Decimal, Matrix, Vector, Transforms2D, GeometryToPath } from '@emasoft/svg-matrix';
14
14
  *
15
- * // Set global precision (default is 20, max is 1e9)
16
- * Decimal.set({ precision: 80 });
15
+ * // Precision is already set to 80 by default (max is 1e9)
16
+ * // You can increase it further if needed:
17
+ * // Decimal.set({ precision: 200 });
17
18
  *
18
19
  * // Create and compose 2D transforms
19
20
  * const M = Transforms2D.translation(2, 3)
@@ -45,11 +46,16 @@ import * as MeshGradient from './mesh-gradient.js';
45
46
  import * as TextToPath from './text-to-path.js';
46
47
  import { Logger, LogLevel, setLogLevel, getLogLevel as getLoggerLevel, enableFileLogging, disableFileLogging } from './logger.js';
47
48
 
49
+ // Set high-precision default (80 significant digits) on module load
50
+ // This is the same precision used internally by all svg-matrix modules
51
+ // Users can increase further with setPrecision() or Decimal.set() - max is 1e9
52
+ Decimal.set({ precision: 80 });
53
+
48
54
  /**
49
55
  * Library version
50
56
  * @constant {string}
51
57
  */
52
- export const VERSION = '1.0.10';
58
+ export const VERSION = '1.0.11';
53
59
 
54
60
  /**
55
61
  * Default precision for path output (decimal places)