script recompilation work
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
0b404723cc
commit
dfd5932675
@ -66,9 +66,18 @@ export const clientHooks: Hook[] = [
|
||||
engine.classes.areaUtils.static.selectAreaRectangular()
|
||||
}
|
||||
},
|
||||
{
|
||||
signal: "ROOM_TOOL_TOGGLE",
|
||||
callback: (engine: Engine) => {
|
||||
engine.singletons.loggerScripts.WARNING('asdf')
|
||||
engine.singletons.loggerScripts.WARNING(JSON.stringify(globalThis))
|
||||
}
|
||||
},
|
||||
{
|
||||
signal: "ROOM_TOOL_MENU",
|
||||
callback: (engine: Engine) => {
|
||||
engine.singletons.loggerScripts.WARNING('asdf')
|
||||
engine.singletons.loggerScripts.WARNING(JSON.stringify(globalThis))
|
||||
engine.classes.menuUtils.static.openDialog('Data/menu/room/roomToolConfig.html')
|
||||
}
|
||||
},
|
||||
|
||||
9
assets/Scripts/compiler/context.js
Normal file
9
assets/Scripts/compiler/context.js
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
/**
|
||||
* The top level variable that should be used to store data
|
||||
*/
|
||||
let Document = {
|
||||
|
||||
}
|
||||
|
||||
@ -19,6 +19,9 @@ export const engine: Engine = {
|
||||
playerState: defaultPlayerState,
|
||||
}
|
||||
|
||||
//store engine in globalThis
|
||||
globalThis.engine = engine;
|
||||
|
||||
/**
|
||||
* Called when the script engine first initializes
|
||||
*/
|
||||
|
||||
@ -1843,6 +1843,7 @@ Capsule-BlockChunk collision correction in collidable trees
|
||||
Out-of-context typescript compilation that falls back to in-context compilation
|
||||
Fix opengl bug
|
||||
Fix typescript out-of-context compilation caching
|
||||
Script recompilation work
|
||||
|
||||
|
||||
|
||||
|
||||
@ -281,9 +281,17 @@ public class ScriptContext {
|
||||
{
|
||||
String pathRaw = toWriteFile.toPath() + "";
|
||||
pathRaw = pathRaw.replace(".\\.cache\\tscache\\src\\", "./assets/");
|
||||
File correspondingFile = new File(pathRaw.replace(".\\.cache\\tscache\\src\\", "./assets/"));
|
||||
String cacheKey = pathRaw.replace("./assets", "").replace("\\", "/");
|
||||
checksumMap.getFileLastModifyMap().put(cacheKey, correspondingFile.lastModified() + "");
|
||||
long lastModified = 0;
|
||||
try {
|
||||
File correspondingSourceFile = new File(pathRaw.replace(".cache\\tscache\\src\\", "./assets/").replace(".js",".ts"));
|
||||
FileTime time = Files.getLastModifiedTime(correspondingSourceFile.toPath());
|
||||
lastModified = time.toMillis();
|
||||
} catch (IOException e) {
|
||||
throw new Error("Failed to gather last modified time! " + lastModified);
|
||||
}
|
||||
checksumMap.getFileLastModifyMap().put(cacheKey, lastModified + "");
|
||||
LoggerInterface.loggerScripts.DEBUG("Putting file in cache " + cacheKey + " " + lastModified);
|
||||
}
|
||||
|
||||
//write the actual file
|
||||
@ -327,11 +335,11 @@ public class ScriptContext {
|
||||
if(!currPath.toFile().isDirectory()){
|
||||
String pathRaw = currPath.toString();
|
||||
pathRaw = pathRaw.replace(".cache\\tscache\\src\\", "./assets/");
|
||||
File correspondingFile = new File(pathRaw.replace(".cache\\tscache\\src\\", "./assets/"));
|
||||
String cacheKey = pathRaw.replace("./assets", "").replace("\\", "/");
|
||||
long lastModified = correspondingFile.lastModified();
|
||||
long lastModified = 0;
|
||||
try {
|
||||
FileTime time = Files.getLastModifiedTime(currPath);
|
||||
File correspondingSourceFile = new File(pathRaw.replace(".cache\\tscache\\src\\", "./assets/").replace(".js",".ts"));
|
||||
FileTime time = Files.getLastModifiedTime(correspondingSourceFile.toPath());
|
||||
lastModified = time.toMillis();
|
||||
} catch (IOException e) {
|
||||
throw new Error("Failed to gather last modified time! " + lastModified);
|
||||
|
||||
@ -5,6 +5,7 @@ import java.io.IOException;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.WatchService;
|
||||
import java.nio.file.attribute.FileTime;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -96,6 +97,9 @@ public class ScriptEngine extends SignalServiceImpl {
|
||||
"Scripts/compiler/file_resolution.js",
|
||||
"Scripts/compiler/compiler.js",
|
||||
"Scripts/compiler/host_access.js",
|
||||
|
||||
//global context
|
||||
"Scripts/compiler/context.js",
|
||||
};
|
||||
|
||||
/**
|
||||
@ -178,9 +182,13 @@ public class ScriptEngine extends SignalServiceImpl {
|
||||
|
||||
//compile
|
||||
if(!readCache){
|
||||
LoggerInterface.loggerScripts.WARNING("Recompiling scripts");
|
||||
if(!scriptContext.compileOutsideContext()){
|
||||
scriptContext.compileInContext();
|
||||
}
|
||||
if(!this.initCache()){
|
||||
throw new Error("Failed to compile!");
|
||||
}
|
||||
}
|
||||
|
||||
//post init logic
|
||||
@ -272,13 +280,25 @@ public class ScriptEngine extends SignalServiceImpl {
|
||||
String relativePath = FileUtils.relativize(file, tsCache);
|
||||
String normalizedPath = "/" + relativePath;
|
||||
boolean shouldLoad = true;
|
||||
File correspondingSourceFile = FileUtils.getAssetFile(compoundedPath + "/" + file.getName());
|
||||
File correspondingSourceFile = FileUtils.getAssetFile(compoundedPath + "/" + file.getName().replace(".js", ".ts"));
|
||||
|
||||
long lastModified = 0;
|
||||
if(correspondingSourceFile.exists()){
|
||||
try {
|
||||
FileTime time = Files.getLastModifiedTime(correspondingSourceFile.toPath());
|
||||
lastModified = time.toMillis();
|
||||
} catch (IOException e) {
|
||||
throw new Error("Failed to gather last modified time! " + lastModified);
|
||||
}
|
||||
} else {
|
||||
shouldLoad = false;
|
||||
}
|
||||
|
||||
//determine if we should load the file
|
||||
if(!fileLastModifyMap.containsKey(normalizedPath)){
|
||||
//cache does not contain this file
|
||||
shouldLoad = false;
|
||||
} else if(!fileLastModifyMap.get(normalizedPath).contains(correspondingSourceFile.lastModified() + "")) {
|
||||
} else if(!fileLastModifyMap.get(normalizedPath).contains(lastModified + "")) {
|
||||
//cache is up to date
|
||||
shouldLoad = false;
|
||||
}
|
||||
@ -300,9 +320,9 @@ public class ScriptEngine extends SignalServiceImpl {
|
||||
boolean inMap = fileLastModifyMap.containsKey(normalizedPath);
|
||||
boolean timeMatch = false;
|
||||
if(inMap){
|
||||
timeMatch = fileLastModifyMap.get(normalizedPath).contains(correspondingSourceFile.lastModified() + "");
|
||||
timeMatch = fileLastModifyMap.get(normalizedPath).contains(lastModified + "");
|
||||
}
|
||||
LoggerInterface.loggerScripts.DEBUG("Skipping Preload: " + normalizedPath + " " + inMap + " " + timeMatch);
|
||||
LoggerInterface.loggerScripts.DEBUG("Skipping Preload: " + normalizedPath + " " + inMap + " " + timeMatch + " " + correspondingSourceFile.exists() + " " + lastModified + " " + correspondingSourceFile.toString());
|
||||
rVal = false;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user