mirror of
https://github.com/standardnotes/server
synced 2026-01-21 08:04:27 -05:00
Compare commits
32 Commits
@standardn
...
@standardn
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f4776b52b | ||
|
|
d20f03127a | ||
|
|
4b6c7774e0 | ||
|
|
d02bca8879 | ||
|
|
5e654ccf94 | ||
|
|
7d3e5c22fb | ||
|
|
23eb61ee5f | ||
|
|
2cded4b2d1 | ||
|
|
ba7662fc1e | ||
|
|
832a48ac76 | ||
|
|
2db0c125fe | ||
|
|
20d9624bc6 | ||
|
|
f20ee68f50 | ||
|
|
cbf45ce3eb | ||
|
|
2e7fdd93dd | ||
|
|
8ce38f82b5 | ||
|
|
ec5429eeec | ||
|
|
4b17c4045d | ||
|
|
aaf42e4693 | ||
|
|
0e3cbfc40b | ||
|
|
a95ca05c10 | ||
|
|
56b600dbdc | ||
|
|
80a013d0a3 | ||
|
|
7ef59bb74c | ||
|
|
9cf1a9e25c | ||
|
|
0fce6c0cd4 | ||
|
|
2d444e9aa0 | ||
|
|
7c393b1125 | ||
|
|
78ab4dc94d | ||
|
|
6a5904cfaa | ||
|
|
a6061ec2a9 | ||
|
|
51c777304b |
BIN
.yarn/cache/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7-228ed71b87.zip
vendored
Normal file
BIN
.yarn/cache/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7-228ed71b87.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/@eslint-eslintrc-npm-1.4.1-007f670de2-4e469ed508.zip
vendored
Normal file
BIN
.yarn/cache/@eslint-eslintrc-npm-1.4.1-007f670de2-4e469ed508.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/@grpc-grpc-js-npm-1.8.4-287c8bdac8-6367a2ee38.zip
vendored
Normal file
BIN
.yarn/cache/@grpc-grpc-js-npm-1.8.4-287c8bdac8-6367a2ee38.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/@grpc-proto-loader-npm-0.7.4-43d91344a0-1f5d4211fe.zip
vendored
Normal file
BIN
.yarn/cache/@grpc-proto-loader-npm-0.7.4-43d91344a0-1f5d4211fe.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/@humanwhocodes-config-array-npm-0.11.8-7955bfecc2-010892ba3c.zip
vendored
Normal file
BIN
.yarn/cache/@humanwhocodes-config-array-npm-0.11.8-7955bfecc2-010892ba3c.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/@standardnotes-features-npm-1.58.1-a51ef65e8a-558e4506d8.zip
vendored
Normal file
BIN
.yarn/cache/@standardnotes-features-npm-1.58.1-a51ef65e8a-558e4506d8.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/@types-newrelic-npm-9.4.0-72a77bd5e6-adb12973e8.zip
vendored
Normal file
BIN
.yarn/cache/@types-newrelic-npm-9.4.0-72a77bd5e6-adb12973e8.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/@typescript-eslint-eslint-plugin-npm-5.48.2-4f86b96814-773d1b78d4.zip
vendored
Normal file
BIN
.yarn/cache/@typescript-eslint-eslint-plugin-npm-5.48.2-4f86b96814-773d1b78d4.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/@typescript-eslint-scope-manager-npm-5.48.2-9a72dae708-788edc410b.zip
vendored
Normal file
BIN
.yarn/cache/@typescript-eslint-scope-manager-npm-5.48.2-9a72dae708-788edc410b.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/@typescript-eslint-types-npm-5.48.2-bdebd4d2d7-8842362cca.zip
vendored
Normal file
BIN
.yarn/cache/@typescript-eslint-types-npm-5.48.2-bdebd4d2d7-8842362cca.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/@typescript-eslint-typescript-estree-npm-5.48.2-2166870a0a-6d3da2b252.zip
vendored
Normal file
BIN
.yarn/cache/@typescript-eslint-typescript-estree-npm-5.48.2-2166870a0a-6d3da2b252.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/@typescript-eslint-utils-npm-5.48.2-0126c67a53-f2f51f1bf6.zip
vendored
Normal file
BIN
.yarn/cache/@typescript-eslint-utils-npm-5.48.2-0126c67a53-f2f51f1bf6.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/@typescript-eslint-visitor-keys-npm-5.48.2-b644f53ee6-7a4ea8035b.zip
vendored
Normal file
BIN
.yarn/cache/@typescript-eslint-visitor-keys-npm-5.48.2-b644f53ee6-7a4ea8035b.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/globals-npm-13.19.0-a63c75a2dd-3f3d6606b7.zip
vendored
Normal file
BIN
.yarn/cache/globals-npm-13.19.0-a63c75a2dd-3f3d6606b7.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/long-npm-5.2.1-3a12730171-f81b18ff29.zip
vendored
Normal file
BIN
.yarn/cache/long-npm-5.2.1-3a12730171-f81b18ff29.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/lru-cache-npm-7.14.1-d3ba9407b6-e4c8c073d9.zip
vendored
Normal file
BIN
.yarn/cache/lru-cache-npm-7.14.1-d3ba9407b6-e4c8c073d9.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/mysql2-npm-3.0.1-ceda50bb4d-6bbee1ee05.zip
vendored
Normal file
BIN
.yarn/cache/mysql2-npm-3.0.1-ceda50bb4d-6bbee1ee05.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/named-placeholders-npm-1.1.3-1b385febe5-1cd77eb10c.zip
vendored
Normal file
BIN
.yarn/cache/named-placeholders-npm-1.1.3-1b385febe5-1cd77eb10c.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/natural-compare-lite-npm-1.4.0-12b6b308ed-e554405686.zip
vendored
Normal file
BIN
.yarn/cache/natural-compare-lite-npm-1.4.0-12b6b308ed-e554405686.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/newrelic-npm-9.8.0-4c49b89cbc-ed3b893298.zip
vendored
Normal file
BIN
.yarn/cache/newrelic-npm-9.8.0-4c49b89cbc-ed3b893298.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
BIN
.yarn/cache/protobufjs-npm-7.1.2-2e50888192-d9cfc7c168.zip
vendored
Normal file
BIN
.yarn/cache/protobufjs-npm-7.1.2-2e50888192-d9cfc7c168.zip
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
18
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/LICENSE
generated
vendored
Normal file
18
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
Copyright 2022 Contrast Security, Inc
|
||||
|
||||
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.
|
||||
43
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/README.md
generated
vendored
Normal file
43
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/README.md
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# @contrast/fn-inspect
|
||||
|
||||
[](https://github.com/Contrast-Security-Inc/node-fn-inspect/actions/workflows/test.yml)
|
||||
|
||||
This module exposes some useful information from the underlying v8 engine,
|
||||
including:
|
||||
|
||||
- file and line number given a function reference
|
||||
- code events (i.e. `'LAZY_COMPILE'`)
|
||||
|
||||
## Usage
|
||||
|
||||
Getting details about a function:
|
||||
|
||||
```js
|
||||
const { funcInfo } = require('@contrast/fn-inspect');
|
||||
|
||||
function testFn() {}
|
||||
|
||||
const results = funcInfo(testFn);
|
||||
// => { lineNumber: 2, column: 15, file: 'example.js', method: 'testFn', type: 'Function' }
|
||||
```
|
||||
|
||||
Registering a listener for code events:
|
||||
|
||||
```js
|
||||
const { setCodeEventListener } = require('@contrast/fn-inspect');
|
||||
|
||||
setCodeEventListener((event) => {
|
||||
console.log(event);
|
||||
});
|
||||
```
|
||||
|
||||
## Building locally
|
||||
|
||||
`npm run build` will build the project for your current OS and architecture.
|
||||
|
||||
`npm run download` will pull the most recent build artifacts from GitHub.
|
||||
|
||||
## Publishing
|
||||
|
||||
Simply run `npm version` and `git push && git push --tags`. CI will take care of
|
||||
releasing on taggedcommits.
|
||||
36
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/binding.gyp
generated
vendored
Normal file
36
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/binding.gyp
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"variables" : {
|
||||
"openssl_fips": "",
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"target_name": "fninspect",
|
||||
"sources": [
|
||||
"src/addon.cc",
|
||||
"src/code-events.cc",
|
||||
"src/event-queue.cc",
|
||||
"src/func-info.cc"
|
||||
],
|
||||
"include_dirs": [
|
||||
"<!(node -e \"require('nan')\")"
|
||||
],
|
||||
"conditions": [
|
||||
[
|
||||
"OS == 'mac'",
|
||||
{
|
||||
"xcode_settings": {
|
||||
"OTHER_CFLAGS": [
|
||||
"-arch x86_64",
|
||||
"-arch arm64"
|
||||
],
|
||||
"OTHER_LDFLAGS": [
|
||||
"-arch x86_64",
|
||||
"-arch arm64"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
45
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/index.d.ts
generated
vendored
Normal file
45
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
|
||||
declare interface FunctionInfo {
|
||||
file: string;
|
||||
column: number;
|
||||
lineNumber: number;
|
||||
method: string;
|
||||
type: 'AsyncFunction' | 'Function';
|
||||
}
|
||||
|
||||
declare interface CodeEvent {
|
||||
func: string;
|
||||
lineNumber: number;
|
||||
script: string;
|
||||
type:
|
||||
| 'Builtin'
|
||||
| 'Callback'
|
||||
| 'Eval'
|
||||
| 'Function'
|
||||
| 'InterpretedFunction'
|
||||
| 'Handler'
|
||||
| 'BytecodeHandler'
|
||||
| 'LazyCompile'
|
||||
| 'RegExp'
|
||||
| 'Script'
|
||||
| 'Stub'
|
||||
| 'Relocation'
|
||||
}
|
||||
|
||||
declare const fnInspect: {
|
||||
/** Retrieves name, type, column, lineNumber and file from a function reference */
|
||||
funcInfo(fn: Function): FunctionInfo | null;
|
||||
|
||||
/**
|
||||
* Sets the function for processing v8 code events.
|
||||
* Will start listening for code events if not already listening.
|
||||
* starts a timer which polls for an available code event once every `interval` ms.
|
||||
*/
|
||||
setCodeEventListener(cb: (event: CodeEvent) => void, interval?: number): void;
|
||||
|
||||
/** Stop listening for v8 code events */
|
||||
stopListening(): void;
|
||||
};
|
||||
|
||||
export = fnInspect;
|
||||
58
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/index.js
generated
vendored
Normal file
58
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/index.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
|
||||
const binding = require('node-gyp-build')(__dirname);
|
||||
|
||||
let codeEventsInited = false;
|
||||
let codeEventListener = null;
|
||||
let timer = null;
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Retrieves name, type, column, lineNumber and file from a function reference
|
||||
*
|
||||
* @param {Function} fn function reference to obtain info
|
||||
* @return {FunctionInfo | null}
|
||||
*/
|
||||
funcInfo(fn) {
|
||||
const info = binding.funcInfo(fn);
|
||||
if (info === null) return null;
|
||||
|
||||
info.type = fn.constructor.name;
|
||||
return info;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the function for processing v8 code events.
|
||||
* Will start listening for code events if not already listening.
|
||||
* starts a timer which polls for an available code event once every `interval` value.
|
||||
*
|
||||
* @param {Function} cb callback function to call
|
||||
* @param {number} [interval=1] how often to get code events in ms
|
||||
*/
|
||||
setCodeEventListener(cb, interval = 1) {
|
||||
if (codeEventsInited) {
|
||||
codeEventListener = cb;
|
||||
return;
|
||||
}
|
||||
|
||||
binding.initHandler();
|
||||
codeEventsInited = true;
|
||||
codeEventListener = cb;
|
||||
timer = setInterval(() => {
|
||||
const codeEvent = binding.getNextCodeEvent();
|
||||
if (codeEvent) codeEventListener(codeEvent);
|
||||
}, interval);
|
||||
},
|
||||
|
||||
/**
|
||||
* Stop listening for v8 code events
|
||||
*/
|
||||
stopListening() {
|
||||
if (!codeEventsInited) return;
|
||||
|
||||
clearInterval(timer);
|
||||
binding.deinitHandler();
|
||||
codeEventListener = null;
|
||||
codeEventsInited = false;
|
||||
},
|
||||
};
|
||||
63
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/package.json
generated
vendored
Normal file
63
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/package.json
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "@contrast/fn-inspect",
|
||||
"version": "3.3.0",
|
||||
"description": "Retrieve function name and line number from a function reference",
|
||||
"keywords": [
|
||||
"instrumentation"
|
||||
],
|
||||
"author": "Contrast Security",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Contrast-Security-Inc/node-fn-inspect.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Contrast-Security-Inc/node-fn-inspect/issues"
|
||||
},
|
||||
"homepage": "https://github.com/Contrast-Security-Inc/node-fn-inspect#readme",
|
||||
"files": [
|
||||
"prebuilds/",
|
||||
"src/",
|
||||
"binding.gyp",
|
||||
"index.d.ts",
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"install": "node-gyp-build",
|
||||
"prepare": "husky install",
|
||||
"build": "prebuildify -t 12.13.0 -t 14.15.0 -t 16.9.1 -t 18.7.0 --strip",
|
||||
"build:linux": "prebuildify-cross -i centos7-devtoolset7 -i alpine -i linux-arm64 -t 12.13.0 -t 14.15.0 -t 16.9.1 -t 18.7.0 --strip",
|
||||
"build:darwin": "npm run build -- --arch x64+arm64",
|
||||
"build:win32": "npm run build",
|
||||
"clean": "rimraf build/ coverage/ prebuilds/",
|
||||
"download": "node scripts/download-artifacts.js",
|
||||
"test": "c8 --reporter lcov --reporter text mocha .",
|
||||
"test:valgrind": "valgrind --xml=yes --xml-file=./valgrind.xml --trace-children=yes --leak-check=full --show-leak-kinds=all mocha . && node scripts/parse-valgrind.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.13.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"nan": "^2.16.0",
|
||||
"node-gyp-build": "^4.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@contrast/eslint-config": "^3.1.1",
|
||||
"@ls-lint/ls-lint": "^1.11.2",
|
||||
"@octokit/rest": "^18.12.0",
|
||||
"c8": "^7.11.3",
|
||||
"chai": "^4.3.6",
|
||||
"husky": "^8.0.1",
|
||||
"inquirer": "^8.2.4",
|
||||
"lint-staged": "^13.0.1",
|
||||
"mocha": "^10.0.0",
|
||||
"node-gyp": "^9.0.0",
|
||||
"prebuildify": "^5.0.0",
|
||||
"prebuildify-cross": "^5.0.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"unzipper": "^0.10.11",
|
||||
"xml-js": "^1.6.11"
|
||||
}
|
||||
}
|
||||
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/darwin-x64+arm64/node.abi108.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/darwin-x64+arm64/node.abi108.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/darwin-x64+arm64/node.abi72.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/darwin-x64+arm64/node.abi72.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/darwin-x64+arm64/node.abi83.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/darwin-x64+arm64/node.abi83.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/darwin-x64+arm64/node.abi93.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/darwin-x64+arm64/node.abi93.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-arm64/node.abi108.armv8.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-arm64/node.abi108.armv8.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-arm64/node.abi72.armv8.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-arm64/node.abi72.armv8.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-arm64/node.abi83.armv8.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-arm64/node.abi83.armv8.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-arm64/node.abi93.armv8.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-arm64/node.abi93.armv8.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-x64/node.abi108.glibc.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-x64/node.abi108.glibc.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-x64/node.abi108.musl.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-x64/node.abi108.musl.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-x64/node.abi72.glibc.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-x64/node.abi72.glibc.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-x64/node.abi72.musl.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-x64/node.abi72.musl.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-x64/node.abi83.glibc.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-x64/node.abi83.glibc.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-x64/node.abi83.musl.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-x64/node.abi83.musl.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-x64/node.abi93.glibc.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-x64/node.abi93.glibc.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-x64/node.abi93.musl.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/linux-x64/node.abi93.musl.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/win32-x64/node.abi108.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/win32-x64/node.abi108.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/win32-x64/node.abi72.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/win32-x64/node.abi72.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/win32-x64/node.abi83.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/win32-x64/node.abi83.node
generated
vendored
Normal file
Binary file not shown.
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/win32-x64/node.abi93.node
generated
vendored
Normal file
BIN
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/prebuilds/win32-x64/node.abi93.node
generated
vendored
Normal file
Binary file not shown.
14
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/src/addon.cc
generated
vendored
Normal file
14
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/src/addon.cc
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <nan.h>
|
||||
|
||||
#include "code-events.h"
|
||||
#include "func-info.h"
|
||||
|
||||
NAN_MODULE_INIT(Init) {
|
||||
NAN_EXPORT(target, initHandler);
|
||||
NAN_EXPORT(target, deinitHandler);
|
||||
NAN_EXPORT(target, getNextCodeEvent);
|
||||
|
||||
NAN_EXPORT(target, funcInfo);
|
||||
}
|
||||
|
||||
NODE_MODULE(addon, Init)
|
||||
75
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/src/code-events.cc
generated
vendored
Normal file
75
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/src/code-events.cc
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
#include "code-events.h"
|
||||
#include "event-queue.h"
|
||||
|
||||
using namespace v8;
|
||||
|
||||
class FnInspectCodeEventHandler : public CodeEventHandler {
|
||||
public:
|
||||
FnInspectCodeEventHandler(Isolate *isolate) : CodeEventHandler(isolate) {
|
||||
this->isolate = isolate;
|
||||
}
|
||||
|
||||
void Handle(CodeEvent *event) {
|
||||
/*
|
||||
* If Handle() is invoked from a worker thread (i.e. during
|
||||
* garbage collection) we don't have access to the isolate
|
||||
* so just bail
|
||||
*/
|
||||
if (Isolate::GetCurrent() != isolate) {
|
||||
return;
|
||||
}
|
||||
events.enqueue(event);
|
||||
}
|
||||
|
||||
EventNode *dequeue() {
|
||||
return this->events.dequeue();
|
||||
}
|
||||
|
||||
unsigned int eventCount() {
|
||||
return this->events.length;
|
||||
}
|
||||
|
||||
private:
|
||||
Isolate *isolate;
|
||||
EventQueue events;
|
||||
};
|
||||
|
||||
FnInspectCodeEventHandler *handler;
|
||||
|
||||
NAN_METHOD(initHandler) {
|
||||
handler = new FnInspectCodeEventHandler(info.GetIsolate());
|
||||
handler->Enable();
|
||||
}
|
||||
|
||||
NAN_METHOD(deinitHandler) {
|
||||
handler->Disable();
|
||||
|
||||
delete handler;
|
||||
handler = NULL;
|
||||
}
|
||||
|
||||
NAN_METHOD(getNextCodeEvent) {
|
||||
EventNode *node = handler->dequeue();
|
||||
|
||||
if (!node)
|
||||
return;
|
||||
|
||||
Local<Object> obj = Nan::New<Object>();
|
||||
|
||||
Nan::Set(obj,
|
||||
Nan::New("script").ToLocalChecked(),
|
||||
Nan::New(node->script).ToLocalChecked());
|
||||
Nan::Set(obj,
|
||||
Nan::New("func").ToLocalChecked(),
|
||||
Nan::New(node->func).ToLocalChecked());
|
||||
Nan::Set(obj,
|
||||
Nan::New("type").ToLocalChecked(),
|
||||
Nan::New(node->type).ToLocalChecked());
|
||||
Nan::Set(obj,
|
||||
Nan::New("lineNumber").ToLocalChecked(),
|
||||
Nan::New(node->lineNumber));
|
||||
|
||||
info.GetReturnValue().Set(obj);
|
||||
|
||||
delete node;
|
||||
}
|
||||
11
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/src/code-events.h
generated
vendored
Normal file
11
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/src/code-events.h
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <nan.h>
|
||||
#include <v8-profiler.h>
|
||||
#include <v8.h>
|
||||
|
||||
#include "event-queue.h"
|
||||
|
||||
NAN_METHOD(initHandler);
|
||||
NAN_METHOD(deinitHandler);
|
||||
NAN_METHOD(getNextCodeEvent);
|
||||
61
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/src/event-queue.cc
generated
vendored
Normal file
61
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/src/event-queue.cc
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
#include <v8-profiler.h>
|
||||
#include <v8.h>
|
||||
|
||||
#include "event-queue.h"
|
||||
|
||||
using namespace v8;
|
||||
|
||||
EventQueue::EventQueue() {
|
||||
this->head = NULL;
|
||||
this->tail = NULL;
|
||||
this->length = 0;
|
||||
}
|
||||
|
||||
EventQueue::~EventQueue() {
|
||||
EventNode *tmp;
|
||||
while (this->head) {
|
||||
tmp = this->head;
|
||||
;
|
||||
this->head = this->head->next;
|
||||
delete tmp;
|
||||
}
|
||||
}
|
||||
|
||||
void EventQueue::enqueue(CodeEvent *event) {
|
||||
if (Nan::Utf8String(event->GetScriptName()).length() == 0)
|
||||
return;
|
||||
|
||||
EventNode *node = new EventNode();
|
||||
|
||||
node->type = strdup(CodeEvent::GetCodeEventTypeName(event->GetCodeType()));
|
||||
node->script = strdup(*Nan::Utf8String(event->GetScriptName()));
|
||||
node->func = strdup(*Nan::Utf8String(event->GetFunctionName()));
|
||||
node->lineNumber = event->GetScriptLine();
|
||||
|
||||
if (this->tail) {
|
||||
this->tail->next = node;
|
||||
this->tail = node;
|
||||
} else {
|
||||
this->head = node;
|
||||
this->tail = node;
|
||||
}
|
||||
|
||||
this->length += 1;
|
||||
}
|
||||
|
||||
EventNode *EventQueue::dequeue() {
|
||||
EventNode *node = this->head;
|
||||
|
||||
if (!node)
|
||||
return NULL;
|
||||
|
||||
this->head = this->head->next;
|
||||
|
||||
if (this->head == NULL) {
|
||||
this->tail = NULL;
|
||||
}
|
||||
|
||||
this->length -= 1;
|
||||
|
||||
return node;
|
||||
}
|
||||
46
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/src/event-queue.h
generated
vendored
Normal file
46
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/src/event-queue.h
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <nan.h>
|
||||
#include <v8-profiler.h>
|
||||
#include <v8.h>
|
||||
|
||||
using namespace v8;
|
||||
|
||||
class EventNode {
|
||||
public:
|
||||
char *type;
|
||||
char *script;
|
||||
char *func;
|
||||
int lineNumber;
|
||||
EventNode *next;
|
||||
~EventNode() {
|
||||
free(this->type);
|
||||
free(this->script);
|
||||
free(this->func);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Implements a simple queue of code events that can be
|
||||
* consumed.
|
||||
*
|
||||
* Thread-Safety: There's no locking on these methods so
|
||||
* they aren't thread safe. However this should be OK
|
||||
* as the expectation is these methods are only ever called
|
||||
* from the main JS thread and they are blocking, there will
|
||||
* only ever be a single thread calling it as a time. We
|
||||
* may want to revisit this if we ever want to support
|
||||
* handling events from worker_threads.
|
||||
*/
|
||||
class EventQueue {
|
||||
public:
|
||||
EventQueue();
|
||||
~EventQueue();
|
||||
void enqueue(CodeEvent *event);
|
||||
EventNode *dequeue();
|
||||
unsigned int length;
|
||||
|
||||
private:
|
||||
EventNode *head;
|
||||
EventNode *tail;
|
||||
};
|
||||
28
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/src/func-info.cc
generated
vendored
Normal file
28
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/src/func-info.cc
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "func-info.h"
|
||||
|
||||
using namespace v8;
|
||||
|
||||
NAN_METHOD(funcInfo) {
|
||||
if (info.Length() < 1 || info[0].IsEmpty() || !info[0]->IsFunction()) {
|
||||
info.GetReturnValue().Set(Nan::Null());
|
||||
return;
|
||||
}
|
||||
|
||||
Local<Function> fn = info[0].As<Function>();
|
||||
|
||||
Local<Object> obj = Nan::New<Object>();
|
||||
Local<Value> resourceName = fn->GetScriptOrigin().ResourceName();
|
||||
|
||||
if (!resourceName.IsEmpty()) {
|
||||
Nan::Set(obj, Nan::New("file").ToLocalChecked(), resourceName);
|
||||
Nan::Set(obj,
|
||||
Nan::New("lineNumber").ToLocalChecked(),
|
||||
Nan::New(fn->GetScriptLineNumber()));
|
||||
Nan::Set(obj, Nan::New("method").ToLocalChecked(), fn->GetName());
|
||||
Nan::Set(obj,
|
||||
Nan::New("column").ToLocalChecked(),
|
||||
Nan::New(fn->GetScriptColumnNumber()));
|
||||
}
|
||||
|
||||
info.GetReturnValue().Set(obj);
|
||||
}
|
||||
6
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/src/func-info.h
generated
vendored
Normal file
6
.yarn/unplugged/@contrast-fn-inspect-npm-3.3.0-c6a8faa5b7/node_modules/@contrast/fn-inspect/src/func-info.h
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <nan.h>
|
||||
#include <v8.h>
|
||||
|
||||
NAN_METHOD(funcInfo);
|
||||
1027
.yarn/unplugged/protobufjs-npm-6.11.3-566fb31188/node_modules/protobufjs/CHANGELOG.md
generated
vendored
1027
.yarn/unplugged/protobufjs-npm-6.11.3-566fb31188/node_modules/protobufjs/CHANGELOG.md
generated
vendored
File diff suppressed because it is too large
Load Diff
6
.yarn/unplugged/protobufjs-npm-6.11.3-566fb31188/node_modules/protobufjs/bin/pbjs
generated
vendored
6
.yarn/unplugged/protobufjs-npm-6.11.3-566fb31188/node_modules/protobufjs/bin/pbjs
generated
vendored
@@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
var path = require("path"),
|
||||
cli = require(path.join(__dirname, "..", "cli", "pbjs.js"));
|
||||
var ret = cli.main(process.argv.slice(2));
|
||||
if (typeof ret === 'number')
|
||||
process.exit(ret);
|
||||
6
.yarn/unplugged/protobufjs-npm-6.11.3-566fb31188/node_modules/protobufjs/bin/pbts
generated
vendored
6
.yarn/unplugged/protobufjs-npm-6.11.3-566fb31188/node_modules/protobufjs/bin/pbts
generated
vendored
@@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
var path = require("path"),
|
||||
cli = require(path.join(__dirname, "..", "cli", "pbts.js"));
|
||||
var ret = cli.main(process.argv.slice(2));
|
||||
if (typeof ret === 'number')
|
||||
process.exit(ret);
|
||||
33
.yarn/unplugged/protobufjs-npm-6.11.3-566fb31188/node_modules/protobufjs/cli/LICENSE
generated
vendored
33
.yarn/unplugged/protobufjs-npm-6.11.3-566fb31188/node_modules/protobufjs/cli/LICENSE
generated
vendored
@@ -1,33 +0,0 @@
|
||||
Copyright (c) 2016, Daniel Wirtz All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of its author, nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
---
|
||||
|
||||
Code generated by the command line utilities is owned by the owner
|
||||
of the input file used when generating it. This code is not
|
||||
standalone and requires a support library to be linked with it. This
|
||||
support library is itself covered by the above license.
|
||||
174
.yarn/unplugged/protobufjs-npm-6.11.3-566fb31188/node_modules/protobufjs/cli/README.md
generated
vendored
174
.yarn/unplugged/protobufjs-npm-6.11.3-566fb31188/node_modules/protobufjs/cli/README.md
generated
vendored
@@ -1,174 +0,0 @@
|
||||
protobufjs-cli
|
||||
==============
|
||||
[](https://www.npmjs.com/package/protobufjs-cli)
|
||||
|
||||
Command line interface (CLI) for [protobuf.js](https://github.com/dcodeIO/protobuf.js). Translates between file formats and generates static code as well as TypeScript definitions.
|
||||
|
||||
* [CLI Documentation](https://github.com/dcodeIO/protobuf.js#command-line)
|
||||
|
||||
**Note** that moving the CLI to its own package is a work in progress. At the moment, it's still part of the main package.
|
||||
* [pbjs for JavaScript](#pbjs-for-javascript)
|
||||
* [pbts for TypeScript](#pbts-for-typescript)
|
||||
* [Reflection vs. static code](#reflection-vs-static-code)
|
||||
* [Command line API](#command-line-api)<br />
|
||||
|
||||
### pbjs for JavaScript
|
||||
|
||||
```
|
||||
Translates between file formats and generates static code.
|
||||
|
||||
-t, --target Specifies the target format. Also accepts a path to require a custom target.
|
||||
|
||||
json JSON representation
|
||||
json-module JSON representation as a module
|
||||
proto2 Protocol Buffers, Version 2
|
||||
proto3 Protocol Buffers, Version 3
|
||||
static Static code without reflection (non-functional on its own)
|
||||
static-module Static code without reflection as a module
|
||||
|
||||
-p, --path Adds a directory to the include path.
|
||||
|
||||
-o, --out Saves to a file instead of writing to stdout.
|
||||
|
||||
--sparse Exports only those types referenced from a main file (experimental).
|
||||
|
||||
Module targets only:
|
||||
|
||||
-w, --wrap Specifies the wrapper to use. Also accepts a path to require a custom wrapper.
|
||||
|
||||
default Default wrapper supporting both CommonJS and AMD
|
||||
commonjs CommonJS wrapper
|
||||
amd AMD wrapper
|
||||
es6 ES6 wrapper (implies --es6)
|
||||
closure A closure adding to protobuf.roots where protobuf is a global
|
||||
|
||||
-r, --root Specifies an alternative protobuf.roots name.
|
||||
|
||||
-l, --lint Linter configuration. Defaults to protobuf.js-compatible rules:
|
||||
|
||||
eslint-disable block-scoped-var, no-redeclare, no-control-regex, no-prototype-builtins
|
||||
|
||||
--es6 Enables ES6 syntax (const/let instead of var)
|
||||
|
||||
Proto sources only:
|
||||
|
||||
--keep-case Keeps field casing instead of converting to camel case.
|
||||
|
||||
Static targets only:
|
||||
|
||||
--no-create Does not generate create functions used for reflection compatibility.
|
||||
--no-encode Does not generate encode functions.
|
||||
--no-decode Does not generate decode functions.
|
||||
--no-verify Does not generate verify functions.
|
||||
--no-convert Does not generate convert functions like from/toObject
|
||||
--no-delimited Does not generate delimited encode/decode functions.
|
||||
--no-beautify Does not beautify generated code.
|
||||
--no-comments Does not output any JSDoc comments.
|
||||
--no-service Does not output service classes.
|
||||
|
||||
--force-long Enforces the use of 'Long' for s-/u-/int64 and s-/fixed64 fields.
|
||||
--force-number Enforces the use of 'number' for s-/u-/int64 and s-/fixed64 fields.
|
||||
--force-message Enforces the use of message instances instead of plain objects.
|
||||
|
||||
usage: pbjs [options] file1.proto file2.json ... (or pipe) other | pbjs [options] -
|
||||
```
|
||||
|
||||
For production environments it is recommended to bundle all your .proto files to a single .json file, which minimizes the number of network requests and avoids any parser overhead (hint: works with just the **light** library):
|
||||
|
||||
```
|
||||
$> pbjs -t json file1.proto file2.proto > bundle.json
|
||||
```
|
||||
|
||||
Now, either include this file in your final bundle:
|
||||
|
||||
```js
|
||||
var root = protobuf.Root.fromJSON(require("./bundle.json"));
|
||||
```
|
||||
|
||||
or load it the usual way:
|
||||
|
||||
```js
|
||||
protobuf.load("bundle.json", function(err, root) {
|
||||
...
|
||||
});
|
||||
```
|
||||
|
||||
Generated static code, on the other hand, works with just the **minimal** library. For example
|
||||
|
||||
```
|
||||
$> pbjs -t static-module -w commonjs -o compiled.js file1.proto file2.proto
|
||||
```
|
||||
|
||||
will generate static code for definitions within `file1.proto` and `file2.proto` to a CommonJS module `compiled.js`.
|
||||
|
||||
**ProTip!** Documenting your .proto files with `/** ... */`-blocks or (trailing) `/// ...` lines translates to generated static code.
|
||||
|
||||
|
||||
### pbts for TypeScript
|
||||
|
||||
```
|
||||
Generates TypeScript definitions from annotated JavaScript files.
|
||||
|
||||
-o, --out Saves to a file instead of writing to stdout.
|
||||
|
||||
-g, --global Name of the global object in browser environments, if any.
|
||||
|
||||
--no-comments Does not output any JSDoc comments.
|
||||
|
||||
Internal flags:
|
||||
|
||||
-n, --name Wraps everything in a module of the specified name.
|
||||
|
||||
-m, --main Whether building the main library without any imports.
|
||||
|
||||
usage: pbts [options] file1.js file2.js ... (or) other | pbts [options] -
|
||||
```
|
||||
|
||||
Picking up on the example above, the following not only generates static code to a CommonJS module `compiled.js` but also its respective TypeScript definitions to `compiled.d.ts`:
|
||||
|
||||
```
|
||||
$> pbjs -t static-module -w commonjs -o compiled.js file1.proto file2.proto
|
||||
$> pbts -o compiled.d.ts compiled.js
|
||||
```
|
||||
|
||||
Additionally, TypeScript definitions of static modules are compatible with their reflection-based counterparts (i.e. as exported by JSON modules), as long as the following conditions are met:
|
||||
|
||||
1. Instead of using `new SomeMessage(...)`, always use `SomeMessage.create(...)` because reflection objects do not provide a constructor.
|
||||
2. Types, services and enums must start with an uppercase letter to become available as properties of the reflected types as well (i.e. to be able to use `MyMessage.MyEnum` instead of `root.lookup("MyMessage.MyEnum")`).
|
||||
|
||||
For example, the following generates a JSON module `bundle.js` and a `bundle.d.ts`, but no static code:
|
||||
|
||||
```
|
||||
$> pbjs -t json-module -w commonjs -o bundle.js file1.proto file2.proto
|
||||
$> pbjs -t static-module file1.proto file2.proto | pbts -o bundle.d.ts -
|
||||
```
|
||||
|
||||
### Reflection vs. static code
|
||||
|
||||
While using .proto files directly requires the full library respectively pure reflection/JSON the light library, pretty much all code but the relatively short descriptors is shared.
|
||||
|
||||
Static code, on the other hand, requires just the minimal library, but generates additional source code without any reflection features. This also implies that there is a break-even point where statically generated code becomes larger than descriptor-based code once the amount of code generated exceeds the size of the full respectively light library.
|
||||
|
||||
There is no significant difference performance-wise as the code generated statically is pretty much the same as generated at runtime and both are largely interchangeable as seen in the previous section.
|
||||
|
||||
| Source | Library | Advantages | Tradeoffs
|
||||
|--------|---------|------------|-----------
|
||||
| .proto | full | Easily editable<br />Interoperability with other libraries<br />No compile step | Some parsing and possibly network overhead
|
||||
| JSON | light | Easily editable<br />No parsing overhead<br />Single bundle (no network overhead) | protobuf.js specific<br />Has a compile step
|
||||
| static | minimal | Works where `eval` access is restricted<br />Fully documented<br />Small footprint for small protos | Can be hard to edit<br />No reflection<br />Has a compile step
|
||||
|
||||
### Command line API
|
||||
|
||||
Both utilities can be used programmatically by providing command line arguments and a callback to their respective `main` functions:
|
||||
|
||||
```js
|
||||
var pbjs = require("protobufjs-cli/pbjs"); // or require("protobufjs-cli").pbjs / .pbts
|
||||
|
||||
pbjs.main([ "--target", "json-module", "path/to/myproto.proto" ], function(err, output) {
|
||||
if (err)
|
||||
throw err;
|
||||
// do something with output
|
||||
});
|
||||
```
|
||||
|
||||
**License:** [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause)
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
var path = require("path"),
|
||||
cli = require(path.join(__dirname, "..", "pbjs.js"));
|
||||
var ret = cli.main(process.argv.slice(2));
|
||||
if (typeof ret === 'number')
|
||||
process.exit(ret);
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
var path = require("path"),
|
||||
cli = require(path.join(__dirname, "..", "pbts.js"));
|
||||
var ret = cli.main(process.argv.slice(2));
|
||||
if (typeof ret === 'number')
|
||||
process.exit(ret);
|
||||
@@ -1,3 +0,0 @@
|
||||
import * as pbjs from "./pbjs.js";
|
||||
import * as pbts from "./pbts.js";
|
||||
export { pbjs, pbts };
|
||||
@@ -1,3 +0,0 @@
|
||||
"use strict";
|
||||
exports.pbjs = require("./pbjs");
|
||||
exports.pbts = require("./pbts");
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"tags": {
|
||||
"allowUnknownTags": false
|
||||
},
|
||||
"plugins": [
|
||||
"./tsd-jsdoc/plugin"
|
||||
],
|
||||
"opts": {
|
||||
"encoding" : "utf8",
|
||||
"recurse" : true,
|
||||
"lenient" : true,
|
||||
"template" : "./tsd-jsdoc",
|
||||
|
||||
"private" : false,
|
||||
"comments" : true,
|
||||
"destination" : false
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2016 Chad Engler
|
||||
|
||||
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.
|
||||
@@ -1,23 +0,0 @@
|
||||
protobuf.js fork of tsd-jsdoc
|
||||
=============================
|
||||
|
||||
This is a modified version of [tsd-jsdoc](https://github.com/englercj/tsd-jsdoc) v1.0.1 for use with protobuf.js, parked here so we can process issues and pull requests. The ultimate goal is to switch back to the a recent version of tsd-jsdoc once it meets our needs.
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
* **module: `string`**<br />
|
||||
Wraps everything in a module of the specified name.
|
||||
|
||||
* **private: `boolean`**<br />
|
||||
Includes private members when set to `true`.
|
||||
|
||||
* **comments: `boolean`**<br />
|
||||
Skips comments when explicitly set to `false`.
|
||||
|
||||
* **destination: `string|boolean`**<br />
|
||||
Saves to the specified destination file or to console when set to `false`.
|
||||
|
||||
Setting options on the command line
|
||||
-----------------------------------
|
||||
Providing `-q, --query <queryString>` on the command line will set respectively override existing options. Example: `-q module=protobufjs`
|
||||
@@ -1,21 +0,0 @@
|
||||
"use strict";
|
||||
exports.defineTags = function(dictionary) {
|
||||
|
||||
dictionary.defineTag("template", {
|
||||
mustHaveValue: true,
|
||||
canHaveType: false,
|
||||
canHaveName: false,
|
||||
onTagged: function(doclet, tag) {
|
||||
(doclet.templates || (doclet.templates = [])).push(tag.text);
|
||||
}
|
||||
});
|
||||
|
||||
dictionary.defineTag("tstype", {
|
||||
mustHaveValue: true,
|
||||
canHaveType: false,
|
||||
canHaveName: false,
|
||||
onTagged: function(doclet, tag) {
|
||||
doclet.tsType = tag.text;
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -1,705 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var fs = require("fs");
|
||||
|
||||
// output stream
|
||||
var out = null;
|
||||
|
||||
// documentation data
|
||||
var data = null;
|
||||
|
||||
// already handled objects, by name
|
||||
var seen = {};
|
||||
|
||||
// indentation level
|
||||
var indent = 0;
|
||||
|
||||
// whether indent has been written for the current line yet
|
||||
var indentWritten = false;
|
||||
|
||||
// provided options
|
||||
var options = {};
|
||||
|
||||
// queued interfaces
|
||||
var queuedInterfaces = [];
|
||||
|
||||
// whether writing the first line
|
||||
var firstLine = true;
|
||||
|
||||
// JSDoc hook
|
||||
exports.publish = function publish(taffy, opts) {
|
||||
options = opts || {};
|
||||
|
||||
// query overrides options
|
||||
if (options.query)
|
||||
Object.keys(options.query).forEach(function(key) {
|
||||
if (key !== "query")
|
||||
switch (options[key] = options.query[key]) {
|
||||
case "true":
|
||||
options[key] = true;
|
||||
break;
|
||||
case "false":
|
||||
options[key] = false;
|
||||
break;
|
||||
case "null":
|
||||
options[key] = null;
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// remove undocumented
|
||||
taffy({ undocumented: true }).remove();
|
||||
taffy({ ignore: true }).remove();
|
||||
taffy({ inherited: true }).remove();
|
||||
|
||||
// remove private
|
||||
if (!options.private)
|
||||
taffy({ access: "private" }).remove();
|
||||
|
||||
// setup output
|
||||
out = options.destination
|
||||
? fs.createWriteStream(options.destination)
|
||||
: process.stdout;
|
||||
|
||||
try {
|
||||
// setup environment
|
||||
data = taffy().get();
|
||||
indent = 0;
|
||||
indentWritten = false;
|
||||
firstLine = true;
|
||||
|
||||
// wrap everything in a module if configured
|
||||
if (options.module) {
|
||||
writeln("export = ", options.module, ";");
|
||||
writeln();
|
||||
writeln("declare namespace ", options.module, " {");
|
||||
writeln();
|
||||
++indent;
|
||||
}
|
||||
|
||||
// handle all
|
||||
getChildrenOf(undefined).forEach(function(child) {
|
||||
handleElement(child, null);
|
||||
});
|
||||
|
||||
// process queued
|
||||
while (queuedInterfaces.length) {
|
||||
var element = queuedInterfaces.shift();
|
||||
begin(element);
|
||||
writeInterface(element);
|
||||
writeln(";");
|
||||
}
|
||||
|
||||
// end wrap
|
||||
if (options.module) {
|
||||
--indent;
|
||||
writeln("}");
|
||||
}
|
||||
|
||||
// close file output
|
||||
if (out !== process.stdout)
|
||||
out.end();
|
||||
|
||||
} finally {
|
||||
// gc environment objects
|
||||
out = data = null;
|
||||
seen = options = {};
|
||||
queuedInterfaces = [];
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Utility
|
||||
//
|
||||
|
||||
// writes one or multiple strings
|
||||
function write() {
|
||||
var s = Array.prototype.slice.call(arguments).join("");
|
||||
if (!indentWritten) {
|
||||
for (var i = 0; i < indent; ++i)
|
||||
s = " " + s;
|
||||
indentWritten = true;
|
||||
}
|
||||
out.write(s);
|
||||
firstLine = false;
|
||||
}
|
||||
|
||||
// writes zero or multiple strings, followed by a new line
|
||||
function writeln() {
|
||||
var s = Array.prototype.slice.call(arguments).join("");
|
||||
if (s.length)
|
||||
write(s, "\n");
|
||||
else if (!firstLine)
|
||||
out.write("\n");
|
||||
indentWritten = false;
|
||||
}
|
||||
|
||||
var keepTags = [
|
||||
"param",
|
||||
"returns",
|
||||
"throws",
|
||||
"see"
|
||||
];
|
||||
|
||||
// parses a comment into text and tags
|
||||
function parseComment(comment) {
|
||||
var lines = comment.replace(/^ *\/\*\* *|^ *\*\/| *\*\/ *$|^ *\* */mg, "").trim().split(/\r?\n|\r/g); // property.description has just "\r" ?!
|
||||
var desc;
|
||||
var text = [];
|
||||
var tags = null;
|
||||
for (var i = 0; i < lines.length; ++i) {
|
||||
var match = /^@(\w+)\b/.exec(lines[i]);
|
||||
if (match) {
|
||||
if (!tags) {
|
||||
tags = [];
|
||||
desc = text;
|
||||
}
|
||||
text = [];
|
||||
tags.push({ name: match[1], text: text });
|
||||
lines[i] = lines[i].substring(match[1].length + 1).trim();
|
||||
}
|
||||
if (lines[i].length || text.length)
|
||||
text.push(lines[i]);
|
||||
}
|
||||
return {
|
||||
text: desc || text,
|
||||
tags: tags || []
|
||||
};
|
||||
}
|
||||
|
||||
// writes a comment
|
||||
function writeComment(comment, otherwiseNewline) {
|
||||
if (!comment || options.comments === false) {
|
||||
if (otherwiseNewline)
|
||||
writeln();
|
||||
return;
|
||||
}
|
||||
if (typeof comment !== "object")
|
||||
comment = parseComment(comment);
|
||||
comment.tags = comment.tags.filter(function(tag) {
|
||||
return keepTags.indexOf(tag.name) > -1 && (tag.name !== "returns" || tag.text[0] !== "{undefined}");
|
||||
});
|
||||
writeln();
|
||||
if (!comment.tags.length && comment.text.length < 2) {
|
||||
writeln("/** " + comment.text[0] + " */");
|
||||
return;
|
||||
}
|
||||
writeln("/**");
|
||||
comment.text.forEach(function(line) {
|
||||
if (line.length)
|
||||
writeln(" * ", line);
|
||||
else
|
||||
writeln(" *");
|
||||
});
|
||||
comment.tags.forEach(function(tag) {
|
||||
var started = false;
|
||||
if (tag.text.length) {
|
||||
tag.text.forEach(function(line, i) {
|
||||
if (i > 0)
|
||||
write(" * ");
|
||||
else if (tag.name !== "throws")
|
||||
line = line.replace(/^\{[^\s]*} ?/, "");
|
||||
if (!line.length)
|
||||
return;
|
||||
if (!started) {
|
||||
write(" * @", tag.name, " ");
|
||||
started = true;
|
||||
}
|
||||
writeln(line);
|
||||
});
|
||||
}
|
||||
});
|
||||
writeln(" */");
|
||||
}
|
||||
|
||||
// recursively replaces all occurencies of re's match
|
||||
function replaceRecursive(name, re, fn) {
|
||||
var found;
|
||||
|
||||
function replacer() {
|
||||
found = true;
|
||||
return fn.apply(null, arguments);
|
||||
}
|
||||
|
||||
do {
|
||||
found = false;
|
||||
name = name.replace(re, replacer);
|
||||
} while (found);
|
||||
return name;
|
||||
}
|
||||
|
||||
// tests if an element is considered to be a class or class-like
|
||||
function isClassLike(element) {
|
||||
return isClass(element) || isInterface(element);
|
||||
}
|
||||
|
||||
// tests if an element is considered to be a class
|
||||
function isClass(element) {
|
||||
return element && element.kind === "class";
|
||||
}
|
||||
|
||||
// tests if an element is considered to be an interface
|
||||
function isInterface(element) {
|
||||
return element && (element.kind === "interface" || element.kind === "mixin");
|
||||
}
|
||||
|
||||
// tests if an element is considered to be a namespace
|
||||
function isNamespace(element) {
|
||||
return element && (element.kind === "namespace" || element.kind === "module");
|
||||
}
|
||||
|
||||
// gets all children of the specified parent
|
||||
function getChildrenOf(parent) {
|
||||
var memberof = parent ? parent.longname : undefined;
|
||||
return data.filter(function(element) {
|
||||
return element.memberof === memberof;
|
||||
});
|
||||
}
|
||||
|
||||
// gets the literal type of an element
|
||||
function getTypeOf(element) {
|
||||
if (element.tsType)
|
||||
return element.tsType.replace(/\r?\n|\r/g, "\n");
|
||||
var name = "any";
|
||||
var type = element.type;
|
||||
if (type && type.names && type.names.length) {
|
||||
if (type.names.length === 1)
|
||||
name = element.type.names[0].trim();
|
||||
else
|
||||
name = "(" + element.type.names.join("|") + ")";
|
||||
} else
|
||||
return name;
|
||||
|
||||
// Replace catchalls with any
|
||||
name = name.replace(/\*|\bmixed\b/g, "any");
|
||||
|
||||
// Ensure upper case Object for map expressions below
|
||||
name = name.replace(/\bobject\b/g, "Object");
|
||||
|
||||
// Correct Something.<Something> to Something<Something>
|
||||
name = replaceRecursive(name, /\b(?!Object|Array)([\w$]+)\.<([^>]*)>/gi, function($0, $1, $2) {
|
||||
return $1 + "<" + $2 + ">";
|
||||
});
|
||||
|
||||
// Replace Array.<string> with string[]
|
||||
name = replaceRecursive(name, /\bArray\.?<([^>]*)>/gi, function($0, $1) {
|
||||
return $1 + "[]";
|
||||
});
|
||||
|
||||
// Replace Object.<string,number> with { [k: string]: number }
|
||||
name = replaceRecursive(name, /\bObject\.?<([^,]*), *([^>]*)>/gi, function($0, $1, $2) {
|
||||
return "{ [k: " + $1 + "]: " + $2 + " }";
|
||||
});
|
||||
|
||||
// Replace functions (there are no signatures) with Function
|
||||
name = name.replace(/\bfunction(?:\(\))?\b/g, "Function");
|
||||
|
||||
// Convert plain Object back to just object
|
||||
name = name.replace(/\b(Object\b(?!\.))/g, function($0, $1) {
|
||||
return $1.toLowerCase();
|
||||
});
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
// begins writing the definition of the specified element
|
||||
function begin(element, is_interface) {
|
||||
if (!seen[element.longname]) {
|
||||
if (isClass(element)) {
|
||||
var comment = parseComment(element.comment);
|
||||
var classdesc = comment.tags.find(function(tag) { return tag.name === "classdesc"; });
|
||||
if (classdesc) {
|
||||
comment.text = classdesc.text;
|
||||
comment.tags = [];
|
||||
}
|
||||
writeComment(comment, true);
|
||||
} else
|
||||
writeComment(element.comment, is_interface || isClassLike(element) || isNamespace(element) || element.isEnum || element.scope === "global");
|
||||
seen[element.longname] = element;
|
||||
} else
|
||||
writeln();
|
||||
// ????: something changed in JSDoc 3.6.0? so that @exports + @enum does
|
||||
// no longer yield a 'global' scope, but is some sort of unscoped module
|
||||
// element now. The additional condition added below works around this.
|
||||
if ((element.scope === "global" || element.isEnum && element.scope === undefined) && !options.module)
|
||||
write("export ");
|
||||
}
|
||||
|
||||
// writes the function signature describing element
|
||||
function writeFunctionSignature(element, isConstructor, isTypeDef) {
|
||||
write("(");
|
||||
|
||||
var params = {};
|
||||
|
||||
// this type
|
||||
if (element.this)
|
||||
params["this"] = {
|
||||
type: element.this.replace(/^{|}$/g, ""),
|
||||
optional: false
|
||||
};
|
||||
|
||||
// parameter types
|
||||
if (element.params)
|
||||
element.params.forEach(function(param) {
|
||||
var path = param.name.split(/\./g);
|
||||
if (path.length === 1)
|
||||
params[param.name] = {
|
||||
type: getTypeOf(param),
|
||||
variable: param.variable === true,
|
||||
optional: param.optional === true,
|
||||
defaultValue: param.defaultvalue // Not used yet (TODO)
|
||||
};
|
||||
else // Property syntax (TODO)
|
||||
params[path[0]].type = "{ [k: string]: any }";
|
||||
});
|
||||
|
||||
var paramNames = Object.keys(params);
|
||||
paramNames.forEach(function(name, i) {
|
||||
var param = params[name];
|
||||
var type = param.type;
|
||||
if (param.variable) {
|
||||
name = "..." + name;
|
||||
type = param.type.charAt(0) === "(" ? "any[]" : param.type + "[]";
|
||||
}
|
||||
write(name, !param.variable && param.optional ? "?: " : ": ", type);
|
||||
if (i < paramNames.length - 1)
|
||||
write(", ");
|
||||
});
|
||||
|
||||
write(")");
|
||||
|
||||
// return type
|
||||
if (!isConstructor) {
|
||||
write(isTypeDef ? " => " : ": ");
|
||||
var typeName;
|
||||
if (element.returns && element.returns.length && (typeName = getTypeOf(element.returns[0])) !== "undefined")
|
||||
write(typeName);
|
||||
else
|
||||
write("void");
|
||||
}
|
||||
}
|
||||
|
||||
// writes (a typedef as) an interface
|
||||
function writeInterface(element) {
|
||||
write("interface ", element.name);
|
||||
writeInterfaceBody(element);
|
||||
writeln();
|
||||
}
|
||||
|
||||
function writeInterfaceBody(element) {
|
||||
writeln("{");
|
||||
++indent;
|
||||
if (element.tsType)
|
||||
writeln(element.tsType.replace(/\r?\n|\r/g, "\n"));
|
||||
else if (element.properties && element.properties.length)
|
||||
element.properties.forEach(writeProperty);
|
||||
--indent;
|
||||
write("}");
|
||||
}
|
||||
|
||||
function writeProperty(property, declare) {
|
||||
writeComment(property.description);
|
||||
if (declare)
|
||||
write("let ");
|
||||
write(property.name);
|
||||
if (property.optional)
|
||||
write("?");
|
||||
writeln(": ", getTypeOf(property), ";");
|
||||
}
|
||||
|
||||
//
|
||||
// Handlers
|
||||
//
|
||||
|
||||
// handles a single element of any understood type
|
||||
function handleElement(element, parent) {
|
||||
if (element.scope === "inner")
|
||||
return false;
|
||||
|
||||
if (element.optional !== true && element.type && element.type.names && element.type.names.length) {
|
||||
for (var i = 0; i < element.type.names.length; i++) {
|
||||
if (element.type.names[i].toLowerCase() === "undefined") {
|
||||
// This element is actually optional. Set optional to true and
|
||||
// remove the 'undefined' type
|
||||
element.optional = true;
|
||||
element.type.names.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (seen[element.longname])
|
||||
return true;
|
||||
if (isClassLike(element))
|
||||
handleClass(element, parent);
|
||||
else switch (element.kind) {
|
||||
case "module":
|
||||
if (element.isEnum) {
|
||||
handleEnum(element, parent);
|
||||
break;
|
||||
}
|
||||
// eslint-disable-line no-fallthrough
|
||||
case "namespace":
|
||||
handleNamespace(element, parent);
|
||||
break;
|
||||
case "constant":
|
||||
case "member":
|
||||
handleMember(element, parent);
|
||||
break;
|
||||
case "function":
|
||||
handleFunction(element, parent);
|
||||
break;
|
||||
case "typedef":
|
||||
handleTypeDef(element, parent);
|
||||
break;
|
||||
case "package":
|
||||
break;
|
||||
}
|
||||
seen[element.longname] = element;
|
||||
return true;
|
||||
}
|
||||
|
||||
// handles (just) a namespace
|
||||
function handleNamespace(element/*, parent*/) {
|
||||
var children = getChildrenOf(element);
|
||||
if (!children.length)
|
||||
return;
|
||||
var first = true;
|
||||
if (element.properties)
|
||||
element.properties.forEach(function(property) {
|
||||
if (!/^[$\w]+$/.test(property.name)) // incompatible in namespace
|
||||
return;
|
||||
if (first) {
|
||||
begin(element);
|
||||
writeln("namespace ", element.name, " {");
|
||||
++indent;
|
||||
first = false;
|
||||
}
|
||||
writeProperty(property, true);
|
||||
});
|
||||
children.forEach(function(child) {
|
||||
if (child.scope === "inner" || seen[child.longname])
|
||||
return;
|
||||
if (first) {
|
||||
begin(element);
|
||||
writeln("namespace ", element.name, " {");
|
||||
++indent;
|
||||
first = false;
|
||||
}
|
||||
handleElement(child, element);
|
||||
});
|
||||
if (!first) {
|
||||
--indent;
|
||||
writeln("}");
|
||||
}
|
||||
}
|
||||
|
||||
// a filter function to remove any module references
|
||||
function notAModuleReference(ref) {
|
||||
return ref.indexOf("module:") === -1;
|
||||
}
|
||||
|
||||
// handles a class or class-like
|
||||
function handleClass(element, parent) {
|
||||
var is_interface = isInterface(element);
|
||||
begin(element, is_interface);
|
||||
if (is_interface)
|
||||
write("interface ");
|
||||
else {
|
||||
if (element.virtual)
|
||||
write("abstract ");
|
||||
write("class ");
|
||||
}
|
||||
write(element.name);
|
||||
if (element.templates && element.templates.length)
|
||||
write("<", element.templates.join(", "), ">");
|
||||
write(" ");
|
||||
|
||||
// extended classes
|
||||
if (element.augments) {
|
||||
var augments = element.augments.filter(notAModuleReference);
|
||||
if (augments.length)
|
||||
write("extends ", augments[0], " ");
|
||||
}
|
||||
|
||||
// implemented interfaces
|
||||
var impls = [];
|
||||
if (element.implements)
|
||||
Array.prototype.push.apply(impls, element.implements);
|
||||
if (element.mixes)
|
||||
Array.prototype.push.apply(impls, element.mixes);
|
||||
impls = impls.filter(notAModuleReference);
|
||||
if (impls.length)
|
||||
write("implements ", impls.join(", "), " ");
|
||||
|
||||
writeln("{");
|
||||
++indent;
|
||||
|
||||
if (element.tsType)
|
||||
writeln(element.tsType.replace(/\r?\n|\r/g, "\n"));
|
||||
|
||||
// constructor
|
||||
if (!is_interface && !element.virtual)
|
||||
handleFunction(element, parent, true);
|
||||
|
||||
// properties
|
||||
if (is_interface && element.properties)
|
||||
element.properties.forEach(function(property) {
|
||||
writeProperty(property);
|
||||
});
|
||||
|
||||
// class-compatible members
|
||||
var incompatible = [];
|
||||
getChildrenOf(element).forEach(function(child) {
|
||||
if (isClassLike(child) || child.kind === "module" || child.kind === "typedef" || child.isEnum) {
|
||||
incompatible.push(child);
|
||||
return;
|
||||
}
|
||||
handleElement(child, element);
|
||||
});
|
||||
|
||||
--indent;
|
||||
writeln("}");
|
||||
|
||||
// class-incompatible members
|
||||
if (incompatible.length) {
|
||||
writeln();
|
||||
if (element.scope === "global" && !options.module)
|
||||
write("export ");
|
||||
writeln("namespace ", element.name, " {");
|
||||
++indent;
|
||||
incompatible.forEach(function(child) {
|
||||
handleElement(child, element);
|
||||
});
|
||||
--indent;
|
||||
writeln("}");
|
||||
}
|
||||
}
|
||||
|
||||
// handles an enum
|
||||
function handleEnum(element) {
|
||||
begin(element);
|
||||
|
||||
var stringEnum = false;
|
||||
element.properties.forEach(function(property) {
|
||||
if (isNaN(property.defaultvalue)) {
|
||||
stringEnum = true;
|
||||
}
|
||||
});
|
||||
if (stringEnum) {
|
||||
writeln("type ", element.name, " =");
|
||||
++indent;
|
||||
element.properties.forEach(function(property, i) {
|
||||
write(i === 0 ? "" : "| ", JSON.stringify(property.defaultvalue));
|
||||
});
|
||||
--indent;
|
||||
writeln(";");
|
||||
} else {
|
||||
writeln("enum ", element.name, " {");
|
||||
++indent;
|
||||
element.properties.forEach(function(property, i) {
|
||||
write(property.name);
|
||||
if (property.defaultvalue !== undefined)
|
||||
write(" = ", JSON.stringify(property.defaultvalue));
|
||||
if (i < element.properties.length - 1)
|
||||
writeln(",");
|
||||
else
|
||||
writeln();
|
||||
});
|
||||
--indent;
|
||||
writeln("}");
|
||||
}
|
||||
}
|
||||
|
||||
// handles a namespace or class member
|
||||
function handleMember(element, parent) {
|
||||
if (element.isEnum) {
|
||||
handleEnum(element);
|
||||
return;
|
||||
}
|
||||
begin(element);
|
||||
|
||||
var inClass = isClassLike(parent);
|
||||
if (inClass) {
|
||||
write(element.access || "public", " ");
|
||||
if (element.scope === "static")
|
||||
write("static ");
|
||||
if (element.readonly)
|
||||
write("readonly ");
|
||||
} else
|
||||
write(element.kind === "constant" ? "const " : "let ");
|
||||
|
||||
write(element.name);
|
||||
if (element.optional)
|
||||
write("?");
|
||||
write(": ");
|
||||
|
||||
if (element.type && element.type.names && /^Object\b/i.test(element.type.names[0]) && element.properties) {
|
||||
writeln("{");
|
||||
++indent;
|
||||
element.properties.forEach(function(property, i) {
|
||||
writeln(JSON.stringify(property.name), ": ", getTypeOf(property), i < element.properties.length - 1 ? "," : "");
|
||||
});
|
||||
--indent;
|
||||
writeln("};");
|
||||
} else
|
||||
writeln(getTypeOf(element), ";");
|
||||
}
|
||||
|
||||
// handles a function or method
|
||||
function handleFunction(element, parent, isConstructor) {
|
||||
var insideClass = true;
|
||||
if (isConstructor) {
|
||||
writeComment(element.comment);
|
||||
write("constructor");
|
||||
} else {
|
||||
begin(element);
|
||||
insideClass = isClassLike(parent);
|
||||
if (insideClass) {
|
||||
write(element.access || "public", " ");
|
||||
if (element.scope === "static")
|
||||
write("static ");
|
||||
} else
|
||||
write("function ");
|
||||
write(element.name);
|
||||
if (element.templates && element.templates.length)
|
||||
write("<", element.templates.join(", "), ">");
|
||||
}
|
||||
writeFunctionSignature(element, isConstructor, false);
|
||||
writeln(";");
|
||||
if (!insideClass)
|
||||
handleNamespace(element);
|
||||
}
|
||||
|
||||
// handles a type definition (not a real type)
|
||||
function handleTypeDef(element, parent) {
|
||||
if (isInterface(element)) {
|
||||
if (isClassLike(parent))
|
||||
queuedInterfaces.push(element);
|
||||
else {
|
||||
begin(element);
|
||||
writeInterface(element);
|
||||
}
|
||||
} else {
|
||||
writeComment(element.comment, true);
|
||||
write("type ", element.name);
|
||||
if (element.templates && element.templates.length)
|
||||
write("<", element.templates.join(", "), ">");
|
||||
write(" = ");
|
||||
if (element.tsType)
|
||||
write(element.tsType.replace(/\r?\n|\r/g, "\n"));
|
||||
else {
|
||||
var type = getTypeOf(element);
|
||||
if (element.type && element.type.names.length === 1 && element.type.names[0] === "function")
|
||||
writeFunctionSignature(element, false, true);
|
||||
else if (type === "object") {
|
||||
if (element.properties && element.properties.length)
|
||||
writeInterfaceBody(element);
|
||||
else
|
||||
write("{}");
|
||||
} else
|
||||
write(type);
|
||||
}
|
||||
writeln(";");
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"version": "6.9.0",
|
||||
"dependencies": {
|
||||
"escodegen": "^2.0.0",
|
||||
"espree": "^7.1.0",
|
||||
"tmp": "^0.2.1"
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"name": "protobufjs-cli",
|
||||
"description": "Translates between file formats and generates static code as well as TypeScript definitions.",
|
||||
"version": "6.9.0",
|
||||
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dcodeIO/protobuf.js.git"
|
||||
},
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"bin": {
|
||||
"pbjs": "bin/pbjs",
|
||||
"pbts": "bin/pbts"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"protobufjs": "~6.9.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^3.0.0",
|
||||
"escodegen": "^1.13.0",
|
||||
"espree": "^6.1.2",
|
||||
"estraverse": "^4.3.0",
|
||||
"glob": "^7.1.6",
|
||||
"jsdoc": "^3.6.3",
|
||||
"minimist": "^1.2.0",
|
||||
"semver": "^7.1.2",
|
||||
"tmp": "^0.1.0",
|
||||
"uglify-js": "^3.7.7"
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user