@mistriwork/engine 1.0.0-rc.43 → 1.0.0-rc.44

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.
@@ -153,8 +153,10 @@ interface PageDecl {
153
153
  actions: string[];
154
154
  /** The address parameters the page keeps its place in: `/{app}/pick-walk?list=12`. */
155
155
  params: string[];
156
- /** The loader that reads for it on the server, by its name in the commands module (`defineLoaders`). */
156
+ /** The loader that reads for it on the server, by its name in the commands module (`defineLoaders`); its result is the page's `data`. */
157
157
  loader?: string;
158
+ /** More loaders the page runs by name (`useLoader`), each with a cache entry and a loading state of its own. */
159
+ loaders?: string[];
158
160
  props: Record<string, unknown>;
159
161
  }
160
162
  /**
@@ -361,8 +361,9 @@ export function parseCustomList(raw, at) {
361
361
  throw new Error(`${at} names one column twice in "show".`);
362
362
  return { kind: 'custom', component, show: columns, props: componentPropValues(component, raw.props, at) };
363
363
  }
364
- /** The most address parameters one page keeps. */
364
+ /** The most address parameters one page keeps, and the most loaders it names. */
365
365
  const MAX_PAGE_PARAMS = 8;
366
+ const MAX_PAGE_LOADERS = 8;
366
367
  const PARAM = /^[a-z][a-z0-9_]{0,31}$/;
367
368
  const LOADER = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
368
369
  /* A parameter's kind is how the page reads its text back (sdk/page.tsx): the address always holds text. */
@@ -418,6 +419,17 @@ export function parsePage(raw, at) {
418
419
  if (raw.loader !== undefined && (typeof raw.loader !== 'string' || !LOADER.test(raw.loader))) {
419
420
  throw new Error(`[page-loader] ${at} has a "loader" that is not a loader's name, as the commands module's defineLoaders() registers it.`);
420
421
  }
422
+ if (raw.loaders !== undefined) {
423
+ const named = raw.loaders;
424
+ if (!Array.isArray(named) ||
425
+ !named.length ||
426
+ named.length > MAX_PAGE_LOADERS ||
427
+ named.some((name) => typeof name !== 'string' || !LOADER.test(name))) {
428
+ throw new Error(`[page-loader] ${at} has "loaders" that are not up to ${MAX_PAGE_LOADERS} loader names, as the commands module's defineLoaders() registers them: loaders: ['board', 'dueFigure'].`);
429
+ }
430
+ if (new Set(named).size !== named.length || (raw.loader !== undefined && named.includes(raw.loader)))
431
+ throw new Error(`[page-loader] ${at} names a loader twice: "loader" and "loaders" together name each loader once.`);
432
+ }
421
433
  return {
422
434
  component,
423
435
  reads: [...new Set(reads.map((name) => name.trim()))],
@@ -425,6 +437,7 @@ export function parsePage(raw, at) {
425
437
  actions: [...new Set(actions.map((name) => name.trim()))],
426
438
  params: [...new Set(params)],
427
439
  ...(raw.loader === undefined ? {} : { loader: raw.loader }),
440
+ ...(raw.loaders === undefined ? {} : { loaders: [...raw.loaders] }),
428
441
  props: componentPropValues(component, raw.props, at),
429
442
  };
430
443
  }
@@ -20,9 +20,10 @@ export declare function parseDocument(raw: unknown, at: string): PageDocument;
20
20
  /**
21
21
  * What a document's sections may be, refused section by section: paper has no
22
22
  * aside, no tabs and nothing to operate, and a list on it is every line — a
23
- * table whose header repeats on each sheet — never a gallery, a card or a
24
- * page of rows. Its lists read every line, up to DOCUMENT_LINES, unless the
25
- * author says fewer.
23
+ * table whose header repeats on each sheet — or, over a file resource, its
24
+ * pictures (a gallery, drawn as a grid, with no lightbox to open), never
25
+ * cards or a page of rows. Its lists read every line, up to DOCUMENT_LINES
26
+ * (DOCUMENT_PICTURES for pictures), unless the author says fewer.
26
27
  */
27
28
  export declare function documentSections(sections: readonly PageSection[], at: string): PageSection[];
28
29
  /** The sheet a document is printed on: its own `size`, else the paper the App's (or tenant's) locale buys. */
@@ -30,6 +30,8 @@ const DOCUMENT_SIZES = ['a4', 'letter'];
30
30
  const DOCUMENT_SECTION_KINDS = ['fields', 'list', 'note'];
31
31
  /** Every line is on paper, up to the most a related list reads at once; a page that would be longer says so. */
32
32
  const DOCUMENT_LINES = 500;
33
+ /** A list of pictures is read on the reader's lease one file at a time, and each takes a sheet's room: fewer by default. */
34
+ const DOCUMENT_PICTURES = 24;
33
35
  /** A page's document, as one page body states it. */
34
36
  export function parseDocument(raw, at) {
35
37
  const where = `${at}, "document"`;
@@ -55,9 +57,10 @@ export function parseDocument(raw, at) {
55
57
  /**
56
58
  * What a document's sections may be, refused section by section: paper has no
57
59
  * aside, no tabs and nothing to operate, and a list on it is every line — a
58
- * table whose header repeats on each sheet — never a gallery, a card or a
59
- * page of rows. Its lists read every line, up to DOCUMENT_LINES, unless the
60
- * author says fewer.
60
+ * table whose header repeats on each sheet — or, over a file resource, its
61
+ * pictures (a gallery, drawn as a grid, with no lightbox to open), never
62
+ * cards or a page of rows. Its lists read every line, up to DOCUMENT_LINES
63
+ * (DOCUMENT_PICTURES for pictures), unless the author says fewer.
61
64
  */
62
65
  export function documentSections(sections, at) {
63
66
  return sections.map((section, i) => {
@@ -74,8 +77,10 @@ export function documentSections(sections, at) {
74
77
  throw new Error(`${where} has "actions"; paper has nothing to press.`);
75
78
  if (section.kind !== 'list')
76
79
  return section;
77
- if (section.presentation !== undefined || section.create || section.rowActions)
78
- throw new Error(`${where} is a list of the record's lines on paper: no presentation, create or row actions.`);
80
+ if ((section.presentation !== undefined && section.presentation !== 'gallery') || section.create || section.rowActions)
81
+ throw new Error(`${where} is a list of the record's lines on paper: no cards, create or row actions.`);
82
+ if (section.presentation === 'gallery')
83
+ return section.limit === undefined ? { ...section, limit: DOCUMENT_PICTURES } : section;
79
84
  return section.limit === undefined ? { ...section, limit: DOCUMENT_LINES } : section;
80
85
  });
81
86
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistriwork/engine",
3
- "version": "1.0.0-rc.43",
3
+ "version": "1.0.0-rc.44",
4
4
  "description": "The engine both products stand on: the adapters (SQLite, Postgres), the catalog, the query language, keyset pages, the HTTP kit and the shared rules. No React.",
5
5
  "homepage": "https://mistriwork.dev",
6
6
  "bugs": {