@cardcore/client
Advanced tools
Comparing version 0.0.1-1f746c46 to 0.0.1-3ec581c3
@@ -12,2 +12,16 @@ "use strict"; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _clientPoll = require("./client-poll"); | ||
Object.keys(_clientPoll).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _clientPoll[key]; | ||
} | ||
}); | ||
}); | ||
var _game = require("@cardcore/game"); | ||
@@ -17,3 +31,3 @@ | ||
var _ssbKeys = require("ssb-keys"); | ||
var _ssbKeys = require("@streamplace/ssb-keys"); | ||
@@ -208,6 +222,37 @@ var _ssbKeys2 = _interopRequireDefault(_ssbKeys); | ||
var CLIENT_GENERATE_IDENTITY = exports.CLIENT_GENERATE_IDENTITY = "CLIENT_GENERATE_IDENTITY"; | ||
var CARDCORE_IDENTITY = "CARDCORE_IDENTITY"; | ||
var clientGenerateIdentity = exports.clientGenerateIdentity = function clientGenerateIdentity() { | ||
var storage = void 0; | ||
if ((typeof localStorage === "undefined" ? "undefined" : _typeof(localStorage)) === "object") { | ||
storage = localStorage; | ||
} else { | ||
// noop i guess? idk this only happens in jsdom? | ||
storage = { | ||
getItem: function getItem() { | ||
return null; | ||
}, | ||
setItem: function setItem() { | ||
return null; | ||
}, | ||
removeItem: function removeItem() { | ||
return null; | ||
} | ||
}; | ||
} | ||
var keys = void 0; | ||
if (storage.getItem(CARDCORE_IDENTITY)) { | ||
try { | ||
keys = JSON.parse(storage.getItem(CARDCORE_IDENTITY)); | ||
} catch (e) { | ||
console.error("error parsing cardcore identity, clearing", e); | ||
storage.removeItem(CARDCORE_IDENTITY); | ||
} | ||
} | ||
if (!keys) { | ||
keys = _ssbKeys2.default.generate(); | ||
storage.setItem(CARDCORE_IDENTITY, JSON.stringify(keys)); | ||
} | ||
return { | ||
type: CLIENT_GENERATE_IDENTITY, | ||
keys: _ssbKeys2.default.generate() | ||
keys: keys | ||
}; | ||
@@ -214,0 +259,0 @@ }; |
@@ -29,3 +29,4 @@ "use strict"; | ||
keys: {}, | ||
started: false | ||
started: false, | ||
loadingState: true | ||
}; | ||
@@ -83,2 +84,14 @@ | ||
if (action.type === clientActions.CLIENT_LOAD_STATE_START) { | ||
return Object.assign({}, state, { | ||
loadingState: true | ||
}); | ||
} | ||
if (action.type === clientActions.CLIENT_LOAD_STATE_DONE || action.type === actions.CREATE_GAME) { | ||
return Object.assign({}, state, { | ||
loadingState: false | ||
}); | ||
} | ||
if (action.type === actions.PLAY_CREATURE) { | ||
@@ -85,0 +98,0 @@ return Object.assign({}, state, { |
{ | ||
"name": "@cardcore/client", | ||
"version": "0.0.1-1f746c46", | ||
"version": "0.0.1-3ec581c3", | ||
"description": "streamcards client", | ||
@@ -13,3 +13,6 @@ "main": "dist/index.js", | ||
}, | ||
"gitHead": "1f746c46c9911e36a1e9be89edf6da902e8ff20f" | ||
"dependencies": { | ||
"@streamplace/ssb-keys": "^7.0.16" | ||
}, | ||
"gitHead": "3ec581c3f6f424e67d96dac06f7bcf5f3eb6f200" | ||
} |
import { playCreature } from "@cardcore/game"; | ||
import { traverseSecret, target as targetHelper } from "@cardcore/util"; | ||
import ssbKeys from "ssb-keys"; | ||
import ssbKeys from "@streamplace/ssb-keys"; | ||
export * from "./client-poll"; | ||
/** | ||
@@ -109,6 +112,31 @@ * This file should contain web-specific actions extranious to the game state | ||
export const CLIENT_GENERATE_IDENTITY = "CLIENT_GENERATE_IDENTITY"; | ||
const CARDCORE_IDENTITY = "CARDCORE_IDENTITY"; | ||
export const clientGenerateIdentity = () => { | ||
let storage; | ||
if (typeof localStorage === "object") { | ||
storage = localStorage; | ||
} else { | ||
// noop i guess? idk this only happens in jsdom? | ||
storage = { | ||
getItem: () => null, | ||
setItem: () => null, | ||
removeItem: () => null | ||
}; | ||
} | ||
let keys; | ||
if (storage.getItem(CARDCORE_IDENTITY)) { | ||
try { | ||
keys = JSON.parse(storage.getItem(CARDCORE_IDENTITY)); | ||
} catch (e) { | ||
console.error("error parsing cardcore identity, clearing", e); | ||
storage.removeItem(CARDCORE_IDENTITY); | ||
} | ||
} | ||
if (!keys) { | ||
keys = ssbKeys.generate(); | ||
storage.setItem(CARDCORE_IDENTITY, JSON.stringify(keys)); | ||
} | ||
return { | ||
type: CLIENT_GENERATE_IDENTITY, | ||
keys: ssbKeys.generate() | ||
keys | ||
}; | ||
@@ -115,0 +143,0 @@ }; |
@@ -11,3 +11,4 @@ import * as actions from "@cardcore/game"; | ||
keys: {}, | ||
started: false | ||
started: false, | ||
loadingState: true | ||
}; | ||
@@ -69,2 +70,19 @@ | ||
if (action.type === clientActions.CLIENT_LOAD_STATE_START) { | ||
return { | ||
...state, | ||
loadingState: true | ||
}; | ||
} | ||
if ( | ||
action.type === clientActions.CLIENT_LOAD_STATE_DONE || | ||
action.type === actions.CREATE_GAME | ||
) { | ||
return { | ||
...state, | ||
loadingState: false | ||
}; | ||
} | ||
if (action.type === actions.PLAY_CREATURE) { | ||
@@ -71,0 +89,0 @@ return { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
52130
13
864
1
8
+ Added@streamplace/chloride@2.2.12(transitive)
+ Added@streamplace/private-box@0.2.1(transitive)
+ Added@streamplace/ssb-keys@7.0.21(transitive)
+ Addedcall-bind@1.0.8(transitive)
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addedchloride-test@1.2.4(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addeded2curve@0.1.4(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.7(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-electron@2.2.2(transitive)
+ Addedisarray@2.0.5(transitive)
+ Addedjson-buffer@2.0.11(transitive)
+ Addedjson-stable-stringify@1.2.1(transitive)
+ Addedjsonify@0.0.1(transitive)
+ Addedlibsodium@0.7.15(transitive)
+ Addedlibsodium-wrappers@0.7.15(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedsha.js@2.4.112.4.5(transitive)
+ Addedsodium-browserify@1.3.0(transitive)
+ Addedsodium-browserify-tweetnacl@0.2.6(transitive)
+ Addedsodium-chloride@1.1.2(transitive)
+ Addedtweetnacl@0.14.51.0.3(transitive)
+ Addedtweetnacl-auth@0.3.1(transitive)