jam-linux-arm64 0.9.2 → 0.9.3

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/bin/jam CHANGED
Binary file
@@ -168858,7 +168858,7 @@ class ScriptCompiler {
168858
168858
  import fs3 from "node:fs";
168859
168859
  import path3 from "node:path";
168860
168860
  import vm from "node:vm";
168861
- import { builtinModules, createRequire } from "node:module";
168861
+ import { builtinModules } from "node:module";
168862
168862
  import { fileURLToPath, pathToFileURL } from "node:url";
168863
168863
 
168864
168864
  // node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
@@ -170632,9 +170632,6 @@ class VmModuleLoader {
170632
170632
  #packageEntryCache;
170633
170633
  #jamTestModule;
170634
170634
  #jamTemplateModule;
170635
- #nativeRequire;
170636
- #nativeRequireByModulePath;
170637
- #nativeModuleIds;
170638
170635
  #bareResolveCache;
170639
170636
  constructor(context, compiler, options) {
170640
170637
  this.#context = context;
@@ -170648,9 +170645,6 @@ class VmModuleLoader {
170648
170645
  this.#packageEntryCache = new Map;
170649
170646
  this.#jamTestModule = createJamTestModule();
170650
170647
  this.#jamTemplateModule = createJamTemplateModule();
170651
- this.#nativeRequire = createRequire(import.meta.url);
170652
- this.#nativeRequireByModulePath = new Map;
170653
- this.#nativeModuleIds = new Set;
170654
170648
  this.#bareResolveCache = new Map;
170655
170649
  }
170656
170650
  loadEntrypoint(scriptPath) {
@@ -170828,27 +170822,7 @@ ${stackBody}`;
170828
170822
  let mappedColumn = typeof mapped.column === "number" ? mapped.column + 1 : 1;
170829
170823
  return `${prefix}${mappedFile}:${mapped.line}:${mappedColumn}${suffix}`;
170830
170824
  }
170831
- dispose() {
170832
- let visited = new Set;
170833
- for (let moduleId of this.#nativeModuleIds) {
170834
- this.evictNativeModule(moduleId, visited);
170835
- }
170836
- this.#nativeModuleIds.clear();
170837
- }
170838
- evictNativeModule(moduleId, visited) {
170839
- if (!moduleId || visited.has(moduleId)) {
170840
- return;
170841
- }
170842
- visited.add(moduleId);
170843
- let cached = this.#nativeRequire.cache[moduleId];
170844
- if (!cached) {
170845
- return;
170846
- }
170847
- for (let child of cached.children || []) {
170848
- this.evictNativeModule(child.id, visited);
170849
- }
170850
- delete this.#nativeRequire.cache[moduleId];
170851
- }
170825
+ dispose() {}
170852
170826
  requireFrom(specifier, modulePath, moduleDir) {
170853
170827
  try {
170854
170828
  if (specifier === "jam:test") {
@@ -171024,21 +170998,15 @@ ${stackBody}`;
171024
170998
  });
171025
170999
  }
171026
171000
  if (!resolved.startsWith("file://")) {
171027
- let nativeRequire2 = this.getNativeRequire(modulePath);
171028
- return nativeRequire2(specifier);
171001
+ throw new ModuleLoaderError("resolve", `Could not resolve bare module "${specifier}" from "${modulePath}": ` + `unsupported resolution target "${resolved}".`);
171029
171002
  }
171030
171003
  let resolvedPath = fileURLToPath(resolved);
171031
171004
  let extension = path3.extname(resolvedPath).toLowerCase();
171032
171005
  if (extension === "" || SCRIPT_EXTENSIONS.includes(extension)) {
171033
- let loaded2 = this.loadModule(resolvedPath);
171034
- return loaded2;
171006
+ let loaded = this.loadModule(resolvedPath);
171007
+ return loaded;
171035
171008
  }
171036
- let nativeRequire = this.getNativeRequire(modulePath);
171037
- let loaded = nativeRequire(resolvedPath);
171038
- if (!resolvedPath.startsWith("node:") && path3.isAbsolute(resolvedPath)) {
171039
- this.#nativeModuleIds.add(resolvedPath);
171040
- }
171041
- return loaded;
171009
+ throw new ModuleLoaderError("resolve", `Could not resolve bare module "${specifier}" from "${modulePath}": ` + `resolved file type "${extension}" is not supported.`);
171042
171010
  }
