├── .editorconfig ├── .eslintrc.json ├── .github ├── pull_request_template.md └── workflows │ └── ci.yml ├── .gitignore ├── .prettierignore ├── .prettierrc.json ├── LICENSE ├── README.md ├── artwork.json ├── components ├── BenchmarkChart.tsx ├── CodeBlock.tsx ├── CookieBanner.tsx ├── DependencyGraph.tsx ├── DirectoryListing.tsx ├── ErrorMessage.tsx ├── FileDisplay.tsx ├── Footer.tsx ├── Header.tsx ├── InlineCode.tsx ├── LoadingPage.tsx ├── Manual.tsx ├── Markdown.tsx ├── NotFound.tsx ├── Registry.tsx ├── RegistryInstructions.tsx ├── Transition.tsx ├── app.css ├── docsearch.css └── markdown.css ├── docs ├── contributing.md ├── contributing │ ├── architecture.md │ ├── building_from_source.md │ ├── development_tools.md │ ├── profiling.md │ ├── release_schedule.md │ ├── style_guide.md │ └── web_platform_tests.md ├── embedding_deno.md ├── examples.md ├── examples │ ├── fetch_data.md │ ├── file_server.md │ ├── file_system_events.md │ ├── hello_world.md │ ├── http_server.md │ ├── import_export.md │ ├── manage_dependencies.md │ ├── module_metadata.md │ ├── os_signals.md │ ├── read_write_files.md │ ├── subprocess.md │ ├── tcp_echo.md │ └── unix_cat.md ├── getting_started.md ├── getting_started │ ├── command_line_interface.md │ ├── debugging_your_code.md │ ├── first_steps.md │ ├── installation.md │ ├── permissions.md │ ├── setup_your_environment.md │ ├── typescript.md │ └── webassembly.md ├── help.md ├── images │ ├── debugger1.jpg │ ├── debugger2.jpg │ ├── debugger3.jpg │ ├── debugger4.jpg │ ├── debugger5.jpg │ ├── debugger7.jpg │ └── deno3.png ├── introduction.md ├── linking_to_external_code.md ├── linking_to_external_code │ ├── import_maps.md │ ├── integrity_checking.md │ ├── private.md │ ├── proxies.md │ └── reloading_modules.md ├── runtime.md ├── runtime │ ├── compiler_apis.md │ ├── location_api.md │ ├── permission_apis.md │ ├── program_lifecycle.md │ ├── stability.md │ ├── web_platform_apis.md │ └── workers.md ├── schemas │ └── module-graph.json ├── standard_library.md ├── testing.md ├── testing │ └── assertions.md ├── toc.ja.json ├── toc.json ├── tools.md ├── tools │ ├── bundler.md │ ├── compiler.md │ ├── dependency_inspector.md │ ├── documentation_generator.md │ ├── formatter.md │ ├── linter.md │ ├── repl.md │ ├── script_installer.md │ └── typescript.md └── typescript │ ├── configuration.md │ ├── faqs.md │ ├── migration.md │ ├── overview.md │ ├── runtime.md │ └── types.md ├── jest.config.js ├── next-env.d.ts ├── next.config.js ├── now.json ├── package.json ├── pages ├── [...rest].tsx ├── _app.tsx ├── _document.tsx ├── artwork.tsx ├── benchmarks.tsx ├── index.tsx ├── status │ └── [id].tsx ├── translations.tsx ├── v1 │ └── hoodie.tsx └── x │ ├── [...rest].tsx │ └── index.tsx ├── postcss.config.js ├── proxy ├── deps.ts ├── fly.toml ├── integration_test.ts ├── main.ts ├── mod.ts ├── src │ ├── registry.ts │ ├── registry_test.ts │ ├── utils.ts │ ├── vscode.ts │ └── website.ts └── test_deps.ts ├── public ├── .well-known │ ├── deno-completion-manifest.json │ ├── deno-import-intellisense.json │ └── security.txt ├── favicon.ico ├── favicon.svg ├── fonts │ └── inter │ │ ├── Inter-Black.woff │ │ ├── Inter-Black.woff2 │ │ ├── Inter-BlackItalic.woff │ │ ├── Inter-BlackItalic.woff2 │ │ ├── Inter-Bold.woff │ │ ├── Inter-Bold.woff2 │ │ ├── Inter-BoldItalic.woff │ │ ├── Inter-BoldItalic.woff2 │ │ ├── Inter-ExtraBold.woff │ │ ├── Inter-ExtraBold.woff2 │ │ ├── Inter-ExtraBoldItalic.woff │ │ ├── Inter-ExtraBoldItalic.woff2 │ │ ├── Inter-ExtraLight.woff │ │ ├── Inter-ExtraLight.woff2 │ │ ├── Inter-ExtraLightItalic.woff │ │ ├── Inter-ExtraLightItalic.woff2 │ │ ├── Inter-Italic.woff │ │ ├── Inter-Italic.woff2 │ │ ├── Inter-Light.woff │ │ ├── Inter-Light.woff2 │ │ ├── Inter-LightItalic.woff │ │ ├── Inter-LightItalic.woff2 │ │ ├── Inter-Medium.woff │ │ ├── Inter-Medium.woff2 │ │ ├── Inter-MediumItalic.woff │ │ ├── Inter-MediumItalic.woff2 │ │ ├── Inter-Regular.woff │ │ ├── Inter-Regular.woff2 │ │ ├── Inter-SemiBold.woff │ │ ├── Inter-SemiBold.woff2 │ │ ├── Inter-SemiBoldItalic.woff │ │ ├── Inter-SemiBoldItalic.woff2 │ │ ├── Inter-Thin.woff │ │ ├── Inter-Thin.woff2 │ │ ├── Inter-ThinItalic.woff │ │ ├── Inter-ThinItalic.woff2 │ │ ├── Inter-italic.var.woff2 │ │ ├── Inter-roman.var.woff2 │ │ ├── Inter.var.woff2 │ │ └── inter.css ├── images │ ├── DenoLogo3D-Anim.gif │ ├── add_webhook.mp4 │ ├── deno-in-2020.png │ ├── deno404.gif │ ├── deno_city.jpeg │ ├── deno_logo.png │ ├── deno_logo_4.gif │ ├── deno_matrix.png │ ├── deno_paper.png │ ├── deno_sun.png │ ├── deno_v1_congrats.jpeg │ ├── discodeno.gif │ ├── duri4n.png │ ├── ferris.gif │ ├── glitchy-deno.jpg │ ├── hashrock_simple.png │ ├── icons │ │ ├── apple-touch-icon-180x180.png │ │ ├── icon-128x128.png │ │ ├── icon-144x144.png │ │ ├── icon-152x152.png │ │ ├── icon-192x192.png │ │ ├── icon-384x384.png │ │ ├── icon-512x512.png │ │ ├── icon-72x72.png │ │ └── icon-96x96.png │ ├── jurassicDeno.jpg │ ├── schematic_v0.2.png │ └── stone.jpeg ├── logo.svg ├── robots.txt ├── site.webmanifest ├── v1.jpg ├── v1.png ├── v1_hoodie_mock.png ├── v1_wide.jpg └── v1_wide.png ├── tailwind.config.js ├── tools └── generate_emojis.js ├── translations.json ├── tsconfig.json ├── util ├── artwork_utils.ts ├── benchmark_utils.ts ├── emoji_util.ts ├── emoji_utils.test.ts ├── emojis.json ├── manual_utils.test.ts ├── manual_utils.ts ├── pagination_utils.test.ts ├── pagination_utils.ts ├── registry_utils.test.ts ├── registry_utils.ts └── translations_utils.ts ├── versions.json └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | root=true 2 | 3 | [*.js, *.ts, *.jsx, *.tsx] 4 | charset = utf-8 5 | 6 | end_of_line = lf 7 | trim_trailing_whitespace = true 8 | 9 | indent_style = space 10 | indent_size = 2 11 | 12 | insert_final_newline = true 13 | 14 | [*.yml] 15 | indent_style = space 16 | indent_size = 2 17 | trim_trailing_whitespace = true 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false 21 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "plugins": ["@typescript-eslint"], 5 | "extends": [ 6 | "plugin:@typescript-eslint/recommended", 7 | "prettier", 8 | "eslint:recommended", 9 | "plugin:react/recommended" 10 | ], 11 | "settings": { 12 | "react": { 13 | "version": "detect" 14 | } 15 | }, 16 | "rules": { 17 | "@typescript-eslint/array-type": ["error", { "default": "array-simple" }], 18 | "@typescript-eslint/explicit-member-accessibility": ["off"], 19 | "@typescript-eslint/no-non-null-assertion": ["off"], 20 | "@typescript-eslint/no-use-before-define": ["off"], 21 | "@typescript-eslint/no-parameter-properties": ["off"], 22 | "@typescript-eslint/no-unused-vars": [ 23 | "error", 24 | { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" } 25 | ], 26 | "@typescript-eslint/ban-ts-ignore": ["off"], 27 | "@typescript-eslint/no-empty-function": ["off"], 28 | "@typescript-eslint/explicit-function-return-type": ["off"], 29 | "@typescript-eslint/no-explicit-any": ["off"], 30 | "//replaced by @typescript-eslint/no-unused-vars": 0, 31 | "no-unused-vars": ["off"], 32 | "react/no-unescaped-entities": ["error", { "forbid": [">", "}"] }], 33 | "react/prop-types": ["off"] 34 | }, 35 | "env": { 36 | "browser": true, 37 | "node": true, 38 | "es6": true 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | web: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v1 10 | - uses: actions/setup-node@v1 11 | with: 12 | node-version: 12 13 | - name: Get yarn cache directory path 14 | id: yarn-cache-dir-path 15 | run: echo "::set-output name=dir::$(yarn cache dir)" 16 | - uses: actions/cache@v1 17 | with: 18 | path: ${{ steps.yarn-cache-dir-path.outputs.dir }} 19 | key: web-${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} 20 | restore-keys: | 21 | web-${{ runner.os }}-yarn- 22 | - run: yarn --frozen-lockfile 23 | - run: yarn format:check 24 | - run: yarn lint 25 | - run: yarn test 26 | #proxy: 27 | # runs-on: ubuntu-latest 28 | # 29 | # steps: 30 | # - uses: actions/checkout@v1 31 | # 32 | # - name: Install Deno (Unix) 33 | # if: | 34 | # !startsWith(matrix.os, 'windows') 35 | # run: |- 36 | # curl -fsSL https://deno.land/x/install/install.sh | sh 37 | # echo "$HOME/.deno/bin" >> $GITHUB_PATH 38 | # 39 | # - name: Format 40 | # run: deno fmt --check 41 | # working-directory: proxy 42 | # 43 | # - name: Lint 44 | # run: deno lint --unstable 45 | # working-directory: proxy 46 | # 47 | # - name: Test 48 | # run: deno test --allow-net 49 | # working-directory: proxy 50 | # 51 | # - name: Install flyctl 52 | # if: 53 | # github.ref == 'refs/heads/main' && github.event_name == 'push' && 54 | # github.repository == 'denoland/deno_website2' 55 | # run: | 56 | # curl -L https://fly.io/install.sh | sh 57 | # echo "$HOME/.fly/bin" >> $GITHUB_PATH 58 | # 59 | # - name: Deploy 60 | # if: 61 | # github.ref == 'refs/heads/main' && github.event_name == 'push' && 62 | # github.repository == 'denoland/deno_website2' 63 | # run: flyctl deploy --env GIT_SHA=$(git rev-parse --short "$GITHUB_SHA") 64 | # working-directory: proxy 65 | # env: 66 | # FLY_ACCESS_TOKEN: ${{ secrets.FLY_ACCESS_TOKEN }} 67 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | 21 | # debug 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | 26 | # local env files 27 | .env.local 28 | .env.development.local 29 | .env.test.local 30 | .env.production.local 31 | 32 | # worker 33 | dist/ 34 | worker/script.js 35 | 36 | .now 37 | .vercel 38 | 39 | # vscode settings 40 | .vscode 41 | 42 | # IDEA settings 43 | .idea/ 44 | 45 | # Diagnostic reports (https://nodejs.org/api/report.html) 46 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 47 | 48 | # Runtime data 49 | pids 50 | *.pid 51 | *.seed 52 | *.pid.lock 53 | 54 | # TypeScript cache 55 | *.tsbuildinfo 56 | 57 | # Optional npm cache directory 58 | .npm 59 | 60 | # Stores VSCode versions used for testing VSCode extensions 61 | .vscode-test 62 | 63 | # yarn v2 64 | .yarn/cache 65 | .yarn/unplugged 66 | .yarn/build-state.yml 67 | .yarn/install-state.gz 68 | .pnp.* 69 | 70 | # Ignore Submlime Editor files 71 | *.sublime-project 72 | *.sublime-workspace 73 | *.komodoproject -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | docs/ 2 | README.md -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "proseWrap": "always" 3 | } 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018-2020 the Deno authors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | ============================================================================== 24 | 25 | MIT License 26 | 27 | Copyright (c) 2020 tokiedokie 28 | 29 | Permission is hereby granted, free of charge, to any person obtaining a copy 30 | of this software and associated documentation files (the "Software"), to deal 31 | in the Software without restriction, including without limitation the rights 32 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 33 | copies of the Software, and to permit persons to whom the Software is 34 | furnished to do so, subject to the following conditions: 35 | 36 | The above copyright notice and this permission notice shall be included in all 37 | copies or substantial portions of the Software. 38 | 39 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 40 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 41 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 42 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 43 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 44 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 45 | SOFTWARE. 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # deno 日本語サイト 2 | 3 | [![Build Status](https://github.com/denoland/deno_website2/workflows/ci/badge.svg?branch=main&event=push)](https://github.com/denoland/deno_website2/actions) 4 | 5 | https://deno-ja.vercel.app/ のレポジトリです。 6 | 7 | ## 翻訳のやり方 8 | 9 | `docs`下の`.md`ファイルは英文をHTMLコメント(``)でコメントアウトし、その下に日本語訳を書いてください。英文が複数行に渡る場合、すべてをコメントアウトして日本語にしてください。英文が一行空いている場合はそれぞれ分けて日本語にしてください。 10 | 11 | `.tsx`の英文はJSXのコメント(`{/* */}`)でコメントアウトし、その下に日本語訳を書いてください。 12 | 13 | `docs/toc.json`は元のファイルです。日本語は`docs/toc.ja.json`に書いてください。 14 | 15 | 改行位置での半角スペースの自動挿入を防ぐため、日本語訳に改行をはさまないでください。 16 | ただし`.tsx`では、改行時に半角スペースの挿入が行われない箇所があり、そこでの改行はOKとします。 17 | 18 | Markdown中のコードとリンクの前後が句読点やカッコでない場合、空白を開けてください。 19 | 20 | 句読点は `。` と `、` を使ってください。 21 | 22 | ## History 23 | 24 | This is a rewrite of the Deno website it will combine the code in 25 | https://github.com/denoland/deno/tree/f96aaa802b245c8b3aeb5d57b031f8a55bb07de2/website 26 | and https://github.com/denoland/registry and have faster deployment. 27 | 28 | This is written in React / TailwindCSS / Vercel / CloudFlare Workers. Not in 29 | Deno. Ideally this could be ported to Deno at some point but we are in need of a 30 | new website and dogfooding takes too long. We hope to see this code ported to 31 | Deno with minimal developer flow interrupted (in particular, we need the ability 32 | to listen for FS events and reload the web server). 33 | 34 | ## Image License 35 | 36 | These Deno images are distributed under the MIT license (public domain and free 37 | for use). 38 | 39 | - [A graphic for the v1 blog post by @hashrock](https://deno.land/v1.jpg) 40 | -------------------------------------------------------------------------------- /components/BenchmarkChart.tsx: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 the Deno authors. All rights reserved. MIT license. */ 2 | 3 | import React, { useState } from "react"; 4 | import dynamic from "next/dynamic"; 5 | const ApexChart = dynamic(() => import("react-apexcharts"), { 6 | ssr: false, 7 | loading: BenchmarkLoading, 8 | }); 9 | 10 | import { Column, formatLogScale, logScale } from "../util/benchmark_utils"; 11 | 12 | export interface BenchmarkChartProps { 13 | yTickFormat?: (n: number) => string; 14 | columns: Column[]; 15 | yLabel?: string; 16 | sha1List: string[]; 17 | } 18 | 19 | function BenchmarkChart(props: BenchmarkChartProps): React.ReactElement { 20 | const [id] = useState(Math.random().toString()); 21 | 22 | const shortSha1List = props.sha1List.map((s) => s.slice(0, 6)); 23 | 24 | function viewCommitOnClick(c1: any, c2: any, { dataPointIndex }: any): void { 25 | window.open( 26 | `https://github.com/denoland/deno/commit/${props.sha1List[dataPointIndex]}` 27 | ); 28 | } 29 | 30 | const cols = props.columns.map((d) => ({ name: d.name, data: [...d.data] })); 31 | 32 | if (props.yTickFormat && props.yTickFormat === formatLogScale) { 33 | logScale(cols); 34 | } 35 | 36 | const options = { 37 | chart: { 38 | toolbar: { 39 | show: true, 40 | }, 41 | animations: { 42 | enabled: false, 43 | }, 44 | events: { 45 | markerClick: viewCommitOnClick, 46 | }, 47 | }, 48 | stroke: { 49 | width: 1, 50 | curve: "straight", 51 | }, 52 | legend: { 53 | show: true, 54 | showForSingleSeries: true, 55 | position: "bottom", 56 | }, 57 | yaxis: { 58 | labels: { 59 | formatter: props.yTickFormat, 60 | }, 61 | title: { 62 | text: props.yLabel, 63 | }, 64 | }, 65 | xaxis: { 66 | labels: { 67 | show: false, 68 | }, 69 | categories: shortSha1List, 70 | tooltip: { 71 | enabled: false, 72 | }, 73 | }, 74 | }; 75 | 76 | const series = cols.sort((a, b) => { 77 | // Sort by last benchmark. 78 | const aLast = a.data[a.data.length - 1]; 79 | const bLast = b.data[b.data.length - 1]; 80 | return (bLast ?? 0) - (aLast ?? 0); 81 | }); 82 | 83 | return ( 84 | 91 | ); 92 | } 93 | 94 | export function BenchmarkLoading(): React.ReactElement { 95 | return ( 96 |
97 | Loading... 98 |
99 | ); 100 | } 101 | 102 | export default BenchmarkChart; 103 | -------------------------------------------------------------------------------- /components/CookieBanner.tsx: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 the Deno authors. All rights reserved. MIT license. */ 2 | 3 | import React, { useState } from "react"; 4 | 5 | export function CookieBanner(): React.ReactElement { 6 | const [cookieBanner, setCookieBanner] = useState( 7 | typeof window === "undefined" || 8 | window.localStorage.getItem("cookiebanner") === "closed" 9 | ); 10 | 11 | return ( 12 |
13 | {cookieBanner ? ( 14 | <> 15 | ) : ( 16 |
17 |
18 |
19 |
20 |

21 | 22 | {/* We make use of functional cookies. */} 23 | 機能性cookieを使用します。 24 | 25 | 26 | {/* 27 | To ensure a good user experience, we make use of functional 28 | cookies. 29 | */} 30 | ユーザーエクスペリエンスを良くするため機能性cookieを使用します。 31 | 32 |

33 |
34 |
35 | 44 |
45 |
46 |
47 |
48 | )} 49 |
50 | ); 51 | } 52 | -------------------------------------------------------------------------------- /components/DependencyGraph.tsx: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 the Deno authors. All rights reserved. MIT license. */ 2 | 3 | import React, { useMemo } from "react"; 4 | // import Link from "next/link"; 5 | import { 6 | DependencyGraph as DependencyGraphType, 7 | graphToTree, 8 | Dep, 9 | } from "../util/registry_utils"; 10 | import Link from "next/link"; 11 | 12 | function DependencyGraph({ 13 | graph, 14 | entrypoint, 15 | currentModule, 16 | }: { 17 | graph: DependencyGraphType; 18 | entrypoint: string; 19 | currentModule: string; 20 | }): React.ReactElement | null { 21 | const tree = useMemo(() => { 22 | const tree = graphToTree(graph, entrypoint); 23 | return tree; 24 | }, [graph, entrypoint]); 25 | 26 | if (tree === undefined) return null; 27 | 28 | return ( 29 |
30 | 33 |
34 | ); 35 | } 36 | 37 | function Node({ node, currentModule }: { node: Dep; currentModule: string }) { 38 | const name = node.name.startsWith(currentModule) 39 | ? "~/" + node.name.substring(currentModule.length) 40 | : node.name; 41 | const url = node.name.startsWith("https://deno.land/x/std") 42 | ? node.name.replace("https://deno.land/x/std", "https://deno.land/std") 43 | : node.name; 44 | return ( 45 |
  • 46 |

    47 | {url.startsWith("https://deno.land/") ? ( 48 | 49 | {name} 50 | 51 | ) : ( 52 | 53 | {name} 54 | 55 | )} 56 |

    57 | 62 |
  • 63 | ); 64 | } 65 | 66 | export default DependencyGraph; 67 | -------------------------------------------------------------------------------- /components/ErrorMessage.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | export function ErrorMessage(props: { 4 | title: string; 5 | body: string; 6 | }): React.ReactElement { 7 | return ( 8 |
    9 |
    10 |
    11 | 16 | 21 | 22 |
    23 |
    24 |

    25 | {props.title} 26 |

    27 |
    28 | {props.body} 29 |
    30 |
    31 |
    32 |
    33 | ); 34 | } 35 | -------------------------------------------------------------------------------- /components/InlineCode.tsx: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 the Deno authors. All rights reserved. MIT license. */ 2 | 3 | import React from "react"; 4 | 5 | function InlineCode(props: { children: React.ReactNode }): React.ReactElement { 6 | return ( 7 | 8 | {props.children} 9 | 10 | ); 11 | } 12 | 13 | export default InlineCode; 14 | -------------------------------------------------------------------------------- /components/LoadingPage.tsx: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 the Deno authors. All rights reserved. MIT license. */ 2 | 3 | import React from "react"; 4 | import Head from "next/head"; 5 | 6 | function LoadingPage(): React.ReactElement { 7 | return ( 8 |
    9 | 10 | Deno 11 | 12 |
    13 |
    14 | ); 15 | } 16 | 17 | export default LoadingPage; 18 | -------------------------------------------------------------------------------- /components/NotFound.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import Footer from "./Footer"; 3 | import Header from "./Header"; 4 | 5 | function NotFoundPage(): React.ReactElement { 6 | return ( 7 |
    8 |
    9 |
    10 |
    11 |

    12 | 404 13 |

    14 |

    15 | Couldn't find what you're looking for. 16 |

    17 |
    18 |
    19 | 20 |
    21 |
    22 | Ferris 23 | Deno 24 |
    25 | 26 |
    27 |
    28 |
    29 | ); 30 | } 31 | 32 | export default NotFoundPage; 33 | -------------------------------------------------------------------------------- /components/Transition.tsx: -------------------------------------------------------------------------------- 1 | // From https://gist.githubusercontent.com/stevecastaneda/e71a8465c3f290b98982e5d160260de2/raw/68a48d6b5e0ef60ec5894a0cf6b171bb48681f23/Transition.tsx 2 | // JSX Version by Adam Wathan: https://gist.github.com/adamwathan/e0a791aa0419098a7ece70028b2e641e 3 | /* Copyright 2020 the Deno authors. All rights reserved. MIT license. */ 4 | 5 | import React, { ReactNode } from "react"; 6 | import { CSSTransition as ReactCSSTransition } from "react-transition-group"; 7 | import { useRef, useEffect, useContext } from "react"; 8 | 9 | interface TransitionProps { 10 | show?: boolean; 11 | enter?: string; 12 | enterFrom?: string; 13 | enterTo?: string; 14 | leave?: string; 15 | leaveFrom?: string; 16 | leaveTo?: string; 17 | appear?: string | boolean; 18 | children: ReactNode; 19 | } 20 | 21 | interface ParentContextProps { 22 | parent: { 23 | show?: boolean; 24 | appear?: string | boolean; 25 | isInitialRender?: boolean; 26 | }; 27 | } 28 | 29 | const TransitionContext = React.createContext({ 30 | parent: {}, 31 | }); 32 | 33 | function useIsInitialRender() { 34 | const isInitialRender = useRef(true); 35 | useEffect(() => { 36 | isInitialRender.current = false; 37 | }, []); 38 | return isInitialRender.current; 39 | } 40 | 41 | function CSSTransition({ 42 | show, 43 | enter = "", 44 | enterFrom = "", 45 | enterTo = "", 46 | leave = "", 47 | leaveFrom = "", 48 | leaveTo = "", 49 | appear, 50 | children, 51 | }: TransitionProps) { 52 | const enterClasses = enter.split(" ").filter((s) => s.length); 53 | const enterFromClasses = enterFrom.split(" ").filter((s) => s.length); 54 | const enterToClasses = enterTo.split(" ").filter((s) => s.length); 55 | const leaveClasses = leave.split(" ").filter((s) => s.length); 56 | const leaveFromClasses = leaveFrom.split(" ").filter((s) => s.length); 57 | const leaveToClasses = leaveTo.split(" ").filter((s) => s.length); 58 | 59 | function addClasses(node: HTMLElement, classes: string[]) { 60 | classes.length && node.classList.add(...classes); 61 | } 62 | 63 | function removeClasses(node: HTMLElement, classes: string[]) { 64 | classes.length && node.classList.remove(...classes); 65 | } 66 | 67 | return ( 68 | { 73 | node.addEventListener("transitionend", done, false); 74 | }} 75 | onEnter={(node: HTMLElement) => { 76 | addClasses(node, [...enterClasses, ...enterFromClasses]); 77 | }} 78 | onEntering={(node: HTMLElement) => { 79 | removeClasses(node, enterFromClasses); 80 | addClasses(node, enterToClasses); 81 | }} 82 | onEntered={(node: HTMLElement) => { 83 | removeClasses(node, [...enterToClasses, ...enterClasses]); 84 | }} 85 | onExit={(node) => { 86 | addClasses(node, [...leaveClasses, ...leaveFromClasses]); 87 | }} 88 | onExiting={(node) => { 89 | removeClasses(node, leaveFromClasses); 90 | addClasses(node, leaveToClasses); 91 | }} 92 | onExited={(node) => { 93 | removeClasses(node, [...leaveToClasses, ...leaveClasses]); 94 | }} 95 | > 96 | {children} 97 | 98 | ); 99 | } 100 | 101 | function Transition({ 102 | show, 103 | appear, 104 | ...rest 105 | }: TransitionProps): React.ReactElement { 106 | const { parent } = useContext(TransitionContext); 107 | const isInitialRender = useIsInitialRender(); 108 | const isChild = show === undefined; 109 | 110 | if (isChild) { 111 | return ( 112 | 117 | ); 118 | } 119 | 120 | return ( 121 | 130 | 131 | 132 | ); 133 | } 134 | 135 | export default Transition; 136 | -------------------------------------------------------------------------------- /components/app.css: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 the Deno authors. All rights reserved. MIT license. */ 2 | 3 | @import "tailwindcss/base"; 4 | @import "tailwindcss/components"; 5 | 6 | @import "tailwindcss/utilities"; 7 | 8 | html { 9 | scroll-behavior: smooth; 10 | } 11 | 12 | /* removes focus outlines on mouse clicks */ 13 | *:focus:not(:focus-visible), 14 | *::before:focus:not(:focus-visible), 15 | *::after:focus:not(:focus-visible) { 16 | outline: none; 17 | } 18 | 19 | /* https://github.com/denoland/deno_website2/issues/1163 */ 20 | .language-toml > code > .token-line > .table { 21 | display: inline; 22 | } 23 | 24 | .link { 25 | @apply text-blue-500; 26 | @apply transition; 27 | @apply duration-75; 28 | @apply ease-in-out; 29 | } 30 | 31 | .link:hover { 32 | @apply text-blue-400; 33 | } 34 | 35 | span.token.plain:empty:before { 36 | content: "\200b"; 37 | } 38 | 39 | ol.nested { 40 | counter-reset: item; 41 | } 42 | ol.nested li { 43 | display: block; 44 | } 45 | ol.nested li:before { 46 | font-feature-settings: "kern" 1, "tnum" 1; 47 | -webkit-font-feature-settings: "kern" 1, "tnum" 1; 48 | -ms-font-feature-settings: "kern" 1, "tnum" 1; 49 | -moz-font-feature-settings: "kern" 1, "tnum" 1; 50 | content: counters(item, ".") ". "; 51 | counter-increment: item; 52 | } 53 | 54 | .prism-code { 55 | border-radius: .25rem; 56 | tab-size: 2; 57 | -moz-tab-size: 2; 58 | } 59 | .highlight-line { 60 | background-color: #fffbdd; 61 | } 62 | 63 | ul.tree, 64 | ul.tree ul { 65 | list-style: none; 66 | margin: 0; 67 | padding: 0; 68 | } 69 | 70 | ul.tree ul { 71 | margin-left: 12px; 72 | } 73 | 74 | ul.tree li { 75 | margin: 0; 76 | padding: 0 8px; 77 | line-height: 20px; 78 | border-left: 1px solid rgb(100, 100, 100); 79 | } 80 | 81 | ul.tree li:last-child { 82 | border-left: none; 83 | } 84 | 85 | ul.tree li:before { 86 | position: relative; 87 | top: -4px; 88 | height: 12px; 89 | width: 12px; 90 | color: white; 91 | border-bottom: 1px solid rgb(100, 100, 100); 92 | content: ""; 93 | display: inline-block; 94 | left: -4px; 95 | } 96 | 97 | ul.tree li:last-child:before { 98 | border-left: 1px solid rgb(100, 100, 100); 99 | } 100 | 101 | /* 404 Page */ 102 | 103 | .NotFoundPage { 104 | width: 100%; 105 | min-height: 100vh; 106 | overflow-x: hidden; 107 | position: relative; 108 | display: flex; 109 | flex-flow: column wrap; 110 | justify-content: space-between; 111 | } 112 | 113 | .NotFoundPage header { 114 | text-align: center; 115 | padding: 10vh 2rem; 116 | z-index: 3; 117 | } 118 | 119 | .NotFoundPage #animation { 120 | margin-top: auto; 121 | width: 100%; 122 | pointer-events: none; 123 | height: 200px; 124 | position: relative; 125 | overflow: hidden; 126 | } 127 | 128 | .NotFoundPage #animation #ferris404 { 129 | transform: translateY(22px); 130 | width: 100px; 131 | position: absolute; 132 | left: 60%; 133 | bottom: 0; 134 | } 135 | 136 | .NotFoundPage #animation #deno404 { 137 | transform: translateY(24px); 138 | width: 200px; 139 | position: absolute; 140 | left: 10%; 141 | animation: move 6s linear infinite; 142 | } 143 | 144 | @keyframes move { 145 | from { 146 | left: -200px; 147 | } 148 | to { 149 | left: 100%; 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /docs/contributing.md: -------------------------------------------------------------------------------- 1 | 2 | # コントリビューティング 3 | 4 | 5 | - [スタイルガイド](./contributing/style_guide.md) を読んでください。 6 | 7 | 8 | - [ベンチマーク](https://deno-ja.vercel.app/benchmarks) を悪くしないでください。 9 | 10 | 11 | - [コミュニティチャットルーム](https://discord.gg/deno) で助けを求めてください。 12 | 13 | 17 | - issue で協力したい場合は、協力する前に _前に_ issue でメンションしてください。 18 | 19 | - If you are going to work on a new feature, create an issue and discuss with 20 | other contributors _before_ you start working on the feature. 21 | 22 | 27 | - フォーラムではプロフェッショナルでいてください。[Rust's code of conduct](https://www.rust-lang.org/policies/code-of-conduct) (CoC) に従っています。問題がある場合は、ry@tinyclouds.org にメールを送ってください。 28 | 29 | 30 | ## 開発 31 | 32 | 36 | ソースからのビルドのガイドは [こちら](./contributing/building_from_source.md) を見てください。 37 | 38 | 39 | ## プルリクエストの提出 40 | 41 | 42 | プルリクエストを提出する前に以下のことが終わっているか確かめてください: 43 | 44 | 65 | 1. PRタイトルに説明を書き込んでください。 66 | 67 | 良いPRタイトルの例: 68 | 69 | - fix(std/http): Fix race condition in server 70 | - docs(console): Update docstrings 71 | - feat(doc): Handle nested re-exports 72 | 73 | 悪いPRタイトルの例: 74 | 75 | - fix #7123 76 | - update docs 77 | - fix bugs 78 | 79 | 2. 関係するissueがありPRテキストに参照されているかどうかを確かめてください。 80 | 3. 変更をカバーするテストが存在するかを確かめてください。 81 | 5. `./tools/format.js` をファイルの変更なくパスするかどうかを確かめてください。 82 | 6. `./tools/lint.js` をパスするかどうかを確かめてください。 83 | 84 | 85 | ## Ops(別名、バインディング)を追加 86 | 87 | 92 | 新しいAPIを追加するときにミスをしないかとても心配しています。OpをDenoに追加するとき、他のプラットフォームでの対応するインターフェースを調べておく必要があります。この機能がGo、Node、Rust、Pythonでどのように行われているかリストアップしてください。 93 | 94 | 98 | 例として、`Deno.rename()` がどのように提案され追加されたか [PR #671](https://github.com/denoland/deno/pull/671) で見てください。 99 | 100 | 101 | ## リリース 102 | 103 | 107 | 前のリリースからの変更点のまとめは [こちら](https://github.com/denoland/deno/releases) で見つかります。 108 | 109 | 110 | ## APIのドキュメントの記述 111 | 112 | 117 | 公開APIのドキュメントを記述することは重要で、インラインでコードと主に記述してほしいです。コードとドキュメントが密に結合していることを確認することが出来ます。 118 | 119 | ### Utilize JSDoc 120 | 121 | 128 | すべての公開されているAPIと型は `deno` モジュールと global/`window` 名前空間の療法でJSDocドキュメントが必要です。このドキュメントは解析されTypeScriptで利用可能で、提供が簡単になります。JSDocブロックは適応される文の直前に来ており `/**` で始まり `*/` で終わります。例えば: 129 | 130 | 136 | ```ts 137 | /** シンプルなJSDocコメント */ 138 | export const FOO = "foo"; 139 | ``` 140 | 141 | 142 | 詳しくは https://jsdoc.app/ を参照してください 143 | -------------------------------------------------------------------------------- /docs/contributing/architecture.md: -------------------------------------------------------------------------------- 1 | 2 | ## 内部の詳細 3 | 4 | 5 | ### DenoとLinuxの類推 6 | 7 | | **Linux** | **Deno** | 8 | | ------------------------------: | :------------------------------------------- | 9 | | Processes | Web Workers | 10 | | Syscalls | Ops | 11 | | File descriptors (fd) | [Resource ids (rid)](architecture#resources) | 12 | | Scheduler | Tokio | 13 | | Userland: libc++ / glib / boost | https://deno.land/std/ | 14 | | /proc/\$\$/stat | [Deno.metrics()](architecture#metrics) | 15 | | man pages | deno types | 16 | 17 | 18 | #### リソース 19 | 20 | 26 | リソース(別名 `rid`)はファイル記述子のDeno版である。これらは開いているファイル、ソケット、その他の概念を参照するために使用される整数値です。テストでは開いているリソースの数を数えることが出来ると良いでしょう。 27 | 28 | ```ts 29 | console.log(Deno.resources()); 30 | // { 0: "stdin", 1: "stdout", 2: "stderr" } 31 | Deno.close(0); 32 | console.log(Deno.resources()); 33 | // { 1: "stdout", 2: "stderr" } 34 | ``` 35 | 36 | 37 | #### メトリック 38 | 39 | 40 | メトリックは各種統計のためのDenoの内部カウンターです。 41 | 42 | ```shell 43 | > console.table(Deno.metrics()) 44 | ┌─────────────────────────┬───────────┐ 45 | │ (idx) │ Values │ 46 | ├─────────────────────────┼───────────┤ 47 | │ opsDispatched │ 9 │ 48 | │ opsDispatchedSync │ 0 │ 49 | │ opsDispatchedAsync │ 0 │ 50 | │ opsDispatchedAsyncUnref │ 0 │ 51 | │ opsCompleted │ 9 │ 52 | │ opsCompletedSync │ 0 │ 53 | │ opsCompletedAsync │ 0 │ 54 | │ opsCompletedAsyncUnref │ 0 │ 55 | │ bytesSentControl │ 504 │ 56 | │ bytesSentData │ 0 │ 57 | │ bytesReceived │ 856 │ 58 | └─────────────────────────┴───────────┘ 59 | ``` 60 | 61 | 62 | ### 概要図 63 | 64 | ![architectural schematic](https://deno.land/images/schematic_v0.2.png) 65 | 66 | 67 | ### コンファレンス 68 | 69 | - Ryan Dahl. (May 27, 2020). 70 | [An interesting case with Deno](https://www.youtube.com/watch?v=1b7FoBwxc7E). 71 | Deno Israel. 72 | - Bartek Iwańczuk. (Oct 6, 2020). 73 | [Deno internals - how modern JS/TS runtime is 74 | built](https://www.youtube.com/watch?v=AOvg_GbnsbA&t=35m13s). Paris Deno. 75 | -------------------------------------------------------------------------------- /docs/contributing/development_tools.md: -------------------------------------------------------------------------------- 1 | 2 | ## テストとツール 3 | 4 | 5 | ### テスト 6 | 7 | 8 | `deno` をテスト: 9 | 10 | 19 | ```shell 20 | # スイートすべてをテスト: 21 | cargo test 22 | 23 | # cli/tests/unit/のみをテスト: 24 | cargo test js_unit_tests 25 | ``` 26 | 27 | 28 | `std/` をテスト: 29 | 30 | ```shell 31 | cargo test std_tests 32 | ``` 33 | 34 | 35 | ### リントとフォーマット 36 | 37 | 38 | コードのリント: 39 | 40 | ```shell 41 | deno run -A --unstable ./tools/lint.js 42 | ``` 43 | 44 | 45 | コードのフォーマット: 46 | 47 | ```shell 48 | deno run -A --unstable ./tools/format.js 49 | ``` 50 | 51 | 52 | ### 継続的ベンチマーク 53 | 54 | 55 | 私達のベンチマークは [こちら](https://deno.land/benchmarks) で見てください。 56 | 57 | 62 | ベンチマークチャートは https://github.com/denoland/benchmark_data/blob/gh-pages/data.json が下記で定義されるような `BenchmarkData` の `BenchmarkData[]` を持っていると想定します: 63 | 64 | ```ts 65 | interface ExecTimeData { 66 | mean: number; 67 | stddev: number; 68 | user: number; 69 | system: number; 70 | min: number; 71 | max: number; 72 | } 73 | 74 | interface BenchmarkData { 75 | created_at: string; 76 | sha1: string; 77 | benchmark: { 78 | [key: string]: ExecTimeData; 79 | }; 80 | binarySizeData: { 81 | [key: string]: number; 82 | }; 83 | threadCountData: { 84 | [key: string]: number; 85 | }; 86 | syscallCountData: { 87 | [key: string]: number; 88 | }; 89 | } 90 | ``` 91 | -------------------------------------------------------------------------------- /docs/contributing/release_schedule.md: -------------------------------------------------------------------------------- 1 | 2 | ## リリーススケジュール 3 | 4 | 9 | `deno` cli の新しいマイナーリリースは6週間毎に行われます。1.9.0 のあと4週毎のリリースサイクルに切り替えます。必要に応じて新しいパッチバージョンが毎週リリースされます。 10 | 11 | 12 | 今後のマイナーリリースの日付は: 13 | 14 | - 1.9.0: April 13, 2021 15 | - 1.10.0: May 11, 2021 16 | - 1.11.0: June 8, 2021 17 | 18 | 22 | 安定バージョンのリリースは[GitHub releases page](https://github.com/denoland/deno/releases)にあります。 23 | 24 | ### Canary channel 25 | 26 | 31 | 上記の安定チャンネルの他に canaries は毎日複数回(main の各コミットごとに)リリースされています。最新の canary チャンネルにアップグレードするには以下を実行してください: 32 | 33 | ``` 34 | deno upgrade --canary 35 | ``` 36 | 37 | 38 | 特定の canary にアップグレードするには `--version` オプションにコミットハッシュを渡してください: 39 | 40 | ``` 41 | deno upgrade --canary --version=973af61d8bb03c1709f61e456581d58386ed4952 42 | ``` 43 | 44 | 45 | 安定ちゃんねるに戻すには `deno upgrade` を実行してください。 46 | 47 | 48 | Canaries は https://dl.deno.land からダウンロードできます。 49 | -------------------------------------------------------------------------------- /docs/embedding_deno.md: -------------------------------------------------------------------------------- 1 | 2 | # Denoの埋め込み 3 | 4 | 9 | Denoは `deno_core` などの様々なパーツから成り立っています。これはJavaScriptランタイムをrustアプリケーションに埋め込むときに使われるrustクレートです。 10 | 11 | 12 | Denoクレートは [crates.io](https://crates.io/crates/deno_core) でホストされています。 13 | 14 | 15 | APIは [docs.rs](https://docs.rs/deno_core) で見ることが出来ます。 16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/examples.md: -------------------------------------------------------------------------------- 1 | 2 | ## サンプル 3 | 4 | 8 | この章ではより深くランタイムを理解するためのサンプルプログラムを見つけることが出来ます。 9 | 10 | 11 | ## 基本 12 | 13 | 20 | - [Hello world](./examples/hello_world.md) 21 | - [モジュールのインポートとエクスポート](./examples/import_export.md) 22 | - [依存関係の管理](./examples/manage_dependencies.md) 23 | - [データの取得](./examples/fetch_data.md) 24 | - [ファイルの読み書き](./examples/read_write_files.md) 25 | 26 | 27 | ## 応用 28 | 29 | 39 | - [Unix cat プログラム](./examples/unix_cat.md) 40 | - [HTTP web サーバー](./examples/http_server.md) 41 | - [ファイルサーバー](./examples/file_server.md) 42 | - [TCP echo サーバー](./examples/tcp_echo.md) 43 | - [サブプロセスの作成](./examples/subprocess.md) 44 | - [OS シグナル](./examples/os_signals.md) 45 | - [ファイルシステムイベント](./examples/file_system_events.md) 46 | - [モジュールメタデータ](./examples/module_metadata.md) -------------------------------------------------------------------------------- /docs/examples/fetch_data.md: -------------------------------------------------------------------------------- 1 | 2 | # データの取得 3 | 4 | 5 | ## 概念 6 | 7 | 14 | - ブラウザのようにDenoは [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) などのwebスタンダードAPIを実装しています。 15 | - Denoはデフォルトで安全です。つまりネットワークへのアクセスには明示的にパーミッションが許可される必要があります。 16 | - Denoの [パーミッション](../getting_started/permissions.md) モデルも見てください。 17 | 18 | 19 | ## 概要 20 | 21 | 28 | webアプリケーションのブルド時、開発者はwebのどこかからデータを取得する必要があるでしょう。これを実行するのにDenoとほかのJavaScriptアプリケーションで違いはありません、`fetch()` メソッドを呼び出してください。fetchに関するさらなる情報は [MDN documentation](https://developer.mozilla.org/ja/docs/Web/API/Fetch_API) を読んでください。 29 | 30 | 37 | Denoの例外は、webで呼び出しを行うスクリプトを実行時に発生します。Denoはデフォルトで安全であり、IO(Input/Output)にアクセスすることは禁止されています。webで呼び出しを行うためにはDenoに明示的に伝えなければいけません。`deno run` コマンド時に `--allow-net` フラグを追加することで実現します。 38 | 39 | 40 | ## 例 41 | 42 | **Command:** `deno run --allow-net fetch.ts` 43 | 44 | ```js 45 | /** 46 | * Output: JSON Data 47 | */ 48 | const json = fetch("https://api.github.com/users/denoland"); 49 | 50 | json.then((response) => { 51 | return response.json(); 52 | }).then((jsonData) => { 53 | console.log(jsonData); 54 | }); 55 | 56 | /** 57 | * Output: HTML Data 58 | */ 59 | const text = fetch("https://deno.land/"); 60 | 61 | text.then((response) => { 62 | return response.text(); 63 | }).then((textData) => { 64 | console.log(textData); 65 | }); 66 | 67 | /** 68 | * Output: Error Message 69 | */ 70 | const error = fetch("https://does.not.exist/"); 71 | 72 | error.catch((error) => console.log(error.message)); 73 | ``` 74 | -------------------------------------------------------------------------------- /docs/examples/file_server.md: -------------------------------------------------------------------------------- 1 | 2 | # ファイルサーバー 3 | 4 | 5 | ## 概念 6 | 7 | 14 | - Deno標準ライブラリの [file_server.ts](https://deno.land/std@$STD_VERSION/http/file_server.ts) を使用し、ファイルサーバーを実行しwebブラウザからファイルにアクセスします。 15 | - [Deno install](../tools/script_installer.md) を実行しファイルサーバーをローカルに保存します。 16 | 17 | 18 | ## 例 19 | 20 | Serve a local directory via HTTP. First install the remote script to your local 21 | file system. This will install the script to the Deno installation root's bin 22 | directory, e.g. `/home/alice/.deno/bin/file_server`. 23 | 24 | ```shell 25 | deno install --allow-net --allow-read https://deno.land/std@$STD_VERSION/http/file_server.ts 26 | ``` 27 | 28 | You can now run the script with the simplified script name. Run it: 29 | 30 | ```shell 31 | $ file_server . 32 | Downloading https://deno.land/std@$STD_VERSION/http/file_server.ts... 33 | [...] 34 | HTTP server listening on http://0.0.0.0:4507/ 35 | ``` 36 | 37 | Now go to [http://0.0.0.0:4507/](http://0.0.0.0:4507/) in your web browser to 38 | see your local directory contents. 39 | 40 | ## Help 41 | 42 | Help and a complete list of options are available via: 43 | 44 | ```shell 45 | file_server --help 46 | ``` 47 | 48 | Example output: 49 | 50 | ``` 51 | Deno File Server 52 | Serves a local directory in HTTP. 53 | 54 | INSTALL: 55 | deno install --allow-net --allow-read https://deno.land/std/http/file_server.ts 56 | 57 | USAGE: 58 | file_server [path] [options] 59 | 60 | OPTIONS: 61 | -h, --help Prints help information 62 | -p, --port Set port 63 | --cors Enable CORS via the "Access-Control-Allow-Origin" header 64 | --host Hostname (default is 0.0.0.0) 65 | -c, --cert TLS certificate file (enables TLS) 66 | -k, --key TLS key file (enables TLS) 67 | --no-dir-listing Disable directory listing 68 | 69 | All TLS options are required when one is provided. 70 | ``` 71 | -------------------------------------------------------------------------------- /docs/examples/file_system_events.md: -------------------------------------------------------------------------------- 1 | 2 | # ファイルシステムイベント 3 | 4 | 5 | ## 概念 6 | 7 | 12 | - [Deno.watchFs](https://doc.deno.land/builtin/stable#Deno.watchFs) を使用し、ファイルシステムイベントを監視します。 13 | - 結果はオペレーティングシステムによって異なる場合があります。 14 | 15 | 16 | ## 例 17 | 18 | 19 | 現在のディレクトリでファイルシステムイベントをポーリングするには: 20 | 21 | ```ts 22 | /** 23 | * watcher.ts 24 | */ 25 | const watcher = Deno.watchFs("."); 26 | for await (const event of watcher) { 27 | console.log(">>>> event", event); 28 | // Example event: { kind: "create", paths: [ "/home/alice/deno/foo.txt" ] } 29 | } 30 | ``` 31 | 32 | 33 | 実行してください: 34 | 35 | ```shell 36 | deno run --allow-read watcher.ts 37 | ``` 38 | 39 | 43 | さらに、`watcher.ts`と同じディレクトリにあるファイルを追加、削除、修正してみてください。 44 | 45 | 49 | イベントの順番はオペレーションシステムによって変わる可能性があります。この機能はプロットフォームによって別々のシステムコールを使います: 50 | 51 | - Linux: [inotify](https://man7.org/linux/man-pages/man7/inotify.7.html) 52 | - macOS: 53 | [FSEvents](https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/FSEvents_ProgGuide/Introduction/Introduction.html) 54 | - Windows: 55 | [ReadDirectoryChangesW](https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-readdirectorychangesw) 56 | -------------------------------------------------------------------------------- /docs/examples/hello_world.md: -------------------------------------------------------------------------------- 1 | # Hello world 2 | 3 | 4 | ## 概念 5 | 6 | 10 | - Denoは追加のツールや設定無しでJavaScriptとTypeScriptを実行できます。 11 | 12 | 13 | ## 概要 14 | 15 | 20 | DenoはJavaScriptとTypeScriptの両方のための安全なランタイムです。下記の hello world のサンプルにあるように、JavaScriptでもTypeScriptでも同じ機能を作ることが出来Denoは両方を実行することが出来ます。 21 | 22 | ## JavaScript 23 | 24 | 28 | JavaScriptの例では `Hello [name]` がコンソールに表示され、コードは提供された name を大文字にします。 29 | 30 | **Command:** `deno run hello-world.js` 31 | 32 | ```js 33 | /** 34 | * hello-world.js 35 | */ 36 | function capitalize(word) { 37 | return word.charAt(0).toUpperCase() + word.slice(1); 38 | } 39 | 40 | function hello(name) { 41 | return "Hello " + capitalize(name); 42 | } 43 | 44 | console.log(hello("john")); 45 | console.log(hello("Sarah")); 46 | console.log(hello("kai")); 47 | 48 | /** 49 | * Output: 50 | * 51 | * Hello John 52 | * Hello Sarah 53 | * Hello Kai 54 | **/ 55 | ``` 56 | 57 | ## TypeScript 58 | 59 | 63 | TypeScriptの例では上記のJavaScriptの例と全く同じことをします。コードはTypeScriptでサポートされつ型情報を追加しただけです。 64 | 65 | 69 | `deno run` コマンドは全く同じで、`*.js` ファイルの代わりに `*.ts` を参照します。 70 | 71 | **Command:** `deno run hello-world.ts` 72 | 73 | 99 | ```ts 100 | function capitalize(word: string): string { 101 | return word.charAt(0).toUpperCase() + word.slice(1); 102 | } 103 | 104 | function hello(name: string): string { 105 | return "Hello " + capitalize(name); 106 | } 107 | 108 | console.log(hello("john")); 109 | console.log(hello("Sarah")); 110 | console.log(hello("kai")); 111 | 112 | /** 113 | * 出力: 114 | * 115 | * Hello John 116 | * Hello Sarah 117 | * Hello Kai 118 | **/ 119 | ``` 120 | -------------------------------------------------------------------------------- /docs/examples/http_server.md: -------------------------------------------------------------------------------- 1 | 2 | # 簡単なHTTP webサーバー 3 | 4 | 5 | ## 概念 6 | 7 | 11 | - stdライブラリ [http module](https://deno.land/std@$STD_VERSION/http) を使用し、webサーバーを実行します。 12 | 13 | 14 | ## 概要 15 | 16 | 20 | 数行のコードでレスポンスステータスやリクエストヘッダーなどをコントールできるhttp webサーバーを実行することができます。 21 | 22 | 23 | ## 簡単なwebサーバー 24 | 25 | 26 | この例では、クライアントのuser-agentがクライアントに返されます: 27 | 28 | ```typescript 29 | /** 30 | * webserver.ts 31 | */ 32 | import { serve } from "https://deno.land/std@$STD_VERSION/http/server.ts"; 33 | 34 | const server = serve({ hostname: "0.0.0.0", port: 8080 }); 35 | console.log(`HTTP webserver running. Access it at: http://localhost:8080/`); 36 | 37 | for await (const request of server) { 38 | let bodyContent = "Your user-agent is:\n\n"; 39 | bodyContent += request.headers.get("user-agent") || "Unknown"; 40 | 41 | request.respond({ status: 200, body: bodyContent }); 42 | } 43 | ``` 44 | 45 | 46 | 実行してください: 47 | 48 | ```shell 49 | deno run --allow-net webserver.ts 50 | ``` 51 | -------------------------------------------------------------------------------- /docs/examples/manage_dependencies.md: -------------------------------------------------------------------------------- 1 | 2 | # 依存関係の管理 3 | 4 | 5 | ## 概念 6 | 7 | 15 | - Denoは依存関係管理にURLを使用します。 16 | - 慣習ではこれらの依存するURLをローカルの `deps.ts` に置きます。定数、関数などは `deps.ts` からエクスポートされ、ローカルモジュールで使用されます。 17 | - この慣習に習い、開発で使う依存関係は `dev_deps.ts` ファイルに保存することができます 18 | - [外部のコードとのリンク](../linking_to_external_code.md) も参照してください 19 | 20 | 21 | ## 概要 22 | 23 | 30 | Denoでは外部モジュールはローカルに直接インポートされるためパッケージマネージャの概念がありません。これはパッケージマネージャなしでどうやってリモートの依存関係を管理しますかという質問を生みます。たくさんの依存関係があるような巨大なプロジェクトでは、個別のモジュールに個別にインポートすると、モジュールの更新が面倒になり時間がかかるようになります。 31 | 32 | 41 | Denoでこの問題を解決する標準的な方法は `deps.ts` を作ることです。すべての要求されるリモート依存関係はこのファイルで参照され、要求されるメソッドとクラスは最エクスポートされます。依存するローカルモジュールはリモートの依存関係ではなく `deps.ts` を参照します。例えば一つのリモートの依存が複数のファイルに使用されていたら、このリモート依存のアップグレードが `deps.ts` 内よりで簡単にできます 42 | 43 | With all dependencies centralized in `deps.ts`, managing these becomes easier. 44 | Dev dependencies can also be managed in a separate `dev_deps.ts` file, allowing 45 | clean separation between dev only and production dependencies. 46 | 47 | 48 | ## 例 49 | 50 | ```ts 51 | /** 52 | * deps.ts 53 | * 54 | * This module re-exports the required methods from the dependant remote Ramda module. 55 | **/ 56 | export { 57 | add, 58 | multiply, 59 | } from "https://x.nest.land/ramda@0.27.0/source/index.js"; 60 | ``` 61 | 62 | 68 | この例では [local and remote import examples](./import_export.md) 同じ機能が作成されています。ただし、Ramdaモジュールを直接参照する代わりにローカルの `deps.ts` モジュールをプロキシで参照されています。 69 | 70 | **Command:** `deno run example.ts` 71 | 72 | 95 | ```ts 96 | import { add, multiply } from "./deps.ts"; 97 | 98 | function totalCost(outbound: number, inbound: number, tax: number): number { 99 | return multiply(add(outbound, inbound), tax); 100 | } 101 | 102 | console.log(totalCost(19, 31, 1.2)); 103 | console.log(totalCost(45, 27, 1.15)); 104 | 105 | /** 106 | * 出力 107 | * 108 | * 60 109 | * 82.8 110 | */ 111 | ``` 112 | -------------------------------------------------------------------------------- /docs/examples/module_metadata.md: -------------------------------------------------------------------------------- 1 | # Module metadata 2 | 3 | 4 | ## 概念 5 | 6 | 19 | - [import.meta](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import.meta) はモジュールのコンテクストの情報を提供します。 20 | - ブーリアン [import.meta.main](https://doc.deno.land/builtin/stable#ImportMeta) は現在のモジュールがエントリーポイントかどうか教えてくれます。 21 | - 文字列 [import.meta.url](https://doc.deno.land/builtin/stable#ImportMeta) は現在のモジュールのURLを教えてくれます。 22 | - 文字列 [Deno.mainModule](https://doc.deno.land/builtin/stable#Deno.mainModule) はメインモジュールのエントリーポイントのURLを教えてくれます。すなわち、denoランタイムによって呼び出されるモジュールのURLです。 23 | 24 | 25 | ## 例 26 | 27 | 32 | 下記の例は `import.meta.url`、`import.meta.main`、`Deno.mainModule` の違いを示すために2つのモジュールを使用します。この例では `module_a.ts` がメインモジュールエントリーポイントです: 33 | 34 | ```ts 35 | /** 36 | * module_b.ts 37 | */ 38 | export function outputB() { 39 | console.log("Module B's import.meta.url", import.meta.url); 40 | console.log("Module B's mainModule url", Deno.mainModule); 41 | console.log( 42 | "Is module B the main module via import.meta.main?", 43 | import.meta.main, 44 | ); 45 | } 46 | ``` 47 | 48 | ```ts 49 | /** 50 | * module_a.ts 51 | */ 52 | import { outputB } from "./module_b.ts"; 53 | 54 | function outputA() { 55 | console.log("Module A's import.meta.url", import.meta.url); 56 | console.log("Module A's mainModule url", Deno.mainModule); 57 | console.log( 58 | "Is module A the main module via import.meta.main?", 59 | import.meta.main, 60 | ); 61 | } 62 | 63 | outputA(); 64 | console.log(""); 65 | outputB(); 66 | ``` 67 | 68 | 72 | もし `module_a.ts` が `/home/alice/deno` にあったら `deno run --allow-read module_a.ts` の出力は: 73 | 74 | ``` 75 | Module A's import.meta.url file:///home/alice/deno/module_a.ts 76 | Module A's mainModule url file:///home/alice/deno/module_a.ts 77 | Is module A the main module via import.meta.main? true 78 | 79 | Module B's import.meta.url file:///home/alice/deno/module_b.ts 80 | Module B's mainModule url file:///home/alice/deno/module_a.ts 81 | Is module B the main module via import.meta.main? false 82 | ``` 83 | -------------------------------------------------------------------------------- /docs/examples/os_signals.md: -------------------------------------------------------------------------------- 1 | 2 | # OSシグナルの取り扱い 3 | 4 | 8 | > このプログラムは不安定版のDenoの機能を使います。詳しくは [不安定版の機能](../runtime/stability.md) を参照してください。 9 | 10 | 11 | ## 概念 12 | 13 | 21 | - Denoの新しい機能や不安定な機能にアクセスするには `--unstable` フラグを使用してください。 22 | - [Deno.signal](https://doc.deno.land/builtin/unstable#Deno.signal) はOSシグナルを取得したり監視したりするのに使用されます。 23 | - シグナルの監視を停止するにはDeno.signal [SignalStream](https://doc.deno.land/builtin/unstable#Deno.SignalStream) の `dispose()` を使用してください。 24 | 25 | 26 | ## 非同期イテレーターの例 27 | 28 | 29 | OSシグナルを取り扱うために `Deno.signal()` を使うことが出来ます: 30 | 31 | ```ts 32 | /** 33 | * async-iterator-signal.ts 34 | */ 35 | console.log("Press Ctrl-C to trigger a SIGINT signal"); 36 | for await (const _ of Deno.signal(Deno.Signal.SIGINT)) { 37 | console.log("interrupted!"); 38 | Deno.exit(); 39 | } 40 | ``` 41 | 42 | 43 | 実行してください: 44 | 45 | ```shell 46 | deno run --unstable async-iterator-signal.ts 47 | ``` 48 | 49 | 50 | ## プロミスの例 51 | 52 | 53 | `Deno.signal()` はpromiseとしても動作します。 54 | 55 | ```ts 56 | /** 57 | * promise-signal.ts 58 | */ 59 | console.log("Press Ctrl-C to trigger a SIGINT signal"); 60 | await Deno.signal(Deno.Signal.SIGINT); 61 | console.log("interrupted!"); 62 | Deno.exit(); 63 | ``` 64 | 65 | 66 | 実行してください: 67 | 68 | ```shell 69 | deno run --unstable promise-signal.ts 70 | ``` 71 | 72 | 73 | ## シグナルの監視の停止 74 | 75 | 79 | シグナルの監視をやめたくなったら、シグナルオブジェクトの `dispose()` メソッドを使うことが出来ます: 80 | 81 | ```ts 82 | /** 83 | * dispose-signal.ts 84 | */ 85 | const sig = Deno.signal(Deno.Signal.SIGINT); 86 | setTimeout(() => { 87 | sig.dispose(); 88 | console.log("No longer watching SIGINT signal"); 89 | }, 5000); 90 | 91 | console.log("Watching SIGINT signals"); 92 | for await (const _ of sig) { 93 | console.log("interrupted"); 94 | } 95 | ``` 96 | 97 | 98 | 実行してください: 99 | 100 | ```shell 101 | deno run --unstable dispose-signal.ts 102 | ``` 103 | 104 | 105 | 上記のfor-awaitループは `sig.dispose()` が呼ばれたあと5秒語に停止します。 106 | -------------------------------------------------------------------------------- /docs/examples/subprocess.md: -------------------------------------------------------------------------------- 1 | 2 | # サブプロセスの作成 3 | 4 | 5 | ## 概念 6 | 7 | 19 | - Deno [Deno.run](https://doc.deno.land/builtin/stable#Deno.run) を通してサブプロセスを生成することができます。 20 | - `--allow-run` パーミッションはサブプロセスの生成に必要です。 21 | - 生成されたサブプロセスはセキュリティサンドボックス内で実行されません。 22 | - サブプロセスとの通信は [stdin](https://doc.deno.land/builtin/stable#Deno.stdin)、[stdout](https://doc.deno.land/builtin/stable#Deno.stdout)、[stderr](https://doc.deno.land/builtin/stable#Deno.stderr) ストリームを通して行います。 23 | - 特定のシェルのパス/名前と文字入力スイッチを指定することで、特定のシェルを使用します、例えば `Deno.run({cmd: ["bash", "-c", '"ls -la"']});` 24 | 25 | 26 | ## 簡単な例 27 | 28 | 29 | この例はコマンドラインから `'echo hello'` を実行しているのと同等です。 30 | 31 | 46 | ```ts 47 | /** 48 | * subprocess_simple.ts 49 | */ 50 | 51 | // サブプロセスの作成 52 | const p = Deno.run({ 53 | cmd: ["echo", "hello"], 54 | }); 55 | 56 | // 完了を待つ 57 | await p.status(); 58 | ``` 59 | 60 | 61 | 実行: 62 | 63 | ```shell 64 | $ deno run --allow-run ./subprocess_simple.ts 65 | hello 66 | ``` 67 | 68 | 69 | ## セキュリティ 70 | 71 | 76 | サブプロセスの作成には `--allow-run` パーミッションが必要です。サブプロセスはDenoサンドボックスで実行されないためコマンドラインからコマンドを実行するのと同じ権限を持っていることに注意してください。 77 | 78 | 79 | ## サブプロセスとの通信 80 | 81 | 86 | デフォルトでは `Deno.run()` サブプロセスを使うとき親プロセスの `stdin`、`stdout` そして `stderr` を継承します。もし開始されたサブプロセスと通信したいときは `"piped"` オプションを使うことが出来ます。 87 | 88 | ```ts 89 | /** 90 | * subprocess.ts 91 | */ 92 | const fileNames = Deno.args; 93 | 94 | const p = Deno.run({ 95 | cmd: [ 96 | "deno", 97 | "run", 98 | "--allow-read", 99 | "https://deno.land/std@$STD_VERSION/examples/cat.ts", 100 | ...fileNames, 101 | ], 102 | stdout: "piped", 103 | stderr: "piped", 104 | }); 105 | 106 | const { code } = await p.status(); 107 | 108 | // Reading the outputs closes their pipes 109 | const rawOutput = await p.output(); 110 | const rawError = await p.stderrOutput(); 111 | 112 | if (code === 0) { 113 | const rawOutput = await p.output(); 114 | await Deno.stdout.write(rawOutput); 115 | } else { 116 | const rawError = await p.stderrOutput(); 117 | const errorString = new TextDecoder().decode(rawError); 118 | console.log(errorString); 119 | } 120 | 121 | Deno.exit(code); 122 | ``` 123 | 124 | 125 | 実行時: 126 | 127 | ```shell 128 | $ deno run --allow-run ./subprocess.ts 129 | [file content] 130 | 131 | $ deno run --allow-run ./subprocess.ts non_existent_file.md 132 | 133 | Uncaught NotFound: No such file or directory (os error 2) 134 | at DenoError (deno/js/errors.ts:22:5) 135 | at maybeError (deno/js/errors.ts:41:12) 136 | at handleAsyncMsgFromRust (deno/js/dispatch.ts:27:17) 137 | ``` 138 | -------------------------------------------------------------------------------- /docs/examples/tcp_echo.md: -------------------------------------------------------------------------------- 1 | 2 | # TCP echo サーバー 3 | 4 | 5 | ## 概念 6 | 7 | 13 | - [Deno.listen](https://doc.deno.land/builtin/stable#Deno.listen) でTCPポートへのコネクションをリッスンする。 14 | - [Deno.copy](https://doc.deno.land/builtin/stable#Deno.copy) を使用し、受信したデータを送信するデータにリダイレクトします。 15 | 16 | 17 | ## 例 18 | 19 | 23 | これはポート8080でコネクションを受けクライアントから送られてきたものをそのまま返すサーバーの例です。 24 | 25 | ```ts 26 | /** 27 | * echo_server.ts 28 | */ 29 | const listener = Deno.listen({ port: 8080 }); 30 | console.log("listening on 0.0.0.0:8080"); 31 | for await (const conn of listener) { 32 | Deno.copy(conn, conn).finally(() => conn.close()); 33 | } 34 | ``` 35 | 36 | 37 | 実行してください: 38 | 39 | ```shell 40 | deno run --allow-net echo_server.ts 41 | ``` 42 | 43 | 49 | テストするには [netcat](https://en.wikipedia.org/wiki/Netcat) (Linux/MacOSのみ)を使用してデータを送信してみてください。下記では `'hello world'` が送信されユーザーにエコーバックされています: 50 | 51 | ```shell 52 | $ nc localhost 8080 53 | hello world 54 | hello world 55 | ``` 56 | 57 | 62 | [cat.tsの例](./unix_cat.md) と同じように `copy()` 関数は無駄なメモリコピーを作りません。この関数はカーネルからパケットが送られそして複雑なことをせずに送り返します。 63 | -------------------------------------------------------------------------------- /docs/examples/unix_cat.md: -------------------------------------------------------------------------------- 1 | 2 | # unix "cat" プログラムの実装 3 | 4 | 5 | ## 概念 6 | 7 | 18 | - DenoランタイムAPIを使用し、ファイルの内容をコンソールに出力します。 19 | - [Deno.args](https://doc.deno.land/builtin/stable#Deno.args) はコマンドライン引数にアクセスします。 20 | - [Deno.open](https://doc.deno.land/builtin/stable#Deno.open) はファイルの取得に使用します。 21 | - [Deno.copy](https://doc.deno.land/builtin/stable#Deno.copy) はファイルから出力ストリームにデータを転送します。 22 | - ファイルは終了したあとに閉じられるべきです。 23 | - モジュールはリモートURLから直接実行できます。 24 | 25 | 26 | ## 例 27 | 28 | 32 | このプログラムはそれぞれのコマンドライン引数をファイル名とし、そのファイルを開き標準出力に表示します(例、コンソール)。 33 | 34 | ```ts 35 | /** 36 | * cat.ts 37 | */ 38 | for (let i = 0; i < Deno.args.length; i++) { 39 | const filename = Deno.args[i]; 40 | const file = await Deno.open(filename); 41 | await Deno.copy(file, Deno.stdout); 42 | file.close(); 43 | } 44 | ``` 45 | 46 | プログラムを実行: 47 | 48 | ```shell 49 | deno run --allow-read https://deno.land/std@$STD_VERSION/examples/cat.ts /etc/passwd 50 | ``` 51 | -------------------------------------------------------------------------------- /docs/getting_started.md: -------------------------------------------------------------------------------- 1 | # Getting Started 2 | 3 | 4 | この章では以下のことが書かれています: 5 | 6 | 16 | - [Denoのインストール](./getting_started/installation.md) 17 | - [環境の構築](./getting_started/setup_your_environment.md) 18 | - [`Hello World`スクリプトの実行](./getting_started/first_steps.md) 19 | - [自身でスクリプトの記述](./getting_started/first_steps.md) 20 | - [コマンドラインインターフェース](./getting_started/command_line_interface.md) 21 | - [パーミッションの理解](./getting_started/permissions.md) 22 | - [WebAssemblyの使用](./getting_started/webassembly.md) 23 | - [コードのデバッグ](./getting_started/debugging_your_code.md) 24 | -------------------------------------------------------------------------------- /docs/getting_started/installation.md: -------------------------------------------------------------------------------- 1 | 2 | ## インストール 3 | 4 | 8 | DenoはmacOS、Linux、Windowsで動作します。Denoは1つの実行ファイルで実行可能です。外部依存はありません。 9 | 10 | 11 | ### ダウンロードとインストール 12 | 13 | 17 | [deno_install](https://github.com/denoland/deno_install)は実行ファイルをダウンロードしてインストールするのに便利なスクリプトを提供します。 18 | 19 | 20 | Shell (macOS、Linux) を使う: 21 | 22 | ```shell 23 | curl -fsSL https://deno.land/x/install/install.sh | sh 24 | ``` 25 | 26 | 27 | PowerShell (Windows) を使う: 28 | 29 | ```shell 30 | iwr https://deno.land/x/install/install.ps1 -useb | iex 31 | ``` 32 | 33 | 34 | [Scoop](https://scoop.sh/) (Windows) を使う: 35 | 36 | ```shell 37 | scoop install deno 38 | ``` 39 | 40 | 41 | [Chocolatey](https://chocolatey.org/packages/deno) (Windows) を使う: 42 | 43 | ```shell 44 | choco install deno 45 | ``` 46 | 47 | 48 | [Homebrew](https://formulae.brew.sh/formula/deno) (macOS)を使う: 49 | 50 | ```shell 51 | brew install deno 52 | ``` 53 | 54 | 55 | [Nix](https://nixos.org/download.html) を使う (macOS and Linux): 56 | 57 | ```shell 58 | nix-shell -p deno 59 | ``` 60 | 61 | 62 | [Cargo](https://crates.io/crates/deno) を使ってソースからビルドしてインストール: 63 | 64 | ```shell 65 | cargo install deno --locked 66 | ``` 67 | 68 | 74 | Deno実行ファイルは [github.com/denoland/deno/releases](https://github.com/denoland/deno/releases) のzipファイルをダウンロードして手動でインストールすることも可能です。これらのパッケージは1つの実行ファイルのみを含んでいます。macOSとLinuxでは実行可能ビットを設定する必要があります。 75 | 76 | 77 | ### インストールの確認 78 | 79 | 83 | インストールが出来たか確認するために `deno --version` を実行してください。コンソールにDenoのバージョンが表示されればインストールは成功しています。 84 | 85 | 89 | `deno help` を使うことでDenoのフラグや使い方を見ることが出来ます。CLIの詳しい使い方は[こちら](./command_line_interface.md)。 90 | 91 | 92 | ### アップデート 93 | 94 | 95 | 前回インストールしたDenoのバージョンからアップデートするには、次を実行してください: 96 | 97 | ```shell 98 | deno upgrade 99 | ``` 100 | 101 | 106 | これは[github.com/denoland/deno/releases](https://github.com/denoland/deno/releases)から最新のリリースを取得、解凍し現在のバージョンの実行ファイルと置き換えます。 107 | 108 | 109 | 次のユーティリティを使うことでDenoの特定のバージョンをインストールすることも出来ます: 110 | 111 | ```shell 112 | deno upgrade --version 1.0.1 113 | ``` 114 | 115 | 116 | ### ソースからのビルド 117 | 118 | 122 | ソースからビルドする方法については `Contributing` を参照してください。 123 | -------------------------------------------------------------------------------- /docs/getting_started/permissions.md: -------------------------------------------------------------------------------- 1 | 2 | ## パーミッション 3 | 4 | 10 | Denoはデフォルトで安全です。そのため、明確に有効にしない限り、Denoモジュールはファイル、ネットワーク、環境などへのアクセスが有りません。セキュリティに関わるエリアや機能へのアクセスはコマンドラインでdenoのプロセスを生成するときにパーミッションの使用を要求します。 11 | 12 | 17 | 次の例では、`mod.ts` がファイルシステムへ読み込みのみのアクセスを得ます。書き込みや他のセキュリティに関わる機能はできません。 18 | 19 | ```shell 20 | deno run --allow-read mod.ts 21 | ``` 22 | 23 | 24 | ### パーミッションリスト 25 | 26 | 27 | 次のパーミッションが利用可能です: 28 | 29 | 50 | - **-A, --allow-all** すべてのパーミッションを許可。すべてのセキュリティを無効化。 51 | - **--allow-env** 環境変数を取得したり設定したりするためのアクセスを許可。 52 | - **--allow-hrtime** 高分解能時間計測を許可。高分解時間はタイミング攻撃やフィンガープリントに使われます。 53 | - **--allow-net=\** ネットワークアクセスを許可。任意で、カンマで区切られたリストを指定して、許可されたドメインの許可リストを提供することが出来ます。 54 | - **--allow-plugin** プラグインのロードを許可。--allow-plugin は不安定な機能であることに注意してください。 55 | - **--allow-read=\** ファイルシステムの読み込みを許可。任意でディレクトリまたはファイルのカンマ区切りのリストを指定することで、ファイルシステムへの許可をするリストを提供する事ができます。 56 | - **--allow-run** サブプロセスの実行を許可。サブプロセスはサンドボックスで実行されるわけではないことに注意してください、そのため、denoのプロセスと同じセキュリティ制限を持ちません。そのため注意してください。 57 | - **--allow-write=\** ファイルシステムへの書き込みを許可。任意でディレクトリまたはファイルのカンマ区切りのリストを指定することで、ファイルシステムへの許可をするリストを提供する事ができます。 58 | 59 | 60 | ### パーミッション許可リスト 61 | 62 | 66 | Denoは許可リストを用いてパーミッションの粒度を制御することが出来ます。 67 | 68 | 73 | この例では `/usr` ディレクトリのみを含む許可リストでファイルシステムを制限しますが、プロセスが `/etc` ディレクトリの中のファイルにアクセスしようとしているため実行に失敗します: 74 | 75 | ```shell 76 | $ deno run --allow-read=/usr https://deno.land/std@$STD_VERSION/examples/cat.ts /etc/passwd 77 | error: Uncaught PermissionDenied: read access to "/etc/passwd", run again with the --allow-read flag 78 | ► $deno$/dispatch_json.ts:40:11 79 | at DenoError ($deno$/errors.ts:20:5) 80 | ... 81 | ``` 82 | 83 | 84 | 許可リストに `/etc` を指定し正しいパーミッションでもう一度試してみてください: 85 | 86 | ```shell 87 | deno run --allow-read=/etc https://deno.land/std@$STD_VERSION/examples/cat.ts /etc/passwd 88 | ``` 89 | 90 | 91 | `--allow-write` は `--allow-read` と同様に動きます。 92 | 93 | 94 | ### ネットワークアクセス: 95 | 96 | _fetch.ts_: 97 | 98 | ```ts 99 | const result = await fetch("https://deno.land/"); 100 | ``` 101 | 102 | 103 | これはホスト/urlの許可リストの例です: 104 | 105 | ```shell 106 | deno run --allow-net=github.com,deno.land fetch.ts 107 | ``` 108 | 109 | 113 | もし `fetch.ts` が他のドメインにネットワークコネクションを確立しようとしたらプロセスは失敗します。 114 | 115 | 116 | すべてのホスト/urlを許可: 117 | 118 | ```shell 119 | deno run --allow-net fetch.ts 120 | ``` 121 | 122 | ### Conference 123 | 124 | Ryan Dahl. (September 25, 2020). 125 | [The Deno security model](https://www.youtube.com/watch?v=r5F6dekUmdE#t=34m57). 126 | Speakeasy JS. 127 | -------------------------------------------------------------------------------- /docs/getting_started/typescript.md: -------------------------------------------------------------------------------- 1 | 2 | ## TypeScriptの使用 3 | 4 | 8 | > i このセクションは [TypeScriptの使用の章](../typescript.md) に移動しました。 9 | -------------------------------------------------------------------------------- /docs/getting_started/webassembly.md: -------------------------------------------------------------------------------- 1 | 2 | ## WebAssembly サポート 3 | 4 | 9 | Deno は [browsers provide](https://developer.mozilla.org/en-US/docs/WebAssembly) と同じインターフェースと使って [WebAssembly](https://webassembly.org/) モジュールを実行できます。 10 | 11 | 12 | 13 | ```ts 14 | const wasmCode = new Uint8Array([ 15 | 0, 97, 115, 109, 1, 0, 0, 0, 1, 133, 128, 128, 128, 0, 1, 96, 0, 1, 127, 16 | 3, 130, 128, 128, 128, 0, 1, 0, 4, 132, 128, 128, 128, 0, 1, 112, 0, 0, 17 | 5, 131, 128, 128, 128, 0, 1, 0, 1, 6, 129, 128, 128, 128, 0, 0, 7, 145, 18 | 128, 128, 128, 0, 2, 6, 109, 101, 109, 111, 114, 121, 2, 0, 4, 109, 97, 19 | 105, 110, 0, 0, 10, 138, 128, 128, 128, 0, 1, 132, 128, 128, 128, 0, 0, 20 | 65, 42, 11 21 | ]); 22 | const wasmModule = new WebAssembly.Module(wasmCode); 23 | const wasmInstance = new WebAssembly.Instance(wasmModule); 24 | const main = wasmInstance.exports.main as CallableFunction 25 | console.log(main().toString()); 26 | ``` 27 | -------------------------------------------------------------------------------- /docs/help.md: -------------------------------------------------------------------------------- 1 | 2 | # ヘルプはどこにありますか? 3 | 4 | 5 | 動かない?迷った?コミュニティからの助けを借りましょう。 6 | 7 | ### [Stack Overflow](https://stackoverflow.com/questions/tagged/deno) 8 | 9 | 14 | Stack Overflow はコードレベルの質問をしたり、特定のエラーで動かない場合の人気のフォーラムです。[聞いてみてください!](https://stackoverflow.com/questions/ask?tags=deno) 15 | 16 | ### [Community Discord](https://discord.gg/deno) 17 | 18 | 19 | 質問をしたり、コミュニティメンバーとリアルタイムでチャットしてください。 20 | 21 | ### [DEV's Deno Community](https://dev.to/t/deno) 22 | 23 | 27 | ベストプラクティスやアプリケーションアーキテクチャ、新しい学びに関する興味深い記事を見つけることが出来る場所です。タグ `deno` をつけて記事を投稿してください。 28 | -------------------------------------------------------------------------------- /docs/images/debugger1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tokiedokie/deno_website2_japanese/e0f5d0d93cd5210a3ddeee823dd5e7ddac8a21f4/docs/images/debugger1.jpg -------------------------------------------------------------------------------- /docs/images/debugger2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tokiedokie/deno_website2_japanese/e0f5d0d93cd5210a3ddeee823dd5e7ddac8a21f4/docs/images/debugger2.jpg -------------------------------------------------------------------------------- /docs/images/debugger3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tokiedokie/deno_website2_japanese/e0f5d0d93cd5210a3ddeee823dd5e7ddac8a21f4/docs/images/debugger3.jpg -------------------------------------------------------------------------------- /docs/images/debugger4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tokiedokie/deno_website2_japanese/e0f5d0d93cd5210a3ddeee823dd5e7ddac8a21f4/docs/images/debugger4.jpg -------------------------------------------------------------------------------- /docs/images/debugger5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tokiedokie/deno_website2_japanese/e0f5d0d93cd5210a3ddeee823dd5e7ddac8a21f4/docs/images/debugger5.jpg -------------------------------------------------------------------------------- /docs/images/debugger7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tokiedokie/deno_website2_japanese/e0f5d0d93cd5210a3ddeee823dd5e7ddac8a21f4/docs/images/debugger7.jpg -------------------------------------------------------------------------------- /docs/images/deno3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tokiedokie/deno_website2_japanese/e0f5d0d93cd5210a3ddeee823dd5e7ddac8a21f4/docs/images/deno3.png -------------------------------------------------------------------------------- /docs/introduction.md: -------------------------------------------------------------------------------- 1 | 2 | # イントロダクション 3 | 4 | 8 | Denoはデフォルトで安全なJavaScript/TypeScriptのランタイムで素晴らしいデベロッパーエクスペリエンスを提供します。 9 | 10 | 13 | V8、Rust、Tokioを使って作られています。 14 | 15 | 16 | ## 機能のハイライト 17 | 18 | 31 | - デフォルトで安全。ファイル、ネットワーク、環境へのアクセスなし(明示的に有効にしない限り)。 32 | - 最初からTypeScriptをサポート。 33 | - 1つの実行ファイル(`deno`)で実行可能。 34 | - 依存関係インスペクター(`deno info`)やコードフォーマッター(`deno fmt`)などのビルトインユーティリティーを持っています。 35 | - Denoで動作する[審査済み(監査済み)の標準モジュール](https://github.com/denoland/deno_std)を持っています。 36 | - スクリプトを1つのJavaScriptファイルにバンドルすることが出来ます。 37 | 38 | 39 | ## 哲学 40 | 41 | 45 | Denoはモダンなプログラマーのための生産的で安全なスクリプトが実行できる環境を目指しています。 46 | 47 | 54 | Denoは常に1つの実行ファイルで配布されます。[~25メガバイトのzip圧縮された実行ファイル](https://github.com/denoland/deno/releases)だけでDenoは実行可能です。 55 | Denoはランタイムとパッケージマネージャの両方の機能を持っています。モジュールの読み込みにはURLなどの標準ブラウザ互換プロトコルを利用します。 56 | 57 | 61 | とりわけ、DenoはBashやPythonで書かれた過去のユーティリティースクリプトの優れた代替です。 62 | 63 | 64 | ## ゴール 65 | 66 | 80 | - 1つの実行ファイル(`deno`)で実行可能。 81 | - 安全な初期設定の提供。 82 | - 明確に許可しない限りスクリプトはファイル、環境、ネットワークにアクセスできません。 83 | - ブラウザ互換であること。 84 | - 完全に JavaScript で書かれていて、グローバル `Deno` 名前空間を使っていない Deno プラグラムのサブセット(もしくはそのための機能テスト)は、モダンなブラウザでも変更なしに実行できるようにする必要があります。 85 | - デベロッパーエクスペリエンスを向上させるためのビルトインツールの提供。 86 | - 例えば、ユニットテスト、コードフォーマット、リント。 87 | - V8のコンセプトをユーザーランドから排除。 88 | - 効率的にHTTPを提供できること。 89 | 90 | 91 | ## Node.jsとの比較 92 | 93 | 104 | - Denoは`npm`を使いません。 105 | - モジュールの参照にはURLやファイルパスを使います。 106 | - Denoはモジュールの解決のために`package.json`を使いません。 107 | - Denoのすべての非同期の動作はプロミスを返します。よって、DenoはNodeと違うAPIを提供します。 108 | - Denoはファイル、ネットワーク、環境へのアクセスには明示的なパーミッションを要求します。 109 | - Denoは捕獲できないエラーの場合かならず停止します。 110 | - "ESモジュール"を使い`require()`をサポートしません。サードパーティモジュールはURLによってインポートされます: 111 | 112 | ```javascript 113 | import * as log from "https://deno.land/std@$STD_VERSION/log/mod.ts"; 114 | ``` 115 | 116 | 117 | ## その他の重要な振る舞い 118 | 119 | 126 | - リモートにあるコードは最初の実行のときに取得、キャッシュされ、`--reload`フラッグ付きで実行されるまでアップデートされません。(だから、飛行機の中でも動きます。) 127 | - リモートのURLからロードされたモジュール/ファイルはイミュータブルでキャッシュ可能になるよう意図しています。 128 | -------------------------------------------------------------------------------- /docs/linking_to_external_code/import_maps.md: -------------------------------------------------------------------------------- 1 | ## Import maps 2 | 3 | 4 | Denoは [import maps](https://github.com/WICG/import-maps) をサポートしています。 5 | 6 | 7 | `--import-map=` CLIフラグでimport mapsを使うことが出来まます。 8 | 9 | 10 | 例: 11 | 12 | **import_map.json** 13 | 14 | ```js 15 | { 16 | "imports": { 17 | "fmt/": "https://deno.land/std@$STD_VERSION/fmt/" 18 | } 19 | } 20 | ``` 21 | 22 | **color.ts** 23 | 24 | ```ts 25 | import { red } from "fmt/colors.ts"; 26 | 27 | console.log(red("hello world")); 28 | ``` 29 | 30 | 31 | 次に: 32 | 33 | ```shell 34 | $ deno run --import-map=import_map.json color.ts 35 | ``` 36 | 37 | 38 | 絶対的インポートにプロジェクトルートを使う: 39 | 40 | **import_map.json** 41 | 42 | ```jsonc 43 | { 44 | "imports": { 45 | "/": "./", 46 | "./": "./" 47 | } 48 | } 49 | ``` 50 | 51 | **main.ts** 52 | 53 | ```ts 54 | import { MyUtil } from "/util.ts"; 55 | ``` 56 | 57 | 61 | これにより `/` で始まるインポート指定子はインポートマップのURLまたはファイルパスに対して相対的に解決されます。 62 | -------------------------------------------------------------------------------- /docs/linking_to_external_code/proxies.md: -------------------------------------------------------------------------------- 1 | 2 | ## プロキシ 3 | 4 | 5 | DenoはモジュールのダウンロードのためのプロキシとWeb標準の `fetch` APIをサポートしています。 6 | 7 | 10 | プロキシ設定は環境変数 `HTTP_PROXY`、`HTTPS_PROXY` 及び `NO_PROXY` から読み込まれます。 11 | 12 | 16 | Windowsの場合、環境変数が見つからない場合Denoはレジストリからプロキシを読み込みます。 17 | -------------------------------------------------------------------------------- /docs/linking_to_external_code/reloading_modules.md: -------------------------------------------------------------------------------- 1 | 2 | ## モジュールの再ロード 3 | 4 | 11 | デフォルトではキャッシュ中のモジュールは新たに取得や再コンパイルされずに再利用されます。これが望ましくない場合はdenoに強制的にモジュールを再取得、再コンパイルさせキャッシュさせることが出来ます。`deno cache` サブコマンドの `--reload` フラグを使うことでローカルの `DENO_DIR` を無効にすることが出来ます。使い方は下記にあります: 12 | 13 | 14 | ### すべてを再ロード 15 | 16 | ```ts 17 | deno cache --reload my_module.ts 18 | ``` 19 | 20 | 21 | ### 特定のモジュールを再ロード 22 | 23 | 27 | いくつかのモジュールだけ更新したいときがあります。そのためには `--reload` フラグに引数を渡すことでコントロール出来ます。 28 | 29 | 30 | すべての\$STD_VERSION標準モジュールを再ロード: 31 | 32 | ```ts 33 | deno cache --reload=https://deno.land/std@$STD_VERSION my_module.ts 34 | ``` 35 | 36 | 40 | 特定のモジュール(この例ではcolorsとファイルシステムcopy)を再ロードするにはURLを分けるのにカンマを使ってください。 41 | 42 | ```ts 43 | deno cache --reload=https://deno.land/std@$STD_VERSION/fs/copy.ts,https://deno.land/std@$STD_VERSION/fmt/colors.ts my_module.ts 44 | ``` 45 | 46 | 47 | -------------------------------------------------------------------------------- /docs/runtime.md: -------------------------------------------------------------------------------- 1 | 2 | # ランタイム 3 | 4 | 9 | すべてのランタイムの機能(Web APIs + `Deno` global)のドキュメントは [`doc.deno.land`](https://doc.deno.land/https/github.com/denoland/deno/releases/latest/download/lib.deno.d.ts) にあります。 10 | 11 | ## Web Platform APIs 12 | 13 | 17 | HTTPリクエストの `fetch` などのすでに存在しているwebスタンダードAPIについて、Denoは新しい独自のAPIを作るのではなくこれらを利用しています。 18 | 19 | 23 | 詳細は [Web Platform APIs](./runtime/web_platform_apis.md) チャプターを参照してください。 24 | 25 | 26 | ## `Deno` グローバル 27 | 28 | 33 | Web標準でないすべてのAPIはグローバルである `Deno` 名前空間に含まれています。 34 | これらにはファイルの読み込み、TCPソケットの開放、サブプロセスの実行などのAPIが含まれています。 35 | 36 | 41 | Deno名前空間のTypeScriptの定義は [`lib.deno.ns.d.ts`](https://github.com/denoland/deno/blob/$CLI_VERSION/cli/dts/lib.deno.ns.d.ts) ファイルにあります。 42 | 43 | 47 | Deno特有のAPIのドキュメントは [doc.deno.land](https://doc.deno.land/https/raw.githubusercontent.com/denoland/deno/main/cli/dts/lib.deno.ns.d.ts) にあります。 48 | -------------------------------------------------------------------------------- /docs/runtime/compiler_apis.md: -------------------------------------------------------------------------------- 1 | 2 | ## コンパイラAPI 3 | 4 | 8 | > i このセクションは [TypeScriptランタイムAPI](../typescript/runtime.md) に移動しました。 9 | -------------------------------------------------------------------------------- /docs/runtime/location_api.md: -------------------------------------------------------------------------------- 1 | ## Location API 2 | 3 | Deno supports the 4 | [`location`](https://developer.mozilla.org/en-US/docs/Web/API/Window/location) 5 | global from the web. Please read on. 6 | 7 | ### Location flag 8 | 9 | There is no "web page" whose URL we can use for a location in a Deno process. We 10 | instead allow users to emulate a document location by specifying one on the CLI 11 | using the `--location` flag. It can be a `http` or `https` URL. 12 | 13 | ```ts 14 | // deno run --location https://example.com/path main.ts 15 | 16 | console.log(location.href); 17 | // "https://example.com/path" 18 | ``` 19 | 20 | You must pass `--location ` for this to work. If you don't, any access to 21 | the `location` global will throw an error. 22 | 23 | ```ts 24 | // deno run main.ts 25 | 26 | console.log(location.href); 27 | // error: Uncaught ReferenceError: Access to "location", run again with --location . 28 | ``` 29 | 30 | Setting `location` or any of its fields will normally cause navigation in 31 | browsers. This is not applicable in Deno, so it will throw in this situation. 32 | 33 | ```ts 34 | // deno run --location https://example.com/path main.ts 35 | 36 | location.pathname = "./foo"; 37 | // error: Uncaught NotSupportedError: Cannot set "location.pathname". 38 | ``` 39 | 40 | ### Extended usage 41 | 42 | On the web, resource resolution (excluding modules) typically uses the value of 43 | `location.href` as the root on which to base any relative URLs. This affects 44 | some web APIs adopted by Deno. 45 | 46 | #### Fetch API 47 | 48 | ```ts 49 | // deno run --location https://api.github.com/ --allow-net main.ts 50 | 51 | const response = await fetch("./orgs/denoland"); 52 | // Fetches "https://api.github.com/orgs/denoland". 53 | ``` 54 | 55 | The `fetch()` call above would throw if the `--location` flag was not passed, 56 | since there is no web-analogous location to base it onto. 57 | 58 | #### Worker modules 59 | 60 | ```ts 61 | // deno run --location https://example.com/index.html --allow-net main.ts 62 | 63 | const worker = new Worker("./workers/hello.ts", { type: "module" }); 64 | // Fetches worker module at "https://example.com/workers/hello.ts". 65 | ``` 66 | 67 | ### Only use if necessary 68 | 69 | For the above use cases, it is preferable to pass URLs in full rather than 70 | relying on `--location`. You can manually base a relative URL using the `URL` 71 | constructor if needed. 72 | 73 | The `--location` flag is intended for those who have some specific purpose in 74 | mind for emulating a document location and are aware that this will only work at 75 | application-level. However, you may also use it to silence errors from a 76 | dependency which is frivolously accessing the `location` global. 77 | -------------------------------------------------------------------------------- /docs/runtime/program_lifecycle.md: -------------------------------------------------------------------------------- 1 | 2 | ## プログラムライフサイクル 3 | 4 | 8 | Denoはブラウザ互換のライフサイクルイベントをサポートしています: `load` と `unload`。プログラム中でコードの設定とクリーンアップを提供するためにこれらのイベントを使うことが出来ます。 9 | 10 | 14 | `load` イベントのリスナーは async や await になることが出来ます。`unload` イベントのリスナーは同期的である必要があります。この両方のイベントは中断できません。 15 | 16 | 17 | 例: 18 | 19 | **main.ts** 20 | 21 | ```ts 22 | import "./imported.ts"; 23 | 24 | const handler = (e: Event): void => { 25 | console.log(`got ${e.type} event in event handler (main)`); 26 | }; 27 | 28 | window.addEventListener("load", handler); 29 | 30 | window.addEventListener("unload", handler); 31 | 32 | window.onload = (e: Event): void => { 33 | console.log(`got ${e.type} event in onload function (main)`); 34 | }; 35 | 36 | window.onunload = (e: Event): void => { 37 | console.log(`got ${e.type} event in onunload function (main)`); 38 | }; 39 | 40 | console.log("log from main script"); 41 | ``` 42 | 43 | **imported.ts** 44 | 45 | ```ts 46 | const handler = (e: Event): void => { 47 | console.log(`got ${e.type} event in event handler (imported)`); 48 | }; 49 | 50 | window.addEventListener("load", handler); 51 | window.addEventListener("unload", handler); 52 | 53 | window.onload = (e: Event): void => { 54 | console.log(`got ${e.type} event in onload function (imported)`); 55 | }; 56 | 57 | window.onunload = (e: Event): void => { 58 | console.log(`got ${e.type} event in onunload function (imported)`); 59 | }; 60 | 61 | console.log("log from imported script"); 62 | ``` 63 | 64 | 69 | イベントハンドラーの定義のために `window.addEventListener` と `window.onload`/`window.onunload` の両方を使っていることに注意してください。この2つには重要な違いがあります。例のプログラムを実行してください: 70 | 71 | ```shell 72 | $ deno run main.ts 73 | log from imported script 74 | log from main script 75 | got load event in event handler (imported) 76 | got load event in event handler (main) 77 | got load event in onload function (main) 78 | got unload event in event handler (imported) 79 | got unload event in event handler (main) 80 | got unload event in onunload function (main) 81 | ``` 82 | 83 | 88 | `window.addEventListener` を使って追加されたすべてのリスナーは実行されました。しかし、`main.ts` で定義された `window.onload` と `window.onunload` は `imported.ts` で定義されたハンドラーに上書きされました。 89 | 90 | 96 | 別の言い方では複数の `window.addEventListener` `"load"` もしくは `"unload"` を登録できますが、最後にロードされる `window.onload` や `window.onunload` しか実行されません。このため、可能であれば `addEventListener` を使用したほうが良いです。 97 | -------------------------------------------------------------------------------- /docs/runtime/stability.md: -------------------------------------------------------------------------------- 1 | 2 | ## 安定性 3 | 4 | 8 | Deno 1.0.0以降は、`Deno` 名前空間のAPIは安定版です。つまり、1.0.0のコードが今後のバージョンでも動くように努力しています。 9 | 10 | 15 | しかし、すべてのDenoの機能のすべてがプロダクション段階ではありません。まだ準備段階の機能は `--unstable` コマンドフラグのもとにあります。 16 | 17 | ```shell 18 | deno run --unstable mod_which_uses_unstable_stuff.ts 19 | ``` 20 | 21 | 22 | このフラグは以下のことをします: 23 | 24 | 31 | - 実行中に不安定版のAPIの使用を有効化します。 32 | - [`lib.deno.unstable.d.ts`](https://doc.deno.land/https/raw.githubusercontent.com/denoland/deno/main/cli/dts/lib.deno.unstable.d.ts) 33 | ファイルを型チェックのためのTypeScriptの定義に追加します。これには `deno type` の出力も含まれます。 34 | 35 | 40 | 多くの不安定版のAPIは**セキュリティレビューを受けておらず**、将来的に**APIのは快適な変更**がある可能性があり、**プロダクションでは非推奨**です。 41 | 42 | 43 | ### 標準モジュール 44 | 45 | 52 | Denoの標準モジュール(https://deno.land/std/)はまだ安定版では有りません。現在モジュールのバージョンをCLIとは異なるものにしてこれを反映さしています。`Deno` 名前空間と違って、標準モジュールの使用の際に `--unstable` フラグを必要としません(標準モジュール自身がDenoの不安定番の機能を使用している場合を除く)。 53 | -------------------------------------------------------------------------------- /docs/schemas/module-graph.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "https://deno.land/schemas/module-graph.json", 3 | "$schema": "http://json-schema.org/draft-07/schema", 4 | "description": "A JSON representation of a Deno module dependency graph.", 5 | "required": [ 6 | "root", 7 | "modules", 8 | "size" 9 | ], 10 | "title": "Deno Dependency Graph Schema", 11 | "type": "object", 12 | "properties": { 13 | "root": { 14 | "default": "", 15 | "description": "The root specifier for the graph.", 16 | "examples": [ 17 | "https://deno.land/x/mod.ts" 18 | ], 19 | "type": "string" 20 | }, 21 | "modules": { 22 | "default": [], 23 | "description": "The modules that are part of the graph.", 24 | "type": "array", 25 | "items": { 26 | "$ref": "#/definitions/module" 27 | } 28 | }, 29 | "size": { 30 | "type": "integer", 31 | "description": "The total size of all the unique dependencies in the graph in bytes.", 32 | "default": 0 33 | } 34 | }, 35 | "definitions": { 36 | "module": { 37 | "type": "object", 38 | "required": [ 39 | "specifier" 40 | ], 41 | "properties": { 42 | "specifier": { 43 | "type": "string", 44 | "description": "The fully qualified module specifier (URL) for the module." 45 | }, 46 | "dependencies": { 47 | "type": "array", 48 | "description": "An array of dependencies of the module.", 49 | "items": { 50 | "$ref": "#/definitions/dependency" 51 | } 52 | }, 53 | "size": { 54 | "type": "integer", 55 | "description": "The size of the module on disk in bytes." 56 | }, 57 | "mediaType": { 58 | "type": "string", 59 | "description": "How the file is treated within Deno. All the possible media types that Deno considers are listed here, but in practice, several of them would never appear in a module graph.", 60 | "enum": [ 61 | "JavaScript", 62 | "TypeScript", 63 | "JSX", 64 | "TSX", 65 | "Dts", 66 | "Json", 67 | "Wasm", 68 | "TsBuildInfo", 69 | "SourceMap", 70 | "Unknown" 71 | ] 72 | }, 73 | "local": { 74 | "type": "string", 75 | "description": "The path to the local file. For local modules this will be the local file path, for remote modules and data URLs, this would be the path to the file in the Deno cache." 76 | }, 77 | "checksum": { 78 | "type": "string", 79 | "description": "The checksum of the local source file. This can be used to validate if the current on disk version matches the version described here." 80 | }, 81 | "emit": { 82 | "type": "string", 83 | "description": "The path to an emitted version of the module, if the module requires transpilation to be loaded into the Deno runtime." 84 | }, 85 | "map": { 86 | "type": "string", 87 | "description": "The path to an optionally emitted source map between the original and emitted version of the file." 88 | }, 89 | "error": { 90 | "type": "string", 91 | "description": "If when resolving the module, Deno encountered an error and the module is unavailable, the text of that error will be indicated here." 92 | } 93 | } 94 | }, 95 | "dependency": { 96 | "type": "object", 97 | "required": [ 98 | "specifier" 99 | ], 100 | "properties": { 101 | "specifier": { 102 | "type": "string", 103 | "description": "The specifier provided from within the module." 104 | }, 105 | "code": { 106 | "type": "string", 107 | "description": "The fully qualified module specifier (URL) for the code dependency." 108 | }, 109 | "type": { 110 | "type": "string", 111 | "description": "The fully qualified module specifier (URL) for the type only dependency." 112 | } 113 | } 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /docs/standard_library.md: -------------------------------------------------------------------------------- 1 | 2 | # 標準ライブラリ 3 | 4 | 8 | Denoはコアチームによって監査されDenoで動くことが保証された標準モジュールセットを提供しています。 9 | 10 | 11 | 標準ライブラリはここにあります: https://deno.land/std/ 12 | 13 | 14 | ## バージョニングと安定性 15 | 16 | 22 | 標準ライブラリはまだ安定版でなくそのためDenoのバージョンと違います。最新のリリースは https://deno.land/std/ もしくは https://deno.land/std/version.ts にあります。標準ライブラリはDenoリリースと同時期にリリースされます。 23 | 24 | 30 | 意図しない変更を回避するために標準ライブラリは固定されたバージョンをつねにインポートすることを強くおすすめします。例えば、いつでも変更される可能性があり、コンパイルエラーや予期できない動作を起こす可能性があるデフォルトブランチのコードにリンクするより: 31 | 32 | 38 | ```typescript 39 | // 最新リリースからインポート、これは避けるべきです 40 | import { copy } from "https://deno.land/std/fs/copy.ts"; 41 | ``` 42 | 43 | 47 | それより、変更されないイミュータブルの std ライブラリのバージョンを使ってください: 48 | 49 | 55 | ```typescript 56 | // 変更されない、v$STD_VERSION の std をインポート 57 | import { copy } from "https://deno.land/std@$STD_VERSION/fs/copy.ts"; 58 | ``` 59 | 60 | 61 | ## トラブルシューティング 62 | 63 | 64 | 標準ライブラリで提供されているモジュールの中には不安定なDeno APIを使用しているものがあります。 65 | 66 | 71 | これらのモジュールを `--unstable` フラグなしで実行しようとすると `Deno` 名前空間にあるいくつかのAPIが存在しないことを示唆する多くのTypeScriptはエラーが発生します。 72 | 73 | ```typescript 74 | // main.ts 75 | import { copy } from "https://deno.land/std@$STD_VERSION/fs/copy.ts"; 76 | 77 | copy("log.txt", "log-old.txt"); 78 | ``` 79 | 80 | ```shell 81 | $ deno run --allow-read --allow-write main.ts 82 | Compile file:///dev/deno/main.ts 83 | Download https://deno.land/std@$STD_VERSION/fs/copy.ts 84 | Download https://deno.land/std@$STD_VERSION/fs/ensure_dir.ts 85 | Download https://deno.land/std@$STD_VERSION/fs/_util.ts 86 | error: TS2339 [ERROR]: Property 'utime' does not exist on type 'typeof Deno'. 'Deno.utime' is an unstable API. Did you forget to run with the '--unstable' flag? 87 | await Deno.utime(dest, statInfo.atime, statInfo.mtime); 88 | ~~~~~ 89 | at https://deno.land/std@$STD_VERSION/fs/copy.ts:92:16 90 | 91 | TS2339 [ERROR]: Property 'utimeSync' does not exist on type 'typeof Deno'. 'Deno.utimeSync' is an unstable API. Did you forget to run with the '--unstable' flag? 92 | Deno.utimeSync(dest, statInfo.atime, statInfo.mtime); 93 | ~~~~~~~~~ 94 | at https://deno.land/std@$STD_VERSION/fs/copy.ts:103:10 95 | ``` 96 | 97 | 98 | これらのプログラムへの解決策は `--unstable` フラグを利用することです: 99 | 100 | ```shell 101 | deno run --allow-read --allow-write --unstable main.ts 102 | ``` 103 | 104 | 109 | APIが不安定なエラーを生成していることを確認するには [`lib.deno.unstable.d.ts`](https://github.com/denoland/deno/blob/$CLI_VERSION/cli/dts/lib.deno.unstable.d.ts) を確認してください。 110 | 111 | 115 | この問題は近いうちに解決されるはずです。依存している特定のモジュールがこのフラグなしで正常にコンパイルされている場合は、このフラグを省略しても構いません。 116 | -------------------------------------------------------------------------------- /docs/toc.ja.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "name": "イントロダクション" 4 | }, 5 | "getting_started": { 6 | "name": "Getting Started", 7 | "children": { 8 | "installation": "インストール", 9 | "setup_your_environment": "環境構築", 10 | "first_steps": "最初の一歩", 11 | "command_line_interface": "コマンドラインインターフェース", 12 | "permissions": "パーミッション", 13 | "webassembly": "WebAssemblyの使用", 14 | "debugging_your_code": "コードのデバッグ" 15 | } 16 | }, 17 | "runtime": { 18 | "name": "ランタイム", 19 | "children": { 20 | "stability": "安定性", 21 | "program_lifecycle": "プログラムライフサイクル", 22 | "permission_apis": "パーミッションAPI", 23 | "web_platform_apis": "Web プラットフォーム APIs", 24 | "location_apis": "ロケーションAPI", 25 | "workers": "ワーカー" 26 | } 27 | }, 28 | "linking_to_external_code": { 29 | "name": "外部のコードとのリンク", 30 | "children": { 31 | "reloading_modules": "モジュールの再ロード", 32 | "integrity_checking": "整合性チェック", 33 | "proxies": "プロキシ", 34 | "private": "プライベートモジュール", 35 | "import_maps": "Import maps" 36 | } 37 | }, 38 | "typescript": { 39 | "name": "Using TypeScript", 40 | "children": { 41 | "overview": "概要", 42 | "configuration": "Configuration", 43 | "types": "型と型宣言", 44 | "migration": "JavaScriptとのマイグレート", 45 | "runtime": "ランタイムコンパイラAPI", 46 | "faqs": "よくある質問" 47 | } 48 | }, 49 | "standard_library": { 50 | "name": "標準ライブラリ" 51 | }, 52 | "testing": { 53 | "name": "テスト", 54 | "children": { 55 | "assertions": "アサーション" 56 | } 57 | }, 58 | "examples": { 59 | "name": "サンプル", 60 | "children": { 61 | "hello_world": "Hello World", 62 | "import_export": "モジュールのインポートとエクスポート", 63 | "manage_dependencies": "依存関係管理", 64 | "fetch_data": "データの取得", 65 | "read_write_files": "ファイルの読み書き", 66 | "unix_cat": "Unix cat プログラム", 67 | "http_server": "HTTP web server", 68 | "file_server": "ファイルサーバー", 69 | "tcp_echo": "TCP echo サーバー", 70 | "subprocess": "サブプロセスの作成", 71 | "os_signals": "OS シグナル", 72 | "file_system_events": "ファイルシステムイベント", 73 | "module_metadata": "Module metadata" 74 | } 75 | }, 76 | "tools": { 77 | "name": "ツール", 78 | "children": { 79 | "script_installer": "スクリプトインストーラー", 80 | "formatter": "フォーマッター", 81 | "repl": "Read-eval-print-loop", 82 | "bundler": "バンドラー", 83 | "compiler": "実行可能ファイルのコンパイル", 84 | "documentation_generator": "ドキュメンテーションジェネレータ", 85 | "dependency_inspector": "依存関係インスペクター", 86 | "linter": "リンター" 87 | } 88 | }, 89 | "embedding_deno": { 90 | "name": "Denoの埋め込み" 91 | }, 92 | "help": { 93 | "name": "ヘルプ" 94 | }, 95 | "contributing": { 96 | "name": "コントリビューティング", 97 | "children": { 98 | "building_from_source": "ソースからのビルド", 99 | "development_tools": "開発ツール", 100 | "web_platform_tests": "Web プロットフォームテスト", 101 | "style_guide": "スタイルガイド", 102 | "architecture": "アーキテクチャ", 103 | "release_schedule": "リリーススケジュール" 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /docs/toc.json: -------------------------------------------------------------------------------- 1 | { 2 | "introduction": { 3 | "name": "Introduction" 4 | }, 5 | "getting_started": { 6 | "name": "Getting Started", 7 | "children": { 8 | "installation": "Installation", 9 | "setup_your_environment": "Setup your environment", 10 | "first_steps": "First steps", 11 | "command_line_interface": "Command line interface", 12 | "permissions": "Permissions", 13 | "webassembly": "Using WebAssembly", 14 | "debugging_your_code": "Debugging your code" 15 | } 16 | }, 17 | "runtime": { 18 | "name": "The Runtime", 19 | "children": { 20 | "stability": "Stability", 21 | "program_lifecycle": "Program lifecycle", 22 | "permission_apis": "Permission APIs", 23 | "web_platform_apis": "Web Platform APIs", 24 | "location_api": "Location APIs", 25 | "workers": "Workers" 26 | } 27 | }, 28 | "linking_to_external_code": { 29 | "name": "Linking to external code", 30 | "children": { 31 | "reloading_modules": "Reloading modules", 32 | "integrity_checking": "Integrity checking", 33 | "proxies": "Proxies", 34 | "private": "Private modules", 35 | "import_maps": "Import maps" 36 | } 37 | }, 38 | "typescript": { 39 | "name": "Using TypeScript", 40 | "children": { 41 | "overview": "Overview", 42 | "configuration": "Configuration", 43 | "types": "Types and type declarations", 44 | "migration": "Migrating to/from JavaScript", 45 | "runtime": "Runtime compiler APIs", 46 | "faqs": "Frequently asked questions" 47 | } 48 | }, 49 | "standard_library": { 50 | "name": "Standard library" 51 | }, 52 | "examples": { 53 | "name": "Examples", 54 | "children": { 55 | "hello_world": "Hello world", 56 | "import_export": "Import and export modules", 57 | "manage_dependencies": "Manage dependencies", 58 | "fetch_data": "Fetch data", 59 | "read_write_files": "Read and write files", 60 | "unix_cat": "Unix cat program", 61 | "http_server": "HTTP web server", 62 | "file_server": "File server", 63 | "tcp_echo": "TCP echo server", 64 | "subprocess": "Creating a subprocess", 65 | "os_signals": "OS signals", 66 | "file_system_events": "File system events", 67 | "module_metadata": "Module metadata" 68 | } 69 | }, 70 | "testing": { 71 | "name": "Testing", 72 | "children": { 73 | "assertions": "Assertions" 74 | } 75 | }, 76 | "tools": { 77 | "name": "Tools", 78 | "children": { 79 | "script_installer": "Script installer", 80 | "formatter": "Formatter", 81 | "repl": "Read-eval-print-loop", 82 | "bundler": "Bundler", 83 | "compiler": "Compiling executables", 84 | "documentation_generator": "Documentation generator", 85 | "dependency_inspector": "Dependency inspector", 86 | "linter": "Linter" 87 | } 88 | }, 89 | "embedding_deno": { 90 | "name": "Embedding Deno" 91 | }, 92 | "help": { 93 | "name": "Help" 94 | 95 | }, 96 | "contributing": { 97 | "name": "Contributing", 98 | "children": { 99 | "building_from_source": "Building from source", 100 | "development_tools": "Development tools", 101 | "web_platform_tests": "Web platform tests", 102 | "style_guide": "Style guide", 103 | "architecture": "Architecture", 104 | "release_schedule": "Release schedule" 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /docs/tools.md: -------------------------------------------------------------------------------- 1 | 2 | # ビルトインツール 3 | 4 | 8 | DenoはJavaScriptとTypeScriptを使うときに便利なビルトインツールを提供します: 9 | 10 | 21 | - [バンドラー (`deno bundle`)](./tools/bundler.md) 22 | - [実行可能ファイルのコンパイル (`deno compile`)](./tools/compiler.md) 23 | - [インストーラー (`deno install`)](./tools/script_installer.md) 24 | - [デバッガー (`--inspect、--inspect-brk`)](./tools/debugger.md) 25 | - [依存インスペクター (`deno info`)](./tools/dependency_inspector.md) 26 | - [ドキュメンテーションジェネレーター (`deno doc`)](./tools/documentation_generator.md) 27 | - [フォーマッター (`deno fmt`)](./tools/formatter.md) 28 | - [repl (`deno repl`)](./tools/repl.md) 29 | - [テストランナー (`deno test`)](./testing.md) 30 | - [リンター (`deno lint`)](./tools/linter.md) 31 | -------------------------------------------------------------------------------- /docs/tools/bundler.md: -------------------------------------------------------------------------------- 1 | 2 | ## バンドル 3 | 4 | 8 | `deno bundle [URL]` は入力で指定されたすべての依存関係を含んだ一つのJavaScriptファイルを出力します。 9 | 10 | ``` 11 | > deno bundle https://deno.land/std@$STD_VERSION/examples/colors.ts colors.bundle.js 12 | Bundle https://deno.land/std@$STD_VERSION/examples/colors.ts 13 | Download https://deno.land/std@$STD_VERSION/examples/colors.ts 14 | Download https://deno.land/std@$STD_VERSION/fmt/colors.ts 15 | Emit "colors.bundle.js" (9.83KB) 16 | ``` 17 | 18 | 19 | 出力ファイルを省略した場合は `stdout` に送られます。 20 | 21 | 22 | バンドルはDenoワールドの他のモジュールと同じように実行することが出来ます。 23 | 24 | ``` 25 | deno run colors.bundle.js 26 | ``` 27 | 28 | 33 | 出力ファイルはESモジュールを自身で含んでいて、コマンドラインで共有されたメインモジュールからのエクスポートが利用可能です。例えば、もしメインモジュールが次のようであれば: 34 | 35 | ```ts 36 | export { foo } from "./foo.js"; 37 | 38 | export const bar = "bar"; 39 | ``` 40 | 41 | 42 | 次のようにインポートされます: 43 | 44 | ```ts 45 | import { bar, foo } from "./lib.bundle.js"; 46 | ``` 47 | 48 | 52 | バンドルはブラウザでもロードできます。バンドルは self-contained ESモジュールで、`type` 属性は `"module"` にセットされるべきです。例えば: 53 | 54 | ```html 55 | 56 | ``` 57 | 58 | 59 | もしくは別のESモジュールにインポートすることが出来ます: 60 | 61 | ```html 62 | 65 | ``` 66 | -------------------------------------------------------------------------------- /docs/tools/compiler.md: -------------------------------------------------------------------------------- 1 | 2 | ## 実行可能ファイルのコンパイル 3 | 4 | 8 | コンパイル機能は比較的新しいので、コマンドを動作させるには `--unstable` フラッグをセットしてください。 9 | 10 | 14 | `deno compile [--output ] ` はスクリプトを自己完結型の実行可能ファイルにコンパイルします。 15 | 16 | ``` 17 | > deno compile --unstable https://deno.land/std/examples/welcome.ts 18 | ``` 19 | 20 | 24 | `OUT` パラメーターを省略すると、実行ファイルの名前は推測されます。 25 | 26 | 27 | ### フラグ 28 | 29 | 34 | [`deno install`](./script_installer.md) と同様にスクリプトの実行に使用するランタイムフラフはコンパイル時に指定しなければいけません。これにはパーミッションフラグも含まれます。 35 | 36 | ``` 37 | > deno compile --unstable --allow-read --allow-net https://deno.land/std/http/file_server.ts 38 | ``` 39 | 40 | 44 | [スクリプト引数](../getting_started/command_line_interface.md#script-arguments) は部分的に埋め込むことができます。 45 | 46 | ``` 47 | > deno compile --unstable --allow-read --allow-net https://deno.land/std/http/file_server.ts -p 8080 48 | > ./file_server --help 49 | ``` 50 | 51 | 52 | ### クロスコンパイル 53 | 54 | 60 | CLI 引数に `--target` を追加することでクロスコンパイルできます。これの利点は、一つの CI マシンで他のプラットフォームへのバイナリを生成できることです。Deno は現在 Windows x64、macOS ARM そして Linux x64 へのコンパイルをサポートします。コンパイルターゲットに関する完全なリストを得るには `deno compile --help` を使ってください。 61 | 62 | 63 | ### より小さいバイナリの生成 64 | 65 | 69 | 引数に `--lite` が渡されると、`deno compile` は小さくしたランタイムのバイナリを使用します。 70 | -------------------------------------------------------------------------------- /docs/tools/dependency_inspector.md: -------------------------------------------------------------------------------- 1 | 2 | ## 依存インスペクター 3 | 4 | 5 | `deno info [URL]` はESモジュールとその依存関係を調査します。 6 | 7 | ```shell 8 | deno info https://deno.land/std@0.67.0/http/file_server.ts 9 | Download https://deno.land/std@0.67.0/http/file_server.ts 10 | ... 11 | local: /home/deno/.cache/deno/deps/https/deno.land/f57792e36f2dbf28b14a75e2372a479c6392780d4712d76698d5031f943c0020 12 | type: TypeScript 13 | compiled: /home/deno/.cache/deno/gen/https/deno.land/f57792e36f2dbf28b14a75e2372a479c6392780d4712d76698d5031f943c0020.js 14 | deps: 23 unique (total 139.89KB) 15 | https://deno.land/std@0.67.0/http/file_server.ts (10.49KB) 16 | ├─┬ https://deno.land/std@0.67.0/path/mod.ts (717B) 17 | │ ├── https://deno.land/std@0.67.0/path/_constants.ts (2.35KB) 18 | │ ├─┬ https://deno.land/std@0.67.0/path/win32.ts (27.36KB) 19 | │ │ ├── https://deno.land/std@0.67.0/path/_interface.ts (657B) 20 | │ │ ├── https://deno.land/std@0.67.0/path/_constants.ts * 21 | │ │ ├─┬ https://deno.land/std@0.67.0/path/_util.ts (3.3KB) 22 | │ │ │ ├── https://deno.land/std@0.67.0/path/_interface.ts * 23 | │ │ │ └── https://deno.land/std@0.67.0/path/_constants.ts * 24 | │ │ └── https://deno.land/std@0.67.0/_util/assert.ts (405B) 25 | │ ├─┬ https://deno.land/std@0.67.0/path/posix.ts (12.67KB) 26 | │ │ ├── https://deno.land/std@0.67.0/path/_interface.ts * 27 | │ │ ├── https://deno.land/std@0.67.0/path/_constants.ts * 28 | │ │ └── https://deno.land/std@0.67.0/path/_util.ts * 29 | │ ├─┬ https://deno.land/std@0.67.0/path/common.ts (1.14KB) 30 | │ │ └─┬ https://deno.land/std@0.67.0/path/separator.ts (264B) 31 | │ │ └── https://deno.land/std@0.67.0/path/_constants.ts * 32 | │ ├── https://deno.land/std@0.67.0/path/separator.ts * 33 | │ ├── https://deno.land/std@0.67.0/path/_interface.ts * 34 | │ └─┬ https://deno.land/std@0.67.0/path/glob.ts (8.12KB) 35 | │ ├── https://deno.land/std@0.67.0/path/_constants.ts * 36 | │ ├── https://deno.land/std@0.67.0/path/mod.ts * 37 | │ └── https://deno.land/std@0.67.0/path/separator.ts * 38 | ├─┬ https://deno.land/std@0.67.0/http/server.ts (10.23KB) 39 | │ ├── https://deno.land/std@0.67.0/encoding/utf8.ts (433B) 40 | │ ├─┬ https://deno.land/std@0.67.0/io/bufio.ts (21.15KB) 41 | │ │ ├── https://deno.land/std@0.67.0/bytes/mod.ts (4.34KB) 42 | │ │ └── https://deno.land/std@0.67.0/_util/assert.ts * 43 | │ ├── https://deno.land/std@0.67.0/_util/assert.ts * 44 | │ ├─┬ https://deno.land/std@0.67.0/async/mod.ts (202B) 45 | │ │ ├── https://deno.land/std@0.67.0/async/deferred.ts (1.03KB) 46 | │ │ ├── https://deno.land/std@0.67.0/async/delay.ts (279B) 47 | │ │ ├─┬ https://deno.land/std@0.67.0/async/mux_async_iterator.ts (1.98KB) 48 | │ │ │ └── https://deno.land/std@0.67.0/async/deferred.ts * 49 | │ │ └── https://deno.land/std@0.67.0/async/pool.ts (1.58KB) 50 | │ └─┬ https://deno.land/std@0.67.0/http/_io.ts (11.25KB) 51 | │ ├── https://deno.land/std@0.67.0/io/bufio.ts * 52 | │ ├─┬ https://deno.land/std@0.67.0/textproto/mod.ts (4.52KB) 53 | │ │ ├── https://deno.land/std@0.67.0/io/bufio.ts * 54 | │ │ ├── https://deno.land/std@0.67.0/bytes/mod.ts * 55 | │ │ └── https://deno.land/std@0.67.0/encoding/utf8.ts * 56 | │ ├── https://deno.land/std@0.67.0/_util/assert.ts * 57 | │ ├── https://deno.land/std@0.67.0/encoding/utf8.ts * 58 | │ ├── https://deno.land/std@0.67.0/http/server.ts * 59 | │ └── https://deno.land/std@0.67.0/http/http_status.ts (5.93KB) 60 | ├─┬ https://deno.land/std@0.67.0/flags/mod.ts (9.54KB) 61 | │ └── https://deno.land/std@0.67.0/_util/assert.ts * 62 | └── https://deno.land/std@0.67.0/_util/assert.ts * 63 | ``` 64 | 65 | 66 | 依存インスペクターはローカルのESモジュールでもリモートのESモジュールでも動きます。 67 | 68 | 69 | ## キャッシュ場所 70 | 71 | 72 | `deno info` はキャッシュ場所の情報を表示するのに使われます: 73 | 74 | ```shell 75 | deno info 76 | DENO_DIR location: "/Users/deno/Library/Caches/deno" 77 | Remote modules cache: "/Users/deno/Library/Caches/deno/deps" 78 | TypeScript compiler cache: "/Users/deno/Library/Caches/deno/gen" 79 | ``` 80 | -------------------------------------------------------------------------------- /docs/tools/documentation_generator.md: -------------------------------------------------------------------------------- 1 | 2 | ## ドキュメンテーションジェネレーター 3 | 4 | 8 | `deno doc` のあとに1つ以上のソースファイルのリストをつけると、モジュールの**エクスポート**メンバーそれぞれのJSDocドキュメントが表示されます。 9 | 10 | 11 | 例えば、以下の内容の `add.ts` が与えられたとき: 12 | 13 | 26 | ```ts 27 | /** 28 | * Adds x and y. 29 | * @param {number} x 30 | * @param {number} y 31 | * @returns {number} x と y の加算 32 | */ 33 | export function add(x: number, y: number): number { 34 | return x + y; 35 | } 36 | ``` 37 | 38 | 39 | Denoの `doc` コマンドを実行すると関数のJSDocコメントが `stdout` に表示されます: 40 | 41 | ```shell 42 | deno doc add.ts 43 | function add(x: number, y: number): number 44 | Adds x and y. @param {number} x @param {number} y @returns {number} Sum of x and y 45 | ``` 46 | 47 | 53 | JSONフォーマットでドキュメントを出力するには `--json` フラグを使ってください。JSONフォーマットは [deno doc website](https://github.com/denoland/doc_website) で利用されモジュールドキュメントを生成するときに使われます。 54 | -------------------------------------------------------------------------------- /docs/tools/formatter.md: -------------------------------------------------------------------------------- 1 | 2 | ## コードフォーマッター 3 | 4 | 8 | DenoはTypeScriptとJavaScriptのコードを自動でフォーマットするコードフォーマッターをビルトインで備えています。 9 | 10 | 22 | ```shell 23 | # 現在のディレクトリとサブディレクトリのすべてのJS/TSファイルをフォーマット 24 | deno fmt 25 | # 特定のファイルをフォーマット 26 | deno fmt myfile1.ts myfile2.ts 27 | # 現在のディレクトリとサブディレクトリのすべてのJS/TSファイルがフォーマットされているかチェック 28 | deno fmt --check 29 | # 標準入力をフォーマットし標準出力に書き込む 30 | cat file.ts | deno fmt - 31 | ``` 32 | 33 | 34 | `// deno-fmt-ignore` コメントをつけることでコードのフォーマットを無視することが出来ます: 35 | 36 | ```ts 37 | // deno-fmt-ignore 38 | export const identity = [ 39 | 1, 0, 0, 40 | 0, 1, 0, 41 | 0, 0, 1, 42 | ]; 43 | ``` 44 | 45 | 49 | `// deno-fmt-ignore-file` コメントをファイルの最初につけることでファイルすべてを無視します。 50 | -------------------------------------------------------------------------------- /docs/tools/linter.md: -------------------------------------------------------------------------------- 1 | 2 | ## リンター 3 | 4 | 5 | DenoはTypeScriptとJavaScriptのコードリンターをビルトインで備えています。 6 | 7 | 11 | **注意: リンターはまだ不安定版なので `--unstable` が必要です** 12 | 13 | 25 | ```shell 26 | # 現在のディレクトリとサブディレクトリのすべてのJS/TSファイルをリント 27 | deno lint --unstable 28 | # 特定のファイルをリント 29 | deno lint --unstable myfile1.ts myfile2.ts 30 | # JSONで結果を表示 31 | deno lint --unstable --json 32 | # 標準入力から読み込み 33 | cat file.ts | deno lint --unstable - 34 | ``` 35 | 36 | 37 | 詳細は、`deno lint --help` を実行してください。 38 | 39 | 40 | ### 利用可能なルール 41 | 42 | - `adjacent-overload-signatures` 43 | - `ban-ts-comment` 44 | - `ban-types` 45 | - `ban-untagged-ignore` 46 | - `camelcase` 47 | - `constructor-super` 48 | - `for-direction` 49 | - `getter-return` 50 | - `no-array-constructor` 51 | - `no-async-promise-executor` 52 | - `no-case-declarations` 53 | - `no-class-assign` 54 | - `no-compare-neg-zero` 55 | - `no-cond-assign` 56 | - `no-constant-condition` 57 | - `no-control-regex` 58 | - `no-debugger` 59 | - `no-delete-var` 60 | - `no-dupe-args` 61 | - `no-dupe-class-members` 62 | - `no-dupe-else-if` 63 | - `no-dupe-keys` 64 | - `no-duplicate-case` 65 | - `no-empty` 66 | - `no-empty-character-class` 67 | - `no-empty-interface` 68 | - `no-empty-pattern` 69 | - `no-ex-assign` 70 | - `no-explicit-any` 71 | - `no-extra-boolean-cast` 72 | - `no-extra-non-null-assertion` 73 | - `no-extra-semi` 74 | - `no-fallthrough` 75 | - `no-func-assign` 76 | - `no-global-assign` 77 | - `no-import-assign` 78 | - `no-inferrable-types` 79 | - `no-inner-declarations` 80 | - `no-invalid-regexp` 81 | - `no-irregular-whitespace` 82 | - `no-misused-new` 83 | - `no-mixed-spaces-and-tabs` 84 | - `no-namespace` 85 | - `no-new-symbol` 86 | - `no-obj-calls` 87 | - `no-octal` 88 | - `no-prototype-builtins` 89 | - `no-redeclare` 90 | - `no-regex-spaces` 91 | - `no-self-assign` 92 | - `no-setter-return` 93 | - `no-shadow-restricted-names` 94 | - `no-this-alias` 95 | - `no-this-before-super` 96 | - `no-undef` 97 | - `no-unreachable` 98 | - `no-unsafe-finally` 99 | - `no-unsafe-negation` 100 | - `no-unused-labels` 101 | - `no-with` 102 | - `prefer-as-const` 103 | - `prefer-const` 104 | - `prefer-namespace-keyword` 105 | - `require-await` 106 | - `require-yield` 107 | - `use-isnan` 108 | - `valid-typeof` 109 | 110 | 114 | それぞれのルールの細かい点は、[the deno_lint rule documentation](https://lint.deno.land) を参照してください。 115 | 116 | ### Ignore directives 117 | 118 | 119 | #### ファイル 120 | 121 | 125 | ファイルをすべて無視するには `// deno-lint-ignore-file` ディレクティブをファイルの一番初めに置いてください: 126 | 127 | ```ts 128 | // deno-lint-ignore-file 129 | 130 | function foo(): any { 131 | // ... 132 | } 133 | ``` 134 | 135 | 136 | Ignore directiveは文や宣言の前に置く必要があります: 137 | 138 | 155 | ```ts 156 | // Copyright 2020 the Deno authors. All rights reserved. MIT license. 157 | 158 | /** 159 | * なにかJSDoc 160 | **/ 161 | 162 | // deno-lint-ignore-file 163 | 164 | import { bar } from "./bar.js"; 165 | 166 | function foo(): any { 167 | // ... 168 | } 169 | ``` 170 | 171 | 174 | また、ファイル全体の特定の診断を無視することもできます 175 | 176 | ```ts 177 | // deno-lint-ignore-file no-explicit-any no-empty 178 | 179 | function foo(): any { 180 | // ... 181 | } 182 | ``` 183 | 184 | 185 | #### 診断 186 | 187 | 191 | 特定の診断を無視するには `// deno-lint-ignore ` ディレクティブを違反行の前においてください。無視するルールを指定する必要があります: 192 | 193 | ```ts 194 | // deno-lint-ignore no-explicit-any 195 | function foo(): any { 196 | // ... 197 | } 198 | 199 | // deno-lint-ignore no-explicit-any explicit-function-return-type 200 | function bar(a: any) { 201 | // ... 202 | } 203 | ``` 204 | -------------------------------------------------------------------------------- /docs/tools/script_installer.md: -------------------------------------------------------------------------------- 1 | 2 | ## スクリプトインストーラー 3 | 4 | 5 | Denoは `deno install` で配布されている実行コードを簡単にインストールすることができます。 6 | 7 | 11 | `deno install [OPTIONS...] [URL] [SCRIPT_ARGS...]` で、`EXE_NAME` の下の `URL` にある利用可能なスクリプトをインストールできます。 12 | 13 | 18 | このコマンドは、指定されたCLIフラッグとメインモジュールを使った `deno` を呼び出す薄い実行可能シェルスクリプトを作ります。それはインストールルートの `bin` ディレクトリの中に置かれます。 19 | 20 | 21 | 例: 22 | 23 | ```shell 24 | $ deno install --allow-net --allow-read https://deno.land/std@$STD_VERSION/http/file_server.ts 25 | [1/1] Compiling https://deno.land/std@$STD_VERSION/http/file_server.ts 26 | 27 | ✅ Successfully installed file_server. 28 | /Users/deno/.deno/bin/file_server 29 | ``` 30 | 31 | 34 | 実行可能ファイル名を変えるためには、`-n`/`--name` を使ってください: 35 | 36 | ```shell 37 | deno install --allow-net --allow-read -n serve https://deno.land/std@$STD_VERSION/http/file_server.ts 38 | ``` 39 | 40 | 43 | 実行可能ファイル名はデフォルトによって推測されます: 44 | 45 | 53 | - URLパスのファイルステムを取得しようとしました。上記の例では'file_server'となります。 54 | - もしファイルステムが'main'、'mod'、'index'、'cli'のようなジェネリックで親のないパスであった場合、親のパスのファイルネームを取得します。そうでなければ、ジェネリック名を用います。 55 | - 結果の名前に'@...'接尾辞がある場合、取り除いてください 56 | 57 | 60 | インストールルートを変えるには `--root` を使います。 61 | 62 | ```shell 63 | deno install --allow-net --allow-read --root /usr/local https://deno.land/std@$STD_VERSION/http/file_server.ts 64 | ``` 65 | 66 | 69 | 優先順位の順に、インストールルートは決定されます: 70 | 71 | - `--root` option 72 | - `DENO_INSTALL_ROOT` environment variable 73 | - `$HOME/.deno` 74 | 75 | 78 | これらは必要に応じて手動でパスを加える必要があります。 79 | 80 | ```shell 81 | echo 'export PATH="$HOME/.deno/bin:$PATH"' >> ~/.bashrc 82 | ``` 83 | 84 | 88 | インストール時にスクリプトを実行するためのパーミッションを指定しなければいけません。 89 | 90 | ```shell 91 | deno install --allow-net --allow-read https://deno.land/std@$STD_VERSION/http/file_server.ts -p 8080 92 | ``` 93 | 94 | 98 | 上記のコマンドは、ネットワークと読み取りパーミッションを設定し8080番のポートにバインドする `file_server` と呼ばれる実行可能ファイルを作っています。 99 | 100 | 104 | 練習のために、実行可能スクリプトファイルの中のエントリーポイントを特定する [`import.meta.main`](../examples/module_metadata.md) イディオムを使ってみましょう。 105 | 106 | 107 | 例: 108 | 109 | 110 | 111 | 123 | ```ts 124 | // https://example.com/awesome/cli.ts 125 | async function myAwesomeCli(): Promise { 126 | -- 省略 -- 127 | } 128 | 129 | if (import.meta.main) { 130 | myAwesomeCli(); 131 | } 132 | ``` 133 | 134 | 138 | 実行可能スクリプトファイルを作る時は、必ずあなたのリポジトリにインストールコマンドの例を追加して、ユーザに知らせましょう: 139 | 140 | ```shell 141 | # Install using deno install 142 | 143 | $ deno install -n awesome_cli https://example.com/awesome/cli.ts 144 | ``` 145 | -------------------------------------------------------------------------------- /docs/tools/typescript.md: -------------------------------------------------------------------------------- 1 | # Using TypeScript 2 | 3 | In this chapter we will discuss: 4 | 5 | - [Overview of TypeScript in Deno](./typescript/overview.md) 6 | - [Configuring TypeScript in Deno](./typescript/configuration.md) 7 | - [Types and Type Declarations](./typescript/types.md) 8 | - [Migrating to/from JavaScript](./typescript/migration.md) 9 | - [Runtime compiler APIs](./typescript/runtime.md) 10 | - [FAQs about TypeScript in Deno](./typescript/faqs.md) -------------------------------------------------------------------------------- /docs/typescript/migration.md: -------------------------------------------------------------------------------- 1 | 2 | ## JavaScript への移行と JavaScript からの移行 3 | 4 | 10 | Deno の有利な点の一つは TypeScript と JavaScript をほぼ同等に扱うことです。これはJavaScript から TypeScript への移行や TypeScript から JavaScript への移行を達成したいということを意味するかもしれません。Deno にはこれらのためのいくつかの機能があります。 11 | 12 | 13 | ### JavaScript の型チェック 14 | 15 | 20 | 型を持っていたいがすべての場所に型をつけることをしたくない JavaScript があるかもしれません。 21 | 22 | 26 | Deno TypeScript 型チェッカーに JavaScript を型チェックさせることをサポートします。ファイルに JavaScript プログマを追加することで、個々のファイルにマークすることができます: 27 | 28 | ```js 29 | // @ts-check 30 | ``` 31 | 32 | 36 | これにより型チェッカーは JavaScript コードの型情報を推定し、診断での問題をあげます。 37 | 38 | 42 | これらは check JS オプションが有効にされた設定ファイルを提供することでプログラム内のすべての JavaScript ファイルに対して有効にすることができます。 43 | 44 | ```json 45 | { 46 | "compilerOptions": { 47 | "checkJs": true 48 | } 49 | } 50 | ``` 51 | 52 | 53 | そして、`--config` オプションをコマンドラインでセットしてください。 54 | 55 | 56 | ### JavaScript での JSDoc の利用 57 | 58 | 67 | JavaScript を型チェックしてたり、JavaScript を TypeScript にインポートしているとき、JavaScript 内で JSDoc を使うことで、コードから推測される型情報より多くの型情報を表現することができます。Deno は追加の設定無しで、これをサポートし、[TypeScript JSDoc](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html) でサポートされるアノテーションを追加するだけでいいです: 68 | 69 | ```js 70 | /** @type {string[]} */ 71 | const a = []; 72 | ``` 73 | 74 | 75 | ### 型チェックのスキップ 76 | 77 | 82 | 構文は有効だけど完全に型安全ではない実験中の TypeScript コードがあるかもしれません。`--no-check` を渡すことでいつでもプログラム全てを型チェックをバイパスすることができます。 83 | 84 | 88 | また、check JS を有効にしている場合には、チェックなしのプラグマを使用することで、JavaScript を含め、型チェックされているファイル全体をスキップすることもできます: 89 | 90 | ```js 91 | // @ts-nocheck 92 | ``` 93 | 94 | 95 | ### JS ファイルを TS ファイルにリネーム 96 | 97 | 104 | うまく行くケースもあるかもしれませんが、Deno では厳しい成約があります。Deno はデフォルトで _strict mode_ と呼ばれる型チェックを実行しますからです。これは non-strict mode では起こらなかった多くの不明瞭な状況や曖昧な状況での診断が生成されます。JavaScript は型に関しては不明瞭で曖昧なものばかりです。 -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 the Deno authors. All rights reserved. MIT license. */ 2 | 3 | module.exports = { 4 | roots: ["/util"], 5 | testMatch: [ 6 | "**/__tests__/**/*.+(ts|tsx|js)", 7 | "**/?(*.)+(spec|test).+(ts|tsx|js)", 8 | ], 9 | transform: { 10 | "^.+\\.(ts|tsx)$": "ts-jest", 11 | }, 12 | testTimeout: 10000, 13 | }; 14 | -------------------------------------------------------------------------------- /next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | const withPreact = require("next-plugin-preact"); 2 | 3 | module.exports = withPreact({ 4 | experimental: { 5 | modern: true, 6 | polyfillsOptimization: true, 7 | }, 8 | redirects() { 9 | return [ 10 | { 11 | source: "/manual.html", 12 | destination: "/manual", 13 | permanent: true, 14 | }, 15 | { 16 | source: "/benchmarks.html", 17 | destination: "/benchmarks", 18 | permanent: true, 19 | }, 20 | { 21 | source: "/posts", 22 | destination: "https://deno.com/blog", 23 | permanent: true, 24 | }, 25 | { 26 | source: "/posts/:id", 27 | destination: "https://deno.com/blog/:id", 28 | permanent: true, 29 | }, 30 | ]; 31 | }, 32 | }); 33 | -------------------------------------------------------------------------------- /now.json: -------------------------------------------------------------------------------- 1 | { 2 | "trailingSlash": false, 3 | "github": { 4 | "silent": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "deno_website2_japanese", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "publish_prod": "wrangler publish --env=production", 7 | "publish_staging": "wrangler publish --env=staging", 8 | "dev": "next dev", 9 | "build": "next build", 10 | "start": "next start", 11 | "test": "jest", 12 | "format": "yarn format:check --write", 13 | "format:check": "prettier --check \"**/*.md\" \"*.js\" \"*.json\" \"{util,public,pages,components}/**/*.{js,ts,jsx,tsx}\" \"{util,public,pages,components}/*.{js,ts,jsx,tsx}\"", 14 | "lint": "eslint --ext .js,.jsx,.ts,.tsx util/ pages/ components/" 15 | }, 16 | "dependencies": { 17 | "@docsearch/react": "^1.0.0-alpha.14", 18 | "@tailwindcss/ui": "^0.7.2", 19 | "apexcharts": "^3.25.0", 20 | "dompurify": "^2.2.6", 21 | "marked": "^2.0.1", 22 | "next": "^10.0.7", 23 | "next-plugin-preact": "^3.0.3", 24 | "preact": "^10.5.12", 25 | "preact-render-to-string": "^5.1.12", 26 | "prism-react-renderer": "^1.2.0", 27 | "prismjs": "^1.23.0", 28 | "react": "npm:@preact/compat", 29 | "react-apexcharts": "^1.3.7", 30 | "react-dom": "npm:@preact/compat", 31 | "react-ssr-prepass": "npm:preact-ssr-prepass", 32 | "react-transition-group": "^4.4.1", 33 | "swr": "^0.4.2", 34 | "tailwindcss": "^1.9.6", 35 | "tailwindcss-hyphens": "^0.1.0", 36 | "timeago-react": "^3.0.2", 37 | "webpack": "^4.46.0" 38 | }, 39 | "devDependencies": { 40 | "@types/dompurify": "^2.2.1", 41 | "@types/jest": "^26.0.20", 42 | "@types/marked": "^1.2.2", 43 | "@types/node": "^14.14.31", 44 | "@types/prismjs": "^1.16.3", 45 | "@types/react": "^17.0.2", 46 | "@types/react-dom": "^17.0.1", 47 | "@types/react-transition-group": "^4.4.1", 48 | "@typescript-eslint/eslint-plugin": "^4.16.1", 49 | "@typescript-eslint/parser": "^4.16.1", 50 | "autoprefixer": "^10.2.4", 51 | "eslint": "^7.21.0", 52 | "eslint-config-prettier": "^8.1.0", 53 | "eslint-plugin-react": "^7.22.0", 54 | "isomorphic-unfetch": "^3.1.0", 55 | "jest": "^26.6.3", 56 | "postcss-import": "^14.0.0", 57 | "prettier": "^2.2.1", 58 | "ts-jest": "^26.5.2", 59 | "typescript": "^4.2.2" 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /pages/[...rest].tsx: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 the Deno authors. All rights reserved. MIT license. */ 2 | 3 | import React, { useMemo } from "react"; 4 | import { useRouter } from "next/router"; 5 | import Registry from "../components/Registry"; 6 | import { parseNameVersion } from "../util/registry_utils"; 7 | import Manual from "../components/Manual"; 8 | import LoadingPage from "../components/LoadingPage"; 9 | import NotFoundPage from "../components/NotFound"; 10 | 11 | function RestPage(): React.ReactElement { 12 | const { query } = useRouter(); 13 | const { name } = useMemo(() => { 14 | const [identifier] = (query.rest as string[]) ?? []; 15 | const [name] = parseNameVersion(identifier ?? ""); 16 | return { name }; 17 | }, [query]); 18 | 19 | if (name === "std") return ; 20 | if (name === "manual") return ; 21 | 22 | if (name === "") return ; 23 | 24 | return ; 25 | } 26 | 27 | export default RestPage; 28 | -------------------------------------------------------------------------------- /pages/_app.tsx: -------------------------------------------------------------------------------- 1 | // Copyright 2020 the Deno authors. All rights reserved. MIT license. 2 | 3 | import React from "react"; 4 | import App from "next/app"; 5 | import Head from "next/head"; 6 | import "../components/app.css"; 7 | import "../components/markdown.css"; 8 | import "../components/docsearch.css"; 9 | import "preact/debug"; 10 | 11 | export default class DenoWebsiteApp extends App { 12 | render(): React.ReactElement { 13 | const { Component, pageProps } = this.props; 14 | return ( 15 |
    16 | 17 | 18 | 19 | 20 | 21 |
    22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /pages/_document.tsx: -------------------------------------------------------------------------------- 1 | // Copyright 2020 the Deno authors. All rights reserved. MIT license. 2 | 3 | import React from "react"; 4 | import Document, { 5 | Html, 6 | Head, 7 | Main, 8 | NextScript, 9 | DocumentContext, 10 | DocumentInitialProps, 11 | } from "next/document"; 12 | 13 | export default class DenoDocDocument extends Document { 14 | static async getInitialProps( 15 | ctx: DocumentContext 16 | ): Promise { 17 | const initialProps = await Document.getInitialProps(ctx); 18 | return { ...initialProps }; 19 | } 20 | 21 | gtag_header = `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': 22 | new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], 23 | j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 24 | 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); 25 | })(window,document,'script','dataLayer','GTM-P9DQ4WJ');`; 26 | gtag_body = ``; 28 | 29 | render(): React.ReactElement { 30 | return ( 31 | // 32 | 33 | 34 | 35 | 36 | 40 | 45 | 46 | 47 | 48 | 52 | 57 | 58 | 59 | 60 | 64 | 65 | 69 | 74 | 75 | {/* */} 76 | 90 | 91 | 92 | ); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /pages/translations.tsx: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 the Deno authors. All rights reserved. MIT license. */ 2 | 3 | import React from "react"; 4 | import Head from "next/head"; 5 | 6 | import Footer from "../components/Footer"; 7 | import Header from "../components/Header"; 8 | import { TRANSLATIONS, Translation } from "../util/translations_utils"; 9 | import { CookieBanner } from "../components/CookieBanner"; 10 | 11 | function TranslationsPage(): React.ReactElement { 12 | return ( 13 | <> 14 | 15 | {/** Translations | Deno */} 16 | 翻訳 | Deno; 17 | 18 | 19 |
    20 |
    21 |
    22 | {/**

    Translations

    */} 23 |

    翻訳

    24 |

    25 | {/** 26 | Dono docs is available in the following languages. Do you have a 27 | piece to display here?{" "} 28 | 32 | Add it! 33 | 34 | */} 35 | Denoドキュメントは次の言語で利用可能です。翻訳した物を持っていますか?{" "} 36 | 40 | 追加してください! 41 | 42 |

    43 |
    44 |
    45 | {TRANSLATIONS.map((language, i) => ( 46 | 47 | ))} 48 |
    49 |
    50 |