Rename browser SDK to un.js to match official naming
This commit is contained in:
parent
52b08894c6
commit
637064bf99
2 changed files with 12 additions and 10 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// Code execution sandbox functionality
|
||||
import { CODE_EXEC_URL } from "./config.js";
|
||||
import * as unsandbox from "./unsandbox.js";
|
||||
import * as un from "./un.js";
|
||||
|
||||
// Helper function to sleep/wait
|
||||
function sleep(ms) {
|
||||
|
|
@ -29,8 +29,8 @@ export async function executeCode(code, language, resultsContainer, playButton)
|
|||
language = 'python';
|
||||
}
|
||||
|
||||
// Check if unsandbox.com API is configured
|
||||
if (unsandbox.isConfigured()) {
|
||||
// Check if un.com API is configured
|
||||
if (un.isConfigured()) {
|
||||
await executeWithUnsandbox(code, language, resultsContainer);
|
||||
} else {
|
||||
await executeWithFallback(code, language, resultsContainer);
|
||||
|
|
@ -46,7 +46,7 @@ export async function executeCode(code, language, resultsContainer, playButton)
|
|||
}
|
||||
}
|
||||
|
||||
// Execute using unsandbox.com SDK (authenticated)
|
||||
// Execute using un.com SDK (authenticated)
|
||||
async function executeWithUnsandbox(code, language, resultsContainer) {
|
||||
let pollCount = 0;
|
||||
let cancelButton = null;
|
||||
|
|
@ -54,13 +54,13 @@ async function executeWithUnsandbox(code, language, resultsContainer) {
|
|||
|
||||
try {
|
||||
// Start async execution to get job_id for cancel button
|
||||
currentJobId = await unsandbox.executeAsync(language, code);
|
||||
currentJobId = await un.executeAsync(language, code);
|
||||
|
||||
// Create cancel button (shown after 3 seconds)
|
||||
cancelButton = createCancelButton(resultsContainer, async () => {
|
||||
if (currentJobId) {
|
||||
try {
|
||||
await unsandbox.cancelJob(currentJobId);
|
||||
await un.cancelJob(currentJobId);
|
||||
cancelButton.disabled = true;
|
||||
cancelButton.textContent = 'Cancelling...';
|
||||
} catch (error) {
|
||||
|
|
@ -70,7 +70,7 @@ async function executeWithUnsandbox(code, language, resultsContainer) {
|
|||
});
|
||||
|
||||
// Wait for job with progress callback
|
||||
const result = await unsandbox.waitForJob(currentJobId, null, null, (count) => {
|
||||
const result = await un.waitForJob(currentJobId, null, null, (count) => {
|
||||
pollCount = count;
|
||||
// Show cancel button after poll #5 (around 3 seconds)
|
||||
if (count >= 5 && cancelButton) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
/**
|
||||
* Unsandbox.com Browser SDK
|
||||
* Browser-compatible wrapper for unsandbox.com API
|
||||
* Based on official SDK patterns from lib/un.js
|
||||
* un.js - Unsandbox.com Browser SDK
|
||||
* Browser-compatible version of the official SDK (lib/un.js)
|
||||
* Uses Web Crypto API for HMAC-SHA256 signing
|
||||
*
|
||||
* Update Node.js SDK: make update-unsandbox-sdk
|
||||
*/
|
||||
|
||||
const API_BASE = "https://api.unsandbox.com";
|
||||
Loading…
Add table
Add a link
Reference in a new issue