superbee 0.4.3 → 0.4.4-pre.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/README.md CHANGED
@@ -53,7 +53,11 @@ Requires a supported Node.js 22, 24, or 26 release (22.14.0 minimum) on macOS or
53
53
  npm install -g superbee
54
54
  ```
55
55
 
56
- Stable releases publish on npm's `latest` tag and prereleases on `next`.
56
+ Stable releases publish on npm's `latest` tag and prereleases on `next`. To try the prerelease:
57
+
58
+ ```sh
59
+ npm install -g superbee@next
60
+ ```
57
61
 
58
62
  Windows adapters and the `superbee-windows` executable live in a separate repository and are
59
63
  not included in `superbee`. Most Windows users should run Superbee in WSL2, where npm sees a
@@ -3,6 +3,11 @@ import { createHash } from "node:crypto";
3
3
  import { mkdir, mkdtemp, realpath, rm, writeFile } from "node:fs/promises";
4
4
  import path from "node:path";
5
5
 
6
+ // ../core/src/path-fold.ts
7
+ function foldPath(path2) {
8
+ return path2.normalize("NFC").toLowerCase().toUpperCase().toLowerCase().normalize("NFC");
9
+ }
10
+
6
11
  // ../core/src/errors.ts
7
12
  var InvalidInputError = class extends Error {
8
13
  constructor(message) {
@@ -175,7 +180,6 @@ function readStoredZip(archive) {
175
180
  return entries;
176
181
  }
177
182
  var WINDOWS_DEVICE_NAMES = /* @__PURE__ */ new Set(["CON", "PRN", "AUX", "NUL", ...Array.from({ length: 9 }, (_, i) => `COM${i + 1}`), ...Array.from({ length: 9 }, (_, i) => `LPT${i + 1}`)]);
178
- var fold = (segment) => segment.normalize("NFC").toLowerCase();
179
183
  function classifyEntryPath(entryPath) {
180
184
  const unsafe = (why) => new ExportArchiveError("unsafe_path", `the archive holds a path a bundle cannot keep (${why}): ${JSON.stringify(entryPath.slice(0, 200))}`);
181
185
  if (entryPath === "" || entryPath.length > 4096) throw unsafe("empty or too long");
@@ -209,13 +213,13 @@ function findEntryCollision(paths) {
209
213
  const dirs = /* @__PURE__ */ new Map();
210
214
  for (const entryPath of paths) {
211
215
  const segments = entryPath.split("/");
212
- const key = segments.map(fold).join("/");
216
+ const key = segments.map(foldPath).join("/");
213
217
  const file = files.get(key) ?? dirs.get(key)?.by;
214
218
  if (file !== void 0) return [file, entryPath];
215
219
  files.set(key, entryPath);
216
220
  for (let depth = 1; depth < segments.length; depth += 1) {
217
221
  const spelling = segments.slice(0, depth).join("/");
218
- const dirKey = segments.slice(0, depth).map(fold).join("/");
222
+ const dirKey = segments.slice(0, depth).map(foldPath).join("/");
219
223
  const asFile = files.get(dirKey);
220
224
  if (asFile !== void 0) return [asFile, entryPath];
221
225
  const seen = dirs.get(dirKey);
@@ -3346,9 +3346,9 @@ var yamlEngine = {
3346
3346
  return import_js_yaml2.default.safeLoad(input, { schema: losslessDateSchema }) ?? {};
3347
3347
  }
3348
3348
  };
3349
- function normalizeFrontmatter(data, okfVersion) {
3349
+ function normalizeFrontmatter(data, options) {
3350
3350
  const out = { ...data };
3351
- if (okfVersion === "0.2") return out;
3351
+ if (options.preserveTimestamp || options.okfVersion === "0.2") return out;
3352
3352
  const value = out.timestamp;
3353
3353
  if (value instanceof Date) {
3354
3354
  out.timestamp = value.toISOString();
@@ -3372,7 +3372,7 @@ function parseFrontmatter(source, context, options = {}) {
3372
3372
  } catch (err) {
3373
3373
  throw new MalformedDocumentError(context, err);
3374
3374
  }
3375
- return normalizeFrontmatter(parsed, options.okfVersion);
3375
+ return normalizeFrontmatter(parsed, options);
3376
3376
  }
3377
3377
  function stringifyFrontmatter(data) {
3378
3378
  return import_js_yaml2.default.safeDump(data).trim();
@@ -5440,6 +5440,11 @@ async function queryEdges2(bundle, filter = {}, options = {}) {
5440
5440
  // ../core/src/bundle.ts
5441
5441
  setDefaultBackendFactory((root) => new FilesystemBackend(root));
5442
5442
 
5443
+ // ../core/src/code-unit-order.ts
5444
+ function compareCodeUnits(a, b) {
5445
+ return a < b ? -1 : a > b ? 1 : 0;
5446
+ }
5447
+
5443
5448
  // ../core/src/managed-document-metadata.ts
5444
5449
  var MANAGED_DOCUMENT_METADATA_FIELDS = /* @__PURE__ */ new Set([
5445
5450
  "generated",
@@ -6328,7 +6333,7 @@ function compareByMeaningfulChange(a, b) {
6328
6333
  } else if (b.timestampMs !== null) {
6329
6334
  return 1;
6330
6335
  }
6331
- return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
6336
+ return compareCodeUnits(a.id, b.id);
6332
6337
  }
6333
6338
  function sortByMeaningfulChange(rows, okfVersion) {
6334
6339
  return rows.map((row) => ({ row, key: meaningfulChangeOrderKey(row.id, row.frontmatter, okfVersion) })).sort((a, b) => compareByMeaningfulChange(a.key, b.key)).map(({ row }) => row);
@@ -31300,9 +31300,9 @@ var yamlEngine = {
31300
31300
  return import_js_yaml2.default.safeLoad(input, { schema: losslessDateSchema }) ?? {};
31301
31301
  }
31302
31302
  };
31303
- function normalizeFrontmatter(data, okfVersion) {
31303
+ function normalizeFrontmatter(data, options) {
31304
31304
  const out = { ...data };
31305
- if (okfVersion === "0.2") return out;
31305
+ if (options.preserveTimestamp || options.okfVersion === "0.2") return out;
31306
31306
  const value = out.timestamp;
31307
31307
  if (value instanceof Date) {
31308
31308
  out.timestamp = value.toISOString();
@@ -31326,7 +31326,7 @@ function parseFrontmatter(source, context, options = {}) {
31326
31326
  } catch (err) {
31327
31327
  throw new MalformedDocumentError(context, err);
31328
31328
  }
31329
- return normalizeFrontmatter(parsed, options.okfVersion);
31329
+ return normalizeFrontmatter(parsed, options);
31330
31330
  }
31331
31331
  function stringifyFrontmatter(data) {
31332
31332
  return import_js_yaml2.default.safeDump(data).trim();
@@ -33424,6 +33424,11 @@ async function queryEdges2(bundle, filter = {}, options = {}) {
33424
33424
  // ../core/src/bundle.ts
33425
33425
  setDefaultBackendFactory((root) => new FilesystemBackend(root));
33426
33426
 
33427
+ // ../core/src/code-unit-order.ts
33428
+ function compareCodeUnits(a, b) {
33429
+ return a < b ? -1 : a > b ? 1 : 0;
33430
+ }
33431
+
33427
33432
  // ../core/src/managed-document-metadata.ts
33428
33433
  var MANAGED_DOCUMENT_METADATA_FIELDS = /* @__PURE__ */ new Set([
33429
33434
  "generated",
@@ -43543,7 +43548,7 @@ function compareByMeaningfulChange(a, b) {
43543
43548
  } else if (b.timestampMs !== null) {
43544
43549
  return 1;
43545
43550
  }
43546
- return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
43551
+ return compareCodeUnits(a.id, b.id);
43547
43552
  }
43548
43553
  function sortByMeaningfulChange(rows, okfVersion) {
43549
43554
  return rows.map((row) => ({ row, key: meaningfulChangeOrderKey(row.id, row.frontmatter, okfVersion) })).sort((a, b) => compareByMeaningfulChange(a.key, b.key)).map(({ row }) => row);