create-nextjs-cms 0.5.21 → 0.5.23

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.
Files changed (137) hide show
  1. package/package.json +6 -6
  2. package/templates/default/_gitignore +1 -1
  3. package/templates/default/app/(auth)/auth/login/LoginPage.tsx +5 -5
  4. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/LICENSE +191 -0
  5. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/README.md +118 -0
  6. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/install/build.js +38 -0
  7. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/install/check.js +14 -0
  8. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/lib/channel.js +177 -0
  9. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/lib/colour.js +195 -0
  10. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/lib/composite.js +212 -0
  11. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/lib/constructor.js +499 -0
  12. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/lib/index.d.ts +1971 -0
  13. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/lib/index.js +16 -0
  14. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/lib/input.js +809 -0
  15. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/lib/is.js +143 -0
  16. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/lib/libvips.js +207 -0
  17. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/lib/operation.js +1016 -0
  18. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/lib/output.js +1666 -0
  19. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/lib/resize.js +595 -0
  20. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/lib/sharp.js +121 -0
  21. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/lib/utility.js +291 -0
  22. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/package.json +202 -0
  23. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/src/binding.gyp +298 -0
  24. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/src/common.cc +1130 -0
  25. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/src/common.h +402 -0
  26. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/src/metadata.cc +346 -0
  27. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/src/metadata.h +90 -0
  28. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/src/operations.cc +499 -0
  29. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/src/operations.h +137 -0
  30. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/src/pipeline.cc +1814 -0
  31. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/src/pipeline.h +408 -0
  32. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/src/sharp.cc +43 -0
  33. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/src/stats.cc +186 -0
  34. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/src/stats.h +62 -0
  35. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/src/utilities.cc +288 -0
  36. package/templates/default/apps/cms/node_modules/next/node_modules/sharp/src/utilities.h +22 -0
  37. package/templates/default/apps/cms/node_modules/sharp/LICENSE +191 -0
  38. package/templates/default/apps/cms/node_modules/sharp/README.md +118 -0
  39. package/templates/default/apps/cms/node_modules/sharp/install/check.js +41 -0
  40. package/templates/default/apps/cms/node_modules/sharp/lib/channel.js +174 -0
  41. package/templates/default/apps/cms/node_modules/sharp/lib/colour.js +180 -0
  42. package/templates/default/apps/cms/node_modules/sharp/lib/composite.js +210 -0
  43. package/templates/default/apps/cms/node_modules/sharp/lib/constructor.js +452 -0
  44. package/templates/default/apps/cms/node_modules/sharp/lib/index.d.ts +1754 -0
  45. package/templates/default/apps/cms/node_modules/sharp/lib/index.js +16 -0
  46. package/templates/default/apps/cms/node_modules/sharp/lib/input.js +658 -0
  47. package/templates/default/apps/cms/node_modules/sharp/lib/is.js +169 -0
  48. package/templates/default/apps/cms/node_modules/sharp/lib/libvips.js +203 -0
  49. package/templates/default/apps/cms/node_modules/sharp/lib/operation.js +958 -0
  50. package/templates/default/apps/cms/node_modules/sharp/lib/output.js +1587 -0
  51. package/templates/default/apps/cms/node_modules/sharp/lib/resize.js +587 -0
  52. package/templates/default/apps/cms/node_modules/sharp/lib/sharp.js +114 -0
  53. package/templates/default/apps/cms/node_modules/sharp/lib/utility.js +296 -0
  54. package/templates/default/apps/cms/node_modules/sharp/package.json +222 -0
  55. package/templates/default/apps/cms/node_modules/sharp/src/binding.gyp +280 -0
  56. package/templates/default/apps/cms/node_modules/sharp/src/common.cc +1091 -0
  57. package/templates/default/apps/cms/node_modules/sharp/src/common.h +393 -0
  58. package/templates/default/apps/cms/node_modules/sharp/src/metadata.cc +320 -0
  59. package/templates/default/apps/cms/node_modules/sharp/src/metadata.h +85 -0
  60. package/templates/default/apps/cms/node_modules/sharp/src/operations.cc +475 -0
  61. package/templates/default/apps/cms/node_modules/sharp/src/operations.h +125 -0
  62. package/templates/default/apps/cms/node_modules/sharp/src/pipeline.cc +1758 -0
  63. package/templates/default/apps/cms/node_modules/sharp/src/pipeline.h +393 -0
  64. package/templates/default/apps/cms/node_modules/sharp/src/sharp.cc +40 -0
  65. package/templates/default/apps/cms/node_modules/sharp/src/stats.cc +183 -0
  66. package/templates/default/apps/cms/node_modules/sharp/src/stats.h +59 -0
  67. package/templates/default/apps/cms/node_modules/sharp/src/utilities.cc +269 -0
  68. package/templates/default/apps/cms/node_modules/sharp/src/utilities.h +19 -0
  69. package/templates/default/components/AdminCard.tsx +1 -1
  70. package/templates/default/components/AdminsPage.tsx +1 -1
  71. package/templates/default/components/AdvancedSettingsPage.tsx +1 -1
  72. package/templates/default/components/AnalyticsPage.tsx +1 -1
  73. package/templates/default/components/BrowsePage.tsx +2 -2
  74. package/templates/default/components/CategorizedSectionPage.tsx +3 -3
  75. package/templates/default/components/CategoryDeleteConfirmPage.tsx +4 -4
  76. package/templates/default/components/CategorySectionSelectInput.tsx +1 -1
  77. package/templates/default/components/ContainerBox.tsx +1 -1
  78. package/templates/default/components/DashboardPage.tsx +1 -1
  79. package/templates/default/components/EmailCard.tsx +1 -1
  80. package/templates/default/components/EmailPasswordForm.tsx +2 -2
  81. package/templates/default/components/EmailQuotaForm.tsx +1 -1
  82. package/templates/default/components/EmailsPage.tsx +1 -1
  83. package/templates/default/components/GalleryPhoto.tsx +1 -1
  84. package/templates/default/components/ItemEditPage.tsx +2 -2
  85. package/templates/default/components/Layout.tsx +1 -1
  86. package/templates/default/components/LogPage.tsx +1 -1
  87. package/templates/default/components/Navbar.tsx +2 -2
  88. package/templates/default/components/NavbarAlt.tsx +6 -6
  89. package/templates/default/components/NewAdminForm.tsx +2 -2
  90. package/templates/default/components/NewEmailForm.tsx +3 -3
  91. package/templates/default/components/NewPage.tsx +2 -2
  92. package/templates/default/components/NewVariantComponent.tsx +1 -1
  93. package/templates/default/components/SectionItemCard.tsx +1 -1
  94. package/templates/default/components/SectionItemStatusBadge.tsx +1 -1
  95. package/templates/default/components/SectionPage.tsx +2 -2
  96. package/templates/default/components/SelectBox.tsx +2 -2
  97. package/templates/default/components/SettingsPage.tsx +1 -1
  98. package/templates/default/components/Sidebar.tsx +3 -3
  99. package/templates/default/components/VariantEditPage.tsx +2 -2
  100. package/templates/default/components/form/Form.tsx +1 -1
  101. package/templates/default/components/form/FormInputElement.tsx +1 -1
  102. package/templates/default/components/form/helpers/{_section-hot-reload.ts → _section-hot-reload.js} +1 -1
  103. package/templates/default/components/form/helpers/util.ts +1 -1
  104. package/templates/default/components/form/inputs/ColorFormInput.tsx +1 -1
  105. package/templates/default/components/form/inputs/DateFormInput.tsx +1 -1
  106. package/templates/default/components/form/inputs/DocumentFormInput.tsx +3 -3
  107. package/templates/default/components/form/inputs/NumberFormInput.tsx +1 -1
  108. package/templates/default/components/form/inputs/PasswordFormInput.tsx +1 -1
  109. package/templates/default/components/form/inputs/PhotoFormInput.tsx +4 -4
  110. package/templates/default/components/form/inputs/SelectFormInput.tsx +1 -1
  111. package/templates/default/components/form/inputs/TagsFormInput.tsx +1 -1
  112. package/templates/default/components/form/inputs/TextFormInput.tsx +1 -1
  113. package/templates/default/components/form/inputs/TextareaFormInput.tsx +1 -1
  114. package/templates/default/components/form/inputs/VideoFormInput.tsx +3 -3
  115. package/templates/default/components/ui/badge.tsx +6 -6
  116. package/templates/default/components/ui/button.tsx +5 -5
  117. package/templates/default/components/ui/card.tsx +1 -1
  118. package/templates/default/components/ui/checkbox.tsx +1 -1
  119. package/templates/default/components/ui/dropdown-menu.tsx +6 -6
  120. package/templates/default/components/ui/input.tsx +1 -1
  121. package/templates/default/components/ui/popover.tsx +1 -1
  122. package/templates/default/components/ui/scroll-area.tsx +2 -2
  123. package/templates/default/components/ui/select.tsx +4 -4
  124. package/templates/default/components/ui/sheet.tsx +1 -1
  125. package/templates/default/components/ui/switch.tsx +1 -1
  126. package/templates/default/components/ui/table.tsx +3 -3
  127. package/templates/default/components/ui/tabs.tsx +2 -2
  128. package/templates/default/components/ui/toast.tsx +4 -4
  129. package/templates/default/eslint.config.mjs +38 -0
  130. package/templates/default/next-env.d.ts +1 -1
  131. package/templates/default/package.json +24 -33
  132. package/templates/default/postcss.config.mjs +7 -0
  133. package/templates/default/{middleware.ts → proxy.ts} +2 -3
  134. package/templates/default/styles/globals.css +107 -4
  135. package/templates/default/tsconfig.json +45 -44
  136. package/templates/default/postcss.config.js +0 -6
  137. package/templates/default/tailwind.config.js +0 -95
