Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@fower/store

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fower/store - npm Package Compare versions

Comparing version 1.29.0 to 1.30.0

6

dist/index.d.ts

@@ -1,2 +0,2 @@

import { FowerPlugin, Configuration, Theme, CSSObject } from '@fower/types';
import { FowerPlugin, Configuration, Theme, CSSObject, ModeType } from '@fower/types';
import { PartialThemeConfig, PartialConfig } from './types';

@@ -6,2 +6,4 @@ declare type Strategy = 'replace' | 'merge' | 'deepmerge';

config: Configuration;
atomCache: Map<string, any>;
getAtomIds: () => string[];
compositions: Map<string, any>;

@@ -13,2 +15,4 @@ get theme(): Theme;

setTheme: (partialThemeConfig: PartialThemeConfig) => void;
getMode: () => string;
setMode: (mode: ModeType) => void;
use: (...plugins: FowerPlugin[]) => void;

@@ -15,0 +19,0 @@ addAtom: (matcher: string | RegExp, handleAtomOrStyleObject: FowerPlugin['handleAtom'] | CSSObject) => FowerPlugin;

@@ -8,2 +8,3 @@ 'use strict';

var deepmerge = _interopDefault(require('deepmerge'));
var utils = require('@fower/utils');

@@ -44,2 +45,4 @@ function _defineProperties(target, props) {

var modeCacheKey = 'fower-mode';
var Store = /*#__PURE__*/function () {

@@ -52,11 +55,39 @@ function Store() {

inline: false,
important: false,
mode: {
currentMode: 'light',
autoDarkMode: {
enabled: false,
mappings: {
white: 'black',
black: 'white',
'50': '900',
'100': '800',
'200': '700',
'300': '600',
'400': '500',
'500': '400',
'600': '300',
'700': '200',
'800': '100',
'900': '50'
}
},
modeList: ['light', 'dark'],
classPrefix: ''
},
prefix: '',
pseudos: [],
pseudos: ['active', 'checked', 'disabled', 'enabled', 'default', 'empty', 'focus', 'focus-within', 'invalid', 'hover', 'link', 'visited', 'first-child', 'last-child', 'after', 'before', 'placeholder', 'selection'],
theme: {
breakpoints: {},
modes: []
breakpoints: {}
},
plugins: []
};
this.atomCache = new Map();
this.getAtomIds = function () {
return Array.from(_this.atomCache.keys());
}; // composed atomic props
this.compositions = new Map();

@@ -91,2 +122,29 @@

this.getMode = function () {
var _this$config$mode;
return ((_this$config$mode = _this.config.mode) == null ? void 0 : _this$config$mode.currentMode) || '';
};
this.setMode = function (mode) {
if (!utils.isBrowser) return;
var currentMode = _this.config.mode.currentMode;
if (currentMode) {
document.documentElement.classList.remove(currentMode);
}
if (mode) {
document.documentElement.classList.add(mode);
}
localStorage.setItem(modeCacheKey, mode);
_this.setConfig({
mode: {
currentMode: mode
}
});
};
this.use = function () {

@@ -93,0 +151,0 @@ var _this$config$plugins;

2

dist/store.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("deepmerge"))&&"object"==typeof e&&"default"in e?e.default:e;function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}var o=new(function(){function e(){var e=this;this.config={unit:"px",inline:!1,prefix:"",pseudos:[],theme:{breakpoints:{},modes:[]},plugins:[]},this.compositions=new Map,this.getConfig=function(){return e.config},this.setConfig=function(o,i){void 0===i&&(i="deepmerge"),e.config="replace"===i?o:"merge"===i?n({},e.config,o):t(e.config,o)},this.getTheme=function(){return e.config.theme},this.setTheme=function(n){e.config.theme=t(e.config.theme||{},n)},this.use=function(){var t;(t=e.config.plugins).push.apply(t,arguments)},this.addAtom=function(t,n){var o={isMatch:function(e){return"string"==typeof t?e===t:t instanceof RegExp&&t.test(e)},handleAtom:"function"==typeof n?n:function(e){return e.style=n,e}};return e.use(o),o},this.composeAtom=function(t,n){e.compositions.get(t)?console.warn(t,"is existed"):e.compositions.set(t,n)}}var o;return(o=[{key:"theme",get:function(){return this.config.theme}}])&&function(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(e.prototype,o),e}());globalThis.__fower_store__=o,exports.store=o;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("deepmerge"))&&"object"==typeof e&&"default"in e?e.default:e,n=require("@fower/utils");function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}var i=new(function(){function e(){var e=this;this.config={unit:"px",inline:!1,important:!1,mode:{currentMode:"light",autoDarkMode:{enabled:!1,mappings:{white:"black",black:"white",50:"900",100:"800",200:"700",300:"600",400:"500",500:"400",600:"300",700:"200",800:"100",900:"50"}},modeList:["light","dark"],classPrefix:""},prefix:"",pseudos:["active","checked","disabled","enabled","default","empty","focus","focus-within","invalid","hover","link","visited","first-child","last-child","after","before","placeholder","selection"],theme:{breakpoints:{}},plugins:[]},this.atomCache=new Map,this.getAtomIds=function(){return Array.from(e.atomCache.keys())},this.compositions=new Map,this.getConfig=function(){return e.config},this.setConfig=function(n,i){void 0===i&&(i="deepmerge"),e.config="replace"===i?n:"merge"===i?o({},e.config,n):t(e.config,n)},this.getTheme=function(){return e.config.theme},this.setTheme=function(n){e.config.theme=t(e.config.theme||{},n)},this.getMode=function(){var t;return(null==(t=e.config.mode)?void 0:t.currentMode)||""},this.setMode=function(t){if(n.isBrowser){var o=e.config.mode.currentMode;o&&document.documentElement.classList.remove(o),t&&document.documentElement.classList.add(t),localStorage.setItem("fower-mode",t),e.setConfig({mode:{currentMode:t}})}},this.use=function(){var t;(t=e.config.plugins).push.apply(t,arguments)},this.addAtom=function(t,n){var o={isMatch:function(e){return"string"==typeof t?e===t:t instanceof RegExp&&t.test(e)},handleAtom:"function"==typeof n?n:function(e){return e.style=n,e}};return e.use(o),o},this.composeAtom=function(t,n){e.compositions.get(t)?console.warn(t,"is existed"):e.compositions.set(t,n)}}var i;return(i=[{key:"theme",get:function(){return this.config.theme}}])&&function(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(e.prototype,i),e}());globalThis.__fower_store__=i,exports.store=i;
//# sourceMappingURL=store.cjs.production.min.js.map
import deepmerge from 'deepmerge';
import { isBrowser } from '@fower/utils';

@@ -37,2 +38,4 @@ function _defineProperties(target, props) {

var modeCacheKey = 'fower-mode';
var Store = /*#__PURE__*/function () {

@@ -45,11 +48,39 @@ function Store() {

inline: false,
important: false,
mode: {
currentMode: 'light',
autoDarkMode: {
enabled: false,
mappings: {
white: 'black',
black: 'white',
'50': '900',
'100': '800',
'200': '700',
'300': '600',
'400': '500',
'500': '400',
'600': '300',
'700': '200',
'800': '100',
'900': '50'
}
},
modeList: ['light', 'dark'],
classPrefix: ''
},
prefix: '',
pseudos: [],
pseudos: ['active', 'checked', 'disabled', 'enabled', 'default', 'empty', 'focus', 'focus-within', 'invalid', 'hover', 'link', 'visited', 'first-child', 'last-child', 'after', 'before', 'placeholder', 'selection'],
theme: {
breakpoints: {},
modes: []
breakpoints: {}
},
plugins: []
};
this.atomCache = new Map();
this.getAtomIds = function () {
return Array.from(_this.atomCache.keys());
}; // composed atomic props
this.compositions = new Map();

@@ -84,2 +115,29 @@

this.getMode = function () {
var _this$config$mode;
return ((_this$config$mode = _this.config.mode) == null ? void 0 : _this$config$mode.currentMode) || '';
};
this.setMode = function (mode) {
if (!isBrowser) return;
var currentMode = _this.config.mode.currentMode;
if (currentMode) {
document.documentElement.classList.remove(currentMode);
}
if (mode) {
document.documentElement.classList.add(mode);
}
localStorage.setItem(modeCacheKey, mode);
_this.setConfig({
mode: {
currentMode: mode
}
});
};
this.use = function () {

@@ -86,0 +144,0 @@ var _this$config$plugins;

{
"name": "@fower/store",
"version": "1.29.0",
"version": "1.30.0",
"license": "MIT",

@@ -24,6 +24,7 @@ "main": "dist/index.js",

"dependencies": {
"@fower/types": "^1.29.0",
"@fower/types": "^1.30.0",
"@fower/utils": "^1.30.0",
"deepmerge": "^4.2.2"
},
"gitHead": "ac5536937911f0fde336b2830f5991c645608f86"
"gitHead": "c79b3d7a6f046ef1d309772e85e20a4440d488ba"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc