Web UI for ARGUS server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.8 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
  3. * http://paperjs.org/
  4. *
  5. * Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
  6. * http://juerglehni.com/ & https://puckey.studio/
  7. *
  8. * Distributed under the MIT license. See LICENSE file for details.
  9. *
  10. * All rights reserved.
  11. */
  12. // Node.js emulation layer of browser environment, based on jsdom with node-
  13. // canvas integration.
  14. var path = require('path');
  15. // Determine the name by which name the module was required (either 'paper',
  16. // 'paper-jsdom' or 'paper-jsdom-canvas'), and use this to determine if error
  17. // exceptions should be thrown or if loading should fail silently.
  18. var parent = module.parent && module.parent.parent,
  19. requireName = parent && path.basename(path.dirname(parent.filename));
  20. requireName = /^paper/.test(requireName) ? requireName : 'paper';
  21. var jsdom,
  22. self;
  23. try {
  24. jsdom = require('jsdom');
  25. } catch(e) {
  26. // Check the required module's name to see if it contains jsdom, and only
  27. // complain about its lack if the module requires it.
  28. if (/\bjsdom\b/.test(requireName)) {
  29. throw new Error('Unable to load jsdom module.');
  30. }
  31. }
  32. if (jsdom) {
  33. // Create our document and window objects through jsdom.
  34. /* global document:true, window:true */
  35. var document = new jsdom.JSDOM('<html><body></body></html>', {
  36. // Use the current working directory as the document's origin, so
  37. // requests to local files work correctly with CORS.
  38. url: 'file://' + process.cwd() + '/',
  39. resources: 'usable'
  40. });
  41. self = document.window;
  42. require('./canvas.js')(self, requireName);
  43. require('./xml.js')(self);
  44. } else {
  45. self = {
  46. navigator: {
  47. userAgent: 'Node.js (' + process.platform + '; U; rv:' +
  48. process.version + ')'
  49. }
  50. };
  51. }
  52. module.exports = self;