@@ -0,0 +1,174 @@
1
+ // Copyright 2013 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ 'use strict';
5
+
6
+ const is = require('./is');
7
+
8
+ /**
9
+ * Boolean operations for bandbool.
10
+ * @private
11
+ */
12
+ const bool = {
13
+ and: 'and',
14
+ or: 'or',
15
+ eor: 'eor'
16
+ };
17
+
18
+ /**
19
+ * Remove alpha channel, if any. This is a no-op if the image does not have an alpha channel.
20
+ *
21
+ * See also {@link /api-operation#flatten|flatten}.
22
+ *
23
+ * @example
24
+ * sharp('rgba.png')
25
+ * .removeAlpha()
26
+ * .toFile('rgb.png', function(err, info) {
27
+ * // rgb.png is a 3 channel image without an alpha channel
28
+ * });
29
+ *
30
+ * @returns {Sharp}
31
+ */
32
+ function removeAlpha () {
33
+ this.options.removeAlpha = true;
34
+ return this;
35
+ }
36
+
37
+ /**
38
+ * Ensure the output image has an alpha transparency channel.
39
+ * If missing, the added alpha channel will have the specified
40
+ * transparency level, defaulting to fully-opaque (1).
41
+ * This is a no-op if the image already has an alpha channel.
42
+ *
43
+ * @since 0.21.2
44
+ *
45
+ * @example
46
+ * // rgba.png will be a 4 channel image with a fully-opaque alpha channel
47
+ * await sharp('rgb.jpg')
48
+ * .ensureAlpha()
49
+ * .toFile('rgba.png')
50
+ *
51
+ * @example
52
+ * // rgba is a 4 channel image with a fully-transparent alpha channel
53
+ * const rgba = await sharp(rgb)
54
+ * .ensureAlpha(0)
55
+ * .toBuffer();
56
+ *
57
+ * @param {number} [alpha=1] - alpha transparency level (0=fully-transparent, 1=fully-opaque)
58
+ * @returns {Sharp}
59
+ * @throws {Error} Invalid alpha transparency level
60
+ */
61
+ function ensureAlpha (alpha) {
62
+ if (is.defined(alpha)) {
63
+ if (is.number(alpha) && is.inRange(alpha, 0, 1)) {
64
+ this.options.ensureAlpha = alpha;
65
+ } else {
66
+ throw is.invalidParameterError('alpha', 'number between 0 and 1', alpha);
67
+ }
68
+ } else {
69
+ this.options.ensureAlpha = 1;
70
+ }
71
+ return this;
72
+ }
73
+
74
+ /**
75
+ * Extract a single channel from a multi-channel image.
76
+ *
77
+ * @example
78
+ * // green.jpg is a greyscale image containing the green channel of the input
79
+ * await sharp(input)
80
+ * .extractChannel('green')
81
+ * .toFile('green.jpg');
82
+ *
83
+ * @example
84
+ * // red1 is the red value of the first pixel, red2 the second pixel etc.
85
+ * const [red1, red2, ...] = await sharp(input)
86
+ * .extractChannel(0)
87
+ * .raw()
88
+ * .toBuffer();
89
+ *
90
+ * @param {number|string} channel - zero-indexed channel/band number to extract, or `red`, `green`, `blue` or `alpha`.
91
+ * @returns {Sharp}
92
+ * @throws {Error} Invalid channel
93
+ */
94
+ function extractChannel (channel) {
95
+ const channelMap = { red: 0, green: 1, blue: 2, alpha: 3 };
96
+ if (Object.keys(channelMap).includes(channel)) {
97
+ channel = channelMap[channel];
98
+ }
99
+ if (is.integer(channel) && is.inRange(channel, 0, 4)) {
100
+ this.options.extractChannel = channel;
101
+ } else {
102
+ throw is.invalidParameterError('channel', 'integer or one of: red, green, blue, alpha', channel);
103
+ }
104
+ return this;
105
+ }
106
+
107
+ /**
108
+ * Join one or more channels to the image.
109
+ * The meaning of the added channels depends on the output colourspace, set with `toColourspace()`.
110
+ * By default the output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.
111
+ * Channel ordering follows vips convention:
112
+ * - sRGB: 0: Red, 1: Green, 2: Blue, 3: Alpha.
113
+ * - CMYK: 0: Magenta, 1: Cyan, 2: Yellow, 3: Black, 4: Alpha.
114
+ *
115
+ * Buffers may be any of the image formats supported by sharp.
116
+ * For raw pixel input, the `options` object should contain a `raw` attribute, which follows the format of the attribute of the same name in the `sharp()` constructor.
117
+ *
118
+ * @param {Array<string|Buffer>|string|Buffer} images - one or more images (file paths, Buffers).
119
+ * @param {Object} options - image options, see `sharp()` constructor.
120
+ * @returns {Sharp}
121
+ * @throws {Error} Invalid parameters
122
+ */
123
+ function joinChannel (images, options) {
124
+ if (Array.isArray(images)) {
125
+ images.forEach(function (image) {
126
+ this.options.joinChannelIn.push(this._createInputDescriptor(image, options));
127
+ }, this);
128
+ } else {
129
+ this.options.joinChannelIn.push(this._createInputDescriptor(images, options));
130
+ }
131
+ return this;
132
+ }
133
+
134
+ /**
135
+ * Perform a bitwise boolean operation on all input image channels (bands) to produce a single channel output image.
136
+ *
137
+ * @example
138
+ * sharp('3-channel-rgb-input.png')
139
+ * .bandbool(sharp.bool.and)
140
+ * .toFile('1-channel-output.png', function (err, info) {
141
+ * // The output will be a single channel image where each pixel `P = R & G & B`.
142
+ * // If `I(1,1) = [247, 170, 14] = [0b11110111, 0b10101010, 0b00001111]`
143
+ * // then `O(1,1) = 0b11110111 & 0b10101010 & 0b00001111 = 0b00000010 = 2`.
144
+ * });
145
+ *
146
+ * @param {string} boolOp - one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively.
147
+ * @returns {Sharp}
148
+ * @throws {Error} Invalid parameters
149
+ */
150
+ function bandbool (boolOp) {
151
+ if (is.string(boolOp) && is.inArray(boolOp, ['and', 'or', 'eor'])) {
152
+ this.options.bandBoolOp = boolOp;
153
+ } else {
154
+ throw is.invalidParameterError('boolOp', 'one of: and, or, eor', boolOp);
155
+ }
156
+ return this;
157
+ }
158
+
159
+ /**
160
+ * Decorate the Sharp prototype with channel-related functions.
161
+ * @private
162
+ */
163
+ module.exports = function (Sharp) {
164
+ Object.assign(Sharp.prototype, {
165
+ // Public instance functions
166
+ removeAlpha,
167
+ ensureAlpha,
168
+ extractChannel,
169
+ joinChannel,
170
+ bandbool
171
+ });
172
+ // Class attributes
173
+ Sharp.bool = bool;
174
+ };
@@ -0,0 +1,180 @@
1
+ // Copyright 2013 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ 'use strict';
5
+
6
+ const color = require('color');
7
+ const is = require('./is');
8
+
9
+ /**
10
+ * Colourspaces.
11
+ * @private
12
+ */
13
+ const colourspace = {
14
+ multiband: 'multiband',
15
+ 'b-w': 'b-w',
16
+ bw: 'b-w',
17
+ cmyk: 'cmyk',
18
+ srgb: 'srgb'
19
+ };
20
+
21
+ /**
22
+ * Tint the image using the provided colour.
23
+ * An alpha channel may be present and will be unchanged by the operation.
24
+ *
25
+ * @example
26
+ * const output = await sharp(input)
27
+ * .tint({ r: 255, g: 240, b: 16 })
28
+ * .toBuffer();
29
+ *
30
+ * @param {string|Object} tint - Parsed by the [color](https://www.npmjs.org/package/color) module.
31
+ * @returns {Sharp}
32
+ * @throws {Error} Invalid parameter
33
+ */
34
+ function tint (tint) {
35
+ this._setBackgroundColourOption('tint', tint);
36
+ return this;
37
+ }
38
+
39
+ /**
40
+ * Convert to 8-bit greyscale; 256 shades of grey.
41
+ * This is a linear operation. If the input image is in a non-linear colour space such as sRGB, use `gamma()` with `greyscale()` for the best results.
42
+ * By default the output image will be web-friendly sRGB and contain three (identical) color channels.
43
+ * This may be overridden by other sharp operations such as `toColourspace('b-w')`,
44
+ * which will produce an output image containing one color channel.
45
+ * An alpha channel may be present, and will be unchanged by the operation.
46
+ *
47
+ * @example
48
+ * const output = await sharp(input).greyscale().toBuffer();
49
+ *
50
+ * @param {Boolean} [greyscale=true]
51
+ * @returns {Sharp}
52
+ */
53
+ function greyscale (greyscale) {
54
+ this.options.greyscale = is.bool(greyscale) ? greyscale : true;
55
+ return this;
56
+ }
57
+
58
+ /**
59
+ * Alternative spelling of `greyscale`.
60
+ * @param {Boolean} [grayscale=true]
61
+ * @returns {Sharp}
62
+ */
63
+ function grayscale (grayscale) {
64
+ return this.greyscale(grayscale);
65
+ }
66
+
67
+ /**
68
+ * Set the pipeline colourspace.
69
+ *
70
+ * The input image will be converted to the provided colourspace at the start of the pipeline.
71
+ * All operations will use this colourspace before converting to the output colourspace,
72
+ * as defined by {@link #tocolourspace|toColourspace}.
73
+ *
74
+ * @since 0.29.0
75
+ *
76
+ * @example
77
+ * // Run pipeline in 16 bits per channel RGB while converting final result to 8 bits per channel sRGB.
78
+ * await sharp(input)
79
+ * .pipelineColourspace('rgb16')
80
+ * .toColourspace('srgb')
81
+ * .toFile('16bpc-pipeline-to-8bpc-output.png')
82
+ *
83
+ * @param {string} [colourspace] - pipeline colourspace e.g. `rgb16`, `scrgb`, `lab`, `grey16` [...](https://github.com/libvips/libvips/blob/41cff4e9d0838498487a00623462204eb10ee5b8/libvips/iofuncs/enumtypes.c#L774)
84
+ * @returns {Sharp}
85
+ * @throws {Error} Invalid parameters
86
+ */
87
+ function pipelineColourspace (colourspace) {
88
+ if (!is.string(colourspace)) {
89
+ throw is.invalidParameterError('colourspace', 'string', colourspace);
90
+ }
91
+ this.options.colourspacePipeline = colourspace;
92
+ return this;
93
+ }
94
+
95
+ /**
96
+ * Alternative spelling of `pipelineColourspace`.
97
+ * @param {string} [colorspace] - pipeline colorspace.
98
+ * @returns {Sharp}
99
+ * @throws {Error} Invalid parameters
100
+ */
101
+ function pipelineColorspace (colorspace) {
102
+ return this.pipelineColourspace(colorspace);
103
+ }
104
+
105
+ /**
106
+ * Set the output colourspace.
107
+ * By default output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.
108
+ *
109
+ * @example
110
+ * // Output 16 bits per pixel RGB
111
+ * await sharp(input)
112
+ * .toColourspace('rgb16')
113
+ * .toFile('16-bpp.png')
114
+ *
115
+ * @param {string} [colourspace] - output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://github.com/libvips/libvips/blob/3c0bfdf74ce1dc37a6429bed47fa76f16e2cd70a/libvips/iofuncs/enumtypes.c#L777-L794)
116
+ * @returns {Sharp}
117
+ * @throws {Error} Invalid parameters
118
+ */
119
+ function toColourspace (colourspace) {
120
+ if (!is.string(colourspace)) {
121
+ throw is.invalidParameterError('colourspace', 'string', colourspace);
122
+ }
123
+ this.options.colourspace = colourspace;
124
+ return this;
125
+ }
126
+
127
+ /**
128
+ * Alternative spelling of `toColourspace`.
129
+ * @param {string} [colorspace] - output colorspace.
130
+ * @returns {Sharp}
131
+ * @throws {Error} Invalid parameters
132
+ */
133
+ function toColorspace (colorspace) {
134
+ return this.toColourspace(colorspace);
135
+ }
136
+
137
+ /**
138
+ * Update a colour attribute of the this.options Object.
139
+ * @private
140
+ * @param {string} key
141
+ * @param {string|Object} value
142
+ * @throws {Error} Invalid value
143
+ */
144
+ function _setBackgroundColourOption (key, value) {
145
+ if (is.defined(value)) {
146
+ if (is.object(value) || is.string(value)) {
147
+ const colour = color(value);
148
+ this.options[key] = [
149
+ colour.red(),
150
+ colour.green(),
151
+ colour.blue(),
152
+ Math.round(colour.alpha() * 255)
153
+ ];
154
+ } else {
155
+ throw is.invalidParameterError('background', 'object or string', value);
156
+ }
157
+ }
158
+ }
159
+
160
+ /**
161
+ * Decorate the Sharp prototype with colour-related functions.
162
+ * @private
163
+ */
164
+ module.exports = function (Sharp) {
165
+ Object.assign(Sharp.prototype, {
166
+ // Public
167
+ tint,
168
+ greyscale,
169
+ grayscale,
170
+ pipelineColourspace,
171
+ pipelineColorspace,
172
+ toColourspace,
173
+ toColorspace,
174
+ // Private
175
+ _setBackgroundColourOption
176
+ });
177
+ // Class attributes
178
+ Sharp.colourspace = colourspace;
179
+ Sharp.colorspace = colourspace;
180
+ };
@@ -0,0 +1,210 @@
1
+ // Copyright 2013 Lovell Fuller and others.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ 'use strict';
5
+
6
+ const is = require('./is');
7
+
8
+ /**
9
+ * Blend modes.
10
+ * @member
11
+ * @private
12
+ */
13
+ const blend = {
14
+ clear: 'clear',
15
+ source: 'source',
16
+ over: 'over',
17
+ in: 'in',
18
+ out: 'out',
19
+ atop: 'atop',
20
+ dest: 'dest',
21
+ 'dest-over': 'dest-over',
22
+ 'dest-in': 'dest-in',
23
+ 'dest-out': 'dest-out',
24
+ 'dest-atop': 'dest-atop',
25
+ xor: 'xor',
26
+ add: 'add',
27
+ saturate: 'saturate',
28
+ multiply: 'multiply',
29
+ screen: 'screen',
30
+ overlay: 'overlay',
31
+ darken: 'darken',
32
+ lighten: 'lighten',
33
+ 'colour-dodge': 'colour-dodge',
34
+ 'color-dodge': 'colour-dodge',
35
+ 'colour-burn': 'colour-burn',
36
+ 'color-burn': 'colour-burn',
37
+ 'hard-light': 'hard-light',
38
+ 'soft-light': 'soft-light',
39
+ difference: 'difference',
40
+ exclusion: 'exclusion'
41
+ };
42
+
43
+ /**
44
+ * Composite image(s) over the processed (resized, extracted etc.) image.
45
+ *
46
+ * The images to composite must be the same size or smaller than the processed image.
47
+ * If both `top` and `left` options are provided, they take precedence over `gravity`.
48
+ *
49
+ * Any resize, rotate or extract operations in the same processing pipeline
50
+ * will always be applied to the input image before composition.
51
+ *
52
+ * The `blend` option can be one of `clear`, `source`, `over`, `in`, `out`, `atop`,
53
+ * `dest`, `dest-over`, `dest-in`, `dest-out`, `dest-atop`,
54
+ * `xor`, `add`, `saturate`, `multiply`, `screen`, `overlay`, `darken`, `lighten`,
55
+ * `colour-dodge`, `color-dodge`, `colour-burn`,`color-burn`,
56
+ * `hard-light`, `soft-light`, `difference`, `exclusion`.
57
+ *
58
+ * More information about blend modes can be found at
59
+ * https://www.libvips.org/API/current/libvips-conversion.html#VipsBlendMode
60
+ * and https://www.cairographics.org/operators/
61
+ *
62
+ * @since 0.22.0
63
+ *
64
+ * @example
65
+ * await sharp(background)
66
+ * .composite([
67
+ * { input: layer1, gravity: 'northwest' },
68
+ * { input: layer2, gravity: 'southeast' },
69
+ * ])
70
+ * .toFile('combined.png');
71
+ *
72
+ * @example
73
+ * const output = await sharp('input.gif', { animated: true })
74
+ * .composite([
75
+ * { input: 'overlay.png', tile: true, blend: 'saturate' }
76
+ * ])
77
+ * .toBuffer();
78
+ *
79
+ * @example
80
+ * sharp('input.png')
81
+ * .rotate(180)
82
+ * .resize(300)
83
+ * .flatten( { background: '#ff6600' } )
84
+ * .composite([{ input: 'overlay.png', gravity: 'southeast' }])
85
+ * .sharpen()
86
+ * .withMetadata()
87
+ * .webp( { quality: 90 } )
88
+ * .toBuffer()
89
+ * .then(function(outputBuffer) {
90
+ * // outputBuffer contains upside down, 300px wide, alpha channel flattened
91
+ * // onto orange background, composited with overlay.png with SE gravity,
92
+ * // sharpened, with metadata, 90% quality WebP image data. Phew!
93
+ * });
94
+ *
95
+ * @param {Object[]} images - Ordered list of images to composite
96
+ * @param {Buffer|String} [images[].input] - Buffer containing image data, String containing the path to an image file, or Create object (see below)
97
+ * @param {Object} [images[].input.create] - describes a blank overlay to be created.
98
+ * @param {Number} [images[].input.create.width]
99
+ * @param {Number} [images[].input.create.height]
100
+ * @param {Number} [images[].input.create.channels] - 3-4
101
+ * @param {String|Object} [images[].input.create.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.
102
+ * @param {Object} [images[].input.text] - describes a new text image to be created.
103
+ * @param {string} [images[].input.text.text] - text to render as a UTF-8 string. It can contain Pango markup, for example `<i>Le</i>Monde`.
104
+ * @param {string} [images[].input.text.font] - font name to render with.
105
+ * @param {string} [images[].input.text.fontfile] - absolute filesystem path to a font file that can be used by `font`.
106
+ * @param {number} [images[].input.text.width=0] - integral number of pixels to word-wrap at. Lines of text wider than this will be broken at word boundaries.
107
+ * @param {number} [images[].input.text.height=0] - integral number of pixels high. When defined, `dpi` will be ignored and the text will automatically fit the pixel resolution defined by `width` and `height`. Will be ignored if `width` is not specified or set to 0.
108
+ * @param {string} [images[].input.text.align='left'] - text alignment (`'left'`, `'centre'`, `'center'`, `'right'`).
109
+ * @param {boolean} [images[].input.text.justify=false] - set this to true to apply justification to the text.
110
+ * @param {number} [images[].input.text.dpi=72] - the resolution (size) at which to render the text. Does not take effect if `height` is specified.
111
+ * @param {boolean} [images[].input.text.rgba=false] - set this to true to enable RGBA output. This is useful for colour emoji rendering, or support for Pango markup features like `<span foreground="red">Red!</span>`.
112
+ * @param {number} [images[].input.text.spacing=0] - text line height in points. Will use the font line height if none is specified.
113
+ * @param {String} [images[].blend='over'] - how to blend this image with the image below.
114
+ * @param {String} [images[].gravity='centre'] - gravity at which to place the overlay.
115
+ * @param {Number} [images[].top] - the pixel offset from the top edge.
116
+ * @param {Number} [images[].left] - the pixel offset from the left edge.
117
+ * @param {Boolean} [images[].tile=false] - set to true to repeat the overlay image across the entire image with the given `gravity`.
118
+ * @param {Boolean} [images[].premultiplied=false] - set to true to avoid premultiplying the image below. Equivalent to the `--premultiplied` vips option.
119
+ * @param {Number} [images[].density=72] - number representing the DPI for vector overlay image.
120
+ * @param {Object} [images[].raw] - describes overlay when using raw pixel data.
121
+ * @param {Number} [images[].raw.width]
122
+ * @param {Number} [images[].raw.height]
123
+ * @param {Number} [images[].raw.channels]
124
+ * @param {boolean} [images[].animated=false] - Set to `true` to read all frames/pages of an animated image.
125
+ * @param {string} [images[].failOn='warning'] - @see {@link /api-constructor#parameters|constructor parameters}
126
+ * @param {number|boolean} [images[].limitInputPixels=268402689] - @see {@link /api-constructor#parameters|constructor parameters}
127
+ * @returns {Sharp}
128
+ * @throws {Error} Invalid parameters
129
+ */
130
+ function composite (images) {
131
+ if (!Array.isArray(images)) {
132
+ throw is.invalidParameterError('images to composite', 'array', images);
133
+ }
134
+ this.options.composite = images.map(image => {
135
+ if (!is.object(image)) {
136
+ throw is.invalidParameterError('image to composite', 'object', image);
137
+ }
138
+ const inputOptions = this._inputOptionsFromObject(image);
139
+ const composite = {
140
+ input: this._createInputDescriptor(image.input, inputOptions, { allowStream: false }),
141
+ blend: 'over',
142
+ tile: false,
143
+ left: 0,
144
+ top: 0,
145
+ hasOffset: false,
146
+ gravity: 0,
147
+ premultiplied: false
148
+ };
149
+ if (is.defined(image.blend)) {
150
+ if (is.string(blend[image.blend])) {
151
+ composite.blend = blend[image.blend];
152
+ } else {
153
+ throw is.invalidParameterError('blend', 'valid blend name', image.blend);
154
+ }
155
+ }
156
+ if (is.defined(image.tile)) {
157
+ if (is.bool(image.tile)) {
158
+ composite.tile = image.tile;
159
+ } else {
160
+ throw is.invalidParameterError('tile', 'boolean', image.tile);
161
+ }
162
+ }
163
+ if (is.defined(image.left)) {
164
+ if (is.integer(image.left)) {
165
+ composite.left = image.left;
166
+ } else {
167
+ throw is.invalidParameterError('left', 'integer', image.left);
168
+ }
169
+ }
170
+ if (is.defined(image.top)) {
171
+ if (is.integer(image.top)) {
172
+ composite.top = image.top;
173
+ } else {
174
+ throw is.invalidParameterError('top', 'integer', image.top);
175
+ }
176
+ }
177
+ if (is.defined(image.top) !== is.defined(image.left)) {
178
+ throw new Error('Expected both left and top to be set');
179
+ } else {
180
+ composite.hasOffset = is.integer(image.top) && is.integer(image.left);
181
+ }
182
+ if (is.defined(image.gravity)) {
183
+ if (is.integer(image.gravity) && is.inRange(image.gravity, 0, 8)) {
184
+ composite.gravity = image.gravity;
185
+ } else if (is.string(image.gravity) && is.integer(this.constructor.gravity[image.gravity])) {
186
+ composite.gravity = this.constructor.gravity[image.gravity];
187
+ } else {
188
+ throw is.invalidParameterError('gravity', 'valid gravity', image.gravity);
189
+ }
190
+ }
191
+ if (is.defined(image.premultiplied)) {
192
+ if (is.bool(image.premultiplied)) {
193
+ composite.premultiplied = image.premultiplied;
194
+ } else {
195
+ throw is.invalidParameterError('premultiplied', 'boolean', image.premultiplied);
196
+ }
197
+ }
198
+ return composite;
199
+ });
200
+ return this;
201
+ }
202
+
203
+ /**
204
+ * Decorate the Sharp prototype with composite-related functions.
205
+ * @private
206
+ */
207
+ module.exports = function (Sharp) {
208
+ Sharp.prototype.composite = composite;
209
+ Sharp.blend = blend;
210
+ };