@meltemi/diagrams-assets 0.0.0-stage → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +35 -2
- package/dist/icon.d.ts +74 -0
- package/dist/icon.d.ts.map +1 -0
- package/dist/icon.js +28 -0
- package/dist/icon.js.map +1 -0
- package/dist/image.d.ts +43 -0
- package/dist/image.d.ts.map +1 -0
- package/dist/image.js +248 -0
- package/dist/image.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/libraries.d.ts +53 -0
- package/dist/libraries.d.ts.map +1 -0
- package/dist/libraries.js +177 -0
- package/dist/libraries.js.map +1 -0
- package/dist/lock.d.ts +36 -0
- package/dist/lock.d.ts.map +1 -0
- package/dist/lock.js +83 -0
- package/dist/lock.js.map +1 -0
- package/dist/messages/en.d.ts +100 -0
- package/dist/messages/en.d.ts.map +1 -0
- package/dist/messages/en.js +101 -0
- package/dist/messages/en.js.map +1 -0
- package/dist/messages/es.d.ts +4 -0
- package/dist/messages/es.d.ts.map +1 -0
- package/dist/messages/es.js +82 -0
- package/dist/messages/es.js.map +1 -0
- package/dist/messages/index.d.ts +82 -0
- package/dist/messages/index.d.ts.map +1 -0
- package/dist/messages/index.js +11 -0
- package/dist/messages/index.js.map +1 -0
- package/dist/node.d.ts +16 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +80 -0
- package/dist/node.js.map +1 -0
- package/dist/packs.d.ts +259 -0
- package/dist/packs.d.ts.map +1 -0
- package/dist/packs.js +540 -0
- package/dist/packs.js.map +1 -0
- package/dist/path.d.ts +65 -0
- package/dist/path.d.ts.map +1 -0
- package/dist/path.js +477 -0
- package/dist/path.js.map +1 -0
- package/dist/sanitize.d.ts +39 -0
- package/dist/sanitize.d.ts.map +1 -0
- package/dist/sanitize.js +460 -0
- package/dist/sanitize.js.map +1 -0
- package/dist/sha256.d.ts +10 -0
- package/dist/sha256.d.ts.map +1 -0
- package/dist/sha256.js +104 -0
- package/dist/sha256.js.map +1 -0
- package/dist/xml.d.ts +28 -0
- package/dist/xml.d.ts.map +1 -0
- package/dist/xml.js +179 -0
- package/dist/xml.js.map +1 -0
- package/libraries/tech.json +1270 -0
- package/package.json +43 -3
- package/vendor/aws.json +1 -0
- package/vendor/azure.json +1 -0
- package/vendor/gcp.json +1 -0
- package/vendor/index.json +1 -0
- package/vendor/kubernetes.json +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Architecture Studio contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @meltemi/diagrams-assets
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Icons and project assets: the built-in Tabler pack, Iconify and SVG folder packs with their
|
|
4
|
+
licences, a strict SVG sanitiser, image reading and the asset lock with SHA-256 digests.
|
|
5
|
+
|
|
6
|
+
It is part of [Meltemi Diagrams](https://github.com/askenaz-dev/meltemi-diagrams#readme), diagrams as code with a canvas, motion and
|
|
7
|
+
exports. Every package of the product has the same version.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @meltemi/diagrams-assets
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Node 22.12.0 or later. The package is an ES module with type declarations.
|
|
16
|
+
|
|
17
|
+
## Use
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { sanitizeSvg } from "@meltemi/diagrams-assets";
|
|
21
|
+
|
|
22
|
+
const result = sanitizeSvg(
|
|
23
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 4h16v16H4z"/><script>alert(1)</script></svg>',
|
|
24
|
+
);
|
|
25
|
+
console.log(result.ok); // false: scripts are refused, never stripped silently
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Documentation
|
|
29
|
+
|
|
30
|
+
- [Icons and assets](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/docs/language/assets.md)
|
|
31
|
+
- [Security](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/docs/security.md)
|
|
32
|
+
- [All documentation](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/docs/README.md)
|
|
33
|
+
|
|
34
|
+
## Licence
|
|
35
|
+
|
|
36
|
+
MIT. Third-party components and their licences are listed in [THIRD_PARTY_LICENSES.md](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/THIRD_PARTY_LICENSES.md).
|
package/dist/icon.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Bounds } from "./path.js";
|
|
2
|
+
/**
|
|
3
|
+
* A paint: `none`, the icon colour (`currentColor`, black or unset in monochrome icons), a colour
|
|
4
|
+
* as written, or a gradient of the icon.
|
|
5
|
+
*/
|
|
6
|
+
export type Paint = {
|
|
7
|
+
readonly kind: "none";
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: "current";
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: "color";
|
|
12
|
+
readonly value: string;
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: "gradient";
|
|
15
|
+
readonly id: string;
|
|
16
|
+
};
|
|
17
|
+
/** One drawable path of an icon, in view box units. */
|
|
18
|
+
export interface IconPath {
|
|
19
|
+
readonly d: string;
|
|
20
|
+
/** `matrix(a b c d e f)` of the element and its groups, or null. */
|
|
21
|
+
readonly transform: string | null;
|
|
22
|
+
readonly fill: Paint;
|
|
23
|
+
readonly stroke: Paint;
|
|
24
|
+
readonly strokeWidth: number;
|
|
25
|
+
readonly lineCap: "butt" | "round" | "square";
|
|
26
|
+
readonly lineJoin: "miter" | "round" | "bevel";
|
|
27
|
+
readonly fillRule: "nonzero" | "evenodd";
|
|
28
|
+
readonly opacity: number;
|
|
29
|
+
readonly fillOpacity: number;
|
|
30
|
+
readonly strokeOpacity: number;
|
|
31
|
+
}
|
|
32
|
+
export interface GradientStop {
|
|
33
|
+
readonly offset: number;
|
|
34
|
+
readonly color: string;
|
|
35
|
+
readonly opacity: number;
|
|
36
|
+
}
|
|
37
|
+
/** A gradient defined inside an icon; coordinates are numbers or percentages as written. */
|
|
38
|
+
export interface IconGradient {
|
|
39
|
+
readonly id: string;
|
|
40
|
+
readonly kind: "linear" | "radial";
|
|
41
|
+
readonly units: "objectBoundingBox" | "userSpaceOnUse";
|
|
42
|
+
readonly transform: string | null;
|
|
43
|
+
readonly spread: "pad" | "reflect" | "repeat";
|
|
44
|
+
/** `x1`, `y1`, `x2`, `y2` for linear gradients; `cx`, `cy`, `r`, `fx`, `fy` for radial ones. */
|
|
45
|
+
readonly coordinates: Readonly<Record<string, string>>;
|
|
46
|
+
readonly stops: readonly GradientStop[];
|
|
47
|
+
}
|
|
48
|
+
export interface ViewBox {
|
|
49
|
+
readonly x: number;
|
|
50
|
+
readonly y: number;
|
|
51
|
+
readonly width: number;
|
|
52
|
+
readonly height: number;
|
|
53
|
+
}
|
|
54
|
+
export interface IconGeometry {
|
|
55
|
+
readonly viewBox: ViewBox;
|
|
56
|
+
readonly paths: readonly IconPath[];
|
|
57
|
+
readonly gradients: readonly IconGradient[];
|
|
58
|
+
/** True when every paint is the icon colour or none, so the icon takes the target's colour. */
|
|
59
|
+
readonly monochrome: boolean;
|
|
60
|
+
/** Bounding box of the drawn paths, strokes included, in view box units. */
|
|
61
|
+
readonly bounds: Bounds | undefined;
|
|
62
|
+
}
|
|
63
|
+
/** Larger side of the content box over the larger side of the view box. */
|
|
64
|
+
export declare function opticalRatio(icon: IconGeometry): number | undefined;
|
|
65
|
+
/** The share of its box an icon's content fills in the reference pack (Tabler: 20 of 24 units). */
|
|
66
|
+
export declare const OPTICAL_TARGET: number;
|
|
67
|
+
/**
|
|
68
|
+
* Size, relative to the icon square, at which a pack's view boxes are drawn so that its content
|
|
69
|
+
* fills the same share as the reference pack.
|
|
70
|
+
*/
|
|
71
|
+
export declare function drawScale(packRatio: number | undefined): number;
|
|
72
|
+
/** The median of a list of numbers, or undefined for an empty list. */
|
|
73
|
+
export declare function median(values: readonly number[]): number | undefined;
|
|
74
|
+
//# sourceMappingURL=icon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../src/icon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC;;;GAGG;AACH,MAAM,MAAM,KAAK,GACb;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;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the larger side of the view box. */
|
|
2
|
+
export function opticalRatio(icon) {
|
|
3
|
+
if (!icon.bounds)
|
|
4
|
+
return undefined;
|
|
5
|
+
const content = Math.max(icon.bounds.maxX - icon.bounds.minX, icon.bounds.maxY - icon.bounds.minY);
|
|
6
|
+
const box = Math.max(icon.viewBox.width, icon.viewBox.height);
|
|
7
|
+
return box > 0 && content > 0 ? content / box : undefined;
|
|
8
|
+
}
|
|
9
|
+
/** The share of its box an icon's content fills in the reference pack (Tabler: 20 of 24 units). */
|
|
10
|
+
export const OPTICAL_TARGET = 20 / 24;
|
|
11
|
+
/**
|
|
12
|
+
* Size, relative to the icon square, at which a pack's view boxes are drawn so that its content
|
|
13
|
+
* fills the same share as the reference pack.
|
|
14
|
+
*/
|
|
15
|
+
export function drawScale(packRatio) {
|
|
16
|
+
if (packRatio === undefined || packRatio <= 0)
|
|
17
|
+
return 1;
|
|
18
|
+
return Math.min(1.25, Math.max(0.75, OPTICAL_TARGET / packRatio));
|
|
19
|
+
}
|
|
20
|
+
/** The median of a list of numbers, or undefined for an empty list. */
|
|
21
|
+
export function median(values) {
|
|
22
|
+
if (values.length === 0)
|
|
23
|
+
return undefined;
|
|
24
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
25
|
+
const middle = Math.floor(sorted.length / 2);
|
|
26
|
+
return sorted.length % 2 === 1 ? sorted[middle] : (sorted[middle - 1] + sorted[middle]) / 2;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=icon.js.map
|
package/dist/icon.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon.js","sourceRoot":"","sources":["../src/icon.ts"],"names":[],"mappings":"AA+DA,2EAA2E;AAC3E,MAAM,UAAU,YAAY,CAAC,IAAkB;IAC7C,IAAI,CAAC,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IACnC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CACtB,IAAI,CAAC,MAAM,CAAC,IAAI,GA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AAC,MAAM,CAAE,CAAC,GAAG,CAAC,CAAC;AAChG,CAAC"}
|
package/dist/image.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { IconGeometry } from "./icon.js";
|
|
2
|
+
/** Raster and vector formats accepted for `image` objects. */
|
|
3
|
+
export type ImageFormat = "png" | "jpeg" | "gif" | "webp" | "svg";
|
|
4
|
+
/** Largest image file, in bytes. */
|
|
5
|
+
export declare const IMAGE_MAX_BYTES: number;
|
|
6
|
+
/** Size of an SVG image that declares neither `width` and `height` nor a `viewBox`. */
|
|
7
|
+
export declare const UNKNOWN_IMAGE_SIZE: {
|
|
8
|
+
readonly width: 160;
|
|
9
|
+
readonly height: 120;
|
|
10
|
+
};
|
|
11
|
+
/** An image ready to embed: its format, pixel size and a `data:` URI. */
|
|
12
|
+
export interface ResolvedImage {
|
|
13
|
+
readonly format: ImageFormat;
|
|
14
|
+
readonly width: number;
|
|
15
|
+
readonly height: number;
|
|
16
|
+
readonly href: string;
|
|
17
|
+
}
|
|
18
|
+
/** Resolves an image path written in a diagram, relative to its file. */
|
|
19
|
+
export interface ImageResolver {
|
|
20
|
+
resolve(path: string): ResolvedImage | undefined;
|
|
21
|
+
}
|
|
22
|
+
export type ImageResult = {
|
|
23
|
+
readonly ok: true;
|
|
24
|
+
readonly image: ResolvedImage;
|
|
25
|
+
} | {
|
|
26
|
+
readonly ok: false;
|
|
27
|
+
readonly message: string;
|
|
28
|
+
};
|
|
29
|
+
/** Reads an image file: its format from the header, its pixel size, and a data URI. */
|
|
30
|
+
export declare function readImage(bytes: Uint8Array): ImageResult;
|
|
31
|
+
/** A standalone SVG made only of the sanitised paths and gradients of an image. */
|
|
32
|
+
export declare function geometrySvg(icon: IconGeometry, width: number, height: number): string;
|
|
33
|
+
/** Standard base64 with padding. */
|
|
34
|
+
export declare function base64(bytes: Uint8Array): string;
|
|
35
|
+
/** The default drawn size of an image: its pixel size, at most 640 wide, keeping the ratio. */
|
|
36
|
+
export declare function defaultImageSize(image: {
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
} | undefined): {
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../src/image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAS,MAAM,WAAW,CAAC;AAIrD,8DAA8D;AAC9D,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;AAElE,oCAAoC;AACpC,eAAO,MAAM,eAAe,QAAkB,CAAC;AAE/C,uFAAuF;AACvF,eAAO,MAAM,kBAAkB;;;CAAuC,CAAC;AAEvE,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;CAClD;AAED,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;CAAE,GACpD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAUrD,uFAAuF;AACvF,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAkBxD;AAqJD,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAkDrF;AAID,oCAAoC;AACpC,wBAAgB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAkBhD;AAED,+FAA+F;AAC/F,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,GAAG;IACtF,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAKA"}
|
package/dist/image.js
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { messages } from "./messages/index.js";
|
|
2
|
+
import { sanitizeSvg } from "./sanitize.js";
|
|
3
|
+
/** Largest image file, in bytes. */
|
|
4
|
+
export const IMAGE_MAX_BYTES = 8 * 1024 * 1024;
|
|
5
|
+
/** Size of an SVG image that declares neither `width` and `height` nor a `viewBox`. */
|
|
6
|
+
export const UNKNOWN_IMAGE_SIZE = { width: 160, height: 120 };
|
|
7
|
+
const MIME = {
|
|
8
|
+
png: "image/png",
|
|
9
|
+
jpeg: "image/jpeg",
|
|
10
|
+
gif: "image/gif",
|
|
11
|
+
webp: "image/webp",
|
|
12
|
+
svg: "image/svg+xml",
|
|
13
|
+
};
|
|
14
|
+
/** Reads an image file: its format from the header, its pixel size, and a data URI. */
|
|
15
|
+
export function readImage(bytes) {
|
|
16
|
+
// Problems are written in the interface language of the moment the file is read.
|
|
17
|
+
const t = messages().images;
|
|
18
|
+
if (bytes.length > IMAGE_MAX_BYTES) {
|
|
19
|
+
return { ok: false, message: t.fileSize(IMAGE_MAX_BYTES / 1024 / 1024) };
|
|
20
|
+
}
|
|
21
|
+
const raster = rasterSize(bytes);
|
|
22
|
+
if (raster) {
|
|
23
|
+
if (!raster.ok)
|
|
24
|
+
return raster;
|
|
25
|
+
const { format, width, height } = raster;
|
|
26
|
+
return {
|
|
27
|
+
ok: true,
|
|
28
|
+
image: { format, width, height, href: `data:${MIME[format]};base64,${base64(bytes)}` },
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const text = decodeUtf8(bytes);
|
|
32
|
+
if (text !== undefined && /<svg[\s>]/.test(text.slice(0, 4096)))
|
|
33
|
+
return svgImage(text);
|
|
34
|
+
return { ok: false, message: t.format };
|
|
35
|
+
}
|
|
36
|
+
function u16be(b, i) {
|
|
37
|
+
return (b[i] << 8) | b[i + 1];
|
|
38
|
+
}
|
|
39
|
+
function u16le(b, i) {
|
|
40
|
+
return b[i] | (b[i + 1] << 8);
|
|
41
|
+
}
|
|
42
|
+
function u24le(b, i) {
|
|
43
|
+
return b[i] | (b[i + 1] << 8) | (b[i + 2] << 16);
|
|
44
|
+
}
|
|
45
|
+
function u32be(b, i) {
|
|
46
|
+
return ((b[i] << 24) >>> 0) + ((b[i + 1] << 16) | (b[i + 2] << 8) | b[i + 3]);
|
|
47
|
+
}
|
|
48
|
+
function ascii(b, start, length) {
|
|
49
|
+
return String.fromCharCode(...b.subarray(start, start + length));
|
|
50
|
+
}
|
|
51
|
+
/** The format and size of a raster image, or undefined when the header is not a raster format. */
|
|
52
|
+
function rasterSize(b) {
|
|
53
|
+
const broken = (format) => ({
|
|
54
|
+
ok: false,
|
|
55
|
+
message: messages().images.brokenHeader(format),
|
|
56
|
+
});
|
|
57
|
+
const sized = (format, width, height) => width > 0 && height > 0 ? { ok: true, format, width, height } : broken(format.toUpperCase());
|
|
58
|
+
if (b.length >= 8 && b[0] === 0x89 && ascii(b, 1, 3) === "PNG") {
|
|
59
|
+
if (b.length < 24 || ascii(b, 12, 4) !== "IHDR")
|
|
60
|
+
return broken("PNG");
|
|
61
|
+
return sized("png", u32be(b, 16), u32be(b, 20));
|
|
62
|
+
}
|
|
63
|
+
if (b.length >= 3 && b[0] === 0xff && b[1] === 0xd8 && b[2] === 0xff) {
|
|
64
|
+
let i = 2;
|
|
65
|
+
while (i + 9 < b.length) {
|
|
66
|
+
if (b[i] !== 0xff)
|
|
67
|
+
return broken("JPEG");
|
|
68
|
+
const marker = b[i + 1];
|
|
69
|
+
if (marker === 0xff) {
|
|
70
|
+
i++;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const length = u16be(b, i + 2);
|
|
74
|
+
const frame = marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc;
|
|
75
|
+
if (frame)
|
|
76
|
+
return sized("jpeg", u16be(b, i + 7), u16be(b, i + 5));
|
|
77
|
+
if (length < 2)
|
|
78
|
+
return broken("JPEG");
|
|
79
|
+
i += 2 + length;
|
|
80
|
+
}
|
|
81
|
+
return broken("JPEG");
|
|
82
|
+
}
|
|
83
|
+
if (b.length >= 6 && (ascii(b, 0, 6) === "GIF87a" || ascii(b, 0, 6) === "GIF89a")) {
|
|
84
|
+
if (b.length < 10)
|
|
85
|
+
return broken("GIF");
|
|
86
|
+
return sized("gif", u16le(b, 6), u16le(b, 8));
|
|
87
|
+
}
|
|
88
|
+
if (b.length >= 12 && ascii(b, 0, 4) === "RIFF" && ascii(b, 8, 4) === "WEBP") {
|
|
89
|
+
if (b.length < 30)
|
|
90
|
+
return broken("WebP");
|
|
91
|
+
const chunk = ascii(b, 12, 4);
|
|
92
|
+
if (chunk === "VP8 ")
|
|
93
|
+
return sized("webp", u16le(b, 26) & 0x3fff, u16le(b, 28) & 0x3fff);
|
|
94
|
+
if (chunk === "VP8L") {
|
|
95
|
+
if (b[20] !== 0x2f)
|
|
96
|
+
return broken("WebP");
|
|
97
|
+
const b0 = b[21];
|
|
98
|
+
const b1 = b[22];
|
|
99
|
+
const b2 = b[23];
|
|
100
|
+
const b3 = b[24];
|
|
101
|
+
const width = 1 + (((b1 & 0x3f) << 8) | b0);
|
|
102
|
+
const height = 1 + (((b3 & 0x0f) << 10) | (b2 << 2) | ((b1 & 0xc0) >> 6));
|
|
103
|
+
return sized("webp", width, height);
|
|
104
|
+
}
|
|
105
|
+
if (chunk === "VP8X")
|
|
106
|
+
return sized("webp", 1 + u24le(b, 24), 1 + u24le(b, 27));
|
|
107
|
+
return broken("WebP");
|
|
108
|
+
}
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
function decodeUtf8(bytes) {
|
|
112
|
+
try {
|
|
113
|
+
// `ignoreBOM: false` is the default; the Workers typings of `TextDecoder` require it spelled out
|
|
114
|
+
// (the cloud Worker compiles this package from source).
|
|
115
|
+
return new TextDecoder("utf-8", { fatal: true, ignoreBOM: false }).decode(bytes);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/** Sanitises an SVG image with the icon sanitiser and writes it back as plain paths. */
|
|
122
|
+
function svgImage(text) {
|
|
123
|
+
const result = sanitizeSvg(text, IMAGE_MAX_BYTES);
|
|
124
|
+
if (!result.ok)
|
|
125
|
+
return { ok: false, message: messages().images.unsafeSvg(result.problem.message) };
|
|
126
|
+
const size = svgSize(text) ?? {
|
|
127
|
+
width: result.icon.viewBox.width,
|
|
128
|
+
height: result.icon.viewBox.height,
|
|
129
|
+
};
|
|
130
|
+
const svg = geometrySvg(result.icon, size.width, size.height);
|
|
131
|
+
return {
|
|
132
|
+
ok: true,
|
|
133
|
+
image: {
|
|
134
|
+
format: "svg",
|
|
135
|
+
width: size.width,
|
|
136
|
+
height: size.height,
|
|
137
|
+
href: `data:${MIME.svg};base64,${base64(new TextEncoder().encode(svg))}`,
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/** The `width` and `height` of the root element when both are plain pixel numbers. */
|
|
142
|
+
function svgSize(text) {
|
|
143
|
+
const root = /<svg\b[^>]*>/.exec(text)?.[0];
|
|
144
|
+
if (!root)
|
|
145
|
+
return undefined;
|
|
146
|
+
const read = (name) => {
|
|
147
|
+
const match = new RegExp(`\\s${name}\\s*=\\s*["']\\s*([\\d.]+)(?:px)?\\s*["']`).exec(root);
|
|
148
|
+
const value = match ? Number(match[1]) : NaN;
|
|
149
|
+
return Number.isFinite(value) && value > 0 ? value : undefined;
|
|
150
|
+
};
|
|
151
|
+
const width = read("width");
|
|
152
|
+
const height = read("height");
|
|
153
|
+
return width && height ? { width, height } : undefined;
|
|
154
|
+
}
|
|
155
|
+
const escapeAttribute = (value) => value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
156
|
+
function paint(value) {
|
|
157
|
+
switch (value.kind) {
|
|
158
|
+
case "none":
|
|
159
|
+
return "none";
|
|
160
|
+
case "current":
|
|
161
|
+
return "#000";
|
|
162
|
+
case "color":
|
|
163
|
+
return escapeAttribute(value.value);
|
|
164
|
+
case "gradient":
|
|
165
|
+
return `url(#${value.id})`;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const n = (value) => String(Math.round(value * 1000) / 1000);
|
|
169
|
+
/** A standalone SVG made only of the sanitised paths and gradients of an image. */
|
|
170
|
+
export function geometrySvg(icon, width, height) {
|
|
171
|
+
const { x, y, width: w, height: h } = icon.viewBox;
|
|
172
|
+
const parts = [
|
|
173
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="${n(width)}" height="${n(height)}" viewBox="${n(x)} ${n(y)} ${n(w)} ${n(h)}">`,
|
|
174
|
+
];
|
|
175
|
+
if (icon.gradients.length > 0) {
|
|
176
|
+
parts.push("<defs>");
|
|
177
|
+
for (const gradient of icon.gradients) {
|
|
178
|
+
const tag = gradient.kind === "linear" ? "linearGradient" : "radialGradient";
|
|
179
|
+
const attributes = [
|
|
180
|
+
`id="${escapeAttribute(gradient.id)}"`,
|
|
181
|
+
`gradientUnits="${gradient.units}"`,
|
|
182
|
+
`spreadMethod="${gradient.spread}"`,
|
|
183
|
+
...Object.entries(gradient.coordinates).map(([k, v]) => `${k}="${escapeAttribute(v)}"`),
|
|
184
|
+
];
|
|
185
|
+
if (gradient.transform) {
|
|
186
|
+
attributes.push(`gradientTransform="${escapeAttribute(gradient.transform)}"`);
|
|
187
|
+
}
|
|
188
|
+
parts.push(`<${tag} ${attributes.join(" ")}>`);
|
|
189
|
+
for (const stop of gradient.stops) {
|
|
190
|
+
parts.push(`<stop offset="${n(stop.offset)}" stop-color="${escapeAttribute(stop.color)}" stop-opacity="${n(stop.opacity)}"/>`);
|
|
191
|
+
}
|
|
192
|
+
parts.push(`</${tag}>`);
|
|
193
|
+
}
|
|
194
|
+
parts.push("</defs>");
|
|
195
|
+
}
|
|
196
|
+
for (const path of icon.paths) {
|
|
197
|
+
const attributes = [
|
|
198
|
+
`d="${escapeAttribute(path.d)}"`,
|
|
199
|
+
`fill="${paint(path.fill)}"`,
|
|
200
|
+
`stroke="${paint(path.stroke)}"`,
|
|
201
|
+
];
|
|
202
|
+
if (path.stroke.kind !== "none") {
|
|
203
|
+
attributes.push(`stroke-width="${n(path.strokeWidth)}"`, `stroke-linecap="${path.lineCap}"`, `stroke-linejoin="${path.lineJoin}"`);
|
|
204
|
+
}
|
|
205
|
+
if (path.fillRule !== "nonzero")
|
|
206
|
+
attributes.push(`fill-rule="${path.fillRule}"`);
|
|
207
|
+
if (path.transform)
|
|
208
|
+
attributes.push(`transform="${escapeAttribute(path.transform)}"`);
|
|
209
|
+
if (path.opacity !== 1)
|
|
210
|
+
attributes.push(`opacity="${n(path.opacity)}"`);
|
|
211
|
+
if (path.fillOpacity !== 1)
|
|
212
|
+
attributes.push(`fill-opacity="${n(path.fillOpacity)}"`);
|
|
213
|
+
if (path.strokeOpacity !== 1)
|
|
214
|
+
attributes.push(`stroke-opacity="${n(path.strokeOpacity)}"`);
|
|
215
|
+
parts.push(`<path ${attributes.join(" ")}/>`);
|
|
216
|
+
}
|
|
217
|
+
parts.push("</svg>");
|
|
218
|
+
return parts.join("");
|
|
219
|
+
}
|
|
220
|
+
const ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
221
|
+
/** Standard base64 with padding. */
|
|
222
|
+
export function base64(bytes) {
|
|
223
|
+
const out = [];
|
|
224
|
+
let i = 0;
|
|
225
|
+
for (; i + 2 < bytes.length; i += 3) {
|
|
226
|
+
const v = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
|
|
227
|
+
out.push(ALPHABET[v >> 18] + ALPHABET[(v >> 12) & 63] + ALPHABET[(v >> 6) & 63] + ALPHABET[v & 63]);
|
|
228
|
+
}
|
|
229
|
+
const rest = bytes.length - i;
|
|
230
|
+
if (rest === 1) {
|
|
231
|
+
const v = bytes[i] << 16;
|
|
232
|
+
out.push(`${ALPHABET[v >> 18]}${ALPHABET[(v >> 12) & 63]}==`);
|
|
233
|
+
}
|
|
234
|
+
else if (rest === 2) {
|
|
235
|
+
const v = (bytes[i] << 16) | (bytes[i + 1] << 8);
|
|
236
|
+
out.push(`${ALPHABET[v >> 18]}${ALPHABET[(v >> 12) & 63]}${ALPHABET[(v >> 6) & 63]}=`);
|
|
237
|
+
}
|
|
238
|
+
return out.join("");
|
|
239
|
+
}
|
|
240
|
+
/** The default drawn size of an image: its pixel size, at most 640 wide, keeping the ratio. */
|
|
241
|
+
export function defaultImageSize(image) {
|
|
242
|
+
if (!image)
|
|
243
|
+
return { ...UNKNOWN_IMAGE_SIZE };
|
|
244
|
+
if (image.width <= 640)
|
|
245
|
+
return { width: Math.round(image.width), height: Math.round(image.height) };
|
|
246
|
+
return { width: 640, height: Math.round((image.height * 640) / image.width) };
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"","sources":["../src/image.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C,oCAAoC;AACpC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAE/C,uFAAuF;AACvF,MAAM,CAAC,MAAM,kBAA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E,CAAE,GAAG,CAAC,CAAC;IAC5F,CAAC;IACD,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACtB,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,gBAAgB,CAAC,KAAoD;IAInF,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,GAAG,kBAAkB,EAAE,CAAC;IAC7C,IAAI,KAAK,CAAC,KAAK,IAAI,GAAG;QACpB,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;IAC9E,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;AAChF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const PACKAGE_NAME = "@meltemi/diagrams-assets";
|
|
2
|
+
export * from "./icon.js";
|
|
3
|
+
export * from "./image.js";
|
|
4
|
+
export * from "./libraries.js";
|
|
5
|
+
export * from "./lock.js";
|
|
6
|
+
export * from "./packs.js";
|
|
7
|
+
export * from "./path.js";
|
|
8
|
+
export * from "./sanitize.js";
|
|
9
|
+
export * from "./sha256.js";
|
|
10
|
+
export { decodeEntities, parseXml, type XmlElement, type XmlLimits, type XmlResult, } from "./xml.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,6BAA6B,CAAC;AAEvD,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,cAAc,EACd,QAAQ,EACR,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,SAAS,GACf,MAAM,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const PACKAGE_NAME = "@meltemi/diagrams-assets";
|
|
2
|
+
export * from "./icon.js";
|
|
3
|
+
export * from "./image.js";
|
|
4
|
+
export * from "./libraries.js";
|
|
5
|
+
export * from "./lock.js";
|
|
6
|
+
export * from "./packs.js";
|
|
7
|
+
export * from "./path.js";
|
|
8
|
+
export * from "./sanitize.js";
|
|
9
|
+
export * from "./sha256.js";
|
|
10
|
+
export { decodeEntities, parseXml, } from "./xml.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,0BAA0B,CAAC;AAEvD,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,OAAO,EACL,cAAc,EACd,QAAQ,GAIT,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { IconPack, IconRegistry } from "./packs.js";
|
|
2
|
+
/** A ready-made element of a library: its icon, its name and, when it matters, its kind. */
|
|
3
|
+
export interface LibraryItem {
|
|
4
|
+
readonly icon: string;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
readonly kind?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LibraryCategory {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly title: string;
|
|
11
|
+
/** How many elements the category holds, known before `items` is read. */
|
|
12
|
+
readonly count: number;
|
|
13
|
+
/** The elements; a pack's category reads its pack the first time. */
|
|
14
|
+
readonly items: readonly LibraryItem[];
|
|
15
|
+
}
|
|
16
|
+
/** A library of ready-made elements by category, from a file or from a pack's categories. */
|
|
17
|
+
export interface Library {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly title: string;
|
|
20
|
+
readonly categories: readonly LibraryCategory[];
|
|
21
|
+
/** Where it comes from: `built-in`, a project or plugin file, or the pack it is read from. */
|
|
22
|
+
readonly source: string;
|
|
23
|
+
}
|
|
24
|
+
export type LibraryParse = {
|
|
25
|
+
readonly ok: true;
|
|
26
|
+
readonly library: Library;
|
|
27
|
+
} | {
|
|
28
|
+
readonly ok: false;
|
|
29
|
+
readonly reason: string;
|
|
30
|
+
};
|
|
31
|
+
/** Reads a library file; the reason when it is not one. */
|
|
32
|
+
export declare function parseLibrary(text: string, source: string): LibraryParse;
|
|
33
|
+
/** The library of a pack that declares categories: one category per pack category, labelled. */
|
|
34
|
+
export declare function packLibrary(pack: IconPack): Library | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* The libraries of a document: the files first (built-in ones, then the project's and the
|
|
37
|
+
* plugins'), then one per pack of the registry that declares categories and has no file of its
|
|
38
|
+
* own, in prefix order.
|
|
39
|
+
*/
|
|
40
|
+
export declare function librariesOf(registry: IconRegistry, files: readonly Library[]): Library[];
|
|
41
|
+
/** An item found by a search, with the library and category it belongs to. */
|
|
42
|
+
export interface LibraryMatch {
|
|
43
|
+
readonly library: Library;
|
|
44
|
+
readonly category: LibraryCategory;
|
|
45
|
+
readonly item: LibraryItem;
|
|
46
|
+
}
|
|
47
|
+
/** Items whose label, icon name or pack keywords hold every word of the query, best first. */
|
|
48
|
+
export declare function searchLibraries(libraries: readonly Library[], registry: IconRegistry, query: string, limit?: number): LibraryMatch[];
|
|
49
|
+
/** The ids of the libraries built into the tool, read as `libraries/<id>.json`. */
|
|
50
|
+
export declare const BUILT_IN_LIBRARIES: readonly ["tech"];
|
|
51
|
+
/** The built-in library files, through a reader of the bundled assets. */
|
|
52
|
+
export declare function builtInLibraries(read: (path: string) => string | undefined): Library[];
|
|
53
|
+
//# sourceMappingURL=libraries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libraries.d.ts","sourceRoot":"","sources":["../src/libraries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEzD,4FAA4F;AAC5F,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,qEAAqE;IACrE,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;CACxC;AAED,6FAA6F;AAC7F,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,SAAS,eAAe,EAAE,CAAC;IAChD,8FAA8F;IAC9F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAKD,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAChD;IAAE,QAAQ,CAAC,EAA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