superbee 0.4.4-pre.13 → 0.4.4-pre.14
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/publication/bridge-host-kind.d.ts +2 -0
- package/dist/publication/bridge.d.ts +1 -1
- package/dist/publication-bridge.mjs +278 -82
- package/dist/publication.mjs +278 -82
- package/dist/superbee.mjs +389 -129
- package/package.json +1 -1
package/dist/publication.mjs
CHANGED
|
@@ -63,8 +63,8 @@ var require_common = __commonJS({
|
|
|
63
63
|
return target;
|
|
64
64
|
}
|
|
65
65
|
function repeat(string3, count) {
|
|
66
|
-
var result = "",
|
|
67
|
-
for (
|
|
66
|
+
var result = "", cycle2;
|
|
67
|
+
for (cycle2 = 0; cycle2 < count; cycle2 += 1) {
|
|
68
68
|
result += string3;
|
|
69
69
|
}
|
|
70
70
|
return result;
|
|
@@ -30835,6 +30835,14 @@ var InvalidInputError = class extends Error {
|
|
|
30835
30835
|
this.name = "InvalidInputError";
|
|
30836
30836
|
}
|
|
30837
30837
|
};
|
|
30838
|
+
var FrontmatterRefusedError = class extends InvalidInputError {
|
|
30839
|
+
code;
|
|
30840
|
+
constructor(code2, detail) {
|
|
30841
|
+
super(`frontmatter cannot be stored: ${detail}`);
|
|
30842
|
+
this.name = "FrontmatterRefusedError";
|
|
30843
|
+
this.code = code2;
|
|
30844
|
+
}
|
|
30845
|
+
};
|
|
30838
30846
|
var FilesystemIdentityAliasError = class extends InvalidInputError {
|
|
30839
30847
|
rel;
|
|
30840
30848
|
segment;
|
|
@@ -30859,12 +30867,21 @@ var ConcurrentReplacementError = class extends Error {
|
|
|
30859
30867
|
}
|
|
30860
30868
|
};
|
|
30861
30869
|
|
|
30862
|
-
// ../core/src/
|
|
30870
|
+
// ../core/src/bounded-yaml.ts
|
|
30863
30871
|
var import_js_yaml = __toESM(require_js_yaml2(), 1);
|
|
30864
30872
|
|
|
30865
30873
|
// ../core/src/frontmatter-contract.ts
|
|
30874
|
+
var FrontmatterLimitError = class extends Error {
|
|
30875
|
+
name = "FrontmatterLimitError";
|
|
30876
|
+
code;
|
|
30877
|
+
constructor(code2, message) {
|
|
30878
|
+
super(message);
|
|
30879
|
+
this.code = code2;
|
|
30880
|
+
}
|
|
30881
|
+
};
|
|
30866
30882
|
var MalformedDocumentError = class extends Error {
|
|
30867
30883
|
name = "MalformedDocumentError";
|
|
30884
|
+
code;
|
|
30868
30885
|
context;
|
|
30869
30886
|
detail;
|
|
30870
30887
|
constructor(context, cause) {
|
|
@@ -30872,12 +30889,165 @@ var MalformedDocumentError = class extends Error {
|
|
|
30872
30889
|
super(
|
|
30873
30890
|
`malformed frontmatter${context ? ` in '${context}'` : ""}: ${detail} \u2014 fix the YAML or remove the file`
|
|
30874
30891
|
);
|
|
30892
|
+
this.code = cause instanceof FrontmatterLimitError ? cause.code : "FRONTMATTER_MALFORMED";
|
|
30875
30893
|
if (context !== void 0) this.context = context;
|
|
30876
30894
|
this.detail = detail;
|
|
30877
30895
|
if (cause !== void 0) this.cause = cause;
|
|
30878
30896
|
}
|
|
30879
30897
|
};
|
|
30880
30898
|
|
|
30899
|
+
// ../core/src/bounded-yaml.ts
|
|
30900
|
+
var FRONTMATTER_LIMITS = Object.freeze({
|
|
30901
|
+
sourceChars: 256 * 1024,
|
|
30902
|
+
depth: 32,
|
|
30903
|
+
aliases: 1e3,
|
|
30904
|
+
expandedNodes: 1e5,
|
|
30905
|
+
expandedChars: 1024 * 1024
|
|
30906
|
+
});
|
|
30907
|
+
var PARSE_NESTING_GUARD = FRONTMATTER_LIMITS.depth * 4;
|
|
30908
|
+
function tooDeep() {
|
|
30909
|
+
return new FrontmatterLimitError("FRONTMATTER_TOO_DEEP", `YAML nesting is deeper than ${FRONTMATTER_LIMITS.depth} levels`);
|
|
30910
|
+
}
|
|
30911
|
+
function tooLarge() {
|
|
30912
|
+
return new FrontmatterLimitError(
|
|
30913
|
+
"FRONTMATTER_ALIAS_LIMIT",
|
|
30914
|
+
`YAML aliases expand to more than ${FRONTMATTER_LIMITS.expandedNodes} nodes or ${FRONTMATTER_LIMITS.expandedChars} characters`
|
|
30915
|
+
);
|
|
30916
|
+
}
|
|
30917
|
+
function cycle() {
|
|
30918
|
+
return new FrontmatterLimitError("FRONTMATTER_CYCLE", "YAML aliases form a cycle");
|
|
30919
|
+
}
|
|
30920
|
+
function scalarExtent(value) {
|
|
30921
|
+
const chars = typeof value === "string" ? value.length : ArrayBuffer.isView(value) ? value.byteLength : 0;
|
|
30922
|
+
return { nodes: 1, chars, depth: 0 };
|
|
30923
|
+
}
|
|
30924
|
+
function isCollection(value) {
|
|
30925
|
+
if (Array.isArray(value)) return true;
|
|
30926
|
+
if (value === null || typeof value !== "object") return false;
|
|
30927
|
+
const prototype = Object.getPrototypeOf(value);
|
|
30928
|
+
return prototype === Object.prototype || prototype === null;
|
|
30929
|
+
}
|
|
30930
|
+
var ExtentMeter = class {
|
|
30931
|
+
known = /* @__PURE__ */ new Map();
|
|
30932
|
+
path = /* @__PURE__ */ new Set();
|
|
30933
|
+
unfinished;
|
|
30934
|
+
constructor(unfinished = /* @__PURE__ */ new Set()) {
|
|
30935
|
+
this.unfinished = unfinished;
|
|
30936
|
+
}
|
|
30937
|
+
measure(value) {
|
|
30938
|
+
if (!isCollection(value)) return scalarExtent(value);
|
|
30939
|
+
const known = this.known.get(value);
|
|
30940
|
+
if (known !== void 0) return known;
|
|
30941
|
+
if (this.path.has(value) || this.unfinished.has(value)) throw cycle();
|
|
30942
|
+
return this.walk(value);
|
|
30943
|
+
}
|
|
30944
|
+
walk(value) {
|
|
30945
|
+
if (this.path.size >= FRONTMATTER_LIMITS.depth) throw tooDeep();
|
|
30946
|
+
this.path.add(value);
|
|
30947
|
+
const keyed = !Array.isArray(value);
|
|
30948
|
+
const extent = { nodes: 1, chars: 0, depth: 1 };
|
|
30949
|
+
for (const [key, child] of Object.entries(value)) {
|
|
30950
|
+
const inner = this.measure(child);
|
|
30951
|
+
extent.nodes += inner.nodes;
|
|
30952
|
+
extent.chars += inner.chars + (keyed ? key.length : 0);
|
|
30953
|
+
extent.depth = Math.max(extent.depth, inner.depth + 1);
|
|
30954
|
+
if (extent.nodes > FRONTMATTER_LIMITS.expandedNodes || extent.chars > FRONTMATTER_LIMITS.expandedChars) throw tooLarge();
|
|
30955
|
+
if (extent.depth > FRONTMATTER_LIMITS.depth) throw tooDeep();
|
|
30956
|
+
}
|
|
30957
|
+
this.path.delete(value);
|
|
30958
|
+
this.known.set(value, extent);
|
|
30959
|
+
return extent;
|
|
30960
|
+
}
|
|
30961
|
+
};
|
|
30962
|
+
var AliasBudget = class {
|
|
30963
|
+
unfinished = /* @__PURE__ */ new Set();
|
|
30964
|
+
finished = /* @__PURE__ */ new Set();
|
|
30965
|
+
meter = new ExtentMeter(this.unfinished);
|
|
30966
|
+
aliases = 0;
|
|
30967
|
+
nodes = 0;
|
|
30968
|
+
chars = 0;
|
|
30969
|
+
/** Wrap the parser's anchor table; the parser reads it only to resolve an alias. */
|
|
30970
|
+
watch(state) {
|
|
30971
|
+
state.anchorMap = new Proxy(state.anchorMap, {
|
|
30972
|
+
get: (target, name, receiver) => {
|
|
30973
|
+
const value = Reflect.get(target, name, receiver);
|
|
30974
|
+
if (typeof name === "string") this.charge(name, value);
|
|
30975
|
+
return value;
|
|
30976
|
+
},
|
|
30977
|
+
set: (target, name, value, receiver) => {
|
|
30978
|
+
if (typeof name === "string") {
|
|
30979
|
+
this.finished.delete(name);
|
|
30980
|
+
if (isCollection(value)) this.unfinished.add(value);
|
|
30981
|
+
}
|
|
30982
|
+
return Reflect.set(target, name, value, receiver);
|
|
30983
|
+
}
|
|
30984
|
+
});
|
|
30985
|
+
}
|
|
30986
|
+
/** Called when an anchored node closes: its anchor now names a complete value. */
|
|
30987
|
+
close(anchor, value) {
|
|
30988
|
+
this.finished.add(anchor);
|
|
30989
|
+
if (isCollection(value)) this.unfinished.delete(value);
|
|
30990
|
+
}
|
|
30991
|
+
charge(name, value) {
|
|
30992
|
+
this.aliases += 1;
|
|
30993
|
+
if (this.aliases > FRONTMATTER_LIMITS.aliases) {
|
|
30994
|
+
throw new FrontmatterLimitError(
|
|
30995
|
+
"FRONTMATTER_ALIAS_LIMIT",
|
|
30996
|
+
`YAML aliases are used more than ${FRONTMATTER_LIMITS.aliases} times`
|
|
30997
|
+
);
|
|
30998
|
+
}
|
|
30999
|
+
if (!this.finished.has(name) && isCollection(value)) throw cycle();
|
|
31000
|
+
const extent = this.meter.measure(value);
|
|
31001
|
+
this.nodes += extent.nodes;
|
|
31002
|
+
this.chars += extent.chars;
|
|
31003
|
+
if (this.nodes > FRONTMATTER_LIMITS.expandedNodes || this.chars > FRONTMATTER_LIMITS.expandedChars) throw tooLarge();
|
|
31004
|
+
}
|
|
31005
|
+
};
|
|
31006
|
+
var MERGE_KEY_LIMIT_REASON = "merge keys exceeded maxTotalMergeKeys";
|
|
31007
|
+
function loadBoundedYaml(source, options = {}) {
|
|
31008
|
+
if (source.length > FRONTMATTER_LIMITS.sourceChars) {
|
|
31009
|
+
throw new FrontmatterLimitError(
|
|
31010
|
+
"FRONTMATTER_TOO_LARGE",
|
|
31011
|
+
`YAML source is longer than ${FRONTMATTER_LIMITS.sourceChars} characters`
|
|
31012
|
+
);
|
|
31013
|
+
}
|
|
31014
|
+
const schema = options.schema === "json" ? import_js_yaml.default.JSON_SCHEMA : options.schema;
|
|
31015
|
+
const budget = new AliasBudget();
|
|
31016
|
+
let watched;
|
|
31017
|
+
let nesting = 0;
|
|
31018
|
+
let value;
|
|
31019
|
+
try {
|
|
31020
|
+
value = import_js_yaml.default.safeLoad(source, {
|
|
31021
|
+
...schema ? { schema } : {},
|
|
31022
|
+
listener(event, rawState) {
|
|
31023
|
+
const state = rawState;
|
|
31024
|
+
if (state.anchorMap !== watched) {
|
|
31025
|
+
budget.watch(state);
|
|
31026
|
+
watched = state.anchorMap;
|
|
31027
|
+
}
|
|
31028
|
+
if (event === "open") {
|
|
31029
|
+
nesting += 1;
|
|
31030
|
+
if (nesting > PARSE_NESTING_GUARD) throw tooDeep();
|
|
31031
|
+
} else {
|
|
31032
|
+
nesting -= 1;
|
|
31033
|
+
if (state.anchor !== null) budget.close(state.anchor, state.result);
|
|
31034
|
+
}
|
|
31035
|
+
}
|
|
31036
|
+
});
|
|
31037
|
+
} catch (error) {
|
|
31038
|
+
const reason = error.reason;
|
|
31039
|
+
if (typeof reason === "string" && reason.startsWith(MERGE_KEY_LIMIT_REASON)) {
|
|
31040
|
+
throw new FrontmatterLimitError("FRONTMATTER_ALIAS_LIMIT", reason);
|
|
31041
|
+
}
|
|
31042
|
+
throw error;
|
|
31043
|
+
}
|
|
31044
|
+
new ExtentMeter().measure(value);
|
|
31045
|
+
return value;
|
|
31046
|
+
}
|
|
31047
|
+
|
|
31048
|
+
// ../core/src/frontmatter.ts
|
|
31049
|
+
var import_js_yaml2 = __toESM(require_js_yaml2(), 1);
|
|
31050
|
+
|
|
30881
31051
|
// ../core/src/frontmatter-splitter.ts
|
|
30882
31052
|
function delimiterLineEnd(input, offset) {
|
|
30883
31053
|
if (!input.startsWith("---", offset)) return null;
|
|
@@ -30907,12 +31077,96 @@ function splitLeadingFrontmatter(raw, context) {
|
|
|
30907
31077
|
throw new MalformedDocumentError(context, new Error("unterminated YAML frontmatter delimiter"));
|
|
30908
31078
|
}
|
|
30909
31079
|
|
|
31080
|
+
// ../core/src/frontmatter.ts
|
|
31081
|
+
var YAML_TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp";
|
|
31082
|
+
function requireYamlTimestampType() {
|
|
31083
|
+
const type = import_js_yaml2.default.DEFAULT_SAFE_SCHEMA.implicit.find(
|
|
31084
|
+
(candidate) => candidate.tag === YAML_TIMESTAMP_TAG
|
|
31085
|
+
);
|
|
31086
|
+
if (!type) throw new Error("js-yaml safe schema is missing its timestamp type");
|
|
31087
|
+
return type;
|
|
31088
|
+
}
|
|
31089
|
+
var yamlTimestampType = requireYamlTimestampType();
|
|
31090
|
+
var stringTimestampType = new import_js_yaml2.default.Type(YAML_TIMESTAMP_TAG, {
|
|
31091
|
+
kind: "scalar",
|
|
31092
|
+
resolve: (value) => yamlTimestampType.resolve(value),
|
|
31093
|
+
construct: (value) => value
|
|
31094
|
+
});
|
|
31095
|
+
var losslessDateSchema = new import_js_yaml2.default.Schema({
|
|
31096
|
+
include: [import_js_yaml2.default.DEFAULT_SAFE_SCHEMA],
|
|
31097
|
+
implicit: [stringTimestampType]
|
|
31098
|
+
});
|
|
31099
|
+
var yamlEngine = {
|
|
31100
|
+
parse(input) {
|
|
31101
|
+
return loadBoundedYaml(input, { schema: losslessDateSchema }) ?? {};
|
|
31102
|
+
}
|
|
31103
|
+
};
|
|
31104
|
+
function normalizeFrontmatter(data, options) {
|
|
31105
|
+
const out = { ...data };
|
|
31106
|
+
if (options.preserveTimestamp || options.okfVersion === "0.2") return out;
|
|
31107
|
+
const value = out.timestamp;
|
|
31108
|
+
if (value instanceof Date) {
|
|
31109
|
+
out.timestamp = value.toISOString();
|
|
31110
|
+
} else if (typeof value === "number" && Number.isFinite(value)) {
|
|
31111
|
+
out.timestamp = new Date(value).toISOString();
|
|
31112
|
+
} else if (typeof value === "string" && yamlTimestampType.resolve(value)) {
|
|
31113
|
+
const parsed = yamlTimestampType.construct(value);
|
|
31114
|
+
if (parsed instanceof Date) out.timestamp = parsed.toISOString();
|
|
31115
|
+
}
|
|
31116
|
+
return out;
|
|
31117
|
+
}
|
|
31118
|
+
function parseMarkdown(raw, context, options = {}) {
|
|
31119
|
+
const split = splitLeadingFrontmatter(raw, context);
|
|
31120
|
+
if (!("yamlSource" in split)) return { frontmatter: {}, body: split.body };
|
|
31121
|
+
return { frontmatter: parseFrontmatter(split.yamlSource, context, options), body: split.body };
|
|
31122
|
+
}
|
|
31123
|
+
function parseFrontmatter(source, context, options = {}) {
|
|
31124
|
+
let parsed;
|
|
31125
|
+
try {
|
|
31126
|
+
parsed = yamlEngine.parse(source);
|
|
31127
|
+
} catch (err) {
|
|
31128
|
+
throw new MalformedDocumentError(context, err);
|
|
31129
|
+
}
|
|
31130
|
+
return normalizeFrontmatter(parsed, options);
|
|
31131
|
+
}
|
|
31132
|
+
function stringifyFrontmatter(data) {
|
|
31133
|
+
const dumped = import_js_yaml2.default.safeDump(data).trim();
|
|
31134
|
+
try {
|
|
31135
|
+
yamlEngine.parse(`${dumped}
|
|
31136
|
+
`);
|
|
31137
|
+
} catch (error) {
|
|
31138
|
+
if (error instanceof FrontmatterLimitError) throw new FrontmatterRefusedError(error.code, error.message);
|
|
31139
|
+
const detail = (error instanceof Error ? error.message : String(error)).split("\n")[0] ?? "";
|
|
31140
|
+
throw new FrontmatterRefusedError("FRONTMATTER_MALFORMED", detail);
|
|
31141
|
+
}
|
|
31142
|
+
return dumped;
|
|
31143
|
+
}
|
|
31144
|
+
function normalizeDocumentBodyForStorage(body) {
|
|
31145
|
+
return body.endsWith("\n") ? body : `${body}
|
|
31146
|
+
`;
|
|
31147
|
+
}
|
|
31148
|
+
function stringifyWithData(data, body) {
|
|
31149
|
+
return stringifyWithSerializedFrontmatter(stringifyFrontmatter(data), body);
|
|
31150
|
+
}
|
|
31151
|
+
function stringifyWithSerializedFrontmatter(dumped, body) {
|
|
31152
|
+
const content3 = body ?? "";
|
|
31153
|
+
const newline = (value) => value.endsWith("\n") ? value : `${value}
|
|
31154
|
+
`;
|
|
31155
|
+
if (dumped === "{}") return normalizeDocumentBodyForStorage(content3);
|
|
31156
|
+
return `---
|
|
31157
|
+
${newline(dumped)}---
|
|
31158
|
+
${normalizeDocumentBodyForStorage(content3)}`;
|
|
31159
|
+
}
|
|
31160
|
+
function stringifyDoc(frontmatter2, body) {
|
|
31161
|
+
return stringifyWithData(frontmatter2, body);
|
|
31162
|
+
}
|
|
31163
|
+
|
|
30910
31164
|
// ../core/src/portable-frontmatter.ts
|
|
30911
31165
|
function parseLeadingFrontmatter(raw, context) {
|
|
30912
31166
|
const split = splitLeadingFrontmatter(raw, context);
|
|
30913
31167
|
if (!("yamlSource" in split)) return {};
|
|
30914
31168
|
try {
|
|
30915
|
-
const parsed =
|
|
31169
|
+
const parsed = loadBoundedYaml(split.yamlSource);
|
|
30916
31170
|
if (parsed === void 0 || parsed === null) return {};
|
|
30917
31171
|
if (typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
30918
31172
|
throw new TypeError("YAML frontmatter must be a mapping");
|
|
@@ -30923,6 +31177,18 @@ function parseLeadingFrontmatter(raw, context) {
|
|
|
30923
31177
|
throw new MalformedDocumentError(context, error);
|
|
30924
31178
|
}
|
|
30925
31179
|
}
|
|
31180
|
+
function assertStorableFrontmatter(raw) {
|
|
31181
|
+
try {
|
|
31182
|
+
parseLeadingFrontmatter(raw);
|
|
31183
|
+
const split = splitLeadingFrontmatter(raw);
|
|
31184
|
+
if ("yamlSource" in split) parseFrontmatter(split.yamlSource);
|
|
31185
|
+
} catch (error) {
|
|
31186
|
+
if (error instanceof MalformedDocumentError && error.code !== "FRONTMATTER_MALFORMED") {
|
|
31187
|
+
throw new FrontmatterRefusedError(error.code, error.detail);
|
|
31188
|
+
}
|
|
31189
|
+
if (!(error instanceof MalformedDocumentError)) throw error;
|
|
31190
|
+
}
|
|
31191
|
+
}
|
|
30926
31192
|
|
|
30927
31193
|
// ../core/src/paths.ts
|
|
30928
31194
|
var RESERVED_FILENAMES = ["index.md", "log.md"];
|
|
@@ -31282,82 +31548,6 @@ function inventoryDigest(inventory) {
|
|
|
31282
31548
|
return `sha256:${sha256HexOfUtf8(JSON.stringify(inventory.map((row) => [row.id, row.version])))}`;
|
|
31283
31549
|
}
|
|
31284
31550
|
|
|
31285
|
-
// ../core/src/frontmatter.ts
|
|
31286
|
-
var import_js_yaml2 = __toESM(require_js_yaml2(), 1);
|
|
31287
|
-
var YAML_TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp";
|
|
31288
|
-
function requireYamlTimestampType() {
|
|
31289
|
-
const type = import_js_yaml2.default.DEFAULT_SAFE_SCHEMA.implicit.find(
|
|
31290
|
-
(candidate) => candidate.tag === YAML_TIMESTAMP_TAG
|
|
31291
|
-
);
|
|
31292
|
-
if (!type) throw new Error("js-yaml safe schema is missing its timestamp type");
|
|
31293
|
-
return type;
|
|
31294
|
-
}
|
|
31295
|
-
var yamlTimestampType = requireYamlTimestampType();
|
|
31296
|
-
var stringTimestampType = new import_js_yaml2.default.Type(YAML_TIMESTAMP_TAG, {
|
|
31297
|
-
kind: "scalar",
|
|
31298
|
-
resolve: (value) => yamlTimestampType.resolve(value),
|
|
31299
|
-
construct: (value) => value
|
|
31300
|
-
});
|
|
31301
|
-
var losslessDateSchema = new import_js_yaml2.default.Schema({
|
|
31302
|
-
include: [import_js_yaml2.default.DEFAULT_SAFE_SCHEMA],
|
|
31303
|
-
implicit: [stringTimestampType]
|
|
31304
|
-
});
|
|
31305
|
-
var yamlEngine = {
|
|
31306
|
-
parse(input) {
|
|
31307
|
-
return import_js_yaml2.default.safeLoad(input, { schema: losslessDateSchema }) ?? {};
|
|
31308
|
-
}
|
|
31309
|
-
};
|
|
31310
|
-
function normalizeFrontmatter(data, options) {
|
|
31311
|
-
const out = { ...data };
|
|
31312
|
-
if (options.preserveTimestamp || options.okfVersion === "0.2") return out;
|
|
31313
|
-
const value = out.timestamp;
|
|
31314
|
-
if (value instanceof Date) {
|
|
31315
|
-
out.timestamp = value.toISOString();
|
|
31316
|
-
} else if (typeof value === "number" && Number.isFinite(value)) {
|
|
31317
|
-
out.timestamp = new Date(value).toISOString();
|
|
31318
|
-
} else if (typeof value === "string" && yamlTimestampType.resolve(value)) {
|
|
31319
|
-
const parsed = yamlTimestampType.construct(value);
|
|
31320
|
-
if (parsed instanceof Date) out.timestamp = parsed.toISOString();
|
|
31321
|
-
}
|
|
31322
|
-
return out;
|
|
31323
|
-
}
|
|
31324
|
-
function parseMarkdown(raw, context, options = {}) {
|
|
31325
|
-
const split = splitLeadingFrontmatter(raw, context);
|
|
31326
|
-
if (!("yamlSource" in split)) return { frontmatter: {}, body: split.body };
|
|
31327
|
-
return { frontmatter: parseFrontmatter(split.yamlSource, context, options), body: split.body };
|
|
31328
|
-
}
|
|
31329
|
-
function parseFrontmatter(source, context, options = {}) {
|
|
31330
|
-
let parsed;
|
|
31331
|
-
try {
|
|
31332
|
-
parsed = yamlEngine.parse(source);
|
|
31333
|
-
} catch (err) {
|
|
31334
|
-
throw new MalformedDocumentError(context, err);
|
|
31335
|
-
}
|
|
31336
|
-
return normalizeFrontmatter(parsed, options);
|
|
31337
|
-
}
|
|
31338
|
-
function stringifyFrontmatter(data) {
|
|
31339
|
-
return import_js_yaml2.default.safeDump(data).trim();
|
|
31340
|
-
}
|
|
31341
|
-
function normalizeDocumentBodyForStorage(body) {
|
|
31342
|
-
return body.endsWith("\n") ? body : `${body}
|
|
31343
|
-
`;
|
|
31344
|
-
}
|
|
31345
|
-
function stringifyWithData(data, body) {
|
|
31346
|
-
return stringifyWithSerializedFrontmatter(stringifyFrontmatter(data), body);
|
|
31347
|
-
}
|
|
31348
|
-
function stringifyWithSerializedFrontmatter(dumped, body) {
|
|
31349
|
-
const content3 = body ?? "";
|
|
31350
|
-
const newline = (value) => value.endsWith("\n") ? value : `${value}
|
|
31351
|
-
`;
|
|
31352
|
-
if (dumped === "{}") return normalizeDocumentBodyForStorage(content3);
|
|
31353
|
-
return `---
|
|
31354
|
-
${newline(dumped)}---
|
|
31355
|
-
${normalizeDocumentBodyForStorage(content3)}`;
|
|
31356
|
-
}
|
|
31357
|
-
function stringifyDoc(frontmatter2, body) {
|
|
31358
|
-
return stringifyWithData(frontmatter2, body);
|
|
31359
|
-
}
|
|
31360
|
-
|
|
31361
31551
|
// ../core/src/code-unit-order.ts
|
|
31362
31552
|
function compareCodeUnits(a, b) {
|
|
31363
31553
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
@@ -31935,6 +32125,13 @@ function resolveContentType(key, override) {
|
|
|
31935
32125
|
return inferContentTypeFromDocKey(key) ?? DEFAULT_BLOB_CONTENT_TYPE;
|
|
31936
32126
|
}
|
|
31937
32127
|
|
|
32128
|
+
// ../core/src/reserved-write.ts
|
|
32129
|
+
function assertStorableReservedWrite(dir, name, content3) {
|
|
32130
|
+
assertSafeReservedDir(dir);
|
|
32131
|
+
assertSafeReservedFilename(name);
|
|
32132
|
+
if (name.endsWith(".md")) assertStorableFrontmatter(content3);
|
|
32133
|
+
}
|
|
32134
|
+
|
|
31938
32135
|
// ../core/src/filesystem-identity.ts
|
|
31939
32136
|
import { promises as fs2 } from "node:fs";
|
|
31940
32137
|
import path2 from "node:path";
|
|
@@ -33289,8 +33486,7 @@ var FilesystemBackend = class _FilesystemBackend {
|
|
|
33289
33486
|
return { content: content3, version: versionOfBytes(content3) };
|
|
33290
33487
|
}
|
|
33291
33488
|
async writeReserved(dir, name, content3, options = {}) {
|
|
33292
|
-
|
|
33293
|
-
assertSafeReservedFilename(name);
|
|
33489
|
+
assertStorableReservedWrite(dir, name, content3);
|
|
33294
33490
|
const rel = reservedPath(dir, name);
|
|
33295
33491
|
return this.#mutateExact(rel, async (target) => {
|
|
33296
33492
|
if (options.expectedVersion !== void 0) {
|