Skip to content

Commit

Permalink
chore: move to jsr completely
Browse files Browse the repository at this point in the history
  • Loading branch information
lino-levan committed Apr 18, 2024
1 parent 2f33fd3 commit a0d7dd2
Show file tree
Hide file tree
Showing 34 changed files with 129 additions and 59 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,5 @@ jobs:
- name: Install Deno
uses: denoland/setup-deno@v1

- name: Vendor packages
run: deno vendor **/*.ts

- name: Publish package
run: deno publish
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Lino Le Van

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ All of our docs are written in markdown and rendered using

```ts
// Import Astral
import { launch } from "https://deno.land/x/astral/mod.ts";
import { launch } from "jsr:@astral/astral";

// Launch the browser
const browser = await launch();
Expand Down
2 changes: 1 addition & 1 deletion bindings/_tools/generate/getProtocol.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { existsSync } from "https://deno.land/[email protected]/fs/exists.ts";
import { existsSync } from "@std/fs/exists";
import { getBinary } from "../../../src/cache.ts";

export interface JSDocable {
Expand Down
20 changes: 19 additions & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,23 @@
"jsx": "react-jsx",
"jsxImportSource": "https://esm.sh/[email protected]"
},
"lock": false
"lock": false,
"imports": {
"@deno-library/progress": "jsr:@deno-library/[email protected]",
"@std/assert": "jsr:@std/[email protected]",
"@std/async": "jsr:@std/[email protected]",
"@std/fs": "jsr:@std/[email protected]",
"@std/path": "jsr:@std/[email protected]",
"@std/testing": "jsr:@std/testing@^0.223.0",
"@zip-js/zip-js": "jsr:@zip-js/[email protected]"
},
"publish": {
"include": [
"LICENSE",
"README.md",
"mod.ts",
"src/**/*.ts",
"bindings/celestial.ts"
]
}
}
2 changes: 1 addition & 1 deletion docs/pages/advanced/connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ connect to its endpoint rather than spawning a new process.

```ts
// Import Astral
import { launch } from "https://deno.land/x/astral/mod.ts";
import { launch } from "jsr:@astral/astral";

// Connect to remote endpoint
const browser = await launch({
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/advanced/sandbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ validate network requests (using `--allow-net` permissions) and file requests

```ts
// Import Astral
import { launch } from "https://deno.land/x/astral/mod.ts";
import { fromFileUrl } from "https://deno.land/std/path/from_file_url.ts";
import { launch } from "jsr:@astral/astral";
import { fromFileUrl } from "@std/path/from-file-url";

// Launch browser
const browser = await launch();
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/guides/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ index: 3

```ts
// Import Astral
import { launch } from "https://deno.land/x/astral/mod.ts";
import { launch } from "jsr:@astral/astral";

// Launch the browser
const browser = await launch();
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/guides/evaluate.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ deno run -A https://deno.land/x/astral/examples/evaluate.ts

```ts
// Import Astral
import { launch } from "https://deno.land/x/astral/mod.ts";
import { launch } from "jsr:@astral/astral";

// Launch the browser
const browser = await launch();
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/guides/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ deno run -A https://deno.land/x/astral/examples/navigation.ts

```ts
// Import Astral
import { launch } from "https://deno.land/x/astral/mod.ts";
import { launch } from "jsr:@astral/astral";

// Launch browser in headfull mode
const browser = await launch({ headless: false });
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/guides/screenshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ deno run -A https://deno.land/x/astral/examples/screenshot.ts

```ts
// Import Astral
import { launch } from "https://deno.land/x/astral/mod.ts";
import { launch } from "jsr:@astral/astral";

// Launch the browser
const browser = await launch();
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Before we go into the depths of the API, let's see a quick demo first:

