@opengeni/runtime 0.5.0 → 0.6.0
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/dist/{chunk-Q36E4MDM.js → chunk-BHA2SU3H.js} +54 -3
- package/dist/chunk-BHA2SU3H.js.map +1 -0
- package/dist/{index-BrdnxaAW.d.ts → index-otZkoLYq.d.ts} +11 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/sandbox/index.d.ts +1 -1
- package/dist/sandbox/index.js +3 -1
- package/package.json +2 -2
- package/src/sandbox/index.ts +2 -0
- package/src/sandbox/providers/modal.ts +107 -2
- package/dist/chunk-Q36E4MDM.js.map +0 -1
|
@@ -249,8 +249,9 @@ var modalProvider = {
|
|
|
249
249
|
if (settings.modalWorkspacePersistence) {
|
|
250
250
|
options.workspacePersistence = settings.modalWorkspacePersistence;
|
|
251
251
|
}
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
const imageSelector = resolveModalImageSelector(settings);
|
|
253
|
+
if (imageSelector) {
|
|
254
|
+
options.image = imageSelector;
|
|
254
255
|
}
|
|
255
256
|
if (settings.modalTokenId) {
|
|
256
257
|
options.tokenId = settings.modalTokenId;
|
|
@@ -264,6 +265,55 @@ var modalProvider = {
|
|
|
264
265
|
return new ModalSandboxClient(options);
|
|
265
266
|
}
|
|
266
267
|
};
|
|
268
|
+
var defaultModalLoader = () => import("modal");
|
|
269
|
+
var resolvedRegistryImages = /* @__PURE__ */ new Map();
|
|
270
|
+
var inFlightRegistryImages = /* @__PURE__ */ new Map();
|
|
271
|
+
function registryImageCacheKey(settings) {
|
|
272
|
+
return [
|
|
273
|
+
settings.modalImageRef ?? "",
|
|
274
|
+
settings.modalImageRegistrySecret ?? "",
|
|
275
|
+
settings.modalEnvironment ?? ""
|
|
276
|
+
].join("|");
|
|
277
|
+
}
|
|
278
|
+
async function ensureModalRegistryImage(settings, loadModal = defaultModalLoader) {
|
|
279
|
+
if (!settings.modalImageRegistrySecret || !settings.modalImageRef) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const key = registryImageCacheKey(settings);
|
|
283
|
+
if (resolvedRegistryImages.has(key)) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
let pending = inFlightRegistryImages.get(key);
|
|
287
|
+
if (!pending) {
|
|
288
|
+
pending = (async () => {
|
|
289
|
+
const modal = await loadModal();
|
|
290
|
+
const client = new modal.ModalClient(modalClientOptions(settings));
|
|
291
|
+
const secret = await modal.Secret.fromName(
|
|
292
|
+
settings.modalImageRegistrySecret,
|
|
293
|
+
settings.modalEnvironment ? { environment: settings.modalEnvironment } : void 0
|
|
294
|
+
);
|
|
295
|
+
const image = client.images.fromRegistry(settings.modalImageRef, secret);
|
|
296
|
+
resolvedRegistryImages.set(key, image);
|
|
297
|
+
})().finally(() => {
|
|
298
|
+
inFlightRegistryImages.delete(key);
|
|
299
|
+
});
|
|
300
|
+
inFlightRegistryImages.set(key, pending);
|
|
301
|
+
}
|
|
302
|
+
await pending;
|
|
303
|
+
}
|
|
304
|
+
function cachedModalRegistryImage(settings) {
|
|
305
|
+
if (!settings.modalImageRegistrySecret || !settings.modalImageRef) {
|
|
306
|
+
return void 0;
|
|
307
|
+
}
|
|
308
|
+
return resolvedRegistryImages.get(registryImageCacheKey(settings));
|
|
309
|
+
}
|
|
310
|
+
function resolveModalImageSelector(settings) {
|
|
311
|
+
if (!settings.modalImageRef) {
|
|
312
|
+
return void 0;
|
|
313
|
+
}
|
|
314
|
+
const registryImage = cachedModalRegistryImage(settings);
|
|
315
|
+
return registryImage ? ModalImageSelector.fromImage(registryImage) : ModalImageSelector.fromTag(settings.modalImageRef);
|
|
316
|
+
}
|
|
267
317
|
function modalClientOptions(settings) {
|
|
268
318
|
return {
|
|
269
319
|
...settings.modalTokenId ? { tokenId: settings.modalTokenId } : {},
|
|
@@ -3636,6 +3686,7 @@ export {
|
|
|
3636
3686
|
SandboxProviderUnavailableError,
|
|
3637
3687
|
modalSandboxAttributionEnvironment,
|
|
3638
3688
|
modalSandboxAttributionTags,
|
|
3689
|
+
ensureModalRegistryImage,
|
|
3639
3690
|
tagModalSandbox,
|
|
3640
3691
|
terminateModalSandboxById,
|
|
3641
3692
|
sweepModalOrphanSandboxes,
|
|
@@ -3726,4 +3777,4 @@ export {
|
|
|
3726
3777
|
collectSandboxEnvironment2 as collectSandboxEnvironment,
|
|
3727
3778
|
parseExposedPorts2 as parseExposedPorts
|
|
3728
3779
|
};
|
|
3729
|
-
//# sourceMappingURL=chunk-
|
|
3780
|
+
//# sourceMappingURL=chunk-BHA2SU3H.js.map
|