paper 0.12.20 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +318 -0
  2. package/README.md +45 -26
  3. package/dist/docs/assets/js/paper.js +1210 -481
  4. package/dist/docs/classes/ChangeFlag.html +384 -0
  5. package/dist/docs/classes/Color.html +63 -47
  6. package/dist/docs/classes/CompoundPath.html +219 -62
  7. package/dist/docs/classes/Curve.html +9 -7
  8. package/dist/docs/classes/CurveLocation.html +1 -1
  9. package/dist/docs/classes/Event.html +1 -1
  10. package/dist/docs/classes/Gradient.html +1 -1
  11. package/dist/docs/classes/GradientStop.html +1 -1
  12. package/dist/docs/classes/Group.html +151 -27
  13. package/dist/docs/classes/HitResult.html +3 -2
  14. package/dist/docs/classes/HostItem.html +6721 -0
  15. package/dist/docs/classes/Item.html +120 -27
  16. package/dist/docs/classes/Key.html +1 -1
  17. package/dist/docs/classes/KeyEvent.html +1 -1
  18. package/dist/docs/classes/Layer.html +151 -27
  19. package/dist/docs/classes/Matrix.html +1 -1
  20. package/dist/docs/classes/MouseEvent.html +1 -1
  21. package/dist/docs/classes/PaperScope.html +88 -1
  22. package/dist/docs/classes/PaperScript.html +2 -1
  23. package/dist/docs/classes/Path.html +232 -72
  24. package/dist/docs/classes/PathItem.html +337 -180
  25. package/dist/docs/classes/Point.html +143 -21
  26. package/dist/docs/classes/PointText.html +151 -27
  27. package/dist/docs/classes/Project.html +201 -8
  28. package/dist/docs/classes/Raster.html +150 -38
  29. package/dist/docs/classes/Rectangle.html +12 -11
  30. package/dist/docs/classes/Segment.html +1 -1
  31. package/dist/docs/classes/Shape.html +120 -27
  32. package/dist/docs/classes/Size.html +81 -21
  33. package/dist/docs/classes/Style.html +35 -3
  34. package/dist/docs/classes/SymbolDefinition.html +1 -1
  35. package/dist/docs/classes/SymbolItem.html +121 -28
  36. package/dist/docs/classes/TextItem.html +151 -27
  37. package/dist/docs/classes/Tool.html +127 -1
  38. package/dist/docs/classes/ToolEvent.html +27 -1
  39. package/dist/docs/classes/Tween.html +1 -1
  40. package/dist/docs/classes/View.html +345 -10
  41. package/dist/docs/classes/global.html +1 -1
  42. package/dist/docs/classes/index.html +2 -2
  43. package/dist/docs/index.html +1 -1
  44. package/dist/node/canvas.js +1 -1
  45. package/dist/node/self.js +4 -3
  46. package/dist/paper-core.js +1182 -465
  47. package/dist/paper-core.min.js +3 -3
  48. package/dist/paper-full.js +1210 -481
  49. package/dist/paper-full.min.js +3 -3
  50. package/dist/paper-sourced.js +18631 -0
  51. package/dist/paper.d.ts +606 -78
  52. package/examples/Rasters/Smoothing.html +1 -1
  53. package/package.json +6 -17
  54. package/dist/node/xml.js +0 -40
@@ -16,6 +16,8 @@
16
16
  <h1>View</h1>
17
17
 
18
18
  <p>The View object wraps an HTML element and handles drawing and user interaction through mouse and keyboard for it. It offer means to scroll the view, find the currently visible bounds in project coordinates, or the center, both useful for constructing artwork that should appear centered on screen.</p>
19
+ <p>If the canvas element has a <code>resize</code> or <code>data-paper-resize</code> attribute, the view adjusts its size to the size of the element whenever the window is resized. The element itself needs to be sized through CSS, e.g. with <code>html, body { height: 100%; }</code> and <code>canvas[resize] { width: 100%; height:
20
+ 100%; }</code> for a canvas that fills the window. Without such CSS, the view does not follow the window, and on HiDPI screens it grows with each resize. Without the attribute, the view sets the element&rsquo;s CSS width and height to its own size, see <a href="../classes/View.html#viewsize"><tt>viewSize</tt></a>.</p>
19
21
 
20
22
  </div>
21
23
 
@@ -76,6 +78,62 @@
76
78
 
77
79
 
78
80
 
