New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@codesandbox/nodebox

Package Overview
Dependencies
Maintainers
4
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codesandbox/nodebox - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

300

build/index.js

@@ -144,172 +144,2 @@ "use strict";

// ../../node_modules/.pnpm/outvariant@1.3.0/node_modules/outvariant/lib/format.js
var require_format = __commonJS({
"../../node_modules/.pnpm/outvariant@1.3.0/node_modules/outvariant/lib/format.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.format = void 0;
var POSITIONALS_EXP = /(%?)(%([sdjo]))/g;
function serializePositional(positional, flag) {
switch (flag) {
case "s":
return positional;
case "d":
case "i":
return Number(positional);
case "j":
return JSON.stringify(positional);
case "o": {
if (typeof positional === "string") {
return positional;
}
var json = JSON.stringify(positional);
if (json === "{}" || json === "[]" || /^\[object .+?\]$/.test(json)) {
return positional;
}
return json;
}
}
}
function format4(message) {
var positionals = [];
for (var _i = 1; _i < arguments.length; _i++) {
positionals[_i - 1] = arguments[_i];
}
if (positionals.length === 0) {
return message;
}
var positionalIndex = 0;
var formattedMessage = message.replace(POSITIONALS_EXP, function(match, isEscaped, _, flag) {
var positional = positionals[positionalIndex];
var value = serializePositional(positional, flag);
if (!isEscaped) {
positionalIndex++;
return value;
}
return match;
});
if (positionalIndex < positionals.length) {
formattedMessage += " " + positionals.slice(positionalIndex).join(" ");
}
formattedMessage = formattedMessage.replace(/%{2,2}/g, "%");
return formattedMessage;
}
exports.format = format4;
}
});
// ../../node_modules/.pnpm/outvariant@1.3.0/node_modules/outvariant/lib/invariant.js
var require_invariant = __commonJS({
"../../node_modules/.pnpm/outvariant@1.3.0/node_modules/outvariant/lib/invariant.js"(exports) {
"use strict";
var __extends = exports && exports.__extends || function() {
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
d2.__proto__ = b2;
} || function(d2, b2) {
for (var p in b2)
if (Object.prototype.hasOwnProperty.call(b2, p))
d2[p] = b2[p];
};
return extendStatics(d, b);
};
return function(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
}();
var __spreadArray = exports && exports.__spreadArray || function(to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.invariant = exports.createInvariantWith = exports.InvariantError = void 0;
var format_1 = require_format();
var STACK_FRAMES_TO_IGNORE = 2;
function cleanErrorStack(error) {
if (!error.stack) {
return;
}
var nextStack = error.stack.split("\n");
nextStack.splice(1, STACK_FRAMES_TO_IGNORE);
error.stack = nextStack.join("\n");
}
var InvariantError = function(_super) {
__extends(InvariantError2, _super);
function InvariantError2(message) {
var positionals = [];
for (var _i = 1; _i < arguments.length; _i++) {
positionals[_i - 1] = arguments[_i];
}
var _this = _super.call(this, message) || this;
_this.message = message;
_this.name = "Invariant Violation";
_this.message = format_1.format.apply(void 0, __spreadArray([message], positionals));
cleanErrorStack(_this);
return _this;
}
return InvariantError2;
}(Error);
exports.InvariantError = InvariantError;
function createInvariantWith(ErrorConstructor) {
var invariant4 = function(predicate, message) {
var positionals = [];
for (var _i = 2; _i < arguments.length; _i++) {
positionals[_i - 2] = arguments[_i];
}
if (!predicate) {
var resolvedMessage = format_1.format.apply(void 0, __spreadArray([message], positionals));
var isConstructor = !!ErrorConstructor.prototype.name;
var error = isConstructor ? new ErrorConstructor(resolvedMessage) : ErrorConstructor(resolvedMessage);
cleanErrorStack(error);
throw error;
}
};
return invariant4;
}
exports.createInvariantWith = createInvariantWith;
function polymorphicInvariant(ErrorClass) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
return createInvariantWith(ErrorClass).apply(void 0, args);
}
exports.invariant = createInvariantWith(InvariantError);
exports.invariant.as = polymorphicInvariant;
}
});
// ../../node_modules/.pnpm/outvariant@1.3.0/node_modules/outvariant/lib/index.js
var require_lib = __commonJS({
"../../node_modules/.pnpm/outvariant@1.3.0/node_modules/outvariant/lib/index.js"(exports) {
"use strict";
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
if (k2 === void 0)
k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() {
return m[k];
} });
} : function(o, m, k, k2) {
if (k2 === void 0)
k2 = k;
o[k2] = m[k];
});
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
for (var p in m)
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
__createBinding(exports2, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require_invariant(), exports);
__exportStar(require_format(), exports);
}
});
// ../../node_modules/.pnpm/@open-draft+deferred-promise@2.1.0/node_modules/@open-draft/deferred-promise/build/createDeferredExecutor.js

