@acryldev/blends-frame 0.2.11 → 0.2.13

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.
package/lib/contract.d.ts CHANGED
@@ -138,6 +138,11 @@ export interface FrameState {
138
138
  readonly unsaved?: number;
139
139
  /** The commit the checked-out branch's upstream points at, as last fetched or pushed; absent without one. A change means the shared marks changed. */
140
140
  readonly upstreamHead?: string;
141
+ /** The Blend's own version (blend.yaml `metadata.version`) and the ACRYL Blends framework's it runs on; each absent when it cannot be read. */
142
+ readonly appVersions?: {
143
+ readonly blend?: string;
144
+ readonly framework?: string;
145
+ };
141
146
  }
142
147
  /** @throws an Error naming the field when the answer is not a frame state. */
143
148
  export declare function parseFrameState(value: unknown): FrameState;
package/lib/index.js CHANGED
@@ -4,6 +4,7 @@ import { execFile, execFileSync, spawn } from "node:child_process";
4
4
  import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, watch, writeFileSync } from "node:fs";
5
5
  import { mkdir, readFile, readdir, rename, writeFile } from "node:fs/promises";
6
6
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
7
+ import { digestFolder, readAppVersions } from "@acryldev/blends-core";
7
8
  import { Acryl } from "@acryldev/blends";
8
9
  import { error } from "@acryldev/loopback-http";
9
10
  import { INVALID_JSON, jsonBody, ownPage, privateApi, readJson } from "@acryldev/loopback-http/router";
@@ -12,7 +13,6 @@ import { GitRunner, Versions } from "@acryldev/versions";
12
13
  import * as workspaceHost from "@acryldev/workspace";
13
14
  import { promisify } from "node:util";
14
15
  import { pathToFileURL } from "node:url";
15
- import { digestFolder } from "@acryldev/blends-core";
16
16
  import { parseDocument } from "yaml";
17
17
  import { boundContextSummary, createUserMessage } from "@deepseek-ai/dsh-llm";
18
18
  import { randomBytes } from "node:crypto";
@@ -80,7 +80,7 @@ function isRecord$2(value) {
80
80
  /** @throws an Error naming the field when the answer is not a frame state. */
81
81
  function parseFrameState(value) {
82
82
  if (!isRecord$2(value)) throw new Error("frame state: not an object");
83
- const { appName, appRoot, appPage, branches, head, unsaved, upstreamHead } = value;
83
+ const { appName, appRoot, appPage, branches, head, unsaved, upstreamHead, appVersions } = value;
84
84
  if (typeof appName !== "string" || appName === "") throw new Error("frame state: appName");
85
85
  if (typeof appRoot !== "string" || appRoot === "") throw new Error("frame state: appRoot");
86
86
  if (appPage !== void 0 && (typeof appPage !== "string" || !appPage.startsWith("/"))) throw new Error("frame state: appPage");
@@ -88,6 +88,7 @@ function parseFrameState(value) {
88
88
  if (head !== void 0 && (typeof head !== "string" || head === "")) throw new Error("frame state: head");
89
89
  if (unsaved !== void 0 && (typeof unsaved !== "number" || !Number.isInteger(unsaved) || unsaved < 0)) throw new Error("frame state: unsaved");
90
90
  if (upstreamHead !== void 0 && (typeof upstreamHead !== "string" || upstreamHead === "")) throw new Error("frame state: upstreamHead");
91
+ if (appVersions !== void 0 && (!isRecord$2(appVersions) || [appVersions.blend, appVersions.framework].some((v) => v !== void 0 && typeof v !== "string"))) throw new Error("frame state: appVersions");
91
92
  const parsed = branches.map((branch) => {
92
93
  if (!isRecord$2(branch) || typeof branch.name !== "string" || typeof branch.current !== "boolean") throw new Error("frame state: branch");
93
94
  return {
@@ -102,7 +103,8 @@ function parseFrameState(value) {
102
103
  branches: parsed,
103
104
  ...head === void 0 ? {} : { head },
104
105
  ...unsaved === void 0 ? {} : { unsaved },
105
- ...upstreamHead === void 0 ? {} : { upstreamHead }
106
+ ...upstreamHead === void 0 ? {} : { upstreamHead },
107
+ ...appVersions === void 0 ? {} : { appVersions }
106
108
  };
107
109
  }
108
110
  const FRAME_PLUGINS_PATH = `${FRAME_API_PREFIX}/plugins`;
@@ -1084,6 +1086,10 @@ function githubReadiness(login) {
1084
1086
  /** A share that could not be planned or sent, in words a person can act on. */
1085
1087
  function plainShareProblem(cause) {
1086
1088
  const message = cause instanceof Error ? cause.message : String(cause);
1089
+ if (/npm whoami failed|sign in with: npm login/iu.test(message)) return {
1090
+ say: "npm is not signed in on this computer. Open a terminal, run npm login, then press Publish to npm again. Nothing was sent.",
1091
+ details: message
1092
+ };
1087
1093
  const setup = githubProblemOf(message);
1088
1094
  if (setup === "missing") return /\bgit is not available/iu.test(message) ? {
1089
1095
  say: `Sharing needs a free program called git, and it is not installed on this computer. Install it from git-scm.com and try again. ${KEEP_HERE}`,
@@ -4107,7 +4113,14 @@ function processGroupId(pid) {
4107
4113
  "pgid=",
4108
4114
  "-p",
4109
4115
  String(pid)
4110
- ], { encoding: "utf8" }).trim());
4116
+ ], {
4117
+ encoding: "utf8",
4118
+ stdio: [
4119
+ "ignore",
4120
+ "pipe",
4121
+ "ignore"
4122
+ ]
4123
+ }).trim());
4111
4124
  return Number.isInteger(value) && value > 0 ? value : void 0;
4112
4125
  } catch {
4113
4126
  return;
@@ -4192,7 +4205,8 @@ function apply(ctx, config = {}) {
4192
4205
  ...appPage === void 0 ? {} : { appPage },
4193
4206
  branches,
4194
4207
  ...worktree,
4195
- ...upstream === void 0 ? {} : { upstreamHead: upstream }
4208
+ ...upstream === void 0 ? {} : { upstreamHead: upstream },
4209
+ appVersions: readAppVersions(root)
4196
4210
  };
4197
4211
  };
4198
4212
  const graph = createGraphPort(ctx, root);
@@ -4243,7 +4257,13 @@ function apply(ctx, config = {}) {
4243
4257
  ...visibility === void 0 ? {} : { visibility },
4244
4258
  ...registry === true ? { registry } : {}
4245
4259
  }, githubSharePorts()),
4246
- share: async (name, confirmed, owner) => confirmed.npm !== void 0 ? shareNpm(npmShareOf(() => ctx.get("pluginShare")), name, confirmed, owner) : shareAppPlugin(root, ctx.appInstance.home, name, confirmed, {
4260
+ share: async (name, confirmed, owner) => confirmed.npm !== void 0 ? shareNpm(npmShareOf(() => ctx.get("pluginShare")), name, confirmed, owner).then(async (shared) => {
4261
+ await recordShare(join(ctx.appInstance.home, "shared-plugins.json"), name, {
4262
+ url: shared.url,
4263
+ version: shared.version
4264
+ });
4265
+ return shared;
4266
+ }) : shareAppPlugin(root, ctx.appInstance.home, name, confirmed, {
4247
4267
  ...shareTo,
4248
4268
  ...owner === void 0 ? {} : { owner }
4249
4269
  }, githubSharePorts()),