@stylable/module-utils
Advanced tools
Comparing version 5.8.0 to 5.9.0
@@ -20,7 +20,7 @@ "use strict"; | ||
const classes = tokens.find(({ type }) => type === 'classes'); | ||
const token = classes === null || classes === void 0 ? void 0 : classes.tokens.find(({ value }) => value === `"${local}"`); | ||
if (token === null || token === void 0 ? void 0 : token.outputValue) { | ||
const stateName = token === null || token === void 0 ? void 0 : token.outputValue.value; | ||
const token = classes?.tokens.find(({ value }) => value === `"${local}"`); | ||
if (token?.outputValue) { | ||
const stateName = token?.outputValue.value; | ||
const states = tokens.find(({ type }) => type === 'states'); | ||
const classStates = states === null || states === void 0 ? void 0 : states.tokens.find(({ className: { value } }) => value === stateName); | ||
const classStates = states?.tokens.find(({ className: { value } }) => value === stateName); | ||
if (classStates) { | ||
@@ -27,0 +27,0 @@ return classStates.classStates; |
@@ -40,5 +40,4 @@ "use strict"; | ||
function getStVarsSrcPosition(varName, meta) { | ||
var _a; | ||
const stVar = Object.values(meta.getAllStVars()).find((v) => v.name === varName); | ||
if ((_a = stVar === null || stVar === void 0 ? void 0 : stVar.node.source) === null || _a === void 0 ? void 0 : _a.start) { | ||
if (stVar?.node.source?.start) { | ||
return { | ||
@@ -54,4 +53,3 @@ line: stVar.node.source.start.line - 1, | ||
return rule.walkDecls((decl) => { | ||
var _a; | ||
if ((_a = decl.source) === null || _a === void 0 ? void 0 : _a.start) { | ||
if (decl.source?.start) { | ||
if (decl.prop === varName) { | ||
@@ -65,5 +63,4 @@ res = { | ||
(0, index_internal_2.processDeclarationFunctions)(decl, (node, level) => { | ||
var _a, _b; | ||
if (node.type === 'item' && node.name === varName) { | ||
const rawDeclaration = `${(_a = decl.raws.before) !== null && _a !== void 0 ? _a : ''}${decl.prop}${(_b = decl.raws.between) !== null && _b !== void 0 ? _b : ''}${decl.value}`; | ||
const rawDeclaration = `${decl.raws.before ?? ''}${decl.prop}${decl.raws.between ?? ''}${decl.value}`; | ||
const rootPosition = { | ||
@@ -130,9 +127,8 @@ line: rule.source.start.line - 1, | ||
function findDefiningClassName(stateToken, entryClassName) { | ||
var _a, _b; | ||
let currentClass = entryClassName; | ||
while (currentClass[`-st-states`]) { | ||
if (((_a = currentClass[`-st-states`]) === null || _a === void 0 ? void 0 : _a[stripQuotes(stateToken.stateName.value)]) !== undefined) { | ||
if (currentClass[`-st-states`]?.[stripQuotes(stateToken.stateName.value)] !== undefined) { | ||
return currentClass.name; | ||
} | ||
if (((_b = currentClass['-st-extends']) === null || _b === void 0 ? void 0 : _b._kind) === 'class') { | ||
if (currentClass['-st-extends']?._kind === 'class') { | ||
currentClass = currentClass[`-st-extends`]; | ||
@@ -191,5 +187,4 @@ } | ||
function getClassSourceName(targetName, classTokens) { | ||
var _a; | ||
for (const classToken of classTokens.tokens) { | ||
if (((_a = classToken.outputValue) === null || _a === void 0 ? void 0 : _a.value) === targetName) { | ||
if (classToken.outputValue?.value === targetName) { | ||
return classToken.value; | ||
@@ -201,3 +196,2 @@ } | ||
function generateDTSSourceMap(dtsContent, meta, targetFilePath) { | ||
var _a; | ||
const tokens = (0, dts_rough_tokenizer_1.tokenizeDTS)(dtsContent); | ||
@@ -238,3 +232,3 @@ const mapping = {}; | ||
const columnDelta = currentSrcPosition.column - lastSrcPosition.column; | ||
mapping[dtsLine] = createLineMapping(generate_dts_1.SPACING.repeat((_a = currentSrcPosition.generatedOffsetLevel) !== null && _a !== void 0 ? _a : 1).length, lineDelta, columnDelta); | ||
mapping[dtsLine] = createLineMapping(generate_dts_1.SPACING.repeat(currentSrcPosition.generatedOffsetLevel ?? 1).length, lineDelta, columnDelta); | ||
// reset to default offset level | ||
@@ -262,3 +256,3 @@ currentSrcPosition.generatedOffsetLevel = undefined; | ||
file: `${stylesheetName}.d.ts`, | ||
sources: [targetFilePath !== null && targetFilePath !== void 0 ? targetFilePath : stylesheetName], | ||
sources: [targetFilePath ?? stylesheetName], | ||
names: [], | ||
@@ -272,3 +266,2 @@ mappings: Object.values(mapping) | ||
function calculateEstimatedPosition(rawValue, name, after = '', rootPosition) { | ||
var _a, _b; | ||
const valueLength = rawValue.indexOf(name + after) + name.length - after.length; | ||
@@ -279,6 +272,6 @@ const value = rawValue.slice(0, valueLength); | ||
return { | ||
line: byLines.length - 1 + ((_a = rootPosition === null || rootPosition === void 0 ? void 0 : rootPosition.line) !== null && _a !== void 0 ? _a : 0), | ||
column: lastLine.length + ((_b = rootPosition === null || rootPosition === void 0 ? void 0 : rootPosition.column) !== null && _b !== void 0 ? _b : 0), | ||
line: byLines.length - 1 + (rootPosition?.line ?? 0), | ||
column: lastLine.length + (rootPosition?.column ?? 0), | ||
}; | ||
} | ||
//# sourceMappingURL=generate-dts-sourcemaps.js.map |
@@ -31,3 +31,3 @@ "use strict"; | ||
const booleanState = !stateDef; | ||
const mappedState = (stateDef === null || stateDef === void 0 ? void 0 : stateDef.type) === 'template' || typeof stateDef === 'string'; | ||
const mappedState = stateDef?.type === 'template' || typeof stateDef === 'string'; | ||
if (booleanState || !mappedState) { | ||
@@ -34,0 +34,0 @@ stateEntriesString += `${asString(stateName)}?: ${getStateTSType(stateDef)}; `; |
@@ -42,8 +42,8 @@ "use strict"; | ||
function runtimeImport(moduleType, runtimeRequest, injectOptions) { | ||
const importInjectCSS = (injectOptions === null || injectOptions === void 0 ? void 0 : injectOptions.css) ? `, injectCSS` : ''; | ||
const request = JSON.stringify(runtimeRequest !== null && runtimeRequest !== void 0 ? runtimeRequest : | ||
// TODO: we use direct requests here since we don't know how this will be resolved | ||
(moduleType === 'esm' | ||
? '@stylable/runtime/esm/runtime.js' | ||
: '@stylable/runtime/dist/runtime.js')); | ||
const importInjectCSS = injectOptions?.css ? `, injectCSS` : ''; | ||
const request = JSON.stringify(runtimeRequest ?? | ||
// TODO: we use direct requests here since we don't know how this will be resolved | ||
(moduleType === 'esm' | ||
? '@stylable/runtime/esm/runtime.js' | ||
: '@stylable/runtime/dist/runtime.js')); | ||
return moduleType === 'esm' | ||
@@ -54,3 +54,3 @@ ? `import { classesRuntime, statesRuntime${importInjectCSS} } from ${request};` | ||
function runtimeExecuteInject(moduleType, injectOptions) { | ||
if (!(injectOptions === null || injectOptions === void 0 ? void 0 : injectOptions.css)) { | ||
if (!injectOptions?.css) { | ||
return ''; | ||
@@ -57,0 +57,0 @@ } |
{ | ||
"name": "@stylable/module-utils", | ||
"version": "5.8.0", | ||
"version": "5.9.0", | ||
"description": "Stylable module creation utilities", | ||
@@ -10,3 +10,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@stylable/core": "^5.8.0", | ||
"@stylable/core": "^5.9.0", | ||
"@tokey/core": "^1.3.0", | ||
@@ -13,0 +13,0 @@ "vlq": "^2.0.4" |
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
Sorry, the diff of this file is not supported yet
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
110112
1989
Updated@stylable/core@^5.9.0