@fieldia/core 0.26.1 → 0.27.0
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/README.md +307 -3
- package/package.json +1 -1
- package/schema/page.schema.json +227 -23
- package/src/index.d.mts +8 -2
- package/src/index.d.ts +8 -2
- package/src/index.js +22 -1
- package/src/index.js.map +1 -1
- package/src/index.mjs +9 -2
- package/src/index.mjs.map +1 -1
- package/src/lib/expression/app-functions.d.mts +47 -0
- package/src/lib/expression/app-functions.d.ts +47 -0
- package/src/lib/expression/app-functions.js +64 -0
- package/src/lib/expression/app-functions.js.map +1 -0
- package/src/lib/expression/app-functions.mjs +58 -0
- package/src/lib/expression/app-functions.mjs.map +1 -0
- package/src/lib/expression/dates.d.mts +21 -0
- package/src/lib/expression/dates.d.ts +21 -0
- package/src/lib/expression/dates.js +73 -0
- package/src/lib/expression/dates.js.map +1 -0
- package/src/lib/expression/dates.mjs +67 -0
- package/src/lib/expression/dates.mjs.map +1 -0
- package/src/lib/expression/evaluator.js +12 -6
- package/src/lib/expression/evaluator.js.map +1 -1
- package/src/lib/expression/evaluator.mjs +12 -6
- package/src/lib/expression/evaluator.mjs.map +1 -1
- package/src/lib/expression/expression.d.mts +7 -3
- package/src/lib/expression/expression.d.ts +7 -3
- package/src/lib/expression/expression.js +8 -2
- package/src/lib/expression/expression.js.map +1 -1
- package/src/lib/expression/expression.mjs +7 -2
- package/src/lib/expression/expression.mjs.map +1 -1
- package/src/lib/expression/functions-part.d.mts +7 -0
- package/src/lib/expression/functions-part.d.ts +7 -0
- package/src/lib/expression/functions-part.js +13 -0
- package/src/lib/expression/functions-part.js.map +1 -0
- package/src/lib/expression/functions-part.mjs +8 -0
- package/src/lib/expression/functions-part.mjs.map +1 -0
- package/src/lib/expression/functions.d.mts +60 -3
- package/src/lib/expression/functions.d.ts +60 -3
- package/src/lib/expression/functions.js +109 -15
- package/src/lib/expression/functions.js.map +1 -1
- package/src/lib/expression/functions.mjs +103 -16
- package/src/lib/expression/functions.mjs.map +1 -1
- package/src/lib/expression/kinds.d.mts +31 -0
- package/src/lib/expression/kinds.d.ts +31 -0
- package/src/lib/expression/kinds.js +159 -0
- package/src/lib/expression/kinds.js.map +1 -0
- package/src/lib/expression/kinds.mjs +151 -0
- package/src/lib/expression/kinds.mjs.map +1 -0
- package/src/lib/expression/modifier.d.mts +4 -3
- package/src/lib/expression/modifier.d.ts +4 -3
- package/src/lib/expression/modifier.js +4 -3
- package/src/lib/expression/modifier.js.map +1 -1
- package/src/lib/expression/modifier.mjs +4 -3
- package/src/lib/expression/modifier.mjs.map +1 -1
- package/src/lib/expression/more-functions.d.mts +8 -0
- package/src/lib/expression/more-functions.d.ts +8 -0
- package/src/lib/expression/more-functions.js +235 -0
- package/src/lib/expression/more-functions.js.map +1 -0
- package/src/lib/expression/more-functions.mjs +230 -0
- package/src/lib/expression/more-functions.mjs.map +1 -0
- package/src/lib/expression/parser.d.mts +4 -1
- package/src/lib/expression/parser.d.ts +4 -1
- package/src/lib/expression/parser.js +6 -3
- package/src/lib/expression/parser.js.map +1 -1
- package/src/lib/expression/parser.mjs +6 -3
- package/src/lib/expression/parser.mjs.map +1 -1
- package/src/lib/expression/reads.d.mts +2 -2
- package/src/lib/expression/reads.d.ts +2 -2
- package/src/lib/expression/reads.js +6 -4
- package/src/lib/expression/reads.js.map +1 -1
- package/src/lib/expression/reads.mjs +6 -4
- package/src/lib/expression/reads.mjs.map +1 -1
- package/src/lib/format/actions.d.mts +16 -16
- package/src/lib/format/actions.d.ts +16 -16
- package/src/lib/format/check-page.d.mts +7 -2
- package/src/lib/format/check-page.d.ts +7 -2
- package/src/lib/format/check-page.js +10 -4
- package/src/lib/format/check-page.js.map +1 -1
- package/src/lib/format/check-page.mjs +10 -4
- package/src/lib/format/check-page.mjs.map +1 -1
- package/src/lib/format/choice-options.d.mts +34 -0
- package/src/lib/format/choice-options.d.ts +34 -0
- package/src/lib/format/choice-options.js +60 -0
- package/src/lib/format/choice-options.js.map +1 -0
- package/src/lib/format/choice-options.mjs +51 -0
- package/src/lib/format/choice-options.mjs.map +1 -0
- package/src/lib/format/endings-checks.d.mts +8 -0
- package/src/lib/format/endings-checks.d.ts +8 -0
- package/src/lib/format/endings-checks.js +23 -0
- package/src/lib/format/endings-checks.js.map +1 -0
- package/src/lib/format/endings-checks.mjs +20 -0
- package/src/lib/format/endings-checks.mjs.map +1 -0
- package/src/lib/format/endings.d.mts +40 -0
- package/src/lib/format/endings.d.ts +40 -0
- package/src/lib/format/endings.js +15 -0
- package/src/lib/format/endings.js.map +1 -0
- package/src/lib/format/endings.mjs +12 -0
- package/src/lib/format/endings.mjs.map +1 -0
- package/src/lib/format/field.d.mts +151 -16
- package/src/lib/format/field.d.ts +151 -16
- package/src/lib/format/field.js +64 -11
- package/src/lib/format/field.js.map +1 -1
- package/src/lib/format/field.mjs +63 -10
- package/src/lib/format/field.mjs.map +1 -1
- package/src/lib/format/head-checks.d.mts +2 -0
- package/src/lib/format/head-checks.d.ts +2 -0
- package/src/lib/format/head-checks.js +2 -59
- package/src/lib/format/head-checks.js.map +1 -1
- package/src/lib/format/head-checks.mjs +1 -58
- package/src/lib/format/head-checks.mjs.map +1 -1
- package/src/lib/format/later-checks.d.mts +17 -0
- package/src/lib/format/later-checks.d.ts +17 -0
- package/src/lib/format/later-checks.js +20 -0
- package/src/lib/format/later-checks.js.map +1 -0
- package/src/lib/format/later-checks.mjs +17 -0
- package/src/lib/format/later-checks.mjs.map +1 -0
- package/src/lib/format/layout.d.mts +241 -188
- package/src/lib/format/layout.d.ts +241 -188
- package/src/lib/format/layout.js +33 -28
- package/src/lib/format/layout.js.map +1 -1
- package/src/lib/format/layout.mjs +13 -3
- package/src/lib/format/layout.mjs.map +1 -1
- package/src/lib/format/layout.types.d.mts +2 -1
- package/src/lib/format/layout.types.d.ts +2 -1
- package/src/lib/format/limits-checks.d.mts +14 -0
- package/src/lib/format/limits-checks.d.ts +14 -0
- package/src/lib/format/limits-checks.js +36 -0
- package/src/lib/format/limits-checks.js.map +1 -0
- package/src/lib/format/limits-checks.mjs +33 -0
- package/src/lib/format/limits-checks.mjs.map +1 -0
- package/src/lib/format/limits.d.mts +24 -0
- package/src/lib/format/limits.d.ts +24 -0
- package/src/lib/format/limits.js +35 -0
- package/src/lib/format/limits.js.map +1 -0
- package/src/lib/format/limits.mjs +32 -0
- package/src/lib/format/limits.mjs.map +1 -0
- package/src/lib/format/list-checks.d.mts +44 -0
- package/src/lib/format/list-checks.d.ts +44 -0
- package/src/lib/format/list-checks.js +340 -0
- package/src/lib/format/list-checks.js.map +1 -0
- package/src/lib/format/list-checks.mjs +336 -0
- package/src/lib/format/list-checks.mjs.map +1 -0
- package/src/lib/format/map-checks.d.mts +33 -0
- package/src/lib/format/map-checks.d.ts +33 -0
- package/src/lib/format/map-checks.js +180 -0
- package/src/lib/format/map-checks.js.map +1 -0
- package/src/lib/format/map-checks.mjs +175 -0
- package/src/lib/format/map-checks.mjs.map +1 -0
- package/src/lib/format/mapchecks-part.d.mts +5 -0
- package/src/lib/format/mapchecks-part.d.ts +5 -0
- package/src/lib/format/mapchecks-part.js +11 -0
- package/src/lib/format/mapchecks-part.js.map +1 -0
- package/src/lib/format/mapchecks-part.mjs +6 -0
- package/src/lib/format/mapchecks-part.mjs.map +1 -0
- package/src/lib/format/option-checks.d.mts +16 -0
- package/src/lib/format/option-checks.d.ts +16 -0
- package/src/lib/format/option-checks.js +39 -0
- package/src/lib/format/option-checks.js.map +1 -0
- package/src/lib/format/option-checks.mjs +36 -0
- package/src/lib/format/option-checks.mjs.map +1 -0
- package/src/lib/format/options-part.d.mts +6 -0
- package/src/lib/format/options-part.d.ts +6 -0
- package/src/lib/format/options-part.js +11 -0
- package/src/lib/format/options-part.js.map +1 -0
- package/src/lib/format/options-part.mjs +7 -0
- package/src/lib/format/options-part.mjs.map +1 -0
- package/src/lib/format/page.d.mts +147 -71
- package/src/lib/format/page.d.ts +147 -71
- package/src/lib/format/page.js +5 -0
- package/src/lib/format/page.js.map +1 -1
- package/src/lib/format/page.mjs +5 -0
- package/src/lib/format/page.mjs.map +1 -1
- package/src/lib/format/part-checks.d.mts +20 -0
- package/src/lib/format/part-checks.d.ts +20 -0
- package/src/lib/format/part-checks.js +3 -0
- package/src/lib/format/part-checks.js.map +1 -0
- package/src/lib/format/part-checks.mjs +2 -0
- package/src/lib/format/part-checks.mjs.map +1 -0
- package/src/lib/format/references.d.mts +71 -65
- package/src/lib/format/references.d.ts +71 -65
- package/src/lib/format/references.js +194 -631
- package/src/lib/format/references.js.map +1 -1
- package/src/lib/format/references.mjs +194 -631
- package/src/lib/format/references.mjs.map +1 -1
- package/src/lib/format/seats-checks.d.mts +3 -0
- package/src/lib/format/seats-checks.d.ts +3 -0
- package/src/lib/format/seats-checks.js +13 -0
- package/src/lib/format/seats-checks.js.map +1 -0
- package/src/lib/format/seats-checks.mjs +10 -0
- package/src/lib/format/seats-checks.mjs.map +1 -0
- package/src/lib/format/sheet-head-checks.d.mts +4 -0
- package/src/lib/format/sheet-head-checks.d.ts +4 -0
- package/src/lib/format/sheet-head-checks.js +68 -0
- package/src/lib/format/sheet-head-checks.js.map +1 -0
- package/src/lib/format/sheet-head-checks.mjs +65 -0
- package/src/lib/format/sheet-head-checks.mjs.map +1 -0
- package/src/lib/format/signature-checks.d.mts +7 -0
- package/src/lib/format/signature-checks.d.ts +7 -0
- package/src/lib/format/signature-checks.js +32 -0
- package/src/lib/format/signature-checks.js.map +1 -0
- package/src/lib/format/signature-checks.mjs +29 -0
- package/src/lib/format/signature-checks.mjs.map +1 -0
- package/src/lib/format/signature-options.d.mts +24 -0
- package/src/lib/format/signature-options.d.ts +24 -0
- package/src/lib/format/signature-options.js +30 -0
- package/src/lib/format/signature-options.js.map +1 -0
- package/src/lib/format/signature-options.mjs +26 -0
- package/src/lib/format/signature-options.mjs.map +1 -0
- package/src/lib/format/slots-checks.d.mts +4 -0
- package/src/lib/format/slots-checks.d.ts +4 -0
- package/src/lib/format/slots-checks.js +21 -0
- package/src/lib/format/slots-checks.js.map +1 -0
- package/src/lib/format/slots-checks.mjs +18 -0
- package/src/lib/format/slots-checks.mjs.map +1 -0
- package/src/lib/format/statusbar-checks.d.mts +8 -0
- package/src/lib/format/statusbar-checks.d.ts +8 -0
- package/src/lib/format/statusbar-checks.js +35 -0
- package/src/lib/format/statusbar-checks.js.map +1 -0
- package/src/lib/format/statusbar-checks.mjs +32 -0
- package/src/lib/format/statusbar-checks.mjs.map +1 -0
- package/src/lib/format/table-checks.d.mts +21 -0
- package/src/lib/format/table-checks.d.ts +21 -0
- package/src/lib/format/table-checks.js +86 -0
- package/src/lib/format/table-checks.js.map +1 -0
- package/src/lib/format/table-checks.mjs +82 -0
- package/src/lib/format/table-checks.mjs.map +1 -0
- package/src/lib/format/translate.js +2 -2
- package/src/lib/format/translate.js.map +1 -1
- package/src/lib/format/translate.mjs +2 -2
- package/src/lib/format/translate.mjs.map +1 -1
- package/src/lib/format/upgrade.d.mts +6 -3
- package/src/lib/format/upgrade.d.ts +6 -3
- package/src/lib/format/upgrade.js +6 -3
- package/src/lib/format/upgrade.js.map +1 -1
- package/src/lib/format/upgrade.mjs +6 -3
- package/src/lib/format/upgrade.mjs.map +1 -1
- package/src/lib/format/validate.d.mts +18 -2
- package/src/lib/format/validate.d.ts +18 -2
- package/src/lib/format/validate.js +36 -3
- package/src/lib/format/validate.js.map +1 -1
- package/src/lib/format/validate.mjs +35 -3
- package/src/lib/format/validate.mjs.map +1 -1
- package/src/lib/format/version.d.mts +2 -2
- package/src/lib/format/version.d.ts +2 -2
- package/src/lib/format/version.js +2 -2
- package/src/lib/format/version.js.map +1 -1
- package/src/lib/format/version.mjs +2 -2
- package/src/lib/format/version.mjs.map +1 -1
- package/src/lib/format/words.d.mts +6 -2
- package/src/lib/format/words.d.ts +6 -2
- package/src/lib/format/words.js +13 -7
- package/src/lib/format/words.js.map +1 -1
- package/src/lib/format/words.mjs +13 -7
- package/src/lib/format/words.mjs.map +1 -1
- package/src/lib/parts.d.mts +45 -0
- package/src/lib/parts.d.ts +45 -0
- package/src/lib/parts.js +60 -0
- package/src/lib/parts.js.map +1 -0
- package/src/lib/parts.mjs +53 -0
- package/src/lib/parts.mjs.map +1 -0
- package/src/lib/record/cells.d.mts +3 -3
- package/src/lib/record/cells.d.ts +3 -3
- package/src/lib/record/cells.js +16 -15
- package/src/lib/record/cells.js.map +1 -1
- package/src/lib/record/cells.mjs +16 -15
- package/src/lib/record/cells.mjs.map +1 -1
- package/src/lib/record/compute.d.mts +16 -5
- package/src/lib/record/compute.d.ts +16 -5
- package/src/lib/record/compute.js +57 -16
- package/src/lib/record/compute.js.map +1 -1
- package/src/lib/record/compute.mjs +57 -16
- package/src/lib/record/compute.mjs.map +1 -1
- package/src/lib/record/data-source.d.mts +140 -3
- package/src/lib/record/data-source.d.ts +140 -3
- package/src/lib/record/data-source.js.map +1 -1
- package/src/lib/record/data-source.mjs.map +1 -1
- package/src/lib/record/drafts.d.mts +19 -0
- package/src/lib/record/drafts.d.ts +19 -0
- package/src/lib/record/drafts.js +35 -0
- package/src/lib/record/drafts.js.map +1 -0
- package/src/lib/record/drafts.mjs +31 -0
- package/src/lib/record/drafts.mjs.map +1 -0
- package/src/lib/record/env.d.mts +5 -1
- package/src/lib/record/env.d.ts +5 -1
- package/src/lib/record/env.js +9 -1
- package/src/lib/record/env.js.map +1 -1
- package/src/lib/record/env.mjs +8 -1
- package/src/lib/record/env.mjs.map +1 -1
- package/src/lib/record/form-limits.d.mts +81 -0
- package/src/lib/record/form-limits.d.ts +81 -0
- package/src/lib/record/form-limits.js +231 -0
- package/src/lib/record/form-limits.js.map +1 -0
- package/src/lib/record/form-limits.mjs +224 -0
- package/src/lib/record/form-limits.mjs.map +1 -0
- package/src/lib/record/form.d.mts +173 -4
- package/src/lib/record/form.d.ts +173 -4
- package/src/lib/record/form.js +792 -88
- package/src/lib/record/form.js.map +1 -1
- package/src/lib/record/form.mjs +792 -88
- package/src/lib/record/form.mjs.map +1 -1
- package/src/lib/record/limits-part.d.mts +6 -0
- package/src/lib/record/limits-part.d.ts +6 -0
- package/src/lib/record/limits-part.js +12 -0
- package/src/lib/record/limits-part.js.map +1 -0
- package/src/lib/record/limits-part.mjs +7 -0
- package/src/lib/record/limits-part.mjs.map +1 -0
- package/src/lib/record/line-choices.d.mts +30 -0
- package/src/lib/record/line-choices.d.ts +30 -0
- package/src/lib/record/line-choices.js +42 -0
- package/src/lib/record/line-choices.js.map +1 -0
- package/src/lib/record/line-choices.mjs +36 -0
- package/src/lib/record/line-choices.mjs.map +1 -0
- package/src/lib/record/locales/ar.js +10 -0
- package/src/lib/record/locales/ar.js.map +1 -1
- package/src/lib/record/locales/ar.mjs +10 -0
- package/src/lib/record/locales/ar.mjs.map +1 -1
- package/src/lib/record/locales/de.js +10 -0
- package/src/lib/record/locales/de.js.map +1 -1
- package/src/lib/record/locales/de.mjs +10 -0
- package/src/lib/record/locales/de.mjs.map +1 -1
- package/src/lib/record/locales/fr.js +10 -0
- package/src/lib/record/locales/fr.js.map +1 -1
- package/src/lib/record/locales/fr.mjs +10 -0
- package/src/lib/record/locales/fr.mjs.map +1 -1
- package/src/lib/record/memory-data-source.d.mts +44 -3
- package/src/lib/record/memory-data-source.d.ts +44 -3
- package/src/lib/record/memory-data-source.js +102 -40
- package/src/lib/record/memory-data-source.js.map +1 -1
- package/src/lib/record/memory-data-source.mjs +101 -40
- package/src/lib/record/memory-data-source.mjs.map +1 -1
- package/src/lib/record/memory-kept.d.mts +20 -0
- package/src/lib/record/memory-kept.d.ts +20 -0
- package/src/lib/record/memory-kept.js +46 -0
- package/src/lib/record/memory-kept.js.map +1 -0
- package/src/lib/record/memory-kept.mjs +43 -0
- package/src/lib/record/memory-kept.mjs.map +1 -0
- package/src/lib/record/memory-later.d.mts +19 -0
- package/src/lib/record/memory-later.d.ts +19 -0
- package/src/lib/record/memory-later.js +39 -0
- package/src/lib/record/memory-later.js.map +1 -0
- package/src/lib/record/memory-later.mjs +35 -0
- package/src/lib/record/memory-later.mjs.map +1 -0
- package/src/lib/record/memory-part.d.mts +7 -0
- package/src/lib/record/memory-part.d.ts +7 -0
- package/src/lib/record/memory-part.js +13 -0
- package/src/lib/record/memory-part.js.map +1 -0
- package/src/lib/record/memory-part.mjs +8 -0
- package/src/lib/record/memory-part.mjs.map +1 -0
- package/src/lib/record/messages.d.mts +17 -0
- package/src/lib/record/messages.d.ts +17 -0
- package/src/lib/record/messages.js +10 -0
- package/src/lib/record/messages.js.map +1 -1
- package/src/lib/record/messages.mjs +10 -0
- package/src/lib/record/messages.mjs.map +1 -1
- package/src/lib/record/option-rules.d.mts +50 -0
- package/src/lib/record/option-rules.d.ts +50 -0
- package/src/lib/record/option-rules.js +137 -0
- package/src/lib/record/option-rules.js.map +1 -0
- package/src/lib/record/option-rules.mjs +134 -0
- package/src/lib/record/option-rules.mjs.map +1 -0
- package/src/lib/record/rules.d.mts +2 -2
- package/src/lib/record/rules.d.ts +2 -2
- package/src/lib/record/rules.js +3 -3
- package/src/lib/record/rules.js.map +1 -1
- package/src/lib/record/rules.mjs +3 -3
- package/src/lib/record/rules.mjs.map +1 -1
- package/src/lib/record/run.js +9 -7
- package/src/lib/record/run.js.map +1 -1
- package/src/lib/record/run.mjs +9 -7
- package/src/lib/record/run.mjs.map +1 -1
- package/src/lib/record/search.d.mts +12 -2
- package/src/lib/record/search.d.ts +12 -2
- package/src/lib/record/search.js +29 -4
- package/src/lib/record/search.js.map +1 -1
- package/src/lib/record/search.mjs +29 -4
- package/src/lib/record/search.mjs.map +1 -1
- package/src/lib/record/set-when.d.mts +3 -3
- package/src/lib/record/set-when.d.ts +3 -3
- package/src/lib/record/set-when.js +9 -9
- package/src/lib/record/set-when.js.map +1 -1
- package/src/lib/record/set-when.mjs +9 -9
- package/src/lib/record/set-when.mjs.map +1 -1
- package/src/lib/record/signed.d.mts +21 -0
- package/src/lib/record/signed.d.ts +21 -0
- package/src/lib/record/signed.js +62 -0
- package/src/lib/record/signed.js.map +1 -0
- package/src/lib/record/signed.mjs +57 -0
- package/src/lib/record/signed.mjs.map +1 -0
- package/src/lib/record/taking.d.mts +60 -0
- package/src/lib/record/taking.d.ts +60 -0
- package/src/lib/record/taking.js +58 -0
- package/src/lib/record/taking.js.map +1 -0
- package/src/lib/record/taking.mjs +50 -0
- package/src/lib/record/taking.mjs.map +1 -0
- package/src/lib/record/value-map.js +11 -4
- package/src/lib/record/value-map.js.map +1 -1
- package/src/lib/record/value-map.mjs +11 -4
- package/src/lib/record/value-map.mjs.map +1 -1
- package/src/lib/record/values.d.mts +20 -0
- package/src/lib/record/values.d.ts +20 -0
- package/src/lib/record/values.js.map +1 -1
- package/src/lib/record/values.mjs.map +1 -1
- package/src/lib/record/waits.d.mts +6 -1
- package/src/lib/record/waits.d.ts +6 -1
- package/src/lib/record/waits.js +2 -2
- package/src/lib/record/waits.js.map +1 -1
- package/src/lib/record/waits.mjs +2 -2
- package/src/lib/record/waits.mjs.map +1 -1
- package/src/runtime.d.mts +16 -5
- package/src/runtime.d.ts +16 -5
- package/src/runtime.js +41 -3
- package/src/runtime.js.map +1 -1
- package/src/runtime.mjs +13 -0
- package/src/runtime.mjs.map +1 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code a page loads the first time it uses it — a work item's text editor,
|
|
3
|
+
* its path picker, a record's head, a form's functions beyond the plain ones —
|
|
4
|
+
* so that a page using none of it never downloads it. Each part is a module of its own (a `*-part.ts` file) asked
|
|
5
|
+
* for with `import()`: an app's bundler makes it a file of its own, and the
|
|
6
|
+
* script bundle a script beside fieldia.js, `fieldia.<name>.js`
|
|
7
|
+
* (tools/script-bundle.mjs).
|
|
8
|
+
*
|
|
9
|
+
* A part is asked for once; a failure (offline, say) is forgotten, so the next
|
|
10
|
+
* use asks again. What draws from a part draws from it at once when it has
|
|
11
|
+
* come; the viewer waits for the parts a page needs before it draws that page,
|
|
12
|
+
* and a widget made before its part has come is drawn plainly, then by its
|
|
13
|
+
* part in the same place as soon as it comes (`partWidget`).
|
|
14
|
+
*/
|
|
15
|
+
export interface Part<M = unknown> {
|
|
16
|
+
/** Its name: the script bundle's file for it is `fieldia.<name>.js`. */
|
|
17
|
+
readonly name: string;
|
|
18
|
+
/** Its code, once it has come; undefined until then. */
|
|
19
|
+
readonly loaded: M | undefined;
|
|
20
|
+
/** Its code: asked for the first time, then the same answer — unless that failed, when it is asked for again. */
|
|
21
|
+
load(): Promise<M>;
|
|
22
|
+
/**
|
|
23
|
+
* Whether asking again once it failed can bring it: true where parts come by a script tag of their own (the one-tag
|
|
24
|
+
* script, `partsComeByScriptTag`), which is asked for anew; false where they come by `import()` — an app's bundler —
|
|
25
|
+
* whose module the browser keeps failed for the page's life, so only a reload brings it. What offers to try again
|
|
26
|
+
* offers it only where it can work.
|
|
27
|
+
*/
|
|
28
|
+
readonly asksAgain?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** Said by the one-tag script as it starts: its parts come by script tags, each asked for anew after a failure. */
|
|
31
|
+
export declare function partsComeByScriptTag(): void;
|
|
32
|
+
/** A part, asked for by `load` (a dynamic import of the part's module) the first time something needs it. */
|
|
33
|
+
export declare function lazyPart<M>(name: string, load: () => Promise<M>): Part<M>;
|
|
34
|
+
/** Every part asked for, and settled: each one in, or failed (and drawn plainly). Never rejects. */
|
|
35
|
+
export declare function settleParts(parts: readonly Part[]): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* A part that draws with others' widgets — an analytic distribution's lines, each with a link's box: in once they all
|
|
38
|
+
* are, its own code its answer. A page that needs it waits for them all; a widget drawn from it before they came is
|
|
39
|
+
* drawn plainly until they have.
|
|
40
|
+
*/
|
|
41
|
+
export declare function partWith<M>(part: Part<M>, ...others: readonly Part[]): Part<M> & {
|
|
42
|
+
readonly parts: readonly Part[];
|
|
43
|
+
};
|
|
44
|
+
/** The parts a part stands for: those it was made `partWith`, or itself. */
|
|
45
|
+
export declare function partsOf(part: Part): readonly Part[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code a page loads the first time it uses it — a work item's text editor,
|
|
3
|
+
* its path picker, a record's head, a form's functions beyond the plain ones —
|
|
4
|
+
* so that a page using none of it never downloads it. Each part is a module of its own (a `*-part.ts` file) asked
|
|
5
|
+
* for with `import()`: an app's bundler makes it a file of its own, and the
|
|
6
|
+
* script bundle a script beside fieldia.js, `fieldia.<name>.js`
|
|
7
|
+
* (tools/script-bundle.mjs).
|
|
8
|
+
*
|
|
9
|
+
* A part is asked for once; a failure (offline, say) is forgotten, so the next
|
|
10
|
+
* use asks again. What draws from a part draws from it at once when it has
|
|
11
|
+
* come; the viewer waits for the parts a page needs before it draws that page,
|
|
12
|
+
* and a widget made before its part has come is drawn plainly, then by its
|
|
13
|
+
* part in the same place as soon as it comes (`partWidget`).
|
|
14
|
+
*/
|
|
15
|
+
export interface Part<M = unknown> {
|
|
16
|
+
/** Its name: the script bundle's file for it is `fieldia.<name>.js`. */
|
|
17
|
+
readonly name: string;
|
|
18
|
+
/** Its code, once it has come; undefined until then. */
|
|
19
|
+
readonly loaded: M | undefined;
|
|
20
|
+
/** Its code: asked for the first time, then the same answer — unless that failed, when it is asked for again. */
|
|
21
|
+
load(): Promise<M>;
|
|
22
|
+
/**
|
|
23
|
+
* Whether asking again once it failed can bring it: true where parts come by a script tag of their own (the one-tag
|
|
24
|
+
* script, `partsComeByScriptTag`), which is asked for anew; false where they come by `import()` — an app's bundler —
|
|
25
|
+
* whose module the browser keeps failed for the page's life, so only a reload brings it. What offers to try again
|
|
26
|
+
* offers it only where it can work.
|
|
27
|
+
*/
|
|
28
|
+
readonly asksAgain?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** Said by the one-tag script as it starts: its parts come by script tags, each asked for anew after a failure. */
|
|
31
|
+
export declare function partsComeByScriptTag(): void;
|
|
32
|
+
/** A part, asked for by `load` (a dynamic import of the part's module) the first time something needs it. */
|
|
33
|
+
export declare function lazyPart<M>(name: string, load: () => Promise<M>): Part<M>;
|
|
34
|
+
/** Every part asked for, and settled: each one in, or failed (and drawn plainly). Never rejects. */
|
|
35
|
+
export declare function settleParts(parts: readonly Part[]): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* A part that draws with others' widgets — an analytic distribution's lines, each with a link's box: in once they all
|
|
38
|
+
* are, its own code its answer. A page that needs it waits for them all; a widget drawn from it before they came is
|
|
39
|
+
* drawn plainly until they have.
|
|
40
|
+
*/
|
|
41
|
+
export declare function partWith<M>(part: Part<M>, ...others: readonly Part[]): Part<M> & {
|
|
42
|
+
readonly parts: readonly Part[];
|
|
43
|
+
};
|
|
44
|
+
/** The parts a part stands for: those it was made `partWith`, or itself. */
|
|
45
|
+
export declare function partsOf(part: Part): readonly Part[];
|
package/src/lib/parts.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.partsComeByScriptTag = partsComeByScriptTag;
|
|
4
|
+
exports.lazyPart = lazyPart;
|
|
5
|
+
exports.settleParts = settleParts;
|
|
6
|
+
exports.partWith = partWith;
|
|
7
|
+
exports.partsOf = partsOf;
|
|
8
|
+
/** Whether this page's parts come by script tags of their own (the one-tag script) rather than by import(). */
|
|
9
|
+
let byScriptTag = false;
|
|
10
|
+
/** Said by the one-tag script as it starts: its parts come by script tags, each asked for anew after a failure. */
|
|
11
|
+
function partsComeByScriptTag() {
|
|
12
|
+
byScriptTag = true;
|
|
13
|
+
}
|
|
14
|
+
/** A part, asked for by `load` (a dynamic import of the part's module) the first time something needs it. */
|
|
15
|
+
function lazyPart(name, load) {
|
|
16
|
+
let pending;
|
|
17
|
+
let loaded;
|
|
18
|
+
return {
|
|
19
|
+
name,
|
|
20
|
+
get loaded() {
|
|
21
|
+
return loaded;
|
|
22
|
+
},
|
|
23
|
+
get asksAgain() {
|
|
24
|
+
return byScriptTag;
|
|
25
|
+
},
|
|
26
|
+
load() {
|
|
27
|
+
return (pending ??= load().then((module) => (loaded = module), (error) => {
|
|
28
|
+
pending = undefined;
|
|
29
|
+
throw error;
|
|
30
|
+
}));
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** Every part asked for, and settled: each one in, or failed (and drawn plainly). Never rejects. */
|
|
35
|
+
function settleParts(parts) {
|
|
36
|
+
return Promise.all(parts.map((part) => part.load().then(() => undefined, () => undefined))).then(() => undefined);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A part that draws with others' widgets — an analytic distribution's lines, each with a link's box: in once they all
|
|
40
|
+
* are, its own code its answer. A page that needs it waits for them all; a widget drawn from it before they came is
|
|
41
|
+
* drawn plainly until they have.
|
|
42
|
+
*/
|
|
43
|
+
function partWith(part, ...others) {
|
|
44
|
+
return {
|
|
45
|
+
name: part.name,
|
|
46
|
+
parts: [part, ...others],
|
|
47
|
+
get loaded() {
|
|
48
|
+
return others.every((other) => other.loaded) ? part.loaded : undefined;
|
|
49
|
+
},
|
|
50
|
+
get asksAgain() {
|
|
51
|
+
return part.asksAgain === true && others.every((other) => other.asksAgain === true);
|
|
52
|
+
},
|
|
53
|
+
load: () => Promise.all([part.load(), ...others.map((other) => other.load())]).then(([module]) => module),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** The parts a part stands for: those it was made `partWith`, or itself. */
|
|
57
|
+
function partsOf(part) {
|
|
58
|
+
return part.parts ?? [part];
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=parts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parts.js","sourceRoot":"","sources":["../../../../../libs/core/src/lib/parts.ts"],"names":[],"mappings":";;AAiCA,oDAEC;AAGD,4BAqBC;AAGD,kCAKC;AAOD,4BAYC;AAGD,0BAEC;AA7DD,+GAA+G;AAC/G,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,mHAAmH;AACnH,SAAgB,oBAAoB;IAClC,WAAW,GAAG,IAAI,CAAC;AACrB,CAAC;AA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AAK,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC;QACtF,CAAC;QACD,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC;KAC1G,CAAC;AACJ,CAAC;AAED,4EAA4E;AAC5E,SAAgB,OAAO,CAAC,IAAU;IAChC,OAAQ,IAAoC,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Whether this page's parts come by script tags of their own (the one-tag script) rather than by import(). */
|
|
2
|
+
let byScriptTag = false;
|
|
3
|
+
/** Said by the one-tag script as it starts: its parts come by script tags, each asked for anew after a failure. */
|
|
4
|
+
export function partsComeByScriptTag() {
|
|
5
|
+
byScriptTag = true;
|
|
6
|
+
}
|
|
7
|
+
/** A part, asked for by `load` (a dynamic import of the part's module) the first time something needs it. */
|
|
8
|
+
export function lazyPart(name, load) {
|
|
9
|
+
let pending;
|
|
10
|
+
let loaded;
|
|
11
|
+
return {
|
|
12
|
+
name,
|
|
13
|
+
get loaded() {
|
|
14
|
+
return loaded;
|
|
15
|
+
},
|
|
16
|
+
get asksAgain() {
|
|
17
|
+
return byScriptTag;
|
|
18
|
+
},
|
|
19
|
+
load() {
|
|
20
|
+
return (pending ??= load().then((module) => (loaded = module), (error) => {
|
|
21
|
+
pending = undefined;
|
|
22
|
+
throw error;
|
|
23
|
+
}));
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** Every part asked for, and settled: each one in, or failed (and drawn plainly). Never rejects. */
|
|
28
|
+
export function settleParts(parts) {
|
|
29
|
+
return Promise.all(parts.map((part) => part.load().then(() => undefined, () => undefined))).then(() => undefined);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A part that draws with others' widgets — an analytic distribution's lines, each with a link's box: in once they all
|
|
33
|
+
* are, its own code its answer. A page that needs it waits for them all; a widget drawn from it before they came is
|
|
34
|
+
* drawn plainly until they have.
|
|
35
|
+
*/
|
|
36
|
+
export function partWith(part, ...others) {
|
|
37
|
+
return {
|
|
38
|
+
name: part.name,
|
|
39
|
+
parts: [part, ...others],
|
|
40
|
+
get loaded() {
|
|
41
|
+
return others.every((other) => other.loaded) ? part.loaded : undefined;
|
|
42
|
+
},
|
|
43
|
+
get asksAgain() {
|
|
44
|
+
return part.asksAgain === true && others.every((other) => other.asksAgain === true);
|
|
45
|
+
},
|
|
46
|
+
load: () => Promise.all([part.load(), ...others.map((other) => other.load())]).then(([module]) => module),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** The parts a part stands for: those it was made `partWith`, or itself. */
|
|
50
|
+
export function partsOf(part) {
|
|
51
|
+
return part.parts ?? [part];
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=parts.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parts.mjs","sourceRoot":"","sources":["../../../../../libs/core/src/lib/parts.ts"],"names":[],"mappings":"AA8BA,+GAA+G;AAC/G,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,mHAAmH;AACnH,MAAM,UAAU,oBAAoB;IAClC,WAAW,GAAG,IAAI,CAAC;AACrB,CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,QAAQ,CAAI,IAAY,EAAE,IAAsB;IAC9D,IAAI,OAA+B,CAAC;IACpC,IAAI,MAAqB,CAAC;IAC1B,OAAO;QACL,IAAI;QACJ,IAAI,MAAM;YACR,OAAO,MAAM,CAAC;QAChB,CAAC;QAC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AAC,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC;KAC1G,CAAC;AACJ,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,OAAO,CAAC,IAAU;IAChC,OAAQ,IAAoC,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ButtonNode, FieldNode, Tone } from '../format/layout.mjs';
|
|
2
|
-
import type { ExpressionEnv } from '../expression/functions.mjs';
|
|
2
|
+
import type { ExpressionEnv, FunctionTable } from '../expression/functions.mjs';
|
|
3
3
|
/** A cell of a table's line, as its rules have it now. */
|
|
4
4
|
export interface CellState {
|
|
5
5
|
invisible: boolean;
|
|
@@ -31,7 +31,7 @@ export interface FieldTone {
|
|
|
31
31
|
bold: boolean;
|
|
32
32
|
}
|
|
33
33
|
/** A field node's tones and bold, read once; read on the record. */
|
|
34
|
-
export declare function compileFieldTone(node: Pick<FieldNode, 'tones' | 'bold'
|
|
35
|
-
export declare function compileTable(node: FieldNode): CompiledTable;
|
|
34
|
+
export declare function compileFieldTone(node: Pick<FieldNode, 'tones' | 'bold'>, functions?: FunctionTable): (context: Record<string, unknown>, env: ExpressionEnv) => FieldTone;
|
|
35
|
+
export declare function compileTable(node: FieldNode, functions?: FunctionTable): CompiledTable;
|
|
36
36
|
/** What a cell is when its column has no rules. */
|
|
37
37
|
export declare const PLAIN_CELL: CellState;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ButtonNode, FieldNode, Tone } from '../format/layout';
|
|
2
|
-
import type { ExpressionEnv } from '../expression/functions';
|
|
2
|
+
import type { ExpressionEnv, FunctionTable } from '../expression/functions';
|
|
3
3
|
/** A cell of a table's line, as its rules have it now. */
|
|
4
4
|
export interface CellState {
|
|
5
5
|
invisible: boolean;
|
|
@@ -31,7 +31,7 @@ export interface FieldTone {
|
|
|
31
31
|
bold: boolean;
|
|
32
32
|
}
|
|
33
33
|
/** A field node's tones and bold, read once; read on the record. */
|
|
34
|
-
export declare function compileFieldTone(node: Pick<FieldNode, 'tones' | 'bold'
|
|
35
|
-
export declare function compileTable(node: FieldNode): CompiledTable;
|
|
34
|
+
export declare function compileFieldTone(node: Pick<FieldNode, 'tones' | 'bold'>, functions?: FunctionTable): (context: Record<string, unknown>, env: ExpressionEnv) => FieldTone;
|
|
35
|
+
export declare function compileTable(node: FieldNode, functions?: FunctionTable): CompiledTable;
|
|
36
36
|
/** What a cell is when its column has no rules. */
|
|
37
37
|
export declare const PLAIN_CELL: CellState;
|
package/src/lib/record/cells.js
CHANGED
|
@@ -6,31 +6,32 @@ exports.compileTable = compileTable;
|
|
|
6
6
|
const modifier_1 = require("../expression/modifier");
|
|
7
7
|
const roles_1 = require("./roles");
|
|
8
8
|
/** A field node's tones and bold, read once; read on the record. */
|
|
9
|
-
function compileFieldTone(node) {
|
|
10
|
-
const tones = tonesOf(node.tones);
|
|
11
|
-
const bold = (0, modifier_1.compileModifier)(node.bold);
|
|
9
|
+
function compileFieldTone(node, functions) {
|
|
10
|
+
const tones = tonesOf(node.tones, functions);
|
|
11
|
+
const bold = (0, modifier_1.compileModifier)(node.bold, functions);
|
|
12
12
|
return (context, env) => ({ tone: toneNow(tones, context, env), bold: bold.evaluate(context, env) });
|
|
13
13
|
}
|
|
14
|
-
const tonesOf = (list) => (list ?? []).map((item) => ({ tone: item.tone, when: (0, modifier_1.compileModifier)(item.when) }));
|
|
14
|
+
const tonesOf = (list, functions) => (list ?? []).map((item) => ({ tone: item.tone, when: (0, modifier_1.compileModifier)(item.when, functions) }));
|
|
15
15
|
const toneNow = (list, context, env) => list.find((item) => item.when.evaluate(context, env))?.tone ?? null;
|
|
16
|
-
function compileTable(node) {
|
|
16
|
+
function compileTable(node, functions) {
|
|
17
|
+
const read = (modifier) => (0, modifier_1.compileModifier)(modifier, functions);
|
|
17
18
|
const cells = new Map();
|
|
18
19
|
for (const [column, rules] of Object.entries(node.cells ?? {})) {
|
|
19
20
|
cells.set(column, {
|
|
20
|
-
invisible: (
|
|
21
|
-
readonly: (
|
|
22
|
-
required: (
|
|
23
|
-
hidden: (
|
|
21
|
+
invisible: read(rules.invisible),
|
|
22
|
+
readonly: read(rules.readonly),
|
|
23
|
+
required: read(rules.required),
|
|
24
|
+
hidden: read(rules.hidden),
|
|
24
25
|
...(rules.roles?.length ? { roles: rules.roles } : {}),
|
|
25
|
-
tones: tonesOf(rules.tones),
|
|
26
|
-
bold: (
|
|
26
|
+
tones: tonesOf(rules.tones, functions),
|
|
27
|
+
bold: read(rules.bold),
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
|
-
const rowTones = tonesOf(node.rowTones);
|
|
30
|
-
const rowBold = (
|
|
31
|
-
const lineDelete = node.lineDelete === undefined ? null : (
|
|
30
|
+
const rowTones = tonesOf(node.rowTones, functions);
|
|
31
|
+
const rowBold = read(node.rowBold);
|
|
32
|
+
const lineDelete = node.lineDelete === undefined ? null : read(node.lineDelete);
|
|
32
33
|
const buttons = node.rowButtons ?? [];
|
|
33
|
-
const shown = buttons.map((button) => ({ id: button.id, roles: button.roles, invisible: (
|
|
34
|
+
const shown = buttons.map((button) => ({ id: button.id, roles: button.roles, invisible: read(button.invisible) }));
|
|
34
35
|
return {
|
|
35
36
|
buttons,
|
|
36
37
|
line(context, env, roles) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cells.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/cells.ts"],"names":[],"mappings":";;;AAuDA,4CAIC;AAKD,
|
|
1
|
+
{"version":3,"file":"cells.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/cells.ts"],"names":[],"mappings":";;;AAuDA,4CAIC;AAKD,o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AM,EAAE,GAAG,EAAE,KAAK;YAC/B,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC/B,OAAO,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAA,kBAAU,EAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;QACzF,CAAC;KACF,CAAC;AACJ,CAAC;AAED,mDAAmD;AACtC,QAAA,UAAU,GAAc,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC"}
|
package/src/lib/record/cells.mjs
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import { compileModifier } from '../expression/modifier.mjs';
|
|
2
2
|
import { rolesAllow } from './roles.mjs';
|
|
3
3
|
/** A field node's tones and bold, read once; read on the record. */
|
|
4
|
-
export function compileFieldTone(node) {
|
|
5
|
-
const tones = tonesOf(node.tones);
|
|
6
|
-
const bold = compileModifier(node.bold);
|
|
4
|
+
export function compileFieldTone(node, functions) {
|
|
5
|
+
const tones = tonesOf(node.tones, functions);
|
|
6
|
+
const bold = compileModifier(node.bold, functions);
|
|
7
7
|
return (context, env) => ({ tone: toneNow(tones, context, env), bold: bold.evaluate(context, env) });
|
|
8
8
|
}
|
|
9
|
-
const tonesOf = (list) => (list ?? []).map((item) => ({ tone: item.tone, when: compileModifier(item.when) }));
|
|
9
|
+
const tonesOf = (list, functions) => (list ?? []).map((item) => ({ tone: item.tone, when: compileModifier(item.when, functions) }));
|
|
10
10
|
const toneNow = (list, context, env) => list.find((item) => item.when.evaluate(context, env))?.tone ?? null;
|
|
11
|
-
export function compileTable(node) {
|
|
11
|
+
export function compileTable(node, functions) {
|
|
12
|
+
const read = (modifier) => compileModifier(modifier, functions);
|
|
12
13
|
const cells = new Map();
|
|
13
14
|
for (const [column, rules] of Object.entries(node.cells ?? {})) {
|
|
14
15
|
cells.set(column, {
|
|
15
|
-
invisible:
|
|
16
|
-
readonly:
|
|
17
|
-
required:
|
|
18
|
-
hidden:
|
|
16
|
+
invisible: read(rules.invisible),
|
|
17
|
+
readonly: read(rules.readonly),
|
|
18
|
+
required: read(rules.required),
|
|
19
|
+
hidden: read(rules.hidden),
|
|
19
20
|
...(rules.roles?.length ? { roles: rules.roles } : {}),
|
|
20
|
-
tones: tonesOf(rules.tones),
|
|
21
|
-
bold:
|
|
21
|
+
tones: tonesOf(rules.tones, functions),
|
|
22
|
+
bold: read(rules.bold),
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
|
-
const rowTones = tonesOf(node.rowTones);
|
|
25
|
-
const rowBold =
|
|
26
|
-
const lineDelete = node.lineDelete === undefined ? null :
|
|
25
|
+
const rowTones = tonesOf(node.rowTones, functions);
|
|
26
|
+
const rowBold = read(node.rowBold);
|
|
27
|
+
const lineDelete = node.lineDelete === undefined ? null : read(node.lineDelete);
|
|
27
28
|
const buttons = node.rowButtons ?? [];
|
|
28
|
-
const shown = buttons.map((button) => ({ id: button.id, roles: button.roles, invisible:
|
|
29
|
+
const shown = buttons.map((button) => ({ id: button.id, roles: button.roles, invisible: read(button.invisible) }));
|
|
29
30
|
return {
|
|
30
31
|
buttons,
|
|
31
32
|
line(context, env, roles) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cells.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/cells.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAyB,MAAM,wBAAwB,CAAC;AAEhF,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAmDrC,oEAAoE;AACpE,MAAM,UAAU,gBAAgB,CAAC,IAAuC;
|
|
1
|
+
{"version":3,"file":"cells.mjs","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/record/cells.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OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK;YAC/B,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC/B,OAAO,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;QACzF,CAAC;KACF,CAAC;AACJ,CAAC;AAED,mDAAmD;AACnD,MAAM,CAAC,MAAM,UAAU,GAAc,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Field, LineField } from '../format/field.mjs';
|
|
2
2
|
import type { Page } from '../format/page.mjs';
|
|
3
|
-
import { type About } from './env.mjs';
|
|
3
|
+
import { type About, type AppReads } from './env.mjs';
|
|
4
4
|
import { type Value, type Values } from './values.mjs';
|
|
5
5
|
/**
|
|
6
6
|
* Values worked out from others: a field's `compute`. A page's own fields are
|
|
@@ -10,16 +10,27 @@ import { type Value, type Values } from './values.mjs';
|
|
|
10
10
|
* form redraws only what did.
|
|
11
11
|
*/
|
|
12
12
|
export interface Computed {
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The values with every worked-out field brought up to date. `asked`, when given, is told each worked out from an
|
|
15
|
+
* app's function that asks and has no answer yet, by its path (a line's `field.lineKey.subfield`): waiting for
|
|
16
|
+
* it (`{}`), or why it did not come (`failed`). Such a value is empty meanwhile.
|
|
17
|
+
*/
|
|
18
|
+
apply(values: Values, asked?: Map<string, AskedFor>): Values;
|
|
15
19
|
/** One line of a one2many on the record `values`, with its worked-out fields brought up to date. */
|
|
16
20
|
line(field: string, line: Values, values: Values): Values;
|
|
17
21
|
}
|
|
22
|
+
/** A value worked out from an app's function that asks, with no answer yet: waiting for it, or why it did not come. */
|
|
23
|
+
export interface AskedFor {
|
|
24
|
+
failed?: string;
|
|
25
|
+
}
|
|
18
26
|
/**
|
|
19
27
|
* A worked-out value as its field holds it: a whole number rounded, a number
|
|
20
28
|
* to the field's decimals, a number as text in a text field, yes or no by
|
|
21
29
|
* Python's idea of true, and null for what the field cannot hold.
|
|
22
30
|
*/
|
|
23
31
|
export declare function fitTo(def: Field | LineField, value: unknown): Value;
|
|
24
|
-
/**
|
|
25
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Read every `compute` of a page once. `today` is the day `today()` gives; `about`, the record's id and the person, as
|
|
34
|
+
* lines read them on `parent`; `app`, the app's functions and the answers of those that ask.
|
|
35
|
+
*/
|
|
36
|
+
export declare function compileComputed(page: Page, today: () => string, about?: () => About, app?: AppReads): Computed;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Field, LineField } from '../format/field';
|
|
2
2
|
import type { Page } from '../format/page';
|
|
3
|
-
import { type About } from './env';
|
|
3
|
+
import { type About, type AppReads } from './env';
|
|
4
4
|
import { type Value, type Values } from './values';
|
|
5
5
|
/**
|
|
6
6
|
* Values worked out from others: a field's `compute`. A page's own fields are
|
|
@@ -10,16 +10,27 @@ import { type Value, type Values } from './values';
|
|
|
10
10
|
* form redraws only what did.
|
|
11
11
|
*/
|
|
12
12
|
export interface Computed {
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The values with every worked-out field brought up to date. `asked`, when given, is told each worked out from an
|
|
15
|
+
* app's function that asks and has no answer yet, by its path (a line's `field.lineKey.subfield`): waiting for
|
|
16
|
+
* it (`{}`), or why it did not come (`failed`). Such a value is empty meanwhile.
|
|
17
|
+
*/
|
|
18
|
+
apply(values: Values, asked?: Map<string, AskedFor>): Values;
|
|
15
19
|
/** One line of a one2many on the record `values`, with its worked-out fields brought up to date. */
|
|
16
20
|
line(field: string, line: Values, values: Values): Values;
|
|
17
21
|
}
|
|
22
|
+
/** A value worked out from an app's function that asks, with no answer yet: waiting for it, or why it did not come. */
|
|
23
|
+
export interface AskedFor {
|
|
24
|
+
failed?: string;
|
|
25
|
+
}
|
|
18
26
|
/**
|
|
19
27
|
* A worked-out value as its field holds it: a whole number rounded, a number
|
|
20
28
|
* to the field's decimals, a number as text in a text field, yes or no by
|
|
21
29
|
* Python's idea of true, and null for what the field cannot hold.
|
|
22
30
|
*/
|
|
23
31
|
export declare function fitTo(def: Field | LineField, value: unknown): Value;
|
|
24
|
-
/**
|
|
25
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Read every `compute` of a page once. `today` is the day `today()` gives; `about`, the record's id and the person, as
|
|
34
|
+
* lines read them on `parent`; `app`, the app's functions and the answers of those that ask.
|
|
35
|
+
*/
|
|
36
|
+
export declare function compileComputed(page: Page, today: () => string, about?: () => About, app?: AppReads): Computed;
|
|
@@ -7,12 +7,22 @@ const operations_1 = require("../expression/operations");
|
|
|
7
7
|
const order_1 = require("../expression/order");
|
|
8
8
|
const env_1 = require("./env");
|
|
9
9
|
const values_1 = require("./values");
|
|
10
|
+
/** What waits at a path, or inside it (a table's lines' cells): undefined when nothing does. */
|
|
11
|
+
function waitsIn(asked, path) {
|
|
12
|
+
const own = asked.get(path);
|
|
13
|
+
if (own)
|
|
14
|
+
return own;
|
|
15
|
+
for (const [key, found] of asked)
|
|
16
|
+
if (key.startsWith(`${path}.`))
|
|
17
|
+
return found;
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
10
20
|
/** The worked-out fields among `fields`, each read once, in the order to work them out. */
|
|
11
|
-
function steps(fields) {
|
|
21
|
+
function steps(fields, functions) {
|
|
12
22
|
const compiled = new Map();
|
|
13
23
|
for (const [name, def] of Object.entries(fields))
|
|
14
24
|
if (def.compute !== undefined)
|
|
15
|
-
compiled.set(name, (0, expression_1.compileExpression)(def.compute));
|
|
25
|
+
compiled.set(name, (0, expression_1.compileExpression)(def.compute, functions));
|
|
16
26
|
const { order } = (0, order_1.dependencyOrder)(new Map([...compiled].map(([name, expression]) => [name, expression.fields])));
|
|
17
27
|
return order.map((name) => [name, compiled.get(name), fields[name]]);
|
|
18
28
|
}
|
|
@@ -45,25 +55,56 @@ function fitTo(def, value) {
|
|
|
45
55
|
return value;
|
|
46
56
|
}
|
|
47
57
|
}
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Read every `compute` of a page once. `today` is the day `today()` gives; `about`, the record's id and the person, as
|
|
60
|
+
* lines read them on `parent`; `app`, the app's functions and the answers of those that ask.
|
|
61
|
+
*/
|
|
62
|
+
function compileComputed(page, today, about = () => ({ recordId: null }), app = {}) {
|
|
63
|
+
const own = steps(page.fields, app.functions);
|
|
51
64
|
const lineSteps = new Map();
|
|
52
65
|
for (const [name, def] of Object.entries(page.fields)) {
|
|
53
66
|
if (def.type !== 'one2many')
|
|
54
67
|
continue;
|
|
55
|
-
const found = steps(def.fields);
|
|
68
|
+
const found = steps(def.fields, app.functions);
|
|
56
69
|
if (found.length)
|
|
57
70
|
lineSteps.set(name, { def, steps: found });
|
|
58
71
|
}
|
|
59
|
-
// Lines hold no lines of their own: inside one, only today()
|
|
60
|
-
const lineEnv = { today };
|
|
61
|
-
/**
|
|
62
|
-
function
|
|
72
|
+
// Lines hold no lines of their own: inside one, only today() and the app's functions need the env.
|
|
73
|
+
const lineEnv = { ...app, today };
|
|
74
|
+
/** A value worked out, and whether it waits for an app's answer, or why that did not come. */
|
|
75
|
+
function worked(expression, context, env) {
|
|
76
|
+
const answer = env.answer;
|
|
77
|
+
if (!answer)
|
|
78
|
+
return { value: expression.evaluate(context, env) };
|
|
79
|
+
let asked;
|
|
80
|
+
const value = expression.evaluate(context, {
|
|
81
|
+
...env,
|
|
82
|
+
answer(key, promise) {
|
|
83
|
+
const found = answer(key, promise);
|
|
84
|
+
if (found === 'asking')
|
|
85
|
+
asked ??= {};
|
|
86
|
+
else if (found?.failed !== undefined)
|
|
87
|
+
asked = { failed: found.failed };
|
|
88
|
+
return found;
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
return asked ? { value, asked } : { value };
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Work out the steps on these values, writing each change into a copy; `read` gives the values as expressions read
|
|
95
|
+
* them; `at`, the path a value's waiting is told by (a line's `field.lineKey.`).
|
|
96
|
+
*/
|
|
97
|
+
function run(values, list, fields, env, read, asked, at = '') {
|
|
63
98
|
let next = values;
|
|
64
99
|
const context = read(values);
|
|
65
100
|
for (const [name, expression, def] of list) {
|
|
66
|
-
const
|
|
101
|
+
const found = worked(expression, context, env);
|
|
102
|
+
// Worked out from a value that waits — a field, or a table's line — it waits as that one does.
|
|
103
|
+
const from = asked?.size ? expression.fields.map((field) => waitsIn(asked, at + field)).find((one) => one !== undefined) : undefined;
|
|
104
|
+
const waits = found.asked ?? from;
|
|
105
|
+
if (waits)
|
|
106
|
+
asked?.set(at + name, waits);
|
|
107
|
+
const value = fitTo(def, found.value);
|
|
67
108
|
if ((0, values_1.sameValue)(value, next[name]))
|
|
68
109
|
continue;
|
|
69
110
|
next = { ...next, [name]: value };
|
|
@@ -72,16 +113,16 @@ function compileComputed(page, today, about = () => ({ recordId: null })) {
|
|
|
72
113
|
}
|
|
73
114
|
return next;
|
|
74
115
|
}
|
|
75
|
-
function line(field, values, parent) {
|
|
116
|
+
function line(field, values, parent, asked, at = '') {
|
|
76
117
|
const found = lineSteps.get(field);
|
|
77
118
|
// A section or a note has nothing to work out.
|
|
78
119
|
if (!found || (0, values_1.lineKind)(found.def, values) !== null)
|
|
79
120
|
return values;
|
|
80
|
-
return run(values, found.steps, found.def.fields, lineEnv, (v) => (0, env_1.lineContext)(v, found.def.fields, parent));
|
|
121
|
+
return run(values, found.steps, found.def.fields, lineEnv, (v) => (0, env_1.lineContext)(v, found.def.fields, parent), asked, at);
|
|
81
122
|
}
|
|
82
123
|
return {
|
|
83
124
|
line: (field, values, record) => line(field, values, (0, env_1.recordContext)(record, page.fields, about())),
|
|
84
|
-
apply(values) {
|
|
125
|
+
apply(values, asked) {
|
|
85
126
|
let next = values;
|
|
86
127
|
const parent = lineSteps.size ? (0, env_1.recordContext)(values, page.fields, about()) : {};
|
|
87
128
|
for (const field of lineSteps.keys()) {
|
|
@@ -90,7 +131,7 @@ function compileComputed(page, today, about = () => ({ recordId: null })) {
|
|
|
90
131
|
continue;
|
|
91
132
|
let changed = false;
|
|
92
133
|
const updated = current.map((l) => {
|
|
93
|
-
const worked = line(field, l.values, parent);
|
|
134
|
+
const worked = line(field, l.values, parent, asked, `${field}.${l.key}.`);
|
|
94
135
|
if (worked === l.values)
|
|
95
136
|
return l;
|
|
96
137
|
changed = true;
|
|
@@ -101,7 +142,7 @@ function compileComputed(page, today, about = () => ({ recordId: null })) {
|
|
|
101
142
|
}
|
|
102
143
|
if (!own.length)
|
|
103
144
|
return next;
|
|
104
|
-
return run(next, own, page.fields, (0, env_1.expressionEnv)(next, page.fields, today), (v) => (0, env_1.recordContext)(v, page.fields, about()));
|
|
145
|
+
return run(next, own, page.fields, (0, env_1.expressionEnv)(next, page.fields, today, app), (v) => (0, env_1.recordContext)(v, page.fields, about()), asked);
|
|
105
146
|
},
|
|
106
147
|
};
|
|
107
148
|
}
|