@bendyline/squisq

中文文档
2.13.14发布于 2026/11/08MITTypeScriptES Module构建来源已验证近 30 天下载 8457

Headless utilities for doc/block rendering, spatial math, Markdown, and storage

原始使用文档
文档目录13 节
  1. Install
  2. What's Inside
  3. New in this release
  4. Subpath Imports
  5. Quick Examples
  6. Parse Markdown
  7. Condense imported Markdown
  8. Author an ASCII Timeline
  9. Spatial Utilities
  10. Materialize a Block
  11. Theme System
  12. Related Packages
  13. License

@bendyline/squisq

Headless utilities for doc/block rendering, spatial math, Markdown parsing, and storage. Framework-agnostic — runs in the browser or Node.js with zero framework dependencies.

Part of the Squisq monorepo.

npm MIT License

Install

npm install @bendyline/squisq

What's Inside

ModuleDescription
schemasType definitions — Doc, BlockTemplate, Viewport, Theme, LayoutStrategy
docTemplate registry, 26 block templates, animation/theme utilities
markdownMarkdown parsing, stringifying, AST types (MarkdownDocument), tree utilities
spatialHaversine distance and bearing, great-circle paths, Geohash encode/decode
storageStorageAdapter interface, Memory + LocalStorage + LocalForage adapters

New in this release

The Squiggly Square markdown standard (see docs/SquigglySquare.md) gained several authoring capabilities:

  • Standalone annotations — a top-level paragraph that is exactly {[templateName …]} becomes a heading-less template block; the body that follows it is its contents.
  • Inline attribute coercion — {[map center="47.6,-122.3" zoom=9]} and {[twoColumn left="Espresso|Bold"]} now render without a data fence (typed via TEMPLATE_INPUT_DESCRIPTORS).
  • Validation additions — new unknown-input / invalid-input-value / missing-input warnings plus possible-data-fence / conflicting-annotation-key info diagnostics (a new info severity).
  • YAML data fences now accept one level of nested mappings (a map center can be pure YAML).
  • Multi-line frontmatter — squisq-custom-templates / squisq-custom-themes can be authored as pretty JSON via YAML literal block scalars (key: |-).
  • Custom-template tokens v2 (see docs/SquigglySquare.md, "Registering custom templates") — {attr:key}, pipe defaults on every token, and per-layer repeat with {item} / {index} tokens.

New @bendyline/squisq/doc exports powering the above: coerceTemplateParams, lintTemplateParams, TEMPLATE_INPUT_DESCRIPTORS, and replaceDataFence.

Subpath Imports

Import only what you need:

import type { Doc, BlockTemplate, Theme } from '@bendyline/squisq/schemas';
import { materializeBlockLayers, expandDocBlocks } from '@bendyline/squisq/doc';
import { parseMarkdown, stringifyMarkdown } from '@bendyline/squisq/markdown';
import { encodeGeohash, haversineDistance } from '@bendyline/squisq/spatial';
import { LocalStorageAdapter } from '@bendyline/squisq/storage';

Or import everything from the root:

import { parseMarkdown, haversineDistance, materializeBlockLayers } from '@bendyline/squisq';

Quick Examples

Parse Markdown

import { parseMarkdown, stringifyMarkdown } from '@bendyline/squisq/markdown';

const doc = parseMarkdown('# Hello\n\nSome content');
console.log(doc.children); // AST nodes

const md = stringifyMarkdown(doc);

Condense imported Markdown

condenseMarkdownSource(source) removes table alignment padding, shortens GFM delimiter rows, and reduces decorative thematic breaks to three markers. It preserves table cells and alignment, code, math, HTML, links, footnotes, prose, and frontmatter. The output is reparsed and structurally compared with the original before returning; the API throws if equivalence cannot be proven. It is idempotent and does not summarize articles or remove citations.

Run condensation after link/image edits, which can re-serialize padded tables.

import { condenseMarkdownSource } from '@bendyline/squisq/markdown';

const compactMarkdown = condenseMarkdownSource(importedMarkdown);

The shared source-transform registry also exposes condense, available from the editor's Transform menu and squisq transform file.md --ops condense.

