Closed bnolan closed 9 years ago
Working on this. Using glob to find all .xml files to serve. I want to start catching some user script errors to prevent the node process going down when <script />
blocks cause uncaught errors. Might want to wrap setInterval and setTimeout so that they can't raise errors.
Totally using a document singleton (and I don't know how to make copies of Documents at the moment). I'll write a test, and once that's fixed we should be a lot closer.
Got this spec:
describe 'compartmentalization', ->
xml1 = "<scene><script>document.foo = 'bar';</script></scene>"
xml2 = "<scene><script>console.dump(document.foo)</script></scene>"
it 'should have seperate document instances', ->
dumped = {}
console.dump = (obj) ->
console.log JSON.stringify(obj)
dumped = obj
Scene.load xml1, (scene1) ->
Scene.load xml2, (scene2) ->
expect(dumped).toBeNull()
Fails at the moment. Once I get this (and the rest of the suite) passing we should be most of the way there.
All the specs pass woo! I've refactored so that scene
isn't exported as a global, you need to use document.scene
, which means I have to fix all the sample scenes. Also, the 'ready' event is fired on document, modelleted on domcontentloaded.
:+1:
Handling exceptions in the parsing the scene now. The line numbers are wrong though, since we don't keep track of the line number of the start of the script block when we parse the xml. See issue #22.
[server] ./scenes/click_to_divide.xml
ReferenceError: scene is not defined
at ./scenes/click_to_divide.xml:23:5
Got pretty close in fc79e0d, but scripts aren't running properly now. Will try and get this sorted tonight.
Okay everything works on bbe7e9e8eef9f28f7944fc2def08e2d87e0716fe. I'm gonna call that working, and ship it. Opening a new issue to kill intervals and timeouts when calling scene#stop, see #24.
I started work on this in the
multi
branch, and it sort of works for static scenes, but due to thedocument
global, I don't think it'll work for scenes with scripts. Refactor how we use document, so that when the scripts are eval'd - there is a unique scene and document object in the scope. The branch also doesn't automatically serve every file in the directory, nor does it successfully restart on scene change. Fix these and it should be good to merge.