Skip to content

Commit 506aa86

Browse files
committed
wip: migrating towards ESM
1 parent ef0bdfe commit 506aa86

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+519
-483
lines changed

local.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/bin/sh
22

3-
tmp=`mktemp`
3+
tmp=`mktemp`.js
44

55
$TROUPE/bin/troupec $1 --output=$tmp
6+
67
if [ $? -eq 0 ]; then
7-
node --stack-trace-limit=1000 $TROUPE/rt/built/troupe.js -f=$tmp --localonly #--debug
8+
node --stack-trace-limit=1000 $TROUPE/rt/built/troupe.mjs -f=$tmp --localonly #--debug
89
rm $tmp
910
else
1011
exit $?

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"license": "ISC",
1616
"dependencies": {
1717
"@nodeutils/defaults-deep": "^1.1.0",
18-
"chalk": "^4.1.0",
18+
"@types/node": "^18.15.3",
19+
"chalk": "^5.2.0",
1920
"find-free-port": "^2.0.0",
2021
"it-length-prefixed": "^3.0.1",
2122
"it-pipe": "^1.1.0",

rt/src/Asserts.ts renamed to rt/src/Asserts.mts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
import { Thread, Capability } from './Thread';
1+
import { Thread, Capability } from './Thread.mjs';
22

3-
const { isListFlagSet, isTupleFlagSet } = require('./ValuesUtil.js');
4-
const proc = require('./process.js');
3+
import { isListFlagSet, isTupleFlagSet } from './ValuesUtil.mjs';
4+
import * as proc from './process.mjs';
55
const ProcessID = proc.ProcessID;
6-
import { Level } from './Level';
7-
import { Authority } from './Authority'
8-
import options = require('./options.js');
9-
import { TroupeType } from './TroupeTypes';
10-
const levels = options;
6+
import { Level } from './Level.mjs';
7+
import { Authority } from './Authority.mjs'
8+
import * as levels from './options.mjs';
9+
import { TroupeType } from './TroupeTypes.mjs';
1110
const flowsTo = levels.flowsTo;
1211

13-
import { getRuntimeObject } from './SysState';
14-
import { __nodeManager } from './NodeManager';
15-
import { TroupeAggregateRawValue, TroupeRawValue } from './TroupeRawValue';
16-
import { LVal } from './Lval';
12+
import { getRuntimeObject } from './SysState.mjs';
13+
import { __nodeManager } from './NodeManager.mjs';
14+
import { TroupeAggregateRawValue, TroupeRawValue } from './TroupeRawValue.mjs';
15+
// import { LVal } from './Lval';
1716

1817
function _thread() {
1918
return getRuntimeObject().__sched.__currentThread

rt/src/Atom.ts renamed to rt/src/Atom.mts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import runId from "./runId"
2-
import { TroupeType } from "./TroupeTypes"
3-
import { TroupeRawValue } from "./TroupeRawValue";
4-
import levels = require ('./options')
1+
import runId from "./runId.mjs"
2+
import { TroupeType } from "./TroupeTypes.mjs"
3+
import { TroupeRawValue } from "./TroupeRawValue.mjs";
4+
import * as levels from './options.mjs'
55

66
let rt_uuid = runId
77

rt/src/Authority.ts renamed to rt/src/Authority.mts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Level } from "./Level";
2-
import { BOT } from "./options";
1+
import { Level } from "./Level.mjs";
2+
import { BOT } from "./options.mjs";
33

4-
import { TroupeRawValue } from "./TroupeRawValue";
5-
import { TroupeType } from "./TroupeTypes";
4+
import { TroupeRawValue } from "./TroupeRawValue.mjs";
5+
import { TroupeType } from "./TroupeTypes.mjs";
66

77
export class Authority implements TroupeRawValue {
88
authorityLevel: Level;

rt/src/BaseFunction.ts renamed to rt/src/BaseFunction.mts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {ClosureType, TroupeType} from './TroupeTypes'
2-
import {TroupeAggregateRawValue} from './TroupeRawValue'
3-
import levels from './options'
4-
import { getRuntimeObject } from './SysState'
1+
import {ClosureType, TroupeType} from './TroupeTypes.mjs'
2+
import {TroupeAggregateRawValue} from './TroupeRawValue.mjs'
3+
import * as levels from './options.mjs'
4+
import { getRuntimeObject } from './SysState.mjs'
55

66
export function BaseFunctionWithExplicitArg(f, name = null) : TroupeAggregateRawValue{
77

rt/src/EqualityChecker.ts renamed to rt/src/EqualityChecker.mts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {TroupeType} from './TroupeTypes'
2-
import {LVal} from './Lval'
3-
const proc = require('./process.js');
4-
import levels = require ('./options')
1+
import {TroupeType} from './TroupeTypes.mjs'
2+
import {LVal} from './Lval.mjs'
3+
import * as proc from './process.mjs'
4+
import * as levels from './options.mjs'
55

66

77

rt/src/Level.ts renamed to rt/src/Level.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { TroupeType } from "./TroupeTypes";
2-
import { TroupeRawValue } from "./TroupeRawValue";
1+
import { TroupeType } from "./TroupeTypes.mjs";
2+
import { TroupeRawValue } from "./TroupeRawValue.mjs";
33
// import levels from './options';
44

55
export abstract class Level implements TroupeRawValue {

rt/src/LocalObject.ts renamed to rt/src/LocalObject.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {TroupeType} from './TroupeTypes'
2-
import {TroupeRawValue} from './TroupeRawValue'
3-
import levels from './options'
1+
import {TroupeType} from './TroupeTypes.mjs'
2+
import {TroupeRawValue} from './TroupeRawValue.mjs'
3+
import * as levels from './options.mjs'
44

55
export class LocalObject implements TroupeRawValue {
66
_troupeType : TroupeType

rt/src/Lval.ts renamed to rt/src/Lval.mts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import levels = require ('./options')
2-
import { Level } from "./Level";
3-
import * as Ty from './TroupeTypes';
4-
import { TroupeRawValue } from './TroupeRawValue';
1+
import * as levels from './options.mjs'
2+
import { Level } from "./Level.mjs";
3+
import * as Ty from './TroupeTypes.mjs';
4+
import { TroupeRawValue } from './TroupeRawValue.mjs';
55

66
export class LVal implements TroupeRawValue{
77
val: any;

rt/src/MailboxInterface.ts renamed to rt/src/MailboxInterface.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Level } from "./Level";
2-
import { ReceiveTaintAction } from "./ReceiveTaintAction";
1+
import { Level } from "./Level.mjs";
2+
import { ReceiveTaintAction } from "./ReceiveTaintAction.mjs";
33

44
export interface MailboxInterface {
55
// rcv(pc: any, pc2: any, handlers: any, boost_level: any, taintLimit?: Level, taintAction?: ReceiveTaintAction );

rt/src/MailboxProcessor.ts renamed to rt/src/MailboxProcessor.mts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
import { assertIsHandler, assertIsNTuple, assertIsFunction } from "./Asserts";
2-
import { mkTuple } from "./ValuesUtil";
3-
import { SchedulerInterface } from "./SchedulerInterface";
4-
import { __unit } from "./UnitVal";
5-
import { RuntimeInterface } from "./RuntimeInterface";
6-
7-
// const {LVal, MbVal} = require('./Lval.js');
8-
const yargs = require ('yargs')
1+
import { assertIsHandler, assertIsNTuple, assertIsFunction } from "./Asserts.mjs";
2+
import { mkTuple } from "./ValuesUtil.mjs";
3+
import { SchedulerInterface } from "./SchedulerInterface.mjs";
4+
import { __unit } from "./UnitVal.mjs";
5+
import { RuntimeInterface } from "./RuntimeInterface.mjs";
6+
7+
import yargs from 'yargs'
98
let logLevel = yargs.argv.debugmailbox ? 'debug': 'info'
10-
const logger = require('./logger.js').mkLogger('MBX', logLevel);
11-
const debug = x => logger.debug(x)
12-
const SandboxStatus = require('./SandboxStatus.js').HandlerState;
13-
import levels, {lub,flowsTo} from './options'
14-
import { ReceiveTaintAction } from "./ReceiveTaintAction";
15-
import { LVal, MbVal } from "./Lval";
16-
import { MailboxInterface } from "./MailboxInterface";
17-
import { Level } from "./Level";
18-
import { Thread } from "./Thread";
9+
10+
import { mkLogger } from './logger.mjs'
11+
const logger = mkLogger('MBX', logLevel);
12+
const debug = x => logger.debug(x);
13+
import { HandlerState as SandboxStatus } from './SandboxStatus.mjs' ;
14+
import {lub,flowsTo} from './options.mjs'
15+
import * as levels from './options.mjs'
16+
import { ReceiveTaintAction } from "./ReceiveTaintAction.mjs";
17+
import { LVal, MbVal } from "./Lval.mjs";
18+
import { MailboxInterface } from "./MailboxInterface.mjs";
19+
import { Level } from "./Level.mjs";
20+
import { Thread } from "./Thread.mjs";
1921

2022

2123
function createMessage(msg, fromNodeId, pc) {

rt/src/NodeManager.ts renamed to rt/src/NodeManager.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

3-
const fs = require('fs')
4-
import levels from "./options";
3+
import * as fs from 'node:fs'
4+
import * as levels from "./options.mjs";
55
import yargs from 'yargs'
66

77
class Node {
@@ -19,7 +19,7 @@ class NodeManager {
1919
constructor () {
2020

2121
let aliases = yargs.argv.aliases
22-
? JSON.parse ( fs.readFileSync(yargs.argv.aliases, 'utf8'))
22+
? JSON.parse ( fs.readFileSync(yargs.argv.aliases as string, 'utf8'))
2323
: {}
2424

2525

rt/src/RawClosure.ts renamed to rt/src/RawClosure.mts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {TroupeAggregateRawValue} from './TroupeRawValue'
2-
import {ClosureType, TroupeType} from './TroupeTypes'
3-
import levels from './options'
1+
import {TroupeAggregateRawValue} from './TroupeRawValue.mjs'
2+
import {ClosureType, TroupeType} from './TroupeTypes.mjs'
3+
import * as levels from './options.mjs'
44
export function RawClosure (e, _t, f) : TroupeAggregateRawValue {
55
let closure:any = () => {
66
return f (e)

rt/src/RawList.ts renamed to rt/src/RawList.mts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {TroupeType} from './TroupeTypes'
2-
import {TroupeAggregateRawValue} from './TroupeRawValue'
3-
import {LVal, listStringRep} from './Lval'
4-
import { Level } from './Level'
5-
import levels from './options'
1+
import {TroupeType} from './TroupeTypes.mjs'
2+
import {TroupeAggregateRawValue} from './TroupeRawValue.mjs'
3+
import {LVal, listStringRep} from './Lval.mjs'
4+
import { Level } from './Level.mjs'
5+
import * as levels from './options.mjs'
66

77

88
export abstract class RawList implements TroupeAggregateRawValue {
File renamed without changes.

rt/src/Record.ts renamed to rt/src/Record.mts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {TroupeType} from './TroupeTypes'
2-
import {TroupeAggregateRawValue} from './TroupeRawValue'
3-
import {LVal, listStringRep} from './Lval'
4-
import { Level } from './Level'
5-
import levels from './options'
6-
import { assertIsRecord } from './Asserts'
1+
import {TroupeType} from './TroupeTypes.mjs'
2+
import {TroupeAggregateRawValue} from './TroupeRawValue.mjs'
3+
import {LVal, listStringRep} from './Lval.mjs'
4+
import { Level } from './Level.mjs'
5+
import * as levels from './options.mjs'
6+
import { assertIsRecord } from './Asserts.mjs'
77

88

99
export class Record implements TroupeAggregateRawValue {

rt/src/RuntimeInterface.ts renamed to rt/src/RuntimeInterface.mts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { SchedulerInterface } from "./SchedulerInterface";
2-
import { Thread } from "./Thread";
3-
import { LVal } from './Lval'
4-
import { MailboxInterface } from "./MailboxInterface";
1+
import { SchedulerInterface } from "./SchedulerInterface.mjs";
2+
import { Thread } from "./Thread.mjs";
3+
import { LVal } from './Lval.mjs'
4+
import { MailboxInterface } from "./MailboxInterface.mjs";
55

66
export interface RuntimeInterface {
77
cleanup(): Promise<void>
@@ -13,7 +13,7 @@ export interface RuntimeInterface {
1313
debug(arg0: string);
1414
__sched: SchedulerInterface
1515
__mbox : MailboxInterface
16-
sendMessageNoChecks(toPid: any, message: import("./Lval").LVal, arg2?: boolean): any;
16+
sendMessageNoChecks(toPid: any, message: import("./Lval.mjs").LVal, arg2?: boolean): any;
1717
ret(arg0: any);
1818
// ret_raw ()
1919
// tailcall(funclos: any, __unit: any);

rt/src/SandboxStatus.ts renamed to rt/src/SandboxStatus.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Level } from "./Level";
1+
import { Level } from "./Level.mjs";
22

33
export interface HnState {
44
isNormal (): boolean

rt/src/Scheduler.ts renamed to rt/src/Scheduler.mts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
'use strict';
22
import { v4 as uuidv4} from 'uuid'
3-
import { Thread } from './Thread';
4-
import runId from './runId';
5-
import { __unit } from './UnitVal';
6-
import { mkTuple } from './ValuesUtil';
7-
import { SchedulerInterface } from './SchedulerInterface';
8-
import { RuntimeInterface } from './RuntimeInterface';
9-
import { LVal } from './Lval.js'
10-
import {ProcessID, pid_equals} from './process'
11-
import SandboxStatus from './SandboxStatus'
12-
import {ThreadError, TroupeError} from './TroupeError'
13-
import levels, {lub} from './options'
14-
const yargs = require('yargs');
3+
import { Thread } from './Thread.mjs';
4+
import runId from './runId.mjs';
5+
import { __unit } from './UnitVal.mjs';
6+
import { mkTuple } from './ValuesUtil.mjs';
7+
import { SchedulerInterface } from './SchedulerInterface.mjs';
8+
import { RuntimeInterface } from './RuntimeInterface.mjs';
9+
import { LVal } from './Lval.mjs'
10+
import {ProcessID, pid_equals} from './process.mjs'
11+
import SandboxStatus from './SandboxStatus.mjs'
12+
import {ThreadError, TroupeError} from './TroupeError.mjs'
13+
import {lub} from './options.mjs'
14+
// import * as levels from './options'
15+
import yargs from 'yargs';
1516
const showStack = yargs.argv.showStack
16-
const logger = require('./logger.js').mkLogger('scheduler');
17+
import { mkLogger } from './logger.mjs'
18+
const logger = mkLogger('scheduler');
1719
const info = x => logger.info(x)
1820
const debug = x => logger.debug(x)
1921

rt/src/SchedulerInterface.ts renamed to rt/src/SchedulerInterface.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Thread } from "./Thread";
1+
import { Thread } from "./Thread.mjs";
22

33
export interface SchedulerInterface {
44
// tailToTroupeFun(f: any, arg:any)

rt/src/SysState.ts renamed to rt/src/SysState.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RuntimeInterface } from "./RuntimeInterface";
1+
import { RuntimeInterface } from "./RuntimeInterface.mjs";
22

33
let __state: RuntimeInterface = null;
44

rt/src/Thread.ts renamed to rt/src/Thread.mts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
import levels = require ('./options')
2-
import { LVal, LValCopyAt } from './Lval.js';
3-
import { HandlerError, ImplementationError, StrThreadError } from './TroupeError.js';
1+
import * as levels from './options.mjs'
2+
import { LVal, LValCopyAt } from './Lval.mjs';
3+
import { HandlerError, ImplementationError, StrThreadError } from './TroupeError.mjs';
44
import yargs from 'yargs';
55
let logLevel = yargs.argv.debug? 'debug' : 'info'
6-
const logger = require('./logger.js').mkLogger('thread', logLevel);
6+
import { mkLogger } from './logger.mjs'
7+
const logger = mkLogger('thread', logLevel);
78
const debug = x => logger.debug(x)
89
let lub = levels.lub;
910
let flowsTo = levels.flowsTo
1011
import { v4 as uuidv4} from 'uuid'
1112

12-
import { TroupeType } from './TroupeTypes'
13-
import { assertIsFunction, assertIsFunctionRaw } from './Asserts';
14-
import { RuntimeInterface } from './RuntimeInterface';
15-
import { __unit } from './UnitVal';
16-
import { Level } from './Level';
17-
import { SchedulerInterface } from './SchedulerInterface';
18-
import { getRuntimeObject } from './SysState';
19-
import SandboxStatus, { HnState } from './SandboxStatus';
20-
import HandlerState from './SandboxStatus';
13+
import { TroupeType } from './TroupeTypes.mjs'
14+
import { assertIsFunction, assertIsFunctionRaw } from './Asserts.mjs'
15+
import { RuntimeInterface } from './RuntimeInterface.mjs';
16+
import { __unit } from './UnitVal.mjs';
17+
import { Level } from './Level.mjs';
18+
import { SchedulerInterface } from './SchedulerInterface.mjs';
19+
import { getRuntimeObject } from './SysState.mjs';
20+
import SandboxStatus, { HnState } from './SandboxStatus.mjs';
21+
import HandlerState from './SandboxStatus.mjs';
2122

2223

2324
let isPiniMode = yargs.argv.pini?true:false;

rt/src/TroupeError.ts renamed to rt/src/TroupeError.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Thread } from "./Thread";
1+
import { Thread } from "./Thread.mjs";
22
// import colors = require('colors/safe');
33
import chalk from 'chalk'
4-
import { SchedulerInterface } from "./SchedulerInterface";
4+
import { SchedulerInterface } from "./SchedulerInterface.mjs";
55

66
export abstract class TroupeError extends Error {
77
abstract handleError (sched: SchedulerInterface) : void

rt/src/TroupeRawValue.ts renamed to rt/src/TroupeRawValue.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {TroupeType} from './TroupeTypes'
2-
import { Level } from './Level'
1+
import {TroupeType} from './TroupeTypes.mjs'
2+
import { Level } from './Level.mjs'
33

44
export interface TroupeRawValue {
55
_troupeType: TroupeType;
File renamed without changes.

rt/src/TrustManager.ts renamed to rt/src/TrustManager.mts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import levels from "./options";
1+
import * as levels from "./options.mjs";
22
import yargs from "yargs";
3-
import fs from 'fs'
4-
import { Level } from "./Level";
5-
import { __nodeManager } from "./NodeManager";
3+
import * as fs from 'node:fs';
4+
import { Level } from "./Level.mjs";
5+
import { __nodeManager } from "./NodeManager.mjs";
66
const { readFile } = fs.promises
77

88

99

1010
let logLevel = yargs.argv.debug ? 'debug' : 'info';
11-
const logger = require('./logger.js').mkLogger('RTM', logLevel);
11+
import { mkLogger } from './logger.mjs'
12+
const logger = mkLogger('RTM', logLevel);
1213

1314

1415
export let _trustMap = {}

0 commit comments

Comments
 (0)