@mattsjones/css-core
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -5,4 +5,2 @@ import type { StyleRule } from './types'; | ||
}; | ||
export declare function setFileScope(newFileScope: string): void; | ||
export declare function endFileScope(): void; | ||
export declare function createVar(debugId?: string): string; | ||
@@ -9,0 +7,0 @@ export declare function style(rule: StyleRule, debugId?: string): string; |
@@ -9,2 +9,3 @@ 'use strict'; | ||
var get = require('lodash/get'); | ||
var fileScope_dist_mattsjonesCssCoreFileScope = require('../fileScope/dist/mattsjones-css-core-fileScope.browser.cjs.js'); | ||
require('postcss-js'); | ||
@@ -57,27 +58,8 @@ require('postcss'); | ||
let refCounter = 0; | ||
const defaultFileScope = 'DEFAULT_FILE_SCOPE'; | ||
const fileScopes = [defaultFileScope]; | ||
function setFileScope(newFileScope) { | ||
refCounter = 0; | ||
fileScopes.unshift(newFileScope); | ||
} | ||
function endFileScope() { | ||
refCounter = 0; | ||
fileScopes.splice(0, 1); | ||
} | ||
function getFileScope() { | ||
return fileScopes[0]; | ||
} | ||
function getShortFileName() { | ||
const fileScope = getFileScope(); | ||
const fileScope = fileScope_dist_mattsjonesCssCoreFileScope.getFileScope(); | ||
const matches = fileScope.match(/.*\/(.*)\..*\..*$/); | ||
if (fileScope !== defaultFileScope) { | ||
const matches = fileScope.match(/.*\/(.*)\..*\..*$/); | ||
if (matches && matches[1]) { | ||
return matches[1]; | ||
} | ||
if (matches && matches[1]) { | ||
return matches[1]; | ||
} | ||
@@ -89,3 +71,4 @@ | ||
const generateClassName = debugId => { | ||
const className = process.env.NODE_ENV !== 'production' && debugId ? `${getShortFileName()}_${debugId}__${hash__default['default'](getFileScope())}${refCounter++}` : `${hash__default['default'](getFileScope())}${refCounter++}`; | ||
const refCount = fileScope_dist_mattsjonesCssCoreFileScope.getAndIncrementRefCounter(); | ||
const className = process.env.NODE_ENV !== 'production' && debugId ? `${getShortFileName()}_${debugId}__${hash__default['default'](fileScope_dist_mattsjonesCssCoreFileScope.getFileScope())}${refCount}` : `${hash__default['default'](fileScope_dist_mattsjonesCssCoreFileScope.getFileScope())}${refCount}`; | ||
return generateCss_dist_mattsjonesCssCoreGenerateCss.sanitiseIdent(className); | ||
@@ -115,3 +98,4 @@ }; | ||
function createVar(debugId) { | ||
const varName = process.env.NODE_ENV !== 'production' && debugId ? `${debugId}__${hash__default['default'](getFileScope())}${refCounter++}` : `${hash__default['default'](getFileScope())}${refCounter++}`; // Dashify CSS var names to replicate postcss-js behaviour | ||
const refCount = fileScope_dist_mattsjonesCssCoreFileScope.getAndIncrementRefCounter(); | ||
const varName = process.env.NODE_ENV !== 'production' && debugId ? `${debugId}__${hash__default['default'](fileScope_dist_mattsjonesCssCoreFileScope.getFileScope())}${refCount}` : `${hash__default['default'](fileScope_dist_mattsjonesCssCoreFileScope.getFileScope())}${refCount}`; // Dashify CSS var names to replicate postcss-js behaviour | ||
// See https://github.com/postcss/postcss-js/blob/d5127d4278c133f333f1c66f990f3552a907128e/parser.js#L30 | ||
@@ -128,3 +112,3 @@ | ||
rule | ||
}, getFileScope()); | ||
}, fileScope_dist_mattsjonesCssCoreFileScope.getFileScope()); | ||
return className; | ||
@@ -155,3 +139,3 @@ } | ||
} | ||
}, getFileScope()); | ||
}, fileScope_dist_mattsjonesCssCoreFileScope.getFileScope()); | ||
@@ -197,4 +181,2 @@ if (shouldCreateVars) { | ||
exports.createVar = createVar; | ||
exports.endFileScope = endFileScope; | ||
exports.setFileScope = setFileScope; | ||
exports.style = style; |
@@ -5,2 +5,3 @@ import { g as generateCss, s as sanitiseIdent } from './generateCss-b00bb8d0.browser.esm.js'; | ||
import get from 'lodash/get'; | ||
import { getAndIncrementRefCounter, getFileScope } from '../fileScope/dist/mattsjones-css-core-fileScope.browser.esm.js'; | ||
import 'postcss-js'; | ||
@@ -48,27 +49,8 @@ import 'postcss'; | ||
let refCounter = 0; | ||
const defaultFileScope = 'DEFAULT_FILE_SCOPE'; | ||
const fileScopes = [defaultFileScope]; | ||
function setFileScope(newFileScope) { | ||
refCounter = 0; | ||
fileScopes.unshift(newFileScope); | ||
} | ||
function endFileScope() { | ||
refCounter = 0; | ||
fileScopes.splice(0, 1); | ||
} | ||
function getFileScope() { | ||
return fileScopes[0]; | ||
} | ||
function getShortFileName() { | ||
const fileScope = getFileScope(); | ||
const matches = fileScope.match(/.*\/(.*)\..*\..*$/); | ||
if (fileScope !== defaultFileScope) { | ||
const matches = fileScope.match(/.*\/(.*)\..*\..*$/); | ||
if (matches && matches[1]) { | ||
return matches[1]; | ||
} | ||
if (matches && matches[1]) { | ||
return matches[1]; | ||
} | ||
@@ -80,3 +62,4 @@ | ||
const generateClassName = debugId => { | ||
const className = process.env.NODE_ENV !== 'production' && debugId ? `${getShortFileName()}_${debugId}__${hash(getFileScope())}${refCounter++}` : `${hash(getFileScope())}${refCounter++}`; | ||
const refCount = getAndIncrementRefCounter(); | ||
const className = process.env.NODE_ENV !== 'production' && debugId ? `${getShortFileName()}_${debugId}__${hash(getFileScope())}${refCount}` : `${hash(getFileScope())}${refCount}`; | ||
return sanitiseIdent(className); | ||
@@ -106,3 +89,4 @@ }; | ||
function createVar(debugId) { | ||
const varName = process.env.NODE_ENV !== 'production' && debugId ? `${debugId}__${hash(getFileScope())}${refCounter++}` : `${hash(getFileScope())}${refCounter++}`; // Dashify CSS var names to replicate postcss-js behaviour | ||
const refCount = getAndIncrementRefCounter(); | ||
const varName = process.env.NODE_ENV !== 'production' && debugId ? `${debugId}__${hash(getFileScope())}${refCount}` : `${hash(getFileScope())}${refCount}`; // Dashify CSS var names to replicate postcss-js behaviour | ||
// See https://github.com/postcss/postcss-js/blob/d5127d4278c133f333f1c66f990f3552a907128e/parser.js#L30 | ||
@@ -181,2 +165,2 @@ | ||
export { createGlobalTheme, createInlineTheme, createTheme, createThemeVars, createVar, endFileScope, setFileScope, style }; | ||
export { createGlobalTheme, createInlineTheme, createTheme, createThemeVars, createVar, style }; |
@@ -9,2 +9,3 @@ 'use strict'; | ||
var get = require('lodash/get'); | ||
var fileScope_dist_mattsjonesCssCoreFileScope = require('../fileScope/dist/mattsjones-css-core-fileScope.cjs.dev.js'); | ||
require('postcss-js'); | ||
@@ -57,27 +58,8 @@ require('postcss'); | ||
let refCounter = 0; | ||
const defaultFileScope = 'DEFAULT_FILE_SCOPE'; | ||
const fileScopes = [defaultFileScope]; | ||
function setFileScope(newFileScope) { | ||
refCounter = 0; | ||
fileScopes.unshift(newFileScope); | ||
} | ||
function endFileScope() { | ||
refCounter = 0; | ||
fileScopes.splice(0, 1); | ||
} | ||
function getFileScope() { | ||
return fileScopes[0]; | ||
} | ||
function getShortFileName() { | ||
const fileScope = getFileScope(); | ||
const fileScope = fileScope_dist_mattsjonesCssCoreFileScope.getFileScope(); | ||
const matches = fileScope.match(/.*\/(.*)\..*\..*$/); | ||
if (fileScope !== defaultFileScope) { | ||
const matches = fileScope.match(/.*\/(.*)\..*\..*$/); | ||
if (matches && matches[1]) { | ||
return matches[1]; | ||
} | ||
if (matches && matches[1]) { | ||
return matches[1]; | ||
} | ||
@@ -89,3 +71,4 @@ | ||
const generateClassName = debugId => { | ||
const className = process.env.NODE_ENV !== 'production' && debugId ? `${getShortFileName()}_${debugId}__${hash__default['default'](getFileScope())}${refCounter++}` : `${hash__default['default'](getFileScope())}${refCounter++}`; | ||
const refCount = fileScope_dist_mattsjonesCssCoreFileScope.getAndIncrementRefCounter(); | ||
const className = process.env.NODE_ENV !== 'production' && debugId ? `${getShortFileName()}_${debugId}__${hash__default['default'](fileScope_dist_mattsjonesCssCoreFileScope.getFileScope())}${refCount}` : `${hash__default['default'](fileScope_dist_mattsjonesCssCoreFileScope.getFileScope())}${refCount}`; | ||
return generateCss_dist_mattsjonesCssCoreGenerateCss.sanitiseIdent(className); | ||
@@ -115,3 +98,4 @@ }; | ||
function createVar(debugId) { | ||
const varName = process.env.NODE_ENV !== 'production' && debugId ? `${debugId}__${hash__default['default'](getFileScope())}${refCounter++}` : `${hash__default['default'](getFileScope())}${refCounter++}`; // Dashify CSS var names to replicate postcss-js behaviour | ||
const refCount = fileScope_dist_mattsjonesCssCoreFileScope.getAndIncrementRefCounter(); | ||
const varName = process.env.NODE_ENV !== 'production' && debugId ? `${debugId}__${hash__default['default'](fileScope_dist_mattsjonesCssCoreFileScope.getFileScope())}${refCount}` : `${hash__default['default'](fileScope_dist_mattsjonesCssCoreFileScope.getFileScope())}${refCount}`; // Dashify CSS var names to replicate postcss-js behaviour | ||
// See https://github.com/postcss/postcss-js/blob/d5127d4278c133f333f1c66f990f3552a907128e/parser.js#L30 | ||
@@ -128,3 +112,3 @@ | ||
rule | ||
}, getFileScope()); | ||
}, fileScope_dist_mattsjonesCssCoreFileScope.getFileScope()); | ||
return className; | ||
@@ -155,3 +139,3 @@ } | ||
} | ||
}, getFileScope()); | ||
}, fileScope_dist_mattsjonesCssCoreFileScope.getFileScope()); | ||
@@ -197,4 +181,2 @@ if (shouldCreateVars) { | ||
exports.createVar = createVar; | ||
exports.endFileScope = endFileScope; | ||
exports.setFileScope = setFileScope; | ||
exports.style = style; |
@@ -9,2 +9,3 @@ 'use strict'; | ||
var get = require('lodash/get'); | ||
var fileScope_dist_mattsjonesCssCoreFileScope = require('../fileScope/dist/mattsjones-css-core-fileScope.cjs.prod.js'); | ||
require('postcss-js'); | ||
@@ -57,20 +58,5 @@ require('postcss'); | ||
let refCounter = 0; | ||
const defaultFileScope = 'DEFAULT_FILE_SCOPE'; | ||
const fileScopes = [defaultFileScope]; | ||
function setFileScope(newFileScope) { | ||
refCounter = 0; | ||
fileScopes.unshift(newFileScope); | ||
} | ||
function endFileScope() { | ||
refCounter = 0; | ||
fileScopes.splice(0, 1); | ||
} | ||
function getFileScope() { | ||
return fileScopes[0]; | ||
} | ||
const generateClassName = debugId => { | ||
const className = `${hash__default['default'](getFileScope())}${refCounter++}`; | ||
const refCount = fileScope_dist_mattsjonesCssCoreFileScope.getAndIncrementRefCounter(); | ||
const className = `${hash__default['default'](fileScope_dist_mattsjonesCssCoreFileScope.getFileScope())}${refCount}`; | ||
return generateCss_dist_mattsjonesCssCoreGenerateCss.sanitiseIdent(className); | ||
@@ -100,3 +86,4 @@ }; | ||
function createVar(debugId) { | ||
const varName = `${hash__default['default'](getFileScope())}${refCounter++}`; // Dashify CSS var names to replicate postcss-js behaviour | ||
const refCount = fileScope_dist_mattsjonesCssCoreFileScope.getAndIncrementRefCounter(); | ||
const varName = `${hash__default['default'](fileScope_dist_mattsjonesCssCoreFileScope.getFileScope())}${refCount}`; // Dashify CSS var names to replicate postcss-js behaviour | ||
// See https://github.com/postcss/postcss-js/blob/d5127d4278c133f333f1c66f990f3552a907128e/parser.js#L30 | ||
@@ -113,3 +100,3 @@ | ||
rule | ||
}, getFileScope()); | ||
}, fileScope_dist_mattsjonesCssCoreFileScope.getFileScope()); | ||
return className; | ||
@@ -140,3 +127,3 @@ } | ||
} | ||
}, getFileScope()); | ||
}, fileScope_dist_mattsjonesCssCoreFileScope.getFileScope()); | ||
@@ -182,4 +169,2 @@ if (shouldCreateVars) { | ||
exports.createVar = createVar; | ||
exports.endFileScope = endFileScope; | ||
exports.setFileScope = setFileScope; | ||
exports.style = style; |
@@ -5,2 +5,3 @@ import { g as generateCss, s as sanitiseIdent } from './generateCss-23bcc40e.esm.js'; | ||
import get from 'lodash/get'; | ||
import { getAndIncrementRefCounter, getFileScope } from '../fileScope/dist/mattsjones-css-core-fileScope.esm.js'; | ||
import 'postcss-js'; | ||
@@ -48,27 +49,8 @@ import 'postcss'; | ||
let refCounter = 0; | ||
const defaultFileScope = 'DEFAULT_FILE_SCOPE'; | ||
const fileScopes = [defaultFileScope]; | ||
function setFileScope(newFileScope) { | ||
refCounter = 0; | ||
fileScopes.unshift(newFileScope); | ||
} | ||
function endFileScope() { | ||
refCounter = 0; | ||
fileScopes.splice(0, 1); | ||
} | ||
function getFileScope() { | ||
return fileScopes[0]; | ||
} | ||
function getShortFileName() { | ||
const fileScope = getFileScope(); | ||
const matches = fileScope.match(/.*\/(.*)\..*\..*$/); | ||
if (fileScope !== defaultFileScope) { | ||
const matches = fileScope.match(/.*\/(.*)\..*\..*$/); | ||
if (matches && matches[1]) { | ||
return matches[1]; | ||
} | ||
if (matches && matches[1]) { | ||
return matches[1]; | ||
} | ||
@@ -80,3 +62,4 @@ | ||
const generateClassName = debugId => { | ||
const className = process.env.NODE_ENV !== 'production' && debugId ? `${getShortFileName()}_${debugId}__${hash(getFileScope())}${refCounter++}` : `${hash(getFileScope())}${refCounter++}`; | ||
const refCount = getAndIncrementRefCounter(); | ||
const className = process.env.NODE_ENV !== 'production' && debugId ? `${getShortFileName()}_${debugId}__${hash(getFileScope())}${refCount}` : `${hash(getFileScope())}${refCount}`; | ||
return sanitiseIdent(className); | ||
@@ -106,3 +89,4 @@ }; | ||
function createVar(debugId) { | ||
const varName = process.env.NODE_ENV !== 'production' && debugId ? `${debugId}__${hash(getFileScope())}${refCounter++}` : `${hash(getFileScope())}${refCounter++}`; // Dashify CSS var names to replicate postcss-js behaviour | ||
const refCount = getAndIncrementRefCounter(); | ||
const varName = process.env.NODE_ENV !== 'production' && debugId ? `${debugId}__${hash(getFileScope())}${refCount}` : `${hash(getFileScope())}${refCount}`; // Dashify CSS var names to replicate postcss-js behaviour | ||
// See https://github.com/postcss/postcss-js/blob/d5127d4278c133f333f1c66f990f3552a907128e/parser.js#L30 | ||
@@ -181,2 +165,2 @@ | ||
export { createGlobalTheme, createInlineTheme, createTheme, createThemeVars, createVar, endFileScope, setFileScope, style }; | ||
export { createGlobalTheme, createInlineTheme, createTheme, createThemeVars, createVar, style }; |
{ | ||
"name": "@mattsjones/css-core", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"main": "dist/mattsjones-css-core.cjs.js", | ||
@@ -14,3 +14,4 @@ "module": "dist/mattsjones-css-core.esm.js", | ||
"adapter.ts", | ||
"generateCss.ts" | ||
"generateCss.ts", | ||
"fileScope.ts" | ||
] | ||
@@ -21,3 +22,4 @@ }, | ||
"/adapter", | ||
"/generateCss" | ||
"/generateCss", | ||
"/fileScope" | ||
], | ||
@@ -24,0 +26,0 @@ "author": "Matt Jones", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
95075
47
2286
0
13