SGApps.IO products · Spreadsheet · Writer · Packer

ApplicationPrototype Thirdparty

Three SGApps.IO products, written in-house from scratch -- an Excel-like Spreadsheet with its own formula engine, a Word-like Writer with its own DOCX reader and writer, and a Packer with its own ZIP, TAR, 7z and LZMA implementations -- about 34,000 lines of original JavaScript (plus 8,700 of CSS) with no third-party editor, parser or archive library inside. Around them, for the application-prototype framework: an iframe sandbox of our own, a CodeMirror-based code editor, and thin Application.require() wrappers for 24 vendored open-source libraries. Plain ES5, no build step, no bundler.

Open the documentation →
Our products · Getting started · Playground · Repository

What is it?

Three SGApps.IO products for the application-prototype framework, and the modules and wrappers around them -- three tiers, and every card below carries a badge saying which is which. SGApps.IO products -- the Spreadsheet, the Writer and the Packer -- are original software developed in-house by SGApps.IO: their formula engine, document model, pagination, OOXML / ODF readers and writers, ZIP / TAR / 7z containers and LZMA codec are all our own code (proprietary, source-available). SGApps.IO modules are Apache-2.0 infrastructure we wrote: the iframe sandbox, and our integration code around CodeMirror and JSZip. Third-party wrappers are thin Application.require() adapters that make 24 open-source libraries (amCharts 4, PDF.js, Tesseract.js, OpenCV.js, SQL.js, Xterm.js, CKEditor 4 / 5, SVG-Edit, JsBarcode, ZXing, ...) load lazily and behave like every other module; each is labelled with its upstream project and licence.

34,000 lines of our own JavaScript

