You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When attempting to hash the methods for 2D / WebGL / Audio context, an instance of that context is created and used to enumerate methods and properties thereof.
This does not work when run with Node.js - server-side js does not know about Canvas, rendering context nor Audio context, since all of these are usually client-side operations.
Upon attempting to create a canvas (for 2D or WebGL context)
ReferenceError: document is not defined
at Object.ShapeShifter.preprocess (shapeShifter.js:75:17)
Upon attempting to create an AudioContext
ReferenceError: AudioContext is not defined
at Object.ShapeShifter.preprocess (shapeShifter.js:115:22)
The text was updated successfully, but these errors were encountered:
There are implementations of Canvas under node, such as node-canvas, however they may or may not have exactly the same methods as the canvas found in browsers (and even these differ, see #20). Sometimes they offer more methods, or implement them in advance of the spec.
Unfortunately, one needs a similar result whether RegPack is run in a browser or with node.js
Proposed solution : introduce a class named ContextDescriptor, in charge of building a list of context properties, methods and constat values, with different implementations :
under a browser, it lists methods and properties of real instances of the appropriate context
under Node, it uses hardcoded lists, which were derived from browsers implementations. These need to be updated whenever a browser introduces a new method in these contexts.
I am not exactly satisfied with that, even though there is no relevant alternative (node-canvas and other implementations suffer the same drawbacks). This design will at least allow for easy replacement of the ContextDescriptor implementation should a better solution arise.
When attempting to hash the methods for 2D / WebGL / Audio context, an instance of that context is created and used to enumerate methods and properties thereof.
This does not work when run with Node.js - server-side js does not know about Canvas, rendering context nor Audio context, since all of these are usually client-side operations.
Upon attempting to create a canvas (for 2D or WebGL context)
Upon attempting to create an AudioContext
The text was updated successfully, but these errors were encountered: