@@ -1125,7 +1125,7 @@ Using canonical function definitions, we can finally write a non-trivial
1125
1125
component that takes a string, does some logging, then returns a string.
1126
1126
``` wasm
1127
1127
(component
1128
- (import "wasi:logging" (instance $logging
1128
+ (import "logging" (id " wasi:logging") (instance $logging
1129
1129
(export "log" (func (param string)))
1130
1130
))
1131
1131
(import "libc" (core module $Libc
@@ -1300,7 +1300,7 @@ Lastly, imports and exports are defined as:
1300
1300
```
1301
1301
import ::= (import <externname> bind-id(<externdesc>))
1302
1302
export ::= (export <id>? <externname> <sortidx> <externdesc>?)
1303
- externname ::= <name> <URL>?
1303
+ externname ::= <name> (id <URL>) ?
1304
1304
```
1305
1305
Both import and export definitions append a new element to the index space of
1306
1306
the imported/exported ` sort ` which can be optionally bound to an identifier in
@@ -1341,12 +1341,12 @@ externally define a type compatible with the exports of the component.
1341
1341
1342
1342
Components split the single externally-visible name of imports and exports into
1343
1343
two sub-fields: a kebab-case ` name ` (as defined [ above] ( #instance-definitions ) )
1344
- and a ` URL ` ( defined by the [ URL Standard] , noting that, in this URL Standard,
1345
- the term "URL" subsumes what has historically been called a [ URI ] , including
1346
- URLs that "identify" as opposed to "locate"). This subdivision of external
1347
- names allows component producers to represent a variety of intentions for how a
1348
- component is to be instantiated and executed so that a variety of hosts can
1349
- portably execute the component.
1344
+ and an ` id ` field that contains a URL (as defined by the [ URL Standard] , noting
1345
+ that, in this URL Standard, the term "URL" subsumes what has historically been
1346
+ called a [ URI ] , including URLs that "identify" as opposed to "locate"). This
1347
+ subdivision of external names allows component producers to represent a variety
1348
+ of intentions for how a component is to be instantiated and executed so that a
1349
+ variety of hosts can portably execute the component.
1350
1350
1351
1351
The ` name ` field of ` externname ` is required to be unique. Thus, a single
1352
1352
` name ` has been used in the preceding definitions of ` with ` and ` alias ` to
@@ -1383,7 +1383,7 @@ and accessing its exports. For example, the [JS API]'s
1383
1383
[ ` WebAssembly.instantiate() ` ] would use import ` name ` s in the [ * read the
1384
1384
imports* ] step and use export ` name ` s in the [ * create an exports object* ] step.
1385
1385
1386
- The optional ` URL ` field of ` externname ` allows a component author to refer to
1386
+ The optional ` id ` field of ` externname ` allows a component author to refer to
1387
1387
an * externally-defined* specification of what an import "wants" or what an
1388
1388
export has "implemented". One example is a URL naming a standard interface such
1389
1389
as ` wasi:filesystem ` (assuming that WASI registered the ` wasi: ` URI scheme with
@@ -1396,48 +1396,48 @@ components, the Component Model doesn't specify how URLs are to be interpreted,
1396
1396
just that they are grammatically URLs. Even ` https: ` URLs may or may not be
1397
1397
literally fetched by the host (c.f. [ import maps] ).
1398
1398
1399
- When present, ` URL ` s must * also* be unique (* in addition* the abovementioned
1400
- uniqueness of ` name ` s). Thus, a ` URL ` can * also* be used to uniquely identify
1401
- the subset of imports or exports that have ` URL ` s .
1399
+ The URLs of present ` id ` fields must * also* be unique (* in addition* the
1400
+ abovementioned uniqueness of ` name ` s). Thus, a URL can * also* be used to
1401
+ uniquely identify the subset of imports or exports that have URLs .
1402
1402
1403
- While the ` name ` field is meant for source-code bindings generators, the ` URL `
1403
+ While the ` name ` field is meant for source-code bindings generators, the ` id `
1404
1404
field is meant for automated interpretation by hosts and toolchains. In
1405
1405
particular, hosts are expected to identify their host-implemented imports and
1406
- host-called exports by ` URL ` , not ` name ` . This allows hosts to implement a
1406
+ host-called exports by URL, not ` name ` . This allows hosts to implement a
1407
1407
wide collection of independently-developed interfaces where ` name ` s are chosen
1408
1408
for developer ergonomics (and name collisions are handled independently in
1409
- the binding generators, which is needed in any case) and ` URL ` s serve as
1409
+ the binding generators, which is needed in any case) and URLs to serve as
1410
1410
the invariant identifier that concretely links the guest to host. If there was
1411
1411
only a ` name ` , interface authors would be forced to implicitly coordinate
1412
1412
across the ecosystem to avoid collisions (which in general, isn't possible)
1413
- while if there was only a ` URL ` , the developer-friendly identifiers would have
1413
+ while if there was only a URL, the developer-friendly identifiers would have
1414
1414
to be specified manually by every developer or derived in an ad hoc fashion
1415
- from the ` URL ` , whose contents may vary widely. This dual-name scheme is thus
1415
+ from the URL, whose contents may vary widely. This dual-name scheme is thus
1416
1416
proposed to resolve these competing requirements.
1417
1417
1418
1418
Inside the component model, this dual-name scheme shows up in [ subtyping] ( #Subtyping.md ) ,
1419
- where the component subtyping simply ignores the ` name ` field when the ` URL `
1419
+ where the component subtyping simply ignores the ` name ` field when the ` id `
1420
1420
field is present. For example, the component:
1421
1421
```
1422
1422
(component
1423
- (import "fs" "wasi:filesystem" ...)
1423
+ (import "fs" (id "wasi:filesystem") ...)
1424
1424
)
1425
1425
```
1426
1426
can be supplied for the ` x ` import of the component:
1427
1427
```
1428
1428
(component
1429
1429
(import "x" (component
1430
- (import "filesystem" "wasi:filesystem" ...)
1430
+ (import "filesystem" (id "wasi:filesystem") ...)
1431
1431
))
1432
1432
)
1433
1433
```
1434
- because the ` name ` s are ignored and the ` URL ` s match. This subtyping is
1434
+ because the ` name ` s are ignored and the ` id ` s match. This subtyping is
1435
1435
symmetric to what was described above for hosts, allowing components to
1436
1436
serve as the "host" of other components, enabling [ virtualization] ( examples/LinkTimeVirtualization.md ) .
1437
1437
1438
1438
Since the concrete artifacts defining the host/guest interface is a collection
1439
1439
of [ Wit files] ( WIT.md ) , Wit must naturally allow interface authors to specify
1440
- both the ` name ` and ` URL ` of component imports and exports. While the syntax is
1440
+ both the ` name ` and ` id ` of component imports and exports. While the syntax is
1441
1441
still very much [ in flux] ( https://github.com/WebAssembly/component-model/pull/83 ) ,
1442
1442
a hypothetical simplified interface between a guest and host might look like:
1443
1443
```
@@ -1453,9 +1453,9 @@ defined interfaces that map to instance types. This "World" definition then
1453
1453
maps to the following component type:
1454
1454
```
1455
1455
(component $Command
1456
- (import "fs" "wasi:filesystem" (instance ... filesystem function exports ...))
1457
- (import "console" "wasi:cli/console" (instance ... log function exports ...))
1458
- (export "main" "wasi:cli/main" (instance (export "main" (func ...))))
1456
+ (import "fs" (id "wasi:filesystem") (instance ... filesystem function exports ...))
1457
+ (import "console" (id "wasi:cli/console") (instance ... log function exports ...))
1458
+ (export "main" (id "wasi:cli/main") (instance (export "main" (func ...))))
1459
1459
)
1460
1460
```
1461
1461
A component * targeting* ` wasi:cli/Command ` would thus need to be a * subtype* of
@@ -1467,10 +1467,10 @@ to call a subset of these exports).
1467
1467
Importantly, this ` wasi:cli/Command ` World has been able to define the short
1468
1468
developer-facing names like ` fs ` and ` console ` without worrying if there are
1469
1469
any other Worlds that conflict with these names. If a host wants to implement
1470
- ` wasi:cli/Command ` and some other World that also happens to pick ` fs ` , either
1471
- the ` URL ` fields are the same, and so the two imports can be unified, or the
1472
- ` URL ` fields are different, and the host supplies two distinct imports,
1473
- identified by ` URL ` .
1470
+ ` wasi:cli/command ` and some other World that also happens to pick ` fs ` , either
1471
+ the ` id ` fields are the same, and so the two imports can be unified, or the
1472
+ ` id ` fields are different, and the host supplies two distinct imports,
1473
+ identified by URL.
1474
1474
1475
1475
1476
1476
## Component Invariants
0 commit comments