cpp.js 1.0.0-beta.22 → 1.0.0-beta.23

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": "cpp.js",
3
- "version": "1.0.0-beta.22",
3
+ "version": "1.0.0-beta.23",
4
4
  "license": "MIT",
5
5
  "homepage": "https://cpp.js.org",
6
6
  "repository": "https://github.com/bugra9/cpp.js.git",
@@ -1,51 +0,0 @@
1
- import getData from '../actions/getData.js';
2
- import loadJson from '../utils/loadJson.js';
3
-
4
- export default function exportReactNative(platform, bridgePath = null) {
5
- const env = JSON.stringify(getData('env', platform));
6
-
7
- const bridgeExportFile = `${bridgePath}.exports.json`;
8
- let symbols = null;
9
- if (bridgePath) {
10
- symbols = loadJson(bridgeExportFile);
11
- }
12
-
13
- let symbolExportDefineString = '';
14
- let symbolExportAssignString = '';
15
- if (symbols && Array.isArray(symbols)) {
16
- symbolExportDefineString = symbols.map((s) => `export let ${s} = null;`).join('\n');
17
- symbolExportAssignString = symbols.map((s) => `${s} = Module.${s};`).join('\n');
18
- }
19
-
20
- return `
21
- import { NativeModules } from 'react-native';
22
- import Module from '@cpp.js/core-embind-jsi';
23
-
24
- const { RNJsiLib } = NativeModules;
25
-
26
- function setEnv() {
27
- const env = JSON.parse('${env}');
28
- const CPPJS_DATA_PATH = Module.CppJS.getEnv('CPPJS_DATA_PATH');
29
-
30
- Object.entries(env).forEach(([key, value]) => {
31
- Module.CppJS.setEnv(key, value.replace('_CPPJS_DATA_PATH_', CPPJS_DATA_PATH), true);
32
- });
33
- }
34
-
35
- export let AllSymbols = {};
36
- ${symbolExportDefineString}
37
- export function initCppJs(config = {}) {
38
- return new Promise((resolve, reject) => {
39
- if (RNJsiLib && RNJsiLib.start) {
40
- RNJsiLib.start();
41
- setEnv();
42
- AllSymbols = Module;
43
- ${symbolExportAssignString}
44
- resolve(Module);
45
- } else {
46
- reject('Module failed to initialise.');
47
- }
48
- });
49
- }
50
- `;
51
- }
@@ -1,42 +0,0 @@
1
- import getData from '../actions/getData.js';
2
- import loadJson from '../utils/loadJson.js';
3
-
4
- const env = JSON.stringify(getData('env'));
5
-
6
- const params = `{
7
- ...config,
8
- env: {...${env}, ...config.env},
9
- paths: {
10
- wasm: 'cpp.wasm',
11
- data: 'cpp.data.txt'
12
- }
13
- }`;
14
-
15
- export default function exportWeb(bridgePath = null) {
16
- const bridgeExportFile = `${bridgePath}.exports.json`;
17
- let symbols = null;
18
- if (bridgePath) {
19
- symbols = loadJson(bridgeExportFile);
20
- }
21
-
22
- let symbolExportDefineString = '';
23
- let symbolExportAssignString = '';
24
- if (symbols && Array.isArray(symbols)) {
25
- symbolExportDefineString = symbols.map((s) => `export let ${s} = null;`).join('\n');
26
- symbolExportAssignString = symbols.map((s) => `${s} = m.${s};`).join('\n');
27
- }
28
-
29
- return `
30
- export let AllSymbols = {};
31
- ${symbolExportDefineString}
32
- export function initCppJs(config = {}) {
33
- return new Promise(
34
- (resolve, reject) => import('/cpp.js').then(n => { return window.CppJs.initCppJs(${params})}).then(m => {
35
- AllSymbols = m;
36
- ${symbolExportAssignString}
37
- resolve(m);
38
- })
39
- );
40
- }
41
- `;
42
- }