@frontmcp/uipack 1.10.8 → 1.10.9-rc.2

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/utils/index.js CHANGED
@@ -1,96 +1 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // libs/uipack/src/utils/index.ts
21
- var utils_exports = {};
22
- __export(utils_exports, {
23
- escapeHtml: () => escapeHtml,
24
- escapeHtmlAttr: () => escapeHtmlAttr,
25
- escapeJsString: () => escapeJsString,
26
- escapeScriptClose: () => escapeScriptClose,
27
- safeJsonForScript: () => safeJsonForScript,
28
- safeStringify: () => safeStringify
29
- });
30
- module.exports = __toCommonJS(utils_exports);
31
- function safeStringify(value, space) {
32
- const seen = /* @__PURE__ */ new WeakSet();
33
- try {
34
- return JSON.stringify(
35
- value,
36
- (_key, val) => {
37
- if (typeof val === "object" && val !== null) {
38
- if (seen.has(val)) return "[Circular]";
39
- seen.add(val);
40
- }
41
- return val;
42
- },
43
- space
44
- );
45
- } catch {
46
- return JSON.stringify({ error: "Output could not be serialized" });
47
- }
48
- }
49
- function escapeHtml(str) {
50
- if (str === null || str === void 0) {
51
- return "";
52
- }
53
- const s = String(str);
54
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
55
- }
56
- function escapeHtmlAttr(str) {
57
- return str.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
58
- }
59
- function escapeJsString(str) {
60
- return str.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
61
- }
62
- function escapeScriptClose(jsonString) {
63
- return jsonString.replace(/<\//g, "<\\/");
64
- }
65
- var SCRIPT_UNSAFE_CHARACTERS = /[<>&\u2028\u2029]/g;
66
- function toUnicodeEscape(character) {
67
- return `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`;
68
- }
69
- function safeJsonForScript(value) {
70
- if (value === void 0) {
71
- return "null";
72
- }
73
- try {
74
- const jsonString = JSON.stringify(value, (_key, val) => {
75
- if (typeof val === "bigint") {
76
- return val.toString();
77
- }
78
- return val;
79
- });
80
- if (jsonString === void 0) {
81
- return "null";
82
- }
83
- return jsonString.replace(SCRIPT_UNSAFE_CHARACTERS, toUnicodeEscape);
84
- } catch {
85
- return '{"error":"Value could not be serialized"}';
86
- }
87
- }
88
- // Annotate the CommonJS export names for ESM import in node:
89
- 0 && (module.exports = {
90
- escapeHtml,
91
- escapeHtmlAttr,
92
- escapeJsString,
93
- escapeScriptClose,
94
- safeJsonForScript,
95
- safeStringify
96
- });
1
+ "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var utils_exports={};__export(utils_exports,{escapeHtml:()=>escapeHtml,escapeHtmlAttr:()=>escapeHtmlAttr,escapeJsString:()=>escapeJsString,escapeScriptClose:()=>escapeScriptClose,safeJsonForScript:()=>safeJsonForScript,safeStringify:()=>safeStringify});module.exports=__toCommonJS(utils_exports);function safeStringify(value,space){const seen=new WeakSet;try{return JSON.stringify(value,(_key,val)=>{if(typeof val==="object"&&val!==null){if(seen.has(val))return"[Circular]";seen.add(val)}return val},space)}catch{return JSON.stringify({error:"Output could not be serialized"})}}function escapeHtml(str){if(str===null||str===void 0){return""}const s=String(str);return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function escapeHtmlAttr(str){return str.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function escapeJsString(str){return str.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function escapeScriptClose(jsonString){return jsonString.replace(/<\//g,"<\\/")}var SCRIPT_UNSAFE_CHARACTERS=/[<>&\u2028\u2029]/g;function toUnicodeEscape(character){return`\\u${character.charCodeAt(0).toString(16).padStart(4,"0")}`}function safeJsonForScript(value){if(value===void 0){return"null"}try{const jsonString=JSON.stringify(value,(_key,val)=>{if(typeof val==="bigint"){return val.toString()}return val});if(jsonString===void 0){return"null"}return jsonString.replace(SCRIPT_UNSAFE_CHARACTERS,toUnicodeEscape)}catch{return'{"error":"Value could not be serialized"}'}}0&&(module.exports={escapeHtml,escapeHtmlAttr,escapeJsString,escapeScriptClose,safeJsonForScript,safeStringify});