@youtyan/code-viewer 0.5.3 → 0.5.4

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.
@@ -6016,10 +6016,13 @@ function sanitizeDbUiState(raw) {
6016
6016
  return emptyDbUiState();
6017
6017
  const prefs = sanitizeDbUiPrefs(raw.prefs);
6018
6018
  const expandedTables = sanitizeDbUiExpandedTables(raw.expandedTables);
6019
+ const snapshotSelectedTables = sanitizeDbUiExpandedTables(raw.snapshotSelectedTables);
6019
6020
  if (!isRecord(raw.columnWidths)) {
6020
6021
  const out2 = emptyDbUiState();
6021
6022
  if (expandedTables)
6022
6023
  out2.expandedTables = expandedTables;
6024
+ if (snapshotSelectedTables)
6025
+ out2.snapshotSelectedTables = snapshotSelectedTables;
6023
6026
  if (prefs)
6024
6027
  out2.prefs = prefs;
6025
6028
  return out2;
@@ -6065,6 +6068,8 @@ function sanitizeDbUiState(raw) {
6065
6068
  const out = { version: 1, columnWidths };
6066
6069
  if (expandedTables)
6067
6070
  out.expandedTables = expandedTables;
6071
+ if (snapshotSelectedTables)
6072
+ out.snapshotSelectedTables = snapshotSelectedTables;
6068
6073
  if (prefs)
6069
6074
  out.prefs = prefs;
6070
6075
  return out;
@@ -6100,12 +6105,17 @@ function mergeDbUiState(current, patch) {
6100
6105
  return current;
6101
6106
  const mergedPrefs = "prefs" in patch ? mergeDbUiPrefs(current.prefs, patch.prefs) : current.prefs;
6102
6107
  const mergedExpandedTables = "expandedTables" in patch ? mergeDbUiExpandedTables(current.expandedTables, patch.expandedTables) : current.expandedTables;
6108
+ const mergedSnapshotSelectedTables = "snapshotSelectedTables" in patch ? mergeDbUiExpandedTables(current.snapshotSelectedTables, patch.snapshotSelectedTables) : current.snapshotSelectedTables;
6103
6109
  if (!isRecord(patch.columnWidths)) {
6104
6110
  const merged = { ...current, version: 1 };
6105
6111
  if (mergedExpandedTables)
6106
6112
  merged.expandedTables = mergedExpandedTables;
6107
6113
  else
6108
6114
  delete merged.expandedTables;
6115
+ if (mergedSnapshotSelectedTables)
6116
+ merged.snapshotSelectedTables = mergedSnapshotSelectedTables;
6117
+ else
6118
+ delete merged.snapshotSelectedTables;
6109
6119
  if (mergedPrefs)
6110
6120
  merged.prefs = mergedPrefs;
6111
6121
  else
@@ -6146,6 +6156,7 @@ function mergeDbUiState(current, patch) {
6146
6156
  ...patch,
6147
6157
  columnWidths,
6148
6158
  expandedTables: mergedExpandedTables,
6159
+ snapshotSelectedTables: mergedSnapshotSelectedTables,
6149
6160
  prefs: mergedPrefs,
6150
6161
  version: 1
6151
6162
  });
@@ -11220,17 +11231,20 @@ async function computeDiffTables(cwd, beforeId, afterId) {
11220
11231
  insertedCount: 0,
11221
11232
  updatedCount: 0,
11222
11233
  deletedCount: 0,
11223
- unchangedCount: b.row_count
11234
+ unchangedCount: b.row_count,
11235
+ coverage: "both"
11224
11236
  });
11225
11237
  continue;
11226
11238
  }
11227
11239
  if (!b) {
11228
11240
  results.push({
11229
11241
  tableName: table,
11230
- insertedCount: a ? a.row_count : 0,
11242
+ insertedCount: 0,
11231
11243
  updatedCount: 0,
11232
11244
  deletedCount: 0,
11233
- unchangedCount: 0
11245
+ unchangedCount: 0,
11246
+ coverage: "after-only",
11247
+ unsnapshottedRowCount: a ? a.row_count : 0
11234
11248
  });
11235
11249
  continue;
11236
11250
  }
@@ -11239,8 +11253,10 @@ async function computeDiffTables(cwd, beforeId, afterId) {
11239
11253
  tableName: table,
11240
11254
  insertedCount: 0,
11241
11255
  updatedCount: 0,
11242
- deletedCount: b.row_count,
11243
- unchangedCount: 0
11256
+ deletedCount: 0,
11257
+ unchangedCount: 0,
11258
+ coverage: "before-only",
11259
+ unsnapshottedRowCount: b.row_count
11244
11260
  });
11245
11261
  continue;
11246
11262
  }
