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

theme-service

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

theme-service - npm Package Compare versions

Comparing version 2.0.0-beta.206 to 2.0.0-beta.207

22

dist/core.d.ts
import { Options, ThemeValue } from './options';
export declare class ThemeService {
options?: Options;
host: HTMLElement;
private _darkMQL;
private _value;
private _current;
options?: Options | undefined;
host: HTMLElement | null;
private _darkMQL?;
private _value?;
private _current?;
initialized: boolean;
constructor(options?: Options, host?: HTMLElement);
constructor(options?: Options | undefined, host?: HTMLElement | null);
init(): this;
get storage(): string;
get storage(): string | null | undefined;
get systemCurrent(): string;
set value(value: ThemeValue);
get value(): ThemeValue;
set current(current: string);
get current(): string;
set value(value: ThemeValue | undefined);
get value(): ThemeService['_value'];
set current(current: string | undefined);
get current(): ThemeService['_current'];
switch(value: ThemeValue): void;

@@ -18,0 +18,0 @@ private _removeDarkMQLListener;

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

(()=>{function f(i){let e=typeof Buffer<"u"?Buffer:null;return!!(e&&i instanceof e||i instanceof Date||i instanceof RegExp)}function u(i){if(typeof Buffer<"u"&&Buffer&&i instanceof Buffer){let e=Buffer.alloc(i.length);return i.copy(e),e}else{if(i instanceof Date)return new Date(i.getTime());if(i instanceof RegExp)return new RegExp(i);throw new Error("Unexpected situation")}}function c(i){let e=[];return i.forEach(function(t,s){typeof t=="object"&&t!==null?Array.isArray(t)?e[s]=c(t):f(t)?e[s]=u(t):e[s]=o({},t):e[s]=t}),e}function h(i,e){return e==="__proto__"?void 0:i[e]}function o(...i){let e={},t,s;return i.forEach(function(n){typeof n!="object"||n===null||Array.isArray(n)||Object.keys(n).forEach(function(r){if(s=h(e,r),t=h(n,r),t!==e)if(typeof t!="object"||t===null){e[r]=t;return}else if(Array.isArray(t)){e[r]=c(t);return}else if(f(t)){e[r]=u(t);return}else if(typeof s!="object"||s===null||Array.isArray(s)){e[r]=o({},t);return}else{e[r]=o(s,t);return}})}),e}var p={store:"theme"},l=p;var a=class{constructor(e,t=typeof document<"u"?document.documentElement:null){this.options=e;this.host=t;this.options=e?o(l,e):l}_darkMQL=typeof matchMedia<"u"?matchMedia?.("(prefers-color-scheme:dark)"):void 0;_value;_current;initialized=!1;init(){let e=this.options.default,t=this.storage;return t&&(e=t),this.value=e,this.initialized=!0,this}get storage(){let{store:e}=this.options;if(typeof localStorage<"u"&&e)return localStorage.getItem(e)}get systemCurrent(){return this._darkMQL.matches?"dark":"light"}set value(e){e==="system"?(this._darkMQL?.addEventListener?.("change",this._onThemeChange),this.current=this.systemCurrent):(this._removeDarkMQLListener(),this.current=e),e!==this._value&&(this.host.dispatchEvent(new CustomEvent("themeChange",{detail:this})),this._value=e)}get value(){return this._value}set current(e){let t=this._current;this._current=e,this.host&&t!==e&&(t&&this.host.classList.remove(t),e&&!this.host.classList.contains(e)&&(this.host.classList.add(e),this.host.style&&(this.host.style.colorScheme=e==="dark"||e==="light"?e:null)))}get current(){return this._current}switch(e){e&&e!==this.value&&(this.value=e,typeof localStorage<"u"&&this.storage!==e&&this.options.store&&localStorage.setItem(this.options.store,e))}_removeDarkMQLListener(){this._darkMQL?.removeEventListener("change",this._onThemeChange)}_onThemeChange=e=>{this.current=e.matches?"dark":"light"};destroy(e=!0){this._removeDarkMQLListener(),this.host&&(this.host.style.colorScheme=null,this.host.classList.remove(this.current)),e&&typeof localStorage<"u"&&this.options.store&&localStorage.removeItem(this.options.store),this._current=null,this._value=null,this.initialized=!1}};new a(window.themeServiceOptions);})();
"use strict";(()=>{function u(i){let e=typeof Buffer<"u"?Buffer:null;return!!(e&&i instanceof e||i instanceof Date||i instanceof RegExp)}function f(i){if(typeof Buffer<"u"&&Buffer&&i instanceof Buffer){let e=Buffer.alloc(i.length);return i.copy(e),e}else{if(i instanceof Date)return new Date(i.getTime());if(i instanceof RegExp)return new RegExp(i);throw new Error("Unexpected situation")}}function c(i){let e=[];return i.forEach(function(t,s){typeof t=="object"&&t!==null?Array.isArray(t)?e[s]=c(t):u(t)?e[s]=f(t):e[s]=o({},t):e[s]=t}),e}function h(i,e){return e==="__proto__"?void 0:i[e]}function o(...i){let e={},t,s;return i.forEach(function(n){typeof n!="object"||n===null||Array.isArray(n)||Object.keys(n).forEach(function(r){if(s=h(e,r),t=h(n,r),t!==e)if(typeof t!="object"||t===null){e[r]=t;return}else if(Array.isArray(t)){e[r]=c(t);return}else if(u(t)){e[r]=f(t);return}else if(typeof s!="object"||s===null||Array.isArray(s)){e[r]=o({},t);return}else{e[r]=o(s,t);return}})}),e}var d={store:"theme"},l=d;var a=class{constructor(e,t=typeof document<"u"?document.documentElement:null){this.options=e;this.host=t;this.options=e?o(l,e):l}_darkMQL=typeof matchMedia<"u"?matchMedia?.("(prefers-color-scheme:dark)"):void 0;_value;_current;initialized=!1;init(){let e=this.options?.default,t=this.storage;return t&&(e=t),this.value=e,this.initialized=!0,this}get storage(){if(typeof localStorage<"u"&&this.options?.store)return localStorage.getItem(this.options?.store)}get systemCurrent(){return this._darkMQL?.matches?"dark":"light"}set value(e){e==="system"?(this._darkMQL?.addEventListener?.("change",this._onThemeChange),this.current=this.systemCurrent):(this._removeDarkMQLListener(),this.current=e),e!==this._value&&(this.host?.dispatchEvent(new CustomEvent("themeChange",{detail:this})),this._value=e)}get value(){return this._value}set current(e){let t=this._current;this._current=e,this.host&&t!==e&&(t&&this.host.classList.remove(t),e&&!this.host.classList.contains(e)&&(this.host.classList.add(e),this.host.style&&(this.host.style.colorScheme=e==="dark"||e==="light"?e:null)))}get current(){return this._current}switch(e){e&&e!==this.value&&(this.value=e,typeof localStorage<"u"&&this.storage!==e&&this.options?.store&&localStorage.setItem(this.options.store,e))}_removeDarkMQLListener(){this._darkMQL?.removeEventListener("change",this._onThemeChange)}_onThemeChange=e=>{this.current=e.matches?"dark":"light"};destroy(e=!0){this._removeDarkMQLListener(),this.host&&(this.host.style.removeProperty("color-scheme"),this.current&&this.host.classList.remove(this.current)),e&&typeof localStorage<"u"&&this.options?.store&&localStorage.removeItem(this.options.store),this._current=null,this._value=null,this.initialized=!1}};new a(window.themeServiceOptions);})();

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

var h=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var L=(t,e)=>{for(var i in e)h(t,i,{get:e[i],enumerable:!0})},x=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of v(e))!_.call(t,s)&&s!==i&&h(t,s,{get:()=>e[s],enumerable:!(r=y(e,s))||r.enumerable});return t};var k=t=>x(h({},"__esModule",{value:!0}),t);var E={};L(E,{ThemeService:()=>n,default:()=>n,getPreInitScript:()=>f,init:()=>c,options:()=>g});module.exports=k(E);function d(t){let e=typeof Buffer<"u"?Buffer:null;return!!(e&&t instanceof e||t instanceof Date||t instanceof RegExp)}function m(t){if(typeof Buffer<"u"&&Buffer&&t instanceof Buffer){let e=Buffer.alloc(t.length);return t.copy(e),e}else{if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t);throw new Error("Unexpected situation")}}function p(t){let e=[];return t.forEach(function(i,r){typeof i=="object"&&i!==null?Array.isArray(i)?e[r]=p(i):d(i)?e[r]=m(i):e[r]=a({},i):e[r]=i}),e}function u(t,e){return e==="__proto__"?void 0:t[e]}function a(...t){let e={},i,r;return t.forEach(function(s){typeof s!="object"||s===null||Array.isArray(s)||Object.keys(s).forEach(function(o){if(r=u(e,o),i=u(s,o),i!==e)if(typeof i!="object"||i===null){e[o]=i;return}else if(Array.isArray(i)){e[o]=p(i);return}else if(d(i)){e[o]=m(i);return}else if(typeof r!="object"||r===null||Array.isArray(r)){e[o]=a({},i);return}else{e[o]=a(r,i);return}})}),e}var g={store:"theme"},l=g;var n=class{constructor(e,i=typeof document<"u"?document.documentElement:null){this.options=e;this.host=i;this.options=e?a(l,e):l}_darkMQL=typeof matchMedia<"u"?matchMedia?.("(prefers-color-scheme:dark)"):void 0;_value;_current;initialized=!1;init(){let e=this.options.default,i=this.storage;return i&&(e=i),this.value=e,this.initialized=!0,this}get storage(){let{store:e}=this.options;if(typeof localStorage<"u"&&e)return localStorage.getItem(e)}get systemCurrent(){return this._darkMQL.matches?"dark":"light"}set value(e){e==="system"?(this._darkMQL?.addEventListener?.("change",this._onThemeChange),this.current=this.systemCurrent):(this._removeDarkMQLListener(),this.current=e),e!==this._value&&(this.host.dispatchEvent(new CustomEvent("themeChange",{detail:this})),this._value=e)}get value(){return this._value}set current(e){let i=this._current;this._current=e,this.host&&i!==e&&(i&&this.host.classList.remove(i),e&&!this.host.classList.contains(e)&&(this.host.classList.add(e),this.host.style&&(this.host.style.colorScheme=e==="dark"||e==="light"?e:null)))}get current(){return this._current}switch(e){e&&e!==this.value&&(this.value=e,typeof localStorage<"u"&&this.storage!==e&&this.options.store&&localStorage.setItem(this.options.store,e))}_removeDarkMQLListener(){this._darkMQL?.removeEventListener("change",this._onThemeChange)}_onThemeChange=e=>{this.current=e.matches?"dark":"light"};destroy(e=!0){this._removeDarkMQLListener(),this.host&&(this.host.style.colorScheme=null,this.host.classList.remove(this.current)),e&&typeof localStorage<"u"&&this.options.store&&localStorage.removeItem(this.options.store),this._current=null,this._value=null,this.initialized=!1}};function f(t){return t=Object.assign(l,t),`let e${t.default?`='${t.default}'`:""};const c=localStorage.getItem("${t.store}");c&&(e=c);let t=e;e==="system"&&(t=matchMedia("(prefers-color-scheme:dark)").matches?"dark":"light");const s=document.documentElement;s.classList.add(t);if(t==='dark'||t==='light'){s.style.colorScheme=t;};`}function c(t,e){return new n(t,e).init()}
"use strict";var h=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var L=(t,e)=>{for(var i in e)h(t,i,{get:e[i],enumerable:!0})},x=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of v(e))!_.call(t,s)&&s!==i&&h(t,s,{get:()=>e[s],enumerable:!(r=y(e,s))||r.enumerable});return t};var k=t=>x(h({},"__esModule",{value:!0}),t);var S={};L(S,{ThemeService:()=>o,default:()=>o,getPreInitScript:()=>f,init:()=>u,options:()=>g});module.exports=k(S);function d(t){let e=typeof Buffer<"u"?Buffer:null;return!!(e&&t instanceof e||t instanceof Date||t instanceof RegExp)}function m(t){if(typeof Buffer<"u"&&Buffer&&t instanceof Buffer){let e=Buffer.alloc(t.length);return t.copy(e),e}else{if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t);throw new Error("Unexpected situation")}}function p(t){let e=[];return t.forEach(function(i,r){typeof i=="object"&&i!==null?Array.isArray(i)?e[r]=p(i):d(i)?e[r]=m(i):e[r]=a({},i):e[r]=i}),e}function c(t,e){return e==="__proto__"?void 0:t[e]}function a(...t){let e={},i,r;return t.forEach(function(s){typeof s!="object"||s===null||Array.isArray(s)||Object.keys(s).forEach(function(n){if(r=c(e,n),i=c(s,n),i!==e)if(typeof i!="object"||i===null){e[n]=i;return}else if(Array.isArray(i)){e[n]=p(i);return}else if(d(i)){e[n]=m(i);return}else if(typeof r!="object"||r===null||Array.isArray(r)){e[n]=a({},i);return}else{e[n]=a(r,i);return}})}),e}var g={store:"theme"},l=g;var o=class{constructor(e,i=typeof document<"u"?document.documentElement:null){this.options=e;this.host=i;this.options=e?a(l,e):l}_darkMQL=typeof matchMedia<"u"?matchMedia?.("(prefers-color-scheme:dark)"):void 0;_value;_current;initialized=!1;init(){let e=this.options?.default,i=this.storage;return i&&(e=i),this.value=e,this.initialized=!0,this}get storage(){if(typeof localStorage<"u"&&this.options?.store)return localStorage.getItem(this.options?.store)}get systemCurrent(){return this._darkMQL?.matches?"dark":"light"}set value(e){e==="system"?(this._darkMQL?.addEventListener?.("change",this._onThemeChange),this.current=this.systemCurrent):(this._removeDarkMQLListener(),this.current=e),e!==this._value&&(this.host?.dispatchEvent(new CustomEvent("themeChange",{detail:this})),this._value=e)}get value(){return this._value}set current(e){let i=this._current;this._current=e,this.host&&i!==e&&(i&&this.host.classList.remove(i),e&&!this.host.classList.contains(e)&&(this.host.classList.add(e),this.host.style&&(this.host.style.colorScheme=e==="dark"||e==="light"?e:null)))}get current(){return this._current}switch(e){e&&e!==this.value&&(this.value=e,typeof localStorage<"u"&&this.storage!==e&&this.options?.store&&localStorage.setItem(this.options.store,e))}_removeDarkMQLListener(){this._darkMQL?.removeEventListener("change",this._onThemeChange)}_onThemeChange=e=>{this.current=e.matches?"dark":"light"};destroy(e=!0){this._removeDarkMQLListener(),this.host&&(this.host.style.removeProperty("color-scheme"),this.current&&this.host.classList.remove(this.current)),e&&typeof localStorage<"u"&&this.options?.store&&localStorage.removeItem(this.options.store),this._current=null,this._value=null,this.initialized=!1}};function f(t){return t=Object.assign(l,t),`let e${t.default?`='${t.default}'`:""};const c=localStorage.getItem("${t.store}");c&&(e=c);let t=e;e==="system"&&(t=matchMedia("(prefers-color-scheme:dark)").matches?"dark":"light");const s=document.documentElement;s.classList.add(t);if(t==='dark'||t==='light'){s.style.colorScheme=t;};`}function u(t,e){return new o(t,e).init()}

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

