@takeshape/util 11.50.0 → 11.51.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/cjs/common/arrays.js +6 -7
  2. package/dist/cjs/common/assert.js +1 -2
  3. package/dist/cjs/common/billing.js +4 -4
  4. package/dist/cjs/common/clone.js +3 -3
  5. package/dist/cjs/common/delay.js +3 -4
  6. package/dist/cjs/common/draftjs.js +8 -8
  7. package/dist/cjs/common/empty.js +1 -2
  8. package/dist/cjs/common/get-image-url.js +1 -2
  9. package/dist/cjs/common/map.js +1 -2
  10. package/dist/cjs/common/memoize.js +1 -2
  11. package/dist/cjs/common/merge.js +4 -5
  12. package/dist/cjs/common/mime.js +2 -3
  13. package/dist/cjs/common/names.js +1 -2
  14. package/dist/cjs/common/naming.js +6 -6
  15. package/dist/cjs/common/predicate.js +3 -4
  16. package/dist/cjs/common/sets.js +2 -3
  17. package/dist/cjs/common/sleep.js +1 -2
  18. package/dist/cjs/common/strings.js +9 -9
  19. package/dist/cjs/common/templates.js +8 -9
  20. package/dist/cjs/common/timezone.js +2 -2
  21. package/dist/cjs/common/types.js +7 -8
  22. package/dist/cjs/common/unix-to-iso.js +3 -4
  23. package/dist/cjs/common/urls.js +1 -2
  24. package/dist/cjs/common/value.js +1 -2
  25. package/dist/cjs/common/visit.js +2 -3
  26. package/dist/cjs/node/buffer.js +26 -0
  27. package/dist/cjs/node/gzip.js +13 -3
  28. package/dist/cjs/node/index.js +1 -0
  29. package/dist/cjs/node/search-params.js +3 -4
  30. package/dist/esm/node/buffer.js +22 -0
  31. package/dist/esm/node/gzip.js +10 -2
  32. package/dist/esm/node/index.js +1 -0
  33. package/dist/tsconfig.cjs.tsbuildinfo +1 -0
  34. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  35. package/dist/tsconfig.types.tsbuildinfo +1 -1
  36. package/dist/types/common/billing.d.ts +0 -217
  37. package/dist/types/common/set-in.d.ts +0 -1
  38. package/dist/types/node/buffer.d.ts +11 -0
  39. package/dist/types/node/encryption.d.ts +0 -1
  40. package/dist/types/node/gzip.d.ts +5 -4
  41. package/dist/types/node/index.d.ts +1 -0
  42. package/dist/types/node/search-params.d.ts +0 -1
  43. package/package.json +3 -2
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensureArray = exports.toArray = exports.isDefined = exports.arrayStartsWith = exports.setIsEqual = exports.arrayContainsAll = void 0;
3
+ exports.arrayContainsAll = arrayContainsAll;
4
+ exports.setIsEqual = setIsEqual;
5
+ exports.arrayStartsWith = arrayStartsWith;
6
+ exports.isDefined = isDefined;
7
+ exports.toArray = toArray;
8
+ exports.ensureArray = ensureArray;
4
9
  function arrayContainsAll(a, b) {
5
10
  return a.every((value) => b.includes(value));
6
11
  }
