Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6,376 changes: 4,268 additions & 2,108 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 8 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
"name": "@stencila/executa",
"version": "1.9.5",
"description": "Document executors: protocols, transports and reference implementations",
"main": "./dist/lib/index.js",
"source": "src/index.ts",
"main": "./dist/lib/executa.js",
"types": "./dist/lib/index.d.ts",
"browser": "./dist/browser/index.js",
"module": "./dist/executa.mjs",
"browser": "./dist/browser/executa.mjs",
"unpkg": "./dist/browser/index.umd.js",
"bin": "./dist/lib/cli/index.js",
"files": [
"dist"
Expand All @@ -28,8 +31,8 @@
"docker:run-image": "docker run -it --init --rm --cap-add=SYS_ADMIN -p 9000:9000",
"build": "npm run build:config && npm run build:node && npm run build:browser",
"build:config": "configa schema",
"build:node": "tsc",
"build:browser": "rollup --config",
"build:node": "microbundle build --target node --format es,cjs -o dist/lib",
"build:browser": "microbundle build -i ./src/index.browser.ts --target web --name executa --format es,umd --tsconfig tsconfig.browser.json -o dist/browser --alias cross-fetch=fetch,isomorphic-ws=WebSocket",
"docs": "npm run docs:readme && npm run docs:api",
"docs:readme": "npm run docs:readme:config && npm run docs:readme:toc",
"docs:readme:config": "configa readme",
Expand All @@ -55,13 +58,7 @@
"jest": "25.4.0",
"lolex": "6.0.0",
"markdown-toc": "1.2.0",
"rollup": "2.6.1",
"rollup-plugin-babel": "4.4.0",
"rollup-plugin-commonjs": "10.1.0",
"rollup-plugin-json": "4.0.0",
"rollup-plugin-node-builtins": "2.1.2",
"rollup-plugin-node-resolve": "5.2.0",
"rollup-plugin-typescript2": "0.27.0",
"microbundle": "^0.12.0-next.8",
"ts-jest": "25.4.0",
"ts-node": "8.9.0",
"ts-node-dev": "1.0.0-pre.44",
Expand Down
43 changes: 0 additions & 43 deletions rollup.config.js

This file was deleted.

10 changes: 7 additions & 3 deletions src/base/Worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ export class Worker extends Executor {
return super.query(node, query, lang)
}

// Enclose in braces to avoid `{}` to be confused with a block.
// This function cannot be inside `execute` as Babel complains with:
// `Calling eval from inside an async function is not supported`
// eslint-disable-next-line no-eval
private evaluate = (text: string): schema.Entity => eval(`(${text})`)

/**
* @override Override of {@link Executor.execute} that
* provides for execution of Javascript expressions.
Expand All @@ -157,9 +163,7 @@ export class Worker extends Executor {
const { text } = node
if (text === undefined || text.trim().length === 0) return node
try {
// Enclose in braces to avoid `{}` to be confused with a block.
// eslint-disable-next-line no-eval
node.output = eval(`(${text})`)
node.output = this.evaluate(text)
} catch (error) {
const { name, message, trace } = error
node.errors = [
Expand Down
6 changes: 3 additions & 3 deletions src/base/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* not for end users.
*/
import { Method, Params } from './Executor'
import * as schema from '@stencila/schema'
import { isEntity, nodeType } from '@stencila/schema'

export class InternalError extends Error {
constructor(message: string) {
Expand Down Expand Up @@ -71,8 +71,8 @@ export class CapabilityError extends Error {
Object.entries(params)
.map(([name, value]) => {
let repr
if (schema.isEntity(value)) {
repr = `<${schema.nodeType(value)}>`
if (isEntity(value)) {
repr = `<${nodeType(value)}>`
} else {
repr = JSON.stringify(value)
if (repr !== undefined && repr.length > 20) {
Expand Down
10 changes: 4 additions & 6 deletions src/browser/init.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { getLogger } from '@stencila/logga'
import * as schema from '@stencila/schema'
import { softwareSession, SoftwareSession, CodeChunk } from '@stencila/schema'
import { WebSocketAddressInitializer } from '../base/Transports'
import { WebSocketClient } from '../ws/WebSocketClient'

const log = getLogger('executa:browser')

let client: WebSocketClient
let session: null | schema.SoftwareSession = null
let session: null | SoftwareSession = null

const executeCodeChunk = async (
codeChunk: schema.CodeChunk
): Promise<schema.CodeChunk> => {
const executeCodeChunk = async (codeChunk: CodeChunk): Promise<CodeChunk> => {
if (session === null) {
session = await client.begin(schema.softwareSession())
session = await client.begin(softwareSession())
}
try {
return client.execute(codeChunk, session)
Expand Down
7 changes: 6 additions & 1 deletion src/stdio/StdioClientServer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ jest.setTimeout(30 * 1000)

describe('StdioClient and StdioServer', () => {
const testServer = (arg = ''): string =>
`npx ts-node --files ${path.join(__dirname, 'stdioTestServer.ts')} ${arg}`
`npx ts-node -P ${path.join(
__dirname,
'..',
'..',
'tsconfig.test.json'
)} --files ${path.join(__dirname, 'stdioTestServer.ts')} ${arg}`

const nextClientMessages = async (count = 1) =>
(await nextLogData(['executa:client', 'executa:stdio:client'], count)).map(
Expand Down
6 changes: 2 additions & 4 deletions tsconfig.browser.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"extends": "@stencila/dev-config/tsconfig.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"moduleResolution": "node",
"module": "esnext",
"experimentalDecorators": true
"outDir": "dist/browser"
},
"include": ["src/**/*.ts"]
}
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"extends": "@stencila/dev-config/tsconfig.json",
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "node",
"outDir": "dist/lib",
"experimentalDecorators": true
},
Expand Down
8 changes: 8 additions & 0 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@stencila/dev-config/tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"experimentalDecorators": true
},
"include": ["src/**/*.ts"]
}