Giter Site home page Giter Site logo

wanglin2 / code-run Goto Github PK

View Code? Open in Web Editor NEW
500.0 11.0 135.0 22.32 MB

一个代码在线编辑预览工具,类似codepen、jsbin、jsfiddle等。

Home Page: https://wanglin2.github.io/code-run/

HTML 0.01% Vue 0.69% JavaScript 99.30% CSS 0.01%
codepen jsbin code-editor code editor javascript vue

code-run's Introduction

code-run

一个代码在线编辑预览工具,类似codepen

在线示例:https://wanglin2.github.io/code-run-online/

相关文章

使用Skypack在浏览器上直接导入ES模块

快速搭建一个代码在线编辑预览工具

如何手动解析vue单文件并预览?

手把手教你实现在Monaco Editor中使用VSCode主题

特性

  • 支持多种预处理语言

  • 支持多种布局随意切换

  • 支持添加额外的cssjs资源

  • 内置多种常用模板

  • 支持导出zip

  • 支持代码格式化

  • 美观强大的控制台

  • 支持vue单文件(2.x、3.x)

  • 支持直接移植VSCode主题,并且已经内置了大量优质主题

  • 内置支持保存到github gist【gist API】,想要保存到自己的存储体系修改也十分简单

  • 内置支持在未配置github gist的情况下将变动保存到url中,可方便的将url分享给他人查看

  • 内置支持生成和carbon一样漂亮美观的代码图片

  • 内置使用unpkgimportmap支持在浏览器上使用ES模块语法

  • 支持嵌入模式,方便在文档网站中使用,让文档示例更轻松

本地构建

git clone https://github.com/wanglin2/code-run.git

cd code-run

npm i

npm run serve

打包

修改应用基路径

请先确认打包后应用的基路径,项目默认的基路径为/code-run/,如果你想换一个,可以按如下步骤修改:

1.修改vue.config.js文件里的publicPath字段。

2.修改src/config/index.js文件的base字段。

修改路由模式

默认的路由模式为hash模式,如果需要使用history模式请修改src/config/index.js文件的routerMode字段。

另外history模式下如果存在多级路径,可能需要修改以下文件:

1.修改/public/index.html文件的prettier相关js资源的路径;

打包命令

npm run build

项目主要技术

脚手架: Vue CLI

框架:Vue 3.X全家桶,通过script setup使用组合式API

UI库:element-plus

代码编辑器:Monaco Editor

界面截图

界面截图1

界面截图2

界面截图3

关于使用ESM

目前在JavaScriptTypeScriptCoffeeScriptVue3Vue2等模式下支持使用ESM,默认情况下,如果你直接按下列方式导入模块的话:

import moment from 'moment'

最后会转换成:

import moment from 'https://unpkg.com/moment?module'

也就是使用unpkg,但是有些模块unpkg获取不到ESM版本,或者直接这样获取到的版本不是我们所期望的,比如导入vue时,我们需要的是https://unpkg.com/[email protected]/dist/vue.esm-browser.js,但是https://unpkg.com/vue?module默认返回的是https://unpkg.com/[email protected]/dist/vue.runtime.esm-bundler.js?module,这个版本无法运行在浏览器上,所以这时候就可以通过手动添加importmap来设置导入模块的来源。

主题新增教程

本教程针对迁移VSCode主题。

1.确定要新增的主题,先在本地VSCode上安装并切换到该主题,然后按F1Command/Control + Shift + P或鼠标右键点击Command Palette/命令面板,接着找到并点击Developer:Generate Color Theme From Current Setting/开发人员:使用当前设置生成颜色主题,然后VSCode就会生成一份json数据,保存到项目的/scripts/vscodeThemes/目录下。

2.然后命令行执行命令npm run convertTheme,转换后的主题会被输出到项目的/public/themes目录下,接下来再执行命令npm run createThemeList即可生成主题配置,接下来即可在设置->主题设置里看到所有主题,并可以切换使用

相关命令介绍

  • npm run buildConsole:编译项目的/public/console/index.js文件为ES5语法,输出到同目录下的compile.js,该文件会在页面预览的iframe里进行加载,请勿直接修改compile.js文件。

  • npm run buildMonacoWorker:打包Monaco Editor编辑器的worker文件,如果使用的Monaco Editor编辑器版本变化了需要重新打包。

  • npm run convertTheme:将VSCode主题文件转换成Monaco Editor主题文件。

  • npm run createThemeList:根据主题文件列表自动生成配置文件。

  • npm run buildVueSFCCompiler:打包@vue/compiler-sfc文件,针对Vue3

编译器更新指南

因为本项目是纯前端项目,所以在使用lesssasstypescript等预处理语言或扩展语言时需要在线进行编译,这个工作是由各个语言的编译器处理的,这些编译器你可以在/public/parses/目录下找到,随着时间的推移,肯定会落后于它们的新版本,所以你需要定期更新它们,获取它们的浏览器使用版本并不是一件易事,所以在这里将有些仅有的经验分享给大家。

  • less