Spreadsheet (~13,000 JS + 2,900 CSS), Writer (~19,400 JS + 5,800 CSS) and Packer (1,642) -- counted with wc -l; a grep for require( over the product folders shows they load only the framework and the Packer: no third-party editor, parser, chart, formula or archive library.

What the code contains

A formula tokenizer / parser / evaluator with 130+ functions and dependency-ordered recalculation; a paginated document engine with its own DOCX reader and writer; a ZIP / ustar / 7z writer whose output the reference tools accept, and an LZMA range coder that 7-Zip accepts.

Verified against the reference tools

Packer's output passes unzip -t, GNU tar, gzip -t and 7z t; the Spreadsheet's XLSX / ODS exports and the Writer's DOCX export open in LibreOffice (headless conversion, recorded in the fix trackers).

One loader, one API

modules/lib.js registers 36 names; products and wrappers alike return ApplicationPrototype instances with on(), bind(), whenLoaded(), and a playground page each.

SGApps.IO products Proprietary, source-available

Original software developed from scratch by SGApps.IO. No third-party runtime code: the only things they load are the application-prototype framework (also ours) and, for packing exports, the Packer. Proprietary, source-available -- the source is published for evaluation; using them in a product needs an agreement with SGApps.IO.

Spreadsheet SGApps.IO product

editors/spreadsheet · ~15,900 lines

An Excel-like editor with its own formula engine -- tokenizer, recursive-descent parser and AST evaluator with 130+ functions (SUM..SUMIFS, VLOOKUP / INDEX / MATCH, IFS, STDEV, PMT / NPV / IRR, dates), dependency-ordered recalculation with #CIRC! detection -- a virtual-scroll grid with freeze panes, own SVG charts (no chart library), conditional formatting, validation, named ranges, undo/redo with batching, and own XLSX / ODS readers and writers over its own ZIP parser and the native DecompressionStream. editor, viewer and minimal modes.

Writer SGApps.IO product

editors/writer · ~25,000 lines

A Word-class document editor: paginated A4 / Letter pages with headers, footers, sections and rulers, or a fluid inline layout; WYSIWYG, Markdown and HTML source modes; styles, themes, presets, slash commands, find & replace. Its own OOXML reader (paragraphs, run formatting resolved against styles.xml, tables, embedded images) and writer (document, styles, header / footer parts, relationships, inline pictures, hyperlinks), its own HTML ↔ JSON and Markdown parsers, a paste cleaner, an image crop tool and a 6,600-line JSON document-model engine with snapshot undo/redo. Imports DOCX, ODT, HTML, Markdown; exports DOCX, HTML, Markdown, text, JSON and PDF via print.

Packer SGApps.IO product

archiver/packer · 1,642 lines, one file

A browser-side archive engine: creates and extracts ZIP, TAR (ustar), GZIP, TAR.GZ and 7z (7z reader: LZMA1 / Copy codecs, uncompressed headers), lists RAR v4 / v5 archives and extracts their stored entries, detects formats by magic bytes. Every container is hand-written -- local headers, central directory and EOCD; ustar checksums and long-name prefixes; the 7z property-block header -- plus a complete LZMA range-coder encoder and decoder whose archives pass 7z t and extract byte-identical. CRC-32 in-house too; UTF-8 through the native TextEncoder / TextDecoder, DEFLATE through the browser's native CompressionStream. Also what Writer and Spreadsheet use to pack their exports.

All modules

36 module names registered by modules/lib.js -- 31 modules, CKEditor 5 contributing six names -- each module with a documentation page and at least one playground example (35 in all). The badge on every card says who wrote what.

SGApps.IO product original software, built in-house from scratch; proprietary, source-available SGApps.IO module our integration code around an open-source library, Apache-2.0 Third-party wrapper a thin loader for someone else's library, which keeps its own licence

SGApps.IO products Proprietary, source-available

Described above.

Spreadsheet SGApps.IO product

editors/spreadsheet

Excel-like editor with its own formula engine (130+ functions), virtual-scroll grid, SVG charts, conditional formatting, and own XLSX / ODS / CSV import and export.

Writer SGApps.IO product

editors/writer

Word-class document editor: paginated or inline layout, WYSIWYG / Markdown / HTML source modes, own DOCX reader and writer, PDF via print.

Packer SGApps.IO product

archiver/packer

ZIP, TAR, GZIP, TAR.GZ and 7z creation and extraction, RAR v4 / v5 reading, own LZMA codec -- one dependency-free file.

SGApps.IO modules Apache-2.0

Infrastructure we wrote for the framework. The Wrapper is entirely ours; the Code Editor and <code-pretty> are our integration layer around CodeMirror, and ZIP is a small facade over JSZip -- credited as such.

Wrapper SGApps.IO module

gadgets/wrapper · 86 lines, no dependencies

Same-origin Blob-URL iframe sandbox written from scratch: node(), container(), document(), window(), whenLoaded(). The isolation host that keeps PDF.js, SVG-Edit and CodeMirror globals and CSS out of your page.

Code Editor SGApps.IO module

gadgets/code-editor · on CodeMirror 3.15 (MIT)

Our loader, lifecycle and API (value(), theme(), syntax(), height(), event:change) around the vendored CodeMirror: sandboxed in a Wrapper iframe, 31 addons booted in order, 70 syntax modes and 23 themes loaded lazily. The editing engine itself is CodeMirror, by Marijn Haverbeke.

<code-pretty> SGApps.IO module

custom-elements/code-pretty · on the Code Editor

A custom element that turns 14 plain attributes (language, theme, readonly, ...) into a syntax-highlighted block rendered by the Code Editor, with progressive enhancement and a dedent normaliser.

ZIP SGApps.IO module

archiver/zip · on JSZip 3.5 (MIT / GPL-3.0)

A 68-line ApplicationPrototype facade over the vendored JSZip: addFile(), folder(), getFile(), generate('blob'). For an archive engine written by us, use the Packer.

Third-party wrappers Upstream licences

Thin loaders -- typically a few dozen lines each, Apache-2.0 like the rest of our infrastructure code -- that fetch a vendored open-source library on first use and hand it back as a module. The libraries are not our work; each keeps its upstream licence (listed on the card and in the documentation).

Archive & charts modules/thirdparty/archive, modules/thirdparty/charts

JSZip Third-party

thirdparty/archive/jszip · JSZip 3.5 (MIT / GPL-3.0)

The raw JSZip 3.5 constructor, for code that wants the library rather than the archiver/zip facade.

LZ-String Third-party

thirdparty/archive/lz-string · lz-string 1.4 (WTFPL)

String compression to UTF-16, Base64 or URI-safe output for localStorage and URL parameters (lz-string 1.4).

amCharts 4 Third-party

thirdparty/charts/amcharts4 · amCharts 4.10 (free linkware licence)

Loads the vendored amCharts 4.10 core.js, charts.js and the animated theme, resolves with { am4core, am4charts, am4themes_animated }.

Image modules/thirdparty/convert/image

QR Generator Third-party

thirdparty/convert/image/qrcode/generator · qrcode-generator (MIT)

QR codes from text or URLs as <img>, SVG, table or data URL (qrcode-generator).

Barcode Generator Third-party

thirdparty/convert/image/barcode/generator · JsBarcode 3.12 (MIT)

1D barcodes -- CODE128, EAN / UPC, CODE39 / 93, ITF-14, MSI, Pharmacode, Codabar -- rendered into an <svg>, a <canvas> or an <img>, with input validation per symbology.

Barcode Reader Third-party

thirdparty/convert/image/barcode/reader · ZXing for JS 0.23 (Apache-2.0)

Multi-format reader: 1D (EAN, UPC, Code 39 / 93 / 128, ITF, Codabar, RSS) and 2D (QR, Data Matrix, PDF417, Aztec) from an image, a canvas, a video element or the camera; format hints, continuous scanning.

QR Reader Third-party

thirdparty/convert/image/qrcode/reader · jsQR 1.3 (Apache-2.0)

Decodes QR codes from images, canvases and camera frames (jsQR 1.3).

Tesseract OCR Third-party

thirdparty/convert/image/ocr/tesseract · Tesseract.js 3.0 (Apache-2.0)

Text recognition in the browser, 100+ languages, progress events (Tesseract.js 3.0).

EXIF Reader Third-party

thirdparty/convert/image/exif/reader · exif.js 2.3 (MIT)

Camera model, GPS and orientation metadata from JPEG / TIFF files (exif.js 2.3).

Jimp Third-party

thirdparty/convert/image/editor/jimp · Jimp 0.22 (MIT)

Resize, crop, rotate, filter and compose images entirely in memory (Jimp 0.22).

Potrace Third-party

thirdparty/convert/image/vectorize/potrace · potrace 2.1 (GPL-2.0)

Bitmap to vector: black-and-white tracing to SVG paths (potrace 2.1).

ImageTracer Third-party

thirdparty/convert/image/vectorize/imagetracer · imagetracerjs 1.2 (Unlicense)

Colour raster to SVG tracing with palette control (imagetracerjs 1.2).

SVG Path Commander Third-party

thirdparty/convert/image/vectorize/svg/path-commander · svg-path-commander 2.0 (MIT)

Parse, normalise, transform and optimise SVG path data strings (svg-path-commander 2.0).

Documents modules/thirdparty/convert/pdf, less, web

PDF Reader Third-party

thirdparty/convert/pdf/reader · PDF.js 2.7 (Apache-2.0)

Render pages to canvas and extract text from PDF documents inside a wrapper iframe (PDF.js 2.7).

LESS Compiler Third-party

thirdparty/convert/less/css/less · less 3.11 (Apache-2.0)

Compile LESS stylesheets to CSS in the browser (less 3.11).

html2canvas Third-party

thirdparty/convert/web/canvas/html2canvas · html2canvas 1.4 (MIT)

Screenshot DOM elements to a canvas for previews, exports and PDF generation (html2canvas 1.4).

Emulators modules/thirdparty/emulators

Xterm.js Third-party

thirdparty/emulators/terminal/xterm · xterm 2.2 (MIT)

Terminal emulator with the attach (WebSocket), fit, fullscreen, linkify and terminado addons loaded (xterm 2.2).

OpenCV.js Third-party

thirdparty/emulators/image/opencv · OpenCV (BSD-3-Clause; vendored through node-opencv, MIT)

Computer vision compiled to JavaScript (asm.js build): filters, contours, feature matching, object detection.

SQL.js Third-party

thirdparty/emulators/databases/sql.js · sql.js 1.8 (MIT)

A complete SQLite engine compiled to JavaScript (asm.js build): in-memory databases, prepared statements, export to a file (sql.js 1.8).

GUI modules/thirdparty/gui

dat.GUI Third-party

thirdparty/gui/controls/dat-gui · dat.gui 0.7 (Apache-2.0)

Lightweight parameter panels for demos, creative coding and prototypes (dat.gui 0.7).

Animate.css Third-party

thirdparty/gui/animations/animate-css · Animate.css 3.7 (MIT)

The Animate.css 3.7 stylesheet plus its animation catalogue for programmatic use.

SVG Editor Third-party

thirdparty/gui/image/svg/editor · SVG-Edit (MIT)

The SVG-Edit vector drawing application inside a wrapper iframe: svgSource(), zoom(), getSelectedElement().

CKEditor 4 Third-party

thirdparty/gui/wysiwyg/html/ckeditor4 · CKEditor 4.14 (GPL / LGPL / MPL)

The classic CKEditor 4.14 WYSIWYG editor, CKEDITOR.replace() ready.

CKEditor 5 Third-party

thirdparty/gui/wysiwyg/html/ckeditor5 · CKEditor 5 (GPL-2.0-or-later or commercial)

The five CKEditor 5 builds, one module each: /classic, /inline, /balloon, /balloon-block, /document.

Live examples

A selection of the playground pages, embedded in preview mode -- the three SGApps.IO products first, then the Code Editor and a few of the wrappers. They load the framework from the SGApps CDN (https://cdn.sgapps.io/components/application-prototype) and the modules and vendored libraries from ../modules and ../thirdparty -- serve the repository root (npm start) and every example runs on your checkout; on a docs-only site they fall back to the CDN copy of this repository. Each frame has an Edit in the playground button that opens the same page with its source in an editor.

Spreadsheet editors/spreadsheet

A workbook pre-filled with quarterly figures and SUM formulas per row and column: type in cells, use the toolbar for styles and number formats, insert a chart, and export from the toolbar. Docs · Open in the playground

Writer editors/writer

A feature showcase document in the paginated layout with the ruler shown: formatting, headings, lists, tables, images and code blocks; switch to the Inline layout, the Markdown or HTML source mode, and export to DOCX or PDF from the toolbar. Docs · Open in the playground

Packer archiver/packer

Create a ZIP from three in-memory files, list its entries and read them back, then run the format-detection demo on ZIP, TAR and GZIP headers. Docs · Open in the playground

Code Editor gadgets/code-editor

A CodeMirror editor pre-filled with HTML in the Monokai theme: read its value, and switch the syntax mode to JavaScript or CSS with new content. Docs · Open in the playground

amCharts 4 thirdparty/charts/amcharts4

The vendored amCharts 4: a column chart built from am4core / am4charts with the animated theme and tooltips. Docs · Open in the playground

QR Generator thirdparty/convert/image/qrcode/generator

Type a text or a URL and get the QR code rendered as inline SVG with createSvgTag(). Docs · Open in the playground

Barcode Reader thirdparty/convert/image/barcode/reader · Generator thirdparty/convert/image/barcode/generator

Two barcodes generated with JsBarcode (CODE128 and EAN-13), decoded back with ZXing at the click of a button; drop in a photo of your own or start the camera for live scanning. Docs · Open in the playground

Xterm.js thirdparty/emulators/terminal/xterm

An 80x20 terminal with a small local shell (help, date, echo, colors, clear) and ANSI colours rendered. Docs · Open in the playground

SQL.js thirdparty/emulators/databases/sql.js

An in-memory SQLite database created, filled and queried from a textarea; edit the SQL and run it again. Docs · Open in the playground

CKEditor 5 thirdparty/gui/wysiwyg/html/ckeditor5

The classic build of CKEditor 5 with a custom toolbar attached to an element through the module wrapper; read the HTML back with getData(). Docs · Open in the playground

Getting started

  1. Clone the repository next to your site and run npm install once: the postinstall step fetches the 20 vendored libraries into thirdparty/ from bower-config.json. The framework itself comes from your application-prototype checkout (or the SGApps CDN).
  2. Load ApplicationPrototype.js and ApplicationBuilder.js, register the framework modules, then the thirdparty modules through modules/lib.js.
  3. Require any module by name.
<script src="/application-prototype/ApplicationPrototype.js"></script>
<script src="/application-prototype/ApplicationBuilder.js"></script>
<script>
var App = new ApplicationBuilder({
    onready: function () {
        var App = this;
        App.modulePath('/application-prototype/constructors');
        App.debugEnabled(true);
        App.require(['extensions/prototype', 'lib'], function (libs) {
            libs.lib();                                            // framework modules by name
            App.require('/application-prototype-thirdparty/modules/lib.js').then(function (loader) {
                loader();                                          // the 34 thirdparty modules by name
                App.require('editors/spreadsheet').then(function (Spreadsheet) {
                    var sheet = Spreadsheet({ container: document.getElementById('mount'), rows: 100, cols: 26 });
                    sheet.whenLoaded().then(function () {
                        sheet.value('A1', 'Total');
                        sheet.value('B1', '=SUM(B2:B10)');
                    });
                });
            });
        });
    }
});
</script>

The Getting Started page explains every step, the two ways of resolving module names and how the wrappers load their libraries; each module page has a Use Cases section with copy-paste snippets.

npm start                     # this page + the docs at http://localhost:3000/ and /docs/
npm run docs-site-published   # serve docs/ alone, the layout of a published docs-only site
npm test                      # lint the documentation (links, sidebar, playground registry, this page)
npm run docs                  # regenerate the JSDoc API reference into documentation/
sgapps.io