Skip to content

Commit

Permalink
chore: fixes after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
nd0ut committed Jun 24, 2024
1 parent 1c0bf19 commit b7ad70c
Show file tree
Hide file tree
Showing 17 changed files with 172 additions and 164 deletions.
8 changes: 4 additions & 4 deletions abstract/ActivityBlock.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
import { debounce } from '../blocks/utils/debounce.js';
import { EventType } from '../blocks/UploadCtxProvider/EventEmitter.js';
import { debounce } from '../blocks/utils/debounce.js';
import { Block } from './Block.js';
import { activityBlockCtx } from './CTX.js';

Expand All @@ -15,15 +15,15 @@ export class ActivityBlock extends Block {

/** @private */
_deactivate() {
let actDesc = ActivityBlock._activityCallbacks.get(this);
const actDesc = ActivityBlock._activityCallbacks.get(this);
this[ACTIVE_PROP] = false;
this.removeAttribute(ACTIVE_ATTR);
actDesc?.deactivateCallback?.();
}

/** @private */
_activate() {
let actDesc = ActivityBlock._activityCallbacks.get(this);
const actDesc = ActivityBlock._activityCallbacks.get(this);
this.$['*historyBack'] = this.historyBack.bind(this);
/** @private */
this[ACTIVE_PROP] = true;
Expand Down Expand Up @@ -167,7 +167,7 @@ export class ActivityBlock extends Block {

historyBack() {
/** @type {String[]} */
let history = this.$['*history'];
const history = this.$['*history'];
if (history) {
let nextActivity = history.pop();
while (nextActivity === this.activityType) {
Expand Down
40 changes: 20 additions & 20 deletions abstract/Block.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import { BaseComponent, Data } from '@symbiotejs/symbiote';
import { initialConfig } from '../blocks/Config/initialConfig.js';
import { EventEmitter } from '../blocks/UploadCtxProvider/EventEmitter.js';
import { WindowHeightTracker } from '../utils/WindowHeightTracker.js';
import { extractFilename, extractCdnUrlModifiers, extractUuid } from '../utils/cdn-utils.js';
import { extractCdnUrlModifiers, extractFilename, extractUuid } from '../utils/cdn-utils.js';
import { getLocaleDirection } from '../utils/getLocaleDirection.js';
import { getPluralForm } from '../utils/getPluralForm.js';
import { applyTemplateData, getPluralObjects } from '../utils/template-utils.js';
import { waitForAttribute } from '../utils/waitForAttribute.js';
import { blockCtx } from './CTX.js';
import { LocaleManager, localeStateKey } from './LocaleManager.js';
import { A11y } from './a11y.js';
import { l10nProcessor } from './l10nProcessor.js';
import { sharedConfigKey } from './sharedConfigKey.js';
import { A11y } from './a11y.js';

const TAG_PREFIX = 'lr-';

Expand All @@ -39,15 +39,15 @@ export class Block extends BaseComponent {
if (!str) {
return '';
}
let template = this.$[localeStateKey(str)] || str;
let pluralObjects = getPluralObjects(template);
for (let pluralObject of pluralObjects) {
const template = this.$[localeStateKey(str)] || str;
const pluralObjects = getPluralObjects(template);
for (const pluralObject of pluralObjects) {
variables[pluralObject.variable] = this.pluralize(
pluralObject.pluralKey,
Number(variables[pluralObject.countVariable]),
);
}
let result = applyTemplateData(template, variables);
const result = applyTemplateData(template, variables);
return result;
}

Expand Down Expand Up @@ -97,7 +97,7 @@ export class Block extends BaseComponent {
* @returns {Boolean}
*/
hasBlockInCtx(callback) {
for (let block of this.blocksRegistry) {
for (const block of this.blocksRegistry) {
if (callback(block)) {
return true;
}
Expand Down Expand Up @@ -129,13 +129,13 @@ export class Block extends BaseComponent {

connectedCallback() {
const styleAttrs = /** @type {typeof Block} */ (this.constructor).styleAttrs;
styleAttrs.forEach((attr) => {
for (const attr of styleAttrs) {
this.setAttribute(attr, '');
});
}

if (this.hasAttribute('retpl')) {
// @ts-ignore TODO: fix this
this.constructor['template'] = null;
this.constructor.template = null;
this.processInnerHtml = true;
}
if (this.requireCtxName) {
Expand Down Expand Up @@ -168,7 +168,7 @@ export class Block extends BaseComponent {
this.add('*blocksRegistry', new Set());
}

let blocksRegistry = this.$['*blocksRegistry'];
const blocksRegistry = this.$['*blocksRegistry'];
blocksRegistry.add(this);

if (!this.has('*eventEmitter')) {
Expand Down Expand Up @@ -204,7 +204,7 @@ export class Block extends BaseComponent {
}

destroyCallback() {
let blocksRegistry = this.blocksRegistry;
const blocksRegistry = this.blocksRegistry;
blocksRegistry.delete(this);

this.localeManager?.destroyL10nBindings(this);
Expand Down Expand Up @@ -239,18 +239,18 @@ export class Block extends BaseComponent {
* @param {Number} [decimals]
*/
fileSizeFmt(bytes, decimals = 2) {
let units = ['B', 'KB', 'MB', 'GB', 'TB'];
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
/**
* @param {String} str
* @returns {String}
*/
if (bytes === 0) {
return `0 ${units[0]}`;
}
let k = 1024;
let dm = decimals < 0 ? 0 : decimals;
let i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / k ** i).toFixed(dm)) + ' ' + units[i];
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const i = Math.floor(Math.log(bytes) / Math.log(k));
return `${Number.parseFloat((bytes / k ** i).toFixed(dm))} ${units[i]}`;
}

/**
Expand Down Expand Up @@ -283,7 +283,7 @@ export class Block extends BaseComponent {
/** @returns {import('../types').ConfigType} } */
get cfg() {
if (!this.__cfgProxy) {
let o = Object.create(null);
const o = Object.create(null);
/** @private */
this.__cfgProxy = new Proxy(o, {
set: (obj, key, value) => {
Expand Down Expand Up @@ -342,10 +342,10 @@ export class Block extends BaseComponent {
/** @param {String} [name] */
static reg(name) {
if (!name) {
super.reg();
BaseComponent.reg();
return;
}
super.reg(name.startsWith(TAG_PREFIX) ? name : TAG_PREFIX + name);
BaseComponent.reg(name.startsWith(TAG_PREFIX) ? name : TAG_PREFIX + name);
}
}

Expand Down
2 changes: 1 addition & 1 deletion abstract/SolutionBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class SolutionBlock extends Block {
}

static set template(value) {
SolutionBlock._template = `${svgIconsSprite + value}<slot></slot>`;
SolutionBlock._template = /* HTML */ `${svgIconsSprite + value}<slot></slot>`;
}

static get template() {
Expand Down
2 changes: 1 addition & 1 deletion abstract/a11y.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
import { startKeyUX, hiddenKeyUX, jumpKeyUX, focusGroupKeyUX, pressKeyUX } from 'keyux';
import { focusGroupKeyUX, hiddenKeyUX, jumpKeyUX, pressKeyUX, startKeyUX } from 'keyux';

/**
* MinimalWindow interface is not exported by keyux, so we import it here using tricky way.
Expand Down
6 changes: 4 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.2/schema.json",
"files": {
"ignore": ["**/web", "./index.ssr.js", "**/svg-sprite.js"]
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
Expand All @@ -17,8 +20,7 @@
"enabled": true,
"rules": {
"recommended": true
},
"ignore": ["**/web", "index.ssr.js"]
}
},
"javascript": {
"formatter": {
Expand Down
Loading

0 comments on commit b7ad70c

Please sign in to comment.