alepop / elm-notification

Elm Native bindings to Notification API
BSD 3-Clause "New" or "Revised" License
10 stars 1 forks source link

ReferenceError: _alepop$elm_notification$Native_Notification is not defined #2

Open geekyme opened 6 years ago

geekyme commented 6 years ago

I downloaded the dependency manually and added it into elm-stuff and updated exact-dependencies.json. I couldn't use https://github.com/gdotdesign/elm-github-install as I am on cygwin.

elm-package.json:

{
    "version": "1.0.0",
    "summary": "helpful summary of your project, less than 80 characters",
    "repository": "https://github.com/user/project.git",
    "license": "BSD3",
    "source-directories": [
        "src"
    ],
    "exposed-modules": [],
    "dependencies": {
        "NoRedInk/elm-decode-pipeline": "3.0.0 <= v < 4.0.0",
        "elm-community/elm-datepicker": "7.2.0 <= v < 8.0.0",
        "elm-lang/core": "5.0.0 <= v < 6.0.0",
        "elm-lang/html": "2.0.0 <= v < 3.0.0",
        "elm-lang/http": "1.0.0 <= v < 2.0.0",
        "elm-lang/websocket": "1.0.2 <= v < 2.0.0",
        "justinmimbs/elm-date-extra": "2.0.3 <= v < 3.0.0",
        "krisajenkins/elm-exts": "27.4.0 <= v < 28.0.0",
        "alepop/elm-notification": "1.0.0 <= v < 2.0.0"
    },
    "elm-version": "0.18.0 <= v < 0.19.0"
}

elm-stuff/exact-dependencies.json:

{
  "elm-lang/html": "2.0.0",
  "elm-lang/websocket": "1.0.2",
  "justinmimbs/elm-date-extra": "2.0.3",
  "elm-lang/http": "1.0.0",
  "NoRedInk/elm-decode-pipeline": "3.0.0",
  "elm-community/elm-datepicker": "7.2.0",
  "elm-lang/core": "5.1.1",
  "elm-lang/trampoline": "1.0.1",
  "krisajenkins/elm-exts": "27.4.0",
  "elm-lang/virtual-dom": "2.0.4",
  "alepop/elm-notification": "1.0.0"
}

When I run the project, I get following runtime error:

ReferenceError: _alepop$elm_notification$Native_Notification is not defined

  6108 |    });
  6109 | _elm_lang$core$Native_Platform.effectManagers['Task'] = {pkg: 'elm-lang/core', init: _elm_lang$core$Task$init, onEffects: _elm_lang$core$Task$onEffects, onSelfMsg: _elm_lang$core$Task$onSelfMsg, tag: 'cmd', cmdMap: _elm_lang$core$Task$cmdMap};
  6110 | 
> 6111 | var _alepop$elm_notification$Notification$create = _alepop$elm_notification$Native_Notification.spawnNotification;
  6112 | var _alepop$elm_notification$Notification$defaultOptions = {dir: 'auto', lang: _elm_lang$core$Maybe$Nothing, badge: _elm_lang$core$Maybe$Nothing, body: _elm_lang$core$Maybe$Nothing, tag: _elm_lang$core$Maybe$Nothing, icon: _elm_lang$core$Maybe$Nothing, image: _elm_lang$core$Maybe$Nothing, vibrate: _elm_lang$core$Maybe$Nothing, renotify: false};
  6113 | var _alepop$elm_notification$Notification$requestPermission = _alepop$elm_notification$Native_Notification.requestPermission;
  6114 | var _alepop$elm_notification$Notification$getPermission = _alepop$elm_notification$Native_Notification.getPermission;

All my other dependencies work

alepop commented 6 years ago

@geekyme hello! Can you please try to use the source files from this commit https://github.com/alepop/elm-notification/tree/3d74f9bb81f7bb2ee1b9326490835cc38516f8aa ?

geekyme commented 6 years ago

Ok I just downloaded those source files from that commit.

I setup my project and manually loaded the library into the directory folder:

screen shot 2017-09-16 at 2 54 00 am

Now i'm getting this error:

screen shot 2017-09-16 at 2 52 36 am
geekyme commented 6 years ago

The only way I've found to have work is to copy your source files (Native/Notification.js and Notification.elm) out into my project src, and declaring my project with:

native-modules: true

As shown in https://github.com/gabrielperales/elm-native-module/blob/master/README.md.

Out of ideas how to do this without elm-github-install.

gurgl commented 6 years ago

I did the same thing as original poster - as there is no mechanism to publish packages locally (wo lots of npm/grunt/bower .js ninja tools)

i think the problem lies in Notification.js (i might be wrong) :

var _z_alepop$elm_notification$Native_Notification = function() {

...which does not correspond the provided namespace in the project given by the github url in elm-package.json:

"repository": "https://github.com/alepop/elm-notification.git",

...elm beliews the namespace is "alepop" and will try to refer to the native binding with "_alepop" in the generated .js code.

Interresting thing is that the "_z" probebly is there for a reason. If we correct the Notification.js to have prefix "_alepop" we still get the error. It seems the order of code comes in to play. By changing the github url to "z_alepop" and leave Notification.js as is - it works.

PS. ...also remember the notiifcations api only works on a legit host - just running it from a file path will not work properly DS.