@blockcast/multicast-browser
被冻结 v1 的浏览器 / 扩展 / IWA 适配器 window.multicast
合同(@blockcast/multicast-contract) (中文(简体) ).
合约包是故意的 纯 叶: evaluateReadiness 是一个
纯函数为调用观测,网关表面为类型
只有这个 一定有东西把它绑在一个真正的浏览器域里, 直到这个软件包
合同是零消费者的 这是约束,和
仅此而已:
| 任务 | 进入点 |
|---|---|
解析已安装的提供者 MulticastGateway | getGateway, (中文(简体) ), hasGateway |
收集事实 evaluateReadiness 消耗量 | observeReadiness 及其组成部分 |
| 在浏览器域中运行合同兼容套件 | createBrowserConformanceDriver |
一个依赖,只消费类型
@blockcast/multicast-contract 是唯一一个输入 dependencies,这是
本身没有依赖性。 它被宣布为 npm install @blockcast/multicast-browser 解析此软件包所释放的类型 .d.ts
名字,没有它,一个消费者得到 TS2307。 。 。 .
运行时没有进口货物:合同已耗尽 只类型,所以请
释放的联署材料完全没有光谱。 这就是保持私人
运输从永远通过公众实现
表面。 运出源的测试针 import typeCI车道把它钉住
重新显示已建输出.
使用量
import { evaluateReadiness } from '@blockcast/multicast-contract';
import { getGateway, observeReadiness } from '@blockcast/multicast-browser';
const gateway = getGateway();
if (gateway === null) {
// Not an exception — an absent provider is the expected state on most pages.
const readiness = evaluateReadiness(
await observeReadiness({ extensionDeadlineElapsed: true }),
);
console.warn(readiness.code, readiness.detail); // e.g. 'provider-absent'
} else {
const subscription = await gateway.subscribe(config);
}
这里没有提示, 捐赠,或打开窗口。 设置 UX 留在主机内
(在合同冻结中批准),这不仅是一种分层偏好:
每个网关呼叫路线都通过部署的系统 sendToIWA自动打开
作为副作用的IWA窗口——所以自己探测的API准备状态将会
打开一扇窗户,因为问"你准备好了吗?".
三个地方很容易出错
每一个都有一个活失败模式 后面,每个都有一个测试.
udpBind 是三州,必须保持三州. 一个真正的电源UDP绑定是
唯一的证据 Direct Sockets工作, 但提供者只尝试过一次
给予精细的许可。 这么说吧 null 意思是没有通知,而且
把它拆开 false 报告"我们从未尝试"作为"束缚失败"——
不同的原因,不同的固定,不同的消息, 和合同有单独的
代码( e)udp-bind-unverified 对 udp-bind-failed) (中文(简体) ). 目前部署的国际水域评估
崩溃; readSocketWorker 没有.
遗产 local-network-access 别名永远不能准备就绪. 当前
铬报告 denied 而两个精美的名字 granted这样
上面写着一座工作桥被封锁了 继续
legacyAlias 仅供参考.
extensionResponded 留下来 null 直至呼叫者的期限快到了.
扩展探测器是无内置超时的火灾和遗忘探测器,所以
沉默与在此之前的缺席是分不开的——合同规定:
null 而不是作为判决 截止时间是打电话者的
参数,因为只有呼叫者知道何时开始探测.
这个包裹怎么看不见,就这么说
observeReadiness 将套接字员工诊断作为 参数 而不是说
调查他们,因为他们无法从一个页面域看到:套接字
工人们住在IWA's isolated-app: 域,扩展显示否
页面化诊断频道. 杀死他们
socket-worker-unavailable这是诚实的阅读 对于一个打电话者
绝对看不到工人 发明健康违约证明
供货商没有人检查.
构建和测试
合约的 声明 是类型来源, 所以先建它 。 运行 这些来自寄存器根 :
npm --prefix packages/multicast-contract install
npm --prefix packages/multicast-contract run build
# This package's lane is install-free: its `tsconfig.json` path mapping resolves
# the contract from the sibling package's emitted declarations above, and its
# tests run on node's own type stripping. That mapping stays — it is what lets
# the lane build without the contract having to exist on the registry first.
packages/multicast-contract/node_modules/.bin/tsc -b packages/multicast-browser
npm --prefix packages/multicast-browser test # unit + browser conformance
CI运行的正是这个 .github/workflows/publish-npm.yml, (中文(简体) ),
在合同本身的阶段之后.