@coralai/sps-plugin-api 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.d.ts +23 -0
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -382,6 +382,29 @@ export interface SpsWorkspace {
382
382
  discover(): Promise<SpsWorkspaceProject[]>;
383
383
  /** 某产品的用户资产范围。没有声明时回落窄兜底,并把 `usedDefault` 置真。 */
384
384
  assetScope(product: string): SpsAssetScope;
385
+ /**
386
+ * 构建方声明的产物目录(`<repoDir>/.sps/build.json` 的 `outDir`)。
387
+ *
388
+ * 🔴 **三态,别塌成两态**:
389
+ * ```
390
+ * undefined 没声明(文件不在 / 没这个字段 / 坏 JSON)
391
+ * null 声明了「这个项目没有产物目录」
392
+ * string 声明的相对目录
393
+ * ```
394
+ * 把 `null` 和 `undefined` 合成一个,就分不出「构建方说没有」和「构建方没说」——
395
+ * 而前者该照做,后者只能去猜。
396
+ *
397
+ * 🔴 **别自己读 `.sps/build.json`。** 它取代的正是"三方各自猜"那个形状:
398
+ * sps 的 play.ts、插件的 publish.mjs 曾各写一份
399
+ * `exists(dist/index.html) ? dist : repoDir` 的三元(逐字相同)。
400
+ * 现有项目全是 vite(默认 `dist`)所以一直没露;webpack 默认 `build`、Next 是 `.next`
401
+ * ⇒ 只要有一个项目的打包器输出不是 dist,猜的那份当场就错,而表现是
402
+ * "预览到未构建的源码",**零报错**。
403
+ *
404
+ * ⚠️ 它在 `sps.workspace` 而不是别处,是因为这是**读工作区里的一个约定文件** ——
405
+ * 和 `assetScope` 同类:约定由宿主定,插件问宿主要答案,而不是自己拼路径。
406
+ */
407
+ declaredOutDir(repoDir: string): string | null | undefined;
385
408
  }
386
409
  /**
387
410
  * `p` 是否在 `root` 之内(含 root 自身)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coralai/sps-plugin-api",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "sps 宿主半区的插件契约:ctx 上那些服务的方法签名。插件装它拿类型。",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",