Expose experimental dynamic modules API through package:dynamic_modules

Change-Id: I14963de5f6face564276955d21d63f4b038cf990
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378722
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
Alexander Markov
2024-08-12 17:56:29 +00:00
committed by Commit Queue
parent b92aeae794
commit 531a4c8f62
6 changed files with 60 additions and 1 deletions
+4
View File
@@ -0,0 +1,4 @@
set noparent
file:/tools/OWNERS_VM
file:/tools/OWNERS_WEB
file:/OWNERS
+9
View File
@@ -0,0 +1,9 @@
This package contains experimental dynamic modules API.
## Status: experimental
**NOTE**: This package is currently experimental and not published or
included in the SDK.
Do not take dependency on this package unless you are prepared for
breaking changes and possibly removal of this code at any point in time.
@@ -0,0 +1,9 @@
# Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
include: package:lints/recommended.yaml
analyzer:
errors:
import_internal_library: ignore
@@ -0,0 +1,30 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:typed_data' show Uint8List;
import 'dart:_internal' as internal;
/// Load a dynamic module from [uri] and execute its entry point method.
///
/// Entry point method is a no-argument method annotated with
/// `@pragma('dyn-module:entry-point')`.
///
/// This API is experimental, can be changed or removed
/// without a notice.
///
/// Returns a future containing the result of the entry point method.
Future<Object?> loadModuleFromUri(Uri uri) =>
internal.loadDynamicModule(uri: uri);
/// Load a dynamic module from [bytes] and execute its entry point method.
///
/// Entry point method is a no-argument method annotated with
/// `@pragma('dyn-module:entry-point')`.
///
/// This API is experimental, can be changed or removed
/// without a notice.
///
/// Returns a future containing the result of the entry point method.
Future<Object?> loadModuleFromBytes(Uint8List bytes) =>
internal.loadDynamicModule(bytes: bytes);
+6
View File
@@ -0,0 +1,6 @@
name: dynamic_modules
# This package is not intended for consumption on pub.dev. DO NOT publish.
publish_to: none
environment:
sdk: '>=3.3.0 <4.0.0'
+2 -1
View File
@@ -347,7 +347,8 @@ abstract class Target {
bool allowPlatformPrivateLibraryAccess(Uri importer, Uri imported) =>
importer.isScheme("dart") ||
(importer.isScheme("package") &&
importer.path.startsWith("dart_internal/"));
(importer.path.startsWith("dart_internal/") ||
importer.path.startsWith("dynamic_modules/")));
/// Whether the `native` language extension is supported within the library
/// with the given import [uri].