Skip to content

Commit

Permalink
Add back the broken types
Browse files Browse the repository at this point in the history
  • Loading branch information
hadihallak committed Oct 4, 2022
1 parent 0414e17 commit d2c1264
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/core/src/sheet.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/** @typedef {import('./sheet').RuleGroup} RuleGroup */
/** @typedef {import('./sheet').RuleGroupNames} RuleGroupNames */
/** @typedef {import('./sheet').SheetGroup} SheetGroup */

/**
* Rules in the sheet appear in this order:
* 1. theme rules (themed)
Expand All @@ -8,10 +12,10 @@
* 6. compound variants rules (allvar)
* 7. inline rules (inline)
*/

/** @type {RuleGroupNames} */
export const names = ['themed', 'global', 'styled', 'onevar', 'resonevar', 'allvar', 'inline']

const isSheetAccessible = (sheet) => {
const isSheetAccessible = (/** @type {CSSStyleSheet} */ sheet) => {
if (sheet.href && !sheet.href.startsWith(location.origin)) {
return false
}
Expand All @@ -23,7 +27,7 @@ const isSheetAccessible = (sheet) => {
}
}

export const createSheet = (root) => {
export const createSheet = (/** @type {DocumentOrShadowRoot} */ root) => {
/** @type {SheetGroup} Object hosting the hydrated stylesheet. */
let groupSheet

Expand Down Expand Up @@ -69,7 +73,7 @@ export const createSheet = (root) => {
}
}


/** @type {StyleSheetList} */
const sheets = Object(root).styleSheets || []

// iterate all stylesheets until a hydratable stylesheet is found
Expand Down Expand Up @@ -117,8 +121,8 @@ export const createSheet = (root) => {

// if no hydratable stylesheet is found
if (!groupSheet) {
const createCSSMediaRule = (sourceCssText, type) => {
return ({
const createCSSMediaRule = (/** @type {string} */ sourceCssText, type) => {
return /** @type {CSSMediaRule} */ ({
type,
cssRules: [],
insertRule(cssText, index) {
Expand Down Expand Up @@ -165,7 +169,7 @@ export const createSheet = (root) => {
return groupSheet
}

const addApplyToGroup = (group) => {
const addApplyToGroup = (/** @type {RuleGroup} */ group) => {
const groupingRule = group.group

let index = groupingRule.cssRules.length
Expand Down

0 comments on commit d2c1264

Please sign in to comment.