Skip to content

Commit

Permalink
Ready for publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed Mar 19, 2019
1 parent b10ceaf commit 71744eb
Show file tree
Hide file tree
Showing 6 changed files with 383 additions and 313 deletions.
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.rpt2_cache
node_modules
.DS_Store
npm-debug.log*
yarn-debug.log*
yarn-error.log*
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@
"lodash-es": "^4.1.2"
},
"scripts": {
"start": "npm-run-all --parallel start-tsc start-rollup",
"start": "npm-run-all --parallel clean start-tsc start-rollup",
"start-tsc": "tsc --watch",
"start-rollup": "rollup -c -w",
"build": "npm-run-all --parallel build-tsc build-rollup",
"build": "npm-run-all --parallel clean build-tsc build-rollup",
"build-tsc": "tsc",
"build-rollup": "rollup -c"
"build-rollup": "rollup -c",
"clean": "rimraf ./es ./dist",
"prepublishOnly": "npm run build"
},
"devDependencies": {
"npm-run-all": "^4.1.5",
"rimraf": "^2.6.3",
"rollup": "^1.1.2",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^4.0.0",
Expand Down
2 changes: 2 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ const config = {
nodeResolve({
browser: true,
preferBuiltins: false,
module: true,
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
typescript({ tsconfigOverride: { compilerOptions: { target: 'es5' } } }),
commonjs({
extensions: ['.js', '.ts', '.tsx'],
exclude: ['node_modules/lodash-es/'],
namedExports: {
events: ['EventEmitter'],
},
Expand Down
5 changes: 4 additions & 1 deletion src/DOM/Watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import { DomProxy } from './Proxy'
import { EventEmitter } from 'events'
import { LiveSelector } from './LiveSelector'

import { differenceWith, intersectionWith, uniqWith } from 'lodash-es'
// import { differenceWith, intersectionWith, uniqWith } from 'lodash-es'
import differenceWith from 'lodash-es/differenceWith'
import intersectionWith from 'lodash-es/intersectionWith'
import uniqWith from 'lodash-es/uniqWith'

//#region Interface for Watcher
type RequireNode<T, V> = T extends Element ? V : never
Expand Down
13 changes: 8 additions & 5 deletions src/Extension/Async-Call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ export const AsyncCall = <AllCalls, OtherSide extends Partial<AllCalls>>(
if (data.method in implementation) {
const p = (implementation[data.method as keyof typeof implementation] as any) as ((...args: any[]) => any)
const e = (err: Error) => {
if (writeToConsole) console.error(`${err.message} %c@${data.callId}\n%c${err.stack}`, 'color: gray', '')
mc.send('response', {
method: data.method,
error: err && err.message ? err.message : err,
error: err instanceof Error ? { message: err.message, stack: err.stack } : err,
return: undefined,
callId: data.callId,
})
Expand All @@ -124,7 +125,7 @@ export const AsyncCall = <AllCalls, OtherSide extends Partial<AllCalls>>(
const promise = p(...args)
if (writeToConsole)
console.log(
`${key}.%c${data.method}%c(${args.map(() => '%o').join(', ')}%c)\n%o %c${data.callId}`,
`${key}.%c${data.method}%c(${args.map(() => '%o').join(', ')}%c)\n%o %c@${data.callId}`,
'color: #d2c057',
'',
...args,
Expand All @@ -143,8 +144,10 @@ export const AsyncCall = <AllCalls, OtherSide extends Partial<AllCalls>>(
if (!resolve) return // drop this response
map.delete(data.callId)
if (data.error) {
reject(new Error(data.error))
if (writeToConsole) console.error(data.error)
const err = new Error(data.error.message)
reject(err)
if (writeToConsole)
console.error(`${data.error.message} %c@${data.callId}\n%c${data.error.stack}`, 'color: gray', '')
return
}
transform('parse', 'return', data.method, data.return).then(resolve, reject)
Expand All @@ -158,7 +161,7 @@ export const AsyncCall = <AllCalls, OtherSide extends Partial<AllCalls>>(
return: any
callId: string
method: string
error?: string
error?: { message: string; stack: string }
}
return new Proxy(
{},
Expand Down
Loading

0 comments on commit 71744eb

Please sign in to comment.