作用域
【Scopes】
使用清单的 "scopes" 字段可以一次为多个资源设置配置。"scopes" 字段通过按段匹配资源来工作。如果某个作用域或资源包含 "cascade": true,未知的说明符将会在其包含的作用域中进行搜索。用于级联的包含作用域是通过递归地减少资源 URL 来找到的,方法是删除段(例如 特别计划),保留尾部的 "/" 后缀,并删除查询参数和哈希片段。这样最终会将 URL 缩减到其源。如果 URL 是非特殊的,作用域将通过 URL 的源来定位。如果找不到源的作用域,或者对于不透明源的情况,可以使用协议字符串作为作用域。如果找不到 URL 协议的作用域,则最终会使用空字符串 "" 作为作用域。
【Use the "scopes" field of a manifest to set configuration for many resources
at once. The "scopes" field works by matching resources by their segments.
If a scope or resource includes "cascade": true, unknown specifiers will
be searched for in their containing scope. The containing scope for cascading
is found by recursively reducing the resource URL by removing segments for
special schemes, keeping trailing "/" suffixes, and removing the query and
hash fragment. This leads to the eventual reduction of the URL to its origin.
If the URL is non-special the scope will be located by the URL's origin. If no
scope is found for the origin or in the case of opaque origins, a protocol
string can be used as a scope. If no scope is found for the URL's protocol, a
final empty string "" scope will be used.】
注意,blob: URL 的来源取自其包含的路径,因此作用域
"blob:https://nodejs.cn" 将没有效果,因为没有 URL 可以具有 blob:https://nodejs.cn 的来源;以 blob:https://nodejs.cn/ 开头的 URL 将使用 https://nodejs.cn 作为其来源,因此 https: 作为其协议作用域。对于不透明来源的 blob: URL,它们将使用 blob: 作为其协议作用域,因为它们不会采用来源。
【Note, blob: URLs adopt their origin from the path they contain, and so a scope
of "blob:https://nodejs.cn" will have no effect since no URL can have an
origin of blob:https://nodejs.cn; URLs starting with
blob:https://nodejs.cn/ will use https://nodejs.cn for its origin and
thus https: for its protocol scope. For opaque origin blob: URLs they will
have blob: for their protocol scope since they do not adopt origins.】