Skip to content
Open
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
4 changes: 4 additions & 0 deletions languages/javascript/src/shared/Transport/MockTransport.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ function send(message) {

let [module, method] = json.method.split('.')

if (!method) {
[method, module] = [module, method]
}

if (testHarness && testHarness.onSend) {
testHarness.onSend(module, method, json.params, json.id)
}
Expand Down
14 changes: 13 additions & 1 deletion languages/javascript/src/shared/Transport/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ let moduleInstance = null
const isEventSuccess = x => x && (typeof x.event === 'string') && (typeof x.listening === 'boolean')

const win = typeof window !== 'undefined' ? window : {}
let initMessage

export function initialize(module, method, params) {
initMessage = { module, method, params }
}

export default class Transport {
constructor () {
Expand Down Expand Up @@ -147,6 +152,12 @@ export default class Transport {

_processRequest (module, method, params, transforms) {

if (initMessage) {
const init = initMessage
initMessage = null
Transport.send(init.module, init.method, init.params)
}

const p = this._addPromiseToQueue(module, method, params, transforms)
const json = this._createRequestJSON(module, method, params)

Expand All @@ -162,7 +173,8 @@ export default class Transport {
}

_createRequestJSON (module, method, params) {
return { jsonrpc: '2.0', method: module.toLowerCase() + '.' + method, params: params, id: this._id }
const rpcMethod = module ? module.toLowerCase() + '.' + method : method
return { jsonrpc: '2.0', method: rpcMethod, params: params, id: this._id }
}

_addPromiseToQueue (module, method, params, transforms) {
Expand Down
3 changes: 3 additions & 0 deletions src/macrofier/engine.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@ const insertAggregateMacros = (fContents = '', aggregateMacros = {}) => {
fContents = fContents.replace(/[ \t]*\/\* \$\{MOCK_OBJECTS\} \*\/[ \t]*\n/, aggregateMacros.mockObjects)
fContents = fContents.replace(/\$\{readable\}/g, aggregateMacros.version.readable)
fContents = fContents.replace(/\$\{package.name\}/g, aggregateMacros.library)
fContents = fContents.replace(/\$\{major\}/g, aggregateMacros.version.major)
fContents = fContents.replace(/\$\{minor\}/g, aggregateMacros.version.minor)
fContents = fContents.replace(/\$\{patch\}/g, aggregateMacros.version.patch)

return fContents
}
Expand Down
2 changes: 1 addition & 1 deletion src/openrpc/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const run = async ({
json = addExternalMarkdown(json, markdown)

// put module name in front of each method
json.methods.forEach(method => method.name = json.info.title + '.' + method.name)
json.methods.forEach(method => json.info.title && (method.name = json.info.title + '.' + method.name))

// merge any info['x-'] extension values (maps & arrays only..)
Object.keys(json.info).filter(key => key.startsWith('x-')).forEach(extension => {
Expand Down