首先npm i less,然后在node_modules找到less/dist/目录,该目录下的两个文件都是umd格式的,可以直接使用。

  • sass

sass目前使用的是这个项目sass.js,但是这个项目已经三年没有更新了。

  • babel

babel提供了浏览器使用版本,具体可以参考官方文档@babel/standalone

  • typescript

typescript直接npm i typescript,然后找到node_modules/typescript/lib/typescript.js文件,它也是支持直接在浏览器上使用的。

  • coffeescript

coffeescript也是直接npm i coffeescript,然后找到node_modules/coffeescript/coffeescript-browser-compiler-legacy/coffeescript.js文件,支持直接在浏览器上使用。

  • livescript

livescript的浏览器使用版本可以直接去其官方仓库下载browser,不过也两年没有更新了。

  • postcss

可以使用Browserifywebpack把它打包到一个文件中。

  • 其他

stylus暂时没有找到浏览器使用版本或编译成功,知道的朋友欢迎提个issue

新增代码模板

项目内置了几个常用的代码模板,可以根据需要进行增减,模板配置文件在src/config/templates.js

新增页面布局模板

教程

项目内置了几个常用的页面布局模板,如果不满足你的需求也可以新增布局,一个布局就是一个vue单文件,可以在src/pages/edit/layouts/目录下找到所有布局,每个布局其实就是确定如何显示编辑器控制台预览三部分,编辑器包含jscsshtmlvue四个编辑器,可配置显示哪几个、顺序、是否允许拖动等,需要新增的布局也需要放到该目录下。

接下来以新增一个vue单文件的布局为例来看,首先确定布局细节,我们想左侧显示一个vue编辑器,右侧显示预览控制台预览模块默认展开,控制台默认最小化:

1.首先我们在layouts目录下创建一个VueSFC.vue

2.修改src/config/constants.js文件,引入该组件,并在layoutListlayoutMap两个配置上新增该布局:

import VueSFC from '../pages/edit/layouts/VueSFC.vue'

export const layoutList = [
	// ...
	{
		name: 'Vue单文件',
		value: 'vue',
	}
]

export const layoutMap = {
	// ...
	vue: VueSFC
}

可以添加一张该布局的预览图片,放置到src/assets/layoutImgs/目录下,然后在constants.js文件里引入,最后在previewImgMap配置上添加即可。

这样修改完后即可在页面的设置功能里的布局设置的下拉列表里看到新增的Vue单文件选项。接下来完善VueSFC.vue的内容。

3.可参考其他布局结构的内容,复制过来修改,最终的内容应该是这样的:

<template>
  <!-- 该容器的直接DragItem直接数量为2,方向水平排列,第一个DragItem直接允许缩小到0,第二个DragItem组件最小允许缩小到20px -->
  <Drag :number="2" dir="h" :config="[{ min: 0 }, { min: 20 }]">
    <!-- 编辑器块,索引为0,禁止缩放该块,隐藏拖动条 -->
    <DragItem :index="0" :disabled="true" :showTouchBar="false">
      <!-- 编辑器增加,内部编辑器排列方向为垂直,配置了要显示的编辑器 -->
      <Editor dir="v" :showList="showList"></Editor>
    </DragItem>
    <!-- 预览&控制台,索引为1,允许拖动进行缩放 -->
    <DragItem :index="1" :disabled="false">
      <!-- DragItem又嵌套了一个容器组件,该容器的直接DragItem直接数量为2,方向垂直排列,第一个DragItem直接允许缩小到0,第二个DragItem组件默认显示的高度为48px,且最小允许缩小到48px -->
      <Drag :number="2" dir="v" :config="[{ min: 0 }, { min: 48, default: 48 }]">
        <DragItem
          :index="0"
          :disabled="true"
          :showTouchBar="false"
          title="预览"
        >
          <Preview></Preview>
        </DragItem>
        <DragItem :index="1" :disabled="false" title="控制台">
          <Console></Console>
        </DragItem>
      </Drag>
    </DragItem>
  </Drag>
</template>

<script setup>
import Editor from '@/components/Editor.vue'
import Preview from '@/components/Preview.vue'
import Console from '@/components/Console.vue'
import Drag from '@/components/Drag.vue'
import DragItem from '@/components/DragItem.vue'
import { reactive } from 'vue'

// 配置只显示vue编辑器
const showList = reactive([
    {
        title: 'VUE',// 编辑器名称
        disableDrag: true,// 禁止拖动进行缩放
        showTouchBar: false// 隐藏推动条
    }
])
</script>

注释已经解释的很详细,详情可参考接下来的组件文档。

布局相关组件文档

Drag组件

该组件相当于是一个容器,每个容器会实例化一个Resize尺寸拖动调整类,内部需要放置DragItem组件。

