@graview/core 0.1.70 → 0.1.71

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 (90) hide show
  1. package/dist/cli/check/hidden-reads.d.ts.map +1 -1
  2. package/dist/cli/check/hidden-reads.js +7 -0
  3. package/dist/cli/check/hidden-reads.js.map +1 -1
  4. package/dist/css/fonts.d.ts +8 -0
  5. package/dist/css/fonts.d.ts.map +1 -1
  6. package/dist/css/fonts.js +8 -0
  7. package/dist/css/fonts.js.map +1 -1
  8. package/dist/css.d.ts +1 -1
  9. package/dist/css.d.ts.map +1 -1
  10. package/dist/css.js +1 -1
  11. package/dist/css.js.map +1 -1
  12. package/dist/document/act-findings.d.ts.map +1 -1
  13. package/dist/document/act-findings.js +51 -1
  14. package/dist/document/act-findings.js.map +1 -1
  15. package/dist/document/blocks.d.ts.map +1 -1
  16. package/dist/document/blocks.js +5 -1
  17. package/dist/document/blocks.js.map +1 -1
  18. package/dist/document/brand-check.d.ts +1 -1
  19. package/dist/document/brand-check.d.ts.map +1 -1
  20. package/dist/document/brand-check.js +1 -1
  21. package/dist/document/brand-check.js.map +1 -1
  22. package/dist/document/compile-checked.d.ts.map +1 -1
  23. package/dist/document/compile-checked.js +2 -1
  24. package/dist/document/compile-checked.js.map +1 -1
  25. package/dist/document/compile.d.ts.map +1 -1
  26. package/dist/document/compile.js +9 -6
  27. package/dist/document/compile.js.map +1 -1
  28. package/dist/document/compiled.d.ts.map +1 -1
  29. package/dist/document/compiled.js +35 -9
  30. package/dist/document/compiled.js.map +1 -1
  31. package/dist/document/design-findings.d.ts.map +1 -1
  32. package/dist/document/design-findings.js +8 -2
  33. package/dist/document/design-findings.js.map +1 -1
  34. package/dist/document/edit.d.ts.map +1 -1
  35. package/dist/document/edit.js +34 -4
  36. package/dist/document/edit.js.map +1 -1
  37. package/dist/document/expr/analyze.d.ts.map +1 -1
  38. package/dist/document/expr/analyze.js +11 -3
  39. package/dist/document/expr/analyze.js.map +1 -1
  40. package/dist/document/expr/evaluate.d.ts +2 -0
  41. package/dist/document/expr/evaluate.d.ts.map +1 -1
  42. package/dist/document/expr/evaluate.js +46 -8
  43. package/dist/document/expr/evaluate.js.map +1 -1
  44. package/dist/document/expr/index.d.ts +1 -0
  45. package/dist/document/expr/index.d.ts.map +1 -1
  46. package/dist/document/expr/index.js +1 -0
  47. package/dist/document/expr/index.js.map +1 -1
  48. package/dist/document/expr/parse.d.ts.map +1 -1
  49. package/dist/document/expr/parse.js +7 -3
  50. package/dist/document/expr/parse.js.map +1 -1
  51. package/dist/document/expr/subject.d.ts +24 -0
  52. package/dist/document/expr/subject.d.ts.map +1 -0
  53. package/dist/document/expr/subject.js +21 -0
  54. package/dist/document/expr/subject.js.map +1 -0
  55. package/dist/document/expr/typing.d.ts.map +1 -1
  56. package/dist/document/expr/typing.js +6 -2
  57. package/dist/document/expr/typing.js.map +1 -1
  58. package/dist/document/guard-names.d.ts +11 -0
  59. package/dist/document/guard-names.d.ts.map +1 -0
  60. package/dist/document/guard-names.js +185 -0
  61. package/dist/document/guard-names.js.map +1 -0
  62. package/dist/document/rule-reads.d.ts.map +1 -1
  63. package/dist/document/rule-reads.js +7 -1
  64. package/dist/document/rule-reads.js.map +1 -1
  65. package/dist/document/template.d.ts +2 -0
  66. package/dist/document/template.d.ts.map +1 -1
  67. package/dist/document/template.js +5 -1
  68. package/dist/document/template.js.map +1 -1
  69. package/dist/document/views.d.ts.map +1 -1
  70. package/dist/document/views.js +4 -0
  71. package/dist/document/views.js.map +1 -1
  72. package/dist/document.schema.json +2 -2
  73. package/dist/graph/graph.d.ts +13 -0
  74. package/dist/graph/graph.d.ts.map +1 -1
  75. package/dist/graph/graph.js +13 -5
  76. package/dist/graph/graph.js.map +1 -1
  77. package/dist/mutations/define-mutation.d.ts +2 -0
  78. package/dist/mutations/define-mutation.d.ts.map +1 -1
  79. package/dist/mutations/define-mutation.js +5 -5
  80. package/dist/mutations/define-mutation.js.map +1 -1
  81. package/dist/mutations/keep-link.js +2 -2
  82. package/dist/mutations/keep-link.js.map +1 -1
  83. package/dist/store.d.ts +44 -0
  84. package/dist/store.d.ts.map +1 -1
  85. package/dist/store.js +99 -8
  86. package/dist/store.js.map +1 -1
  87. package/dist/theme/types.d.ts +2 -2
  88. package/dist/version.d.ts +1 -1
  89. package/dist/version.js +1 -1
  90. package/package.json +1 -1
