@mrigx/core 0.1.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/src/types.ts ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @file types.ts
3
+ * @description Core type definitions for the Mrig Optical Engine.
4
+ */
5
+
6
+ export type OpticalMaterial = 'glass' | 'soft-glass' | 'liquid' | 'crystal' | 'abyss';
7
+
8
+ export interface InteractionSource {
9
+ x: number;
10
+ y: number;
11
+ vx: number;
12
+ vy: number;
13
+ radius: number;
14
+ strength: number;
15
+ isActive: number;
16
+ type?: number;
17
+ angle?: number;
18
+ docY?: number;
19
+ }
20
+
21
+ export interface SurfaceConfig {
22
+ material?: OpticalMaterial;
23
+ materialStrength: number;
24
+ borderRadius: number;
25
+ isDynamic?: boolean;
26
+ }
27
+
28
+ export interface SurfaceData {
29
+ x: number;
30
+ y: number;
31
+ width: number;
32
+ height: number;
33
+ config: SurfaceConfig;
34
+ atlasUV?: [number, number, number, number];
35
+ }
36
+
37
+
38
+
package/src/utils.ts ADDED
@@ -0,0 +1,26 @@
1
+ import type { OpticalMaterial } from './types';
2
+
3
+ export type OpticalStrength = 'soft' | 'default' | 'strong' | 'heavy' | number;
4
+
5
+ export function resolveOpticalStrength(strength?: OpticalStrength, defaultVal: number = 1.0): number {
6
+ if (typeof strength === 'number') return strength;
7
+ switch (strength) {
8
+ case 'soft': return 0.5;
9
+ case 'default': return 1.0;
10
+ case 'strong': return 1.8;
11
+ case 'heavy': return 2.5;
12
+ default: return defaultVal;
13
+ }
14
+ }
15
+
16
+ export function resolveMaterialProps(material?: OpticalMaterial) {
17
+ switch (material) {
18
+ case 'soft-glass': return { refMult: 0.5, highMult: 0.15 };
19
+ case 'liquid': return { refMult: 2.0, highMult: 0.6 };
20
+ case 'crystal': return { refMult: 1.5, highMult: 0.8 };
21
+ case 'abyss': return { refMult: 3.0, highMult: 1.0 };
22
+ case 'glass':
23
+ default: return { refMult: 1.0, highMult: 0.4 };
24
+ }
25
+ }
26
+
package/tsconfig.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "lib": [
6
+ "ES2020",
7
+ "DOM",
8
+ "DOM.Iterable"
9
+ ],
10
+ "module": "ESNext",
11
+ "skipLibCheck": true,
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "resolveJsonModule": true,
15
+ "isolatedModules": true,
16
+ "noEmit": true,
17
+ "jsx": "react-jsx",
18
+ "strict": true,
19
+ "noUnusedLocals": true,
20
+ "noUnusedParameters": true,
21
+ "noFallthroughCasesInSwitch": true,
22
+ "baseUrl": ".",
23
+ "paths": {
24
+ "@mrigx/core": [
25
+ "./src/index.ts"
26
+ ]
27
+ }
28
+ },
29
+ "include": [
30
+ "src"
31
+ ]
32
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,35 @@
1
+ import { defineConfig } from 'vite';
2
+ import dts from 'vite-plugin-dts';
3
+ import { resolve } from 'path';
4
+ import url from 'url';
5
+
6
+ const dirname = url.fileURLToPath(new URL('.', import.meta.url));
7
+
8
+ export default defineConfig({
9
+ publicDir: false,
10
+ plugins: [
11
+ dts({
12
+ include: ['src/**/*'],
13
+ outDir: 'dist',
14
+ insertTypesEntry: true,
15
+ tsconfigPath: './tsconfig.json'
16
+ })
17
+ ],
18
+ build: {
19
+ outDir: 'dist',
20
+ emptyOutDir: true,
21
+ lib: {
22
+ entry: resolve(dirname, 'src/index.ts'),
23
+ name: 'MrigCore',
24
+ fileName: (format) => 'core.' + format + '.js'
25
+ },
26
+ rollupOptions: {
27
+ external: ['html-to-image'],
28
+ output: {
29
+ globals: {
30
+ 'html-to-image': 'htmlToImage'
31
+ }
32
+ }
33
+ }
34
+ }
35
+ });