
console.log("yes i am in")
loadCC();

const res = tt.canIUse("getLiveUserInfo");
console.log("Version: "+ tt.env.VERSION);
console.log("DataPath: "+ tt.env.USER_DATA_PATH);

tt.onShow((res) => {
    console.log("i'm show")
});
tt.onError((err) => {
    console.log(err);
});
//const res = tt.getLaunchOptionsSync();
//console.log(res.path)
/*tt.getExtConfig({
    success: (res) => {
        console.log("success: "+ res.openScene)
    },
    fail: (res) => {
        console.log("failed");
    },
});*/


function loadCC() {
    require('./web-adapter');


    // Polyfills bundle.
    require("src/polyfills.bundle.43263.js");


    // SystemJS support.
    require("src/system.bundle.dfb8d.js");

    // Adapt for IOS, swap if opposite
    if (canvas){
        var _w = canvas.width;
        var _h = canvas.height;
        if (screen.width < screen.height) {
            if (canvas.width > canvas.height) {
                _w = canvas.height;
                _h = canvas.width;
            }
        } else {
            if (canvas.width < canvas.height) {
                _w = canvas.height;
                _h = canvas.width;
            }
        }
        canvas.width = _w;
        canvas.height = _h;
    }

    // Adjust initial canvas size
    if (canvas && window.devicePixelRatio >= 2) {canvas.width *= 2; canvas.height *= 2;}

    const importMap = require("src/import-map.ac3d3.js").default;
    System.warmup({
        importMap,
        importMapUrl: 'src/import-map.ac3d3.js',
        defaultHandler: (urlNoSchema) => {
            require('.' + urlNoSchema);
        },
        handlers: {
            'plugin:': (urlNoSchema) => {
                requirePlugin(urlNoSchema);
            },
        },
    });

    System.import('./application.87e2e.js').then(({ Application }) => {
        return new Application();
    }).then((application) => {
        return onApplicationCreated(application);
    }).catch((err) => {
        console.error(err);
    });

    function onApplicationCreated(application) {
        return System.import('cc').then((cc) => {
            require('./engine-adapter');
            return application.init(cc);
        }).then(() => { return application.start(); });
    }

}
