Skip to content

Commit 531a4c8

Browse files
alexmarkovCommit Queue
authored and
Commit Queue
committed
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 <[email protected]> Reviewed-by: Bob Nystrom <[email protected]> Commit-Queue: Alexander Markov <[email protected]> Reviewed-by: Slava Egorov <[email protected]> Reviewed-by: Sigmund Cherem <[email protected]>
1 parent b92aeae commit 531a4c8

File tree

6 files changed

+60
-1
lines changed

6 files changed

+60
-1
lines changed

pkg/dynamic_modules/OWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
set noparent
2+
file:/tools/OWNERS_VM
3+
file:/tools/OWNERS_WEB
4+
file:/OWNERS

pkg/dynamic_modules/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
This package contains experimental dynamic modules API.
2+
3+
## Status: experimental
4+
5+
**NOTE**: This package is currently experimental and not published or
6+
included in the SDK.
7+
8+
Do not take dependency on this package unless you are prepared for
9+
breaking changes and possibly removal of this code at any point in time.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
# for details. All rights reserved. Use of this source code is governed by a
3+
# BSD-style license that can be found in the LICENSE file.
4+
5+
include: package:lints/recommended.yaml
6+
7+
analyzer:
8+
errors:
9+
import_internal_library: ignore
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:typed_data' show Uint8List;
6+
import 'dart:_internal' as internal;
7+
8+
/// Load a dynamic module from [uri] and execute its entry point method.
9+
///
10+
/// Entry point method is a no-argument method annotated with
11+
/// `@pragma('dyn-module:entry-point')`.
12+
///
13+
/// This API is experimental, can be changed or removed
14+
/// without a notice.
15+
///
16+
/// Returns a future containing the result of the entry point method.
17+
Future<Object?> loadModuleFromUri(Uri uri) =>
18+
internal.loadDynamicModule(uri: uri);
19+
20+
/// Load a dynamic module from [bytes] and execute its entry point method.
21+
///
22+
/// Entry point method is a no-argument method annotated with
23+
/// `@pragma('dyn-module:entry-point')`.
24+
///
25+
/// This API is experimental, can be changed or removed
26+
/// without a notice.
27+
///
28+
/// Returns a future containing the result of the entry point method.
29+
Future<Object?> loadModuleFromBytes(Uint8List bytes) =>
30+
internal.loadDynamicModule(bytes: bytes);

pkg/dynamic_modules/pubspec.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: dynamic_modules
2+
# This package is not intended for consumption on pub.dev. DO NOT publish.
3+
publish_to: none
4+
5+
environment:
6+
sdk: '>=3.3.0 <4.0.0'

pkg/kernel/lib/target/targets.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ abstract class Target {
347347
bool allowPlatformPrivateLibraryAccess(Uri importer, Uri imported) =>
348348
importer.isScheme("dart") ||
349349
(importer.isScheme("package") &&
350-
importer.path.startsWith("dart_internal/"));
350+
(importer.path.startsWith("dart_internal/") ||
351+
importer.path.startsWith("dynamic_modules/")));
351352

352353
/// Whether the `native` language extension is supported within the library
353354
/// with the given import [uri].

0 commit comments

Comments
 (0)