Exemplo n.º 1
0
def compile(build_dir,target_dir, option, license_js, effekseer_core_js, effekseer_src_js, effekseer_js, effekseer_min_js):
    if not os.path.exists(build_dir):
        os.mkdir(build_dir)
    os.chdir(build_dir)

    if platform.system() == "Windows":
        subprocess.check_call(["cmd", "/c", "emcmake", "cmake",
                           "-G", "MinGW Makefiles", option, target_dir])
        subprocess.check_call(["mingw32-make"])
    else:
        subprocess.check_call(["command", "emcmake", "cmake", option, target_dir])
        subprocess.check_call(["make"])

    outfile_js = open(effekseer_js, "w")
    outfile_min_js = open(effekseer_min_js, "w")

    with open(license_js) as infile:
        data = infile.read()
        outfile_js.write(data)
        outfile_min_js.write(data)
    with open(effekseer_core_js) as infile:
        data = infile.read()
        outfile_js.write(data)
        outfile_min_js.write(data)
    with open(effekseer_src_js) as infile:
        data = infile.read()
        data_es5 = dukpy.babel_compile(data)["code"]
        outfile_js.write(data_es5)
        outfile_min_js.write(jsmin.jsmin(data_es5))

    os.chdir('../')
Exemplo n.º 2
0
 def input(self, _in, out, **kw):
     options = {'filename': os.path.basename(kw['source_path'])}
     if self.loader == 'systemjs':
         options['plugins'] = ['transform-es2015-modules-systemjs']
     elif self.loader == 'umd':
         options['plugins'] = ['transform-es2015-modules-umd']
     src = dukpy.babel_compile(_in.read(), **options)
     out.write(src['code'])
Exemplo n.º 3
0
 def input(self, _in, out, **kw):
     options = {'filename': os.path.basename(kw['source_path'])}
     if self.loader == 'systemjs':
         options['plugins'] = ['transform-es2015-modules-systemjs']
     elif self.loader == 'umd':
         options['plugins'] = ['transform-es2015-modules-umd']
     src = dukpy.babel_compile(_in.read(), **options)
     out.write(src['code'])
Exemplo n.º 4
0
 def input(self, _in, out, **kw):
     indata = _in.read()
     if sys.version_info[0] < 3:
         indata = indata.encode('utf-8')
     src = dukpy.babel_compile(indata)
     if sys.version_info[0] < 3:
         src = src.decode('utf-8')
     out.write(src)
Exemplo n.º 5
0
 def input(self, _in, out, **kw):
     indata = _in.read()
     if sys.version_info[0] < 3:
         indata = indata.encode("utf-8")
     src = dukpy.babel_compile(indata)
     if sys.version_info[0] < 3:
         src = src.decode("utf-8")
     out.write(src)
Exemplo n.º 6
0
def build_js():
    print("building js...")

    if not os.path.exists("build/assets/js"):
        os.makedirs("build/assets/js")

    for js_file in glob("assets/js/**/*.js", recursive=True):
        with open(js_file, "r") as og:
            with open(f'./build/{js_file}', "w") as b:
                b.write(minify_js(babel_compile(og.read())['code']))
Exemplo n.º 7
0
    def test_babel(self):
        ans = dukpy.babel_compile('''
class Point {
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }
    toString() {
        return '(' + this.x + ', ' + this.y + ')';
    }
}
''')
        assert '''var Point = (function () {
    function Point(x, y) {
''' in ans['code'], ans['code']
Exemplo n.º 8
0
    def test_babel(self):
        ans = dukpy.babel_compile('''
class Point {
    constructor(x, y) {
        this.x = x;
        this.y = y;
    }
    toString() {
        return '(' + this.x + ', ' + this.y + ')';
    }
}
''')
        assert '''var Point = function () {
    function Point(x, y) {
''' in ans['code'], ans['code']
Exemplo n.º 9
0
	def compress(self, read, _type):

		if self.running:
			try:
				if _type == 'js':
					read = dukpy.babel_compile(read)['code']
				else:
					read = read
				data = {'input': read}

				r = post(self.api[_type], data=data)
				if 'Error' in r.text:
					return read.strip()
				return r.text
			except:
				
				if self.verbose and self.running:
					print('[x] Error in compress verify your connection ...')
					self.running = False
				
				return read
