Skip to content

Commit

Permalink
monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
toyobayashi committed Jan 30, 2022
1 parent 27e319c commit 649c483
Show file tree
Hide file tree
Showing 169 changed files with 551 additions and 390 deletions.
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/dist
**/dist
node_modules
/lib/typings
.eslintrc.js
/example
/test/.cgenbuild
/test/CMakeFiles
/packages/runtime/lib
/packages/emnapi/lib
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/test/cmake_install.cmake
/test/Makefile
/test/CMakefiles
/node_modules
node_modules
/include/node_api_full.h
/dist
package-lock.json
Expand Down
17 changes: 0 additions & 17 deletions .npmignore

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"env": {
"includePath": [
"${default}",
"${workspaceFolder}/include"
"${workspaceFolder}/packages/emnapi/include"
],
"defines": ["NAPI_DISABLE_CPP_EXCEPTIONS", "NODE_ADDON_API_ENABLE_MAYBE"],
"clPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29910\\bin\\Hostx64\\x64\\cl.exe",
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"request": "launch",
"name": "Launch Program",
"runtimeArgs": ["--expose-gc"],
"program": "${workspaceFolder}/test/emnapi/emnapi.test.js",
"program": "${workspaceFolder}/packages/test/emnapi/emnapi.test.js",
"args": []
},
{
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"files.associations": {
"api-extractor.json": "jsonc"
"**/api-extractor.json": "jsonc"
}
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Toyobayashi
Copyright (c) 2021-present Toyobayashi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion example/node_modules/@tybys/emnapi/CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 0 additions & 23 deletions lib/runtime/tsconfig.json

This file was deleted.

51 changes: 8 additions & 43 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,11 @@
{
"name": "@tybys/emnapi",
"private": true,
"version": "0.10.0",
"description": "Node-API implementation for Emscripten",
"main": "index.js",
"typings": "index.d.ts",
"scripts": {
"clean": "cd test && cgen clean",
"build:runtime": "tsc -p ./lib/runtime/tsconfig.json && node ./script/build-runtime.js",
"build:lib": "npm run build:runtime && tsc && node ./script/build.js",
"build": "cd ./packages/runtime&&npm run build&&cd ../emnapi&&npm run build",
"release": "npm run build:runtime && tsc && node ./script/build.js&&node ./script/release.js",
"prepare": "npm run build:lib",
"rebuild": "npm run build:lib && cd test && cgen rebuild -e -d",
"rebuild:r": "npm run build:lib && cd test && cgen rebuild -e",
"rebuild:n": "cd test && cgen rebuild -d",
"rebuild:nr": "cd test && cgen rebuild",
"lint": "eslint {lib/**/*.ts,test/**/*.ts}",
"test": "node ./script/test.js",
"test:r": "cross-env NODE_ENV=production node ./script/test.js",
"test:n": "cross-env EMNAPI_TEST_NATIVE=1 node ./script/test.js",
"test:nr": "cross-env EMNAPI_TEST_NATIVE=1 NODE_ENV=production node ./script/test.js"
"lint": "eslint packages/**/*.ts"
},
"keywords": [
"emscripten",
"wasm",
"emcc",
"webassembly",
"bindings",
"c",
"c++",
"cpp",
"n-api",
"napi",
"node-addon-api"
],
"author": "toyobayashi",
"repository": {
"type": "git",
Expand All @@ -47,28 +20,20 @@
},
"license": "MIT",
"devDependencies": {
"@microsoft/api-extractor": "^7.19.4",
"@rollup/plugin-node-resolve": "^13.1.3",
"@rollup/plugin-typescript": "^8.3.0",
"@tybys/cgen": "^0.11.1",
"@tybys/cross-zip": "^3.1.0",
"@types/fs-extra": "^9.0.13",
"@types/node": "^16.11.21",
"@typescript-eslint/eslint-plugin": "^5.8.1",
"@typescript-eslint/parser": "^5.8.1",
"chalk": "^4.1.1",
"cross-env": "^7.0.3",
"eslint": "^8.5.0",
"eslint-config-standard-with-typescript": "^21.0.1",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.0.0",
"fs-extra": "^10.0.0",
"glob": "^7.2.0",
"node-addon-api": "4.3.0",
"rollup": "^2.66.1",
"rollup-plugin-terser": "^7.0.2",
"tslib": "^2.3.1",
"typescript": "~4.5.2"
}
"typescript": "~4.5.5"
},
"workspaces": [
"./packages/*"
]
}
2 changes: 2 additions & 0 deletions packages/emnapi/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
/dist
File renamed without changes.
21 changes: 21 additions & 0 deletions packages/emnapi/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021-present Toyobayashi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 36 additions & 0 deletions packages/emnapi/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@tybys/emnapi",
"version": "0.10.0",
"description": "Node-API implementation for Emscripten",
"main": "index.js",
"devDependencies": {},
"scripts": {
"build": "tsc && node ./script/build.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/toyobayashi/emnapi.git"
},
"keywords": [
"emscripten",
"wasm",
"emcc",
"webassembly",
"bindings",
"c",
"c++",
"cpp",
"n-api",
"napi",
"node-addon-api"
],
"author": "toyobayashi",
"license": "MIT",
"bugs": {
"url": "https://github.com/toyobayashi/emnapi/issues"
},
"homepage": "https://github.com/toyobayashi/emnapi#readme",
"publishConfig": {
"access": "public"
}
}
72 changes: 72 additions & 0 deletions packages/emnapi/script/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const fs = require('fs')
const path = require('path')

