knitting 0.1.54 → 0.1.56
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/README.md +3 -3
- package/knitting.d.ts +2 -1
- package/knitting.js +2 -1
- package/map.md +12 -11
- package/package.json +15 -6
- package/shared-memory.d.ts +1 -0
- package/shared-memory.js +1 -0
- package/src/api.js +1 -9
- package/src/connections/node-addons.js +4 -3
- package/src/connections/numeric-array.d.ts +5 -0
- package/src/connections/numeric-array.js +17 -0
- package/src/connections/package-assets.d.ts +2 -0
- package/src/connections/package-assets.js +45 -0
- package/src/connections/windows.js +2 -2
- package/src/memory/lock.d.ts +3 -1
- package/src/memory/lock.js +2 -0
- package/src/memory/payloadCodec.js +43 -0
- package/src/worker/loop.js +1 -1
- package/src/worker/task-loader.js +1 -9
package/README.md
CHANGED
|
@@ -667,7 +667,7 @@ copying the whole payload for every call.
|
|
|
667
667
|
import {
|
|
668
668
|
getDefaultProcessSharedBufferPrimitives,
|
|
669
669
|
ProcessSharedBuffer,
|
|
670
|
-
} from "knitting/
|
|
670
|
+
} from "knitting/shared-memory";
|
|
671
671
|
import { createPool, isMain, task } from "knitting";
|
|
672
672
|
|
|
673
673
|
export const readFirstCell = task<ProcessSharedBuffer, number>({
|
|
@@ -712,7 +712,7 @@ name; the other opens that same name.
|
|
|
712
712
|
import {
|
|
713
713
|
getDefaultProcessSharedBufferPrimitives,
|
|
714
714
|
ProcessSharedBuffer,
|
|
715
|
-
} from "knitting/
|
|
715
|
+
} from "knitting/shared-memory";
|
|
716
716
|
|
|
717
717
|
const name = "knitting-demo-channel";
|
|
718
718
|
const primitives = getDefaultProcessSharedBufferPrimitives();
|
|
@@ -761,7 +761,7 @@ import { createPool, isMain, task } from "knitting";
|
|
|
761
761
|
import {
|
|
762
762
|
getDefaultProcessSharedBufferPrimitives,
|
|
763
763
|
ProcessSharedBuffer,
|
|
764
|
-
} from "knitting/
|
|
764
|
+
} from "knitting/shared-memory";
|
|
765
765
|
|
|
766
766
|
export const readCounter = task<ProcessSharedBuffer, number>({
|
|
767
767
|
f: (shared) => Atomics.load(shared.view(Int32Array), 0),
|
package/knitting.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { workerMainLoop } from "./src/worker/loop.js";
|
|
2
2
|
import { createPool, importTask, isMain, task } from "./src/api.js";
|
|
3
3
|
import { Envelope } from "./src/common/envelope.js";
|
|
4
|
-
|
|
4
|
+
import { isNumericArray, NumericArray } from "./src/connections/numeric-array.js";
|
|
5
|
+
export { createPool as createPool, Envelope as Envelope, importTask as importTask, isMain as isMain, isNumericArray as isNumericArray, NumericArray as NumericArray, task as task, workerMainLoop as workerMainLoop, };
|
|
5
6
|
export type { EnvelopeBody as EnvelopeBody, EnvelopeHeader as EnvelopeHeader, } from "./src/common/envelope.js";
|
package/knitting.js
CHANGED
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
import { workerMainLoop } from "./src/worker/loop.js";
|
|
3
3
|
import { createPool, importTask, isMain, task } from "./src/api.js";
|
|
4
4
|
import { Envelope } from "./src/common/envelope.js";
|
|
5
|
-
|
|
5
|
+
import { isNumericArray, NumericArray } from "./src/connections/numeric-array.js";
|
|
6
|
+
export { createPool as createPool, Envelope as Envelope, importTask as importTask, isMain as isMain, isNumericArray as isNumericArray, NumericArray as NumericArray, task as task, workerMainLoop as workerMainLoop, };
|
package/map.md
CHANGED
|
@@ -18,8 +18,10 @@ The core flow is:
|
|
|
18
18
|
|
|
19
19
|
- `knitting.ts`: Main package entry. Re-exports `createPool`, `task`,
|
|
20
20
|
`importTask`, `isMain`, `Envelope`, and `workerMainLoop`.
|
|
21
|
-
- `
|
|
21
|
+
- `shared-memory.ts`: Secondary public export for process-safe shared-memory
|
|
22
22
|
helpers.
|
|
23
|
+
- `process-shared-buffer.ts`: Backward-compatible alias for the shared-memory
|
|
24
|
+
public export.
|
|
23
25
|
- `unsafe.ts`: Public export for experimental lower-level capabilities such as
|
|
24
26
|
`BufferReference`.
|
|
25
27
|
- `utils.ts`: Public export for request/response buffer conversion helpers.
|
|
@@ -34,11 +36,11 @@ The core flow is:
|
|
|
34
36
|
|
|
35
37
|
## Build And Scripts
|
|
36
38
|
|
|
37
|
-
- `build.ts`:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
- `scripts/rewrite-declaration-imports.mjs`:
|
|
41
|
-
|
|
39
|
+
- `build.ts`: Cleans generated npm artifacts, then compiles public entries and
|
|
40
|
+
`src/**/*.ts` to `.js` and `.d.ts` files with TypeScript.
|
|
41
|
+
- `tsconfig.npm.json`: TypeScript config used by the npm release build.
|
|
42
|
+
- `scripts/rewrite-declaration-imports.mjs`: Rewrites generated declaration
|
|
43
|
+
imports from `.ts` to `.js` so npm consumers resolve the compiled files.
|
|
42
44
|
- `scripts/build-native-addons.ts`: Compiles the native Node addons into
|
|
43
45
|
`build/Release/` on Linux, macOS, and Windows. It finds Node headers/libs,
|
|
44
46
|
splits user flags, builds the shared-memory and futex addons, and emits the
|
|
@@ -309,12 +311,11 @@ The core flow is:
|
|
|
309
311
|
|
|
310
312
|
- `build/Release/*.node`: Native addon output produced by
|
|
311
313
|
`scripts/build-native-addons.ts`.
|
|
312
|
-
- `out/`: Bundled output produced by `build.ts`.
|
|
313
|
-
- `dest/`: Scratch output used by the `build:node` package script.
|
|
314
314
|
- `knitting.js`, `knitting.d.ts`, `process-shared-buffer.js`,
|
|
315
|
-
`process-shared-buffer.d.ts`,
|
|
316
|
-
|
|
315
|
+
`process-shared-buffer.d.ts`, `shared-memory.js`, `shared-memory.d.ts`,
|
|
316
|
+
`unsafe.js`, `unsafe.d.ts`, `utils.js`, `utils.d.ts`, and generated
|
|
317
|
+
`src/**/*.js`/`src/**/*.d.ts`: npm release build artifacts produced by
|
|
318
|
+
`build.ts` and `scripts/rewrite-declaration-imports.mjs`.
|
|
317
319
|
- `results/`: Benchmark output produced by `run.sh`.
|
|
318
320
|
- `log/`, `logs`, and `*.log`: Local runtime/log output.
|
|
319
321
|
- `node_modules/`: Installed dependencies. Not part of the source map.
|
|
320
|
-
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knitting",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.56",
|
|
4
4
|
"description": "Shared-memory IPC runtime for Node.js, Deno, and Bun.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
"types": "./process-shared-buffer.d.ts",
|
|
25
25
|
"default": "./process-shared-buffer.js"
|
|
26
26
|
},
|
|
27
|
+
"./shared-memory": {
|
|
28
|
+
"types": "./shared-memory.d.ts",
|
|
29
|
+
"default": "./shared-memory.js"
|
|
30
|
+
},
|
|
27
31
|
"./unsafe": {
|
|
28
32
|
"types": "./unsafe.d.ts",
|
|
29
33
|
"default": "./unsafe.js"
|
|
@@ -47,18 +51,22 @@
|
|
|
47
51
|
"knitting.js",
|
|
48
52
|
"process-shared-buffer.d.ts",
|
|
49
53
|
"process-shared-buffer.js",
|
|
54
|
+
"shared-memory.d.ts",
|
|
55
|
+
"shared-memory.js",
|
|
50
56
|
"unsafe.d.ts",
|
|
51
57
|
"unsafe.js",
|
|
52
58
|
"utils.d.ts",
|
|
53
59
|
"utils.js"
|
|
54
60
|
],
|
|
55
61
|
"scripts": {
|
|
56
|
-
"build": "bun run build.ts",
|
|
57
|
-
"build:
|
|
62
|
+
"build": "bun run build.ts && node scripts/rewrite-declaration-imports.mjs",
|
|
63
|
+
"build:js": "bun run build.ts && node scripts/rewrite-declaration-imports.mjs",
|
|
64
|
+
"build:types": "bun run build.ts && node scripts/rewrite-declaration-imports.mjs",
|
|
65
|
+
"build:npm": "bun run build.ts && node scripts/rewrite-declaration-imports.mjs",
|
|
58
66
|
"build:native": "bun run scripts/build-native-addons.ts",
|
|
59
|
-
"build:release": "bun run build:native &&
|
|
60
|
-
"build:node": "bun build
|
|
61
|
-
"prepack": "npm run build
|
|
67
|
+
"build:release": "bun run build:native && npm run build",
|
|
68
|
+
"build:node": "bun run build.ts && node scripts/rewrite-declaration-imports.mjs",
|
|
69
|
+
"prepack": "npm run build",
|
|
62
70
|
"release:npm": "npm run test:all && npm publish",
|
|
63
71
|
"release:npm:dry-run": "npm publish --dry-run",
|
|
64
72
|
"test": "npm run test:deno",
|
|
@@ -84,6 +92,7 @@
|
|
|
84
92
|
"@types/bun": "latest",
|
|
85
93
|
"@types/deno": "latest",
|
|
86
94
|
"@types/node": "latest",
|
|
95
|
+
"dts-bundle-generator": "^9.5.1",
|
|
87
96
|
"mitata": "^1.0.34",
|
|
88
97
|
"typescript": "^5.2.0"
|
|
89
98
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getDefaultProcessSharedBufferPrimitives, parseProcessSharedBufferMetadata, PROCESS_SHARED_BUFFER_BRAND, ProcessSharedBuffer, setDefaultProcessSharedBufferPrimitives, type ProcessSharedBufferCreator, type ProcessSharedBufferMapper, type ProcessSharedBufferMetadata, type ProcessSharedBufferPrimitives, type ProcessSharedBufferRange, type ProcessSharedBufferView, type ProcessSharedBufferViewConstructor, } from "./src/connections/process-shared-buffer.js";
|
package/shared-memory.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getDefaultProcessSharedBufferPrimitives, parseProcessSharedBufferMetadata, PROCESS_SHARED_BUFFER_BRAND, ProcessSharedBuffer, setDefaultProcessSharedBufferPrimitives, } from "./src/connections/process-shared-buffer.js";
|
package/src/api.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
-
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
-
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
-
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
return path;
|
|
8
|
-
};
|
|
9
1
|
import { getCallerFilePath, getCallerHref } from "./common/task-source.js";
|
|
10
2
|
import { DEBUG_ENABLED, resolveDebugNamespaces } from "./debug/gate.js";
|
|
11
3
|
import { genTaskID } from "./common/task-source.js";
|
|
@@ -592,7 +584,7 @@ const createImportedTaskFn = (href, exportName) => {
|
|
|
592
584
|
if (cachedFn)
|
|
593
585
|
return cachedFn;
|
|
594
586
|
if (!cachedLoad) {
|
|
595
|
-
cachedLoad = import(
|
|
587
|
+
cachedLoad = import(href).then((module) => {
|
|
596
588
|
const record = module;
|
|
597
589
|
const selected = exportName === DEFAULT_IMPORT_EXPORT_NAME
|
|
598
590
|
? record.default
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolveKnittingPackageAsset } from "./package-assets.js";
|
|
1
2
|
const readNodePlatformInfo = () => {
|
|
2
3
|
const processLike = globalThis.process;
|
|
3
4
|
if (typeof processLike?.platform !== "string" ||
|
|
@@ -12,18 +13,18 @@ const readNodePlatformInfo = () => {
|
|
|
12
13
|
};
|
|
13
14
|
export const nodeNativeAddonSpecifiers = (name) => {
|
|
14
15
|
const platformInfo = readNodePlatformInfo();
|
|
15
|
-
const fallback =
|
|
16
|
+
const fallback = resolveKnittingPackageAsset("build", "Release", `${name}.node`);
|
|
16
17
|
if (platformInfo === undefined)
|
|
17
18
|
return [fallback];
|
|
18
19
|
const nodeModuleAbi = platformInfo.modules;
|
|
19
20
|
if (typeof nodeModuleAbi === "string" && nodeModuleAbi.length > 0) {
|
|
20
21
|
return [
|
|
21
|
-
|
|
22
|
+
resolveKnittingPackageAsset("prebuilds", `${platformInfo.platform}-${platformInfo.arch}-node-${nodeModuleAbi}`, `${name}.node`),
|
|
22
23
|
fallback,
|
|
23
24
|
];
|
|
24
25
|
}
|
|
25
26
|
return [
|
|
26
|
-
|
|
27
|
+
resolveKnittingPackageAsset("prebuilds", `${platformInfo.platform}-${platformInfo.arch}`, `${name}.node`),
|
|
27
28
|
fallback,
|
|
28
29
|
];
|
|
29
30
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const NUMERIC_ARRAY_BRAND: unique symbol;
|
|
2
|
+
export declare class NumericArray extends Array<number> {
|
|
3
|
+
}
|
|
4
|
+
export declare const isNumericArray: (value: object) => value is NumericArray;
|
|
5
|
+
export declare const numericArrayFromFloat64: (view: Float64Array) => NumericArray;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const NUMERIC_ARRAY_BRAND = Symbol.for("knitting.numericArray");
|
|
2
|
+
export class NumericArray extends Array {
|
|
3
|
+
}
|
|
4
|
+
Object.defineProperty(NumericArray.prototype, NUMERIC_ARRAY_BRAND, {
|
|
5
|
+
value: true,
|
|
6
|
+
enumerable: false,
|
|
7
|
+
writable: false,
|
|
8
|
+
configurable: false,
|
|
9
|
+
});
|
|
10
|
+
export const isNumericArray = (value) => value[NUMERIC_ARRAY_BRAND] === true;
|
|
11
|
+
export const numericArrayFromFloat64 = (view) => {
|
|
12
|
+
const length = view.length;
|
|
13
|
+
const out = new NumericArray(length);
|
|
14
|
+
for (let i = 0; i < length; i++)
|
|
15
|
+
out[i] = view[i];
|
|
16
|
+
return out;
|
|
17
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { existsSync, statSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
const safeExists = (path) => {
|
|
5
|
+
try {
|
|
6
|
+
return existsSync(path);
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const safeIsDirectory = (path) => {
|
|
13
|
+
try {
|
|
14
|
+
return statSync(path).isDirectory();
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const moduleDirectory = (moduleUrl) => {
|
|
21
|
+
const path = fileURLToPath(moduleUrl);
|
|
22
|
+
return safeIsDirectory(path) ? path : dirname(path);
|
|
23
|
+
};
|
|
24
|
+
const isKnittingPackageRoot = (dir) => safeExists(join(dir, "package.json")) &&
|
|
25
|
+
(safeExists(join(dir, "prebuilds")) ||
|
|
26
|
+
safeExists(join(dir, "src")) ||
|
|
27
|
+
safeExists(join(dir, "build")));
|
|
28
|
+
let cachedPackageRoot;
|
|
29
|
+
export const findKnittingPackageRoot = (moduleUrl = import.meta.url) => {
|
|
30
|
+
if (cachedPackageRoot !== undefined)
|
|
31
|
+
return cachedPackageRoot;
|
|
32
|
+
let current = moduleDirectory(moduleUrl);
|
|
33
|
+
while (true) {
|
|
34
|
+
if (isKnittingPackageRoot(current)) {
|
|
35
|
+
cachedPackageRoot = current;
|
|
36
|
+
return current;
|
|
37
|
+
}
|
|
38
|
+
const parent = dirname(current);
|
|
39
|
+
if (parent === current) {
|
|
40
|
+
throw new Error(`Could not locate knitting package root from ${moduleUrl}`);
|
|
41
|
+
}
|
|
42
|
+
current = parent;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export const resolveKnittingPackageAsset = (...segments) => join(findKnittingPackageRoot(), ...segments);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveKnittingPackageAsset } from "./package-assets.js";
|
|
2
2
|
import { expectFd, expectPositiveSize, readCreateMode, readCreateSize, readRequiredCreateName, } from "./types.js";
|
|
3
3
|
const WINDOWS_CREATE_MODE_CREATE = 1;
|
|
4
4
|
const WINDOWS_CREATE_MODE_OPEN = 2;
|
|
@@ -45,7 +45,7 @@ const windowsArch = () => {
|
|
|
45
45
|
return processArch;
|
|
46
46
|
throw new Error("Windows shared memory prebuilds support x64 only");
|
|
47
47
|
};
|
|
48
|
-
export const windowsSharedMemoryPrebuildPath = () =>
|
|
48
|
+
export const windowsSharedMemoryPrebuildPath = () => resolveKnittingPackageAsset("prebuilds", `win32-${windowsArch()}`, "knitting_windows_shared_memory.dll");
|
|
49
49
|
export const makeWindowsAnonymousSharedMemoryName = (runtime) => {
|
|
50
50
|
const processId = globalThis.process?.pid ??
|
|
51
51
|
globalThis.Deno?.pid ??
|
package/src/memory/lock.d.ts
CHANGED
|
@@ -55,7 +55,9 @@ export declare enum PayloadBuffer {
|
|
|
55
55
|
EnvelopeStaticHeaderExternal = 49,
|
|
56
56
|
EnvelopeDynamicHeaderExternal = 50,
|
|
57
57
|
EnvelopeStaticHeaderStringExternal = 51,
|
|
58
|
-
EnvelopeDynamicHeaderStringExternal = 52
|
|
58
|
+
EnvelopeDynamicHeaderStringExternal = 52,
|
|
59
|
+
NumericArray = 53,
|
|
60
|
+
StaticNumericArray = 54
|
|
59
61
|
}
|
|
60
62
|
export declare enum LockBound {
|
|
61
63
|
paddingLock = 0,
|
package/src/memory/lock.js
CHANGED
|
@@ -60,6 +60,8 @@ export var PayloadBuffer;
|
|
|
60
60
|
PayloadBuffer[PayloadBuffer["EnvelopeDynamicHeaderExternal"] = 50] = "EnvelopeDynamicHeaderExternal";
|
|
61
61
|
PayloadBuffer[PayloadBuffer["EnvelopeStaticHeaderStringExternal"] = 51] = "EnvelopeStaticHeaderStringExternal";
|
|
62
62
|
PayloadBuffer[PayloadBuffer["EnvelopeDynamicHeaderStringExternal"] = 52] = "EnvelopeDynamicHeaderStringExternal";
|
|
63
|
+
PayloadBuffer[PayloadBuffer["NumericArray"] = 53] = "NumericArray";
|
|
64
|
+
PayloadBuffer[PayloadBuffer["StaticNumericArray"] = 54] = "StaticNumericArray";
|
|
63
65
|
})(PayloadBuffer || (PayloadBuffer = {}));
|
|
64
66
|
export var LockBound;
|
|
65
67
|
(function (LockBound) {
|
|
@@ -6,6 +6,7 @@ import { encoderError, ErrorKnitting } from "../error.js";
|
|
|
6
6
|
import { Envelope } from "../common/envelope.js";
|
|
7
7
|
import { resolvePayloadBufferOptions, } from "./payload-config.js";
|
|
8
8
|
import { getSharedArrayBufferPayload, SHARED_ARRAY_BUFFER_CODEC_ID, SHARED_ARRAY_BUFFER_NUMERIC_TRANSFER, SHARED_ARRAY_BUFFER_NUMERIC_WORDS, } from "../connections/shared-array-buffer-payload.js";
|
|
9
|
+
import { isNumericArray, numericArrayFromFloat64, } from "../connections/numeric-array.js";
|
|
9
10
|
const BUFFER_REFERENCE_NUMERIC_TRANSFER = Symbol.for("knitting.bufferReference.numericTransfer");
|
|
10
11
|
const memory = new ArrayBuffer(8);
|
|
11
12
|
const Float64View = new Float64Array(memory);
|
|
@@ -499,6 +500,37 @@ export const encodePayload = ({ lockSector, payload, sab, payloadConfig, headers
|
|
|
499
500
|
task.value = null;
|
|
500
501
|
return true;
|
|
501
502
|
};
|
|
503
|
+
let numericArrayScratch = new Float64Array(0);
|
|
504
|
+
const encodeObjectNumericArray = (task, slotIndex, numericArray) => {
|
|
505
|
+
const length = numericArray.length;
|
|
506
|
+
if (numericArrayScratch.length < length) {
|
|
507
|
+
numericArrayScratch = new Float64Array(length);
|
|
508
|
+
}
|
|
509
|
+
for (let i = 0; i < length; i++)
|
|
510
|
+
numericArrayScratch[i] = numericArray[i];
|
|
511
|
+
const float64 = numericArrayScratch.subarray(0, length);
|
|
512
|
+
const bytes = float64.byteLength;
|
|
513
|
+
if (bytes <= staticMaxBytes) {
|
|
514
|
+
const written = writeStatic8Binary(float64, slotIndex);
|
|
515
|
+
if (written !== -1) {
|
|
516
|
+
task[TaskIndex.Type] = PayloadBuffer.StaticNumericArray;
|
|
517
|
+
task[TaskIndex.PayloadLen] = written;
|
|
518
|
+
task.value = null;
|
|
519
|
+
return true;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
task[TaskIndex.Type] = PayloadBuffer.NumericArray;
|
|
523
|
+
if (!ensureWithinDynamicLimit(task, bytes, "NumericArray"))
|
|
524
|
+
return false;
|
|
525
|
+
const reservedSlot = reserveDynamicObject(task, bytes);
|
|
526
|
+
const written = writeDynamic8Binary(float64, task[TaskIndex.Start]);
|
|
527
|
+
if (written < 0)
|
|
528
|
+
return failDynamicWriteAfterReserve(task, reservedSlot);
|
|
529
|
+
task[TaskIndex.PayloadLen] = written;
|
|
530
|
+
setSlotLength(reservedSlot, written);
|
|
531
|
+
task.value = null;
|
|
532
|
+
return true;
|
|
533
|
+
};
|
|
502
534
|
const encodeObjectArrayBuffer = (task, slotIndex, arrayBuffer) => {
|
|
503
535
|
const bytes = arrayBuffer.byteLength;
|
|
504
536
|
if (bytes <= staticMaxBytes) {
|
|
@@ -921,6 +953,9 @@ export const encodePayload = ({ lockSector, payload, sab, payloadConfig, headers
|
|
|
921
953
|
if (isRuntimeUint8Array(objectValue)) {
|
|
922
954
|
return encodeObjectUint8Array(task, slotIndex, objectValue);
|
|
923
955
|
}
|
|
956
|
+
if (arrayIsArray(objectValue) && isNumericArray(objectValue)) {
|
|
957
|
+
return encodeObjectNumericArray(task, slotIndex, objectValue);
|
|
958
|
+
}
|
|
924
959
|
if (arrayIsArray(objectValue) ||
|
|
925
960
|
objectProto === objectPrototype ||
|
|
926
961
|
objectProto === null) {
|
|
@@ -1247,6 +1282,14 @@ export const decodePayload = ({ lockSector, payload, sab, payloadConfig, headers
|
|
|
1247
1282
|
case PayloadBuffer.StaticFloat64Array:
|
|
1248
1283
|
task.value = readStatic8BytesFloatCopy(0, task[TaskIndex.PayloadLen], slotIndex);
|
|
1249
1284
|
return;
|
|
1285
|
+
case PayloadBuffer.NumericArray: {
|
|
1286
|
+
task.value = numericArrayFromFloat64(readDynamic8BytesFloatView(task[TaskIndex.Start], task[TaskIndex.Start] + task[TaskIndex.PayloadLen]));
|
|
1287
|
+
freeTaskSlot(task);
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
case PayloadBuffer.StaticNumericArray:
|
|
1291
|
+
task.value = numericArrayFromFloat64(readStatic8BytesFloatCopy(0, task[TaskIndex.PayloadLen], slotIndex));
|
|
1292
|
+
return;
|
|
1250
1293
|
case PayloadBuffer.BigInt64Array: {
|
|
1251
1294
|
const bytes = readDynamicBufferCopy(task[TaskIndex.Start], task[TaskIndex.Start] + task[TaskIndex.PayloadLen]);
|
|
1252
1295
|
task.value = new BigInt64Array(bytes.buffer, bytes.byteOffset, bytes.byteLength >>> 3);
|
package/src/worker/loop.js
CHANGED
|
@@ -75,7 +75,7 @@ export const workerMainLoop = async (startupData) => {
|
|
|
75
75
|
assertWorkerSharedMemoryBootData({ sab, lock, returnLock });
|
|
76
76
|
const debugNamespaces = resolveDebugNamespaces(debug);
|
|
77
77
|
const dbg = debugNamespaces.size > 0
|
|
78
|
-
? await import("../debug/handle.
|
|
78
|
+
? await import("../debug/handle.ts").then((module) => module.initDebug({
|
|
79
79
|
name: `w${thread}`,
|
|
80
80
|
runtime: RUNTIME,
|
|
81
81
|
namespaces: debugNamespaces,
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
-
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
-
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
-
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
-
});
|
|
6
|
-
}
|
|
7
|
-
return path;
|
|
8
|
-
};
|
|
9
1
|
import { endpointSymbol } from "../common/task-symbol.js";
|
|
10
2
|
import { toModuleUrl } from "../common/module-url.js";
|
|
11
3
|
const normalizeTimeout = (timeout) => {
|
|
@@ -38,7 +30,7 @@ export const getFunctions = async ({ list, ids, names, at, permission }) => {
|
|
|
38
30
|
const modules = list.map((specifier) => toModuleUrl(specifier));
|
|
39
31
|
const nameSet = new Set(names);
|
|
40
32
|
const results = await Promise.all(modules.map(async (imports) => {
|
|
41
|
-
const module = (await import(
|
|
33
|
+
const module = (await import(imports));
|
|
42
34
|
const fixedTasks = Object.entries(module)
|
|
43
35
|
.filter(([_, value]) => value != null && typeof value === "object" &&
|
|
44
36
|
//@ts-ignore Reason -> trust me
|