Exemplo n.º 10
0
    def calcUnit(self):
        UnitSummary.objects.all().delete()
        max_level = UnitSummary.max_level()
        max_rank = UnitSummary.max_rank()
        max_rarity = UnitSummary.max_rarity()
        max_love = UnitSummary.max_love()

        js_path = finders.find("pcrd_unpack/scripts/elements/UnitDataModel.js")
        with open(js_path) as f:
            es6js = f.read()
        es5js = dukpy.babel_compile(es6js)["code"]
        jsi = dukpy.JSInterpreter()

        for u in UnitListView().get_queryset():
            unit_id = u.unit_id
            data = UnitJsonView().get_unit_data(unit_id=unit_id)
            context_data = UnitDetailView().get_context_data(unit_id=unit_id)

            # new an instant once of one calc, due to the dukpy bug
            r = jsi.evaljs([
                es5js, "var udm = new UnitDataModel()",
                "udm.unit_parameter = dukpy['value']",
                "udm.result_ids = dukpy['data_tags']",
                "udm.calc(dukpy['max_level'],dukpy['max_rank'],dukpy['max_rarity'],dukpy['max_love'])",
                "udm;"
            ],
                           max_level=max_level,
                           max_rank=max_rank,
                           max_rarity=max_rarity,
                           max_love=max_love,
                           value=data,
                           data_tags=context_data["data_tags"])
            us = UnitSummary(unit_id=unit_id)
            for p in context_data["data_tags"]:
                setattr(us, p, r[p])
            us.save()
Exemplo n.º 11
0
        except subprocess.CalledProcessError:
            print("[Typescript compile Error]")

    f = open(src, 'rt', encoding="utf-8")
    src_str = f.read()
    f.close()

    try:
        import dukpy
        if (src.endswith('.es6')):
            print("[Translate:ES6 to ES5]")
            source[i] = src[:-3] + "js"
        elif (src.endswith('.js')):
            print("[Translate:ESNEXT to ES5]")
            source[i] = src[:-2] + "js"
        src_str = dukpy.babel_compile(src_str)['code']
    except ImportError:
        print("[Translate - Failed]")

    print("CREATE " + source[i])
    f = open(source[i], 'wt', encoding="utf-8")
    f.write(src_str + " ")
    f.close()

# do copying
for section in getConfigSections():
    sectionMap = getConfigSectionMap(section)
    if (sectionMap["method"] == "local"):
        print("[Local:" + section + " Copying]")
        localCopying(source, sectionMap)
    elif (sectionMap["method"] == "ftp"):
Exemplo n.º 12
0
    def input(self, **kwargs):
        options = {}
        src = babel_compile(self.content, **options)

        return src["code"]
Exemplo n.º 13
0
def minifyJSProc(srcText):
    return dukpy.babel_compile(srcText, comments=False, minified=True)
Exemplo n.º 14
0
 def input(self, _in, out, **kw):
     src = dukpy.babel_compile(_in.read())
     out.write(src['code'])
Exemplo n.º 15
0
if not os.path.exists("build"):
    os.mkdir("build")
os.chdir("build")

if platform.system() == "Windows":
    subprocess.check_call(
        ["cmd", "/c", "emcmake", "cmake", "-G", "MinGW Makefiles", ".."])
    subprocess.check_call(["mingw32-make"])
else:
    subprocess.check_call(["command", "emcmake", "cmake", ".."])
    subprocess.check_call(["make"])

effekseer_core_js = os.path.join(".", "effekseer.core.js")
effekseer_src_js = os.path.join("..", "Dev", "Source", "effekseer.src.js")
effekseer_js = os.path.join("..", "Release", "effekseer.js")
effekseer_min_js = os.path.join("..", "Release", "effekseer.min.js")

outfile_js = open(effekseer_js, "w")
outfile_min_js = open(effekseer_min_js, "w")

with open(effekseer_core_js) as infile:
    data = infile.read()
    outfile_js.write(data)
    outfile_min_js.write(data)
with open(effekseer_src_js) as infile:
    data = infile.read()
    data_es5 = dukpy.babel_compile(data)["code"]
    outfile_js.write(data_es5)
    outfile_min_js.write(jsmin.jsmin(data_es5))