81
+ </div>
82
+
83
+ </div>
84
+ </div>
85
+
86
+
87
+ <div id="project" class="member">
88
+ <div class="member-link">
89
+ <a name="project" href="#project"><tt><b>project</b></tt></a>
90
+ </div>
91
+ <div class="member-description hidden">
92
+
93
+ <div class="member-text">
94
+ <p>The project that this view displays.</p>
95
+
96
+ <p>Read only.</p>
97
+
98
+
99
+
100
+ <ul class="member-list">
101
+ <h4>Type:</h4>
102
+ <li>
103
+ <a href="../classes/Project.html"><tt>Project</tt></a>
104
+ </li>
105
+ </ul>
106
+
107
+
108
+
109
+ </div>
110
+
111
+ </div>
112
+ </div>
113
+
114
+
115
+ <div id="scope" class="member">
116
+ <div class="member-link">
117
+ <a name="scope" href="#scope"><tt><b>scope</b></tt></a>
118
+ </div>
119
+ <div class="member-description hidden">
120
+
121
+ <div class="member-text">
122
+ <p>The scope that this view belongs to.</p>
123
+
124
+ <p>Read only.</p>
125
+
126
+
127
+
128
+ <ul class="member-list">
129
+ <h4>Type:</h4>
130
+ <li>
131
+ <a href="../classes/PaperScope.html"><tt>PaperScope</tt></a>
132
+ </li>
133
+ </ul>
134
+
135
+
136
+
79
137
  </div>
80
138
 
81
139
  </div>
@@ -253,7 +311,7 @@
253
311
  <div class="member-description hidden">
254
312
 
255
313
  <div class="member-text">
256
- <p>The view&rsquo;s zoom factor by which the project coordinates are magnified.</p>
314
+ <p>The view&rsquo;s zoom factor by which the project coordinates are magnified. Setting it to a value that isn&rsquo;t a positive number has no effect.</p>
257
315
 
258
316
 
259
317
 
