summaryrefslogtreecommitdiff
path: root/runtime/examples
AgeCommit message (Collapse)Author
2024-05-08chore: enable clippy::print_stdout and clippy::print_stderr (#23732)David Sherret
1. Generally we should prefer to use the `log` crate. 2. I very often accidentally commit `eprintln`s. When we should use `println` or `eprintln`, it's not too bad to be a bit more verbose and ignore the lint rule.
2024-03-14fix(cli): unbreak extension example and fix __runtime_js_sources (#22906)Matt Mastracci
Better example to close https://github.com/denoland/deno/issues/22600 --------- Signed-off-by: Matt Mastracci <matthew@mastracci.com>
2024-01-01chore: update copyright to 2024 (#21753)David Sherret
2023-09-21refactor: rewrite some ops to op2 macro (#20603)Bartek Iwańczuk
2023-06-29fix(core): consistent extension source resolution (#19615)Nayeem Rahman
Currently the resolution for extension sources is different depending on whether `include_js_files_for_snapshotting` is enabled. If sources are embedded it uses `include_str!()` which is module-relative. If sources are read at runtime paths are joined to `CARGO_MANIFEST_DIR` and are package-relative. This makes them both package-relative. Fixes `cargo run -p deno_runtime --example extension_with_esm --features include_js_files_for_snapshotting`.
2023-06-26Revert "Reland "refactor(core): cleanup feature flags for js source i… ↵Bartek Iwańczuk
(#19611) …nclusion" (#19519)" This reverts commit 28a4f3d0f5383695b1d49ccdc8b0f799a715b2c2. This change causes failures when used outside Deno repo: ``` ============================================================ Deno has panicked. This is a bug in Deno. Please report this at https://github.com/denoland/deno/issues/new. If you can reliably reproduce this panic, include the reproduction steps and re-run with the RUST_BACKTRACE=1 env var set and include the backtrace in your report. Platform: linux x86_64 Version: 1.34.3+b37b286 Args: ["/opt/hostedtoolcache/deno/0.0.0-b37b286f7fa68d5656f7c180f6127bdc38cf2cf5/x64/deno", "test", "--doc", "--unstable", "--allow-all", "--coverage=./cov"] thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Failed to read "/home/runner/work/deno/deno/core/00_primordials.js" Caused by: No such file or directory (os error 2)', core/runtime/jsruntime.rs:699:8 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ```
2023-06-25Reland "refactor(core): cleanup feature flags for js source inclusion" (#19519)Nayeem Rahman
Relands #19463. This time the `ExtensionFileSourceCode` enum is preserved, so this effectively just splits feature `include_js_for_snapshotting` into `exclude_js_sources` and `runtime_js_sources`, adds a `force_include_js_sources` option on `extension!()`, and unifies `ext::Init_ops_and_esm()` and `ext::init_ops()` into `ext::init()`.
2023-06-13Revert "refactor(core): cleanup feature flags for js source inclusion… ↵Bartek Iwańczuk
(#19490) … (#19463)" This reverts commit ceb03cfb037cf7024a5048b17b508ddda59cfa05. This is being reverted because it causes 3.5Mb increase in the binary size, due to runtime JS code being included in the binary, even though it's already snapshotted. CC @nayeemrmn
2023-06-13refactor(core): cleanup feature flags for js source inclusion (#19463)Nayeem Rahman
Remove `ExtensionFileSourceCode::LoadedFromFsDuringSnapshot` and feature `include_js_for_snapshotting` since they leak paths that are only applicable in this repo to embedders. Replace with feature `exclude_js_sources`. Additionally the feature `force_include_js_sources` allows negating it, if both features are set. We need both of these because features are additive and there must be a way of force including sources for snapshot creation while still having the `exclude_js_sources` feature. `force_include_js_sources` is only set for build deps, so sources are still excluded from the final binary. You can also specify `force_include_js_sources` on any extension to override the above features for that extension. Towards #19398. But there was still the snapshot-from-snapshot situation where code could be executed twice, I addressed that by making `mod_evaluate()` and scripts like `core/01_core.js` behave idempotently. This allowed unifying `ext::init_ops()` and `ext::init_ops_and_esm()` into `ext::init()`.
2023-06-03refactor(core): remove force_op_registration and cleanup ↵Nayeem Rahman
JsRuntimeForSnapshot (#19353) Addresses https://github.com/denoland/deno/pull/19308#discussion_r1212248194. Removes force_op_registration as it is no longer necessary.
2023-05-31feat(runtime): Add example for extension with ops (#19204)Exidex
Spend quite some time trying to get this working. With proper example would have been a lot faster. So this is pr with the example. I also rearranged examples a little bit to allow for addition of more examples
2023-05-14fix(runtime): Example hello_runtime panic (#19125)yzy-1
After commit f34fcd, running example will panic because esm_entry_point is not set. Closes https://github.com/denoland/deno/issues/19127
2023-05-10feat(compile): unstable npm and node specifier support (#19005)David Sherret
This is the initial support for npm and node specifiers in `deno compile`. The npm packages are included in the binary and read from it via a virtual file system. This also supports the `--node-modules-dir` flag, dependencies specified in a package.json, and npm binary commands (ex. `deno compile --unstable npm:cowsay`) Closes #16632
2023-05-04fix(core): allow esm extensions not included in snapshot (#18980)Nayeem Rahman
Fixes #18979. This changes the predicate for allowing `ext:` specifier resolution from `snapshot_loaded_and_not_snapshotting` to `ext_resolution_allowed` which is only set to true during the extension module loading phase. Module loaders as used in core are now declared as `ExtModuleLoader` rather than `dyn ModuleLoader`.
2023-05-01perf: lazily create RootCertStore (#18938)David Sherret
2023-04-24refactor(ext/node): allow injecting `NodeFs` from CLI (#18829)David Sherret
This allows providing a `NodeFs` as part of the `WorkerOptions`.
2023-03-26refactor: use default implementation of BootstrapOptions (#18439)Bartek Iwańczuk
Drive-by cleanup while I was looking into serialization of BootstrapOptions. There's no need to use non-default implementation in these places.
2023-03-13refactor(core): pass cwd explicitly to resolve_path (#18092)Bartek Iwańczuk
Towards landing #15454
2023-03-13Revert "feat(core): prevent isolate drop for CLI main worker (#18059)" (#18157)Ryan Dahl
Fixes https://github.com/denoland/deno/issues/18120 https://github.com/denoland/deno/issues/18137 https://github.com/denoland/fresh/issues/1073 This reverts commit 0cce9c2bcc9667935a571d30847e66ef5d01a196.
2023-03-09refactor(core): remove RuntimeOptions::extensions_with_js (#18099)Bartek Iwańczuk
This commit removes "deno_core::RuntimeOptions::extensions_with_js". Now it's embedders' responsibility to properly register extensions that will not contains JavaScript sources when running from an existing snapshot. Prerequisite for https://github.com/denoland/deno/pull/18080
2023-03-08feat(core): prevent isolate drop for CLI main worker (#18059)Divy Srivastava
``` Benchmark 1: deno run -A ../empty.js Time (mean ± σ): 20.5 ms ± 0.5 ms [User: 13.4 ms, System: 5.1 ms] Range (min … max): 19.8 ms … 24.0 ms 119 runs Benchmark 2: target/release/deno run -A ../empty.js Time (mean ± σ): 18.8 ms ± 0.3 ms [User: 13.0 ms, System: 4.9 ms] Range (min … max): 18.3 ms … 19.9 ms 129 runs ``` --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2023-01-07refactor(permissions): add PermissionsContainer struct for internal ↵Bartek Iwańczuk
mutability (#17134) Turns out we were cloning permissions which after prompting were discarded, so the state of permissions was never preserved. To handle that we need to store all permissions behind "Arc<Mutex<>>" (because there are situations where we need to send them to other thread). Testing and benching code still uses "Permissions" in most places - it's undesirable to share the same permission set between various test/bench files - otherwise granting or revoking permissions in one file would influence behavior of other test files.
2023-01-02chore: update copyright year to 2023 (#17247)David Sherret
Yearly tradition of creating extra noise in git.
2022-12-19fix(runtime): expose `extensions_with_js` from WorkerOptions (#17109)Leo Kettmeir
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-12-12feat: add `--inspect-wait` flag (#17001)Bartek Iwańczuk
This commit adds new "--inspect-wait" flag which works similarly to "--inspect-brk" in that it waits for inspector session to be established before running code. However it doesn't break on the first statement of user code, but instead runs it as soon as a session is established.
2022-11-10feat(runtime): support creating workers with custom v8 snapshots (#16553)Mathias Lafeldt
This PR makes it possible for applications to create workers from custom snapshots to improve runtime performance (without having to fork/copy `runtime/workers.rs`).
2022-10-18feat: introduce navigator.language (#12322)Luca Matei Pintilie
Link to the spec: https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-language-dev Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-09-28feat: implement Web Cache API (#15829)Satya Rohith
2022-09-17perf(ext/console): avoid `wrapConsole` when not inspecting (#15931)Divy Srivastava
2022-08-20feat(unstable): initial support for npm specifiers (#15484)David Sherret
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-08-16feat(runtime): add pre_execute_module_cb (#15485)David Sherret
2022-07-05Revert "refactor(snapshots): to their own crate (#14794)" (#15076)Bartek Iwańczuk
This reverts commit fd5a12d7e25dc53238e2bbcffe970e646c1035f3.
2022-06-24refactor(snapshots): to their own crate (#14794)Aaron O'Mullan
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2022-05-14feat: add userAgent property to Navigator's prototype (#14415)randomicon00
2022-04-27refactor: Remove PrettyJsError and js_error_create_fn (#14378)Nayeem Rahman
This commit: - removes "fmt_errors::PrettyJsError" in favor of "format_js_error" fn - removes "deno_core::JsError::create" and "deno_core::RuntimeOptions::js_error_create_fn" - adds new option to "deno_runtime::ops::worker_host::init"
2022-04-26fix(test): capture worker stdout and stderr in test output (#14410)David Sherret
2022-04-15refactor: Move source map lookups to core (#14274)Nayeem Rahman
The following transformations gradually faced by "JsError" have all been moved up front to "JsError::from_v8_exception()": - finding the first non-"deno:" source line; - moving "JsError::script_resource_name" etc. into the first error stack in case of syntax errors; - source mapping "JsError::script_resource_name" etc. when wrapping the error even though the frame locations are source mapped earlier; - removing "JsError::{script_resource_name,line_number,start_column,end_column}" entirely in favour of "js_error.frames.get(0)". We also no longer pass a js-side callback to "core/02_error.js" from cli. I avoided doing this on previous occasions because the source map lookups were in an awkward place.
2022-03-01fix(runtime): disable console color for non tty stdout (#13782)Antonio Musolino
2022-02-11compat: support --compat in web workers (#13629)Bartek Iwańczuk
Adds another callback to WebWorkerOptions that allows to execute some modules before actual worker code executes. This allows to set up Node global using std/node.
2022-01-07chore: update copyright to 2022 (#13306)Ryan Dahl
Co-authored-by: Erfan Safari <erfanshield@outlook.com>
2021-10-08feat(runtime): allow passing extensions via Worker options (#12362)Aaron O'Mullan
2021-10-05refactor(runtime): Worker bootstrap options (#12299)Aaron O'Mullan
2021-09-29feat: support serializing `WebAssembly.Module` objects (#12140)Andreu Botella
2021-09-18fix(core): prevent multiple main module loading (#12128)Bartek Iwańczuk
This commit fixes a problem where loading and executing multiple modules leads to all of the having "import.meta.main" set to true. Following Rust APIs were deprecated: - deno_core::JsRuntime::load_module - deno_runtime::Worker::execute_module - deno_runtime::WebWorker::execute_module Following Rust APIs were added: - deno_core::JsRuntime::load_main_module - deno_core::JsRuntime::load_side_module - deno_runtime::Worker::execute_main_module - deno_runtime::Worker::execute_side_module - deno_runtime::WebWorker::execute_main_module Trying to load multiple "main" modules into the runtime now results in an error. If user needs to load additional "non-main" modules they should use APIs for "side" module.
2021-08-16feat(runtime): support classic workers for internal testing (#11338)Andreu Botella
This commit implements classic workers, but only when the `--enable-testing-features-do-not-use` flag is provided. This change is not user facing. Classic workers are used extensively in WPT tests. The classic workers do not support loading from disk, and do not support TypeScript. Co-authored-by: Luca Casonato <hello@lcas.dev>
2021-08-10refactor: --unsafely-ignore-certificate-errors (#11629)Bartek Iwańczuk
2021-08-09feat: Add --unsafely-treat-insecure-origin-as-secure flag to disable SSL ↵TheAifam5
verification (#11324) This commit adds "--unsafely-treat-insecure-origin-as-secure" flag that allows to disable SSL verification for all domains, or specific domains if they were passed as an argument to the flag. Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2021-08-07feat(tls): Optionally support loading native certs (#11491)Justin Chase
This commit adds "DENO_TLS_CA_STORE" env variable to support optionally loading certificates from the users local certificate store. This will allow them to successfully connect via tls with corporate and self signed certs provided they have them installed in their keystore. It also allows them to deal with revoked certs by simply updating their keystore without having to upgrade Deno. Currently supported values are "mozilla", "system" or empty value.
2021-07-29feat(runtime): implement navigator.hardwareConcurrency (#11448)Divy Srivastava
This commit implements "navigator.hardwareConcurrency" API, which supersedes "Deno.systemCpuInfo()" API (which was removed in this commit).
2021-07-06feat: support SharedArrayBuffer sharing between workers (#11040)Luca Casonato
This commit adds support for sharing SABs between workers.