コード例 #1
0
        /// <summary>
        /// Request Babel and ReactJS scripts from https://unpkg.com and freeze the two <see cref="ScriptLoader"/>s.
        /// Add our own appropriate JS helper scripts from embedded ressources in this library.
        /// </summary>
        public void LoadExternalScripts()
        {
            if (BabelRepository != null && ReactRepository != null)
            {
                return;
            }

            BabelLoader.AddUrl("https://unpkg.com/babel-standalone@{0}/babel.min.js", UseBabelVersion);
            BabelLoader.AddUrl("https://unpkg.com/babel-polyfill@{0}/dist/polyfill.min.js", UseBabelVersion);

            ReactLoader.AddUrl("https://unpkg.com/react@{0}/dist/react.min.js", UseReactVersion);
            ReactLoader.AddUrl("https://unpkg.com/react-dom@{0}/dist/react-dom.min.js", UseReactVersion);
            ReactLoader.AddUrl("https://unpkg.com/react-dom@{0}/dist/react-dom-server.min.js", UseReactVersion);

            BabelRepository = BabelLoader.GetRepository();
            BabelRepository.AddAssetResource("ArrayConverter.js"); // function convertToJsArray(host)
            BabelRepository.AddAssetResource("JSX.js");            // function transformCode(code, url), function transformCode__2()

            ReactRepository = ReactLoader.GetRepository();
            ReactRepository.AddAssetResource("ArrayConverter.js"); // function convertToJsArray(host)
            ReactRepository.AddAssetResource("ReactStub.js");      // function PrepareReact(rfunc, component)
        }