рдбреЗрдиреЛ v1.0: рдЬрд╛рд╡рд╛рд╕реНрдХреНрд░рд┐рдкреНрдЯ рдФрд░ рдЯрд╛рдЗрдкрд╕реНрдХреНрд░рд┐рдкреНрдЯ рдХреЗ рд▓рд┐рдП рд╕реБрд░рдХреНрд╖рд┐рдд рд░рдирдЯрд╛рдЗрдоред рдлрд╝реАрдЪрд░ рдЕрд╡рд▓реЛрдХрди


  1. рдкрд░рд┐рдЪрдп
  2. рд╕реНрдерд╛рдкрдирд╛
  3. рдпрд╣ рдЕрдВрджрд░ рд╕реЗ рдХреИрд╕рд╛ рджрд┐рдЦрддрд╛ рд╣реИ
  4. рдХрд╛рд░реНрдпрдХреНрд╖рдорддрд╛
  5. WASM, RUST, рдкреНрд▓рдЧрдЗрдиреНрд╕
  6. рдбрд┐рдмрдЧрд┐рдВрдЧ, рдЖрдИ.рдбреА.рдИ.
  7. рдкрд░рд┐рдХреНрд╖рдг
  8. рдХрдВрдкрд╛рдЗрд▓рд░ рдПрдкреАрдЖрдИ
  9. Ci
  10. рд╡рд┐рд╡рд┐рдз

рдкрд░рд┐рдЪрдп


, Ryan Dahl, NodeJS, JSConf, , NodeJS. : Deno, .


, .


2 , , .


, Deno. , , . Deno, . , Deno .



, , , , .


deno.land, .


Using Shell:


curl -fsSL https://deno.land/x/install/install.sh | sh

Or using PowerShell:


iwr https://deno.land/x/install/install.ps1 -useb | iex

, scoop, homebrew. , . . URL https://github.com/denoland/deno_install .


, , deno upgrade


Windows. , , Deno.


Windows,


, Deno, github, , .


, deno , {username}\AppData\Local\deno
:


  • deps,

, , , response headers, , , url. , , , Deno. , , -r deno run. , lock , тАЬ DenoтАЭ


  • gen

js, typescript . , , .
. , gen/file/C/dev/my_first_project


  • deno_history.txt

deno .


  • lib.deno.d.ts, lib.deno_runtime.d.ts

deno core. , Deno.



Typescript. , API , . API https://deno.land/typedoc. std x : https://doc.deno.land/. std, x тАЬ DenoтАЭ.


Typescript/ Javascript , ( V8, тАЬтАЭ). Rust, тАЬтАЭ. API- Deno ( ) Typescript , Rust Rusty V8 ( ) . Deno.core.send(), Deno.core.recv() .


Rusty V8 тАФ Typescript Rust, V8 . V8 / V8. V8 V8 https://v8.dev/blog/custom-startup-snapshots. , Deno Typescript. .


Rust Backend. , ┬л ┬╗, , , Rust. , , Rust тАФ , Mozilla, . , Servo. Rust Go, Deno, 2018 . GC.


V8 тАФ JavaScript / WebAssembly Google. C++, Google Chrome Node.js. V8 TypeScript. TypeScript, Deno, JavaScript TS, .deno. , JS.


Tokio тАФ Rust. . Deno . Tokio Rust Future, , Promise JavaScript.


TS Rust. , Flutbuffers, . , , . , . Deno : https://www.youtube.com/watch?v=qt7fbmypAFk



, , CLI Deno. deno help, deno [subcommand] -- help :


>deno help
deno 1.0.0-rc2
A secure JavaScript and TypeScript runtime

