@plitzi/sdk-authoring 0.39.0 → 0.39.2

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/dist/node.js CHANGED
@@ -1,11 +1,11 @@
1
- import { Ar as t$1, Cr as g$1, Do as element, Dr as o$3, Er as m$2, Ir as buildHandles, Ka as container, Kr as s$3, Mr as v$1, Nr as y$1, Or as p$2, So as component, Sr as f$2, Tr as l$3, _r as S$1, br as c$3, gr as N$1, hr as M$1, hs as J, jr as u$3, kr as s$4, l as validateSpace, n as authorSpace, u as compactSvg, vr as _, wr as j$1, xr as d$2, xs as e$2, yr as b$1 } from "./index-src.js";
1
+ import { Ao as element, Ar as p$2, Cr as c$4, Dr as l$3, Er as g$1, Fr as y$1, Ja as container, Jr as c$3, Mr as t$1, Nr as u$3, Or as m$2, Pr as v$1, Rr as buildHandles, Sr as b$1, To as component, Tr as f$2, _r as C$1, br as P, jr as s$3, kr as o$3, l as validateSpace, n as authorSpace, u as compactSvg, vr as M$1, vs as Y, wr as d$2, ws as e$2, xr as _, yr as N$1 } from "./index-src.js";
2
2
  import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
3
3
  import { createRequire } from "node:module";
4
4
  import e from "node:path";
5
5
  import { fileURLToPath, pathToFileURL } from "node:url";
6
6
  import "node:crypto";
7
7
  import { spawn } from "node:child_process";
