From 1b9350f86f0f85875d053a805c21b59f60ed0eeb Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Fri, 5 Feb 2016 16:19:49 -0800 Subject: [PATCH] Speed up page load times by "compiling" the disk library manifests --- Gruntfile.js | 50 +- .../5150/cga/384kb/softkbd/machine.xml | 2 +- .../5160/cga/256kb/softkbd/machine.xml | 2 +- .../cga/256kb/win101/debugger/machine.xml | 2 +- .../5160/cga/256kb/win101/softkbd/machine.xml | 2 +- .../5160/cga/640kb/debugger/machine.xml | 2 +- .../5160/cga/640kb/dos400m/machine.xml | 2 +- devices/pc/machine/5160/cga/640kb/machine.xml | 2 +- .../5160/ega/256kb/debugger/machine.xml | 2 +- .../machine/5160/ega/640kb/array/machine.xml | 2 +- .../5160/ega/640kb/debugger/machine.xml | 2 +- devices/pc/machine/5160/ega/640kb/machine.xml | 2 +- .../ega/640kb/win101/debugger/machine.xml | 2 +- .../machine/5160/ega/640kb/win101/machine.xml | 2 +- .../5160/mda/256kb/debugger/machine.xml | 2 +- devices/pc/machine/5160/mda/256kb/machine.xml | 2 +- .../5170/ega/1152kb/rev1/debugger/machine.xml | 2 +- .../rev3/debugger/backtrack/machine.xml | 2 +- .../5170/ega/640kb/rev1/debugger/machine.xml | 2 +- .../machine/5170/ega/640kb/rev1/machine.xml | 2 +- .../compaq/deskpro386/ega/2048kb/machine.xml | 2 +- .../compaq/deskpro386/ega/4096kb/machine.xml | 2 +- .../deskpro386/other/2048kb/machine.xml | 2 +- .../compaq/deskpro386/vga/2048kb/machine.xml | 2 +- .../compaq/deskpro386/vga/4096kb/machine.xml | 2 +- disks/pc/compiled/library.xml | 434 ++++++++++++++++++ disks/pc/compiled/samples.xml | 16 + disks/pc/os2/ibm/1.0/machine.xml | 2 +- disks/pc/os2/misc/README.md | 22 +- disks/pc/os2/misc/football/87058/README.md | 2 +- docs/pcjs/demos/components.xsl | 8 +- docs/pcjs/demos/pc-dbg.js | 56 +-- docs/pcjs/demos/pc.js | 168 +++---- modules/pcjs/lib/debugger.js | 10 +- versions/c1pjs/1.20.8/c1p-dbg.js | 6 +- versions/c1pjs/1.20.8/c1p.js | 6 +- versions/pcjs/1.20.8/components.xsl | 8 +- versions/pcjs/1.20.8/pc-dbg.js | 56 +-- versions/pcjs/1.20.8/pc.js | 168 +++---- 39 files changed, 785 insertions(+), 275 deletions(-) create mode 100644 disks/pc/compiled/library.xml create mode 100644 disks/pc/compiled/samples.xml diff --git a/Gruntfile.js b/Gruntfile.js index 956971e76..97fa3d1b6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -312,7 +312,7 @@ module.exports = function(grunt) { "c1pxsl": { files: [ { - cwd: "./modules/shared/templates/", + cwd: "modules/shared/templates/", src: ["common.css", "common.xsl", "document.css", "document.xsl", "machine.xsl", "manifest.xsl", "outline.xsl"], dest: "versions/c1pjs/<%= pkg.version %>/", expand: true @@ -330,7 +330,7 @@ module.exports = function(grunt) { "pcxsl": { files: [ { - cwd: "./modules/shared/templates/", + cwd: "modules/shared/templates/", src: ["common.css", "common.xsl", "document.css", "document.xsl", "machine.xsl", "manifest.xsl", "outline.xsl"], dest: "versions/pcjs/<%= pkg.version %>/", expand: true @@ -348,7 +348,7 @@ module.exports = function(grunt) { "c1pjs": { files: [ { - cwd: "./modules/c1pjs/templates/", + cwd: "modules/c1pjs/templates/", src: ["components.*"], dest: "versions/c1pjs/<%= pkg.version %>/", expand: true @@ -365,7 +365,7 @@ module.exports = function(grunt) { "pcjs": { files: [ { - cwd: "./modules/pcjs/templates/", + cwd: "modules/pcjs/templates/", src: ["components.*"], dest: "versions/pcjs/<%= pkg.version %>/", expand: true @@ -393,6 +393,48 @@ module.exports = function(grunt) { return content.replace(/\/versions\/\{\$APPCLASS}\/\{\$APPVERSION}\//g, ""); } } + }, + "manifests": { + files: [ + { + cwd: "disks/pc/", + src: ["library.xml", "samples.xml"], + dest: "disks/pc/compiled/", + expand: true + } + ], + options: { + process: function(content, srcPath) { + var contentOrig = content; + var reManifest = /([ \t]*)/g, matchManifest; + while ((matchManifest = reManifest.exec(contentOrig))) { + var sManifest = grunt.file.read(path.join('.', matchManifest[2])); + if (!sManifest) continue; + var sDefaultName = "", match; + match = sManifest.match(/(.*?)<\/title>/); + if (match) { + sDefaultName = match[1]; + match = sManifest.match(/(.*?)<\/version>/); + if (match) sDefaultName += ' ' + match[1]; + } + var reDisk, matchDisk, sDisks = ""; + reDisk = //g; + while ((matchDisk = reDisk.exec(sManifest))) { + if (sDisks) sDisks += "\n"; + sDisks += matchManifest[1] + "" + sDefaultName + ""; + } + reDisk = /([\S\s]*?)<\/disk>/g; + while ((matchDisk = reDisk.exec(sManifest))) { + if (sDisks) sDisks += "\n"; + var matchName = matchDisk[2].match(/(.*?)<\/name>/); + var sName = matchName && matchName[1] || sDefaultName; + sDisks += matchManifest[1] + "" + sName + ""; + } + content = content.replace(matchManifest[0], sDisks); + } + return content; + } + } } }, run: { diff --git a/devices/pc/machine/5150/cga/384kb/softkbd/machine.xml b/devices/pc/machine/5150/cga/384kb/softkbd/machine.xml index 7e3ad6baf..d5c3c3e4a 100644 --- a/devices/pc/machine/5150/cga/384kb/softkbd/machine.xml +++ b/devices/pc/machine/5150/cga/384kb/softkbd/machine.xml @@ -11,7 +11,7 @@