@acryldev/blends-frame 0.2.5 → 0.2.7

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.
@@ -4,7 +4,7 @@
4
4
  * `extensions` row finds it). `blend.yaml` is edited by lines, so its comments and layout stay as the person wrote them. The running app takes a
5
5
  * switch when its Loader row (`app-plugins`) loads again, which the client asks for.
6
6
  */
7
- import { type PublishGitPort, type RepositoryHostPort } from '@acryldev/plugin-hub-core';
7
+ import { type Placement, type PublishGitPort, type RepositoryHostPort } from '@acryldev/plugin-hub-core';
8
8
  import { type AppPluginView, type FramePluginState, type FramePluginView, type SavedPluginResult, type SavedPluginView, type ShareVisibility, type SharedPluginView, type SharePlan } from './contract.ts';
9
9
  /** One row of `blend.yaml`'s `spec.rows`: where its block starts and ends (line indexes, end exclusive). */
10
10
  export interface BlendRow {
@@ -81,7 +81,7 @@ export declare function frameRowState(row: FrameRow): FramePluginState;
81
81
  export declare function readFramePlugins(root: string, rows: readonly FrameRow[]): Promise<FramePluginView[]>;
82
82
  /** The package.json a local plugin is shared with: the fields the builder's package_plugin writes (plugins/builder/index.ts), plus the Loader
83
83
  * patch the plugin-hub's share requires so the package can also be installed as a row. */
84
- export declare function pluginPackageManifest(name: string, description: string, version?: string, license?: string): Record<string, unknown>;
84
+ export declare function pluginPackageManifest(name: string, description: string, version?: string, license?: string, placement?: Placement): Record<string, unknown>;
85
85
  /**
86
86
  * The shares this app completed, from its own home (`shared-plugins.json`). The record is written only after the hub's whole share succeeded: a
87
87
  * package.json can name a repository before the release exists, because the hub prepares it before its guards, and a refused share must not look
@@ -93,7 +93,7 @@ export declare function recordShare(file: string, name: string, shared: SharedPl
93
93
  /** Where the frame packages the plugins it shares: under the app's home, never in the app's folder, so a share leaves no file to save. */
94
94
  export declare const pluginPackagesOf: (home: string) => string;
95
95
  /** Copy one local plugin into its package folder under `packages`, the way the builder's package_plugin does; answers the folder. */
96
- export declare function packageAppPlugin(root: string, name: string, packages: string, license?: string): Promise<string>;
96
+ export declare function packageAppPlugin(root: string, name: string, packages: string, license?: string, placement?: Placement): Promise<string>;
97
97
  /** Bump one package folder's patch version (what the hub asks for after a release), and answer the new version. */
98
98
  export declare function bumpPackageVersion(dir: string): Promise<string>;
99
99
  /**
package/lib/client.js CHANGED
@@ -174,24 +174,50 @@ window.__ModuleLoader__.load({
174
174
  const FRAME_APP_SHARE_PATH = `${FRAME_API_PREFIX}/app/share`;
175
175
  /** POST `{ png: base64 }`: the app's own icon (assets/icon.png), drawn by the page at 512 px. */
176
176
  const FRAME_APP_ICON_PATH = `${FRAME_API_PREFIX}/app/icon`;
177
+ /** The Blends store's categories (published by acrylblends.github.io; @acryldev/app-persistence CATEGORIES_URL names the same list). */
178
+ const STORE_CATEGORIES_URL = "https://acrylblends.github.io/categories.json";
179
+ function parseListing(value) {
180
+ if (value === void 0) return void 0;
181
+ if (!isRecord$5(value) || !isRecord$5(value.placement)) throw new Error("app share plan: listing");
182
+ const { id, license, tag } = value;
183
+ const { category, subcategory } = value.placement;
184
+ if (typeof id !== "string" || typeof license !== "string" || typeof tag !== "string" || typeof category !== "string") throw new Error("app share plan: listing");
185
+ if (subcategory !== void 0 && typeof subcategory !== "string") throw new Error("app share plan: listing subcategory");
186
+ return {
187
+ id,
188
+ placement: {
189
+ category,
190
+ ...subcategory === void 0 ? {} : { subcategory }
191
+ },
192
+ license,
193
+ tag
194
+ };
195
+ }
177
196
  function parseAppSharePlan(value) {
178
197
  if (!isRecord$5(value)) throw new Error("app share plan: not a plan");
179
198
  const { repository, create, visibility, changes } = value;
180
199
  if (typeof repository !== "string" || repository === "" || typeof create !== "boolean") throw new Error("app share plan: repository");
181
200
  if (visibility !== "private" && visibility !== "public") throw new Error("app share plan: visibility");
182
201
  if (typeof changes !== "number" || !Number.isSafeInteger(changes) || changes < 0) throw new Error("app share plan: changes");
202
+ const listing = parseListing(value.listing);
183
203
  return {
184
204
  repository,
185
205
  create,
186
206
  visibility,
187
- changes
207
+ changes,
208
+ ...listing === void 0 ? {} : { listing }
188
209
  };
189
210
  }
190
211
  function parseAppShared(value) {
191
212
  if (!isRecord$5(value) || typeof value.remote !== "string" || typeof value.created !== "boolean") throw new Error("app share: where it went");
213
+ const listed = isRecord$5(value.listed) && typeof value.listed.tag === "string" && typeof value.listed.created === "boolean" ? {
214
+ tag: value.listed.tag,
215
+ created: value.listed.created
216
+ } : void 0;
192
217
  return {
193
218
  remote: value.remote,
194
- created: value.created
219
+ created: value.created,
220
+ ...listed === void 0 ? {} : { listed }
195
221
  };
196
222
  }
197
223
  const FRAME_PLUGINS_SHARE_PLAN_PATH = `${FRAME_API_PREFIX}/plugins/share-plan`;
@@ -211,13 +237,18 @@ window.__ModuleLoader__.load({
211
237
  /** @throws when the value is not a share plan. */
212
238
  function parseSharePlan(value) {
213
239
  if (!isRecord$5(value)) throw new Error("share plan: not a plan");
214
- const { owner, repo, version, visibility, createsRepository, released, license, registry } = value;
240
+ const { owner, repo, version, visibility, createsRepository, released, license, registry, placement } = value;
215
241
  if (typeof owner !== "string" || !GITHUB_NAME.test(owner) || typeof repo !== "string" || !GITHUB_NAME.test(repo)) throw new Error("share plan: repository");
216
242
  if (typeof version !== "string" || version === "" || released !== void 0 && (typeof released !== "string" || released === "")) throw new Error("share plan: version");
217
243
  if (visibility !== "private" && visibility !== "public" || typeof createsRepository !== "boolean") throw new Error("share plan: visibility");
218
244
  if (license !== void 0 && (typeof license !== "string" || !/^[A-Za-z0-9.+-]+$/u.test(license))) throw new Error("share plan: license");
219
245
  if (registry !== void 0 && typeof registry !== "boolean") throw new Error("share plan: registry");
220
246
  if (registry === true && visibility !== "public") throw new Error("share plan: only a public share can be listed in the registry");
247
+ const place = placement === void 0 ? void 0 : isRecord$5(placement) && typeof placement.category === "string" && (placement.subcategory === void 0 || typeof placement.subcategory === "string") ? {
248
+ category: placement.category,
249
+ ...typeof placement.subcategory === "string" ? { subcategory: placement.subcategory } : {}
250
+ } : null;
251
+ if (place === null) throw new Error("share plan: placement");
221
252
  return {
222
253
  owner,
223
254
  repo,
@@ -226,7 +257,8 @@ window.__ModuleLoader__.load({
226
257
  createsRepository,
227
258
  ...released === void 0 ? {} : { released },
228
259
  ...license === void 0 ? {} : { license },
229
- ...registry === true ? { registry } : {}
260
+ ...registry === true ? { registry } : {},
261
+ ...place === void 0 ? {} : { placement: place }
230
262
  };
231
263
  }
232
264
  /** @throws when the value is not what a save answers. */
@@ -17595,7 +17627,8 @@ window.__ModuleLoader__.load({
17595
17627
  shareSentence(plan),
17596
17628
  `Repository: ${plan.owner}/${plan.repo} on GitHub (${plan.createsRepository ? "a new one" : "it exists"}), ${plan.visibility}`,
17597
17629
  ...plan.license === void 0 ? [] : [`License: ${plan.license}`],
17598
- ...plan.registry === true ? ["Topic: cordis-plugin, which cordisplugins.github.io lists within about an hour"] : []
17630
+ ...plan.registry === true ? ["Topic: cordis-plugin, which cordisplugins.github.io lists within about an hour"] : [],
17631
+ ...plan.placement === void 0 ? [] : [`Category: ${plan.placement.category}${plan.placement.subcategory === void 0 ? "" : ` › ${plan.placement.subcategory}`}, where this app is in the Blends store`]
17599
17632
  ];
17600
17633
  }
17601
17634
  const DAY_MS = 864e5;
@@ -48850,6 +48883,29 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
48850
48883
  return false;
48851
48884
  }
48852
48885
  }
48886
+ /** The store's categories for the two selects; empty when the list cannot be read (the plan still names the place). */
48887
+ async function storeCategories() {
48888
+ try {
48889
+ const response = await fetch(STORE_CATEGORIES_URL);
48890
+ const list = response.ok ? (await response.json()).categories : void 0;
48891
+ return Array.isArray(list) ? list : [];
48892
+ } catch {
48893
+ return [];
48894
+ }
48895
+ }
48896
+ const LICENSES = [
48897
+ "MIT",
48898
+ "Apache-2.0",
48899
+ "BSD-3-Clause",
48900
+ "GPL-3.0-or-later",
48901
+ "MPL-2.0"
48902
+ ];
48903
+ /** Where the store lists it, in words: `Application › Productivity`. */
48904
+ function placeWords(listing, categories) {
48905
+ const category = categories.find((c) => c.slug === listing.placement.category);
48906
+ const sub = category?.subs.find((s) => s.slug === listing.placement.subcategory);
48907
+ return [category?.name ?? listing.placement.category, ...listing.placement.subcategory === void 0 ? [] : [sub?.name ?? listing.placement.subcategory]].join(" › ");
48908
+ }
48853
48909
  /** `github.com/ana/shop` from a remote address, for reading. */
48854
48910
  const readable = (remote) => remote.replace(/^git\+/u, "").replace(/^https?:\/\//u, "").replace(/\.git$/u, "");
48855
48911
  function ShareAppSection({ share, registry }) {
@@ -48857,6 +48913,11 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
48857
48913
  const [owner, setOwner] = (0, react.useState)("");
48858
48914
  const [visibility, setVisibility] = (0, react.useState)("private");
48859
48915
  const [step, setStep] = (0, react.useState)({ kind: "ask" });
48916
+ const [list, setList] = (0, react.useState)(void 0);
48917
+ const [categories, setCategories] = (0, react.useState)([]);
48918
+ (0, react.useEffect)(() => {
48919
+ if (list !== void 0 && categories.length === 0) storeCategories().then(setCategories);
48920
+ }, [list, categories.length]);
48860
48921
  const [failure, setFailure] = (0, react.useState)(void 0);
48861
48922
  const readGithub = (0, react.useCallback)(() => {
48862
48923
  registry.github().then(setGithub, () => {
@@ -48866,9 +48927,11 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
48866
48927
  (0, react.useEffect)(() => {
48867
48928
  readGithub();
48868
48929
  }, [readGithub]);
48930
+ const listed = visibility === "public" && list !== void 0;
48869
48931
  const request = {
48870
48932
  ...owner.trim() === "" ? {} : { owner: owner.trim() },
48871
- visibility
48933
+ visibility,
48934
+ ...listed ? { list } : {}
48872
48935
  };
48873
48936
  const fail = (cause) => {
48874
48937
  setFailure(cause instanceof PlainFailure || cause instanceof Error ? cause.message : String(cause));
@@ -48887,6 +48950,30 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
48887
48950
  fail(cause);
48888
48951
  });
48889
48952
  };
48953
+ /** A new place or licence: the plan is read again, so the yes covers exactly what is shown. */
48954
+ const replace = (change, current) => {
48955
+ const subcategory = "subcategory" in change ? change.subcategory : current.placement.subcategory;
48956
+ const next = {
48957
+ category: change.category ?? current.placement.category,
48958
+ ...subcategory === void 0 ? {} : { subcategory },
48959
+ license: change.license ?? current.license
48960
+ };
48961
+ setList(next);
48962
+ setFailure(void 0);
48963
+ setStep({ kind: "busy" });
48964
+ share.plan({
48965
+ ...request,
48966
+ list: next
48967
+ }).then((plan) => {
48968
+ setStep({
48969
+ kind: "plan",
48970
+ plan
48971
+ });
48972
+ }, (cause) => {
48973
+ setStep({ kind: "ask" });
48974
+ fail(cause);
48975
+ });
48976
+ };
48890
48977
  const send = (plan) => {
48891
48978
  setFailure(void 0);
48892
48979
  setStep({
@@ -48929,20 +49016,27 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
48929
49016
  }),
48930
49017
  step.kind === "shared" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
48931
49018
  className: "acrylBlendsAppRow",
48932
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: "Shared" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("small", {
48933
- role: "status",
48934
- children: [
48935
- "Sent to ",
48936
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
48937
- className: "acrylBlendsMeta",
48938
- children: readable(step.shared.remote)
48939
- }),
48940
- step.shared.created ? " (a new repository)" : "",
48941
- ". Every later version is saved there too. Someone you give access makes their own copy with",
48942
- " ",
48943
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: `git clone ${step.shared.remote.replace(/^git\+/u, "")}` })
48944
- ]
48945
- })]
49019
+ children: [
49020
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: "Shared" }),
49021
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("small", {
49022
+ role: "status",
49023
+ children: [
49024
+ "Sent to ",
49025
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
49026
+ className: "acrylBlendsMeta",
49027
+ children: readable(step.shared.remote)
49028
+ }),
49029
+ step.shared.created ? " (a new repository)" : "",
49030
+ ". Every later version is saved there too. Someone you give access makes their own copy with",
49031
+ " ",
49032
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: `git clone ${step.shared.remote.replace(/^git\+/u, "")}` })
49033
+ ]
49034
+ }),
49035
+ step.shared.listed !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", {
49036
+ role: "status",
49037
+ children: step.shared.listed.created ? `Listed in the Blends store from ${step.shared.listed.tag}: acrylblends.github.io and Control Center show it within about an hour.` : `${step.shared.listed.tag} was already listed, so the store keeps that version. Raise the version in package.json to list this one.`
49038
+ })
49039
+ ]
48946
49040
  }) : step.kind === "plan" || step.kind === "sending" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
