@bitcobblers/wod-wiki-engine 0.59.2236 → 0.59.2238

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.
@@ -858,13 +858,13 @@ function csvToTelemetryBundle(csv) {
858
858
  }
859
859
 
860
860
  // src/version.ts
861
- var VERSION = "0.59.2236";
862
- var GIT_SHA = "7b4743b";
863
- var BUILD_TIME = "2026-11-16T04:52:27.639Z";
861
+ var VERSION = "0.59.2238";
862
+ var GIT_SHA = "9029981";
863
+ var BUILD_TIME = "2026-11-16T16:02:29.109Z";
864
864
  var SEMVER = {
865
- version: "0.59.2236",
866
- gitSha: "7b4743b",
867
- buildTime: "2026-11-16T04:52:27.639Z"
865
+ version: "0.59.2238",
866
+ gitSha: "9029981",
867
+ buildTime: "2026-11-16T16:02:29.109Z"
868
868
  };
869
869
  var SEED_SCHEMA = 9;
870
870
  var SEED_REGISTERED_WIDGETS = KNOWN_SECTION_WIDGETS;
@@ -1753,7 +1753,7 @@ async function applyPreparedSeedChunkInTx(tx, prepared) {
1753
1753
  if (compiledById.get(compiled.blockId)?.dataType !== "wod") throw new Error("Orphan seed session pin");
1754
1754
  const prior = existingTelemetrySessions.get(compiled.id);
1755
1755
  if (prior && prior.noteId !== id) throw new Error(`Seed session ${compiled.id} belongs to another note`);
1756
- if (prior?.origin) {
1756
+ if (prior && (prior.origin || !prior.id.startsWith("seed:"))) {
1757
1757
  userRecordedSessions.add(compiled.id);
1758
1758
  continue;
1759
1759
  }
@@ -3105,10 +3105,26 @@ async function collectPublicStorageState(storage, options = {}) {
3105
3105
  storedCheckpoint
3106
3106
  };
3107
3107
  }
3108
+ async function recordPublishedFeedCheckpoint(storage, report) {
3109
+ const chunkShas = {};
3110
+ for (const c of report.manifest.chunks) chunkShas[c.id] = c.sha256;
3111
+ const cp = {
3112
+ key: PUBLISHED_FEED_META_KEY,
3113
+ version: report.manifest.version,
3114
+ builtAt: report.manifest.builtAt,
3115
+ manifestSha256: report.manifestSha256,
3116
+ chunkShas
3117
+ };
3118
+ await storage.transaction(["meta"], "readwrite", async (tx) => {
3119
+ await tx.readwrite("meta").put(cp);
3120
+ });
3121
+ }
3108
3122
  async function publishFeedFromStorage(storage, tree, options = {}) {
3123
+ options.signal?.throwIfAborted();
3109
3124
  const t0 = Date.now();
3110
3125
  const layout = options.layout ?? "feed";
3111
3126
  const state = await collectPublicStorageState(storage, options);
3127
+ options.signal?.throwIfAborted();
3112
3128
  if (state.notebooks.size === 0) {
3113
3129
  throw new Error("No public notebooks found to publish. Mark at least one user-owned notebook as Public first.");
3114
3130
  }
@@ -3396,28 +3412,19 @@ ${group.description ?? ""}
3396
3412
  const manifestBytes = encodeUtf8(JSON.stringify(manifest, null, 2) + "\n");
3397
3413
  const manifestSha256 = await sha256HexAsync(manifestBytes);
3398
3414
  await tree.write(`${artifactPrefix}manifest.json`, manifestBytes);
3399
- const shouldCheckpoint = options.recordCheckpoint ?? (layout === "feed" && !options.notebookSlug);
3400
- if (shouldCheckpoint) {
3401
- const chunkShas = {};
3402
- for (const c of manifestChunks) chunkShas[c.id] = c.sha256;
3403
- const cp = {
3404
- key: PUBLISHED_FEED_META_KEY,
3405
- version: nextVersion,
3406
- builtAt,
3407
- manifestSha256,
3408
- chunkShas
3409
- };
3410
- await storage.transaction(["meta"], "readwrite", async (tx) => {
3411
- await tx.readwrite("meta").put(cp);
3412
- });
3413
- }
3414
- return {
3415
+ const report = {
3415
3416
  manifest,
3416
3417
  notebooks: sortedSlugs,
3417
3418
  totalNotes,
3418
3419
  totalPublicSessions,
3419
3420
  manifestSha256
3420
3421
  };
3422
+ const shouldCheckpoint = options.recordCheckpoint ?? (layout === "feed" && !options.notebookSlug);
3423
+ if (shouldCheckpoint) {
3424
+ options.signal?.throwIfAborted();
3425
+ await recordPublishedFeedCheckpoint(storage, report);
3426
+ }
3427
+ return report;
3421
3428
  }
3422
3429
  async function checkUnpublishedFeedChanges(storage, currentTree, options = {}) {
3423
3430
  const state = await collectPublicStorageState(storage, options);
@@ -4236,6 +4243,208 @@ async function ingestPortableFilesIntoStorage(storage, files, options = {}) {
4236
4243
  errors
4237
4244
  };
4238
4245
  }
4246
+ var FEED_SUBSCRIPTIONS_META_KEY = "feed:subscriptions";
4247
+ async function removeSeedSourceContent(storage, meta) {
4248
+ return await storage.transaction(
4249
+ [
4250
+ "notes",
4251
+ "attachments",
4252
+ "tags",
4253
+ "note_tags",
4254
+ "block_index",
4255
+ "block_efforts",
4256
+ "block_equipment",
4257
+ "page_notes",
4258
+ "efforts",
4259
+ "equipment",
4260
+ "property_overrides",
4261
+ "meta"
4262
+ ],
4263
+ "readwrite",
4264
+ async (tx) => {
4265
+ const targetIds = /* @__PURE__ */ new Set();
4266
+ const legacyChunks = [];
4267
+ for (const [chunkId, chunk] of Object.entries(meta.chunks)) {
4268
+ if (chunk.noteIds?.length) {
4269
+ for (const id of chunk.noteIds) targetIds.add(id);
4270
+ } else {
4271
+ legacyChunks.push(chunkId);
4272
+ }
4273
+ }
4274
+ if (legacyChunks.length) {
4275
+ for (const note of await tx.readwrite("notes").getAll()) {
4276
+ if (note.seedOrigin === "seed" && note.seedChunkId && legacyChunks.includes(note.seedChunkId)) {
4277
+ targetIds.add(note.id);
4278
+ }
4279
+ }
4280
+ }
4281
+ const metaStore = tx.readwrite("meta");
4282
+ const otherCheckpoints = [];
4283
+ for (const row of await metaStore.getAll()) {
4284
+ const other = row;
4285
+ if (!other || typeof other.key !== "string" || !other.key.startsWith("seed:") || other.key === meta.key) {
4286
+ continue;
4287
+ }
4288
+ const noteIds = /* @__PURE__ */ new Set();
4289
+ for (const chunk of Object.values(other.chunks ?? {})) {
4290
+ for (const id of chunk.noteIds ?? []) noteIds.add(id);
4291
+ }
4292
+ otherCheckpoints.push({
4293
+ key: other.key,
4294
+ sourceId: other.key.slice(5),
4295
+ rank: seedPrecedenceRank(other.key, other.tier),
4296
+ meta: other,
4297
+ noteIds
4298
+ });
4299
+ }
4300
+ otherCheckpoints.sort((a, b) => b.rank - a.rank);
4301
+ const isClaimedByOther = (noteId) => otherCheckpoints.some((cp) => cp.noteIds.has(noteId));
4302
+ const removedSourceId = meta.key.startsWith("seed:") ? meta.key.slice(5) : meta.key;
4303
+ const notes = tx.readwrite("notes");
4304
+ const noteTags = tx.readwrite("note_tags");
4305
+ let deleted = 0;
4306
+ const removedPaths = /* @__PURE__ */ new Set();
4307
+ const touchedTagIds = /* @__PURE__ */ new Set();
4308
+ for (const id of targetIds) {
4309
+ if (isClaimedByOther(id)) continue;
4310
+ const note = await notes.get(id);
4311
+ if (!note || note.seedOrigin !== "seed") continue;
4312
+ if (note.seedChunkId && !meta.chunks[note.seedChunkId]) continue;
4313
+ if (note.sourcePath) removedPaths.add(note.sourcePath);
4314
+ await notes.delete(id);
4315
+ const attachments = tx.readwrite("attachments");
4316
+ for (const attachment of await attachments.getAllFromIndex("by-note", id)) {
4317
+ await attachments.delete(attachment.id);
4318
+ }
4319
+ for (const link of await noteTags.getAllFromIndex("by-note", id)) {
4320
+ touchedTagIds.add(link.tagId);
4321
+ await noteTags.delete(link.id);
4322
+ }
4323
+ const blockIndex = tx.readwrite("block_index");
4324
+ for (const row of await blockIndex.getAllFromIndex("by-note", id)) await blockIndex.delete(row.id);
4325
+ const blockEfforts = tx.readwrite("block_efforts");
4326
+ for (const row of await blockEfforts.getAllFromIndex("by-note", id)) await blockEfforts.delete(row.id);
4327
+ const blockEquipment = tx.readwrite("block_equipment");
4328
+ for (const row of await blockEquipment.getAllFromIndex("by-note", id)) await blockEquipment.delete(row.id);
4329
+ const pageNotes = tx.readwrite("page_notes");
4330
+ for (const link of await pageNotes.getAllFromIndex("by-note", id)) await pageNotes.delete(link.id);
4331
+ deleted++;
4332
+ }
4333
+ if (touchedTagIds.size > 0) {
4334
+ const tagsStore = tx.readwrite("tags");
4335
+ for (const tagId of touchedTagIds) {
4336
+ const remainingLinks = await noteTags.countFromIndex("by-tag", tagId);
4337
+ if (remainingLinks > 0) continue;
4338
+ const tag = await tagsStore.get(tagId);
4339
+ if (!tag) continue;
4340
+ if (tag.contributions && tag.contributions.length > 0) continue;
4341
+ const refNote = await notes.get(`t/${tag.type ?? "tag"}/${tag.label}`);
4342
+ if (refNote) continue;
4343
+ await tagsStore.delete(tagId);
4344
+ }
4345
+ }
4346
+ const defFamilies = [
4347
+ { storeName: "efforts", familyPathPrefix: "markdown/efforts/", parse: parseEffortFile },
4348
+ { storeName: "equipment", familyPathPrefix: "markdown/equipment/", parse: parseEquipmentFile }
4349
+ ];
4350
+ for (const { storeName, familyPathPrefix, parse } of defFamilies) {
4351
+ const store = tx.readwrite(storeName);
4352
+ for (const row of await store.getAll()) {
4353
+ if (row.registrySource !== "bundled") continue;
4354
+ const owned = row.sourceId === removedSourceId || row.ownerNoteId !== void 0 && targetIds.has(row.ownerNoteId) && (!row.sourceId || row.sourceId === storeName) || row.sourcePath !== void 0 && row.sourcePath.startsWith(familyPathPrefix) && removedPaths.has(row.sourcePath);
4355
+ if (!owned) continue;
4356
+ let restored = false;
4357
+ for (const cp of otherCheckpoints) {
4358
+ const candidateIds = cp.meta.chunks?.[storeName]?.noteIds ?? [];
4359
+ for (const candidateId of candidateIds) {
4360
+ const candidateNote = await notes.get(candidateId);
4361
+ if (!candidateNote || candidateNote.seedOrigin !== "seed") continue;
4362
+ const parsed = parse(candidateNote.rawContent);
4363
+ if (parsed && parsed.slug === row.slug) {
4364
+ await store.put({
4365
+ ...parsed,
4366
+ registrySource: "bundled",
4367
+ ownerNoteId: candidateNote.id,
4368
+ sourceId: cp.sourceId,
4369
+ feedSourceId: cp.sourceId,
4370
+ sourcePath: candidateNote.sourcePath ?? ""
4371
+ });
4372
+ restored = true;
4373
+ break;
4374
+ }
4375
+ }
4376
+ if (restored) break;
4377
+ }
4378
+ if (!restored) await store.delete(row.slug);
4379
+ }
4380
+ }
4381
+ try {
4382
+ const overrideStore = tx.readwrite("property_overrides");
4383
+ for (const ov of await overrideStore.getAll()) {
4384
+ if (ov.seedOrigin === "seed" && ov.feedSourceId === removedSourceId) {
4385
+ await overrideStore.delete(ov.id);
4386
+ }
4387
+ }
4388
+ } catch {
4389
+ }
4390
+ await metaStore.delete(meta.key);
4391
+ return deleted;
4392
+ }
4393
+ );
4394
+ }
4395
+ async function readFeedSubscriptionsMap(storage) {
4396
+ const row = await storage.readonly("meta").get(FEED_SUBSCRIPTIONS_META_KEY);
4397
+ return { ...row?.entries ?? {} };
4398
+ }
4399
+ async function writeFeedSubscriptionEntry(storage, sourceId, entry) {
4400
+ await storage.transaction(["meta"], "readwrite", async (tx) => {
4401
+ const metaStore = tx.readwrite("meta");
4402
+ const existing = await metaStore.get(FEED_SUBSCRIPTIONS_META_KEY);
4403
+ const entries = { ...existing?.entries ?? {}, [sourceId]: entry };
4404
+ await metaStore.put({ key: FEED_SUBSCRIPTIONS_META_KEY, entries });
4405
+ });
4406
+ }
4407
+ async function listFeedSubscriptionsHeadless(storage) {
4408
+ return readFeedSubscriptionsMap(storage);
4409
+ }
4410
+ async function subscribeFeedSourceHeadless(storage, sourceId, options) {
4411
+ const notebookIds = options?.notebookIds && options.notebookIds.length > 0 ? options.notebookIds : null;
4412
+ await writeFeedSubscriptionEntry(storage, sourceId, {
4413
+ subscribed: true,
4414
+ notebookIds,
4415
+ hidden: false,
4416
+ ...options?.url ? { url: options.url } : {},
4417
+ ...options?.name ? { name: options.name } : {},
4418
+ updatedAt: Date.now()
4419
+ });
4420
+ return { sourceId, subscribed: true, notebookIds };
4421
+ }
4422
+ async function unsubscribeFeedSourceHeadless(storage, sourceId) {
4423
+ if (sourceId === "core") {
4424
+ throw new Error("Core feed cannot be unsubscribed.");
4425
+ }
4426
+ const meta = await storage.readonly("meta").get(seedMetaKey(sourceId));
4427
+ const deletedNotes = meta ? await removeSeedSourceContent(storage, meta) : 0;
4428
+ await writeFeedSubscriptionEntry(storage, sourceId, {
4429
+ subscribed: false,
4430
+ hidden: false,
4431
+ updatedAt: Date.now()
4432
+ });
4433
+ return { sourceId, unsubscribed: true, deletedNotes };
4434
+ }
4435
+ async function deleteFeedSourceHeadless(storage, sourceId) {
4436
+ if (sourceId === "core") {
4437
+ throw new Error("Core feed cannot be deleted.");
4438
+ }
4439
+ const meta = await storage.readonly("meta").get(seedMetaKey(sourceId));
4440
+ const deletedNotes = meta ? await removeSeedSourceContent(storage, meta) : 0;
4441
+ await writeFeedSubscriptionEntry(storage, sourceId, {
4442
+ subscribed: false,
4443
+ hidden: true,
4444
+ updatedAt: Date.now()
4445
+ });
4446
+ return { sourceId, deleted: true, deletedNotes };
4447
+ }
4239
4448
  function mintUuid() {
4240
4449
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
4241
4450
  return crypto.randomUUID();
@@ -4535,6 +4744,6 @@ function buildNoteProvenance(sourceNote, sourceNotebookId, clonedAt) {
4535
4744
  };
4536
4745
  }
4537
4746
 
4538
- export { APP_ORIGIN, BUILD_TIME, CANVAS_CHUNK_ID, DASHBOARDS_CHUNK_ID, DirectoryHandleFeedTree, EFFORTS_CHUNK_ID, EQUIPMENT_CHUNK_ID, FeedTreeError, GIT_SHA, HttpFeedTree, MemoryFeedTree, NOTE_ID_FRONTMATTER_KEY, PUBLISHED_FEED_META_KEY, QR_SCRIPT_ID, SEED_BROADCAST_CHANNEL, SEED_NAMESPACE, SEED_REGISTERED_WIDGETS, SEED_SCHEMA, SEMVER, SESSION_CSV_HEADER, TELEMETRY_CSV_HEADER, VERSION, applySeedChunk, applySeedChunks, assertNotebookIndex, assertSeedManifest, assertSeedRow, assertSeedRows, backfillFeedProvenance, buildNoteProvenance, buildStatementTree, canvasRouteSlug, checkUnpublishedFeedChanges, cloneRemoteRecord, composeNoteMarkdown, createIRFile, createUserNotebookLanding, csvToEquipmentLabels, csvToSessionRows, csvToTelemetryBundle, decodeUtf8, effortToMarkdown, emptySeedMeta, encodeUtf8, equipmentToCsv, equipmentToMarkdown, exportPortableFilesFromStorage, extractNoteIdentity, extractTypedTags, feedIdOfMetaKey, getNoteNotebooks, getNotePublicationSummary, ingestPortableFilesIntoStorage, injectIdentityFrontmatter, isIRFile, listScopedPropertyOverrides, makeNotebookLinkId, makeScopedOverrideId, migrateNotebookVocabulary, normalizeFeedTreePath, notebookSlugForChunkId, parseCsvLine, parseFrontmatterDateMs, parseNoteMarkdown, prepareJournalSessionRun, previewRemoteNotebook, previewRemoteRecord, promoteNoteToNotebooks, promoteReferencedOverridesToNotebook, publishFeedFromStorage, qrInlineScript, readFrontmatterMeta, removeNoteFromNotebook, renderFeedLandingHtml, resolveScopedPropertyCatalog, resolveUpstreamProvenance, saveScopedPropertyOverride, seedMetaKey, seedNoteId, seedNoteSourceId, seedPrecedenceRank, seedSourceTier, sessionToCsv, setNoteNotebooks, setNotebookPublic, setSessionPublic, sha256HexAsync, splitCsvRecords, statementToNode, telemetryBundleToCsv };
4539
- //# sourceMappingURL=chunk-KQYTRLW3.mjs.map
4540
- //# sourceMappingURL=chunk-KQYTRLW3.mjs.map
4747
+ export { APP_ORIGIN, BUILD_TIME, CANVAS_CHUNK_ID, DASHBOARDS_CHUNK_ID, DirectoryHandleFeedTree, EFFORTS_CHUNK_ID, EQUIPMENT_CHUNK_ID, FEED_SUBSCRIPTIONS_META_KEY, FeedTreeError, GIT_SHA, HttpFeedTree, MemoryFeedTree, NOTE_ID_FRONTMATTER_KEY, PUBLISHED_FEED_META_KEY, QR_SCRIPT_ID, SEED_BROADCAST_CHANNEL, SEED_NAMESPACE, SEED_REGISTERED_WIDGETS, SEED_SCHEMA, SEMVER, SESSION_CSV_HEADER, TELEMETRY_CSV_HEADER, VERSION, applySeedChunk, applySeedChunks, assertNotebookIndex, assertSeedManifest, assertSeedRow, assertSeedRows, backfillFeedProvenance, buildNoteProvenance, buildStatementTree, canvasRouteSlug, checkUnpublishedFeedChanges, cloneRemoteRecord, composeNoteMarkdown, createIRFile, createUserNotebookLanding, csvToEquipmentLabels, csvToSessionRows, csvToTelemetryBundle, decodeUtf8, deleteFeedSourceHeadless, effortToMarkdown, emptySeedMeta, encodeUtf8, equipmentToCsv, equipmentToMarkdown, exportPortableFilesFromStorage, extractNoteIdentity, extractTypedTags, feedIdOfMetaKey, getNoteNotebooks, getNotePublicationSummary, ingestPortableFilesIntoStorage, injectIdentityFrontmatter, isIRFile, listFeedSubscriptionsHeadless, listScopedPropertyOverrides, makeNotebookLinkId, makeScopedOverrideId, migrateNotebookVocabulary, normalizeFeedTreePath, notebookSlugForChunkId, parseCsvLine, parseFrontmatterDateMs, parseNoteMarkdown, prepareJournalSessionRun, previewRemoteNotebook, previewRemoteRecord, promoteNoteToNotebooks, promoteReferencedOverridesToNotebook, publishFeedFromStorage, qrInlineScript, readFrontmatterMeta, recordPublishedFeedCheckpoint, removeNoteFromNotebook, removeSeedSourceContent, renderFeedLandingHtml, resolveScopedPropertyCatalog, resolveUpstreamProvenance, saveScopedPropertyOverride, seedMetaKey, seedNoteId, seedNoteSourceId, seedPrecedenceRank, seedSourceTier, sessionToCsv, setNoteNotebooks, setNotebookPublic, setSessionPublic, sha256HexAsync, splitCsvRecords, statementToNode, subscribeFeedSourceHeadless, telemetryBundleToCsv, unsubscribeFeedSourceHeadless };
4748
+ //# sourceMappingURL=chunk-YUFWRUL6.mjs.map
4749
+ //# sourceMappingURL=chunk-YUFWRUL6.mjs.map