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

Removed reference to window and change to self #116

Merged
merged 3 commits into from Sep 6, 2017

Conversation

tmulkern
Copy link
Contributor

Removed reference to window and change to self. This is to allow the
client to be used in Web Workers see:
https://developer.mozilla.org/en/docs/Web/API/Window/self

Signed-off-by: Tadhg Mulkerntadhg.j.mulkern@gmail.com

Removed reference to window and change to self. This is to allow the
client to be used in Web Workers see:
https://developer.mozilla.org/en/docs/Web/API/Window/self

Signed-off-by: Tadhg Mulkern<tadhg.j.mulkern@gmail.com>
@tmulkern
Copy link
Contributor Author

I cannot see why the build is failing

@tmulkern
Copy link
Contributor Author

It builds perfectly on my local machine, the build error seems to be about a plugin

/home/travis/build/eclipse/paho.mqtt.javascript/node_modules/jsdoc/node_modules/babylon/lib/index.js:115
      beforeExpr,
                ^
SyntaxError: Unexpected token ,
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Object.load (/home/travis/build/eclipse/paho.mqtt.javascript/node_modules/jsdoc/node_modules/requizzle/lib/loader.js:112:15)
    at Requizzle.requizzle (/home/travis/build/eclipse/paho.mqtt.javascript/node_modules/jsdoc/node_modules/requizzle/lib/requizzle.js:90:24)
    at infectProxy (/home/travis/build/eclipse/paho.mqtt.javascript/node_modules/jsdoc/node_modules/requizzle/lib/loader.js:82:28)
    at Module.targetModule.require ...

@jpwsutton
Copy link
Member

Thanks for the contribution @tmulkern, just two changes please:

  1. Could you target this at the develop branch please?
  2. To fix the failing tests, you'll need to change global.window = global; to global.self = global; in client-harness.js. I've tested it locally and the tests then pass.

@jpwsutton jpwsutton self-requested a review August 21, 2017 10:35
@jpwsutton jpwsutton self-assigned this Aug 21, 2017
@jpwsutton jpwsutton removed their request for review August 21, 2017 10:36
@tmulkern tmulkern changed the base branch from master to develop August 21, 2017 19:39
Updated Client-hareness.js, set global.window = global; to global.self =
global;
@tmulkern
Copy link
Contributor Author

Done and Done, thanks for the help @jpwsutton

@tmulkern
Copy link
Contributor Author

@jpwsutton the build is still failing with the original failure, any ideas?

Update .travis.yml to fix build error, set nodejs version to use the
latest stable version of 5.x
@tmulkern
Copy link
Contributor Author

tmulkern commented Sep 5, 2017

@jpwsutton fixed the problem with the build, nobody specified the version of nodejs to run in .travis.yml. This cause problems with the bundling, in the build log the plugins stated that they needed a version of node greater that 4.2 (see here)

[INFO] --- exec-maven-plugin:1.2.1:exec (install-jsdoc-modules) @ paho.javascript ---
npm WARN package.json paho-client@ No repository field.
npm WARN engine jsdoc@3.5.4: wanted: {"node":">=4.2.0"} (current: {"node":"0.10.36","npm":"1.4.28"})
npm WARN engine babylon@7.0.0-beta.20: wanted: {"node":">=4.2.0"} (current: {"node":"0.10.36","npm":"1.4.28"})
jsdoc@3.5.4 node_modules/jsdoc

So I set the version to be the latest version of 5.x

@jpwsutton jpwsutton merged commit d9ab728 into eclipse:develop Sep 6, 2017
@tmulkern tmulkern deleted the remove-window-reference branch September 8, 2017 11:40
@eval
Copy link

eval commented Nov 3, 2017

@jpwsutton Instead of having the requirement for global.self, which makes the following fail:

(develop)$ node src/paho-mqtt.js
/Users/gert/src/paho.mqtt.javascript/src/paho-mqtt.js:2386
})(self);
   ^

