@contentful/experiences-visual-editor-react 1.7.1 → 1.7.2-dev-20240613T1745-9217fd8.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/dist/index.js +232 -232
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +895 -895
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/renderApp.js
CHANGED
|
@@ -34028,330 +34028,6 @@ function isSlowBuffer (obj) {
|
|
|
34028
34028
|
var md5Exports = md5$1.exports;
|
|
34029
34029
|
var md5 = /*@__PURE__*/getDefaultExportFromCjs(md5Exports);
|
|
34030
34030
|
|
|
34031
|
-
var dist = {};
|
|
34032
|
-
|
|
34033
|
-
var blocks = {};
|
|
34034
|
-
|
|
34035
|
-
Object.defineProperty(blocks, "__esModule", { value: true });
|
|
34036
|
-
blocks.BLOCKS = void 0;
|
|
34037
|
-
/**
|
|
34038
|
-
* Map of all Contentful block types. Blocks contain inline or block nodes.
|
|
34039
|
-
*/
|
|
34040
|
-
var BLOCKS;
|
|
34041
|
-
(function (BLOCKS) {
|
|
34042
|
-
BLOCKS["DOCUMENT"] = "document";
|
|
34043
|
-
BLOCKS["PARAGRAPH"] = "paragraph";
|
|
34044
|
-
BLOCKS["HEADING_1"] = "heading-1";
|
|
34045
|
-
BLOCKS["HEADING_2"] = "heading-2";
|
|
34046
|
-
BLOCKS["HEADING_3"] = "heading-3";
|
|
34047
|
-
BLOCKS["HEADING_4"] = "heading-4";
|
|
34048
|
-
BLOCKS["HEADING_5"] = "heading-5";
|
|
34049
|
-
BLOCKS["HEADING_6"] = "heading-6";
|
|
34050
|
-
BLOCKS["OL_LIST"] = "ordered-list";
|
|
34051
|
-
BLOCKS["UL_LIST"] = "unordered-list";
|
|
34052
|
-
BLOCKS["LIST_ITEM"] = "list-item";
|
|
34053
|
-
BLOCKS["HR"] = "hr";
|
|
34054
|
-
BLOCKS["QUOTE"] = "blockquote";
|
|
34055
|
-
BLOCKS["EMBEDDED_ENTRY"] = "embedded-entry-block";
|
|
34056
|
-
BLOCKS["EMBEDDED_ASSET"] = "embedded-asset-block";
|
|
34057
|
-
BLOCKS["EMBEDDED_RESOURCE"] = "embedded-resource-block";
|
|
34058
|
-
BLOCKS["TABLE"] = "table";
|
|
34059
|
-
BLOCKS["TABLE_ROW"] = "table-row";
|
|
34060
|
-
BLOCKS["TABLE_CELL"] = "table-cell";
|
|
34061
|
-
BLOCKS["TABLE_HEADER_CELL"] = "table-header-cell";
|
|
34062
|
-
})(BLOCKS || (blocks.BLOCKS = BLOCKS = {}));
|
|
34063
|
-
|
|
34064
|
-
var inlines = {};
|
|
34065
|
-
|
|
34066
|
-
Object.defineProperty(inlines, "__esModule", { value: true });
|
|
34067
|
-
inlines.INLINES = void 0;
|
|
34068
|
-
/**
|
|
34069
|
-
* Map of all Contentful inline types. Inline contain inline or text nodes.
|
|
34070
|
-
*/
|
|
34071
|
-
var INLINES;
|
|
34072
|
-
(function (INLINES) {
|
|
34073
|
-
INLINES["HYPERLINK"] = "hyperlink";
|
|
34074
|
-
INLINES["ENTRY_HYPERLINK"] = "entry-hyperlink";
|
|
34075
|
-
INLINES["ASSET_HYPERLINK"] = "asset-hyperlink";
|
|
34076
|
-
INLINES["RESOURCE_HYPERLINK"] = "resource-hyperlink";
|
|
34077
|
-
INLINES["EMBEDDED_ENTRY"] = "embedded-entry-inline";
|
|
34078
|
-
INLINES["EMBEDDED_RESOURCE"] = "embedded-resource-inline";
|
|
34079
|
-
})(INLINES || (inlines.INLINES = INLINES = {}));
|
|
34080
|
-
|
|
34081
|
-
var marks = {};
|
|
34082
|
-
|
|
34083
|
-
Object.defineProperty(marks, "__esModule", { value: true });
|
|
34084
|
-
marks.MARKS = void 0;
|
|
34085
|
-
/**
|
|
34086
|
-
* Map of all Contentful marks.
|
|
34087
|
-
*/
|
|
34088
|
-
var MARKS;
|
|
34089
|
-
(function (MARKS) {
|
|
34090
|
-
MARKS["BOLD"] = "bold";
|
|
34091
|
-
MARKS["ITALIC"] = "italic";
|
|
34092
|
-
MARKS["UNDERLINE"] = "underline";
|
|
34093
|
-
MARKS["CODE"] = "code";
|
|
34094
|
-
MARKS["SUPERSCRIPT"] = "superscript";
|
|
34095
|
-
MARKS["SUBSCRIPT"] = "subscript";
|
|
34096
|
-
})(MARKS || (marks.MARKS = MARKS = {}));
|
|
34097
|
-
|
|
34098
|
-
var schemaConstraints = {};
|
|
34099
|
-
|
|
34100
|
-
(function (exports) {
|
|
34101
|
-
var __spreadArray = (commonjsGlobal && commonjsGlobal.__spreadArray) || function (to, from, pack) {
|
|
34102
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
34103
|
-
if (ar || !(i in from)) {
|
|
34104
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
34105
|
-
ar[i] = from[i];
|
|
34106
|
-
}
|
|
34107
|
-
}
|
|
34108
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
34109
|
-
};
|
|
34110
|
-
var _a;
|
|
34111
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34112
|
-
exports.V1_MARKS = exports.V1_NODE_TYPES = exports.TEXT_CONTAINERS = exports.HEADINGS = exports.CONTAINERS = exports.VOID_BLOCKS = exports.TABLE_BLOCKS = exports.LIST_ITEM_BLOCKS = exports.TOP_LEVEL_BLOCKS = void 0;
|
|
34113
|
-
var blocks_1 = blocks;
|
|
34114
|
-
var inlines_1 = inlines;
|
|
34115
|
-
var marks_1 = marks;
|
|
34116
|
-
/**
|
|
34117
|
-
* Array of all top level block types.
|
|
34118
|
-
* Only these block types can be the direct children of the document.
|
|
34119
|
-
*/
|
|
34120
|
-
exports.TOP_LEVEL_BLOCKS = [
|
|
34121
|
-
blocks_1.BLOCKS.PARAGRAPH,
|
|
34122
|
-
blocks_1.BLOCKS.HEADING_1,
|
|
34123
|
-
blocks_1.BLOCKS.HEADING_2,
|
|
34124
|
-
blocks_1.BLOCKS.HEADING_3,
|
|
34125
|
-
blocks_1.BLOCKS.HEADING_4,
|
|
34126
|
-
blocks_1.BLOCKS.HEADING_5,
|
|
34127
|
-
blocks_1.BLOCKS.HEADING_6,
|
|
34128
|
-
blocks_1.BLOCKS.OL_LIST,
|
|
34129
|
-
blocks_1.BLOCKS.UL_LIST,
|
|
34130
|
-
blocks_1.BLOCKS.HR,
|
|
34131
|
-
blocks_1.BLOCKS.QUOTE,
|
|
34132
|
-
blocks_1.BLOCKS.EMBEDDED_ENTRY,
|
|
34133
|
-
blocks_1.BLOCKS.EMBEDDED_ASSET,
|
|
34134
|
-
blocks_1.BLOCKS.EMBEDDED_RESOURCE,
|
|
34135
|
-
blocks_1.BLOCKS.TABLE,
|
|
34136
|
-
];
|
|
34137
|
-
/**
|
|
34138
|
-
* Array of all allowed block types inside list items
|
|
34139
|
-
*/
|
|
34140
|
-
exports.LIST_ITEM_BLOCKS = [
|
|
34141
|
-
blocks_1.BLOCKS.PARAGRAPH,
|
|
34142
|
-
blocks_1.BLOCKS.HEADING_1,
|
|
34143
|
-
blocks_1.BLOCKS.HEADING_2,
|
|
34144
|
-
blocks_1.BLOCKS.HEADING_3,
|
|
34145
|
-
blocks_1.BLOCKS.HEADING_4,
|
|
34146
|
-
blocks_1.BLOCKS.HEADING_5,
|
|
34147
|
-
blocks_1.BLOCKS.HEADING_6,
|
|
34148
|
-
blocks_1.BLOCKS.OL_LIST,
|
|
34149
|
-
blocks_1.BLOCKS.UL_LIST,
|
|
34150
|
-
blocks_1.BLOCKS.HR,
|
|
34151
|
-
blocks_1.BLOCKS.QUOTE,
|
|
34152
|
-
blocks_1.BLOCKS.EMBEDDED_ENTRY,
|
|
34153
|
-
blocks_1.BLOCKS.EMBEDDED_ASSET,
|
|
34154
|
-
blocks_1.BLOCKS.EMBEDDED_RESOURCE,
|
|
34155
|
-
];
|
|
34156
|
-
exports.TABLE_BLOCKS = [
|
|
34157
|
-
blocks_1.BLOCKS.TABLE,
|
|
34158
|
-
blocks_1.BLOCKS.TABLE_ROW,
|
|
34159
|
-
blocks_1.BLOCKS.TABLE_CELL,
|
|
34160
|
-
blocks_1.BLOCKS.TABLE_HEADER_CELL,
|
|
34161
|
-
];
|
|
34162
|
-
/**
|
|
34163
|
-
* Array of all void block types
|
|
34164
|
-
*/
|
|
34165
|
-
exports.VOID_BLOCKS = [
|
|
34166
|
-
blocks_1.BLOCKS.HR,
|
|
34167
|
-
blocks_1.BLOCKS.EMBEDDED_ENTRY,
|
|
34168
|
-
blocks_1.BLOCKS.EMBEDDED_ASSET,
|
|
34169
|
-
blocks_1.BLOCKS.EMBEDDED_RESOURCE,
|
|
34170
|
-
];
|
|
34171
|
-
/**
|
|
34172
|
-
* Dictionary of all container block types, and the set block types they accept as children.
|
|
34173
|
-
*
|
|
34174
|
-
* Note: This does not include `[BLOCKS.DOCUMENT]: TOP_LEVEL_BLOCKS`
|
|
34175
|
-
*/
|
|
34176
|
-
exports.CONTAINERS = (_a = {},
|
|
34177
|
-
_a[blocks_1.BLOCKS.OL_LIST] = [blocks_1.BLOCKS.LIST_ITEM],
|
|
34178
|
-
_a[blocks_1.BLOCKS.UL_LIST] = [blocks_1.BLOCKS.LIST_ITEM],
|
|
34179
|
-
_a[blocks_1.BLOCKS.LIST_ITEM] = exports.LIST_ITEM_BLOCKS,
|
|
34180
|
-
_a[blocks_1.BLOCKS.QUOTE] = [blocks_1.BLOCKS.PARAGRAPH],
|
|
34181
|
-
_a[blocks_1.BLOCKS.TABLE] = [blocks_1.BLOCKS.TABLE_ROW],
|
|
34182
|
-
_a[blocks_1.BLOCKS.TABLE_ROW] = [blocks_1.BLOCKS.TABLE_CELL, blocks_1.BLOCKS.TABLE_HEADER_CELL],
|
|
34183
|
-
_a[blocks_1.BLOCKS.TABLE_CELL] = [blocks_1.BLOCKS.PARAGRAPH],
|
|
34184
|
-
_a[blocks_1.BLOCKS.TABLE_HEADER_CELL] = [blocks_1.BLOCKS.PARAGRAPH],
|
|
34185
|
-
_a);
|
|
34186
|
-
/**
|
|
34187
|
-
* Array of all heading levels
|
|
34188
|
-
*/
|
|
34189
|
-
exports.HEADINGS = [
|
|
34190
|
-
blocks_1.BLOCKS.HEADING_1,
|
|
34191
|
-
blocks_1.BLOCKS.HEADING_2,
|
|
34192
|
-
blocks_1.BLOCKS.HEADING_3,
|
|
34193
|
-
blocks_1.BLOCKS.HEADING_4,
|
|
34194
|
-
blocks_1.BLOCKS.HEADING_5,
|
|
34195
|
-
blocks_1.BLOCKS.HEADING_6,
|
|
34196
|
-
];
|
|
34197
|
-
/**
|
|
34198
|
-
* Array of all block types that may contain text and inline nodes.
|
|
34199
|
-
*/
|
|
34200
|
-
exports.TEXT_CONTAINERS = __spreadArray([blocks_1.BLOCKS.PARAGRAPH], exports.HEADINGS, true);
|
|
34201
|
-
/**
|
|
34202
|
-
* Node types before `tables` release.
|
|
34203
|
-
*/
|
|
34204
|
-
exports.V1_NODE_TYPES = [
|
|
34205
|
-
blocks_1.BLOCKS.DOCUMENT,
|
|
34206
|
-
blocks_1.BLOCKS.PARAGRAPH,
|
|
34207
|
-
blocks_1.BLOCKS.HEADING_1,
|
|
34208
|
-
blocks_1.BLOCKS.HEADING_2,
|
|
34209
|
-
blocks_1.BLOCKS.HEADING_3,
|
|
34210
|
-
blocks_1.BLOCKS.HEADING_4,
|
|
34211
|
-
blocks_1.BLOCKS.HEADING_5,
|
|
34212
|
-
blocks_1.BLOCKS.HEADING_6,
|
|
34213
|
-
blocks_1.BLOCKS.OL_LIST,
|
|
34214
|
-
blocks_1.BLOCKS.UL_LIST,
|
|
34215
|
-
blocks_1.BLOCKS.LIST_ITEM,
|
|
34216
|
-
blocks_1.BLOCKS.HR,
|
|
34217
|
-
blocks_1.BLOCKS.QUOTE,
|
|
34218
|
-
blocks_1.BLOCKS.EMBEDDED_ENTRY,
|
|
34219
|
-
blocks_1.BLOCKS.EMBEDDED_ASSET,
|
|
34220
|
-
inlines_1.INLINES.HYPERLINK,
|
|
34221
|
-
inlines_1.INLINES.ENTRY_HYPERLINK,
|
|
34222
|
-
inlines_1.INLINES.ASSET_HYPERLINK,
|
|
34223
|
-
inlines_1.INLINES.EMBEDDED_ENTRY,
|
|
34224
|
-
'text',
|
|
34225
|
-
];
|
|
34226
|
-
/**
|
|
34227
|
-
* Marks before `superscript` & `subscript` release.
|
|
34228
|
-
*/
|
|
34229
|
-
exports.V1_MARKS = [marks_1.MARKS.BOLD, marks_1.MARKS.CODE, marks_1.MARKS.ITALIC, marks_1.MARKS.UNDERLINE];
|
|
34230
|
-
|
|
34231
|
-
} (schemaConstraints));
|
|
34232
|
-
|
|
34233
|
-
var types = {};
|
|
34234
|
-
|
|
34235
|
-
Object.defineProperty(types, "__esModule", { value: true });
|
|
34236
|
-
|
|
34237
|
-
var nodeTypes = {};
|
|
34238
|
-
|
|
34239
|
-
Object.defineProperty(nodeTypes, "__esModule", { value: true });
|
|
34240
|
-
|
|
34241
|
-
var emptyDocument = {};
|
|
34242
|
-
|
|
34243
|
-
Object.defineProperty(emptyDocument, "__esModule", { value: true });
|
|
34244
|
-
emptyDocument.EMPTY_DOCUMENT = void 0;
|
|
34245
|
-
var blocks_1$1 = blocks;
|
|
34246
|
-
/**
|
|
34247
|
-
* A rich text document considered to be empty.
|
|
34248
|
-
* Any other document structure than this is not considered empty.
|
|
34249
|
-
*/
|
|
34250
|
-
emptyDocument.EMPTY_DOCUMENT = {
|
|
34251
|
-
nodeType: blocks_1$1.BLOCKS.DOCUMENT,
|
|
34252
|
-
data: {},
|
|
34253
|
-
content: [
|
|
34254
|
-
{
|
|
34255
|
-
nodeType: blocks_1$1.BLOCKS.PARAGRAPH,
|
|
34256
|
-
data: {},
|
|
34257
|
-
content: [
|
|
34258
|
-
{
|
|
34259
|
-
nodeType: 'text',
|
|
34260
|
-
value: '',
|
|
34261
|
-
marks: [],
|
|
34262
|
-
data: {},
|
|
34263
|
-
},
|
|
34264
|
-
],
|
|
34265
|
-
},
|
|
34266
|
-
],
|
|
34267
|
-
};
|
|
34268
|
-
|
|
34269
|
-
var helpers = {};
|
|
34270
|
-
|
|
34271
|
-
Object.defineProperty(helpers, "__esModule", { value: true });
|
|
34272
|
-
helpers.isText = helpers.isBlock = helpers.isInline = void 0;
|
|
34273
|
-
var blocks_1 = blocks;
|
|
34274
|
-
var inlines_1 = inlines;
|
|
34275
|
-
/**
|
|
34276
|
-
* Tiny replacement for Object.values(object).includes(key) to
|
|
34277
|
-
* avoid including CoreJS polyfills
|
|
34278
|
-
*/
|
|
34279
|
-
function hasValue(obj, value) {
|
|
34280
|
-
for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {
|
|
34281
|
-
var key = _a[_i];
|
|
34282
|
-
if (value === obj[key]) {
|
|
34283
|
-
return true;
|
|
34284
|
-
}
|
|
34285
|
-
}
|
|
34286
|
-
return false;
|
|
34287
|
-
}
|
|
34288
|
-
/**
|
|
34289
|
-
* Checks if the node is an instance of Inline.
|
|
34290
|
-
*/
|
|
34291
|
-
function isInline(node) {
|
|
34292
|
-
return hasValue(inlines_1.INLINES, node.nodeType);
|
|
34293
|
-
}
|
|
34294
|
-
helpers.isInline = isInline;
|
|
34295
|
-
/**
|
|
34296
|
-
* Checks if the node is an instance of Block.
|
|
34297
|
-
*/
|
|
34298
|
-
function isBlock(node) {
|
|
34299
|
-
return hasValue(blocks_1.BLOCKS, node.nodeType);
|
|
34300
|
-
}
|
|
34301
|
-
helpers.isBlock = isBlock;
|
|
34302
|
-
/**
|
|
34303
|
-
* Checks if the node is an instance of Text.
|
|
34304
|
-
*/
|
|
34305
|
-
function isText(node) {
|
|
34306
|
-
return node.nodeType === 'text';
|
|
34307
|
-
}
|
|
34308
|
-
helpers.isText = isText;
|
|
34309
|
-
|
|
34310
|
-
(function (exports) {
|
|
34311
|
-
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
34312
|
-
if (k2 === undefined) k2 = k;
|
|
34313
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
34314
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
34315
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
34316
|
-
}
|
|
34317
|
-
Object.defineProperty(o, k2, desc);
|
|
34318
|
-
}) : (function(o, m, k, k2) {
|
|
34319
|
-
if (k2 === undefined) k2 = k;
|
|
34320
|
-
o[k2] = m[k];
|
|
34321
|
-
}));
|
|
34322
|
-
var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
34323
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
34324
|
-
}) : function(o, v) {
|
|
34325
|
-
o["default"] = v;
|
|
34326
|
-
});
|
|
34327
|
-
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
34328
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
34329
|
-
};
|
|
34330
|
-
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
|
|
34331
|
-
if (mod && mod.__esModule) return mod;
|
|
34332
|
-
var result = {};
|
|
34333
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
34334
|
-
__setModuleDefault(result, mod);
|
|
34335
|
-
return result;
|
|
34336
|
-
};
|
|
34337
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34338
|
-
exports.helpers = exports.EMPTY_DOCUMENT = exports.MARKS = exports.INLINES = exports.BLOCKS = void 0;
|
|
34339
|
-
var blocks_1 = blocks;
|
|
34340
|
-
Object.defineProperty(exports, "BLOCKS", { enumerable: true, get: function () { return blocks_1.BLOCKS; } });
|
|
34341
|
-
var inlines_1 = inlines;
|
|
34342
|
-
Object.defineProperty(exports, "INLINES", { enumerable: true, get: function () { return inlines_1.INLINES; } });
|
|
34343
|
-
var marks_1 = marks;
|
|
34344
|
-
Object.defineProperty(exports, "MARKS", { enumerable: true, get: function () { return marks_1.MARKS; } });
|
|
34345
|
-
__exportStar(schemaConstraints, exports);
|
|
34346
|
-
__exportStar(types, exports);
|
|
34347
|
-
__exportStar(nodeTypes, exports);
|
|
34348
|
-
var emptyDocument_1 = emptyDocument;
|
|
34349
|
-
Object.defineProperty(exports, "EMPTY_DOCUMENT", { enumerable: true, get: function () { return emptyDocument_1.EMPTY_DOCUMENT; } });
|
|
34350
|
-
var helpers$1 = __importStar(helpers);
|
|
34351
|
-
exports.helpers = helpers$1;
|
|
34352
|
-
|
|
34353
|
-
} (dist));
|
|
34354
|
-
|
|
34355
34031
|
var util;
|
|
34356
34032
|
(function (util) {
|
|
34357
34033
|
util.assertEqual = (val) => val;
|
|
@@ -38024,349 +37700,673 @@ ZodCatch.create = (type, params) => {
|
|
|
38024
37700
|
...processCreateParams(params),
|
|
38025
37701
|
});
|
|
38026
37702
|
};
|
|
38027
|
-
class ZodNaN extends ZodType {
|
|
38028
|
-
_parse(input) {
|
|
38029
|
-
const parsedType = this._getType(input);
|
|
38030
|
-
if (parsedType !== ZodParsedType.nan) {
|
|
38031
|
-
const ctx = this._getOrReturnCtx(input);
|
|
38032
|
-
addIssueToContext(ctx, {
|
|
38033
|
-
code: ZodIssueCode.invalid_type,
|
|
38034
|
-
expected: ZodParsedType.nan,
|
|
38035
|
-
received: ctx.parsedType,
|
|
38036
|
-
});
|
|
38037
|
-
return INVALID;
|
|
38038
|
-
}
|
|
38039
|
-
return { status: "valid", value: input.data };
|
|
38040
|
-
}
|
|
38041
|
-
}
|
|
38042
|
-
ZodNaN.create = (params) => {
|
|
38043
|
-
return new ZodNaN({
|
|
38044
|
-
typeName: ZodFirstPartyTypeKind.ZodNaN,
|
|
38045
|
-
...processCreateParams(params),
|
|
38046
|
-
});
|
|
37703
|
+
class ZodNaN extends ZodType {
|
|
37704
|
+
_parse(input) {
|
|
37705
|
+
const parsedType = this._getType(input);
|
|
37706
|
+
if (parsedType !== ZodParsedType.nan) {
|
|
37707
|
+
const ctx = this._getOrReturnCtx(input);
|
|
37708
|
+
addIssueToContext(ctx, {
|
|
37709
|
+
code: ZodIssueCode.invalid_type,
|
|
37710
|
+
expected: ZodParsedType.nan,
|
|
37711
|
+
received: ctx.parsedType,
|
|
37712
|
+
});
|
|
37713
|
+
return INVALID;
|
|
37714
|
+
}
|
|
37715
|
+
return { status: "valid", value: input.data };
|
|
37716
|
+
}
|
|
37717
|
+
}
|
|
37718
|
+
ZodNaN.create = (params) => {
|
|
37719
|
+
return new ZodNaN({
|
|
37720
|
+
typeName: ZodFirstPartyTypeKind.ZodNaN,
|
|
37721
|
+
...processCreateParams(params),
|
|
37722
|
+
});
|
|
37723
|
+
};
|
|
37724
|
+
const BRAND = Symbol("zod_brand");
|
|
37725
|
+
class ZodBranded extends ZodType {
|
|
37726
|
+
_parse(input) {
|
|
37727
|
+
const { ctx } = this._processInputParams(input);
|
|
37728
|
+
const data = ctx.data;
|
|
37729
|
+
return this._def.type._parse({
|
|
37730
|
+
data,
|
|
37731
|
+
path: ctx.path,
|
|
37732
|
+
parent: ctx,
|
|
37733
|
+
});
|
|
37734
|
+
}
|
|
37735
|
+
unwrap() {
|
|
37736
|
+
return this._def.type;
|
|
37737
|
+
}
|
|
37738
|
+
}
|
|
37739
|
+
class ZodPipeline extends ZodType {
|
|
37740
|
+
_parse(input) {
|
|
37741
|
+
const { status, ctx } = this._processInputParams(input);
|
|
37742
|
+
if (ctx.common.async) {
|
|
37743
|
+
const handleAsync = async () => {
|
|
37744
|
+
const inResult = await this._def.in._parseAsync({
|
|
37745
|
+
data: ctx.data,
|
|
37746
|
+
path: ctx.path,
|
|
37747
|
+
parent: ctx,
|
|
37748
|
+
});
|
|
37749
|
+
if (inResult.status === "aborted")
|
|
37750
|
+
return INVALID;
|
|
37751
|
+
if (inResult.status === "dirty") {
|
|
37752
|
+
status.dirty();
|
|
37753
|
+
return DIRTY(inResult.value);
|
|
37754
|
+
}
|
|
37755
|
+
else {
|
|
37756
|
+
return this._def.out._parseAsync({
|
|
37757
|
+
data: inResult.value,
|
|
37758
|
+
path: ctx.path,
|
|
37759
|
+
parent: ctx,
|
|
37760
|
+
});
|
|
37761
|
+
}
|
|
37762
|
+
};
|
|
37763
|
+
return handleAsync();
|
|
37764
|
+
}
|
|
37765
|
+
else {
|
|
37766
|
+
const inResult = this._def.in._parseSync({
|
|
37767
|
+
data: ctx.data,
|
|
37768
|
+
path: ctx.path,
|
|
37769
|
+
parent: ctx,
|
|
37770
|
+
});
|
|
37771
|
+
if (inResult.status === "aborted")
|
|
37772
|
+
return INVALID;
|
|
37773
|
+
if (inResult.status === "dirty") {
|
|
37774
|
+
status.dirty();
|
|
37775
|
+
return {
|
|
37776
|
+
status: "dirty",
|
|
37777
|
+
value: inResult.value,
|
|
37778
|
+
};
|
|
37779
|
+
}
|
|
37780
|
+
else {
|
|
37781
|
+
return this._def.out._parseSync({
|
|
37782
|
+
data: inResult.value,
|
|
37783
|
+
path: ctx.path,
|
|
37784
|
+
parent: ctx,
|
|
37785
|
+
});
|
|
37786
|
+
}
|
|
37787
|
+
}
|
|
37788
|
+
}
|
|
37789
|
+
static create(a, b) {
|
|
37790
|
+
return new ZodPipeline({
|
|
37791
|
+
in: a,
|
|
37792
|
+
out: b,
|
|
37793
|
+
typeName: ZodFirstPartyTypeKind.ZodPipeline,
|
|
37794
|
+
});
|
|
37795
|
+
}
|
|
37796
|
+
}
|
|
37797
|
+
class ZodReadonly extends ZodType {
|
|
37798
|
+
_parse(input) {
|
|
37799
|
+
const result = this._def.innerType._parse(input);
|
|
37800
|
+
if (isValid(result)) {
|
|
37801
|
+
result.value = Object.freeze(result.value);
|
|
37802
|
+
}
|
|
37803
|
+
return result;
|
|
37804
|
+
}
|
|
37805
|
+
}
|
|
37806
|
+
ZodReadonly.create = (type, params) => {
|
|
37807
|
+
return new ZodReadonly({
|
|
37808
|
+
innerType: type,
|
|
37809
|
+
typeName: ZodFirstPartyTypeKind.ZodReadonly,
|
|
37810
|
+
...processCreateParams(params),
|
|
37811
|
+
});
|
|
37812
|
+
};
|
|
37813
|
+
const custom = (check, params = {},
|
|
37814
|
+
/**
|
|
37815
|
+
* @deprecated
|
|
37816
|
+
*
|
|
37817
|
+
* Pass `fatal` into the params object instead:
|
|
37818
|
+
*
|
|
37819
|
+
* ```ts
|
|
37820
|
+
* z.string().custom((val) => val.length > 5, { fatal: false })
|
|
37821
|
+
* ```
|
|
37822
|
+
*
|
|
37823
|
+
*/
|
|
37824
|
+
fatal) => {
|
|
37825
|
+
if (check)
|
|
37826
|
+
return ZodAny.create().superRefine((data, ctx) => {
|
|
37827
|
+
var _a, _b;
|
|
37828
|
+
if (!check(data)) {
|
|
37829
|
+
const p = typeof params === "function"
|
|
37830
|
+
? params(data)
|
|
37831
|
+
: typeof params === "string"
|
|
37832
|
+
? { message: params }
|
|
37833
|
+
: params;
|
|
37834
|
+
const _fatal = (_b = (_a = p.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
|
|
37835
|
+
const p2 = typeof p === "string" ? { message: p } : p;
|
|
37836
|
+
ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
|
|
37837
|
+
}
|
|
37838
|
+
});
|
|
37839
|
+
return ZodAny.create();
|
|
37840
|
+
};
|
|
37841
|
+
const late = {
|
|
37842
|
+
object: ZodObject.lazycreate,
|
|
37843
|
+
};
|
|
37844
|
+
var ZodFirstPartyTypeKind;
|
|
37845
|
+
(function (ZodFirstPartyTypeKind) {
|
|
37846
|
+
ZodFirstPartyTypeKind["ZodString"] = "ZodString";
|
|
37847
|
+
ZodFirstPartyTypeKind["ZodNumber"] = "ZodNumber";
|
|
37848
|
+
ZodFirstPartyTypeKind["ZodNaN"] = "ZodNaN";
|
|
37849
|
+
ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
|
|
37850
|
+
ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
|
|
37851
|
+
ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
|
|
37852
|
+
ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
|
|
37853
|
+
ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
|
|
37854
|
+
ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
|
|
37855
|
+
ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
|
|
37856
|
+
ZodFirstPartyTypeKind["ZodUnknown"] = "ZodUnknown";
|
|
37857
|
+
ZodFirstPartyTypeKind["ZodNever"] = "ZodNever";
|
|
37858
|
+
ZodFirstPartyTypeKind["ZodVoid"] = "ZodVoid";
|
|
37859
|
+
ZodFirstPartyTypeKind["ZodArray"] = "ZodArray";
|
|
37860
|
+
ZodFirstPartyTypeKind["ZodObject"] = "ZodObject";
|
|
37861
|
+
ZodFirstPartyTypeKind["ZodUnion"] = "ZodUnion";
|
|
37862
|
+
ZodFirstPartyTypeKind["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
|
|
37863
|
+
ZodFirstPartyTypeKind["ZodIntersection"] = "ZodIntersection";
|
|
37864
|
+
ZodFirstPartyTypeKind["ZodTuple"] = "ZodTuple";
|
|
37865
|
+
ZodFirstPartyTypeKind["ZodRecord"] = "ZodRecord";
|
|
37866
|
+
ZodFirstPartyTypeKind["ZodMap"] = "ZodMap";
|
|
37867
|
+
ZodFirstPartyTypeKind["ZodSet"] = "ZodSet";
|
|
37868
|
+
ZodFirstPartyTypeKind["ZodFunction"] = "ZodFunction";
|
|
37869
|
+
ZodFirstPartyTypeKind["ZodLazy"] = "ZodLazy";
|
|
37870
|
+
ZodFirstPartyTypeKind["ZodLiteral"] = "ZodLiteral";
|
|
37871
|
+
ZodFirstPartyTypeKind["ZodEnum"] = "ZodEnum";
|
|
37872
|
+
ZodFirstPartyTypeKind["ZodEffects"] = "ZodEffects";
|
|
37873
|
+
ZodFirstPartyTypeKind["ZodNativeEnum"] = "ZodNativeEnum";
|
|
37874
|
+
ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
|
|
37875
|
+
ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
|
|
37876
|
+
ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
|
|
37877
|
+
ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
|
|
37878
|
+
ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
|
|
37879
|
+
ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
|
|
37880
|
+
ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
|
|
37881
|
+
ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
|
|
37882
|
+
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
37883
|
+
const instanceOfType = (
|
|
37884
|
+
// const instanceOfType = <T extends new (...args: any[]) => any>(
|
|
37885
|
+
cls, params = {
|
|
37886
|
+
message: `Input not instance of ${cls.name}`,
|
|
37887
|
+
}) => custom((data) => data instanceof cls, params);
|
|
37888
|
+
const stringType = ZodString.create;
|
|
37889
|
+
const numberType = ZodNumber.create;
|
|
37890
|
+
const nanType = ZodNaN.create;
|
|
37891
|
+
const bigIntType = ZodBigInt.create;
|
|
37892
|
+
const booleanType = ZodBoolean.create;
|
|
37893
|
+
const dateType = ZodDate.create;
|
|
37894
|
+
const symbolType = ZodSymbol.create;
|
|
37895
|
+
const undefinedType = ZodUndefined.create;
|
|
37896
|
+
const nullType = ZodNull.create;
|
|
37897
|
+
const anyType = ZodAny.create;
|
|
37898
|
+
const unknownType = ZodUnknown.create;
|
|
37899
|
+
const neverType = ZodNever.create;
|
|
37900
|
+
const voidType = ZodVoid.create;
|
|
37901
|
+
const arrayType = ZodArray.create;
|
|
37902
|
+
const objectType = ZodObject.create;
|
|
37903
|
+
const strictObjectType = ZodObject.strictCreate;
|
|
37904
|
+
const unionType = ZodUnion.create;
|
|
37905
|
+
const discriminatedUnionType = ZodDiscriminatedUnion.create;
|
|
37906
|
+
const intersectionType = ZodIntersection.create;
|
|
37907
|
+
const tupleType = ZodTuple.create;
|
|
37908
|
+
const recordType = ZodRecord.create;
|
|
37909
|
+
const mapType = ZodMap.create;
|
|
37910
|
+
const setType = ZodSet.create;
|
|
37911
|
+
const functionType = ZodFunction.create;
|
|
37912
|
+
const lazyType = ZodLazy.create;
|
|
37913
|
+
const literalType = ZodLiteral.create;
|
|
37914
|
+
const enumType = ZodEnum.create;
|
|
37915
|
+
const nativeEnumType = ZodNativeEnum.create;
|
|
37916
|
+
const promiseType = ZodPromise.create;
|
|
37917
|
+
const effectsType = ZodEffects.create;
|
|
37918
|
+
const optionalType = ZodOptional.create;
|
|
37919
|
+
const nullableType = ZodNullable.create;
|
|
37920
|
+
const preprocessType = ZodEffects.createWithPreprocess;
|
|
37921
|
+
const pipelineType = ZodPipeline.create;
|
|
37922
|
+
const ostring = () => stringType().optional();
|
|
37923
|
+
const onumber = () => numberType().optional();
|
|
37924
|
+
const oboolean = () => booleanType().optional();
|
|
37925
|
+
const coerce = {
|
|
37926
|
+
string: ((arg) => ZodString.create({ ...arg, coerce: true })),
|
|
37927
|
+
number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
|
|
37928
|
+
boolean: ((arg) => ZodBoolean.create({
|
|
37929
|
+
...arg,
|
|
37930
|
+
coerce: true,
|
|
37931
|
+
})),
|
|
37932
|
+
bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
|
|
37933
|
+
date: ((arg) => ZodDate.create({ ...arg, coerce: true })),
|
|
37934
|
+
};
|
|
37935
|
+
const NEVER = INVALID;
|
|
37936
|
+
|
|
37937
|
+
var z = /*#__PURE__*/Object.freeze({
|
|
37938
|
+
__proto__: null,
|
|
37939
|
+
defaultErrorMap: errorMap,
|
|
37940
|
+
setErrorMap: setErrorMap,
|
|
37941
|
+
getErrorMap: getErrorMap,
|
|
37942
|
+
makeIssue: makeIssue,
|
|
37943
|
+
EMPTY_PATH: EMPTY_PATH,
|
|
37944
|
+
addIssueToContext: addIssueToContext,
|
|
37945
|
+
ParseStatus: ParseStatus,
|
|
37946
|
+
INVALID: INVALID,
|
|
37947
|
+
DIRTY: DIRTY,
|
|
37948
|
+
OK: OK,
|
|
37949
|
+
isAborted: isAborted,
|
|
37950
|
+
isDirty: isDirty,
|
|
37951
|
+
isValid: isValid,
|
|
37952
|
+
isAsync: isAsync,
|
|
37953
|
+
get util () { return util; },
|
|
37954
|
+
get objectUtil () { return objectUtil; },
|
|
37955
|
+
ZodParsedType: ZodParsedType,
|
|
37956
|
+
getParsedType: getParsedType,
|
|
37957
|
+
ZodType: ZodType,
|
|
37958
|
+
ZodString: ZodString,
|
|
37959
|
+
ZodNumber: ZodNumber,
|
|
37960
|
+
ZodBigInt: ZodBigInt,
|
|
37961
|
+
ZodBoolean: ZodBoolean,
|
|
37962
|
+
ZodDate: ZodDate,
|
|
37963
|
+
ZodSymbol: ZodSymbol,
|
|
37964
|
+
ZodUndefined: ZodUndefined,
|
|
37965
|
+
ZodNull: ZodNull,
|
|
37966
|
+
ZodAny: ZodAny,
|
|
37967
|
+
ZodUnknown: ZodUnknown,
|
|
37968
|
+
ZodNever: ZodNever,
|
|
37969
|
+
ZodVoid: ZodVoid,
|
|
37970
|
+
ZodArray: ZodArray,
|
|
37971
|
+
ZodObject: ZodObject,
|
|
37972
|
+
ZodUnion: ZodUnion,
|
|
37973
|
+
ZodDiscriminatedUnion: ZodDiscriminatedUnion,
|
|
37974
|
+
ZodIntersection: ZodIntersection,
|
|
37975
|
+
ZodTuple: ZodTuple,
|
|
37976
|
+
ZodRecord: ZodRecord,
|
|
37977
|
+
ZodMap: ZodMap,
|
|
37978
|
+
ZodSet: ZodSet,
|
|
37979
|
+
ZodFunction: ZodFunction,
|
|
37980
|
+
ZodLazy: ZodLazy,
|
|
37981
|
+
ZodLiteral: ZodLiteral,
|
|
37982
|
+
ZodEnum: ZodEnum,
|
|
37983
|
+
ZodNativeEnum: ZodNativeEnum,
|
|
37984
|
+
ZodPromise: ZodPromise,
|
|
37985
|
+
ZodEffects: ZodEffects,
|
|
37986
|
+
ZodTransformer: ZodEffects,
|
|
37987
|
+
ZodOptional: ZodOptional,
|
|
37988
|
+
ZodNullable: ZodNullable,
|
|
37989
|
+
ZodDefault: ZodDefault,
|
|
37990
|
+
ZodCatch: ZodCatch,
|
|
37991
|
+
ZodNaN: ZodNaN,
|
|
37992
|
+
BRAND: BRAND,
|
|
37993
|
+
ZodBranded: ZodBranded,
|
|
37994
|
+
ZodPipeline: ZodPipeline,
|
|
37995
|
+
ZodReadonly: ZodReadonly,
|
|
37996
|
+
custom: custom,
|
|
37997
|
+
Schema: ZodType,
|
|
37998
|
+
ZodSchema: ZodType,
|
|
37999
|
+
late: late,
|
|
38000
|
+
get ZodFirstPartyTypeKind () { return ZodFirstPartyTypeKind; },
|
|
38001
|
+
coerce: coerce,
|
|
38002
|
+
any: anyType,
|
|
38003
|
+
array: arrayType,
|
|
38004
|
+
bigint: bigIntType,
|
|
38005
|
+
boolean: booleanType,
|
|
38006
|
+
date: dateType,
|
|
38007
|
+
discriminatedUnion: discriminatedUnionType,
|
|
38008
|
+
effect: effectsType,
|
|
38009
|
+
'enum': enumType,
|
|
38010
|
+
'function': functionType,
|
|
38011
|
+
'instanceof': instanceOfType,
|
|
38012
|
+
intersection: intersectionType,
|
|
38013
|
+
lazy: lazyType,
|
|
38014
|
+
literal: literalType,
|
|
38015
|
+
map: mapType,
|
|
38016
|
+
nan: nanType,
|
|
38017
|
+
nativeEnum: nativeEnumType,
|
|
38018
|
+
never: neverType,
|
|
38019
|
+
'null': nullType,
|
|
38020
|
+
nullable: nullableType,
|
|
38021
|
+
number: numberType,
|
|
38022
|
+
object: objectType,
|
|
38023
|
+
oboolean: oboolean,
|
|
38024
|
+
onumber: onumber,
|
|
38025
|
+
optional: optionalType,
|
|
38026
|
+
ostring: ostring,
|
|
38027
|
+
pipeline: pipelineType,
|
|
38028
|
+
preprocess: preprocessType,
|
|
38029
|
+
promise: promiseType,
|
|
38030
|
+
record: recordType,
|
|
38031
|
+
set: setType,
|
|
38032
|
+
strictObject: strictObjectType,
|
|
38033
|
+
string: stringType,
|
|
38034
|
+
symbol: symbolType,
|
|
38035
|
+
transformer: effectsType,
|
|
38036
|
+
tuple: tupleType,
|
|
38037
|
+
'undefined': undefinedType,
|
|
38038
|
+
union: unionType,
|
|
38039
|
+
unknown: unknownType,
|
|
38040
|
+
'void': voidType,
|
|
38041
|
+
NEVER: NEVER,
|
|
38042
|
+
ZodIssueCode: ZodIssueCode,
|
|
38043
|
+
quotelessJson: quotelessJson,
|
|
38044
|
+
ZodError: ZodError
|
|
38045
|
+
});
|
|
38046
|
+
|
|
38047
|
+
var dist = {};
|
|
38048
|
+
|
|
38049
|
+
var blocks = {};
|
|
38050
|
+
|
|
38051
|
+
Object.defineProperty(blocks, "__esModule", { value: true });
|
|
38052
|
+
blocks.BLOCKS = void 0;
|
|
38053
|
+
/**
|
|
38054
|
+
* Map of all Contentful block types. Blocks contain inline or block nodes.
|
|
38055
|
+
*/
|
|
38056
|
+
var BLOCKS;
|
|
38057
|
+
(function (BLOCKS) {
|
|
38058
|
+
BLOCKS["DOCUMENT"] = "document";
|
|
38059
|
+
BLOCKS["PARAGRAPH"] = "paragraph";
|
|
38060
|
+
BLOCKS["HEADING_1"] = "heading-1";
|
|
38061
|
+
BLOCKS["HEADING_2"] = "heading-2";
|
|
38062
|
+
BLOCKS["HEADING_3"] = "heading-3";
|
|
38063
|
+
BLOCKS["HEADING_4"] = "heading-4";
|
|
38064
|
+
BLOCKS["HEADING_5"] = "heading-5";
|
|
38065
|
+
BLOCKS["HEADING_6"] = "heading-6";
|
|
38066
|
+
BLOCKS["OL_LIST"] = "ordered-list";
|
|
38067
|
+
BLOCKS["UL_LIST"] = "unordered-list";
|
|
38068
|
+
BLOCKS["LIST_ITEM"] = "list-item";
|
|
38069
|
+
BLOCKS["HR"] = "hr";
|
|
38070
|
+
BLOCKS["QUOTE"] = "blockquote";
|
|
38071
|
+
BLOCKS["EMBEDDED_ENTRY"] = "embedded-entry-block";
|
|
38072
|
+
BLOCKS["EMBEDDED_ASSET"] = "embedded-asset-block";
|
|
38073
|
+
BLOCKS["EMBEDDED_RESOURCE"] = "embedded-resource-block";
|
|
38074
|
+
BLOCKS["TABLE"] = "table";
|
|
38075
|
+
BLOCKS["TABLE_ROW"] = "table-row";
|
|
38076
|
+
BLOCKS["TABLE_CELL"] = "table-cell";
|
|
38077
|
+
BLOCKS["TABLE_HEADER_CELL"] = "table-header-cell";
|
|
38078
|
+
})(BLOCKS || (blocks.BLOCKS = BLOCKS = {}));
|
|
38079
|
+
|
|
38080
|
+
var inlines = {};
|
|
38081
|
+
|
|
38082
|
+
Object.defineProperty(inlines, "__esModule", { value: true });
|
|
38083
|
+
inlines.INLINES = void 0;
|
|
38084
|
+
/**
|
|
38085
|
+
* Map of all Contentful inline types. Inline contain inline or text nodes.
|
|
38086
|
+
*/
|
|
38087
|
+
var INLINES;
|
|
38088
|
+
(function (INLINES) {
|
|
38089
|
+
INLINES["HYPERLINK"] = "hyperlink";
|
|
38090
|
+
INLINES["ENTRY_HYPERLINK"] = "entry-hyperlink";
|
|
38091
|
+
INLINES["ASSET_HYPERLINK"] = "asset-hyperlink";
|
|
38092
|
+
INLINES["RESOURCE_HYPERLINK"] = "resource-hyperlink";
|
|
38093
|
+
INLINES["EMBEDDED_ENTRY"] = "embedded-entry-inline";
|
|
38094
|
+
INLINES["EMBEDDED_RESOURCE"] = "embedded-resource-inline";
|
|
38095
|
+
})(INLINES || (inlines.INLINES = INLINES = {}));
|
|
38096
|
+
|
|
38097
|
+
var marks = {};
|
|
38098
|
+
|
|
38099
|
+
Object.defineProperty(marks, "__esModule", { value: true });
|
|
38100
|
+
marks.MARKS = void 0;
|
|
38101
|
+
/**
|
|
38102
|
+
* Map of all Contentful marks.
|
|
38103
|
+
*/
|
|
38104
|
+
var MARKS;
|
|
38105
|
+
(function (MARKS) {
|
|
38106
|
+
MARKS["BOLD"] = "bold";
|
|
38107
|
+
MARKS["ITALIC"] = "italic";
|
|
38108
|
+
MARKS["UNDERLINE"] = "underline";
|
|
38109
|
+
MARKS["CODE"] = "code";
|
|
38110
|
+
MARKS["SUPERSCRIPT"] = "superscript";
|
|
38111
|
+
MARKS["SUBSCRIPT"] = "subscript";
|
|
38112
|
+
})(MARKS || (marks.MARKS = MARKS = {}));
|
|
38113
|
+
|
|
38114
|
+
var schemaConstraints = {};
|
|
38115
|
+
|
|
38116
|
+
(function (exports) {
|
|
38117
|
+
var __spreadArray = (commonjsGlobal && commonjsGlobal.__spreadArray) || function (to, from, pack) {
|
|
38118
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
38119
|
+
if (ar || !(i in from)) {
|
|
38120
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
38121
|
+
ar[i] = from[i];
|
|
38122
|
+
}
|
|
38123
|
+
}
|
|
38124
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
38125
|
+
};
|
|
38126
|
+
var _a;
|
|
38127
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38128
|
+
exports.V1_MARKS = exports.V1_NODE_TYPES = exports.TEXT_CONTAINERS = exports.HEADINGS = exports.CONTAINERS = exports.VOID_BLOCKS = exports.TABLE_BLOCKS = exports.LIST_ITEM_BLOCKS = exports.TOP_LEVEL_BLOCKS = void 0;
|
|
38129
|
+
var blocks_1 = blocks;
|
|
38130
|
+
var inlines_1 = inlines;
|
|
38131
|
+
var marks_1 = marks;
|
|
38132
|
+
/**
|
|
38133
|
+
* Array of all top level block types.
|
|
38134
|
+
* Only these block types can be the direct children of the document.
|
|
38135
|
+
*/
|
|
38136
|
+
exports.TOP_LEVEL_BLOCKS = [
|
|
38137
|
+
blocks_1.BLOCKS.PARAGRAPH,
|
|
38138
|
+
blocks_1.BLOCKS.HEADING_1,
|
|
38139
|
+
blocks_1.BLOCKS.HEADING_2,
|
|
38140
|
+
blocks_1.BLOCKS.HEADING_3,
|
|
38141
|
+
blocks_1.BLOCKS.HEADING_4,
|
|
38142
|
+
blocks_1.BLOCKS.HEADING_5,
|
|
38143
|
+
blocks_1.BLOCKS.HEADING_6,
|
|
38144
|
+
blocks_1.BLOCKS.OL_LIST,
|
|
38145
|
+
blocks_1.BLOCKS.UL_LIST,
|
|
38146
|
+
blocks_1.BLOCKS.HR,
|
|
38147
|
+
blocks_1.BLOCKS.QUOTE,
|
|
38148
|
+
blocks_1.BLOCKS.EMBEDDED_ENTRY,
|
|
38149
|
+
blocks_1.BLOCKS.EMBEDDED_ASSET,
|
|
38150
|
+
blocks_1.BLOCKS.EMBEDDED_RESOURCE,
|
|
38151
|
+
blocks_1.BLOCKS.TABLE,
|
|
38152
|
+
];
|
|
38153
|
+
/**
|
|
38154
|
+
* Array of all allowed block types inside list items
|
|
38155
|
+
*/
|
|
38156
|
+
exports.LIST_ITEM_BLOCKS = [
|
|
38157
|
+
blocks_1.BLOCKS.PARAGRAPH,
|
|
38158
|
+
blocks_1.BLOCKS.HEADING_1,
|
|
38159
|
+
blocks_1.BLOCKS.HEADING_2,
|
|
38160
|
+
blocks_1.BLOCKS.HEADING_3,
|
|
38161
|
+
blocks_1.BLOCKS.HEADING_4,
|
|
38162
|
+
blocks_1.BLOCKS.HEADING_5,
|
|
38163
|
+
blocks_1.BLOCKS.HEADING_6,
|
|
38164
|
+
blocks_1.BLOCKS.OL_LIST,
|
|
38165
|
+
blocks_1.BLOCKS.UL_LIST,
|
|
38166
|
+
blocks_1.BLOCKS.HR,
|
|
38167
|
+
blocks_1.BLOCKS.QUOTE,
|
|
38168
|
+
blocks_1.BLOCKS.EMBEDDED_ENTRY,
|
|
38169
|
+
blocks_1.BLOCKS.EMBEDDED_ASSET,
|
|
38170
|
+
blocks_1.BLOCKS.EMBEDDED_RESOURCE,
|
|
38171
|
+
];
|
|
38172
|
+
exports.TABLE_BLOCKS = [
|
|
38173
|
+
blocks_1.BLOCKS.TABLE,
|
|
38174
|
+
blocks_1.BLOCKS.TABLE_ROW,
|
|
38175
|
+
blocks_1.BLOCKS.TABLE_CELL,
|
|
38176
|
+
blocks_1.BLOCKS.TABLE_HEADER_CELL,
|
|
38177
|
+
];
|
|
38178
|
+
/**
|
|
38179
|
+
* Array of all void block types
|
|
38180
|
+
*/
|
|
38181
|
+
exports.VOID_BLOCKS = [
|
|
38182
|
+
blocks_1.BLOCKS.HR,
|
|
38183
|
+
blocks_1.BLOCKS.EMBEDDED_ENTRY,
|
|
38184
|
+
blocks_1.BLOCKS.EMBEDDED_ASSET,
|
|
38185
|
+
blocks_1.BLOCKS.EMBEDDED_RESOURCE,
|
|
38186
|
+
];
|
|
38187
|
+
/**
|
|
38188
|
+
* Dictionary of all container block types, and the set block types they accept as children.
|
|
38189
|
+
*
|
|
38190
|
+
* Note: This does not include `[BLOCKS.DOCUMENT]: TOP_LEVEL_BLOCKS`
|
|
38191
|
+
*/
|
|
38192
|
+
exports.CONTAINERS = (_a = {},
|
|
38193
|
+
_a[blocks_1.BLOCKS.OL_LIST] = [blocks_1.BLOCKS.LIST_ITEM],
|
|
38194
|
+
_a[blocks_1.BLOCKS.UL_LIST] = [blocks_1.BLOCKS.LIST_ITEM],
|
|
38195
|
+
_a[blocks_1.BLOCKS.LIST_ITEM] = exports.LIST_ITEM_BLOCKS,
|
|
38196
|
+
_a[blocks_1.BLOCKS.QUOTE] = [blocks_1.BLOCKS.PARAGRAPH],
|
|
38197
|
+
_a[blocks_1.BLOCKS.TABLE] = [blocks_1.BLOCKS.TABLE_ROW],
|
|
38198
|
+
_a[blocks_1.BLOCKS.TABLE_ROW] = [blocks_1.BLOCKS.TABLE_CELL, blocks_1.BLOCKS.TABLE_HEADER_CELL],
|
|
38199
|
+
_a[blocks_1.BLOCKS.TABLE_CELL] = [blocks_1.BLOCKS.PARAGRAPH],
|
|
38200
|
+
_a[blocks_1.BLOCKS.TABLE_HEADER_CELL] = [blocks_1.BLOCKS.PARAGRAPH],
|
|
38201
|
+
_a);
|
|
38202
|
+
/**
|
|
38203
|
+
* Array of all heading levels
|
|
38204
|
+
*/
|
|
38205
|
+
exports.HEADINGS = [
|
|
38206
|
+
blocks_1.BLOCKS.HEADING_1,
|
|
38207
|
+
blocks_1.BLOCKS.HEADING_2,
|
|
38208
|
+
blocks_1.BLOCKS.HEADING_3,
|
|
38209
|
+
blocks_1.BLOCKS.HEADING_4,
|
|
38210
|
+
blocks_1.BLOCKS.HEADING_5,
|
|
38211
|
+
blocks_1.BLOCKS.HEADING_6,
|
|
38212
|
+
];
|
|
38213
|
+
/**
|
|
38214
|
+
* Array of all block types that may contain text and inline nodes.
|
|
38215
|
+
*/
|
|
38216
|
+
exports.TEXT_CONTAINERS = __spreadArray([blocks_1.BLOCKS.PARAGRAPH], exports.HEADINGS, true);
|
|
38217
|
+
/**
|
|
38218
|
+
* Node types before `tables` release.
|
|
38219
|
+
*/
|
|
38220
|
+
exports.V1_NODE_TYPES = [
|
|
38221
|
+
blocks_1.BLOCKS.DOCUMENT,
|
|
38222
|
+
blocks_1.BLOCKS.PARAGRAPH,
|
|
38223
|
+
blocks_1.BLOCKS.HEADING_1,
|
|
38224
|
+
blocks_1.BLOCKS.HEADING_2,
|
|
38225
|
+
blocks_1.BLOCKS.HEADING_3,
|
|
38226
|
+
blocks_1.BLOCKS.HEADING_4,
|
|
38227
|
+
blocks_1.BLOCKS.HEADING_5,
|
|
38228
|
+
blocks_1.BLOCKS.HEADING_6,
|
|
38229
|
+
blocks_1.BLOCKS.OL_LIST,
|
|
38230
|
+
blocks_1.BLOCKS.UL_LIST,
|
|
38231
|
+
blocks_1.BLOCKS.LIST_ITEM,
|
|
38232
|
+
blocks_1.BLOCKS.HR,
|
|
38233
|
+
blocks_1.BLOCKS.QUOTE,
|
|
38234
|
+
blocks_1.BLOCKS.EMBEDDED_ENTRY,
|
|
38235
|
+
blocks_1.BLOCKS.EMBEDDED_ASSET,
|
|
38236
|
+
inlines_1.INLINES.HYPERLINK,
|
|
38237
|
+
inlines_1.INLINES.ENTRY_HYPERLINK,
|
|
38238
|
+
inlines_1.INLINES.ASSET_HYPERLINK,
|
|
38239
|
+
inlines_1.INLINES.EMBEDDED_ENTRY,
|
|
38240
|
+
'text',
|
|
38241
|
+
];
|
|
38242
|
+
/**
|
|
38243
|
+
* Marks before `superscript` & `subscript` release.
|
|
38244
|
+
*/
|
|
38245
|
+
exports.V1_MARKS = [marks_1.MARKS.BOLD, marks_1.MARKS.CODE, marks_1.MARKS.ITALIC, marks_1.MARKS.UNDERLINE];
|
|
38246
|
+
|
|
38247
|
+
} (schemaConstraints));
|
|
38248
|
+
|
|
38249
|
+
var types = {};
|
|
38250
|
+
|
|
38251
|
+
Object.defineProperty(types, "__esModule", { value: true });
|
|
38252
|
+
|
|
38253
|
+
var nodeTypes = {};
|
|
38254
|
+
|
|
38255
|
+
Object.defineProperty(nodeTypes, "__esModule", { value: true });
|
|
38256
|
+
|
|
38257
|
+
var emptyDocument = {};
|
|
38258
|
+
|
|
38259
|
+
Object.defineProperty(emptyDocument, "__esModule", { value: true });
|
|
38260
|
+
emptyDocument.EMPTY_DOCUMENT = void 0;
|
|
38261
|
+
var blocks_1$1 = blocks;
|
|
38262
|
+
/**
|
|
38263
|
+
* A rich text document considered to be empty.
|
|
38264
|
+
* Any other document structure than this is not considered empty.
|
|
38265
|
+
*/
|
|
38266
|
+
emptyDocument.EMPTY_DOCUMENT = {
|
|
38267
|
+
nodeType: blocks_1$1.BLOCKS.DOCUMENT,
|
|
38268
|
+
data: {},
|
|
38269
|
+
content: [
|
|
38270
|
+
{
|
|
38271
|
+
nodeType: blocks_1$1.BLOCKS.PARAGRAPH,
|
|
38272
|
+
data: {},
|
|
38273
|
+
content: [
|
|
38274
|
+
{
|
|
38275
|
+
nodeType: 'text',
|
|
38276
|
+
value: '',
|
|
38277
|
+
marks: [],
|
|
38278
|
+
data: {},
|
|
38279
|
+
},
|
|
38280
|
+
],
|
|
38281
|
+
},
|
|
38282
|
+
],
|
|
38047
38283
|
};
|
|
38048
|
-
|
|
38049
|
-
|
|
38050
|
-
|
|
38051
|
-
|
|
38052
|
-
|
|
38053
|
-
|
|
38054
|
-
|
|
38055
|
-
|
|
38056
|
-
|
|
38057
|
-
|
|
38058
|
-
|
|
38059
|
-
|
|
38060
|
-
|
|
38061
|
-
|
|
38062
|
-
|
|
38063
|
-
|
|
38064
|
-
_parse(input) {
|
|
38065
|
-
const { status, ctx } = this._processInputParams(input);
|
|
38066
|
-
if (ctx.common.async) {
|
|
38067
|
-
const handleAsync = async () => {
|
|
38068
|
-
const inResult = await this._def.in._parseAsync({
|
|
38069
|
-
data: ctx.data,
|
|
38070
|
-
path: ctx.path,
|
|
38071
|
-
parent: ctx,
|
|
38072
|
-
});
|
|
38073
|
-
if (inResult.status === "aborted")
|
|
38074
|
-
return INVALID;
|
|
38075
|
-
if (inResult.status === "dirty") {
|
|
38076
|
-
status.dirty();
|
|
38077
|
-
return DIRTY(inResult.value);
|
|
38078
|
-
}
|
|
38079
|
-
else {
|
|
38080
|
-
return this._def.out._parseAsync({
|
|
38081
|
-
data: inResult.value,
|
|
38082
|
-
path: ctx.path,
|
|
38083
|
-
parent: ctx,
|
|
38084
|
-
});
|
|
38085
|
-
}
|
|
38086
|
-
};
|
|
38087
|
-
return handleAsync();
|
|
38088
|
-
}
|
|
38089
|
-
else {
|
|
38090
|
-
const inResult = this._def.in._parseSync({
|
|
38091
|
-
data: ctx.data,
|
|
38092
|
-
path: ctx.path,
|
|
38093
|
-
parent: ctx,
|
|
38094
|
-
});
|
|
38095
|
-
if (inResult.status === "aborted")
|
|
38096
|
-
return INVALID;
|
|
38097
|
-
if (inResult.status === "dirty") {
|
|
38098
|
-
status.dirty();
|
|
38099
|
-
return {
|
|
38100
|
-
status: "dirty",
|
|
38101
|
-
value: inResult.value,
|
|
38102
|
-
};
|
|
38103
|
-
}
|
|
38104
|
-
else {
|
|
38105
|
-
return this._def.out._parseSync({
|
|
38106
|
-
data: inResult.value,
|
|
38107
|
-
path: ctx.path,
|
|
38108
|
-
parent: ctx,
|
|
38109
|
-
});
|
|
38110
|
-
}
|
|
38284
|
+
|
|
38285
|
+
var helpers = {};
|
|
38286
|
+
|
|
38287
|
+
Object.defineProperty(helpers, "__esModule", { value: true });
|
|
38288
|
+
helpers.isText = helpers.isBlock = helpers.isInline = void 0;
|
|
38289
|
+
var blocks_1 = blocks;
|
|
38290
|
+
var inlines_1 = inlines;
|
|
38291
|
+
/**
|
|
38292
|
+
* Tiny replacement for Object.values(object).includes(key) to
|
|
38293
|
+
* avoid including CoreJS polyfills
|
|
38294
|
+
*/
|
|
38295
|
+
function hasValue(obj, value) {
|
|
38296
|
+
for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {
|
|
38297
|
+
var key = _a[_i];
|
|
38298
|
+
if (value === obj[key]) {
|
|
38299
|
+
return true;
|
|
38111
38300
|
}
|
|
38112
38301
|
}
|
|
38113
|
-
|
|
38114
|
-
return new ZodPipeline({
|
|
38115
|
-
in: a,
|
|
38116
|
-
out: b,
|
|
38117
|
-
typeName: ZodFirstPartyTypeKind.ZodPipeline,
|
|
38118
|
-
});
|
|
38119
|
-
}
|
|
38302
|
+
return false;
|
|
38120
38303
|
}
|
|
38121
|
-
|
|
38122
|
-
|
|
38123
|
-
|
|
38124
|
-
|
|
38125
|
-
|
|
38126
|
-
}
|
|
38127
|
-
return result;
|
|
38128
|
-
}
|
|
38304
|
+
/**
|
|
38305
|
+
* Checks if the node is an instance of Inline.
|
|
38306
|
+
*/
|
|
38307
|
+
function isInline(node) {
|
|
38308
|
+
return hasValue(inlines_1.INLINES, node.nodeType);
|
|
38129
38309
|
}
|
|
38130
|
-
|
|
38131
|
-
return new ZodReadonly({
|
|
38132
|
-
innerType: type,
|
|
38133
|
-
typeName: ZodFirstPartyTypeKind.ZodReadonly,
|
|
38134
|
-
...processCreateParams(params),
|
|
38135
|
-
});
|
|
38136
|
-
};
|
|
38137
|
-
const custom = (check, params = {},
|
|
38310
|
+
helpers.isInline = isInline;
|
|
38138
38311
|
/**
|
|
38139
|
-
*
|
|
38140
|
-
*
|
|
38141
|
-
* Pass `fatal` into the params object instead:
|
|
38142
|
-
*
|
|
38143
|
-
* ```ts
|
|
38144
|
-
* z.string().custom((val) => val.length > 5, { fatal: false })
|
|
38145
|
-
* ```
|
|
38146
|
-
*
|
|
38312
|
+
* Checks if the node is an instance of Block.
|
|
38147
38313
|
*/
|
|
38148
|
-
|
|
38149
|
-
|
|
38150
|
-
|
|
38151
|
-
|
|
38152
|
-
|
|
38153
|
-
|
|
38154
|
-
|
|
38155
|
-
|
|
38156
|
-
|
|
38157
|
-
|
|
38158
|
-
|
|
38159
|
-
const p2 = typeof p === "string" ? { message: p } : p;
|
|
38160
|
-
ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
|
|
38161
|
-
}
|
|
38162
|
-
});
|
|
38163
|
-
return ZodAny.create();
|
|
38164
|
-
};
|
|
38165
|
-
const late = {
|
|
38166
|
-
object: ZodObject.lazycreate,
|
|
38167
|
-
};
|
|
38168
|
-
var ZodFirstPartyTypeKind;
|
|
38169
|
-
(function (ZodFirstPartyTypeKind) {
|
|
38170
|
-
ZodFirstPartyTypeKind["ZodString"] = "ZodString";
|
|
38171
|
-
ZodFirstPartyTypeKind["ZodNumber"] = "ZodNumber";
|
|
38172
|
-
ZodFirstPartyTypeKind["ZodNaN"] = "ZodNaN";
|
|
38173
|
-
ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
|
|
38174
|
-
ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
|
|
38175
|
-
ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
|
|
38176
|
-
ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
|
|
38177
|
-
ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
|
|
38178
|
-
ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
|
|
38179
|
-
ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
|
|
38180
|
-
ZodFirstPartyTypeKind["ZodUnknown"] = "ZodUnknown";
|
|
38181
|
-
ZodFirstPartyTypeKind["ZodNever"] = "ZodNever";
|
|
38182
|
-
ZodFirstPartyTypeKind["ZodVoid"] = "ZodVoid";
|
|
38183
|
-
ZodFirstPartyTypeKind["ZodArray"] = "ZodArray";
|
|
38184
|
-
ZodFirstPartyTypeKind["ZodObject"] = "ZodObject";
|
|
38185
|
-
ZodFirstPartyTypeKind["ZodUnion"] = "ZodUnion";
|
|
38186
|
-
ZodFirstPartyTypeKind["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
|
|
38187
|
-
ZodFirstPartyTypeKind["ZodIntersection"] = "ZodIntersection";
|
|
38188
|
-
ZodFirstPartyTypeKind["ZodTuple"] = "ZodTuple";
|
|
38189
|
-
ZodFirstPartyTypeKind["ZodRecord"] = "ZodRecord";
|
|
38190
|
-
ZodFirstPartyTypeKind["ZodMap"] = "ZodMap";
|
|
38191
|
-
ZodFirstPartyTypeKind["ZodSet"] = "ZodSet";
|
|
38192
|
-
ZodFirstPartyTypeKind["ZodFunction"] = "ZodFunction";
|
|
38193
|
-
ZodFirstPartyTypeKind["ZodLazy"] = "ZodLazy";
|
|
38194
|
-
ZodFirstPartyTypeKind["ZodLiteral"] = "ZodLiteral";
|
|
38195
|
-
ZodFirstPartyTypeKind["ZodEnum"] = "ZodEnum";
|
|
38196
|
-
ZodFirstPartyTypeKind["ZodEffects"] = "ZodEffects";
|
|
38197
|
-
ZodFirstPartyTypeKind["ZodNativeEnum"] = "ZodNativeEnum";
|
|
38198
|
-
ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
|
|
38199
|
-
ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
|
|
38200
|
-
ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
|
|
38201
|
-
ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
|
|
38202
|
-
ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
|
|
38203
|
-
ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
|
|
38204
|
-
ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
|
|
38205
|
-
ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
|
|
38206
|
-
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
38207
|
-
const instanceOfType = (
|
|
38208
|
-
// const instanceOfType = <T extends new (...args: any[]) => any>(
|
|
38209
|
-
cls, params = {
|
|
38210
|
-
message: `Input not instance of ${cls.name}`,
|
|
38211
|
-
}) => custom((data) => data instanceof cls, params);
|
|
38212
|
-
const stringType = ZodString.create;
|
|
38213
|
-
const numberType = ZodNumber.create;
|
|
38214
|
-
const nanType = ZodNaN.create;
|
|
38215
|
-
const bigIntType = ZodBigInt.create;
|
|
38216
|
-
const booleanType = ZodBoolean.create;
|
|
38217
|
-
const dateType = ZodDate.create;
|
|
38218
|
-
const symbolType = ZodSymbol.create;
|
|
38219
|
-
const undefinedType = ZodUndefined.create;
|
|
38220
|
-
const nullType = ZodNull.create;
|
|
38221
|
-
const anyType = ZodAny.create;
|
|
38222
|
-
const unknownType = ZodUnknown.create;
|
|
38223
|
-
const neverType = ZodNever.create;
|
|
38224
|
-
const voidType = ZodVoid.create;
|
|
38225
|
-
const arrayType = ZodArray.create;
|
|
38226
|
-
const objectType = ZodObject.create;
|
|
38227
|
-
const strictObjectType = ZodObject.strictCreate;
|
|
38228
|
-
const unionType = ZodUnion.create;
|
|
38229
|
-
const discriminatedUnionType = ZodDiscriminatedUnion.create;
|
|
38230
|
-
const intersectionType = ZodIntersection.create;
|
|
38231
|
-
const tupleType = ZodTuple.create;
|
|
38232
|
-
const recordType = ZodRecord.create;
|
|
38233
|
-
const mapType = ZodMap.create;
|
|
38234
|
-
const setType = ZodSet.create;
|
|
38235
|
-
const functionType = ZodFunction.create;
|
|
38236
|
-
const lazyType = ZodLazy.create;
|
|
38237
|
-
const literalType = ZodLiteral.create;
|
|
38238
|
-
const enumType = ZodEnum.create;
|
|
38239
|
-
const nativeEnumType = ZodNativeEnum.create;
|
|
38240
|
-
const promiseType = ZodPromise.create;
|
|
38241
|
-
const effectsType = ZodEffects.create;
|
|
38242
|
-
const optionalType = ZodOptional.create;
|
|
38243
|
-
const nullableType = ZodNullable.create;
|
|
38244
|
-
const preprocessType = ZodEffects.createWithPreprocess;
|
|
38245
|
-
const pipelineType = ZodPipeline.create;
|
|
38246
|
-
const ostring = () => stringType().optional();
|
|
38247
|
-
const onumber = () => numberType().optional();
|
|
38248
|
-
const oboolean = () => booleanType().optional();
|
|
38249
|
-
const coerce = {
|
|
38250
|
-
string: ((arg) => ZodString.create({ ...arg, coerce: true })),
|
|
38251
|
-
number: ((arg) => ZodNumber.create({ ...arg, coerce: true })),
|
|
38252
|
-
boolean: ((arg) => ZodBoolean.create({
|
|
38253
|
-
...arg,
|
|
38254
|
-
coerce: true,
|
|
38255
|
-
})),
|
|
38256
|
-
bigint: ((arg) => ZodBigInt.create({ ...arg, coerce: true })),
|
|
38257
|
-
date: ((arg) => ZodDate.create({ ...arg, coerce: true })),
|
|
38258
|
-
};
|
|
38259
|
-
const NEVER = INVALID;
|
|
38314
|
+
function isBlock(node) {
|
|
38315
|
+
return hasValue(blocks_1.BLOCKS, node.nodeType);
|
|
38316
|
+
}
|
|
38317
|
+
helpers.isBlock = isBlock;
|
|
38318
|
+
/**
|
|
38319
|
+
* Checks if the node is an instance of Text.
|
|
38320
|
+
*/
|
|
38321
|
+
function isText(node) {
|
|
38322
|
+
return node.nodeType === 'text';
|
|
38323
|
+
}
|
|
38324
|
+
helpers.isText = isText;
|
|
38260
38325
|
|
|
38261
|
-
|
|
38262
|
-
|
|
38263
|
-
|
|
38264
|
-
|
|
38265
|
-
|
|
38266
|
-
|
|
38267
|
-
|
|
38268
|
-
|
|
38269
|
-
|
|
38270
|
-
|
|
38271
|
-
|
|
38272
|
-
|
|
38273
|
-
|
|
38274
|
-
|
|
38275
|
-
|
|
38276
|
-
|
|
38277
|
-
|
|
38278
|
-
|
|
38279
|
-
|
|
38280
|
-
|
|
38281
|
-
|
|
38282
|
-
|
|
38283
|
-
|
|
38284
|
-
|
|
38285
|
-
|
|
38286
|
-
|
|
38287
|
-
|
|
38288
|
-
|
|
38289
|
-
|
|
38290
|
-
|
|
38291
|
-
|
|
38292
|
-
|
|
38293
|
-
|
|
38294
|
-
|
|
38295
|
-
|
|
38296
|
-
|
|
38297
|
-
|
|
38298
|
-
|
|
38299
|
-
|
|
38300
|
-
|
|
38301
|
-
|
|
38302
|
-
|
|
38303
|
-
|
|
38304
|
-
|
|
38305
|
-
ZodLiteral: ZodLiteral,
|
|
38306
|
-
ZodEnum: ZodEnum,
|
|
38307
|
-
ZodNativeEnum: ZodNativeEnum,
|
|
38308
|
-
ZodPromise: ZodPromise,
|
|
38309
|
-
ZodEffects: ZodEffects,
|
|
38310
|
-
ZodTransformer: ZodEffects,
|
|
38311
|
-
ZodOptional: ZodOptional,
|
|
38312
|
-
ZodNullable: ZodNullable,
|
|
38313
|
-
ZodDefault: ZodDefault,
|
|
38314
|
-
ZodCatch: ZodCatch,
|
|
38315
|
-
ZodNaN: ZodNaN,
|
|
38316
|
-
BRAND: BRAND,
|
|
38317
|
-
ZodBranded: ZodBranded,
|
|
38318
|
-
ZodPipeline: ZodPipeline,
|
|
38319
|
-
ZodReadonly: ZodReadonly,
|
|
38320
|
-
custom: custom,
|
|
38321
|
-
Schema: ZodType,
|
|
38322
|
-
ZodSchema: ZodType,
|
|
38323
|
-
late: late,
|
|
38324
|
-
get ZodFirstPartyTypeKind () { return ZodFirstPartyTypeKind; },
|
|
38325
|
-
coerce: coerce,
|
|
38326
|
-
any: anyType,
|
|
38327
|
-
array: arrayType,
|
|
38328
|
-
bigint: bigIntType,
|
|
38329
|
-
boolean: booleanType,
|
|
38330
|
-
date: dateType,
|
|
38331
|
-
discriminatedUnion: discriminatedUnionType,
|
|
38332
|
-
effect: effectsType,
|
|
38333
|
-
'enum': enumType,
|
|
38334
|
-
'function': functionType,
|
|
38335
|
-
'instanceof': instanceOfType,
|
|
38336
|
-
intersection: intersectionType,
|
|
38337
|
-
lazy: lazyType,
|
|
38338
|
-
literal: literalType,
|
|
38339
|
-
map: mapType,
|
|
38340
|
-
nan: nanType,
|
|
38341
|
-
nativeEnum: nativeEnumType,
|
|
38342
|
-
never: neverType,
|
|
38343
|
-
'null': nullType,
|
|
38344
|
-
nullable: nullableType,
|
|
38345
|
-
number: numberType,
|
|
38346
|
-
object: objectType,
|
|
38347
|
-
oboolean: oboolean,
|
|
38348
|
-
onumber: onumber,
|
|
38349
|
-
optional: optionalType,
|
|
38350
|
-
ostring: ostring,
|
|
38351
|
-
pipeline: pipelineType,
|
|
38352
|
-
preprocess: preprocessType,
|
|
38353
|
-
promise: promiseType,
|
|
38354
|
-
record: recordType,
|
|
38355
|
-
set: setType,
|
|
38356
|
-
strictObject: strictObjectType,
|
|
38357
|
-
string: stringType,
|
|
38358
|
-
symbol: symbolType,
|
|
38359
|
-
transformer: effectsType,
|
|
38360
|
-
tuple: tupleType,
|
|
38361
|
-
'undefined': undefinedType,
|
|
38362
|
-
union: unionType,
|
|
38363
|
-
unknown: unknownType,
|
|
38364
|
-
'void': voidType,
|
|
38365
|
-
NEVER: NEVER,
|
|
38366
|
-
ZodIssueCode: ZodIssueCode,
|
|
38367
|
-
quotelessJson: quotelessJson,
|
|
38368
|
-
ZodError: ZodError
|
|
38369
|
-
});
|
|
38326
|
+
(function (exports) {
|
|
38327
|
+
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
38328
|
+
if (k2 === undefined) k2 = k;
|
|
38329
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
38330
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
38331
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
38332
|
+
}
|
|
38333
|
+
Object.defineProperty(o, k2, desc);
|
|
38334
|
+
}) : (function(o, m, k, k2) {
|
|
38335
|
+
if (k2 === undefined) k2 = k;
|
|
38336
|
+
o[k2] = m[k];
|
|
38337
|
+
}));
|
|
38338
|
+
var __setModuleDefault = (commonjsGlobal && commonjsGlobal.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
38339
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
38340
|
+
}) : function(o, v) {
|
|
38341
|
+
o["default"] = v;
|
|
38342
|
+
});
|
|
38343
|
+
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
38344
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
38345
|
+
};
|
|
38346
|
+
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
|
|
38347
|
+
if (mod && mod.__esModule) return mod;
|
|
38348
|
+
var result = {};
|
|
38349
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
38350
|
+
__setModuleDefault(result, mod);
|
|
38351
|
+
return result;
|
|
38352
|
+
};
|
|
38353
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38354
|
+
exports.helpers = exports.EMPTY_DOCUMENT = exports.MARKS = exports.INLINES = exports.BLOCKS = void 0;
|
|
38355
|
+
var blocks_1 = blocks;
|
|
38356
|
+
Object.defineProperty(exports, "BLOCKS", { enumerable: true, get: function () { return blocks_1.BLOCKS; } });
|
|
38357
|
+
var inlines_1 = inlines;
|
|
38358
|
+
Object.defineProperty(exports, "INLINES", { enumerable: true, get: function () { return inlines_1.INLINES; } });
|
|
38359
|
+
var marks_1 = marks;
|
|
38360
|
+
Object.defineProperty(exports, "MARKS", { enumerable: true, get: function () { return marks_1.MARKS; } });
|
|
38361
|
+
__exportStar(schemaConstraints, exports);
|
|
38362
|
+
__exportStar(types, exports);
|
|
38363
|
+
__exportStar(nodeTypes, exports);
|
|
38364
|
+
var emptyDocument_1 = emptyDocument;
|
|
38365
|
+
Object.defineProperty(exports, "EMPTY_DOCUMENT", { enumerable: true, get: function () { return emptyDocument_1.EMPTY_DOCUMENT; } });
|
|
38366
|
+
var helpers$1 = __importStar(helpers);
|
|
38367
|
+
exports.helpers = helpers$1;
|
|
38368
|
+
|
|
38369
|
+
} (dist));
|
|
38370
38370
|
|
|
38371
38371
|
/** Detect free variable `global` from Node.js. */
|
|
38372
38372
|
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
|
@@ -42275,244 +42275,13 @@ const buildCfStyles = ({ cfHorizontalAlignment, cfVerticalAlignment, cfFlexDirec
|
|
|
42275
42275
|
* If a container component has children => height: 'fit-content'
|
|
42276
42276
|
*/
|
|
42277
42277
|
const calculateNodeDefaultHeight = ({ blockId, children, value, }) => {
|
|
42278
|
-
if (!blockId || !isContentfulStructureComponent(blockId) || value !== 'auto') {
|
|
42279
|
-
return value;
|
|
42280
|
-
}
|
|
42281
|
-
if (children.length) {
|
|
42282
|
-
return '100%';
|
|
42283
|
-
}
|
|
42284
|
-
return EMPTY_CONTAINER_HEIGHT$1;
|
|
42285
|
-
};
|
|
42286
|
-
|
|
42287
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42288
|
-
function get(obj, path) {
|
|
42289
|
-
if (!path.length) {
|
|
42290
|
-
return obj;
|
|
42291
|
-
}
|
|
42292
|
-
try {
|
|
42293
|
-
const [currentPath, ...nextPath] = path;
|
|
42294
|
-
return get(obj[currentPath], nextPath);
|
|
42295
|
-
}
|
|
42296
|
-
catch (err) {
|
|
42297
|
-
return undefined;
|
|
42298
|
-
}
|
|
42299
|
-
}
|
|
42300
|
-
|
|
42301
|
-
const getBoundValue = (entryOrAsset, path) => {
|
|
42302
|
-
const value = get(entryOrAsset, path.split('/').slice(2, -1));
|
|
42303
|
-
return value && typeof value == 'object' && value.url
|
|
42304
|
-
? value.url
|
|
42305
|
-
: value;
|
|
42306
|
-
};
|
|
42307
|
-
|
|
42308
|
-
const transformRichText = (entryOrAsset, path) => {
|
|
42309
|
-
const value = getBoundValue(entryOrAsset, path);
|
|
42310
|
-
if (typeof value === 'string') {
|
|
42311
|
-
return {
|
|
42312
|
-
data: {},
|
|
42313
|
-
content: [
|
|
42314
|
-
{
|
|
42315
|
-
nodeType: dist.BLOCKS.PARAGRAPH,
|
|
42316
|
-
data: {},
|
|
42317
|
-
content: [
|
|
42318
|
-
{
|
|
42319
|
-
data: {},
|
|
42320
|
-
nodeType: 'text',
|
|
42321
|
-
value: value,
|
|
42322
|
-
marks: [],
|
|
42323
|
-
},
|
|
42324
|
-
],
|
|
42325
|
-
},
|
|
42326
|
-
],
|
|
42327
|
-
nodeType: dist.BLOCKS.DOCUMENT,
|
|
42328
|
-
};
|
|
42329
|
-
}
|
|
42330
|
-
if (typeof value === 'object' && value.nodeType === dist.BLOCKS.DOCUMENT) {
|
|
42331
|
-
return value;
|
|
42332
|
-
}
|
|
42333
|
-
return undefined;
|
|
42334
|
-
};
|
|
42335
|
-
|
|
42336
|
-
function getOptimizedImageUrl(url, width, quality, format) {
|
|
42337
|
-
if (url.startsWith('//')) {
|
|
42338
|
-
url = 'https:' + url;
|
|
42339
|
-
}
|
|
42340
|
-
const params = new URLSearchParams();
|
|
42341
|
-
if (width) {
|
|
42342
|
-
params.append('w', width.toString());
|
|
42343
|
-
}
|
|
42344
|
-
if (quality && quality > 0 && quality < 100) {
|
|
42345
|
-
params.append('q', quality.toString());
|
|
42346
|
-
}
|
|
42347
|
-
if (format) {
|
|
42348
|
-
params.append('fm', format);
|
|
42349
|
-
}
|
|
42350
|
-
const queryString = params.toString();
|
|
42351
|
-
return `${url}${queryString ? '?' + queryString : ''}`;
|
|
42352
|
-
}
|
|
42353
|
-
|
|
42354
|
-
function validateParams(file, quality, format) {
|
|
42355
|
-
if (!file.details.image) {
|
|
42356
|
-
throw Error('No image in file asset to transform');
|
|
42357
|
-
}
|
|
42358
|
-
if (quality < 0 || quality > 100) {
|
|
42359
|
-
throw Error('Quality must be between 0 and 100');
|
|
42360
|
-
}
|
|
42361
|
-
if (format && !SUPPORTED_IMAGE_FORMATS.includes(format)) {
|
|
42362
|
-
throw Error(`Format must be one of ${SUPPORTED_IMAGE_FORMATS.join(', ')}`);
|
|
42363
|
-
}
|
|
42364
|
-
return true;
|
|
42365
|
-
}
|
|
42366
|
-
|
|
42367
|
-
const MAX_WIDTH_ALLOWED$1 = 2000;
|
|
42368
|
-
const getOptimizedBackgroundImageAsset = (file, widthStyle, quality = '100%', format) => {
|
|
42369
|
-
const qualityNumber = Number(quality.replace('%', ''));
|
|
42370
|
-
if (!validateParams(file, qualityNumber, format)) ;
|
|
42371
|
-
if (!validateParams(file, qualityNumber, format)) ;
|
|
42372
|
-
const url = file.url;
|
|
42373
|
-
const { width1x, width2x } = getWidths(widthStyle, file);
|
|
42374
|
-
const imageUrl1x = getOptimizedImageUrl(url, width1x, qualityNumber, format);
|
|
42375
|
-
const imageUrl2x = getOptimizedImageUrl(url, width2x, qualityNumber, format);
|
|
42376
|
-
const srcSet = [`url(${imageUrl1x}) 1x`, `url(${imageUrl2x}) 2x`];
|
|
42377
|
-
const returnedUrl = getOptimizedImageUrl(url, width2x, qualityNumber, format);
|
|
42378
|
-
const optimizedBackgroundImageAsset = {
|
|
42379
|
-
url: returnedUrl,
|
|
42380
|
-
srcSet,
|
|
42381
|
-
file,
|
|
42382
|
-
};
|
|
42383
|
-
return optimizedBackgroundImageAsset;
|
|
42384
|
-
function getWidths(widthStyle, file) {
|
|
42385
|
-
let width1x = 0;
|
|
42386
|
-
let width2x = 0;
|
|
42387
|
-
const intrinsicImageWidth = file.details.image.width;
|
|
42388
|
-
if (widthStyle.endsWith('px')) {
|
|
42389
|
-
width1x = Math.min(Number(widthStyle.replace('px', '')), intrinsicImageWidth);
|
|
42390
|
-
}
|
|
42391
|
-
else {
|
|
42392
|
-
width1x = Math.min(MAX_WIDTH_ALLOWED$1, intrinsicImageWidth);
|
|
42393
|
-
}
|
|
42394
|
-
width2x = Math.min(width1x * 2, intrinsicImageWidth);
|
|
42395
|
-
return { width1x, width2x };
|
|
42396
|
-
}
|
|
42397
|
-
};
|
|
42398
|
-
|
|
42399
|
-
const MAX_WIDTH_ALLOWED = 4000;
|
|
42400
|
-
const getOptimizedImageAsset = ({ file, sizes, loading, quality = '100%', format, }) => {
|
|
42401
|
-
const qualityNumber = Number(quality.replace('%', ''));
|
|
42402
|
-
if (!validateParams(file, qualityNumber, format)) ;
|
|
42403
|
-
const url = file.url;
|
|
42404
|
-
const maxWidth = Math.min(file.details.image.width, MAX_WIDTH_ALLOWED);
|
|
42405
|
-
const numOfParts = Math.max(2, Math.ceil(maxWidth / 500));
|
|
42406
|
-
const widthParts = Array.from({ length: numOfParts }, (_, index) => Math.ceil((index + 1) * (maxWidth / numOfParts)));
|
|
42407
|
-
const srcSet = sizes
|
|
42408
|
-
? widthParts.map((width) => `${getOptimizedImageUrl(url, width, qualityNumber, format)} ${width}w`)
|
|
42409
|
-
: [];
|
|
42410
|
-
const intrinsicImageWidth = file.details.image.width;
|
|
42411
|
-
if (intrinsicImageWidth > MAX_WIDTH_ALLOWED) {
|
|
42412
|
-
srcSet.push(`${getOptimizedImageUrl(url, undefined, qualityNumber, format)} ${intrinsicImageWidth}w`);
|
|
42413
|
-
}
|
|
42414
|
-
const returnedUrl = getOptimizedImageUrl(url, file.details.image.width > 2000 ? 2000 : undefined, qualityNumber, format);
|
|
42415
|
-
const optimizedImageAsset = {
|
|
42416
|
-
url: returnedUrl,
|
|
42417
|
-
srcSet,
|
|
42418
|
-
sizes,
|
|
42419
|
-
file,
|
|
42420
|
-
loading,
|
|
42421
|
-
};
|
|
42422
|
-
return optimizedImageAsset;
|
|
42423
|
-
};
|
|
42424
|
-
|
|
42425
|
-
const transformMedia = (asset, variables, resolveDesignValue, variableName, path) => {
|
|
42426
|
-
let value;
|
|
42427
|
-
// If it is not a deep path and not pointing to the file of the asset,
|
|
42428
|
-
// it is just pointing to a normal field and therefore we just resolve the value as normal field
|
|
42429
|
-
if (!isDeepPath(path) && !lastPathNamedSegmentEq(path, 'file')) {
|
|
42430
|
-
return getBoundValue(asset, path);
|
|
42431
|
-
}
|
|
42432
|
-
//TODO: this will be better served by injectable type transformers instead of if statement
|
|
42433
|
-
if (variableName === 'cfImageAsset') {
|
|
42434
|
-
const optionsVariableName = 'cfImageOptions';
|
|
42435
|
-
const options = resolveDesignValue(variables[optionsVariableName]?.type === 'DesignValue'
|
|
42436
|
-
? variables[optionsVariableName].valuesByBreakpoint
|
|
42437
|
-
: {}, optionsVariableName);
|
|
42438
|
-
if (!options) {
|
|
42439
|
-
console.error(`Error transforming image asset: Required variable [${optionsVariableName}] missing from component definition`);
|
|
42440
|
-
return;
|
|
42441
|
-
}
|
|
42442
|
-
try {
|
|
42443
|
-
value = getOptimizedImageAsset({
|
|
42444
|
-
file: asset.fields.file,
|
|
42445
|
-
loading: options.loading,
|
|
42446
|
-
sizes: options.targetSize,
|
|
42447
|
-
quality: options.quality,
|
|
42448
|
-
format: options.format,
|
|
42449
|
-
});
|
|
42450
|
-
return value;
|
|
42451
|
-
}
|
|
42452
|
-
catch (error) {
|
|
42453
|
-
console.error('Error transforming image asset', error);
|
|
42454
|
-
}
|
|
42455
|
-
return;
|
|
42456
|
-
}
|
|
42457
|
-
if (variableName === 'cfBackgroundImageUrl') {
|
|
42458
|
-
const width = resolveDesignValue(variables['cfWidth']?.type === 'DesignValue' ? variables['cfWidth'].valuesByBreakpoint : {}, 'cfWidth');
|
|
42459
|
-
const optionsVariableName = 'cfBackgroundImageOptions';
|
|
42460
|
-
const options = resolveDesignValue(variables[optionsVariableName]?.type === 'DesignValue'
|
|
42461
|
-
? variables[optionsVariableName].valuesByBreakpoint
|
|
42462
|
-
: {}, optionsVariableName);
|
|
42463
|
-
if (!options) {
|
|
42464
|
-
console.error(`Error transforming image asset: Required variable [${optionsVariableName}] missing from component definition`);
|
|
42465
|
-
return;
|
|
42466
|
-
}
|
|
42467
|
-
try {
|
|
42468
|
-
value = getOptimizedBackgroundImageAsset(asset.fields.file, width, options.quality, options.format);
|
|
42469
|
-
return value;
|
|
42470
|
-
}
|
|
42471
|
-
catch (error) {
|
|
42472
|
-
console.error('Error transforming image asset', error);
|
|
42473
|
-
}
|
|
42474
|
-
return;
|
|
42475
|
-
}
|
|
42476
|
-
return asset.fields.file?.url;
|
|
42477
|
-
};
|
|
42478
|
-
|
|
42479
|
-
const transformBoundContentValue = (variables, entityStore, binding, resolveDesignValue, variableName, variableDefinition, path) => {
|
|
42480
|
-
const entityOrAsset = entityStore.getEntryOrAsset(binding, path);
|
|
42481
|
-
if (!entityOrAsset)
|
|
42482
|
-
return;
|
|
42483
|
-
switch (variableDefinition.type) {
|
|
42484
|
-
case 'Media':
|
|
42485
|
-
// If we bound a normal entry field to the media veriable we just return the bound value
|
|
42486
|
-
if (entityOrAsset.sys.type === 'Entry') {
|
|
42487
|
-
return getBoundValue(entityOrAsset, path);
|
|
42488
|
-
}
|
|
42489
|
-
return transformMedia(entityOrAsset, variables, resolveDesignValue, variableName, path);
|
|
42490
|
-
case 'RichText':
|
|
42491
|
-
return transformRichText(entityOrAsset, path);
|
|
42492
|
-
default:
|
|
42493
|
-
return getBoundValue(entityOrAsset, path);
|
|
42278
|
+
if (!blockId || !isContentfulStructureComponent(blockId) || value !== 'auto') {
|
|
42279
|
+
return value;
|
|
42494
42280
|
}
|
|
42495
|
-
|
|
42496
|
-
|
|
42497
|
-
const getDataFromTree = (tree) => {
|
|
42498
|
-
let dataSource = {};
|
|
42499
|
-
let unboundValues = {};
|
|
42500
|
-
const queue = [...tree.root.children];
|
|
42501
|
-
while (queue.length) {
|
|
42502
|
-
const node = queue.shift();
|
|
42503
|
-
if (!node) {
|
|
42504
|
-
continue;
|
|
42505
|
-
}
|
|
42506
|
-
dataSource = { ...dataSource, ...node.data.dataSource };
|
|
42507
|
-
unboundValues = { ...unboundValues, ...node.data.unboundValues };
|
|
42508
|
-
if (node.children.length) {
|
|
42509
|
-
queue.push(...node.children);
|
|
42510
|
-
}
|
|
42281
|
+
if (children.length) {
|
|
42282
|
+
return '100%';
|
|
42511
42283
|
}
|
|
42512
|
-
return
|
|
42513
|
-
dataSource,
|
|
42514
|
-
unboundValues,
|
|
42515
|
-
};
|
|
42284
|
+
return EMPTY_CONTAINER_HEIGHT$1;
|
|
42516
42285
|
};
|
|
42517
42286
|
|
|
42518
42287
|
// These styles get added to every component, user custom or contentful provided
|
|
@@ -43101,6 +42870,237 @@ var CodeNames;
|
|
|
43101
42870
|
CodeNames["Custom"] = "custom";
|
|
43102
42871
|
})(CodeNames || (CodeNames = {}));
|
|
43103
42872
|
|
|
42873
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42874
|
+
function get(obj, path) {
|
|
42875
|
+
if (!path.length) {
|
|
42876
|
+
return obj;
|
|
42877
|
+
}
|
|
42878
|
+
try {
|
|
42879
|
+
const [currentPath, ...nextPath] = path;
|
|
42880
|
+
return get(obj[currentPath], nextPath);
|
|
42881
|
+
}
|
|
42882
|
+
catch (err) {
|
|
42883
|
+
return undefined;
|
|
42884
|
+
}
|
|
42885
|
+
}
|
|
42886
|
+
|
|
42887
|
+
const getBoundValue = (entryOrAsset, path) => {
|
|
42888
|
+
const value = get(entryOrAsset, path.split('/').slice(2, -1));
|
|
42889
|
+
return value && typeof value == 'object' && value.url
|
|
42890
|
+
? value.url
|
|
42891
|
+
: value;
|
|
42892
|
+
};
|
|
42893
|
+
|
|
42894
|
+
const transformRichText = (entryOrAsset, path) => {
|
|
42895
|
+
const value = getBoundValue(entryOrAsset, path);
|
|
42896
|
+
if (typeof value === 'string') {
|
|
42897
|
+
return {
|
|
42898
|
+
data: {},
|
|
42899
|
+
content: [
|
|
42900
|
+
{
|
|
42901
|
+
nodeType: dist.BLOCKS.PARAGRAPH,
|
|
42902
|
+
data: {},
|
|
42903
|
+
content: [
|
|
42904
|
+
{
|
|
42905
|
+
data: {},
|
|
42906
|
+
nodeType: 'text',
|
|
42907
|
+
value: value,
|
|
42908
|
+
marks: [],
|
|
42909
|
+
},
|
|
42910
|
+
],
|
|
42911
|
+
},
|
|
42912
|
+
],
|
|
42913
|
+
nodeType: dist.BLOCKS.DOCUMENT,
|
|
42914
|
+
};
|
|
42915
|
+
}
|
|
42916
|
+
if (typeof value === 'object' && value.nodeType === dist.BLOCKS.DOCUMENT) {
|
|
42917
|
+
return value;
|
|
42918
|
+
}
|
|
42919
|
+
return undefined;
|
|
42920
|
+
};
|
|
42921
|
+
|
|
42922
|
+
function getOptimizedImageUrl(url, width, quality, format) {
|
|
42923
|
+
if (url.startsWith('//')) {
|
|
42924
|
+
url = 'https:' + url;
|
|
42925
|
+
}
|
|
42926
|
+
const params = new URLSearchParams();
|
|
42927
|
+
if (width) {
|
|
42928
|
+
params.append('w', width.toString());
|
|
42929
|
+
}
|
|
42930
|
+
if (quality && quality > 0 && quality < 100) {
|
|
42931
|
+
params.append('q', quality.toString());
|
|
42932
|
+
}
|
|
42933
|
+
if (format) {
|
|
42934
|
+
params.append('fm', format);
|
|
42935
|
+
}
|
|
42936
|
+
const queryString = params.toString();
|
|
42937
|
+
return `${url}${queryString ? '?' + queryString : ''}`;
|
|
42938
|
+
}
|
|
42939
|
+
|
|
42940
|
+
function validateParams(file, quality, format) {
|
|
42941
|
+
if (!file.details.image) {
|
|
42942
|
+
throw Error('No image in file asset to transform');
|
|
42943
|
+
}
|
|
42944
|
+
if (quality < 0 || quality > 100) {
|
|
42945
|
+
throw Error('Quality must be between 0 and 100');
|
|
42946
|
+
}
|
|
42947
|
+
if (format && !SUPPORTED_IMAGE_FORMATS.includes(format)) {
|
|
42948
|
+
throw Error(`Format must be one of ${SUPPORTED_IMAGE_FORMATS.join(', ')}`);
|
|
42949
|
+
}
|
|
42950
|
+
return true;
|
|
42951
|
+
}
|
|
42952
|
+
|
|
42953
|
+
const MAX_WIDTH_ALLOWED$1 = 2000;
|
|
42954
|
+
const getOptimizedBackgroundImageAsset = (file, widthStyle, quality = '100%', format) => {
|
|
42955
|
+
const qualityNumber = Number(quality.replace('%', ''));
|
|
42956
|
+
if (!validateParams(file, qualityNumber, format)) ;
|
|
42957
|
+
if (!validateParams(file, qualityNumber, format)) ;
|
|
42958
|
+
const url = file.url;
|
|
42959
|
+
const { width1x, width2x } = getWidths(widthStyle, file);
|
|
42960
|
+
const imageUrl1x = getOptimizedImageUrl(url, width1x, qualityNumber, format);
|
|
42961
|
+
const imageUrl2x = getOptimizedImageUrl(url, width2x, qualityNumber, format);
|
|
42962
|
+
const srcSet = [`url(${imageUrl1x}) 1x`, `url(${imageUrl2x}) 2x`];
|
|
42963
|
+
const returnedUrl = getOptimizedImageUrl(url, width2x, qualityNumber, format);
|
|
42964
|
+
const optimizedBackgroundImageAsset = {
|
|
42965
|
+
url: returnedUrl,
|
|
42966
|
+
srcSet,
|
|
42967
|
+
file,
|
|
42968
|
+
};
|
|
42969
|
+
return optimizedBackgroundImageAsset;
|
|
42970
|
+
function getWidths(widthStyle, file) {
|
|
42971
|
+
let width1x = 0;
|
|
42972
|
+
let width2x = 0;
|
|
42973
|
+
const intrinsicImageWidth = file.details.image.width;
|
|
42974
|
+
if (widthStyle.endsWith('px')) {
|
|
42975
|
+
width1x = Math.min(Number(widthStyle.replace('px', '')), intrinsicImageWidth);
|
|
42976
|
+
}
|
|
42977
|
+
else {
|
|
42978
|
+
width1x = Math.min(MAX_WIDTH_ALLOWED$1, intrinsicImageWidth);
|
|
42979
|
+
}
|
|
42980
|
+
width2x = Math.min(width1x * 2, intrinsicImageWidth);
|
|
42981
|
+
return { width1x, width2x };
|
|
42982
|
+
}
|
|
42983
|
+
};
|
|
42984
|
+
|
|
42985
|
+
const MAX_WIDTH_ALLOWED = 4000;
|
|
42986
|
+
const getOptimizedImageAsset = ({ file, sizes, loading, quality = '100%', format, }) => {
|
|
42987
|
+
const qualityNumber = Number(quality.replace('%', ''));
|
|
42988
|
+
if (!validateParams(file, qualityNumber, format)) ;
|
|
42989
|
+
const url = file.url;
|
|
42990
|
+
const maxWidth = Math.min(file.details.image.width, MAX_WIDTH_ALLOWED);
|
|
42991
|
+
const numOfParts = Math.max(2, Math.ceil(maxWidth / 500));
|
|
42992
|
+
const widthParts = Array.from({ length: numOfParts }, (_, index) => Math.ceil((index + 1) * (maxWidth / numOfParts)));
|
|
42993
|
+
const srcSet = sizes
|
|
42994
|
+
? widthParts.map((width) => `${getOptimizedImageUrl(url, width, qualityNumber, format)} ${width}w`)
|
|
42995
|
+
: [];
|
|
42996
|
+
const intrinsicImageWidth = file.details.image.width;
|
|
42997
|
+
if (intrinsicImageWidth > MAX_WIDTH_ALLOWED) {
|
|
42998
|
+
srcSet.push(`${getOptimizedImageUrl(url, undefined, qualityNumber, format)} ${intrinsicImageWidth}w`);
|
|
42999
|
+
}
|
|
43000
|
+
const returnedUrl = getOptimizedImageUrl(url, file.details.image.width > 2000 ? 2000 : undefined, qualityNumber, format);
|
|
43001
|
+
const optimizedImageAsset = {
|
|
43002
|
+
url: returnedUrl,
|
|
43003
|
+
srcSet,
|
|
43004
|
+
sizes,
|
|
43005
|
+
file,
|
|
43006
|
+
loading,
|
|
43007
|
+
};
|
|
43008
|
+
return optimizedImageAsset;
|
|
43009
|
+
};
|
|
43010
|
+
|
|
43011
|
+
const transformMedia = (asset, variables, resolveDesignValue, variableName, path) => {
|
|
43012
|
+
let value;
|
|
43013
|
+
// If it is not a deep path and not pointing to the file of the asset,
|
|
43014
|
+
// it is just pointing to a normal field and therefore we just resolve the value as normal field
|
|
43015
|
+
if (!isDeepPath(path) && !lastPathNamedSegmentEq(path, 'file')) {
|
|
43016
|
+
return getBoundValue(asset, path);
|
|
43017
|
+
}
|
|
43018
|
+
//TODO: this will be better served by injectable type transformers instead of if statement
|
|
43019
|
+
if (variableName === 'cfImageAsset') {
|
|
43020
|
+
const optionsVariableName = 'cfImageOptions';
|
|
43021
|
+
const options = resolveDesignValue(variables[optionsVariableName]?.type === 'DesignValue'
|
|
43022
|
+
? variables[optionsVariableName].valuesByBreakpoint
|
|
43023
|
+
: {}, optionsVariableName);
|
|
43024
|
+
if (!options) {
|
|
43025
|
+
console.error(`Error transforming image asset: Required variable [${optionsVariableName}] missing from component definition`);
|
|
43026
|
+
return;
|
|
43027
|
+
}
|
|
43028
|
+
try {
|
|
43029
|
+
value = getOptimizedImageAsset({
|
|
43030
|
+
file: asset.fields.file,
|
|
43031
|
+
loading: options.loading,
|
|
43032
|
+
sizes: options.targetSize,
|
|
43033
|
+
quality: options.quality,
|
|
43034
|
+
format: options.format,
|
|
43035
|
+
});
|
|
43036
|
+
return value;
|
|
43037
|
+
}
|
|
43038
|
+
catch (error) {
|
|
43039
|
+
console.error('Error transforming image asset', error);
|
|
43040
|
+
}
|
|
43041
|
+
return;
|
|
43042
|
+
}
|
|
43043
|
+
if (variableName === 'cfBackgroundImageUrl') {
|
|
43044
|
+
const width = resolveDesignValue(variables['cfWidth']?.type === 'DesignValue' ? variables['cfWidth'].valuesByBreakpoint : {}, 'cfWidth');
|
|
43045
|
+
const optionsVariableName = 'cfBackgroundImageOptions';
|
|
43046
|
+
const options = resolveDesignValue(variables[optionsVariableName]?.type === 'DesignValue'
|
|
43047
|
+
? variables[optionsVariableName].valuesByBreakpoint
|
|
43048
|
+
: {}, optionsVariableName);
|
|
43049
|
+
if (!options) {
|
|
43050
|
+
console.error(`Error transforming image asset: Required variable [${optionsVariableName}] missing from component definition`);
|
|
43051
|
+
return;
|
|
43052
|
+
}
|
|
43053
|
+
try {
|
|
43054
|
+
value = getOptimizedBackgroundImageAsset(asset.fields.file, width, options.quality, options.format);
|
|
43055
|
+
return value;
|
|
43056
|
+
}
|
|
43057
|
+
catch (error) {
|
|
43058
|
+
console.error('Error transforming image asset', error);
|
|
43059
|
+
}
|
|
43060
|
+
return;
|
|
43061
|
+
}
|
|
43062
|
+
return asset.fields.file?.url;
|
|
43063
|
+
};
|
|
43064
|
+
|
|
43065
|
+
const transformBoundContentValue = (variables, entityStore, binding, resolveDesignValue, variableName, variableDefinition, path) => {
|
|
43066
|
+
const entityOrAsset = entityStore.getEntryOrAsset(binding, path);
|
|
43067
|
+
if (!entityOrAsset)
|
|
43068
|
+
return;
|
|
43069
|
+
switch (variableDefinition.type) {
|
|
43070
|
+
case 'Media':
|
|
43071
|
+
// If we bound a normal entry field to the media veriable we just return the bound value
|
|
43072
|
+
if (entityOrAsset.sys.type === 'Entry') {
|
|
43073
|
+
return getBoundValue(entityOrAsset, path);
|
|
43074
|
+
}
|
|
43075
|
+
return transformMedia(entityOrAsset, variables, resolveDesignValue, variableName, path);
|
|
43076
|
+
case 'RichText':
|
|
43077
|
+
return transformRichText(entityOrAsset, path);
|
|
43078
|
+
default:
|
|
43079
|
+
return getBoundValue(entityOrAsset, path);
|
|
43080
|
+
}
|
|
43081
|
+
};
|
|
43082
|
+
|
|
43083
|
+
const getDataFromTree = (tree) => {
|
|
43084
|
+
let dataSource = {};
|
|
43085
|
+
let unboundValues = {};
|
|
43086
|
+
const queue = [...tree.root.children];
|
|
43087
|
+
while (queue.length) {
|
|
43088
|
+
const node = queue.shift();
|
|
43089
|
+
if (!node) {
|
|
43090
|
+
continue;
|
|
43091
|
+
}
|
|
43092
|
+
dataSource = { ...dataSource, ...node.data.dataSource };
|
|
43093
|
+
unboundValues = { ...unboundValues, ...node.data.unboundValues };
|
|
43094
|
+
if (node.children.length) {
|
|
43095
|
+
queue.push(...node.children);
|
|
43096
|
+
}
|
|
43097
|
+
}
|
|
43098
|
+
return {
|
|
43099
|
+
dataSource,
|
|
43100
|
+
unboundValues,
|
|
43101
|
+
};
|
|
43102
|
+
};
|
|
43103
|
+
|
|
43104
43104
|
const MEDIA_QUERY_REGEXP = /(<|>)(\d{1,})(px|cm|mm|in|pt|pc)$/;
|
|
43105
43105
|
const toCSSMediaQuery = ({ query }) => {
|
|
43106
43106
|
if (query === '*')
|