web4more / html-navigator

Navigator api for node.js
https://npmjs.com/package/node-navigator
MIT License
3 stars 0 forks source link

[Milestone] v2 #9

Open jcbhmr opened 1 year ago

jcbhmr commented 1 year ago

Here's what I would love to see for a v2 of this package

History: https://www.npmjs.com/package/node-navigator?activeTab=versions Current state:

module.exports = {
    Navigator,
    NavigatorConcurrentHardware,
    NavigatorID,
    NavigatorLanguage,
    NavigatorOnLine,
    NavigatorGeolocation
};

Things to do for v2:

For the extension mixins, I'm imagining that this package is the "html-system-state" package (implements all things from https://html.spec.whatwg.org/multipage/system-state.html) and there's other packages that implement things from https://storage.spec.whatwg.org/ ("storage") and https://www.w3.org/TR/geolocation/ ("geolocation") etc.

I could see:

  1. This package has an additional packages/ folder with many sub-projects in it pertaining to each of those "geolocation" "storage", etc. navigator-related implementations
  2. Recommend other polyfills like a fictitious jcbhmr/geolocation (that I have yet to create) or something

For the documentation website, I'd love to see something that describes how each of the more complicated things gets its information. For instance, saying ".hardwareConcurrency uses os.cpus().length" or something is a 👍 from me! This can be generated from JSDoc-like /** */ comments using TypeDoc: https://typedoc.org/

I'd also like to see a docs/example/ folder that uses StackBlitz https://stackblitz.com/ to insta-launch a demo project that a potential user can use as a playground.

@skdhg Any other improvements you think could be made? Looking for ideas and feedback on my ideas

jcbhmr commented 1 year ago

Don't worry about existing consumers! That's what major versions are for, remember! 😉

{
  "dependencies": {
    // Will NOT auto-install v2. Stays on v1.0.1!
    "node-navigator": "^1.0.1"
    //                 👆
    // This is the default when 'npm install node-navigator' is run:
    // The "^" caret range is vN.x.x
  }
}
jcbhmr commented 1 year ago

Another good thing to do that I just thought would be good to mention is a comparison between https://www.npmjs.com/package/navigator by @coolaj86 (last published 12 years ago) and https://www.npmjs.com/package/node-navigator (ours). Even better would be to deprecate one and favor the other since they both seem to do a similar thing, but I don't know how to get in touch with @coolaj86 about a 12 year old package. 🤷‍♀️

Here's the entirety of https://www.npmjs.com/package/navigator?activeTab=code 😆

(function () {
  "use strict";

  var machine = "Macintosh"
    , arch = "Intel Mac OS X 10_6_7"
    , engine = "AppleWebKit/534.36 (KHTML, like Gecko) NodeJS/v0.4.7 Chrome/13.0.767.0 Safari/534.36";

  module.exports = {
      appCodeName: "Mozilla"
    , appName: "Netscape"
    , appVersion: "5.0 (" + machine + "; " + arch + ") " + engine
    , cookieEnabled: true
    , geolocation: undefined
      /*
        clearWatch
        getCurrentPosition
        watchPosition
      */
    , mimeTypes: []
      /*
      */
    , onLine: true
    , platform: "MacIntel"
    , plugins: []
      /*
      */
    , product: "Gecko"
    , productSub: "20030107"
    , userAgent: "Mozilla/5.0 (" + machine + "; " + arch + ") " + engine
    , vendor: "Joyent"
    , vendorSub: ""
  }
}());

Yeah, a comparison and a "why use this over the other one" would be a good idea. 😊

twlite commented 1 year ago

@jcbhmr I've sent you the transfer request of this repository, please check your email. I have also invited you to npm registry.

jcbhmr commented 1 year ago

@skdhg Awesome! ❤️ I have accepted that transfer and the npm thing. 👍