48947
49041
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
48948
49042
  className: "acrylBlendsAppRow",
@@ -48950,8 +49044,80 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
48950
49044
  }),
48951
49045
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
48952
49046
  className: "acrylBlendsAppRow",
48953
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: "Who can see it" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: step.plan.visibility === "private" ? "Only you and people you invite (private)" : "Anyone (public); listed in the Blends registry as Community" })]
49047
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: "Who can see it" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: step.plan.visibility === "private" ? "Only you and people you invite (private)" : "Anyone (public)" })]
48954
49048
  }),
49049
+ step.plan.listing !== void 0 && (() => {
49050
+ const listing = step.plan.listing;
49051
+ const category = categories.find((c) => c.slug === listing.placement.category);
49052
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
49053
+ className: "acrylBlendsAppRow",
49054
+ "data-wide": "",
49055
+ children: [
49056
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: "Blends store" }),
49057
+ categories.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
49058
+ className: "acrylBlendsAppControls",
49059
+ children: [
49060
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
49061
+ className: "acrylBlendsSearch",
49062
+ "aria-label": "Category",
49063
+ disabled: step.kind === "sending",
49064
+ value: listing.placement.category,
49065
+ onChange: (event) => {
49066
+ replace({
49067
+ category: event.target.value,
49068
+ subcategory: void 0
49069
+ }, listing);
49070
+ },
49071
+ children: categories.map((c) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
49072
+ value: c.slug,
49073
+ children: c.name
49074
+ }, c.slug))
49075
+ }),
49076
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
49077
+ className: "acrylBlendsSearch",
49078
+ "aria-label": "Subcategory",
49079
+ disabled: step.kind === "sending",
49080
+ value: listing.placement.subcategory ?? "",
49081
+ onChange: (event) => {
49082
+ replace({ subcategory: event.target.value === "" ? void 0 : event.target.value }, listing);
49083
+ },
49084
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
49085
+ value: "",
49086
+ children: "No subcategory"
49087
+ }), (category?.subs ?? []).map((s) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
49088
+ value: s.slug,
49089
+ children: s.name
49090
+ }, s.slug))]
49091
+ }),
49092
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
49093
+ className: "acrylBlendsSearch",
49094
+ "aria-label": "Licence",
49095
+ disabled: step.kind === "sending",
49096
+ value: listing.license,
49097
+ onChange: (event) => {
49098
+ replace({ license: event.target.value }, listing);
49099
+ },
49100
+ children: [.../* @__PURE__ */ new Set([listing.license, ...LICENSES])].map((id) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
49101
+ value: id,
49102
+ children: `Licence: ${id}`
49103
+ }, id))
49104
+ })
49105
+ ]
49106
+ }),
49107
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("small", { children: [
49108
+ "Listed as ",
49109
+ listing.id,
49110
+ " under ",
49111
+ placeWords(listing, categories),
49112
+ ", marked Community with your name, licence ",
49113
+ listing.license,
49114
+ ". People start from ",
49115
+ listing.tag,
49116
+ "."
49117
+ ] })
49118
+ ]
49119
+ });
49120
+ })(),
48955
49121
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
48956
49122
  className: "acrylBlendsAppRow",
48957
49123
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: "What is sent" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: step.plan.changes === 0 ? "The versions saved so far" : `${String(step.plan.changes)} changed ${step.plan.changes === 1 ? "file is" : "files are"} saved first, then every saved version` })]
@@ -49013,9 +49179,19 @@ body[data-bf-settings-full] { --bf-pane-h: calc(100vh - 24px); }
49013
49179
  children: "Private: only you and people you invite"
49014
49180
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
49015
49181
  value: "public",
49016
- children: "Public: anyone, listed as Community"
49182
+ children: "Public: anyone can see it"
49017
49183
  })]
49018
49184
  }),
49185
+ visibility === "public" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
49186
+ className: "acrylBlendsMeta",
49187
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
49188
+ type: "checkbox",
49189
+ checked: list !== void 0,
49190
+ onChange: (event) => {
49191
+ setList(event.target.checked ? {} : void 0);
49192
+ }
49193
+ }), " List it in the Blends store"]
49194
+ }),
49019
49195
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
49020
49196
  type: "submit",
49021
49197
  className: "acrylBlendsAppButton",