组件props

名称 介绍 类型 默认值
dir 容器内部的DragItem组件排列方式,可选项:h(水平排列)、v(垂直排列) String h
number 内部的DragItem组件数量 Number 0
config 配置内部的DragItem组件的信息,数组类型,每一项都是一个对象,具体的属性请看表1 Array []

表1

config数组每一项的对象的属性:

名称 介绍 类型 默认值
default 对应索引的DragItem组件默认显示的尺寸,dirh时指宽度,为v时指高度 Number 默认容器内的所有DragItem组件平分空间
min 对应索引的DragItem组件允许显示的最小尺寸,当发生拖动时,如果该组件空间被挤压,默认允许被压缩到0,即完全不显示,如果配置了该属性,则缩小到配置的大小后不再变化 Number 0
max 对应索引的DragItem组件允许显示的最大尺寸,当发生拖动时,如果该组件空间被增加,默认会增加到允许的最大尺寸,如果配置了该属性,则增加到配置的大小后不再变化 Number 0

DragItem组件

该组件代表一个可拖动的块,需要放置在Drag组件下,通过slot来传入需要实际显示的内容。DragItem组件内可再嵌套Drag容器。

组件props

名称 介绍 类型 默认值
disabled 是否禁止拖动 Boolean false
touchBarSize 拖动条的尺寸,dirh时指宽度,为v时指高度 Number 20
index 该组件在容器内的同级DragItem组件列表中的索引,从0开始 Number 0
showTouchBar 是否显示拖动条 Boolean true
title 标题 String
hide 是否隐藏该组件 Boolean false

Editor组件

该组件目前包含jscsshtmlvue四个编辑器,可以控制具体显示哪几个,以及它们的排列方式。

组件props

名称 介绍 类型 默认值
hide 是否隐藏编辑器 Boolean false
dir 排布方向,v(垂直)、h(水平) String h
showList 要显示的编辑器列表,数组类型,每一项可以是数字也可以是一个对象,见表2 Array ['HTML', 'CSS', 'JS']

表2

showList数组的每一项可以是一个字符串,可选值为:HTMLCSSJSVUE,代表四种编辑器,配置了哪几个就显示哪几个。

如果需要再配置一些属性,比如是否允许该编辑器拖动等等,可配置的属性如下:

名称 介绍 类型 默认值
title 编辑器名称,可选项:HTMLCSSJSVUE String
disableDrag 是否禁止拖动缩放该编辑器 Boolean
showTouchBar 是否显示该编辑器的推动条 Boolean

暂未解决的问题

1.生成代码图片功能偶尔生成的图片高度超出了代码实际的高度,目前暂未找到原因及根本解决方法。可选方法之一为生成图片后再提供一个图片裁剪的功能。

2.极少数情况下会出现主题不生效的问题。

致谢

本项目中预处理/扩展语言的编译部分、其他一些细节有参考了项目codepan的实现。

License

MIT

code-run's People

Contributors

wanglin2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

code-run's Issues

导出 ZIP 报无法读取 dist/script.js

image

Uncaught (in promise) Error: Can't read the data of 'dist/script.js'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?
    at eval (jszip.min.js?c4e3:13:1)
eval	@	jszip.min.js?c4e3:13
Promise.then(异步)		
exportZip	@	exportZip.js?bf5c:125
await in exportZip(异步)		
confirmExport	@	Header.vue?0418:272
callWithErrorHandling	@	runtime-core.esm-bundler.js?5c40:155
callWithAsyncErrorHandling	@	runtime-core.esm-bundler.js?5c40:164
emit$1	@	runtime-core.esm-bundler.js?5c40:718
eval	@	runtime-core.esm-bundler.js?5c40:7388
handleClick	@	index.js?b4bc:78
Object.onClick._cache.<computed>._cache.<computed>	@	index.js?b4bc:112
callWithErrorHandling	@	runtime-core.esm-bundler.js?5c40:155
callWithAsyncErrorHandling	@	runtime-core.esm-bundler.js?5c40:164
invoker	@	runtime-dom.esm-bundler.js?830f:339

将大段代码直接粘贴至js编辑器内会出现整个页面卡死

使用提供的demo https://wanglin2.github.io/code-run-online/#/
如:
"use strict";

function _regeneratorRuntime() { "use strict"; /! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE / _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.proto = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = genkey; var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
function x() {
console.log("Hello world!");
}
var hotList = [];
hotList.filter(function (e) {
return e.type === 2;
});
var c = [].concat(hosList);
var d = {
a: 1
};
var f = d == null ? void 0 : d.a;
function a() {
return _a.apply(this, arguments);
}
function _a() {
_a = _asyncToGenerator( /
#PURE
/_regeneratorRuntime().mark(function _callee() {
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
case "end":
return _context.stop();
}
}, _callee);
}));
return _a.apply(this, arguments);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.