@linxin666/dsh-pet 0.4.11 → 0.4.13
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/lib/client.js +46 -5
- package/lib/client.js.map +1 -1
- package/lib/index.js +32 -0
- package/lib/types/client/PetSettingsCard.d.ts +16 -1
- package/lib/types/client/PetSettingsCard.d.ts.map +1 -1
- package/lib/types/client/PetSettingsCard.js +49 -4
- package/lib/types/registry.d.ts.map +1 -1
- package/lib/types/registry.js +35 -0
- package/package.json +1 -1
- package/src/client/PetSettingsCard.test.tsx +50 -0
- package/src/client/PetSettingsCard.tsx +51 -5
- package/src/registry.test.ts +121 -1
- package/src/registry.ts +37 -0
package/src/registry.ts
CHANGED
|
@@ -837,6 +837,29 @@ function resolveFrames2dEntry(
|
|
|
837
837
|
}
|
|
838
838
|
}
|
|
839
839
|
|
|
840
|
+
/**
|
|
841
|
+
* Directory-name suffix the market installer carries while it downloads:
|
|
842
|
+
* '<id>.install-<base36 ms>-<base36 suffix>'
|
|
843
|
+
* (`installAsset` in dsh-web `packages/dsh-market/src/core/installer.ts` builds
|
|
844
|
+
* it as `dest + '.install-' + Date.now().toString(36) + '-' +
|
|
845
|
+
* Math.random().toString(36).slice(2, 8)`). Success renames the staging
|
|
846
|
+
* directory onto its id, and the failure path removes it, so such a directory
|
|
847
|
+
* surviving on disk means an install was interrupted and what it holds is a
|
|
848
|
+
* partial pet.
|
|
849
|
+
*
|
|
850
|
+
* The bounds are the producer's real range rather than a guess: base36 of
|
|
851
|
+
* `Date.now()` is 8 digits today and stays under 11 for several millennia,
|
|
852
|
+
* and `.slice(2, 8)` always yields exactly 6 base36 characters. A directory
|
|
853
|
+
* whose name merely mentions '.install-' outside that shape stays an ordinary
|
|
854
|
+
* pet directory.
|
|
855
|
+
*/
|
|
856
|
+
const PET_INSTALL_STAGING_NAME = /\.install-[0-9a-z]{1,11}-[0-9a-z]{1,11}$/
|
|
857
|
+
|
|
858
|
+
/** True when a pet directory name is an interrupted-install staging leftover. */
|
|
859
|
+
function isPetInstallStagingName(name: string): boolean {
|
|
860
|
+
return PET_INSTALL_STAGING_NAME.test(name)
|
|
861
|
+
}
|
|
862
|
+
|
|
840
863
|
/** Scan one directory of pet folders; entries come back in name order. */
|
|
841
864
|
function scanPetDir(dir: string, options: { assetPrefix?: string; warnings?: string[]; diagnostics?: PetRegistryDiagnostic[] }): PetEntry[] {
|
|
842
865
|
if (!existsSync(dir)) return []
|
|
@@ -849,6 +872,20 @@ function scanPetDir(dir: string, options: { assetPrefix?: string; warnings?: str
|
|
|
849
872
|
names.sort()
|
|
850
873
|
const entries: PetEntry[] = []
|
|
851
874
|
for (const name of names) {
|
|
875
|
+
// An interrupted market install leaves '<id>.install-<base36>-<base36>'
|
|
876
|
+
// behind holding a partial pet.json. Because a directory sorts just before
|
|
877
|
+
// its own staging suffixes and later entries win the id collision below,
|
|
878
|
+
// the leftover would override the finished pet with the same id. Drop it
|
|
879
|
+
// before the manifest is read, and only report it: cleanup belongs to the
|
|
880
|
+
// installer, and a scan must stay read-only.
|
|
881
|
+
if (isPetInstallStagingName(name)) {
|
|
882
|
+
const leftover = join(dir, name)
|
|
883
|
+
const message = 'skipping install staging leftover ' + name + ' (' + leftover
|
|
884
|
+
+ '): an interrupted install left it behind, and it is ignored so it cannot override the finished pet with the same id'
|
|
885
|
+
options.warnings?.push(message)
|
|
886
|
+
options.diagnostics?.push({ level: 'warning', source: leftover, message })
|
|
887
|
+
continue
|
|
888
|
+
}
|
|
852
889
|
const manifestFile = join(dir, name, 'pet.json')
|
|
853
890
|
if (!existsSync(manifestFile)) continue
|
|
854
891
|
const parsed = readPetJson(manifestFile, options)
|