Docs: [https://deno.land/std/manual.md](https://deno.land/std/manual.md)
Modules: [https://deno.land/std/](https://deno.land/std/) [https://deno.land/x/](https://deno.land/x/)
Bugs: [https://github.com/denoland/deno/issues](https://github.com/denoland/deno/issues)

To start the REPL:
  deno

To execute a script:
  deno run [https://deno.land/std/examples/welcome.ts](https://deno.land/std/examples/welcome.ts)

To evaluate code in the shell:
  deno eval "console.log(30933 + 404)"

USAGE:
    deno [OPTIONS] [SUBCOMMAND]

OPTIONS:
    -h, --help                     Prints help information
    -L, --log-level <log-level>    Set log level [possible values: debug, info]
    -q, --quiet                    Suppress diagnostic output
    -V, --version                  Prints version information

SUBCOMMANDS:
    bundle         Bundle module and dependencies into single file
    cache          Cache the dependencies
    completions    Generate shell completions
    doc            Show documentation for a module
    eval           Eval script
    fmt            Format source files
    help           Prints this message or the help of the given subcommand(s)
    info           Show info about cache or info related to source file
    install        Install script as an executable
    repl           Read Eval Print Loop
    run            Run a program given a filename or url to the module
    test           Run tests
    types          Print runtime TypeScript declarations
    upgrade        Upgrade deno executable to given version

ENVIRONMENT VARIABLES:
    DENO_DIR             Set deno's base directory (defaults to $HOME/.deno)
    DENO_INSTALL_ROOT    Set deno install's output directory
                         (defaults to $HOME/.deno/bin)
    NO_COLOR             Set to disable color
    HTTP_PROXY           Proxy address for HTTP requests
                         (module downloads, fetch)
    HTTPS_PROXY          Same but for HTTPS

-unstable, Deno core API.



Deno . , Node.js .



deno run main.ts 

, :


error: Uncaught PermissionDenied: ...

Deno , . :


  • environment

, . , , -allow-read, url -allow-net


deno run --allow-read=/path --allow-net=localhost:4545 file.ts

, bash script -A ( -- allow-all), . Drake тАФ make Deno.


, deno , deno install . , $PATH.


Strict: true


- , . , , .


tsconfig.json


Deno , , , , . typescript, . :


deno run -c tsconfig.json main.ts


Deno Node.js , Deno ECMAScript, CommonJS. Node.js es 2019 , 13.2.0, , - .mjs. Deno , - .


import * as framework from "https://deno.land/x/alosaur/src/mod.ts";
import { assert } from "https://deno.land/std/testing/mod.ts";

, typescript , . . Ryan Dahl, require, N1 Node.js.


3 : Core, Std, X.


Deno.core


, c Rust .


Deno Standard Modules


https://deno.land/std/ тАФ , Deno, Deno. , . Go. , , , .


Deno X


. Deno, .


https://deno.land/x тАФ . , pull request.


JSPM, Pika.dev тАФ , npm es . :


import HandlebarsJS from тАШhttps://dev.jspm.io/handlebars@4.7.6';


, Deno. , , . . , npm, Deno .


package.json, deps.ts, :


export { assert } from "https://deno.land/std@v0.42.0/testing/asserts.ts";

-importmap (-unstable), json :


{
  "imports": {
    "moment": "./moment/moment.ts",
    "moment/": "./moment/",
    "lodash": "./lodash/lodash.ts",
    "lodash/": "./lodash/",
    "https://www.unpkg.com/vue/dist/vue.runtime.esm.js": "./vue.ts"
  },
  "scopes": {
    "scope/": {
      "moment": "./scoped_moment.ts"
    }
  }
}

std , , , : file:, http:, https:


Lock file


Deno , JSON. -- lock = lock.json, . , -- lock = lock.json -- lock-write.


Web standards


, Deno, , , Deno c , Deno. :


> reverse=a=>a.sort(n=>1)
> reverse([1,2,3])

- node (10.13.0): [3,2,1]
- deno (0.4.0) [1,2,3]
- chrome (74.0) [1,2,3]
- other browsers: [1,2,3]

, , , fetch.


, , Nodejs, Deno, . , , Deno.


Compat Table deno: https://deno.dev/wpt/


WASM, RUST,


, Deno wasm . , .


. Deno , , import, , , Deno.openPlugin. , , .deno_plugins . , :


https://github.com/manyuanrong/deno-plugin-prepare


:


const pluginOptions: PerpareOptions = {
  name: "test_plugin",

  // Whether to output log. Optional, default is true
  // printLog: true,

  // Whether to use locally cached files. Optional, default is true
  // checkCache: true,

  // Support "http://", "https://", "file://"
  urls: {
    mac: `${releaseUrl}/libtest_plugin.dylib`,
    win: `${releaseUrl}/test_plugin.dll`,
    linux: `${releaseUrl}/libtest_plugin.so`,
  },
};
const rid = await prepare(pluginOptions);
//@ts-ignore
const { testSync } = Deno.core.ops();

const response = Deno.core.dispatch(
  testSync,
  new Uint8Array([116, 101, 115, 116])
)!;

console.log(response);

, Deno webView. :


https://denotutorials.net/making-desktop-gui-applications-using-deno-webview.html


Debugging, IDE


Deno , Visual Studio Code . :


deno run -A -- inspect-brk fileToDebug.ts

Chrome chrome://inspect, Target Deno, Inspect. .


Deno Rust API Deno.watchFs (). Deno API , . -- watch, .


Visual Studio Code c justjavac.vscode-deno


WebStorm, star jetbrains https://youtrack.jetbrains.com/issue/WEB-41607



тАЛтАЛDeno Deno.test(). , assert, assertEquals .. . , :


import { assert, assertEquals } from "https://deno.land/std/testing/asserts.ts";

Deno.test({
  name: "Test name",
  fn(): void {
    assert("test" === "test");
    assertEquals("test", "test");
  },
});

:


deno test

.



Deno (https://github.com/alosaur/alosaur), , . , Deno . тАФ Deno.run(). : . : https://github.com/alosaur/alosaur/tree/master/e2e


Compiler API


Deno Typescript. Deno , : Deno.compile() Deno.bundle() Deno.transpileOnly()


compile() тАФ tsc Nodejs,


bundle() тАФ compile, , , es , . CLI deno bundle.


, :


export { foo } from "./foo.js";

export const bar = "bar";

:


import { foo, bar } from "./lib.bundle.js";

Bundle -. Bundle ES, type ┬лmodule┬╗. :


<script type="module">
  import * as website from "website.bundle.js";
</script>

transpileOnly() тАФ , transpileModule Typescript. , , ┬л┬╗ JavaScript. .


dev_server


transpileOnly dev_server (https://github.com/zhmushan/dev_server) тАФ deno.


?
index.html, main.ts,


( tsconfig), js url.


?
jspm, cdn.pika, unpkg. , importmap.


, JIT, systemjs.
: dev .


, , , , Angular CLI


:


deno run -- allow-net -- allow-read -- allow-write -- unstable
https://deno.land/x/dev_server/mod.ts тАФ template angular


, Angular, Angular , telegram https://t.me/ngFanatic.


CI, CD


, , . Deno github actions. , Ryan Dahl travis, ( ), . github actions , , . : https://github.com/alosaur/alosaur/blob/master/.github/workflows/ci.yml



Deno install


Deno deno install . , deno, CLI.


$ deno install --allow-net --allow-read https://deno.land/std/http/file_server.ts
[1/1] Compiling https://deno.land/std/http/file_server.ts

 Successfully installed file_server.
/Users/deno/.deno/bin/file_server

, file_server.


: https://github.com/denoland/deno/blob/master/docs/tools/script_installer.md


Deno.run()


, , deno , , python:


// --allow-run
const cmd = Deno.run({
  cmd: ["python3", "test.py"], 
  stdout: "piped",
  stderr: "piped"
});

const output = await cmd.output();
const outStr = new TextDecoder().decode(output);

const error = await p.stderrOutput();
const errorStr = new TextDecoder().decode(error);

cmd.close();

console.log(outStr, errorStr);

Deno doc


doc.deno.land. typescript type checker (https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API#using-the-type-checker) , JSdoc.


Deno format


Deno , JavaScript Typescript. Prettier.


Deno playground


deno , : https://deno.town https://deno-play.app


Deno awesome


Deno, , !


https://github.com/denolib/awesome-deno



рдореБрдЭреЗ рдЖрд╢рд╛ рд╣реИ, рдореЗрд░реЗ рд▓реЗрдЦ рдХреЗ рд╕рд╛рде рдореИрдВ рдЕрднреА рдЖрдкрдХреЛ рдбреЗрдиреЛ рдХреА рдХреЛрд╢рд┐рд╢ рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рдЖрдХрд░реНрд╖рд┐рдд рдХрд░рдиреЗ рдореЗрдВ рд╕рдХреНрд╖рдо рдерд╛ред рдФрд░ рдпрджрд┐ рдЖрдкрдХреЗ рдХреЛрдИ рдкреНрд░рд╢реНрди рд╣реИрдВ, рддреЛ рдореИрдВ рд╣рд░ рдХрд┐рд╕реА рдХреЛ рдЯреЗрд▓реАрдЧреНрд░рд╛рдо рдореЗрдВ рд╣рдорд╛рд░реА рдЖрд░рд╛рдорджрд╛рдпрдХ рдЪреИрдЯ рдкрд░ рдЖрдордВрддреНрд░рд┐рдд рдХрд░рддрд╛ рд╣реВрдВ:


https://t.me/denoland


рдФрд░ рдЕрдЧрд░ рдЖрдкрдХреЛ рдЕрдк-рдЯреВ-рдбреЗрдЯ рдЬрд╛рдирдХрд╛рд░реА рдХреА рдЖрд╡рд╢реНрдпрдХрддрд╛ рд╣реИ, рддреЛ рдбреЗрдиреЛ рдХреЗ рдмрд╛рд░реЗ рдореЗрдВ рдПрдХ рдкрд╛рдЪрди, рдЗрд╕рдХреЗ рд▓рд┐рдП рдбреЗрдиреЛ рдлреИрдиреЗрдЯрд┐рдХ рдЪреИрдирд▓ рдмрдирд╛рдпрд╛ рдЧрдпрд╛ рд╣реИред


https://t.me/denoFanatic


ps


рдореИрдВ рдбреЗрдврд╝ рд╕рд╛рд▓ рд╕реЗ рдЕрдзрд┐рдХ рд╕рдордп рд╕реЗ рдбреЗрдХреЛрд░реЗрдЯрд░ рдкрд░ рдЕрдкрдирд╛ рд╡реЗрдм рдврд╛рдВрдЪрд╛ рд╡рд┐рдХрд╕рд┐рдд рдХрд░ рд░рд╣рд╛ рд╣реВрдВ, рдореБрдЭреЗ рдХрд┐рд╕реА рднреА рдкреНрд░рддрд┐рдХреНрд░рд┐рдпрд╛ рдкрд░ рдЦреБрд╢реА рд╣реЛрдЧреА:


https://github.com/alosaur/alosaur


All Articles