@blockbite/shared-utils

v2.1.10

Published

Blockbite shared JavaScript utilities

Readme

Shared Utilities

A collection of shared Blockbite JavaScript/TypeScript utilities.

Installation

pnpm add @blockbite/shared-utils
# or
npm install @blockbite/shared-utils

Usage Examples

Array Utilities

import { getClosest, chunkArray } from '@blockbite/shared-utils';

const closest = getClosest([10, 20, 30], 25); // 20
const chunks = chunkArray([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]

Webpack Helpers

const { blockbiteDefaultConfig } = require('@blockbite/shared-utils');

// Use with wp-scripts
const defaultConfig = blockbiteDefaultConfig(wpConfig);
const originalEntry = defaultConfig.entry;

defaultConfig.entry = async () => {
  const defaultEntries = await originalEntry();
  const customEntries = {
    'blockbite-bb': path.resolve(process.cwd(), 'src/core', 'bb.ts'),
    'blockbite-core': path.resolve(process.cwd(), 'src/core', 'core.ts'),
  };
  const finalEntries = { ...defaultEntries, ...customEntries };

  return finalEntries;
};

Responsive AST Compiler (CLI-Friendly)

import {
  compileResponsivenessForAst,
  defaultResponsivenessSettings,
} from '@blockbite/shared-utils';

const ast = {
  children: [
    {
      type: 'core/group',
      props: { bbStyle: 'flex flex-row gap-10' },
      children: [],
    },
  ],
};

const { ast: nextAst } = compileResponsivenessForAst(ast, {
  ...defaultResponsivenessSettings,
  enabled: true,
});

Responsive CLI

pnpm exec bb-responsive --path-latest="/var/www/html/web/app/uploads/blockbite/figma"
# or
pnpm exec bb-responsive --path="/var/www/html/web/app/uploads/blockbite/figma/20260221-082527"

The CLI reads responsiveness.settings.json from the target folder when available and rewrites *.ast.json files in place.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.