0.10.4 • Published 3 months ago

@kipper/core v0.10.4

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
3 months ago

npm.io

Kipper Core Package - @kipper/core

Version npm.io Issues License Install size Publish size

The core module and dependency for the entire Kipper project, which contains the core language and compiler.

Kipper is a simple TS-based strongly and statically typed programming language, which is designed to allow for simple and straightforward coding similar to TypeScript and Python.

Note that this is a development version! Stable releases might take until April/May 2022

Kipper Docs

For proper documentation on the kipper language go here!

This is a project in work, and as such some docs pages can be incomplete or work in progress!

How to use Kipper?

To use, Kipper you have three options:

  • Run it in the browser using the CDN kipper-standalone.min.js file, which bundles the entire compiler for your browser.
  • Run it using the NodeJS CLI
  • Import the package @kipper/core in NodeJS or Deno

In a browser

For running Kipper in the browser, you will have to include the kipper-standalone.min.js file, which provides the kipper compiler for the browser. This script will fetch your code from script tags with the property type="text/kipper", and replace the content with runnable JavaScript.

As a dependency you will also have to include babel.min.js, which is needed to allow for a compilation from TS to JS in your browser, as Kipper compiles only to TypeScript.

Simple example of running your code in your browser using Kipper and Babel:

<!-- Babel dependency -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<!-- Kipper dependency -->
<script src="https://cdn.jsdelivr.net/npm/@kipper/core@latest/kipper-standalone.min.js"></script>

<!-- You won't have to define Kipper or anything after including the previous file. It will be defined per default  -->
<!-- with the global 'Kipper' -->
<script type="module">
  // Define your own logger and compiler, which will handle the compilation
  const logger = new Kipper.KipperLogger((level, msg) => {
    console.log(`[${Kipper.getLogLevelString(level)}] ${msg}`);
  });
  // Define your own compiler with your wanted configuration
  const compiler = new Kipper.KipperCompiler(logger);
  
  // Compile the code to Typescript
  // Top-level await ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#top_level_await
  const result = (await compiler.compile(`call print("Hello world!");`)).write();
  
  // Transpile the TS code into JS
  const jsCode = Babel.transform(result, { filename: "kipper-web-script.ts", presets: ["env", "typescript"] });
  
  // Finally, run your program
  eval(jsCode.code);
</script>

Locally using Node.js and the CLI

This is to recommend way to use Kipper if you want to dive deeper into Kipper, as it allows you to locally use and run kipper, without depending on a browser.

This also enables the usage of files, which can be read and compiled to TypeScript, and run using the CLI, without having to do anything yourself. This also allows the input of data over the console and file-interactions, which are not supported inside a browser.

For more info go to the CLI repository here or visit the npm page here.

Locally in your own code as a package

This is the recommended way if you intend to use kipper in a workflow or write code yourself to manage the compiler. This also allows for special handling of logging and customising the compilation process.

Simple example of using kipper using Node.js:

import * as ts from "typescript";
import { promises as fs } from "fs";
import { KipperCompiler } from "@kipper/core";

const path = "INSERT_PATH";
fs.readFile(path, "utf8" as BufferEncoding).then(
  (fileContent: string) => {
    // Define your own logger and compiler, which will handle the compilation
    const yourLogger = new Kipper.KipperLogger((level, msg) => {
      console.log(`[${level}] ${msg}`);
    })
    const yourCompiler = new Kipper.KipperCompiler(yourLogger);
    
    // Compile the code string or stream
    let code = yourCompiler.compile(fileContent).write();
      
    // Compiling down to JS using the typescript node module
    let jsCode = ts.transpile(code);
    
    // Running the Kipper program
    eval(jsCode);
  }
);

Copyright and License

License FOSSA Status

Copyright (C) 2021-2022 Luna Klatzer

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

See the LICENSE for information on terms & conditions for usage.

FOSSA License Report

FOSSA Status

0.11.0-alpha.1

3 months ago

0.10.3

10 months ago

0.10.4

9 months ago

0.10.2

11 months ago

0.11.0-alpha.0

11 months ago

0.10.0-rc.0

1 year ago

0.10.0-alpha.7

1 year ago

0.10.1

1 year ago

0.10.0-beta.0

1 year ago

0.10.0

1 year ago

0.10.0-alpha.6

1 year ago

0.10.0-alpha.5

2 years ago

0.9.0-beta.1

2 years ago

0.9.0-beta.0

2 years ago

0.10.0-alpha.3

2 years ago

0.10.0-alpha.2

2 years ago

0.10.0-alpha.4

2 years ago

0.10.0-alpha.1

2 years ago

0.10.0-alpha.0

2 years ago

0.9.0-rc.0

2 years ago

0.9.0

2 years ago

0.9.2

2 years ago

0.8.3

2 years ago

0.9.1

2 years ago

0.8.2

2 years ago

0.8.1

2 years ago

0.8.0

2 years ago

0.8.0-rc.0

2 years ago

0.8.0-beta.2

2 years ago

0.8.0-beta.1

2 years ago

0.8.0-beta.0

2 years ago

0.7.0

2 years ago

0.7.0-rc.0

2 years ago

0.7.0-beta.0

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.5.0-rc.1

2 years ago

0.5.0-rc.0

2 years ago