document-schema 7.15.1 → 7.15.2

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/dist/color.cjs CHANGED
@@ -13,12 +13,18 @@ const COLOR_BLACK = {
13
13
  };
14
14
  const HEX_DIGITS_PATTERN = /^[0-9a-fA-F]{6}$/;
15
15
  const HEX_BYTE_MAX = 255;
16
+ const HEX_RADIX = 16;
17
+ const HEX_DIGITS_PER_BYTE = 2;
18
+ function hexByteAt(digits, channel) {
19
+ const start = channel * HEX_DIGITS_PER_BYTE;
20
+ return Number.parseInt(digits.slice(start, start + HEX_DIGITS_PER_BYTE), HEX_RADIX);
21
+ }
16
22
  function rgbHexToColor(hex) {
17
23
  const digits = hex.startsWith("#") ? hex.slice(1) : hex;
18
24
  if (!HEX_DIGITS_PATTERN.test(digits)) throw new Error(`not a 6-digit hex colour: ${hex}`);
19
- const r = Number.parseInt(digits.slice(0, 2), 16);
20
- const g = Number.parseInt(digits.slice(2, 4), 16);
21
- const b = Number.parseInt(digits.slice(4, 6), 16);
25
+ const r = hexByteAt(digits, 0);
26
+ const g = hexByteAt(digits, 1);
27
+ const b = hexByteAt(digits, 2);
22
28
  return {
23
29
  r: r / HEX_BYTE_MAX,
24
30
  g: g / HEX_BYTE_MAX,
@@ -26,7 +32,7 @@ function rgbHexToColor(hex) {
26
32
  };
27
33
  }
28
34
  function toHexByte(component) {
29
- return Math.round(component * HEX_BYTE_MAX).toString(16).padStart(2, "0");
35
+ return Math.round(component * HEX_BYTE_MAX).toString(HEX_RADIX).padStart(HEX_DIGITS_PER_BYTE, "0");
30
36
  }
31
37
  function colorToRgbHex(color) {
32
38
  return `${toHexByte(color.r)}${toHexByte(color.g)}${toHexByte(color.b)}`;
package/dist/color.js CHANGED
@@ -12,12 +12,18 @@ const COLOR_BLACK = {
12
12
  };
13
13
  const HEX_DIGITS_PATTERN = /^[0-9a-fA-F]{6}$/;
14
14
  const HEX_BYTE_MAX = 255;
15
+ const HEX_RADIX = 16;
16
+ const HEX_DIGITS_PER_BYTE = 2;
17
+ function hexByteAt(digits, channel) {
18
+ const start = channel * HEX_DIGITS_PER_BYTE;
19
+ return Number.parseInt(digits.slice(start, start + HEX_DIGITS_PER_BYTE), HEX_RADIX);
20
+ }
15
21
  function rgbHexToColor(hex) {
16
22
  const digits = hex.startsWith("#") ? hex.slice(1) : hex;
17
23
  if (!HEX_DIGITS_PATTERN.test(digits)) throw new Error(`not a 6-digit hex colour: ${hex}`);
18
- const r = Number.parseInt(digits.slice(0, 2), 16);
19
- const g = Number.parseInt(digits.slice(2, 4), 16);
20
- const b = Number.parseInt(digits.slice(4, 6), 16);
24
+ const r = hexByteAt(digits, 0);
25
+ const g = hexByteAt(digits, 1);
26
+ const b = hexByteAt(digits, 2);
21
27
  return {
22
28
  r: r / HEX_BYTE_MAX,
23
29
  g: g / HEX_BYTE_MAX,
@@ -25,7 +31,7 @@ function rgbHexToColor(hex) {
25
31
  };
26
32
  }
27
33
  function toHexByte(component) {
28
- return Math.round(component * HEX_BYTE_MAX).toString(16).padStart(2, "0");
34
+ return Math.round(component * HEX_BYTE_MAX).toString(HEX_RADIX).padStart(HEX_DIGITS_PER_BYTE, "0");
29
35
  }
30
36
  function colorToRgbHex(color) {
31
37
  return `${toHexByte(color.r)}${toHexByte(color.g)}${toHexByte(color.b)}`;
package/dist/content.cjs CHANGED
@@ -120,8 +120,9 @@ const ContentParagraphSchema = zod.z.object({
120
120
  frames: zod.z.array(require_geometry.LayoutFrameSchema).optional(),
121
121
  ...CONTENT_ANNOTATION_FIELDS
122
122
  });
123
+ const MAX_HEADING_LEVEL = 6;
123
124
  function clampHeadingLevel(level) {
124
- return Math.min(6, Math.max(1, Math.round(level)));
125
+ return Math.min(MAX_HEADING_LEVEL, Math.max(1, Math.round(level)));
125
126
  }
126
127
  const ContentFloatOriginSchema = zod.z.enum([
127
128
  "page",
@@ -647,6 +648,8 @@ const ContentSheetConditionalFormatValueSchema = zod.z.object({
647
648
  type: cfvoTypeSchema,
648
649
  value: zod.z.string().optional()
649
650
  });
651
+ const MIN_COLOR_SCALE_STOPS = 2;
652
+ const MAX_COLOR_SCALE_STOPS = 3;
650
653
  const conditionalFormatCommonFields = {
651
654
  ranges: zod.z.array(ContentSheetRangeSchema),
652
655
  priority: zod.z.number().int().optional(),
@@ -727,7 +730,7 @@ const ContentSheetConditionalFormatSchema = zod.z.discriminatedUnion("type", [
727
730
  stops: zod.z.array(zod.z.object({
728
731
  value: ContentSheetConditionalFormatValueSchema,
729
732
  color: require_color.ColorSchema
730
- })).min(2).max(3)
733
+ })).min(MIN_COLOR_SCALE_STOPS).max(MAX_COLOR_SCALE_STOPS)
731
734
  }),
732
735
  zod.z.object({
733
736
  type: zod.z.literal("dataBar"),
package/dist/content.js CHANGED
@@ -119,8 +119,9 @@ const ContentParagraphSchema = z.object({
119
119
  frames: z.array(LayoutFrameSchema).optional(),
120
120
  ...CONTENT_ANNOTATION_FIELDS
121
121
  });
122
+ const MAX_HEADING_LEVEL = 6;
122
123
  function clampHeadingLevel(level) {
123
- return Math.min(6, Math.max(1, Math.round(level)));
124
+ return Math.min(MAX_HEADING_LEVEL, Math.max(1, Math.round(level)));
124
125
  }
125
126
  const ContentFloatOriginSchema = z.enum([
126
127
  "page",
@@ -646,6 +647,8 @@ const ContentSheetConditionalFormatValueSchema = z.object({
646
647
  type: cfvoTypeSchema,
647
648
  value: z.string().optional()
648
649
  });
650
+ const MIN_COLOR_SCALE_STOPS = 2;
651
+ const MAX_COLOR_SCALE_STOPS = 3;
649
652
  const conditionalFormatCommonFields = {
650
653
  ranges: z.array(ContentSheetRangeSchema),
651
654
  priority: z.number().int().optional(),
@@ -726,7 +729,7 @@ const ContentSheetConditionalFormatSchema = z.discriminatedUnion("type", [
726
729
  stops: z.array(z.object({
727
730
  value: ContentSheetConditionalFormatValueSchema,
728
731
  color: ColorSchema
729
- })).min(2).max(3)
732
+ })).min(MIN_COLOR_SCALE_STOPS).max(MAX_COLOR_SCALE_STOPS)
730
733
  }),
731
734
  z.object({
732
735
  type: z.literal("dataBar"),
@@ -7,7 +7,7 @@ const SCHEMA_FILE_NAMES = {
7
7
  ContentDocument: "content-document.schema.json"
8
8
  };
9
9
  function schemaUriFor(kind) {
10
- return `https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/${SCHEMA_FILE_NAMES[kind]}`;
10
+ return `https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/${SCHEMA_FILE_NAMES[kind]}`;
11
11
  }
12
12
  const SCHEMA_URI_PATTERN = /^https:\/\/cdn\.jsdelivr\.net\/npm\/document-schema\.js@([^/]+)\/schemas\/(document-tree|document-package|content-document|layout-document)\.schema\.json$/;
13
13
  function parseSchemaUri(uri) {
@@ -102,7 +102,7 @@ function documentFromJson(value) {
102
102
  if (parts.stem === "document-package") throw new DocumentPackageRenamedError(value.$schema);
103
103
  const kind = kindForFileStem(parts.stem);
104
104
  if (kind === void 0) throw new UnrecognizedDocumentSchemaError(value.$schema);
105
- if (majorVersionOf(parts.version) !== majorVersionOf("7.15.1")) throw new SchemaVersionMismatchError(value.$schema, parts.version, "7.15.1");
105
+ if (majorVersionOf(parts.version) !== majorVersionOf("7.15.2")) throw new SchemaVersionMismatchError(value.$schema, parts.version, "7.15.2");
106
106
  switch (kind) {
107
107
  case "DocumentTree": return {
108
108
  kind,
package/dist/schema-io.js CHANGED
@@ -6,7 +6,7 @@ const SCHEMA_FILE_NAMES = {
6
6
  ContentDocument: "content-document.schema.json"
7
7
  };
8
8
  function schemaUriFor(kind) {
9
- return `https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/${SCHEMA_FILE_NAMES[kind]}`;
9
+ return `https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/${SCHEMA_FILE_NAMES[kind]}`;
10
10
  }
11
11
  const SCHEMA_URI_PATTERN = /^https:\/\/cdn\.jsdelivr\.net\/npm\/document-schema\.js@([^/]+)\/schemas\/(document-tree|document-package|content-document|layout-document)\.schema\.json$/;
12
12
  function parseSchemaUri(uri) {
@@ -101,7 +101,7 @@ function documentFromJson(value) {
101
101
  if (parts.stem === "document-package") throw new DocumentPackageRenamedError(value.$schema);
102
102
  const kind = kindForFileStem(parts.stem);
103
103
  if (kind === void 0) throw new UnrecognizedDocumentSchemaError(value.$schema);
104
- if (majorVersionOf(parts.version) !== majorVersionOf("7.15.1")) throw new SchemaVersionMismatchError(value.$schema, parts.version, "7.15.1");
104
+ if (majorVersionOf(parts.version) !== majorVersionOf("7.15.2")) throw new SchemaVersionMismatchError(value.$schema, parts.version, "7.15.2");
105
105
  switch (kind) {
106
106
  case "DocumentTree": return {
107
107
  kind,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document-schema",
3
- "version": "7.15.1",
3
+ "version": "7.15.2",
4
4
  "description": "The canonical, format-agnostic content and document-tree schemas shared by ooxml.js, odf.js, documents.js, pdf-codec, and markdown-codec, plus the structural transform between them — no format-specific or I/O behaviour.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/content-document.schema.json",
3
+ "$id": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/content-document.schema.json",
4
4
  "oneOf": [
5
5
  {
6
6
  "type": "object",
@@ -133,7 +133,7 @@
133
133
  "blocks": {
134
134
  "type": "array",
135
135
  "items": {
136
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/undefined#/$defs/schema2"
136
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/undefined#/$defs/schema2"
137
137
  }
138
138
  },
139
139
  "breakType": {
@@ -151,19 +151,19 @@
151
151
  "default": {
152
152
  "type": "array",
153
153
  "items": {
154
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/undefined#/$defs/schema2"
154
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/undefined#/$defs/schema2"
155
155
  }
156
156
  },
157
157
  "even": {
158
158
  "type": "array",
159
159
  "items": {
160
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/undefined#/$defs/schema2"
160
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/undefined#/$defs/schema2"
161
161
  }
162
162
  },
163
163
  "first": {
164
164
  "type": "array",
165
165
  "items": {
166
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/undefined#/$defs/schema2"
166
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/undefined#/$defs/schema2"
167
167
  }
168
168
  }
169
169
  },
@@ -175,19 +175,19 @@
175
175
  "default": {
176
176
  "type": "array",
177
177
  "items": {
178
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/undefined#/$defs/schema2"
178
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/undefined#/$defs/schema2"
179
179
  }
180
180
  },
181
181
  "even": {
182
182
  "type": "array",
183
183
  "items": {
184
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/undefined#/$defs/schema2"
184
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/undefined#/$defs/schema2"
185
185
  }
186
186
  },
187
187
  "first": {
188
188
  "type": "array",
189
189
  "items": {
190
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/undefined#/$defs/schema2"
190
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/undefined#/$defs/schema2"
191
191
  }
192
192
  }
193
193
  },
@@ -199,19 +199,19 @@
199
199
  "default": {
200
200
  "type": "array",
201
201
  "items": {
202
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/undefined#/$defs/schema2"
202
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/undefined#/$defs/schema2"
203
203
  }
204
204
  },
205
205
  "even": {
206
206
  "type": "array",
207
207
  "items": {
208
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/undefined#/$defs/schema2"
208
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/undefined#/$defs/schema2"
209
209
  }
210
210
  },
211
211
  "first": {
212
212
  "type": "array",
213
213
  "items": {
214
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/undefined#/$defs/schema2"
214
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/undefined#/$defs/schema2"
215
215
  }
216
216
  }
217
217
  },
@@ -638,7 +638,7 @@
638
638
  "blocks": {
639
639
  "type": "array",
640
640
  "items": {
641
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/undefined#/$defs/schema2"
641
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/undefined#/$defs/schema2"
642
642
  }
643
643
  }
644
644
  },
@@ -2659,7 +2659,7 @@
2659
2659
  ]
2660
2660
  },
2661
2661
  "document": {
2662
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/content-document.schema.json"
2662
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/content-document.schema.json"
2663
2663
  },
2664
2664
  "frame": {
2665
2665
  "type": "object",
@@ -5021,7 +5021,7 @@
5021
5021
  "blocks": {
5022
5022
  "type": "array",
5023
5023
  "items": {
5024
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/undefined#/$defs/schema2"
5024
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/undefined#/$defs/schema2"
5025
5025
  }
5026
5026
  }
5027
5027
  },
@@ -8045,7 +8045,7 @@
8045
8045
  ]
8046
8046
  },
8047
8047
  "document": {
8048
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/content-document.schema.json"
8048
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/content-document.schema.json"
8049
8049
  },
8050
8050
  "frame": {
8051
8051
  "$ref": "#/$defs/Box"
@@ -10371,7 +10371,7 @@
10371
10371
  ]
10372
10372
  },
10373
10373
  "document": {
10374
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/content-document.schema.json"
10374
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/content-document.schema.json"
10375
10375
  },
10376
10376
  "frame": {
10377
10377
  "$ref": "#/$defs/Box"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/document-tree.schema.json",
3
+ "$id": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/document-tree.schema.json",
4
4
  "oneOf": [
5
5
  {
6
6
  "type": "object",
@@ -2011,7 +2011,7 @@
2011
2011
  ]
2012
2012
  },
2013
2013
  "document": {
2014
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/content-document.schema.json"
2014
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/content-document.schema.json"
2015
2015
  },
2016
2016
  "frame": {
2017
2017
  "$ref": "#/$defs/Box"
@@ -4337,7 +4337,7 @@
4337
4337
  ]
4338
4338
  },
4339
4339
  "document": {
4340
- "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.1/schemas/content-document.schema.json"
4340
+ "$ref": "https://cdn.jsdelivr.net/npm/document-schema.js@7.15.2/schemas/content-document.schema.json"
4341
4341
  },
4342
4342
  "frame": {
4343
4343
  "$ref": "#/$defs/Box"