@danielx/civet 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.
- package/README.md +107 -0
- package/dist/browser.js +3074 -0
- package/dist/browser.js.map +7 -0
- package/dist/civet +18 -0
- package/dist/cli.js.map +7 -0
- package/dist/main.js +3066 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Civet
|
|
2
|
+
=====
|
|
3
|
+
|
|
4
|
+
[](https://github.com/DanielXMoore/Civet/actions/workflows/build.yml)
|
|
5
|
+
|
|
6
|
+
A new CoffeeScript. Much closer to ES2015+ (for better or worse).
|
|
7
|
+
|
|
8
|
+
Also TypeScript, the sky is the limit.
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
Code Sample
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import ts, {CompilerOptions} from "typescript"
|
|
17
|
+
|
|
18
|
+
const DefaultCompilerOptions : CompilerOptions =
|
|
19
|
+
allowNonTsExtensions: true
|
|
20
|
+
allowJs: true
|
|
21
|
+
target: ts.ScriptTarget.Latest
|
|
22
|
+
moduleResolution: ts.ModuleResolutionKind.NodeJs
|
|
23
|
+
module: ts.ModuleKind.CommonJS
|
|
24
|
+
allowSyntheticDefaultImports: true
|
|
25
|
+
experimentalDecorators: true
|
|
26
|
+
|
|
27
|
+
const fileCache : Record<string, any> = {}
|
|
28
|
+
|
|
29
|
+
const createCompilerHost = (options: CompilerOptions, moduleSearchLocations : string[]) ->
|
|
30
|
+
const fileExists = (fileName: string) : boolean ->
|
|
31
|
+
return fileCache[fileName]?
|
|
32
|
+
|
|
33
|
+
const readFile = (fileName: string) ->
|
|
34
|
+
return fileCache[fileName]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Things Kept from CoffeeScript
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
- `is` -> `===`
|
|
41
|
+
- `or` -> `||`
|
|
42
|
+
- `and` -> `&&`
|
|
43
|
+
- `loop` -> `while(true)`
|
|
44
|
+
- Object literal syntax
|
|
45
|
+
```coffee
|
|
46
|
+
x =
|
|
47
|
+
a: 1
|
|
48
|
+
b: 2
|
|
49
|
+
c:
|
|
50
|
+
x: "pretty"
|
|
51
|
+
y: "cool"
|
|
52
|
+
```
|
|
53
|
+
- Optional semi-colons
|
|
54
|
+
- Indentation based block syntax
|
|
55
|
+
- OptionalChain shorthand for index and function application `a?[b]` -> `a?.[b]`, `a?(b)` -> `a?.(b)`
|
|
56
|
+
- `@` -> `this`
|
|
57
|
+
- `@id` -> `this.id`
|
|
58
|
+
- TODO
|
|
59
|
+
- `"""` Strings (for compatibility with existing .coffee code)
|
|
60
|
+
|
|
61
|
+
Things Removed from CoffeeScript
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
- `on` (use `true`)
|
|
65
|
+
- `off` (use `false`)
|
|
66
|
+
- `do` keyword (replaced with JS `do`)
|
|
67
|
+
- `for from` (use JS `for of`)
|
|
68
|
+
- Comprensions (a case could be made for keeping them)
|
|
69
|
+
- Iteration expression results
|
|
70
|
+
- Implicit declarations
|
|
71
|
+
- Implicit returns (will probably add later)
|
|
72
|
+
- Rest parameter in any assignment position (might add later)
|
|
73
|
+
|
|
74
|
+
Things Changed from CoffeeScript
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
- `==` -> `==` rather than `===` (can be kept with `"use coffee-compat"`)
|
|
78
|
+
- `!=` -> `!=` rather than `!==` (can be kept with `"use coffee-compat"`)
|
|
79
|
+
- `for in` and `for of` are no longer swapped and become their JS equivalents.
|
|
80
|
+
- `a...` is now `...a` just like JS
|
|
81
|
+
- `x?.y` now compiles to `x?.y` rather than the `if typeof x !== 'undefined' && x !== null` if check
|
|
82
|
+
- Existential `x?` -> `(x != null)` no longer checks for undeclared variables.
|
|
83
|
+
|
|
84
|
+
Things Added that CoffeeScript didn't
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
- JS Compatability
|
|
88
|
+
- `var`, `let`, `const`
|
|
89
|
+
- JS Comment Syntax `//` and `/* */`
|
|
90
|
+
- Braced Blocks
|
|
91
|
+
- OptionalChain longhand
|
|
92
|
+
- ConditionalExpression
|
|
93
|
+
- `case` statement
|
|
94
|
+
- `while`
|
|
95
|
+
- `do`
|
|
96
|
+
- Convenience for ES6+ Features
|
|
97
|
+
- `<` as `extends` shorthand
|
|
98
|
+
- `@#id` -> `this.#id` shorthand for private identifiers
|
|
99
|
+
- ClassStaticBlock
|
|
100
|
+
- `get`/`set` method definitions
|
|
101
|
+
- Private identifiers `#id`
|
|
102
|
+
- Shebang line
|
|
103
|
+
```civet
|
|
104
|
+
#!./node_modules/.bin/ts-node
|
|
105
|
+
console.log "hi"
|
|
106
|
+
```
|
|
107
|
+
- TypeScript Types
|