test file loading
mason manifest
This commit is contained in:
parent
edc489ab1a
commit
d4f8b736ed
34
mason.json
Normal file
34
mason.json
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"version": "0.0.1",
|
||||||
|
"name": "mimicry",
|
||||||
|
"dependencies": [],
|
||||||
|
"build": [
|
||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"dependency.js",
|
||||||
|
"errors.js",
|
||||||
|
"loadingFile.js",
|
||||||
|
"module.js",
|
||||||
|
"queue.js"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"targets": ["browser"],
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"source": "browser.js",
|
||||||
|
"target": "mimicry.js"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"targets": ["node"],
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"source": "node.js",
|
||||||
|
"target": "mimicry.js"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
11
node.js
11
node.js
@ -1,5 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
const {BasicError, LoadError, FileError} = require("./errors")
|
const {BasicError, LoadError, FileError} = require("./errors")
|
||||||
const LoadingFile = require("./loadingFile");
|
const LoadingFile = require("./loadingFile");
|
||||||
@ -368,6 +369,7 @@ function executeLoad (/*String*/path, /*LoadingFile*/loadingFile) {
|
|||||||
//getByXHR(path, boundLoad, boundError, "arraybuffer", this._config.seed);
|
//getByXHR(path, boundLoad, boundError, "arraybuffer", this._config.seed);
|
||||||
break;
|
break;
|
||||||
case Type.text:
|
case Type.text:
|
||||||
|
fs.readFile(path, "utf8", onFileRead.bind(this, path));
|
||||||
//getByXHR(path, boundLoad, boundError, "text", this._config.seed);
|
//getByXHR(path, boundLoad, boundError, "text", this._config.seed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -401,6 +403,15 @@ function onLoaded(/*String*/path, /*any*/value) {
|
|||||||
notifyProgressSubscribers.call(this);
|
notifyProgressSubscribers.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onFileRead (/*String*/path, err, value) {
|
||||||
|
if (err) {
|
||||||
|
this._errors.set(path, err);
|
||||||
|
onError.call(this, path)
|
||||||
|
} else {
|
||||||
|
onLoaded.call(this, path, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onError (/*String*/path) {
|
function onError (/*String*/path) {
|
||||||
const loading = this._loadingFiles.get(path);
|
const loading = this._loadingFiles.get(path);
|
||||||
let error = this._errors.get(path);
|
let error = this._errors.get(path);
|
||||||
|
@ -24,15 +24,32 @@ function test () {
|
|||||||
log("Error instantiating Mimicry");
|
log("Error instantiating Mimicry");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
mimicry.addErrorHandler((err) => {
|
||||||
|
log(err);
|
||||||
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mimicry.module(["module"], function (global, [module]) {
|
mimicry.module(["module"], function (global, [module]) {
|
||||||
log("Mimicry empty module successfully resolved");
|
log("Mimicry empty module successfully resolved");
|
||||||
log("The background now is supposed to be bluish if you're testing in browser")
|
log("The background now is supposed to be bluish if you're testing in browser")
|
||||||
if (module === true)
|
|
||||||
|
if (module instanceof Array) {
|
||||||
log("Value returned from additional module is correct");
|
log("Value returned from additional module is correct");
|
||||||
else
|
|
||||||
|
let allGood = true;
|
||||||
|
for (let i = 0; i < module.length; ++i) {
|
||||||
|
if (!module[i]) {
|
||||||
|
log("Component number " + i + " returned from additional module is incorrect");
|
||||||
|
allGood = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allGood)
|
||||||
|
log("All components returned from additional module are correct");
|
||||||
|
|
||||||
|
} else {
|
||||||
log("Value returned from additional module is \"" + module + "\", which is incorrect");
|
log("Value returned from additional module is \"" + module + "\", which is incorrect");
|
||||||
|
}
|
||||||
|
|
||||||
const json = mimicry.getAsset("simple");
|
const json = mimicry.getAsset("simple");
|
||||||
if (json instanceof Object && json.I === "am")
|
if (json instanceof Object && json.I === "am")
|
||||||
|
18
test/main.js
18
test/main.js
@ -24,10 +24,24 @@ function test () {
|
|||||||
mimicry.module(["module"], function (global, [module]) {
|
mimicry.module(["module"], function (global, [module]) {
|
||||||
log("Mimicry empty module successfully resolved");
|
log("Mimicry empty module successfully resolved");
|
||||||
log("The background now is supposed to be bluish if you're testing in browser")
|
log("The background now is supposed to be bluish if you're testing in browser")
|
||||||
if (module === true)
|
|
||||||
|
if (module instanceof Array) {
|
||||||
log("Value returned from additional module is correct");
|
log("Value returned from additional module is correct");
|
||||||
else
|
|
||||||
|
let allGood = true;
|
||||||
|
for (let i = 0; i < module.length; ++i) {
|
||||||
|
if (!module[i]) {
|
||||||
|
log("Component number " + i + " returned from additional module is incorrect");
|
||||||
|
allGood = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allGood)
|
||||||
|
log("All components returned from additional module are correct");
|
||||||
|
|
||||||
|
} else {
|
||||||
log("Value returned from additional module is \"" + module + "\", which is incorrect");
|
log("Value returned from additional module is \"" + module + "\", which is incorrect");
|
||||||
|
}
|
||||||
|
|
||||||
const json = mimicry.getAsset("simple");
|
const json = mimicry.getAsset("simple");
|
||||||
if (json instanceof Object && json.I === "am")
|
if (json instanceof Object && json.I === "am")
|
||||||
|
@ -2,7 +2,12 @@
|
|||||||
mimicry.module([
|
mimicry.module([
|
||||||
"terminalModule",
|
"terminalModule",
|
||||||
"simple", Mimicry.Type.json,
|
"simple", Mimicry.Type.json,
|
||||||
"background", Mimicry.Type.css
|
"background", Mimicry.Type.css,
|
||||||
], function (global, [terminalModule, simple]) {
|
"text", Mimicry.Type.text
|
||||||
return terminalModule === "terminal" && simple.a[4] === 115;
|
], function (global, [terminalModule, simple, background, text]) {
|
||||||
|
return [
|
||||||
|
terminalModule === "terminal",
|
||||||
|
simple.a[4] === 115,
|
||||||
|
text === "Lorem ipsum, I guess"
|
||||||
|
];
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user