소스 검색

Update view.js (#1089)

Lutz Roeder 1 년 전
부모
커밋
b91cbe2602
9개의 변경된 파일405개의 추가작업 그리고 335개의 파일을 삭제
  1. 2 2
      source/browser.js
  2. 1 1
      source/electron.mjs
  3. 5 5
      source/pickle.js
  4. 1 1
      source/pytorch.js
  5. 2 2
      source/tf.js
  6. 1 1
      source/torch.js
  7. 375 319
      source/view.js
  8. 1 1
      test/models.js
  9. 17 3
      test/worker.js

+ 2 - 2
source/browser.js

@@ -662,7 +662,7 @@ host.BrowserHost.BrowserFileContext = class {
         return await this._host.require(id);
     }
 
-    exception(error, fatal) {
+    error(error, fatal) {
         this._host.exception(error, fatal);
     }
 
@@ -809,7 +809,7 @@ host.BrowserHost.Context = class {
         return this._host.require(id);
     }
 
-    exception(error, fatal) {
+    error(error, fatal) {
         this._host.exception(error, fatal);
     }
 };

+ 1 - 1
source/electron.mjs

@@ -709,7 +709,7 @@ host.ElectronHost.Context = class {
         return await this._host.require(id);
     }
 
-    exception(error, fatal) {
+    error(error, fatal) {
         this._host.exception(error, fatal);
     }
 };

+ 5 - 5
source/pickle.js

@@ -26,15 +26,15 @@ pickle.ModelFactory = class {
         let format = 'Pickle';
         const obj = context.target;
         if (obj === null || obj === undefined) {
-            context.exception(new pickle.Error("Unsupported Pickle null object."));
+            context.error(new pickle.Error("Unsupported Pickle null object."));
         } else if (obj instanceof Error) {
             throw obj;
         } else if (Array.isArray(obj)) {
             if (obj.length > 0 && obj[0] && obj.every((item) => item && item.__class__ && obj[0].__class__ && item.__class__.__module__ === obj[0].__class__.__module__ && item.__class__.__name__ === obj[0].__class__.__name__)) {
                 const type = `${obj[0].__class__.__module__}.${obj[0].__class__.__name__}`;
-                context.exception(new pickle.Error(`Unsupported Pickle '${type}' array object.`));
+                context.error(new pickle.Error(`Unsupported Pickle '${type}' array object.`));
             } else if (obj.length > 0) {
-                context.exception(new pickle.Error("Unsupported Pickle array object."));
+                context.error(new pickle.Error("Unsupported Pickle array object."));
             }
         } else if (obj && obj.__class__) {
             const formats = new Map([
@@ -44,10 +44,10 @@ pickle.ModelFactory = class {
             if (formats.has(type)) {
                 format = formats.get(type);
             } else {
-                context.exception(new pickle.Error(`Unsupported Pickle type '${type}'.`));
+                context.error(new pickle.Error(`Unsupported Pickle type '${type}'.`));
             }
         } else {
-            context.exception(new pickle.Error('Unsupported Pickle object.'));
+            context.error(new pickle.Error('Unsupported Pickle object.'));
         }
         return new pickle.Model(obj, format);
     }

+ 1 - 1
source/pytorch.js

@@ -25,7 +25,7 @@ pytorch.ModelFactory = class {
         const metadata = await pytorch.Metadata.open(context);
         const target = context.target;
         target.on('resolve', (_, name) => {
-            context.exception(new pytorch.Error(`Unknown type name '${name}'.`), false);
+            context.error(new pytorch.Error(`Unknown type name '${name}'.`), false);
         });
         await target.read(metadata);
         return new pytorch.Model(metadata, target);

+ 2 - 2
source/tf.js

@@ -283,7 +283,7 @@ tf.ModelFactory = class {
                 const bundle = await tf.TensorBundle.open(stream, identifier, context);
                 return openModel(null, `TensorFlow Tensor Bundle v${bundle.format}`, null, bundle);
             } catch (error) {
-                context.exception(error, false);
+                context.error(error, false);
                 throw error;
             }
         };
@@ -1309,7 +1309,7 @@ tf.TensorBundle = class {
             const streams = contexts.map((context) => context.stream);
             return new tf.TensorBundle(format, table.entries, streams);
         } catch (error) {
-            context.exception(error, false);
+            context.error(error, false);
             return new tf.TensorBundle(format, table.entries, null);
         }
     }

+ 1 - 1
source/torch.js

@@ -18,7 +18,7 @@ torch.ModelFactory = class {
         const reader = context.target;
         reader.callback = (name) => {
             if (name && name !== 'nn.JointTrainModule' && !name.startsWith('nn.MSDNet_') && !name.startsWith('onmt.')) {
-                context.exception(new torch.Error(`Unsupported type '${name}'.`));
+                context.error(new torch.Error(`Unsupported type '${name}'.`));
             }
             return null;
         };

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 375 - 319
source/view.js


+ 1 - 1
test/models.js

@@ -287,4 +287,4 @@ const main = async () => {
     }
 };
 
-main();
+await main();

+ 17 - 3
test/worker.js

@@ -136,7 +136,7 @@ host.TestHost.Context = class {
         return this._host.require(id);
     }
 
-    exception(error, fatal) {
+    error(error, fatal) {
         this._host.exception(error, fatal);
     }
 };
@@ -164,7 +164,7 @@ class DOMTokenList {
 
     add(...tokens) {
         const value = this._element.getAttribute('class') || '';
-        tokens = new Set(value.split(' ').contact(tokens));
+        tokens = new Set(value.split(' ').concat(tokens));
         this._element.setAttribute('class', Array.from(tokens).join(' '));
     }
 
@@ -190,6 +190,10 @@ class HTMLElement {
 
     }
 
+    get childNodes() {
+        return this._childNodes;
+    }
+
     get lastChild() {
         const index = this._childNodes.length - 1;
         if (index >= 0) {
@@ -202,6 +206,13 @@ class HTMLElement {
         this._childNodes.push(node);
     }
 
+    insertBefore(newNode, referenceNode) {
+        const index = this._childNodes.indexOf(referenceNode);
+        if (index !== -1) {
+            this._childNodes.splice(index, 0, newNode);
+        }
+    }
+
     removeChild(node) {
         const index = this._childNodes.lastIndexOf(node);
         if (index !== -1) {
@@ -711,8 +722,11 @@ export class Target {
                         chain.name.length;
                     }
                 }
-                // new dialog.NodeSidebar(host, node);
+                // const sidebar = new view.NodeSidebar(this.host, node);
+                // sidebar.render();
             }
+            const sidebar = new view.ModelSidebar(this.host, this.model, graph);
+            sidebar.render();
         };
         /* eslint-enable no-unused-expressions */
         for (const graph of this.model.graphs) {

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.