Skip to content

Commit

Permalink
更新 TS 项目用 esmodule
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Oct 21, 2024
1 parent 18ff7e6 commit 9a917c3
Show file tree
Hide file tree
Showing 180 changed files with 703 additions and 717 deletions.
1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
更新 TS 项目用 esmodule
删除类型系统,并补充相关笔记
更改命名惯例为 lisp-case

Expand Down
9 changes: 1 addition & 8 deletions bin/inet.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
#!/usr/bin/env node

const process = require("process")

process.on("unhandledRejection", (error) => {
console.error(error)
process.exit(1)
})

const { createCommandRunner } = require("../lib/command-line")
import { createCommandRunner } from "../lib/command-line/index.js"

createCommandRunner().run()
20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
"name": "@cicada-lang/inet",
"version": "0.2.0",
"repository": "github:cicada-lang/inet",
"license": "GPL-3.0-or-later",
"type": "module",
"main": "./lib/index.js",
"files": [
"lib"
"lib",
"src"
],
"bin": {
"inet": "bin/inet.js"
Expand All @@ -18,13 +21,6 @@
"test": "npm run test:ts && npm run test:inet && npm run test:inet-error",
"format": "prettier src docs --write"
},
"devDependencies": {
"@types/node": "^20.8.10",
"@xieyuheng/test-runner": "^0.2.10",
"prettier": "^3.0.3",
"prettier-plugin-organize-imports": "^3.2.3",
"typescript": "^5.2.2"
},
"dependencies": {
"@cicada-lang/framework": "^0.1.6",
"@cicada-lang/partech": "^0.2.5",
Expand All @@ -33,5 +29,11 @@
"picocolors": "^1.0.0",
"vitest": "^0.34.6"
},
"license": "GPL-3.0-or-later"
"devDependencies": {
"@types/node": "^20.8.10",
"@xieyuheng/test-runner": "^0.2.10",
"prettier": "^3.0.3",
"prettier-plugin-organize-imports": "^3.2.3",
"typescript": "^5.2.2"
}
}
4 changes: 1 addition & 3 deletions src/app/App.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { AppConfig } from "./AppConfig"
import { AppHome } from "./AppHome.js"
import { AppReplEventHandler } from "./AppReplEventHandler"
import { AppReplEventHandler } from "./AppReplEventHandler.js"

export class App {
home = new AppHome()
config = new AppConfig()
replEventHandler = new AppReplEventHandler()
}
9 changes: 0 additions & 9 deletions src/app/AppConfig.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/AppHome.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LocalFileStore } from "@cicada-lang/framework/lib/file-stores/LocalFileStore"
import { LocalFileStore } from "@cicada-lang/framework/lib/file-stores/LocalFileStore.js"
import os from "os"
import Path from "path"
import process from "process"
Expand Down
11 changes: 7 additions & 4 deletions src/app/AppReplEventHandler.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { ReplEvent, ReplEventHandler } from "@cicada-lang/framework/lib/repl"
import {
ReplEventHandler,
type ReplEvent,
} from "@cicada-lang/framework/lib/repl/index.js"
import { ParsingError } from "@cicada-lang/partech"
import fs from "fs"
import { relative } from "node:path"
import process from "process"
import { app } from "../app"
import { Fetcher } from "../fetcher/Fetcher.js"
import { Report } from "../lang/errors/Report.js"
import { parseStmts } from "../lang/syntax/index.js"
import { Loader } from "../loader"
import { Loader } from "../loader/index.js"
import { version } from "../version.js"

const fetcher = new Fetcher()

Expand Down Expand Up @@ -42,7 +45,7 @@ export class AppReplEventHandler extends ReplEventHandler {
loader = new Loader({ fetcher })

greeting(): void {
console.log(`iNet Cute ${app.config.packageJson.version}`)
console.log(`iNet Cute ${version}`)
}

async handle(event: ReplEvent): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion src/app/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { App } from "./App"
import { App } from "./App.js"

export const app = new App()
4 changes: 2 additions & 2 deletions src/command-line/commands/Default.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Command, CommandRunner } from "@xieyuheng/command-line"
import { ty } from "@xieyuheng/ty"
import { app } from "../../app/index.js"
import { version } from "../../version.js"
import * as Commands from "./index.js"

type Args = { path?: string }
Expand All @@ -26,7 +26,7 @@ export class Default extends Command<Args, Opts> {
}

if (argv["version"]) {
console.log(app.config.packageJson.version)
console.log(version)
return
}

Expand Down
4 changes: 2 additions & 2 deletions src/command-line/commands/Repl.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ReadlineRepl } from "@cicada-lang/framework/lib/repls/readline-repl"
import { ReadlineRepl } from "@cicada-lang/framework/lib/repls/readline-repl/index.js"
import { Command, CommandRunner } from "@xieyuheng/command-line"
import Path from "path"
import { app } from "../../app"
import { app } from "../../app/index.js"

type Args = {}