Author an ASCII Timeline

Timeline fences are source-of-truth markdown. Unicode marker rails are auto-detected; the explicit timeline language also accepts sparse/ASCII forms. Repeat rails for multiple tracks and use event ids in branch: lines for forks or cross-track links. Add longer callout text after ::; optional side=above|below, descriptionSide=above|below, and callout=false metadata control placement or suppress labels on dense cadence points.

## Runtime timing

```timeline
Kernel: ● T28 :: Δ28 {#t28 side=above descriptionSide=below} ─────● T29 {#t29} ─────● T30 {#t30} ───►
Client: ──────────────────● Frame A {#frame-a} ───● Frame B {#frame-b} ───►
branch: t29 -> frame-a : interpolate
```

markdownToDoc() derives globally aligned event positions while preserving the original fence byte-for-byte for markdown round-trips.

Spatial Utilities

import {
  destinationPoint,
  encodeGeohash,
  haversineDistance,
  sampleGreatCircle,
} from '@bendyline/squisq/spatial';

const distanceKm = haversineDistance({ lat: 47.6, lng: -122.3 }, { lat: 37.7, lng: -122.4 });
const hash = encodeGeohash(47.6, -122.3, 7);

// Points along the shortest route, and a position projected 5 km due east.
const route = sampleGreatCircle({ lat: 47.6, lng: -122.3 }, { lat: 51.5, lng: -0.1 }, 20);
const ahead = destinationPoint({ lat: 47.6, lng: -122.3 }, 90, 5_000);

Materialize a Block

import { materializeBlockLayers } from '@bendyline/squisq/doc';

const result = materializeBlockLayers(block, {
  theme,
  viewport,
  customTemplates: doc.customTemplates,
});

render(result.layers);
if (result.diagnostic) report(result.diagnostic);

The canonical materializer handles authored layers, built-in and document-scoped templates, theme motion, and persistent layers. Failed templates produce a visible fallback plus a structured diagnostic by default; pass failureMode: 'empty' when a host deliberately wants no fallback UI.

Theme System

import {
  compileTheme,
  createThemeRegistry,
  getAvailableThemes,
  resolveTheme,
} from '@bendyline/squisq/schemas';

const themes = getAvailableThemes(); // 11 built-in themes
const theme = resolveTheme('cinematic');

// Host-level custom themes live in an explicit caller-owned registry.
const registry = createThemeRegistry([
  compileTheme({ id: 'brand', name: 'Brand', seedColors: { primary: '#6633cc' } }),
]);
const brand = resolveTheme('brand', registry);
PackageDescription
@bendyline/squisq-reactReact components for rendering docs
@bendyline/squisq-formatsDOCX, PDF, HTML import/export
@bendyline/squisq-editor-reactReact editor with raw/WYSIWYG/preview modes

License

MIT

版本与发布记录

@bendyline/squisq 共发布 76 个版本,首次发布于 2026/03/16;过去 12 个月发布了 76 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.13.14latest2026/11/08今天
2.13.132026/11/07今天
2.13.122026/11/052 天前
2.13.112026/11/053 天前
2.13.102026/11/017 天前
2.13.92026/10/308 天前

关于 @bendyline/squisq 的常见问题

@bendyline/squisq 是什么?

Headless utilities for doc/block rendering, spatial math, Markdown, and storage

如何安装 @bendyline/squisq?

在项目目录运行 npm install @bendyline/squisq,或使用 pnpm add / yarn add / bun add。

@bendyline/squisq 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bendyline/squisq 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bendyline/squisq 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^22.22.2 || ^24.15.0 || >=26.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bendyline/squisq 可以商用吗?

@bendyline/squisq 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bendyline/squisq 的下载量有多少?

根据 npm 官方下载统计,@bendyline/squisq 在 2026/10/08 – 2026/11/06 这 30 天内被下载 8,457 次,日均约 282 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bendyline/squisq 还在维护吗?

最新版本 2.13.14 发布于 2026/11/08(今天);至今共发布 76 个版本,其中过去 12 个月发布了 76 个;首次发布于 2026/03/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。