MCPcopy Create free account
hub / github.com/codecombat/codecombat / loadCreateJs

Function loadCreateJs

app/models/ThangType.js:29–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27// @param {string} movieClipUrl - The url of the javascript file.
28// @return {Promise<Object>} - The movieclips and metaData returned from the createjs javascript file.
29const loadCreateJs = movieClipUrl => fetch(movieClipUrl, { method: 'GET' })
30 .then(data => data.text())
31 .then(function (movieClipDefinition) {
32 // There is a method that is deprecated that we need to replace. The method and property are semantically identical
33 movieClipDefinition = movieClipDefinition.replace(/getNumChildren\(\)/g, 'numChildren')
34
35 const AnimateComposition = {}
36 // eslint-disable-next-line no-new-func
37 new Function('createjs', 'AdobeAn', movieClipDefinition)(window.createjs, AnimateComposition)
38
39 if (Object.values(AnimateComposition.compositions).length !== 1) {
40 throw new Error('There must be one composition per Adobe Animate export')
41 }
42
43 const comp = Object.values(AnimateComposition.compositions)[0]
44 const lib = comp.getLibrary()
45 const ss = comp.getSpriteSheet()
46 const { ssMetadata } = lib
47
48 return { lib, ss, ssMetadata }
49 })
50
51let buildQueue = []
52

Callers 1

Calls 1

fetchFunction · 0.50

Tested by

no test coverage detected