@agentmark-ai/shared-utils 0.5.0 → 0.5.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/index.js +5 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -136,53 +136,24 @@ function hexToBytes(hex) {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
// src/serialize.ts
|
|
139
|
+
var import_js_yaml = __toESM(require("js-yaml"));
|
|
139
140
|
function toFrontMatter(content) {
|
|
140
|
-
|
|
141
|
-
let frontMatter = "";
|
|
142
|
-
const indentation = " ".repeat(indent);
|
|
143
|
-
for (const key in json) {
|
|
144
|
-
if (Object.prototype.hasOwnProperty.call(json, key)) {
|
|
145
|
-
const value = json[key];
|
|
146
|
-
if (typeof value === "object" && !Array.isArray(value)) {
|
|
147
|
-
frontMatter += `${indentation}${key}:
|
|
148
|
-
`;
|
|
149
|
-
frontMatter += jsonToFrontMatter(value, indent + 1);
|
|
150
|
-
} else if (Array.isArray(value)) {
|
|
151
|
-
frontMatter += `${indentation}${key}:
|
|
152
|
-
`;
|
|
153
|
-
value.forEach((item) => {
|
|
154
|
-
if (typeof item === "object") {
|
|
155
|
-
frontMatter += `${indentation}-
|
|
156
|
-
`;
|
|
157
|
-
frontMatter += jsonToFrontMatter(item, indent + 2);
|
|
158
|
-
} else {
|
|
159
|
-
frontMatter += `${indentation}- ${item}
|
|
160
|
-
`;
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
} else {
|
|
164
|
-
frontMatter += `${indentation}${key}: ${value}
|
|
165
|
-
`;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return frontMatter;
|
|
170
|
-
}
|
|
141
|
+
const body = Object.keys(content).length === 0 ? "" : import_js_yaml.default.dump(content, { lineWidth: -1, noRefs: true, skipInvalid: true });
|
|
171
142
|
return `---
|
|
172
|
-
${
|
|
143
|
+
${body}---
|
|
173
144
|
`;
|
|
174
145
|
}
|
|
175
146
|
|
|
176
147
|
// src/generate-types.ts
|
|
177
148
|
var fs = __toESM(require("fs-extra"));
|
|
178
149
|
var import_path = __toESM(require("path"));
|
|
179
|
-
var
|
|
150
|
+
var import_js_yaml2 = __toESM(require("js-yaml"));
|
|
180
151
|
function extractFrontmatter(content) {
|
|
181
152
|
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
182
153
|
if (!match) {
|
|
183
154
|
return { attributes: {} };
|
|
184
155
|
}
|
|
185
|
-
const attributes =
|
|
156
|
+
const attributes = import_js_yaml2.default.load(match[1]);
|
|
186
157
|
return { attributes: attributes || {} };
|
|
187
158
|
}
|
|
188
159
|
var _compile = null;
|