hydra-nodegl 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "hydra-nodegl",
3
+ "version": "2.1.0",
4
+ "description": "It'll be convenience for hydra used by Node.js.",
5
+ "main": "./index.cjs",
6
+ "bin": {
7
+ "nodegl": "./index.cjs"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/Uchida16104/NodeGL.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/Uchida16104/NodeGL/issues"
15
+ },
16
+ "homepage": "https://uchida16104.github.io/NodeGL",
17
+ "author": "Hirotoshi Uchida",
18
+ "license": "MIT",
19
+ "type": "commonjs",
20
+ "scripts": {
21
+ "start": "node ./index.cjs && rm -f package.json && refresh",
22
+ "test": "echo 'Running NodeGL...'"
23
+ },
24
+ "keywords": [
25
+ "extension"
26
+ ]
27
+ }
package/script.cjs ADDED
@@ -0,0 +1,93 @@
1
+ let hydra, hydraCanvas;
2
+ hydraCanvas = document.createElement("canvas");
3
+ hydraCanvas.width = 512;
4
+ hydraCanvas.height = 512;
5
+ hydraCanvas.id = "hydraCanvas";
6
+
7
+ hydra = new Hydra({
8
+ canvas: hydraCanvas,
9
+ detectAudio: false,
10
+ enableStreamCapture: false,
11
+ width: 512,
12
+ height: 512,
13
+ });
14
+
15
+ const codeblocks = document.getElementsByClassName("codeblock");
16
+
17
+ for (const cb of codeblocks) {
18
+ const cd = cb.querySelector("div");
19
+ cd.style.width = "512px";
20
+ cd.style.height = "512px";
21
+ cd.style.left = "50%";
22
+ cd.style.position = "relative";
23
+ cd.style.transform = "translate(-50%, 0%)";
24
+
25
+ var observer = new IntersectionObserver(function (entries) {
26
+ if (entries[0].isIntersecting === true) {
27
+ hush();
28
+ solid(0,0,0,0).out(o0);
29
+ solid(0,0,0,0).out(o1);
30
+ solid(0,0,0,0).out(o2);
31
+ solid(0,0,0,0).out(o3);
32
+ render(o0);
33
+ setTimeout(() => {
34
+ eval(cb.querySelector("code").textContent);
35
+ }, 60);
36
+ cd.appendChild(hydraCanvas);
37
+ }
38
+ }, { threshold: [0.7] });
39
+
40
+ observer.observe(cb);
41
+ }
42
+
43
+ document.addEventListener('DOMContentLoaded', function() {
44
+ const readyEls = Array.from(document.getElementsByClassName('ready'));
45
+ const codeEls = Array.from(document.getElementsByClassName('codeblock'));
46
+ const allEls = readyEls.concat(codeEls);
47
+
48
+ allEls.forEach(el => {
49
+ let codeText;
50
+ const codeChild = el.querySelector('code');
51
+ if (codeChild) {
52
+ codeText = codeChild.textContent;
53
+ } else {
54
+ codeText = el.textContent;
55
+ }
56
+
57
+ const snippet = document.createElement('div');
58
+ snippet.className = 'qiita-snippet';
59
+
60
+ const pre = document.createElement('pre');
61
+ const codeNode = document.createElement('code');
62
+ codeNode.textContent = codeText.trim();
63
+ pre.appendChild(codeNode);
64
+ snippet.appendChild(pre);
65
+
66
+ const btn = document.createElement('button');
67
+ btn.className = 'copy-button';
68
+ btn.textContent = 'Copy';
69
+ btn.addEventListener('click', () => {
70
+ navigator.clipboard.writeText(codeNode.textContent)
71
+ .then(() => {
72
+ btn.textContent = 'Copied';
73
+ setTimeout(() => btn.textContent = 'Copy', 2000);
74
+ })
75
+ .catch(err => console.error('Copy failed', err));
76
+ });
77
+ snippet.appendChild(btn);
78
+
79
+ if (codeChild) {
80
+ el.replaceChild(snippet, codeChild);
81
+ } else {
82
+ el.innerHTML = '';
83
+ el.appendChild(snippet);
84
+ }
85
+ });
86
+
87
+ const accordionHeader = document.querySelector('.accordion-header');
88
+ const accordionContent = document.querySelector('.accordion-content');
89
+ accordionHeader.addEventListener('click', function() {
90
+ const isVisible = accordionContent.style.display === 'block';
91
+ accordionContent.style.display = isVisible ? 'none' : 'block';
92
+ });
93
+ });
package/style.css ADDED
@@ -0,0 +1,82 @@
1
+ * {
2
+ scroll-behavior: smooth;
3
+ background: black;
4
+ color: cyan;
5
+ }
6
+
7
+ body, code {
8
+ font-family: 'Monaspace Krypton', monospace;
9
+ margin: 0;
10
+ padding: 0;
11
+ }
12
+
13
+ .sidebar {
14
+ position: fixed;
15
+ left: 0;
16
+ top: 50%;
17
+ transform: translateY(-50%);
18
+ width: 200px;
19
+ background-color: #f1f1f1;
20
+ padding: 10px;
21
+ box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
22
+ font-size: 10px;
23
+ color: #0b0b0b;
24
+ overflow-y: auto;
25
+ }
26
+
27
+ .sidebar:hover {
28
+ background-color: #0b0b0b;
29
+ font-size: 20px;
30
+ color: #f4f4f4;
31
+ }
32
+
33
+ .accordion {
34
+ width: 100%;
35
+ }
36
+
37
+ .accordion-header {
38
+ background-color: #007bff;
39
+ color: white;
40
+ padding: 15px;
41
+ cursor: pointer;
42
+ user-select: none;
43
+ }
44
+
45
+ .accordion-content {
46
+ display: none;
47
+ padding: 5px;
48
+ background-color: white;
49
+ }
50
+
51
+ .accordion-content ul {
52
+ display: block;
53
+ list-style-type: none;
54
+ padding: 0;
55
+ margin: 0;
56
+ max-height: 200px;
57
+ overflow-y: auto;
58
+ }
59
+
60
+ .accordion-content li {
61
+ margin-bottom: 10px;
62
+ }
63
+
64
+ .accordion-content ul > li:hover {
65
+ background-color: #0b0b0b;
66
+ font-size: 20px;
67
+ color: #f4f4f4;
68
+ }
69
+
70
+ .accordion-content a {
71
+ color: #007bff;
72
+ text-decoration: none;
73
+ }
74
+
75
+ .accordion-content a:hover {
76
+ text-decoration: underline;
77
+ }
78
+
79
+ .content {
80
+ margin-left: 220px;
81
+ padding: 20px;
82
+ }