Merged world/lodash/aether breakup for world workers.

This commit is contained in:
Nick Winter 2014-05-10 18:52:55 -07:00
commit 8df3b01f9e
14 changed files with 29 additions and 22 deletions

View file

@ -1,7 +1,7 @@
var window = self; var window = self;
var Global = self; var Global = self;
importScripts("/javascripts/tome_aether.js"); importScripts("/javascripts/lodash.js", "/javascripts/aether.js");
console.log("imported scripts!"); console.log("imported scripts!");
var aethers = {}; var aethers = {};

View file

@ -58,7 +58,7 @@ var console = {
console.error = console.warn = console.info = console.debug = console.log; console.error = console.warn = console.info = console.debug = console.log;
self.console = console; self.console = console;
self.importScripts('/javascripts/world.js'); self.importScripts('/javascripts/world.js', '/javascripts/lodash.js', '/javascripts/aether.js');
// We could do way more from this: http://stackoverflow.com/questions/10653809/making-webworkers-a-safe-environment // We could do way more from this: http://stackoverflow.com/questions/10653809/making-webworkers-a-safe-environment
Object.defineProperty(self, "XMLHttpRequest", { Object.defineProperty(self, "XMLHttpRequest", {

View file

@ -34,6 +34,7 @@
<script src="/lib/ace/ace.js"></script> <script src="/lib/ace/ace.js"></script>
<!--[if IE 9]> <script src="/javascripts/vendor_with_box2d.js"></script> <![endif]--> <!--[if IE 9]> <script src="/javascripts/vendor_with_box2d.js"></script> <![endif]-->
<!--[if !IE]><!--> <script src="/javascripts/vendor.js"></script> <!--<![endif]--> <!--[if !IE]><!--> <script src="/javascripts/vendor.js"></script> <!--<![endif]-->
<script src="/javascripts/aether.js"></script>
<script src="/javascripts/app.js"></script> <!-- it's all Backbone! --> <script src="/javascripts/app.js"></script> <!-- it's all Backbone! -->
<script> <script>

View file

@ -33,7 +33,7 @@ module.exports = class RegionChooser extends CocoClass
@options.camera.dragDisabled = false @options.camera.dragDisabled = false
restrictRegion: -> restrictRegion: ->
RATIO = 1.56876 # 1848 / 1178 RATIO = 1.56876 # 924 / 589
rect = @options.camera.normalizeBounds([@firstPoint, @secondPoint]) rect = @options.camera.normalizeBounds([@firstPoint, @secondPoint])
currentRatio = rect.width / rect.height currentRatio = rect.width / rect.height
if currentRatio > RATIO if currentRatio > RATIO

View file

@ -27,7 +27,7 @@ block modal-body-content
div.alert.alert-info div.alert.alert-info
strong Enter strong Enter
| to confirm | to confirm
canvas(width=1848, height=1178) canvas(width=924, height=589)
block modal-footer-content block modal-footer-content
a.btn.btn-primary#done-button Done a.btn.btn-primary#done-button Done

View file

@ -27,7 +27,7 @@ button.navbar-toggle.toggle.btn-primary#thangs-palette-toggle(type="button", dat
a(data-i18n="editor.delete") Delete a(data-i18n="editor.delete") Delete
li#duplicate li#duplicate
a(data-i18n="editor.duplicate") Duplicate a(data-i18n="editor.duplicate") Duplicate
canvas(width=1848, height=1178)#surface canvas(width=924, height=589)#surface
#canvas-left-gradient.gradient #canvas-left-gradient.gradient
#canvas-top-gradient.gradient #canvas-top-gradient.gradient

View file

@ -8,7 +8,7 @@
#tome-view #tome-view
#canvas-wrapper #canvas-wrapper
canvas(width=1848, height=1178)#surface canvas(width=924, height=589)#surface
#canvas-left-gradient.gradient #canvas-left-gradient.gradient
#canvas-top-gradient.gradient #canvas-top-gradient.gradient

View file

@ -3,7 +3,7 @@
.level-content .level-content
#control-bar-view #control-bar-view
#canvas-wrapper #canvas-wrapper
canvas(width=1848, height=1178)#surface canvas(width=924, height=589)#surface
#canvas-left-gradient.gradient #canvas-left-gradient.gradient
#canvas-top-gradient.gradient #canvas-top-gradient.gradient
#gold-view.secret.expanded #gold-view.secret.expanded

View file

@ -78,8 +78,8 @@ module.exports = class WorldSelectModal extends View
showZoomRegion: -> showZoomRegion: ->
d = @defaultFromZoom d = @defaultFromZoom
canvasWidth = 1848 # Dimensions for canvas player. Need these somewhere. canvasWidth = 924 # Dimensions for canvas player. Need these somewhere.
canvasHeight = 1178 canvasHeight = 589
dimensions = {x: canvasWidth/d.zoom, y: canvasHeight/d.zoom} dimensions = {x: canvasWidth/d.zoom, y: canvasHeight/d.zoom}
dimensions = @surface.camera.surfaceToWorld(dimensions) dimensions = @surface.camera.surfaceToWorld(dimensions)
width = dimensions.x width = dimensions.x

View file

@ -3,7 +3,7 @@ ThangType = require '/models/ThangType'
makeButton = -> $('<a class="btn btn-primary btn-xs treema-map-button"><span class="glyphicon glyphicon-screenshot"></span></a>') makeButton = -> $('<a class="btn btn-primary btn-xs treema-map-button"><span class="glyphicon glyphicon-screenshot"></span></a>')
shorten = (f) -> parseFloat(f.toFixed(1)) shorten = (f) -> parseFloat(f.toFixed(1))
WIDTH = 1848 WIDTH = 924
module.exports.WorldPointNode = class WorldPointNode extends TreemaNode.nodeMap.point2d module.exports.WorldPointNode = class WorldPointNode extends TreemaNode.nodeMap.point2d
constructor: (args...) -> constructor: (args...) ->

View file

@ -22,24 +22,24 @@ exports.config =
|(app[\/\\]lib[\/\\]utils.coffee) |(app[\/\\]lib[\/\\]utils.coffee)
|(vendor[\/\\]scripts[\/\\]Box2dWeb-2.1.a.3) |(vendor[\/\\]scripts[\/\\]Box2dWeb-2.1.a.3)
|(vendor[\/\\]scripts[\/\\]string_score.js) |(vendor[\/\\]scripts[\/\\]string_score.js)
|(bower_components[\/\\]lodash[\/\\]dist[\/\\]lodash.js)
|(bower_components[\/\\]aether[\/\\]build[\/\\]aether.js)
)/// )///
'javascripts/app.js': /^app/ 'javascripts/app.js': /^app/
'javascripts/vendor.js': ///^( 'javascripts/vendor.js': ///^(
vendor[\/\\](?!scripts[\/\\]Box2d) vendor[\/\\](?!scripts[\/\\]Box2d)
|bower_components |bower_components[\/\\](?!aether)
)/// )///
'javascripts/vendor_with_box2d.js': ///^( 'javascripts/vendor_with_box2d.js': ///^(
vendor[\/\\] vendor[\/\\]
|bower_components # include box2dweb for profiling (and for IE9...) |bower_components[\/\\](?!aether) # include box2dweb for profiling (and for IE9...)
)/// )///
'javascripts/tome_aether.js': ///^( 'javascripts/lodash.js': ///^(
(bower_components[\/\\]lodash[\/\\]dist[\/\\]lodash.js) (bower_components[\/\\]lodash[\/\\]dist[\/\\]lodash.js)
|(bower_components[\/\\]aether[\/\\]build[\/\\]aether.js)
)/// )///
'test/javascripts/test.js': /^test[\/\\](?!vendor)/ 'javascripts/aether.js': ///^(
'test/javascripts/test-vendor.js': /^test[\/\\](?=vendor)/ (bower_components[\/\\]aether[\/\\]build[\/\\]aether.js)
)///
# 'test/javascripts/test.js': /^test[\/\\](?!vendor)/
# 'test/javascripts/test-vendor.js': /^test[\/\\](?=vendor)/
order: order:
before: [ before: [
'bower_components/jquery/dist/jquery.js' 'bower_components/jquery/dist/jquery.js'

View file

@ -4,6 +4,8 @@
JASON = require 'jason' JASON = require 'jason'
fs = require 'fs' fs = require 'fs'
GLOBAL.Aether = Aether = require 'aether'
GLOBAL._ = _ = require 'lodash'
betterConsole = () -> betterConsole = () ->
@ -172,8 +174,9 @@ work = () ->
self.postMessage type: "worker-initialized" self.postMessage type: "worker-initialized"
world = fs.readFileSync "./public/javascripts/world.js", 'utf8' worldCode = fs.readFileSync "./public/javascripts/world.js", 'utf8'
lodashCode = fs.readFileSync "./public/javascripts/lodash.js", 'utf8'
aetherCode = fs.readFileSync "./public/javascripts/aether.js", 'utf8'
#window.BOX2D_ENABLED = true; #window.BOX2D_ENABLED = true;
@ -190,7 +193,9 @@ ret = """
try { try {
// the world javascript file // the world javascript file
#{world}; #{worldCode};
#{lodashCode};
#{aetherCode};
// Don't let user generated code access stuff from our file system! // Don't let user generated code access stuff from our file system!
self.importScripts = importScripts = null; self.importScripts = importScripts = null;

View file

@ -47,7 +47,7 @@
"mongoose-text-search": "~0.0.2", "mongoose-text-search": "~0.0.2",
"request": "2.12.x", "request": "2.12.x",
"tv4": "~1.0.16", "tv4": "~1.0.16",
"lodash": "~2.0.0", "lodash": "~2.4.1",
"underscore.string": "2.3.x", "underscore.string": "2.3.x",
"async": "0.2.x", "async": "0.2.x",
"connect": "2.7.x", "connect": "2.7.x",

View file

@ -107,6 +107,7 @@ module.exports.setup = (app) ->
else else
return res.end() return res.end()
else else
console.log 'password is', user.get('passwordReset')
res.send user.get('passwordReset') res.send user.get('passwordReset')
return res.end() return res.end()
) )