@junoscript/juno 0.0.0-stage → 0.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.
Files changed (57) hide show
  1. package/Modules/async.ts +81 -0
  2. package/Modules/juno-node-fs.ts +105 -0
  3. package/Modules/juno-test.jn +156 -0
  4. package/dist/CLI/build-juno.d.ts +5 -0
  5. package/dist/CLI/build-juno.js +58 -0
  6. package/dist/CLI/generate-juno-types.d.ts +1 -0
  7. package/dist/CLI/generate-juno-types.js +51 -0
  8. package/dist/CLI/junode.d.ts +2 -0
  9. package/dist/CLI/junode.js +32 -0
  10. package/dist/Lexer/lexer.d.ts +42 -0
  11. package/dist/Lexer/lexer.js +300 -0
  12. package/dist/Lexer/parser.d.ts +395 -0
  13. package/dist/Lexer/parser.js +1881 -0
  14. package/dist/Modules/async.d.ts +33 -0
  15. package/dist/Modules/async.js +76 -0
  16. package/dist/Modules/index.d.ts +195 -0
  17. package/dist/Modules/index.js +31 -0
  18. package/dist/Modules/juno-node-fs.d.ts +52 -0
  19. package/dist/Modules/juno-node-fs.js +129 -0
  20. package/dist/Modules/juno-node.d.ts +74 -0
  21. package/dist/Modules/juno-node.js +56 -0
  22. package/dist/Modules/juno-test.d.ts +141 -0
  23. package/dist/Modules/juno-test.js +134 -0
  24. package/dist/Modules/juno-types.d.ts +35 -0
  25. package/dist/Modules/juno-types.js +2 -0
  26. package/dist/Modules/juno.d.ts +21 -0
  27. package/dist/Modules/juno.js +76 -0
  28. package/dist/Modules/types.d.ts +56 -0
  29. package/dist/Modules/types.js +87 -0
  30. package/dist/Runtime/interpreter.d.ts +64 -0
  31. package/dist/Runtime/interpreter.js +2533 -0
  32. package/dist/Runtime/resolve-import.d.ts +2 -0
  33. package/dist/Runtime/resolve-import.js +30 -0
  34. package/dist/vscode-junoscript/src/language.d.ts +86 -0
  35. package/dist/vscode-junoscript/src/language.js +4206 -0
  36. package/package.json +19 -4
  37. package/types/array.jn +158 -0
  38. package/types/boolean.jn +18 -0
  39. package/types/error.jn +28 -0
  40. package/types/error.ts +9 -0
  41. package/types/index.jn +11 -0
  42. package/types/iterable.jn +211 -0
  43. package/types/map.jn +44 -0
  44. package/types/map.ts +132 -0
  45. package/types/number.ts +52 -0
  46. package/types/object.jn +94 -0
  47. package/types/object.ts +49 -0
  48. package/types/queue.jn +46 -0
  49. package/types/random.jn +25 -0
  50. package/types/random.ts +1 -0
  51. package/types/range.jn +27 -0
  52. package/types/set.jn +139 -0
  53. package/types/set.ts +209 -0
  54. package/types/string.jn +33 -0
  55. package/types/string.ts +1 -0
  56. package/types/tuple.jn +11 -0
  57. 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,195 @@
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 { Range } from './juno';
3
+ export type { Error } from './juno';
4
+ export type { Iterable } from './juno-types';
5
+ /** Runtime module table used to resolve JunoScript import specifiers. */
6
+ export declare const modules: {
7
+ readonly juno: Record<string, any>;
8
+ readonly 'juno:node': {
9
+ console: {
10
+ args: string[];
11
+ read(encoding?: string): string;
12
+ readLines(encoding?: string): string[];
13
+ assert(condition?: boolean, ...data: any[]): void;
14
+ clear(): void;
15
+ count(label?: string): void;
16
+ countReset(label?: string): void;
17
+ debug(...data: any[]): void;
18
+ dir(item?: any, options?: any): void;
19
+ dirxml(...data: any[]): void;
20
+ error(...data: any[]): void;
21
+ group(...data: any[]): void;
22
+ groupCollapsed(...data: any[]): void;
23
+ groupEnd(): void;
24
+ info(...data: any[]): void;
25
+ log(...data: any[]): void;
26
+ table(tabularData?: any, properties?: string[]): void;
27
+ time(label?: string): void;
28
+ timeEnd(label?: string): void;
29
+ timeLog(label?: string, ...data: any[]): void;
30
+ timeStamp(label?: string): void;
31
+ trace(...data: any[]): void;
32
+ warn(...data: any[]): void;
33
+ Console: {
34
+ prototype: import("node:console").Console;
35
+ new (stdout: NodeJS.WritableStream, stderr?: NodeJS.WritableStream, ignoreErrors?: boolean): import("node:console").Console;
36
+ new (options: import("node:console").ConsoleOptions): import("node:console").Console;
37
+ };
38
+ profile(label?: string): void;
39
+ profileEnd(label?: string): void;
40
+ };
41
+ readEnv: typeof import("./juno-node").readEnv;
42
+ };
43
+ readonly 'juno:types': {
44
+ Partial: (input: unknown) => {
45
+ __junoTypeConstructor?: true;
46
+ __junoTypeDescriptor?: true;
47
+ typeNode?: import("../Lexer/parser").TypeNode;
48
+ };
49
+ Required: (input: unknown) => {
50
+ __junoTypeConstructor?: true;
51
+ __junoTypeDescriptor?: true;
52
+ typeNode?: import("../Lexer/parser").TypeNode;
53
+ };
54
+ Readonly: (input: unknown) => {
55
+ __junoTypeConstructor?: true;
56
+ __junoTypeDescriptor?: true;
57
+ typeNode?: import("../Lexer/parser").TypeNode;
58
+ };
59
+ Pick: (input: unknown, keys: unknown) => {
60
+ __junoTypeConstructor?: true;
61
+ __junoTypeDescriptor?: true;
62
+ typeNode?: import("../Lexer/parser").TypeNode;
63
+ };
64
+ Omit: (input: unknown, keys: unknown) => {
65
+ __junoTypeConstructor?: true;
66
+ __junoTypeDescriptor?: true;
67
+ typeNode?: import("../Lexer/parser").TypeNode;
68
+ };
69
+ KeyOf: (input: unknown) => {
70
+ __junoTypeConstructor?: true;
71
+ __junoTypeDescriptor?: true;
72
+ typeNode?: import("../Lexer/parser").TypeNode;
73
+ };
74
+ Exclude: (input: unknown, excluded: unknown) => {
75
+ __junoTypeConstructor?: true;
76
+ __junoTypeDescriptor?: true;
77
+ typeNode?: import("../Lexer/parser").TypeNode;
78
+ };
79
+ Items: () => (string | number)[];
80
+ };
81
+ readonly 'juno:async': {
82
+ Promise: PromiseConstructor;
83
+ setTimeout: typeof import("./async").setTimeout;
84
+ setInterval: typeof import("./async").setInterval;
85
+ clearTimeout: typeof import("./async").clearTimeout;
86
+ clearInterval: typeof import("./async").clearInterval;
87
+ setImmediate: typeof import("./async").setImmediate;
88
+ clearImmediate: typeof import("./async").clearImmediate;
89
+ queueMicrotask: typeof import("./async").queueMicrotask;
90
+ fetch: typeof import("./async").fetch;
91
+ };
92
+ readonly 'juno:node:fs': {
93
+ readFile: typeof import("./juno-node-fs").readFile;
94
+ writeFile: typeof import("./juno-node-fs").writeFile;
95
+ appendFile: typeof import("./juno-node-fs").appendFile;
96
+ exists: typeof import("./juno-node-fs").exists;
97
+ mkdir: typeof import("./juno-node-fs").mkdir;
98
+ readdir: typeof import("./juno-node-fs").readdir;
99
+ remove: typeof import("./juno-node-fs").remove;
100
+ rename: typeof import("./juno-node-fs").rename;
101
+ copyFile: typeof import("./juno-node-fs").copyFile;
102
+ stat: typeof import("./juno-node-fs").stat;
103
+ readFileSync: typeof import("./juno-node-fs").readFileSync;
104
+ writeFileSync: typeof import("./juno-node-fs").writeFileSync;
105
+ appendFileSync: typeof import("./juno-node-fs").appendFileSync;
106
+ existsSync: typeof import("./juno-node-fs").existsSync;
107
+ mkdirSync: typeof import("./juno-node-fs").mkdirSync;
108
+ readdirSync: typeof import("./juno-node-fs").readdirSync;
109
+ removeSync: typeof import("./juno-node-fs").removeSync;
110
+ renameSync: typeof import("./juno-node-fs").renameSync;
111
+ copyFileSync: typeof import("./juno-node-fs").copyFileSync;
112
+ statSync: typeof import("./juno-node-fs").statSync;
113
+ };
114
+ readonly 'juno:test': {
115
+ expect: import("./juno-test").JunoExpect;
116
+ Mock: typeof import("./juno-test").Mock;
117
+ spyOn: {
118
+ <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;
119
+ <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;
120
+ };
121
+ replaceProperty: <T extends object, K extends keyof T>(object: T, propertyKey: K, value: T[K]) => import("jest-mock").Replaced<T[K]>;
122
+ isMockFunction: {
123
+ <T extends import("jest-mock").FunctionLike = import("jest-mock").UnknownFunction>(fn: import("jest-mock").MockInstance<T>): fn is import("jest-mock").MockInstance<T>;
124
+ <P extends Array<unknown>, R>(fn: (...args: P) => R): fn is import("jest-mock").Mock<(...args: P) => R>;
125
+ (fn: unknown): fn is import("jest-mock").Mock<import("jest-mock").UnknownFunction>;
126
+ };
127
+ clearAllMocks: () => void;
128
+ resetAllMocks: () => void;
129
+ restoreAllMocks: () => void;
130
+ describe: typeof import("./juno-test").describe;
131
+ test: typeof import("./juno-test").test;
132
+ it: typeof import("./juno-test").test;
133
+ beforeEach: typeof import("./juno-test").beforeEach;
134
+ afterEach: typeof import("./juno-test").afterEach;
135
+ useFakeTimers: (fakeTimersConfig?: {
136
+ advanceTimers?: boolean | number;
137
+ doNotFake?: Array<"Date" | "hrtime" | "nextTick" | "performance" | "queueMicrotask" | "requestAnimationFrame" | "cancelAnimationFrame" | "requestIdleCallback" | "cancelIdleCallback" | "setImmediate" | "clearImmediate" | "setInterval" | "clearInterval" | "setTimeout" | "clearTimeout" | "Temporal">;
138
+ now?: number | Date | {
139
+ epochMilliseconds: number;
140
+ };
141
+ timerLimit?: number;
142
+ legacyFakeTimers?: false;
143
+ }) => void;
144
+ useRealTimers: () => void;
145
+ clearAllTimers: () => void;
146
+ runAllTimers: () => void;
147
+ runAllTimersAsync: () => Promise<void>;
148
+ runOnlyPendingTimers: () => void;
149
+ advanceTimersByTime: (msToRun: number | import("@sinonjs/fake-timers").TemporalDuration) => void;
150
+ advanceTimersByTimeAsync: (msToRun: number | import("@sinonjs/fake-timers").TemporalDuration) => Promise<void>;
151
+ advanceTimersToNextTimer: (steps?: number) => void;
152
+ setSystemTime: (now?: number | Date | import("@sinonjs/fake-timers").TemporalTimelike) => void;
153
+ getTimerCount: () => number;
154
+ };
155
+ readonly types: {
156
+ Partial: (input: unknown) => {
157
+ __junoTypeConstructor?: true;
158
+ __junoTypeDescriptor?: true;
159
+ typeNode?: import("../Lexer/parser").TypeNode;
160
+ };
161
+ Required: (input: unknown) => {
162
+ __junoTypeConstructor?: true;
163
+ __junoTypeDescriptor?: true;
164
+ typeNode?: import("../Lexer/parser").TypeNode;
165
+ };
166
+ Readonly: (input: unknown) => {
167
+ __junoTypeConstructor?: true;
168
+ __junoTypeDescriptor?: true;
169
+ typeNode?: import("../Lexer/parser").TypeNode;
170
+ };
171
+ Pick: (input: unknown, keys: unknown) => {
172
+ __junoTypeConstructor?: true;
173
+ __junoTypeDescriptor?: true;
174
+ typeNode?: import("../Lexer/parser").TypeNode;
175
+ };
176
+ Omit: (input: unknown, keys: unknown) => {
177
+ __junoTypeConstructor?: true;
178
+ __junoTypeDescriptor?: true;
179
+ typeNode?: import("../Lexer/parser").TypeNode;
180
+ };
181
+ KeyOf: (input: unknown) => {
182
+ __junoTypeConstructor?: true;
183
+ __junoTypeDescriptor?: true;
184
+ typeNode?: import("../Lexer/parser").TypeNode;
185
+ };
186
+ Exclude: (input: unknown, excluded: unknown) => {
187
+ __junoTypeConstructor?: true;
188
+ __junoTypeDescriptor?: true;
189
+ typeNode?: import("../Lexer/parser").TypeNode;
190
+ };
191
+ Items: () => (string | number)[];
192
+ };
193
+ };
194
+ export type ModuleName = keyof typeof modules;
195
+ export declare function resolveModule(name: string): (typeof modules)[ModuleName];
@@ -0,0 +1,31 @@
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.Range = 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, "Range", { enumerable: true, get: function () { return juno_2.Range; } });
16
+ /** Runtime module table used to resolve JunoScript import specifiers. */
17
+ exports.modules = {
18
+ juno: juno_1.default,
19
+ 'juno:node': juno_node_1.default,
20
+ 'juno:types': types_1.default,
21
+ 'juno:async': async_1.default,
22
+ 'juno:node:fs': juno_node_fs_1.default,
23
+ 'juno:test': juno_test_1.default,
24
+ types: types_1.default
25
+ };
26
+ function resolveModule(name) {
27
+ if (name !== 'juno' && name !== 'juno:node' && name !== 'juno:types' && name !== 'juno:async' && name !== 'juno:node:fs' && name !== 'juno:test' && name !== 'types') {
28
+ throw new Error(`Unknown JunoScript module '${name}'`);
29
+ }
30
+ return exports.modules[name];
31
+ }
@@ -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;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.console = void 0;
4
+ exports.readEnv = readEnv;
5
+ const node_fs_1 = require("node:fs");
6
+ const node_util_1 = require("node:util");
7
+ const pathType = {
8
+ kind: 'ObjectType',
9
+ members: [{ name: 'path', type: { kind: 'NamedType', name: 'string' }, optional: false, readonly: false, constant: false }]
10
+ };
11
+ /** Read a UTF-8 .env file without modifying process.env. */
12
+ function readEnv(source) {
13
+ return (0, node_util_1.parseEnv)((0, node_fs_1.readFileSync)(typeof source === 'string' ? source : source.path, 'utf8'));
14
+ }
15
+ /** Node.js console module with synchronous stdin helpers. */
16
+ exports.console = {
17
+ ...globalThis.console,
18
+ /** Arguments passed after the JunoScript file: junode <file> [args...]. */
19
+ get args() {
20
+ return process.argv.slice(3);
21
+ },
22
+ read(encoding = 'utf8') {
23
+ return readLine(encoding);
24
+ },
25
+ readLines(encoding = 'utf8') {
26
+ const input = readInput(encoding, true);
27
+ return input;
28
+ }
29
+ };
30
+ function readInput(encoding, lines) {
31
+ const chunks = [];
32
+ const buffer = Buffer.alloc(1024);
33
+ let bytesRead;
34
+ // Read until EOF. This API is intentionally synchronous to match juno:node.
35
+ while ((bytesRead = (0, node_fs_1.readSync)(0, buffer, 0, buffer.length, null)) > 0) {
36
+ chunks.push(Buffer.from(buffer.subarray(0, bytesRead)));
37
+ }
38
+ const value = Buffer.concat(chunks).toString(encoding);
39
+ if (!lines)
40
+ return value;
41
+ return value.length === 0 ? [] : value.split(/\r?\n/).filter((line, index, all) => !(line === '' && index === all.length - 1));
42
+ }
43
+ function readLine(encoding) {
44
+ const bytes = [];
45
+ const buffer = Buffer.alloc(1);
46
+ while ((0, node_fs_1.readSync)(0, buffer, 0, 1, null) > 0) {
47
+ if (buffer[0] === 10)
48
+ break;
49
+ if (buffer[0] !== 13)
50
+ bytes.push(buffer[0]);
51
+ }
52
+ return Buffer.from(bytes).toString(encoding);
53
+ }
54
+ const junoNode = { console: exports.console, readEnv };
55
+ Object.defineProperty(junoNode, '__junoTypes', { value: { Path: { value: pathType, generics: [] } } });
56
+ exports.default = junoNode;