@axdspub/axiom-ui-forms 0.2.8 → 0.2.9
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/library/axiom-ui-forms.d.ts +36 -4
- package/library/esm/_virtual/index10.js +2 -2
- package/library/esm/_virtual/index11.js +2 -2
- package/library/esm/_virtual/index12.js +6 -2
- package/library/esm/_virtual/index12.js.map +1 -1
- package/library/esm/_virtual/index13.js +6 -2
- package/library/esm/_virtual/index13.js.map +1 -1
- package/library/esm/_virtual/index14.js +2 -2
- package/library/esm/_virtual/index15.js +4 -0
- package/library/esm/_virtual/index15.js.map +1 -0
- package/library/esm/_virtual/index16.js +4 -0
- package/library/esm/_virtual/index16.js.map +1 -0
- package/library/esm/_virtual/index17.js +4 -0
- package/library/esm/_virtual/index17.js.map +1 -0
- package/library/esm/_virtual/index6.js +2 -2
- package/library/esm/_virtual/index6.js.map +1 -1
- package/library/esm/_virtual/index7.js +2 -2
- package/library/esm/_virtual/index7.js.map +1 -1
- package/library/esm/_virtual/index8.js +2 -2
- package/library/esm/_virtual/index9.js +2 -2
- package/library/esm/_virtual/utilities.js +4 -0
- package/library/esm/_virtual/utilities.js.map +1 -0
- package/library/esm/node_modules/@axdspub/axiom-ui-utilities/library/index.js +241 -9
- package/library/esm/node_modules/@axdspub/axiom-ui-utilities/library/index.js.map +1 -1
- package/library/esm/node_modules/@babel/runtime/helpers/esm/extends.js +12 -0
- package/library/esm/node_modules/@babel/runtime/helpers/esm/extends.js.map +1 -0
- package/library/esm/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +12 -0
- package/library/esm/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js.map +1 -0
- package/library/esm/node_modules/@codemirror/autocomplete/dist/index.js +1652 -0
- package/library/esm/node_modules/@codemirror/autocomplete/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/commands/dist/index.js +1444 -0
- package/library/esm/node_modules/@codemirror/commands/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/lang-json/dist/index.js +33 -0
- package/library/esm/node_modules/@codemirror/lang-json/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/lang-yaml/dist/index.js +59 -0
- package/library/esm/node_modules/@codemirror/lang-yaml/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/language/dist/index.js +1821 -0
- package/library/esm/node_modules/@codemirror/language/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/lint/dist/index.js +589 -0
- package/library/esm/node_modules/@codemirror/lint/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/search/dist/index.js +1227 -0
- package/library/esm/node_modules/@codemirror/search/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/state/dist/index.js +3882 -0
- package/library/esm/node_modules/@codemirror/state/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/theme-one-dark/dist/index.js +114 -0
- package/library/esm/node_modules/@codemirror/theme-one-dark/dist/index.js.map +1 -0
- package/library/esm/node_modules/@codemirror/view/dist/index.js +11052 -0
- package/library/esm/node_modules/@codemirror/view/dist/index.js.map +1 -0
- package/library/esm/node_modules/@lezer/common/dist/index.js +1704 -0
- package/library/esm/node_modules/@lezer/common/dist/index.js.map +1 -0
- package/library/esm/node_modules/@lezer/highlight/dist/index.js +876 -0
- package/library/esm/node_modules/@lezer/highlight/dist/index.js.map +1 -0
- package/library/esm/node_modules/@lezer/json/dist/index.js +38 -0
- package/library/esm/node_modules/@lezer/json/dist/index.js.map +1 -0
- package/library/esm/node_modules/@lezer/lr/dist/index.js +1855 -0
- package/library/esm/node_modules/@lezer/lr/dist/index.js.map +1 -0
- package/library/esm/node_modules/@lezer/yaml/dist/index.js +392 -0
- package/library/esm/node_modules/@lezer/yaml/dist/index.js.map +1 -0
- package/library/esm/node_modules/@marijn/find-cluster-break/src/index.js +83 -0
- package/library/esm/node_modules/@marijn/find-cluster-break/src/index.js.map +1 -0
- package/library/esm/node_modules/@radix-ui/react-icons/dist/react-icons.esm.js +67 -1
- package/library/esm/node_modules/@radix-ui/react-icons/dist/react-icons.esm.js.map +1 -1
- package/library/esm/node_modules/@uiw/codemirror-extensions-basic-setup/esm/index.js +100 -0
- package/library/esm/node_modules/@uiw/codemirror-extensions-basic-setup/esm/index.js.map +1 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/getDefaultExtensions.js +58 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/getDefaultExtensions.js.map +1 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/index.js +89 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/index.js.map +1 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/theme/light.js +12 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/theme/light.js.map +1 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/useCodeMirror.js +151 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/useCodeMirror.js.map +1 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/utils.js +19 -0
- package/library/esm/node_modules/@uiw/react-codemirror/esm/utils.js.map +1 -0
- package/library/esm/node_modules/@ungap/structured-clone/esm/deserialize.js +77 -0
- package/library/esm/node_modules/@ungap/structured-clone/esm/deserialize.js.map +1 -0
- package/library/esm/node_modules/@ungap/structured-clone/esm/index.js +25 -0
- package/library/esm/node_modules/@ungap/structured-clone/esm/index.js.map +1 -0
- package/library/esm/node_modules/@ungap/structured-clone/esm/serialize.js +159 -0
- package/library/esm/node_modules/@ungap/structured-clone/esm/serialize.js.map +1 -0
- package/library/esm/node_modules/@ungap/structured-clone/esm/types.js +14 -0
- package/library/esm/node_modules/@ungap/structured-clone/esm/types.js.map +1 -0
- package/library/esm/node_modules/ajv/dist/compile/index.js +1 -1
- package/library/esm/node_modules/ajv/dist/vocabularies/applicator/index.js +1 -1
- package/library/esm/node_modules/ajv/dist/vocabularies/core/index.js +1 -1
- package/library/esm/node_modules/ajv/dist/vocabularies/format/index.js +1 -1
- package/library/esm/node_modules/ajv/dist/vocabularies/validation/index.js +1 -1
- package/library/esm/node_modules/bail/index.js +15 -0
- package/library/esm/node_modules/bail/index.js.map +1 -0
- package/library/esm/node_modules/comma-separated-tokens/index.js +37 -0
- package/library/esm/node_modules/comma-separated-tokens/index.js.map +1 -0
- package/library/esm/node_modules/crelt/index.js +30 -0
- package/library/esm/node_modules/crelt/index.js.map +1 -0
- package/library/esm/node_modules/decode-named-character-reference/index.dom.js +39 -0
- package/library/esm/node_modules/decode-named-character-reference/index.dom.js.map +1 -0
- package/library/esm/node_modules/devlop/lib/default.js +6 -0
- package/library/esm/node_modules/devlop/lib/default.js.map +1 -0
- package/library/esm/node_modules/estree-util-is-identifier-name/lib/index.js +31 -0
- package/library/esm/node_modules/estree-util-is-identifier-name/lib/index.js.map +1 -0
- package/library/esm/node_modules/extend/index.js +127 -0
- package/library/esm/node_modules/extend/index.js.map +1 -0
- package/library/esm/node_modules/fast-uri/index.js +1 -1
- package/library/esm/node_modules/hast-util-to-jsx-runtime/lib/index.js +791 -0
- package/library/esm/node_modules/hast-util-to-jsx-runtime/lib/index.js.map +1 -0
- package/library/esm/node_modules/hast-util-whitespace/lib/index.js +37 -0
- package/library/esm/node_modules/hast-util-whitespace/lib/index.js.map +1 -0
- package/library/esm/node_modules/html-url-attributes/lib/index.js +34 -0
- package/library/esm/node_modules/html-url-attributes/lib/index.js.map +1 -0
- package/library/esm/node_modules/inline-style-parser/index.js +268 -0
- package/library/esm/node_modules/inline-style-parser/index.js.map +1 -0
- package/library/esm/node_modules/js-yaml/dist/js-yaml.js +3850 -0
- package/library/esm/node_modules/js-yaml/dist/js-yaml.js.map +1 -0
- package/library/esm/node_modules/json-schema-traverse/index.js +1 -1
- package/library/esm/node_modules/mdast-util-from-markdown/lib/index.js +1181 -0
- package/library/esm/node_modules/mdast-util-from-markdown/lib/index.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/footer.js +197 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/footer.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/blockquote.js +31 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/blockquote.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/break.js +27 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/break.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/code.js +51 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/code.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/delete.js +31 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/delete.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/emphasis.js +31 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/emphasis.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/footnote-reference.js +74 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/footnote-reference.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/heading.js +31 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/heading.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/html.js +32 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/html.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/image-reference.js +45 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/image-reference.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/image.js +40 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/image.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/index.js +67 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/index.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/inline-code.js +36 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/inline-code.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/link-reference.js +50 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/link-reference.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/link.js +41 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/link.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/list-item.js +126 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/list-item.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/list.js +57 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/list.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/paragraph.js +31 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/paragraph.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/root.js +27 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/root.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/strong.js +31 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/strong.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/table-cell.js +33 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/table-cell.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/table-row.js +70 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/table-row.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/table.js +65 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/table.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/text.js +29 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/text.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/thematic-break.js +31 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/handlers/thematic-break.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/index.js +105 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/index.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/revert.js +56 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/revert.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/state.js +322 -0
- package/library/esm/node_modules/mdast-util-to-hast/lib/state.js.map +1 -0
- package/library/esm/node_modules/mdast-util-to-string/lib/index.js +111 -0
- package/library/esm/node_modules/mdast-util-to-string/lib/index.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/constructs.js +108 -0
- package/library/esm/node_modules/micromark/lib/constructs.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/create-tokenizer.js +576 -0
- package/library/esm/node_modules/micromark/lib/create-tokenizer.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/initialize/content.js +83 -0
- package/library/esm/node_modules/micromark/lib/initialize/content.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/initialize/document.js +361 -0
- package/library/esm/node_modules/micromark/lib/initialize/document.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/initialize/flow.js +62 -0
- package/library/esm/node_modules/micromark/lib/initialize/flow.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/initialize/text.js +213 -0
- package/library/esm/node_modules/micromark/lib/initialize/text.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/parse.js +60 -0
- package/library/esm/node_modules/micromark/lib/parse.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/postprocess.js +22 -0
- package/library/esm/node_modules/micromark/lib/postprocess.js.map +1 -0
- package/library/esm/node_modules/micromark/lib/preprocess.js +118 -0
- package/library/esm/node_modules/micromark/lib/preprocess.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/attention.js +245 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/attention.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/autolink.js +237 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/autolink.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/blank-line.js +65 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/blank-line.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/block-quote.js +147 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/block-quote.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/character-escape.js +68 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/character-escape.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/character-reference.js +153 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/character-reference.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/code-fenced.js +464 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/code-fenced.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/code-indented.js +181 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/code-indented.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/code-text.js +228 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/code-text.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/content.js +167 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/content.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/definition.js +258 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/definition.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/hard-break-escape.js +64 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/hard-break-escape.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/heading-atx.js +199 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/heading-atx.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/html-flow.js +880 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/html-flow.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/html-text.js +682 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/html-text.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/label-end.js +564 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/label-end.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/label-start-image.js +106 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/label-start-image.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/label-start-link.js +59 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/label-start-link.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/line-ending.js +36 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/line-ending.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/list.js +217 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/list.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/setext-underline.js +189 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/setext-underline.js.map +1 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/thematic-break.js +106 -0
- package/library/esm/node_modules/micromark-core-commonmark/lib/thematic-break.js.map +1 -0
- package/library/esm/node_modules/micromark-factory-destination/index.js +210 -0
- package/library/esm/node_modules/micromark-factory-destination/index.js.map +1 -0
- package/library/esm/node_modules/micromark-factory-label/index.js +152 -0
- package/library/esm/node_modules/micromark-factory-label/index.js.map +1 -0
- package/library/esm/node_modules/micromark-factory-space/index.js +68 -0
- package/library/esm/node_modules/micromark-factory-space/index.js.map +1 -0
- package/library/esm/node_modules/micromark-factory-title/index.js +162 -0
- package/library/esm/node_modules/micromark-factory-title/index.js.map +1 -0
- package/library/esm/node_modules/micromark-factory-whitespace/index.js +48 -0
- package/library/esm/node_modules/micromark-factory-whitespace/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-character/index.js +249 -0
- package/library/esm/node_modules/micromark-util-character/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-chunked/index.js +84 -0
- package/library/esm/node_modules/micromark-util-chunked/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-classify-character/index.js +31 -0
- package/library/esm/node_modules/micromark-util-classify-character/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-combine-extensions/index.js +96 -0
- package/library/esm/node_modules/micromark-util-combine-extensions/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-decode-numeric-character-reference/index.js +35 -0
- package/library/esm/node_modules/micromark-util-decode-numeric-character-reference/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-decode-string/index.js +49 -0
- package/library/esm/node_modules/micromark-util-decode-string/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-html-tag-name/index.js +96 -0
- package/library/esm/node_modules/micromark-util-html-tag-name/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-normalize-identifier/index.js +36 -0
- package/library/esm/node_modules/micromark-util-normalize-identifier/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-resolve-all/index.js +35 -0
- package/library/esm/node_modules/micromark-util-resolve-all/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-sanitize-uri/index.js +67 -0
- package/library/esm/node_modules/micromark-util-sanitize-uri/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-subtokenize/index.js +227 -0
- package/library/esm/node_modules/micromark-util-subtokenize/index.js.map +1 -0
- package/library/esm/node_modules/micromark-util-subtokenize/lib/splice-buffer.js +254 -0
- package/library/esm/node_modules/micromark-util-subtokenize/lib/splice-buffer.js.map +1 -0
- package/library/esm/node_modules/property-information/index.js +16 -0
- package/library/esm/node_modules/property-information/index.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/aria.js +64 -0
- package/library/esm/node_modules/property-information/lib/aria.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/find.js +101 -0
- package/library/esm/node_modules/property-information/lib/find.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/hast-to-react.js +33 -0
- package/library/esm/node_modules/property-information/lib/hast-to-react.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/html.js +318 -0
- package/library/esm/node_modules/property-information/lib/html.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/normalize.js +15 -0
- package/library/esm/node_modules/property-information/lib/normalize.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/svg.js +564 -0
- package/library/esm/node_modules/property-information/lib/svg.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/util/case-insensitive-transform.js +16 -0
- package/library/esm/node_modules/property-information/lib/util/case-insensitive-transform.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/util/case-sensitive-transform.js +14 -0
- package/library/esm/node_modules/property-information/lib/util/case-sensitive-transform.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/util/create.js +47 -0
- package/library/esm/node_modules/property-information/lib/util/create.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/util/defined-info.js +64 -0
- package/library/esm/node_modules/property-information/lib/util/defined-info.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/util/info.js +35 -0
- package/library/esm/node_modules/property-information/lib/util/info.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/util/merge.js +31 -0
- package/library/esm/node_modules/property-information/lib/util/merge.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/util/schema.js +32 -0
- package/library/esm/node_modules/property-information/lib/util/schema.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/util/types.js +16 -0
- package/library/esm/node_modules/property-information/lib/util/types.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/xlink.js +20 -0
- package/library/esm/node_modules/property-information/lib/xlink.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/xml.js +12 -0
- package/library/esm/node_modules/property-information/lib/xml.js.map +1 -0
- package/library/esm/node_modules/property-information/lib/xmlns.js +12 -0
- package/library/esm/node_modules/property-information/lib/xmlns.js.map +1 -0
- package/library/esm/node_modules/react-markdown/lib/index.js +267 -0
- package/library/esm/node_modules/react-markdown/lib/index.js.map +1 -0
- package/library/esm/node_modules/react-router/dist/development/chunk-HA7DTUK3.js +1 -1
- package/library/esm/node_modules/react-router/node_modules/cookie/dist/index.js +1 -1
- package/library/esm/node_modules/remark-parse/lib/index.js +43 -0
- package/library/esm/node_modules/remark-parse/lib/index.js.map +1 -0
- package/library/esm/node_modules/remark-rehype/lib/index.js +132 -0
- package/library/esm/node_modules/remark-rehype/lib/index.js.map +1 -0
- package/library/esm/node_modules/space-separated-tokens/index.js +23 -0
- package/library/esm/node_modules/space-separated-tokens/index.js.map +1 -0
- package/library/esm/node_modules/style-mod/src/style-mod.js +175 -0
- package/library/esm/node_modules/style-mod/src/style-mod.js.map +1 -0
- package/library/esm/node_modules/style-to-js/cjs/index.js +38 -0
- package/library/esm/node_modules/style-to-js/cjs/index.js.map +1 -0
- package/library/esm/node_modules/style-to-js/cjs/utilities.js +58 -0
- package/library/esm/node_modules/style-to-js/cjs/utilities.js.map +1 -0
- package/library/esm/node_modules/style-to-object/cjs/index.js +56 -0
- package/library/esm/node_modules/style-to-object/cjs/index.js.map +1 -0
- package/library/esm/node_modules/trim-lines/index.js +72 -0
- package/library/esm/node_modules/trim-lines/index.js.map +1 -0
- package/library/esm/node_modules/trough/lib/index.js +209 -0
- package/library/esm/node_modules/trough/lib/index.js.map +1 -0
- package/library/esm/node_modules/unified/lib/callable-instance.js +47 -0
- package/library/esm/node_modules/unified/lib/callable-instance.js.map +1 -0
- package/library/esm/node_modules/unified/lib/index.js +979 -0
- package/library/esm/node_modules/unified/lib/index.js.map +1 -0
- package/library/esm/node_modules/unified/node_modules/is-plain-obj/index.js +11 -0
- package/library/esm/node_modules/unified/node_modules/is-plain-obj/index.js.map +1 -0
- package/library/esm/node_modules/unist-util-is/lib/index.js +179 -0
- package/library/esm/node_modules/unist-util-is/lib/index.js.map +1 -0
- package/library/esm/node_modules/unist-util-position/lib/index.js +98 -0
- package/library/esm/node_modules/unist-util-position/lib/index.js.map +1 -0
- package/library/esm/node_modules/unist-util-stringify-position/lib/index.js +87 -0
- package/library/esm/node_modules/unist-util-stringify-position/lib/index.js.map +1 -0
- package/library/esm/node_modules/unist-util-visit/lib/index.js +95 -0
- package/library/esm/node_modules/unist-util-visit/lib/index.js.map +1 -0
- package/library/esm/node_modules/unist-util-visit-parents/lib/color.js +10 -0
- package/library/esm/node_modules/unist-util-visit-parents/lib/color.js.map +1 -0
- package/library/esm/node_modules/unist-util-visit-parents/lib/index.js +188 -0
- package/library/esm/node_modules/unist-util-visit-parents/lib/index.js.map +1 -0
- package/library/esm/node_modules/vfile/lib/index.js +644 -0
- package/library/esm/node_modules/vfile/lib/index.js.map +1 -0
- package/library/esm/node_modules/vfile/lib/minpath.browser.js +427 -0
- package/library/esm/node_modules/vfile/lib/minpath.browser.js.map +1 -0
- package/library/esm/node_modules/vfile/lib/minproc.browser.js +11 -0
- package/library/esm/node_modules/vfile/lib/minproc.browser.js.map +1 -0
- package/library/esm/node_modules/vfile/lib/minurl.browser.js +77 -0
- package/library/esm/node_modules/vfile/lib/minurl.browser.js.map +1 -0
- package/library/esm/node_modules/vfile/lib/minurl.shared.js +34 -0
- package/library/esm/node_modules/vfile/lib/minurl.shared.js.map +1 -0
- package/library/esm/node_modules/vfile-message/lib/index.js +305 -0
- package/library/esm/node_modules/vfile-message/lib/index.js.map +1 -0
- package/library/esm/node_modules/w3c-keyname/index.js +122 -0
- package/library/esm/node_modules/w3c-keyname/index.js.map +1 -0
- package/library/esm/src/Form/Components/FieldLabel.js +13 -3
- package/library/esm/src/Form/Components/FieldLabel.js.map +1 -1
- package/library/esm/src/Form/Components/InlineMarkdown.js +15 -0
- package/library/esm/src/Form/Components/InlineMarkdown.js.map +1 -0
- package/library/esm/src/Form/Components/Inputs/Boolean.js +5 -2
- package/library/esm/src/Form/Components/Inputs/Boolean.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/GeoJSONInputLoader.js +1 -1
- package/library/esm/src/Form/Components/Inputs/Geometry.js +290 -329
- package/library/esm/src/Form/Components/Inputs/Geometry.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/JSON.js +132 -0
- package/library/esm/src/Form/Components/Inputs/JSON.js.map +1 -0
- package/library/esm/src/Form/Components/Inputs/JSONInputLoader.js +19 -0
- package/library/esm/src/Form/Components/Inputs/JSONInputLoader.js.map +1 -0
- package/library/esm/src/Form/Components/Inputs/Number.js +78 -8
- package/library/esm/src/Form/Components/Inputs/Number.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/inputMap.js +2 -2
- package/library/esm/src/Form/Components/Inputs/inputMap.js.map +1 -1
- package/library/esm/src/Form/Creator/FormCreator.js +6 -2
- package/library/esm/src/Form/Creator/FormCreator.js.map +1 -1
- package/library/esm/src/Form/Creator/FormHeader.js +7 -5
- package/library/esm/src/Form/Creator/FormHeader.js.map +1 -1
- package/library/esm/src/Form/Creator/Page.js +4 -3
- package/library/esm/src/Form/Creator/Page.js.map +1 -1
- package/library/esm/src/Form/Manage/CopyableJSONOutput.js +41 -0
- package/library/esm/src/Form/Manage/CopyableJSONOutput.js.map +1 -0
- package/library/esm/src/Form/helpers.js +1 -1
- package/library/esm/src/Form/helpers.js.map +1 -1
- package/library/esm/src/Form/schemaToFormHelpers.js +87 -1
- package/library/esm/src/Form/schemaToFormHelpers.js.map +1 -1
- package/library/esm/src/library.js +1 -1
- package/package.json +7 -1
- package/library/esm/src/Form/Components/Inputs/JSONString.js +0 -34
- package/library/esm/src/Form/Components/Inputs/JSONString.js.map +0 -1
@@ -0,0 +1,979 @@
|
|
1
|
+
import { bail } from '../../bail/index.js';
|
2
|
+
import extend from '../../../_virtual/index13.js';
|
3
|
+
import isPlainObject from '../node_modules/is-plain-obj/index.js';
|
4
|
+
import { CallableInstance } from './callable-instance.js';
|
5
|
+
import { trough } from '../../trough/lib/index.js';
|
6
|
+
import { VFile } from '../../vfile/lib/index.js';
|
7
|
+
|
8
|
+
/**
|
9
|
+
* @typedef {import('trough').Pipeline} Pipeline
|
10
|
+
*
|
11
|
+
* @typedef {import('unist').Node} Node
|
12
|
+
*
|
13
|
+
* @typedef {import('vfile').Compatible} Compatible
|
14
|
+
* @typedef {import('vfile').Value} Value
|
15
|
+
*
|
16
|
+
* @typedef {import('../index.js').CompileResultMap} CompileResultMap
|
17
|
+
* @typedef {import('../index.js').Data} Data
|
18
|
+
* @typedef {import('../index.js').Settings} Settings
|
19
|
+
*/
|
20
|
+
|
21
|
+
|
22
|
+
// To do: next major: drop `Compiler`, `Parser`: prefer lowercase.
|
23
|
+
|
24
|
+
// To do: we could start yielding `never` in TS when a parser is missing and
|
25
|
+
// `parse` is called.
|
26
|
+
// Currently, we allow directly setting `processor.parser`, which is untyped.
|
27
|
+
|
28
|
+
const own = {}.hasOwnProperty;
|
29
|
+
|
30
|
+
/**
|
31
|
+
* @template {Node | undefined} [ParseTree=undefined]
|
32
|
+
* Output of `parse` (optional).
|
33
|
+
* @template {Node | undefined} [HeadTree=undefined]
|
34
|
+
* Input for `run` (optional).
|
35
|
+
* @template {Node | undefined} [TailTree=undefined]
|
36
|
+
* Output for `run` (optional).
|
37
|
+
* @template {Node | undefined} [CompileTree=undefined]
|
38
|
+
* Input of `stringify` (optional).
|
39
|
+
* @template {CompileResults | undefined} [CompileResult=undefined]
|
40
|
+
* Output of `stringify` (optional).
|
41
|
+
* @extends {CallableInstance<[], Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>>}
|
42
|
+
*/
|
43
|
+
class Processor extends CallableInstance {
|
44
|
+
/**
|
45
|
+
* Create a processor.
|
46
|
+
*/
|
47
|
+
constructor() {
|
48
|
+
// If `Processor()` is called (w/o new), `copy` is called instead.
|
49
|
+
super('copy');
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Compiler to use (deprecated).
|
53
|
+
*
|
54
|
+
* @deprecated
|
55
|
+
* Use `compiler` instead.
|
56
|
+
* @type {(
|
57
|
+
* Compiler<
|
58
|
+
* CompileTree extends undefined ? Node : CompileTree,
|
59
|
+
* CompileResult extends undefined ? CompileResults : CompileResult
|
60
|
+
* > |
|
61
|
+
* undefined
|
62
|
+
* )}
|
63
|
+
*/
|
64
|
+
this.Compiler = undefined;
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Parser to use (deprecated).
|
68
|
+
*
|
69
|
+
* @deprecated
|
70
|
+
* Use `parser` instead.
|
71
|
+
* @type {(
|
72
|
+
* Parser<ParseTree extends undefined ? Node : ParseTree> |
|
73
|
+
* undefined
|
74
|
+
* )}
|
75
|
+
*/
|
76
|
+
this.Parser = undefined;
|
77
|
+
|
78
|
+
// Note: the following fields are considered private.
|
79
|
+
// However, they are needed for tests, and TSC generates an untyped
|
80
|
+
// `private freezeIndex` field for, which trips `type-coverage` up.
|
81
|
+
// Instead, we use `@deprecated` to visualize that they shouldn’t be used.
|
82
|
+
/**
|
83
|
+
* Internal list of configured plugins.
|
84
|
+
*
|
85
|
+
* @deprecated
|
86
|
+
* This is a private internal property and should not be used.
|
87
|
+
* @type {Array<PluginTuple<Array<unknown>>>}
|
88
|
+
*/
|
89
|
+
this.attachers = [];
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Compiler to use.
|
93
|
+
*
|
94
|
+
* @type {(
|
95
|
+
* Compiler<
|
96
|
+
* CompileTree extends undefined ? Node : CompileTree,
|
97
|
+
* CompileResult extends undefined ? CompileResults : CompileResult
|
98
|
+
* > |
|
99
|
+
* undefined
|
100
|
+
* )}
|
101
|
+
*/
|
102
|
+
this.compiler = undefined;
|
103
|
+
|
104
|
+
/**
|
105
|
+
* Internal state to track where we are while freezing.
|
106
|
+
*
|
107
|
+
* @deprecated
|
108
|
+
* This is a private internal property and should not be used.
|
109
|
+
* @type {number}
|
110
|
+
*/
|
111
|
+
this.freezeIndex = -1;
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Internal state to track whether we’re frozen.
|
115
|
+
*
|
116
|
+
* @deprecated
|
117
|
+
* This is a private internal property and should not be used.
|
118
|
+
* @type {boolean | undefined}
|
119
|
+
*/
|
120
|
+
this.frozen = undefined;
|
121
|
+
|
122
|
+
/**
|
123
|
+
* Internal state.
|
124
|
+
*
|
125
|
+
* @deprecated
|
126
|
+
* This is a private internal property and should not be used.
|
127
|
+
* @type {Data}
|
128
|
+
*/
|
129
|
+
this.namespace = {};
|
130
|
+
|
131
|
+
/**
|
132
|
+
* Parser to use.
|
133
|
+
*
|
134
|
+
* @type {(
|
135
|
+
* Parser<ParseTree extends undefined ? Node : ParseTree> |
|
136
|
+
* undefined
|
137
|
+
* )}
|
138
|
+
*/
|
139
|
+
this.parser = undefined;
|
140
|
+
|
141
|
+
/**
|
142
|
+
* Internal list of configured transformers.
|
143
|
+
*
|
144
|
+
* @deprecated
|
145
|
+
* This is a private internal property and should not be used.
|
146
|
+
* @type {Pipeline}
|
147
|
+
*/
|
148
|
+
this.transformers = trough();
|
149
|
+
}
|
150
|
+
|
151
|
+
/**
|
152
|
+
* Copy a processor.
|
153
|
+
*
|
154
|
+
* @deprecated
|
155
|
+
* This is a private internal method and should not be used.
|
156
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
157
|
+
* New *unfrozen* processor ({@linkcode Processor}) that is
|
158
|
+
* configured to work the same as its ancestor.
|
159
|
+
* When the descendant processor is configured in the future it does not
|
160
|
+
* affect the ancestral processor.
|
161
|
+
*/
|
162
|
+
copy() {
|
163
|
+
// Cast as the type parameters will be the same after attaching.
|
164
|
+
const destination =
|
165
|
+
/** @type {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>} */ (
|
166
|
+
new Processor()
|
167
|
+
);
|
168
|
+
let index = -1;
|
169
|
+
|
170
|
+
while (++index < this.attachers.length) {
|
171
|
+
const attacher = this.attachers[index];
|
172
|
+
destination.use(...attacher);
|
173
|
+
}
|
174
|
+
|
175
|
+
destination.data(extend(true, {}, this.namespace));
|
176
|
+
|
177
|
+
return destination
|
178
|
+
}
|
179
|
+
|
180
|
+
/**
|
181
|
+
* Configure the processor with info available to all plugins.
|
182
|
+
* Information is stored in an object.
|
183
|
+
*
|
184
|
+
* Typically, options can be given to a specific plugin, but sometimes it
|
185
|
+
* makes sense to have information shared with several plugins.
|
186
|
+
* For example, a list of HTML elements that are self-closing, which is
|
187
|
+
* needed during all phases.
|
188
|
+
*
|
189
|
+
* > **Note**: setting information cannot occur on *frozen* processors.
|
190
|
+
* > Call the processor first to create a new unfrozen processor.
|
191
|
+
*
|
192
|
+
* > **Note**: to register custom data in TypeScript, augment the
|
193
|
+
* > {@linkcode Data} interface.
|
194
|
+
*
|
195
|
+
* @example
|
196
|
+
* This example show how to get and set info:
|
197
|
+
*
|
198
|
+
* ```js
|
199
|
+
* import {unified} from 'unified'
|
200
|
+
*
|
201
|
+
* const processor = unified().data('alpha', 'bravo')
|
202
|
+
*
|
203
|
+
* processor.data('alpha') // => 'bravo'
|
204
|
+
*
|
205
|
+
* processor.data() // => {alpha: 'bravo'}
|
206
|
+
*
|
207
|
+
* processor.data({charlie: 'delta'})
|
208
|
+
*
|
209
|
+
* processor.data() // => {charlie: 'delta'}
|
210
|
+
* ```
|
211
|
+
*
|
212
|
+
* @template {keyof Data} Key
|
213
|
+
*
|
214
|
+
* @overload
|
215
|
+
* @returns {Data}
|
216
|
+
*
|
217
|
+
* @overload
|
218
|
+
* @param {Data} dataset
|
219
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
220
|
+
*
|
221
|
+
* @overload
|
222
|
+
* @param {Key} key
|
223
|
+
* @returns {Data[Key]}
|
224
|
+
*
|
225
|
+
* @overload
|
226
|
+
* @param {Key} key
|
227
|
+
* @param {Data[Key]} value
|
228
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
229
|
+
*
|
230
|
+
* @param {Data | Key} [key]
|
231
|
+
* Key to get or set, or entire dataset to set, or nothing to get the
|
232
|
+
* entire dataset (optional).
|
233
|
+
* @param {Data[Key]} [value]
|
234
|
+
* Value to set (optional).
|
235
|
+
* @returns {unknown}
|
236
|
+
* The current processor when setting, the value at `key` when getting, or
|
237
|
+
* the entire dataset when getting without key.
|
238
|
+
*/
|
239
|
+
data(key, value) {
|
240
|
+
if (typeof key === 'string') {
|
241
|
+
// Set `key`.
|
242
|
+
if (arguments.length === 2) {
|
243
|
+
assertUnfrozen('data', this.frozen);
|
244
|
+
this.namespace[key] = value;
|
245
|
+
return this
|
246
|
+
}
|
247
|
+
|
248
|
+
// Get `key`.
|
249
|
+
return (own.call(this.namespace, key) && this.namespace[key]) || undefined
|
250
|
+
}
|
251
|
+
|
252
|
+
// Set space.
|
253
|
+
if (key) {
|
254
|
+
assertUnfrozen('data', this.frozen);
|
255
|
+
this.namespace = key;
|
256
|
+
return this
|
257
|
+
}
|
258
|
+
|
259
|
+
// Get space.
|
260
|
+
return this.namespace
|
261
|
+
}
|
262
|
+
|
263
|
+
/**
|
264
|
+
* Freeze a processor.
|
265
|
+
*
|
266
|
+
* Frozen processors are meant to be extended and not to be configured
|
267
|
+
* directly.
|
268
|
+
*
|
269
|
+
* When a processor is frozen it cannot be unfrozen.
|
270
|
+
* New processors working the same way can be created by calling the
|
271
|
+
* processor.
|
272
|
+
*
|
273
|
+
* It’s possible to freeze processors explicitly by calling `.freeze()`.
|
274
|
+
* Processors freeze automatically when `.parse()`, `.run()`, `.runSync()`,
|
275
|
+
* `.stringify()`, `.process()`, or `.processSync()` are called.
|
276
|
+
*
|
277
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
278
|
+
* The current processor.
|
279
|
+
*/
|
280
|
+
freeze() {
|
281
|
+
if (this.frozen) {
|
282
|
+
return this
|
283
|
+
}
|
284
|
+
|
285
|
+
// Cast so that we can type plugins easier.
|
286
|
+
// Plugins are supposed to be usable on different processors, not just on
|
287
|
+
// this exact processor.
|
288
|
+
const self = /** @type {Processor} */ (/** @type {unknown} */ (this));
|
289
|
+
|
290
|
+
while (++this.freezeIndex < this.attachers.length) {
|
291
|
+
const [attacher, ...options] = this.attachers[this.freezeIndex];
|
292
|
+
|
293
|
+
if (options[0] === false) {
|
294
|
+
continue
|
295
|
+
}
|
296
|
+
|
297
|
+
if (options[0] === true) {
|
298
|
+
options[0] = undefined;
|
299
|
+
}
|
300
|
+
|
301
|
+
const transformer = attacher.call(self, ...options);
|
302
|
+
|
303
|
+
if (typeof transformer === 'function') {
|
304
|
+
this.transformers.use(transformer);
|
305
|
+
}
|
306
|
+
}
|
307
|
+
|
308
|
+
this.frozen = true;
|
309
|
+
this.freezeIndex = Number.POSITIVE_INFINITY;
|
310
|
+
|
311
|
+
return this
|
312
|
+
}
|
313
|
+
|
314
|
+
/**
|
315
|
+
* Parse text to a syntax tree.
|
316
|
+
*
|
317
|
+
* > **Note**: `parse` freezes the processor if not already *frozen*.
|
318
|
+
*
|
319
|
+
* > **Note**: `parse` performs the parse phase, not the run phase or other
|
320
|
+
* > phases.
|
321
|
+
*
|
322
|
+
* @param {Compatible | undefined} [file]
|
323
|
+
* file to parse (optional); typically `string` or `VFile`; any value
|
324
|
+
* accepted as `x` in `new VFile(x)`.
|
325
|
+
* @returns {ParseTree extends undefined ? Node : ParseTree}
|
326
|
+
* Syntax tree representing `file`.
|
327
|
+
*/
|
328
|
+
parse(file) {
|
329
|
+
this.freeze();
|
330
|
+
const realFile = vfile(file);
|
331
|
+
const parser = this.parser || this.Parser;
|
332
|
+
assertParser('parse', parser);
|
333
|
+
return parser(String(realFile), realFile)
|
334
|
+
}
|
335
|
+
|
336
|
+
/**
|
337
|
+
* Process the given file as configured on the processor.
|
338
|
+
*
|
339
|
+
* > **Note**: `process` freezes the processor if not already *frozen*.
|
340
|
+
*
|
341
|
+
* > **Note**: `process` performs the parse, run, and stringify phases.
|
342
|
+
*
|
343
|
+
* @overload
|
344
|
+
* @param {Compatible | undefined} file
|
345
|
+
* @param {ProcessCallback<VFileWithOutput<CompileResult>>} done
|
346
|
+
* @returns {undefined}
|
347
|
+
*
|
348
|
+
* @overload
|
349
|
+
* @param {Compatible | undefined} [file]
|
350
|
+
* @returns {Promise<VFileWithOutput<CompileResult>>}
|
351
|
+
*
|
352
|
+
* @param {Compatible | undefined} [file]
|
353
|
+
* File (optional); typically `string` or `VFile`]; any value accepted as
|
354
|
+
* `x` in `new VFile(x)`.
|
355
|
+
* @param {ProcessCallback<VFileWithOutput<CompileResult>> | undefined} [done]
|
356
|
+
* Callback (optional).
|
357
|
+
* @returns {Promise<VFile> | undefined}
|
358
|
+
* Nothing if `done` is given.
|
359
|
+
* Otherwise a promise, rejected with a fatal error or resolved with the
|
360
|
+
* processed file.
|
361
|
+
*
|
362
|
+
* The parsed, transformed, and compiled value is available at
|
363
|
+
* `file.value` (see note).
|
364
|
+
*
|
365
|
+
* > **Note**: unified typically compiles by serializing: most
|
366
|
+
* > compilers return `string` (or `Uint8Array`).
|
367
|
+
* > Some compilers, such as the one configured with
|
368
|
+
* > [`rehype-react`][rehype-react], return other values (in this case, a
|
369
|
+
* > React tree).
|
370
|
+
* > If you’re using a compiler that doesn’t serialize, expect different
|
371
|
+
* > result values.
|
372
|
+
* >
|
373
|
+
* > To register custom results in TypeScript, add them to
|
374
|
+
* > {@linkcode CompileResultMap}.
|
375
|
+
*
|
376
|
+
* [rehype-react]: https://github.com/rehypejs/rehype-react
|
377
|
+
*/
|
378
|
+
process(file, done) {
|
379
|
+
const self = this;
|
380
|
+
|
381
|
+
this.freeze();
|
382
|
+
assertParser('process', this.parser || this.Parser);
|
383
|
+
assertCompiler('process', this.compiler || this.Compiler);
|
384
|
+
|
385
|
+
return done ? executor(undefined, done) : new Promise(executor)
|
386
|
+
|
387
|
+
// Note: `void`s needed for TS.
|
388
|
+
/**
|
389
|
+
* @param {((file: VFileWithOutput<CompileResult>) => undefined | void) | undefined} resolve
|
390
|
+
* @param {(error: Error | undefined) => undefined | void} reject
|
391
|
+
* @returns {undefined}
|
392
|
+
*/
|
393
|
+
function executor(resolve, reject) {
|
394
|
+
const realFile = vfile(file);
|
395
|
+
// Assume `ParseTree` (the result of the parser) matches `HeadTree` (the
|
396
|
+
// input of the first transform).
|
397
|
+
const parseTree =
|
398
|
+
/** @type {HeadTree extends undefined ? Node : HeadTree} */ (
|
399
|
+
/** @type {unknown} */ (self.parse(realFile))
|
400
|
+
);
|
401
|
+
|
402
|
+
self.run(parseTree, realFile, function (error, tree, file) {
|
403
|
+
if (error || !tree || !file) {
|
404
|
+
return realDone(error)
|
405
|
+
}
|
406
|
+
|
407
|
+
// Assume `TailTree` (the output of the last transform) matches
|
408
|
+
// `CompileTree` (the input of the compiler).
|
409
|
+
const compileTree =
|
410
|
+
/** @type {CompileTree extends undefined ? Node : CompileTree} */ (
|
411
|
+
/** @type {unknown} */ (tree)
|
412
|
+
);
|
413
|
+
|
414
|
+
const compileResult = self.stringify(compileTree, file);
|
415
|
+
|
416
|
+
if (looksLikeAValue(compileResult)) {
|
417
|
+
file.value = compileResult;
|
418
|
+
} else {
|
419
|
+
file.result = compileResult;
|
420
|
+
}
|
421
|
+
|
422
|
+
realDone(error, /** @type {VFileWithOutput<CompileResult>} */ (file));
|
423
|
+
});
|
424
|
+
|
425
|
+
/**
|
426
|
+
* @param {Error | undefined} error
|
427
|
+
* @param {VFileWithOutput<CompileResult> | undefined} [file]
|
428
|
+
* @returns {undefined}
|
429
|
+
*/
|
430
|
+
function realDone(error, file) {
|
431
|
+
if (error || !file) {
|
432
|
+
reject(error);
|
433
|
+
} else if (resolve) {
|
434
|
+
resolve(file);
|
435
|
+
} else {
|
436
|
+
done(undefined, file);
|
437
|
+
}
|
438
|
+
}
|
439
|
+
}
|
440
|
+
}
|
441
|
+
|
442
|
+
/**
|
443
|
+
* Process the given file as configured on the processor.
|
444
|
+
*
|
445
|
+
* An error is thrown if asynchronous transforms are configured.
|
446
|
+
*
|
447
|
+
* > **Note**: `processSync` freezes the processor if not already *frozen*.
|
448
|
+
*
|
449
|
+
* > **Note**: `processSync` performs the parse, run, and stringify phases.
|
450
|
+
*
|
451
|
+
* @param {Compatible | undefined} [file]
|
452
|
+
* File (optional); typically `string` or `VFile`; any value accepted as
|
453
|
+
* `x` in `new VFile(x)`.
|
454
|
+
* @returns {VFileWithOutput<CompileResult>}
|
455
|
+
* The processed file.
|
456
|
+
*
|
457
|
+
* The parsed, transformed, and compiled value is available at
|
458
|
+
* `file.value` (see note).
|
459
|
+
*
|
460
|
+
* > **Note**: unified typically compiles by serializing: most
|
461
|
+
* > compilers return `string` (or `Uint8Array`).
|
462
|
+
* > Some compilers, such as the one configured with
|
463
|
+
* > [`rehype-react`][rehype-react], return other values (in this case, a
|
464
|
+
* > React tree).
|
465
|
+
* > If you’re using a compiler that doesn’t serialize, expect different
|
466
|
+
* > result values.
|
467
|
+
* >
|
468
|
+
* > To register custom results in TypeScript, add them to
|
469
|
+
* > {@linkcode CompileResultMap}.
|
470
|
+
*
|
471
|
+
* [rehype-react]: https://github.com/rehypejs/rehype-react
|
472
|
+
*/
|
473
|
+
processSync(file) {
|
474
|
+
/** @type {boolean} */
|
475
|
+
let complete = false;
|
476
|
+
/** @type {VFileWithOutput<CompileResult> | undefined} */
|
477
|
+
let result;
|
478
|
+
|
479
|
+
this.freeze();
|
480
|
+
assertParser('processSync', this.parser || this.Parser);
|
481
|
+
assertCompiler('processSync', this.compiler || this.Compiler);
|
482
|
+
|
483
|
+
this.process(file, realDone);
|
484
|
+
assertDone('processSync', 'process', complete);
|
485
|
+
|
486
|
+
return result
|
487
|
+
|
488
|
+
/**
|
489
|
+
* @type {ProcessCallback<VFileWithOutput<CompileResult>>}
|
490
|
+
*/
|
491
|
+
function realDone(error, file) {
|
492
|
+
complete = true;
|
493
|
+
bail(error);
|
494
|
+
result = file;
|
495
|
+
}
|
496
|
+
}
|
497
|
+
|
498
|
+
/**
|
499
|
+
* Run *transformers* on a syntax tree.
|
500
|
+
*
|
501
|
+
* > **Note**: `run` freezes the processor if not already *frozen*.
|
502
|
+
*
|
503
|
+
* > **Note**: `run` performs the run phase, not other phases.
|
504
|
+
*
|
505
|
+
* @overload
|
506
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
507
|
+
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
|
508
|
+
* @returns {undefined}
|
509
|
+
*
|
510
|
+
* @overload
|
511
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
512
|
+
* @param {Compatible | undefined} file
|
513
|
+
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} done
|
514
|
+
* @returns {undefined}
|
515
|
+
*
|
516
|
+
* @overload
|
517
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
518
|
+
* @param {Compatible | undefined} [file]
|
519
|
+
* @returns {Promise<TailTree extends undefined ? Node : TailTree>}
|
520
|
+
*
|
521
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
522
|
+
* Tree to transform and inspect.
|
523
|
+
* @param {(
|
524
|
+
* RunCallback<TailTree extends undefined ? Node : TailTree> |
|
525
|
+
* Compatible
|
526
|
+
* )} [file]
|
527
|
+
* File associated with `node` (optional); any value accepted as `x` in
|
528
|
+
* `new VFile(x)`.
|
529
|
+
* @param {RunCallback<TailTree extends undefined ? Node : TailTree>} [done]
|
530
|
+
* Callback (optional).
|
531
|
+
* @returns {Promise<TailTree extends undefined ? Node : TailTree> | undefined}
|
532
|
+
* Nothing if `done` is given.
|
533
|
+
* Otherwise, a promise rejected with a fatal error or resolved with the
|
534
|
+
* transformed tree.
|
535
|
+
*/
|
536
|
+
run(tree, file, done) {
|
537
|
+
assertNode(tree);
|
538
|
+
this.freeze();
|
539
|
+
|
540
|
+
const transformers = this.transformers;
|
541
|
+
|
542
|
+
if (!done && typeof file === 'function') {
|
543
|
+
done = file;
|
544
|
+
file = undefined;
|
545
|
+
}
|
546
|
+
|
547
|
+
return done ? executor(undefined, done) : new Promise(executor)
|
548
|
+
|
549
|
+
// Note: `void`s needed for TS.
|
550
|
+
/**
|
551
|
+
* @param {(
|
552
|
+
* ((tree: TailTree extends undefined ? Node : TailTree) => undefined | void) |
|
553
|
+
* undefined
|
554
|
+
* )} resolve
|
555
|
+
* @param {(error: Error) => undefined | void} reject
|
556
|
+
* @returns {undefined}
|
557
|
+
*/
|
558
|
+
function executor(resolve, reject) {
|
559
|
+
const realFile = vfile(file);
|
560
|
+
transformers.run(tree, realFile, realDone);
|
561
|
+
|
562
|
+
/**
|
563
|
+
* @param {Error | undefined} error
|
564
|
+
* @param {Node} outputTree
|
565
|
+
* @param {VFile} file
|
566
|
+
* @returns {undefined}
|
567
|
+
*/
|
568
|
+
function realDone(error, outputTree, file) {
|
569
|
+
const resultingTree =
|
570
|
+
/** @type {TailTree extends undefined ? Node : TailTree} */ (
|
571
|
+
outputTree || tree
|
572
|
+
);
|
573
|
+
|
574
|
+
if (error) {
|
575
|
+
reject(error);
|
576
|
+
} else if (resolve) {
|
577
|
+
resolve(resultingTree);
|
578
|
+
} else {
|
579
|
+
done(undefined, resultingTree, file);
|
580
|
+
}
|
581
|
+
}
|
582
|
+
}
|
583
|
+
}
|
584
|
+
|
585
|
+
/**
|
586
|
+
* Run *transformers* on a syntax tree.
|
587
|
+
*
|
588
|
+
* An error is thrown if asynchronous transforms are configured.
|
589
|
+
*
|
590
|
+
* > **Note**: `runSync` freezes the processor if not already *frozen*.
|
591
|
+
*
|
592
|
+
* > **Note**: `runSync` performs the run phase, not other phases.
|
593
|
+
*
|
594
|
+
* @param {HeadTree extends undefined ? Node : HeadTree} tree
|
595
|
+
* Tree to transform and inspect.
|
596
|
+
* @param {Compatible | undefined} [file]
|
597
|
+
* File associated with `node` (optional); any value accepted as `x` in
|
598
|
+
* `new VFile(x)`.
|
599
|
+
* @returns {TailTree extends undefined ? Node : TailTree}
|
600
|
+
* Transformed tree.
|
601
|
+
*/
|
602
|
+
runSync(tree, file) {
|
603
|
+
/** @type {boolean} */
|
604
|
+
let complete = false;
|
605
|
+
/** @type {(TailTree extends undefined ? Node : TailTree) | undefined} */
|
606
|
+
let result;
|
607
|
+
|
608
|
+
this.run(tree, file, realDone);
|
609
|
+
|
610
|
+
assertDone('runSync', 'run', complete);
|
611
|
+
return result
|
612
|
+
|
613
|
+
/**
|
614
|
+
* @type {RunCallback<TailTree extends undefined ? Node : TailTree>}
|
615
|
+
*/
|
616
|
+
function realDone(error, tree) {
|
617
|
+
bail(error);
|
618
|
+
result = tree;
|
619
|
+
complete = true;
|
620
|
+
}
|
621
|
+
}
|
622
|
+
|
623
|
+
/**
|
624
|
+
* Compile a syntax tree.
|
625
|
+
*
|
626
|
+
* > **Note**: `stringify` freezes the processor if not already *frozen*.
|
627
|
+
*
|
628
|
+
* > **Note**: `stringify` performs the stringify phase, not the run phase
|
629
|
+
* > or other phases.
|
630
|
+
*
|
631
|
+
* @param {CompileTree extends undefined ? Node : CompileTree} tree
|
632
|
+
* Tree to compile.
|
633
|
+
* @param {Compatible | undefined} [file]
|
634
|
+
* File associated with `node` (optional); any value accepted as `x` in
|
635
|
+
* `new VFile(x)`.
|
636
|
+
* @returns {CompileResult extends undefined ? Value : CompileResult}
|
637
|
+
* Textual representation of the tree (see note).
|
638
|
+
*
|
639
|
+
* > **Note**: unified typically compiles by serializing: most compilers
|
640
|
+
* > return `string` (or `Uint8Array`).
|
641
|
+
* > Some compilers, such as the one configured with
|
642
|
+
* > [`rehype-react`][rehype-react], return other values (in this case, a
|
643
|
+
* > React tree).
|
644
|
+
* > If you’re using a compiler that doesn’t serialize, expect different
|
645
|
+
* > result values.
|
646
|
+
* >
|
647
|
+
* > To register custom results in TypeScript, add them to
|
648
|
+
* > {@linkcode CompileResultMap}.
|
649
|
+
*
|
650
|
+
* [rehype-react]: https://github.com/rehypejs/rehype-react
|
651
|
+
*/
|
652
|
+
stringify(tree, file) {
|
653
|
+
this.freeze();
|
654
|
+
const realFile = vfile(file);
|
655
|
+
const compiler = this.compiler || this.Compiler;
|
656
|
+
assertCompiler('stringify', compiler);
|
657
|
+
assertNode(tree);
|
658
|
+
|
659
|
+
return compiler(tree, realFile)
|
660
|
+
}
|
661
|
+
|
662
|
+
/**
|
663
|
+
* Configure the processor to use a plugin, a list of usable values, or a
|
664
|
+
* preset.
|
665
|
+
*
|
666
|
+
* If the processor is already using a plugin, the previous plugin
|
667
|
+
* configuration is changed based on the options that are passed in.
|
668
|
+
* In other words, the plugin is not added a second time.
|
669
|
+
*
|
670
|
+
* > **Note**: `use` cannot be called on *frozen* processors.
|
671
|
+
* > Call the processor first to create a new unfrozen processor.
|
672
|
+
*
|
673
|
+
* @example
|
674
|
+
* There are many ways to pass plugins to `.use()`.
|
675
|
+
* This example gives an overview:
|
676
|
+
*
|
677
|
+
* ```js
|
678
|
+
* import {unified} from 'unified'
|
679
|
+
*
|
680
|
+
* unified()
|
681
|
+
* // Plugin with options:
|
682
|
+
* .use(pluginA, {x: true, y: true})
|
683
|
+
* // Passing the same plugin again merges configuration (to `{x: true, y: false, z: true}`):
|
684
|
+
* .use(pluginA, {y: false, z: true})
|
685
|
+
* // Plugins:
|
686
|
+
* .use([pluginB, pluginC])
|
687
|
+
* // Two plugins, the second with options:
|
688
|
+
* .use([pluginD, [pluginE, {}]])
|
689
|
+
* // Preset with plugins and settings:
|
690
|
+
* .use({plugins: [pluginF, [pluginG, {}]], settings: {position: false}})
|
691
|
+
* // Settings only:
|
692
|
+
* .use({settings: {position: false}})
|
693
|
+
* ```
|
694
|
+
*
|
695
|
+
* @template {Array<unknown>} [Parameters=[]]
|
696
|
+
* @template {Node | string | undefined} [Input=undefined]
|
697
|
+
* @template [Output=Input]
|
698
|
+
*
|
699
|
+
* @overload
|
700
|
+
* @param {Preset | null | undefined} [preset]
|
701
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
702
|
+
*
|
703
|
+
* @overload
|
704
|
+
* @param {PluggableList} list
|
705
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
706
|
+
*
|
707
|
+
* @overload
|
708
|
+
* @param {Plugin<Parameters, Input, Output>} plugin
|
709
|
+
* @param {...(Parameters | [boolean])} parameters
|
710
|
+
* @returns {UsePlugin<ParseTree, HeadTree, TailTree, CompileTree, CompileResult, Input, Output>}
|
711
|
+
*
|
712
|
+
* @param {PluggableList | Plugin | Preset | null | undefined} value
|
713
|
+
* Usable value.
|
714
|
+
* @param {...unknown} parameters
|
715
|
+
* Parameters, when a plugin is given as a usable value.
|
716
|
+
* @returns {Processor<ParseTree, HeadTree, TailTree, CompileTree, CompileResult>}
|
717
|
+
* Current processor.
|
718
|
+
*/
|
719
|
+
use(value, ...parameters) {
|
720
|
+
const attachers = this.attachers;
|
721
|
+
const namespace = this.namespace;
|
722
|
+
|
723
|
+
assertUnfrozen('use', this.frozen);
|
724
|
+
|
725
|
+
if (value === null || value === undefined) ; else if (typeof value === 'function') {
|
726
|
+
addPlugin(value, parameters);
|
727
|
+
} else if (typeof value === 'object') {
|
728
|
+
if (Array.isArray(value)) {
|
729
|
+
addList(value);
|
730
|
+
} else {
|
731
|
+
addPreset(value);
|
732
|
+
}
|
733
|
+
} else {
|
734
|
+
throw new TypeError('Expected usable value, not `' + value + '`')
|
735
|
+
}
|
736
|
+
|
737
|
+
return this
|
738
|
+
|
739
|
+
/**
|
740
|
+
* @param {Pluggable} value
|
741
|
+
* @returns {undefined}
|
742
|
+
*/
|
743
|
+
function add(value) {
|
744
|
+
if (typeof value === 'function') {
|
745
|
+
addPlugin(value, []);
|
746
|
+
} else if (typeof value === 'object') {
|
747
|
+
if (Array.isArray(value)) {
|
748
|
+
const [plugin, ...parameters] =
|
749
|
+
/** @type {PluginTuple<Array<unknown>>} */ (value);
|
750
|
+
addPlugin(plugin, parameters);
|
751
|
+
} else {
|
752
|
+
addPreset(value);
|
753
|
+
}
|
754
|
+
} else {
|
755
|
+
throw new TypeError('Expected usable value, not `' + value + '`')
|
756
|
+
}
|
757
|
+
}
|
758
|
+
|
759
|
+
/**
|
760
|
+
* @param {Preset} result
|
761
|
+
* @returns {undefined}
|
762
|
+
*/
|
763
|
+
function addPreset(result) {
|
764
|
+
if (!('plugins' in result) && !('settings' in result)) {
|
765
|
+
throw new Error(
|
766
|
+
'Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither'
|
767
|
+
)
|
768
|
+
}
|
769
|
+
|
770
|
+
addList(result.plugins);
|
771
|
+
|
772
|
+
if (result.settings) {
|
773
|
+
namespace.settings = extend(true, namespace.settings, result.settings);
|
774
|
+
}
|
775
|
+
}
|
776
|
+
|
777
|
+
/**
|
778
|
+
* @param {PluggableList | null | undefined} plugins
|
779
|
+
* @returns {undefined}
|
780
|
+
*/
|
781
|
+
function addList(plugins) {
|
782
|
+
let index = -1;
|
783
|
+
|
784
|
+
if (plugins === null || plugins === undefined) ; else if (Array.isArray(plugins)) {
|
785
|
+
while (++index < plugins.length) {
|
786
|
+
const thing = plugins[index];
|
787
|
+
add(thing);
|
788
|
+
}
|
789
|
+
} else {
|
790
|
+
throw new TypeError('Expected a list of plugins, not `' + plugins + '`')
|
791
|
+
}
|
792
|
+
}
|
793
|
+
|
794
|
+
/**
|
795
|
+
* @param {Plugin} plugin
|
796
|
+
* @param {Array<unknown>} parameters
|
797
|
+
* @returns {undefined}
|
798
|
+
*/
|
799
|
+
function addPlugin(plugin, parameters) {
|
800
|
+
let index = -1;
|
801
|
+
let entryIndex = -1;
|
802
|
+
|
803
|
+
while (++index < attachers.length) {
|
804
|
+
if (attachers[index][0] === plugin) {
|
805
|
+
entryIndex = index;
|
806
|
+
break
|
807
|
+
}
|
808
|
+
}
|
809
|
+
|
810
|
+
if (entryIndex === -1) {
|
811
|
+
attachers.push([plugin, ...parameters]);
|
812
|
+
}
|
813
|
+
// Only set if there was at least a `primary` value, otherwise we’d change
|
814
|
+
// `arguments.length`.
|
815
|
+
else if (parameters.length > 0) {
|
816
|
+
let [primary, ...rest] = parameters;
|
817
|
+
const currentPrimary = attachers[entryIndex][1];
|
818
|
+
if (isPlainObject(currentPrimary) && isPlainObject(primary)) {
|
819
|
+
primary = extend(true, currentPrimary, primary);
|
820
|
+
}
|
821
|
+
|
822
|
+
attachers[entryIndex] = [plugin, primary, ...rest];
|
823
|
+
}
|
824
|
+
}
|
825
|
+
}
|
826
|
+
}
|
827
|
+
|
828
|
+
// Note: this returns a *callable* instance.
|
829
|
+
// That’s why it’s documented as a function.
|
830
|
+
/**
|
831
|
+
* Create a new processor.
|
832
|
+
*
|
833
|
+
* @example
|
834
|
+
* This example shows how a new processor can be created (from `remark`) and linked
|
835
|
+
* to **stdin**(4) and **stdout**(4).
|
836
|
+
*
|
837
|
+
* ```js
|
838
|
+
* import process from 'node:process'
|
839
|
+
* import concatStream from 'concat-stream'
|
840
|
+
* import {remark} from 'remark'
|
841
|
+
*
|
842
|
+
* process.stdin.pipe(
|
843
|
+
* concatStream(function (buf) {
|
844
|
+
* process.stdout.write(String(remark().processSync(buf)))
|
845
|
+
* })
|
846
|
+
* )
|
847
|
+
* ```
|
848
|
+
*
|
849
|
+
* @returns
|
850
|
+
* New *unfrozen* processor (`processor`).
|
851
|
+
*
|
852
|
+
* This processor is configured to work the same as its ancestor.
|
853
|
+
* When the descendant processor is configured in the future it does not
|
854
|
+
* affect the ancestral processor.
|
855
|
+
*/
|
856
|
+
const unified = new Processor().freeze();
|
857
|
+
|
858
|
+
/**
|
859
|
+
* Assert a parser is available.
|
860
|
+
*
|
861
|
+
* @param {string} name
|
862
|
+
* @param {unknown} value
|
863
|
+
* @returns {asserts value is Parser}
|
864
|
+
*/
|
865
|
+
function assertParser(name, value) {
|
866
|
+
if (typeof value !== 'function') {
|
867
|
+
throw new TypeError('Cannot `' + name + '` without `parser`')
|
868
|
+
}
|
869
|
+
}
|
870
|
+
|
871
|
+
/**
|
872
|
+
* Assert a compiler is available.
|
873
|
+
*
|
874
|
+
* @param {string} name
|
875
|
+
* @param {unknown} value
|
876
|
+
* @returns {asserts value is Compiler}
|
877
|
+
*/
|
878
|
+
function assertCompiler(name, value) {
|
879
|
+
if (typeof value !== 'function') {
|
880
|
+
throw new TypeError('Cannot `' + name + '` without `compiler`')
|
881
|
+
}
|
882
|
+
}
|
883
|
+
|
884
|
+
/**
|
885
|
+
* Assert the processor is not frozen.
|
886
|
+
*
|
887
|
+
* @param {string} name
|
888
|
+
* @param {unknown} frozen
|
889
|
+
* @returns {asserts frozen is false}
|
890
|
+
*/
|
891
|
+
function assertUnfrozen(name, frozen) {
|
892
|
+
if (frozen) {
|
893
|
+
throw new Error(
|
894
|
+
'Cannot call `' +
|
895
|
+
name +
|
896
|
+
'` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.'
|
897
|
+
)
|
898
|
+
}
|
899
|
+
}
|
900
|
+
|
901
|
+
/**
|
902
|
+
* Assert `node` is a unist node.
|
903
|
+
*
|
904
|
+
* @param {unknown} node
|
905
|
+
* @returns {asserts node is Node}
|
906
|
+
*/
|
907
|
+
function assertNode(node) {
|
908
|
+
// `isPlainObj` unfortunately uses `any` instead of `unknown`.
|
909
|
+
// type-coverage:ignore-next-line
|
910
|
+
if (!isPlainObject(node) || typeof node.type !== 'string') {
|
911
|
+
throw new TypeError('Expected node, got `' + node + '`')
|
912
|
+
// Fine.
|
913
|
+
}
|
914
|
+
}
|
915
|
+
|
916
|
+
/**
|
917
|
+
* Assert that `complete` is `true`.
|
918
|
+
*
|
919
|
+
* @param {string} name
|
920
|
+
* @param {string} asyncName
|
921
|
+
* @param {unknown} complete
|
922
|
+
* @returns {asserts complete is true}
|
923
|
+
*/
|
924
|
+
function assertDone(name, asyncName, complete) {
|
925
|
+
if (!complete) {
|
926
|
+
throw new Error(
|
927
|
+
'`' + name + '` finished async. Use `' + asyncName + '` instead'
|
928
|
+
)
|
929
|
+
}
|
930
|
+
}
|
931
|
+
|
932
|
+
/**
|
933
|
+
* @param {Compatible | undefined} [value]
|
934
|
+
* @returns {VFile}
|
935
|
+
*/
|
936
|
+
function vfile(value) {
|
937
|
+
return looksLikeAVFile(value) ? value : new VFile(value)
|
938
|
+
}
|
939
|
+
|
940
|
+
/**
|
941
|
+
* @param {Compatible | undefined} [value]
|
942
|
+
* @returns {value is VFile}
|
943
|
+
*/
|
944
|
+
function looksLikeAVFile(value) {
|
945
|
+
return Boolean(
|
946
|
+
value &&
|
947
|
+
typeof value === 'object' &&
|
948
|
+
'message' in value &&
|
949
|
+
'messages' in value
|
950
|
+
)
|
951
|
+
}
|
952
|
+
|
953
|
+
/**
|
954
|
+
* @param {unknown} [value]
|
955
|
+
* @returns {value is Value}
|
956
|
+
*/
|
957
|
+
function looksLikeAValue(value) {
|
958
|
+
return typeof value === 'string' || isUint8Array(value)
|
959
|
+
}
|
960
|
+
|
961
|
+
/**
|
962
|
+
* Assert `value` is an `Uint8Array`.
|
963
|
+
*
|
964
|
+
* @param {unknown} value
|
965
|
+
* thing.
|
966
|
+
* @returns {value is Uint8Array}
|
967
|
+
* Whether `value` is an `Uint8Array`.
|
968
|
+
*/
|
969
|
+
function isUint8Array(value) {
|
970
|
+
return Boolean(
|
971
|
+
value &&
|
972
|
+
typeof value === 'object' &&
|
973
|
+
'byteLength' in value &&
|
974
|
+
'byteOffset' in value
|
975
|
+
)
|
976
|
+
}
|
977
|
+
|
978
|
+
export { Processor, unified };
|
979
|
+
//# sourceMappingURL=index.js.map
|