-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(parser) move parser from sails-js to own library (#491)
Co-authored-by: Dmitry Osipov <dmith.osipov@gmail.com>
- Loading branch information
1 parent
15a64cd
commit e88e9ed
Showing
76 changed files
with
1,823 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"endOfLine": "lf", | ||
"printWidth": 120, | ||
"semi": true, | ||
"bracketSpacing": true, | ||
"bracketSameLine": true, | ||
"arrowParens": "always", | ||
"tabWidth": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as fs from 'fs'; | ||
|
||
const main = async () => { | ||
const buf = fs.readFileSync('./parser.wasm'); | ||
|
||
const cs = new CompressionStream('gzip'); | ||
|
||
const compressedReadableStream = new Response(buf).body.pipeThrough(cs); | ||
|
||
const reader = compressedReadableStream.getReader(); | ||
|
||
let resultArr = []; | ||
|
||
while (true) { | ||
const read = await reader.read(); | ||
|
||
if (read.done) break; | ||
|
||
resultArr = resultArr.concat(Array.from(read.value)); | ||
} | ||
|
||
const base64Bytes = Buffer.from(Uint8Array.from(resultArr).buffer).toString('base64'); | ||
|
||
fs.writeFileSync('./lib/wasm-bytes.js', `export default '${base64Bytes}'`); | ||
fs.writeFileSync( | ||
'./lib/cjs/wasm-bytes.js', | ||
`Object.defineProperty(exports, '__esModule', { value: true });\n\nvar wasmParserBytes = '${base64Bytes}';\n\nexports.default = wasmParserBytes;`, | ||
); | ||
}; | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.log(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "idl-parser-js", | ||
"version": "0.1.0", | ||
"description": "IDL parser for TypeScript", | ||
"main": "index.js", | ||
"type": "module", | ||
"license": "GPL-3.0", | ||
"author": "Gear Technologies", | ||
"bugs": { | ||
"url": "https://github.com/gear-tech/sails/issues" | ||
}, | ||
"homepage": "https://github.com/gear-tech/sails/tree/master/js#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://githib.com/gear-tech/sails.git" | ||
}, | ||
"keywords": [ | ||
"gear", | ||
"sails", | ||
"parser" | ||
], | ||
"scripts": { | ||
"build": "rm -rf lib && rollup --config rollup.config.js && node compress-parser.js" | ||
}, | ||
"devDependencies": { | ||
"ts-node": "10.9.2", | ||
"typescript": "5.5.4", | ||
"@rollup/plugin-commonjs": "26.0.1", | ||
"@rollup/plugin-typescript": "11.1.6", | ||
"@types/node": "22.4.1", | ||
"rollup": "4.21.0", | ||
"rollup-plugin-peer-deps-external": "2.2.4", | ||
"rollup-plugin-typescript2": "0.36.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { cpSync, writeFileSync } from 'fs'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import typescript from 'rollup-plugin-typescript2'; | ||
|
||
function writePackageJson(type) { | ||
return { | ||
name: 'write-package-json', | ||
closeBundle() { | ||
if (type === 'cjs') { | ||
writeFileSync('./lib/cjs/package.json', JSON.stringify({ type: 'commonjs' })); | ||
} else { | ||
cpSync('./package.json', 'lib/package.json'); | ||
} | ||
}, | ||
}; | ||
} | ||
|
||
export default [ | ||
{ | ||
input: 'src/index.ts', | ||
output: [ | ||
{ | ||
dir: 'lib', | ||
format: 'es', | ||
preserveModules: true, | ||
strict: false, | ||
}, | ||
], | ||
plugins: [ | ||
typescript({ | ||
tsconfig: 'tsconfig.build.json', | ||
}), | ||
writePackageJson('es'), | ||
], | ||
}, | ||
{ | ||
input: 'src/index.ts', | ||
output: [ | ||
{ | ||
dir: 'lib/cjs', | ||
format: 'cjs', | ||
preserveModules: true, | ||
exports: 'named', | ||
strict: false, | ||
}, | ||
], | ||
plugins: [ | ||
typescript({ | ||
tsconfig: 'tsconfig.cjs.json', | ||
}), | ||
commonjs(), | ||
writePackageJson('cjs'), | ||
], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './parser.js'; | ||
export { Program, Ctor, CtorFunc } from './program.js'; | ||
export { Service, ServiceFunc, ServiceEvent, FuncParam } from './service.js'; | ||
export { TypeDef, EnumDef, EnumVariant } from './types.js'; |
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleResolution": "node", | ||
"declaration": true, | ||
"outDir": "./lib", | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": false, | ||
"noImplicitAny": false, | ||
"skipLibCheck": true | ||
}, | ||
"include": ["src"] | ||
} |
Oops, something went wrong.