Skip to content

Commit

Permalink
Merge branch 'master' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffpar committed Nov 20, 2023
2 parents fd6adfa + 0f2c231 commit c76b9af
Show file tree
Hide file tree
Showing 21 changed files with 158 additions and 122 deletions.
6 changes: 4 additions & 2 deletions _developer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ url: "http://localhost:4000"
# the <machine> tag of each XML file must set 'uncompiled' to "true" in order to use uncompiled scripts.
#
# 'site.pcjs.localdisks' can be turned if on you have local copies of PCjs disk images; be sure to remove
# '/disks' from the "exclude" section below as well. See https://github.com/jeffpar/pcjs/wiki/Using-a-Local-Web-Server#accessing-disk-images-locally
# for more information.
# '/disks' from the "exclude" section below as well.
#
# See https://github.com/jeffpar/pcjs/wiki/Using-a-Local-Web-Server#accessing-disk-images-locally for more
# information.
#
pcjs:
localdisks: false
Expand Down
21 changes: 11 additions & 10 deletions machines/dec/pdp10/releases/2.21/pdp10-uncompiled.js
Original file line number Diff line number Diff line change
Expand Up @@ -2518,13 +2518,14 @@ class WebLib {
sURL = sURL.replace(/^\/(disks\/|)(diskettes|gamedisks|miscdisks|harddisks|decdisks|pcsigdisks|pcsig[0-9a-z]*-disks|private)\//, "https://$2.pcjs.org/").replace(/^\/(disks\/cdroms|discs)\/([^/]*)\//, "https://$2.pcjs.org/");
}

Component.printf(MESSAGE.DEBUG, "getResource(%s)\n", sURL);

/*
* globals.node.readFileSync exists only when another module has import filelib.js, which means we're
* running under Node.js, and we can use Node's file system to read local files. Note that filelib.js only
* offers readFileSync() at the moment.
*/
if (globals.node.readFileSync && sURL.indexOf("http") != 0) {
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "reading: %s\n", sURL);
try {
let encoding = (type == "arraybuffer"? null : "utf8");
resource = globals.node.readFileSync(sURL, encoding);
Expand Down Expand Up @@ -2571,7 +2572,7 @@ class WebLib {
} else if (globals.window.ActiveXObject) {
request = new globals.window.ActiveXObject("Microsoft.XMLHTTP");
} else if (globals.window.fetch) {
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "fetching: %s\n", sURL);
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "getResource.fetch(%s)\n", sURL);
fetch(sURL)
.then(response => {
switch(type) {
Expand All @@ -2585,19 +2586,19 @@ class WebLib {
}
})
.then(resource => {
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "fetch %s complete: %d bytes\n", sURL, resource.length);
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "getResource.fetch(%s): %d bytes\n", sURL, resource.length);
if (done) done(sURL, resource, nErrorCode);
})
.catch(error => {
Component.printf(MESSAGE.LOG, "fetch %s error: %d\n", sURL, nErrorCode);
Component.printf(MESSAGE.LOG, "getResource.fetch(%s) error: %d\n", sURL, nErrorCode);
if (done) done(sURL, resource, nErrorCode);
});
return response;
}

let fArrayBuffer = false, fXHR2 = (typeof request.responseType === 'string');

