@agentshouse/mdmodel 0.1.0-c896b3d9398b1 → 0.1.0-c8ef006e419a0
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/API.md +345 -279
- package/README.md +28 -29
- package/dist/body.d.ts +85 -0
- package/dist/body.d.ts.map +1 -0
- package/dist/body.js +1083 -0
- package/dist/built-in.d.ts +4 -0
- package/dist/built-in.d.ts.map +1 -0
- package/dist/built-in.js +19 -0
- package/dist/definition.d.ts +36 -11
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +434 -107
- package/dist/divide.d.ts.map +1 -1
- package/dist/divide.js +32 -21
- package/dist/document.d.ts +15 -6
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +961 -217
- package/dist/event.d.ts +77 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +200 -0
- package/dist/facts.d.ts +15 -0
- package/dist/facts.d.ts.map +1 -0
- package/dist/facts.js +41 -0
- package/dist/fields.d.ts +3 -1
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +8 -1
- package/dist/form.d.ts +4 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +153 -0
- package/dist/house-model.d.ts +831 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +462 -0
- package/dist/house-references/crockford.d.ts +4 -0
- package/dist/house-references/crockford.d.ts.map +1 -0
- package/dist/house-references/crockford.js +3 -0
- package/dist/house-references/patterns.d.ts +9 -0
- package/dist/house-references/patterns.d.ts.map +1 -0
- package/dist/house-references/patterns.js +13 -0
- package/dist/index.d.ts +38 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -7
- package/dist/kinds.d.ts +18 -0
- package/dist/kinds.d.ts.map +1 -0
- package/dist/kinds.js +150 -0
- package/dist/markdown.d.ts +75 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +265 -0
- package/dist/media-type.d.ts +72 -0
- package/dist/media-type.d.ts.map +1 -0
- package/dist/media-type.js +157 -0
- package/dist/paths.d.ts +20 -2
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +177 -16
- package/dist/pattern.d.ts +10 -0
- package/dist/pattern.d.ts.map +1 -0
- package/dist/pattern.js +356 -0
- package/dist/project.d.ts +1 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +61 -65
- package/dist/query/language.d.ts +254 -0
- package/dist/query/language.d.ts.map +1 -0
- package/dist/query/language.js +620 -0
- package/dist/query/match.d.ts +14 -0
- package/dist/query/match.d.ts.map +1 -0
- package/dist/query/match.js +150 -0
- package/dist/query/rows.d.ts +32 -0
- package/dist/query/rows.d.ts.map +1 -0
- package/dist/query/rows.js +161 -0
- package/dist/query/sql.d.ts +39 -0
- package/dist/query/sql.d.ts.map +1 -0
- package/dist/query/sql.js +285 -0
- package/dist/references.d.ts +1 -1
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +7 -2
- package/dist/refuse.d.ts +1 -0
- package/dist/refuse.d.ts.map +1 -1
- package/dist/refuse.js +1 -0
- package/dist/reserved.d.ts +6 -0
- package/dist/reserved.d.ts.map +1 -0
- package/dist/reserved.js +21 -0
- package/dist/room-types.d.ts +7 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +137 -0
- package/dist/schema.d.ts +1 -2
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +11 -24
- package/dist/types.d.ts +55 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +34 -2
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +383 -142
- package/dist/yaml.d.ts +7 -3
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +110 -55
- package/fixtures/README.md +62 -25
- package/fixtures/cases/absent-link-dangles/library/item.md +1 -1
- package/fixtures/cases/absent-link-dangles/schema.yaml +2 -3
- package/fixtures/cases/absent-optional-field/library/companies/acme.md +1 -1
- package/fixtures/cases/absent-optional-field/library/deals/lead.md +3 -3
- package/fixtures/cases/absent-optional-field/schema.yaml +10 -11
- package/fixtures/cases/absolute-link/library/item.md +1 -1
- package/fixtures/cases/absolute-link/schema.yaml +2 -3
- package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/products/support.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/products/support.md +1 -1
- package/fixtures/cases/attachment-reference-outside/expected.json +2 -1
- package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-outside/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/products/support.md +1 -1
- package/fixtures/cases/binary-any-reference/expected.json +2 -1
- package/fixtures/cases/binary-any-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-prototype-reference/expected.json +2 -1
- package/fixtures/cases/binary-prototype-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-typed-reference/expected.json +2 -1
- package/fixtures/cases/binary-typed-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/boolean-field/expected.json +2 -1
- package/fixtures/cases/boolean-field/library/companies/acme.md +1 -1
- package/fixtures/cases/boolean-field/library/deals/renewal.md +49 -24
- package/fixtures/cases/boolean-field/schema.yaml +10 -11
- package/fixtures/cases/bracketed-link-definition/library/item.md +1 -1
- package/fixtures/cases/bracketed-link-definition/schema.yaml +2 -3
- package/fixtures/cases/closed-nested-object/expected.json +2 -1
- package/fixtures/cases/closed-nested-object/library/companies/acme.md +1 -1
- package/fixtures/cases/closed-nested-object/library/deals/renewal.md +50 -25
- package/fixtures/cases/closed-nested-object/schema.yaml +10 -11
- package/fixtures/cases/composed-root-reference/library/a.md +2 -2
- package/fixtures/cases/conditional-long-text/expected.json +7 -0
- package/fixtures/cases/conditional-long-text/library/questions/hosting.md +9 -0
- package/fixtures/cases/conditional-long-text/library/questions/payments.md +12 -0
- package/fixtures/cases/conditional-long-text/schema.yaml +13 -0
- package/fixtures/cases/cross-room-link/library/clients/acme.md +6 -0
- package/fixtures/cases/cross-room-link/schema.yaml +3 -0
- package/fixtures/cases/cross-room-reference/expected.json +1 -0
- package/fixtures/cases/cross-room-reference/library/clients/acme.md +9 -0
- package/fixtures/cases/cross-room-reference/schema.yaml +8 -0
- package/fixtures/cases/date-time-format/expected.json +2 -1
- package/fixtures/cases/date-time-format/library/companies/acme.md +1 -1
- package/fixtures/cases/date-time-format/library/deals/renewal.md +49 -24
- package/fixtures/cases/date-time-format/schema.yaml +10 -11
- package/fixtures/cases/default-unfilled/library/companies/acme.md +1 -1
- package/fixtures/cases/default-unfilled/library/deals/renewal.md +47 -22
- package/fixtures/cases/default-unfilled/schema.yaml +10 -11
- package/fixtures/cases/defs-pattern/expected.json +2 -1
- package/fixtures/cases/defs-pattern/library/companies/acme.md +1 -1
- package/fixtures/cases/defs-pattern/library/deals/renewal.md +49 -24
- package/fixtures/cases/defs-pattern/schema.yaml +10 -11
- package/fixtures/cases/dependent-rule/library/companies/acme.md +1 -1
- package/fixtures/cases/dependent-rule/library/deals/renewal.md +48 -23
- package/fixtures/cases/dependent-rule/schema.yaml +10 -11
- package/fixtures/cases/duplicate-link-definition/library/item.md +1 -1
- package/fixtures/cases/duplicate-link-definition/schema.yaml +2 -3
- package/fixtures/cases/email-format/expected.json +2 -1
- package/fixtures/cases/email-format/library/companies/acme.md +1 -1
- package/fixtures/cases/email-format/library/deals/renewal.md +49 -24
- package/fixtures/cases/email-format/schema.yaml +10 -11
- package/fixtures/cases/equal-labels/expected.json +5 -0
- package/fixtures/cases/equal-labels/schema.yaml +4 -0
- package/fixtures/cases/fenced-link-definition/library/item.md +1 -1
- package/fixtures/cases/fenced-link-definition/schema.yaml +2 -3
- package/fixtures/cases/field-enum/expected.json +2 -1
- package/fixtures/cases/field-enum/library/item.md +2 -2
- package/fixtures/cases/field-enum/schema.yaml +3 -4
- package/fixtures/cases/integer-field/expected.json +2 -1
- package/fixtures/cases/integer-field/library/companies/acme.md +1 -1
- package/fixtures/cases/integer-field/library/deals/renewal.md +49 -24
- package/fixtures/cases/integer-field/schema.yaml +10 -11
- package/fixtures/cases/json-schema-constructs/library/companies/acme.md +1 -1
- package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +49 -24
- package/fixtures/cases/json-schema-constructs/schema.yaml +10 -11
- package/fixtures/cases/labels-in-the-rooms-language/expected.json +1 -0
- package/fixtures/cases/labels-in-the-rooms-language/library/deals/atlas.md +7 -0
- package/fixtures/cases/labels-in-the-rooms-language/schema.yaml +9 -0
- package/fixtures/cases/lazy-list-item/expected.json +3 -0
- package/fixtures/cases/lazy-list-item/library/item.md +10 -0
- package/fixtures/cases/lazy-list-item/schema.yaml +3 -0
- package/fixtures/cases/link-into-a-reserved-name/expected.json +5 -0
- package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +6 -0
- package/fixtures/cases/link-into-a-reserved-name/schema.yaml +3 -0
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/expected.json +5 -0
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/library/notes/b.md +5 -0
- package/fixtures/cases/list-item-enum/expected.json +7 -0
- package/fixtures/cases/list-item-enum/library/task.md +7 -0
- package/fixtures/cases/list-item-enum/schema.yaml +3 -0
- package/fixtures/cases/list-item-kind/context.json +1 -0
- package/fixtures/cases/list-item-kind/expected.json +7 -0
- package/fixtures/cases/list-item-kind/library/task.md +6 -0
- package/fixtures/cases/list-item-kind/schema.yaml +3 -0
- package/fixtures/cases/list-items/context.json +1 -0
- package/fixtures/cases/list-items/expected.json +1 -0
- package/fixtures/cases/list-items/library/page.md +26 -0
- package/fixtures/cases/list-items/schema.yaml +10 -0
- package/fixtures/cases/list-of-objects-closed/expected.json +2 -1
- package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +49 -25
- package/fixtures/cases/list-of-objects-closed/schema.yaml +10 -11
- package/fixtures/cases/list-of-objects-item/expected.json +2 -1
- package/fixtures/cases/list-of-objects-item/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +49 -24
- package/fixtures/cases/list-of-objects-item/schema.yaml +10 -11
- package/fixtures/cases/list-of-objects-reference/expected.json +2 -1
- package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/list-of-objects-reference/library/places/depot.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/products/seats.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/products/support.md +1 -1
- package/fixtures/cases/list-reference-path/context.json +1 -0
- package/fixtures/cases/list-reference-path/expected.json +7 -0
- package/fixtures/cases/list-reference-path/library/page.md +5 -0
- package/fixtures/cases/list-reference-path/schema.yaml +3 -0
- package/fixtures/cases/list-reference-type/context.json +1 -0
- package/fixtures/cases/list-reference-type/expected.json +7 -0
- package/fixtures/cases/list-reference-type/library/page.md +6 -0
- package/fixtures/cases/list-reference-type/schema.yaml +3 -0
- package/fixtures/cases/list-size/expected.json +2 -1
- package/fixtures/cases/list-size/library/companies/acme.md +1 -1
- package/fixtures/cases/list-size/library/deals/renewal.md +51 -24
- package/fixtures/cases/list-size/schema.yaml +10 -11
- package/fixtures/cases/long-value-past-six-levels/context.json +1 -0
- package/fixtures/cases/long-value-past-six-levels/expected.json +5 -0
- package/fixtures/cases/long-value-past-six-levels/schema.yaml +15 -0
- package/fixtures/cases/malformed-list/context.json +1 -0
- package/fixtures/cases/malformed-list/expected.json +7 -0
- package/fixtures/cases/{structured-section → malformed-list}/library/item.md +1 -1
- package/fixtures/cases/malformed-list/schema.yaml +6 -0
- package/fixtures/cases/member-document/library/people/ana.md +2 -2
- package/fixtures/cases/member-on-an-untyped-document/context.json +1 -0
- package/fixtures/cases/member-on-an-untyped-document/expected.json +6 -0
- package/fixtures/cases/member-on-an-untyped-document/library/note.md +4 -0
- package/fixtures/cases/member-on-another-type/context.json +1 -0
- package/fixtures/cases/member-on-another-type/expected.json +6 -0
- package/fixtures/cases/member-on-another-type/library/note.md +4 -0
- package/fixtures/cases/member-on-another-type/schema.yaml +7 -0
- package/fixtures/cases/missing-required-field/library/item.md +1 -1
- package/fixtures/cases/missing-required-field/schema.yaml +3 -4
- package/fixtures/cases/misspelled-key/expected.json +2 -1
- package/fixtures/cases/misspelled-key/library/companies/acme.md +1 -1
- package/fixtures/cases/misspelled-key/library/deals/renewal.md +50 -25
- package/fixtures/cases/misspelled-key/schema.yaml +10 -11
- package/fixtures/cases/name-not-a-string/context.json +1 -0
- package/fixtures/cases/name-not-a-string/expected.json +5 -0
- package/fixtures/cases/name-not-a-string/schema.yaml +5 -0
- package/fixtures/cases/nested-defs/expected.json +2 -1
- package/fixtures/cases/nested-defs/library/deal.md +3 -3
- package/fixtures/cases/nested-object-reference/expected.json +2 -1
- package/fixtures/cases/nested-object-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-object-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/nested-object-reference/library/places/depot.md +1 -1
- package/fixtures/cases/nested-object-reference/library/products/seats.md +1 -1
- package/fixtures/cases/nested-object-reference/library/products/support.md +1 -1
- package/fixtures/cases/nested-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-reference/library/deals/renewal.md +13 -10
- package/fixtures/cases/nested-reference/library/places/depot.md +1 -1
- package/fixtures/cases/nested-reference/library/products/seats.md +1 -1
- package/fixtures/cases/nested-reference/library/products/support.md +1 -1
- package/fixtures/cases/nested-required-field/expected.json +2 -1
- package/fixtures/cases/nested-required-field/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-required-field/library/deals/renewal.md +48 -23
- package/fixtures/cases/nested-required-field/schema.yaml +10 -11
- package/fixtures/cases/numeric-range/expected.json +2 -1
- package/fixtures/cases/numeric-range/library/companies/acme.md +1 -1
- package/fixtures/cases/numeric-range/library/deals/renewal.md +49 -24
- package/fixtures/cases/numeric-range/schema.yaml +10 -11
- package/fixtures/cases/one-key-two-labels/context.json +1 -0
- package/fixtures/cases/one-key-two-labels/expected.json +5 -0
- package/fixtures/cases/one-key-two-labels/schema.yaml +5 -0
- package/fixtures/cases/one-key-two-types/context.json +1 -0
- package/fixtures/cases/one-key-two-types/expected.json +5 -0
- package/fixtures/cases/one-key-two-types/schema.yaml +4 -0
- package/fixtures/cases/one-of-variant/expected.json +2 -1
- package/fixtures/cases/one-of-variant/library/companies/acme.md +1 -1
- package/fixtures/cases/one-of-variant/library/deals/renewal.md +49 -24
- package/fixtures/cases/one-of-variant/schema.yaml +10 -11
- package/fixtures/cases/other-room-reference/expected.json +2 -1
- package/fixtures/cases/other-room-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/other-room-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/other-room-reference/library/places/depot.md +1 -1
- package/fixtures/cases/other-room-reference/library/products/seats.md +1 -1
- package/fixtures/cases/other-room-reference/library/products/support.md +1 -1
- package/fixtures/cases/prototype-field/expected.json +2 -1
- package/fixtures/cases/prototype-field/library/item.md +2 -2
- package/fixtures/cases/prototype-field/schema.yaml +2 -3
- package/fixtures/cases/reference-into-a-reserved-name/context.json +1 -0
- package/fixtures/cases/reference-into-a-reserved-name/expected.json +7 -0
- package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +4 -0
- package/fixtures/cases/reference-into-a-reserved-name/library/settings/brief.md +1 -0
- package/fixtures/cases/reference-into-a-reserved-name/schema.yaml +3 -0
- package/fixtures/cases/referenced-missing-file/library/a.md +2 -2
- package/fixtures/cases/referenced-missing-file/library/b.md +2 -2
- package/fixtures/cases/referenced-missing-file/schema.yaml +3 -4
- package/fixtures/cases/room-md-declares-a-type/context.json +1 -0
- package/fixtures/cases/room-md-declares-a-type/expected.json +6 -0
- package/fixtures/cases/room-md-declares-a-type/library/ROOM.md +5 -0
- package/fixtures/cases/sections-keyword-refused/context.json +1 -0
- package/fixtures/cases/sections-keyword-refused/expected.json +5 -0
- package/fixtures/cases/{structured-section → sections-keyword-refused}/schema.yaml +1 -2
- package/fixtures/cases/shortcut-reference-link/library/item.md +1 -1
- package/fixtures/cases/shortcut-reference-link/schema.yaml +2 -3
- package/fixtures/cases/string-length/expected.json +2 -1
- package/fixtures/cases/string-length/library/companies/acme.md +1 -1
- package/fixtures/cases/string-length/library/deals/renewal.md +49 -24
- package/fixtures/cases/string-length/schema.yaml +10 -11
- package/fixtures/cases/submission-keys/library/notes/visitor.md +2 -2
- package/fixtures/cases/text-field-kind/expected.json +1 -4
- package/fixtures/cases/text-field-kind/library/page.md +1 -1
- package/fixtures/cases/thematic-break-ends-the-values/context.json +1 -0
- package/fixtures/cases/thematic-break-ends-the-values/expected.json +1 -0
- package/fixtures/cases/thematic-break-ends-the-values/library/item.md +10 -0
- package/fixtures/cases/thematic-break-ends-the-values/schema.yaml +3 -0
- package/fixtures/cases/typed-path-names-another-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-another-type/expected.json +6 -0
- package/fixtures/cases/typed-path-names-another-type/library/settings/prefs/one.md +3 -0
- package/fixtures/cases/typed-path-names-another-type/schema.yaml +6 -0
- package/fixtures/cases/typed-path-names-its-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-its-type/expected.json +3 -0
- package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/deeper/two.md +1 -0
- package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +4 -0
- package/fixtures/cases/typed-path-names-its-type/schema.yaml +6 -0
- package/fixtures/cases/typed-path-names-no-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-no-type/expected.json +6 -0
- package/fixtures/cases/typed-path-names-no-type/library/settings/prefs/one.md +1 -0
- package/fixtures/cases/typed-path-names-no-type/schema.yaml +6 -0
- package/fixtures/cases/types-folder-content/library/types/task.md +1 -1
- package/fixtures/cases/undeclared-field/expected.json +2 -1
- package/fixtures/cases/undeclared-field/library/item.md +2 -2
- package/fixtures/cases/undeclared-field/schema.yaml +2 -3
- package/fixtures/cases/unevaluated-items-closed/expected.json +2 -1
- package/fixtures/cases/unevaluated-items-closed/library/trip.md +13 -3
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/expected.json +6 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/library/rooms/team/tasks/plan.md +5 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/schema.yaml +5 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/expected.json +6 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +7 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/schema.yaml +5 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/expected.json +3 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/plan.md +1 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +6 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/schema.yaml +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/expected.json +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/schema.yaml +5 -0
- package/fixtures/cases/unresolved-link/library/item.md +1 -1
- package/fixtures/cases/unresolved-link/schema.yaml +2 -3
- package/fixtures/cases/valid-typed-document/library/people/ada.md +1 -1
- package/fixtures/cases/valid-typed-document/library/tasks/one.md +11 -11
- package/fixtures/cases/valid-typed-document/schema.yaml +5 -6
- package/fixtures/division.json +111 -66
- package/fixtures/forms.json +347 -0
- package/fixtures/preamble.json +26 -5
- package/fixtures/projection.json +121 -18
- package/fixtures/queries.json +964 -0
- package/package.json +19 -3
- package/dist/blocks.d.ts +0 -11
- package/dist/blocks.d.ts.map +0 -1
- package/dist/blocks.js +0 -62
- package/dist/condition.d.ts +0 -149
- package/dist/condition.d.ts.map +0 -1
- package/dist/condition.js +0 -497
- package/dist/links.d.ts +0 -26
- package/dist/links.d.ts.map +0 -1
- package/dist/links.js +0 -774
- package/dist/profile.d.ts +0 -6
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js +0 -5
- package/dist/sections.d.ts +0 -11
- package/dist/sections.d.ts.map +0 -1
- package/dist/sections.js +0 -57
- package/fixtures/cases/missing-section-item-kind/expected.json +0 -5
- package/fixtures/cases/missing-section-item-kind/schema.yaml +0 -6
- package/fixtures/cases/null-refused/expected.json +0 -6
- package/fixtures/cases/null-refused/library/companies/acme.md +0 -4
- package/fixtures/cases/null-refused/library/deals/renewal.md +0 -31
- package/fixtures/cases/null-refused/schema.yaml +0 -56
- package/fixtures/cases/open-map-value/expected.json +0 -6
- package/fixtures/cases/open-map-value/library/companies/acme.md +0 -4
- package/fixtures/cases/open-map-value/library/deals/renewal.md +0 -31
- package/fixtures/cases/open-map-value/schema.yaml +0 -56
- package/fixtures/cases/section-item-enum/expected.json +0 -6
- package/fixtures/cases/section-item-enum/library/task.md +0 -8
- package/fixtures/cases/section-item-enum/schema.yaml +0 -3
- package/fixtures/cases/section-item-kind/expected.json +0 -6
- package/fixtures/cases/section-item-kind/library/task.md +0 -8
- package/fixtures/cases/section-item-kind/schema.yaml +0 -3
- package/fixtures/cases/section-items/library/page.md +0 -42
- package/fixtures/cases/section-items/schema.yaml +0 -10
- package/fixtures/cases/section-reference-path/expected.json +0 -6
- package/fixtures/cases/section-reference-path/library/page.md +0 -7
- package/fixtures/cases/section-reference-path/schema.yaml +0 -3
- package/fixtures/cases/section-reference-type/expected.json +0 -6
- package/fixtures/cases/section-reference-type/library/page.md +0 -7
- package/fixtures/cases/section-reference-type/schema.yaml +0 -3
- package/fixtures/cases/structured-section/expected.json +0 -6
- /package/fixtures/cases/{missing-section-item-kind → conditional-long-text}/context.json +0 -0
- /package/fixtures/cases/{null-refused → cross-room-link}/context.json +0 -0
- /package/fixtures/cases/{section-items → cross-room-link}/expected.json +0 -0
- /package/fixtures/cases/{open-map-value → cross-room-reference}/context.json +0 -0
- /package/fixtures/cases/{section-item-enum → equal-labels}/context.json +0 -0
- /package/fixtures/cases/{section-item-kind → labels-in-the-rooms-language}/context.json +0 -0
- /package/fixtures/cases/{section-items → lazy-list-item}/context.json +0 -0
- /package/fixtures/cases/{section-reference-type → link-into-a-reserved-name}/context.json +0 -0
- /package/fixtures/cases/{section-reference-path → link-into-a-reserved-name-from-an-untyped-document}/context.json +0 -0
- /package/fixtures/cases/{structured-section → list-item-enum}/context.json +0 -0
- /package/fixtures/cases/{section-items → list-items}/library/other.md +0 -0
- /package/fixtures/cases/{section-reference-path → list-reference-path}/library/other.md +0 -0
- /package/fixtures/cases/{section-reference-type → list-reference-type}/library/note.md +0 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
export const MEDIA_TYPES = {
|
|
2
|
+
html: 'text/html',
|
|
3
|
+
css: 'text/css',
|
|
4
|
+
javascript: 'text/javascript',
|
|
5
|
+
plainText: 'text/plain',
|
|
6
|
+
markdown: 'text/markdown',
|
|
7
|
+
csv: 'text/csv',
|
|
8
|
+
json: 'application/json',
|
|
9
|
+
xml: 'application/xml',
|
|
10
|
+
yaml: 'application/yaml',
|
|
11
|
+
ndjson: 'application/x-ndjson',
|
|
12
|
+
webManifest: 'application/manifest+json',
|
|
13
|
+
reports: 'application/reports+json',
|
|
14
|
+
githubJson: 'application/vnd.github+json',
|
|
15
|
+
form: 'application/x-www-form-urlencoded',
|
|
16
|
+
octetStream: 'application/octet-stream',
|
|
17
|
+
gzip: 'application/gzip',
|
|
18
|
+
tar: 'application/x-tar',
|
|
19
|
+
zip: 'application/zip',
|
|
20
|
+
gitBundle: 'application/x-git-bundle',
|
|
21
|
+
wasm: 'application/wasm',
|
|
22
|
+
pdf: 'application/pdf',
|
|
23
|
+
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
24
|
+
pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
25
|
+
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
26
|
+
avif: 'image/avif',
|
|
27
|
+
gif: 'image/gif',
|
|
28
|
+
heic: 'image/heic',
|
|
29
|
+
icon: 'image/vnd.microsoft.icon',
|
|
30
|
+
jpeg: 'image/jpeg',
|
|
31
|
+
png: 'image/png',
|
|
32
|
+
svg: 'image/svg+xml',
|
|
33
|
+
webp: 'image/webp',
|
|
34
|
+
aac: 'audio/aac',
|
|
35
|
+
amr: 'audio/amr',
|
|
36
|
+
m4a: 'audio/mp4',
|
|
37
|
+
mp3: 'audio/mpeg',
|
|
38
|
+
ogg: 'audio/ogg',
|
|
39
|
+
wav: 'audio/wav',
|
|
40
|
+
threeGpp: 'video/3gpp',
|
|
41
|
+
mp4: 'video/mp4',
|
|
42
|
+
quickTime: 'video/quicktime',
|
|
43
|
+
webm: 'video/webm',
|
|
44
|
+
otf: 'font/otf',
|
|
45
|
+
ttf: 'font/ttf',
|
|
46
|
+
woff: 'font/woff',
|
|
47
|
+
woff2: 'font/woff2',
|
|
48
|
+
};
|
|
49
|
+
const UTF8 = 'utf-8';
|
|
50
|
+
export function withCharset(type, charset) {
|
|
51
|
+
return `${type}; charset=${charset}`;
|
|
52
|
+
}
|
|
53
|
+
function utf8(type) {
|
|
54
|
+
return withCharset(type, UTF8);
|
|
55
|
+
}
|
|
56
|
+
export const UTF8_TEXT = {
|
|
57
|
+
html: utf8(MEDIA_TYPES.html),
|
|
58
|
+
css: utf8(MEDIA_TYPES.css),
|
|
59
|
+
javascript: utf8(MEDIA_TYPES.javascript),
|
|
60
|
+
plainText: utf8(MEDIA_TYPES.plainText),
|
|
61
|
+
markdown: utf8(MEDIA_TYPES.markdown),
|
|
62
|
+
xml: utf8(MEDIA_TYPES.xml),
|
|
63
|
+
};
|
|
64
|
+
export const SCRIPT_MEDIA_TYPES = [
|
|
65
|
+
MEDIA_TYPES.javascript,
|
|
66
|
+
'application/javascript',
|
|
67
|
+
'text/ecmascript',
|
|
68
|
+
'application/ecmascript',
|
|
69
|
+
];
|
|
70
|
+
const FILE_TYPES = [
|
|
71
|
+
[MEDIA_TYPES.aac, 'aac'],
|
|
72
|
+
[MEDIA_TYPES.amr, 'amr'],
|
|
73
|
+
[MEDIA_TYPES.avif, 'avif'],
|
|
74
|
+
[MEDIA_TYPES.css, 'css'],
|
|
75
|
+
[MEDIA_TYPES.csv, 'csv'],
|
|
76
|
+
[MEDIA_TYPES.docx, 'docx'],
|
|
77
|
+
[MEDIA_TYPES.gif, 'gif'],
|
|
78
|
+
[MEDIA_TYPES.heic, 'heic'],
|
|
79
|
+
[MEDIA_TYPES.html, 'html'],
|
|
80
|
+
[MEDIA_TYPES.icon, 'ico'],
|
|
81
|
+
[MEDIA_TYPES.javascript, 'js', 'mjs'],
|
|
82
|
+
[MEDIA_TYPES.jpeg, 'jpg', 'jpeg'],
|
|
83
|
+
[MEDIA_TYPES.json, 'json', 'map'],
|
|
84
|
+
[MEDIA_TYPES.m4a, 'm4a'],
|
|
85
|
+
[MEDIA_TYPES.markdown, 'md'],
|
|
86
|
+
[MEDIA_TYPES.mp3, 'mp3'],
|
|
87
|
+
[MEDIA_TYPES.mp4, 'mp4'],
|
|
88
|
+
[MEDIA_TYPES.ogg, 'ogg'],
|
|
89
|
+
[MEDIA_TYPES.otf, 'otf'],
|
|
90
|
+
[MEDIA_TYPES.pdf, 'pdf'],
|
|
91
|
+
[MEDIA_TYPES.plainText, 'txt'],
|
|
92
|
+
[MEDIA_TYPES.png, 'png'],
|
|
93
|
+
[MEDIA_TYPES.pptx, 'pptx'],
|
|
94
|
+
[MEDIA_TYPES.quickTime, 'mov'],
|
|
95
|
+
[MEDIA_TYPES.svg, 'svg'],
|
|
96
|
+
[MEDIA_TYPES.threeGpp, '3gp'],
|
|
97
|
+
[MEDIA_TYPES.ttf, 'ttf'],
|
|
98
|
+
[MEDIA_TYPES.wasm, 'wasm'],
|
|
99
|
+
[MEDIA_TYPES.wav, 'wav'],
|
|
100
|
+
[MEDIA_TYPES.webm, 'webm'],
|
|
101
|
+
[MEDIA_TYPES.webManifest, 'webmanifest'],
|
|
102
|
+
[MEDIA_TYPES.webp, 'webp'],
|
|
103
|
+
[MEDIA_TYPES.woff, 'woff'],
|
|
104
|
+
[MEDIA_TYPES.woff2, 'woff2'],
|
|
105
|
+
[MEDIA_TYPES.xlsx, 'xlsx'],
|
|
106
|
+
[MEDIA_TYPES.zip, 'zip'],
|
|
107
|
+
];
|
|
108
|
+
export const FILE_MEDIA_TYPES = FILE_TYPES.reduce((table, [type, ...extensions]) => extensions.reduce((named, extension) => ({ ...named, [extension]: type }), table), {});
|
|
109
|
+
export function servedMediaType(path) {
|
|
110
|
+
const dot = path.lastIndexOf('.');
|
|
111
|
+
const extension = dot === -1 ? '' : path.slice(dot + 1).toLowerCase();
|
|
112
|
+
const type = FILE_TYPES.find(([, ...extensions]) => extensions.includes(extension))?.[0] ??
|
|
113
|
+
MEDIA_TYPES.octetStream;
|
|
114
|
+
return type.startsWith('text/') ? utf8(type) : type;
|
|
115
|
+
}
|
|
116
|
+
export function fileExtension(type) {
|
|
117
|
+
const essence = mediaTypeEssence(type);
|
|
118
|
+
return FILE_TYPES.find(([named]) => named === essence)?.[1] ?? null;
|
|
119
|
+
}
|
|
120
|
+
export function dataUrl(type, base64) {
|
|
121
|
+
return `data:${type};base64,${base64}`;
|
|
122
|
+
}
|
|
123
|
+
function caseless(text) {
|
|
124
|
+
return text.replace(/[a-z]/gu, (letter) => `[${letter}${letter.toUpperCase()}]`);
|
|
125
|
+
}
|
|
126
|
+
export function dataUrlPattern(types) {
|
|
127
|
+
const named = types.map((type) => caseless(type).replace(/[+.]/gu, '\\$&')).join('|');
|
|
128
|
+
return new RegExp(`^${caseless('data:')}(${named});${caseless('base64')},([A-Za-z0-9+/]+={0,2})$`, 'u');
|
|
129
|
+
}
|
|
130
|
+
export function formDataType(boundary) {
|
|
131
|
+
return `multipart/form-data; boundary=${boundary}`;
|
|
132
|
+
}
|
|
133
|
+
export function gitMediaType(service, part) {
|
|
134
|
+
return `application/x-${service}-${part}`;
|
|
135
|
+
}
|
|
136
|
+
export function mediaTypeEssence(value) {
|
|
137
|
+
return value.split(';', 1)[0].trim().toLowerCase();
|
|
138
|
+
}
|
|
139
|
+
export function declaresUtf8(value) {
|
|
140
|
+
const match = /;\s*charset\s*=\s*(?:"([^"]*)"|([^;\s]*))/iu.exec(value);
|
|
141
|
+
return match === null || (match[1] ?? match[2]).toLowerCase() === UTF8;
|
|
142
|
+
}
|
|
143
|
+
export function acceptsType(accept, type) {
|
|
144
|
+
return (accept ?? '').split(',').some((range) => mediaTypeEssence(range) === type);
|
|
145
|
+
}
|
|
146
|
+
function ofTopLevel(value, top) {
|
|
147
|
+
return mediaTypeEssence(value).startsWith(`${top}/`);
|
|
148
|
+
}
|
|
149
|
+
export function isImageType(value) {
|
|
150
|
+
return ofTopLevel(value, 'image');
|
|
151
|
+
}
|
|
152
|
+
export function isVideoType(value) {
|
|
153
|
+
return ofTopLevel(value, 'video');
|
|
154
|
+
}
|
|
155
|
+
export function isAudioType(value) {
|
|
156
|
+
return ofTopLevel(value, 'audio');
|
|
157
|
+
}
|
package/dist/paths.d.ts
CHANGED
|
@@ -1,17 +1,35 @@
|
|
|
1
1
|
export declare function dirname(path: string): string;
|
|
2
2
|
export declare function join(base: string, relative: string): string;
|
|
3
3
|
export declare function normalize(path: string): string | null;
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function destinationPath(href: string): string | null;
|
|
5
|
+
export type RoomTarget = {
|
|
6
|
+
readonly handle: string;
|
|
7
|
+
readonly path: string;
|
|
8
|
+
};
|
|
9
|
+
type Classified = {
|
|
5
10
|
kind: 'skip';
|
|
6
11
|
} | {
|
|
7
12
|
kind: 'path';
|
|
8
13
|
path: string;
|
|
9
|
-
} | {
|
|
14
|
+
} | ({
|
|
15
|
+
kind: 'room';
|
|
16
|
+
} & RoomTarget) | {
|
|
10
17
|
kind: 'invalid';
|
|
11
18
|
};
|
|
19
|
+
export declare function classifyHref(from: string, href: string): Classified;
|
|
20
|
+
export declare function roomTarget(href: string): RoomTarget | null;
|
|
21
|
+
export declare function roomPath(href: string): string | null;
|
|
12
22
|
export declare function target(from: string, href: string): string | null;
|
|
23
|
+
export interface LinkedPath {
|
|
24
|
+
readonly handle: string | null;
|
|
25
|
+
readonly path: string;
|
|
26
|
+
readonly fragment: string | null;
|
|
27
|
+
}
|
|
28
|
+
export declare function linkedPath(from: string, href: string): LinkedPath | null;
|
|
13
29
|
export declare function retarget(href: string, to: string): string;
|
|
14
30
|
export declare function relative(from: string, target: string): string;
|
|
15
31
|
export declare const SHELL_ROOMS = "/rooms/";
|
|
16
32
|
export declare function shellTarget(href: string, handle: string): string | null;
|
|
33
|
+
export declare function destinationText(to: string, bracketed: boolean): string | null;
|
|
34
|
+
export {};
|
|
17
35
|
//# sourceMappingURL=paths.d.ts.map
|
package/dist/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAUA,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYrD;AA6DD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAW3D;AAgBD,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAiB5E,KAAK,UAAU,GACX;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAAC,GAC/B;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAgBxB,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAGnE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAG1D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGpD;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGhE;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAaxE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAW7D;AAED,eAAO,MAAM,WAAW,YAAY,CAAC;AAErC,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMvE;AAoBD,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAI7E"}
|
package/dist/paths.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { decodeNamedCharacterReference } from 'decode-named-character-reference';
|
|
2
|
+
import { decodeNumericCharacterReference } from 'micromark-util-decode-numeric-character-reference';
|
|
3
|
+
const BACKSLASH = 0x5c;
|
|
4
|
+
const PUNCTUATION = /^[!-/:-@[-`{-~]$/;
|
|
5
|
+
function escapes(text, index) {
|
|
6
|
+
return text.charCodeAt(index) === BACKSLASH && PUNCTUATION.test(text[index + 1] ?? '');
|
|
7
|
+
}
|
|
1
8
|
export function dirname(path) {
|
|
2
9
|
const index = path.lastIndexOf('/');
|
|
3
10
|
return index === -1 ? '' : path.slice(0, index);
|
|
@@ -22,30 +29,156 @@ export function normalize(path) {
|
|
|
22
29
|
}
|
|
23
30
|
return parts.join('/');
|
|
24
31
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
const REFERENCE = /&(?:#[xX]([0-9a-fA-F]{1,6})|#([0-9]{1,7})|([A-Za-z][A-Za-z0-9]{0,31}));/y;
|
|
33
|
+
const PERCENT = /^%[0-9a-fA-F]{2}/;
|
|
34
|
+
function referenceAt(text, at) {
|
|
35
|
+
REFERENCE.lastIndex = at;
|
|
36
|
+
const match = REFERENCE.exec(text);
|
|
37
|
+
if (match === null)
|
|
38
|
+
return null;
|
|
39
|
+
const [whole, hex, decimal, name] = match;
|
|
40
|
+
const end = at + whole.length;
|
|
41
|
+
if (name !== undefined) {
|
|
42
|
+
const decoded = decodeNamedCharacterReference(name);
|
|
43
|
+
return decoded === false ? null : { text: decoded, end };
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
text: decodeNumericCharacterReference(hex ?? decimal, hex === undefined ? 10 : 16),
|
|
47
|
+
end,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function spelled(written, from, stops) {
|
|
51
|
+
let text = '';
|
|
52
|
+
let i = from;
|
|
53
|
+
while (i < written.length) {
|
|
54
|
+
const escaped = escapes(written, i);
|
|
55
|
+
const reference = escaped || written[i] !== '&' ? null : referenceAt(written, i);
|
|
56
|
+
const one = escaped ? written[i + 1] : (reference?.text ?? written[i]);
|
|
57
|
+
if (stops && (one.startsWith('?') || one.startsWith('#')))
|
|
58
|
+
return { text, end: i };
|
|
59
|
+
text += one;
|
|
60
|
+
i = escaped ? i + 2 : (reference?.end ?? i + 1);
|
|
61
|
+
}
|
|
62
|
+
return { text, end: written.length };
|
|
63
|
+
}
|
|
64
|
+
function unescaped(written) {
|
|
65
|
+
const { text, end } = spelled(written, 0, true);
|
|
66
|
+
return { base: text, suffix: end };
|
|
67
|
+
}
|
|
68
|
+
function located(href) {
|
|
69
|
+
const written = href.trim();
|
|
70
|
+
const { base, suffix } = unescaped(written);
|
|
71
|
+
const url = base.replace(/[\t\n\r]/g, '').replace(/^[\u0000-\u0020]+/, '');
|
|
72
|
+
return {
|
|
73
|
+
base: suffix === written.length ? url.replace(/(?<![\u0000-\u0020])[\u0000-\u0020]+$/, '') : url,
|
|
74
|
+
suffix,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const ENCODED = /(?:%[0-9a-fA-F]{2})+/g;
|
|
78
|
+
function decodedRun(run) {
|
|
79
|
+
try {
|
|
80
|
+
return decodeURIComponent(run);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export function destinationPath(href) {
|
|
87
|
+
const base = located(href).base;
|
|
88
|
+
let path = '';
|
|
89
|
+
let cursor = 0;
|
|
90
|
+
for (const match of base.matchAll(ENCODED)) {
|
|
91
|
+
const decoded = decodedRun(match[0]);
|
|
92
|
+
if (decoded === null)
|
|
93
|
+
return null;
|
|
94
|
+
path += base.slice(cursor, match.index) + decoded;
|
|
95
|
+
cursor = match.index + match[0].length;
|
|
96
|
+
}
|
|
97
|
+
return path + base.slice(cursor);
|
|
98
|
+
}
|
|
99
|
+
function written(path) {
|
|
100
|
+
let text = '';
|
|
101
|
+
for (let i = 0; i < path.length; i += 1) {
|
|
102
|
+
const char = path[i];
|
|
103
|
+
if (char === '?' || char === '#' || char < ' ')
|
|
104
|
+
text += encodeURIComponent(char);
|
|
105
|
+
else if (char === ' ' && (i === 0 || i === path.length - 1))
|
|
106
|
+
text += '%20';
|
|
107
|
+
else if (char === '%' && PERCENT.test(path.slice(i)))
|
|
108
|
+
text += '%25';
|
|
109
|
+
else if (escapes(path, i))
|
|
110
|
+
text += '%5C';
|
|
111
|
+
else if (char === '&' && referenceAt(path, i) !== null)
|
|
112
|
+
text += '%26';
|
|
113
|
+
else
|
|
114
|
+
text += char;
|
|
115
|
+
}
|
|
116
|
+
return text;
|
|
117
|
+
}
|
|
118
|
+
function roomAt(path) {
|
|
119
|
+
if (!path.startsWith(SHELL_ROOMS))
|
|
120
|
+
return null;
|
|
121
|
+
const rest = path.slice(SHELL_ROOMS.length);
|
|
122
|
+
const slash = rest.indexOf('/');
|
|
123
|
+
const handle = slash === -1 ? rest : rest.slice(0, slash);
|
|
124
|
+
if (handle === '' || handle === '.' || handle === '..')
|
|
125
|
+
return null;
|
|
126
|
+
const within = normalize(slash === -1 ? '' : rest.slice(slash + 1));
|
|
127
|
+
return within === null ? null : { handle, path: within };
|
|
128
|
+
}
|
|
129
|
+
function roomTargetOf(path) {
|
|
130
|
+
const room = roomAt(path);
|
|
131
|
+
return room === null || room.path === '' ? null : room;
|
|
132
|
+
}
|
|
133
|
+
function resolvedOf(from, href) {
|
|
134
|
+
const base = located(href).base;
|
|
135
|
+
if (base === '')
|
|
30
136
|
return { kind: 'skip' };
|
|
31
|
-
if (
|
|
32
|
-
return { kind: 'invalid' };
|
|
33
|
-
const bare = trimmed.replace(/[?#].*$/, '');
|
|
34
|
-
if (bare === '')
|
|
137
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(base))
|
|
35
138
|
return { kind: 'skip' };
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
139
|
+
const path = destinationPath(href);
|
|
140
|
+
if (path === null)
|
|
38
141
|
return { kind: 'invalid' };
|
|
39
|
-
|
|
142
|
+
if (path.startsWith('/')) {
|
|
143
|
+
const room = roomAt(path);
|
|
144
|
+
return room === null ? { kind: 'invalid' } : { kind: 'room', ...room };
|
|
145
|
+
}
|
|
146
|
+
const resolved = normalize(join(dirname(from), path));
|
|
147
|
+
return resolved === null ? { kind: 'invalid' } : { kind: 'path', path: resolved };
|
|
148
|
+
}
|
|
149
|
+
export function classifyHref(from, href) {
|
|
150
|
+
const resolved = resolvedOf(from, href);
|
|
151
|
+
return 'path' in resolved && resolved.path === '' ? { kind: 'invalid' } : resolved;
|
|
152
|
+
}
|
|
153
|
+
export function roomTarget(href) {
|
|
154
|
+
const path = destinationPath(href);
|
|
155
|
+
return path === null ? null : roomTargetOf(path);
|
|
156
|
+
}
|
|
157
|
+
export function roomPath(href) {
|
|
158
|
+
const room = roomTarget(href);
|
|
159
|
+
return room === null ? null : `${SHELL_ROOMS}${room.handle}/${room.path}`;
|
|
40
160
|
}
|
|
41
161
|
export function target(from, href) {
|
|
42
162
|
const resolved = classifyHref(from, href);
|
|
43
163
|
return resolved.kind === 'path' ? resolved.path : null;
|
|
44
164
|
}
|
|
165
|
+
export function linkedPath(from, href) {
|
|
166
|
+
const resolved = located(href).base === '' ? { kind: 'path', path: from } : resolvedOf(from, href);
|
|
167
|
+
if (!('path' in resolved))
|
|
168
|
+
return null;
|
|
169
|
+
const written = href.trim();
|
|
170
|
+
const suffix = spelled(written, unescaped(written).suffix, false).text;
|
|
171
|
+
const hash = suffix.indexOf('#');
|
|
172
|
+
const fragment = hash === -1 ? '' : suffix.slice(hash + 1);
|
|
173
|
+
return {
|
|
174
|
+
handle: resolved.kind === 'room' ? resolved.handle : null,
|
|
175
|
+
path: resolved.path,
|
|
176
|
+
fragment: fragment === '' ? null : (decodedRun(fragment) ?? fragment),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
45
179
|
export function retarget(href, to) {
|
|
46
180
|
const trimmed = href.trim();
|
|
47
|
-
|
|
48
|
-
return match === null ? to : to + trimmed.slice(match.index);
|
|
181
|
+
return written(to) + trimmed.slice(unescaped(trimmed).suffix);
|
|
49
182
|
}
|
|
50
183
|
export function relative(from, target) {
|
|
51
184
|
const base = dirname(from)
|
|
@@ -62,8 +195,36 @@ export function relative(from, target) {
|
|
|
62
195
|
export const SHELL_ROOMS = '/rooms/';
|
|
63
196
|
export function shellTarget(href, handle) {
|
|
64
197
|
const prefix = `${SHELL_ROOMS}${handle}/`;
|
|
65
|
-
|
|
198
|
+
const decoded = destinationPath(href);
|
|
199
|
+
if (decoded === null || !decoded.startsWith(prefix))
|
|
66
200
|
return null;
|
|
67
|
-
const path = normalize(
|
|
201
|
+
const path = normalize(decoded.slice(prefix.length));
|
|
68
202
|
return path === null || path === '' ? null : path;
|
|
69
203
|
}
|
|
204
|
+
function fitsBare(to) {
|
|
205
|
+
if (to === '' || to.startsWith('<'))
|
|
206
|
+
return false;
|
|
207
|
+
let depth = 0;
|
|
208
|
+
for (const character of to) {
|
|
209
|
+
if (/[\s\u0000-\u001f\u007f]/.test(character))
|
|
210
|
+
return false;
|
|
211
|
+
if (character === '(')
|
|
212
|
+
depth += 1;
|
|
213
|
+
else if (character === ')') {
|
|
214
|
+
if (depth === 0)
|
|
215
|
+
return false;
|
|
216
|
+
depth -= 1;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return depth === 0;
|
|
220
|
+
}
|
|
221
|
+
function fitsBrackets(to) {
|
|
222
|
+
return to !== '' && !/[<>\n\r]/.test(to);
|
|
223
|
+
}
|
|
224
|
+
export function destinationText(to, bracketed) {
|
|
225
|
+
if (fitsBare(to))
|
|
226
|
+
return bracketed && fitsBrackets(to) ? `<${to}>` : to;
|
|
227
|
+
if (fitsBrackets(to))
|
|
228
|
+
return `<${to}>`;
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const PATTERN_STATES = 1000;
|
|
2
|
+
export declare class PatternTooCostly extends Error {
|
|
3
|
+
}
|
|
4
|
+
export type Pattern = {
|
|
5
|
+
readonly test: (text: string) => boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function linearPattern(source: string): Pattern | null;
|
|
8
|
+
export declare function withLinearRegExp<T>(run: () => T): T;
|
|
9
|
+
export declare function openPatternBudget(): () => void;
|
|
10
|
+
//# sourceMappingURL=pattern.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern.d.ts","sourceRoot":"","sources":["../src/pattern.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,OAAQ,CAAC;AAMpC,qBAAa,gBAAiB,SAAQ,KAAK;CAAG;AAQ9C,MAAM,MAAM,OAAO,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAA;CAAE,CAAC;AAkUnE,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAM5D;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAkBnD;AAED,wBAAgB,iBAAiB,IAAI,MAAM,IAAI,CAM9C"}
|