MMRIZE / MMM-CalendarExt3

MagicMirror calendar view module
MIT License
58 stars 22 forks source link

MM 2.25, node 20 HTMLElement is not defined #96

Closed sdetweil closed 1 year ago

sdetweil commented 1 year ago

see this error on startup

[04.10.2023 07:59.52.457] [ERROR] ReferenceError: HTMLElement is not defined
    at Object.<anonymous> (/home/sam/MagicMirror/modules/MMM-CalendarExt3/MMM-CalendarExt3.js:1:26)
eouia commented 1 year ago

Where did you meet this error? In backend log? Or console? Or validator?

eouia commented 1 year ago

If you get that message from a Validator(or lint or any DOM Parser), that is not my fault. HTMLElement is a standard native object of javascript in all browser, but some programmatic parser might not be able to handle it. https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement

Anyway, I can add a fallback routine for it in the next update.

const popoverSupported = (typeof HTMLElement !== 'undefined') ? HTMLElement.prototype.hasOwnProperty('popover') : false
sdetweil commented 1 year ago

this is just out of Electron in MM 2.25, no special code..

sdetweil commented 1 year ago

when MMM-RemoteControl is installed

[04.10.2023 10:41.45.729] [LOG]   Connecting socket for: MMM-Remote-Control
[04.10.2023 10:41.45.729] [LOG]   Starting node helper for: MMM-Remote-Control
[04.10.2023 10:41.45.736] [LOG]   Sockets connected & modules started ...
[04.10.2023 10:41.45.834] [LOG]   Launching application.
[1435830:1004/104145.861991:ERROR:object_proxy.cc(590)] Failed to call method: org.freedesktop.portal.Settings.Read: object_path= /org/freedesktop/po>
[04.10.2023 10:41.45.905] [ERROR] ERROR! Could not validate main module js file.
[04.10.2023 10:41.45.906] [ERROR] ReferenceError: HTMLElement is not defined
    at Object.<anonymous> (/home/sam/MagicMirror/modules/MMM-CalendarExt3/MMM-CalendarExt3.js:1:26)
    at Module._compile (node:internal/modules/cjs/loader:1271:14)
    at Object..js (node:internal/modules/cjs/loader:1326:10)
    at Module.load (node:internal/modules/cjs/loader:1126:32)
    at node:internal/modules/cjs/loader:967:12
    at Function._load (node:electron/js2c/asar_bundle:2:13327)
    at Module.require (node:internal/modules/cjs/loader:1150:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Class.loadModuleDefaultConfig (/home/sam/MagicMirror/modules/MMM-Remote-Control/node_helper.js:314:30)
    at /home/sam/MagicMirror/modules/MMM-Remote-Control/node_helper.js:268:26
    at FSReqCallback.oncomplete (node:fs:209:5)

the config..

     {
  module: "MMM-CalendarExt3",
  position: "bottom_bar",
  //disabled: true,
  title: "",
  config: {
    mode: "month",
    //instanceId: "basicCalendar",
    //locale: 'de-DE',
    maxEventLines: 5,
    firstDayOfWeek: 1,
    calendarSet: [], // ['us_holiday', 'abfall', 'mytest'],
  }
},
{
    module: 'MMM-Remote-Control',
    // uncomment the following line to show the URL of the remote control on the mirror
    // position: 'bottom_left',
    // you can hide this module afterwards from the remote control itself
    config: {
        customCommand: {},  // Optional, See "Using Custom Commands" below
        showModuleApiMenu: true, // Optional, Enable the Module Controls menu
        secureEndpoints: true, // Optional, See API/README.md
        // uncomment any of the lines below if you're gonna use it
        // customMenu: "custom_menu.json", // Optional, See "Custom Menu Items" below
        //apiKey: "12345", // Optional, See API/README.md for details
        // classes: {} // Optional, See "Custom Classes" below
    }
},
eouia commented 1 year ago

MMM-Remote-Control tries to load(require) module file in its node_helper directly.

https://github.com/Jopyth/MMM-Remote-Control/blob/fb20bd483540ebb6eef0c8495cecd807d5dd1e0e/node_helper.js#L314C17-L314C48

Of course, it will fail because HTMLElement is not supported in NodeJS. Should I support the loading module in the NodeJS environment? (Maybe yes. Anyway, I'll add the code above in the next update)

By the way, that kind of approach of MMM-Remote-Control is the easiest way, but I think it would be better to use improved JS Parser instead of loading module directly.