Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Call initialize w/ SDK version first #128

Open
wants to merge 3 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions languages/javascript/src/shared/Transport/index.mjs
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 version

export function initialize(v) {
version = v
}

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

_processRequest (module, method, params, transforms) {

if (version) {
const v = version
version = null
Transport.send("Internal", "initialize", { version: v })
}

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

Expand Down
3 changes: 3 additions & 0 deletions src/macrofier/engine.mjs
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