@takeshape/util 11.45.5 → 11.47.1
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/cjs/common/arrays.js +42 -0
- package/dist/cjs/common/assert.js +9 -0
- package/dist/cjs/common/async-noop.js +5 -0
- package/dist/cjs/common/billing.js +35 -0
- package/dist/cjs/common/clone.js +76 -0
- package/dist/cjs/common/delay.js +28 -0
- package/dist/cjs/common/draftjs-templates.js +131 -0
- package/dist/cjs/common/draftjs.js +807 -0
- package/dist/cjs/common/get-image-url.js +8 -0
- package/dist/cjs/common/highlight-code.js +33 -0
- package/dist/cjs/common/http.js +19 -0
- package/dist/cjs/common/index.js +50 -0
- package/dist/cjs/common/map.js +7 -0
- package/dist/cjs/common/memoize.js +13 -0
- package/dist/cjs/common/merge.js +64 -0
- package/dist/cjs/common/mime.js +68 -0
- package/dist/cjs/common/names.js +13 -0
- package/dist/cjs/common/naming.js +65 -0
- package/dist/cjs/common/path-to-string.js +10 -0
- package/dist/cjs/common/persisted-queries.js +4 -0
- package/dist/cjs/common/predicate.js +15 -0
- package/dist/cjs/common/set-in.js +13 -0
- package/dist/cjs/common/sets.js +19 -0
- package/dist/cjs/common/sleep.js +9 -0
- package/dist/cjs/common/sort-object.js +16 -0
- package/dist/cjs/common/strings.js +74 -0
- package/dist/cjs/common/templates.js +109 -0
- package/dist/cjs/common/timezone.js +606 -0
- package/dist/cjs/common/tracing.js +2 -0
- package/dist/cjs/common/types.js +63 -0
- package/dist/cjs/common/unix-to-iso.js +15 -0
- package/dist/cjs/common/urls.js +9 -0
- package/dist/cjs/common/validation.js +5 -0
- package/dist/cjs/common/value.js +8 -0
- package/dist/cjs/common/visit.js +60 -0
- package/dist/cjs/node/encryption.js +31 -0
- package/dist/cjs/node/gzip.js +10 -0
- package/dist/cjs/node/index.js +19 -0
- package/dist/cjs/node/search-params.js +23 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/common/arrays.js +33 -0
- package/dist/esm/common/assert.js +5 -0
- package/dist/esm/common/async-noop.js +2 -0
- package/dist/esm/common/billing.js +29 -0
- package/dist/esm/common/clone.js +71 -0
- package/dist/esm/common/delay.js +22 -0
- package/dist/esm/common/draftjs-templates.js +122 -0
- package/dist/esm/common/draftjs.js +792 -0
- package/{es → dist/esm/common}/get-image-url.js +2 -7
- package/dist/esm/common/highlight-code.js +26 -0
- package/dist/esm/common/http.js +15 -0
- package/dist/esm/common/index.js +34 -0
- package/{es → dist/esm/common}/map.js +2 -2
- package/dist/esm/common/memoize.js +6 -0
- package/dist/esm/common/merge.js +54 -0
- package/dist/esm/common/mime.js +60 -0
- package/dist/esm/common/names.js +9 -0
- package/dist/esm/common/naming.js +54 -0
- package/dist/esm/common/path-to-string.js +6 -0
- package/{es → dist/esm/common}/persisted-queries.js +1 -1
- package/{es → dist/esm/common}/predicate.js +4 -4
- package/dist/esm/common/set-in.js +7 -0
- package/dist/esm/common/sets.js +14 -0
- package/dist/esm/common/sleep.js +5 -0
- package/dist/esm/common/sort-object.js +12 -0
- package/dist/esm/common/strings.js +60 -0
- package/dist/esm/common/templates.js +95 -0
- package/dist/esm/common/timezone.js +602 -0
- package/dist/esm/common/tracing.js +1 -0
- package/dist/esm/common/types.js +50 -0
- package/dist/esm/common/unix-to-iso.js +9 -0
- package/dist/esm/common/urls.js +5 -0
- package/dist/esm/common/validation.js +2 -0
- package/dist/esm/common/value.js +4 -0
- package/dist/esm/common/visit.js +52 -0
- package/dist/esm/node/encryption.js +25 -0
- package/dist/esm/node/gzip.js +4 -0
- package/dist/esm/node/index.js +3 -0
- package/dist/esm/node/search-params.js +17 -0
- package/dist/esm/package.json +1 -0
- package/dist/tsconfig.types.tsbuildinfo +1 -0
- package/dist/{arrays.d.ts → types/common/arrays.d.ts} +0 -1
- package/dist/{assert.d.ts → types/common/assert.d.ts} +0 -1
- package/dist/{async-noop.d.ts → types/common/async-noop.d.ts} +0 -1
- package/dist/types/common/billing.d.ts +365 -0
- package/dist/{clone.d.ts → types/common/clone.d.ts} +0 -1
- package/dist/{delay.d.ts → types/common/delay.d.ts} +0 -1
- package/dist/{draftjs-templates.d.ts → types/common/draftjs-templates.d.ts} +1 -2
- package/dist/{draftjs.d.ts → types/common/draftjs.d.ts} +1 -2
- package/dist/{get-image-url.d.ts → types/common/get-image-url.d.ts} +0 -1
- package/dist/types/common/highlight-code.d.ts +14 -0
- package/dist/{http.d.ts → types/common/http.d.ts} +0 -1
- package/dist/types/common/index.d.ts +34 -0
- package/dist/{map.d.ts → types/common/map.d.ts} +0 -1
- package/dist/{memoize.d.ts → types/common/memoize.d.ts} +0 -1
- package/dist/{merge.d.ts → types/common/merge.d.ts} +0 -1
- package/dist/{mime.d.ts → types/common/mime.d.ts} +0 -1
- package/dist/{names.d.ts → types/common/names.d.ts} +0 -1
- package/dist/{naming.d.ts → types/common/naming.d.ts} +0 -1
- package/dist/{path-to-string.d.ts → types/common/path-to-string.d.ts} +0 -1
- package/dist/{persisted-queries.d.ts → types/common/persisted-queries.d.ts} +0 -1
- package/dist/{predicate.d.ts → types/common/predicate.d.ts} +0 -1
- package/dist/{set-in.d.ts → types/common/set-in.d.ts} +0 -1
- package/dist/{sets.d.ts → types/common/sets.d.ts} +0 -1
- package/dist/{sleep.d.ts → types/common/sleep.d.ts} +0 -1
- package/dist/{sort-object.d.ts → types/common/sort-object.d.ts} +0 -1
- package/dist/{strings.d.ts → types/common/strings.d.ts} +1 -2
- package/dist/{templates.d.ts → types/common/templates.d.ts} +1 -2
- package/dist/{timezone.d.ts → types/common/timezone.d.ts} +0 -1
- package/dist/{tracing.d.ts → types/common/tracing.d.ts} +1 -2
- package/dist/{types.d.ts → types/common/types.d.ts} +0 -1
- package/dist/{unix-to-iso.d.ts → types/common/unix-to-iso.d.ts} +0 -1
- package/dist/{urls.d.ts → types/common/urls.d.ts} +0 -1
- package/dist/{validation.d.ts → types/common/validation.d.ts} +0 -1
- package/dist/{value.d.ts → types/common/value.d.ts} +0 -1
- package/dist/{visit.d.ts → types/common/visit.d.ts} +0 -1
- package/dist/{encryption.d.ts → types/node/encryption.d.ts} +0 -1
- package/dist/{gzip.d.ts → types/node/gzip.d.ts} +1 -2
- package/dist/types/node/index.d.ts +3 -0
- package/dist/{search-params.d.ts → types/node/search-params.d.ts} +1 -2
- package/package.json +33 -21
- package/dist/arrays.d.ts.map +0 -1
- package/dist/arrays.js +0 -44
- package/dist/assert.d.ts.map +0 -1
- package/dist/assert.js +0 -11
- package/dist/async-noop.d.ts.map +0 -1
- package/dist/async-noop.js +0 -8
- package/dist/billing.d.ts +0 -366
- package/dist/billing.d.ts.map +0 -1
- package/dist/billing.js +0 -48
- package/dist/browser.d.ts +0 -2
- package/dist/browser.d.ts.map +0 -1
- package/dist/browser.js +0 -16
- package/dist/clone.d.ts.map +0 -1
- package/dist/clone.js +0 -101
- package/dist/common.d.ts +0 -32
- package/dist/common.d.ts.map +0 -1
- package/dist/common.js +0 -346
- package/dist/delay.d.ts.map +0 -1
- package/dist/delay.js +0 -34
- package/dist/draftjs-templates.d.ts.map +0 -1
- package/dist/draftjs-templates.js +0 -157
- package/dist/draftjs.d.ts.map +0 -1
- package/dist/draftjs.js +0 -836
- package/dist/encryption.d.ts.map +0 -1
- package/dist/encryption.js +0 -33
- package/dist/get-image-url.d.ts.map +0 -1
- package/dist/get-image-url.js +0 -15
- package/dist/gzip.d.ts.map +0 -1
- package/dist/gzip.js +0 -11
- package/dist/highlight-code.d.ts +0 -15
- package/dist/highlight-code.d.ts.map +0 -1
- package/dist/highlight-code.js +0 -35
- package/dist/http.d.ts.map +0 -1
- package/dist/http.js +0 -18
- package/dist/index.d.ts +0 -6
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -60
- package/dist/map.d.ts.map +0 -1
- package/dist/map.js +0 -9
- package/dist/memoize.d.ts.map +0 -1
- package/dist/memoize.js +0 -13
- package/dist/merge.d.ts.map +0 -1
- package/dist/merge.js +0 -67
- package/dist/mime.d.ts.map +0 -1
- package/dist/mime.js +0 -37
- package/dist/names.d.ts.map +0 -1
- package/dist/names.js +0 -15
- package/dist/naming.d.ts.map +0 -1
- package/dist/naming.js +0 -91
- package/dist/path-to-string.d.ts.map +0 -1
- package/dist/path-to-string.js +0 -13
- package/dist/persisted-queries.d.ts.map +0 -1
- package/dist/persisted-queries.js +0 -7
- package/dist/predicate.d.ts.map +0 -1
- package/dist/predicate.js +0 -17
- package/dist/search-params.d.ts.map +0 -1
- package/dist/search-params.js +0 -25
- package/dist/set-in.d.ts.map +0 -1
- package/dist/set-in.js +0 -11
- package/dist/sets.d.ts.map +0 -1
- package/dist/sets.js +0 -21
- package/dist/sleep.d.ts.map +0 -1
- package/dist/sleep.js +0 -11
- package/dist/sort-object.d.ts.map +0 -1
- package/dist/sort-object.js +0 -21
- package/dist/strings.d.ts.map +0 -1
- package/dist/strings.js +0 -87
- package/dist/templates.d.ts.map +0 -1
- package/dist/templates.js +0 -120
- package/dist/timezone.d.ts.map +0 -1
- package/dist/timezone.js +0 -17
- package/dist/tracing.d.ts.map +0 -1
- package/dist/tracing.js +0 -5
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -92
- package/dist/unix-to-iso.d.ts.map +0 -1
- package/dist/unix-to-iso.js +0 -17
- package/dist/urls.d.ts.map +0 -1
- package/dist/urls.js +0 -11
- package/dist/validation.d.ts.map +0 -1
- package/dist/validation.js +0 -8
- package/dist/value.d.ts.map +0 -1
- package/dist/value.js +0 -11
- package/dist/visit.d.ts.map +0 -1
- package/dist/visit.js +0 -61
- package/es/arrays.js +0 -33
- package/es/assert.js +0 -5
- package/es/async-noop.js +0 -2
- package/es/billing.js +0 -40
- package/es/browser.js +0 -1
- package/es/clone.js +0 -94
- package/es/common.js +0 -31
- package/es/delay.js +0 -26
- package/es/draftjs-templates.js +0 -147
- package/es/draftjs.js +0 -819
- package/es/encryption.js +0 -26
- package/es/gzip.js +0 -4
- package/es/highlight-code.js +0 -26
- package/es/http.js +0 -11
- package/es/index.js +0 -6
- package/es/memoize.js +0 -6
- package/es/merge.js +0 -58
- package/es/mime.js +0 -29
- package/es/names.js +0 -9
- package/es/naming.js +0 -78
- package/es/path-to-string.js +0 -6
- package/es/search-params.js +0 -17
- package/es/set-in.js +0 -6
- package/es/sets.js +0 -14
- package/es/sleep.js +0 -5
- package/es/sort-object.js +0 -14
- package/es/strings.js +0 -72
- package/es/templates.js +0 -105
- package/es/timezone.js +0 -10
- package/es/tracing.js +0 -1
- package/es/types.js +0 -80
- package/es/unix-to-iso.js +0 -9
- package/es/urls.js +0 -5
- package/es/validation.js +0 -2
- package/es/value.js +0 -4
- package/es/visit.js +0 -53
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getImageUrl = void 0;
|
|
4
|
+
const routing_1 = require("@takeshape/routing");
|
|
5
|
+
function getImageUrl(path, defaultImageConfig, imageBaseUrl, config) {
|
|
6
|
+
return (0, routing_1.getImageUrl)(path, { ...defaultImageConfig, ...config }, { baseUrl: imageBaseUrl });
|
|
7
|
+
}
|
|
8
|
+
exports.getImageUrl = getImageUrl;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.highlightCode = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* The intention is to move all this to the client package in the end, but right now it's here
|
|
9
|
+
* to be shared between the draftjs / mdx implementations, which span the client / server differently.
|
|
10
|
+
*/
|
|
11
|
+
const prismjs_1 = __importDefault(require("prismjs"));
|
|
12
|
+
require("prismjs/components/prism-javascript.js");
|
|
13
|
+
require("prismjs/components/prism-markup.js");
|
|
14
|
+
require("prismjs/components/prism-markup-templating.js");
|
|
15
|
+
require("prismjs/components/prism-css.js");
|
|
16
|
+
require("prismjs/components/prism-bash.js");
|
|
17
|
+
require("prismjs/components/prism-django.js");
|
|
18
|
+
require("prismjs/components/prism-twig.js");
|
|
19
|
+
require("prismjs/components/prism-yaml.js");
|
|
20
|
+
require("prismjs/components/prism-graphql.js");
|
|
21
|
+
require("prismjs/components/prism-sass.js");
|
|
22
|
+
require("prismjs/components/prism-scss.js");
|
|
23
|
+
require("prismjs/components/prism-markdown.js");
|
|
24
|
+
require("prismjs/components/prism-json.js");
|
|
25
|
+
const escape_js_1 = __importDefault(require("lodash/escape.js"));
|
|
26
|
+
const highlightCode = (code, lang) => {
|
|
27
|
+
if (lang) {
|
|
28
|
+
const syntax = prismjs_1.default.languages[lang];
|
|
29
|
+
return prismjs_1.default.highlight(code, syntax, lang);
|
|
30
|
+
}
|
|
31
|
+
return (0, escape_js_1.default)(code);
|
|
32
|
+
};
|
|
33
|
+
exports.highlightCode = highlightCode;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBasicAuthString = void 0;
|
|
4
|
+
const browser_or_node_1 = require("browser-or-node");
|
|
5
|
+
const getBasicAuthString = (basicAuth) => {
|
|
6
|
+
let authString = '';
|
|
7
|
+
if (basicAuth.username) {
|
|
8
|
+
authString += basicAuth.username;
|
|
9
|
+
}
|
|
10
|
+
authString += ':';
|
|
11
|
+
if (basicAuth.password) {
|
|
12
|
+
authString += basicAuth.password;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Not ideal, but this is used in service-providers which is imported into both the client and the api.
|
|
16
|
+
*/
|
|
17
|
+
return browser_or_node_1.isBrowser ? window.btoa(authString) : Buffer.from(authString).toString('base64');
|
|
18
|
+
};
|
|
19
|
+
exports.getBasicAuthString = getBasicAuthString;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./arrays.js"), exports);
|
|
18
|
+
__exportStar(require("./assert.js"), exports);
|
|
19
|
+
__exportStar(require("./async-noop.js"), exports);
|
|
20
|
+
__exportStar(require("./billing.js"), exports);
|
|
21
|
+
__exportStar(require("./clone.js"), exports);
|
|
22
|
+
__exportStar(require("./delay.js"), exports);
|
|
23
|
+
__exportStar(require("./draftjs-templates.js"), exports);
|
|
24
|
+
__exportStar(require("./draftjs.js"), exports);
|
|
25
|
+
__exportStar(require("./get-image-url.js"), exports);
|
|
26
|
+
__exportStar(require("./highlight-code.js"), exports);
|
|
27
|
+
__exportStar(require("./http.js"), exports);
|
|
28
|
+
__exportStar(require("./map.js"), exports);
|
|
29
|
+
__exportStar(require("./memoize.js"), exports);
|
|
30
|
+
__exportStar(require("./merge.js"), exports);
|
|
31
|
+
__exportStar(require("./mime.js"), exports);
|
|
32
|
+
__exportStar(require("./names.js"), exports);
|
|
33
|
+
__exportStar(require("./naming.js"), exports);
|
|
34
|
+
__exportStar(require("./path-to-string.js"), exports);
|
|
35
|
+
__exportStar(require("./persisted-queries.js"), exports);
|
|
36
|
+
__exportStar(require("./predicate.js"), exports);
|
|
37
|
+
__exportStar(require("./set-in.js"), exports);
|
|
38
|
+
__exportStar(require("./sets.js"), exports);
|
|
39
|
+
__exportStar(require("./sleep.js"), exports);
|
|
40
|
+
__exportStar(require("./sort-object.js"), exports);
|
|
41
|
+
__exportStar(require("./strings.js"), exports);
|
|
42
|
+
__exportStar(require("./templates.js"), exports);
|
|
43
|
+
__exportStar(require("./timezone.js"), exports);
|
|
44
|
+
__exportStar(require("./tracing.js"), exports);
|
|
45
|
+
__exportStar(require("./types.js"), exports);
|
|
46
|
+
__exportStar(require("./unix-to-iso.js"), exports);
|
|
47
|
+
__exportStar(require("./urls.js"), exports);
|
|
48
|
+
__exportStar(require("./validation.js"), exports);
|
|
49
|
+
__exportStar(require("./value.js"), exports);
|
|
50
|
+
__exportStar(require("./visit.js"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.weakMemoize = void 0;
|
|
7
|
+
const memoize_js_1 = __importDefault(require("lodash/memoize.js"));
|
|
8
|
+
function weakMemoize(fn) {
|
|
9
|
+
const memoized = (0, memoize_js_1.default)(fn);
|
|
10
|
+
memoized.cache = new WeakMap();
|
|
11
|
+
return memoized;
|
|
12
|
+
}
|
|
13
|
+
exports.weakMemoize = weakMemoize;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.rebaseArray = exports.rebaseObject = exports.mergeWithArrayMerge = exports.mergeWithArrayConcat = void 0;
|
|
7
|
+
const difference_js_1 = __importDefault(require("lodash/difference.js"));
|
|
8
|
+
const isArray_js_1 = __importDefault(require("lodash/isArray.js"));
|
|
9
|
+
const isEqual_js_1 = __importDefault(require("lodash/isEqual.js"));
|
|
10
|
+
const isNull_js_1 = __importDefault(require("lodash/isNull.js"));
|
|
11
|
+
const merge_js_1 = __importDefault(require("lodash/merge.js"));
|
|
12
|
+
const mergeWith_js_1 = __importDefault(require("lodash/mergeWith.js"));
|
|
13
|
+
const omit_js_1 = __importDefault(require("lodash/omit.js"));
|
|
14
|
+
const union_js_1 = __importDefault(require("lodash/union.js"));
|
|
15
|
+
/**
|
|
16
|
+
* Lodash `mergeWith` customizer to concat arrays
|
|
17
|
+
*/
|
|
18
|
+
const arrayConcatCustomizer = (value, srcValue) => {
|
|
19
|
+
if ((0, isArray_js_1.default)(value)) {
|
|
20
|
+
return value.concat(srcValue);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Lodash `mergeWith` loaded with a customizer that concatenates arrays for a
|
|
25
|
+
* deeper merge.
|
|
26
|
+
*/
|
|
27
|
+
function mergeWithArrayConcat(object, source) {
|
|
28
|
+
return (0, mergeWith_js_1.default)(object, source, arrayConcatCustomizer);
|
|
29
|
+
}
|
|
30
|
+
exports.mergeWithArrayConcat = mergeWithArrayConcat;
|
|
31
|
+
/**
|
|
32
|
+
* Lodash `mergeWith` customizer to merge arrays
|
|
33
|
+
*/
|
|
34
|
+
const arrayMergeCustomizer = (value, srcValue) => {
|
|
35
|
+
if ((0, isArray_js_1.default)(value) && (0, isArray_js_1.default)(srcValue)) {
|
|
36
|
+
return (0, merge_js_1.default)(value, srcValue).filter((val) => !(0, isNull_js_1.default)(val));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Lodash `mergeWith` loaded with a customizer that merges arrays at the same
|
|
41
|
+
* object path. Array items set to `null` will be removed.
|
|
42
|
+
*/
|
|
43
|
+
function mergeWithArrayMerge(object, source) {
|
|
44
|
+
return (0, mergeWith_js_1.default)(object, source, arrayMergeCustomizer);
|
|
45
|
+
}
|
|
46
|
+
exports.mergeWithArrayMerge = mergeWithArrayMerge;
|
|
47
|
+
function rebaseObject(to, base, from) {
|
|
48
|
+
const fromKeys = Object.keys(from);
|
|
49
|
+
const removedKeys = (0, difference_js_1.default)(Object.keys(base), fromKeys);
|
|
50
|
+
const newObj = (0, omit_js_1.default)(to, removedKeys);
|
|
51
|
+
for (const key of fromKeys) {
|
|
52
|
+
if (!(0, isEqual_js_1.default)(base[key], from[key])) {
|
|
53
|
+
newObj[key] = from[key];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return newObj;
|
|
57
|
+
}
|
|
58
|
+
exports.rebaseObject = rebaseObject;
|
|
59
|
+
function rebaseArray(to, base, from) {
|
|
60
|
+
const removed = (0, difference_js_1.default)(base, from);
|
|
61
|
+
const added = (0, difference_js_1.default)(from, base);
|
|
62
|
+
return (0, union_js_1.default)((0, difference_js_1.default)(to, removed), added);
|
|
63
|
+
}
|
|
64
|
+
exports.rebaseArray = rebaseArray;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.shouldCompress = exports.contentType = void 0;
|
|
7
|
+
const mime_types_1 = __importDefault(require("mime-types"));
|
|
8
|
+
const compressedMimeTypes = new Set([
|
|
9
|
+
'application/atom+xml',
|
|
10
|
+
'application/javascript',
|
|
11
|
+
'application/json',
|
|
12
|
+
'application/ld+json',
|
|
13
|
+
'application/manifest+json',
|
|
14
|
+
'application/rdf+xml',
|
|
15
|
+
'application/rss+xml',
|
|
16
|
+
'application/schema+json',
|
|
17
|
+
'application/vnd.geo+json',
|
|
18
|
+
'application/vnd.ms-fontobject',
|
|
19
|
+
'application/x-font-ttf',
|
|
20
|
+
'application/x-javascript',
|
|
21
|
+
'application/x-web-app-manifest+json',
|
|
22
|
+
'application/xhtml+xml',
|
|
23
|
+
'application/xml',
|
|
24
|
+
'font/eot',
|
|
25
|
+
'font/otf',
|
|
26
|
+
'font/opentype',
|
|
27
|
+
'image/bmp',
|
|
28
|
+
'image/svg+xml',
|
|
29
|
+
'image/vnd.microsoft.icon',
|
|
30
|
+
'image/x-icon',
|
|
31
|
+
'text/cache-manifest',
|
|
32
|
+
'text/css',
|
|
33
|
+
'text/html',
|
|
34
|
+
'text/javascript',
|
|
35
|
+
'text/plain',
|
|
36
|
+
'text/vcard',
|
|
37
|
+
'text/vnd.rim.location.xloc',
|
|
38
|
+
'text/vtt',
|
|
39
|
+
'text/x-component',
|
|
40
|
+
'text/x-cross-domain-policy',
|
|
41
|
+
'text/xml'
|
|
42
|
+
]);
|
|
43
|
+
// Application/octetstream
|
|
44
|
+
const DEFAULT_TYPE = mime_types_1.default.lookup('bin');
|
|
45
|
+
/**
|
|
46
|
+
* Gets the content type of the file, based on it's extension.
|
|
47
|
+
* @param {String} src Path to file fow which content type should be evaluated.
|
|
48
|
+
* @return {String} Returns string with content type and charset.
|
|
49
|
+
*/
|
|
50
|
+
function contentType(src) {
|
|
51
|
+
let type = (mime_types_1.default.lookup(src) || DEFAULT_TYPE).replace('-', '');
|
|
52
|
+
const charset = mime_types_1.default.charset(type);
|
|
53
|
+
if (charset) {
|
|
54
|
+
type += `; charset=${charset}`;
|
|
55
|
+
}
|
|
56
|
+
return type;
|
|
57
|
+
}
|
|
58
|
+
exports.contentType = contentType;
|
|
59
|
+
/**
|
|
60
|
+
* Determines whether we should compress based on file extension
|
|
61
|
+
* @param {String} src Path to file fow which content type should be evaluated.
|
|
62
|
+
* @return {Boolean} Returns true if we should compress
|
|
63
|
+
*/
|
|
64
|
+
function shouldCompress(src) {
|
|
65
|
+
const mimeType = mime_types_1.default.lookup(src);
|
|
66
|
+
return Boolean(mimeType && compressedMimeTypes.has(mimeType));
|
|
67
|
+
}
|
|
68
|
+
exports.shouldCompress = shouldCompress;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUnusedName = void 0;
|
|
4
|
+
function getUnusedName(names, desiredName) {
|
|
5
|
+
let number = 2;
|
|
6
|
+
let candidate = desiredName;
|
|
7
|
+
while (names.has(candidate)) {
|
|
8
|
+
candidate = `${desiredName}${number}`;
|
|
9
|
+
number++;
|
|
10
|
+
}
|
|
11
|
+
return candidate;
|
|
12
|
+
}
|
|
13
|
+
exports.getUnusedName = getUnusedName;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
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;
|
|
7
|
+
const camelCase_js_1 = __importDefault(require("lodash/camelCase.js"));
|
|
8
|
+
const kebabCase_js_1 = __importDefault(require("lodash/kebabCase.js"));
|
|
9
|
+
function prefixName(config, params, name) {
|
|
10
|
+
const { withVariant, withRegion, separator } = config;
|
|
11
|
+
const { appName, stage: { env, variant }, region } = params;
|
|
12
|
+
const parts = [appName, env];
|
|
13
|
+
if (withVariant && env !== 'prod' && variant) {
|
|
14
|
+
parts.push(variant);
|
|
15
|
+
}
|
|
16
|
+
if (withRegion) {
|
|
17
|
+
if (!region) {
|
|
18
|
+
throw new Error('Cannot provide a region prefix without a region in context');
|
|
19
|
+
}
|
|
20
|
+
parts.push(region);
|
|
21
|
+
}
|
|
22
|
+
if (name === '*') {
|
|
23
|
+
parts.push(name);
|
|
24
|
+
}
|
|
25
|
+
else if (config.case === 'kebabCase') {
|
|
26
|
+
parts.push((0, kebabCase_js_1.default)(name));
|
|
27
|
+
}
|
|
28
|
+
else if (config.case === 'camelCase') {
|
|
29
|
+
parts.push((0, camelCase_js_1.default)(name));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
parts.push(name);
|
|
33
|
+
}
|
|
34
|
+
return parts.join(separator);
|
|
35
|
+
}
|
|
36
|
+
exports.prefixName = prefixName;
|
|
37
|
+
function dynamoTableName(params, name) {
|
|
38
|
+
return prefixName({ withVariant: true, withRegion: false, separator: '--' }, params, name);
|
|
39
|
+
}
|
|
40
|
+
exports.dynamoTableName = dynamoTableName;
|
|
41
|
+
exports.variantResourceName = prefixName.bind(null, {
|
|
42
|
+
withVariant: true,
|
|
43
|
+
withRegion: false,
|
|
44
|
+
separator: '--',
|
|
45
|
+
case: 'kebabCase'
|
|
46
|
+
});
|
|
47
|
+
exports.sharedResourceName = prefixName.bind(null, {
|
|
48
|
+
withVariant: false,
|
|
49
|
+
withRegion: false,
|
|
50
|
+
separator: '--',
|
|
51
|
+
case: 'kebabCase'
|
|
52
|
+
});
|
|
53
|
+
function variantBucketName(params, name) {
|
|
54
|
+
return prefixName({ withVariant: true, withRegion: true, separator: '--' }, params, name);
|
|
55
|
+
}
|
|
56
|
+
exports.variantBucketName = variantBucketName;
|
|
57
|
+
function sharedBucketName(params, name) {
|
|
58
|
+
return prefixName({ withVariant: false, withRegion: true, separator: '--' }, params, name);
|
|
59
|
+
}
|
|
60
|
+
exports.sharedBucketName = sharedBucketName;
|
|
61
|
+
exports.sharedTopicName = exports.sharedResourceName;
|
|
62
|
+
function keyName(params, name) {
|
|
63
|
+
return prefixName({ withVariant: true, withRegion: false, separator: '--' }, params, name);
|
|
64
|
+
}
|
|
65
|
+
exports.keyName = keyName;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pathToString = void 0;
|
|
4
|
+
const pathToString = (array) => {
|
|
5
|
+
return array.reduce((string, item) => {
|
|
6
|
+
const prefix = string === '' ? '' : '.';
|
|
7
|
+
return string + (Number.isNaN(Number(item)) ? prefix + item : `[${item}]`);
|
|
8
|
+
}, '');
|
|
9
|
+
};
|
|
10
|
+
exports.pathToString = pathToString;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.falsy = exports.equals = exports.not = void 0;
|
|
4
|
+
function not(predicate) {
|
|
5
|
+
return (value) => !predicate(value);
|
|
6
|
+
}
|
|
7
|
+
exports.not = not;
|
|
8
|
+
function equals(a) {
|
|
9
|
+
return (b) => a === b;
|
|
10
|
+
}
|
|
11
|
+
exports.equals = equals;
|
|
12
|
+
function falsy(obj) {
|
|
13
|
+
return !obj;
|
|
14
|
+
}
|
|
15
|
+
exports.falsy = falsy;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.setIn = void 0;
|
|
7
|
+
const clone_js_1 = __importDefault(require("lodash/fp/clone.js"));
|
|
8
|
+
const curry_js_1 = __importDefault(require("lodash/fp/curry.js"));
|
|
9
|
+
const setWith_js_1 = __importDefault(require("lodash/fp/setWith.js"));
|
|
10
|
+
/**
|
|
11
|
+
* Same as lodash/set but does not mutate the arguments
|
|
12
|
+
*/
|
|
13
|
+
exports.setIn = (0, curry_js_1.default)((obj, path, value) => (0, setWith_js_1.default)(clone_js_1.default, path, value, (0, clone_js_1.default)(obj)));
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapSet = exports.addAll = void 0;
|
|
4
|
+
function addAll(set, iterable) {
|
|
5
|
+
for (const value of iterable) {
|
|
6
|
+
set.add(value);
|
|
7
|
+
}
|
|
8
|
+
return set;
|
|
9
|
+
}
|
|
10
|
+
exports.addAll = addAll;
|
|
11
|
+
function mapSet(set, fn) {
|
|
12
|
+
const result = new Array(set.size);
|
|
13
|
+
let i = 0;
|
|
14
|
+
for (const value of set) {
|
|
15
|
+
result[i++] = fn(value);
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
exports.mapSet = mapSet;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sortObject = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Object key order is not guarenteed. This can be useful
|
|
6
|
+
* but should not be depended upon.
|
|
7
|
+
*/
|
|
8
|
+
const sortObject = (obj) => {
|
|
9
|
+
// Convert object to array of key-value pairs
|
|
10
|
+
const arr = Object.entries(obj);
|
|
11
|
+
// Sort array by key
|
|
12
|
+
arr.sort(([key1], [key2]) => key1.localeCompare(key2));
|
|
13
|
+
// Convert array back to object
|
|
14
|
+
return Object.fromEntries(arr);
|
|
15
|
+
};
|
|
16
|
+
exports.sortObject = sortObject;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
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;
|
|
7
|
+
const browser_or_node_1 = require("browser-or-node");
|
|
8
|
+
const camelCase_js_1 = __importDefault(require("lodash/camelCase.js"));
|
|
9
|
+
const isEmpty_js_1 = __importDefault(require("lodash/isEmpty.js"));
|
|
10
|
+
const isString_js_1 = __importDefault(require("lodash/isString.js"));
|
|
11
|
+
const upperFirst_js_1 = __importDefault(require("lodash/upperFirst.js"));
|
|
12
|
+
const arrays_js_1 = require("./arrays.js");
|
|
13
|
+
exports.camelCase = camelCase_js_1.default;
|
|
14
|
+
function formatShapeName(str, options) {
|
|
15
|
+
const strings = (0, arrays_js_1.ensureArray)(str);
|
|
16
|
+
const shapeNameIndex = options?.shapeNameIndex ?? 0;
|
|
17
|
+
const shapeName = strings.at(shapeNameIndex);
|
|
18
|
+
// If the shapeNameIndex is incorrect, behave as normal
|
|
19
|
+
if (!shapeName) {
|
|
20
|
+
throw new Error(`Could not find a ShapeName at index '${shapeNameIndex}'`);
|
|
21
|
+
}
|
|
22
|
+
const prefix = strings.slice(0, Math.max(shapeNameIndex, 0));
|
|
23
|
+
const suffix = strings.slice(shapeNameIndex + 1);
|
|
24
|
+
let arr = [];
|
|
25
|
+
if (prefix) {
|
|
26
|
+
arr = [...arr, pascalCase(prefix)];
|
|
27
|
+
}
|
|
28
|
+
if (shapeName.length > 2 && shapeName.startsWith('TS') && shapeName.charAt(2) === shapeName.charAt(2).toUpperCase()) {
|
|
29
|
+
// Built-in shape, prefixed with `TS`
|
|
30
|
+
arr = [...arr, shapeName];
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
arr = [...arr, pascalCase(shapeName)];
|
|
34
|
+
}
|
|
35
|
+
if (suffix) {
|
|
36
|
+
arr = [...arr, pascalCase(suffix)];
|
|
37
|
+
}
|
|
38
|
+
return arr.join('');
|
|
39
|
+
}
|
|
40
|
+
exports.formatShapeName = formatShapeName;
|
|
41
|
+
/**
|
|
42
|
+
* Optional config triggers a namespace-preserving behavior for built-in shapes starting with `TS`.
|
|
43
|
+
*/
|
|
44
|
+
function pascalCase(str) {
|
|
45
|
+
return (0, upperFirst_js_1.default)((0, exports.camelCase)(str));
|
|
46
|
+
}
|
|
47
|
+
exports.pascalCase = pascalCase;
|
|
48
|
+
function isUuid(str) {
|
|
49
|
+
return Boolean(/\w{8,}(-\w{4,}){3,}-\w{12,}/.exec(str));
|
|
50
|
+
}
|
|
51
|
+
exports.isUuid = isUuid;
|
|
52
|
+
function isEmptyString(str) {
|
|
53
|
+
return (0, isString_js_1.default)(str) && (0, isEmpty_js_1.default)(str);
|
|
54
|
+
}
|
|
55
|
+
exports.isEmptyString = isEmptyString;
|
|
56
|
+
function isIntegerLike(value) {
|
|
57
|
+
if (typeof value === 'number') {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return /^\d+$/.test(value);
|
|
61
|
+
}
|
|
62
|
+
exports.isIntegerLike = isIntegerLike;
|
|
63
|
+
function encodePropertyName(value) {
|
|
64
|
+
return value.replace(/[^A-Za-z0-9]/g, (c) => `%${c.charCodeAt(0).toString(16)}`);
|
|
65
|
+
}
|
|
66
|
+
exports.encodePropertyName = encodePropertyName;
|
|
67
|
+
function base64Encode(str) {
|
|
68
|
+
return browser_or_node_1.isBrowser ? window.btoa(str) : Buffer.from(str).toString('base64');
|
|
69
|
+
}
|
|
70
|
+
exports.base64Encode = base64Encode;
|
|
71
|
+
function base64Decode(str) {
|
|
72
|
+
return browser_or_node_1.isBrowser ? window.atob(str) : Buffer.from(str, 'base64').toString();
|
|
73
|
+
}
|
|
74
|
+
exports.base64Decode = base64Decode;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
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;
|
|
7
|
+
const routing_1 = require("@takeshape/routing");
|
|
8
|
+
/*
|
|
9
|
+
* The intention is to move all this to the client package in the end, but right now it's here
|
|
10
|
+
* to be shared between the draftjs / mdx implementations, which span the client / server differently.
|
|
11
|
+
*/
|
|
12
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
13
|
+
const escape_js_1 = __importDefault(require("lodash/escape.js"));
|
|
14
|
+
const highlight_code_js_1 = require("./highlight-code.js");
|
|
15
|
+
const types_js_1 = require("./types.js");
|
|
16
|
+
function getApplyPrefix(prefix) {
|
|
17
|
+
return (className) => (className ? prefix + className : '');
|
|
18
|
+
}
|
|
19
|
+
exports.getApplyPrefix = getApplyPrefix;
|
|
20
|
+
function attrs(obj) {
|
|
21
|
+
const attrStrings = [];
|
|
22
|
+
const attrNames = Object.keys(obj);
|
|
23
|
+
attrNames.sort();
|
|
24
|
+
for (const attrName of attrNames) {
|
|
25
|
+
const value = obj[attrName];
|
|
26
|
+
if (value) {
|
|
27
|
+
attrStrings.push(`${attrName}="${(0, escape_js_1.default)(value)}"`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return attrStrings.length ? ` ${attrStrings.join(' ')}` : '';
|
|
31
|
+
}
|
|
32
|
+
exports.attrs = attrs;
|
|
33
|
+
function imageTemplate(applyPrefix, data) {
|
|
34
|
+
const { caption, credit, alignment, size, asset, imageParams } = data;
|
|
35
|
+
if (!asset) {
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
const imageUrl = (0, routing_1.getImageUrl)(asset.path, imageParams);
|
|
39
|
+
let figCaption = '';
|
|
40
|
+
if (caption || credit) {
|
|
41
|
+
const htmlCaption = caption ? `<span class="${applyPrefix('caption')}">${caption}</span>` : '';
|
|
42
|
+
const htmlCredit = credit ? `<span class="${applyPrefix('credit')}">${credit}</span>` : '';
|
|
43
|
+
figCaption = `<figcaption>${htmlCaption} ${htmlCredit}</figcaption>`;
|
|
44
|
+
}
|
|
45
|
+
const classes = (0, classnames_1.default)(applyPrefix(alignment), applyPrefix(size));
|
|
46
|
+
const classAttr = classes ? ` class="${classes}"` : '';
|
|
47
|
+
const imgAttrs = attrs({
|
|
48
|
+
alt: asset.description,
|
|
49
|
+
title: asset.title
|
|
50
|
+
});
|
|
51
|
+
let image = `<img${imgAttrs} src="${imageUrl}"/>`;
|
|
52
|
+
if (data.link?.url) {
|
|
53
|
+
const target = data.link.external ? ' target="blank" rel="noopener noreferrer"' : '';
|
|
54
|
+
image = `<a href="${data.link.url}"${target}>${image}</a>`;
|
|
55
|
+
}
|
|
56
|
+
return `<figure${classAttr}>${image}${figCaption}</figure>`;
|
|
57
|
+
}
|
|
58
|
+
exports.imageTemplate = imageTemplate;
|
|
59
|
+
function renderMdx(tag, attributes, data, children) {
|
|
60
|
+
const tagWithAttributes = `${tag} ${attributes.map((attr) => `${attr}="${(0, escape_js_1.default)(data[attr])}"`).join(' ')}`;
|
|
61
|
+
if (children) {
|
|
62
|
+
return `<${tagWithAttributes}>
|
|
63
|
+
${children.replace(/[\n\r]+$/, '')}
|
|
64
|
+
</${tag}>`;
|
|
65
|
+
}
|
|
66
|
+
return `<${tagWithAttributes}/>`;
|
|
67
|
+
}
|
|
68
|
+
function imageTemplateMdx(applyPrefix, data) {
|
|
69
|
+
return renderMdx(applyPrefix('Image'), ['id', 'caption', 'credit', 'link', 'linkisexternal', 'alignment', 'size', 'src'], data);
|
|
70
|
+
}
|
|
71
|
+
exports.imageTemplateMdx = imageTemplateMdx;
|
|
72
|
+
function oembedTemplate(applyPrefix, data) {
|
|
73
|
+
return `<div class="${applyPrefix('oembed')}">${data.html}</div>`;
|
|
74
|
+
}
|
|
75
|
+
exports.oembedTemplate = oembedTemplate;
|
|
76
|
+
function oembedTemplateMdx(applyPrefix, data) {
|
|
77
|
+
return renderMdx(applyPrefix('Oembed'), ['url', 'author_name', 'author_url', 'width', 'height', 'type', 'cache_age', 'provider_name', 'version'], data, data.html);
|
|
78
|
+
}
|
|
79
|
+
exports.oembedTemplateMdx = oembedTemplateMdx;
|
|
80
|
+
function codeTemplate(applyPrefix, data) {
|
|
81
|
+
const { text, lang } = data;
|
|
82
|
+
const code = (0, highlight_code_js_1.highlightCode)(text, lang);
|
|
83
|
+
const langClass = lang ? ` class="${applyPrefix(`language-${lang}`)}"` : '';
|
|
84
|
+
return `<pre><code${langClass}>${code}</code></pre>`;
|
|
85
|
+
}
|
|
86
|
+
exports.codeTemplate = codeTemplate;
|
|
87
|
+
function jsonTemplate(template, context) {
|
|
88
|
+
const renderTemplate = (template) => {
|
|
89
|
+
return template.replace(/{{(\w+)}}/g, (_, name) => context[name] ?? '');
|
|
90
|
+
};
|
|
91
|
+
const transform = (obj) => {
|
|
92
|
+
if (Array.isArray(obj)) {
|
|
93
|
+
return obj.map(transform);
|
|
94
|
+
}
|
|
95
|
+
if ((0, types_js_1.isRecord)(obj)) {
|
|
96
|
+
const result = {};
|
|
97
|
+
for (const key of Object.keys(obj)) {
|
|
98
|
+
result[renderTemplate(key)] = transform(obj[key]);
|
|
99
|
+
}
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
if (typeof obj === 'string') {
|
|
103
|
+
return renderTemplate(obj);
|
|
104
|
+
}
|
|
105
|
+
return obj;
|
|
106
|
+
};
|
|
107
|
+
return transform(template);
|
|
108
|
+
}
|
|
109
|
+
exports.jsonTemplate = jsonTemplate;
|