Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ombori/ga-settings

Package Overview
Dependencies
Maintainers
0
Versions
143
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ombori/ga-settings - npm Package Compare versions

Comparing version 4.1.21 to 4.1.22

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## 4.1.22 (2024-08-25)
### Bug Fixes
* track active downloads ([75c0878](https://github.com/ombori/gridapp/commit/75c087891d0c6f23abfa79f9dfa42311d3616eb5))
## 4.1.21 (2024-08-25)

@@ -8,0 +19,0 @@

55

dist/index.js

@@ -67,9 +67,9 @@ "use strict";

return __awaiter(this, void 0, void 0, function () {
var _i, obj_1, item, _a, _b, _c, key, mediaId, cachedBlobUrl, newBlobUrl;
return __generator(this, function (_d) {
switch (_d.label) {
var _i, obj_1, item, _a, _b, _c, key, mediaId, cachedBlobUrl, _d, downloadPromise, newBlobUrl;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
if (!Array.isArray(obj)) return [3 /*break*/, 5];
_i = 0, obj_1 = obj;
_d.label = 1;
_e.label = 1;
case 1:

@@ -80,10 +80,10 @@ if (!(_i < obj_1.length)) return [3 /*break*/, 4];

case 2:
_d.sent();
_d.label = 3;
_e.sent();
_e.label = 3;
case 3:
_i++;
return [3 /*break*/, 1];
case 4: return [3 /*break*/, 13];
case 4: return [3 /*break*/, 15];
case 5:
if (!(obj !== null && typeof obj === 'object')) return [3 /*break*/, 13];
if (!(obj !== null && typeof obj === 'object')) return [3 /*break*/, 15];
_a = [];

@@ -93,3 +93,3 @@ for (_b in obj)

_c = 0;
_d.label = 6;
_e.label = 6;
case 6:

@@ -101,4 +101,4 @@ if (!(_c < _a.length)) return [3 /*break*/, 9];

case 7:
_d.sent();
_d.label = 8;
_e.sent();
_e.label = 8;
case 8:

@@ -108,4 +108,4 @@ _c++;

case 9:
if (!(obj.type === 'MEDIA' && obj.media)) return [3 /*break*/, 13];
if (!(obj.media.url && !obj.media.url.startsWith('blob:'))) return [3 /*break*/, 13];
if (!(obj.type === 'MEDIA' && obj.media)) return [3 /*break*/, 15];
if (!(obj.media.url && !obj.media.url.startsWith('blob:'))) return [3 /*break*/, 15];
mediaId = pageIdentifier + "_" + obj.media.id;

@@ -119,13 +119,27 @@ usedMediaIds.add(mediaId);

case 10:
cachedBlobUrl = _d.sent();
cachedBlobUrl = _e.sent();
if (!cachedBlobUrl) return [3 /*break*/, 11];
// Use the cached blob URL if available
obj.media.url = cachedBlobUrl;
return [3 /*break*/, 13];
case 11: return [4 /*yield*/, downloadAndStoreMedia(obj.media.url, mediaId, db)];
return [3 /*break*/, 15];
case 11:
if (!activeDownloads.has(obj.media.url)) return [3 /*break*/, 13];
// Wait for the ongoing download to finish
_d = obj.media;
return [4 /*yield*/, activeDownloads.get(obj.media.url)];
case 12:
newBlobUrl = _d.sent();
// Wait for the ongoing download to finish
_d.url = _e.sent();
return [3 /*break*/, 15];
case 13:
downloadPromise = downloadAndStoreMedia(obj.media.url, mediaId, db);
activeDownloads.set(obj.media.url, downloadPromise);
return [4 /*yield*/, downloadPromise];
case 14:
newBlobUrl = _e.sent();
obj.media.url = newBlobUrl;
_d.label = 13;
case 13: return [2 /*return*/];
// Remove from active downloads once completed
activeDownloads.delete(obj.media.url);
_e.label = 15;
case 15: return [2 /*return*/];
}

@@ -231,3 +245,3 @@ });

}
var db, pageIdentifier, usedMediaIds;
var db, pageIdentifier, usedMediaIds, activeDownloads;
return __generator(this, function (_a) {

@@ -239,2 +253,3 @@ switch (_a.label) {

usedMediaIds = new Set();
activeDownloads = new Map();
// Start the recursive process

@@ -241,0 +256,0 @@ return [4 /*yield*/, recursiveReplace(settings)];

{
"name": "@ombori/ga-settings",
"version": "4.1.21",
"version": "4.1.22",
"main": "dist/index.js",

@@ -22,3 +22,3 @@ "license": "UNLICENSED",

},
"gitHead": "dc8463503c7732e24e133184fc630b3f35e0e738"
"gitHead": "597ba2050c9ba552ec4105a81aec45d4fa4ebe29"
}

@@ -31,2 +31,5 @@ import { useEffect, useState, useRef } from 'react';

// Track active downloads to prevent duplicate downloads
const activeDownloads = new Map();
// Helper function to recursively traverse the settings object

@@ -66,5 +69,17 @@ async function recursiveReplace(obj: any) {

} else {
// Download the media, cache it, and replace the URL with a new Blob URL
const newBlobUrl = await downloadAndStoreMedia(obj.media.url, mediaId, db);
obj.media.url = newBlobUrl;
// Check if this URL is already being downloaded
if (activeDownloads.has(obj.media.url)) {
// Wait for the ongoing download to finish
obj.media.url = await activeDownloads.get(obj.media.url);
} else {
// Start downloading and caching the media
const downloadPromise = downloadAndStoreMedia(obj.media.url, mediaId, db);
activeDownloads.set(obj.media.url, downloadPromise);
const newBlobUrl = await downloadPromise;
obj.media.url = newBlobUrl;
// Remove from active downloads once completed
activeDownloads.delete(obj.media.url);
}
}

@@ -71,0 +86,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc