main repo

This commit is contained in:
Basilosaurusrex
2025-11-24 18:09:40 +01:00
parent b636ee5e70
commit f027651f9b
34146 changed files with 4436636 additions and 0 deletions

41
node_modules/react-style-singleton/README.md generated vendored Normal file
View File

@@ -0,0 +1,41 @@
react-style-singleton
====
__300b__ with all dependencies, minified and gzipped
Creates a style component with internal _tracker_.
- Adds styles to the browser on the __first__ instance mount.
- Removes after the __last__ instance unmount.
- Thus helps you deliver styles you need to the customer, and clean up later.
- Is not server-side rendering compatible!
# API
## Component
```js
import {styleSingleton} from 'react-style-singleton'
const Style = styleSingleton();
export const App = () => (
<Style styles={'body {color:red}'} />
);
```
## Hook
```js
import {styleHookSingleton} from 'react-style-singleton';
const useStyle = styleHookSingleton();
const useAnotherStyle = styleHookSingleton();
export const App = () => {
useStyle('div {color:red}');
useAnotherStyle('body { background-color:red }');
return (<div />);
}
```

View File

@@ -0,0 +1,21 @@
import * as React from 'react';
declare type Props = {
/**
* styles to apply
*/
styles: string;
/**
* marks style as dynamic, so it will be reapplied on styles change
* note: this is not expected behavior from a "singleton"
* @default false
*/
dynamic?: boolean;
};
/**
* create a Component to add styles on demand
* - styles are added when first instance is mounted
* - styles are removed when the last instance is unmounted
* - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
*/
export declare const styleSingleton: () => React.FC<Props>;
export {};

View File

@@ -0,0 +1,16 @@
import { styleHookSingleton } from './hook';
/**
* create a Component to add styles on demand
* - styles are added when first instance is mounted
* - styles are removed when the last instance is unmounted
* - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
*/
export var styleSingleton = function () {
var useStyle = styleHookSingleton();
var Sheet = function (_a) {
var styles = _a.styles, dynamic = _a.dynamic;
useStyle(styles, dynamic);
return null;
};
return Sheet;
};

View File

@@ -0,0 +1,23 @@
/**
* creates a style on demand
*/
declare type StyleSingletonHook = (
/**
* styles to create
*/
styles: string,
/**
* indication that styles should be reapplied on change
*/
isDynamic?: boolean) => void;
/**
* creates a hook to control style singleton
* @see {@link styleSingleton} for a safer component version
* @example
* ```tsx
* const useStyle = styleHookSingleton();
* ///
* useStyle('body { overflow: hidden}');
*/
export declare const styleHookSingleton: () => StyleSingletonHook;
export {};

22
node_modules/react-style-singleton/dist/es2015/hook.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
import * as React from 'react';
import { stylesheetSingleton } from './singleton';
/**
* creates a hook to control style singleton
* @see {@link styleSingleton} for a safer component version
* @example
* ```tsx
* const useStyle = styleHookSingleton();
* ///
* useStyle('body { overflow: hidden}');
*/
export var styleHookSingleton = function () {
var sheet = stylesheetSingleton();
return function (styles, isDynamic) {
React.useEffect(function () {
sheet.add(styles);
return function () {
sheet.remove();
};
}, [styles && isDynamic]);
};
};

View File

@@ -0,0 +1,3 @@
export { styleSingleton } from './component';
export { stylesheetSingleton } from './singleton';
export { styleHookSingleton } from './hook';

View File

@@ -0,0 +1,3 @@
export { styleSingleton } from './component';
export { stylesheetSingleton } from './singleton';
export { styleHookSingleton } from './hook';

View File

@@ -0,0 +1,4 @@
export declare const stylesheetSingleton: () => {
add: (style: string) => void;
remove: () => void;
};

View File

