hello" }} />;
19 | ```
20 |
--------------------------------------------------------------------------------
/lint/rules/react-no-danger.md:
--------------------------------------------------------------------------------
1 | ---
2 | tags: [react, fresh]
3 | ---
4 |
5 | 防止使用 `dangerouslySetInnerHTML`,如果使用不当可能导致 XSS 漏洞。
6 |
7 | **无效示例:**
8 |
9 | ```tsx
10 | const hello =
;
11 | ```
12 |
13 | **有效示例:**
14 |
15 | ```tsx
16 | const hello =
Hello World!
;
17 | ```
18 |
--------------------------------------------------------------------------------
/lint/rules/react-rules-of-hooks.md:
--------------------------------------------------------------------------------
1 | ---
2 | tags: [react, fresh]
3 | ---
4 |
5 | 确保在 React/Preact 组件中正确调用
6 | hooks。它们必须在组件的顶层调用,而不是在条件语句或循环内部。
7 |
8 | **无效示例:**
9 |
10 | ```tsx
11 | // 错误:在条件内部调用
12 | function MyComponent() {
13 | if (condition) {
14 | const [count, setCount] = useState(0);
15 | }
16 | }
17 |
18 | // 错误:在 for 循环内部调用
19 | function MyComponent() {
20 | for (const item of items) {
21 | const [count, setCount] = useState(0);
22 | }
23 | }
24 |
25 | // 错误:在 while 循环内部调用
26 | function MyComponent() {
27 | while (condition) {
28 | const [count, setCount] = useState(0);
29 | }
30 | }
31 |
32 | // 错误:在条件之后调用
33 | function MyComponent() {
34 | if (condition) {
35 | // ...
36 | }
37 |
38 | const [count, setCount] = useState(0);
39 | }
40 | ```
41 |
42 | **有效示例:**
43 |
44 | ```tsx
45 | function MyComponent() {
46 | const [count, setCount] = useState(0);
47 | }
48 | ```
49 |
--------------------------------------------------------------------------------
/lint/rules/require-yield.md:
--------------------------------------------------------------------------------
1 | ---
2 | tags: [recommended]
3 | ---
4 |
5 | 禁止使用没有 `yield` 的生成器函数。
6 |
7 | JavaScript 提供了通过 `function*`
8 | 表示的生成器函数,我们可以在其中暂停并在稍后恢复函数的执行。在这些暂停点,我们使用
9 | `yield` 关键字。换句话说,创建不包含 `yield`
10 | 关键字的生成器函数毫无意义,因为这样的函数可以写成普通函数。
11 |
12 | **无效示例:**
13 |
14 | ```typescript
15 | function* f1() {
16 | return "f1";
17 | }
18 | ```
19 |
20 | **有效示例:**
21 |
22 | ```typescript
23 | function* f1() {
24 | yield "f1";
25 | }
26 |
27 | // 允许空的生成器函数
28 | function* f2() {}
29 |
30 | function f3() {
31 | return "f3";
32 | }
33 | ```
34 |
--------------------------------------------------------------------------------
/lint/rules/single-var-declarator.md:
--------------------------------------------------------------------------------
1 | ---
2 | tags: []
3 | ---
4 |
5 | 禁止在同一声明语句中定义多个变量。
6 |
7 | **无效示例:**
8 |
9 | ```typescript
10 | const foo = 1, bar = "2";
11 | ```
12 |
13 | **有效示例:**
14 |
15 | ```typescript
16 | const foo = 1;
17 | const bar = "2";
18 | ```
19 |
--------------------------------------------------------------------------------
/lint/rules/triple-slash-reference.md:
--------------------------------------------------------------------------------
1 | ---
2 | tags: []
3 | ---
4 |
5 | 禁止使用某些三斜杠指令,推荐使用 ES6 风格的 import 声明。
6 |
7 | TypeScript 的 `///`
8 | 三斜杠引用是一种指示文件中可以使用另一个模块的类型的方式。通常不推荐使用三斜杠引用类型指令,而是推荐使用
9 | ECMAScript 模块导入。此规则报告
10 | `///
`、`///
` 或
11 | `///
` 指令的使用。
12 |
13 | **无效:**
14 |
15 | ```typescript
16 | ///
17 | import * as foo from "foo";
18 | ```
19 |
20 | **有效:**
21 |
22 | ```typescript
23 | import * as foo from "foo";
24 | ```
25 |
--------------------------------------------------------------------------------
/lint/rules/use-isnan.md:
--------------------------------------------------------------------------------
1 | ---
2 | tags: [recommended]
3 | ---
4 |
5 | 禁止与 `NaN` 进行比较。
6 |
7 | 由于 `NaN` 在 JavaScript 中是独一无二的,它不等于任何值,包括它自己,因此与
8 | `NaN` 进行比较的结果会令人困惑:
9 |
10 | - `NaN === NaN` 或 `NaN == NaN` 的值为 `false`
11 | - `NaN !== NaN` 或 `NaN != NaN` 的值为 `true`
12 |
13 | 因此,该规则要求你使用 `isNaN()` 或 `Number.isNaN()` 来判断某个值是否为 `NaN`。
14 |
15 | **无效示例:**
16 |
17 | ```typescript
18 | if (foo == NaN) {
19 | // ...
20 | }
21 |
22 | if (foo != NaN) {
23 | // ...
24 | }
25 |
26 | switch (NaN) {
27 | case foo:
28 | // ...
29 | }
30 |
31 | switch (foo) {
32 | case NaN:
33 | // ...
34 | }
35 | ```
36 |
37 | **有效示例:**
38 |
39 | ```typescript
40 | if (isNaN(foo)) {
41 | // ...
42 | }
43 |
44 | if (!isNaN(foo)) {
45 | // ...
46 | }
47 | ```
48 |
--------------------------------------------------------------------------------
/lint/rules/verbatim-module-syntax.md:
--------------------------------------------------------------------------------
1 | ---
2 | tags: [jsr]
3 | ---
4 |
5 | 强制将类型导入声明为类型导入。
6 |
7 | 此规则确保在启用 `verbatimModuleSyntax` TypeScript
8 | 编译器选项时代码能够正常工作。这对于分发 TypeScript
9 | 代码的库非常有用,以便在更多场景中工作。
10 |
11 | **无效示例:**
12 |
13 | ```typescript
14 | import { Person } from "./person.ts";
15 |
16 | const person: Person = {
17 | name: "David",
18 | };
19 | console.log(person);
20 | ```
21 |
22 | ```typescript
23 | import { output, Person } from "./person.ts";
24 |
25 | const person: Person = {
26 | name: "David",
27 | };
28 | output(person);
29 | ```
30 |
31 | **有效示例:**
32 |
33 | ```typescript
34 | import type { Person } from "./person.ts";
35 |
36 | const person: Person = {
37 | name: "David",
38 | };
39 | console.log(person);
40 | ```
41 |
42 | ```typescript
43 | import { output, type Person } from "./person.ts";
44 |
45 | const person: Person = {
46 | name: "David",
47 | };
48 | output(person);
49 | ```
50 |
--------------------------------------------------------------------------------
/lint_rules.client.ts:
--------------------------------------------------------------------------------
1 | const searchbar = document.getElementById("lint-rule-search");
2 |
3 | if (searchbar) {
4 | searchbar.addEventListener("input", (e) => {
5 | const query = e.currentTarget?.value;
6 |
7 | const allBoxes = document.querySelectorAll(".lint-rule-box");
8 |
9 | for (const box of allBoxes) {
10 | if (!box.id.includes(query)) {
11 | box.style.display = "none";
12 | } else {
13 | box.style.display = "block";
14 | }
15 | }
16 | });
17 | }
18 |
--------------------------------------------------------------------------------
/lume.ts:
--------------------------------------------------------------------------------
1 | import "lume/cli.ts";
2 |
--------------------------------------------------------------------------------
/markdown-it/codeblock-title.ts:
--------------------------------------------------------------------------------
1 | // deno-lint-ignore-file no-explicit-any
2 |
3 | export default function codeblockTitlePlugin(md: any) {
4 | const defaultRender = md.renderer.rules.fence;
5 |
6 | md.renderer.rules.fence = function (
7 | tokens: any[],
8 | idx: number,
9 | options,
10 | env,
11 | self,
12 | ) {
13 | const render = defaultRender(tokens, idx, options, env, self);
14 |
15 | const maybeTitle = (tokens[idx].info ?? "").match(/title="(.+?)"/)?.[1];
16 | if (maybeTitle) {
17 | return `
`;
18 | }
19 |
20 | return render;
21 | };
22 | }
23 |
--------------------------------------------------------------------------------
/markdown-it/replacer.ts:
--------------------------------------------------------------------------------
1 | // deno-lint-ignore-file no-explicit-any
2 | import REPLACEMENTS from "../replacements.json" with { type: "json" };
3 |
4 | export default function replacerPlugin(md: any) {
5 | md.core.ruler.before("inline", "replacer", (state) => {
6 | state.tokens.forEach((token) => {
7 | Object.entries(REPLACEMENTS).forEach(([key, value]) => {
8 | token.content = token.content.replace(
9 | new RegExp(`\\$${key}`, "g"),
10 | value,
11 | );
12 | });
13 | });
14 | });
15 | }
16 |
--------------------------------------------------------------------------------
/middleware/functionRoutes.ts:
--------------------------------------------------------------------------------
1 | import type { RequestHandler } from "lume/core/server.ts";
2 | import defaultRoutes from "./functions/routes.ts";
3 |
4 | export default function createRoutingMiddleware(
5 | routeObject: Record
= defaultRoutes,
6 | ) {
7 | return function functionRoutesMiddleware(
8 | req: Request,
9 | next: RequestHandler,
10 | ): Promise {
11 | const url = new URL(req.url);
12 | const route = routeObject[url.pathname];
13 | return route ? route(req) : next(req);
14 | };
15 | }
16 |
--------------------------------------------------------------------------------
/middleware/functions/feedback_test.ts:
--------------------------------------------------------------------------------
1 | import { loadSync } from "@std/dotenv";
2 | loadSync({ export: true });
3 |
4 | import { assertEquals } from "@std/assert";
5 | import feedbackRequestHandler from "./feedback.ts";
6 |
7 | Deno.test("integration: can insert record into feedback google sheet", async () => {
8 | const request = new Request("http://localhost:8000/_api/send-feedback");
9 |
10 | const result = await feedbackRequestHandler(request);
11 |
12 | assertEquals(result.status, 200);
13 | });
14 |
--------------------------------------------------------------------------------
/middleware/functions/health.ts:
--------------------------------------------------------------------------------
1 | export default async function healthRequestHandler(
2 | _: Request,
3 | ): Promise {
4 | return new Response("OK", { status: 200 });
5 | }
6 |
--------------------------------------------------------------------------------
/middleware/functions/routes.ts:
--------------------------------------------------------------------------------
1 | import type { RequestHandler } from "lume/core/server.ts";
2 | import healthRequestHandler from "./health.ts";
3 | import feedbackRequestHandler from "./feedback.ts";
4 |
5 | export default {
6 | "/_api/health": healthRequestHandler,
7 | "/_api/send-feedback": feedbackRequestHandler,
8 | } satisfies Record;
9 |
--------------------------------------------------------------------------------
/middleware/null.ts:
--------------------------------------------------------------------------------
1 | import type { RequestHandler } from "lume/core/server.ts";
2 |
3 | export default function nullMiddleware(
4 | req: Request,
5 | next: RequestHandler,
6 | ): Promise {
7 | return next(req);
8 | }
9 |
--------------------------------------------------------------------------------
/prism.ts:
--------------------------------------------------------------------------------
1 | import Prism from "npm:prismjs@1.29.0";
2 | import "npm:prismjs@1.29.0/components/prism-typescript.js";
3 | import "npm:prismjs@1.29.0/components/prism-diff.js";
4 | import "npm:prismjs@1.29.0/components/prism-json.js";
5 | import "npm:prismjs@1.29.0/components/prism-bash.js";
6 | import "npm:prismjs@1.29.0/components/prism-json5.js";
7 | import "npm:prismjs@1.29.0/components/prism-jsx.js";
8 | import "npm:prismjs@1.29.0/components/prism-tsx.js";
9 |
10 | Prism.languages.jsonc = Prism.languages.json5;
11 |
12 | export default Prism;
13 |
--------------------------------------------------------------------------------
/reference/_components/Anchor.tsx:
--------------------------------------------------------------------------------
1 | import type { AnchorCtx } from "@deno/doc";
2 |
3 | export default function ({ anchor }: { anchor: AnchorCtx }) {
4 | return (
5 |
11 | #
12 |
13 | );
14 | }
15 |
--------------------------------------------------------------------------------
/reference/_components/Arrow.tsx:
--------------------------------------------------------------------------------
1 | export default function () {
2 | return (
3 |
17 | );
18 | }
19 |
--------------------------------------------------------------------------------
/reference/_components/Check.tsx:
--------------------------------------------------------------------------------
1 | export default function () {
2 | return (
3 |
18 | );
19 | }
20 |
--------------------------------------------------------------------------------
/reference/_components/Copy.tsx:
--------------------------------------------------------------------------------
1 | export default function () {
2 | return (
3 |
18 | );
19 | }
20 |
--------------------------------------------------------------------------------
/reference/_components/Deprecated.tsx:
--------------------------------------------------------------------------------
1 | export default function ({ markdownContent }) {
2 | if (markdownContent === null) {
3 | return null;
4 | }
5 |
6 | return (
7 |
8 |
9 | 已弃用
10 |
11 |
12 | {/*markdown rendering*/}
13 | {markdownContent && (
14 |
15 | )}
16 |
17 | );
18 | }
19 |
--------------------------------------------------------------------------------
/reference/_components/DocBlockSubtitleInterface.tsx:
--------------------------------------------------------------------------------
1 | import type { DocBlockSubtitleInterfaceValueCtx } from "@deno/doc";
2 |
3 | export default function (
4 | { subtitle }: { subtitle: DocBlockSubtitleInterfaceValueCtx },
5 | ) {
6 | return (
7 |
8 | extends{" "}
9 | {subtitle.extends.map((item, i) => (
10 | <>
11 |
12 | {/*typedef rendering*/}
13 | {i > 1 && ,{" "}}
14 | >
15 | ))}
16 |
17 | );
18 | }
19 |
--------------------------------------------------------------------------------
/reference/_components/DocNodeKindIcon.tsx:
--------------------------------------------------------------------------------
1 | import type { DocNodeKindCtx } from "@deno/doc";
2 |
3 | export default function ({ kinds }: { kinds: DocNodeKindCtx[] }) {
4 | return (
5 |
6 | {kinds.map((item, index) => (
7 |
12 | {item.char}
13 |
14 | ))}
15 |
16 | );
17 | }
18 |
--------------------------------------------------------------------------------
/reference/_components/Example.tsx:
--------------------------------------------------------------------------------
1 | import type { ExampleCtx } from "@deno/doc";
2 |
3 | export default function (
4 | { comp, example }: { comp: any; example: ExampleCtx },
5 | ) {
6 | return (
7 |
8 |
9 |
10 | {/*markdown rendering; usually not markdown but just a string, but some cases might be markdown (ie the title contains inline-code)*/}
11 |
12 | {/*markdown rendering*/}
13 |
14 |
15 | );
16 | }
17 |
--------------------------------------------------------------------------------
/reference/_components/IndexSignature.tsx:
--------------------------------------------------------------------------------
1 | import type { DocEntryCtx } from "@deno/doc";
2 |
3 | export default function (
4 | { comp, indexSignature }: { comp: any; indexSignature: DocEntryCtx },
5 | ) {
6 | return (
7 |
8 |
9 | {indexSignature.readonly && readonly}
10 | {/* param rendering */}
11 | [
12 | ]
13 | {/* typedef rendering */}
14 |
15 |
16 | );
17 | }
18 |
--------------------------------------------------------------------------------
/reference/_components/ModuleDoc.tsx:
--------------------------------------------------------------------------------
1 | import type { ModuleDocCtx } from "@deno/doc";
2 |
3 | export default function (
4 | { comp, moduleDoc }: { comp: any; moduleDoc: ModuleDocCtx },
5 | ) {
6 | return (
7 |
8 |
9 | {moduleDoc.deprecated && (
10 |
11 | )}
12 |
13 |
14 |
15 | );
16 | }
17 |
--------------------------------------------------------------------------------
/reference/_components/RefNav.tsx:
--------------------------------------------------------------------------------
1 | export default function (data: Lume.Data, url: string) {
2 | return (
3 |
32 | );
33 | }
34 |
--------------------------------------------------------------------------------
/reference/_components/Section.css:
--------------------------------------------------------------------------------
1 | h1.ref-h1 {
2 | font-size: 1.6rem;
3 | border: 0;
4 | padding: 0;
5 | }
6 |
7 | code.inline-code-block {
8 | display: inline-block;
9 | margin-bottom: 1rem;
10 | padding: 1rem;
11 | }
12 |
13 | hr.hr {
14 | height: 1px;
15 | }
16 |
17 | .anchorable-heading .context-link {
18 | color: hsl(var(--foreground-primary));
19 | }
20 |
--------------------------------------------------------------------------------
/reference/_components/See.tsx:
--------------------------------------------------------------------------------
1 | export default function ({ sees }: { sees: string[] }) {
2 | return (
3 |
4 | {/*markdown rendering*/}
5 | {sees.map((see) => )}
6 |
7 | );
8 | }
9 |
--------------------------------------------------------------------------------
/reference/_components/SymbolContent.tsx:
--------------------------------------------------------------------------------
1 | import type { SymbolContentCtx } from "@deno/doc";
2 |
3 | export default function (
4 | { symbolContent, comp }: { comp: any; symbolContent: SymbolContentCtx },
5 | ) {
6 | return (
7 |
8 | {/*markdown rendering*/}
9 | {symbolContent.docs && (
10 |
11 | )}
12 |
13 | {symbolContent.sections.map((section) => (
14 |
15 | ))}
16 |
17 | );
18 | }
19 |
--------------------------------------------------------------------------------
/reference/_components/UsageLarge.tsx:
--------------------------------------------------------------------------------
1 | import type { UsagesCtx } from "@deno/doc";
2 |
3 | export default function ({ usages }: { usages: UsagesCtx | null }) {
4 | if (!usages?.usages?.[0]) {
5 | return null;
6 | }
7 |
8 | return (
9 |
10 |
Usage in Deno
11 |
12 | {/*markdown rendering*/}
13 |
14 |
15 | );
16 | }
17 |
--------------------------------------------------------------------------------
/reference_gen/deno-doc.ts:
--------------------------------------------------------------------------------
1 | import { doc, generateHtmlAsJSON } from "@deno/doc";
2 | import {
3 | hrefResolver,
4 | renderMarkdown,
5 | stripMarkdown,
6 | } from "./common.ts";
7 | import categoryDocs from "./deno-categories.json" with { type: "json" };
8 |
9 | const url = import.meta.resolve("./types/deno.d.ts");
10 |
11 | console.log("Generating doc nodes...");
12 |
13 | const nodes = await doc([url], { includeAll: true });
14 |
15 | console.log("Generating json structure...");
16 |
17 | const files = await generateHtmlAsJSON(nodes, {
18 | packageName: "Deno",
19 | categoryDocs,
20 | disableSearch: true,
21 | hrefResolver,
22 | usageComposer: {
23 | singleMode: true,
24 | compose(_currentResolve, _usageToMd) {
25 | return new Map();
26 | },
27 | },
28 | markdownRenderer: renderMarkdown,
29 | markdownStripper: stripMarkdown,
30 | });
31 |
32 | await Deno.writeTextFile("./gen/deno.json", JSON.stringify(files));
33 |
--------------------------------------------------------------------------------
/reference_gen/node-default-map.json:
--------------------------------------------------------------------------------
1 | {
2 | "assert": "assert"
3 | }
4 |
--------------------------------------------------------------------------------
/reference_gen/node-exclude-map.json:
--------------------------------------------------------------------------------
1 | {
2 | "assert.d.ts": [
3 | "assert"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/reference_gen/node-symbol-map.json:
--------------------------------------------------------------------------------
1 | {
2 | "buffer": {
3 | "Blob": "/api/web/~/Blob"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/assert.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/async_hooks.yaml:
--------------------------------------------------------------------------------
1 | status: partial
2 | symbols:
3 | AsyncResource: The AsyncResource implementation is a non-functional stub.
4 | executionAsyncId: The executionAsyncId implementation is a non-functional stub.
5 | createHook: The createHook implementation is a non-functional stub.
6 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/buffer.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/child_process.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/cluster.yaml:
--------------------------------------------------------------------------------
1 | status: unsupported
2 | description: All exports are non-functional stubs.
3 | symbols:
4 | "*": This symbol is a non-functional stub.
5 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/console.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/crypto.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 | symbols:
3 | Certificate: The methods are non-functional stubs.
4 | generateKeyPair: The `x448` option is not supported.
5 | generatePrime: The `safe`, `add` and `rem` option is not supported.
6 | KeyObject: |
7 | The following are non-functional stubs:
8 | - from
9 | - symmetricKeySize
10 | - equals
11 | - export
12 | publicDecrypt: This symbol is a non-functional stub.
13 | secureHeapUsed: This symbol is a non-functional stub.
14 | setEngine: This symbol is a non-functional stub.
15 | ECDH: The `convertKey` method is a non-functional sub.
16 | Sign: The `sign` and `verify` methods are not supported with non BinaryLike input.
17 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/dgram.yaml:
--------------------------------------------------------------------------------
1 | status: partial
2 | symbols:
3 | Socket: |
4 | The following methods are non-functional stubs:
5 | - addMembership
6 | - addSourceSpecificMembership
7 | - dropMembership
8 | - dropSourceSpecificMembership
9 | - setBroadcast
10 | - setMulticastInterface
11 | - setMulticastLoopback
12 | - setMulticastTtl
13 | - setTtl
14 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/diagnostics_channel.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/dns.yaml:
--------------------------------------------------------------------------------
1 | status: partial
2 | symbols:
3 | resolve: The `ttl` option is not supported.
4 | resolve4: The `ttl` option is not supported.
5 | resolve6: The `ttl` option is not supported.
6 | resolveCname: The `ttl` option is not supported.
7 | resolveCaa: The `ttl` option is not supported.
8 | resolveMx: The `ttl` option is not supported.
9 | resolveNaptr: The `ttl` option is not supported.
10 | resolveNs: The `ttl` option is not supported.
11 | resolvePtr: The `ttl` option is not supported.
12 | resolveSoa: The `ttl` option is not supported.
13 | resolveSrv: The `ttl` option is not supported.
14 | resolveTxt: The `ttl` option is not supported.
15 | resolveAny: The `ttl` option is not supported.
16 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/domain.yaml:
--------------------------------------------------------------------------------
1 | status: unsupported
2 | description: |
3 | All exports are non-functional stubs.
4 | This is a deprecated Node module.
5 |
6 | symbols:
7 | "*": This symbol is a non-functional stub.
8 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/events.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/fs--promises.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 | symbols:
3 | lchmod: The lchmod implementation is a not implemented.
4 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/fs.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 | symbols:
3 | writeFile: Missing `utf16le`, `latin1` and `ucs2` encoding.
4 | writeFileSync: Missing `utf16le`, `latin1` and `ucs2` encoding.
5 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/http.yaml:
--------------------------------------------------------------------------------
1 | status: partial
2 | symbols:
3 | RequestOptions: Option `createConnection` is not supported.
4 | ClientRequestArgs: Option `createConnection` is not supported.
5 | ClientRequest: Constructor option `createConnection` is not supported.
6 | request: Constructor option `createConnection` is not supported.
7 | get: Constructor option `createConnection` is not supported.
8 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/http2.yaml:
--------------------------------------------------------------------------------
1 | status: partial
2 | symbols:
3 | Http2Session: |
4 | The following methods are non-functional stubs:
5 | - setLocalWindowSize
6 | - ping
7 | - localSettings
8 | - remoteSettings
9 | - settings
10 | - ref
11 | - unref
12 | ServerHttp2Session: All methods are non-functional stubs.
13 | Http2Stream: |
14 | The following methods are non-functional stubs:
15 | - aborted
16 | - bufferSize
17 | - endAfterHeaders
18 | - id
19 | - pending
20 | - priority
21 | - rstCode
22 | - sentHeaders
23 | - sentInfoHeaders
24 | - sentTrailers
25 | - state
26 | ClientHttp2Stream: All methods are non-functional stubs.
27 | getDefaultSettings: This function is a non-functional stub.
28 | getPackedSettings: This function is a non-functional stub.
29 | getUnpackedSettings: This function is a non-functional stub.
30 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/https.yaml:
--------------------------------------------------------------------------------
1 | status: partial
2 | symbols:
3 | Server: The `cert` and `key` options do not support an array input.
4 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/inspector.yaml:
--------------------------------------------------------------------------------
1 | status: partial
2 | description: "`console` is supported. Other APIs are non-functional stubs."
3 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/module.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 | symbols:
3 | Module: The `register` method is a non-functional stub.
4 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/net.yaml:
--------------------------------------------------------------------------------
1 | status: partial
2 | symbols:
3 | Socket: The `fd` option is not supported.
4 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/os.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/path.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/perf_hooks.yaml:
--------------------------------------------------------------------------------
1 | status: partial
2 | symbols:
3 | performance: |
4 | The `eventLoopUtilization` method is a non-functional stub.
5 | The `timerify` method is not implemented.
6 | monitorEventLoopDelay: This symbol is not implemented.
7 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/process.yaml:
--------------------------------------------------------------------------------
1 | status: partial
2 | description: The `multipleResolves` and `worker` events are not supported.
3 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/punycode.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/querystring.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/readline.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/repl.yaml:
--------------------------------------------------------------------------------
1 | status: unsupported
2 | description: All symbols are not supported.
3 |
4 | symbols:
5 | "*": This symbol is not supported.
6 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/sea.yaml:
--------------------------------------------------------------------------------
1 | status: unsupported
2 | description: All symbols are not supported.
3 |
4 | symbols:
5 | "*": This symbol is not supported.
6 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/sqlite.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 | description: This module has been added in Deno v2.2.
3 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/stream.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/string_decoder.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/test.yaml:
--------------------------------------------------------------------------------
1 | # TODO: we currently don't render the test module
2 | status: partial
3 | description: Currently only `test` API is supported.
4 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/timers.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/tls.yaml:
--------------------------------------------------------------------------------
1 | status: partial
2 | symbols:
3 | createSecurePair: This symbol is currently not supported.
4 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/trace_events.yaml:
--------------------------------------------------------------------------------
1 | status: unsupported
2 | description: All exports are non-functional stubs.
3 | symbols:
4 | "*": This symbol is a non-functional stub.
5 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/tty.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/url.yaml:
--------------------------------------------------------------------------------
1 | status: good
2 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/util.yaml:
--------------------------------------------------------------------------------
1 | status: partial
2 | symbols:
3 | transferableAbortSignal: This symbol is currently not supported.
4 | transferableAbortController: This symbol is currently not supported.
5 | MIMEParams: This symbol is currently not supported.
6 | MIMEType: This symbol is currently not supported.
7 | getSystemErrorMap: This symbol is currently not supported.
8 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/v8.yaml:
--------------------------------------------------------------------------------
1 | status: partial
2 | description: |
3 | `cachedDataVersionTag` and `getHeapStatistics`, `serialize` and `deserialize` are supported.
4 | `setFlagsFromStrings` is a noop.
5 | Other APIs are not supported and will throw and error.
6 |
7 | symbols:
8 | setFlagsFromStrings: This function is a noop.
9 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/vm.yaml:
--------------------------------------------------------------------------------
1 | status: partial
2 | symbols:
3 | measureMemory: This is a non-functional stub.
4 | compile: The `importModuleDynamically` parameter is not supported.
5 | createContext: The `importModuleDynamically` parameter is not supported.
6 | Script: |
7 | The `importModuleDynamically` parameter is not supported.
8 | The `runInContext` method does not support break on `SIGINT`.
9 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/wasi.yaml:
--------------------------------------------------------------------------------
1 | status: unsupported
2 | description: All exports are non-functional stubs.
3 | symbols:
4 | "*": This symbol is a non-functional stub.
5 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/worker_threads.yaml:
--------------------------------------------------------------------------------
1 | status: partial
2 | symbols:
3 | parentPort: |
4 | The `emit` method is not supported.
5 | The `removeAllListeners` method is not supported.
6 | markAsUntransferable: This symbol is not supported.
7 | moveMessagePortToContext: This symbol is not supported.
8 | receiveMessageOnPort: This symbol is not supported.
9 | Worker: The `getHeapSnapshot` method is not supported.
10 |
--------------------------------------------------------------------------------
/reference_gen/node_descriptions/zlib.yaml:
--------------------------------------------------------------------------------
1 | status: partial
2 | symbols:
3 | Options: This class is not supported.
4 | BrotliOptions: This class is not supported.
5 | BrotliCompress: This class is not supported.
6 | BrotliDecompress: This class is not supported.
7 | ZlibBase: This class is not supported.
8 |
--------------------------------------------------------------------------------
/reference_gen/web-doc.ts:
--------------------------------------------------------------------------------
1 | import { doc, generateHtmlAsJSON } from "@deno/doc";
2 | import {
3 | hrefResolver,
4 | renderMarkdown,
5 | stripMarkdown,
6 | } from "./common.ts";
7 | import categoryDocs from "./web-categories.json" with { type: "json" };
8 |
9 | const url = import.meta.resolve("./types/web.d.ts");
10 |
11 | console.log("Generating doc nodes...");
12 |
13 | const nodes = await doc([url], { includeAll: true });
14 |
15 | console.log("Generating json structure...");
16 |
17 | const files = await generateHtmlAsJSON(nodes, {
18 | packageName: "Web",
19 | categoryDocs,
20 | disableSearch: true,
21 | hrefResolver,
22 | usageComposer: {
23 | singleMode: true,
24 | compose(_currentResolve, _usageToMd) {
25 | return new Map();
26 | },
27 | },
28 | markdownRenderer: renderMarkdown,
29 | markdownStripper: stripMarkdown,
30 | });
31 |
32 | await Deno.writeTextFile("./gen/web.json", JSON.stringify(files));
33 |
--------------------------------------------------------------------------------
/replacements.json:
--------------------------------------------------------------------------------
1 | {
2 | "CLI_VERSION": "2.2.3"
3 | }
4 |
--------------------------------------------------------------------------------
/runtime/contributing/docs.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Deno 文档"
3 | ---
4 |
5 | 我们欢迎并感谢对 Deno
6 | 文档的贡献。如果您发现问题,或想要添加内容,每个页面底部都有一个“编辑此页面”按钮。点击此按钮将带您进入
7 | [Deno 文档仓库](https://github.com/denoland/docs/)
8 | 中该页面的源文件。然后您可以进行更改并提交拉取请求。
9 |
10 | Deno 文档中的某些页面是从 Deno 仓库中的源文件生成的。这些页面无法直接编辑:
11 |
12 | - [API 参考](/api/deno/) 页面是从 Deno 仓库中的类型定义生成的。
13 | - 每个单独命令的 [CLI 参考](/runtime/reference/cli/) 页面是从 Deno
14 | 仓库中的源文件生成的。
15 |
16 | 如果您发现这些页面中的问题,您可以向 Deno 仓库提交拉取请求。或者在
17 | [Deno 文档仓库](https://github.com/denoland/docs/issues)
18 | 中提出问题,我们会尽快修复。
19 |
--------------------------------------------------------------------------------
/runtime/contributing/examples.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 贡献一个示例
3 | ---
4 |
5 | [Deno 示例](/examples/) 是一个展示如何使用 Deno 及其 API
6 | 的示例集合。如果您贡献了一个示例,我们将免费赠送您一套贴纸!
7 |
8 | 
9 |
10 | ## 贡献一个示例
11 |
12 | 如果您有一个想要与社区分享的 Deno 示例,您可以将其贡献到
13 | [Deno 文档仓库](https://github.com/denoland/docs?tab=readme-ov-file#examples),或者如果您希望看到某个示例,可以提出一个问题。如果您的示例被合并,我们将把您列为作者,并赠送您一些特别版的
14 | Deno 贴纸,作为对您贡献的感谢,您可以展示这些贴纸来彰显您的贡献者身份。
15 |
16 | ## 获取您的贴纸
17 |
18 | 如果您贡献了一个示例,请给我们发送邮件至
19 | [docs@deno.com](mailto:docs@deno.com),告知我们,以便我们为您寄送贴纸!
20 |
--------------------------------------------------------------------------------
/runtime/contributing/images/stickers.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/contributing/images/stickers.jpg
--------------------------------------------------------------------------------
/runtime/contributing/release_schedule.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "发布计划"
3 | oldUrl: /runtime/manual/references/contributing/release_schedule/
4 | ---
5 |
6 | `deno` CLI 的新次要版本计划每 12 周发布一次。
7 |
8 | 有关即将发布的版本,请参阅
9 | [Deno 的 GitHub 里程碑](https://github.com/denoland/deno/milestones)。
10 |
11 | 通常在次要版本发布后会有几个补丁版本(每周发布);之后,新功能的合并窗口将打开,为即将到来的次要版本做准备。
12 |
13 | 稳定版本可以在 [GitHub 发布页面](https://github.com/denoland/deno/releases)
14 | 找到。
15 |
16 | ## Canary 频道
17 |
18 | 除了上述的稳定频道外,Canary
19 | 版本每天会发布多次(针对主分支的每次提交)。您可以通过运行以下命令升级到最新的
20 | Canary 版本:
21 |
22 | ```console
23 | deno upgrade --canary
24 | ```
25 |
26 | 要更新到特定的 Canary 版本,请在 `--version` 选项中传递提交哈希:
27 |
28 | ```console
29 | deno upgrade --canary --version=973af61d8bb03c1709f61e456581d58386ed4952
30 | ```
31 |
32 | 要切换回稳定频道,请运行 `deno upgrade`。
33 |
34 | Canary 版本可以从 https://dl.deno.land 下载。
35 |
--------------------------------------------------------------------------------
/runtime/fundamentals/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "基础",
3 | "position": 2,
4 | "link": {
5 | "type": "doc",
6 | "id": "index"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/runtime/fundamentals/images/debugger1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/debugger1.png
--------------------------------------------------------------------------------
/runtime/fundamentals/images/debugger2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/debugger2.jpg
--------------------------------------------------------------------------------
/runtime/fundamentals/images/debugger3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/debugger3.jpg
--------------------------------------------------------------------------------
/runtime/fundamentals/images/debugger4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/debugger4.jpg
--------------------------------------------------------------------------------
/runtime/fundamentals/images/debugger5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/debugger5.jpg
--------------------------------------------------------------------------------
/runtime/fundamentals/images/debugger7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/debugger7.jpg
--------------------------------------------------------------------------------
/runtime/fundamentals/images/deno-lts-support.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/deno-lts-support.png
--------------------------------------------------------------------------------
/runtime/fundamentals/images/jb-ide-debug.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/jb-ide-debug.png
--------------------------------------------------------------------------------
/runtime/fundamentals/images/node_modules_dir.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/node_modules_dir.png
--------------------------------------------------------------------------------
/runtime/fundamentals/images/private-github-new-token.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/private-github-new-token.png
--------------------------------------------------------------------------------
/runtime/fundamentals/images/private-github-token-display.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/private-github-token-display.png
--------------------------------------------------------------------------------
/runtime/fundamentals/images/private-pat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/fundamentals/images/private-pat.png
--------------------------------------------------------------------------------
/runtime/getting_started/_category_.json:
--------------------------------------------------------------------------------
1 | {
2 | "label": "入门指南",
3 | "position": 1,
4 | "link": {
5 | "type": "doc",
6 | "id": "index"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/runtime/getting_started/images/vscode-setup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/getting_started/images/vscode-setup.png
--------------------------------------------------------------------------------
/runtime/getting_started/images/webstorm_setup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/getting_started/images/webstorm_setup.png
--------------------------------------------------------------------------------
/runtime/help.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "在哪里获取帮助"
3 | oldUrl: /runtime/manual/help/
4 | ---
5 |
6 | 遇到困难?迷失方向?从社区获取帮助。
7 |
8 | ## [社区 Discord](https://discord.gg/deno)
9 |
10 | 实时提问并与社区成员聊天。
11 |
12 | ## [Stack Overflow](https://stackoverflow.com/questions/tagged/deno)
13 |
14 | Stack Overflow
15 | 是一个流行的论坛,可以提出代码级别的问题,或者如果你遇到特定错误时寻求帮助。
16 | [提出你的问题!](https://stackoverflow.com/questions/ask?tags=deno)
17 |
18 | ## [DEV 的 Deno 社区](https://dev.to/t/deno)
19 |
20 | 这是一个寻找关于最佳实践、应用程序架构和新知识的有趣文章的好地方。使用 `deno`
21 | 标签发布你的文章。
22 |
--------------------------------------------------------------------------------
/runtime/reference/cli/add.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "deno add"
3 | command: add
4 | ---
5 |
--------------------------------------------------------------------------------
/runtime/reference/cli/check.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "deno check"
3 | oldUrl: /runtime/manual/tools/check/
4 | command: check
5 | ---
6 |
7 | ## 示例
8 |
9 | 不执行代码,仅进行类型检查。
10 |
11 | ```ts title="example.ts"
12 | const x: string = 1 + 1n;
13 | ```
14 |
15 | ```bash
16 | deno check example.ts
17 | ```
18 |
--------------------------------------------------------------------------------
/runtime/reference/cli/clean.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "deno clean"
3 | command: clean
4 | ---
5 |
--------------------------------------------------------------------------------
/runtime/reference/cli/completions.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "deno completions"
3 | oldUrl: /runtime/manual/tools/completions/
4 | command: completions
5 | ---
6 |
7 | ## 示例
8 |
9 | ### 配置 Bash shell 自动补全
10 |
11 | ```bash
12 | deno completions bash > /usr/local/etc/bash_completion.d/deno.bash
13 | source /usr/local/etc/bash_completion.d/deno.bash
14 | ```
15 |
16 | ### 配置 PowerShell shell 自动补全
17 |
18 | ```bash
19 | deno completions powershell | Out-String | Invoke-Expression
20 | ```
21 |
22 | ### 配置 zsh shell 自动补全
23 |
24 | 首先将以下内容添加到你的 `.zshrc` 文件中:
25 |
26 | ```bash
27 | fpath=(~/.zsh/completion $fpath)
28 | autoload -U compinit
29 | compinit
30 | ```
31 |
32 | 然后运行以下命令:
33 |
34 | ```bash
35 | deno completions zsh > _deno
36 | mv _deno ~/.zsh/completion/_deno
37 | autoload -U compinit && compinit
38 | ```
39 |
40 | ### 配置 fish shell 自动补全
41 |
42 | ```bash
43 | deno completions fish > completions.fish
44 | chmod +x ./completions.fish
45 | ```
46 |
--------------------------------------------------------------------------------
/runtime/reference/cli/eval.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "deno eval"
3 | oldUrl: /runtime/manual/tools/eval/
4 | command: eval
5 | ---
6 |
--------------------------------------------------------------------------------
/runtime/reference/cli/lsp.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "deno lsp"
3 | oldUrl: /runtime/manual/tools/lsp/
4 | ---
5 |
6 | :::info
7 |
8 | 通常人类不会直接使用这个子命令。'deno lsp' 可以为 IDE
9 | 提供跳转到定义支持和自动代码格式化功能。
10 |
11 | :::
12 |
13 | 启动 Deno
14 | 语言服务器。语言服务器被编辑器用来提供智能提示、代码格式化等功能。了解更多关于
15 | [与 Deno LSP 集成](/runtime/reference/lsp_integration/) 的信息。
16 |
17 | ## 描述
18 |
19 | 'deno lsp' 子命令为代码编辑器和 IDE 提供了一种通过语言服务器协议与 Deno
20 | 交互的方式。
21 |
22 | 了解更多关于
23 | [如何将编辑器和 IDE 连接到 `deno lsp`](https://deno.land/manual@v1.42.4/getting_started/setup_your_environment#editors-and-ides)
24 | 的信息。
25 |
--------------------------------------------------------------------------------
/runtime/reference/cli/remove.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "deno remove"
3 | command: remove
4 | ---
5 |
--------------------------------------------------------------------------------
/runtime/reference/cli/serve.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "deno serve"
3 | oldUrl: /runtime/manual/tools/serve/
4 | command: serve
5 | ---
6 |
7 | ## 示例
8 |
9 | 以下是一个示例,展示了如何使用声明式 fetch 创建一个简单的 HTTP 服务器:
10 |
11 | ```typescript title="server.ts"
12 | export default {
13 | async fetch(_req) {
14 | return new Response("Hello world!");
15 | },
16 | };
17 | ```
18 |
19 | 然后,你可以使用 `deno serve` 命令运行服务器:
20 |
21 | ```bash
22 | deno serve server.ts
23 | ```
24 |
25 | `fetch` 函数中的逻辑可以自定义,以处理不同类型的请求并相应地提供内容:
26 |
27 | ```typescript title="server.ts"
28 | export default {
29 | async fetch(request) {
30 | if (request.url.startsWith("/json")) {
31 | return Response.json({ hello: "world" });
32 | }
33 |
34 | return new Response("Hello world!");
35 | },
36 | };
37 | ```
38 |
--------------------------------------------------------------------------------
/runtime/reference/cli/test.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "deno test"
3 | oldUrl: /runtime/manual/tools/test/
4 | command: test
5 | ---
6 |
7 | ## 附加信息
8 |
9 | 它可以在监视模式下执行(`--watch`),支持并行执行(`--parallel`),并且可以配置为以随机顺序运行测试(`--shuffle`)。此外,还内置了对代码覆盖率(`--coverage`)和内存泄漏检测(`--trace-leaks`)的支持。
10 |
11 | ## 示例
12 |
13 | 运行测试
14 |
15 | ```bash
16 | deno test
17 | ```
18 |
19 | 运行特定文件中的测试
20 |
21 | ```bash
22 | deno test src/fetch_test.ts src/signal_test.ts
23 | ```
24 |
25 | 运行匹配 glob 模式的测试
26 |
27 | ```bash
28 | deno test src/*.test.ts
29 | ```
30 |
31 | 运行测试并跳过类型检查
32 |
33 | ```bash
34 | deno test --no-check
35 | ```
36 |
37 | 运行测试,并在文件更改时重新运行
38 |
39 | ```bash
40 | deno test --watch
41 | ```
42 |
--------------------------------------------------------------------------------
/runtime/reference/cli/types.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "deno types"
3 | oldUrl: /runtime/manual/tools/types/
4 | command: types
5 | ---
6 |
--------------------------------------------------------------------------------
/runtime/reference/cli/upgrade.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "deno upgrade"
3 | oldUrl: /runtime/manual/tools/upgrade/
4 | command: upgrade
5 | ---
6 |
--------------------------------------------------------------------------------
/runtime/reference/images/command_palette.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/command_palette.png
--------------------------------------------------------------------------------
/runtime/reference/images/jupyter-broadcast.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter-broadcast.mp4
--------------------------------------------------------------------------------
/runtime/reference/images/jupyter-cli.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter-cli.gif
--------------------------------------------------------------------------------
/runtime/reference/images/jupyter-confirm-prompt.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter-confirm-prompt.mp4
--------------------------------------------------------------------------------
/runtime/reference/images/jupyter-display.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter-display.png
--------------------------------------------------------------------------------
/runtime/reference/images/jupyter-html.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter-html.png
--------------------------------------------------------------------------------
/runtime/reference/images/jupyter-md.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter-md.png
--------------------------------------------------------------------------------
/runtime/reference/images/jupyter-plot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter-plot.png
--------------------------------------------------------------------------------
/runtime/reference/images/jupyter-svg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter-svg.png
--------------------------------------------------------------------------------
/runtime/reference/images/jupyter_notebook.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/jupyter_notebook.png
--------------------------------------------------------------------------------
/runtime/reference/images/vscode_workspace_initialized.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/runtime/reference/images/vscode_workspace_initialized.png
--------------------------------------------------------------------------------
/runtime/reference/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 参考指南
3 | ---
4 |
5 | 在这里,您将找到详细的技术文档和全面的指南,帮助您掌握 Deno 的高级功能和工具。
6 |
7 | ## 运行时 API
8 |
9 | Deno 拥有广泛的命名空间
10 | API,提供了文件系统操作、网络请求、子进程管理等多种功能。Deno 还旨在通过将现代
11 | Web API 引入服务器端环境,弥合服务器与浏览器之间的差距。最后,Deno 提供了一组
12 | Node.js 兼容 API,帮助您将现有的 Node.js 应用程序迁移到 Deno。
13 |
14 | - [Deno API](/runtime/reference/deno_namespace_apis/)
15 | - [Web API 支持](/runtime/reference/web_platform_apis/)
16 | - [Node API 支持](/api/node/)
17 |
18 | ## 设置您的环境
19 |
20 | 获取有关如何为 Deno 开发设置 Visual Studio Code (VS Code)
21 | 的分步说明。本指南将帮助您配置开发环境,以充分利用 Deno 的功能,包括 TypeScript
22 | 支持、调试等。如果您使用的是其他编辑器,也可以查看 Deno 语言服务器。
23 |
24 | - [为 Deno 设置 VS Code](/runtime/reference/vscode/)
25 | - [Deno 语言服务器](/runtime/reference/cli/lsp_integration/)
26 | - [持续集成](/runtime/reference/continuous_integration/)
27 |
28 | ## Deno CLI 参考指南
29 |
30 | 这份全面的资源涵盖了 Deno 命令行界面中的所有命令和选项,为您提供有效管理和运行
31 | Deno 应用程序所需的知识。
32 |
33 | - [Deno CLI 参考指南](/runtime/reference/cli/)
34 |
--------------------------------------------------------------------------------
/server.ts:
--------------------------------------------------------------------------------
1 | import "@std/dotenv/load";
2 |
3 | import Server from "lume/core/server.ts";
4 | import NotFoundMiddleware from "lume/middlewares/not_found.ts";
5 | import apiDocumentContentTypeMiddleware from "./middleware/apiDocContentType.ts";
6 | import redirectsMiddleware from "./middleware/redirects.ts";
7 | import createRoutingMiddleware from "./middleware/functionRoutes.ts";
8 |
9 | export const server = new Server({ root: "." });
10 |
11 | server.use(redirectsMiddleware);
12 | server.use(NotFoundMiddleware({ root: ".", page404: "./404" }));
13 | server.use(createRoutingMiddleware());
14 | server.use(apiDocumentContentTypeMiddleware);
15 |
16 | server.start();
17 |
18 | console.log("Listening on http://localhost:8000");
19 |
--------------------------------------------------------------------------------
/static/.nojekyll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/.nojekyll
--------------------------------------------------------------------------------
/static/android-chrome-192x192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/android-chrome-192x192.png
--------------------------------------------------------------------------------
/static/android-chrome-512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/android-chrome-512x512.png
--------------------------------------------------------------------------------
/static/apple-touch-icon-precomposed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/apple-touch-icon-precomposed.png
--------------------------------------------------------------------------------
/static/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/apple-touch-icon.png
--------------------------------------------------------------------------------
/static/examples.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/examples.png
--------------------------------------------------------------------------------
/static/examples/local.ts:
--------------------------------------------------------------------------------
1 | const local = "This is a local variable inside of local.ts";
2 |
--------------------------------------------------------------------------------
/static/examples/welcome.ts:
--------------------------------------------------------------------------------
1 | console.log("Welcome to Deno!");
2 |
--------------------------------------------------------------------------------
/static/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/favicon-16x16.png
--------------------------------------------------------------------------------
/static/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/favicon-32x32.png
--------------------------------------------------------------------------------
/static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/favicon.ico
--------------------------------------------------------------------------------
/static/fonts/inter/Inter-Italic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/fonts/inter/Inter-Italic.woff2
--------------------------------------------------------------------------------
/static/fonts/inter/Inter-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/fonts/inter/Inter-Regular.woff2
--------------------------------------------------------------------------------
/static/fonts/inter/Inter-SemiBold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/fonts/inter/Inter-SemiBold.woff2
--------------------------------------------------------------------------------
/static/fonts/inter/Inter-SemiBoldItalic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/fonts/inter/Inter-SemiBoldItalic.woff2
--------------------------------------------------------------------------------
/static/github-mark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/github-mark.png
--------------------------------------------------------------------------------
/static/img/checkmark.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/img/chevron.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/static/img/cover@xl.avif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/img/cover@xl.avif
--------------------------------------------------------------------------------
/static/img/dark.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/static/img/docusaurus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/img/docusaurus.png
--------------------------------------------------------------------------------
/static/img/fresh.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/img/jsr.svg:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/static/img/jsx.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/img/light.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/static/img/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/img/og.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/img/og.webp
--------------------------------------------------------------------------------
/static/img/react.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/img/search.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/static/img/social.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/static/img/social.png
--------------------------------------------------------------------------------
/static/js/darkmode.client.js:
--------------------------------------------------------------------------------
1 | const THEME_KEY = "denoDocsTheme";
2 | const DARK_CLASS = "dark";
3 | const LIGHT_CLASS = "light";
4 |
5 | function getPreferredTheme() {
6 | if (THEME_KEY in localStorage) {
7 | return localStorage[THEME_KEY];
8 | }
9 | return globalThis.matchMedia("(prefers-color-scheme: dark)").matches
10 | ? DARK_CLASS
11 | : LIGHT_CLASS;
12 | }
13 |
14 | function setTheme(theme) {
15 | const root = document.documentElement;
16 | root.classList.add(theme);
17 | root.classList.remove(theme === DARK_CLASS ? LIGHT_CLASS : DARK_CLASS);
18 | }
19 |
20 | setTheme(getPreferredTheme());
21 |
--------------------------------------------------------------------------------
/static/js/nav-toggle.client.js:
--------------------------------------------------------------------------------
1 | const sidebar = document.getElementById("nav");
2 |
3 | if (sidebar) {
4 | const checkboxes = document.querySelectorAll(".sub-nav-toggle-checkbox");
5 | checkboxes.forEach((checkbox) => {
6 | // on change of the checkbox, update the checked state in the local storage
7 | checkbox.addEventListener("change", (e) => {
8 | console.log("updated");
9 | localStorage.setItem(checkbox.id, checkbox.checked);
10 | });
11 |
12 | // set the checked state of the checkbox based on the value in the local storage
13 | const checked = localStorage.getItem(checkbox.id) === "true";
14 | checkbox.checked = checked;
15 | });
16 | }
17 |
--------------------------------------------------------------------------------
/static/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Allow: /
3 |
4 | Sitemap: https://docs.denohub.com/sitemap.xml
5 |
--------------------------------------------------------------------------------
/styleguide/_data.ts:
--------------------------------------------------------------------------------
1 | import { Sidebar } from "../types.ts";
2 |
3 | export const sidebar = [
4 | {
5 | title: "Style Guide",
6 | href: "/styleguide/",
7 | items: [
8 | {
9 | title: "Typography",
10 | href: "/styleguide/typography/",
11 | },
12 | {
13 | title: "Components",
14 | href: "/styleguide/components/",
15 | },
16 | ],
17 | },
18 | ] satisfies Sidebar;
19 |
20 | export const sectionTitle = "Style Guide";
21 | export const sectionHref = "/styleguide/";
22 |
--------------------------------------------------------------------------------
/styleguide/components.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: "组件"
3 | description: "可在 Deno 文档中使用的组件。"
4 | ---
5 |
6 | ## Logo 组件
7 |
8 | 大小受其包含元素限制
9 |
10 | ```tsx
11 |
12 | ```
13 |
14 |
--------------------------------------------------------------------------------
/styleguide/example-page.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 示例页面
3 | description: 这是一个示例页面
4 | openGraphLayout: /open_graph/examples.jsx
5 | ---
6 |
7 | # 示例页面
8 |
--------------------------------------------------------------------------------
/styleguide/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "风格指南"
3 | description: "Deno 文档的风格和设计指南。"
4 | ---
5 |
6 | - [排版](/styleguide/typography)
7 | - [组件](/styleguide/components)
8 |
--------------------------------------------------------------------------------
/styleguide/typography.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: "排版"
3 | description: "Deno 文档的排版指南。"
4 | ---
5 |
6 | Deno 文档网站中使用的排版样式示例。
7 |
8 | # 标题 1
9 |
10 | ## 标题 2
11 |
12 | ### 标题 3
13 |
14 | #### 标题 4
15 |
16 | ## 段落
17 |
18 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
19 |
20 | ## 链接语言
21 |
22 | - [标准内容链接](/styleguide)
23 | - [外部链接](https://deno.com)
24 |
25 | ### 上下文中的链接
26 |
27 | Lorem ipsum dolor sit amet, [标准内容链接](/styleguide) consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
28 |
29 | 当内联代码元素包含链接时,[`它们看起来像这样`](/styleguide)。
30 |
31 | ## 预格式化文本
32 |
33 | 我们可以使用 `内联代码元素`,也可以使用如下所示的代码块。
34 |
35 | ```ts
36 | const x = 1;
37 | ```
38 |
39 | 代码块可用于显示代码示例,并且可以显示标题并使用给定语言的语法高亮。
40 |
41 | ```ts title="title.ts"
42 | const x = 1;
43 | const y = 2;
44 | ```
--------------------------------------------------------------------------------
/subhosting/api/images/org-id.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/justjavac/deno-docs/52ec22964b6eb8633ba3fdc523f5b1f79c31eed5/subhosting/api/images/org-id.png
--------------------------------------------------------------------------------
/subhosting/index.md:
--------------------------------------------------------------------------------
1 | 您的输入为空,请提供需要翻译的内容。
2 |
--------------------------------------------------------------------------------
/subhosting/manual/acceptable_use_policy.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 可接受使用政策
3 | ---
4 |
5 | Deno Subhosting 服务包含的资源(CPU
6 | 时间、请求次数)受此可接受使用政策的约束。本文档可以大致估算我们认为是“可接受使用”的内容,以及我们不认为是可接受使用的内容。
7 |
8 | ### 可接受使用的示例
9 |
10 | - ✅ 服务器端渲染的网站
11 | - ✅ Jamstack 站点和应用程序
12 | - ✅ 单页应用程序
13 | - ✅ 查询数据库或外部 API 的 API
14 | - ✅ 个人博客
15 | - ✅ 公司网站
16 | - ✅ 电子商务网站
17 |
18 | ### 不可接受的使用
19 |
20 | - ❌ 加密货币挖矿
21 | - ❌ 高度 CPU 密集型负载(例如机器学习)
22 | - ❌ 为外部站点托管媒体
23 | - ❌ 爬虫
24 | - ❌ 代理或 VPN
25 |
26 | ## 指南
27 |
28 | 我们预计大多数项目都会在合理的使用限制范围内。如果您的项目使用情况显著偏离常态,我们将通知您。在采取任何行动以解决对我们基础设施的不合理负担之前,我们会在可能的情况下与您联系。
29 |
--------------------------------------------------------------------------------
/subhosting/manual/pricing_and_limits.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 定价与限制
3 | ---
4 |
5 | ## 部署大小
6 |
7 | 每次部署中,所有源代码和资源的总和应小于 1GB。
8 |
9 | ## 部署频率
10 |
11 | 子托管用户每小时的最大部署次数为 60 次(免费层级)或 300
12 | 次(构建者层级)。企业计划中的组织可获得更高的限制。
13 |
14 | ## 每次请求的 CPU 时间
15 |
16 | - 50ms 或 200ms,取决于层级。
17 | - 每次请求的 CPU 时间限制是基于多次请求的平均值,并非严格按每次请求执行。
18 | - 不包括部署等待 I/O 的时间(例如,在发出 fetch() 请求时等待远程服务器的时间)。
19 |
20 | ## 阻塞事件循环
21 |
22 | 程序不应阻塞事件循环超过 1 秒。
23 |
24 | ## 可用内存
25 |
26 | 最大可用内存为 512MB。
27 |
--------------------------------------------------------------------------------
/timeUtils.ts:
--------------------------------------------------------------------------------
1 | export function cliNow() {
2 | const timeOnly = new Date().toLocaleTimeString();
3 | return `[${timeOnly}]`;
4 | }
5 |
--------------------------------------------------------------------------------