Add implementation for VirtualTextSizer using opentype.js [#32]
This commit is contained in:
parent
c58b8f7a22
commit
2a7d9e76ed
|
@ -97,8 +97,9 @@ the root of `/web` as their entry-points.
|
|||
The testing library used here is [Jasmine](https://jasmine.github.io/).
|
||||
|
||||
All test files follow the naming convention of `<filename>_spec.mjs`
|
||||
(commandline and browser) or `_webspec.mjs` (browser-only). Linting
|
||||
automatically applies to all files with a `.js` or `.mjs` extension.
|
||||
(commandline and browser), `_webspec.mjs` (browser-only), or
|
||||
`_nodespec.mjs` (commandline-only). Linting automatically applies to
|
||||
all files with a `.js` or `.mjs` extension.
|
||||
|
||||
You can run just the browser tests by running `npm run web-test`.
|
||||
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,90 @@
|
|||
Handlee font, by Joe Prince
|
||||
Downloaded from Google Fonts
|
||||
https://fonts.google.com/specimen/Handlee
|
||||
|
||||
|
||||
SIL OPEN FONT LICENSE
|
||||
Version 1.1 - 26 February 2007
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting — in part or in whole — any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
@ -0,0 +1,12 @@
|
|||
AUTHORS
|
||||
|
||||
Current Contributors (sorted alphabetically):
|
||||
- Pravin Satpute <psatpute at redhat dot com>
|
||||
Project Owner (Current)
|
||||
Red Hat, Inc.
|
||||
|
||||
Previous Contributors
|
||||
|
||||
- Steve Matteson
|
||||
Original Designer
|
||||
Ascender, Inc.
|
|
@ -0,0 +1,14 @@
|
|||
* Thu Oct 04 2012 Pravin Satpute <psatpute AT redhat DOT com>
|
||||
- Resolved "Glyphs with multiple unicode encodings inhibit subsetting" #851790
|
||||
- Resolved #851791, #854601 and #851825
|
||||
- Following GASP table version as per Liberation old version. (Anti-aliasing disabled)
|
||||
- Added support for Serbian glyphs for wikipedia #657849
|
||||
- In Monospace fonts, isFixedPitch bit set via script for getting it recognized as Monospace in putty.exe
|
||||
|
||||
* Fri Jul 06 2012 Pravin Satpute <psatpute AT redhat DOT com>
|
||||
- Initial version of Liberation fonts based on croscore fonts version 1.21.0
|
||||
- Converted TTF files into SFD files to be open source.
|
||||
- Update Copyright and License file
|
||||
- set fsType bit to 0, Installable Embedding is allowed.
|
||||
- Absolute value in HHeadAscent/Descent values for maintaining Metric compatibility.
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
Digitized data copyright (c) 2010 Google Corporation
|
||||
with Reserved Font Arimo, Tinos and Cousine.
|
||||
Copyright (c) 2012 Red Hat, Inc.
|
||||
with Reserved Font Name Liberation.
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License,
|
||||
Version 1.1.
|
||||
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
|
||||
PREAMBLE The goals of the Open Font License (OFL) are to stimulate
|
||||
worldwide development of collaborative font projects, to support the font
|
||||
creation efforts of academic and linguistic communities, and to provide
|
||||
a free and open framework in which fonts may be shared and improved in
|
||||
partnership with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves.
|
||||
The fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply to
|
||||
any document created using the fonts or their derivatives.
|
||||
|
||||
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such.
|
||||
This may include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components
|
||||
as distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting ? in part or in whole ?
|
||||
any of the components of the Original Version, by changing formats or
|
||||
by porting the Font Software to a new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical writer
|
||||
or other person who contributed to the Font Software.
|
||||
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,in
|
||||
Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the
|
||||
corresponding Copyright Holder. This restriction only applies to the
|
||||
primary font name as presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole, must
|
||||
be distributed entirely under this license, and must not be distributed
|
||||
under any other license. The requirement for fonts to remain under
|
||||
this license does not apply to any document created using the Font
|
||||
Software.
|
||||
|
||||
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are not met.
|
||||
|
||||
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER
|
||||
DEALINGS IN THE FONT SOFTWARE.
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,80 @@
|
|||
1. What's this?
|
||||
=================
|
||||
|
||||
The Liberation Fonts is font collection which aims to provide document
|
||||
layout compatibility as usage of Times New Roman, Arial, Courier New.
|
||||
|
||||
|
||||
2. Requirements
|
||||
=================
|
||||
|
||||
* fontforge is installed.
|
||||
(http://fontforge.sourceforge.net)
|
||||
|
||||
|
||||
3. Install
|
||||
============
|
||||
|
||||
3.1 Decompress tarball
|
||||
|
||||
You can extract the files by following command:
|
||||
|
||||
$ tar zxvf liberation-fonts-[VERSION].tar.gz
|
||||
|
||||
3.2 Build from the source
|
||||
|
||||
Change into directory liberation-fonts-[VERSION]/ and build from sources by
|
||||
following commands:
|
||||
|
||||
$ cd liberation-fonts-[VERSION]
|
||||
$ make
|
||||
|
||||
The built font files will be available in 'build' directory.
|
||||
|
||||
3.3 Install to system
|
||||
|
||||
For Fedora, you could manually install the fonts by copying the TTFs to
|
||||
~/.fonts for user wide usage, or to /usr/share/fonts/truetype/liberation
|
||||
for system-wide availability. Then, run "fc-cache" to let that cached.
|
||||
|
||||
For other distributions, please check out corresponding documentation.
|
||||
|
||||
|
||||
4. Usage
|
||||
==========
|
||||
|
||||
Simply select preferred liberation font in applications and start using.
|
||||
|
||||
|
||||
5. License
|
||||
============
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License,
|
||||
Version 1.1.
|
||||
|
||||
Please read file "LICENSE" for details.
|
||||
|
||||
|
||||
6. For Maintainers
|
||||
====================
|
||||
|
||||
Before packaging a new release based on a new source tarball, you have to
|
||||
update the version suffix in the Makefile:
|
||||
|
||||
VER = [VERSION]
|
||||
|
||||
Make sure that the defined version corresponds to the font software metadata
|
||||
which you can check with ftinfo/otfinfo or fontforge itself. It is highly
|
||||
recommended that file 'ChangeLog' is updated to reflect changes.
|
||||
|
||||
Create a tarball with the following command:
|
||||
|
||||
$ make dist
|
||||
|
||||
The new versioned tarball will be available in the dist/ folder as
|
||||
'liberation-fonts-[NEW_VERSION].tar.gz'.
|
||||
|
||||
7. Credits
|
||||
============
|
||||
|
||||
Please read file "AUTHORS" for list of contributors.
|
|
@ -0,0 +1,5 @@
|
|||
Here are todo for next release
|
||||
1) Serbian glyph for wikipedia https://bugzilla.redhat.com/show_bug.cgi?id=657849
|
||||
- Improving shape of S_BE https://bugzilla.redhat.com/show_bug.cgi?id=657849#c96
|
||||
2) Liberation Mono not recognizing as Mono in Windows application #861003
|
||||
- presently it is patch, we have to update zero width characters to fixed width
|
|
@ -7005,8 +7005,7 @@
|
|||
const labelKey = JSON.stringify(line);
|
||||
const cache = attrCache.lines.get(labelKey);
|
||||
if(cache.width === null) {
|
||||
window.console.warn('Performing unexpected measurement', line);
|
||||
this.performMeasurements();
|
||||
throw new Error('Unexpected measurement of ' + line);
|
||||
}
|
||||
return cache.width;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -7005,8 +7005,7 @@
|
|||
const labelKey = JSON.stringify(line);
|
||||
const cache = attrCache.lines.get(labelKey);
|
||||
if(cache.width === null) {
|
||||
window.console.warn('Performing unexpected measurement', line);
|
||||
this.performMeasurements();
|
||||
throw new Error('Unexpected measurement of ' + line);
|
||||
}
|
||||
return cache.width;
|
||||
}
|
||||
|
@ -10225,28 +10224,127 @@
|
|||
}
|
||||
}
|
||||
|
||||
class VirtualTextSizer {
|
||||
// Simplified text sizer, which assumes all characters render as
|
||||
// 1x1 px squares for repeatable renders in all browsers
|
||||
const fs = require('fs');
|
||||
const opentype = require('opentype.js');
|
||||
|
||||
baseline() {
|
||||
return 1;
|
||||
const FONTS = new Map();
|
||||
|
||||
function loadFont(path) {
|
||||
// Must be synchronous so that measurements are ready once startup completes
|
||||
/* eslint-disable no-sync */
|
||||
const data = fs.readFileSync(path);
|
||||
/* eslint-enable no-sync */
|
||||
return opentype.parse(data.buffer);
|
||||
}
|
||||
|
||||
function addFont(name, variants) {
|
||||
const types = new Map();
|
||||
for(const v in variants) {
|
||||
if(Object.prototype.hasOwnProperty.call(variants, v)) {
|
||||
const font = loadFont(variants[v]);
|
||||
font.id = name + '-' + v;
|
||||
types.set(v, font);
|
||||
}
|
||||
}
|
||||
FONTS.set(name.toLowerCase(), types);
|
||||
}
|
||||
|
||||
addFont('sans-serif', {
|
||||
'': 'fonts/liberation-fonts/LiberationSans-Regular.ttf',
|
||||
'bold': 'fonts/liberation-fonts/LiberationSans-Bold.ttf',
|
||||
'bold-italic': 'fonts/liberation-fonts/LiberationSans-BoldItalic.ttf',
|
||||
'italic': 'fonts/liberation-fonts/LiberationSans-Italic.ttf',
|
||||
});
|
||||
addFont('monospace', {
|
||||
'': 'fonts/liberation-fonts/LiberationMono-Regular.ttf',
|
||||
'bold': 'fonts/liberation-fonts/LiberationMono-Bold.ttf',
|
||||
'bold-italic': 'fonts/liberation-fonts/LiberationMono-BoldItalic.ttf',
|
||||
'italic': 'fonts/liberation-fonts/LiberationMono-Italic.ttf',
|
||||
});
|
||||
addFont('handlee', {
|
||||
'': 'fonts/handlee/Handlee.ttf',
|
||||
});
|
||||
|
||||
const DEFAULT_FONT = 'sans-serif';
|
||||
|
||||
const OPENTYPE_OPTIONS = {hinting: true};
|
||||
|
||||
function getFont(attrs) {
|
||||
const family = (attrs['font-family'] || DEFAULT_FONT).split(',');
|
||||
for(const nm of family) {
|
||||
const name = nm.trim().replace(/['"]/g, '').toLowerCase();
|
||||
const font = FONTS.get(name);
|
||||
if(font) {
|
||||
return font;
|
||||
}
|
||||
}
|
||||
return FONTS.get(DEFAULT_FONT);
|
||||
}
|
||||
|
||||
function tryVariant(font, condition, name) {
|
||||
if(!condition) {
|
||||
return null;
|
||||
}
|
||||
return font.get(name) || null;
|
||||
}
|
||||
|
||||
function getVariantRaw(font, {bold, italic}) {
|
||||
return (
|
||||
tryVariant(font, bold && italic, 'bold-italic') ||
|
||||
tryVariant(font, bold, 'bold') ||
|
||||
tryVariant(font, italic, 'italic') ||
|
||||
font.get('')
|
||||
);
|
||||
}
|
||||
|
||||
function getVariant(font, attrs) {
|
||||
const weight = attrs['font-weight'] || '';
|
||||
const style = attrs['font-style'] || '';
|
||||
const bold = (weight.includes('bold') || Number(weight) > 400);
|
||||
const italic = style.includes('italic');
|
||||
|
||||
return getVariantRaw(font, {bold, italic});
|
||||
}
|
||||
|
||||
function getFontSize(attrs) {
|
||||
return Number(attrs['font-size']);
|
||||
}
|
||||
|
||||
function measure(attrs, text) {
|
||||
const font = getFont(attrs);
|
||||
const variant = getVariant(font, attrs);
|
||||
const size = getFontSize(attrs);
|
||||
return variant.getAdvanceWidth(text, size, OPENTYPE_OPTIONS);
|
||||
}
|
||||
|
||||
class VirtualTextSizer {
|
||||
baseline({attrs}) {
|
||||
return getFontSize(attrs);
|
||||
}
|
||||
|
||||
measureHeight({formatted}) {
|
||||
return formatted.length;
|
||||
measureHeight({attrs, formatted}) {
|
||||
const size = this.baseline({attrs, formatted});
|
||||
const lineHeight = size * (Number(attrs['line-height']) || 1);
|
||||
return formatted.length * lineHeight;
|
||||
}
|
||||
|
||||
prepMeasurement(attrs, formatted) {
|
||||
return formatted;
|
||||
return {attrs, formatted};
|
||||
}
|
||||
|
||||
prepComplete() {
|
||||
// No-op
|
||||
}
|
||||
|
||||
performMeasurement(data) {
|
||||
return data.reduce((total, part) => total + part.text.length, 0);
|
||||
performMeasurement({attrs, formatted}) {
|
||||
let len = 0;
|
||||
for(const part of formatted) {
|
||||
if(!part.text) {
|
||||
continue;
|
||||
}
|
||||
len += measure(Object.assign({}, attrs, part.attrs), part.text);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
teardown() {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1561,13 +1561,15 @@
|
|||
"dependencies": {
|
||||
"abbrev": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz",
|
||||
"integrity": "sha1-0FVMIlZjbi9W58LlrRg/hZQo2B8=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"ajv": {
|
||||
"version": "4.11.8",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz",
|
||||
"integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=",
|
||||
"requires": {
|
||||
"co": "4.6.0",
|
||||
"json-stable-stringify": "1.0.1"
|
||||
|
@ -1575,18 +1577,21 @@
|
|||
},
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
|
||||
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=",
|
||||
"dev": true
|
||||
},
|
||||
"aproba": {
|
||||
"version": "1.1.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/aproba/-/aproba-1.1.1.tgz",
|
||||
"integrity": "sha1-ldNgDwdxCqDpKYxyatXs8urLq6s=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"are-we-there-yet": {
|
||||
"version": "1.1.4",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz",
|
||||
"integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
|
@ -1596,31 +1601,38 @@
|
|||
},
|
||||
"asn1": {
|
||||
"version": "0.2.3",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz",
|
||||
"integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y="
|
||||
},
|
||||
"assert-plus": {
|
||||
"version": "0.2.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz",
|
||||
"integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ="
|
||||
},
|
||||
"asynckit": {
|
||||
"version": "0.4.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
|
||||
},
|
||||
"aws-sign2": {
|
||||
"version": "0.6.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz",
|
||||
"integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8="
|
||||
},
|
||||
"aws4": {
|
||||
"version": "1.6.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz",
|
||||
"integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4="
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "0.4.2",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz",
|
||||
"integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg="
|
||||
},
|
||||
"bcrypt-pbkdf": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz",
|
||||
"integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"tweetnacl": "0.14.5"
|
||||
|
@ -1628,21 +1640,24 @@
|
|||
},
|
||||
"block-stream": {
|
||||
"version": "0.0.9",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz",
|
||||
"integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=",
|
||||
"requires": {
|
||||
"inherits": "2.0.3"
|
||||
}
|
||||
},
|
||||
"boom": {
|
||||
"version": "2.10.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz",
|
||||
"integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=",
|
||||
"requires": {
|
||||
"hoek": "2.16.3"
|
||||
}
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.7",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.7.tgz",
|
||||
"integrity": "sha1-Pv/DxQ4ABTH7cg6v+A8K6O8jz1k=",
|
||||
"requires": {
|
||||
"balanced-match": "0.4.2",
|
||||
"concat-map": "0.0.1"
|
||||
|
@ -1650,93 +1665,110 @@
|
|||
},
|
||||
"buffer-shims": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz",
|
||||
"integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E="
|
||||
},
|
||||
"caseless": {
|
||||
"version": "0.12.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
|
||||
"integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw="
|
||||
},
|
||||
"co": {
|
||||
"version": "4.6.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
|
||||
"integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ="
|
||||
},
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
|
||||
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
|
||||
"dev": true
|
||||
},
|
||||
"combined-stream": {
|
||||
"version": "1.0.5",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz",
|
||||
"integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=",
|
||||
"requires": {
|
||||
"delayed-stream": "1.0.0"
|
||||
}
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
|
||||
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
|
||||
"dev": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
||||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
|
||||
},
|
||||
"cryptiles": {
|
||||
"version": "2.0.5",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz",
|
||||
"integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=",
|
||||
"requires": {
|
||||
"boom": "2.10.1"
|
||||
}
|
||||
},
|
||||
"dashdash": {
|
||||
"version": "1.14.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
|
||||
"integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
|
||||
"requires": {
|
||||
"assert-plus": "1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"assert-plus": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
|
||||
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
|
||||
}
|
||||
}
|
||||
},
|
||||
"debug": {
|
||||
"version": "2.6.8",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz",
|
||||
"integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=",
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"deep-extend": {
|
||||
"version": "0.4.2",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz",
|
||||
"integrity": "sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
|
||||
},
|
||||
"delegates": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz",
|
||||
"integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"detect-libc": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.2.tgz",
|
||||
"integrity": "sha1-ca1dIEvxempsqPRQxhRUBm70YeE=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"ecc-jsbn": {
|
||||
"version": "0.1.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz",
|
||||
"integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"jsbn": "0.1.1"
|
||||
|
@ -1744,19 +1776,23 @@
|
|||
},
|
||||
"extend": {
|
||||
"version": "3.0.1",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz",
|
||||
"integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ="
|
||||
},
|
||||
"extsprintf": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz",
|
||||
"integrity": "sha1-4QgOBljjALBilJkMxw4VAiNf1VA="
|
||||
},
|
||||
"forever-agent": {
|
||||
"version": "0.6.1",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
|
||||
"integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE="
|
||||
},
|
||||
"form-data": {
|
||||
"version": "2.1.4",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz",
|
||||
"integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=",
|
||||
"requires": {
|
||||
"asynckit": "0.4.0",
|
||||
"combined-stream": "1.0.5",
|
||||
|
@ -1765,11 +1801,13 @@
|
|||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||
},
|
||||
"fstream": {
|
||||
"version": "1.0.11",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz",
|
||||
"integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=",
|
||||
"requires": {
|
||||
"graceful-fs": "4.1.11",
|
||||
"inherits": "2.0.3",
|
||||
|
@ -1779,7 +1817,8 @@
|
|||
},
|
||||
"fstream-ignore": {
|
||||
"version": "1.0.5",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/fstream-ignore/-/fstream-ignore-1.0.5.tgz",
|
||||
"integrity": "sha1-nDHa40dnAY/h0kmyTa2mfQktoQU=",
|
||||
"requires": {
|
||||
"fstream": "1.0.11",
|
||||
"inherits": "2.0.3",
|
||||
|
@ -1788,7 +1827,8 @@
|
|||
},
|
||||
"gauge": {
|
||||
"version": "2.7.4",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz",
|
||||
"integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
|
@ -1804,20 +1844,23 @@
|
|||
},
|
||||
"getpass": {
|
||||
"version": "0.1.7",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
|
||||
"integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
|
||||
"requires": {
|
||||
"assert-plus": "1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"assert-plus": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
|
||||
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
|
||||
}
|
||||
}
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.2",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
|
||||
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
|
||||
"requires": {
|
||||
"fs.realpath": "1.0.0",
|
||||
"inflight": "1.0.6",
|
||||
|
@ -1829,15 +1872,18 @@
|
|||
},
|
||||
"graceful-fs": {
|
||||
"version": "4.1.11",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
|
||||
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg="
|
||||
},
|
||||
"har-schema": {
|
||||
"version": "1.0.5",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz",
|
||||
"integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4="
|
||||
},
|
||||
"har-validator": {
|
||||
"version": "4.2.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz",
|
||||
"integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=",
|
||||
"requires": {
|
||||
"ajv": "4.11.8",
|
||||
"har-schema": "1.0.5"
|
||||
|
@ -1845,13 +1891,15 @@
|
|||
},
|
||||
"has-unicode": {
|
||||
"version": "2.0.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz",
|
||||
"integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"hawk": {
|
||||
"version": "3.1.3",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz",
|
||||
"integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=",
|
||||
"requires": {
|
||||
"boom": "2.10.1",
|
||||
"cryptiles": "2.0.5",
|
||||
|
@ -1861,11 +1909,13 @@
|
|||
},
|
||||
"hoek": {
|
||||
"version": "2.16.3",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz",
|
||||
"integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0="
|
||||
},
|
||||
"http-signature": {
|
||||
"version": "1.1.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz",
|
||||
"integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=",
|
||||
"requires": {
|
||||
"assert-plus": "0.2.0",
|
||||
"jsprim": "1.4.0",
|
||||
|
@ -1874,7 +1924,8 @@
|
|||
},
|
||||
"inflight": {
|
||||
"version": "1.0.6",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
||||
"requires": {
|
||||
"once": "1.4.0",
|
||||
"wrappy": "1.0.2"
|
||||
|
@ -1882,17 +1933,20 @@
|
|||
},
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.4",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz",
|
||||
"integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"is-fullwidth-code-point": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
|
||||
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"number-is-nan": "1.0.1"
|
||||
|
@ -1900,19 +1954,23 @@
|
|||
},
|
||||
"is-typedarray": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
|
||||
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo="
|
||||
},
|
||||
"isarray": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
||||
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
|
||||
},
|
||||
"isstream": {
|
||||
"version": "0.1.2",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
|
||||
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
|
||||
},
|
||||
"jodid25519": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/jodid25519/-/jodid25519-1.0.2.tgz",
|
||||
"integrity": "sha1-BtSRIlUJNBlHfUJWM2BuDpB4KWc=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"jsbn": "0.1.1"
|
||||
|
@ -1920,31 +1978,37 @@
|
|||
},
|
||||
"jsbn": {
|
||||
"version": "0.1.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
|
||||
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
|
||||
"optional": true
|
||||
},
|
||||
"json-schema": {
|
||||
"version": "0.2.3",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz",
|
||||
"integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM="
|
||||
},
|
||||
"json-stable-stringify": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz",
|
||||
"integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=",
|
||||
"requires": {
|
||||
"jsonify": "0.0.0"
|
||||
}
|
||||
},
|
||||
"json-stringify-safe": {
|
||||
"version": "5.0.1",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
|
||||
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
|
||||
},
|
||||
"jsonify": {
|
||||
"version": "0.0.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
|
||||
"integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM="
|
||||
},
|
||||
"jsprim": {
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz",
|
||||
"integrity": "sha1-o7h+QCmNjDgFUtjMdiigu5WiKRg=",
|
||||
"requires": {
|
||||
"assert-plus": "1.0.0",
|
||||
"extsprintf": "1.0.2",
|
||||
|
@ -1954,42 +2018,49 @@
|
|||
"dependencies": {
|
||||
"assert-plus": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
|
||||
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
|
||||
}
|
||||
}
|
||||
},
|
||||
"mime-db": {
|
||||
"version": "1.27.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz",
|
||||
"integrity": "sha1-gg9XIpa70g7CXtVeW13oaeVDbrE="
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.15",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz",
|
||||
"integrity": "sha1-pOv1BkCUVpI3uM9wBGd20J/JKu0=",
|
||||
"requires": {
|
||||
"mime-db": "1.27.0"
|
||||
}
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"requires": {
|
||||
"brace-expansion": "1.1.7"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||
},
|
||||
"node-pre-gyp": {
|
||||
"version": "0.9.1",
|
||||
|
@ -2037,7 +2108,8 @@
|
|||
},
|
||||
"nopt": {
|
||||
"version": "4.0.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz",
|
||||
"integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
|
@ -2047,7 +2119,8 @@
|
|||
},
|
||||
"npmlog": {
|
||||
"version": "4.1.0",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.0.tgz",
|
||||
"integrity": "sha512-ocolIkZYZt8UveuiDS0yAkkIjid1o7lPG8cYm05yNYzBn8ykQtaiPMEGp8fY9tKdDgm8okpdKzkvu1y9hUYugA==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
|
@ -2059,41 +2132,48 @@
|
|||
},
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
|
||||
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
|
||||
"dev": true
|
||||
},
|
||||
"oauth-sign": {
|
||||
"version": "0.8.2",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz",
|
||||
"integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM="
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"requires": {
|
||||
"wrappy": "1.0.2"
|
||||
}
|
||||
},
|
||||
"os-homedir": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
|
||||
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"os-tmpdir": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
|
||||
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"osenv": {
|
||||
"version": "0.1.4",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.4.tgz",
|
||||
"integrity": "sha1-Qv5tWVPfBsgGS+bxdsPQWqqjRkQ=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
|
@ -2103,27 +2183,33 @@
|
|||
},
|
||||
"path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
|
||||
},
|
||||
"performance-now": {
|
||||
"version": "0.2.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz",
|
||||
"integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU="
|
||||
},
|
||||
"process-nextick-args": {
|
||||
"version": "1.0.7",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
|
||||
"integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M="
|
||||
},
|
||||
"punycode": {
|
||||
"version": "1.4.1",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
|
||||
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4="
|
||||
},
|
||||
"qs": {
|
||||
"version": "6.4.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz",
|
||||
"integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM="
|
||||
},
|
||||
"rc": {
|
||||
"version": "1.2.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/rc/-/rc-1.2.1.tgz",
|
||||
"integrity": "sha1-LgPo5C7kULjLPc5lvhv4l04d/ZU=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
|
@ -2135,7 +2221,8 @@
|
|||
"dependencies": {
|
||||
"minimist": {
|
||||
"version": "1.2.0",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
}
|
||||
|
@ -2143,7 +2230,8 @@
|
|||
},
|
||||
"readable-stream": {
|
||||
"version": "2.2.9",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.9.tgz",
|
||||
"integrity": "sha1-z3jsb0ptHrQ9JkiMrJfwQudLf8g=",
|
||||
"requires": {
|
||||
"buffer-shims": "1.0.0",
|
||||
"core-util-is": "1.0.2",
|
||||
|
@ -2156,7 +2244,8 @@
|
|||
},
|
||||
"request": {
|
||||
"version": "2.81.0",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz",
|
||||
"integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=",
|
||||
"requires": {
|
||||
"aws-sign2": "0.6.0",
|
||||
"aws4": "1.6.0",
|
||||
|
@ -2184,43 +2273,50 @@
|
|||
},
|
||||
"rimraf": {
|
||||
"version": "2.6.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz",
|
||||
"integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=",
|
||||
"requires": {
|
||||
"glob": "7.1.2"
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.0.1",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz",
|
||||
"integrity": "sha1-0mPKVGls2KMGtcplUekt5XkY++c="
|
||||
},
|
||||
"semver": {
|
||||
"version": "5.3.0",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz",
|
||||
"integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"set-blocking": {
|
||||
"version": "2.0.0",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",
|
||||
"integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"signal-exit": {
|
||||
"version": "3.0.2",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
|
||||
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"sntp": {
|
||||
"version": "1.0.9",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz",
|
||||
"integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=",
|
||||
"requires": {
|
||||
"hoek": "2.16.3"
|
||||
}
|
||||
},
|
||||
"sshpk": {
|
||||
"version": "1.13.0",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.0.tgz",
|
||||
"integrity": "sha1-/yo+T9BEl1Vf7Zezmg/YL6+zozw=",
|
||||
"requires": {
|
||||
"asn1": "0.2.3",
|
||||
"assert-plus": "1.0.0",
|
||||
|
@ -2235,13 +2331,15 @@
|
|||
"dependencies": {
|
||||
"assert-plus": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
|
||||
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
|
||||
}
|
||||
}
|
||||
},
|
||||
"string-width": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
|
||||
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"code-point-at": "1.1.0",
|
||||
|
@ -2251,18 +2349,21 @@
|
|||
},
|
||||
"string_decoder": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.1.tgz",
|
||||
"integrity": "sha1-YuIA8DmVWmgQ2N8KM//A8BNmLZg=",
|
||||
"requires": {
|
||||
"safe-buffer": "5.0.1"
|
||||
}
|
||||
},
|
||||
"stringstream": {
|
||||
"version": "0.0.5",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz",
|
||||
"integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg="
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "3.0.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
|
||||
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "2.1.1"
|
||||
|
@ -2270,13 +2371,15 @@
|
|||
},
|
||||
"strip-json-comments": {
|
||||
"version": "2.0.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
|
||||
"integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"tar": {
|
||||
"version": "2.2.1",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz",
|
||||
"integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=",
|
||||
"requires": {
|
||||
"block-stream": "0.0.9",
|
||||
"fstream": "1.0.11",
|
||||
|
@ -2285,7 +2388,8 @@
|
|||
},
|
||||
"tar-pack": {
|
||||
"version": "3.4.0",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/tar-pack/-/tar-pack-3.4.0.tgz",
|
||||
"integrity": "sha1-I74tf2cagzk3bL2wuP4/3r8xeYQ=",
|
||||
"requires": {
|
||||
"debug": "2.6.8",
|
||||
"fstream": "1.0.11",
|
||||
|
@ -2299,45 +2403,53 @@
|
|||
},
|
||||
"tough-cookie": {
|
||||
"version": "2.3.2",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz",
|
||||
"integrity": "sha1-8IH3bkyFcg5sN6X6ztc3FQ2EByo=",
|
||||
"requires": {
|
||||
"punycode": "1.4.1"
|
||||
}
|
||||
},
|
||||
"tunnel-agent": {
|
||||
"version": "0.6.0",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
||||
"integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
|
||||
"requires": {
|
||||
"safe-buffer": "5.0.1"
|
||||
}
|
||||
},
|
||||
"tweetnacl": {
|
||||
"version": "0.14.5",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
|
||||
"integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=",
|
||||
"optional": true
|
||||
},
|
||||
"uid-number": {
|
||||
"version": "0.0.6",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz",
|
||||
"integrity": "sha1-DqEOgDXo61uOREnwbaHHMGY7qoE="
|
||||
},
|
||||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.0.1",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.0.1.tgz",
|
||||
"integrity": "sha1-ZUS7ot/ajBzxfmKaOjBeK7H+5sE="
|
||||
},
|
||||
"verror": {
|
||||
"version": "1.3.6",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz",
|
||||
"integrity": "sha1-z/XfEpRtKX0rqu+qJoniW+AcAFw=",
|
||||
"requires": {
|
||||
"extsprintf": "1.0.2"
|
||||
}
|
||||
},
|
||||
"wide-align": {
|
||||
"version": "1.1.2",
|
||||
"bundled": true,
|
||||
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz",
|
||||
"integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
|
@ -2346,7 +2458,8 @@
|
|||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
},
|
||||
"yallist": {
|
||||
"version": "3.0.2",
|
||||
|
@ -3952,6 +4065,14 @@
|
|||
"integrity": "sha1-XG2ixdflgx6P+jlklQ+NZnSskLg=",
|
||||
"dev": true
|
||||
},
|
||||
"opentype.js": {
|
||||
"version": "0.8.0",
|
||||
"resolved": "https://registry.npmjs.org/opentype.js/-/opentype.js-0.8.0.tgz",
|
||||
"integrity": "sha1-rKvPoWQvvolKPk11nkO6aU4CvTU=",
|
||||
"requires": {
|
||||
"tiny-inflate": "1.0.2"
|
||||
}
|
||||
},
|
||||
"optimist": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz",
|
||||
|
@ -5015,6 +5136,11 @@
|
|||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"tiny-inflate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/tiny-inflate/-/tiny-inflate-1.0.2.tgz",
|
||||
"integrity": "sha1-k9nez/yIBb1X6uQxDwt0Xptvs6c="
|
||||
},
|
||||
"tmp": {
|
||||
"version": "0.0.33",
|
||||
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
|
||||
|
|
12
package.json
12
package.json
|
@ -12,10 +12,11 @@
|
|||
},
|
||||
"license": "LGPL-3.0",
|
||||
"files": [
|
||||
"lib/sequence-diagram-web.js",
|
||||
"bin",
|
||||
"fonts",
|
||||
"lib/sequence-diagram.js",
|
||||
"scripts",
|
||||
"bin"
|
||||
"lib/sequence-diagram-web.js",
|
||||
"scripts"
|
||||
],
|
||||
"main": "lib/sequence-diagram",
|
||||
"module": "scripts/standalone",
|
||||
|
@ -24,7 +25,7 @@
|
|||
},
|
||||
"scripts": {
|
||||
"lint": "eslint . --config spec/support/eslintrc.js --ignore-path spec/support/eslintignore --ext .js --ext .mjs",
|
||||
"minify-lib": "rollup --config scripts/rollup.config.js && uglifyjs --compress --mangle --warn --output lib/sequence-diagram-web.min.js -- lib/sequence-diagram-web.js && uglifyjs --compress --mangle --warn --output lib/sequence-diagram.min.js -- lib/sequence-diagram.js",
|
||||
"minify-lib": "rollup --config scripts/rollup.config.js && uglifyjs --compress --mangle --warn --output lib/sequence-diagram-web.min.js -- lib/sequence-diagram-web.js",
|
||||
"minify-web": "rollup --config web/rollup.config.js && uglifyjs --compress --mangle --warn --output weblib/editor.min.js -- weblib/editor.js",
|
||||
"minify": "npm run minify-lib && npm run minify-web",
|
||||
"prepublishOnly": "npm run minify-lib",
|
||||
|
@ -51,5 +52,8 @@
|
|||
"rollup-plugin-multi-entry": "^2.0.2",
|
||||
"source-map-support": "^0.5.4",
|
||||
"uglify-es": "^3.1.10"
|
||||
},
|
||||
"dependencies": {
|
||||
"opentype.js": "^0.8.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,27 +4,24 @@ import Generator from './generator/Generator.mjs';
|
|||
import Parser from './parser/Parser.mjs';
|
||||
import Renderer from './renderer/Renderer.mjs';
|
||||
import SequenceDiagram from './SequenceDiagram.mjs';
|
||||
import {nodejs} from '../core/browser.mjs';
|
||||
|
||||
function getSimplifiedContent(d) {
|
||||
return (d.dom().outerHTML
|
||||
.replace(/<g><\/g>/g, '')
|
||||
.replace(/<defs><\/defs>/g, '')
|
||||
.replace(' xmlns="http://www.w3.org/2000/svg" version="1.1"', '')
|
||||
);
|
||||
}
|
||||
|
||||
function makeDiagram(code) {
|
||||
return new SequenceDiagram(code, {
|
||||
document: new VirtualDocument(),
|
||||
namespace: '',
|
||||
textSizerFactory,
|
||||
});
|
||||
}
|
||||
|
||||
describe('SequenceDiagram', () => {
|
||||
function getSimplifiedContent(d) {
|
||||
return (d.dom().outerHTML
|
||||
.replace(/<g><\/g>/g, '')
|
||||
.replace(/<defs><\/defs>/g, '')
|
||||
.replace(' xmlns="http://www.w3.org/2000/svg" version="1.1"', '')
|
||||
);
|
||||
}
|
||||
|
||||
let diagram = null;
|
||||
|
||||
beforeEach(() => {
|
||||
diagram = new SequenceDiagram({
|
||||
document: new VirtualDocument(),
|
||||
namespace: '',
|
||||
textSizerFactory,
|
||||
});
|
||||
});
|
||||
|
||||
it('contains references to core objects', () => {
|
||||
expect(SequenceDiagram.Parser).toBe(Parser);
|
||||
expect(SequenceDiagram.Generator).toBe(Generator);
|
||||
|
@ -37,7 +34,7 @@ describe('SequenceDiagram', () => {
|
|||
});
|
||||
|
||||
it('renders empty diagrams without error', () => {
|
||||
diagram.set('');
|
||||
const diagram = makeDiagram('');
|
||||
|
||||
expect(getSimplifiedContent(diagram)).toEqual(
|
||||
'<svg viewBox="-5 -5 10 10">' +
|
||||
|
@ -60,7 +57,7 @@ describe('SequenceDiagram', () => {
|
|||
});
|
||||
|
||||
it('renders simple metadata', () => {
|
||||
diagram.set('title My title here');
|
||||
const diagram = makeDiagram('title My title here');
|
||||
|
||||
expect(getSimplifiedContent(diagram)).toEqual(
|
||||
'<svg viewBox="-11.5 -16 23 21">' +
|
||||
|
@ -92,8 +89,15 @@ describe('SequenceDiagram', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('re-renders when changed', () => {
|
||||
const diagram = makeDiagram('title My title here');
|
||||
diagram.set('title Another title');
|
||||
|
||||
expect(getSimplifiedContent(diagram)).toContain('Another title');
|
||||
});
|
||||
|
||||
it('renders simple components', () => {
|
||||
diagram.set('A -> B');
|
||||
const diagram = makeDiagram('A -> B');
|
||||
|
||||
const content = getSimplifiedContent(diagram);
|
||||
|
||||
|
@ -142,7 +146,7 @@ describe('SequenceDiagram', () => {
|
|||
});
|
||||
|
||||
it('renders collapsed blocks', () => {
|
||||
diagram.set('if\nA -> B\nend');
|
||||
const diagram = makeDiagram('if\nA -> B\nend');
|
||||
diagram.setCollapsed(0, true);
|
||||
|
||||
const content = getSimplifiedContent(diagram);
|
||||
|
@ -167,54 +171,4 @@ describe('SequenceDiagram', () => {
|
|||
|
||||
expect(content).toContain('<g class="region collapsed"');
|
||||
});
|
||||
|
||||
it('measures OS fonts correctly on the first render', (done) => {
|
||||
if(nodejs) {
|
||||
pending('NodeJS font rendering not implemented yet');
|
||||
return;
|
||||
}
|
||||
|
||||
const code = 'title message';
|
||||
const sd = new SequenceDiagram(code);
|
||||
const widthImmediate = sd.getSize().width;
|
||||
|
||||
expect(widthImmediate).toBeGreaterThan(40);
|
||||
|
||||
sd.set(code);
|
||||
|
||||
expect(sd.getSize().width).toEqual(widthImmediate);
|
||||
|
||||
setTimeout(() => {
|
||||
sd.set(code);
|
||||
|
||||
expect(sd.getSize().width).toEqual(widthImmediate);
|
||||
|
||||
done();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
it('measures embedded fonts correctly on the first render', (done) => {
|
||||
if(nodejs) {
|
||||
pending('NodeJS font rendering not implemented yet');
|
||||
return;
|
||||
}
|
||||
|
||||
const code = 'theme sketch\ntitle message';
|
||||
const sd = new SequenceDiagram(code);
|
||||
const widthImmediate = sd.getSize().width;
|
||||
|
||||
expect(widthImmediate).toBeGreaterThan(40);
|
||||
|
||||
sd.set(code);
|
||||
|
||||
expect(sd.getSize().width).toEqual(widthImmediate);
|
||||
|
||||
setTimeout(() => {
|
||||
sd.set(code);
|
||||
|
||||
expect(sd.getSize().width).toEqual(widthImmediate);
|
||||
|
||||
done();
|
||||
}, 500);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
import SequenceDiagram from './SequenceDiagram.mjs';
|
||||
|
||||
describe('Browser-backed SequenceDiagram', () => {
|
||||
it('measures OS fonts correctly on the first render', (done) => {
|
||||
const code = 'title message';
|
||||
const sd = new SequenceDiagram(code);
|
||||
const widthImmediate = sd.getSize().width;
|
||||
|
||||
expect(widthImmediate).toBeGreaterThan(40);
|
||||
|
||||
sd.set(code);
|
||||
|
||||
expect(sd.getSize().width).toEqual(widthImmediate);
|
||||
|
||||
setTimeout(() => {
|
||||
sd.set(code);
|
||||
|
||||
expect(sd.getSize().width).toEqual(widthImmediate);
|
||||
|
||||
done();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
it('measures embedded fonts correctly on the first render', (done) => {
|
||||
const code = 'theme sketch\ntitle message';
|
||||
const sd = new SequenceDiagram(code);
|
||||
const widthImmediate = sd.getSize().width;
|
||||
|
||||
expect(widthImmediate).toBeGreaterThan(40);
|
||||
|
||||
sd.set(code);
|
||||
|
||||
expect(sd.getSize().width).toEqual(widthImmediate);
|
||||
|
||||
setTimeout(() => {
|
||||
sd.set(code);
|
||||
|
||||
expect(sd.getSize().width).toEqual(widthImmediate);
|
||||
|
||||
done();
|
||||
}, 500);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,97 @@
|
|||
import Exporter from './exporter/Exporter.mjs';
|
||||
import Generator from './generator/Generator.mjs';
|
||||
import Parser from './parser/Parser.mjs';
|
||||
import Renderer from './renderer/Renderer.mjs';
|
||||
import VirtualSequenceDiagram from './VirtualSequenceDiagram.mjs';
|
||||
|
||||
function getSimplifiedContent(d) {
|
||||
return (d.dom().outerHTML
|
||||
.replace(/<g><\/g>/g, '')
|
||||
.replace(/<defs><\/defs>/g, '')
|
||||
.replace(' xmlns="http://www.w3.org/2000/svg" version="1.1"', '')
|
||||
);
|
||||
}
|
||||
|
||||
describe('VirtualSequenceDiagram', () => {
|
||||
it('contains references to core objects', () => {
|
||||
expect(VirtualSequenceDiagram.Parser).toBe(Parser);
|
||||
expect(VirtualSequenceDiagram.Generator).toBe(Generator);
|
||||
expect(VirtualSequenceDiagram.Renderer).toBe(Renderer);
|
||||
expect(VirtualSequenceDiagram.Exporter).toBe(Exporter);
|
||||
});
|
||||
|
||||
it('provides default themes', () => {
|
||||
expect(VirtualSequenceDiagram.themes.length).toBeGreaterThan(1);
|
||||
});
|
||||
|
||||
it('renders empty diagrams without error', () => {
|
||||
const diagram = new VirtualSequenceDiagram();
|
||||
diagram.set('');
|
||||
|
||||
expect(getSimplifiedContent(diagram)).toEqual(
|
||||
'<svg viewBox="-5 -5 10 10">' +
|
||||
'<metadata></metadata>' +
|
||||
'<defs>' +
|
||||
'<mask id="FullMask" maskUnits="userSpaceOnUse">' +
|
||||
'<rect fill="#FFFFFF" height="10" width="10" x="-5" y="-5">' +
|
||||
'</rect>' +
|
||||
'</mask>' +
|
||||
'<mask id="LineMask" maskUnits="userSpaceOnUse">' +
|
||||
'<rect fill="#FFFFFF" height="10" width="10" x="-5" y="-5">' +
|
||||
'</rect>' +
|
||||
'</mask>' +
|
||||
'</defs>' +
|
||||
'<g mask="url(#FullMask)">' +
|
||||
'<g mask="url(#LineMask)"></g>' +
|
||||
'</g>' +
|
||||
'</svg>'
|
||||
);
|
||||
});
|
||||
|
||||
it('re-renders when changed', () => {
|
||||
const diagram = new VirtualSequenceDiagram('title My title here');
|
||||
diagram.set('title Another title');
|
||||
|
||||
expect(getSimplifiedContent(diagram)).toContain('Another title');
|
||||
});
|
||||
|
||||
it('measures OS fonts correctly on the first render', (done) => {
|
||||
const code = 'title message';
|
||||
const sd = new VirtualSequenceDiagram(code);
|
||||
const widthImmediate = sd.getSize().width;
|
||||
|
||||
expect(widthImmediate).toBeNear(91.2, 1e-1);
|
||||
|
||||
sd.set(code);
|
||||
|
||||
expect(sd.getSize().width).toEqual(widthImmediate);
|
||||
|
||||
setTimeout(() => {
|
||||
sd.set(code);
|
||||
|
||||
expect(sd.getSize().width).toEqual(widthImmediate);
|
||||
|
||||
done();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
it('measures embedded fonts correctly on the first render', (done) => {
|
||||
const code = 'theme sketch\ntitle message';
|
||||
const sd = new VirtualSequenceDiagram(code);
|
||||
const widthImmediate = sd.getSize().width;
|
||||
|
||||
expect(widthImmediate).toBeNear(78.0, 1e-1);
|
||||
|
||||
sd.set(code);
|
||||
|
||||
expect(sd.getSize().width).toEqual(widthImmediate);
|
||||
|
||||
setTimeout(() => {
|
||||
sd.set(code);
|
||||
|
||||
expect(sd.getSize().width).toEqual(widthImmediate);
|
||||
|
||||
done();
|
||||
}, 500);
|
||||
});
|
||||
});
|
|
@ -72,8 +72,7 @@ class TextSizerWrapper {
|
|||
const labelKey = JSON.stringify(line);
|
||||
const cache = attrCache.lines.get(labelKey);
|
||||
if(cache.width === null) {
|
||||
window.console.warn('Performing unexpected measurement', line);
|
||||
this.performMeasurements();
|
||||
throw new Error('Unexpected measurement of ' + line);
|
||||
}
|
||||
return cache.width;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import {DOMWrapper, dom, textSizerFactory} from '../../spec/stubs/TestDOM.mjs';
|
||||
import {SVGTextBlock, TextSizer} from './SVGTextBlock.mjs';
|
||||
import {dom, textSizerFactory} from '../../spec/stubs/TestDOM.mjs';
|
||||
import SVG from './SVG.mjs';
|
||||
import {nodejs} from '../core/browser.mjs';
|
||||
import {SVGTextBlock} from './SVGTextBlock.mjs';
|
||||
|
||||
describe('SVGTextBlock', () => {
|
||||
const attrs = {'font-size': 10, 'line-height': 1.5};
|
||||
|
@ -127,105 +126,4 @@ describe('SVGTextBlock', () => {
|
|||
expect(block.lines.length).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('TextSizer', () => {
|
||||
if(nodejs) {
|
||||
// TextSizer is for browsers only
|
||||
return;
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
svg = new SVG(
|
||||
new DOMWrapper(window.document),
|
||||
(svgBase) => new TextSizer(svgBase)
|
||||
);
|
||||
document.body.appendChild(svg.body.element);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(svg.body.element);
|
||||
});
|
||||
|
||||
describe('.measure', () => {
|
||||
it('calculates the size of the formatted text', () => {
|
||||
const size = svg.textSizer.measure(attrs, [[{text: 'foo'}]]);
|
||||
|
||||
expect(size.width).toBeGreaterThan(0);
|
||||
expect(size.height).toEqual(15);
|
||||
});
|
||||
|
||||
it('calculates the size of text blocks', () => {
|
||||
block.set({formatted: [[{text: 'foo'}]]});
|
||||
const size = svg.textSizer.measure(block);
|
||||
|
||||
expect(size.width).toBeGreaterThan(0);
|
||||
expect(size.height).toEqual(15);
|
||||
});
|
||||
|
||||
it('measures multiline text', () => {
|
||||
const size = svg.textSizer.measure(attrs, [
|
||||
[{text: 'foo'}],
|
||||
[{text: 'bar'}],
|
||||
]);
|
||||
|
||||
expect(size.width).toBeGreaterThan(0);
|
||||
expect(size.height).toEqual(30);
|
||||
});
|
||||
|
||||
it('returns 0, 0 for empty content', () => {
|
||||
const size = svg.textSizer.measure(attrs, []);
|
||||
|
||||
expect(size.width).toEqual(0);
|
||||
expect(size.height).toEqual(0);
|
||||
});
|
||||
|
||||
it('returns the maximum width for multiline text', () => {
|
||||
const size0 = svg.textSizer.measure(attrs, [
|
||||
[{text: 'foo'}],
|
||||
]);
|
||||
const size1 = svg.textSizer.measure(attrs, [
|
||||
[{text: 'longline'}],
|
||||
]);
|
||||
const size = svg.textSizer.measure(attrs, [
|
||||
[{text: 'foo'}],
|
||||
[{text: 'longline'}],
|
||||
[{text: 'foo'}],
|
||||
]);
|
||||
|
||||
expect(size1.width).toBeGreaterThan(size0.width);
|
||||
expect(size.width).toEqual(size1.width);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.measureHeight', () => {
|
||||
it('calculates the height of the rendered text', () => {
|
||||
const height = svg.textSizer.measureHeight(attrs, [
|
||||
[{text: 'foo'}],
|
||||
]);
|
||||
|
||||
expect(height).toEqual(15);
|
||||
});
|
||||
|
||||
it('measures multiline text', () => {
|
||||
const height = svg.textSizer.measureHeight(attrs, [
|
||||
[{text: 'foo'}],
|
||||
[{text: 'bar'}],
|
||||
]);
|
||||
|
||||
expect(height).toEqual(30);
|
||||
});
|
||||
|
||||
it('returns 0 for empty content', () => {
|
||||
const height = svg.textSizer.measureHeight(attrs, []);
|
||||
|
||||
expect(height).toEqual(0);
|
||||
});
|
||||
|
||||
it('does not require the container', () => {
|
||||
svg.textSizer.measureHeight(attrs, [[{text: 'foo'}]]);
|
||||
|
||||
expect(svg.body.element.childNodes.length).toEqual(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,139 @@
|
|||
import {SVGTextBlock, TextSizer} from './SVGTextBlock.mjs';
|
||||
import {DOMWrapper} from '../../spec/stubs/TestDOM.mjs';
|
||||
import SVG from './SVG.mjs';
|
||||
|
||||
describe('TextSizer', () => {
|
||||
const attrs = {'font-size': 10, 'line-height': 1.5};
|
||||
let svg = null;
|
||||
|
||||
beforeEach(() => {
|
||||
svg = new SVG(
|
||||
new DOMWrapper(window.document),
|
||||
(svgBase) => new TextSizer(svgBase)
|
||||
);
|
||||
document.body.appendChild(svg.body.element);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(svg.body.element);
|
||||
});
|
||||
|
||||
function safeMeasure(attributes, formatted) {
|
||||
svg.textSizer.expectMeasure(attributes, formatted);
|
||||
svg.textSizer.performMeasurements();
|
||||
return svg.textSizer.measure(attributes, formatted);
|
||||
}
|
||||
|
||||
describe('.measure', () => {
|
||||
it('calculates the size of the formatted text', () => {
|
||||
const size = safeMeasure(attrs, [[{text: 'foo'}]]);
|
||||
|
||||
expect(size.width).toBeGreaterThan(0);
|
||||
expect(size.height).toEqual(15);
|
||||
});
|
||||
|
||||
it('calculates the size of text blocks', () => {
|
||||
const block = new SVGTextBlock(svg.body, svg, {attrs});
|
||||
block.set({formatted: [[{text: 'foo'}]]});
|
||||
const size = safeMeasure(block);
|
||||
|
||||
expect(size.width).toBeGreaterThan(0);
|
||||
expect(size.height).toEqual(15);
|
||||
});
|
||||
|
||||
it('measures multiline text', () => {
|
||||
const size = safeMeasure(attrs, [
|
||||
[{text: 'foo'}],
|
||||
[{text: 'bar'}],
|
||||
]);
|
||||
|
||||
expect(size.width).toBeGreaterThan(0);
|
||||
expect(size.height).toEqual(30);
|
||||
});
|
||||
|
||||
it('uses font styles where available', () => {
|
||||
const sizeRegular = safeMeasure(attrs, [[
|
||||
{text: 'foo'},
|
||||
{text: 'bar'},
|
||||
]]);
|
||||
|
||||
const sizeBold = safeMeasure(attrs, [[
|
||||
{text: 'foo'},
|
||||
{attrs: {'font-weight': 'bolder'}, text: 'bar'},
|
||||
]]);
|
||||
|
||||
const sizeMono = safeMeasure(attrs, [[
|
||||
{text: 'foo'},
|
||||
{attrs: {'font-family': 'monospace'}, text: 'bar'},
|
||||
]]);
|
||||
|
||||
const sizeMonoBold = safeMeasure(attrs, [[
|
||||
{text: 'foo'},
|
||||
{attrs: {
|
||||
'font-family': 'monospace',
|
||||
'font-weight': 'bolder',
|
||||
}, text: 'bar'},
|
||||
]]);
|
||||
|
||||
expect(sizeBold.width).toBeGreaterThan(sizeRegular.width);
|
||||
|
||||
expect(sizeMono.width).toBeGreaterThan(sizeRegular.width);
|
||||
expect(sizeMonoBold.width).toBeNear(sizeMono.width, 1e-1);
|
||||
});
|
||||
|
||||
it('returns 0, 0 for empty content', () => {
|
||||
const size = safeMeasure(attrs, []);
|
||||
|
||||
expect(size.width).toEqual(0);
|
||||
expect(size.height).toEqual(0);
|
||||
});
|
||||
|
||||
it('returns the maximum width for multiline text', () => {
|
||||
const size0 = safeMeasure(attrs, [
|
||||
[{text: 'foo'}],
|
||||
]);
|
||||
const size1 = safeMeasure(attrs, [
|
||||
[{text: 'longline'}],
|
||||
]);
|
||||
const size = safeMeasure(attrs, [
|
||||
[{text: 'foo'}],
|
||||
[{text: 'longline'}],
|
||||
[{text: 'foo'}],
|
||||
]);
|
||||
|
||||
expect(size1.width).toBeGreaterThan(size0.width);
|
||||
expect(size.width).toEqual(size1.width);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.measureHeight', () => {
|
||||
it('calculates the height of the rendered text', () => {
|
||||
const height = svg.textSizer.measureHeight(attrs, [
|
||||
[{text: 'foo'}],
|
||||
]);
|
||||
|
||||
expect(height).toEqual(15);
|
||||
});
|
||||
|
||||
it('measures multiline text', () => {
|
||||
const height = svg.textSizer.measureHeight(attrs, [
|
||||
[{text: 'foo'}],
|
||||
[{text: 'bar'}],
|
||||
]);
|
||||
|
||||
expect(height).toEqual(30);
|
||||
});
|
||||
|
||||
it('returns 0 for empty content', () => {
|
||||
const height = svg.textSizer.measureHeight(attrs, []);
|
||||
|
||||
expect(height).toEqual(0);
|
||||
});
|
||||
|
||||
it('does not require the container', () => {
|
||||
svg.textSizer.measureHeight(attrs, [[{text: 'foo'}]]);
|
||||
|
||||
expect(svg.body.element.childNodes.length).toEqual(0);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,25 +1,124 @@
|
|||
export default class VirtualTextSizer {
|
||||
// Simplified text sizer, which assumes all characters render as
|
||||
// 1x1 px squares for repeatable renders in all browsers
|
||||
const fs = require('fs');
|
||||
const opentype = require('opentype.js');
|
||||
|
||||
baseline() {
|
||||
return 1;
|
||||
const FONTS = new Map();
|
||||
|
||||
function loadFont(path) {
|
||||
// Must be synchronous so that measurements are ready once startup completes
|
||||
/* eslint-disable no-sync */
|
||||
const data = fs.readFileSync(path);
|
||||
/* eslint-enable no-sync */
|
||||
return opentype.parse(data.buffer);
|
||||
}
|
||||
|
||||
function addFont(name, variants) {
|
||||
const types = new Map();
|
||||
for(const v in variants) {
|
||||
if(Object.prototype.hasOwnProperty.call(variants, v)) {
|
||||
const font = loadFont(variants[v]);
|
||||
font.id = name + '-' + v;
|
||||
types.set(v, font);
|
||||
}
|
||||
}
|
||||
FONTS.set(name.toLowerCase(), types);
|
||||
}
|
||||
|
||||
addFont('sans-serif', {
|
||||
'': 'fonts/liberation-fonts/LiberationSans-Regular.ttf',
|
||||
'bold': 'fonts/liberation-fonts/LiberationSans-Bold.ttf',
|
||||
'bold-italic': 'fonts/liberation-fonts/LiberationSans-BoldItalic.ttf',
|
||||
'italic': 'fonts/liberation-fonts/LiberationSans-Italic.ttf',
|
||||
});
|
||||
addFont('monospace', {
|
||||
'': 'fonts/liberation-fonts/LiberationMono-Regular.ttf',
|
||||
'bold': 'fonts/liberation-fonts/LiberationMono-Bold.ttf',
|
||||
'bold-italic': 'fonts/liberation-fonts/LiberationMono-BoldItalic.ttf',
|
||||
'italic': 'fonts/liberation-fonts/LiberationMono-Italic.ttf',
|
||||
});
|
||||
addFont('handlee', {
|
||||
'': 'fonts/handlee/Handlee.ttf',
|
||||
});
|
||||
|
||||
const DEFAULT_FONT = 'sans-serif';
|
||||
|
||||
const OPENTYPE_OPTIONS = {hinting: true};
|
||||
|
||||
function getFont(attrs) {
|
||||
const family = (attrs['font-family'] || DEFAULT_FONT).split(',');
|
||||
for(const nm of family) {
|
||||
const name = nm.trim().replace(/['"]/g, '').toLowerCase();
|
||||
const font = FONTS.get(name);
|
||||
if(font) {
|
||||
return font;
|
||||
}
|
||||
}
|
||||
return FONTS.get(DEFAULT_FONT);
|
||||
}
|
||||
|
||||
function tryVariant(font, condition, name) {
|
||||
if(!condition) {
|
||||
return null;
|
||||
}
|
||||
return font.get(name) || null;
|
||||
}
|
||||
|
||||
function getVariantRaw(font, {bold, italic}) {
|
||||
return (
|
||||
tryVariant(font, bold && italic, 'bold-italic') ||
|
||||
tryVariant(font, bold, 'bold') ||
|
||||
tryVariant(font, italic, 'italic') ||
|
||||
font.get('')
|
||||
);
|
||||
}
|
||||
|
||||
function getVariant(font, attrs) {
|
||||
const weight = attrs['font-weight'] || '';
|
||||
const style = attrs['font-style'] || '';
|
||||
const bold = (weight.includes('bold') || Number(weight) > 400);
|
||||
const italic = style.includes('italic');
|
||||
|
||||
return getVariantRaw(font, {bold, italic});
|
||||
}
|
||||
|
||||
function getFontSize(attrs) {
|
||||
return Number(attrs['font-size']);
|
||||
}
|
||||
|
||||
function measure(attrs, text) {
|
||||
const font = getFont(attrs);
|
||||
const variant = getVariant(font, attrs);
|
||||
const size = getFontSize(attrs);
|
||||
return variant.getAdvanceWidth(text, size, OPENTYPE_OPTIONS);
|
||||
}
|
||||
|
||||
export default class VirtualTextSizer {
|
||||
baseline({attrs}) {
|
||||
return getFontSize(attrs);
|
||||
}
|
||||
|
||||
measureHeight({formatted}) {
|
||||
return formatted.length;
|
||||
measureHeight({attrs, formatted}) {
|
||||
const size = this.baseline({attrs, formatted});
|
||||
const lineHeight = size * (Number(attrs['line-height']) || 1);
|
||||
return formatted.length * lineHeight;
|
||||
}
|
||||
|
||||
prepMeasurement(attrs, formatted) {
|
||||
return formatted;
|
||||
return {attrs, formatted};
|
||||
}
|
||||
|
||||
prepComplete() {
|
||||
// No-op
|
||||
}
|
||||
|
||||
performMeasurement(data) {
|
||||
return data.reduce((total, part) => total + part.text.length, 0);
|
||||
performMeasurement({attrs, formatted}) {
|
||||
let len = 0;
|
||||
for(const part of formatted) {
|
||||
if(!part.text) {
|
||||
continue;
|
||||
}
|
||||
len += measure(Object.assign({}, attrs, part.attrs), part.text);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
teardown() {
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
import SVG from './SVG.mjs';
|
||||
import {SVGTextBlock} from './SVGTextBlock.mjs';
|
||||
import VirtualTextSizer from './VirtualTextSizer.mjs';
|
||||
import {dom} from '../../spec/stubs/TestDOM.mjs';
|
||||
|
||||
describe('VirtualTextSizer', () => {
|
||||
const attrs = {'font-size': 10, 'line-height': 1.5};
|
||||
let svg = null;
|
||||
|
||||
beforeEach(() => {
|
||||
svg = new SVG(dom, () => new VirtualTextSizer());
|
||||
});
|
||||
|
||||
function safeMeasure(attributes, formatted) {
|
||||
svg.textSizer.expectMeasure(attributes, formatted);
|
||||
svg.textSizer.performMeasurements();
|
||||
return svg.textSizer.measure(attributes, formatted);
|
||||
}
|
||||
|
||||
describe('.measure', () => {
|
||||
it('calculates the size of the formatted text', () => {
|
||||
const size = safeMeasure(attrs, [[{text: 'foo'}]]);
|
||||
|
||||
expect(size.width).toBeNear(13.9, 1e-1);
|
||||
expect(size.height).toEqual(15);
|
||||
});
|
||||
|
||||
it('calculates the size of text blocks', () => {
|
||||
const block = new SVGTextBlock(svg.body, svg, {attrs});
|
||||
block.set({formatted: [[{text: 'foo'}]]});
|
||||
const size = safeMeasure(block);
|
||||
|
||||
expect(size.width).toBeNear(13.9, 1e-1);
|
||||
expect(size.height).toEqual(15);
|
||||
});
|
||||
|
||||
it('measures multiline text', () => {
|
||||
const size = safeMeasure(attrs, [
|
||||
[{text: 'foo'}],
|
||||
[{text: 'bar'}],
|
||||
]);
|
||||
|
||||
expect(size.width).toBeNear(14.5, 1e-1);
|
||||
expect(size.height).toEqual(30);
|
||||
});
|
||||
|
||||
it('uses font styles where available', () => {
|
||||
const sizeRegular = safeMeasure(attrs, [[
|
||||
{text: 'foo'},
|
||||
{text: 'bar'},
|
||||
]]);
|
||||
|
||||
const sizeBold = safeMeasure(attrs, [[
|
||||
{text: 'foo'},
|
||||
{attrs: {'font-weight': 'bolder'}, text: 'bar'},
|
||||
]]);
|
||||
|
||||
const sizeMono = safeMeasure(attrs, [[
|
||||
{text: 'foo'},
|
||||
{attrs: {'font-family': 'monospace'}, text: 'bar'},
|
||||
]]);
|
||||
|
||||
const sizeMonoBold = safeMeasure(attrs, [[
|
||||
{text: 'foo'},
|
||||
{attrs: {
|
||||
'font-family': 'monospace',
|
||||
'font-weight': 'bolder',
|
||||
}, text: 'bar'},
|
||||
]]);
|
||||
|
||||
expect(sizeRegular.width).toBeNear(28.4, 1e-1);
|
||||
expect(sizeBold.width).toBeGreaterThan(sizeRegular.width);
|
||||
|
||||
expect(sizeMono.width).toBeNear(31.9, 1e-1);
|
||||
expect(sizeMonoBold.width).toBeNear(sizeMono.width, 1e-1);
|
||||
});
|
||||
|
||||
it('returns 0, 0 for empty content', () => {
|
||||
const size = safeMeasure(attrs, []);
|
||||
|
||||
expect(size.width).toEqual(0);
|
||||
expect(size.height).toEqual(0);
|
||||
});
|
||||
|
||||
it('returns the maximum width for multiline text', () => {
|
||||
const size0 = safeMeasure(attrs, [
|
||||
[{text: 'foo'}],
|
||||
]);
|
||||
const size1 = safeMeasure(attrs, [
|
||||
[{text: 'longline'}],
|
||||
]);
|
||||
const size = safeMeasure(attrs, [
|
||||
[{text: 'foo'}],
|
||||
[{text: 'longline'}],
|
||||
[{text: 'foo'}],
|
||||
]);
|
||||
|
||||
expect(size1.width).toBeGreaterThan(size0.width);
|
||||
expect(size.width).toEqual(size1.width);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.measureHeight', () => {
|
||||
it('calculates the height of the rendered text', () => {
|
||||
const height = svg.textSizer.measureHeight(attrs, [
|
||||
[{text: 'foo'}],
|
||||
]);
|
||||
|
||||
expect(height).toEqual(15);
|
||||
});
|
||||
|
||||
it('measures multiline text', () => {
|
||||
const height = svg.textSizer.measureHeight(attrs, [
|
||||
[{text: 'foo'}],
|
||||
[{text: 'bar'}],
|
||||
]);
|
||||
|
||||
expect(height).toEqual(30);
|
||||
});
|
||||
|
||||
it('returns 0 for empty content', () => {
|
||||
const height = svg.textSizer.measureHeight(attrs, []);
|
||||
|
||||
expect(height).toEqual(0);
|
||||
});
|
||||
|
||||
it('does not require the container', () => {
|
||||
svg.textSizer.measureHeight(attrs, [[{text: 'foo'}]]);
|
||||
|
||||
expect(svg.body.element.childNodes.length).toEqual(0);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -5,9 +5,13 @@ export default [
|
|||
input: [
|
||||
'spec/helpers/**/*.mjs',
|
||||
'scripts/**/*_spec.mjs',
|
||||
'scripts/**/*_nodespec.mjs',
|
||||
'spec/**/*_spec.mjs',
|
||||
'spec/**/*_nodespec.mjs',
|
||||
'web/**/*_spec.mjs',
|
||||
'web/**/*_nodespec.mjs',
|
||||
'bin/**/*_spec.mjs',
|
||||
'bin/**/*_nodespec.mjs',
|
||||
],
|
||||
output: {
|
||||
file: 'ephemeral/spec_bundle.js',
|
||||
|
|
Loading…
Reference in New Issue