8
- //#region ../sdk-shared/dist/project/layout/codes.mjs
8
+ // ../sdk-shared/dist/project/layout/codes.mjs
9
9
  var e$1 = {
10
10
  "plugin-entry-missing": {
11
11
  level: "error",
@@ -112,8 +112,7 @@ var t = (t, n, r, i, a) => ({
112
112
  fix: i,
113
113
  ...a ? { autofix: a } : {}
114
114
  });
115
- //#endregion
116
- //#region ../sdk-shared/dist/project/layout/files.mjs
115
+ // ../sdk-shared/dist/project/layout/files.mjs
117
116
  var r$1 = /* @__PURE__ */ new Set([
118
117
  ".gitkeep",
119
118
  "README.md",
@@ -170,12 +169,11 @@ var p$1 = (e, t) => {
170
169
  };
171
170
  var m$1 = "macOS and Windows disks ignore case, so it is found there — and not on Linux, where the project is deployed.";
172
171
  var h$1 = (e, t) => u$2(e, t) ? `git mv ${e} ${e}-tmp && git mv ${e}-tmp ${t}` : `git mv ${e} ${t}`;
173
- //#endregion
174
- //#region ../sdk-shared/dist/project/layout/vendor.mjs
175
- var s$1 = (t) => e$2(t.assets) ? Object.values(t.assets).flatMap((t) => e$2(t) && typeof t.src == "string" && typeof t.type == "string" ? [{
176
- src: t.src,
177
- type: t.type,
178
- isMain: t.isMain === !0
172
+ // ../sdk-shared/dist/project/layout/vendor.mjs
173
+ var s$1 = (e) => e$2(e.assets) ? Object.values(e.assets).flatMap((e) => e$2(e) && typeof e.src == "string" && typeof e.type == "string" ? [{
174
+ src: e.src,
175
+ type: e.type,
176
+ isMain: e.isMain === !0
179
177
  }] : []) : [];
180
178
  var c$1 = (c, l) => {
181
179
  let u = `${p$2}/${l}`, d = `${u}/${m$2}`, f = `npx plitzi space pull brings it again — or delete ${u}/, and the space renders no ${l}.`;
@@ -183,8 +181,8 @@ var c$1 = (c, l) => {
183
181
  let p;
184
182
  try {
185
183
  p = JSON.parse(readFileSync(e.join(c, d), "utf-8"));
186
- } catch (e) {
187
- return { problem: t("vendor-manifest-invalid", d, `${d} is not JSON (${e instanceof Error ? e.message : String(e)}), so ${l} does not run.`, f) };
184
+ } catch (t$16) {
185
+ return { problem: t("vendor-manifest-invalid", d, `${d} is not JSON (${t$16 instanceof Error ? t$16.message : String(t$16)}), so ${l} does not run.`, f) };
188
186
  }
189
187
  if (!e$2(p)) return { problem: t("vendor-manifest-invalid", d, `${d} is not a manifest, so ${l} does not run.`, f) };
190
188
  let m = s$1(p), h = m.find((e) => e.type === "script" && e.isMain) ?? m.find((e) => e.type === "script");
@@ -198,122 +196,120 @@ var c$1 = (c, l) => {
198
196
  ...typeof p.functions == "string" ? { functions: e.join(c, u, p.functions) } : {}
199
197
  };
200
198
  };
201
- //#endregion
202
- //#region ../sdk-shared/dist/project/layout/plugins.mjs
199
+ // ../sdk-shared/dist/project/layout/plugins.mjs
203
200
  var b = (e) => `${e.charAt(0).toLowerCase()}${e.slice(1)}`;
204
201
  var x$1 = (e) => {
205
202
  let t = e.split(/[^A-Za-z0-9]+/).filter(Boolean).map(d$1).join(""), n = /^\d+/.exec(t)?.[0] ?? "", r = `${d$1(t.slice(n.length))}${n}`;
206
203
  return a$2.test(r) ? r : void 0;
207
204
  };
208
205
  var w$1 = (e) => e.length > 1 ? `${e[0]} (or ${e.slice(1).join(", ")})` : e[0];
209
- var T$1 = (e$16, i) => {
210
- let { folder: a, accepted: o, code: u, lost: p } = i, m = o$2(e.join(e$16, a)), h = o.filter((e) => m.files.includes(e));
206
+ var T$1 = (r, i) => {
207
+ let { folder: a, accepted: l, code: f, lost: p } = i, m = o$2(e.join(r, a)), h = l.filter((e) => m.files.includes(e));
211
208
  if (h.length === 1) return [];
212
209
  if (h.length > 1) return [t("plugin-entry-ambiguous", `${a}/`, `${a}/ has both ${h.join(" and ")}, and a plugin is built from one of them.`, `Keep one — ${h[h.length - 1]} when it writes JSX — and delete the other.`)];
213
210
  let g = m.files.find((e) => i$1.test(e));
214
211
  if (g) {
215
- let e = g.endsWith(".jsx") && o.includes("index.tsx") ? "index.tsx" : "index.ts";
216
- return [t("entry-not-typescript", `${a}/${g}`, `${a}/${g} is JavaScript, and ${a}/ is built from ${w$1(o)}: the project's code is TypeScript, so ${p}.`, `Rename it ${e} — JavaScript is TypeScript already, types left out: ${h$1(`${a}/${g}`, `${a}/${e}`)}`, {
212
+ let t$8 = g.endsWith(".jsx") && l.includes("index.tsx") ? "index.tsx" : "index.ts";
213
+ return [t("entry-not-typescript", `${a}/${g}`, `${a}/${g} is JavaScript, and ${a}/ is built from ${w$1(l)}: the project's code is TypeScript, so ${p}.`, `Rename it ${t$8} — JavaScript is TypeScript already, types left out: ${h$1(`${a}/${g}`, `${a}/${t$8}`)}`, {
217
214
  action: "move",
218
215
  from: `${a}/${g}`,
219
- to: `${a}/${e}`
216
+ to: `${a}/${t$8}`
220
217
  })];
221
218
  }
222
- let _ = m.files.find((e) => o.some((t) => p$1(e, t)));
219
+ let _ = m.files.find((e) => l.some((t) => p$1(e, t)));
223
220
  if (_) {
224
- let e = o.find((e) => p$1(_, e)) ?? o[0];
225
- return [t(u, `${a}/${_}`, `${a}/ has no ${e} — did you mean ${_}? Named otherwise, ${p}.${u$2(_, e) ? ` ${m$1}` : ""}`, `Rename it ${e}: ${h$1(`${a}/${_}`, `${a}/${e}`)}`, {
221
+ let n = l.find((e) => p$1(_, e)) ?? l[0];
222
+ return [t(f, `${a}/${_}`, `${a}/ has no ${n} — did you mean ${_}? Named otherwise, ${p}.${u$2(_, n) ? ` ${m$1}` : ""}`, `Rename it ${n}: ${h$1(`${a}/${_}`, `${a}/${n}`)}`, {
226
223
  action: "move",
227
224
  from: `${a}/${_}`,
228
- to: `${a}/${e}`
225
+ to: `${a}/${n}`
229
226
  })];
230
227
  }
231
- let v = m.folders.find((t) => o.some((n) => s$2(e$16, `${a}/${t}/${n}`, "file")));
232
- return v ? [t(u, `${a}/${v}/`, `${a}/ has no ${w$1(o)}, and ${a}/${v}/ has: one folder too deep, so ${p}.`, `Move what ${a}/${v}/ holds up into ${a}/.`, {
228
+ let v = m.folders.find((e) => l.some((t) => s$2(r, `${a}/${e}/${t}`, "file")));
229
+ return v ? [t(f, `${a}/${v}/`, `${a}/ has no ${w$1(l)}, and ${a}/${v}/ has: one folder too deep, so ${p}.`, `Move what ${a}/${v}/ holds up into ${a}/.`, {
233
230
  action: "move",
234
231
  from: `${a}/${v}/`,
235
232
  to: `${a}/`
236
- })] : [t(u, `${a}/`, `${a}/ has no ${w$1(o)}, so ${p}.`, i.write)];
233
+ })] : [t(f, `${a}/`, `${a}/ has no ${w$1(l)}, so ${p}.`, i.write)];
237
234
  };
238
- var E$1 = (n, r) => {
239
- let i = o$2(e.join(n, r.folder));
240
- if (!l$2(i) || i.files.some(s$3)) return [];
241
- let a = i.folders.find((t) => o$2(e.join(n, r.folder, t)).files.some(s$3));
242
- return [t(r.code, `${r.folder}/${a === void 0 ? "" : `${a}/`}`, `${r.folder}/ has no file at its top${a === void 0 ? "" : `, and ${r.folder}/${a}/ has: a folder there is helpers`}, so ${r.lost}.`, r.write)];
235
+ var E$1 = (t$9, n) => {
236
+ let r = o$2(e.join(t$9, n.folder));
237
+ if (!l$2(r) || r.files.some(c$3)) return [];
238
+ let i = r.folders.find((e$18) => o$2(e.join(t$9, n.folder, e$18)).files.some(c$3));
239
+ return [t(n.code, `${n.folder}/${i === void 0 ? "" : `${i}/`}`, `${n.folder}/ has no file at its top${i === void 0 ? "" : `, and ${n.folder}/${i}/ has: a folder there is helpers`}, so ${n.lost}.`, n.write)];
243
240
  };
244
- var D$1 = (e$17, t) => l$2(o$2(e.join(e$17, t.folder))) ? T$1(e$17, t) : [];
245
- var O = (e) => {
246
- let n = x$1(e), r = `${l$3}/${e}`;
241
+ var D$1 = (e$19, t) => l$2(o$2(e.join(e$19, t.folder))) ? T$1(e$19, t) : [];
242
+ var O = (t$10) => {
243
+ let n = x$1(t$10), r = `${l$3}/${t$10}`;
247
244
  return t("plugin-name-invalid", `${r}/`, `${r}/ cannot be a plugin: a folder of ${l$3}/ is registered as the element type its name makes, and a type is a letter followed by letters and digits.${n ? ` Did you mean ${n}?` : ""}`, n ? `Rename it ${n} — the type ${b(n)}: ${h$1(r, `${l$3}/${n}`)}; then type: '${b(n)}' in its ${d$2}, and renderType: '${b(n)}' where the space renders it.` : "Rename it with letters and digits, starting with a letter: StatCard is the type statCard.");
248
245
  };
249
246
  var k = (e, t) => e.find((e) => e === `${t}.tsx`) ?? e.find((e) => e === `${t}.ts`);
250
- var A = (e$18, r) => {
251
- let i = `${l$3}/${r}`, { files: a } = o$2(e.join(e$18, i));
247
+ var A = (n, r) => {
248
+ let i = `${l$3}/${r}`, { files: a } = o$2(e.join(n, i));
252
249
  if (a.includes("declaration.ts")) return [];
253
- let o = b(r), c = `authoring holds none of the space's ${o} elements to its attributes, and the builder does not offer it`, u = a.find((e) => p$1(e, d$2));
254
- return u ? [t("plugin-declaration-missing", `${i}/${u}`, `${i}/ has no ${d$2} — did you mean ${u}? Named otherwise, ${c}.${u$2(u, "declaration.ts") ? ` ${m$1}` : ""}`, `Rename it ${d$2}: ${h$1(`${i}/${u}`, `${i}/${d$2}`)}`, {
250
+ let s = b(r), l = `authoring holds none of the space's ${s} elements to its attributes, and the builder does not offer it`, f = a.find((e) => p$1(e, d$2));
251
+ return f ? [t("plugin-declaration-missing", `${i}/${f}`, `${i}/ has no ${d$2} — did you mean ${f}? Named otherwise, ${l}.${u$2(f, "declaration.ts") ? ` ${m$1}` : ""}`, `Rename it ${d$2}: ${h$1(`${i}/${f}`, `${i}/${d$2}`)}`, {
255
252
  action: "move",
256
- from: `${i}/${u}`,
253
+ from: `${i}/${f}`,
257
254
  to: `${i}/${d$2}`
258
- })] : [t("plugin-declaration-missing", `${i}/`, `${i}/ has no ${d$2}: ${c}.`, `Write ${i}/${d$2} — export default { type: '${o}', … } — as npx plitzi plugin add writes one beside the component it makes.`)];
255
+ })] : [t("plugin-declaration-missing", `${i}/`, `${i}/ has no ${d$2}: ${l}.`, `Write ${i}/${d$2} — export default { type: '${s}', … } — as npx plitzi plugin add writes one beside the component it makes.`)];
259
256
  };
260
- var j = (e$19, t) => {
257
+ var j = (e$20, t) => {
261
258
  if (!a$2.test(t)) return [O(t)];
262
- let n = `${l$3}/${t}`, r = b(t), i = k(o$2(e.join(e$19, n)).files, t);
259
+ let n = `${l$3}/${t}`, r = b(t), a = k(o$2(e.join(e$20, n)).files, t);
263
260
  return [
264
- ...T$1(e$19, {
261
+ ...T$1(e$20, {
265
262
  folder: n,
266
263
  accepted: u$3,
267
264
  code: "plugin-entry-missing",
268
265
  lost: `the server cannot build the plugin ${r}`,
269
- write: `Write ${n}/index.ts exporting the component by default${i ? ` — export { default } from './${i}';` : ""} — as npx plitzi plugin add writes it. Every folder of ${l$3}/ is a plugin: code several plugins share goes outside it (src/shared/).`
266
+ write: `Write ${n}/index.ts exporting the component by default${a ? ` — export { default } from './${a}';` : ""} — as npx plitzi plugin add writes it. Every folder of ${l$3}/ is a plugin: code several plugins share goes outside it (src/shared/).`
270
267
  }),
271
- ...E$1(e$19, {
268
+ ...E$1(e$20, {
272
269
  folder: `${n}/${f$2}`,
273
270
  code: "plugin-functions-entry-missing",
274
271
  lost: `none of the plugin's server half runs (its routes under /fn/plugins/${r}/)`,
275
272
  write: `Write ${n}/${f$2}/index.ts exporting defineFunctions({ … }) by default — as npx plitzi plugin add --server writes it.`
276
273
  }),
277
- ...A(e$19, t)
274
+ ...A(e$20, t)
278
275
  ];
279
276
  };
280
- var M = (e) => {
277
+ var M = (t$12) => {
281
278
  let n = /* @__PURE__ */ new Map();
282
- for (let t of e.filter((e) => a$2.test(e))) n.set(b(t), [...n.get(b(t)) ?? [], t]);
283
- return [...n].flatMap(([e, n]) => n.slice(1).map((r) => t("plugin-type-taken", `${l$3}/${r}/`, `${l$3}/${n[0]}/ and ${l$3}/${r}/ are both the plugin ${e}: the server registers a folder by its name with a small first letter, and keeps one.`, `Put them in one folder, or rename one: git mv ${l$3}/${r} ${l$3}/<AnotherName>`)));
279
+ for (let e of t$12.filter((e) => a$2.test(e))) n.set(b(e), [...n.get(b(e)) ?? [], e]);
280
+ return [...n].flatMap(([t$11, n]) => n.slice(1).map((r) => t("plugin-type-taken", `${l$3}/${r}/`, `${l$3}/${n[0]}/ and ${l$3}/${r}/ are both the plugin ${t$11}: the server registers a folder by its name with a small first letter, and keeps one.`, `Put them in one folder, or rename one: git mv ${l$3}/${r} ${l$3}/<AnotherName>`)));
284
281
  };
285
- var N = (e$20) => {
286
- let { files: n, folders: r } = o$2(e.join(e$20, l$3)), o = n.filter((e) => !r$1.has(e) && e !== "declarations.ts").map((e$21) => {
287
- let { name: n } = e.parse(e$21), r = n !== "index" && x$1(n) || "<Name>";
288
- return t("plugin-file-loose", `${l$3}/${e$21}`, `${l$3}/${e$21} is a file, and every plugin is a folder of ${l$3}/: the server reads nothing of it.`, `Give it a folder with an index.ts that exports it by default — ${l$3}/${r}/${e$21} and ${l$3}/${r}/index.ts, as npx plitzi plugin add writes them — or move it out of ${l$3}/.`);
289
- }), c = o$2(e.join(e$20, p$2)).folders, l = new Set(r.filter((e) => a$2.test(e)).map(b)), u = c.filter((e) => l.has(e)).map((e) => t("plugin-shadowed", `${p$2}/${e}/`, `${e} is both ${p$2}/${e}/, as it was built, and a folder of ${l$3}/: the server runs the built one, and a change to the source shows nowhere.`, `Delete ${p$2}/${e}/: the source is the plugin now.`)), d = c.flatMap((t) => {
290
- let n = c$1(e$20, t);
282
+ var N = (t$14) => {
283
+ let { files: n, folders: a } = o$2(e.join(t$14, l$3)), s = n.filter((e) => !r$1.has(e) && e !== "declarations.ts").map((t$13) => {
284
+ let { name: n } = e.parse(t$13), r = n !== "index" && x$1(n) || "<Name>";
285
+ return t("plugin-file-loose", `${l$3}/${t$13}`, `${l$3}/${t$13} is a file, and every plugin is a folder of ${l$3}/: the server reads nothing of it.`, `Give it a folder with an index.ts that exports it by default — ${l$3}/${r}/${t$13} and ${l$3}/${r}/index.ts, as npx plitzi plugin add writes them — or move it out of ${l$3}/.`);
286
+ }), c = o$2(e.join(t$14, p$2)).folders, l = new Set(a.filter((e) => a$2.test(e)).map(b)), u = c.filter((e) => l.has(e)).map((t$15) => t("plugin-shadowed", `${p$2}/${t$15}/`, `${t$15} is both ${p$2}/${t$15}/, as it was built, and a folder of ${l$3}/: the server runs the built one, and a change to the source shows nowhere.`, `Delete ${p$2}/${t$15}/: the source is the plugin now.`)), d = c.flatMap((e) => {
287
+ let n = c$1(t$14, e);
291
288
  return "problem" in n ? [n.problem] : [];
292
289
  });
293
290
  return [
294
- ...r.flatMap((t) => j(e$20, t)),
295
- ...M(r),
296
- ...o,
291
+ ...a.flatMap((e) => j(t$14, e)),
292
+ ...M(a),
293
+ ...s,
297
294
  ...u,
298
295
  ...d
299
296
  ];
300
297
  };
301
- //#endregion
302
- //#region ../sdk-shared/dist/project/layout/contents.mjs
298
+ // ../sdk-shared/dist/project/layout/contents.mjs
303
299
  var l$1 = (e) => e.split("\n").map((e) => e.replace(/^(\s*(?:export\s+)?[A-Za-z_][A-Za-z0-9_]*\s*=).*$/, "$1")).join("\n");
304
- var u$1 = (t$4) => {
305
- let i = o$2(t$4).files, a = i.includes(".env"), u = i.includes(".env.example"), d = c$2(t$4, "src", /* @__PURE__ */ new Set(["node_modules"])).filter((e$10) => e.posix.basename(e$10) === ".env"), f = !a && d.length === 1, p = d.map((t$3) => t("env-in-src", t$3, `${t$3} is never read: Node reads the project's settings from the .env at its root, as its scripts start it (--env-file-if-exists=.env).`, f ? `Move it to the root: mv ${t$3} .env` : `Copy what it sets into the root's .env, then delete ${t$3}.`, f ? {
300
+ var u$1 = (e$12) => {
301
+ let t$5 = o$2(e$12).files, i = t$5.includes(".env"), u = t$5.includes(".env.example"), d = c$2(e$12, "src", /* @__PURE__ */ new Set(["node_modules"])).filter((e$11) => e.posix.basename(e$11) === ".env"), f = !i && d.length === 1, p = d.map((e) => t("env-in-src", e, `${e} is never read: Node reads the project's settings from the .env at its root, as its scripts start it (--env-file-if-exists=.env).`, f ? `Move it to the root: mv ${e} .env` : `Copy what it sets into the root's .env, then delete ${e}.`, f ? {
306
302
  action: "move",
307
- from: t$3,
303
+ from: e,
308
304
  to: ".env"
309
- } : void 0)), m = `${e.resolve(t$4).split(e.sep).join("/")}/`.includes(`/${t$1}/`), h = a || m || p.length > 0 ? [] : [t("env-missing", ".env", ".env is missing at the project’s root: none of its settings is set — the keys and secrets its code reads from process.env.", u ? "Copy .env.example and fill it in: cp .env.example .env" : "Write .env with the settings the project reads (process.env.*), and .env.example naming them.", u ? {
305
+ } : void 0)), m = `${e.resolve(e$12).split(e.sep).join("/")}/`.includes(`/${t$1}/`), h = i || m || p.length > 0 ? [] : [t("env-missing", ".env", ".env is missing at the project’s root: none of its settings is set — the keys and secrets its code reads from process.env.", u ? "Copy .env.example and fill it in: cp .env.example .env" : "Write .env with the settings the project reads (process.env.*), and .env.example naming them.", u ? {
310
306
  action: "copy",
311
307
  from: ".env.example",
312
308
  to: ".env"
313
- } : void 0)], g = u ? [] : [t("env-example-missing", ".env.example", ".env.example is missing: committed where .env never is, it names the settings .env holds, with no secret in them — so a clone knows what to fill in.", a ? "Write it from .env with every value left empty, and commit it." : "Write it — each setting the project reads, as KEY= with no value — and commit it.", a ? {
309
+ } : void 0)], g = u ? [] : [t("env-example-missing", ".env.example", ".env.example is missing: committed where .env never is, it names the settings .env holds, with no secret in them — so a clone knows what to fill in.", i ? "Write it from .env with every value left empty, and commit it." : "Write it — each setting the project reads, as KEY= with no value — and commit it.", i ? {
314
310
  action: "write",
315
311
  file: ".env.example",
316
- contents: l$1(readFileSync(e.join(t$4, ".env"), "utf-8"))
312
+ contents: l$1(readFileSync(e.join(e$12, ".env"), "utf-8"))
317
313
  } : void 0)];
318
314
  return [
319
315
  ...p,
@@ -321,47 +317,46 @@ var u$1 = (t$4) => {
321
317
  ...g
322
318
  ];
323
319
  };
324
- var d = (n) => c$2(n, _).filter((e$11) => !r$1.has(e.posix.basename(e$11)) && !e$11.endsWith(".json")).map((t$5) => t("data-not-json", t$5, `${t$5} is not JSON: a provider's /data/<file> and ctx.data read JSON files only, and plitzi space push leaves it behind.`, `Keep it as JSON (${t$5.replace(/\.[^./]*$/, "")}.json), or move it out of ${_}/.`));
320
+ var d = (t$7) => c$2(t$7, _).filter((e$13) => !r$1.has(e.posix.basename(e$13)) && !e$13.endsWith(".json")).map((t$6) => t("data-not-json", t$6, `${t$6} is not JSON: a provider's /data/<file> and ctx.data read JSON files only, and plitzi space push leaves it behind.`, `Keep it as JSON (${t$6.replace(/\.[^./]*$/, "")}.json), or move it out of ${_}/.`));
325
321
  var f = /^\.env(?:\..*)?$|\.(?:pem|key|p12|pfx|jks|keystore|sqlite3?|db|sql|dump)$|secret|credential|password|passwd|private[-_.]?key|id_rsa|id_ed25519|service[-_]?account/i;
326
- var p = (t$7, n) => {
327
- let o = c$2(t$7, g$1, /* @__PURE__ */ new Set(["node_modules"])), c = o.filter((e$12) => f.test(e.posix.basename(e$12))).map((t$6) => t("public-secret-file", t$6, `${t$6} is served to anyone who asks, as it is — everything in ${g$1}/ is on the internet once the project is deployed — and its name says it holds a secret, a key or a database.`, `Take it out of ${g$1}/: settings go in the root's .env${n === "server" ? `, data only the server reads in ${_}/` : ""}.`)), l = `${g$1}/data`, u = n === "server" ? o.filter((e) => e.startsWith(`${l}/`) && e.endsWith(".json")) : [], d = u.slice(0, 3).map((e$13) => e.posix.basename(e$13)), p = u.length > 0 ? [t("public-data", `${l}/`, `${l}/ holds ${String(u.length)} JSON file${u.length === 1 ? "" : "s"} (${d.join(", ")}${u.length > d.length ? ", …" : ""}), served to anyone who asks: every visitor can read all of ${u.length === 1 ? "it" : "them"}, not only what a page shows.`, `Data only the server should read goes in ${_}/ — a provider reads it on the server (runtime: 'server', query: '/data/<file>'), a function with ctx.data('<file>'), and neither serves the file. What every visitor may read can stay.`)] : [];
322
+ var p = (n, i) => {
323
+ let a = c$2(n, g$1, /* @__PURE__ */ new Set(["node_modules"])), c = a.filter((e$14) => f.test(e.posix.basename(e$14))).map((n) => t("public-secret-file", n, `${n} is served to anyone who asks, as it is — everything in ${g$1}/ is on the internet once the project is deployed — and its name says it holds a secret, a key or a database.`, `Take it out of ${g$1}/: settings go in the root's .env${i === "server" ? `, data only the server reads in ${_}/` : ""}.`)), l = `${g$1}/data`, u = i === "server" ? a.filter((e) => e.startsWith(`${l}/`) && e.endsWith(".json")) : [], d = u.slice(0, 3).map((e$15) => e.posix.basename(e$15)), p = u.length > 0 ? [t("public-data", `${l}/`, `${l}/ holds ${String(u.length)} JSON file${u.length === 1 ? "" : "s"} (${d.join(", ")}${u.length > d.length ? ", …" : ""}), served to anyone who asks: every visitor can read all of ${u.length === 1 ? "it" : "them"}, not only what a page shows.`, `Data only the server should read goes in ${_}/ — a provider reads it on the server (runtime: 'server', query: '/data/<file>'), a function with ctx.data('<file>'), and neither serves the file. What every visitor may read can stay.`)] : [];
328
324
  return [...c, ...p];
329
325
  };
330
- //#endregion
331
- //#region ../sdk-shared/dist/project/layout/folders.mjs
326
+ // ../sdk-shared/dist/project/layout/folders.mjs
332
327
  var x = (e, t) => t.map((t) => e.find((e) => u$2(e, t))).find((e) => e !== void 0);
333
- var S = (e$5) => (t) => {
334
- for (let n of o$2(e.join(e$5, t)).folders) {
335
- let i = x(o$2(e.join(e$5, t, n)).files, [...u$3, d$2]);
336
- if (i) return `${t}/${n}/${i}`;
328
+ var S = (e$6) => (t) => {
329
+ for (let n of o$2(e.join(e$6, t)).folders) {
330
+ let r = x(o$2(e.join(e$6, t, n)).files, [...u$3, d$2]);
331
+ if (r) return `${t}/${n}/${r}`;
337
332
  }
338
333
  };
339
- var C = (e$6) => (t) => {
340
- let n = x(o$2(e.join(e$6, t)).files, ["index.ts"]);
334
+ var C = (e$7) => (t) => {
335
+ let n = x(o$2(e.join(e$7, t)).files, ["index.ts"]);
341
336
  return n ? `${t}/${n}` : void 0;
342
337
  };
343
- var w = (e, { mode: t, space: n }) => [
338
+ var w = (i, { mode: a, space: u }) => [
344
339
  {
345
340
  at: l$3,
346
341
  reads: `the server builds plugins from ${l$3}/ only`,
347
- holds: S(e)
342
+ holds: S(i)
348
343
  },
349
344
  {
350
345
  at: y$1,
351
346
  reads: `the project's functions are built from ${y$1}/ only`,
352
- holds: C(e)
347
+ holds: C(i)
353
348
  },
354
349
  {
355
350
  at: b$1,
356
351
  reads: `the space's runtime is run from ${b$1}/ only`,
357
- holds: C(e)
352
+ holds: C(i)
358
353
  },
359
- ...n === "local" ? [{
360
- at: s$4,
361
- reads: `the server's entry point and ${o$3} import the space from ${c$3}`,
362
- holds: C(e)
354
+ ...u === "local" ? [{
355
+ at: s$3,
356
+ reads: `the server's entry point and ${o$3} import the space from ${c$4}`,
357
+ holds: C(i)
363
358
  }] : [],
364
- ...t === "server" ? [{
359
+ ...a === "server" ? [{
365
360
  at: _,
366
361
  reads: `the server reads the project's data from ${_}/ only (/data/<file>, ctx.data)`
367
362
  }] : [],
@@ -370,66 +365,65 @@ var w = (e, { mode: t, space: n }) => [
370
365
  reads: `the server serves ${g$1}/ only, at the site's root`
371
366
  }
372
367
  ];
373
- var T = (e$7, t) => {
374
- let n = e.posix.dirname(t), i = e.posix.basename(t), a = n === "." ? "src" : ".", s = o$2(e.join(e$7, n)).folders.filter((e) => p$1(e, i)).map((e$8) => e.posix.join(n, e$8)), c = o$2(e.join(e$7, a)).folders.filter((e) => e === i || p$1(e, i)).map((e$9) => e.posix.join(a, e$9));
375
- return [...s, ...c];
368
+ var T = (e$8, t) => {
369
+ let n = e.posix.dirname(t), r = e.posix.basename(t), i = n === "." ? "src" : ".", a = o$2(e.join(e$8, n)).folders.filter((e) => p$1(e, r)).map((e$9) => e.posix.join(n, e$9)), o = o$2(e.join(e$8, i)).folders.filter((e) => e === r || p$1(e, r)).map((e$10) => e.posix.join(i, e$10));
370
+ return [...a, ...o];
376
371
  };
377
- var E = (r, o) => w(r, o).flatMap(({ at: o, reads: c, holds: l }) => T(r, o).map((u) => {
378
- let d = l?.(u), f = u$2(u, o), p = `did you mean ${o}/? ${d$1(c)}.${f ? ` ${m$1}` : ""}`, m = `Move it: ${h$1(u, o)}`;
379
- f ? m = `Rename it: ${h$1(u, o)}` : s$2(r, o, "folder") && (m = `Move what it holds into ${o}/, and delete it.`);
380
- let h = {
372
+ var E = (e, t$3) => w(e, t$3).flatMap(({ at: t$2, reads: n, holds: r }) => T(e, t$2).map((i) => {
373
+ let a = r?.(i), o = u$2(i, t$2), s = `did you mean ${t$2}/? ${d$1(n)}.${o ? ` ${m$1}` : ""}`, c = `Move it: ${h$1(i, t$2)}`;
374
+ o ? c = `Rename it: ${h$1(i, t$2)}` : s$2(e, t$2, "folder") && (c = `Move what it holds into ${t$2}/, and delete it.`);
375
+ let l = {
381
376
  action: "move",
382
- from: `${u}/`,
383
- to: `${o}/`
377
+ from: `${i}/`,
378
+ to: `${t$2}/`
384
379
  };
385
- return d ? t("folder-misplaced", `${u}/`, `${u}/ holds ${d}, and nothing reads it there — ${p}`, m, h) : t("folder-near-miss", `${u}/`, `${u}/ is read by nothing — ${p}`, m, h);
380
+ return a ? t("folder-misplaced", `${i}/`, `${i}/ holds ${a}, and nothing reads it there — ${s}`, c, l) : t("folder-near-miss", `${i}/`, `${i}/ is read by nothing — ${s}`, c, l);
386
381
  }));
387
- var D = (t$2, n) => {
388
- if (!s$2(t$2, "src/space/index.ts", "file")) return n.some((e) => e.code === "folder-misplaced" && e.autofix?.action === "move" && e.autofix.to === "src/space/") ? [] : T$1(t$2, {
389
- folder: s$4,
382
+ var D = (t$4, n) => {
383
+ if (!s$2(t$4, "src/space/index.ts", "file")) return n.some((e) => e.code === "folder-misplaced" && e.autofix?.action === "move" && e.autofix.to === "src/space/") ? [] : T$1(t$4, {
384
+ folder: s$3,
390
385
  accepted: ["index.ts"],
391
386
  code: "space-entry-missing",
392
- lost: `the server's entry point and ${o$3}, which import the space from ${c$3}, do not start`,
393
- write: `Write ${c$3} exporting the space — export const space = { name, permanentUrl, pages } — or bring back the one git has: git checkout -- ${c$3}`
387
+ lost: `the server's entry point and ${o$3}, which import the space from ${c$4}, do not start`,
388
+ write: `Write ${c$4} exporting the space — export const space = { name, permanentUrl, pages } — or bring back the one git has: git checkout -- ${c$4}`
394
389
  });
395
- let r = readFileSync(e.join(t$2, c$3), "utf-8"), a = /^\s*export\s+default\b/m.test(r), o = /\bexport\s+(?:const|let|var|function)\s+space\b/.test(r) || /\bexport\s*\{[^}]*\bspace\b[^}]*\}/.test(r);
396
- return a && !o ? [t("space-default-export", c$3, `${c$3} exports the space by default, and it is imported by name — import { space } from './space/index.ts' — so the server's entry point and ${o$3} find no space.`, "Export it as `export const space = …` instead of `export default …`.")] : [];
390
+ let r = readFileSync(e.join(t$4, c$4), "utf-8"), i = /^\s*export\s+default\b/m.test(r), a = /\bexport\s+(?:const|let|var|function)\s+space\b/.test(r) || /\bexport\s*\{[^}]*\bspace\b[^}]*\}/.test(r);
391
+ return i && !a ? [t("space-default-export", c$4, `${c$4} exports the space by default, and it is imported by name — import { space } from './space/index.ts' — so the server's entry point and ${o$3} find no space.`, "Export it as `export const space = …` instead of `export default …`.")] : [];
397
392
  };
398
- //#endregion
399
- //#region ../sdk-shared/dist/project/layout/check.mjs
400
- var m = (t) => {
393
+ // ../sdk-shared/dist/project/layout/check.mjs
394
+ var m = (e$5) => {
401
395
  try {
402
- let n = JSON.parse(readFileSync(e.join(t, "package.json"), "utf-8"));
403
- return e$2(n) && [n.dependencies, n.devDependencies].some((t) => e$2(t) && "@plitzi/sdk-server" in t);
396
+ let t = JSON.parse(readFileSync(e.join(e$5, "package.json"), "utf-8"));
397
+ return e$2(t) && [t.dependencies, t.devDependencies].some((e) => e$2(e) && "@plitzi/sdk-server" in e);
404
398
  } catch {
405
399
  return !1;
406
400
  }
407
401
  };
408
- var h = (e, n) => ({
409
- mode: n.mode ?? (m(e) ? "server" : "client"),
410
- space: n.space ?? (s$2(e, "src/space", "folder") || s$2(e, ".plitzi/author.ts", "file") ? "local" : "cloud")
402
+ var h = (e, t) => ({
403
+ mode: t.mode ?? (m(e) ? "server" : "client"),
404
+ space: t.space ?? (s$2(e, "src/space", "folder") || s$2(e, ".plitzi/author.ts", "file") ? "local" : "cloud")
411
405
  });
412
- var g = (e, t = {}) => {
413
- let f = h(e, t), p$3 = E(e, f), m = [
414
- ...N(e),
415
- ...E$1(e, {
406
+ var g = (r, o = {}) => {
407
+ let f = h(r, o), p$3 = E(r, f), m = [
408
+ ...N(r),
409
+ ...E$1(r, {
416
410
  folder: y$1,
417
411
  code: "functions-entry-missing",
418
412
  lost: "none of the project’s functions runs",
419
413
  write: `Write the domain's file at the top of ${y$1}/ (rooms.ts) exporting defineFunctions({ tasks: [ … ] }) by default — a domain a file, nothing to list.`
420
414
  }),
421
- ...D$1(e, {
415
+ ...D$1(r, {
422
416
  folder: b$1,
423
417
  accepted: ["index.ts"],
424
418
  code: "runtime-entry-missing",
425
419
  lost: "the space’s runtime does not run",
426
420
  write: `Write ${b$1}/index.ts exporting defineRuntime(…) by default — npx plitzi runtime add writes one.`
427
421
  }),
428
- ...f.space === "local" ? D(e, p$3) : [],
422
+ ...f.space === "local" ? D(r, p$3) : [],
429
423
  ...p$3,
430
- ...u$1(e),
431
- ...f.mode === "server" ? d(e) : [],
432
- ...p(e, f.mode)
424
+ ...u$1(r),
425
+ ...f.mode === "server" ? d(r) : [],
426
+ ...p(r, f.mode)
433
427
  ];
434
428
  return [...m.filter((e) => e.level === "error"), ...m.filter((e) => e.level === "warning")];
435
429
  };
@@ -449,8 +443,7 @@ var y = (e, t = {}) => {
449
443
  if (r.length > 0) throw new v(r);
450
444
  return n;
451
445
  };
452
- //#endregion
453
- //#region ../sdk-shared/dist/project/root.mjs
446
+ // ../sdk-shared/dist/project/root.mjs
454
447
  var a$1 = ["package.json", "src/"];
455
448
  var o$1 = class extends Error {
456
449
  constructor(e, t) {
@@ -472,11 +465,10 @@ var l = (e$4) => {
472
465
  }
473
466
  };
474
467
  var u = (n, r, i) => {
475
- let a = l(e.join(n, S$1)), o = i !== void 0 && l(i).startsWith(`${a}${e.sep}`);
476
- return e.join(n, o ? e.join(S$1, e.relative("src", r)).replace(/\.tsx?$/, ".js") : r);
468
+ let a = l(e.join(n, C$1)), o = i !== void 0 && l(i).startsWith(`${a}${e.sep}`);
469
+ return e.join(n, o ? e.join(C$1, e.relative("src", r)).replace(/\.tsx?$/, ".js") : r);
477
470
  };
478
- //#endregion
479
- //#region ../sdk-shared/dist/project/pages/index.mjs
471
+ // ../sdk-shared/dist/project/pages/index.mjs
480
472
  var r = /\.(?:[cm]?[jt]sx?)$/;
481
473
  var i = /\.(?:test|spec)\.[cm]?[jt]sx?$|\.d\.[cm]?ts$/;
482
474
  var a = [
@@ -489,8 +481,7 @@ var o = (o) => existsSync(o) ? readdirSync(o, { withFileTypes: !0 }).flatMap((n)
489
481
  let s = n.isDirectory() ? a.find((r) => existsSync(e.join(o, n.name, r))) : void 0;
490
482
  return s ? [e.join(o, n.name, s)] : [];
491
483
  }).sort() : [];
492
- //#endregion
493
- //#region src/preview.ts
484
+ // src/preview.ts
494
485
  /**
495
486
  * Why the element asked to be drawn alone cannot be: a name that is no component or type, an address the space uses, a
496
487
  * file that is not one. Its message is the whole report — a project's server says it alone, with no stack.
@@ -502,8 +493,8 @@ var SpacePreviewError = class extends Error {
502
493
  }
503
494
  };
504
495
  Object.defineProperty(SpacePreviewError, "name", { value: "SpacePreviewError" });
505
- var PREVIEW_ID = M$1;
506
- var BUILT_IN = new Set(Object.values(J).map((declaration) => declaration.type));
496
+ var PREVIEW_ID = N$1;
497
+ var BUILT_IN = new Set(Object.values(Y).map((declaration) => declaration.type));
507
498
  /** A preview file read as one, or why it is not, said whole. */
508
499
  var parsePreview = (value) => {
509
500
  if (!e$2(value) || typeof value.element !== "string" || value.element === "") return { problem: "it names no element: write { \"element\": \"<a component or an element type>\", \"copies\": [{ … }] }" };
@@ -519,14 +510,14 @@ var parsePreview = (value) => {
519
510
  * and classes as any page has them. A page the space already answers there is refused: the preview would hide it.
520
511
  */
521
512
  var withPreview = (space, preview, pluginTypes = []) => {
522
- if (space.pages.some((page) => page.slug === "plitzi-preview" && page.folder === void 0)) throw new SpacePreviewError(`The space has a page at /${M$1} already: an element is drawn alone there — rename that page's slug to look at one`);
513
+ if (space.pages.some((page) => page.slug === "plitzi-preview" && page.folder === void 0)) throw new SpacePreviewError(`The space has a page at /${N$1} already: an element is drawn alone there — rename that page's slug to look at one`);
523
514
  const components = (space.components ?? []).map((each) => each.id);
524
515
  const isComponent = components.includes(preview.element);
525
516
  if (!isComponent && !pluginTypes.includes(preview.element) && !BUILT_IN.has(preview.element)) throw new SpacePreviewError(`"${preview.element}" is no component of the space and no element type to draw alone: its components are ${components.join(", ") || "none"}; its plugins' elements ${pluginTypes.join(", ") || "none"} — or a built-in type (heading, container…)`);
526
517
  const page = {
527
518
  id: PREVIEW_ID,
528
519
  name: `${preview.element}, alone`,
529
- slug: M$1,
520
+ slug: N$1,
530
521
  robots: "noindex, nofollow",
531
522
  body: [container({
532
523
  id: `${PREVIEW_ID}-copies`,
@@ -537,11 +528,11 @@ var withPreview = (space, preview, pluginTypes = []) => {
537
528
  padding: "48px 24px"
538
529
  },
539
530
  children: preview.copies.map((copy, index) => isComponent ? component(preview.element, {
540
- id: N$1(index),
531
+ id: P(index),
541
532
  props: copy
542
533
  }) : element(preview.element, {
543
534
  ...copy,
544
- id: N$1(index)
535
+ id: P(index)
545
536
  }))
546
537
  })]
547
538
  };
@@ -555,20 +546,19 @@ var withPreview = (space, preview, pluginTypes = []) => {
555
546
  * one is refused, saying what to write — never a space served without the page it was started to draw.
556
547
  */
557
548
  var previewOfProcess = () => {
558
- const file = process.env[j$1];
549
+ const file = process.env[M$1];
559
550
  if (file === void 0 || file === "") return;
560
551
  let value;
561
552
  try {
562
553
  value = JSON.parse(readFileSync(file, "utf-8"));
563
554
  } catch (error) {
564
- throw new SpacePreviewError(`${j$1} names ${file}, which is not JSON to read: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
555
+ throw new SpacePreviewError(`${M$1} names ${file}, which is not JSON to read: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
565
556
  }
566
557
  const preview = parsePreview(value);
567
- if ("problem" in preview) throw new SpacePreviewError(`${j$1} names ${file}, which is not an element to draw alone: ${preview.problem}`);
558
+ if ("problem" in preview) throw new SpacePreviewError(`${M$1} names ${file}, which is not an element to draw alone: ${preview.problem}`);
568
559
  return preview;
569
560
  };
570
- //#endregion
571
- //#region src/isolated.ts
561
+ // src/isolated.ts
572
562
  /** The `node_modules` nearest the module that has `@plitzi/sdk-authoring` in it: where its imports resolve. */
573
563
  var modulesOf = (dir) => {
574
564
  for (let at = dir;; at = e.dirname(at)) {
@@ -777,8 +767,7 @@ var authorIsolated = (file, options = {}) => {
777
767
  });
778
768
  });
779
769
  };
780
- //#endregion
781
- //#region src/node.ts
770
+ // src/node.ts
782
771
  /**
783
772
  * What only an author running on Node can do: read the project's own files. A separate entry, so the package's main
784
773
  * one stays what it is — data and functions over data, for a browser as much as a build script.
@@ -1092,17 +1081,45 @@ var importProjectModule = async (file, root) => {
1092
1081
  * rest of it, field by field, and says what is wrong — so this only has to tell a space from anything else.
1093
1082
  */
1094
1083
  var isSpaceSpec = (value) => e$2(value) && typeof value.name === "string" && typeof value.permanentUrl === "string" && Array.isArray(value.pages);
1084
+ /** The names a project's icon is found by, the first there winning: a vector first, then a picture, then the classic. */
1085
+ var ICON_NAMES = [
1086
+ "favicon.svg",
1087
+ "favicon.png",
1088
+ "favicon.ico"
1089
+ ];
1090
+ /**
1091
+ * The icon a project keeps, by its name, for a space that names none (`settings.favicon`): in `public/assets/` first —
1092
+ * served by a project's own server, and put on the space's CDN by `plitzi space push` — else in `public/`, which only a
1093
+ * project's own server serves (push says so). As the page names it: `/assets/favicon.svg`, `/favicon.svg`.
1094
+ */
1095
+ var projectIcon = (root) => {
1096
+ for (const folder of ["assets", ""]) {
1097
+ const name = ICON_NAMES.find((file) => existsSync(e.join(root, g$1, folder, file)));
1098
+ if (name) return `/${folder ? `${folder}/` : ""}${name}`;
1099
+ }
1100
+ };
1101
+ /** The space with the project's icon when it names none of its own: one it names is never replaced. */
1102
+ var withProjectIcon = (space, root) => {
1103
+ const icon = space.settings?.favicon === void 0 ? projectIcon(root) : void 0;
1104
+ return icon === void 0 ? space : {
1105
+ ...space,
1106
+ settings: {
1107
+ ...space.settings,
1108
+ favicon: icon
1109
+ }
1110
+ };
1111
+ };
1095
1112
  /**
1096
1113
  * `projectSpace` of the project at `root`, held to the same checks: for a tool that works on a project from another
1097
1114
  * folder — the CLI, run anywhere inside one. A project's own code calls `projectSpace()` or `authorProjectSpace()`.
1098
1115
  */
1099
1116
  var projectSpaceAt = async (root) => {
1100
1117
  const authoring = await projectAuthoringAt(root);
1101
- const module = await importProjectModule(u(root, c$3, process.argv[1]), root);
1118
+ const module = await importProjectModule(u(root, c$4, process.argv[1]), root);
1102
1119
  const space = e$2(module) ? module.space : void 0;
1103
- if (!isSpaceSpec(space)) throw new ProjectSpaceError(c$3);
1120
+ if (!isSpaceSpec(space)) throw new ProjectSpaceError(c$4);
1104
1121
  return {
1105
- space,
1122
+ space: withProjectIcon(space, root),
1106
1123
  authoring
1107
1124
  };
1108
1125
  };
@@ -1128,5 +1145,4 @@ var authorProjectSpace = async () => {
1128
1145
  const { space, authoring } = await projectSpace();
1129
1146
  return authorSpace(space, authoring);
1130
1147
  };
1131
- //#endregion
1132
- export { ProjectModuleError, ProjectSpaceError, actionsIn, authorIsolated, authorProjectSpace, compactSvg, moduleProblem, pagesIn, pluginDeclarations, pluginFolders, pluginStylesheets, projectAuthoring, projectAuthoringAt, projectData, projectSpace, projectSpaceAt, publicData, svgFile, svgFiles };
1148
+ export { ProjectModuleError, ProjectSpaceError, actionsIn, authorIsolated, authorProjectSpace, compactSvg, moduleProblem, pagesIn, pluginDeclarations, pluginFolders, pluginStylesheets, projectAuthoring, projectAuthoringAt, projectData, projectIcon, projectSpace, projectSpaceAt, publicData, svgFile, svgFiles };
package/dist/plugin.d.ts CHANGED
@@ -610,6 +610,11 @@ declare type RuleGroup = {
610
610
  enabled?: boolean;
611
611
  };
612
612
 
613
+ /**
614
+ * A condition as Plitzi stores it — a flag's rules, an interaction's `when`, a binding's condition: the schema's own
615
+ * format, so sdk-shared defines it (RFC 0032, D13). plitzi-ui's QueryBuilder edits the same shape with prop types of its
616
+ * own, and a type test in the builder, where the two meet, holds them assignable both ways.
617
+ */
613
618
  declare type RuleValue = Date | string | number | boolean | undefined | null | object;
614
619
 
615
620
  declare type SpaceCredentialProvider = 's3' | 'r2' | 'ssr' | 'custom' | 'smtp';