{"name":"theme-service","scripts":{"build":"techor pack","dev":"pnpm run build --watch --no-declare","test":"jest","type-check":"tsc --noEmit","lint":"eslint src"},"license":"MIT","description":"A CSS theme-switching service for Master CSS","author":"Aoyue Design LLC.","funding":"https://css.master.co/docs/donate","homepage":"https://beta.css.master.co/docs/theme-service","bugs":{"url":"https://github.com/master-co/css/issues"},"repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/theme-service"},"keywords":["css","theme","theme-switching","prefers-color-scheme","dark mode","mastercss"],"sideEffects":false,"main":"./dist/index.bundle.js","jsnext:main":"./dist/index.bundle.mjs","esnext":"./dist/index.bundle.mjs","module":"./dist/index.bundle.mjs","browser":"./dist/index.browser.bundle.js","types":"./dist/index.d.ts","exports":{".":{"browser":{"import":"./dist/index.bundle.mjs","types":"./dist/index.browser.d.ts"},"require":"./dist/index.bundle.js","import":"./dist/index.bundle.mjs","types":"./dist/index.d.ts"}},"files":["dist"],"publishConfig":{"access":"public"},"devDependencies":{"@techor/extend":"^2.5.4"},"version":"2.0.0-beta.206"}
{"name":"theme-service","scripts":{"build":"techor pack","dev":"pnpm run build --watch --no-declare","test":"jest","type-check":"tsc --noEmit","lint":"eslint src"},"license":"MIT","description":"A CSS theme-switching service for Master CSS","author":"Aoyue Design LLC.","funding":"https://css.master.co/docs/donate","homepage":"https://beta.css.master.co/docs/theme-service","bugs":{"url":"https://github.com/master-co/css/issues"},"repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/theme-service"},"keywords":["css","theme","theme-switching","prefers-color-scheme","dark mode","mastercss"],"sideEffects":false,"main":"./dist/index.bundle.js","jsnext:main":"./dist/index.bundle.mjs","esnext":"./dist/index.bundle.mjs","module":"./dist/index.bundle.mjs","browser":"./dist/index.browser.bundle.js","types":"./dist/index.d.ts","exports":{".":{"browser":{"import":"./dist/index.bundle.mjs","types":"./dist/index.browser.d.ts"},"require":"./dist/index.bundle.js","import":"./dist/index.bundle.mjs","types":"./dist/index.d.ts"}},"files":["dist"],"publishConfig":{"access":"public"},"devDependencies":{"@techor/extend":"^2.5.4"},"version":"2.0.0-beta.207"}

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