@@ -0,0 +1,48 @@
import { getNonce } from 'get-nonce';
function makeStyleTag() {
if (!document)
return null;
var tag = document.createElement('style');
tag.type = 'text/css';
var nonce = getNonce();
if (nonce) {
tag.setAttribute('nonce', nonce);
}
return tag;
}
function injectStyles(tag, css) {
// @ts-ignore
if (tag.styleSheet) {
// @ts-ignore
tag.styleSheet.cssText = css;
}
else {
tag.appendChild(document.createTextNode(css));
}
}
function insertStyleTag(tag) {
var head = document.head || document.getElementsByTagName('head')[0];
head.appendChild(tag);
}
export var stylesheetSingleton = function () {
var counter = 0;
var stylesheet = null;
return {
add: function (style) {
if (counter == 0) {
if ((stylesheet = makeStyleTag())) {
injectStyles(stylesheet, style);
insertStyleTag(stylesheet);
}
}
counter++;
},
remove: function () {
counter--;
if (!counter && stylesheet) {
stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
stylesheet = null;
}
},
};
};

View File

@@ -0,0 +1,21 @@
import * as React from 'react';
declare type Props = {
/**
* styles to apply
*/
styles: string;
/**
* marks style as dynamic, so it will be reapplied on styles change
* note: this is not expected behavior from a "singleton"
* @default false
*/
dynamic?: boolean;
};
/**
* create a Component to add styles on demand
* - styles are added when first instance is mounted
* - styles are removed when the last instance is unmounted
* - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
*/
export declare const styleSingleton: () => React.FC<Props>;
export {};

View File

@@ -0,0 +1,15 @@
import { styleHookSingleton } from './hook';
/**
* create a Component to add styles on demand
* - styles are added when first instance is mounted
* - styles are removed when the last instance is unmounted
* - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
*/
export const styleSingleton = () => {
const useStyle = styleHookSingleton();
const Sheet = ({ styles, dynamic }) => {
useStyle(styles, dynamic);
return null;
};
return Sheet;
};

View File

@@ -0,0 +1,23 @@
/**
* creates a style on demand
*/
declare type StyleSingletonHook = (
/**
* styles to create
*/
styles: string,
/**
* indication that styles should be reapplied on change
*/
isDynamic?: boolean) => void;
/**
* creates a hook to control style singleton
* @see {@link styleSingleton} for a safer component version
* @example
* ```tsx
* const useStyle = styleHookSingleton();
* ///
* useStyle('body { overflow: hidden}');
*/
export declare const styleHookSingleton: () => StyleSingletonHook;
export {};

22
node_modules/react-style-singleton/dist/es2019/hook.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
import * as React from 'react';
import { stylesheetSingleton } from './singleton';
/**
* creates a hook to control style singleton
* @see {@link styleSingleton} for a safer component version
* @example
* ```tsx
* const useStyle = styleHookSingleton();
* ///
* useStyle('body { overflow: hidden}');
*/
export const styleHookSingleton = () => {
const sheet = stylesheetSingleton();
return (styles, isDynamic) => {
React.useEffect(() => {
sheet.add(styles);
return () => {
sheet.remove();
};
}, [styles && isDynamic]);
};
};

View File

@@ -0,0 +1,3 @@
export { styleSingleton } from './component';
export { stylesheetSingleton } from './singleton';
export { styleHookSingleton } from './hook';

View File

@@ -0,0 +1,3 @@
export { styleSingleton } from './component';
export { stylesheetSingleton } from './singleton';
export { styleHookSingleton } from './hook';

View File

@@ -0,0 +1,4 @@
export declare const stylesheetSingleton: () => {
add: (style: string) => void;
remove: () => void;
};

View File

@@ -0,0 +1,48 @@
import { getNonce } from 'get-nonce';
function makeStyleTag() {
if (!document)
return null;
const tag = document.createElement('style');
tag.type = 'text/css';
const nonce = getNonce();
if (nonce) {
tag.setAttribute('nonce', nonce);
}
return tag;
}
function injectStyles(tag, css) {
// @ts-ignore
if (tag.styleSheet) {
// @ts-ignore
tag.styleSheet.cssText = css;
}
else {
tag.appendChild(document.createTextNode(css));
}
}
function insertStyleTag(tag) {
const head = document.head || document.getElementsByTagName('head')[0];
head.appendChild(tag);
}
export const stylesheetSingleton = () => {
let counter = 0;
let stylesheet = null;
return {
add: (style) => {
if (counter == 0) {
if ((stylesheet = makeStyleTag())) {
injectStyles(stylesheet, style);
insertStyleTag(stylesheet);
}
}
counter++;
},
remove: () => {
counter--;
if (!counter && stylesheet) {
stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
stylesheet = null;
}
},
};
};

