@devizovaburza/mdm-sdk 0.0.8 → 0.0.9
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/v1/index.cjs +243 -205
- package/dist/v1/index.d.cts +315 -236
- package/dist/v1/index.d.mts +315 -236
- package/dist/v1/index.d.ts +315 -236
- package/dist/v1/index.mjs +243 -202
- package/package.json +1 -1
package/dist/v1/index.cjs
CHANGED
|
@@ -9,9 +9,6 @@ const z = require('zod/v4/core');
|
|
|
9
9
|
require('node:fs');
|
|
10
10
|
require('node:crypto');
|
|
11
11
|
require('node:path');
|
|
12
|
-
const require$$0 = require('buffer');
|
|
13
|
-
|
|
14
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
15
12
|
|
|
16
13
|
function _interopNamespaceCompat(e) {
|
|
17
14
|
if (e && typeof e === 'object' && 'default' in e) return e;
|
|
@@ -26,7 +23,6 @@ function _interopNamespaceCompat(e) {
|
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
const z__namespace = /*#__PURE__*/_interopNamespaceCompat(z);
|
|
29
|
-
const require$$0__default = /*#__PURE__*/_interopDefaultCompat(require$$0);
|
|
30
26
|
|
|
31
27
|
const createMdmClient = (baseUrl, options) => {
|
|
32
28
|
return client.hc(baseUrl, options);
|
|
@@ -7902,123 +7898,6 @@ function requireEsprima () {
|
|
|
7902
7898
|
return esprima$1.exports;
|
|
7903
7899
|
}
|
|
7904
7900
|
|
|
7905
|
-
var util = {};
|
|
7906
|
-
|
|
7907
|
-
var hasRequiredUtil;
|
|
7908
|
-
|
|
7909
|
-
function requireUtil () {
|
|
7910
|
-
if (hasRequiredUtil) return util;
|
|
7911
|
-
hasRequiredUtil = 1;
|
|
7912
|
-
// Copyright Joyent, Inc. and other Node contributors.
|
|
7913
|
-
//
|
|
7914
|
-
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
7915
|
-
// copy of this software and associated documentation files (the
|
|
7916
|
-
// "Software"), to deal in the Software without restriction, including
|
|
7917
|
-
// without limitation the rights to use, copy, modify, merge, publish,
|
|
7918
|
-
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
7919
|
-
// persons to whom the Software is furnished to do so, subject to the
|
|
7920
|
-
// following conditions:
|
|
7921
|
-
//
|
|
7922
|
-
// The above copyright notice and this permission notice shall be included
|
|
7923
|
-
// in all copies or substantial portions of the Software.
|
|
7924
|
-
//
|
|
7925
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
7926
|
-
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
7927
|
-
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
7928
|
-
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
7929
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
7930
|
-
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
7931
|
-
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
7932
|
-
|
|
7933
|
-
// NOTE: These type checking functions intentionally don't use `instanceof`
|
|
7934
|
-
// because it is fragile and can be easily faked with `Object.create()`.
|
|
7935
|
-
|
|
7936
|
-
function isArray(arg) {
|
|
7937
|
-
if (Array.isArray) {
|
|
7938
|
-
return Array.isArray(arg);
|
|
7939
|
-
}
|
|
7940
|
-
return objectToString(arg) === '[object Array]';
|
|
7941
|
-
}
|
|
7942
|
-
util.isArray = isArray;
|
|
7943
|
-
|
|
7944
|
-
function isBoolean(arg) {
|
|
7945
|
-
return typeof arg === 'boolean';
|
|
7946
|
-
}
|
|
7947
|
-
util.isBoolean = isBoolean;
|
|
7948
|
-
|
|
7949
|
-
function isNull(arg) {
|
|
7950
|
-
return arg === null;
|
|
7951
|
-
}
|
|
7952
|
-
util.isNull = isNull;
|
|
7953
|
-
|
|
7954
|
-
function isNullOrUndefined(arg) {
|
|
7955
|
-
return arg == null;
|
|
7956
|
-
}
|
|
7957
|
-
util.isNullOrUndefined = isNullOrUndefined;
|
|
7958
|
-
|
|
7959
|
-
function isNumber(arg) {
|
|
7960
|
-
return typeof arg === 'number';
|
|
7961
|
-
}
|
|
7962
|
-
util.isNumber = isNumber;
|
|
7963
|
-
|
|
7964
|
-
function isString(arg) {
|
|
7965
|
-
return typeof arg === 'string';
|
|
7966
|
-
}
|
|
7967
|
-
util.isString = isString;
|
|
7968
|
-
|
|
7969
|
-
function isSymbol(arg) {
|
|
7970
|
-
return typeof arg === 'symbol';
|
|
7971
|
-
}
|
|
7972
|
-
util.isSymbol = isSymbol;
|
|
7973
|
-
|
|
7974
|
-
function isUndefined(arg) {
|
|
7975
|
-
return arg === void 0;
|
|
7976
|
-
}
|
|
7977
|
-
util.isUndefined = isUndefined;
|
|
7978
|
-
|
|
7979
|
-
function isRegExp(re) {
|
|
7980
|
-
return objectToString(re) === '[object RegExp]';
|
|
7981
|
-
}
|
|
7982
|
-
util.isRegExp = isRegExp;
|
|
7983
|
-
|
|
7984
|
-
function isObject(arg) {
|
|
7985
|
-
return typeof arg === 'object' && arg !== null;
|
|
7986
|
-
}
|
|
7987
|
-
util.isObject = isObject;
|
|
7988
|
-
|
|
7989
|
-
function isDate(d) {
|
|
7990
|
-
return objectToString(d) === '[object Date]';
|
|
7991
|
-
}
|
|
7992
|
-
util.isDate = isDate;
|
|
7993
|
-
|
|
7994
|
-
function isError(e) {
|
|
7995
|
-
return (objectToString(e) === '[object Error]' || e instanceof Error);
|
|
7996
|
-
}
|
|
7997
|
-
util.isError = isError;
|
|
7998
|
-
|
|
7999
|
-
function isFunction(arg) {
|
|
8000
|
-
return typeof arg === 'function';
|
|
8001
|
-
}
|
|
8002
|
-
util.isFunction = isFunction;
|
|
8003
|
-
|
|
8004
|
-
function isPrimitive(arg) {
|
|
8005
|
-
return arg === null ||
|
|
8006
|
-
typeof arg === 'boolean' ||
|
|
8007
|
-
typeof arg === 'number' ||
|
|
8008
|
-
typeof arg === 'string' ||
|
|
8009
|
-
typeof arg === 'symbol' || // ES6 symbol
|
|
8010
|
-
typeof arg === 'undefined';
|
|
8011
|
-
}
|
|
8012
|
-
util.isPrimitive = isPrimitive;
|
|
8013
|
-
|
|
8014
|
-
util.isBuffer = require$$0__default.Buffer.isBuffer;
|
|
8015
|
-
|
|
8016
|
-
function objectToString(o) {
|
|
8017
|
-
return Object.prototype.toString.call(o);
|
|
8018
|
-
}
|
|
8019
|
-
return util;
|
|
8020
|
-
}
|
|
8021
|
-
|
|
8022
7901
|
/**
|
|
8023
7902
|
* Default minimum size of a run.
|
|
8024
7903
|
*/
|
|
@@ -9115,14 +8994,6 @@ var hasRequiredCommon;
|
|
|
9115
8994
|
function requireCommon () {
|
|
9116
8995
|
if (hasRequiredCommon) return common;
|
|
9117
8996
|
hasRequiredCommon = 1;
|
|
9118
|
-
const {
|
|
9119
|
-
isObject,
|
|
9120
|
-
isArray,
|
|
9121
|
-
isString,
|
|
9122
|
-
isNumber,
|
|
9123
|
-
isFunction
|
|
9124
|
-
} = requireUtil();
|
|
9125
|
-
|
|
9126
8997
|
const PREFIX_BEFORE = 'before';
|
|
9127
8998
|
const PREFIX_AFTER_PROP = 'after-prop';
|
|
9128
8999
|
const PREFIX_AFTER_COLON = 'after-colon';
|
|
@@ -9160,6 +9031,57 @@ function requireCommon () {
|
|
|
9160
9031
|
const COLON = ':';
|
|
9161
9032
|
const UNDEFINED = undefined;
|
|
9162
9033
|
|
|
9034
|
+
const LINE_BREAKS_BEFORE = new WeakMap();
|
|
9035
|
+
const LINE_BREAKS_AFTER = new WeakMap();
|
|
9036
|
+
const RAW_STRING_LITERALS = new WeakMap();
|
|
9037
|
+
|
|
9038
|
+
const is_string = subject => typeof subject === 'string';
|
|
9039
|
+
const is_number = subject => typeof subject === 'number';
|
|
9040
|
+
/**
|
|
9041
|
+
* @param {unknown} v
|
|
9042
|
+
* @returns {v is NonNullable<object>}
|
|
9043
|
+
*/
|
|
9044
|
+
const is_object = v => typeof v === 'object' && v !== null;
|
|
9045
|
+
|
|
9046
|
+
const normalize_key = key => is_string(key) || is_number(key)
|
|
9047
|
+
? String(key)
|
|
9048
|
+
: null;
|
|
9049
|
+
|
|
9050
|
+
const set_raw_string_literal = (host, key, raw) => {
|
|
9051
|
+
if (!is_object(host) || !is_string(raw)) {
|
|
9052
|
+
return
|
|
9053
|
+
}
|
|
9054
|
+
|
|
9055
|
+
const normalized = normalize_key(key);
|
|
9056
|
+
if (normalized === null) {
|
|
9057
|
+
return
|
|
9058
|
+
}
|
|
9059
|
+
|
|
9060
|
+
let map = RAW_STRING_LITERALS.get(host);
|
|
9061
|
+
if (!map) {
|
|
9062
|
+
map = new Map();
|
|
9063
|
+
RAW_STRING_LITERALS.set(host, map);
|
|
9064
|
+
}
|
|
9065
|
+
|
|
9066
|
+
map.set(normalized, raw);
|
|
9067
|
+
};
|
|
9068
|
+
|
|
9069
|
+
const get_raw_string_literal = (host, key) => {
|
|
9070
|
+
if (!is_object(host)) {
|
|
9071
|
+
return
|
|
9072
|
+
}
|
|
9073
|
+
|
|
9074
|
+
const normalized = normalize_key(key);
|
|
9075
|
+
if (normalized === null) {
|
|
9076
|
+
return
|
|
9077
|
+
}
|
|
9078
|
+
|
|
9079
|
+
const map = RAW_STRING_LITERALS.get(host);
|
|
9080
|
+
return map
|
|
9081
|
+
? map.get(normalized)
|
|
9082
|
+
: undefined
|
|
9083
|
+
};
|
|
9084
|
+
|
|
9163
9085
|
const symbol = (prefix, key) => Symbol.for(prefix + COLON + key);
|
|
9164
9086
|
const symbol_checked = (prefix, key) => {
|
|
9165
9087
|
if (key) {
|
|
@@ -9247,7 +9169,7 @@ function requireCommon () {
|
|
|
9247
9169
|
// Assign keys and comments
|
|
9248
9170
|
const assign = (target, source, keys) => {
|
|
9249
9171
|
keys.forEach(key => {
|
|
9250
|
-
if (
|
|
9172
|
+
if (typeof key !== 'string' && typeof key !== 'number') {
|
|
9251
9173
|
return
|
|
9252
9174
|
}
|
|
9253
9175
|
|
|
@@ -9262,13 +9184,26 @@ function requireCommon () {
|
|
|
9262
9184
|
return target
|
|
9263
9185
|
};
|
|
9264
9186
|
|
|
9265
|
-
const is_raw_json =
|
|
9187
|
+
const is_raw_json = typeof JSON.isRawJSON === 'function'
|
|
9266
9188
|
// For backward compatibility,
|
|
9267
9189
|
// since JSON.isRawJSON is not supported in node < 21
|
|
9268
9190
|
? JSON.isRawJSON
|
|
9269
9191
|
// istanbul ignore next
|
|
9270
9192
|
: () => false;
|
|
9271
9193
|
|
|
9194
|
+
const set_comment_line_breaks = (comment, before, after) => {
|
|
9195
|
+
if (is_number(before) && before >= 0) {
|
|
9196
|
+
LINE_BREAKS_BEFORE.set(comment, before);
|
|
9197
|
+
}
|
|
9198
|
+
|
|
9199
|
+
if (is_number(after) && after >= 0) {
|
|
9200
|
+
LINE_BREAKS_AFTER.set(comment, after);
|
|
9201
|
+
}
|
|
9202
|
+
};
|
|
9203
|
+
|
|
9204
|
+
const get_comment_line_breaks_before = comment => LINE_BREAKS_BEFORE.get(comment);
|
|
9205
|
+
const get_comment_line_breaks_after = comment => LINE_BREAKS_AFTER.get(comment);
|
|
9206
|
+
|
|
9272
9207
|
common = {
|
|
9273
9208
|
PROP_SYMBOL_PREFIXES,
|
|
9274
9209
|
|
|
@@ -9299,7 +9234,16 @@ function requireCommon () {
|
|
|
9299
9234
|
swap_comments,
|
|
9300
9235
|
assign_non_prop_comments,
|
|
9301
9236
|
|
|
9237
|
+
is_string,
|
|
9238
|
+
is_number,
|
|
9239
|
+
is_object,
|
|
9240
|
+
|
|
9302
9241
|
is_raw_json,
|
|
9242
|
+
set_raw_string_literal,
|
|
9243
|
+
get_raw_string_literal,
|
|
9244
|
+
set_comment_line_breaks,
|
|
9245
|
+
get_comment_line_breaks_before,
|
|
9246
|
+
get_comment_line_breaks_after,
|
|
9303
9247
|
|
|
9304
9248
|
/**
|
|
9305
9249
|
* Assign properties and comments from source to target object.
|
|
@@ -9330,11 +9274,11 @@ function requireCommon () {
|
|
|
9330
9274
|
* assign(target, source, [])
|
|
9331
9275
|
*/
|
|
9332
9276
|
assign (target, source, keys) {
|
|
9333
|
-
if (!
|
|
9277
|
+
if (!is_object(target)) {
|
|
9334
9278
|
throw new TypeError('Cannot convert undefined or null to object')
|
|
9335
9279
|
}
|
|
9336
9280
|
|
|
9337
|
-
if (!
|
|
9281
|
+
if (!is_object(source)) {
|
|
9338
9282
|
return target
|
|
9339
9283
|
}
|
|
9340
9284
|
|
|
@@ -9347,7 +9291,7 @@ function requireCommon () {
|
|
|
9347
9291
|
// We assign non-property comments
|
|
9348
9292
|
// if argument `keys` is not specified
|
|
9349
9293
|
assign_non_prop_comments(target, source);
|
|
9350
|
-
} else if (!isArray(keys)) {
|
|
9294
|
+
} else if (!Array.isArray(keys)) {
|
|
9351
9295
|
throw new TypeError('keys must be array or undefined')
|
|
9352
9296
|
} else if (keys.length === 0) {
|
|
9353
9297
|
// Copy all non-property comments from source to target
|
|
@@ -9405,7 +9349,7 @@ function requireCommon () {
|
|
|
9405
9349
|
where: to_where,
|
|
9406
9350
|
key: to_key
|
|
9407
9351
|
}, override = false) {
|
|
9408
|
-
if (!
|
|
9352
|
+
if (!is_object(source)) {
|
|
9409
9353
|
throw new TypeError('source must be an object')
|
|
9410
9354
|
}
|
|
9411
9355
|
|
|
@@ -9413,7 +9357,7 @@ function requireCommon () {
|
|
|
9413
9357
|
target = source;
|
|
9414
9358
|
}
|
|
9415
9359
|
|
|
9416
|
-
if (!
|
|
9360
|
+
if (!is_object(target)) {
|
|
9417
9361
|
// No target to move to
|
|
9418
9362
|
return
|
|
9419
9363
|
}
|
|
@@ -9468,7 +9412,7 @@ function requireCommon () {
|
|
|
9468
9412
|
where,
|
|
9469
9413
|
key
|
|
9470
9414
|
}) {
|
|
9471
|
-
if (!
|
|
9415
|
+
if (!is_object(target)) {
|
|
9472
9416
|
throw new TypeError('target must be an object')
|
|
9473
9417
|
}
|
|
9474
9418
|
|
|
@@ -9489,7 +9433,6 @@ var hasRequiredArray;
|
|
|
9489
9433
|
function requireArray () {
|
|
9490
9434
|
if (hasRequiredArray) return array;
|
|
9491
9435
|
hasRequiredArray = 1;
|
|
9492
|
-
const {isArray} = requireUtil();
|
|
9493
9436
|
const {sort} = requireSrc$1();
|
|
9494
9437
|
|
|
9495
9438
|
const {
|
|
@@ -9739,7 +9682,7 @@ function requireArray () {
|
|
|
9739
9682
|
|
|
9740
9683
|
items.forEach(item => {
|
|
9741
9684
|
const prev = length;
|
|
9742
|
-
length += isArray(item)
|
|
9685
|
+
length += Array.isArray(item)
|
|
9743
9686
|
? item.length
|
|
9744
9687
|
: 1;
|
|
9745
9688
|
|
|
@@ -9847,7 +9790,10 @@ function requireParse () {
|
|
|
9847
9790
|
|
|
9848
9791
|
UNDEFINED,
|
|
9849
9792
|
|
|
9793
|
+
is_object,
|
|
9850
9794
|
define,
|
|
9795
|
+
set_raw_string_literal,
|
|
9796
|
+
set_comment_line_breaks,
|
|
9851
9797
|
assign_non_prop_comments
|
|
9852
9798
|
} = requireCommon();
|
|
9853
9799
|
|
|
@@ -10037,17 +9983,41 @@ function requireParse () {
|
|
|
10037
9983
|
inline
|
|
10038
9984
|
};
|
|
10039
9985
|
|
|
9986
|
+
const previous_line = last
|
|
9987
|
+
? last.loc.end.line
|
|
9988
|
+
: 1;
|
|
9989
|
+
|
|
9990
|
+
set_comment_line_breaks(
|
|
9991
|
+
comment,
|
|
9992
|
+
Math.max(0, comment.loc.start.line - previous_line)
|
|
9993
|
+
);
|
|
9994
|
+
|
|
10040
9995
|
// delete comment.loc
|
|
10041
9996
|
comments.push(comment);
|
|
10042
9997
|
|
|
10043
9998
|
next();
|
|
10044
9999
|
}
|
|
10045
10000
|
|
|
10001
|
+
const {length} = comments;
|
|
10002
|
+
|
|
10003
|
+
if (length) {
|
|
10004
|
+
const comment = comments[length - 1];
|
|
10005
|
+
const current_line = current
|
|
10006
|
+
? current.loc.start.line
|
|
10007
|
+
: comment.loc.end.line;
|
|
10008
|
+
|
|
10009
|
+
set_comment_line_breaks(
|
|
10010
|
+
comment,
|
|
10011
|
+
undefined,
|
|
10012
|
+
Math.max(0, current_line - comment.loc.end.line)
|
|
10013
|
+
);
|
|
10014
|
+
}
|
|
10015
|
+
|
|
10046
10016
|
if (remove_comments) {
|
|
10047
10017
|
return
|
|
10048
10018
|
}
|
|
10049
10019
|
|
|
10050
|
-
if (!
|
|
10020
|
+
if (!length) {
|
|
10051
10021
|
return
|
|
10052
10022
|
}
|
|
10053
10023
|
|
|
@@ -10226,6 +10196,8 @@ function requireParse () {
|
|
|
10226
10196
|
|
|
10227
10197
|
switch (tt) {
|
|
10228
10198
|
case 'String':
|
|
10199
|
+
set_raw_string_literal(comments_host, last_prop, current.value);
|
|
10200
|
+
// falls through
|
|
10229
10201
|
case 'Boolean':
|
|
10230
10202
|
case 'Null':
|
|
10231
10203
|
case 'Numeric':
|
|
@@ -10245,8 +10217,6 @@ function requireParse () {
|
|
|
10245
10217
|
}
|
|
10246
10218
|
}
|
|
10247
10219
|
|
|
10248
|
-
const isObject = subject => Object(subject) === subject;
|
|
10249
|
-
|
|
10250
10220
|
/**
|
|
10251
10221
|
* Converts a JavaScript Object Notation (JSON) string with comments into an
|
|
10252
10222
|
* object.
|
|
@@ -10310,7 +10280,7 @@ function requireParse () {
|
|
|
10310
10280
|
// We should run reviver before the checks below,
|
|
10311
10281
|
// otherwise the comment info will be lost
|
|
10312
10282
|
if (!no_comments && result !== null) {
|
|
10313
|
-
if (!
|
|
10283
|
+
if (!is_object(result)) {
|
|
10314
10284
|
// 1 -> new Number(1)
|
|
10315
10285
|
// true -> new Boolean(1)
|
|
10316
10286
|
// "foo" -> new String("foo")
|
|
@@ -10342,10 +10312,6 @@ var hasRequiredStringify;
|
|
|
10342
10312
|
function requireStringify () {
|
|
10343
10313
|
if (hasRequiredStringify) return stringify_1;
|
|
10344
10314
|
hasRequiredStringify = 1;
|
|
10345
|
-
const {
|
|
10346
|
-
isArray, isObject, isFunction, isNumber, isString
|
|
10347
|
-
} = requireUtil();
|
|
10348
|
-
|
|
10349
10315
|
const {
|
|
10350
10316
|
PREFIX_BEFORE_ALL,
|
|
10351
10317
|
PREFIX_BEFORE,
|
|
@@ -10365,12 +10331,17 @@ function requireStringify () {
|
|
|
10365
10331
|
|
|
10366
10332
|
UNDEFINED,
|
|
10367
10333
|
|
|
10334
|
+
is_string,
|
|
10335
|
+
is_number,
|
|
10336
|
+
is_object,
|
|
10337
|
+
|
|
10338
|
+
get_raw_string_literal,
|
|
10339
|
+
get_comment_line_breaks_before,
|
|
10340
|
+
get_comment_line_breaks_after,
|
|
10341
|
+
|
|
10368
10342
|
is_raw_json
|
|
10369
10343
|
} = requireCommon();
|
|
10370
10344
|
|
|
10371
|
-
// eslint-disable-next-line no-control-regex, no-misleading-character-class
|
|
10372
|
-
const ESCAPABLE = /[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
|
10373
|
-
|
|
10374
10345
|
// String constants
|
|
10375
10346
|
const SPACE = ' ';
|
|
10376
10347
|
const LF = '\n';
|
|
@@ -10383,39 +10354,54 @@ function requireStringify () {
|
|
|
10383
10354
|
const AFTER_VALUE = prop => `${PREFIX_AFTER_VALUE}:${prop}`;
|
|
10384
10355
|
const AFTER = prop => `${PREFIX_AFTER}:${prop}`;
|
|
10385
10356
|
|
|
10386
|
-
|
|
10387
|
-
const
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10392
|
-
|
|
10393
|
-
|
|
10394
|
-
|
|
10395
|
-
|
|
10357
|
+
const quote = JSON.stringify;
|
|
10358
|
+
const comment_stringify = (value, line) => line
|
|
10359
|
+
? `//${value}`
|
|
10360
|
+
: `/*${value}*/`;
|
|
10361
|
+
const repeat_line_breaks = (line_breaks, gap) => (LF + gap).repeat(line_breaks);
|
|
10362
|
+
const read_line_breaks = line_breaks => is_number(line_breaks) && line_breaks >= 0
|
|
10363
|
+
? line_breaks
|
|
10364
|
+
: null;
|
|
10365
|
+
const read_line_breaks_from_loc = (previous_comment, comment) => {
|
|
10366
|
+
if (
|
|
10367
|
+
!previous_comment
|
|
10368
|
+
|| !previous_comment.loc
|
|
10369
|
+
|| !comment.loc
|
|
10370
|
+
) {
|
|
10371
|
+
return null
|
|
10372
|
+
}
|
|
10396
10373
|
|
|
10397
|
-
|
|
10398
|
-
|
|
10374
|
+
const {end} = previous_comment.loc;
|
|
10375
|
+
const {start} = comment.loc;
|
|
10399
10376
|
|
|
10400
|
-
if (
|
|
10401
|
-
|
|
10377
|
+
if (
|
|
10378
|
+
!end
|
|
10379
|
+
|| !start
|
|
10380
|
+
|| !is_number(end.line)
|
|
10381
|
+
|| !is_number(start.line)
|
|
10382
|
+
) {
|
|
10383
|
+
return null
|
|
10402
10384
|
}
|
|
10403
10385
|
|
|
10404
|
-
|
|
10405
|
-
|
|
10406
|
-
|
|
10407
|
-
|
|
10408
|
-
|
|
10409
|
-
})
|
|
10386
|
+
const line_breaks = start.line - end.line;
|
|
10387
|
+
|
|
10388
|
+
return line_breaks >= 0
|
|
10389
|
+
? line_breaks
|
|
10390
|
+
: null
|
|
10410
10391
|
};
|
|
10392
|
+
const count_trailing_line_breaks = (str, gap) => {
|
|
10393
|
+
const unit = LF + gap;
|
|
10394
|
+
const {length} = unit;
|
|
10395
|
+
let i = str.length;
|
|
10396
|
+
let count = 0;
|
|
10397
|
+
|
|
10398
|
+
while (i >= length && str.slice(i - length, i) === unit) {
|
|
10399
|
+
i -= length;
|
|
10400
|
+
count ++;
|
|
10401
|
+
}
|
|
10411
10402
|
|
|
10412
|
-
|
|
10413
|
-
|
|
10414
|
-
// then we can safely slap some quotes around it.
|
|
10415
|
-
const quote = string => `"${escape(string)}"`;
|
|
10416
|
-
const comment_stringify = (value, line) => line
|
|
10417
|
-
? `//${value}`
|
|
10418
|
-
: `/*${value}*/`;
|
|
10403
|
+
return count
|
|
10404
|
+
};
|
|
10419
10405
|
|
|
10420
10406
|
// display_block `boolean` whether the
|
|
10421
10407
|
// WHOLE block of comments is always a block group
|
|
@@ -10425,27 +10411,58 @@ function requireStringify () {
|
|
|
10425
10411
|
return EMPTY
|
|
10426
10412
|
}
|
|
10427
10413
|
|
|
10428
|
-
let
|
|
10414
|
+
let str = EMPTY;
|
|
10415
|
+
let last_comment = null;
|
|
10429
10416
|
|
|
10430
|
-
|
|
10431
|
-
|
|
10432
|
-
|
|
10433
|
-
|
|
10434
|
-
|
|
10435
|
-
|
|
10436
|
-
? SPACE
|
|
10437
|
-
: LF + deeper_gap;
|
|
10417
|
+
comments.forEach((comment, i) => {
|
|
10418
|
+
const {
|
|
10419
|
+
inline,
|
|
10420
|
+
type,
|
|
10421
|
+
value
|
|
10422
|
+
} = comment;
|
|
10438
10423
|
|
|
10439
|
-
|
|
10424
|
+
let line_breaks_before = read_line_breaks(
|
|
10425
|
+
get_comment_line_breaks_before(comment)
|
|
10426
|
+
);
|
|
10440
10427
|
|
|
10441
|
-
|
|
10442
|
-
|
|
10428
|
+
if (line_breaks_before === null) {
|
|
10429
|
+
line_breaks_before = read_line_breaks_from_loc(last_comment, comment);
|
|
10430
|
+
}
|
|
10443
10431
|
|
|
10444
|
-
|
|
10445
|
-
|
|
10446
|
-
|
|
10447
|
-
|
|
10448
|
-
|
|
10432
|
+
if (line_breaks_before === null) {
|
|
10433
|
+
line_breaks_before = inline
|
|
10434
|
+
? 0
|
|
10435
|
+
: 1;
|
|
10436
|
+
}
|
|
10437
|
+
|
|
10438
|
+
const delimiter = line_breaks_before > 0
|
|
10439
|
+
? repeat_line_breaks(line_breaks_before, deeper_gap)
|
|
10440
|
+
: inline
|
|
10441
|
+
? SPACE
|
|
10442
|
+
// The first comment at the very beginning of the source.
|
|
10443
|
+
: i === 0
|
|
10444
|
+
? EMPTY
|
|
10445
|
+
: LF + deeper_gap;
|
|
10446
|
+
|
|
10447
|
+
const is_line_comment = type === 'LineComment';
|
|
10448
|
+
|
|
10449
|
+
str += delimiter + comment_stringify(value, is_line_comment);
|
|
10450
|
+
|
|
10451
|
+
last_comment = comment;
|
|
10452
|
+
});
|
|
10453
|
+
|
|
10454
|
+
const default_line_breaks_after = display_block
|
|
10455
|
+
// line comment should always end with a LF
|
|
10456
|
+
|| last_comment.type === 'LineComment'
|
|
10457
|
+
? 1
|
|
10458
|
+
: 0;
|
|
10459
|
+
|
|
10460
|
+
const line_breaks_after = Math.max(
|
|
10461
|
+
default_line_breaks_after,
|
|
10462
|
+
read_line_breaks(get_comment_line_breaks_after(last_comment)) || 0
|
|
10463
|
+
);
|
|
10464
|
+
|
|
10465
|
+
return str + repeat_line_breaks(line_breaks_after, deeper_gap)
|
|
10449
10466
|
};
|
|
10450
10467
|
|
|
10451
10468
|
let replacer = null;
|
|
@@ -10464,9 +10481,15 @@ function requireStringify () {
|
|
|
10464
10481
|
// and make a mistake.
|
|
10465
10482
|
// SO, we are not to only trimRight but trim for both sides
|
|
10466
10483
|
? one + two.trim() + LF + gap
|
|
10467
|
-
: one.trimRight() +
|
|
10484
|
+
: one.trimRight() + repeat_line_breaks(
|
|
10485
|
+
Math.max(1, count_trailing_line_breaks(one, gap)),
|
|
10486
|
+
gap
|
|
10487
|
+
)
|
|
10468
10488
|
: two
|
|
10469
|
-
? two.trimRight() +
|
|
10489
|
+
? two.trimRight() + repeat_line_breaks(
|
|
10490
|
+
Math.max(1, count_trailing_line_breaks(two, gap)),
|
|
10491
|
+
gap
|
|
10492
|
+
)
|
|
10470
10493
|
: EMPTY;
|
|
10471
10494
|
|
|
10472
10495
|
const join_content = (inside, value, gap) => {
|
|
@@ -10475,6 +10498,21 @@ function requireStringify () {
|
|
|
10475
10498
|
return join(comment, inside, gap)
|
|
10476
10499
|
};
|
|
10477
10500
|
|
|
10501
|
+
const stringify_string = (holder, key, value) => {
|
|
10502
|
+
const raw = get_raw_string_literal(holder, key);
|
|
10503
|
+
if (is_string(raw)) {
|
|
10504
|
+
try {
|
|
10505
|
+
if (JSON.parse(raw) === value) {
|
|
10506
|
+
return raw
|
|
10507
|
+
}
|
|
10508
|
+
} catch (e) {
|
|
10509
|
+
// ignore invalid raw string literals and fallback to native behavior
|
|
10510
|
+
}
|
|
10511
|
+
}
|
|
10512
|
+
|
|
10513
|
+
return quote(value)
|
|
10514
|
+
};
|
|
10515
|
+
|
|
10478
10516
|
// | deeper_gap |
|
|
10479
10517
|
// | gap | indent |
|
|
10480
10518
|
// [
|
|
@@ -10544,7 +10582,7 @@ function requireStringify () {
|
|
|
10544
10582
|
let after_comma = EMPTY;
|
|
10545
10583
|
let first = true;
|
|
10546
10584
|
|
|
10547
|
-
const keys = isArray(replacer)
|
|
10585
|
+
const keys = Array.isArray(replacer)
|
|
10548
10586
|
? replacer
|
|
10549
10587
|
: Object.keys(value);
|
|
10550
10588
|
|
|
@@ -10609,19 +10647,19 @@ function requireStringify () {
|
|
|
10609
10647
|
let value = holder[key];
|
|
10610
10648
|
|
|
10611
10649
|
// If the value has a toJSON method, call it to obtain a replacement value.
|
|
10612
|
-
if (
|
|
10650
|
+
if (is_object(value) && typeof value.toJSON === 'function') {
|
|
10613
10651
|
value = value.toJSON(key);
|
|
10614
10652
|
}
|
|
10615
10653
|
|
|
10616
10654
|
// If we were called with a replacer function, then call the replacer to
|
|
10617
10655
|
// obtain a replacement value.
|
|
10618
|
-
if (
|
|
10656
|
+
if (typeof replacer === 'function') {
|
|
10619
10657
|
value = replacer.call(holder, key, value);
|
|
10620
10658
|
}
|
|
10621
10659
|
|
|
10622
10660
|
switch (typeof value) {
|
|
10623
10661
|
case 'string':
|
|
10624
|
-
return
|
|
10662
|
+
return stringify_string(holder, key, value)
|
|
10625
10663
|
|
|
10626
10664
|
case 'number':
|
|
10627
10665
|
// JSON numbers must be finite. Encode non-finite numbers as null.
|
|
@@ -10642,7 +10680,7 @@ function requireStringify () {
|
|
|
10642
10680
|
return value.rawJSON
|
|
10643
10681
|
}
|
|
10644
10682
|
|
|
10645
|
-
return isArray(value)
|
|
10683
|
+
return Array.isArray(value)
|
|
10646
10684
|
? array_stringify(value, gap)
|
|
10647
10685
|
: object_stringify(value, gap)
|
|
10648
10686
|
// JSON.stringify(undefined) === undefined
|
|
@@ -10650,10 +10688,10 @@ function requireStringify () {
|
|
|
10650
10688
|
}
|
|
10651
10689
|
}
|
|
10652
10690
|
|
|
10653
|
-
const get_indent = space =>
|
|
10691
|
+
const get_indent = space => typeof space === 'string'
|
|
10654
10692
|
// If the space parameter is a string, it will be used as the indent string.
|
|
10655
10693
|
? space
|
|
10656
|
-
:
|
|
10694
|
+
: typeof space === 'number'
|
|
10657
10695
|
? SPACE.repeat(space)
|
|
10658
10696
|
: EMPTY;
|
|
10659
10697
|
|
|
@@ -10716,7 +10754,7 @@ function requireStringify () {
|
|
|
10716
10754
|
}
|
|
10717
10755
|
|
|
10718
10756
|
// vanilla `JSON.parse` allow invalid replacer
|
|
10719
|
-
if (
|
|
10757
|
+
if (typeof replacer_ !== 'function' && !Array.isArray(replacer_)) {
|
|
10720
10758
|
replacer_ = null;
|
|
10721
10759
|
}
|
|
10722
10760
|
|
|
@@ -10729,7 +10767,7 @@ function requireStringify () {
|
|
|
10729
10767
|
|
|
10730
10768
|
clean();
|
|
10731
10769
|
|
|
10732
|
-
return
|
|
10770
|
+
return is_object(value)
|
|
10733
10771
|
? process_comments(value, PREFIX_BEFORE_ALL, EMPTY, true).trimLeft()
|
|
10734
10772
|
+ str
|
|
10735
10773
|
+ process_comments(value, PREFIX_AFTER_ALL, EMPTY).trimRight()
|