@memberjunction/code-execution 3.4.0 → 4.1.0
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/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +33 -0
- package/README.md +293 -172
- package/dist/CodeExecutionService.d.ts +2 -2
- package/dist/CodeExecutionService.js +4 -9
- package/dist/CodeExecutionService.js.map +1 -1
- package/dist/WorkerPool.d.ts +1 -1
- package/dist/WorkerPool.d.ts.map +1 -1
- package/dist/WorkerPool.js +21 -49
- package/dist/WorkerPool.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -20
- package/dist/index.js.map +1 -1
- package/dist/libraries/index-old.js +6 -12
- package/dist/libraries/index-old.js.map +1 -1
- package/dist/libraries/index.d.ts.map +1 -1
- package/dist/libraries/index.js +12 -27
- package/dist/libraries/index.js.map +1 -1
- package/dist/types/index.js +1 -2
- package/dist/worker.js +9 -14
- package/dist/worker.js.map +1 -1
- package/package.json +16 -15
- package/src/WorkerPool.ts +4 -0
- package/src/libraries/index.ts +8 -18
- package/tsconfig.json +5 -21
package/src/WorkerPool.ts
CHANGED
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
|
|
15
15
|
import { fork, ChildProcess } from 'child_process';
|
|
16
16
|
import * as path from 'path';
|
|
17
|
+
import { fileURLToPath } from 'node:url';
|
|
18
|
+
|
|
19
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
+
const __dirname = path.dirname(__filename);
|
|
17
21
|
import { CodeExecutionParams, CodeExecutionResult } from './types';
|
|
18
22
|
import { LogError, LogStatus } from '@memberjunction/core';
|
|
19
23
|
|
package/src/libraries/index.ts
CHANGED
|
@@ -9,6 +9,14 @@
|
|
|
9
9
|
* SECURITY NOTE: Only add libraries here that are safe for untrusted code execution.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import fs from 'fs';
|
|
13
|
+
import path from 'path';
|
|
14
|
+
import { fileURLToPath } from 'url';
|
|
15
|
+
|
|
16
|
+
// Get __dirname equivalent in ESM
|
|
17
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
18
|
+
const __dirname = path.dirname(__filename);
|
|
19
|
+
|
|
12
20
|
/**
|
|
13
21
|
* Allowed module names
|
|
14
22
|
*/
|
|
@@ -381,12 +389,6 @@ function getValidatorSource(): string {
|
|
|
381
389
|
* We bundle the actual mathjs library for full functionality
|
|
382
390
|
*/
|
|
383
391
|
function getMathjsSource(): string {
|
|
384
|
-
// Load bundled library source at compile time
|
|
385
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
386
|
-
const fs = require('fs');
|
|
387
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
388
|
-
const path = require('path');
|
|
389
|
-
|
|
390
392
|
const libPath = path.join(__dirname, 'bundled-libs', 'mathjs.js');
|
|
391
393
|
const source = fs.readFileSync(libPath, 'utf8');
|
|
392
394
|
|
|
@@ -403,12 +405,6 @@ function getMathjsSource(): string {
|
|
|
403
405
|
* We bundle the actual papaparse library
|
|
404
406
|
*/
|
|
405
407
|
function getPapaparseSource(): string {
|
|
406
|
-
// Load bundled library source at compile time
|
|
407
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
408
|
-
const fs = require('fs');
|
|
409
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
410
|
-
const path = require('path');
|
|
411
|
-
|
|
412
408
|
const libPath = path.join(__dirname, 'bundled-libs', 'papaparse.js');
|
|
413
409
|
const source = fs.readFileSync(libPath, 'utf8');
|
|
414
410
|
|
|
@@ -425,12 +421,6 @@ function getPapaparseSource(): string {
|
|
|
425
421
|
* We bundle the actual jstat library
|
|
426
422
|
*/
|
|
427
423
|
function getJstatSource(): string {
|
|
428
|
-
// Load bundled library source at compile time
|
|
429
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
430
|
-
const fs = require('fs');
|
|
431
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
432
|
-
const path = require('path');
|
|
433
|
-
|
|
434
424
|
const libPath = path.join(__dirname, 'bundled-libs', 'jstat.js');
|
|
435
425
|
const source = fs.readFileSync(libPath, 'utf8');
|
|
436
426
|
|
package/tsconfig.json
CHANGED
|
@@ -1,25 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
+
"extends": "../../../tsconfig.server.json",
|
|
2
3
|
"compilerOptions": {
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"module": "commonjs",
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"target": "ES2022",
|
|
8
|
-
"lib": ["ES2022"],
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"declaration": true,
|
|
11
|
-
"declarationMap": true,
|
|
12
|
-
"moduleResolution": "node",
|
|
13
|
-
"sourceMap": true,
|
|
14
|
-
"outDir": "./dist",
|
|
15
|
-
"rootDir": "./src"
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"rootDir": "src"
|
|
16
6
|
},
|
|
17
|
-
"include": [
|
|
18
|
-
|
|
19
|
-
],
|
|
20
|
-
"exclude": [
|
|
21
|
-
"node_modules",
|
|
22
|
-
"dist",
|
|
23
|
-
"**/*.spec.ts"
|
|
24
|
-
]
|
|
7
|
+
"include": ["src/**/*"],
|
|
8
|
+
"exclude": ["node_modules"]
|
|
25
9
|
}
|