@storybook/addons
Advanced tools
Comparing version 4.0.0-alpha.1 to 4.0.0-alpha.2
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.AddonStore = undefined; | ||
exports.AddonStore = exports.mockChannel = undefined; | ||
@@ -21,4 +21,15 @@ var _keys = require('babel-runtime/core-js/object/keys'); | ||
var _global = require('global'); | ||
var _global2 = _interopRequireDefault(_global); | ||
var _storybookChannelMock = require('./storybook-channel-mock'); | ||
var _storybookChannelMock2 = _interopRequireDefault(_storybookChannelMock); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// Resolves to window in browser and to global in node | ||
exports.mockChannel = _storybookChannelMock2.default; | ||
var AddonStore = exports.AddonStore = function () { | ||
@@ -38,4 +49,3 @@ function AddonStore() { | ||
value: function getChannel() { | ||
// this.channel should get overwritten by setChannel if package versions are | ||
// correct and AddonStore is a proper singleton. If not, throw. | ||
// this.channel should get overwritten by setChannel. If it wasn't called (e.g. in non-browser environment), throw. | ||
if (!this.channel) { | ||
@@ -101,2 +111,13 @@ throw new Error('Accessing nonexistent addons channel, see https://storybook.js.org/basics/faq/#why-is-there-no-addons-channel'); | ||
exports.default = new AddonStore(); | ||
// Enforce addons store to be a singleton | ||
var KEY = '__STORYBOOK_ADDONS'; | ||
function getAddonsStore() { | ||
if (!_global2.default[KEY]) { | ||
_global2.default[KEY] = new AddonStore(); | ||
} | ||
return _global2.default[KEY]; | ||
} | ||
exports.default = getAddonsStore(); |
{ | ||
"name": "@storybook/addons", | ||
"version": "4.0.0-alpha.1", | ||
"version": "4.0.0-alpha.2", | ||
"description": "Storybook addons store", | ||
@@ -21,3 +21,7 @@ "keywords": [ | ||
"prepare": "node ../../scripts/prepare.js" | ||
}, | ||
"dependencies": { | ||
"@storybook/channels": "4.0.0-alpha.2", | ||
"global": "^4.3.2" | ||
} | ||
} |
@@ -0,1 +1,6 @@ | ||
// Resolves to window in browser and to global in node | ||
import global from 'global'; | ||
export mockChannel from './storybook-channel-mock'; | ||
export class AddonStore { | ||
@@ -11,4 +16,3 @@ constructor() { | ||
getChannel() { | ||
// this.channel should get overwritten by setChannel if package versions are | ||
// correct and AddonStore is a proper singleton. If not, throw. | ||
// this.channel should get overwritten by setChannel. If it wasn't called (e.g. in non-browser environment), throw. | ||
if (!this.channel) { | ||
@@ -61,2 +65,11 @@ throw new Error( | ||
export default new AddonStore(); | ||
// Enforce addons store to be a singleton | ||
const KEY = '__STORYBOOK_ADDONS'; | ||
function getAddonsStore() { | ||
if (!global[KEY]) { | ||
global[KEY] = new AddonStore(); | ||
} | ||
return global[KEY]; | ||
} | ||
export default getAddonsStore(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8363
7
178
2
+ Addedglobal@^4.3.2
+ Added@storybook/channels@4.0.0-alpha.2(transitive)
+ Addeddom-walk@0.1.2(transitive)
+ Addedglobal@4.4.0(transitive)
+ Addedmin-document@2.19.0(transitive)
+ Addedprocess@0.11.10(transitive)