@@ -721,6 +779,97 @@ view.onResize = function(event) {
721
779
  </ul>
722
780
 
723
781
 
782
+ </div>
783
+
784
+ </div>
785
+ </div>
786
+
787
+
788
+ <div id="onkeydown" class="member">
789
+ <div class="member-link">
790
+ <a name="onkeydown" href="#onkeydown"><tt><b>onKeyDown</b></tt></a>
791
+ </div>
792
+ <div class="member-description hidden">
793
+
794
+ <div class="member-text">
795
+ <p>The function to be called when the user presses a key on the keyboard. The function receives a <a href="../classes/KeyEvent.html"><tt>KeyEvent</tt></a> object which contains information about the keyboard event.</p>
796
+ <p>If the function returns <code>false</code>, the keyboard event will be prevented from bubbling up. This can be used for example to stop the window from scrolling, when you need the user to interact with arrow keys.</p>
797
+
798
+
799
+
800
+ <ul class="member-list">
801
+ <h4>Type:</h4>
802
+ <li>
803
+ <tt>Function</tt>⟋<tt>null</tt>
804
+ </li>
805
+ </ul>
806
+
807
+
808
+ <h4>Example:<span class="description">Scaling a path whenever the user presses the space bar:</span></h4>
809
+
810
+ <div class="paperscript split">
811
+
812
+ <div class="buttons">
813
+ <div class="button run">Run</div>
814
+ </div>
815
+
816
+ <script type="text/paperscript" canvas="canvas-1">
817
+ // Create a circle shaped path:
818
+ var path = new Path.Circle({
819
+ center: new Point(50, 50),
820
+ radius: 30,
821
+ fillColor: 'red'
822
+ });
823
+
824
+ view.onKeyDown = function(event) {
825
+ if (event.key == 'space') {
826
+ // Scale the path by 110%:
827
+ path.scale(1.1);
828
+
829
+ // Prevent the key event from bubbling
830
+ return false;
831
+ }
832
+ }
833
+ </script>
834
+ <div class="canvas"><canvas width="516" height="100" id="canvas-1"></canvas></div>
835
+ </div>
836
+
837
+
838
+ </div>
839
+
840
+ </div>
841
+ </div>
842
+
843
+
844
+ <div id="onkeyup" class="member">
845
+ <div class="member-link">
846
+ <a name="onkeyup" href="#onkeyup"><tt><b>onKeyUp</b></tt></a>
847
+ </div>
848
+ <div class="member-description hidden">
849
+
850
+ <div class="member-text">
851
+ <p>The function to be called when the user releases a key on the keyboard. The function receives a <a href="../classes/KeyEvent.html"><tt>KeyEvent</tt></a> object which contains information about the keyboard event.</p>
852
+ <p>If the function returns <code>false</code>, the keyboard event will be prevented from bubbling up. This can be used for example to stop the window from scrolling, when you need the user to interact with arrow keys.</p>
853
+
854
+
855
+
856
+ <ul class="member-list">
857
+ <h4>Type:</h4>
858
+ <li>
859
+ <tt>Function</tt>⟋<tt>null</tt>
860
+ </li>
861
+ </ul>
862
+
863
+
864
+ <h4>Example:</h4>
865
+
866
+
867
+ <pre><code>view.onKeyUp = function(event) {
868
+ if (event.key == 'space') {
869
+ console.log('The spacebar was released!');
870
+ }
871
+ }</code></pre>
872
+
724
873
  </div>
725
874
 
726
875
  </div>
@@ -758,13 +907,25 @@ view.onResize = function(event) {
758
907
 
759
908
  <div id="update" class="member">
760
909
  <div class="member-link">
761
- <a name="update" href="#update"><tt><b>update</b>()</tt></a>
910
+ <a name="update" href="#update"><tt><b>update</b>([force])</tt></a>
762
911
  </div>
763
912
  <div class="member-description hidden">
764
913
  <div class="member-text">
765
- <p>Updates the view if there are changes. Note that when using built-in event hanlders for interaction, animation and load events, this method is invoked for you automatically at the end.</p>
914
+ <p>Updates the view if there are changes. Note that when using built-in event handlers for interaction, animation and load events, this method is invoked for you automatically at the end.</p>
766
915
 
767
916
 
917
+ <ul class="member-list">
918
+ <h4>Parameters:</h4>
919
+
920
+ <li>
921
+ <tt>force:</tt>
922
+ <tt>Boolean</tt>
923
+ &mdash;&nbsp;whether to redraw the view even if nothing has changed, e.g. after a web font used by text items has finished loading
924
+ &mdash;&nbsp;optional, default: <tt>false</tt>
925
+ </li>
926
+
927
+ </ul>
928
+
768
929
 
769
930
  <ul class="member-list">
770
931
  <h4>Returns:</h4>
@@ -1282,6 +1443,66 @@ view.onResize = function(event) {
1282
1443
 
1283
1444
 
1284
1445
 
1446
+ </div>
1447
+ </div>
1448
+ </div>
1449
+
1450
+
1451
+ <div id="fitbounds-rectangle" class="member">
1452
+ <div class="member-link">
1453
+ <a name="fitbounds-rectangle" href="#fitbounds-rectangle"><tt><b>fitBounds</b>(rectangle[, fit])</tt></a>
1454
+ </div>
1455
+ <div class="member-description hidden">
1456
+ <div class="member-text">
1457
+ <p>Transform the view so that the specified rectangle is centered in it and fitted to it as described by <code>fit</code>, keeping the view&rsquo;s rotation and mirroring.</p>
1458
+
1459
+
1460
+ <ul class="member-list">
1461
+ <h4>Parameters:</h4>
1462
+
1463
+ <li>
1464
+ <tt>rectangle:</tt>
1465
+ <a href="../classes/Rectangle.html"><tt>Rectangle</tt></a>
1466
+ &mdash;&nbsp;the rectangle to fit, in project coordinates
1467
+
1468
+ </li>
1469
+
1470
+ <li>
1471
+ <tt>fit:</tt>
1472
+ <tt>String</tt>
1473
+ &mdash;&nbsp;how to fit the rectangle, as in CSS&rsquo;s <code>object-fit</code>: <code>&#39;contain&#39;</code> shows all of it, and <code>&#39;cover&#39;</code> fills the whole view with it, cropping the parts that don&rsquo;t fit
1474
+ &mdash;&nbsp;optional, default: <tt>&lsquo;contain&rsquo;</tt>
1475
+ </li>
1476
+
1477
+ </ul>
1478
+
1479
+
1480
+
1481
+
1482
+
1483
+ <h4>Example:<span class="description">Fitting the view to the bounds of an item:</span></h4>
1484
+
1485
+ <div class="paperscript split">
1486
+
1487
+ <div class="buttons">
1488
+ <div class="button run">Run</div>
1489
+ </div>
1490
+
1491
+ <script type="text/paperscript" canvas="canvas-2">
1492
+ // Create a circle shaped path around the top left corner of the view:
1493
+ var path = new Path.Circle({
1494
+ center: [0, 0],
1495
+ radius: 50,
1496
+ fillColor: 'orange'
1497
+ });
1498
+
1499
+ // Make the view show the whole circle:
1500
+ view.fitBounds(path.bounds);
1501
+ </script>
1502
+ <div class="canvas"><canvas width="516" height="100" id="canvas-2"></canvas></div>
1503
+ </div>
1504
+
1505
+
1285
1506
  </div>
1286
1507
  </div>
1287
1508
  </div>
@@ -1462,7 +1683,7 @@ view.onResize = function(event) {
1462
1683
  <div class="button run">Run</div>
1463
1684
  </div>
1464
1685
 
1465
- <script type="text/paperscript" canvas="canvas-1">
1686
+ <script type="text/paperscript" canvas="canvas-3">
1466
1687
  var path = new Path.Rectangle(new Point(50, 25), new Size(50, 50));
1467
1688
  path.fillColor = 'black';
1468
1689
 
@@ -1473,7 +1694,7 @@ var frameHandler = function(event) {
1473
1694
 
1474
1695
  view.on('frame', frameHandler);
1475
1696
  </script>
1476
- <div class="canvas"><canvas width="516" height="100" id="canvas-1"></canvas></div>
1697
+ <div class="canvas"><canvas width="516" height="100" id="canvas-3"></canvas></div>
1477
1698
  </div>
1478
1699
 
1479
1700
 
@@ -1525,7 +1746,7 @@ view.on('frame', frameHandler);
1525
1746
  <div class="button run">Run</div>
1526
1747
  </div>
1527
1748
 
1528
- <script type="text/paperscript" canvas="canvas-2">
1749
+ <script type="text/paperscript" canvas="canvas-4">
1529
1750
  var path = new Path.Rectangle(new Point(50, 25), new Size(50, 50));
1530
1751
  path.fillColor = 'black';
1531
1752
 
@@ -1538,7 +1759,7 @@ view.on({
1538
1759
  frame: frameHandler
1539
1760
  });
1540
1761
  </script>
1541
- <div class="canvas"><canvas width="516" height="100" id="canvas-2"></canvas></div>
1762
+ <div class="canvas"><canvas width="516" height="100" id="canvas-4"></canvas></div>
1542
1763
  </div>
1543
1764
 
1544
1765
 
@@ -1597,7 +1818,7 @@ view.on({
1597
1818
  <div class="button run">Run</div>
1598
1819
  </div>
1599
1820
 
1600
- <script type="text/paperscript" canvas="canvas-3">
1821
+ <script type="text/paperscript" canvas="canvas-5">
1601
1822
  var path = new Path.Rectangle(new Point(50, 25), new Size(50, 50));
1602
1823
  path.fillColor = 'black';
1603
1824
 
@@ -1616,7 +1837,7 @@ function onMouseDown(event) {
1616
1837
  view.off('frame');
1617
1838
  }
1618
1839
  </script>
1619
- <div class="canvas"><canvas width="516" height="100" id="canvas-3"></canvas></div>
1840
+ <div class="canvas"><canvas width="516" height="100" id="canvas-5"></canvas></div>
1620
1841
  </div>
1621
1842
 
1622
1843
 
@@ -1750,6 +1971,120 @@ function onMouseDown(event) {
1750
1971
 
1751
1972
 
1752
1973
 
1974
+ </div>
1975
+ </div>
1976
+ </div>
1977
+
1978
+
1979
+ <div id="dispatchmouseevent-type-point" class="member">
1980
+ <div class="member-link">
1981
+ <a name="dispatchmouseevent-type-point" href="#dispatchmouseevent-type-point"><tt><b>dispatchMouseEvent</b>(type, point[, options])</tt></a>
1982
+ </div>
1983
+ <div class="member-description hidden">
1984
+ <div class="member-text">
1985
+ <p>Handles a mouse event that the host provides, for hosts without a DOM, such as workers, or with their own event source. It runs the same handling as the DOM&rsquo;s mouse events: the active tool&rsquo;s handlers, with <a href="../classes/Tool.html#mindistance"><tt>tool.minDistance</tt></a> and the like, then those of the items under the point and of the view, including the events that Paper.js derives itself: <code>&#39;mousedrag&#39;</code>, <code>&#39;click&#39;</code>, <code>&#39;doubleclick&#39;</code>, <code>&#39;mouseenter&#39;</code> and <code>&#39;mouseleave&#39;</code>.</p>
1986
+ <ul class="member-list">
1987
+ <h4>Options:</h4>
1988
+ <li>[options.modifiers] {Object} the state of the modifier keys,
1989
+ see {@link Key#modifiers}</li>
1990
+ <li><tt>options.button: <tt>Number</tt></tt> &mdash; the mouse button &mdash;&nbsp;default: <tt>0</tt></li>
1991
+ <li><tt>options.timeStamp: <tt>Number</tt></tt> &mdash; the time stamp &mdash;&nbsp;default: <tt>Date.now()</tt></li>
1992
+ </ul>
1993
+
1994
+ <ul class="member-list">
1995
+ <h4>Parameters:</h4>
1996
+
1997
+ <li>
1998
+ <tt>type:</tt>
1999
+ <tt>String</tt>
2000
+ &mdash;&nbsp;the type of the event: <tt>&lsquo;mousedown&rsquo;</tt>, <tt>&lsquo;mousemove&rsquo;</tt>, <tt>&lsquo;mouseup&rsquo;</tt>
2001
+
2002
+ </li>
2003
+
2004
+ <li>
2005
+ <tt>point:</tt>
2006
+ <a href="../classes/Point.html"><tt>Point</tt></a>
2007
+ &mdash;&nbsp;the location of the mouse in project coordinates
2008
+
2009
+ </li>
2010
+
2011
+ <li>
2012
+ <tt>options:</tt>
2013
+ <tt>Object</tt>
2014
+ &mdash;&nbsp;the details of the event
2015
+ &mdash;&nbsp;optional
2016
+ </li>
2017
+
2018
+ </ul>
2019
+
2020
+
2021
+ <ul class="member-list">
2022
+ <h4>Returns:</h4>
2023
+
2024
+ <li>
2025
+ <tt><tt>Boolean</tt></tt>&nbsp;&mdash;&nbsp;<tt>true</tt> if a handler prevented the event&rsquo;s default, <tt>false</tt> otherwise
2026
+ </li>
2027
+
2028
+
2029
+ </ul>
2030
+
2031
+
2032
+
2033
+
2034
+
2035
+ </div>
2036
+ </div>
2037
+ </div>
2038
+
2039
+
2040
+ <div id="dispatchkeyevent-type-key" class="member">
2041
+ <div class="member-link">
2042
+ <a name="dispatchkeyevent-type-key" href="#dispatchkeyevent-type-key"><tt><b>dispatchKeyEvent</b>(type, key[, options])</tt></a>
2043
+ </div>
2044
+ <div class="member-description hidden">
2045
+ <div class="member-text">
2046
+ <p>Handles a key event that the host provides, for hosts without a DOM, such as workers, or with their own event source. It updates <tt>Key#modifiers</tt> and <tt>Key#isDown(key)</tt>, and calls the view&rsquo;s and the active tool&rsquo;s handlers, as the DOM&rsquo;s key events do.</p>
2047
+ <ul class="member-list">
2048
+ <h4>Options:</h4>
2049
+ <li>[options.character] {String} the character that the key
2050
+ produces. By default, keydown takes the key itself if it is a
2051
+ single character, and keyup the character of its keydown</li>
2052
+ <li>[options.modifiers] {Object} the state of the modifier keys,
2053
+ see {@link Key#modifiers}</li>
2054
+ <li><tt>options.timeStamp: <tt>Number</tt></tt> &mdash; the time stamp &mdash;&nbsp;default: <tt>Date.now()</tt></li>
2055
+ </ul>
2056
+
2057
+ <ul class="member-list">
2058
+ <h4>Parameters:</h4>
2059
+
2060
+ <li>
2061
+ <tt>type:</tt>
2062
+ <tt>String</tt>
2063
+ &mdash;&nbsp;the type of the event: <tt>&lsquo;keydown&rsquo;</tt>, <tt>&lsquo;keyup&rsquo;</tt>
2064
+
2065
+ </li>
2066
+
2067
+ <li>
2068
+ <tt>key:</tt>
2069
+ <tt>String</tt>
2070
+ &mdash;&nbsp;the key, as in <a href="../classes/KeyEvent.html#key"><tt>keyEvent.key</tt></a>
2071
+
2072
+ </li>
2073
+
2074
+ <li>
2075
+ <tt>options:</tt>
2076
+ <tt>Object</tt>
2077
+ &mdash;&nbsp;the details of the event
2078
+ &mdash;&nbsp;optional
2079
+ </li>
2080
+
2081
+ </ul>
2082
+
2083
+
2084
+
2085
+
2086
+
2087
+
1753
2088
  </div>
1754
2089
  </div>
1755
2090
  </div>
@@ -1763,7 +2098,7 @@ function onMouseDown(event) {
1763
2098
 
1764
2099
  <!-- =========================== copyright notice ========================== -->
1765
2100
  <p class="footer">
1766
- Paper.js v0.12.20<br>
2101
+ Paper.js v0.14.0<br>
1767
2102
  Copyright &#169; 2011—2026 <a href="http://www.lehni.org" target="_blank">J&uuml;rg Lehni</a> &amp; <a href="http://www.jonathanpuckey.com" target="_blank">Jonathan Puckey</a>. All Rights Reserved.</p>
1768
2103
  <div class="content-end"></div>
1769
2104
 
@@ -416,7 +416,7 @@
416
416
 
417
417
  <!-- =========================== copyright notice ========================== -->
418
418
  <p class="footer">
419
- Paper.js v0.12.20<br>
419
+ Paper.js v0.14.0<br>
420
420
  Copyright &#169; 2011—2026 <a href="http://www.lehni.org" target="_blank">J&uuml;rg Lehni</a> &amp; <a href="http://www.jonathanpuckey.com" target="_blank">Jonathan Puckey</a>. All Rights Reserved.</p>
421
421
  <div class="content-end"></div>
422
422
 
@@ -2,13 +2,13 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
- <title>Paper.js v0.12.20</title>
5
+ <title>Paper.js v0.14.0</title>
6
6
  <base target="class-frame">
7
7
  <link href="../assets/css/docs.css" rel="stylesheet" type="text/css">
8
8
  </head>
9
9
  <body class="reference">
10
10
  <div class="reference-index">
11
- <h1>Paper.js<span class="version">0.12.20</span></h1>
11
+ <h1>Paper.js<span class="version">0.14.0</span></h1>
12
12
  <ul class="reference-classes"><li><a href="../classes/global.html">Global Scope</a></li>
13
13
  <li>
14
14
  <h2>Basic Types</h2>
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
- <title>Paper.js v0.12.20</title>
5
+ <title>Paper.js v0.14.0</title>
6
6
  </head>
7
7
  <frameset cols="230,*">
8
8
  <frame src="classes/index.html" name="packageListFrame" title="All Packages">
@@ -24,7 +24,7 @@ module.exports = function(self, requireName) {
24
24
  // Check the required module's name to see if it contains canvas, and
25
25
  // only complain about its lack if the module requires it.
26
26
  if (/\bcanvas\b/.test(requireName)) {
27
- throw new Error('Unable to load canvas module.');
27
+ throw new Error('Unable to load canvas module.', { cause: error });
28
28
  }
29
29
  return false;
30
30
  }
package/dist/node/self.js CHANGED
@@ -18,7 +18,9 @@ var path = require('path');
18
18
  // 'paper-jsdom' or 'paper-jsdom-canvas'), and use this to determine if error
19
19
  // exceptions should be thrown or if loading should fail silently.
20
20
  var parent = module.parent && module.parent.parent,
21
- requireName = parent && path.basename(path.dirname(parent.filename));
21
+ // The REPL's module has no filename:
22
+ requireName = parent && parent.filename &&
23
+ path.basename(path.dirname(parent.filename));
22
24
  requireName = /^paper/.test(requireName) ? requireName : 'paper';
23
25
 
24
26
  var jsdom,
@@ -30,7 +32,7 @@ try {
30
32
  // Check the required module's name to see if it contains jsdom, and only
31
33
  // complain about its lack if the module requires it.
32
34
  if (/\bjsdom\b/.test(requireName)) {
33
- throw new Error('Unable to load jsdom module.');
35
+ throw new Error('Unable to load jsdom module.', { cause: e });
34
36
  }
35
37
  }
36
38
 
@@ -53,7 +55,6 @@ if (jsdom) {
53
55
  // jsdom's window can't be removed from itself, so inherit from it:
54
56
  self = Object.create(self, { window: { value: null } });
55
57
  }
56
- require('./xml.js')(self);
57
58
  } else {
58
59
  self = {
59
60
  navigator: {