Expand Down
10 changes: 5 additions & 5 deletions src/command-line/commands/Run.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ParsingError } from "@cicada-lang/partech/lib/errors"
import { ParsingError } from "@cicada-lang/partech"
import { Command, CommandRunner } from "@xieyuheng/command-line"
import { ty } from "@xieyuheng/ty"
import fs from "node:fs"
import { relative } from "node:path"
import process from "node:process"
import { Fetcher } from "../../fetcher"
import { Report } from "../../lang/errors/Report"
import { Loader } from "../../loader"
import { createURL } from "../../utils/createURL"
import { Fetcher } from "../../fetcher/index.js"
import { Report } from "../../lang/errors/Report.js"
import { Loader } from "../../loader/index.js"
import { createURL } from "../../utils/createURL.js"

type Args = { path: string }
type Opts = {}
Expand Down
8 changes: 4 additions & 4 deletions src/command-line/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from "@xieyuheng/command-line/lib/commands"
export * from "./Default"
export * from "./Repl"
export * from "./Run"
export * from "@xieyuheng/command-line/lib/commands/index.js"
export * from "./Default.js"
export * from "./Repl.js"
export * from "./Run.js"
2 changes: 1 addition & 1 deletion src/command-line/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CommandRunner, CommandRunners } from "@xieyuheng/command-line"
import * as Commands from "./commands"
import * as Commands from "./commands/index.js"

