Socket
Socket
Sign inDemoInstall

miniflare

Package Overview
Dependencies
Maintainers
1
Versions
307
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

miniflare - npm Package Compare versions

Comparing version 1.4.0 to 1.4.1

11

CHANGELOG.md
# 🚧 Changelog
## 1.4.1
### Fixes
- Fixed linking of modules with cyclic imports, allowing
[new Rust workers](https://blog.cloudflare.com/workers-rust-sdk/) to be run
with Miniflare. Closes
[issue #41](https://github.com/mrbbot/miniflare/issues/41), thanks
[@nuvanti](https://github.com/nuvanti).
- Fixed handling of `ArrayBufferView`s as `Response` bodies
## 1.4.0

@@ -4,0 +15,0 @@

4

dist/kv/do.js

@@ -94,2 +94,3 @@ "use strict";

// Delete shadow copies for each entry, and record operation in write log
// FIXME: what if previously added key in this transaction?
const deleted = await __classPrivateFieldGet(this, _DurableObjectTransaction_storage, "f").hasMany(keys);

@@ -110,2 +111,4 @@ for (const key of keys) {

// what if a transaction adding a new key commits before this commits?
// FIXME: as this can only be called outside transactions, could just run
// transaction that lists then deletes all keys
const keys = (await __classPrivateFieldGet(this, _DurableObjectTransaction_storage, "f").list()).map(({ name }) => name);

@@ -118,2 +121,3 @@ await this.delete(keys);

const direction = (options === null || options === void 0 ? void 0 : options.reverse) ? -1 : 1;
// FIXME: this doesn't include shadow copies (e.g. newly added keys)
const keys = await __classPrivateFieldGet(this, _DurableObjectTransaction_storage, "f").list({

@@ -120,0 +124,0 @@ skipMetadata: true,

@@ -31,2 +31,3 @@ /// <reference types="node" />

private _referencedPathsSizes;
private _moduleCache;
readonly extraSourceMaps: Map<string, string>;

@@ -33,0 +34,0 @@ readonly linker: ModuleLinker;

22

dist/scripts.js

@@ -77,2 +77,3 @@ "use strict";

this._referencedPathsSizes = new Map();
this._moduleCache = new Map();
this.extraSourceMaps = new Map();

@@ -95,2 +96,5 @@ this.linker = this._linker.bind(this);

const modulePath = path_1.default.resolve(path_1.default.dirname(referencingModule.identifier), specifier);
const cached = this._moduleCache.get(modulePath);
if (cached)
return cached;
// Find first matching module rule

@@ -109,5 +113,7 @@ const rule = this.moduleRules.find((rule) => rule.include.some((regexp) => modulePath.match(regexp)));

};
let result;
switch (rule.type) {
case "ESModule":
return new vm_1.default.SourceTextModule(data.toString("utf8"), moduleOptions);
result = new vm_1.default.SourceTextModule(data.toString("utf8"), moduleOptions);
break;
case "CommonJS":

@@ -124,18 +130,24 @@ // TODO: (low priority) try do this without TypeScript

this.extraSourceMaps.set(modulePath, transpiled.sourceMapText);
return new vm_1.default.SourceTextModule(transpiled.outputText, moduleOptions);
result = new vm_1.default.SourceTextModule(transpiled.outputText, moduleOptions);
break;
case "Text":
return new vm_1.default.SyntheticModule(["default"], function () {
result = new vm_1.default.SyntheticModule(["default"], function () {
this.setExport("default", data.toString("utf8"));
}, moduleOptions);
break;
case "Data":
return new vm_1.default.SyntheticModule(["default"], function () {
result = new vm_1.default.SyntheticModule(["default"], function () {
this.setExport("default", data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength));
}, moduleOptions);
break;
case "CompiledWasm":
return new vm_1.default.SyntheticModule(["default"], function () {
result = new vm_1.default.SyntheticModule(["default"], function () {
this.setExport("default", new WebAssembly.Module(data));
}, moduleOptions);
break;
default:
throw new helpers_1.MiniflareError(`${errorBase}: ${rule.type} modules are unsupported`);
}
this._moduleCache.set(modulePath, result);
return result;
}

@@ -142,0 +154,0 @@ }

{
"name": "miniflare",
"version": "1.4.0",
"version": "1.4.1",
"description": "Fun, full-featured, fully-local simulator for Cloudflare Workers",

@@ -37,3 +37,3 @@ "keywords": [

"@iarna/toml": "^2.2.5",
"@mrbbot/node-fetch": "^4.5.0",
"@mrbbot/node-fetch": "^4.6.0",
"@peculiar/webcrypto": "^1.1.4",

@@ -40,0 +40,0 @@ "chokidar": "^3.5.1",

@@ -152,2 +152,3 @@ import assert from "assert";

// Delete shadow copies for each entry, and record operation in write log
// FIXME: what if previously added key in this transaction?
const deleted = await this.#storage.hasMany(keys);

@@ -169,2 +170,4 @@ for (const key of keys) {

// what if a transaction adding a new key commits before this commits?
// FIXME: as this can only be called outside transactions, could just run
// transaction that lists then deletes all keys
const keys = (await this.#storage.list()).map(({ name }) => name);

@@ -180,2 +183,3 @@ await this.delete(keys);

const direction = options?.reverse ? -1 : 1;
// FIXME: this doesn't include shadow copies (e.g. newly added keys)
const keys = await this.#storage.list({

@@ -182,0 +186,0 @@ skipMetadata: true,

@@ -82,2 +82,3 @@ import assert from "assert";

private _referencedPathsSizes = new Map<string, number>();
private _moduleCache = new Map<string, vm.Module>();
readonly extraSourceMaps = new Map<string, string>();

@@ -118,2 +119,4 @@ readonly linker: ModuleLinker;

);
const cached = this._moduleCache.get(modulePath);
if (cached) return cached;

@@ -136,5 +139,7 @@ // Find first matching module rule

};
let result: vm.Module;
switch (rule.type) {
case "ESModule":
return new vm.SourceTextModule(data.toString("utf8"), moduleOptions);
result = new vm.SourceTextModule(data.toString("utf8"), moduleOptions);
break;
case "CommonJS":

@@ -151,5 +156,6 @@ // TODO: (low priority) try do this without TypeScript

this.extraSourceMaps.set(modulePath, transpiled.sourceMapText);
return new vm.SourceTextModule(transpiled.outputText, moduleOptions);
result = new vm.SourceTextModule(transpiled.outputText, moduleOptions);
break;
case "Text":
return new vm.SyntheticModule<{ default: string }>(
result = new vm.SyntheticModule<{ default: string }>(
["default"],

@@ -161,4 +167,5 @@ function () {

);
break;
case "Data":
return new vm.SyntheticModule<{ default: ArrayBuffer }>(
result = new vm.SyntheticModule<{ default: ArrayBuffer }>(
["default"],

@@ -176,4 +183,5 @@ function () {

);
break;
case "CompiledWasm":
return new vm.SyntheticModule<{ default: WebAssembly.Module }>(
result = new vm.SyntheticModule<{ default: WebAssembly.Module }>(
["default"],

@@ -185,2 +193,3 @@ function () {

);
break;
default:

@@ -191,3 +200,5 @@ throw new MiniflareError(

}
this._moduleCache.set(modulePath, result);
return result;
}
}

Sorry, the diff of this file is not supported yet

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