vfsjs-test 1.0.5 → 1.0.6
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/index.html +0 -3
- package/main.js +27 -15
- package/package.json +1 -1
package/index.html
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Infrared Engine Workspace</title>
|
|
7
|
-
<link rel="stylesheet" href="live-theme.css">
|
|
8
7
|
</head>
|
|
9
8
|
<body style="background: #0f172a; color: #38bdf8; font-family: monospace; padding: 20px;">
|
|
10
9
|
|
|
@@ -13,8 +12,6 @@
|
|
|
13
12
|
> Initializing isolated modular framework...
|
|
14
13
|
</div>
|
|
15
14
|
|
|
16
|
-
<script src="index.js"></script>
|
|
17
|
-
|
|
18
15
|
<script src="vfsjs.js"></script>
|
|
19
16
|
<script src="main.js"></script>
|
|
20
17
|
</body>
|
package/main.js
CHANGED
|
@@ -1,53 +1,66 @@
|
|
|
1
1
|
// main.js - User API Facade and Browser Orchestration
|
|
2
2
|
const display = document.getElementById('status');
|
|
3
3
|
|
|
4
|
-
// Expose clean interface functions to the developer
|
|
5
4
|
window.vfs = {
|
|
6
5
|
add(filename, contentString, customMime = null) {
|
|
7
6
|
if (!window._vfsKernel) return console.error("VFS Engine Kernel Offline.");
|
|
8
7
|
return window._vfsKernel.write(filename, contentString, customMime);
|
|
9
8
|
},
|
|
10
|
-
|
|
11
9
|
delete(filename) {
|
|
12
10
|
if (!window._vfsKernel) return console.error("VFS Engine Kernel Offline.");
|
|
13
11
|
return window._vfsKernel.remove(filename);
|
|
14
12
|
},
|
|
15
|
-
|
|
16
13
|
clear() {
|
|
17
14
|
if (!window._vfsKernel) return console.error("VFS Engine Kernel Offline.");
|
|
18
15
|
return window._vfsKernel.wipe();
|
|
19
16
|
}
|
|
20
17
|
};
|
|
21
18
|
|
|
19
|
+
// Helper function to mount our virtual files safely into the DOM runtime
|
|
20
|
+
function executeVirtualEnvironment() {
|
|
21
|
+
display.innerHTML += "<br>> Mounting virtual assets into DOM tree...";
|
|
22
|
+
|
|
23
|
+
// 1. Inject the Style Layer
|
|
24
|
+
const styleLink = document.createElement('link');
|
|
25
|
+
styleLink.rel = 'stylesheet';
|
|
26
|
+
styleLink.href = 'live-theme.css';
|
|
27
|
+
document.head.appendChild(styleLink);
|
|
28
|
+
|
|
29
|
+
// 2. Inject the Logic Layer
|
|
30
|
+
const scriptTag = document.createElement('script');
|
|
31
|
+
scriptTag.src = 'index.js';
|
|
32
|
+
document.body.appendChild(scriptTag);
|
|
33
|
+
}
|
|
34
|
+
|
|
22
35
|
async function bootEngine() {
|
|
23
36
|
try {
|
|
24
|
-
// Step 1: Fire up background kernel thread
|
|
25
37
|
const registration = await navigator.serviceWorker.register('./sw.js');
|
|
26
38
|
display.innerHTML += "<br>> Service worker synchronized.";
|
|
27
39
|
|
|
28
|
-
// Step 2: Await activation capture if first mount context
|
|
29
40
|
if (!navigator.serviceWorker.controller) {
|
|
30
|
-
display.innerHTML += "<br>> Activating routing links... (
|
|
41
|
+
display.innerHTML += "<br>> Activating routing links... (Please refresh if stuck)";
|
|
31
42
|
await new Promise(r => {
|
|
32
43
|
navigator.serviceWorker.addEventListener('controllerchange', r, { once: true });
|
|
33
44
|
});
|
|
34
45
|
}
|
|
35
|
-
display.innerHTML += "<br>> Pipeline linked.
|
|
46
|
+
display.innerHTML += "<br>> Pipeline linked. Writing data layers...";
|
|
36
47
|
|
|
37
|
-
//
|
|
48
|
+
// Write targets directly into memory first
|
|
38
49
|
vfs.add('live-theme.css', `
|
|
39
|
-
body { background: #030712 !important; color: #
|
|
50
|
+
body { background: #030712 !important; color: #22d3ee !important; }
|
|
40
51
|
#status { border-color: #1f2937 !important; background: #0b0f19 !important; }
|
|
41
52
|
`, 'text/css');
|
|
42
53
|
|
|
43
54
|
vfs.add('index.js', `
|
|
44
|
-
console.log("VFS Live: Running
|
|
45
|
-
document.getElementById('status').innerHTML += "<br>> <span style='color: #34d399;'>Virtual routing
|
|
55
|
+
console.log("VFS Live: Running perfectly under dynamic injection!");
|
|
56
|
+
document.getElementById('status').innerHTML += "<br>> <span style='color: #34d399;'>Virtual routing complete. Engine stable.</span>";
|
|
46
57
|
`, 'text/javascript');
|
|
47
58
|
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
// Give the background worker thread a brief split-second to cache the blobs
|
|
60
|
+
await new Promise(r => setTimeout(r, 50));
|
|
61
|
+
|
|
62
|
+
// Now run them safely!
|
|
63
|
+
executeVirtualEnvironment();
|
|
51
64
|
|
|
52
65
|
} catch (err) {
|
|
53
66
|
display.innerHTML += `<br>><span style="color: #ef4444;"> Boot Exception: ${err.message}</span>`;
|
|
@@ -55,5 +68,4 @@ async function bootEngine() {
|
|
|
55
68
|
}
|
|
56
69
|
}
|
|
57
70
|
|
|
58
|
-
// Instantiate ecosystem initialization
|
|
59
71
|
bootEngine();
|