export function createCommandRunner(): CommandRunner {
return new CommandRunners.CommonCommandRunner({
Expand Down
2 changes: 1 addition & 1 deletion src/fetcher/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./Fetcher"
export * from "./Fetcher.js"
36 changes: 18 additions & 18 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
export * from "./fetcher"
export * from "./lang/cap"
export * from "./lang/definition"
export * from "./lang/edge"
export * from "./lang/env"
export * from "./lang/errors"
export * from "./lang/interact"
export * from "./lang/mod"
export * from "./lang/net"
export * from "./lang/node"
export * from "./lang/port"
export * from "./lang/present"
export * from "./lang/rule"
export * from "./lang/run"
export * from "./lang/syntax"
export * from "./lang/value"
export * from "./lang/word"
export * from "./loader"
export * from "./fetcher/index.js"
export * from "./lang/cap/index.js"
export * from "./lang/definition/index.js"
export * from "./lang/edge/index.js"
export * from "./lang/env/index.js"
export * from "./lang/errors/index.js"
export * from "./lang/interact/index.js"
export * from "./lang/mod/index.js"
export * from "./lang/net/index.js"
export * from "./lang/node/index.js"
export * from "./lang/port/index.js"
export * from "./lang/present/index.js"
export * from "./lang/rule/index.js"
export * from "./lang/run/index.js"
export * from "./lang/syntax/index.js"
export * from "./lang/value/index.js"
export * from "./lang/word/index.js"
export * from "./loader/index.js"
2 changes: 1 addition & 1 deletion src/lang/builtins/Type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Env } from "../env"
import { type Env } from "../env/index.js"

export function compose(env: Env): void {
env.stack.push({
Expand Down
8 changes: 4 additions & 4 deletions src/lang/builtins/apply.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComposeOptions } from "../compose/compose"
import { composeNode } from "../compose/composeNode"
import { Env } from "../env"
import { formatValue } from "../value"
import { type ComposeOptions } from "../compose/compose.js"
import { composeNode } from "../compose/composeNode.js"
import { type Env } from "../env/index.js"
import { formatValue } from "../value/index.js"

export function compose(env: Env, options: ComposeOptions): void {
const value = env.stack.pop()
Expand Down
10 changes: 5 additions & 5 deletions src/lang/builtins/connect.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ComposeOptions } from "../compose/compose"
import { connect } from "../connect/connect"
import { Env } from "../env"
import { unifyTypes } from "../unify/unifyTypes"
import { formatValue } from "../value/formatValue"
import { type ComposeOptions } from "../compose/compose.js"
import { connect } from "../connect/connect.js"
import { type Env } from "../env/index.js"
import { unifyTypes } from "../unify/unifyTypes.js"
import { formatValue } from "../value/formatValue.js"

export function compose(env: Env, options: ComposeOptions): void {
const first = env.stack.pop()
Expand Down
6 changes: 3 additions & 3 deletions src/lang/builtins/defineBuiltinOperator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComposeOptions } from "../compose/compose"
import { Env } from "../env"
import { Mod } from "../mod"
import { type ComposeOptions } from "../compose/compose.js"
import { type Env } from "../env/index.js"
import { type Mod } from "../mod/index.js"

export function defineBuiltinOperator(
mod: Mod,
Expand Down
20 changes: 10 additions & 10 deletions src/lang/builtins/defineBuiltinOperators.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Mod } from "../mod"
import * as Type from "./Type"
import * as apply from "./apply"
import * as connect from "./connect"
import { defineBuiltinOperator } from "./defineBuiltinOperator"
import * as inspect from "./inspect"
import * as rot from "./rot"
import * as run from "./run"
import * as spread from "./spread"
import * as swap from "./swap"
import { type Mod } from "../mod/index.js"
import * as Type from "./Type.js"
import * as apply from "./apply.js"
import * as connect from "./connect.js"
import { defineBuiltinOperator } from "./defineBuiltinOperator.js"
import * as inspect from "./inspect.js"
import * as rot from "./rot.js"
import * as run from "./run.js"
import * as spread from "./spread.js"
import * as swap from "./swap.js"

export function defineBuiltinOperators(mod: Mod): void {
defineBuiltinOperator(mod, "swap", swap)
Expand Down
10 changes: 5 additions & 5 deletions src/lang/builtins/inspect.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { indent } from "../../utils/indent"
import { Env } from "../env"
import { findConnectedComponent } from "../net/findConnectedComponent"
import { formatNet } from "../net/formatNet"
import { formatValue } from "../value/formatValue"
import { indent } from "../../utils/indent.js"
import { type Env } from "../env/index.js"
import { findConnectedComponent } from "../net/findConnectedComponent.js"
import { formatNet } from "../net/formatNet.js"
import { formatValue } from "../value/formatValue.js"

export function compose(env: Env): void {
const value = env.stack[env.stack.length - 1]
Expand Down
4 changes: 2 additions & 2 deletions src/lang/builtins/rot.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Env } from "../env"
import { formatValue } from "../value/formatValue"
import { type Env } from "../env/index.js"
import { formatValue } from "../value/formatValue.js"

export function compose(env: Env): void {
const first = env.stack.pop()
Expand Down
6 changes: 3 additions & 3 deletions src/lang/builtins/run.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Env } from "../env"
import { runPort } from "../run/runPort"
import { formatValue } from "../value/formatValue"
import { type Env } from "../env/index.js"
import { runPort } from "../run/runPort.js"
import { formatValue } from "../value/formatValue.js"

export function compose(env: Env): void {
const port = env.stack.pop()
Expand Down
10 changes: 5 additions & 5 deletions src/lang/builtins/spread.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ComposeOptions } from "../compose/compose"
import { Env } from "../env"
import { findInputPorts } from "../net/findInputPorts"
import { findOutputPorts } from "../net/findOutputPorts"
import { formatValue } from "../value"
import { type ComposeOptions } from "../compose/compose.js"
import { type Env } from "../env/index.js"
import { findInputPorts } from "../net/findInputPorts.js"
import { findOutputPorts } from "../net/findOutputPorts.js"
import { formatValue } from "../value/index.js"

export function compose(env: Env, options: ComposeOptions): void {
const value = env.stack.pop()
Expand Down
4 changes: 2 additions & 2 deletions src/lang/builtins/swap.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Env } from "../env"
import { formatValue } from "../value/formatValue"
import { type Env } from "../env/index.js"
import { formatValue } from "../value/formatValue.js"

export function compose(env: Env): void {
const first = env.stack.pop()
Expand Down
16 changes: 8 additions & 8 deletions src/lang/cap/capInputPort.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { connect } from "../connect/connect"
import { Mod } from "../mod"
import { Net } from "../net"
import { addNode } from "../net/addNode"
import { findNodeEntryOrFail } from "../net/findNodeEntryOrFail"
import { findOutputPorts } from "../net/findOutputPorts"
import { Port } from "../port"
import { PortExp } from "../port/PortExp"
import { connect } from "../connect/connect.js"
import { type Mod } from "../mod/index.js"
import { addNode } from "../net/addNode.js"
import { findNodeEntryOrFail } from "../net/findNodeEntryOrFail.js"
import { findOutputPorts } from "../net/findOutputPorts.js"
import { type Net } from "../net/index.js"
import { type PortExp } from "../port/PortExp.js"
import { type Port } from "../port/index.js"

export function capInputPort(mod: Mod, net: Net, port: Port): Port {
const portExp: PortExp = {
Expand Down
14 changes: 7 additions & 7 deletions src/lang/cap/capNodeAllPorts.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Mod } from "../mod"
import { Net } from "../net"
import { findInputPorts } from "../net/findInputPorts"
import { findOutputPorts } from "../net/findOutputPorts"
import { Node } from "../node"
import { capInputPort } from "./capInputPort"
import { capOutputPort } from "./capOutputPort"
import { type Mod } from "../mod/index.js"
import { findInputPorts } from "../net/findInputPorts.js"
import { findOutputPorts } from "../net/findOutputPorts.js"
import { type Net } from "../net/index.js"
import { type Node } from "../node/index.js"
import { capInputPort } from "./capInputPort.js"
import { capOutputPort } from "./capOutputPort.js"

export function capNodeAllPorts(mod: Mod, net: Net, node: Node): void {
for (const port of findInputPorts(net, node)) {
Expand Down
Loading

0 comments on commit 9a917c3

Please sign in to comment.