expo-tiddlywiki-filesystem-android-external-storage 2.2.1 → 2.2.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.
@@ -638,6 +638,92 @@ class ExternalStorageModule : Module() {
638
638
  changes.toString()
639
639
  }
640
640
 
641
+ /**
642
+ * Return diagnostic info about git index vs working directory.
643
+ * Used to debug why gitStatus returns 0 when changes exist.
644
+ */
645
+ AsyncFunction("gitStatusDebug") { gitRootDir: String ->
646
+ val root = File(gitRootDir)
647
+ val gitDir = File(root, ".git")
648
+ val indexFile = File(gitDir, "index")
649
+
650
+ val result = JSONObject()
651
+
652
+ if (!indexFile.exists()) {
653
+ result.put("error", "no git index file")
654
+ return@AsyncFunction result.toString()
655
+ }
656
+
657
+ val indexEntries = parseGitIndex(indexFile)
658
+ result.put("indexEntryCount", indexEntries.size)
659
+
660
+ // Sample a few index entries with their stats
661
+ val indexSamples = JSONArray()
662
+ // Find $__StoryList.tid or similar common tiddler in the index
663
+ val storyListEntry = indexEntries.find { it.path == "tiddlers/\$__StoryList.tid" }
664
+ if (storyListEntry != null) {
665
+ val obj = JSONObject()
666
+ obj.put("path", storyListEntry.path)
667
+ obj.put("indexSize", storyListEntry.size)
668
+ obj.put("indexMtime", storyListEntry.mtimeSeconds)
669
+ val workFile = File(root, storyListEntry.path)
670
+ obj.put("diskExists", workFile.exists())
671
+ if (workFile.exists()) {
672
+ obj.put("diskSize", workFile.length())
673
+ obj.put("diskMtime", workFile.lastModified() / 1000)
674
+ obj.put("diskMtimeMs", workFile.lastModified())
675
+ obj.put("sizeMatch", workFile.length() == storyListEntry.size)
676
+ obj.put("mtimeMatch", workFile.lastModified() / 1000 == storyListEntry.mtimeSeconds)
677
+ }
678
+ indexSamples.put(obj)
679
+ }
680
+
681
+ // Check 新条目.tid
682
+ val newEntryFile = File(root, "tiddlers/新条目.tid")
683
+ val newObj = JSONObject()
684
+ newObj.put("path", "tiddlers/新条目.tid")
685
+ newObj.put("diskExists", newEntryFile.exists())
686
+ if (newEntryFile.exists()) {
687
+ newObj.put("diskSize", newEntryFile.length())
688
+ newObj.put("diskMtime", newEntryFile.lastModified() / 1000)
689
+ }
690
+ val inIndex = indexEntries.any { it.path == "tiddlers/新条目.tid" }
691
+ newObj.put("inIndex", inIndex)
692
+ indexSamples.put(newObj)
693
+
694
+ // Walk working dir and count
695
+ val skipDirs = setOf(".git", "node_modules", "output")
696
+ val workdirFiles = mutableSetOf<String>()
697
+ fun walkDir(dir: File, prefix: String) {
698
+ val children = dir.listFiles() ?: return
699
+ for (child in children) {
700
+ val relPath = if (prefix.isEmpty()) child.name else "$prefix/${child.name}"
701
+ if (child.isDirectory) {
702
+ if (child.name !in skipDirs) walkDir(child, relPath)
703
+ } else {
704
+ workdirFiles.add(relPath)
705
+ }
706
+ }
707
+ }
708
+ walkDir(root, "")
709
+
710
+ result.put("workdirFileCount", workdirFiles.size)
711
+ result.put("tiddlerFileCount", workdirFiles.count { it.startsWith("tiddlers/") })
712
+ result.put("newEntryInWorkdir", workdirFiles.contains("tiddlers/新条目.tid"))
713
+ result.put("samples", indexSamples)
714
+
715
+ // Count files in workdir not in index (potential adds)
716
+ val indexPaths = indexEntries.map { it.path }.toSet()
717
+ val addCount = workdirFiles.count { it !in indexPaths }
718
+ result.put("potentialAddCount", addCount)
719
+ // List first 5 potential adds
720
+ val addSamples = JSONArray()
721
+ workdirFiles.filter { it !in indexPaths }.take(5).forEach { addSamples.put(it) }
722
+ result.put("potentialAddSamples", addSamples)
723
+
724
+ result.toString()
725
+ }
726
+
641
727
  // ─── TiddlyWiki batch file parsing ─────────────────────────────────
642
728
 
643
729
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-tiddlywiki-filesystem-android-external-storage",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "description": "Expo native module for TidGi-Mobile: external storage I/O + TiddlyWiki .tid/.meta/.json batch parsing in Kotlin",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",