let callback = function() {
let callback = function getResourceDone() {
if (request.readyState !== 4) {
if (progress) progress(1);
return null;
Expand Down Expand Up @@ -2628,18 +2629,18 @@ class WebLib {
try {
resource = fArrayBuffer? request.response : request.responseText;
} catch(err) {
Component.printf(MESSAGE.LOG, "xmlHTTPRequest(%s) exception: %s\n", sURL, err.message);
Component.printf(MESSAGE.LOG, "getResource.done(%s) exception: %s\n", sURL, err.message);
}
/*
* The normal "success" case is a non-null resource and an HTTP status code of 200, but when loading files from the
* local file system (ie, when using the "file:" protocol), we have to be a bit more flexible.
*/
if (resource != null && (request.status == 200 || !request.status && resource.length && WebLib.getHostProtocol() == "file:")) {
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "xmlHTTPRequest(%s): returned %d bytes\n", sURL, resource.length);
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "getResource.done(%s): %d bytes\n", sURL, resource.length);
}
else {
nErrorCode = request.status || -1;
Component.printf(MESSAGE.LOG, "xmlHTTPRequest(%s) returned error %d\n", sURL, nErrorCode);
Component.printf(MESSAGE.DEBUG, "getResource.done(%s) error: %d\n", sURL, nErrorCode);
if (!request.status && !WebLib.fAdBlockerWarning) {
let match = sURL.match(/(^https?:\/\/[^/]+)(.*)/);
if (match) {
Expand Down Expand Up @@ -2667,12 +2668,12 @@ class WebLib {
sPost += p + '=' + encodeURIComponent(type[p]);
}
sPost = sPost.replace(/%20/g, '+');
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "posting: %s (%d bytes)\n", sURL, sPost.length);
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "getResource.post(%s): %d bytes\n", sURL, sPost.length);
request.open("POST", sURL, fAsync);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.send(sPost);
} else {
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "requesting: %s\n", sURL);
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "getResource.get(%s)\n", sURL);
request.open("GET", sURL, fAsync);
if (type == "arraybuffer") {
if (fXHR2) {
Expand Down
10 changes: 5 additions & 5 deletions machines/dec/pdp10/releases/2.21/pdp10.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion machines/dec/pdp10/releases/2.21/pdp10.js.map

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions machines/dec/pdp11/releases/2.21/pdp11-uncompiled.js
Original file line number Diff line number Diff line change
Expand Up @@ -2757,13 +2757,14 @@ class WebLib {
sURL = sURL.replace(/^\/(disks\/|)(diskettes|gamedisks|miscdisks|harddisks|decdisks|pcsigdisks|pcsig[0-9a-z]*-disks|private)\//, "https://$2.pcjs.org/").replace(/^\/(disks\/cdroms|discs)\/([^/]*)\//, "https://$2.pcjs.org/");
}

Component.printf(MESSAGE.DEBUG, "getResource(%s)\n", sURL);

/*
* globals.node.readFileSync exists only when another module has import filelib.js, which means we're
* running under Node.js, and we can use Node's file system to read local files. Note that filelib.js only
* offers readFileSync() at the moment.
*/
if (globals.node.readFileSync && sURL.indexOf("http") != 0) {
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "reading: %s\n", sURL);
try {
let encoding = (type == "arraybuffer"? null : "utf8");
resource = globals.node.readFileSync(sURL, encoding);
Expand Down Expand Up @@ -2810,7 +2811,7 @@ class WebLib {
} else if (globals.window.ActiveXObject) {
request = new globals.window.ActiveXObject("Microsoft.XMLHTTP");
} else if (globals.window.fetch) {
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "fetching: %s\n", sURL);
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "getResource.fetch(%s)\n", sURL);
fetch(sURL)
.then(response => {
switch(type) {
Expand All @@ -2824,19 +2825,19 @@ class WebLib {
}
})
.then(resource => {
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "fetch %s complete: %d bytes\n", sURL, resource.length);
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "getResource.fetch(%s): %d bytes\n", sURL, resource.length);
if (done) done(sURL, resource, nErrorCode);
})
.catch(error => {
Component.printf(MESSAGE.LOG, "fetch %s error: %d\n", sURL, nErrorCode);
Component.printf(MESSAGE.LOG, "getResource.fetch(%s) error: %d\n", sURL, nErrorCode);
if (done) done(sURL, resource, nErrorCode);
});
return response;
}

let fArrayBuffer = false, fXHR2 = (typeof request.responseType === 'string');

let callback = function() {
let callback = function getResourceDone() {
if (request.readyState !== 4) {
if (progress) progress(1);
return null;
Expand Down Expand Up @@ -2867,18 +2868,18 @@ class WebLib {
try {
resource = fArrayBuffer? request.response : request.responseText;
} catch(err) {
Component.printf(MESSAGE.LOG, "xmlHTTPRequest(%s) exception: %s\n", sURL, err.message);
Component.printf(MESSAGE.LOG, "getResource.done(%s) exception: %s\n", sURL, err.message);
}
/*
* The normal "success" case is a non-null resource and an HTTP status code of 200, but when loading files from the
* local file system (ie, when using the "file:" protocol), we have to be a bit more flexible.
*/
if (resource != null && (request.status == 200 || !request.status && resource.length && WebLib.getHostProtocol() == "file:")) {
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "xmlHTTPRequest(%s): returned %d bytes\n", sURL, resource.length);
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "getResource.done(%s): %d bytes\n", sURL, resource.length);
}
else {
nErrorCode = request.status || -1;
Component.printf(MESSAGE.LOG, "xmlHTTPRequest(%s) returned error %d\n", sURL, nErrorCode);
Component.printf(MESSAGE.DEBUG, "getResource.done(%s) error: %d\n", sURL, nErrorCode);
if (!request.status && !WebLib.fAdBlockerWarning) {
let match = sURL.match(/(^https?:\/\/[^/]+)(.*)/);
if (match) {
Expand Down Expand Up @@ -2906,12 +2907,12 @@ class WebLib {
sPost += p + '=' + encodeURIComponent(type[p]);
}
sPost = sPost.replace(/%20/g, '+');
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "posting: %s (%d bytes)\n", sURL, sPost.length);
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "getResource.post(%s): %d bytes\n", sURL, sPost.length);
request.open("POST", sURL, fAsync);
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
request.send(sPost);
} else {
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "requesting: %s\n", sURL);
Component.printf(MESSAGE.DEBUG + MESSAGE.LOG, "getResource.get(%s)\n", sURL);
request.open("GET", sURL, fAsync);
if (type == "arraybuffer") {
if (fXHR2) {
Expand Down
Loading

0 comments on commit c76b9af

Please sign in to comment.