7
- exports.arrayContainsAll = arrayContainsAll;
8
12
  function setIsEqual(a, b) {
9
13
  if (a.length !== b.length) {
10
14
  return false;
@@ -15,7 +19,6 @@ function setIsEqual(a, b) {
15
19
  const refSet = new Set(a);
16
20
  return b.every((value) => refSet.has(value));
17
21
  }
18
- exports.setIsEqual = setIsEqual;
19
22
  function arrayStartsWith(a, b) {
20
23
  if (a.length < b.length) {
21
24
  return false;
@@ -27,16 +30,12 @@ function arrayStartsWith(a, b) {
27
30
  }
28
31
  return true;
29
32
  }
30
- exports.arrayStartsWith = arrayStartsWith;
31
33
  function isDefined(x) {
32
34
  return x !== null && x !== undefined;
33
35
  }
34
- exports.isDefined = isDefined;
35
36
  function toArray(obj) {
36
37
  return obj ? [obj] : [];
37
38
  }
38
- exports.toArray = toArray;
39
39
  function ensureArray(obj) {
40
40
  return Array.isArray(obj) ? obj : [obj];
41
41
  }
42
- exports.ensureArray = ensureArray;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assert = void 0;
3
+ exports.assert = assert;
4
4
  function assert(arg, message) {
5
5
  if (!arg) {
6
6
  throw new Error(message);
7
7
  }
8
8
  }
9
- exports.assert = assert;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isStripeChargeObject = exports.getStripeProductObject = exports.isStripeProductObject = exports.DEFAULT_ENTITLEMENTS = exports.DEFAULT_MIN_SCHEDULE_TRIGGER_INTERVAL = void 0;
3
+ exports.DEFAULT_ENTITLEMENTS = exports.DEFAULT_MIN_SCHEDULE_TRIGGER_INTERVAL = void 0;
4
+ exports.isStripeProductObject = isStripeProductObject;
5
+ exports.getStripeProductObject = getStripeProductObject;
6
+ exports.isStripeChargeObject = isStripeChargeObject;
4
7
  const assert_js_1 = require("./assert.js");
5
8
  exports.DEFAULT_MIN_SCHEDULE_TRIGGER_INTERVAL = 60;
6
9
  exports.DEFAULT_ENTITLEMENTS = {
@@ -23,13 +26,10 @@ exports.DEFAULT_ENTITLEMENTS = {
23
26
  function isStripeProductObject(product) {
24
27
  return Boolean(product && typeof product !== 'string' && product.object === 'product' && !product.deleted);
25
28
  }
26
- exports.isStripeProductObject = isStripeProductObject;
27
29
  function getStripeProductObject(product) {
28
30
  (0, assert_js_1.assert)(isStripeProductObject(product), 'product is not a Stripe product object');
29
31
  return product;
30
32
  }
31
- exports.getStripeProductObject = getStripeProductObject;
32
33
  function isStripeChargeObject(charge) {
33
34
  return typeof charge !== 'string';
34
35
  }
35
- exports.isStripeChargeObject = isStripeChargeObject;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deepCloneWith = exports.REMOVE = exports.deepClone = void 0;
3
+ exports.REMOVE = void 0;
4
+ exports.deepClone = deepClone;
5
+ exports.deepCloneWith = deepCloneWith;
4
6
  const types_js_1 = require("./types.js");
5
7
  /**
6
8
  * Clone any JSON serializable value similar to JSON.parse(JSON.stringify()) but better performance
@@ -30,7 +32,6 @@ function deepClone(value) {
30
32
  }
31
33
  return value;
32
34
  }
33
- exports.deepClone = deepClone;
34
35
  exports.REMOVE = Symbol('REMOVE');
35
36
  function arrayFilter(value) {
36
37
  return value !== exports.REMOVE;
@@ -73,4 +74,3 @@ function deepCloneWith(value, customizer) {
73
74
  };
74
75
  return clone(value, undefined, undefined);
75
76
  }
76
- exports.deepCloneWith = deepCloneWith;
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.randomDelay = exports.backoff = exports.delay = void 0;
3
+ exports.delay = delay;
4
+ exports.backoff = backoff;
5
+ exports.randomDelay = randomDelay;
4
6
  async function delay(timeout, value) {
5
7
  return new Promise((resolve) => {
6
8
  setTimeout(resolve, timeout, value);
7
9
  });
8
10
  }
9
- exports.delay = delay;
10
11
  function randomInt(minimum, maximum) {
11
12
  const co = Math.random() * (maximum - minimum + 1);
12
13
  return Math.floor(co + minimum);
@@ -21,8 +22,6 @@ async function backoff(baseDelay, maxDelay, attempt = { num: 1, lastDelay: 0 })
21
22
  lastDelay: msec
22
23
  };
23
24
  }
24
- exports.backoff = backoff;
25
25
  async function randomDelay(minimum, maximum, value) {
26
26
  return delay(randomInt(minimum, maximum), value);
27
27
  }
28
- exports.randomDelay = randomDelay;
@@ -3,7 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.mdxToDraftjs = exports.insertBreaksAroundBlocks = exports.getImagePathFromUrl = exports.mdToDraftjs = exports.draftjsToMdx = exports.draftjsToMd = exports.fromDraftjs = exports.encodeHtmlEntities = exports.adjustRanges = void 0;
6
+ exports.encodeHtmlEntities = exports.adjustRanges = void 0;
7
+ exports.fromDraftjs = fromDraftjs;
8
+ exports.draftjsToMd = draftjsToMd;
9
+ exports.draftjsToMdx = draftjsToMdx;
10
+ exports.mdToDraftjs = mdToDraftjs;
11
+ exports.getImagePathFromUrl = getImagePathFromUrl;
12
+ exports.insertBreaksAroundBlocks = insertBreaksAroundBlocks;
13
+ exports.mdxToDraftjs = mdxToDraftjs;
7
14
  const routing_1 = require("@takeshape/routing");
8
15
  const dom_serializer_1 = __importDefault(require("dom-serializer"));
9
16
  const he_1 = __importDefault(require("he"));
@@ -195,7 +202,6 @@ function fromDraftjs(draftjs, styleItems, entityItems) {
195
202
  markdown = markdown.replace(/\+/g, '\\+').replace(new RegExp(INSERT_MARKER, 'g'), '++');
196
203
  return markdown;
197
204
  }
198
- exports.fromDraftjs = fromDraftjs;
199
205
  function draftjsToMd(draftjs, assets) {
200
206
  return fromDraftjs(draftjs, {
201
207
  pullquote: {
@@ -246,7 +252,6 @@ function draftjsToMd(draftjs, assets) {
246
252
  }
247
253
  });
248
254
  }
249
- exports.draftjsToMd = draftjsToMd;
250
255
  function getTextFromDraftjs(draftjs) {
251
256
  return draftjs?.blocks?.[0]?.text;
252
257
  }
@@ -308,7 +313,6 @@ function draftjsToMdx(draftjs, assets, prefix = mdxShortcodePrefix) {
308
313
  }
309
314
  });
310
315
  }
311
- exports.draftjsToMdx = draftjsToMdx;
312
316
  function getAssetIdFromImageSrc(src) {
313
317
  return new url_parse_1.default(src).pathname.split('/')[3];
314
318
  }
@@ -518,11 +522,9 @@ function mdToDraftjs(mdx) {
518
522
  };
519
523
  return result;
520
524
  }
521
- exports.mdToDraftjs = mdToDraftjs;
522
525
  function getImagePathFromUrl(url) {
523
526
  return new url_parse_1.default(url).pathname.substr(1);
524
527
  }
525
- exports.getImagePathFromUrl = getImagePathFromUrl;
526
528
  function mdxToBr(item) {
527
529
  if (item.content.startsWith('<br/>')) {
528
530
  return {
@@ -721,7 +723,6 @@ function insertBreaksAroundBlocks(mdx) {
721
723
  }
722
724
  return mdx;
723
725
  }
724
- exports.insertBreaksAroundBlocks = insertBreaksAroundBlocks;
725
726
  function mdxToDraftjs(mdx) {
726
727
  const replacementBlocks = {};
727
728
  const entities = {};
@@ -804,4 +805,3 @@ function mdxToDraftjs(mdx) {
804
805
  }, (entity, key) => entity.data?.marker === undefined && !entityKeysToExclude.includes(Number(key)));
805
806
  return result;
806
807
  }
807
- exports.mdxToDraftjs = mdxToDraftjs;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isDeepEmpty = void 0;
3
+ exports.isDeepEmpty = isDeepEmpty;
4
4
  /**
5
5
  * Checks if a value and all nested values are empty.
6
6
  */
@@ -22,4 +22,3 @@ function isDeepEmpty(value) {
22
22
  }
23
23
  return value === undefined;
24
24
  }
25
- exports.isDeepEmpty = isDeepEmpty;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getImageUrl = void 0;
3
+ exports.getImageUrl = getImageUrl;
4
4
  const routing_1 = require("@takeshape/routing");
5
5
  function getImageUrl(path, defaultImageConfig, imageBaseUrl, config) {
6
6
  return (0, routing_1.getImageUrl)(path, { ...defaultImageConfig, ...config }, { baseUrl: imageBaseUrl });
7
7
  }
8
- exports.getImageUrl = getImageUrl;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapKeysToArray = void 0;
3
+ exports.mapKeysToArray = mapKeysToArray;
4
4
  function mapKeysToArray(map) {
5
5
  return Array.from(map.keys());
6
6
  }
7
- exports.mapKeysToArray = mapKeysToArray;
@@ -3,11 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.weakMemoize = void 0;
6
+ exports.weakMemoize = weakMemoize;
7
7
  const memoize_js_1 = __importDefault(require("lodash/memoize.js"));
8
8
  function weakMemoize(fn) {
9
9
  const memoized = (0, memoize_js_1.default)(fn);
10
10
  memoized.cache = new WeakMap();
11
11
  return memoized;
12
12
  }
13
- exports.weakMemoize = weakMemoize;
@@ -3,7 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.rebaseArray = exports.rebaseObject = exports.mergeWithArrayMerge = exports.mergeWithArrayConcat = void 0;
6
+ exports.mergeWithArrayConcat = mergeWithArrayConcat;
7
+ exports.mergeWithArrayMerge = mergeWithArrayMerge;
8
+ exports.rebaseObject = rebaseObject;
9
+ exports.rebaseArray = rebaseArray;
7
10
  const difference_js_1 = __importDefault(require("lodash/difference.js"));
8
11
  const isArray_js_1 = __importDefault(require("lodash/isArray.js"));
9
12
  const isEqual_js_1 = __importDefault(require("lodash/isEqual.js"));
@@ -27,7 +30,6 @@ const arrayConcatCustomizer = (value, srcValue) => {
27
30
  function mergeWithArrayConcat(object, source) {
28
31
  return (0, mergeWith_js_1.default)(object, source, arrayConcatCustomizer);
29
32
  }
30
- exports.mergeWithArrayConcat = mergeWithArrayConcat;
31
33
  /**
32
34
  * Lodash `mergeWith` customizer to merge arrays
33
35
  */
@@ -43,7 +45,6 @@ const arrayMergeCustomizer = (value, srcValue) => {
43
45
  function mergeWithArrayMerge(object, source) {
44
46
  return (0, mergeWith_js_1.default)(object, source, arrayMergeCustomizer);
45
47
  }
46
- exports.mergeWithArrayMerge = mergeWithArrayMerge;
47
48
  function rebaseObject(to, base, from) {
48
49
  const fromKeys = Object.keys(from);
49
50
  const removedKeys = (0, difference_js_1.default)(Object.keys(base), fromKeys);
@@ -55,10 +56,8 @@ function rebaseObject(to, base, from) {
55
56
  }
56
57
  return newObj;
57
58
  }
58
- exports.rebaseObject = rebaseObject;
59
59
  function rebaseArray(to, base, from) {
60
60
  const removed = (0, difference_js_1.default)(base, from);
61
61
  const added = (0, difference_js_1.default)(from, base);
62
62
  return (0, union_js_1.default)((0, difference_js_1.default)(to, removed), added);
63
63
  }
64
- exports.rebaseArray = rebaseArray;
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.shouldCompress = exports.contentType = void 0;
6
+ exports.contentType = contentType;
7
+ exports.shouldCompress = shouldCompress;
7
8
  const mime_types_1 = __importDefault(require("mime-types"));
8
9
  const compressedMimeTypes = new Set([
9
10
  'application/atom+xml',
@@ -55,7 +56,6 @@ function contentType(src) {
55
56
  }
56
57
  return type;
57
58
  }
58
- exports.contentType = contentType;
59
59
  /**
60
60
  * Determines whether we should compress based on file extension
61
61
  * @param {String} src Path to file fow which content type should be evaluated.
@@ -65,4 +65,3 @@ function shouldCompress(src) {
65
65
  const mimeType = mime_types_1.default.lookup(src);
66
66
  return Boolean(mimeType && compressedMimeTypes.has(mimeType));
67
67
  }
68
- exports.shouldCompress = shouldCompress;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUnusedName = void 0;
3
+ exports.getUnusedName = getUnusedName;
4
4
  function getUnusedName(names, desiredName) {
5
5
  let number = 2;
6
6
  let candidate = desiredName;
@@ -10,4 +10,3 @@ function getUnusedName(names, desiredName) {
10
10
  }
11
11
  return candidate;
12
12
  }
13
- exports.getUnusedName = getUnusedName;
@@ -3,7 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.keyName = exports.sharedTopicName = exports.sharedBucketName = exports.variantBucketName = exports.sharedResourceName = exports.variantResourceName = exports.dynamoTableName = exports.prefixName = void 0;
6
+ exports.sharedTopicName = exports.sharedResourceName = exports.variantResourceName = void 0;
7
+ exports.prefixName = prefixName;
8
+ exports.dynamoTableName = dynamoTableName;
9
+ exports.variantBucketName = variantBucketName;
10
+ exports.sharedBucketName = sharedBucketName;
11
+ exports.keyName = keyName;
7
12
  const camelCase_js_1 = __importDefault(require("lodash/camelCase.js"));
8
13
  const kebabCase_js_1 = __importDefault(require("lodash/kebabCase.js"));
9
14
  function prefixName(config, params, name) {
@@ -33,11 +38,9 @@ function prefixName(config, params, name) {
33
38
  }
34
39
  return parts.join(separator);
35
40
  }
36
- exports.prefixName = prefixName;
37
41
  function dynamoTableName(params, name) {
38
42
  return prefixName({ withVariant: true, withRegion: false, separator: '--' }, params, name);
39
43
  }
40
- exports.dynamoTableName = dynamoTableName;
41
44
  exports.variantResourceName = prefixName.bind(null, {
42
45
  withVariant: true,
43
46
  withRegion: false,
@@ -53,13 +56,10 @@ exports.sharedResourceName = prefixName.bind(null, {
53
56
  function variantBucketName(params, name) {
54
57
  return prefixName({ withVariant: true, withRegion: true, separator: '--' }, params, name);
55
58
  }
56
- exports.variantBucketName = variantBucketName;
57
59
  function sharedBucketName(params, name) {
58
60
  return prefixName({ withVariant: false, withRegion: true, separator: '--' }, params, name);
59
61
  }
60
- exports.sharedBucketName = sharedBucketName;
61
62
  exports.sharedTopicName = exports.sharedResourceName;
62
63
  function keyName(params, name) {
63
64
  return prefixName({ withVariant: true, withRegion: false, separator: '--' }, params, name);
64
65
  }
65
- exports.keyName = keyName;
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.falsy = exports.equals = exports.not = void 0;
3
+ exports.not = not;
4
+ exports.equals = equals;
5
+ exports.falsy = falsy;
4
6
  function not(predicate) {
5
7
  return (value) => !predicate(value);
6
8
  }
7
- exports.not = not;
8
9
  function equals(a) {
9
10
  return (b) => a === b;
10
11
  }
11
- exports.equals = equals;
12
12
  function falsy(obj) {
13
13
  return !obj;
14
14
  }
15
- exports.falsy = falsy;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapSet = exports.addAll = void 0;
3
+ exports.addAll = addAll;
4
+ exports.mapSet = mapSet;
4
5
  function addAll(set, iterable) {
5
6
  for (const value of iterable) {
6
7
  set.add(value);
7
8
  }
8
9
  return set;
9
10
  }
10
- exports.addAll = addAll;
11
11
  function mapSet(set, fn) {
12
12
  const result = new Array(set.size);
13
13
  let i = 0;
@@ -16,4 +16,3 @@ function mapSet(set, fn) {
16
16
  }
17
17
  return result;
18
18
  }
19
- exports.mapSet = mapSet;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sleep = void 0;
3
+ exports.sleep = sleep;
4
4
  async function sleep(ms) {
5
5
  return new Promise((resolve) => {
6
6
  setTimeout(resolve, ms);
7
7
  });
8
8
  }
9
- exports.sleep = sleep;
@@ -3,7 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.base64Decode = exports.base64Encode = exports.encodePropertyName = exports.isIntegerLike = exports.isEmptyString = exports.isUuid = exports.pascalCase = exports.formatShapeName = exports.camelCase = void 0;
6
+ exports.camelCase = void 0;
7
+ exports.formatShapeName = formatShapeName;
8
+ exports.pascalCase = pascalCase;
9
+ exports.isUuid = isUuid;
10
+ exports.isEmptyString = isEmptyString;
11
+ exports.isIntegerLike = isIntegerLike;
12
+ exports.encodePropertyName = encodePropertyName;
13
+ exports.base64Encode = base64Encode;
14
+ exports.base64Decode = base64Decode;
7
15
  const browser_or_node_1 = require("browser-or-node");
8
16
  const camelCase_js_1 = __importDefault(require("lodash/camelCase.js"));
9
17
  const isEmpty_js_1 = __importDefault(require("lodash/isEmpty.js"));
@@ -37,38 +45,30 @@ function formatShapeName(str, options) {
37
45
  }
38
46
  return arr.join('');
39
47
  }
40
- exports.formatShapeName = formatShapeName;
41
48
  /**
42
49
  * Optional config triggers a namespace-preserving behavior for built-in shapes starting with `TS`.
43
50
  */
44
51
  function pascalCase(str) {
45
52
  return (0, upperFirst_js_1.default)((0, exports.camelCase)(str));
46
53
  }
47
- exports.pascalCase = pascalCase;
48
54
  function isUuid(str) {
49
55
  return Boolean(/\w{8,}(-\w{4,}){3,}-\w{12,}/.exec(str));
50
56
  }
51
- exports.isUuid = isUuid;
52
57
  function isEmptyString(str) {
53
58
  return (0, isString_js_1.default)(str) && (0, isEmpty_js_1.default)(str);
54
59
  }
55
- exports.isEmptyString = isEmptyString;
56
60
  function isIntegerLike(value) {
57
61
  if (typeof value === 'number') {
58
62
  return true;
59
63
  }
60
64
  return /^\d+$/.test(value);
61
65
  }
62
- exports.isIntegerLike = isIntegerLike;
63
66
  function encodePropertyName(value) {
64
67
  return value.replace(/[^A-Za-z0-9]/g, (c) => `%${c.charCodeAt(0).toString(16)}`);
65
68
  }
66
- exports.encodePropertyName = encodePropertyName;
67
69
  function base64Encode(str) {
68
70
  return browser_or_node_1.isBrowser ? window.btoa(str) : Buffer.from(str).toString('base64');
69
71
  }
70
- exports.base64Encode = base64Encode;
71
72
  function base64Decode(str) {
72
73
  return browser_or_node_1.isBrowser ? window.atob(str) : Buffer.from(str, 'base64').toString();
73
74
  }
74
- exports.base64Decode = base64Decode;
@@ -3,7 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.jsonTemplate = exports.codeTemplate = exports.oembedTemplateMdx = exports.oembedTemplate = exports.imageTemplateMdx = exports.imageTemplate = exports.attrs = exports.getApplyPrefix = void 0;
6
+ exports.getApplyPrefix = getApplyPrefix;
7
+ exports.attrs = attrs;
8
+ exports.imageTemplate = imageTemplate;
9
+ exports.imageTemplateMdx = imageTemplateMdx;
10
+ exports.oembedTemplate = oembedTemplate;
11
+ exports.oembedTemplateMdx = oembedTemplateMdx;
12
+ exports.codeTemplate = codeTemplate;
13
+ exports.jsonTemplate = jsonTemplate;
7
14
  const routing_1 = require("@takeshape/routing");
8
15
  /*
9
16
  * The intention is to move all this to the client package in the end, but right now it's here
@@ -16,7 +23,6 @@ const types_js_1 = require("./types.js");
16
23
  function getApplyPrefix(prefix) {
17
24
  return (className) => (className ? prefix + className : '');
18
25
  }
19
- exports.getApplyPrefix = getApplyPrefix;
20
26
  function attrs(obj) {
21
27
  const attrStrings = [];
22
28
  const attrNames = Object.keys(obj);
@@ -29,7 +35,6 @@ function attrs(obj) {
29
35
  }
30
36
  return attrStrings.length ? ` ${attrStrings.join(' ')}` : '';
31
37
  }
32
- exports.attrs = attrs;
33
38
  function imageTemplate(applyPrefix, data) {
34
39
  const { caption, credit, alignment, size, asset, imageParams } = data;
35
40
  if (!asset) {
@@ -55,7 +60,6 @@ function imageTemplate(applyPrefix, data) {
55
60
  }
56
61
  return `<figure${classAttr}>${image}${figCaption}</figure>`;
57
62
  }
58
- exports.imageTemplate = imageTemplate;
59
63
  function renderMdx(tag, attributes, data, children) {
60
64
  const tagWithAttributes = `${tag} ${attributes.map((attr) => `${attr}="${(0, escape_js_1.default)(data[attr])}"`).join(' ')}`;
61
65
  if (children) {
@@ -68,22 +72,18 @@ ${children.replace(/[\n\r]+$/, '')}
68
72
  function imageTemplateMdx(applyPrefix, data) {
69
73
  return renderMdx(applyPrefix('Image'), ['id', 'caption', 'credit', 'link', 'linkisexternal', 'alignment', 'size', 'src'], data);
70
74
  }
71
- exports.imageTemplateMdx = imageTemplateMdx;
72
75
  function oembedTemplate(applyPrefix, data) {
73
76
  return `<div class="${applyPrefix('oembed')}">${data.html}</div>`;
74
77
  }
75
- exports.oembedTemplate = oembedTemplate;
76
78
  function oembedTemplateMdx(applyPrefix, data) {
77
79
  return renderMdx(applyPrefix('Oembed'), ['url', 'author_name', 'author_url', 'width', 'height', 'type', 'cache_age', 'provider_name', 'version'], data, data.html);
78
80
  }
79
- exports.oembedTemplateMdx = oembedTemplateMdx;
80
81
  function codeTemplate(applyPrefix, data) {
81
82
  const { text, lang } = data;
82
83
  const code = (0, highlight_code_js_1.highlightCode)(text, lang);
83
84
  const langClass = lang ? ` class="${applyPrefix(`language-${lang}`)}"` : '';
84
85
  return `<pre><code${langClass}>${code}</code></pre>`;
85
86
  }
86
- exports.codeTemplate = codeTemplate;
87
87
  function jsonTemplate(template, context) {
88
88
  const renderTemplate = (template) => {
89
89
  return template.replace(/{{(\w+)}}/g, (_, name) => context[name] ?? '');
@@ -106,4 +106,3 @@ function jsonTemplate(template, context) {
106
106
  };
107
107
  return transform(template);
108
108
  }
109
- exports.jsonTemplate = jsonTemplate;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.timeZoneList = exports.guessTimeZone = void 0;
3
+ exports.timeZoneList = void 0;
4
+ exports.guessTimeZone = guessTimeZone;
4
5
  function guessTimeZone() {
5
6
  if (Intl) {
6
7
  return Intl.DateTimeFormat().resolvedOptions().timeZone;
7
8
  }
8
9
  return 'UTC';
9
10
  }
10
- exports.guessTimeZone = guessTimeZone;
11
11
  // Equivalent to `moment.tz.names()`
12
12
  exports.timeZoneList = [
13
13
  'Africa/Abidjan',
@@ -3,7 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isNumericString = exports.getSingle = exports.isScalar = exports.isPrimitive = exports.createEnumMatcher = exports.isIterableObject = exports.isRecord = void 0;
6
+ exports.isRecord = isRecord;
7
+ exports.isIterableObject = isIterableObject;
8
+ exports.createEnumMatcher = createEnumMatcher;
9
+ exports.isPrimitive = isPrimitive;
10
+ exports.isScalar = isScalar;
11
+ exports.getSingle = getSingle;
12
+ exports.isNumericString = isNumericString;
7
13
  const isNull_js_1 = __importDefault(require("lodash/isNull.js"));
8
14
  const isPlainObject_js_1 = __importDefault(require("lodash/isPlainObject.js"));
9
15
  /**
@@ -13,7 +19,6 @@ const isPlainObject_js_1 = __importDefault(require("lodash/isPlainObject.js"));
13
19
  function isRecord(maybeRecord) {
14
20
  return (0, isPlainObject_js_1.default)(maybeRecord);
15
21
  }
16
- exports.isRecord = isRecord;
17
22
  /**
18
23
  A guard for objects that ensures they are iterable records objects
19
24
  not as strict as isRecord but better performance when that matters
@@ -21,7 +26,6 @@ exports.isRecord = isRecord;
21
26
  function isIterableObject(x) {
22
27
  return Boolean(x) && typeof x === 'object';
23
28
  }
24
- exports.isIterableObject = isIterableObject;
25
29
  /**
26
30
  * Create enum matchers, which will return the enum entry from the provided
27
31
  * enum when the value matches.
@@ -29,7 +33,6 @@ exports.isIterableObject = isIterableObject;
29
33
  function createEnumMatcher(enumVariable) {
30
34
  return (testValue) => Object.entries(enumVariable).find(([, enumValue]) => enumValue === testValue);
31
35
  }
32
- exports.createEnumMatcher = createEnumMatcher;
33
36
  function isPrimitive(maybePrimitive) {
34
37
  return (typeof maybePrimitive === 'string' ||
35
38
  typeof maybePrimitive === 'number' ||
@@ -39,25 +42,21 @@ function isPrimitive(maybePrimitive) {
39
42
  typeof maybePrimitive === 'bigint' ||
40
43
  (0, isNull_js_1.default)(maybePrimitive));
41
44
  }
42
- exports.isPrimitive = isPrimitive;
43
45
  function isScalar(maybeScalar) {
44
46
  return (typeof maybeScalar === 'string' ||
45
47
  typeof maybeScalar === 'number' ||
46
48
  typeof maybeScalar === 'boolean' ||
47
49
  typeof maybeScalar === 'bigint');
48
50
  }
49
- exports.isScalar = isScalar;
50
51
  function getSingle(t) {
51
52
  if (Array.isArray(t)) {
52
53
  return t[0];
53
54
  }
54
55
  return t;
55
56
  }
56
- exports.getSingle = getSingle;
57
57
  /**
58
58
  * Test whether a provided string is numeric, e.g., '9' is numeric while 'nine' is not.
59
59
  */
60
60
  function isNumericString(key) {
61
61
  return !Number.isNaN(Number(key));
62
62
  }
63
- exports.isNumericString = isNumericString;
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unixToISODateOnly = exports.unixToISO = exports.isoToISODateOnly = void 0;
3
+ exports.isoToISODateOnly = isoToISODateOnly;
4
+ exports.unixToISO = unixToISO;
5
+ exports.unixToISODateOnly = unixToISODateOnly;
4
6
  function isoToISODateOnly(iso) {
5
7
  return iso.slice(0, 10);
6
8
  }
7
- exports.isoToISODateOnly = isoToISODateOnly;
8
9
  function unixToISO(unix) {
9
10
  return new Date(unix * 1000).toISOString();
10
11
  }
11
- exports.unixToISO = unixToISO;
12
12
  function unixToISODateOnly(unix) {
13
13
  return isoToISODateOnly(unixToISO(unix));
14
14
  }
15
- exports.unixToISODateOnly = unixToISODateOnly;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFileName = void 0;
3
+ exports.getFileName = getFileName;
4
4
  function getFileName(urlOrPath) {
5
5
  const path = urlOrPath.includes('://') ? new URL(urlOrPath).pathname : urlOrPath;
6
6
  const index = path.lastIndexOf('/');
7
7
  return index === -1 ? path : path.substring(index + 1);
8
8
  }
9
- exports.getFileName = getFileName;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.value = void 0;
3
+ exports.value = value;
4
4
  function value(x) {
5
5
  return () => x;
6
6
  }
7
- exports.value = value;
8
7
  exports.default = value;