@danielx/civet 0.5.25 → 0.5.27

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 CHANGED
@@ -24,13 +24,15 @@ Quickstart Guide
24
24
  ```bash
25
25
  # Install
26
26
  npm install -g @danielx/civet
27
- # Run civet code directly in a REPL
27
+ # Run Civet code directly in a REPL
28
28
  civet
29
- # Compile civet source file to typescript
29
+ # Transpile typed Civet code into TypeScript in a REPL
30
+ civet -c
31
+ # Compile Civet source file to TypeScript
30
32
  civet < source.civet > output.ts
31
- # Execute a simple civet script (no imports)
33
+ # Execute a simple .civet script (no imports)
32
34
  civet source.civet ...args...
33
- # Execute a civet source file in node using ts-node
35
+ # Execute a .civet source file in node using ts-node
34
36
  node --loader ts-node/esm --loader @danielx/civet/esm source.civet
35
37
  ```
36
38
 
@@ -232,10 +234,13 @@ Things Added that CoffeeScript didn't
232
234
  to specify how to use left-hand side
233
235
  - `|> await`, `|> yield`, and `|> return` (at end)
234
236
  for wrapping left-hand side with that operation
235
- - Flagging shorthand [from LiveScript](https://livescript.net/#literals) `{+debug, -live}` → `{debug: true, live: false}`
237
+ - Flagging shorthand based on [from LiveScript](https://livescript.net/#literals-objects):
238
+ `{+debug, -live, !verbose}` → `{debug: true, live: false, verbose: false}`
236
239
  - JSX enhancements (inspired by [solid-dsl discussions](https://github.com/solidjs-community/solid-dsl/discussions)):
237
240
  - Indentation: instead of explicitly closing `<tag>`s or `<>`s,
238
241
  you can indent the children and Civet will close your tags for you
242
+ - Multiple adjacent elements and/or fragments get automatically
243
+ combined into a fragment.
239
244
  - Arrow function children do not need to be wrapped in braces
240
245
  (assuming they are not preceded by text); this is unambiguous because
241
246
  `>` isn't valid JSX text. For example, `<For> (item) => ...`
@@ -245,6 +250,7 @@ Things Added that CoffeeScript didn't
245
250
  - `.foo` shorthand for `class="foo"` (but must be at least one space after
246
251
  tag name); also `.foo.bar`, `."foo bar"`, `` .`foo ${bar}` ``, `.{expr}`
247
252
  - `"civet react"` flag uses `className` instead of `class`
253
+ - `+foo` shorthand for `foo={true}`, `-foo`/`!foo` shorthand for `foo={false}`
248
254
  - Any braced object literal can be used as an attribute:
249
255
  `{foo}` → `foo={foo}`, `{foo: bar}` → `foo={bar}`,
250
256
  `{...foo}` remains as is; methods and getters/setters work too.
@@ -451,3 +457,39 @@ esbuild.build({
451
457
  ```
452
458
 
453
459
  It's super fast and works great!
460
+
461
+ Philosophy
462
+ ---
463
+
464
+ Civet is a **large language that feels small**. Civet is large because it is mostly a **superset of TypeScript**,
465
+ an already large language. Civet feels small because of the coherent design aesthetic: related
466
+ features look and behave similarly, so when seeing a new feature you can have a good idea what it does,
467
+ and your existing knowledge of JavaScript and other languages leads you in the right direction.
468
+
469
+ Civet works with **existing tools**. We're not trying to replace the TypeScript type checker; we want to
470
+ amplify its power. We're not trying to change ES semantics; we want to present them in a coherent and expressive
471
+ way.
472
+
473
+ **Less syntax** is preferred.
474
+
475
+ **Context matters**. The same tokens can mean different things in different contexts. This shouldn't be arbitrary
476
+ but based on pragmatic concerns. Things should be consistent where possible, especially conceptually.
477
+
478
+ Civet builds on top of **history**. We've taken inspiration from languages like CoffeeScript, Elm, LiveScript, Flow,
479
+ Haskell, Perl, Python, Ruby, Crystal, Bash, and others.
480
+
481
+ Civet is **pragmatic**. Civet design is informed by 25+ years of JavaScript development. Frontend frameworks
482
+ have come and gone but they all addressed issues that were important for their time. We focus heavily on
483
+ addressing concerns that real developers feel every day. A key criteria for evaluating features is "how does it
484
+ work in practice?".
485
+
486
+ Civet **evolves**. As the official JS and TS specifications evolve into the future, Civet also evolves favoring **compatibility**.
487
+ This may lead us to difficult choices where the future spec has evolved differently than we anticipated (pipe operators,
488
+ do expressions, pattern matching). In those cases, Civet will adapt to match the latest spec while providing configuration
489
+ options to allow migration bit by bit while keeping existing code working.
490
+
491
+ Civet is **configurable**. There is no single "right way" for everyone at all times. Some of us have older CoffeeScript
492
+ codebases that would benefit from added types. Others have massive TypeScript applications that could benefit from
493
+ new language features and shorthand syntax. Civet provides a way to get the benefits bit by bit without a complete
494
+ rewrite. This same configurability lets us experiment with language features to gain experience and improve them before
495
+ locking them in. It also allows us to adapt to a changing future.