View File

@@ -0,0 +1,21 @@
import * as React from 'react';
declare type Props = {
/**
* styles to apply
*/
styles: string;
/**
* marks style as dynamic, so it will be reapplied on styles change
* note: this is not expected behavior from a "singleton"
* @default false
*/
dynamic?: boolean;
};
/**
* create a Component to add styles on demand
* - styles are added when first instance is mounted
* - styles are removed when the last instance is unmounted
* - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
*/
export declare const styleSingleton: () => React.FC<Props>;
export {};

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.styleSingleton = void 0;
var hook_1 = require("./hook");
/**
* create a Component to add styles on demand
* - styles are added when first instance is mounted
* - styles are removed when the last instance is unmounted
* - changing styles in runtime does nothing unless dynamic is set. But with multiple components that can lead to the undefined behavior
*/
var styleSingleton = function () {
var useStyle = (0, hook_1.styleHookSingleton)();
var Sheet = function (_a) {
var styles = _a.styles, dynamic = _a.dynamic;
useStyle(styles, dynamic);
return null;
};
return Sheet;
};
exports.styleSingleton = styleSingleton;

23
node_modules/react-style-singleton/dist/es5/hook.d.ts generated vendored Normal file
View File

@@ -0,0 +1,23 @@
/**
* creates a style on demand
*/
declare type StyleSingletonHook = (
/**
* styles to create
*/
styles: string,
/**
* indication that styles should be reapplied on change
*/
isDynamic?: boolean) => void;
/**
* creates a hook to control style singleton
* @see {@link styleSingleton} for a safer component version
* @example
* ```tsx
* const useStyle = styleHookSingleton();
* ///
* useStyle('body { overflow: hidden}');
*/
export declare const styleHookSingleton: () => StyleSingletonHook;
export {};

27
node_modules/react-style-singleton/dist/es5/hook.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.styleHookSingleton = void 0;
var tslib_1 = require("tslib");
var React = tslib_1.__importStar(require("react"));
var singleton_1 = require("./singleton");
/**
* creates a hook to control style singleton
* @see {@link styleSingleton} for a safer component version
* @example
* ```tsx
* const useStyle = styleHookSingleton();
* ///
* useStyle('body { overflow: hidden}');
*/
var styleHookSingleton = function () {
var sheet = (0, singleton_1.stylesheetSingleton)();
return function (styles, isDynamic) {
React.useEffect(function () {
sheet.add(styles);
return function () {
sheet.remove();
};
}, [styles && isDynamic]);
};
};
exports.styleHookSingleton = styleHookSingleton;

View File

@@ -0,0 +1,3 @@
export { styleSingleton } from './component';
export { stylesheetSingleton } from './singleton';
export { styleHookSingleton } from './hook';

9
node_modules/react-style-singleton/dist/es5/index.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.styleHookSingleton = exports.stylesheetSingleton = exports.styleSingleton = void 0;
var component_1 = require("./component");
Object.defineProperty(exports, "styleSingleton", { enumerable: true, get: function () { return component_1.styleSingleton; } });
var singleton_1 = require("./singleton");
Object.defineProperty(exports, "stylesheetSingleton", { enumerable: true, get: function () { return singleton_1.stylesheetSingleton; } });
var hook_1 = require("./hook");
Object.defineProperty(exports, "styleHookSingleton", { enumerable: true, get: function () { return hook_1.styleHookSingleton; } });

View File

@@ -0,0 +1,4 @@
export declare const stylesheetSingleton: () => {
add: (style: string) => void;
remove: () => void;
};

View File