171043
171011
  resolveBareSpecifier(specifier, modulePath) {
171044
171012
  let cacheKey = `${modulePath}\x00${specifier}`;
@@ -171120,15 +171088,6 @@ ${stackBody}`;
171120
171088
  isNodeBuiltinSpecifier(specifier) {
171121
171089
  return NODE_BUILTINS.has(specifier);
171122
171090
  }
171123
- getNativeRequire(modulePath) {
171124
- let cached = this.#nativeRequireByModulePath.get(modulePath);
171125
- if (cached) {
171126
- return cached;
171127
- }
171128
- let created = createRequire(modulePath);
171129
- this.#nativeRequireByModulePath.set(modulePath, created);
171130
- return created;
171131
- }
171132
171091
  assertPathInsideRoot(targetPath, specifier, importer, attempts) {
171133
171092
  let absolute = path3.resolve(targetPath);
171134
171093
  attempts.push(absolute);
@@ -171218,7 +171177,8 @@ function extractPhpEnvValues(payload) {
171218
171177
  }
171219
171178
  function parseUrlEncodedPhpPost(rawBody) {
171220
171179
  let values = {};
171221
- let decoded = new URLSearchParams(rawBody.toString("utf8"));
171180
+ let decoder = new TextDecoder("utf-8");
171181
+ let decoded = new URLSearchParams(decoder.decode(rawBody));
171222
171182
  for (let [key, value] of decoded.entries()) {
171223
171183
  if (!(key in values)) {
171224
171184
  values[key] = value;
@@ -171358,7 +171318,7 @@ function buildRequest(message) {
171358
171318
  }
171359
171319
  let requestUrl = `${protocol}://${host}${pathWithQuery}`;
171360
171320
  let bodyBytes = message.body instanceof Uint8Array ? message.body : new Uint8Array(0);
171361
- let rawBody = Buffer.from(bodyBytes.buffer, bodyBytes.byteOffset, bodyBytes.byteLength);
171321
+ let rawBody = bodyBytes;
171362
171322
  let requestBody;
171363
171323
  if (bodyBytes.byteLength > 0 && method !== "GET" && method !== "HEAD") {
171364
171324
  requestBody = bodyBytes;
@@ -171401,6 +171361,22 @@ function nextFormDataBoundary() {
171401
171361
  function escapeFormDataString(value) {
171402
171362
  return String(value).replaceAll("\\", "\\\\").replaceAll('"', "\\\"");
171403
171363
  }
171364
+ function decodeBase64ToBytes(base64Value) {
171365
+ let normalized = String(base64Value || "").trim();
171366
+ if (normalized === "") {
171367
+ return new Uint8Array(0);
171368
+ }
171369
+ let binary = atob(normalized);
171370
+ let bytes = new Uint8Array(binary.length);
171371
+ for (let i = 0;i < binary.length; i += 1) {
171372
+ bytes[i] = binary.charCodeAt(i) & 255;
171373
+ }
171374
+ return bytes;
171375
+ }
171376
+ function encodeUtf8(value) {
171377
+ let encoder = new TextEncoder;
171378
+ return encoder.encode(value);
171379
+ }
171404
171380
  function encodeFormDataBody(formData, boundary) {
171405
171381
  let lines = [];
171406
171382
  for (let [name, value] of formData.entries()) {
@@ -171425,7 +171401,7 @@ function encodeFormDataBody(formData, boundary) {
171425
171401
  `);
171426
171402
  }
171427
171403
  lines.push(`--${boundary}--`);
171428
- return Buffer.from(lines.join(""), "utf8");
171404
+ return encodeUtf8(lines.join(""));
171429
171405
  }
171430
171406
  function isAbsoluteURL(value) {
171431
171407
  if (typeof value !== "string") {
@@ -171477,7 +171453,7 @@ function buildFetchStubResponse(stub) {
171477
171453
  }
171478
171454
  let body;
171479
171455
  if (typeof stub.bodyBase64 === "string" && stub.bodyBase64.trim() !== "") {
171480
- body = Buffer.from(stub.bodyBase64, "base64");
171456
+ body = decodeBase64ToBytes(stub.bodyBase64);
171481
171457
  } else {
171482
171458
  body = String(stub.body || "");
171483
171459
  }
@@ -171850,8 +171826,7 @@ function createExecutionContext(payload, requestURL) {
171850
171826
  btoa,
171851
171827
  crypto: cryptoCompat,
171852
171828
  performance: performanceFacade,
171853
- structuredClone,
171854
- Buffer
171829
+ structuredClone
171855
171830
  };
171856
171831
  sandbox.globalThis = sandbox;
171857
171832
  sandbox.global = sandbox;
@@ -171888,7 +171863,10 @@ async function executeScript(compiler, sharedResolutionCache, payload) {
171888
171863
  return {
171889
171864
  status: templateResult.status || 200,
171890
171865
  headers,
171891
- body: Buffer.from(templateResult.body)
171866
+ response: new Response(templateResult.body, {
171867
+ status: templateResult.status || 200,
171868
+ headers: templateResult.headers
171869
+ })
171892
171870
  };
171893
171871
  }
171894
171872
  let phpGlobals = await buildPhpGlobals(payload, builtRequest.request, builtRequest.rawBody);
@@ -171921,11 +171899,10 @@ async function executeScript(compiler, sharedResolutionCache, payload) {
171921
171899
  }
171922
171900
  headers[name].push(value);
171923
171901
  }
171924
- let body = new Uint8Array(await response.arrayBuffer());
171925
171902
  return {
171926
171903
  status: response.status || 200,
171927
171904
  headers,
171928
- body
171905
+ response
171929
171906
  };
171930
171907
  } catch (error) {
171931
171908
  if (!(error instanceof ModuleLoaderError)) {
@@ -171991,6 +171968,25 @@ class SharedResolutionCache {
171991
171968
  var compiler = new ScriptCompiler;
171992
171969
  var sharedResolutionCache = new SharedResolutionCache;
171993
171970
  var workerThreadState = { started: false };
171971
+ function getMemoryUsageBytes() {
171972
+ return process.memoryUsage().heapUsed;
171973
+ }
171974
+ function normalizeChunkBytes(chunk) {
171975
+ if (chunk.byteOffset === 0 && chunk.byteLength === chunk.buffer.byteLength) {
171976
+ return chunk;
171977
+ }
171978
+ return chunk.slice();
171979
+ }
171980
+ function postMessage(message, transferList = []) {
171981
+ if (!parentPort) {
171982
+ return;
171983
+ }
171984
+ if (transferList.length > 0) {
171985
+ parentPort.postMessage(message, transferList);
171986
+ return;
171987
+ }
171988
+ parentPort.postMessage(message);
171989
+ }
171994
171990
  function startWorkerThread() {
171995
171991
  if (workerThreadState.started) {
171996
171992
  return;
@@ -172005,24 +172001,63 @@ function startWorkerThread() {
172005
172001
  }
172006
172002
  try {
172007
172003
  let result = await executeScript(compiler, sharedResolutionCache, message.payload);
172008
- let response = {
172004
+ let startMessage = {
172005
+ type: "response-start",
172009
172006
  id: message.id,
172010
- ok: true,
172011
- result,
172012
- memoryUsageBytes: process.memoryUsage().heapUsed
172007
+ status: result.status,
172008
+ headers: result.headers,
172009
+ memoryUsageBytes: getMemoryUsageBytes()
172013
172010
  };
172014
- parentPort.postMessage(response, [result.body.buffer]);
172011
+ postMessage(startMessage);
172012
+ if (!result.response.body) {
172013
+ let endMessage2 = {
172014
+ type: "response-end",
172015
+ id: message.id,
172016
+ memoryUsageBytes: getMemoryUsageBytes()
172017
+ };
172018
+ postMessage(endMessage2);
172019
+ return;
172020
+ }
172021
+ let reader = result.response.body.getReader();
172022
+ try {
172023
+ while (true) {
172024
+ let { done, value } = await reader.read();
172025
+ if (done) {
172026
+ break;
172027
+ }
172028
+ let rawChunk = value || new Uint8Array(0);
172029
+ if (rawChunk.byteLength === 0) {
172030
+ continue;
172031
+ }
172032
+ let chunk = normalizeChunkBytes(rawChunk);
172033
+ let chunkMessage = {
172034
+ type: "response-chunk",
172035
+ id: message.id,
172036
+ chunk,
172037
+ memoryUsageBytes: getMemoryUsageBytes()
172038
+ };
172039
+ postMessage(chunkMessage, [chunk.buffer]);
172040
+ }
172041
+ } finally {
172042
+ reader.releaseLock();
172043
+ }
172044
+ let endMessage = {
172045
+ type: "response-end",
172046
+ id: message.id,
172047
+ memoryUsageBytes: getMemoryUsageBytes()
172048
+ };
172049
+ postMessage(endMessage);
172015
172050
  } catch (error) {
172016
172051
  let response = {
172052
+ type: "response-error",
172017
172053
  id: message.id,
172018
- ok: false,
172019
172054
  error: {
172020
172055
  message: error instanceof Error ? error.message : String(error),
172021
172056
  stack: error instanceof Error ? error.stack : undefined
172022
172057
  },
172023
- memoryUsageBytes: process.memoryUsage().heapUsed
172058
+ memoryUsageBytes: getMemoryUsageBytes()
172024
172059
  };
172025
- parentPort.postMessage(response);
172060
+ postMessage(response);
172026
172061
  }
172027
172062
  });
172028
172063
  }
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "jam-linux-arm64",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "Linux arm64 binary for jam",
5
5
  "license": "MIT",
6
+ "author": "Michael Jackson <mjijackson@gmail.com>",
6
7
  "type": "module",
7
8
  "repository": {
8
9
  "type": "git",