expo-tiddlywiki-filesystem-android-external-storage 2.2.1 → 2.2.3

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,109 @@ 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
+ result.put("rootExists", root.exists())
652
+ result.put("rootIsDir", root.isDirectory)
653
+ result.put("gitDirExists", gitDir.exists())
654
+ result.put("gitDirIsDir", gitDir.isDirectory)
655
+ result.put("indexFileExists", indexFile.exists())
656
+ result.put("rootPath", root.absolutePath)
657
+ result.put("gitDirPath", gitDir.absolutePath)
658
+ result.put("indexPath", indexFile.absolutePath)
659
+
660
+ // List contents of root (first 10)
661
+ val rootChildren = root.listFiles()?.map { it.name }?.sorted()?.take(10) ?: emptyList()
662
+ result.put("rootChildren", JSONArray(rootChildren))
663
+
664
+ // List contents of .git if exists
665
+ if (gitDir.exists() && gitDir.isDirectory) {
666
+ val gitChildren = gitDir.listFiles()?.map { it.name }?.sorted() ?: emptyList()
667
+ result.put("gitDirChildren", JSONArray(gitChildren))
668
+ }
669
+
670
+ if (!indexFile.exists()) {
671
+ return@AsyncFunction result.toString()
672
+ }
673
+
674
+ val indexEntries = parseGitIndex(indexFile)
675
+ result.put("indexEntryCount", indexEntries.size)
676
+
677
+ // Sample a few index entries with their stats
678
+ val indexSamples = JSONArray()
679
+ // Find $__StoryList.tid or similar common tiddler in the index
680
+ val storyListEntry = indexEntries.find { it.path == "tiddlers/\$__StoryList.tid" }
681
+ if (storyListEntry != null) {
682
+ val obj = JSONObject()
683
+ obj.put("path", storyListEntry.path)
684
+ obj.put("indexSize", storyListEntry.size)
685
+ obj.put("indexMtime", storyListEntry.mtimeSeconds)
686
+ val workFile = File(root, storyListEntry.path)
687
+ obj.put("diskExists", workFile.exists())
688
+ if (workFile.exists()) {
689
+ obj.put("diskSize", workFile.length())
690
+ obj.put("diskMtime", workFile.lastModified() / 1000)
691
+ obj.put("diskMtimeMs", workFile.lastModified())
692
+ obj.put("sizeMatch", workFile.length() == storyListEntry.size)
693
+ obj.put("mtimeMatch", workFile.lastModified() / 1000 == storyListEntry.mtimeSeconds)
694
+ }
695
+ indexSamples.put(obj)
696
+ }
697
+
698
+ // Check 新条目.tid
699
+ val newEntryFile = File(root, "tiddlers/新条目.tid")
700
+ val newObj = JSONObject()
701
+ newObj.put("path", "tiddlers/新条目.tid")
702
+ newObj.put("diskExists", newEntryFile.exists())
703
+ if (newEntryFile.exists()) {
704
+ newObj.put("diskSize", newEntryFile.length())
705
+ newObj.put("diskMtime", newEntryFile.lastModified() / 1000)
706
+ }
707
+ val inIndex = indexEntries.any { it.path == "tiddlers/新条目.tid" }
708
+ newObj.put("inIndex", inIndex)
709
+ indexSamples.put(newObj)
710
+
711
+ // Walk working dir and count
712
+ val skipDirs = setOf(".git", "node_modules", "output")
713
+ val workdirFiles = mutableSetOf<String>()
714
+ fun walkDir(dir: File, prefix: String) {
715
+ val children = dir.listFiles() ?: return
716
+ for (child in children) {
717
+ val relPath = if (prefix.isEmpty()) child.name else "$prefix/${child.name}"
718
+ if (child.isDirectory) {
719
+ if (child.name !in skipDirs) walkDir(child, relPath)
720
+ } else {
721
+ workdirFiles.add(relPath)
722
+ }
723
+ }
724
+ }
725
+ walkDir(root, "")
726
+
727
+ result.put("workdirFileCount", workdirFiles.size)
728
+ result.put("tiddlerFileCount", workdirFiles.count { it.startsWith("tiddlers/") })
729
+ result.put("newEntryInWorkdir", workdirFiles.contains("tiddlers/新条目.tid"))
730
+ result.put("samples", indexSamples)
731
+
732
+ // Count files in workdir not in index (potential adds)
733
+ val indexPaths = indexEntries.map { it.path }.toSet()
734
+ val addCount = workdirFiles.count { it !in indexPaths }
735
+ result.put("potentialAddCount", addCount)
736
+ // List first 5 potential adds
737
+ val addSamples = JSONArray()
738
+ workdirFiles.filter { it !in indexPaths }.take(5).forEach { addSamples.put(it) }
739
+ result.put("potentialAddSamples", addSamples)
740
+
741
+ result.toString()
742
+ }
743
+
641
744
  // ─── TiddlyWiki batch file parsing ─────────────────────────────────
642
745
 
643
746
  /**
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.3",
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",