crossplatform optimisation
This commit is contained in:
parent
b52b157eff
commit
7f5d84ee5e
11 changed files with 109 additions and 22 deletions
|
|
@ -61,6 +61,8 @@ Archive: result/bin/xrforge.com
|
|||
|
||||
> Profit! you have aqcuired the sourcecode from the binary: run and distribute modified versions if needed ♥
|
||||
|
||||
**NOTE**: if the binary does not work on your server, use [xrforge-x86_64]() from the releases section instead.
|
||||
|
||||
## Adding content
|
||||
|
||||
First you need a directory with glTF or JanusXR experiences.<br>
|
||||
|
|
@ -167,6 +169,10 @@ Then run with debug flag to see output of `trace()` calls
|
|||
$ DEBUG=1 result/bin/xrforge.com
|
||||
```
|
||||
|
||||
> Testing: run the builtin testrunner: `cd src && ../result/bin/xrforge.com test`
|
||||
|
||||
Use `ARCH=x86_64 build` to enforce x86_64 output (instead of a cosmopolitan binary)
|
||||
|
||||
## Permacomputing Spirit
|
||||
|
||||
* developed on [Dillo](https://dillo-browser.github.io/) as lowest common denominator / compatibility
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
package.path = package.path .. ";.lua/?.lua"
|
||||
package.path = package.path .. ";/zip/?.lua"
|
||||
package.path = package.path .. ";src/.lua/?.lua"
|
||||
package.path = package.path .. ";middleware/?.lua"
|
||||
package.path = package.path .. ";cmd/?.lua"
|
||||
package.path = package.path .. ";plugin/?.lua"
|
||||
package.path = package.path .. ";.lua/?.lua;/zip/.lua/?.lua"
|
||||
package.path = package.path .. ";middleware/?.lua;/zip/middleware/?.lua"
|
||||
package.path = package.path .. ";cmd/?.lua;/zip/cmd/?.lua"
|
||||
package.path = package.path .. ";plugin/?.lua;/zip/plugin/?.lua"
|
||||
|
||||
util = require "util"
|
||||
json = require "json"
|
||||
|
|
@ -14,7 +15,7 @@ HidePath('/usr/share/ssl/')
|
|||
-- create
|
||||
app = require("soakbean") {
|
||||
bin = "./xrforge.com",
|
||||
bindir = arg[-1]:gsub("xrforge.com",""),
|
||||
bindir = arg[-1]:gsub("/[a-zA-Z0-9-_ ]+.com$","/"),
|
||||
cache = { items = {}, url = {} },
|
||||
plugin = {},
|
||||
opts = {},
|
||||
|
|
@ -116,7 +117,3 @@ end
|
|||
OnServerStart = function()
|
||||
app.init() -- this triggers init event
|
||||
end
|
||||
|
||||
OnServerStop = function()
|
||||
print("todo: kill threads")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -52,6 +52,14 @@ function pluginInput(opt)
|
|||
return html
|
||||
end
|
||||
|
||||
app.on('set', function(k,v) -- clear url cache
|
||||
if k:match("app.opts") then -- after (admin) updates to app.opts.*
|
||||
foreach( app.cache.url, function(k,v)
|
||||
app.cache.url = nil
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
function pluginUI(seen,data)
|
||||
return function(name,plugin)
|
||||
if seen[ plugin.name ] then return end -- already processed
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
{if true then
|
||||
showfediportals = app.opts.plugin_federation_strategy == 'always' or
|
||||
(app.opts.plugin_federation_strategy == 'homepage' and urlpath == '/')
|
||||
end}
|
||||
|
||||
|
||||
<fireboxroom>
|
||||
<assets>
|
||||
<assetshader id="xrforgeportal" src="${opts.baseurl}shader/xrforgeportal.shadertoy.frag" shadertype="shadertoy"></assetshader>
|
||||
|
|
@ -6,12 +12,14 @@
|
|||
print('\t<assetimage src="' .. v.thumbnail .. '" id="img' .. i .. '"/>')
|
||||
end
|
||||
end}
|
||||
{for i=1,5 do
|
||||
local urls = app.opts[ 'plugin_federation_url_' .. i]
|
||||
if #urls > 0 then
|
||||
local fediurl = urls:gsub(' .*','')
|
||||
local thumburl = urls:gsub('.* ','')
|
||||
print('\t<assetimage src="' .. thumburl .. '" id="federated' .. i .. '"/>')
|
||||
{if showfediportals then
|
||||
for i=1,5 do
|
||||
local urls = app.opts[ 'plugin_federation_url_' .. i]
|
||||
if #urls > 0 then
|
||||
local fediurl = urls:gsub(' .*','')
|
||||
local thumburl = urls:gsub('.* ','')
|
||||
print('\t<assetimage src="' .. thumburl .. '" id="federated' .. i .. '"/>')
|
||||
end
|
||||
end
|
||||
end}
|
||||
</assets>
|
||||
|
|
@ -49,7 +57,7 @@
|
|||
addPortal('dir',center, v, url,i, -4, 'img', '0 0 0', '0.2 0.2 0.2')
|
||||
end
|
||||
end}
|
||||
{if not item then
|
||||
{if showfediportals and not item then
|
||||
local portals = {}
|
||||
for i=1,5 do
|
||||
local urls = app.opts[ 'plugin_federation_url_' .. i]
|
||||
|
|
|
|||
|
|
@ -113,15 +113,14 @@ local plugin = {
|
|||
getRandomRoom = function()
|
||||
local me = app.plugin.janusxr
|
||||
local room= ''
|
||||
math.randomseed(os.time())
|
||||
foreach( me.opts, function(k,v)
|
||||
print(v.key)
|
||||
if v.key == 'app.opts.plugin_janusxr_portalroom' then
|
||||
local ordered = {}
|
||||
foreach( v.values, function(k,v) table.insert(ordered,v) end)
|
||||
room = ordered[ math.random( #ordered ) ]
|
||||
end
|
||||
end)
|
||||
print("ROOM = " .. room)
|
||||
return room
|
||||
end
|
||||
}
|
||||
|
|
|
|||
10
src/test/cheatsheet.txt
Normal file
10
src/test/cheatsheet.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
expect(...).to.exist()
|
||||
expect(...).to.be.truthy()
|
||||
expect(...).to.be.falsy()
|
||||
expect(...).to.be(...)
|
||||
expect(...).to.equal(...)
|
||||
expect(...).to.approximately.equal(...)
|
||||
expect(...).to.approximately(eps).equal(...)
|
||||
expect(t).to.have(val)
|
||||
expect(f).to.fail(pattern?)
|
||||
expect(x).to_not.*
|
||||
|
|
@ -3,6 +3,7 @@ local describe, it, expect = lust.describe, lust.it, lust.expect
|
|||
-- usage: https://github.com/bjornbytes/lust
|
||||
|
||||
require('test/plugin_diskscan')(lust)
|
||||
require('test/plugin_xrfragment')(lust)
|
||||
|
||||
if lust.errors == 0 then
|
||||
print("✅ all tests passed")
|
||||
|
|
|
|||
|
|
@ -21,4 +21,23 @@ return function(lust)
|
|||
|
||||
end)
|
||||
|
||||
describe('src/plugin/diskscan.lua (e2e)', function()
|
||||
|
||||
describe('ℹ️ scan_experience', function() -- Can be nested
|
||||
|
||||
local dirs = 0
|
||||
|
||||
app.on('scan_experience', function(exp)
|
||||
if exp.dir then dirs = dirs +1 end
|
||||
end)
|
||||
|
||||
it('on init', function()
|
||||
app.init()
|
||||
expect(dirs > 0).to.be.truthy()
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
|
|
|||
30
src/test/plugin_xrfragment.lua
Normal file
30
src/test/plugin_xrfragment.lua
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
return function(lust)
|
||||
|
||||
|
||||
local describe, it, expect = lust.describe, lust.it, lust.expect
|
||||
|
||||
describe('src/plugin/xrfragments.lua', function()
|
||||
|
||||
describe('ℹ️ detect sidecarfiles', function() -- Can be nested
|
||||
|
||||
local sidecarfile = {}
|
||||
|
||||
it('on init', function()
|
||||
app.init()
|
||||
foreach(app.cache.items, function(k,exp)
|
||||
if exp.sidecarfile then
|
||||
foreach( {"png","vtt","ogg","json"}, function(k,ext)
|
||||
if exp.sidecarfile[k] then sidecarfile[ext] = true end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
print_r(sidecarfile)
|
||||
expect( (sidecarfile.png ~= nil) ).to.be.truthy()
|
||||
expect( (sidecarfile.vtt ~= nil) ).to.be.truthy()
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
|
||||
end
|
||||
|
|
@ -12,11 +12,21 @@ download(){
|
|||
verify(){
|
||||
echo "$REDBEAN_CRC" > /tmp/checksum
|
||||
sha256sum -c /tmp/checksum || { echo "psuedosecurity checksum failed"; exit 1; }
|
||||
chmod +x $OUTDIR/xrforge.com
|
||||
}
|
||||
test -f /tmp/xrforge.com || wget --no-check-certificate "$REDBEAN_URL" -O /tmp/xrforge.com
|
||||
test -f /tmp/xrforge.com || {
|
||||
wget --no-check-certificate "$REDBEAN_URL" -O /tmp/xrforge.com
|
||||
}
|
||||
cp /tmp/xrforge.com $OUTDIR/xrforge.com
|
||||
verify
|
||||
test -n "$ARCH" && {
|
||||
test -f /tmp/assimilate || {
|
||||
wget https://cosmo.zip/pub/cosmos/bin/assimilate-x86_64.elf -O /tmp/assimilate
|
||||
chmod +x /tmp/assimilate
|
||||
}
|
||||
rm $OUTDIR/*.bak || true
|
||||
/tmp/assimilate $OUTDIR/xrforge.com
|
||||
}
|
||||
chmod +x $OUTDIR/*.com
|
||||
#verify
|
||||
}
|
||||
|
||||
janusweb(){
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
../result/bin/xrforge.lua
|
||||
Loading…
Add table
Reference in a new issue