@@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.stylesheetSingleton = void 0;
var get_nonce_1 = require("get-nonce");
function makeStyleTag() {
if (!document)
return null;
var tag = document.createElement('style');
tag.type = 'text/css';
var nonce = (0, get_nonce_1.getNonce)();
if (nonce) {
tag.setAttribute('nonce', nonce);
}
return tag;
}
function injectStyles(tag, css) {
// @ts-ignore
if (tag.styleSheet) {
// @ts-ignore
tag.styleSheet.cssText = css;
}
else {
tag.appendChild(document.createTextNode(css));
}
}
function insertStyleTag(tag) {
var head = document.head || document.getElementsByTagName('head')[0];
head.appendChild(tag);
}
var stylesheetSingleton = function () {
var counter = 0;
var stylesheet = null;
return {
add: function (style) {
if (counter == 0) {
if ((stylesheet = makeStyleTag())) {
injectStyles(stylesheet, style);
insertStyleTag(stylesheet);
}
}
counter++;
},
remove: function () {
counter--;
if (!counter && stylesheet) {
stylesheet.parentNode && stylesheet.parentNode.removeChild(stylesheet);
stylesheet = null;
}
},
};
};
exports.stylesheetSingleton = stylesheetSingleton;

1
node_modules/react-style-singleton/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){e.exports=a},function(e,t,n){e.exports=n(2)},function(e,t,n){"use strict";n.r(t),n.d(t,"styleSingleton",(function(){return l})),n.d(t,"stylesheetSingleton",(function(){return c})),n.d(t,"styleHookSingleton",(function(){return i}));var r,o=n(0);function u(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=r||n.nc;return t&&e.setAttribute("nonce",t),e}var c=function(){var e=0,t=null;return{add:function(n){var r,o;0==e&&(t=u())&&(o=n,(r=t).styleSheet?r.styleSheet.cssText=o:r.appendChild(document.createTextNode(o)),function(e){(document.head||document.getElementsByTagName("head")[0]).appendChild(e)}(t)),e++},remove:function(){!--e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},i=function(){var e=c();return function(t){o.useEffect((function(){return e.add(t),function(){e.remove()}}),[])}},l=function(){var e=i();return function(t){var n=t.styles;return e(n),null}}}]);

87
node_modules/react-style-singleton/package.json generated vendored Normal file
View File

@@ -0,0 +1,87 @@
{
"name": "react-style-singleton",
"version": "2.2.1",
"description": "Just create a single stylesheet...",
"main": "dist/es5/index.js",
"types": "dist/es5/index.d.ts",
"jsnext:main": "dist/es2015/index.js",
"module": "dist/es2015/index.js",
"module:es2019": "dist/es2019/index.js",
"files": [
"dist"
],
"scripts": {
"dev": "lib-builder dev",
"test": "jest",
"test:ci": "jest --runInBand --coverage",
"build": "lib-builder build && yarn size:report",
"release": "yarn build && yarn test",
"size": "npx size-limit",
"size:report": "npx size-limit --json > .size.json",
"lint": "lib-builder lint",
"format": "lib-builder format",
"update": "lib-builder update",
"prepublish-only": "yarn build && yarn changelog",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"changelog:rewrite": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0"
},
"repository": "",
"bugs": {
"url": "https://github.com/theKashey/react-style-singleton/issues"
},
"homepage": "https://github.com/theKashey/react-style-singleton#readme",
"author": "Anton Korzunov (thekashey@gmail.com)",
"license": "MIT",
"devDependencies": {
"@theuiteam/lib-builder": "^0.1.4",
"@size-limit/preset-small-lib": "^2.1.6",
"@types/invariant": "^2.2.29",
"react": "^16.8.6",
"react-dom": "^16.8.6"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
},
"keywords": [
"react",
"style",
"css"
],
"dependencies": {
"tslib": "^2.0.0",
"get-nonce": "^1.0.0",
"invariant": "^2.2.4"
},
"engines": {
"node": ">=10"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{ts,tsx}": [
"prettier --write",
"eslint --fix",
"git add"
],
"*.{js,css,json,md}": [
"prettier --write",
"git add"
]
},
"prettier": {
"printWidth": 120,
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
}