@junoscript/juno 0.0.0-stage → 0.1.2
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/Modules/async.ts +81 -0
- package/Modules/juno-node-fs.ts +105 -0
- package/Modules/juno-test.jn +156 -0
- package/dist/CLI/build-juno.d.ts +5 -0
- package/dist/CLI/build-juno.js +58 -0
- package/dist/CLI/generate-juno-types.d.ts +1 -0
- package/dist/CLI/generate-juno-types.js +54 -0
- package/dist/CLI/junode.d.ts +2 -0
- package/dist/CLI/junode.js +58 -0
- package/dist/Lexer/lexer.d.ts +42 -0
- package/dist/Lexer/lexer.js +300 -0
- package/dist/Lexer/parser.d.ts +403 -0
- package/dist/Lexer/parser.js +1930 -0
- package/dist/Modules/async.d.ts +33 -0
- package/dist/Modules/async.js +76 -0
- package/dist/Modules/bytes.d.ts +15 -0
- package/dist/Modules/bytes.js +35 -0
- package/dist/Modules/index.d.ts +201 -0
- package/dist/Modules/index.js +35 -0
- package/dist/Modules/juno-node-fs.d.ts +52 -0
- package/dist/Modules/juno-node-fs.js +129 -0
- package/dist/Modules/juno-node.d.ts +74 -0
- package/dist/Modules/juno-node.js +56 -0
- package/dist/Modules/juno-test.d.ts +141 -0
- package/dist/Modules/juno-test.js +134 -0
- package/dist/Modules/juno-types.d.ts +35 -0
- package/dist/Modules/juno-types.js +2 -0
- package/dist/Modules/juno.d.ts +24 -0
- package/dist/Modules/juno.js +84 -0
- package/dist/Modules/types.d.ts +61 -0
- package/dist/Modules/types.js +95 -0
- package/dist/Runtime/interpreter.d.ts +64 -0
- package/dist/Runtime/interpreter.js +2630 -0
- package/dist/Runtime/resolve-import.d.ts +2 -0
- package/dist/Runtime/resolve-import.js +30 -0
- package/dist/vscode-junoscript/src/language.d.ts +86 -0
- package/dist/vscode-junoscript/src/language.js +4481 -0
- package/package.json +20 -4
- package/types/array.jn +158 -0
- package/types/boolean.jn +18 -0
- package/types/error.jn +28 -0
- package/types/error.ts +9 -0
- package/types/index.jn +11 -0
- package/types/iterable.jn +211 -0
- package/types/map.jn +44 -0
- package/types/map.ts +132 -0
- package/types/number.ts +52 -0
- package/types/object.jn +94 -0
- package/types/object.ts +49 -0
- package/types/queue.jn +46 -0
- package/types/random.jn +25 -0
- package/types/random.ts +1 -0
- package/types/range.jn +27 -0
- package/types/set.jn +139 -0
- package/types/set.ts +209 -0
- package/types/string.jn +33 -0
- package/types/string.ts +1 -0
- package/types/tuple.jn +11 -0
- package/README.md +0 -3
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** JavaScript asynchronous primitives exposed to JunoScript. */
|
|
2
|
+
export type TimerHandle = object;
|
|
3
|
+
export type ImmediateHandle = object;
|
|
4
|
+
export type AsyncCallback = (...args: unknown[]) => void;
|
|
5
|
+
export type FetchInput = string | URL | Request;
|
|
6
|
+
export type FetchOptions = RequestInit;
|
|
7
|
+
export type FetchResponse = Response;
|
|
8
|
+
export type RejectedResult<E = unknown> = {
|
|
9
|
+
ok: false;
|
|
10
|
+
error: E;
|
|
11
|
+
};
|
|
12
|
+
declare const PromiseFactory: PromiseConstructor;
|
|
13
|
+
export { PromiseFactory as Promise };
|
|
14
|
+
export declare function setTimeout<T, TArgs extends any[]>(callback: (...args: TArgs) => T, delay: number, ...args: TArgs): T;
|
|
15
|
+
export declare function setInterval<T, TArgs extends any[]>(callback: (...args: TArgs) => T, delay?: number, ...args: TArgs): TimerHandle;
|
|
16
|
+
export declare function clearTimeout(handle: TimerHandle): void;
|
|
17
|
+
export declare function clearInterval(handle: TimerHandle): void;
|
|
18
|
+
export declare function setImmediate(callback: AsyncCallback, ...args: unknown[]): ImmediateHandle;
|
|
19
|
+
export declare function clearImmediate(handle: ImmediateHandle): void;
|
|
20
|
+
export declare function queueMicrotask(callback: AsyncCallback): void;
|
|
21
|
+
export declare function fetch(input: FetchInput, init?: FetchOptions): Promise<FetchResponse>;
|
|
22
|
+
declare const _default: {
|
|
23
|
+
Promise: PromiseConstructor;
|
|
24
|
+
setTimeout: typeof setTimeout;
|
|
25
|
+
setInterval: typeof setInterval;
|
|
26
|
+
clearTimeout: typeof clearTimeout;
|
|
27
|
+
clearInterval: typeof clearInterval;
|
|
28
|
+
setImmediate: typeof setImmediate;
|
|
29
|
+
clearImmediate: typeof clearImmediate;
|
|
30
|
+
queueMicrotask: typeof queueMicrotask;
|
|
31
|
+
fetch: typeof fetch;
|
|
32
|
+
};
|
|
33
|
+
export default _default;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Promise = void 0;
|
|
4
|
+
exports.setTimeout = setTimeout;
|
|
5
|
+
exports.setInterval = setInterval;
|
|
6
|
+
exports.clearTimeout = clearTimeout;
|
|
7
|
+
exports.clearInterval = clearInterval;
|
|
8
|
+
exports.setImmediate = setImmediate;
|
|
9
|
+
exports.clearImmediate = clearImmediate;
|
|
10
|
+
exports.queueMicrotask = queueMicrotask;
|
|
11
|
+
exports.fetch = fetch;
|
|
12
|
+
const PromiseFactory = function (executor) {
|
|
13
|
+
if (arguments.length !== 1)
|
|
14
|
+
throw new TypeError('Promise() accepts exactly one executor callback');
|
|
15
|
+
return new globalThis.Promise((resolve, reject) => executor(value => {
|
|
16
|
+
if (isRejectedResult(value))
|
|
17
|
+
reject(value.error);
|
|
18
|
+
else
|
|
19
|
+
resolve(value);
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
22
|
+
exports.Promise = PromiseFactory;
|
|
23
|
+
Object.setPrototypeOf(PromiseFactory, globalThis.Promise);
|
|
24
|
+
for (const name of ['all', 'allSettled', 'any', 'race', 'reject', 'resolve', 'withResolvers']) {
|
|
25
|
+
const member = globalThis.Promise[name];
|
|
26
|
+
if (!member)
|
|
27
|
+
continue;
|
|
28
|
+
const value = name === 'resolve'
|
|
29
|
+
? (input) => isRejectedResult(input)
|
|
30
|
+
? globalThis.Promise.reject(input.error)
|
|
31
|
+
: globalThis.Promise.resolve(input)
|
|
32
|
+
: name === 'withResolvers'
|
|
33
|
+
? () => {
|
|
34
|
+
const controls = globalThis.Promise.withResolvers();
|
|
35
|
+
return {
|
|
36
|
+
promise: controls.promise,
|
|
37
|
+
resolve: (input) => {
|
|
38
|
+
if (isRejectedResult(input))
|
|
39
|
+
controls.reject(input.error);
|
|
40
|
+
else
|
|
41
|
+
controls.resolve(input);
|
|
42
|
+
},
|
|
43
|
+
reject: controls.reject
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
: member.bind(globalThis.Promise);
|
|
47
|
+
Object.defineProperty(PromiseFactory, name, { value, enumerable: true });
|
|
48
|
+
}
|
|
49
|
+
function isRejectedResult(value) {
|
|
50
|
+
return value !== null && typeof value === 'object' && 'ok' in value && value.ok === false && 'error' in value;
|
|
51
|
+
}
|
|
52
|
+
function setTimeout(callback, delay, ...args) {
|
|
53
|
+
return globalThis.setTimeout(callback, delay, ...args);
|
|
54
|
+
}
|
|
55
|
+
function setInterval(callback, delay, ...args) {
|
|
56
|
+
return globalThis.setInterval(callback, delay ?? 0, ...args);
|
|
57
|
+
}
|
|
58
|
+
function clearTimeout(handle) { globalThis.clearTimeout(handle); }
|
|
59
|
+
function clearInterval(handle) { globalThis.clearInterval(handle); }
|
|
60
|
+
function setImmediate(callback, ...args) {
|
|
61
|
+
return globalThis.setImmediate(callback, ...args);
|
|
62
|
+
}
|
|
63
|
+
function clearImmediate(handle) { globalThis.clearImmediate(handle); }
|
|
64
|
+
function queueMicrotask(callback) { globalThis.queueMicrotask(callback); }
|
|
65
|
+
function fetch(input, init) { return globalThis.fetch(input, init); }
|
|
66
|
+
exports.default = {
|
|
67
|
+
Promise: PromiseFactory,
|
|
68
|
+
setTimeout,
|
|
69
|
+
setInterval,
|
|
70
|
+
clearTimeout,
|
|
71
|
+
clearInterval,
|
|
72
|
+
setImmediate,
|
|
73
|
+
clearImmediate,
|
|
74
|
+
queueMicrotask,
|
|
75
|
+
fetch
|
|
76
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Buffer as NodeBuffer } from 'node:buffer';
|
|
2
|
+
export type Encoding = BufferEncoding;
|
|
3
|
+
export declare const encodings: readonly ["utf8", "utf-8", "utf16le", "utf-16le", "ucs2", "ucs-2", "ascii", "latin1", "binary", "base64", "base64url", "hex"];
|
|
4
|
+
declare function createUint8Array(input?: number | ArrayLike<number> | ArrayBufferLike, byteOffset?: number, length?: number): Uint8Array;
|
|
5
|
+
declare function bufferFrom<T>(input: T, encoding?: Encoding): NodeBuffer;
|
|
6
|
+
export declare const Uint8ArrayConstructor: typeof createUint8Array & {
|
|
7
|
+
from: (input: ArrayLike<number>) => Uint8Array<ArrayBuffer>;
|
|
8
|
+
of: (...bytes: number[]) => Uint8Array<ArrayBuffer>;
|
|
9
|
+
};
|
|
10
|
+
export declare const BufferConstructor: ((input?: number | string | ArrayLike<number>, encoding?: Encoding) => NodeBuffer<ArrayBufferLike>) & {
|
|
11
|
+
from: typeof bufferFrom;
|
|
12
|
+
alloc: (size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding) => Buffer<ArrayBuffer>;
|
|
13
|
+
isBuffer: (obj: any) => obj is Buffer;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BufferConstructor = exports.Uint8ArrayConstructor = exports.encodings = void 0;
|
|
4
|
+
const node_buffer_1 = require("node:buffer");
|
|
5
|
+
exports.encodings = ['utf8', 'utf-8', 'utf16le', 'utf-16le', 'ucs2', 'ucs-2', 'ascii', 'latin1', 'binary', 'base64', 'base64url', 'hex'];
|
|
6
|
+
function createUint8Array(input = 0, byteOffset, length) {
|
|
7
|
+
if (typeof input === 'number')
|
|
8
|
+
return new Uint8Array(input);
|
|
9
|
+
if (input instanceof ArrayBuffer || input instanceof SharedArrayBuffer)
|
|
10
|
+
return new Uint8Array(input, byteOffset, length);
|
|
11
|
+
return new Uint8Array(input);
|
|
12
|
+
}
|
|
13
|
+
function bufferFrom(input, encoding = 'utf8') {
|
|
14
|
+
if (typeof input === 'string')
|
|
15
|
+
return node_buffer_1.Buffer.from(input, encoding);
|
|
16
|
+
if (input instanceof ArrayBuffer || input instanceof SharedArrayBuffer)
|
|
17
|
+
return node_buffer_1.Buffer.from(input);
|
|
18
|
+
if (Array.isArray(input) || input instanceof Uint8Array)
|
|
19
|
+
return node_buffer_1.Buffer.from(input);
|
|
20
|
+
if (input !== null && typeof input === 'object' && 'length' in input && typeof input.length === 'number') {
|
|
21
|
+
return node_buffer_1.Buffer.from(input);
|
|
22
|
+
}
|
|
23
|
+
if (!['utf8', 'utf-8', 'utf16le', 'utf-16le', 'ucs2', 'ucs-2', 'ascii', 'latin1', 'binary'].includes(encoding)) {
|
|
24
|
+
throw new TypeError('Serializing a value to Buffer requires a text encoding');
|
|
25
|
+
}
|
|
26
|
+
const json = JSON.stringify(input);
|
|
27
|
+
if (json === undefined)
|
|
28
|
+
throw new TypeError('Buffer.from requires bytes, text, or a JSON-serializable value');
|
|
29
|
+
return node_buffer_1.Buffer.from(json, encoding);
|
|
30
|
+
}
|
|
31
|
+
exports.Uint8ArrayConstructor = Object.assign(createUint8Array, {
|
|
32
|
+
from: (input) => Uint8Array.from(input),
|
|
33
|
+
of: (...bytes) => Uint8Array.of(...bytes)
|
|
34
|
+
});
|
|
35
|
+
exports.BufferConstructor = Object.assign((input = 0, encoding) => typeof input === 'number' ? node_buffer_1.Buffer.alloc(input) : bufferFrom(input, encoding), { from: bufferFrom, alloc: node_buffer_1.Buffer.alloc, isBuffer: node_buffer_1.Buffer.isBuffer });
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
export type { Awaited, ConstructorParameters, Exclude, Extract, InstanceType, KeyOf, NonNullable, Omit, OmitThisParameter, Parameters, Partial, Pick, Readonly, Record, Required, ReturnType, ThisParameterType, ThisType } from './types';
|
|
2
|
+
export { Buffer, Range, Uint8Array } from './juno';
|
|
3
|
+
export { Date } from './types';
|
|
4
|
+
export type { Encoding } from './bytes';
|
|
5
|
+
export type { Error } from './juno';
|
|
6
|
+
export type { Iterable } from './juno-types';
|
|
7
|
+
/** Runtime module table used to resolve JunoScript import specifiers. */
|
|
8
|
+
export declare const modules: {
|
|
9
|
+
readonly juno: Record<string, any>;
|
|
10
|
+
readonly 'juno:node': {
|
|
11
|
+
console: {
|
|
12
|
+
args: string[];
|
|
13
|
+
read(encoding?: string): string;
|
|
14
|
+
readLines(encoding?: string): string[];
|
|
15
|
+
assert(condition?: boolean, ...data: any[]): void;
|
|
16
|
+
clear(): void;
|
|
17
|
+
count(label?: string): void;
|
|
18
|
+
countReset(label?: string): void;
|
|
19
|
+
debug(...data: any[]): void;
|
|
20
|
+
dir(item?: any, options?: any): void;
|
|
21
|
+
dirxml(...data: any[]): void;
|
|
22
|
+
error(...data: any[]): void;
|
|
23
|
+
group(...data: any[]): void;
|
|
24
|
+
groupCollapsed(...data: any[]): void;
|
|
25
|
+
groupEnd(): void;
|
|
26
|
+
info(...data: any[]): void;
|
|
27
|
+
log(...data: any[]): void;
|
|
28
|
+
table(tabularData?: any, properties?: string[]): void;
|
|
29
|
+
time(label?: string): void;
|
|
30
|
+
timeEnd(label?: string): void;
|
|
31
|
+
timeLog(label?: string, ...data: any[]): void;
|
|
32
|
+
timeStamp(label?: string): void;
|
|
33
|
+
trace(...data: any[]): void;
|
|
34
|
+
warn(...data: any[]): void;
|
|
35
|
+
Console: {
|
|
36
|
+
prototype: import("node:console").Console;
|
|
37
|
+
new (stdout: NodeJS.WritableStream, stderr?: NodeJS.WritableStream, ignoreErrors?: boolean): import("node:console").Console;
|
|
38
|
+
new (options: import("node:console").ConsoleOptions): import("node:console").Console;
|
|
39
|
+
};
|
|
40
|
+
profile(label?: string): void;
|
|
41
|
+
profileEnd(label?: string): void;
|
|
42
|
+
};
|
|
43
|
+
readEnv: typeof import("./juno-node").readEnv;
|
|
44
|
+
};
|
|
45
|
+
readonly 'juno:types': {
|
|
46
|
+
Partial: (input: unknown) => {
|
|
47
|
+
__junoTypeConstructor?: true;
|
|
48
|
+
__junoTypeDescriptor?: true;
|
|
49
|
+
typeNode?: import("../Lexer/parser").TypeNode;
|
|
50
|
+
};
|
|
51
|
+
Required: (input: unknown) => {
|
|
52
|
+
__junoTypeConstructor?: true;
|
|
53
|
+
__junoTypeDescriptor?: true;
|
|
54
|
+
typeNode?: import("../Lexer/parser").TypeNode;
|
|
55
|
+
};
|
|
56
|
+
Readonly: (input: unknown) => {
|
|
57
|
+
__junoTypeConstructor?: true;
|
|
58
|
+
__junoTypeDescriptor?: true;
|
|
59
|
+
typeNode?: import("../Lexer/parser").TypeNode;
|
|
60
|
+
};
|
|
61
|
+
Pick: (input: unknown, keys: unknown) => {
|
|
62
|
+
__junoTypeConstructor?: true;
|
|
63
|
+
__junoTypeDescriptor?: true;
|
|
64
|
+
typeNode?: import("../Lexer/parser").TypeNode;
|
|
65
|
+
};
|
|
66
|
+
Omit: (input: unknown, keys: unknown) => {
|
|
67
|
+
__junoTypeConstructor?: true;
|
|
68
|
+
__junoTypeDescriptor?: true;
|
|
69
|
+
typeNode?: import("../Lexer/parser").TypeNode;
|
|
70
|
+
};
|
|
71
|
+
KeyOf: (input: unknown) => {
|
|
72
|
+
__junoTypeConstructor?: true;
|
|
73
|
+
__junoTypeDescriptor?: true;
|
|
74
|
+
typeNode?: import("../Lexer/parser").TypeNode;
|
|
75
|
+
};
|
|
76
|
+
Exclude: (input: unknown, excluded: unknown) => {
|
|
77
|
+
__junoTypeConstructor?: true;
|
|
78
|
+
__junoTypeDescriptor?: true;
|
|
79
|
+
typeNode?: import("../Lexer/parser").TypeNode;
|
|
80
|
+
};
|
|
81
|
+
Items: () => (string | number)[];
|
|
82
|
+
Keys: () => (string | number)[];
|
|
83
|
+
Date: typeof import("./types").Date;
|
|
84
|
+
};
|
|
85
|
+
readonly 'juno:async': {
|
|
86
|
+
Promise: PromiseConstructor;
|
|
87
|
+
setTimeout: typeof import("./async").setTimeout;
|
|
88
|
+
setInterval: typeof import("./async").setInterval;
|
|
89
|
+
clearTimeout: typeof import("./async").clearTimeout;
|
|
90
|
+
clearInterval: typeof import("./async").clearInterval;
|
|
91
|
+
setImmediate: typeof import("./async").setImmediate;
|
|
92
|
+
clearImmediate: typeof import("./async").clearImmediate;
|
|
93
|
+
queueMicrotask: typeof import("./async").queueMicrotask;
|
|
94
|
+
fetch: typeof import("./async").fetch;
|
|
95
|
+
};
|
|
96
|
+
readonly 'juno:node:fs': {
|
|
97
|
+
readFile: typeof import("./juno-node-fs").readFile;
|
|
98
|
+
writeFile: typeof import("./juno-node-fs").writeFile;
|
|
99
|
+
appendFile: typeof import("./juno-node-fs").appendFile;
|
|
100
|
+
exists: typeof import("./juno-node-fs").exists;
|
|
101
|
+
mkdir: typeof import("./juno-node-fs").mkdir;
|
|
102
|
+
readdir: typeof import("./juno-node-fs").readdir;
|
|
103
|
+
remove: typeof import("./juno-node-fs").remove;
|
|
104
|
+
rename: typeof import("./juno-node-fs").rename;
|
|
105
|
+
copyFile: typeof import("./juno-node-fs").copyFile;
|
|
106
|
+
stat: typeof import("./juno-node-fs").stat;
|
|
107
|
+
readFileSync: typeof import("./juno-node-fs").readFileSync;
|
|
108
|
+
writeFileSync: typeof import("./juno-node-fs").writeFileSync;
|
|
109
|
+
appendFileSync: typeof import("./juno-node-fs").appendFileSync;
|
|
110
|
+
existsSync: typeof import("./juno-node-fs").existsSync;
|
|
111
|
+
mkdirSync: typeof import("./juno-node-fs").mkdirSync;
|
|
112
|
+
readdirSync: typeof import("./juno-node-fs").readdirSync;
|
|
113
|
+
removeSync: typeof import("./juno-node-fs").removeSync;
|
|
114
|
+
renameSync: typeof import("./juno-node-fs").renameSync;
|
|
115
|
+
copyFileSync: typeof import("./juno-node-fs").copyFileSync;
|
|
116
|
+
statSync: typeof import("./juno-node-fs").statSync;
|
|
117
|
+
};
|
|
118
|
+
readonly 'juno:test': {
|
|
119
|
+
expect: import("./juno-test").JunoExpect;
|
|
120
|
+
Mock: typeof import("./juno-test").Mock;
|
|
121
|
+
spyOn: {
|
|
122
|
+
<T extends object, K extends import("jest-mock").PropertyLikeKeys<T>, V extends Required<T>[K], A extends "get" | "set">(object: T, methodKey: K, accessType: A): A extends "get" ? import("jest-mock").SpiedGetter<V> : A extends "set" ? import("jest-mock").SpiedSetter<V> : never;
|
|
123
|
+
<T extends object, K extends import("jest-mock").ConstructorLikeKeys<T> | import("jest-mock").MethodLikeKeys<T>, V extends Required<T>[K]>(object: T, methodKey: K): V extends import("jest-mock").ClassLike | import("jest-mock").FunctionLike ? import("jest-mock").Spied<V> : never;
|
|
124
|
+
};
|
|
125
|
+
replaceProperty: <T extends object, K extends keyof T>(object: T, propertyKey: K, value: T[K]) => import("jest-mock").Replaced<T[K]>;
|
|
126
|
+
isMockFunction: {
|
|
127
|
+
<T extends import("jest-mock").FunctionLike = import("jest-mock").UnknownFunction>(fn: import("jest-mock").MockInstance<T>): fn is import("jest-mock").MockInstance<T>;
|
|
128
|
+
<P extends Array<unknown>, R>(fn: (...args: P) => R): fn is import("jest-mock").Mock<(...args: P) => R>;
|
|
129
|
+
(fn: unknown): fn is import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
|
|
130
|
+
};
|
|
131
|
+
clearAllMocks: () => void;
|
|
132
|
+
resetAllMocks: () => void;
|
|
133
|
+
restoreAllMocks: () => void;
|
|
134
|
+
describe: typeof import("./juno-test").describe;
|
|
135
|
+
test: typeof import("./juno-test").test;
|
|
136
|
+
it: typeof import("./juno-test").test;
|
|
137
|
+
beforeEach: typeof import("./juno-test").beforeEach;
|
|
138
|
+
afterEach: typeof import("./juno-test").afterEach;
|
|
139
|
+
useFakeTimers: (fakeTimersConfig?: {
|
|
140
|
+
advanceTimers?: boolean | number;
|
|
141
|
+
doNotFake?: Array<"Date" | "hrtime" | "nextTick" | "performance" | "queueMicrotask" | "requestAnimationFrame" | "cancelAnimationFrame" | "requestIdleCallback" | "cancelIdleCallback" | "setImmediate" | "clearImmediate" | "setInterval" | "clearInterval" | "setTimeout" | "clearTimeout" | "Temporal">;
|
|
142
|
+
now?: number | Date | {
|
|
143
|
+
epochMilliseconds: number;
|
|
144
|
+
};
|
|
145
|
+
timerLimit?: number;
|
|
146
|
+
legacyFakeTimers?: false;
|
|
147
|
+
}) => void;
|
|
148
|
+
useRealTimers: () => void;
|
|
149
|
+
clearAllTimers: () => void;
|
|
150
|
+
runAllTimers: () => void;
|
|
151
|
+
runAllTimersAsync: () => Promise<void>;
|
|
152
|
+
runOnlyPendingTimers: () => void;
|
|
153
|
+
advanceTimersByTime: (msToRun: number | import("@sinonjs/fake-timers").TemporalDuration) => void;
|
|
154
|
+
advanceTimersByTimeAsync: (msToRun: number | import("@sinonjs/fake-timers").TemporalDuration) => Promise<void>;
|
|
155
|
+
advanceTimersToNextTimer: (steps?: number) => void;
|
|
156
|
+
setSystemTime: (now?: number | Date | import("@sinonjs/fake-timers").TemporalTimelike) => void;
|
|
157
|
+
getTimerCount: () => number;
|
|
158
|
+
};
|
|
159
|
+
readonly types: {
|
|
160
|
+
Partial: (input: unknown) => {
|
|
161
|
+
__junoTypeConstructor?: true;
|
|
162
|
+
__junoTypeDescriptor?: true;
|
|
163
|
+
typeNode?: import("../Lexer/parser").TypeNode;
|
|
164
|
+
};
|
|
165
|
+
Required: (input: unknown) => {
|
|
166
|
+
__junoTypeConstructor?: true;
|
|
167
|
+
__junoTypeDescriptor?: true;
|
|
168
|
+
typeNode?: import("../Lexer/parser").TypeNode;
|
|
169
|
+
};
|
|
170
|
+
Readonly: (input: unknown) => {
|
|
171
|
+
__junoTypeConstructor?: true;
|
|
172
|
+
__junoTypeDescriptor?: true;
|
|
173
|
+
typeNode?: import("../Lexer/parser").TypeNode;
|
|
174
|
+
};
|
|
175
|
+
Pick: (input: unknown, keys: unknown) => {
|
|
176
|
+
__junoTypeConstructor?: true;
|
|
177
|
+
__junoTypeDescriptor?: true;
|
|
178
|
+
typeNode?: import("../Lexer/parser").TypeNode;
|
|
179
|
+
};
|
|
180
|
+
Omit: (input: unknown, keys: unknown) => {
|
|
181
|
+
__junoTypeConstructor?: true;
|
|
182
|
+
__junoTypeDescriptor?: true;
|
|
183
|
+
typeNode?: import("../Lexer/parser").TypeNode;
|
|
184
|
+
};
|
|
185
|
+
KeyOf: (input: unknown) => {
|
|
186
|
+
__junoTypeConstructor?: true;
|
|
187
|
+
__junoTypeDescriptor?: true;
|
|
188
|
+
typeNode?: import("../Lexer/parser").TypeNode;
|
|
189
|
+
};
|
|
190
|
+
Exclude: (input: unknown, excluded: unknown) => {
|
|
191
|
+
__junoTypeConstructor?: true;
|
|
192
|
+
__junoTypeDescriptor?: true;
|
|
193
|
+
typeNode?: import("../Lexer/parser").TypeNode;
|
|
194
|
+
};
|
|
195
|
+
Items: () => (string | number)[];
|
|
196
|
+
Keys: () => (string | number)[];
|
|
197
|
+
Date: typeof import("./types").Date;
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
export type ModuleName = keyof typeof modules;
|
|
201
|
+
export declare function resolveModule(name: string): (typeof modules)[ModuleName];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.modules = exports.Date = exports.Uint8Array = exports.Range = exports.Buffer = void 0;
|
|
7
|
+
exports.resolveModule = resolveModule;
|
|
8
|
+
const juno_1 = __importDefault(require("./juno"));
|
|
9
|
+
const juno_node_1 = __importDefault(require("./juno-node"));
|
|
10
|
+
const types_1 = __importDefault(require("./types"));
|
|
11
|
+
const async_1 = __importDefault(require("./async"));
|
|
12
|
+
const juno_node_fs_1 = __importDefault(require("./juno-node-fs"));
|
|
13
|
+
const juno_test_1 = __importDefault(require("./juno-test"));
|
|
14
|
+
var juno_2 = require("./juno");
|
|
15
|
+
Object.defineProperty(exports, "Buffer", { enumerable: true, get: function () { return juno_2.Buffer; } });
|
|
16
|
+
Object.defineProperty(exports, "Range", { enumerable: true, get: function () { return juno_2.Range; } });
|
|
17
|
+
Object.defineProperty(exports, "Uint8Array", { enumerable: true, get: function () { return juno_2.Uint8Array; } });
|
|
18
|
+
var types_2 = require("./types");
|
|
19
|
+
Object.defineProperty(exports, "Date", { enumerable: true, get: function () { return types_2.Date; } });
|
|
20
|
+
/** Runtime module table used to resolve JunoScript import specifiers. */
|
|
21
|
+
exports.modules = {
|
|
22
|
+
juno: juno_1.default,
|
|
23
|
+
'juno:node': juno_node_1.default,
|
|
24
|
+
'juno:types': types_1.default,
|
|
25
|
+
'juno:async': async_1.default,
|
|
26
|
+
'juno:node:fs': juno_node_fs_1.default,
|
|
27
|
+
'juno:test': juno_test_1.default,
|
|
28
|
+
types: types_1.default
|
|
29
|
+
};
|
|
30
|
+
function resolveModule(name) {
|
|
31
|
+
if (name !== 'juno' && name !== 'juno:node' && name !== 'juno:types' && name !== 'juno:async' && name !== 'juno:node:fs' && name !== 'juno:test' && name !== 'types') {
|
|
32
|
+
throw new Error(`Unknown JunoScript module '${name}'`);
|
|
33
|
+
}
|
|
34
|
+
return exports.modules[name];
|
|
35
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** A serializable subset of Node's fs.Stats. */
|
|
2
|
+
export type FileStat = {
|
|
3
|
+
size: number;
|
|
4
|
+
createdAt: number;
|
|
5
|
+
modifiedAt: number;
|
|
6
|
+
isFile: boolean;
|
|
7
|
+
isDirectory: boolean;
|
|
8
|
+
isSymbolicLink: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function readFileSync(path: string, encoding?: string): string;
|
|
11
|
+
export declare function writeFileSync(path: string, data: string, encoding?: string): void;
|
|
12
|
+
export declare function appendFileSync(path: string, data: string, encoding?: string): void;
|
|
13
|
+
export declare function existsSync(path: string): boolean;
|
|
14
|
+
export declare function mkdirSync(path: string, recursive?: boolean): void;
|
|
15
|
+
export declare function readdirSync(path: string): string[];
|
|
16
|
+
export declare function removeSync(path: string, recursive?: boolean, force?: boolean): void;
|
|
17
|
+
export declare function renameSync(oldPath: string, newPath: string): void;
|
|
18
|
+
export declare function copyFileSync(source: string, destination: string): void;
|
|
19
|
+
export declare function statSync(path: string): FileStat;
|
|
20
|
+
export declare function readFile(path: string, encoding?: string): Promise<string>;
|
|
21
|
+
export declare function writeFile(path: string, data: string, encoding?: string): Promise<null>;
|
|
22
|
+
export declare function appendFile(path: string, data: string, encoding?: string): Promise<null>;
|
|
23
|
+
export declare function exists(path: string): Promise<boolean>;
|
|
24
|
+
export declare function mkdir(path: string, recursive?: boolean): Promise<null>;
|
|
25
|
+
export declare function readdir(path: string): Promise<string[]>;
|
|
26
|
+
export declare function remove(path: string, recursive?: boolean, force?: boolean): Promise<null>;
|
|
27
|
+
export declare function rename(oldPath: string, newPath: string): Promise<null>;
|
|
28
|
+
export declare function copyFile(source: string, destination: string): Promise<null>;
|
|
29
|
+
export declare function stat(path: string): Promise<FileStat>;
|
|
30
|
+
declare const _default: {
|
|
31
|
+
readFile: typeof readFile;
|
|
32
|
+
writeFile: typeof writeFile;
|
|
33
|
+
appendFile: typeof appendFile;
|
|
34
|
+
exists: typeof exists;
|
|
35
|
+
mkdir: typeof mkdir;
|
|
36
|
+
readdir: typeof readdir;
|
|
37
|
+
remove: typeof remove;
|
|
38
|
+
rename: typeof rename;
|
|
39
|
+
copyFile: typeof copyFile;
|
|
40
|
+
stat: typeof stat;
|
|
41
|
+
readFileSync: typeof readFileSync;
|
|
42
|
+
writeFileSync: typeof writeFileSync;
|
|
43
|
+
appendFileSync: typeof appendFileSync;
|
|
44
|
+
existsSync: typeof existsSync;
|
|
45
|
+
mkdirSync: typeof mkdirSync;
|
|
46
|
+
readdirSync: typeof readdirSync;
|
|
47
|
+
removeSync: typeof removeSync;
|
|
48
|
+
renameSync: typeof renameSync;
|
|
49
|
+
copyFileSync: typeof copyFileSync;
|
|
50
|
+
statSync: typeof statSync;
|
|
51
|
+
};
|
|
52
|
+
export default _default;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.readFileSync = readFileSync;
|
|
37
|
+
exports.writeFileSync = writeFileSync;
|
|
38
|
+
exports.appendFileSync = appendFileSync;
|
|
39
|
+
exports.existsSync = existsSync;
|
|
40
|
+
exports.mkdirSync = mkdirSync;
|
|
41
|
+
exports.readdirSync = readdirSync;
|
|
42
|
+
exports.removeSync = removeSync;
|
|
43
|
+
exports.renameSync = renameSync;
|
|
44
|
+
exports.copyFileSync = copyFileSync;
|
|
45
|
+
exports.statSync = statSync;
|
|
46
|
+
exports.readFile = readFile;
|
|
47
|
+
exports.writeFile = writeFile;
|
|
48
|
+
exports.appendFile = appendFile;
|
|
49
|
+
exports.exists = exists;
|
|
50
|
+
exports.mkdir = mkdir;
|
|
51
|
+
exports.readdir = readdir;
|
|
52
|
+
exports.remove = remove;
|
|
53
|
+
exports.rename = rename;
|
|
54
|
+
exports.copyFile = copyFile;
|
|
55
|
+
exports.stat = stat;
|
|
56
|
+
const nodeFs = __importStar(require("node:fs"));
|
|
57
|
+
const promises = __importStar(require("node:fs/promises"));
|
|
58
|
+
function readFileSync(path, encoding = 'utf8') {
|
|
59
|
+
return nodeFs.readFileSync(path, { encoding: encoding });
|
|
60
|
+
}
|
|
61
|
+
function writeFileSync(path, data, encoding = 'utf8') {
|
|
62
|
+
nodeFs.writeFileSync(path, data, { encoding: encoding });
|
|
63
|
+
}
|
|
64
|
+
function appendFileSync(path, data, encoding = 'utf8') {
|
|
65
|
+
nodeFs.appendFileSync(path, data, { encoding: encoding });
|
|
66
|
+
}
|
|
67
|
+
function existsSync(path) { return nodeFs.existsSync(path); }
|
|
68
|
+
function mkdirSync(path, recursive = false) {
|
|
69
|
+
nodeFs.mkdirSync(path, { recursive });
|
|
70
|
+
}
|
|
71
|
+
function readdirSync(path) { return nodeFs.readdirSync(path); }
|
|
72
|
+
function removeSync(path, recursive = false, force = false) {
|
|
73
|
+
nodeFs.rmSync(path, { recursive, force });
|
|
74
|
+
}
|
|
75
|
+
function renameSync(oldPath, newPath) { nodeFs.renameSync(oldPath, newPath); }
|
|
76
|
+
function copyFileSync(source, destination) { nodeFs.copyFileSync(source, destination); }
|
|
77
|
+
function statSync(path) {
|
|
78
|
+
return fileStat(nodeFs.statSync(path));
|
|
79
|
+
}
|
|
80
|
+
function fileStat(value) {
|
|
81
|
+
return {
|
|
82
|
+
size: value.size,
|
|
83
|
+
createdAt: value.birthtimeMs,
|
|
84
|
+
modifiedAt: value.mtimeMs,
|
|
85
|
+
isFile: value.isFile(),
|
|
86
|
+
isDirectory: value.isDirectory(),
|
|
87
|
+
isSymbolicLink: value.isSymbolicLink()
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function readFile(path, encoding = 'utf8') {
|
|
91
|
+
return promises.readFile(path, { encoding: encoding });
|
|
92
|
+
}
|
|
93
|
+
async function writeFile(path, data, encoding = 'utf8') {
|
|
94
|
+
await promises.writeFile(path, data, { encoding: encoding });
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
async function appendFile(path, data, encoding = 'utf8') {
|
|
98
|
+
await promises.appendFile(path, data, { encoding: encoding });
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
function exists(path) {
|
|
102
|
+
return promises.access(path).then(() => true, () => false);
|
|
103
|
+
}
|
|
104
|
+
async function mkdir(path, recursive = false) {
|
|
105
|
+
await promises.mkdir(path, { recursive });
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
function readdir(path) {
|
|
109
|
+
return promises.readdir(path);
|
|
110
|
+
}
|
|
111
|
+
async function remove(path, recursive = false, force = false) {
|
|
112
|
+
await promises.rm(path, { recursive, force });
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
async function rename(oldPath, newPath) {
|
|
116
|
+
await promises.rename(oldPath, newPath);
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
async function copyFile(source, destination) {
|
|
120
|
+
await promises.copyFile(source, destination);
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
async function stat(path) {
|
|
124
|
+
return fileStat(await promises.stat(path));
|
|
125
|
+
}
|
|
126
|
+
exports.default = {
|
|
127
|
+
readFile, writeFile, appendFile, exists, mkdir, readdir, remove, rename, copyFile, stat,
|
|
128
|
+
readFileSync, writeFileSync, appendFileSync, existsSync, mkdirSync, readdirSync, removeSync, renameSync, copyFileSync, statSync
|
|
129
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export type Path = {
|
|
2
|
+
path: string;
|
|
3
|
+
};
|
|
4
|
+
/** Read a UTF-8 .env file without modifying process.env. */
|
|
5
|
+
export declare function readEnv(source: string | Path): Record<string, any>;
|
|
6
|
+
/** Node.js console module with synchronous stdin helpers. */
|
|
7
|
+
export declare const console: {
|
|
8
|
+
args: string[];
|
|
9
|
+
read(encoding?: string): string;
|
|
10
|
+
readLines(encoding?: string): string[];
|
|
11
|
+
assert(condition?: boolean, ...data: any[]): void;
|
|
12
|
+
clear(): void;
|
|
13
|
+
count(label?: string): void;
|
|
14
|
+
countReset(label?: string): void;
|
|
15
|
+
debug(...data: any[]): void;
|
|
16
|
+
dir(item?: any, options?: any): void;
|
|
17
|
+
dirxml(...data: any[]): void;
|
|
18
|
+
error(...data: any[]): void;
|
|
19
|
+
group(...data: any[]): void;
|
|
20
|
+
groupCollapsed(...data: any[]): void;
|
|
21
|
+
groupEnd(): void;
|
|
22
|
+
info(...data: any[]): void;
|
|
23
|
+
log(...data: any[]): void;
|
|
24
|
+
table(tabularData?: any, properties?: string[]): void;
|
|
25
|
+
time(label?: string): void;
|
|
26
|
+
timeEnd(label?: string): void;
|
|
27
|
+
timeLog(label?: string, ...data: any[]): void;
|
|
28
|
+
timeStamp(label?: string): void;
|
|
29
|
+
trace(...data: any[]): void;
|
|
30
|
+
warn(...data: any[]): void;
|
|
31
|
+
Console: {
|
|
32
|
+
prototype: import("node:console").Console;
|
|
33
|
+
new (stdout: NodeJS.WritableStream, stderr?: NodeJS.WritableStream, ignoreErrors?: boolean): import("node:console").Console;
|
|
34
|
+
new (options: import("node:console").ConsoleOptions): import("node:console").Console;
|
|
35
|
+
};
|
|
36
|
+
profile(label?: string): void;
|
|
37
|
+
profileEnd(label?: string): void;
|
|
38
|
+
};
|
|
39
|
+
declare const junoNode: {
|
|
40
|
+
console: {
|
|
41
|
+
args: string[];
|
|
42
|
+
read(encoding?: string): string;
|
|
43
|
+
readLines(encoding?: string): string[];
|
|
44
|
+
assert(condition?: boolean, ...data: any[]): void;
|
|
45
|
+
clear(): void;
|
|
46
|
+
count(label?: string): void;
|
|
47
|
+
countReset(label?: string): void;
|
|
48
|
+
debug(...data: any[]): void;
|
|
49
|
+
dir(item?: any, options?: any): void;
|
|
50
|
+
dirxml(...data: any[]): void;
|
|
51
|
+
error(...data: any[]): void;
|
|
52
|
+
group(...data: any[]): void;
|
|
53
|
+
groupCollapsed(...data: any[]): void;
|
|
54
|
+
groupEnd(): void;
|
|
55
|
+
info(...data: any[]): void;
|
|
56
|
+
log(...data: any[]): void;
|
|
57
|
+
table(tabularData?: any, properties?: string[]): void;
|
|
58
|
+
time(label?: string): void;
|
|
59
|
+
timeEnd(label?: string): void;
|
|
60
|
+
timeLog(label?: string, ...data: any[]): void;
|
|
61
|
+
timeStamp(label?: string): void;
|
|
62
|
+
trace(...data: any[]): void;
|
|
63
|
+
warn(...data: any[]): void;
|
|
64
|
+
Console: {
|
|
65
|
+
prototype: import("node:console").Console;
|
|
66
|
+
new (stdout: NodeJS.WritableStream, stderr?: NodeJS.WritableStream, ignoreErrors?: boolean): import("node:console").Console;
|
|
67
|
+
new (options: import("node:console").ConsoleOptions): import("node:console").Console;
|
|
68
|
+
};
|
|
69
|
+
profile(label?: string): void;
|
|
70
|
+
profileEnd(label?: string): void;
|
|
71
|
+
};
|
|
72
|
+
readEnv: typeof readEnv;
|
|
73
|
+
};
|
|
74
|
+
export default junoNode;
|