Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@office-open/core

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@office-open/core

Shared OOXML infrastructure: XmlComponent, value validators, unit converters

Source
npmnpm
Version
0.6.9
Version published
Weekly downloads
731
-61.47%
Maintainers
1
Weekly downloads
 
Created
Source

@office-open/core

npm version npm downloads npm license

Shared OOXML infrastructure: XmlComponent, value validators, unit converters, chart types, and SmartArt definitions.

Features

  • XmlComponent Framework - Base classes for building OOXML element trees with dynamic namespace support
  • Value Validators - Runtime validation for OOXML spec types (ST_HexColor, ST_OnOff, ST_DecimalNumber, etc.)
  • Unit Converters - TWIP and EMU conversions (mm/in/pt/px)
  • Chart Components - Shared chart types (bar, line, pie, area, scatter) and chart collection for DOCX/PPTX
  • SmartArt Components - Data model, tree-to-model converter, collection, and built-in layout/style/color definitions
  • ID Generators - Sequential numeric IDs, nanoid, SHA-1 hash, UUID v4
  • OOXML Compliance - All types verified against ISO/IEC 29500-4 XSD schemas

Installation

# Install with npm
$ npm install @office-open/core

# Install with pnpm
$ pnpm add @office-open/core

Quick Start

import {
  OnOffElement,
  StringValueElement,
  BuilderElement,
  StringContainer,
  hexColorValue,
  decimalNumber,
  convertMillimetersToTwip,
  uniqueNumericIdCreator,
} from "@office-open/core";

// CT_OnOff — dynamic namespace prefix per XSD spec
new OnOffElement("w:b", false);
// → { "w:b": { _attr: { "w:val": false } } }

new OnOffElement("m:hideBot", false);
// → { "m:hideBot": { _attr: { "m:val": false } } }

// Builder with attributes + children
new BuilderElement({
  name: "w:r",
  attributes: { lang: { key: "xml:lang", value: "en-US" } },
  children: [new StringContainer("w:t", "Hello")],
});

// Value validators
hexColorValue("#FF0000"); // → "FF0000"
hexColorValue("auto"); // → "auto"
decimalNumber(10.7); // → 10

// Unit converters
convertMillimetersToTwip(25.4); // → 1440 (1 inch)
convertPixelsToEmu(100); // → 952500
convertInchesToEmu(1); // → 914400
convertPointsToEmu(12); // → 152400

// ID generators
const gen = uniqueNumericIdCreator();
gen(); // → 1, 2, 3, ...

OOXML Schema Compliance

TypeXSD Reference
ThemeColorST_ThemeColor (17 values)
ThemeFontST_Theme (8 values)
UniversalMeasureST_UniversalMeasure (mm, cm, in, pt, pc, pi)
PercentageST_Percentage
hexColorValueST_HexColor (auto + 3-byte hexBinary)
OnOffElementCT_OnOff (dynamic namespace prefix)
HpsMeasureElementCT_HpsMeasure
StringValueElementCT_String

Exports

PathContents
@office-open/coreXmlComponent, validators, converters, ID generators
@office-open/core/valuesValidators + ThemeColor/ThemeFont only
@office-open/core/chartChart types, series data, chart collection, title
@office-open/core/smartartSmartArt data model, tree-to-model, definitions

Benchmark

Operationhz
decimalNumber~21M
hexColorValue (6-char hex)~13M
uniqueNumericIdCreator~21M
uniqueId (nanoid)~3.2M
uniqueUuid~2.0M
onOffObj (true)~19M
onOffObj (false)~3.7M
BuilderElement (attributes)~3.1M
BuilderElement (children)~2.6M

License

  • MIT © Demo Macro

Keywords

core

FAQs

Package last updated on 31 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts