MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Any plan to replace "request" and "moment"?

    Scheduled Pinned Locked Moved Unsolved Feature Requests
    61 Posts 8 Posters 35.2k Views 8 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • karsten13K Offline
      karsten13 @swvalenti
      last edited by

      @swvalenti one addition: Only modules are affected which rely on that request is intalled in core mm (which is a dirty hack of the module developer), modules which install request on their own are not!

      S 1 Reply Last reply Reply Quote 0
      • S Offline
        sdetweil @karsten13
        last edited by

        @karsten13 said in Any plan to replace "request" and "moment"?:

        which is a dirty hack of the module developer

        no… don’t say it that way…

        lack of experience on the part of the developer…

        it just worked, so they didn’t know to ask if there was a more correct way…

        I had that problem early on in my nodejs development too…

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        karsten13K 1 Reply Last reply Reply Quote 1
        • karsten13K Offline
          karsten13 @sdetweil
          last edited by

          @sdetweil doing this in some of my own modules so I’m allowed to say this ;)

          S 1 Reply Last reply Reply Quote 0
          • S Offline
            sdetweil @karsten13
            last edited by

            @karsten13 doing it ON PURPOSE is a hack!!

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            0m4r0 1 Reply Last reply Reply Quote 0
            • 0m4r0 Offline
              0m4r Module Developer @sdetweil
              last edited by

              @sdetweil @sdetweil I am not convinced about both of your points of view. I mean technically yes.

              But… looking into the modules themselves, they are solely made to work with the MagicMirror code base (99% of the cases)
              What is the point to bloat the size of the installation with the same node module installed over and over again? when on, “global” can be used and relied upon? (well, yeah, I agree, “this situation” is one reason for it!). But why trade-off convenience over complexity?

              I see it as a part of the Magic Mirror ecosystem, provide some common “code” to be used by everyone to both ease the development and the set-up of it.

              As mentioned in the other thread, old legacy modules will probably stop working - forking them or re-doing them will fix them. This not only pushes forward the advancement of the whole MagicMirror tech stack, but it may strengthen the community and really push it to hold together and upgrade, modernize the code of the modules.

              bottom line, nobody says it is going to be easy, but it is a big opportunity.

              https://github.com/0m4r

              S 1 Reply Last reply Reply Quote 0
              • S Offline
                sdetweil @0m4r
                last edited by

                @0m4r said in Any plan to replace "request" and "moment"?:

                What is the point to bloat the size of the installation with the same node module installed over and over again

                it is NOT installed over and over

                npm install start with the module folder and says

                is it here?   
                   no   
                     look in the parent folders, 1 by 1, looking for a node_modules folder
                       is it there?
                          yes, stop
                   yes, 
                     stop. 
                

                so it will only be installed once…

                in the near term with all the old modules ‘assuming’ is was installed,
                it’ll have to be installed in the MM/node_modules (but only once)

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                0m4r0 1 Reply Last reply Reply Quote 1
                • 0m4r0 Offline
                  0m4r Module Developer @sdetweil
                  last edited by

                  @sdetweil yeah, I guess, I was not clear enough. And I think we are saying the same thing.

                  Installing “request” in the MM root folder solves the problem, and this is how I do run my magic mirror from the development branch at this very moment.

                  What I mean is that if the module is removed from the “MM/node_modules” folder (the last “parent” level for all modules), every single module will most likely need to install it on its own node_modules folder. This is where I meant it may blow up the size of the MM installation (modules included!)

                  I hope this clarifies my prev post :)

                  https://github.com/0m4r

                  S 1 Reply Last reply Reply Quote 0
                  • S Offline
                    sdetweil @0m4r
                    last edited by

                    @0m4r said in Any plan to replace "request" and "moment"?:

                    What I mean is that if the module is removed from the “MM/node_modules” folder (the last “parent” level for all modules), every single module will most likely need to install it on its own node_modules folder. This is where I meant it may blow up the size of the MM installation (modules included!)

                    yeh, you have NO idea how big other stuff is already…

                    but, this is the design… there is virtual memory, and paging and … to offset these

                    now, remember, we are NOT making an installable bundle from all this, just a runtime layout

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    1 Reply Last reply Reply Quote 0
                    • BKeyportB Offline
                      BKeyport Module Developer @0m4r
                      last edited by BKeyport

                      God, the alternatives to moment are head spinning. I don’t understand 'em, and can’t even get basic functions to work right within jsfiddle.net (Example: Date1 <= Date2 crashes jsfiddle)

                      For now, I’ve added package.json to both modules, and if needed, will update my install instructions.

                      The "E" in "Javascript" stands for "Easy"

                      1 Reply Last reply Reply Quote 1
                      • M Offline
                        MMRIZE
                        last edited by

                        For the moment, maybe luxon or date-fns could be the alternative. (And there are several other modules also.)

                        However, After releasing TC39’s new proposal (currently stage 3. https://tc39.es/ecma402/), Browsers and NodeJS will have the native features of handling dates. So I would recommend waiting.

                        At this moment, native implementing moment’s features is not easy. Though Intl could handle many aspects of moment already, the unsolved big issue is, current Date and Intl features are still not perfect for localization, like weekOfYear, startdayOfWeek and so on. (Those will be solved by ECMA402)

                        0m4r0 cowboysdudeC 2 Replies Last reply Reply Quote 0
                        • 0m4r0 Offline
                          0m4r Module Developer @MMRIZE
                          last edited by

                          @mmrize agree to support native browser APIs, but I do also believe we cannot assume everyone is running an up-to-date system for their magic mirror.

                          One idea could be to provide a wrapper module to abstract the “behind the scene” tool to manipulate dates, but it may turn out to be quite of an effort and limiting the module developer.

                          https://github.com/0m4r

                          1 Reply Last reply Reply Quote 0
                          • cowboysdudeC Offline
                            cowboysdude Module Developer @MMRIZE
                            last edited by

                            @mmrize Well we all know how ‘browsers supporting’ all work out LOL

                            Some do…some don’t.

                            S 1 Reply Last reply Reply Quote 0
                            • S Offline
                              sdetweil @cowboysdude
                              last edited by

                              @cowboysdude AND for mm, the calendar date work is done OUTSIDE the browser in the node helper. soooooo, still need something

                              Sam

                              How to add modules

                              learning how to use browser developers window for css changes

                              1 Reply Last reply Reply Quote 0
                              • M Offline
                                MMRIZE
                                last edited by

                                @cowboysdude @sdetweil
                                Fortunately, We need to consider only ‘Chromium’ and ‘node’ at most. (Firefox already implements almost-complete Intl features. For Safari… who cares.)
                                And in this case, Intl (and the Temporal in the future) suggests the STANDARD WAY how to handle date/time for L10N/I18N in Javascript environments(includes browsers and nodeJS). So I believe it has worthy looking inside.

                                Once (yesterday), I’ve tried to rewrite clock module and calendar module without momentjs or any other 3rd party library, only with Date and Intl.

                                The start was not so bad. I could rewrite many features with only Date and Intl.
                                Where I stuck was the showWeek config feature. It has to show the ordinal number of weeks of the year. To calculate ISOweek is not difficult. But in some areas, like the US. they never use the ISO system. damn!. To calculate the conventional US week number, additional pieces of information are needed. (read this.) Current Intl has not yet that feature. I’m waiting for Temporal and enhanced Intl releasing.

                                One solution might be to obtain additional information needed for conventional calculation from the user by configuration. At this point, I stopped rewriting. It needs to change config.js and that was not my first intention.

                                A usual solution might be to use 3rd party library like momentjs or luxon. It is easier.

                                However it’s good to read this from the momentjs (https://momentjs.com/docs/#/-project-status/future/) I agree to him, In the near future, native JS features Date, Intl, Temporal will be a standard.

                                S BKeyportB 2 Replies Last reply Reply Quote 0
                                • S Offline
                                  sdetweil @MMRIZE
                                  last edited by

                                  @mmrize i don’t see whats so hard on week of the year.

                                  what day of the week is 1/1, subtract that from 7, and then that is the start of the weekly cycle.
                                  til you run out of days to count.

                                  we don’t use it normally, but its still the week of the year. has nothing to do with month. that is a different scheme

                                  my science teacher in high school had a great topic, measurement…
                                  you can measure anything with anything… just record what the tool was

                                  we were required to measure everything in broomstick handles, broomstick #1 in the lab to be precise.

                                  we could subdivide broomstick #1 however we wanted to provide more accuracy, as long as we wrote down the algorithm. (divide by 3, 6, 10?.. , 1000 ml beaker height, whatever)

                                  the last week doesn’t run over into a new year, it ENDS when the year ends.
                                  just so happens that week #1 of the NEXT year is the same logical week, but who cares, as we started counting from 1 again.

                                  Sam

                                  How to add modules

                                  learning how to use browser developers window for css changes

                                  M BKeyportB 2 Replies Last reply Reply Quote 0
                                  • M Offline
                                    MMRIZE @sdetweil
                                    last edited by MMRIZE

                                    @sdetweil said in Any plan to replace "request" and "moment"?:

                                    what day of the week is 1/1, subtract that from 7, and then that is the start of the weekly cycle.

                                    ISOWeek is easy. Conventional week is the problem.

                                    For example, in the United States, Sunday is the first day of the week. The week with January 1st in it is the first week of the year.

                                    In France, Monday is the first day of the week, and the week with January 4th is the first week of the year. It means January 1st could be the last week of the last year sometimes. And Jan. 10th could be the first week in certain year.

                                    And in other countries, there is also their own rule.

                                    This might be important in some European countries, because they use week number in real life (“my vacation ends 23. Weeks“)

                                    BKeyportB 1 Reply Last reply Reply Quote 0
                                    • BKeyportB Offline
                                      BKeyport Module Developer @MMRIZE
                                      last edited by

                                      @mmrize I care about safari. 😢😢😢

                                      The "E" in "Javascript" stands for "Easy"

                                      0m4r0 1 Reply Last reply Reply Quote 0
                                      • BKeyportB Offline
                                        BKeyport Module Developer @sdetweil
                                        last edited by

                                        @mmrize said in Any plan to replace "request" and "moment"?:

                                        Once (yesterday), I’ve tried to rewrite clock module and calendar module
                                        without momentjs or any other 3rd party library, only with Date and Intl.

                                        The start was not so bad. I could rewrite many features with only Date and Intl.
                                        Where I stuck was the showWeek config feature. It has to show the ordinal number of weeks of the year. To calculate ISOweek is not difficult. But in some areas, like the US. they never use the ISO system. damn!. To calculate the conventional US week number, additional pieces of information are needed. (read this.) Current Intl has not yet that feature. I’m waiting for Temporal and enhanced Intl releasing.

                                        Where I’m getting stuck with Luxon is basic comparision of dates:

                                        Is this time the same or before that time? 
                                        Moment: m1.isSameOrBefore(m2) (works) 
                                        Luxon:  dt1 <= dt2 (Crashes jsfiddle) 
                                        

                                        and querying luxon for the locale’s weekday strings is always returning Monday as first, even though it will treat the week correctly otherwise.

                                        luxon.info.weekdays('short') == Mon
                                        

                                        The "E" in "Javascript" stands for "Easy"

                                        1 Reply Last reply Reply Quote 0
                                        • BKeyportB Offline
                                          BKeyport Module Developer @MMRIZE
                                          last edited by

                                          @mmrize said in Any plan to replace "request" and "moment"?:

                                          @sdetweil said in Any plan to replace "request" and "moment"?:

                                          what day of the week is 1/1, subtract that from 7, and then that is the start of the weekly cycle.

                                          ISOWeek is easy. Conventional week is the problem.

                                          For example, in the United States, Sunday is the first day of the week. The week with January 1st in it is the first week of the year.

                                          In France, Monday is the first day of the week, and the week with January 4th is the first week of the year. It means January 1st could be the last week of the last year sometimes. And Jan. 10th could be the first week in certain year.

                                          And in other countries, there is also their own rule.

                                          This might be important in some European countries, because they use week number in real life (“my vacation ends 23. Weeks“)

                                          Moment handles this automatically. Everyone else, not so much.

                                          The "E" in "Javascript" stands for "Easy"

                                          1 Reply Last reply Reply Quote 0
                                          • 0m4r0 Offline
                                            0m4r Module Developer @BKeyport
                                            last edited by

                                            @bkeyport many do, and you are not alone.
                                            But how many people are running MM in a safari browser?

                                            I guess this is the relevant point here :)

                                            https://github.com/0m4r

                                            BKeyportB 1 Reply Last reply Reply Quote 0

                                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                            With your input, this post could be even better 💗

                                            Register Login
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 4 / 4
                                            • First post
                                              Last post
                                            Enjoying MagicMirror? Please consider a donation!
                                            MagicMirror created by Michael Teeuw.
                                            Forum managed by Sam, technical setup by Karsten.
                                            This forum is using NodeBB as its core | Contributors
                                            Contact | Privacy Policy