package/dist/store.js CHANGED
@@ -29,7 +29,7 @@ import { MOST_PROPOSED, PROPOSE_CHANGES, proposeChangesMutation } from "./mutati
29
29
  import { namesUnseen, redact } from "./ops/withheld.js";
30
30
  import { writersBehind } from "./ops/writers.js";
31
31
  import { nounOf } from "./schema/define-node.js";
32
- import { behind, fieldsJudged, mayKeepField, partialSight, recordsOf } from "./permissions/sight.js";
32
+ import { behind, fieldsJudged, mayKeepField, partialSight, recordsOf, sees } from "./permissions/sight.js";
33
33
  import { PermissionDeniedError } from "./permissions/types.js";
34
34
  import { checkUndo, UndoBlockedError, undoneInverses, undoPrimitives } from "./ops/undo.js";
35
35
  import { validateGraph } from "./validate-graph.js";
@@ -251,6 +251,8 @@ export class Store {
251
251
  past;
252
252
  /** How often `pastOf` keeps a point to fold from, in ops (`StoreOptions.pastEvery`). */
253
253
  pastEvery;
254
+ /** What `version` reads: each time this store told its subscribers something, or would have. */
255
+ told = 0;
254
256
  listeners = new Set();
255
257
  constructor(options) {
256
258
  this.pastEvery = Math.max(1, options.pastEvery ?? 64);
@@ -919,7 +921,9 @@ export class Store {
919
921
  me: author && meIn(this.schema, author),
920
922
  everHeld: (id) => recordsOf(this.log).kindOf(id) !== undefined,
921
923
  keeps: (kind, field) => mayKeepField(this.policy?.sees, kind, field),
922
- ...(author && this.hasNoRecord(author) ? { noRecord: true } : {}),
924
+ ...(author && this.hasNoRecord(author, false) ? { noRecord: true } : {}),
925
+ // Kept from its own person by its sight: an act declared as done as its author is refused, in words; another act's `ctx.me` is as it was.
926
+ ...(author && !this.hasNoRecord(author, false) && this.hasNoRecord(author) ? { selfUnseen: true } : {}),
923
927
  // The host's own may ask for an id a seat may not: it could write the same through `applyPrimitives`.
924
928
  ...(author && isSystem(author) ? { hostsOwn: true } : {}),
925
929
  };
@@ -1079,7 +1083,7 @@ export class Store {
1079
1083
  const derived = all.filter((mutation) => mutation.derived !== undefined &&
1080
1084
  permits(this.policy, principal, mutation.name, mutation.derived.kind, this.viaOf(mutation), actingAs(principal).id).ok);
1081
1085
  const offered = [...declared, ...publishing, ...derived];
1082
- return profileOf(principal) ? offered.filter((mutation) => !this.noOneToBe(mutation, principal)) : offered;
1086
+ return offered.filter((mutation) => !this.noOneToBe(mutation, principal));
1083
1087
  }
1084
1088
  /**
1085
1089
  * The kind a call acts on, read off the mutation's own subject binding.
@@ -1177,6 +1181,8 @@ export class Store {
1177
1181
  const before = this.violations();
1178
1182
  this.ticked = { day, on };
1179
1183
  const moved = this.moved(before, this.violations());
1184
+ if (day !== was)
1185
+ this.told += 1;
1180
1186
  if (day !== was && !this.rehearsing && this.quiet === 0)
1181
1187
  for (const listener of this.listeners)
1182
1188
  listener(EMPTY_DIFF, []);
@@ -1190,6 +1196,7 @@ export class Store {
1190
1196
  * diff and no ops, so what reads through the link reads again.
1191
1197
  */
1192
1198
  reread() {
1199
+ this.told += 1;
1193
1200
  if (this.rehearsing || this.quiet > 0)
1194
1201
  return;
1195
1202
  for (const listener of this.listeners)
@@ -1262,6 +1269,67 @@ export class Store {
1262
1269
  return true;
1263
1270
  }
1264
1271
  }
1272
+ /**
1273
+ * WHAT EACH CALL WOULD DO, REHEARSING NOTHING: change something, change
1274
+ * nothing, or be refused by the act itself — compiled under the author's
1275
+ * sight, as `wouldChange` is, but a call that cannot compile hands back
1276
+ * why rather than counting as a change. The author's sight is worked out
1277
+ * once for all of them and no copy of the log is made, so a face may ask
1278
+ * it of every record it shows. The author is the store's own, unsaid, as
1279
+ * `apply`'s is; a profile whose person is not made yet is judged as the
1280
+ * person `apply` would make first, on one copy of the graph for them all.
1281
+ *
1282
+ * It does not judge what only applying judges: the policy (`permits`
1283
+ * does), the records a call needs that a host has not loaded
1284
+ * (`missingFor`), a host's `admit`, the rules the change would break, and
1285
+ * what tidying refuses (a record left alone, a change a person declined).
1286
+ */
1287
+ wouldDo(calls, author = this.by) {
1288
+ const as = withValidProfile(author);
1289
+ const person = this.personFor(as);
1290
+ return person ? this.withPersonMade(as, person.id).compiledEach(calls, as) : this.compiledEach(calls, as);
1291
+ }
1292
+ /**
1293
+ * THE STORE AS IT WOULD BE WITH A PROFILE'S PERSON MADE: one copy, kept
1294
+ * while this store's `version` stands, so every call a face asks of it in
1295
+ * one look — each act over every chosen record — is judged on the same copy.
1296
+ */
1297
+ withPersonMade(author, person) {
1298
+ const key = JSON.stringify([this.version, this.log.length, actingAs(author).id, person, profileOf(author)?.name]);
1299
+ if (this.personMade?.key === key)
1300
+ return this.personMade.twin;
1301
+ const twin = this.rehearsal();
1302
+ const made = twin.personToMake(author, PREVIEW_BATCH, {});
1303
+ if (made) {
1304
+ twin.graph.applyPrimitives(made.primitives);
1305
+ twin.log.append(made);
1306
+ }
1307
+ this.personMade = { key, twin };
1308
+ return twin;
1309
+ }
1310
+ /** The copy `withPersonMade` keeps, and the store's version and person it was made for. */
1311
+ personMade;
1312
+ compiledEach(calls, author) {
1313
+ const sighted = this.sighted(author);
1314
+ return calls.map((call) => {
1315
+ try {
1316
+ return compileMutation(this.graph, this.mutation(call.name), call.args, sighted).primitives.length > 0 ? "changes" : "nothing";
1317
+ }
1318
+ catch (error) {
1319
+ return { refused: error };
1320
+ }
1321
+ });
1322
+ }
1323
+ /**
1324
+ * HOW MANY TIMES THIS STORE HAS TOLD ITS SUBSCRIBERS SOMETHING, or would
1325
+ * have: a change, an adopt, the day turning, something read beside the
1326
+ * graph answering. What a face that keeps an answer worked out from the
1327
+ * store keys it on: the same number, the same store as far as anybody
1328
+ * reading it can tell.
1329
+ */
1330
+ get version() {
1331
+ return this.told;
1332
+ }
1265
1333
  preview(call, context, options = {}) {
1266
1334
  call = this.spelledCall(call);
1267
1335
  const definition = this.mutation(call.name);
@@ -1326,6 +1394,7 @@ export class Store {
1326
1394
  nextId: () => `${PREVIEW_BATCH}:${++made}`,
1327
1395
  mintBatch: () => PREVIEW_BATCH,
1328
1396
  rehearsing: true,
1397
+ personMade: undefined,
1329
1398
  });
1330
1399
  // Its own acts, so "Type text" reads the text back off the rehearsal's log, as the apply would off this one's.
1331
1400
  const typer = this.typer && TYPING.typeText(twin);
@@ -2106,19 +2175,38 @@ export class Store {
2106
2175
  * no person of that kind and none to be had (a record of another kind at its
2107
2176
  * id, from a restore or a host's own change, is not one), or an account whose
2108
2177
  * own id reads as a person's. With no people kind, nobody is asked to be one.
2178
+ *
2179
+ * AND A SEAT WHOSE SIGHT KEEPS ITS OWN PERSON FROM IT. An act runs under its
2180
+ * author's sight (`sighted`), where a record the author may not see is no
2181
+ * record: `$me` resolves to nothing there, so the act is not offered, and is
2182
+ * refused in the words it would refuse in, with a profile or without.
2109
2183
  */
2110
- hasNoRecord(author) {
2111
- if (!this.schema.definitions.some((definition) => definition.people))
2184
+ hasNoRecord(author, bySight = true) {
2185
+ const people = this.schema.definitions.find((definition) => definition.people);
2186
+ if (!people)
2112
2187
  return false;
2188
+ // Kept from its own person by its sight: a seat with no id of its own sees one only through a sight of the whole kind.
2189
+ const kept = (person) => bySight && !this.seesOwnPerson(author, person);
2113
2190
  if (actingAs(author).id === undefined)
2114
- return false;
2191
+ return kept({ id: "", kind: people.kind });
2115
2192
  const id = meOf(author);
2116
2193
  if (id === undefined)
2117
2194
  return true;
2195
+ const kind = this.graph.getNode(id)?.kind;
2196
+ if (kind !== undefined && this.schema.tryDefinition(kind)?.people)
2197
+ return kept({ id, kind });
2118
2198
  if (!profileOf(author))
2119
2199
  return false;
2120
- const kind = this.graph.getNode(id)?.kind;
2121
- return !(kind !== undefined && this.schema.tryDefinition(kind)?.people) && !this.personFor(author);
2200
+ const person = this.personFor(author);
2201
+ return !person || kept({ id: person.id, kind: person.node.kind });
2202
+ }
2203
+ /** Whether a seat's sight shows it its own person, there or about to be made: one with no links yet is judged as one. */
2204
+ seesOwnPerson(author, person) {
2205
+ if (!hidesFrom(this, author))
2206
+ return true;
2207
+ if (this.modules.disabledKinds.has(person.kind) && !isSystem(author))
2208
+ return false;
2209
+ return this.graph.has(person.id) ? seesId(this, author)(person.id) : sees(this.policy, author, person, { out: () => [], in: () => [] }, recordsOf(this.log), fieldsJudged(this));
2122
2210
  }
2123
2211
  /**
2124
2212
  * WHY AN ACT DONE AS `$me` IS NOT THIS SEAT'S: its profile has no person
@@ -2230,6 +2318,9 @@ export class Store {
2230
2318
  * is nothing to tell.
2231
2319
  */
2232
2320
  notify(diff, ops) {
2321
+ this.told += 1;
2322
+ // A copy kept for a profile's person not made yet is the store as it was: let it go.
2323
+ this.personMade = undefined;
2233
2324
  if (this.quiet > 0)
2234
2325
  return;
2235
2326
  if (ops.length === 0 && isEmptyDiff(diff))