facebetter 1.0.12 → 1.0.13
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 +2 -2
- package/lib/index.js +0 -94
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "facebetter",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Face beauty effects SDK with WebAssembly support",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -46,6 +46,6 @@
|
|
|
46
46
|
"rollup": "^3.0.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"facebetter-core": "^1.0.
|
|
49
|
+
"facebetter-core": "^1.0.3"
|
|
50
50
|
}
|
|
51
51
|
}
|
package/lib/index.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Node.js CommonJS Entry Point
|
|
3
|
-
* For require() usage in Node.js
|
|
4
|
-
* Uses facebetter-core npm package for WASM module
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// Import ESM module (Node.js 12+ supports import() for CommonJS)
|
|
8
|
-
let wasmModuleInstance = null;
|
|
9
|
-
let wasmModulePromise = null;
|
|
10
|
-
|
|
11
|
-
async function loadWasmModule(options = {}) {
|
|
12
|
-
if (wasmModuleInstance) {
|
|
13
|
-
return wasmModuleInstance;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (wasmModulePromise) {
|
|
17
|
-
return wasmModulePromise;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
wasmModulePromise = (async () => {
|
|
21
|
-
try {
|
|
22
|
-
let FaceBetterModuleFactory;
|
|
23
|
-
|
|
24
|
-
if (options.wasmPath) {
|
|
25
|
-
// If custom path is provided, use it (for backward compatibility or custom builds)
|
|
26
|
-
const module = await import(options.wasmPath);
|
|
27
|
-
FaceBetterModuleFactory = module.default || module;
|
|
28
|
-
} else {
|
|
29
|
-
// Import from facebetter-core npm package
|
|
30
|
-
const module = await import('facebetter-core');
|
|
31
|
-
FaceBetterModuleFactory = module.default || module.createFaceBetterModule;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (!FaceBetterModuleFactory) {
|
|
35
|
-
throw new Error('WASM module does not export createFaceBetterModule function');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Initialize the module
|
|
39
|
-
// With SINGLE_FILE=1, WASM binary and data are embedded in the JS file
|
|
40
|
-
wasmModuleInstance = await FaceBetterModuleFactory({
|
|
41
|
-
locateFile: (path) => {
|
|
42
|
-
// With SINGLE_FILE=1, Emscripten handles embedded files automatically
|
|
43
|
-
// Custom locateFile is only needed if user provides one
|
|
44
|
-
return path;
|
|
45
|
-
},
|
|
46
|
-
...options
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
if (!wasmModuleInstance) {
|
|
50
|
-
throw new Error('Failed to initialize WASM module');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
wasmModuleInstance.ready = true;
|
|
54
|
-
return wasmModuleInstance;
|
|
55
|
-
} catch (e) {
|
|
56
|
-
throw new Error(`Failed to load WASM module: ${e.message}`);
|
|
57
|
-
}
|
|
58
|
-
})();
|
|
59
|
-
|
|
60
|
-
return wasmModulePromise;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Re-export from ESM module
|
|
64
|
-
async function getExports() {
|
|
65
|
-
// Import the ESM version
|
|
66
|
-
const esmModule = await import('../src/node/index.js');
|
|
67
|
-
return esmModule;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// For CommonJS, we need to export a promise or use async exports
|
|
71
|
-
// This is a limitation - Node.js CommonJS doesn't support async exports well
|
|
72
|
-
// Users should use the ESM version or await the exports
|
|
73
|
-
|
|
74
|
-
module.exports = {
|
|
75
|
-
// Export a function that returns the actual exports
|
|
76
|
-
async getFacebetter() {
|
|
77
|
-
const exports = await getExports();
|
|
78
|
-
return exports;
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
// Export loadWasmModule
|
|
82
|
-
loadWasmModule
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
// Also try to export synchronously (may not work if module needs async init)
|
|
86
|
-
// This is a workaround for CommonJS compatibility
|
|
87
|
-
let cachedExports = null;
|
|
88
|
-
module.exports.getSync = () => {
|
|
89
|
-
if (!cachedExports) {
|
|
90
|
-
throw new Error('Module not initialized. Use getFacebetter() or loadWasmModule() first.');
|
|
91
|
-
}
|
|
92
|
-
return cachedExports;
|
|
93
|
-
};
|
|
94
|
-
|