### Setup apt-get for Dart SDK on Linux Source: https://github.com/dart-lang/sdk/blob/main/docs/Installing-beta-and-dev-releases-using-package-managers.md One-time setup commands for using apt-get to install Dart SDK packages on Linux. This includes updating package lists, installing dependencies, and adding Dart's signing key and repository lists. ```bash $ apt-get -q update && apt-get install --no-install-recommends -y -q gnupg2 curl git ca-certificates apt-transport-https openssh-client && \ curl https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list && \ curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_testing.list > /etc/apt/sources.list.d/dart_testing.list && \ curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_unstable.list > /etc/apt/sources.list.d/dart_unstable.list && \ apt-get update ``` -------------------------------- ### Install Dart SDK channels with apt-get Source: https://github.com/dart-lang/sdk/blob/main/docs/Installing-beta-and-dev-releases-using-package-managers.md Commands to install different channels of the Dart SDK on Linux using apt-get after the initial setup. ```bash $ apt-get -t unstable install dart # installs the latest dev dart $ apt-get -t testing install dart # installs the latest beta dart $ apt-get -t stable install dart # installs the latest stable dart $ apt-get install dart # installs the latest version of dart ``` -------------------------------- ### Install snapshot_analysis CLI Source: https://github.com/dart-lang/sdk/blob/main/pkg/vm_snapshot_analysis/README.md Install the `snapshot_analysis` command-line tool globally using `pub global activate`. ```console $ pub global activate vm_snapshot_analysis ``` -------------------------------- ### Install Uprobe for Allocation Profiling Source: https://github.com/dart-lang/sdk/blob/main/runtime/tools/profiling/README.md Install a uprobe specifically for the `AllocationProbePoint` to capture allocation-related data. Requires root privileges. ```bash sudo $(which dart) runtime/tools/profiling/bin/set_uprobe.dart alloc AllocationProbePoint test.aot ``` -------------------------------- ### Debug Dart VM with GDB and QEMU Source: https://github.com/dart-lang/sdk/blob/main/runtime/docs/qemu.md Install GDB for multi-architecture debugging. Start the Dart VM under QEMU with GDB server enabled, then connect to it using GDB, setting the system root and continuing execution. ```bash $ sudo apt install qemu-user libc6-arm64-cross gdb-multiarch $ QEMU_LD_PREFIX=/usr/aarch64-linux-gnu/ qemu-aarch4 -g 9090 out/DebugXARM64/dartvm hello.dart.dill ``` ```gdb (gdb) set sysroot /usr/aarch64-linux-gnu/ (gdb) target remote localhost:9090 (gdb) continue ``` -------------------------------- ### Start Android Emulator Source: https://github.com/dart-lang/sdk/blob/main/docs/Building-the-Dart-VM-for-Android.md Launch an Android emulator using the android_finder.py script. The -b flag ensures an emulator is started if none are available for the specified ABI. ```bash $ runtime/tools/android_finder.py -a {armeabi-v7a, x86} -b ``` -------------------------------- ### Install build tools on Linux Source: https://github.com/dart-lang/sdk/blob/main/docs/Building.md Installs essential build tools for Dart SDK on Linux systems. Ensure git, python3, curl, and xz-utils are installed before proceeding. ```bash sudo apt-get install git python3 curl xz-utils ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/dart-lang/sdk/blob/main/runtime/tools/wiki/README.md Install all necessary Python dependencies for the wiki rendering tools using pip. This command should be run after cloning the repository. ```console pip3 install coloredlogs jinja2 markdown aiohttp watchdog pymdown-extensions pygments ``` -------------------------------- ### Start HTTP Server for Browser Tests Source: https://github.com/dart-lang/sdk/blob/main/docs/Building.md Use this command to start a local HTTP server for debugging browser test failures. The exact path may vary. ```bash To retest, run: /usr/local/[...]/dart/tools/testing/bin/linux/dart /usr/local/[...]/dart/tools/testing/dart/http_server.dart ... ``` -------------------------------- ### Build with Scons Source: https://github.com/dart-lang/sdk/blob/main/third_party/double-conversion/README.md Use 'scons install' to build and install the static and shared libraries. The DESTDIR option can change the target installation directory. ```bash scons install ``` ```bash scons DESTDIR=alternative_directory install ``` -------------------------------- ### Install beta Dart SDK with Homebrew Source: https://github.com/dart-lang/sdk/blob/main/docs/Installing-beta-and-dev-releases-using-package-managers.md Use this command to install the latest beta release of the Dart SDK on macOS using Homebrew. ```bash brew install dart-beta ``` -------------------------------- ### Install specific Dart SDK version with apt-get Source: https://github.com/dart-lang/sdk/blob/main/docs/Installing-beta-and-dev-releases-using-package-managers.md Use this command to install a specific version of the Dart SDK on Linux using apt-get. ```bash $ apt-get install dart=2.9.0-4.0.dev-1 ``` -------------------------------- ### Dart Example Code Block Source: https://github.com/dart-lang/sdk/blob/main/pkg/analyzer/doc/implementation/diagnostics.md Illustrates how to format a Dart code example within documentation, including language specification and highlight markers. ```dart ```dart // Example code here [!diagnostic region!] ``` ``` -------------------------------- ### LayeredPicture get guid() Getter Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Returns the unique identifier (guid) of the LayeredPicture. ```javascript get guid(){return this.guid_;} ``` -------------------------------- ### Get Annotation by GUID Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Retrieves an annotation object using its unique GUID. ```javascript getAnnotationByGUID(guid){return this.annotationsByGuid\_\\[guid\\];} ``` -------------------------------- ### Build release VM and run FFI unit tests Source: https://github.com/dart-lang/sdk/blob/main/docs/Building.md Before running tests, use `build.py` to build the 'most' and 'run_ffi_unit_tests' targets. This example builds the release version of the VM. ```bash ./tools/build.py --mode release most run_ffi_unit_tests ``` -------------------------------- ### Run Wiki Webserver for Development Source: https://github.com/dart-lang/sdk/blob/main/runtime/tools/wiki/README.md Use this command to start a local webserver for developing wiki pages. Ensure you are in the root directory of the SDK. ```shell runtime/tools/wiki/build/build.py ``` -------------------------------- ### Get Start Angle Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Accessor function to retrieve the start angle of a radial element. ```javascript function ro(n){return n.startAngle} ``` -------------------------------- ### Begin Hosting Context Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Pushes the current component onto the host stack, initiating a hosting context for child elements. ```javascript this._beginHosting=function(){Polymer.Base._hostStack.push(this);if(!this._clients){this._clients=[];}} ``` -------------------------------- ### PictureSnapshot get guid() Getter Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Returns the unique identifier (guid) of the PictureSnapshot, which is delegated to the underlying Picture object. ```javascript get guid(){return this.picture_.guid;} ``` -------------------------------- ### JNIgen Configuration Example Source: https://github.com/dart-lang/sdk/blob/main/docs/gsoc/Dart-GSoC-2024-Project-Ideas.md An example of a jnigen.yaml configuration file used for generating Dart bindings from Java code. This file specifies build settings and dependencies for the JNIgen process. ```yaml targets: - name: cronet_http sources: - src/java package: org.chromium.cronet_http # ... other configurations ``` -------------------------------- ### Patch File Syntax Example Source: https://github.com/dart-lang/sdk/blob/main/pkg/front_end/testcases/dartino/README.md Demonstrates the basic syntax of a .patch file, including conditional blocks and alternatives. ```text ==> file.txt.patch <== first <<<< "ex1" v1 ==== "ex2" v2 ==== "ex2" v3 >>>> last ``` -------------------------------- ### Get Frame Start Time Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Determines the start time of a frame, considering pre-traversal work ranges. It finds the closest pre-traversal work range that starts before the traversal. ```javascript function getFrameStartTime(traversalStart,preTraversalWorkRanges){ const preTraversalWorkRange=tr.b.findClosestIntervalInSortedIntervals(preTraversalWorkRanges,function(range){return range.start;},function(range){return range.end;},traversalStart,3); if(preTraversalWorkRange){ return preTraversalWorkRange.start; } return traversalStart; } ``` -------------------------------- ### Build a sample project to interop with a Go library Source: https://github.com/dart-lang/sdk/blob/main/docs/gsoc/Dart-GSoC-2023-Project-Ideas.md This is a suggested sample project for the GOgen idea. It involves building a small project to demonstrate interop with a Go library. ```dart Build a small sample project where you interop with a Go library. (2) Build a prototype for generating the bindings for that library, and (3) use a Go parser to generate those bindings. ``` -------------------------------- ### Get V8 Source Code and Build Source: https://github.com/dart-lang/sdk/blob/main/pkg/dart2wasm/docs/v8.md Use this command sequence to fetch the V8 source code and perform an initial build. Ensure `depot_tools` is in your PATH. ```bash % mkdir v8-gclient && cd v8-gclient v8-gclient % fetch v8 && cd v8 v8-gclient/v8 % tools/dev/gm.py x64.release d8 wami ... ``` -------------------------------- ### Compare Events by Time and GUID in JavaScript Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Compares two event objects based on their start and end times, and then by GUID if available. This is crucial for stable sorting of events. ```javascript function compareEvents(x,y){ if(x.start!==y.start){ return x.start-y.start; } if(x.end!==y.end){ return x.end-y.end; } if(x.guid&&y.guid){ return x.guid-y.guid; } return 0; } ``` -------------------------------- ### Initialize Help Button Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Sets up the help button, which toggles the visibility of an overlay containing help information. The overlay is created as a tr.ui.b.Overlay element. ```javascript initHelpButton_(){ const helpButtonEl=this.$.view_help_button; const dlg=new tr.ui.b.Overlay(); dlg.title='Chrome Tracing Help'; dlg.visible=false; dlg.appendChild(document.createElement('tr-ui-timeline-view-help-overlay')); function onClick(e){ dlg.visible=!dlg.visible; e.stopPropagation(); } helpButtonEl.addEventListener('click',onClick.bind(this)); } ``` -------------------------------- ### Get Navigation Start Timestamps Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Extracts navigation start timestamps from trace events. Filters events by title 'navigationStart' and category 'blink.user_timing'. Requires a renderer helper object. ```javascript function getNavStartTimestamps(rendererHelper) { const navStartTimestamps = []; for (const e of rendererHelper.mainThread.sliceGroup.childEvents()) { if (hasTitleAndCategory(e, 'navigationStart', 'blink.user_timing')) { navStartTimestamps.push(e.start); } } return navStartTimestamps; } ``` -------------------------------- ### Get SPA Navigation Start Candidates in Dart Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Identifies potential SPA navigation start events from both renderer and browser helpers. It filters events based on specific titles and categories. ```dart const HANDLE_INPUT_EVENT_TITLE='WebViewImpl::handleInputEvent';function getSpaNavigationStartCandidates_(rendererHelper,browserHelper){const isNavStartEvent=e=>{if(e.title===HANDLE_INPUT_EVENT_TITLE&&e.args.type==='MouseUp'){return true;} return e.title==='NavigationControllerImpl::GoToIndex';};return[...rendererHelper.mainThread.sliceGroup.getDescendantEvents(),...browserHelper.mainThread.sliceGroup.getDescendantEvents()].filter(isNavStartEvent);} ``` -------------------------------- ### Setup Component Configuration Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Initializes the component's configuration object and handler array. Use when creating a new component instance. ```javascript this._setupConfigure:function(initialConfig){this._config={};this._handlers=[]this._aboveConfig=null;if(initialConfig){for(var i in initialConfig){if(initialConfig[i]!==undefined){this._config[i]=initialConfig[i];}}}} ``` -------------------------------- ### D3.js Transition Delay Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Sets or gets the delay before a transition starts. Can be a fixed value or a function. ```javascript Ns.delay=function(n){var t=this.id;return R(this,"function"==typeof n?function(e,r,u){e.__transition__[t].delay=+n.call(e,e.__data__,r,u)}:(n=+n,function(e){e.__transition__[t].delay=n}))} ``` -------------------------------- ### Serve Observatory Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/README.md Execute this command to serve the Observatory tool. Use the --launch flag to automatically open it in Chrome. ```bash observatory ``` ```bash observatory --launch ``` -------------------------------- ### Get Field Name Node Source: https://github.com/dart-lang/sdk/blob/main/pkg/analysis_server/doc/implementation/quick_fix.md Retrieves the AST node for the field name. This is the starting point for fix computation. ```dart var fieldName = node; ``` -------------------------------- ### Test RISC-V 32 with QEMU Source: https://github.com/dart-lang/sdk/blob/main/runtime/docs/riscv32.md Configure QEMU's dynamic linker prefix using QEMU_LD_PREFIX and then use test.py to run tests for riscv32 architecture with QEMU. This example specifically targets FFI tests and generates ELF snapshots. ```bash export QEMU_LD_PREFIX="$RV32_TOOLCHAIN/riscv32-buildroot-linux-gnu/sysroot" ./tools/test.py -mrelease -ariscv32 --use-qemu --gen-snapshot-format=elf -cdartk,dartkp -t900 ffi ``` -------------------------------- ### Get SPA Navigation Event to Navigation Start Map in Dart Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Maps SPA navigation events to their corresponding navigation start candidates and input latency events. This function is part of a larger process for analyzing navigation performance. ```dart function getSpaNavigationEventToNavigationStartMap_(rendererHelper,browserHelper){const mainThread=rendererHelper.mainThread;const spaNavEvents=getSpaNavigationEvents_(rendererHelper);const navStartCandidates=getSpaNavigationStartCandidates_(rendererHelper,browserHelper).sort(tr.importer.compareEvents);const spaNavEventToNavStartCandidateMap=findPrecedingEvents_(spaNavEvents,navStartCandidates);const inputLatencyEventByBindIdMap=getInputLatencyEventByBindIdMap_(browserHelper);const spaNavEventToNavStartEventMap=new Map();for(const[spaNavEvent,navStartCandidate]of spaNavEventToNavStartCandidateMap){if(navStart ``` -------------------------------- ### Sort Rasterizer Slices Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Sorts rasterizer slices based on their start time and then by GUID. This is a utility function for organizing rasterization tasks. ```dart sortRasterizerSlices(rasterWorkerThreads,sortedRasterizerSlices){rasterWorkerThreads.forEach(function(rasterizer){Array.prototype.push.apply(sortedRasterizerSlices,rasterizer.sliceGroup.slices);},this);sortedRasterizerSlices.sort(function(a,b){if(a.start!==b.start){return a.start-b.start;} return a.guid-b.guid;});} ``` -------------------------------- ### Launch Coverage Server Tool Source: https://github.com/dart-lang/sdk/blob/main/pkg/dart2js_info/README.md Start the coverage server tool to serve the JavaScript code of your application. This is a step in setting up coverage analysis. ```bash $ dart bin/tools.dart coverage_server main.dart.js ``` -------------------------------- ### Find Next Slice After Timestamp in Dart Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Finds the next slice that starts after a given timestamp, optionally considering a reference GUID to skip slices. ```dart findNextSliceAfter(ts,refGuid){let i=tr.b.findLowIndexInSortedArray(this.slices,getSliceLo,ts);if(i===this.slices.length){return undefined;} for(;its)return slice;if(slice.guid<=refGuid)continue;return slice;} return undefined;} ``` -------------------------------- ### Prepare Local Web Server Document Root Source: https://github.com/dart-lang/sdk/blob/main/pkg/compiler/test/codesize/swarm/appengine/dev.html Navigate to the web server's document root, remove old data if necessary, unzip new data, and set read/write permissions. This prepares the directory for serving local files. ```bash pushd /Library/WebServer/Document # If you are replacing old data: # rm -rf data/ unzip ~/Downloads/CannedData.zip chmod -R +rw data ``` -------------------------------- ### Layout: Get Deepest Leftmost Node Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Recursively finds the leftmost node at the deepest level of a tree. Useful for determining the starting point of a layout. ```javascript function Ni(n){var t=n.children;return t&&t.length?Ni(t[0]):n} ``` -------------------------------- ### Dart FFI SQLite Error Example Source: https://github.com/dart-lang/sdk/blob/main/samples/ffi/sqlite/README.md This error message indicates that the SQLite dynamic library could not be loaded. Ensure the SQLite development library is installed on your system. ```text Unhandled exception: Invalid argument(s): Failed to load dynamic library (126) #0 _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:13:55) #1 new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:22:12) ``` -------------------------------- ### Install QEMU and Cross-Architecture Libraries Source: https://github.com/dart-lang/sdk/blob/main/docs/Building-Dart-SDK-for-ARM-or-RISC-V.md Installs QEMU user-mode emulator and necessary cross-architecture C libraries for testing Dart VM on different architectures without hardware. This is required for running tests using QEMU. ```bash $ sudo apt install qemu-user libc6-armhf-cross libc6-arm64-cross libc6-riscv64-cross ``` -------------------------------- ### List Available Benchmarks Source: https://github.com/dart-lang/sdk/blob/main/pkg/analysis_server/benchmark/readme.md Run this command to see a list of all available benchmarks. ```bash dart benchmark/benchmarks.dart list ``` -------------------------------- ### EventRef Class Definition Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html A lightweight reference class for events, storing essential details like stable ID, title, start time, and duration. It generates a unique GUID for each instance. ```javascript 'use strict'; tr.exportTo('tr.v.d',function(){ class EventRef{ constructor(event){ this.stableId=event.stableId; this.title=event.title; this.start=event.start; this.duration=event.duration; this.end=this.start+this.duration; this.guid=tr.b.GUID.allocateSimple(); } } return{EventRef,}; }); ``` -------------------------------- ### Get Event Endpoints Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Generates an array of endpoint objects (time and type) for a given list of events, marking the start and end of each event. Used for network and long task analysis. ```javascript function getEndpoints_(events,startType,endType){const endpoints=[];for(const event of events){endpoints.push({time:event.start,type:startType});endpoints.push({time:event.end,type:endType});} return endpoints;} ``` -------------------------------- ### Run Dart VM with QEMU Source: https://github.com/dart-lang/sdk/blob/main/runtime/docs/qemu.md Install necessary packages and build the Dart VM for ARM64. Then, run a Dart program using QEMU, specifying the QEMU interpreter and the path to the cross-architecture dynamic linker prefix. ```bash $ sudo apt install qemu-user libc6-arm64-cross $ tools/build.py --arch arm64 runtime runtime_precompiled $ QEMU_LD_PREFIX=/usr/aarch64-linux-gnu/ qemu-aarch64 out/DebugXARM64/dartvm hello.dart.dill ``` -------------------------------- ### Dart 'And' Combiner Node Example Source: https://github.com/dart-lang/sdk/blob/main/pkg/compiler/doc/split_constraints.md Demonstrates deferred loading with 'and' combiner logic where the order of loading libraries might vary. This setup allows Dart2js to merge shared code between 'step1a' and 'step1b' and their respective successors/predecessors. ```dart import '...' deferred as step1a; import '...' deferred as step1b; do() { if (...) { step1a.loadLibrary().then((_) { step1b.loadLibrary().then(...) } ); } else { step1b.loadLibrary().then((_) { step1a.loadLibrary().then(...) } ); } } ``` ```yaml ... - type: and name: step1 nodes: - step1a - step1b ... ``` -------------------------------- ### Example Grouping Configuration YAML Source: https://github.com/dart-lang/sdk/blob/main/pkg/dart2js_info/README.md An example YAML file for configuring library grouping in the size split tool. It demonstrates various ways to define groups, including using regular expressions to extract names and specifying cluster indices. ```yaml groups: # This group shows the total size for all libraries that were loaded from # file:// urls, it is shown in cluster #2, which happens to be the last # cluster in this example before the totals are shown: - name: "Loose files" regexp: "file://.*" cluster: 2 # This group shows the total size of all code loaded from packages: - { name: "All packages", regexp: "package:.*", cluster: 2} # This group shows the total size of all code loaded from core libraries: - { name: "Core libs", regexp: "dart:.*", cluster: 2} # This group shows the total size of all libraries in a single package. Here # we omitted the `name` entry, instead we extract it from the regexp # directly. In this case, the name will be the package-name portion of the # package-url (determined by group(1) of the regexp). - { regexp: "package:([^/]*)", cluster: 1} # The next two groups match the entire library url as the name of the group. - regexp: "package:.*" - regexp: "dart:.*" # If your code lives under /my/project/dir, this will match any file loaded from a file:// url, and we use as a name the relative path to it. - regexp: "file:///my/project/dir/(.*)" ``` -------------------------------- ### Get Lock Contention Alert Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Generates an alert for UI thread lock contention if the blocked duration exceeds 1 millisecond. Filters events by titles starting with 'Lock Contention on '. Requires associated events related to lock contention. ```javascript AndroidAuditor.getLockContentionAlert_ = function(frame) { const events = frame.associatedEvents.filter(function(event) { return /^Lock Contention on /.test(event.title); }); const blockedDuration = Statistics.sum(events, getDuration); if (blockedDuration < 1) return undefined; const start = Statistics.min(events, getStart); events.push(frame); return new Alert(AndroidAuditor.lockContentionAlertInfo_, start, events, { 'Blocked duration': new Scalar(timeDurationInMs, blockedDuration) }); }; ``` -------------------------------- ### Install Specific Alpine Linux Sysroots Source: https://github.com/dart-lang/sdk/blob/main/build/linux/alpine_sysroot_scripts/README.md Specify the desired architectures when running the install script to customize the sysroot installation. ```sh ./build/linux/alpine_sysroot_scripts/install-sysroot.sh aarch64 riscv64 x86_64 ... ``` -------------------------------- ### Build Wiki for Deployment Source: https://github.com/dart-lang/sdk/blob/main/runtime/tools/wiki/README.md Execute this command to build the wiki for deployment. This command also handles the generation of reference sections for C++ symbols and files if present in the markdown. ```shell runtime/tools/wiki/build/build.py --deploy ``` -------------------------------- ### Client Initialization with Experimental Commands Source: https://github.com/dart-lang/sdk/blob/main/pkg/analysis_server/tool/lsp_spec/README.md Clients must declare support for experimental commands during initialization by listing them in the 'experimental.commands' field of their capabilities. ```js { // ... other client capabilities "experimental": { "commands": [ "dart.goToLocation", ] } } ``` -------------------------------- ### Fix Response Animation Starts Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Adjusts the start time of animation ProtoExpectations to align with the end time of intersecting response ProtoExpectations. Filters out impl frame events that start before the new animation start time. ```javascript function fixResponseAnimationStarts(protoExpectations){protoExpectations.forEach(function(ape){if(ape.type!==ProtoExpectation.ANIMATION_TYPE){return;} protoExpectations.forEach(function(rpe){if(rpe.type!==ProtoExpectation.RESPONSE_TYPE){return;} if(!ape.containsTimestampInclusive(rpe.end)){return;} if(ape.containsTimestampInclusive(rpe.start)){return;} ape.start=rpe.end;if(ape.associatedEvents!==undefined){ape.associatedEvents=ape.associatedEvents.filter(e=>(!isImplFrameEvent(e)||e.start>=ape.start));}});});return protoExpectations;} ``` -------------------------------- ### Initialize Binary Size Analysis UI Source: https://github.com/dart-lang/sdk/blob/main/pkg/vm_snapshot_analysis/lib/src/assets/index.html Initializes the UI for binary size analysis, setting up the subtitle and the D3 treemap visualization. Requires window.metadata to be defined. ```javascript function init() { if (window.metadata !== undefined && window.metadata.subtitle) { document.getElementById('subtitle').innerHTML = ': ' + escape(metadata.subtitle); } initFilterOptions(); treemap = new D3SymbolTreeMap( savedSettings.width, savedSettings.height, savedSettings.maxLevels); treemap.init(); } ``` -------------------------------- ### Build Perfetto Tools Source: https://github.com/dart-lang/sdk/blob/main/third_party/perfetto/README.md Clone the Perfetto repository, checkout the required revision, install build dependencies, configure build arguments, and compile the protoc and protozero_plugin tools. ```bash $ git clone https://github.com/google/perfetto $ cd perfetto $ git checkout $perfetto_rev_from_DEPS $ tools/install-build-deps $ gn args out/linux $ ninja -C out/linux protoc protozero_plugin ``` -------------------------------- ### streamListen Request Example Source: https://github.com/dart-lang/sdk/blob/main/runtime/vm/service/service.md Example of a streamListen RPC request, demonstrating how to provide parameters. ```APIDOC ## streamListen Request Example ### Description Example of a streamListen RPC request, demonstrating how to provide parameters. ### Method POST (typically) ### Endpoint / ### Request Body Example ```json { "jsonrpc": "2.0", "method": "streamListen", "params": { "streamId": "GC" }, "id": "2" } ``` ### Parameters - **jsonrpc** (string) - Required - Specifies the JSON-RPC protocol version. - **method** (string) - Required - The name of the method to be invoked (e.g., "streamListen"). - **params** (object) - Required - An object containing named parameters for the method. - **streamId** (string) - Required - The identifier of the stream to listen to (e.g., "GC"). - **id** (string | number | null) - Required - An identifier established by the client to match the request with the response. ``` -------------------------------- ### Run FFI Tests with QEMU Source: https://github.com/dart-lang/sdk/blob/main/runtime/docs/qemu.md Install cross-compilation packages for ARM and RISC-V. Build the Dart VM with snapshot generation for the simulator and runtime. Finally, execute FFI tests using the test runner, specifying QEMU, compilation modes, snapshot format, and architecture flags. ```bash $ sudo apt install qemu-user libc6-armhf-cross libc6-arm64-cross libc6-riscv64-cross $ ./tools/build.py --arch simarm_x64 gen_snapshot $ ./tools/build.py --arch arm,arm64,riscv64,simarm64_arm64 runtime runtime_precompiled $ ./tools/test.py --arch arm,arm64,riscv64,simarm64_arm64 --use-qemu --compiler dartk,dartkp --gen-snapshot-format elf --timeout 500 ffi ``` -------------------------------- ### Dart Diagnostic Description Example Source: https://github.com/dart-lang/sdk/blob/main/pkg/analyzer/doc/implementation/diagnostics.md Example of a description for a Dart diagnostic, explaining when it's produced and why. ```dart > The analyzer produces this diagnostic when an extension override doesn't > have exactly one argument. > The argument is the expression used to compute the value of `this` within the > extension method, so there must be one argument. ``` -------------------------------- ### Create Dart Test Script Source: https://github.com/dart-lang/sdk/blob/main/docs/Building-the-Dart-VM-for-Android.md Create a simple Dart script that prints 'Hello, world!' to the console. This script will be used to test the Dart VM on the emulator. ```bash $ echo "main(){ print(\"Hello, world!\");}" >hello.dart ``` -------------------------------- ### workspace/startLanguageServer Source: https://github.com/dart-lang/sdk/blob/main/pkg/dartpad/doc/worker-protocol.md Starts a language server instance for the workspace. ```APIDOC ## Method workspace/startLanguageServer ### Description Start a language-server. ### Method POST ### Endpoint /workspace/startLanguageServer ### Parameters #### Request Body - **workspaceId** (number) - Required - The ID of the workspace. ### Response #### Success Response (200) - **languageServerId** (number) - Required - Identifier for the language-server just started. ``` -------------------------------- ### Source File and Line Starts Source: https://github.com/dart-lang/sdk/blob/main/pkg/dart2bytecode/docs/bytecode.md Defines the structure for source files, including flags indicating the presence of line starts, source content, and const constructor coverage. It also details the encoding of line start offsets. ```dart type SourceFile { UInt flags = (hasLineStarts, hasSource, hasConstConstructorCoverageFlag) PackedObject importUri; if hasLineStarts // Offset of line starts in ‘lineStarts’ section of BytecodeFile. UInt lineStartsOffset; if hasSource PackedString source; if hasConstConstructorCoverageFlag List coveredConstConstructors; } type LineStarts { // Can be also treated as line lengths. List deltaEncodedLineStarts; } ``` -------------------------------- ### Build with Bazel Source: https://github.com/dart-lang/sdk/blob/main/third_party/double-conversion/README.md Build the library or run unit tests using Bazel commands. The library is available through the Bazel Central Registry. ```bash bazel build //:double-conversion ``` ```bash bazel test //:cctest ``` -------------------------------- ### Install dartdoc tool Source: https://github.com/dart-lang/sdk/blob/main/pkg/dart2js_info/DEVELOPER.md Ensure the dartdoc tool is installed globally. This is required for generating API documentation. ```bash pub global activate dartdoc ``` -------------------------------- ### Build and Test Dart SDK (Precompilation) Source: https://github.com/dart-lang/sdk/blob/main/docs/Testing-the-VM.md Build and test the Dart SDK with precompilation enabled for faster startup times. ```bash ./tools/build.py -mrelease runtime_precompiled ``` ```bash ./tools/test.py -mrelease -cprecompiler -rdart_precompiled ``` -------------------------------- ### Ready Component Clients Source: https://github.com/dart-lang/sdk/blob/main/pkg/observatory/web/third_party/trace_viewer_full.html Iterates through the component's clients and calls their respective '_ready()' methods, ensuring they are initialized. ```javascript this._readyClients=function(){this._beginDistribute();var c$=this._clients;if(c$){for(var i=0,l=c$.length,c;istartNotBefore+MAX_DRAW_DELAY_IN_MS)continue;if(slice.title!=='draw')continue;if(drawSlice===undefined||slice.start