@zero-library/common 2.1.8 → 2.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +21 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.esm.js +20 -3
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -223,7 +223,7 @@ function extractAlertPlaceholders(src) {
|
|
|
223
223
|
out += src.slice(pos, start);
|
|
224
224
|
const afterStart = src.slice(start);
|
|
225
225
|
const relAfter = afterStart.slice(":::alert".length);
|
|
226
|
-
const matchLineEnd = relAfter.search(/\
|
|
226
|
+
const matchLineEnd = relAfter.search(/\s*:::\s*/);
|
|
227
227
|
let endIdx = -1;
|
|
228
228
|
if (matchLineEnd !== -1) {
|
|
229
229
|
endIdx = start + ":::alert".length + matchLineEnd + 1;
|
|
@@ -283,7 +283,7 @@ var RenderMarkdown_default = ({ content = "", searchValue, customComponents, onC
|
|
|
283
283
|
let incomplete = false;
|
|
284
284
|
if (openCount > closeCount) {
|
|
285
285
|
incomplete = true;
|
|
286
|
-
fixedContent += ":::";
|
|
286
|
+
fixedContent += " :::";
|
|
287
287
|
}
|
|
288
288
|
const { text: preprocessed, placeholders } = extractAlertPlaceholders(fixedContent);
|
|
289
289
|
let rawHtml = md.render(preprocessed);
|
|
@@ -741,6 +741,23 @@ var getWebSocketUrl = (path, customHost) => {
|
|
|
741
741
|
const host = customHost || window.location.host;
|
|
742
742
|
return `${protocol}//${host}${path}`;
|
|
743
743
|
};
|
|
744
|
+
function transform(source, fieldMap) {
|
|
745
|
+
const result = {};
|
|
746
|
+
for (const [targetKey, mapping] of Object.entries(fieldMap)) {
|
|
747
|
+
const key = targetKey;
|
|
748
|
+
if (typeof mapping === "function") {
|
|
749
|
+
result[key] = mapping(source);
|
|
750
|
+
} else if (typeof mapping === "string" && source && mapping in source) {
|
|
751
|
+
result[key] = source[mapping];
|
|
752
|
+
} else {
|
|
753
|
+
result[key] = mapping;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
return result;
|
|
757
|
+
}
|
|
758
|
+
function transforms(sources, fieldMap) {
|
|
759
|
+
return sources?.map((source) => transform(source, fieldMap)) || [];
|
|
760
|
+
}
|
|
744
761
|
|
|
745
762
|
// src/hooks/useDeepEffect.ts
|
|
746
763
|
function useDeepEffect(effect, deps) {
|
|
@@ -5354,6 +5371,8 @@ exports.textAreaView = textAreaView;
|
|
|
5354
5371
|
exports.themeConfig = themeConfig;
|
|
5355
5372
|
exports.times = times;
|
|
5356
5373
|
exports.toFixed = toFixed;
|
|
5374
|
+
exports.transform = transform;
|
|
5375
|
+
exports.transforms = transforms;
|
|
5357
5376
|
exports.useCreateValtioContext = useCreateValtioContext;
|
|
5358
5377
|
exports.useDebounce = useDebounce;
|
|
5359
5378
|
exports.useDeepEffect = useDeepEffect;
|