@teachinglab/omd 0.6.3 → 0.6.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/index.js +4 -1
- package/omd/utils/registerMathGlobal.js +19 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
* const { omdTable } = await import('@teachinglab/omd')
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
// Ensure math.js is available globally before loading modules that rely on window/global math
|
|
15
|
+
import './omd/utils/registerMathGlobal.js';
|
|
16
|
+
|
|
14
17
|
// Import everything first to ensure proper loading order
|
|
15
18
|
import * as omdCore from './omd/core/index.js';
|
|
16
19
|
import * as omdCanvas from './canvas/index.js';
|
|
@@ -77,4 +80,4 @@ export default {
|
|
|
77
80
|
const { omdDisplay } = await import('./omd/core/index.js');
|
|
78
81
|
return new omdDisplay(container);
|
|
79
82
|
}
|
|
80
|
-
};
|
|
83
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as mathjs from 'mathjs';
|
|
2
|
+
|
|
3
|
+
const globalScope = (() => {
|
|
4
|
+
if (typeof globalThis !== 'undefined') return globalThis;
|
|
5
|
+
if (typeof window !== 'undefined') return window;
|
|
6
|
+
if (typeof global !== 'undefined') return global;
|
|
7
|
+
return undefined;
|
|
8
|
+
})();
|
|
9
|
+
|
|
10
|
+
if (globalScope && !globalScope.math) {
|
|
11
|
+
try {
|
|
12
|
+
globalScope.math = mathjs;
|
|
13
|
+
} catch (_) {
|
|
14
|
+
// Silently ignore if the global object is not writable.
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const math = mathjs;
|
|
19
|
+
export default mathjs;
|