chore: remove axios and js-beautify
This commit is contained in:
@@ -41,6 +41,11 @@ module.exports = {
|
|||||||
resolve: {
|
resolve: {
|
||||||
symlinks: false,
|
symlinks: false,
|
||||||
},
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
axios: path.resolve(__dirname, '../src/lib/empty.js'),
|
||||||
|
},
|
||||||
|
},
|
||||||
devServer: {
|
devServer: {
|
||||||
static: {
|
static: {
|
||||||
directory: path.join(__dirname, '../test'),
|
directory: path.join(__dirname, '../test'),
|
||||||
|
|||||||
@@ -59,7 +59,6 @@
|
|||||||
"jasmine-core": "^2.99.1",
|
"jasmine-core": "^2.99.1",
|
||||||
"jasmine-jquery": "^2.1.1",
|
"jasmine-jquery": "^2.1.1",
|
||||||
"jquery": "^3.4.1",
|
"jquery": "^3.4.1",
|
||||||
"js-beautify": "^1.10.3",
|
|
||||||
"karma": "^6.4.0",
|
"karma": "^6.4.0",
|
||||||
"karma-chrome-launcher": "^3.1.0",
|
"karma-chrome-launcher": "^3.1.0",
|
||||||
"karma-coverage-istanbul-reporter": "^2.1.1",
|
"karma-coverage-istanbul-reporter": "^2.1.1",
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
lowerCase,
|
lowerCase,
|
||||||
isNull,
|
isNull,
|
||||||
} from '../lib/util'
|
} from '../lib/util'
|
||||||
|
import extend from 'licia/extend'
|
||||||
import evalCss from '../lib/evalCss'
|
import evalCss from '../lib/evalCss'
|
||||||
import emitter from '../lib/emitter'
|
import emitter from '../lib/emitter'
|
||||||
import Settings from '../Settings/Settings'
|
import Settings from '../Settings/Settings'
|
||||||
@@ -139,7 +140,7 @@ export default class Console extends Tool {
|
|||||||
const _$input = _$inputContainer.find('textarea')
|
const _$input = _$inputContainer.find('textarea')
|
||||||
const _$inputBtns = _$inputContainer.find('.eruda-buttons')
|
const _$inputBtns = _$inputContainer.find('.eruda-buttons')
|
||||||
|
|
||||||
Object.assign(this, {
|
extend(this, {
|
||||||
_$control: $el.find('.eruda-control'),
|
_$control: $el.find('.eruda-control'),
|
||||||
_$logs: $el.find('.eruda-logs-container'),
|
_$logs: $el.find('.eruda-logs-container'),
|
||||||
_$inputContainer,
|
_$inputContainer,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import Tool from '../DevTools/Tool'
|
import Tool from '../DevTools/Tool'
|
||||||
import beautify from 'js-beautify'
|
|
||||||
import LunaObjectViewer from 'luna-object-viewer'
|
import LunaObjectViewer from 'luna-object-viewer'
|
||||||
import Settings from '../Settings/Settings'
|
import Settings from '../Settings/Settings'
|
||||||
import { ajax, escape, trim, isStr, highlight } from '../lib/util'
|
import { ajax, escape, trim, isStr, highlight } from '../lib/util'
|
||||||
@@ -13,8 +12,6 @@ export default class Sources extends Tool {
|
|||||||
|
|
||||||
this.name = 'sources'
|
this.name = 'sources'
|
||||||
this._showLineNum = true
|
this._showLineNum = true
|
||||||
this._formatCode = true
|
|
||||||
this._indentSize = 4
|
|
||||||
|
|
||||||
this._loadTpl()
|
this._loadTpl()
|
||||||
}
|
}
|
||||||
@@ -121,34 +118,20 @@ export default class Sources extends Tool {
|
|||||||
|
|
||||||
if (!settings) return
|
if (!settings) return
|
||||||
|
|
||||||
settings
|
settings.remove(cfg, 'showLineNum').remove('Sources')
|
||||||
.remove(cfg, 'showLineNum')
|
|
||||||
.remove(cfg, 'formatCode')
|
|
||||||
.remove(cfg, 'indentSize')
|
|
||||||
.remove('Sources')
|
|
||||||
}
|
}
|
||||||
_initCfg() {
|
_initCfg() {
|
||||||
const cfg = (this.config = Settings.createCfg('sources', {
|
const cfg = (this.config = Settings.createCfg('sources', {
|
||||||
showLineNum: true,
|
showLineNum: true,
|
||||||
formatCode: true,
|
|
||||||
indentSize: 4,
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if (!cfg.get('showLineNum')) this._showLineNum = false
|
if (!cfg.get('showLineNum')) this._showLineNum = false
|
||||||
if (!cfg.get('formatCode')) this._formatCode = false
|
|
||||||
this._indentSize = cfg.get('indentSize')
|
|
||||||
|
|
||||||
cfg.on('change', (key, val) => {
|
cfg.on('change', (key, val) => {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'showLineNum':
|
case 'showLineNum':
|
||||||
this._showLineNum = val
|
this._showLineNum = val
|
||||||
return
|
return
|
||||||
case 'formatCode':
|
|
||||||
this._formatCode = val
|
|
||||||
return
|
|
||||||
case 'indentSize':
|
|
||||||
this._indentSize = +val
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -156,8 +139,6 @@ export default class Sources extends Tool {
|
|||||||
settings
|
settings
|
||||||
.text('Sources')
|
.text('Sources')
|
||||||
.switch(cfg, 'showLineNum', 'Show Line Numbers')
|
.switch(cfg, 'showLineNum', 'Show Line Numbers')
|
||||||
.switch(cfg, 'formatCode', 'Beautify Code')
|
|
||||||
.select(cfg, 'indentSize', 'Indent Size', ['2', '4'])
|
|
||||||
.separator()
|
.separator()
|
||||||
}
|
}
|
||||||
_render() {
|
_render() {
|
||||||
@@ -185,25 +166,12 @@ export default class Sources extends Tool {
|
|||||||
}
|
}
|
||||||
_renderCode() {
|
_renderCode() {
|
||||||
const data = this._data
|
const data = this._data
|
||||||
const indent_size = this._indentSize
|
|
||||||
|
|
||||||
let code = data.val
|
let code = data.val
|
||||||
const len = data.val.length
|
const len = data.val.length
|
||||||
|
|
||||||
// If source code too big, don't process it.
|
// If source code too big, don't process it.
|
||||||
if (len < MAX_BEAUTIFY_LEN && this._formatCode) {
|
if (len < MAX_BEAUTIFY_LEN) {
|
||||||
switch (data.type) {
|
|
||||||
case 'html':
|
|
||||||
code = beautify.html(code, { unformatted: [], indent_size })
|
|
||||||
break
|
|
||||||
case 'css':
|
|
||||||
code = beautify.css(code, { indent_size })
|
|
||||||
break
|
|
||||||
case 'js':
|
|
||||||
code = beautify(code, { indent_size })
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
const curTheme = evalCss.getCurTheme()
|
const curTheme = evalCss.getCurTheme()
|
||||||
code = highlight(code, data.type, {
|
code = highlight(code, data.type, {
|
||||||
keyword: `color:${curTheme.keywordColor}`,
|
keyword: `color:${curTheme.keywordColor}`,
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import {
|
|||||||
upperFirst,
|
upperFirst,
|
||||||
nextTick
|
nextTick
|
||||||
} from './lib/util'
|
} from './lib/util'
|
||||||
|
import extend from 'licia/extend'
|
||||||
import evalCss from './lib/evalCss'
|
import evalCss from './lib/evalCss'
|
||||||
import chobitsu from './lib/chobitsu'
|
import chobitsu from './lib/chobitsu'
|
||||||
|
|
||||||
@@ -174,7 +175,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(el, {
|
extend(el, {
|
||||||
id: 'eruda',
|
id: 'eruda',
|
||||||
className: 'eruda-container',
|
className: 'eruda-container',
|
||||||
contentEditable: false
|
contentEditable: false
|
||||||
|
|||||||
1
src/lib/empty.js
Normal file
1
src/lib/empty.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export default {}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
import beautify from 'js-beautify'
|
|
||||||
import evalCss from './evalCss'
|
import evalCss from './evalCss'
|
||||||
|
import extend from 'licia/extend'
|
||||||
|
|
||||||
export default function (util) {
|
export default function (util) {
|
||||||
Object.assign(util, {
|
extend(util, {
|
||||||
beautify,
|
|
||||||
evalCss,
|
evalCss,
|
||||||
isErudaEl,
|
isErudaEl,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -62,8 +62,8 @@
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
addClickEvent('issue17', function () {
|
addClickEvent('issue17', function () {
|
||||||
let B = function () {}
|
var B = function () {}
|
||||||
let A = function () {
|
var A = function () {
|
||||||
this._data = 'eruda'
|
this._data = 'eruda'
|
||||||
}
|
}
|
||||||
A.prototype = Object.create(B.prototype)
|
A.prototype = Object.create(B.prototype)
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
return this._data
|
return this._data
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
let a = new A()
|
var a = new A()
|
||||||
console.log(a)
|
console.log(a)
|
||||||
})
|
})
|
||||||
addClickEvent('plugin', function () {
|
addClickEvent('plugin', function () {
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let Tool = eruda.Tool
|
var Tool = eruda.Tool
|
||||||
eruda.add(
|
eruda.add(
|
||||||
new (Tool.extend({
|
new (Tool.extend({
|
||||||
name: 'test3',
|
name: 'test3',
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
new Promise(function (resolve, reject) {
|
new Promise(function (resolve, reject) {
|
||||||
resolve()
|
resolve()
|
||||||
}).then(function (res) {
|
}).then(function (res) {
|
||||||
let a = res.a
|
var a = res.a
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
addClickEvent('issue31', function () {
|
addClickEvent('issue31', function () {
|
||||||
@@ -114,8 +114,8 @@
|
|||||||
triggerError()
|
triggerError()
|
||||||
})
|
})
|
||||||
addClickEvent('big-array', function () {
|
addClickEvent('big-array', function () {
|
||||||
let arr = []
|
var arr = []
|
||||||
for (let i = 0; i < 10000; i++) {
|
for (var i = 0; i < 10000; i++) {
|
||||||
arr.push(i)
|
arr.push(i)
|
||||||
}
|
}
|
||||||
console.log(arr)
|
console.log(arr)
|
||||||
@@ -123,10 +123,10 @@
|
|||||||
addClickEvent('override-style', function () {
|
addClickEvent('override-style', function () {
|
||||||
util.evalCss('.eruda-nav-bar {background: red !important;}')
|
util.evalCss('.eruda-nav-bar {background: red !important;}')
|
||||||
})
|
})
|
||||||
addClickEvent('log', () => {
|
addClickEvent('log', function () {
|
||||||
console.clear()
|
console.clear()
|
||||||
console.log('log')
|
console.log('log')
|
||||||
for (let i = 0; i < 10; i++) {
|
for (var i = 0; i < 10; i++) {
|
||||||
console.log('repeat log')
|
console.log('repeat log')
|
||||||
}
|
}
|
||||||
console.warn('warn')
|
console.warn('warn')
|
||||||
@@ -142,7 +142,7 @@
|
|||||||
var site2 = { name: 'Google', site: 'www.google.com' }
|
var site2 = { name: 'Google', site: 'www.google.com' }
|
||||||
var site3 = { name: 'Taobao', site: 'www.taobao.com' }
|
var site3 = { name: 'Taobao', site: 'www.taobao.com' }
|
||||||
console.table([site1, site2, site3], ['site'])
|
console.table([site1, site2, site3], ['site'])
|
||||||
const el = util.toEl(
|
var el = util.toEl(
|
||||||
'<div class="test"><div class="test-inner"></div></div>'
|
'<div class="test"><div class="test-inner"></div></div>'
|
||||||
)
|
)
|
||||||
console.log('test dom', el)
|
console.log('test dom', el)
|
||||||
@@ -168,13 +168,13 @@
|
|||||||
for (var i = 0; i < 10000; i++) arr.push(i)
|
for (var i = 0; i < 10000; i++) arr.push(i)
|
||||||
console.log(arr)
|
console.log(arr)
|
||||||
})
|
})
|
||||||
addClickEvent('log-10000', () => {
|
addClickEvent('log-10000', function () {
|
||||||
for (let i = 0; i < 10000; i++) {
|
for (var i = 0; i < 10000; i++) {
|
||||||
console.log(location, i)
|
console.log(location, i)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
addClickEvent('log-1000', () => {
|
addClickEvent('log-1000', function () {
|
||||||
for (let i = 0; i < 1000; i++) {
|
for (var i = 0; i < 1000; i++) {
|
||||||
console.log(location, i)
|
console.log(location, i)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user