未验证 提交 539068c6 编写于 作者: P Peter Pan 提交者: GitHub

build: remove protobufjs dependency (#703)

上级 8ca250da
......@@ -33,11 +33,11 @@
"dependencies": {
"d3": "5.16.0",
"dagre": "0.8.5",
"flatbuffers": "1.12.0",
"long": "4.0.0",
"marked": "1.1.0",
"netron": "PeterPanZH/netron",
"pako": "1.0.11",
"protobufjs": "lutzroeder/protobuf.js#b9a9d027589356226f4704f9d77f2639f52172f3"
"pako": "1.0.11"
},
"devDependencies": {
"autoprefixer": "9.8.4",
......
......@@ -115,7 +115,7 @@ host.BrowserHost = class {
}
return new Promise((resolve, reject) => {
window.module = {exports: {}};
let script = document.createElement('script');
const script = document.createElement('script');
script.setAttribute('id', id);
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', url);
......@@ -138,7 +138,7 @@ host.BrowserHost = class {
}
export(file, blob) {
let element = this.document.createElement('a');
const element = this.document.createElement('a');
element.download = file;
element.href = URL.createObjectURL(blob);
this.document.body.appendChild(element);
......@@ -446,7 +446,7 @@ class BrowserFileContext {
return Promise.reject(new Error("File not found '" + file + "'."));
}
return new Promise((resolve, reject) => {
let reader = new FileReader();
const reader = new FileReader();
reader.onload = e => {
resolve(encoding ? e.target.result : new Uint8Array(e.target.result));
};
......
......@@ -3,6 +3,5 @@ window.flatbuffers = require('flatbuffers').flatbuffers;
window.long = {
Long: require('long')
};
window.protobuf = require('protobufjs');
window.prototxt = require('protobufjs/ext/prototxt');
window.protobuf = require('netron/src/protobuf');
window.zip = require('netron/src/zip');
const zip = require('netron/src/zip');
const gzip = require('netron/src/gzip');
const tar = require('netron/src/tar');
const protobuf = require('protobufjs');
const prototxt = require('protobufjs/ext/prototxt');
const protobuf = require('netron/src/protobuf');
const d3 = require('d3');
const dagre = require('dagre');
......@@ -25,6 +24,7 @@ view.View = class {
this._showAttributes = false;
this._showInitializers = true;
this._showNames = false;
this._showHorizontal = false;
this._modelFactoryService = new view.ModelFactoryService(this._host);
})
.catch(err => {
......@@ -93,6 +93,18 @@ view.View = class {
return this._showNames;
}
toggleDirection(toggle) {
if (toggle != null && !(toggle ^ this._showHorizontal)) {
return;
}
this._showHorizontal = toggle == null ? !this._showHorizontal : toggle;
this._reload();
}
get showHorizontal() {
return this._showHorizontal;
}
_reload() {
this._host.status('loading');
if (this._model && this._activeGraph) {
......@@ -254,6 +266,9 @@ view.View = class {
const graphOptions = {};
graphOptions.nodesep = 25;
graphOptions.ranksep = 20;
if (this._showHorizontal) {
graphOptions.rankdir = 'LR';
}
const g = new dagre.graphlib.Graph({compound: groups});
g.setGraph(graphOptions);
......@@ -637,17 +652,13 @@ view.View = class {
ys.push(inputTransform.f);
}
let x = xs[0];
let y = ys[0];
const y = ys[0];
if (ys.every(y => y == ys[0])) {
x =
xs.reduce((a, b) => {
return a + b;
}) / xs.length;
x = xs.reduce((a, b) => a + b) / xs.length;
}
this._zoom.transform(
svg,
d3.zoomIdentity.translate(svgSize.width / 2 - x, svgSize.height / 4 - y)
);
const sx = svgSize.width / (this._showHorizontal ? 4 : 2) - x;
const sy = svgSize.height / (this._showHorizontal ? 2 : 4) - y;
this._zoom.transform(svg, d3.zoomIdentity.translate(sx, sy));
} else {
this._zoom.transform(
svg,
......@@ -799,7 +810,7 @@ view.View = class {
// ['quint8', 'u1'],
// ['quint16', 'u2']
// ]);
// let array = new numpy.Array();
// const array = new numpy.Array();
// array.shape = tensor.type.shape.dimensions;
// array.data = tensor.value;
// array.dataType = dataTypeMap.has(tensor.type.dataType)
......@@ -922,7 +933,7 @@ class ModelContext {
) {
break;
}
const reader = prototxt.TextReader.create(this.text);
const reader = protobuf.TextReader.create(this.text);
reader.start(false);
while (!reader.end(false)) {
const tag = reader.tag();
......@@ -932,10 +943,16 @@ class ModelContext {
break;
}
case 'pb': {
const reader = new protobuf.Reader.create(this.buffer);
while (reader.pos < reader.len) {
const tagTypes = new Set([0, 1, 2, 3, 5]);
const reader = protobuf.Reader.create(this.buffer);
const end = reader.next();
while (reader.pos < end) {
const tagType = reader.uint32();
tags.set(tagType >>> 3, tagType & 7);
if (!tagTypes.has(tagType & 7)) {
tags = new Map();
break;
}
try {
reader.skipType(tagType & 7);
} catch (err) {
......@@ -1198,7 +1215,7 @@ view.ModelFactoryService = class {
}
try {
let folders = {};
const folders = {};
for (const entry of archive.entries) {
if (entry.name.indexOf('/') != -1) {
folders[entry.name.split('/').shift() + '/'] = true;
......@@ -1212,7 +1229,7 @@ view.ModelFactoryService = class {
let rootFolder = Object.keys(folders).length == 1 ? Object.keys(folders)[0] : '';
rootFolder = rootFolder == '/' ? '' : rootFolder;
let matches = [];
let entries = archive.entries.slice();
const entries = archive.entries.slice();
const nextEntry = () => {
if (entries.length > 0) {
const entry = entries.shift();
......
......@@ -2726,59 +2726,6 @@
resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.4.2.tgz#7c6dc4ecef16149fd7a736710baa1b811017fdca"
integrity sha512-JlGTGRYHC2QK+DDbePyXdBdooxFq2+noLfWpRqJtkxcb/oYWzOF0kcbfvvbWrwevCC1l6hLUg1wHYT+ona5BWQ==
"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf"
integrity sha1-m4sMxmPWaafY9vXQiToU00jzD78=
"@protobufjs/base64@^1.1.2":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735"
integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==
"@protobufjs/codegen@^2.0.4":
version "2.0.4"
resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb"
integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==
"@protobufjs/eventemitter@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70"
integrity sha1-NVy8mLr61ZePntCV85diHx0Ga3A=
"@protobufjs/fetch@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45"
integrity sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=
dependencies:
"@protobufjs/aspromise" "^1.1.1"
"@protobufjs/inquire" "^1.1.0"
"@protobufjs/float@^1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1"
integrity sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E=
"@protobufjs/inquire@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089"
integrity sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik=
"@protobufjs/path@^1.1.2":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d"
integrity sha1-bMKyDFya1q0NzP0hynZz2Nf79o0=
"@protobufjs/pool@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54"
integrity sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q=
"@protobufjs/utf8@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570"
integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=
"@sindresorhus/is@^0.14.0":
version "0.14.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"
......@@ -3017,11 +2964,6 @@
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.157.tgz#fdac1c52448861dfde1a2e1515dbc46e54926dc8"
integrity sha512-Ft5BNFmv2pHDgxV5JDsndOWTRJ+56zte0ZpYLowp03tW+K+t8u8YMOzAnpuqPgzX6WO1XpDIUm7u04M8vdDiVQ==
"@types/long@^4.0.0":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.1.tgz#459c65fa1867dafe6a8f322c4c51695663cc55e9"
integrity sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==
"@types/memory-fs@*":
version "0.3.2"
resolved "https://registry.yarnpkg.com/@types/memory-fs/-/memory-fs-0.3.2.tgz#5d4753f9b390cb077c8c8af97bc96463399ceccd"
......@@ -3049,20 +2991,15 @@
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6"
integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY=
"@types/node@*", "@types/node@>= 8":
version "14.0.5"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.5.tgz#3d03acd3b3414cf67faf999aed11682ed121f22b"
integrity sha512-90hiq6/VqtQgX8Sp0EzeIsv3r+ellbGj4URKj5j30tLlZvRUpnAe9YbYnjl3pJM93GyXU0tghHhvXHq+5rnCKA==
"@types/node@14.0.14":
"@types/node@*", "@types/node@14.0.14":
version "14.0.14"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.14.tgz#24a0b5959f16ac141aeb0c5b3cd7a15b7c64cbce"
integrity sha512-syUgf67ZQpaJj01/tRTknkMNoBBLWJOBODF0Zm4NrXmiSuxjymFrxnTu1QVYRubhVkRcZLYZG8STTwJRdVm/WQ==
"@types/node@^10.1.0":
version "10.17.24"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.24.tgz#c57511e3a19c4b5e9692bb2995c40a3a52167944"
integrity sha512-5SCfvCxV74kzR3uWgTYiGxrd69TbT1I6+cMx1A5kEly/IVveJBimtAMlXiEyVFn5DvUFewQWxOOiJhlxeQwxgA==
"@types/node@>= 8":
version "14.0.5"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.5.tgz#3d03acd3b3414cf67faf999aed11682ed121f22b"
integrity sha512-90hiq6/VqtQgX8Sp0EzeIsv3r+ellbGj4URKj5j30tLlZvRUpnAe9YbYnjl3pJM93GyXU0tghHhvXHq+5rnCKA==
"@types/normalize-package-data@^2.4.0":
version "2.4.0"
......@@ -3143,9 +3080,9 @@
"@types/node" "*"
"@types/semver@^7.1.0":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.2.0.tgz#0d72066965e910531e1db4621c15d0ca36b8d83b"
integrity sha512-TbB0A8ACUWZt3Y6bQPstW9QNbhNeebdgLX4T/ZfkrswAfUzRiXrgd9seol+X379Wa589Pu4UEx9Uok0D4RjRCQ==
version "7.3.1"
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.1.tgz#7a9a5d595b6d873f338c867dcef64df289468cfa"
integrity sha512-ooD/FJ8EuwlDKOI6D9HWxgIgJjMg2cuziXm/42npDC8y4NjxplBUn9loewZiBNCt44450lHAU0OSb51/UqXeag==
dependencies:
"@types/node" "*"
......@@ -3618,7 +3555,7 @@ ajv-keywords@^3.1.0, ajv-keywords@^3.4.1:
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.4.1.tgz#ef916e271c64ac12171fd8384eaae6b2345854da"
integrity sha512-RO1ibKvd27e6FEShVFfPALuHI3WjSVNeK5FIsmme/LYRNxjKuNj+Dt7bucLa6NdSv3JcVTyMlm9kGR84z1XpaQ==
ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.0, ajv@^6.12.2, ajv@^6.5.5:
ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.0, ajv@^6.12.2:
version "6.12.2"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.2.tgz#c629c5eced17baf314437918d2da88c99d5958cd"
integrity sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ==
......@@ -3628,6 +3565,16 @@ ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.0, ajv@^6.12.2, ajv@^6.5.5:
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"
ajv@^6.5.5:
version "6.12.3"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.3.tgz#18c5af38a111ddeb4f2697bd78d68abc1cabd706"
integrity sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==
dependencies:
fast-deep-equal "^3.1.1"
fast-json-stable-stringify "^2.0.0"
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"
ally.js@1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/ally.js/-/ally.js-1.4.1.tgz#9fb7e6ba58efac4ee9131cb29aa9ee3b540bcf1e"
......@@ -7177,9 +7124,9 @@ fast-deep-equal@2.0.1:
integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=
fast-deep-equal@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz#545145077c501491e33b15ec408c294376e94ae4"
integrity sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==
version "3.1.3"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
fast-diff@^1.1.2:
version "1.2.0"
......@@ -9882,7 +9829,7 @@ loglevel@^1.6.2:
resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.6.8.tgz#8a25fb75d092230ecd4457270d80b54e28011171"
integrity sha512-bsU7+gc9AJ2SqpzxwU3+1fedl8zAntbtC5XYlt3s2j1hJcn2PsXSmgN8TaLG/J1/2mod4+cE/3vNL70/c1RNCA==
long@4.0.0, long@^4.0.0:
long@4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28"
integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==
......@@ -10559,8 +10506,8 @@ netmask@^1.0.6:
integrity sha1-ICl+idhvb2QA8lDZ9Pa0wZRfzTU=
netron@PeterPanZH/netron:
version "4.3.5"
resolved "https://codeload.github.com/PeterPanZH/netron/tar.gz/2c04a5d19b18ec09ddb9087f99177e7d27f156bd"
version "4.3.8"
resolved "https://codeload.github.com/PeterPanZH/netron/tar.gz/ecd84708e2140b4de62cc3cbed6dbb1e02c27bc4"
dependencies:
d3 "5.16.0"
dagre "0.8.5"
......@@ -10569,7 +10516,6 @@ netron@PeterPanZH/netron:
long "4.0.0"
marked "1.1.0"
pako "1.0.11"
protobufjs "github:lutzroeder/protobuf.js"
universal-analytics "0.4.20"
next-tick@~1.0.0:
......@@ -12211,25 +12157,6 @@ proto-list@~1.2.1:
resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849"
integrity sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk=
"protobufjs@github:lutzroeder/protobuf.js", protobufjs@lutzroeder/protobuf.js#b9a9d027589356226f4704f9d77f2639f52172f3:
version "6.8.8"
uid b9a9d027589356226f4704f9d77f2639f52172f3
resolved "https://codeload.github.com/lutzroeder/protobuf.js/tar.gz/b9a9d027589356226f4704f9d77f2639f52172f3"
dependencies:
"@protobufjs/aspromise" "^1.1.2"
"@protobufjs/base64" "^1.1.2"
"@protobufjs/codegen" "^2.0.4"
"@protobufjs/eventemitter" "^1.1.0"
"@protobufjs/fetch" "^1.1.0"
"@protobufjs/float" "^1.0.2"
"@protobufjs/inquire" "^1.1.0"
"@protobufjs/path" "^1.1.2"
"@protobufjs/pool" "^1.1.0"
"@protobufjs/utf8" "^1.1.0"
"@types/long" "^4.0.0"
"@types/node" "^10.1.0"
long "^4.0.0"
protocols@^1.1.0, protocols@^1.4.0:
version "1.4.7"
resolved "https://registry.yarnpkg.com/protocols/-/protocols-1.4.7.tgz#95f788a4f0e979b291ffefcf5636ad113d037d32"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册