const {
runtimeOut
} = require('../../runtime/script/build.js')

async function build () {
const libTsconfigPath = path.join(__dirname, '../tsconfig.json')
const libTsconfig = JSON.parse(fs.readFileSync(libTsconfigPath, 'utf8'))

const libOut = path.join(path.dirname(libTsconfigPath), libTsconfig.compilerOptions.outFile)

const runtimeCode = fs.readFileSync(runtimeOut, 'utf8')
const libCode = fs.readFileSync(libOut, 'utf8')

fs.writeFileSync(libOut,
libCode
.replace('__EMNAPI_RUNTIME_REPLACE__', `'${runtimeCode.replace(/\\/g, '\\\\').replace(/\r?\n/g, '\\n').replace(/'/g, "\\'")}'`)
.replace('__EMNAPI_RUNTIME_INIT__;', '')
.replace(/(makeDynCall\(.*?\))/g, '{{{ $1 }}}')
/* .replace(/(makeMalloc\(.*?\))/g, '{{{ $1 }}}') */,
'utf8'
)

fs.writeFileSync(path.join(path.dirname(libOut), path.basename(libOut, '.js') + '_no_runtime.js'),
libCode
.replace('__EMNAPI_RUNTIME_REPLACE__', '""')
.replace('__EMNAPI_RUNTIME_INIT__;', `
(function () {
if ('emnapiRuntime' in Module) {
emnapi = Module.emnapiRuntime;
}
if (!emnapi && typeof require === 'function') {
try {
emnapi = require('@tybys/emnapi-runtime')
} catch (_) {}
}
if (!emnapi) {
emnapi = (function () {
let g;
g = (function () { return this })();
try {
g = g || new Function('return this')();
} catch (_) {
if (typeof globalThis !== 'undefined') return globalThis;
if (typeof __webpack_public_path__ === 'undefined') {
if (typeof global !== 'undefined') return global;
}
if (typeof window !== 'undefined') return window;
if (typeof self !== 'undefined') return self;
}
return g;
})().emnapi;
}
})();`)
.replace(/(makeDynCall\(.*?\))/g, '{{{ $1 }}}')
/* .replace(/(makeMalloc\(.*?\))/g, '{{{ $1 }}}') */,
'utf8'
)
}

exports.build = build

if (module === require.main) {
build().catch(err => {
console.error(err)
process.exit(1)
})
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
declare type Pointer<T> = number
// eslint-disable-next-line @typescript-eslint/no-unused-vars
declare type PointerPointer<T> = number
declare type FunctionPointer<T extends (...args: any[]) => any> = Pointer<T>
declare type Const<T> = T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ declare interface ICallbackInfo {
_this: any
_data: void_p
_length: number
_args: any[],
_newTarget: Function | undefined,
_args: any[]
_newTarget: Function | undefined
_isConstructCall: boolean
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions tsconfig.prod.json → packages/emnapi/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "ESNext",
"downlevelIteration": true,
"removeComments": true,
"declaration": false,
"outFile": "./dist/library_napi.js",
"importHelpers": false,
"noEmitHelpers": true,
"types": [],
"lib": [
"ES5",
Expand All @@ -15,7 +14,8 @@
]
},
"include": [
"./lib/typings/napi.d.ts",
"./lib/runtime/**/*.ts"
"../runtime/dist/emnapi.d.ts",
"../runtime/src/napi.d.ts",
"./src/**/*.ts"
]
}
3 changes: 3 additions & 0 deletions packages/runtime/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/lib
node_modules
/dist
9 changes: 9 additions & 0 deletions packages/runtime/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.vscode
node_modules
/script
/lib/**/*.d.ts
/src
.gitignore
.npmignore
api-extractor.json
tsconfig.json
21 changes: 21 additions & 0 deletions packages/runtime/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021-present Toyobayashi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 649c483

Please sign in to comment.