```ts
// Import Astral
import { launch } from "https://deno.land/x/astral/mod.ts";
import { launch } from "jsr:@astral/astral";

// Launch the browser
const browser = await launch();
Expand Down
1 change: 0 additions & 1 deletion docs/pages/showcase.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ensureDirSync } from "https://deno.land/[email protected]/fs/ensure_dir.ts";
import { launch } from "../../mod.ts";
import { type PageProps } from "https://deno.land/x/[email protected]/page.ts";
import { ensureFileSync } from "https://deno.land/[email protected]/fs/ensure_file.ts";
Expand Down
4 changes: 2 additions & 2 deletions src/browser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { retry } from "https://deno.land/[email protected]/async/retry.ts";
import { deadline } from "https://deno.land/[email protected]/async/deadline.ts";
import { retry } from "@std/async/retry";
import { deadline } from "@std/async/deadline";

import { Celestial, PROTOCOL_VERSION } from "../bindings/celestial.ts";
import { getBinary } from "./cache.ts";
Expand Down
54 changes: 44 additions & 10 deletions src/cache.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { ensureDirSync } from "https://deno.land/[email protected]/fs/ensure_dir.ts";
import { resolve } from "https://deno.land/[email protected]/path/mod.ts";
import { ensureDir } from "https://deno.land/[email protected]/fs/ensure_dir.ts";
import { dirname } from "https://deno.land/[email protected]/path/dirname.ts";
import { join } from "https://deno.land/[email protected]/path/join.ts";
import { ZipReader } from "https://deno.land/x/[email protected]/index.js";
import ProgressBar from "https://deno.land/x/[email protected]/mod.ts";
import { exists, existsSync } from "https://deno.land/[email protected]/fs/exists.ts";
import { retry } from "https://deno.land/[email protected]/async/retry.ts";
import cacheDir from "https://deno.land/x/[email protected]/cache_dir/mod.ts";
import { ensureDir, ensureDirSync } from "@std/fs/ensure-dir";
import { exists, existsSync } from "@std/fs/exists";
import { resolve } from "@std/path/resolve";
import { dirname } from "@std/path/dirname";
import { retry } from "@std/async/retry";
import { join } from "@std/path/join";
import { ZipReader } from "@zip-js/zip-js";
import ProgressBar from "@deno-library/progress";

export const SUPPORTED_VERSIONS = {
chrome: "121.0.6130.0",
Expand Down Expand Up @@ -39,6 +37,42 @@ async function knownGoodVersions(): Promise<KnownGoodVersions> {
return await req.json();
}

/** Stolen from https://github.com/justjavac/deno_dirs/blob/main/cache_dir/mod.ts
*
* Returns the path to the user's cache directory.
*
* The returned value depends on the operating system and is either a string,
* containing a value from the following table, or `null`.
*
* |Platform | Value | Example |
* | ------- | ----------------------------------- | -------------------------------- |
* | Linux | `$XDG_CACHE_HOME` or `$HOME`/.cache | /home/justjavac/.cache |
* | macOS | `$HOME`/Library/Caches | /Users/justjavac/Library/Caches |
* | Windows | `$LOCALAPPDATA` | C:\Users\justjavac\AppData\Local |
*/
function cacheDir(): string | null {
switch (Deno.build.os) {
case "linux": {
const xdg = Deno.env.get("XDG_CACHE_HOME");
if (xdg) return xdg;

const home = Deno.env.get("HOME");
if (home) return `${home}/.cache`;
break;
}

case "darwin": {
const home = Deno.env.get("HOME");
if (home) return `${home}/Library/Caches`;
break;
}

case "windows":
return Deno.env.get("LOCALAPPDATA") ?? null;
}

return null;
}
export function getDefaultCachePath(): string {
const path = cacheDir();
if (!path) throw new Error("couldn't determine default cache directory");
Expand Down
2 changes: 1 addition & 1 deletion src/element_handle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deadline } from "https://deno.land/[email protected]/async/deadline.ts";
import { deadline } from "@std/async/deadline";

import { Celestial, type Runtime_CallArgument } from "../bindings/celestial.ts";
import { KeyboardTypeOptions } from "./keyboard.ts";
Expand Down
2 changes: 1 addition & 1 deletion src/file_chooser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve } from "https://deno.land/[email protected]/path/resolve.ts";
import { resolve } from "@std/path/resolve";

import type {
Celestial,
Expand Down
4 changes: 2 additions & 2 deletions src/page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { deadline } from "https://deno.land/[email protected]/async/deadline.ts";
import { deadline } from "@std/async/deadline";
import { fromFileUrl } from "@std/path/from-file-url";

import { Celestial } from "../bindings/celestial.ts";
import type {
Expand All @@ -14,7 +15,6 @@ import { Keyboard } from "./keyboard.ts";
import { Touchscreen } from "./touchscreen.ts";
import { Dialog } from "./dialog.ts";
import { FileChooser } from "./file_chooser.ts";
import { fromFileUrl } from "https://deno.land/[email protected]/path/from_file_url.ts";

export type DeleteCookieOptions = Omit<
Parameters<Celestial["Network"]["deleteCookies"]>[0],
Expand Down
4 changes: 2 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { deadline } from "https://deno.land/[email protected]/async/deadline.ts";
import { retry } from "https://deno.land/[email protected]/async/retry.ts";
import { deadline } from "@std/async/deadline";
import { retry } from "@std/async/retry";

export const WEBSOCKET_ENDPOINT_REGEX = /ws:\/\/(.*:.*?)\//;

Expand Down
2 changes: 1 addition & 1 deletion tests/benchs/_get_binary_bench.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cleanCache, getBinary } from "../../mod.ts";
import { assert } from "https://deno.land/[email protected]/assert/assert.ts";
import { assert } from "@std/assert/assert";

Deno.bench({
name: "Download progress",
Expand Down
2 changes: 1 addition & 1 deletion tests/dialog_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/[email protected]/assert/assert_equals.ts";
import { assertEquals } from "@std/assert/assert-equals";

import { launch } from "../mod.ts";

Expand Down
4 changes: 2 additions & 2 deletions tests/element_evaluate_test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference lib="dom" />

import { assertEquals } from "https://deno.land/[email protected]/assert/assert_equals.ts";
import { assertRejects } from "https://deno.land/[email protected]/assert/assert_rejects.ts";
import { assertEquals } from "@std/assert/assert-equals";
import { assertRejects } from "@std/assert/assert-rejects";

import { launch } from "../mod.ts";

Expand Down
4 changes: 2 additions & 2 deletions tests/evaluate_test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference lib="dom" />

import { assertEquals } from "https://deno.land/[email protected]/assert/assert_equals.ts";
import { assertSnapshot } from "https://deno.land/[email protected]/testing/snapshot.ts";
import { assertEquals } from "@std/assert/assert-equals";
import { assertSnapshot } from "@std/testing/snapshot";

import { launch } from "../mod.ts";

Expand Down
2 changes: 1 addition & 1 deletion tests/event_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals } from "https://deno.land/[email protected]/assert/assert_equals.ts";
import { assertEquals } from "@std/assert/assert-equals";

import { launch } from "../mod.ts";

Expand Down
4 changes: 2 additions & 2 deletions tests/existing_ws_endpoint_test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { launch } from "../mod.ts";
import { assertThrows } from "https://deno.land/[email protected]/assert/assert_throws.ts";
import { assert } from "https://deno.land/[email protected]/assert/assert.ts";
import { assertThrows } from "@std/assert/assert-throws";
import { assert } from "@std/assert/assert";

Deno.test("Test existing ws endpoint", async () => {
// Spawn one browser instance and spawn another one connecting to the first one
Expand Down
2 changes: 1 addition & 1 deletion tests/extract_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertSnapshot } from "https://deno.land/[email protected]/testing/snapshot.ts";
import { assertSnapshot } from "@std/testing/snapshot";

import { launch } from "../mod.ts";

Expand Down
4 changes: 2 additions & 2 deletions tests/get_attributes_test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference lib="dom" />

import { assertEquals } from "https://deno.land/[email protected]/assert/assert_equals.ts";
import { assertExists } from "https://deno.land/[email protected]/assert/assert_exists.ts";
import { assertEquals } from "@std/assert/assert-equals";
import { assertExists } from "@std/assert/assert-exists";

import { launch } from "../mod.ts";

Expand Down
10 changes: 5 additions & 5 deletions tests/get_binary_test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { assertMatch } from "https://deno.land/[email protected]/assert/assert_match.ts";
import { assertStringIncludes } from "@std/assert/assert-string-includes";
import { assertRejects } from "@std/assert/assert-rejects";
import { assertMatch } from "@std/assert/assert-match";
import { assert } from "@std/assert/assert";
import { resolve } from "@std/path/resolve";
import { cleanCache, getBinary, launch } from "../mod.ts";
import { assert } from "https://deno.land/[email protected]/assert/assert.ts";
import { assertRejects } from "https://deno.land/[email protected]/assert/assert_rejects.ts";
import { resolve } from "https://deno.land/[email protected]/path/resolve.ts";
import { assertStringIncludes } from "https://deno.land/[email protected]/assert/assert_string_includes.ts";

const tempDir = Deno.env.get("TMPDIR") || Deno.env.get("TMP") ||
Deno.env.get("TEMP") || "/tmp";
Expand Down
3 changes: 2 additions & 1 deletion tests/install_lock_file_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { deadline } from "@std/async/deadline";
import { cleanCache, getBinary, launch } from "../mod.ts";
import { deadline } from "https://deno.land/[email protected]/async/deadline.ts";

// Tests should be performed in directory different from others tests as cache is cleaned during this one
//Deno.env.set("ASTRAL_QUIET_INSTALL", "true");
const cache = await Deno.makeTempDir({
Expand Down
2 changes: 1 addition & 1 deletion tests/query_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertExists } from "https://deno.land/[email protected]/assert/assert_exists.ts";
import { assertExists } from "@std/assert/assert-exists";
import { launch } from "../mod.ts";

Deno.test("Set content", async () => {
Expand Down
6 changes: 3 additions & 3 deletions tests/sandbox_test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getDefaultCachePath, launch } from "../mod.ts";
import { assertStrictEquals } from "https://deno.land/[email protected]/assert/assert_strict_equals.ts";
import { assert } from "https://deno.land/[email protected]/assert/assert.ts";
import { fromFileUrl } from "https://deno.land/[email protected]/path/from_file_url.ts";
import { assertStrictEquals } from "@std/assert/assert-strict-equals";
import { fromFileUrl } from "@std/path/from-file-url";
import { assert } from "@std/assert/assert";

const cache = getDefaultCachePath();

Expand Down
2 changes: 1 addition & 1 deletion tests/set_content_test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertStrictEquals } from "https://deno.land/[email protected]/assert/assert_strict_equals.ts";
import { assertStrictEquals } from "@std/assert/assert-strict-equals";
import { launch } from "../mod.ts";

Deno.test("Set content", async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/stealth_test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference lib="dom" />

import { assert } from "https://deno.land/[email protected]/assert/assert.ts";
import { assert } from "@std/assert/assert";

import { launch } from "../mod.ts";

Expand Down
4 changes: 2 additions & 2 deletions tests/wait_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assertSnapshot } from "https://deno.land/[email protected]/testing/snapshot.ts";
import { assertRejects } from "https://deno.land/[email protected]/assert/mod.ts";
import { assertSnapshot } from "@std/testing/snapshot";
import { assertRejects } from "@std/assert/assert-rejects";

import { launch } from "../mod.ts";

Expand Down

0 comments on commit a0d7dd2

Please sign in to comment.