Closed oliverfoster closed 5 years ago
We discussed this internally today and are floating the idea of a separate repo for a NodeJS-specific xAPI wrapper. There's a limited functionality one that we use internally, but will let you know after we talk about it more tomorrow morning.
Also, I used your branch this morning and some of the response callbacks were getting dropped when stress testing. Switching to an axios-driven internal wrapper resolved the issue, how are requests being handled for the Node version?
Superb.
how are requests being handled for the Node version?
There is a partial shim for the xmlhttprequest api https://github.com/adlnet/xAPIWrapper/pull/126/files#diff-1b2039be21a4454c52d6b497832996ebR1397 I'm not surprised it drops callbacks, but i'm sure it'd be quite easy to fix with a replacement as you said.
I think the biggest barriers to using this wrapper in node are:
window
global throughoutwindow.location
needs to not be used in nodeOther than that it's pretty nice. It would work in all environments just by changing the scope slightly by always distributing it as a bundled library rather than separate but dependent files.
I really don't mind doing the work, I just need someone to help me figure out an order to submit the prs, a review process and what's possible with the current user requirements and the current state of the code.
Considering that the work required here is pretty straight forward, would it not make sense to use the same well tested wrapper for both environments rather than releasing an entirely new code base?
A new branch was created for this project.
@FlorianTolk what did you envisage for the NodeCompatibleWrapper branch?
I have series of PR's going into master to move this idea forward. Did you want me to re-base them to the other branch?
I could do with an answer to the question of browser support (#135) and wrapping functions (#137).
This new branch is meant as a playground where most these new PRs can be directed at, as we do not want to make any major functionality changes to the main. To quote @vbhayden 's response to another PR, the only major changes we want to push to the main branch are:
The new branch was created to ingest any other changes members of the community would like to make to the xAPI Wrapper. Thanks!
Thanks for getting back to me. This branch would need to be published to npm to provide standard node support. It'd either need to replace the master publication or be a separate version lineage.
Can someone comment on the status of this thread? There does not appear to be another branch called NodeCompatibleWrapper and the package (xapiwrapper-node) published by @oliverfoster does not appear to be up to date with his repo (the github page for it has disappeared too)
Well. My attempt failed. There was too much fear that dropping support for older browsers would somehow break the library. Then there was mention of a node version of the wrapper used internally and that it would be released instead of making this one compatible.
Nothing much happened after that and I gave up.
Thanks for the update. I'll assume that npm package is functionally the same but that your later commits were compatibility oriented
67
Works undertaken
window.location
in nodeXMLHttpRequest
ADL.xapiutil
Notes
xapiwrapper
out of the global scope as they shouldn't be declared there.Date
object withDate.prototype.toISOString
but instead defining aDateToISOString
function.text-encoding
module. This is as it adds support for multiple encoding types when I assume we'll realistically ever needutf8
encoding. For that extra support in internet explorer the module brings a lot of complexity across the node<->browser boundary. I've replaced it with a much simplerutf8
only polyfil from https://gist.github.com/Yaffle/5458286.xapiwrapper.min.js
text-encoding
.requirejs
,commonjs
andwindow.ADL
global environments.ADL.launch
in nodexapiwrapper.js
const ADL = require('xapiwrapper');
if published on npm.Intellisense
The functions which wrap each file stop intellisense from working. The wrapping functions are required if a developer is using the files individually in a browser such that the code in each file does not bleed into the global scope. The wrapping functions stop intellisense as they need to be executed by the intellisense interpreter for their modifications to the global ADL namespace to be produced (as far as I can tell). The grunt file now removes these wrapping functions when producing
xapiwrapper.min.js
andxapiwrapper.js
. The grunt file removes these function wrappers as they are supplanted by the umd wrapper function. By removing these functions and producing a separate, unminified file containing all of the comments, intellisense works as it should.