LocalStorage Not defined

Fuse version 1.2.1 (build 13974)
OSX

I’m having an issue where localStorage is not defined. Per the release notes a shim should be enabled - but it appears to not exist. This is causing ParseJS to fail. According to the docs and examples, i believe i’m doing everything correctly. This happens in preview and in the iOS Simulator.

[Viewport]: Error: ReferenceError: localStorage is not defined: Name: ReferenceError: localStorage is not defined
Error message: Uncaught ReferenceError: localStorage is not defined
File name: js/parse.min.js

implParse.js

var Parse = require('./parse.min.js').Parse;

Parse.initialize(
  "[...]",
  "[...]"
);
Parse.serverURL = '[...]';

module.exports = { ParseImpl: Parse }

Usage

var Parse = require("./implParse.js").ParseImpl;
var GameScore = Parse.Object.extend("Venues");
var gameScore = new GameScore();

gameScore.set("Name", "[...]");
gameScore.set("City", "Las Vegas");
gameScore.set("State", "NV");

gameScore.save(null, {
  success: function(gameScore) {
    console.log('New object created with objectId: ' + gameScore.id);
  },
  error: function(gameScore, error) {
    console.log('Failed to create new object, with error code: ' + error.message);
  }
});

Adding to this - when a shim is applied manually. XMLHTTPRequest also fails to work.

[Viewport]: Error: Error: Cannot make a request: No definition of XMLHttpRequest was found.: Name: Error: Cannot make a request: No definition of XMLHttpRequest was found.
Error message: Uncaught Error: Cannot make a request: No definition of XMLHttpRequest was found.
File name: js/parse.min.js
Line number: 8403

Hi Chris,

I have no idea what parse.min.js does with localStorage, but this little snippet works just fine in Fuse:

<App>
    <JavaScript>
    var myStorage = window.localStorage;
    myStorage.setItem("myCat", "Tom");
    console.log(myStorage.getItem("myCat"));
    myStorage.removeItem("myCat");
    </JavaScript>
</App>

I’m guessing the problem with XMLHttpRequest is going to turn out to be something similar.

FuseJS just uses localStorage for caching requests to/from the db. I removed ParseJS and inserted the snipped you posted into my mainview, and the problem remains the same. Adding to that i’ve done uno clean and uno doctor on the project and neither had a change. It seems the polyfills are nonexistent?

[Viewport]: Error: ReferenceError: window is not defined: Name: ReferenceError: window is not defined
Error message: Uncaught ReferenceError: window is not defined
File name: MainView.ux
Line number: 14
Source line:     var myStorage = window.localStorage;
JS stack trace: ReferenceError: window is not defined
    at Object._tempMethod (MainView.ux:14:21)
 in Fuse.Reactive.DiagnosticSubject<MainView.ux:14>
[Viewport]: Error: ReferenceError: window is not defined: Name: ReferenceError: window is not defined
Error message: Uncaught ReferenceError: window is not defined
File name: MainView.ux
Line number: 14
Source line:     var myStorage = window.localStorage;
JS stack trace: ReferenceError: window is not defined
    at Object._tempMethod (MainView.ux:14:21)
 in Fuse.Reactive.DiagnosticSubject<MainView.ux:14>

It’s a problem on your machine then, because that snippet works perfectly well on mine. Running uno clean is nice, but did you rebuild the project after you cleaned? Have you only tested local preview, or device previews too?