@@ -592,3 +422,3 @@ var require_createDeferredExecutor = __commonJS({

// ../../node_modules/.pnpm/strict-event-emitter@0.4.3/node_modules/strict-event-emitter/lib/index.js
var require_lib2 = __commonJS({
var require_lib = __commonJS({
"../../node_modules/.pnpm/strict-event-emitter@0.4.3/node_modules/strict-event-emitter/lib/index.js"(exports) {

@@ -635,3 +465,81 @@ "use strict";

var import_cuid = __toESM(require_cuid());
var import_outvariant = __toESM(require_lib());
// ../../node_modules/.pnpm/outvariant@1.4.0/node_modules/outvariant/lib/index.mjs
var POSITIONALS_EXP = /(%?)(%([sdjo]))/g;
function serializePositional(positional, flag) {
switch (flag) {
case "s":
return positional;
case "d":
case "i":
return Number(positional);
case "j":
return JSON.stringify(positional);
case "o": {
if (typeof positional === "string") {
return positional;
}
const json = JSON.stringify(positional);
if (json === "{}" || json === "[]" || /^\[object .+?\]$/.test(json)) {
return positional;
}
return json;
}
}
}
function format(message, ...positionals) {
if (positionals.length === 0) {
return message;
}
let positionalIndex = 0;
let formattedMessage = message.replace(
POSITIONALS_EXP,
(match, isEscaped, _, flag) => {
const positional = positionals[positionalIndex];
const value = serializePositional(positional, flag);
if (!isEscaped) {
positionalIndex++;
return value;
}
return match;
}
);
if (positionalIndex < positionals.length) {
formattedMessage += ` ${positionals.slice(positionalIndex).join(" ")}`;
}
formattedMessage = formattedMessage.replace(/%{2,2}/g, "%");
return formattedMessage;
}
var STACK_FRAMES_TO_IGNORE = 2;
function cleanErrorStack(error) {
if (!error.stack) {
return;
}
const nextStack = error.stack.split("\n");
nextStack.splice(1, STACK_FRAMES_TO_IGNORE);
error.stack = nextStack.join("\n");
}
var InvariantError = class extends Error {
constructor(message, ...positionals) {
super(message);
this.message = message;
this.name = "Invariant Violation";
this.message = format(message, ...positionals);
cleanErrorStack(this);
}
};
var invariant = (predicate, message, ...positionals) => {
if (!predicate) {
throw new InvariantError(message, ...positionals);
}
};
invariant.as = (ErrorConstructor, predicate, message, ...positionals) => {
if (!predicate) {
const isConstructor = ErrorConstructor.prototype.name != null;
const error = isConstructor ? new ErrorConstructor(format(message, positionals)) : ErrorConstructor(format(message, positionals));
throw error;
}
};
// src/messages.ts
var import_deferred_promise = __toESM(require_build());

@@ -686,3 +594,3 @@

if (data.type === "internal/handshake") {
(0, import_outvariant.invariant)(
invariant(
message.ports.length > 0,

@@ -706,3 +614,3 @@ "Failed to confirm a MessageReceiver handshake: received event has no ports"

addMessageListener() {
(0, import_outvariant.invariant)(
invariant(
this.senderPort,

@@ -744,3 +652,3 @@ "[MessageReceiver] Failed to add a message listener: sender port is not defined. Did you forget to await a handshake?"

send(event, ...data) {
(0, import_outvariant.invariant)(
invariant(
this.senderPort,

@@ -855,3 +763,2 @@ '[MessageReceiver] Failed to send a message "%j": sender port is not defined. Did you forget to await a handshake?',

// src/Nodebox.ts
var import_outvariant5 = __toESM(require_lib());
var import_deferred_promise3 = __toESM(require_build());

@@ -861,3 +768,2 @@

var import_cuid2 = __toESM(require_cuid());
var import_outvariant2 = __toESM(require_lib());
var FileSystemApi = class {

@@ -872,3 +778,3 @@ constructor(channel) {

const response = await this.channel.send("fs/readFile", { path, encoding }).catch((error) => {
throw new Error((0, import_outvariant2.format)('Failed to read file at path "%s"', path), { cause: error });
throw new Error(format('Failed to read file at path "%s"', path), { cause: error });
});

@@ -890,3 +796,3 @@ if (!response) {

await this.channel.send("fs/writeFile", { path, content, encoding, recursive }).catch((error) => {
throw new Error((0, import_outvariant2.format)('Failed to write file at path "%s"', path), { cause: error });
throw new Error(format('Failed to write file at path "%s"', path), { cause: error });
});

@@ -896,3 +802,3 @@ }

const response = await this.channel.send("fs/readdir", { path }).catch((error) => {
throw new Error((0, import_outvariant2.format)('Failed to read directory at path "%s"', path), { cause: error });
throw new Error(format('Failed to read directory at path "%s"', path), { cause: error });
});

@@ -907,3 +813,3 @@ if (!response) {

await this.channel.send("fs/mkdir", { path, recursive }).catch((error) => {
throw new Error((0, import_outvariant2.format)('Failed to make directory at path "%s"', path), { cause: error });
throw new Error(format('Failed to make directory at path "%s"', path), { cause: error });
});

@@ -913,3 +819,3 @@ }

const response = await this.channel.send("fs/stat", { path }).catch((error) => {
throw new Error((0, import_outvariant2.format)('Failed to stat file at path "%s"', path), { cause: error });
throw new Error(format('Failed to stat file at path "%s"', path), { cause: error });
});

@@ -924,3 +830,3 @@ if (!response) {

await this.channel.send("fs/rm", { path, force, recursive }).catch((error) => {
throw new Error((0, import_outvariant2.format)('Failed to remove file at path "%s"', path), { cause: error });
throw new Error(format('Failed to remove file at path "%s"', path), { cause: error });
});

@@ -945,4 +851,3 @@ }

// src/modules/shell.ts
var import_outvariant3 = __toESM(require_lib());
var import_strict_event_emitter = __toESM(require_lib2());
var import_strict_event_emitter = __toESM(require_lib());
var ShellApi = class {

@@ -996,5 +901,5 @@ constructor(channel) {

async runCommand(command, args, options = {}) {
(0, import_outvariant3.invariant)(!this.id, 'Failed to run "runCommand" on a ShellProcess: there is already a process running.');
invariant(!this.id, 'Failed to run "runCommand" on a ShellProcess: there is already a process running.');
const shellInfo = await this.channel.send("shell/runCommand", { command, args, options });
(0, import_outvariant3.invariant)(shellInfo, 'Failed to run "runCommand" on a ShellProcess: was not able to retrieve a running process.');
invariant(shellInfo, 'Failed to run "runCommand" on a ShellProcess: was not able to retrieve a running process.');
this.id = shellInfo.id;

@@ -1023,3 +928,3 @@ this.state = "running";

async kill() {
(0, import_outvariant3.invariant)(
invariant(
this.id,

@@ -1030,3 +935,3 @@ 'Failed to run "kill" on a ShellProcess: there is no process running. Did you forget to run it?'

await this.channel.send("shell/exit", { id: this.id }).catch((error) => {
throw new Error((0, import_outvariant3.format)('Failed to kill shell with ID "%s"', this.id), { cause: error });
throw new Error(format('Failed to kill shell with ID "%s"', this.id), { cause: error });
});

@@ -1038,3 +943,2 @@ this.id = void 0;

// src/modules/preview.ts
var import_outvariant4 = __toESM(require_lib());
var import_deferred_promise2 = __toESM(require_build());

@@ -1054,3 +958,3 @@ var TIMEOUT = 2e4;

new Error(
(0, import_outvariant4.format)(
format(
'Failed to look up preview information for shell ID "%s" (port: %d)',

@@ -1086,3 +990,3 @@ payload.sourceShellId,

return this.waitFor({ sourceShellId }, (data) => data.sourceShellId === sourceShellId, timeout).catch((error) => {
throw new Error((0, import_outvariant4.format)('Failed to get shell by ID "%s"', sourceShellId), { cause: error });
throw new Error(format('Failed to get shell by ID "%s"', sourceShellId), { cause: error });
});

@@ -1092,3 +996,3 @@ }

return this.waitFor({ port }, (data) => data.port === port, timeout).catch((error) => {
throw new Error((0, import_outvariant4.format)("Failed to await port %d", port), { cause: error });
throw new Error(format("Failed to await port %d", port), { cause: error });
});

@@ -1110,3 +1014,3 @@ }

__publicField(this, "previewApi", null);
(0, import_outvariant5.invariant)(
invariant(
this.options.iframe,

@@ -1128,3 +1032,3 @@ 'Failed to create a Nodebox: expected "iframe" argument to be a reference to an <iframe> element but got %j',

}
(0, import_outvariant5.invariant)(
invariant(
iframe.contentWindow,

@@ -1166,3 +1070,3 @@ "Failed to create a MessageChannel with the Nodebox iframe: no content window found"

get fs() {
(0, import_outvariant5.invariant)(
invariant(
this.isConnected,

@@ -1178,3 +1082,3 @@ 'Failed to access the File System API: consumer is not connected. Did you forget to run "connect()"?'

get shell() {
(0, import_outvariant5.invariant)(
invariant(
this.isConnected,

@@ -1190,3 +1094,3 @@ 'Failed to access the Shell API: consumer is not connected. Did you forget to run "connect()"?'

get preview() {
(0, import_outvariant5.invariant)(
invariant(
this.isConnected,

@@ -1193,0 +1097,0 @@ 'Failed to access the Preview API: consumer is not connected. Did you forget to run "connect()"?'

{
"name": "@codesandbox/nodebox",
"version": "0.1.7",
"version": "0.1.8",
"description": "Public API of Nodebox",

@@ -29,5 +29,5 @@ "main": "./build/index.js",

"dependencies": {
"outvariant": "^1.3.0",
"outvariant": "^1.4.0",
"strict-event-emitter": "^0.4.3"
}
}

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