pnotify icon indicating copy to clipboard operation
pnotify copied to clipboard

ES5 - ES6 Installation Errors

Open jamesta696 opened this issue 4 years ago • 5 comments

Having errors on simple ES5/6 installation. Please see screenshots. Any way to get this fixed?

ES5 Installation image image

ES6 Installation image image

jamesta696 avatar Nov 30 '20 23:11 jamesta696

Below is working for me...

<!DOCTYPE html>
<html lang="en">

<head>
    <title>W3.CSS Template</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="node_modules/@pnotify/core/dist/PNotify.css" rel="stylesheet" type="text/css" />
    <link href="node_modules/@pnotify/mobile/dist/PNotifyMobile.css" rel="stylesheet" type="text/css" />
    <script type="module">
        import * as PNotify from './node_modules/@pnotify/core/dist/PNotify.js';
        import * as PNotifyMobile from './node_modules/@pnotify/mobile/dist/PNotifyMobile.js';
    </script>

     <script type="text/javascript">
        window.addEventListener('DOMContentLoaded', () => {
            PNotify.defaultModules.set(PNotifyMobile, {});
            PNotify.alert({
                text: 'Notice me, senpai!'
            });
        });
    </script>
</head>

<body>
</body>

</html>

if you want another module like Confirm, so you must add link for PnotifyConfirm.css

    <link href="node_modules/@pnotify/confirm/dist/PNotifyConfirm.css" rel="stylesheet" type="text/css" />

also import module inside module area like this:

    <script type="module">
        import * as PNotify from './node_modules/@pnotify/core/dist/PNotify.js';
        import * as PNotifyMobile from './node_modules/@pnotify/mobile/dist/PNotifyMobile.js';
        import * as PNotifyConfirm'./node_modules/@pnotify/confirm/dist/PNotifyConfirm.js';
    </script>

and after export, you can use like this:

  <script type="text/javascript">
        window.addEventListener('DOMContentLoaded', () => {

            PNotify.defaultModules.set(PNotifyMobile, {});
            const notice = PNotify.notice({
                title: 'Confirmation Needed',
                text: 'Are you sure?',
                icon: 'fas fa-question-circle',
                hide: false,
                destroy: true,
                closer: false,
                sticker: false,
                modules: new Map([
                    ...PNotify.defaultModules,
                    [PNotifyConfirm, {
                        confirm: true
                    }]
                ])
            });
            notice.on('pnotify:confirm', () => alert('Ok, cool.'));
            notice.on('pnotify:cancel', () => alert('Oh ok. Chicken, I see.'));
        });
    </script>

for another module like desktop, you can doing like above step... but you must check apropriate file as you expected...

azzahrah avatar Feb 09 '21 02:02 azzahrah

Hi, Since no devs had answered me I moved on to another library but I'll try this again when I get to the point I need it again. I appreciate your feedback sir.

jamesta696 avatar Feb 09 '21 04:02 jamesta696

@jamesta696 , can you telme what pnotify alternate?

azzahrah avatar Feb 09 '21 09:02 azzahrah

This might not be a perfect fix but it takes care of the compile-time errors for my angular application.

node_modules/@pnotify/core/Stack.d.ts you will have to modify line 1 to import { Notice } from './';

replace line 193 to 208 with the code below swap( one: Notice, theOther: Notice, immediate: boolean, waitAfter: boolean ): Promise<unknown>;

replace line 220 with the following fire(event: string, detail: {}): void;

In @pnotify/core/index.d.ts file replace line 250 with open(immediate?: boolean): Promise<unknown>; and replace line 261 to 265 with close( immediate?: boolean, timerHide?: boolean, waitAfterward?: boolean ): Promise<unknown>;

This fix worked for "pnotify": "^5.2.0", hopefully the next update will fix these error. Ummmm you might have to redo this again if you reinstall the same package.

samuelsonokoi avatar Mar 06 '21 13:03 samuelsonokoi

Today we wanted to update from 3.0.0 to 5.2.0, but we can't because of the same error described above for ES5 Installation. We used the code described for Vanilla JS (ES5). We also tried 5.1, 5.0, 4.0.1 ...same error, so I assume we'll have to wait until we port our code to ES2015 (ES6).

DJDaveMark avatar Apr 19 '22 13:04 DJDaveMark