@@ -11262,7 +11278,8 @@ async function computeDiffTables(cwd, beforeId, afterId) {
11262
11278
  insertedCount,
11263
11279
  updatedCount,
11264
11280
  deletedCount,
11265
- unchangedCount: Math.max(0, unchangedCount)
11281
+ unchangedCount: Math.max(0, unchangedCount),
11282
+ coverage: "both"
11266
11283
  });
11267
11284
  }
11268
11285
  results.sort((a, b) => {
@@ -11400,9 +11417,11 @@ async function runSnapshot(cwd, source, dbId, containers, note, onProgress, opti
11400
11417
  const snapshotId = await createSnapshot(cwd, dbId, snapshotSource.kind, containers, note, options.schema);
11401
11418
  try {
11402
11419
  options.onSnapshotId?.(snapshotId);
11403
- for (const container of containers) {
11420
+ const total = containers.length;
11421
+ for (let i = 0;i < containers.length; i++) {
11422
+ const container = containers[i];
11404
11423
  throwIfAborted(options.signal, "snapshot cancelled");
11405
- onProgress?.(container, false);
11424
+ onProgress?.({ container, done: false, index: i, total });
11406
11425
  const collected = [];
11407
11426
  let pkColumns = [];
11408
11427
  if (snapshotSource.model === "sql") {
@@ -11427,7 +11446,7 @@ async function runSnapshot(cwd, source, dbId, containers, note, onProgress, opti
11427
11446
  await addSnapshotTableData(cwd, snapshotId, container, pkColumns, collected);
11428
11447
  }
11429
11448
  await finalizeSnapshot(cwd, snapshotId);
11430
- onProgress?.("", true);
11449
+ onProgress?.({ container: "", done: true, index: total, total });
11431
11450
  return snapshotId;
11432
11451
  } catch (err) {
11433
11452
  const msg = err instanceof Error ? err.message : String(err);
@@ -12465,13 +12484,16 @@ async function handleSnapshotCreate(cwd, req, sendSse, omitDirNames) {
12465
12484
  let activeSnapshotId;
12466
12485
  (async () => {
12467
12486
  try {
12468
- const snapshotId = await runSnapshot(cwd, source, snapshotDbId, snapshotContainers, note, (table, done) => {
12487
+ const snapshotId = await runSnapshot(cwd, source, snapshotDbId, snapshotContainers, note, (progress) => {
12469
12488
  sendSse?.("db-snapshot", JSON.stringify({
12470
12489
  action: "progress",
12471
12490
  dbId: snapshotDbId,
12472
12491
  schema: body.schema,
12473
- table,
12474
- done
12492
+ id: activeSnapshotId,
12493
+ table: progress.container,
12494
+ done: progress.done,
12495
+ index: progress.index,
12496
+ total: progress.total
12475
12497
  }));
12476
12498
  }, {
12477
12499
  signal: abortController.signal,
@@ -12484,7 +12506,8 @@ async function handleSnapshotCreate(cwd, req, sendSse, omitDirNames) {
12484
12506
  action: "started",
12485
12507
  dbId: snapshotDbId,
12486
12508
  schema: body.schema,
12487
- id
12509
+ id,
12510
+ total: snapshotContainers.length
12488
12511
  }));
12489
12512
  }
12490
12513
  });
@@ -12503,6 +12526,7 @@ async function handleSnapshotCreate(cwd, req, sendSse, omitDirNames) {
12503
12526
  action: aborted ? "aborted" : "error",
12504
12527
  dbId: snapshotDbId,
12505
12528
  schema: body.schema,
12529
+ id: activeSnapshotId,
12506
12530
  ...aborted ? {} : { error: err instanceof Error ? err.message : String(err) }
12507
12531
  }));
12508
12532
  } finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youtyan/code-viewer",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Local browser-based code and git diff viewer",
5
5
  "type": "module",
6
6
  "bin": {