greybel-interpreter 2.8.4 → 2.8.6
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/dist/context.d.ts +3 -0
- package/dist/context.js +11 -10
- package/dist/utils/error.d.ts +1 -1
- package/dist/utils/error.js +2 -2
- package/dist/utils/uuid.d.ts +1 -0
- package/dist/utils/uuid.js +36 -0
- package/package.json +1 -1
package/dist/context.d.ts
CHANGED
|
@@ -46,6 +46,9 @@ export interface ExitObserver {
|
|
|
46
46
|
export declare class ProcessState extends EventEmitter {
|
|
47
47
|
isPending: boolean;
|
|
48
48
|
last: OperationContext;
|
|
49
|
+
private observer;
|
|
50
|
+
private observerWithExitOccurence;
|
|
51
|
+
constructor();
|
|
49
52
|
createExitObserver(): ExitObserver;
|
|
50
53
|
}
|
|
51
54
|
export declare class LoopState {
|
package/dist/context.js
CHANGED
|
@@ -19,6 +19,7 @@ const default_1 = require("./types/default");
|
|
|
19
19
|
const map_1 = require("./types/map");
|
|
20
20
|
const path_1 = require("./utils/path");
|
|
21
21
|
const set_immediate_1 = require("./utils/set-immediate");
|
|
22
|
+
const uuid_1 = require("./utils/uuid");
|
|
22
23
|
var ContextType;
|
|
23
24
|
(function (ContextType) {
|
|
24
25
|
ContextType[ContextType["Api"] = 0] = "Api";
|
|
@@ -124,22 +125,22 @@ class Debugger {
|
|
|
124
125
|
exports.Debugger = Debugger;
|
|
125
126
|
class ProcessState extends events_1.EventEmitter {
|
|
126
127
|
constructor() {
|
|
127
|
-
super(
|
|
128
|
+
super();
|
|
128
129
|
this.isPending = false;
|
|
129
130
|
/* eslint-disable no-use-before-define */
|
|
130
131
|
this.last = null;
|
|
132
|
+
this.observer = new Set();
|
|
133
|
+
this.observerWithExitOccurence = new Set();
|
|
134
|
+
this.once('exit', () => {
|
|
135
|
+
this.observerWithExitOccurence = new Set(this.observer);
|
|
136
|
+
});
|
|
131
137
|
}
|
|
132
138
|
createExitObserver() {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
isExit = true;
|
|
136
|
-
};
|
|
137
|
-
this.once('exit', listener);
|
|
139
|
+
const id = (0, uuid_1.uuid)();
|
|
140
|
+
this.observer.add(id);
|
|
138
141
|
return {
|
|
139
|
-
occured: () =>
|
|
140
|
-
close: () =>
|
|
141
|
-
this.off('exit', listener);
|
|
142
|
-
}
|
|
142
|
+
occured: () => this.observerWithExitOccurence.has(id),
|
|
143
|
+
close: () => this.observer.delete(id)
|
|
143
144
|
};
|
|
144
145
|
}
|
|
145
146
|
}
|
package/dist/utils/error.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare class RuntimeError extends Error {
|
|
|
8
8
|
target: string;
|
|
9
9
|
stackTrace: Operation[];
|
|
10
10
|
source?: Error;
|
|
11
|
-
constructor(message: string, context
|
|
11
|
+
constructor(message: string, context?: RuntimeContext, source?: Error);
|
|
12
12
|
private createTrace;
|
|
13
13
|
}
|
|
14
14
|
interface PrepareContext {
|
package/dist/utils/error.js
CHANGED
|
@@ -5,8 +5,8 @@ class RuntimeError extends Error {
|
|
|
5
5
|
constructor(message, context, source) {
|
|
6
6
|
var _a;
|
|
7
7
|
super(message);
|
|
8
|
-
this.target = context.target;
|
|
9
|
-
this.stackTrace = (_a = context.stackTrace) !== null && _a !== void 0 ? _a : [];
|
|
8
|
+
this.target = context === null || context === void 0 ? void 0 : context.target;
|
|
9
|
+
this.stackTrace = (_a = context === null || context === void 0 ? void 0 : context.stackTrace) !== null && _a !== void 0 ? _a : [];
|
|
10
10
|
this.stack = this.createTrace();
|
|
11
11
|
this.source = source;
|
|
12
12
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const uuid: () => string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uuid = void 0;
|
|
4
|
+
// Source: https://gist.github.com/alemures/ba4cd1b37a4b11346d7f54f05c826d24
|
|
5
|
+
function createUUIDFactory() {
|
|
6
|
+
const lut = [];
|
|
7
|
+
for (let i = 0; i < 256; i++)
|
|
8
|
+
lut[i] = (i < 16 ? '0' : '') + i.toString(16);
|
|
9
|
+
return function () {
|
|
10
|
+
const d0 = (Math.random() * 0xffffffff) | 0;
|
|
11
|
+
const d1 = (Math.random() * 0xffffffff) | 0;
|
|
12
|
+
const d2 = (Math.random() * 0xffffffff) | 0;
|
|
13
|
+
const d3 = (Math.random() * 0xffffffff) | 0;
|
|
14
|
+
return (lut[d0 & 0xff] +
|
|
15
|
+
lut[(d0 >> 8) & 0xff] +
|
|
16
|
+
lut[(d0 >> 16) & 0xff] +
|
|
17
|
+
lut[(d0 >> 24) & 0xff] +
|
|
18
|
+
'-' +
|
|
19
|
+
lut[d1 & 0xff] +
|
|
20
|
+
lut[(d1 >> 8) & 0xff] +
|
|
21
|
+
'-' +
|
|
22
|
+
lut[((d1 >> 16) & 0x0f) | 0x40] +
|
|
23
|
+
lut[(d1 >> 24) & 0xff] +
|
|
24
|
+
'-' +
|
|
25
|
+
lut[(d2 & 0x3f) | 0x80] +
|
|
26
|
+
lut[(d2 >> 8) & 0xff] +
|
|
27
|
+
'-' +
|
|
28
|
+
lut[(d2 >> 16) & 0xff] +
|
|
29
|
+
lut[(d2 >> 24) & 0xff] +
|
|
30
|
+
lut[d3 & 0xff] +
|
|
31
|
+
lut[(d3 >> 8) & 0xff] +
|
|
32
|
+
lut[(d3 >> 16) & 0xff] +
|
|
33
|
+
lut[(d3 >> 24) & 0xff]);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
exports.uuid = createUUIDFactory();
|