From 86dbd2e2ac5616695201b47ee2353f30d2ac78a9 Mon Sep 17 00:00:00 2001
From: baletiballo <75846481+baletiballo@users.noreply.github.com>
Date: Fri, 24 Jan 2025 18:55:59 +0100
Subject: [PATCH] Added JSDoc Type annotations

---
 .../scroll_interaction/Drop_facts.js          | 14 ++++++++--
 .../scroll_interaction/SetScrollContent.js    | 26 +++++++++++++++++++
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/Assets/StreamingAssets/ScrollView_Server/scroll_interaction/Drop_facts.js b/Assets/StreamingAssets/ScrollView_Server/scroll_interaction/Drop_facts.js
index 0916b3d9..fb09f7cc 100644
--- a/Assets/StreamingAssets/ScrollView_Server/scroll_interaction/Drop_facts.js
+++ b/Assets/StreamingAssets/ScrollView_Server/scroll_interaction/Drop_facts.js
@@ -1,11 +1,21 @@
 /**
- * @typedef Point
+ * @typedef point
  * @type {object}
  * @property {number} x
  * @property {number} y
  * @property {number} z
  */
 
+/**
+ * @typedef {Object} fact
+ * @property {string} id Fact id
+ * @property {string} s_type Fact type
+ * @property {string} label used in unity
+ * @property {string | null} _CustomLabel Custom label
+ * @property {boolean} hasCustomLabel
+ * @property {number} labelId
+ */
+
 /**
  * @property {Point} point
  * @property {Point} normal
@@ -122,7 +132,7 @@ function dropHandler(event) {
     //const data = event.dataTransfer.getData("text/plain")
     console.log(`Dropped data: '${event.dataTransfer.types}'`, event.dataTransfer.types)
 
-    /** @type {Fact} */
+    /** @type {fact} */
     const fact = JSON.parse(data)
     console.warn(`Dropped Fact '${fact.label}':`, fact)
 
diff --git a/Assets/StreamingAssets/ScrollView_Server/scroll_interaction/SetScrollContent.js b/Assets/StreamingAssets/ScrollView_Server/scroll_interaction/SetScrollContent.js
index 7fcf8b06..d2ba962b 100644
--- a/Assets/StreamingAssets/ScrollView_Server/scroll_interaction/SetScrollContent.js
+++ b/Assets/StreamingAssets/ScrollView_Server/scroll_interaction/SetScrollContent.js
@@ -1,6 +1,32 @@
+
+/**
+ * A MMT..whatever. Somewhere between the first and second "meta-" MMT had to leave common nomenclature behind
+ * @typedef {{kind : string, uri: string}} MMTReference
+ */
+/**
+ * Facts, as they are send by MMT. Not *quite* the same format as Unity uses \*sigh\*, and everything has shortened names to avoid five additional letters \*double sigh\*
+ * @typedef {Object} MMTFact
+ * @property {MMTReference} ref the reference MMT uses to identify this fact 
+ * @property {string} label the human readable lable to display this fact. 
+ * @property {?any} df the definition of the Fact. May be null for {@link MMTScroll.requiredFacts}
+ * @property {?MMTReference} tp the MMT type of this fact
+ * @property {string} kind since a Fact is a MMTThingy, they also have a {@link MMTReference.kind}
+ */
+/**
+ * @typedef {Object} MMTScroll
+ * @property {string} ref The MMT URI
+ * @property {string} label The human-readable name
+ * @property {string} description The description to be rendered here
+ * @property {MMTFact[]} requiredFacts List of all facts required to apply the scroll. If the scroll has been partially applied these Facts may be the assigned ones
+ * @property {MMTFact[]} acquiredFacts List of all facts that will be acquired when applying the scroll
+ * @property {string} name Unity artifact; The URI again
+ * @property {?string} path Unity artifact; will always be null
+ */
+
 let currentScrollRef = "" // ref of the scroll currently displayed 
 
 function RenderScroll() {
+    /** @type {MMTScroll} */
     const scroll = JSON.parse(document.querySelector("#Unity-Data-Interface").dataset.scrollDynamic);
     console.log(scroll.requiredFacts);
     const scrollContainer = document.querySelector("#scrollContainer");
-- 
GitLab