ReferenceError: self is not defined
    at LibraryFactory (/Users/gert/src/paho.mqtt.javascript/src/paho-mqtt.js:2386:4)
    at ExportLibrary (/Users/gert/src/paho.mqtt.javascript/src/paho-mqtt.js:86:20)
    at Object.<anonymous> (/Users/gert/src/paho.mqtt.javascript/src/paho-mqtt.js:97:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:423:7)

How about setting this somewhere within: eval@67e92a9

jpwsutton added a commit that referenced this pull request Jul 23, 2018
* Removed reference to window and change to self (#116)

* Removed reference to window and change to self

Removed reference to window and change to self. This is to allow the
client to be used in Web Workers see:
https://developer.mozilla.org/en/docs/Web/API/Window/self

Signed-off-by: Tadhg Mulkern<tadhg.j.mulkern@gmail.com>

* Updated Client-hareness.js

Updated Client-hareness.js, set global.window = global; to global.self =
global;

* Update .travis.yml to fix build error

Update .travis.yml to fix build error, set nodejs version to use the
latest stable version of 5.x

* Refactored Properties using Object.defineProperties (#120)

* Refactored Properties using Object.defineProperties

Refactored Properties using Object.defineProperties as seen here

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties

This reduces the javascript code by removing repeated code. This will
have a impact on overall file size.

Signed-off-by: Tadhg Mulkern<tadhg.j.mulkern@gmail.com>

* Added additional cleanup of code

Added a piece of code to removed the need for all the Typed Array
checks, base on this method

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView
and from the Stackoverflow answer
https://stackoverflow.com/questions/15251879/how-to-check-if-a-variable-is-a-typed-array-in-javascript/29651223#29651223

* Remove the needed for reversing arrays for processing

Changed usages of push on this._buffered_msg_queue and this._msg_queue
to use unshift

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift,
removing the need to reverse the array to pop elements in fifo order

Signed-off-by: Tadhg Mulkern<tadhg.j.mulkern@gmail.com>

* Tweaking tests to run on travis.

Signed-off-by: James Sutton <james.sutton@uk.ibm.com>

* Fix typo (#128)

Signed-off-by: Nico Rikken <nico@nicorikken.eu>

* Moving to eslint and setting consistent code style in paho-mqtt.js as well as improving build

Signed-off-by: James Sutton <james.sutton@uk.ibm.com>

* Fixing tests to fully complete

Signed-off-by: James Sutton <james.sutton@uk.ibm.com>

* Variable message should not be global

Signed-off-by: Jannik Hunziker <jannik.hunziker@gmail.com>

* Function call should be local

Signed-off-by: Jannik Hunziker <jannik.hunziker@gmail.com>

* Variable client should not be global

Signed-off-by: Jannik Hunziker <jannik.hunziker@gmail.com>

* Variable client should not be global

Signed-off-by: Jannik Hunziker <jannik.hunziker@gmail.com>

* Updating Utility to use Automatic Reconnect & have visible console

Signed-off-by: James Sutton <james.sutton@uk.ibm.com>

* Fixing tests to work with updated interopability broker, updating .gitignore and readme.

Signed-off-by: James Sutton <james.sutton@uk.ibm.com>

* Adding Travis badge and fixing typo.

Signed-off-by: James Sutton <james.sutton@uk.ibm.com>

* Added subscribe/unsunbscribe support for multiple topics

Signed-off-by: Michael Zak <feanorr@gmail.com>

* Fixing typo in PR and adding a test case

Signed-off-by: James Sutton <james.sutton@uk.ibm.com>

* GDPR - Adding LocalStorage Warning to Utility

Signed-off-by: James Sutton <james.sutton@uk.ibm.com>

* Brings Paho one step closer to be supported in non-browser environments. (#153)

* Fix global object

Signed-off-by: Manuel Iglesias <manuelig@amazon.com>

* Remove references to self

Signed-off-by: Manuel Iglesias <manuelig@amazon.com>

* Fix arguments conversion to array

Signed-off-by: Manuel Iglesias <manuelig@amazon.com>

* Use simple in-memory fake of localStorage when global one is not available

Signed-off-by: Manuel Iglesias <manuelig@amazon.com>

* Updating version to 1.1.0 for Eclipse Photon

Signed-off-by: James Sutton <james.sutton@uk.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants