pull-request-split-advisor 3.1.2
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/LICENSE +52 -0
- package/README.md +168 -0
- package/dist/ai/config-wizard.js +282 -0
- package/dist/ai/enricher.js +290 -0
- package/dist/ai/prompts.js +231 -0
- package/dist/ai/provider.js +265 -0
- package/dist/cli.js +442 -0
- package/dist/config/config.js +315 -0
- package/dist/config/default-config.js +223 -0
- package/dist/core/blocks.js +145 -0
- package/dist/core/commit-planner.js +273 -0
- package/dist/core/dependency.js +284 -0
- package/dist/core/file-stats.js +341 -0
- package/dist/core/history.js +72 -0
- package/dist/core/planner.js +25 -0
- package/dist/core/scoring.js +166 -0
- package/dist/core/strategy.js +486 -0
- package/dist/git/branch-naming.js +120 -0
- package/dist/git/executor.js +378 -0
- package/dist/git/git.js +239 -0
- package/dist/output/report-styles.generated.js +10 -0
- package/dist/output/report.js +726 -0
- package/dist/output/ui.js +417 -0
- package/dist/shared/constants.js +59 -0
- package/dist/shared/types.js +7 -0
- package/dist/shared/utils.js +73 -0
- package/node_modules/@colors/colors/LICENSE +26 -0
- package/node_modules/@colors/colors/README.md +219 -0
- package/node_modules/@colors/colors/examples/normal-usage.js +83 -0
- package/node_modules/@colors/colors/examples/safe-string.js +80 -0
- package/node_modules/@colors/colors/index.d.ts +136 -0
- package/node_modules/@colors/colors/lib/colors.js +211 -0
- package/node_modules/@colors/colors/lib/custom/trap.js +46 -0
- package/node_modules/@colors/colors/lib/custom/zalgo.js +110 -0
- package/node_modules/@colors/colors/lib/extendStringPrototype.js +110 -0
- package/node_modules/@colors/colors/lib/index.js +13 -0
- package/node_modules/@colors/colors/lib/maps/america.js +10 -0
- package/node_modules/@colors/colors/lib/maps/rainbow.js +12 -0
- package/node_modules/@colors/colors/lib/maps/random.js +11 -0
- package/node_modules/@colors/colors/lib/maps/zebra.js +5 -0
- package/node_modules/@colors/colors/lib/styles.js +95 -0
- package/node_modules/@colors/colors/lib/system/has-flag.js +35 -0
- package/node_modules/@colors/colors/lib/system/supports-colors.js +151 -0
- package/node_modules/@colors/colors/package.json +45 -0
- package/node_modules/@colors/colors/safe.d.ts +48 -0
- package/node_modules/@colors/colors/safe.js +10 -0
- package/node_modules/@colors/colors/themes/generic-logging.js +12 -0
- package/node_modules/ansi-align/LICENSE +13 -0
- package/node_modules/ansi-align/README.md +80 -0
- package/node_modules/ansi-align/index.js +61 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/index.d.ts +37 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/index.js +10 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/license +9 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/package.json +55 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/readme.md +78 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/README.md +73 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/es2015/index.js +6 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/es2015/text.js +6 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/index.d.ts +23 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/index.js +6 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/package.json +50 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/text.js +6 -0
- package/node_modules/ansi-align/node_modules/string-width/index.d.ts +29 -0
- package/node_modules/ansi-align/node_modules/string-width/index.js +47 -0
- package/node_modules/ansi-align/node_modules/string-width/license +9 -0
- package/node_modules/ansi-align/node_modules/string-width/package.json +56 -0
- package/node_modules/ansi-align/node_modules/string-width/readme.md +50 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/index.d.ts +17 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/index.js +4 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/license +9 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/package.json +54 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/readme.md +46 -0
- package/node_modules/ansi-align/package.json +43 -0
- package/node_modules/ansi-regex/index.d.ts +33 -0
- package/node_modules/ansi-regex/index.js +14 -0
- package/node_modules/ansi-regex/license +9 -0
- package/node_modules/ansi-regex/package.json +61 -0
- package/node_modules/ansi-regex/readme.md +66 -0
- package/node_modules/ansi-styles/index.d.ts +236 -0
- package/node_modules/ansi-styles/index.js +223 -0
- package/node_modules/ansi-styles/license +9 -0
- package/node_modules/ansi-styles/package.json +54 -0
- package/node_modules/ansi-styles/readme.md +173 -0
- package/node_modules/boxen/index.d.ts +267 -0
- package/node_modules/boxen/index.js +376 -0
- package/node_modules/boxen/license +9 -0
- package/node_modules/boxen/package.json +69 -0
- package/node_modules/boxen/readme.md +300 -0
- package/node_modules/camelcase/index.d.ts +102 -0
- package/node_modules/camelcase/index.js +110 -0
- package/node_modules/camelcase/license +9 -0
- package/node_modules/camelcase/package.json +47 -0
- package/node_modules/camelcase/readme.md +135 -0
- package/node_modules/chalk/license +9 -0
- package/node_modules/chalk/package.json +83 -0
- package/node_modules/chalk/readme.md +297 -0
- package/node_modules/chalk/source/index.d.ts +325 -0
- package/node_modules/chalk/source/index.js +225 -0
- package/node_modules/chalk/source/utilities.js +33 -0
- package/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +236 -0
- package/node_modules/chalk/source/vendor/ansi-styles/index.js +223 -0
- package/node_modules/chalk/source/vendor/supports-color/browser.d.ts +1 -0
- package/node_modules/chalk/source/vendor/supports-color/browser.js +34 -0
- package/node_modules/chalk/source/vendor/supports-color/index.d.ts +55 -0
- package/node_modules/chalk/source/vendor/supports-color/index.js +190 -0
- package/node_modules/cli-boxes/boxes.json +82 -0
- package/node_modules/cli-boxes/index.d.ts +127 -0
- package/node_modules/cli-boxes/index.js +6 -0
- package/node_modules/cli-boxes/license +9 -0
- package/node_modules/cli-boxes/package.json +42 -0
- package/node_modules/cli-boxes/readme.md +115 -0
- package/node_modules/cli-table3/LICENSE +21 -0
- package/node_modules/cli-table3/README.md +236 -0
- package/node_modules/cli-table3/index.d.ts +96 -0
- package/node_modules/cli-table3/index.js +1 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/index.d.ts +37 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/index.js +10 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/license +9 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/package.json +55 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/readme.md +78 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/README.md +73 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/es2015/index.js +6 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/es2015/text.js +6 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/index.d.ts +23 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/index.js +6 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/package.json +50 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/text.js +6 -0
- package/node_modules/cli-table3/node_modules/string-width/index.d.ts +29 -0
- package/node_modules/cli-table3/node_modules/string-width/index.js +47 -0
- package/node_modules/cli-table3/node_modules/string-width/license +9 -0
- package/node_modules/cli-table3/node_modules/string-width/package.json +56 -0
- package/node_modules/cli-table3/node_modules/string-width/readme.md +50 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/index.d.ts +17 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/index.js +4 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/license +9 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/package.json +54 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/readme.md +46 -0
- package/node_modules/cli-table3/package.json +100 -0
- package/node_modules/cli-table3/src/cell.js +409 -0
- package/node_modules/cli-table3/src/debug.js +28 -0
- package/node_modules/cli-table3/src/layout-manager.js +254 -0
- package/node_modules/cli-table3/src/table.js +106 -0
- package/node_modules/cli-table3/src/utils.js +344 -0
- package/node_modules/commander/LICENSE +22 -0
- package/node_modules/commander/Readme.md +1157 -0
- package/node_modules/commander/esm.mjs +16 -0
- package/node_modules/commander/index.js +24 -0
- package/node_modules/commander/lib/argument.js +149 -0
- package/node_modules/commander/lib/command.js +2509 -0
- package/node_modules/commander/lib/error.js +39 -0
- package/node_modules/commander/lib/help.js +520 -0
- package/node_modules/commander/lib/option.js +330 -0
- package/node_modules/commander/lib/suggestSimilar.js +101 -0
- package/node_modules/commander/package-support.json +16 -0
- package/node_modules/commander/package.json +84 -0
- package/node_modules/commander/typings/esm.d.mts +3 -0
- package/node_modules/commander/typings/index.d.ts +969 -0
- package/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/emoji-regex/README.md +107 -0
- package/node_modules/emoji-regex/index.d.ts +3 -0
- package/node_modules/emoji-regex/index.js +4 -0
- package/node_modules/emoji-regex/index.mjs +4 -0
- package/node_modules/emoji-regex/package.json +45 -0
- package/node_modules/get-east-asian-width/index.d.ts +60 -0
- package/node_modules/get-east-asian-width/index.js +30 -0
- package/node_modules/get-east-asian-width/license +9 -0
- package/node_modules/get-east-asian-width/lookup-data.js +18 -0
- package/node_modules/get-east-asian-width/lookup.js +135 -0
- package/node_modules/get-east-asian-width/package.json +71 -0
- package/node_modules/get-east-asian-width/readme.md +65 -0
- package/node_modules/get-east-asian-width/utilities.js +24 -0
- package/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
- package/node_modules/is-fullwidth-code-point/index.js +50 -0
- package/node_modules/is-fullwidth-code-point/license +9 -0
- package/node_modules/is-fullwidth-code-point/package.json +42 -0
- package/node_modules/is-fullwidth-code-point/readme.md +39 -0
- package/node_modules/isbinaryfile/LICENSE.txt +22 -0
- package/node_modules/isbinaryfile/README.md +70 -0
- package/node_modules/isbinaryfile/lib/index.d.ts +3 -0
- package/node_modules/isbinaryfile/lib/index.js +256 -0
- package/node_modules/isbinaryfile/package.json +64 -0
- package/node_modules/string-width/index.d.ts +39 -0
- package/node_modules/string-width/index.js +82 -0
- package/node_modules/string-width/license +9 -0
- package/node_modules/string-width/package.json +64 -0
- package/node_modules/string-width/readme.md +66 -0
- package/node_modules/strip-ansi/index.d.ts +15 -0
- package/node_modules/strip-ansi/index.js +19 -0
- package/node_modules/strip-ansi/license +9 -0
- package/node_modules/strip-ansi/package.json +59 -0
- package/node_modules/strip-ansi/readme.md +37 -0
- package/node_modules/type-fest/index.d.ts +178 -0
- package/node_modules/type-fest/license-cc0 +121 -0
- package/node_modules/type-fest/license-mit +9 -0
- package/node_modules/type-fest/package.json +91 -0
- package/node_modules/type-fest/readme.md +1060 -0
- package/node_modules/type-fest/source/all-union-fields.d.ts +88 -0
- package/node_modules/type-fest/source/and.d.ts +25 -0
- package/node_modules/type-fest/source/array-indices.d.ts +23 -0
- package/node_modules/type-fest/source/array-slice.d.ts +109 -0
- package/node_modules/type-fest/source/array-splice.d.ts +99 -0
- package/node_modules/type-fest/source/array-tail.d.ts +76 -0
- package/node_modules/type-fest/source/array-values.d.ts +22 -0
- package/node_modules/type-fest/source/arrayable.d.ts +29 -0
- package/node_modules/type-fest/source/async-return-type.d.ts +23 -0
- package/node_modules/type-fest/source/asyncify.d.ts +32 -0
- package/node_modules/type-fest/source/basic.d.ts +68 -0
- package/node_modules/type-fest/source/camel-case.d.ts +89 -0
- package/node_modules/type-fest/source/camel-cased-properties-deep.d.ts +97 -0
- package/node_modules/type-fest/source/camel-cased-properties.d.ts +43 -0
- package/node_modules/type-fest/source/conditional-except.d.ts +45 -0
- package/node_modules/type-fest/source/conditional-keys.d.ts +47 -0
- package/node_modules/type-fest/source/conditional-pick-deep.d.ts +118 -0
- package/node_modules/type-fest/source/conditional-pick.d.ts +44 -0
- package/node_modules/type-fest/source/conditional-simplify.d.ts +32 -0
- package/node_modules/type-fest/source/delimiter-case.d.ts +78 -0
- package/node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts +106 -0
- package/node_modules/type-fest/source/delimiter-cased-properties.d.ts +46 -0
- package/node_modules/type-fest/source/distributed-omit.d.ts +89 -0
- package/node_modules/type-fest/source/distributed-pick.d.ts +85 -0
- package/node_modules/type-fest/source/empty-object.d.ts +46 -0
- package/node_modules/type-fest/source/enforce-optional.d.ts +47 -0
- package/node_modules/type-fest/source/entries.d.ts +62 -0
- package/node_modules/type-fest/source/entry.d.ts +65 -0
- package/node_modules/type-fest/source/exact.d.ts +68 -0
- package/node_modules/type-fest/source/except.d.ts +108 -0
- package/node_modules/type-fest/source/find-global-type.d.ts +64 -0
- package/node_modules/type-fest/source/fixed-length-array.d.ts +43 -0
- package/node_modules/type-fest/source/get.d.ts +219 -0
- package/node_modules/type-fest/source/global-this.d.ts +21 -0
- package/node_modules/type-fest/source/greater-than-or-equal.d.ts +22 -0
- package/node_modules/type-fest/source/greater-than.d.ts +56 -0
- package/node_modules/type-fest/source/has-optional-keys.d.ts +21 -0
- package/node_modules/type-fest/source/has-readonly-keys.d.ts +21 -0
- package/node_modules/type-fest/source/has-required-keys.d.ts +59 -0
- package/node_modules/type-fest/source/has-writable-keys.d.ts +21 -0
- package/node_modules/type-fest/source/if-any.d.ts +24 -0
- package/node_modules/type-fest/source/if-empty-object.d.ts +26 -0
- package/node_modules/type-fest/source/if-never.d.ts +24 -0
- package/node_modules/type-fest/source/if-null.d.ts +24 -0
- package/node_modules/type-fest/source/if-unknown.d.ts +24 -0
- package/node_modules/type-fest/source/includes.d.ts +22 -0
- package/node_modules/type-fest/source/int-closed-range.d.ts +35 -0
- package/node_modules/type-fest/source/int-range.d.ts +55 -0
- package/node_modules/type-fest/source/internal/array.d.ts +126 -0
- package/node_modules/type-fest/source/internal/characters.d.ts +67 -0
- package/node_modules/type-fest/source/internal/index.d.ts +8 -0
- package/node_modules/type-fest/source/internal/keys.d.ts +97 -0
- package/node_modules/type-fest/source/internal/numeric.d.ts +118 -0
- package/node_modules/type-fest/source/internal/object.d.ts +236 -0
- package/node_modules/type-fest/source/internal/string.d.ts +210 -0
- package/node_modules/type-fest/source/internal/tuple.d.ts +90 -0
- package/node_modules/type-fest/source/internal/type.d.ts +139 -0
- package/node_modules/type-fest/source/invariant-of.d.ts +76 -0
- package/node_modules/type-fest/source/is-any.d.ts +33 -0
- package/node_modules/type-fest/source/is-equal.d.ts +31 -0
- package/node_modules/type-fest/source/is-float.d.ts +41 -0
- package/node_modules/type-fest/source/is-integer.d.ts +58 -0
- package/node_modules/type-fest/source/is-literal.d.ts +296 -0
- package/node_modules/type-fest/source/is-never.d.ts +42 -0
- package/node_modules/type-fest/source/is-null.d.ts +20 -0
- package/node_modules/type-fest/source/is-tuple.d.ts +89 -0
- package/node_modules/type-fest/source/is-unknown.d.ts +52 -0
- package/node_modules/type-fest/source/iterable-element.d.ts +64 -0
- package/node_modules/type-fest/source/join.d.ts +68 -0
- package/node_modules/type-fest/source/jsonifiable.d.ts +37 -0
- package/node_modules/type-fest/source/jsonify.d.ts +122 -0
- package/node_modules/type-fest/source/kebab-case.d.ts +44 -0
- package/node_modules/type-fest/source/kebab-cased-properties-deep.d.ts +63 -0
- package/node_modules/type-fest/source/kebab-cased-properties.d.ts +40 -0
- package/node_modules/type-fest/source/keys-of-union.d.ts +42 -0
- package/node_modules/type-fest/source/last-array-element.d.ts +38 -0
- package/node_modules/type-fest/source/less-than-or-equal.d.ts +22 -0
- package/node_modules/type-fest/source/less-than.d.ts +26 -0
- package/node_modules/type-fest/source/literal-to-primitive-deep.d.ts +36 -0
- package/node_modules/type-fest/source/literal-to-primitive.d.ts +36 -0
- package/node_modules/type-fest/source/literal-union.d.ts +37 -0
- package/node_modules/type-fest/source/merge-deep.d.ts +486 -0
- package/node_modules/type-fest/source/merge-exclusive.d.ts +41 -0
- package/node_modules/type-fest/source/merge.d.ts +48 -0
- package/node_modules/type-fest/source/multidimensional-array.d.ts +44 -0
- package/node_modules/type-fest/source/multidimensional-readonly-array.d.ts +48 -0
- package/node_modules/type-fest/source/non-empty-object.d.ts +35 -0
- package/node_modules/type-fest/source/non-empty-string.d.ts +28 -0
- package/node_modules/type-fest/source/non-empty-tuple.d.ts +21 -0
- package/node_modules/type-fest/source/numeric.d.ts +222 -0
- package/node_modules/type-fest/source/observable-like.d.ts +63 -0
- package/node_modules/type-fest/source/omit-deep.d.ts +167 -0
- package/node_modules/type-fest/source/omit-index-signature.d.ts +95 -0
- package/node_modules/type-fest/source/opaque.d.ts +1 -0
- package/node_modules/type-fest/source/optional-keys-of.d.ts +39 -0
- package/node_modules/type-fest/source/or.d.ts +25 -0
- package/node_modules/type-fest/source/override-properties.d.ts +36 -0
- package/node_modules/type-fest/source/package-json.d.ts +676 -0
- package/node_modules/type-fest/source/partial-deep.d.ts +151 -0
- package/node_modules/type-fest/source/partial-on-undefined-deep.d.ts +78 -0
- package/node_modules/type-fest/source/pascal-case.d.ts +42 -0
- package/node_modules/type-fest/source/pascal-cased-properties-deep.d.ts +62 -0
- package/node_modules/type-fest/source/pascal-cased-properties.d.ts +36 -0
- package/node_modules/type-fest/source/paths.d.ts +262 -0
- package/node_modules/type-fest/source/pick-deep.d.ts +149 -0
- package/node_modules/type-fest/source/pick-index-signature.d.ts +50 -0
- package/node_modules/type-fest/source/primitive.d.ts +13 -0
- package/node_modules/type-fest/source/promisable.d.ts +25 -0
- package/node_modules/type-fest/source/readonly-deep.d.ts +81 -0
- package/node_modules/type-fest/source/readonly-keys-of.d.ts +30 -0
- package/node_modules/type-fest/source/readonly-tuple.d.ts +41 -0
- package/node_modules/type-fest/source/replace.d.ts +85 -0
- package/node_modules/type-fest/source/require-all-or-none.d.ts +51 -0
- package/node_modules/type-fest/source/require-at-least-one.d.ts +47 -0
- package/node_modules/type-fest/source/require-exactly-one.d.ts +45 -0
- package/node_modules/type-fest/source/require-one-or-none.d.ts +46 -0
- package/node_modules/type-fest/source/required-deep.d.ts +78 -0
- package/node_modules/type-fest/source/required-keys-of.d.ts +30 -0
- package/node_modules/type-fest/source/schema.d.ts +114 -0
- package/node_modules/type-fest/source/screaming-snake-case.d.ts +28 -0
- package/node_modules/type-fest/source/set-field-type.d.ts +65 -0
- package/node_modules/type-fest/source/set-non-nullable-deep.d.ts +83 -0
- package/node_modules/type-fest/source/set-non-nullable.d.ts +39 -0
- package/node_modules/type-fest/source/set-optional.d.ts +38 -0
- package/node_modules/type-fest/source/set-parameter-type.d.ts +117 -0
- package/node_modules/type-fest/source/set-readonly.d.ts +39 -0
- package/node_modules/type-fest/source/set-required-deep.d.ts +68 -0
- package/node_modules/type-fest/source/set-required.d.ts +70 -0
- package/node_modules/type-fest/source/set-return-type.d.ts +29 -0
- package/node_modules/type-fest/source/shared-union-fields-deep.d.ts +178 -0
- package/node_modules/type-fest/source/shared-union-fields.d.ts +76 -0
- package/node_modules/type-fest/source/simplify-deep.d.ts +115 -0
- package/node_modules/type-fest/source/simplify.d.ts +58 -0
- package/node_modules/type-fest/source/single-key-object.d.ts +29 -0
- package/node_modules/type-fest/source/snake-case.d.ts +45 -0
- package/node_modules/type-fest/source/snake-cased-properties-deep.d.ts +63 -0
- package/node_modules/type-fest/source/snake-cased-properties.d.ts +40 -0
- package/node_modules/type-fest/source/split.d.ts +88 -0
- package/node_modules/type-fest/source/spread.d.ts +84 -0
- package/node_modules/type-fest/source/string-key-of.d.ts +25 -0
- package/node_modules/type-fest/source/string-repeat.d.ts +47 -0
- package/node_modules/type-fest/source/string-slice.d.ts +37 -0
- package/node_modules/type-fest/source/stringified.d.ts +23 -0
- package/node_modules/type-fest/source/structured-cloneable.d.ts +92 -0
- package/node_modules/type-fest/source/subtract.d.ts +83 -0
- package/node_modules/type-fest/source/sum.d.ts +78 -0
- package/node_modules/type-fest/source/tagged-union.d.ts +51 -0
- package/node_modules/type-fest/source/tagged.d.ts +256 -0
- package/node_modules/type-fest/source/trim.d.ts +27 -0
- package/node_modules/type-fest/source/tsconfig-json.d.ts +1294 -0
- package/node_modules/type-fest/source/tuple-to-object.d.ts +42 -0
- package/node_modules/type-fest/source/tuple-to-union.d.ts +51 -0
- package/node_modules/type-fest/source/typed-array.d.ts +17 -0
- package/node_modules/type-fest/source/undefined-on-partial-deep.d.ts +80 -0
- package/node_modules/type-fest/source/union-to-intersection.d.ts +61 -0
- package/node_modules/type-fest/source/union-to-tuple.d.ts +56 -0
- package/node_modules/type-fest/source/unknown-array.d.ts +25 -0
- package/node_modules/type-fest/source/unknown-map.d.ts +24 -0
- package/node_modules/type-fest/source/unknown-record.d.ts +31 -0
- package/node_modules/type-fest/source/unknown-set.d.ts +24 -0
- package/node_modules/type-fest/source/value-of.d.ts +42 -0
- package/node_modules/type-fest/source/words.d.ts +118 -0
- package/node_modules/type-fest/source/writable-deep.d.ts +83 -0
- package/node_modules/type-fest/source/writable-keys-of.d.ts +33 -0
- package/node_modules/type-fest/source/writable.d.ts +68 -0
- package/node_modules/widest-line/index.d.ts +12 -0
- package/node_modules/widest-line/index.js +11 -0
- package/node_modules/widest-line/license +9 -0
- package/node_modules/widest-line/package.json +60 -0
- package/node_modules/widest-line/readme.md +26 -0
- package/node_modules/wrap-ansi/index.d.ts +41 -0
- package/node_modules/wrap-ansi/index.js +222 -0
- package/node_modules/wrap-ansi/license +9 -0
- package/node_modules/wrap-ansi/package.json +69 -0
- package/node_modules/wrap-ansi/readme.md +75 -0
- package/package.json +78 -0
- package/scripts/postinstall.cjs +122 -0
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
const { info, debug } = require('./debug');
|
|
2
|
+
const utils = require('./utils');
|
|
3
|
+
|
|
4
|
+
class Cell {
|
|
5
|
+
/**
|
|
6
|
+
* A representation of a cell within the table.
|
|
7
|
+
* Implementations must have `init` and `draw` methods,
|
|
8
|
+
* as well as `colSpan`, `rowSpan`, `desiredHeight` and `desiredWidth` properties.
|
|
9
|
+
* @param options
|
|
10
|
+
* @constructor
|
|
11
|
+
*/
|
|
12
|
+
constructor(options) {
|
|
13
|
+
this.setOptions(options);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Each cell will have it's `x` and `y` values set by the `layout-manager` prior to
|
|
17
|
+
* `init` being called;
|
|
18
|
+
* @type {Number}
|
|
19
|
+
*/
|
|
20
|
+
this.x = null;
|
|
21
|
+
this.y = null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
setOptions(options) {
|
|
25
|
+
if (['boolean', 'number', 'bigint', 'string'].indexOf(typeof options) !== -1) {
|
|
26
|
+
options = { content: '' + options };
|
|
27
|
+
}
|
|
28
|
+
options = options || {};
|
|
29
|
+
this.options = options;
|
|
30
|
+
let content = options.content;
|
|
31
|
+
if (['boolean', 'number', 'bigint', 'string'].indexOf(typeof content) !== -1) {
|
|
32
|
+
this.content = String(content);
|
|
33
|
+
} else if (!content) {
|
|
34
|
+
this.content = this.options.href || '';
|
|
35
|
+
} else {
|
|
36
|
+
throw new Error('Content needs to be a primitive, got: ' + typeof content);
|
|
37
|
+
}
|
|
38
|
+
this.colSpan = options.colSpan || 1;
|
|
39
|
+
this.rowSpan = options.rowSpan || 1;
|
|
40
|
+
if (this.options.href) {
|
|
41
|
+
Object.defineProperty(this, 'href', {
|
|
42
|
+
get() {
|
|
43
|
+
return this.options.href;
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
mergeTableOptions(tableOptions, cells) {
|
|
50
|
+
this.cells = cells;
|
|
51
|
+
|
|
52
|
+
let optionsChars = this.options.chars || {};
|
|
53
|
+
let tableChars = tableOptions.chars;
|
|
54
|
+
let chars = (this.chars = {});
|
|
55
|
+
CHAR_NAMES.forEach(function (name) {
|
|
56
|
+
setOption(optionsChars, tableChars, name, chars);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
this.truncate = this.options.truncate || tableOptions.truncate;
|
|
60
|
+
|
|
61
|
+
let style = (this.options.style = this.options.style || {});
|
|
62
|
+
let tableStyle = tableOptions.style;
|
|
63
|
+
setOption(style, tableStyle, 'padding-left', this);
|
|
64
|
+
setOption(style, tableStyle, 'padding-right', this);
|
|
65
|
+
this.head = style.head || tableStyle.head;
|
|
66
|
+
this.border = style.border || tableStyle.border;
|
|
67
|
+
|
|
68
|
+
this.fixedWidth = tableOptions.colWidths[this.x];
|
|
69
|
+
this.lines = this.computeLines(tableOptions);
|
|
70
|
+
|
|
71
|
+
this.desiredWidth = utils.strlen(this.content) + this.paddingLeft + this.paddingRight;
|
|
72
|
+
this.desiredHeight = this.lines.length;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
computeLines(tableOptions) {
|
|
76
|
+
const tableWordWrap = tableOptions.wordWrap || tableOptions.textWrap;
|
|
77
|
+
const { wordWrap = tableWordWrap } = this.options;
|
|
78
|
+
if (this.fixedWidth && wordWrap) {
|
|
79
|
+
this.fixedWidth -= this.paddingLeft + this.paddingRight;
|
|
80
|
+
if (this.colSpan) {
|
|
81
|
+
let i = 1;
|
|
82
|
+
while (i < this.colSpan) {
|
|
83
|
+
this.fixedWidth += tableOptions.colWidths[this.x + i];
|
|
84
|
+
i++;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const { wrapOnWordBoundary: tableWrapOnWordBoundary = true } = tableOptions;
|
|
88
|
+
const { wrapOnWordBoundary = tableWrapOnWordBoundary } = this.options;
|
|
89
|
+
return this.wrapLines(utils.wordWrap(this.fixedWidth, this.content, wrapOnWordBoundary));
|
|
90
|
+
}
|
|
91
|
+
return this.wrapLines(this.content.split('\n'));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
wrapLines(computedLines) {
|
|
95
|
+
const lines = utils.colorizeLines(computedLines);
|
|
96
|
+
if (this.href) {
|
|
97
|
+
return lines.map((line) => utils.hyperlink(this.href, line));
|
|
98
|
+
}
|
|
99
|
+
return lines;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Initializes the Cells data structure.
|
|
104
|
+
*
|
|
105
|
+
* @param tableOptions - A fully populated set of tableOptions.
|
|
106
|
+
* In addition to the standard default values, tableOptions must have fully populated the
|
|
107
|
+
* `colWidths` and `rowWidths` arrays. Those arrays must have lengths equal to the number
|
|
108
|
+
* of columns or rows (respectively) in this table, and each array item must be a Number.
|
|
109
|
+
*
|
|
110
|
+
*/
|
|
111
|
+
init(tableOptions) {
|
|
112
|
+
let x = this.x;
|
|
113
|
+
let y = this.y;
|
|
114
|
+
this.widths = tableOptions.colWidths.slice(x, x + this.colSpan);
|
|
115
|
+
this.heights = tableOptions.rowHeights.slice(y, y + this.rowSpan);
|
|
116
|
+
this.width = this.widths.reduce(sumPlusOne, -1);
|
|
117
|
+
this.height = this.heights.reduce(sumPlusOne, -1);
|
|
118
|
+
|
|
119
|
+
this.hAlign = this.options.hAlign || tableOptions.colAligns[x];
|
|
120
|
+
this.vAlign = this.options.vAlign || tableOptions.rowAligns[y];
|
|
121
|
+
|
|
122
|
+
this.drawRight = x + this.colSpan == tableOptions.colWidths.length;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Draws the given line of the cell.
|
|
127
|
+
* This default implementation defers to methods `drawTop`, `drawBottom`, `drawLine` and `drawEmpty`.
|
|
128
|
+
* @param lineNum - can be `top`, `bottom` or a numerical line number.
|
|
129
|
+
* @param spanningCell - will be a number if being called from a RowSpanCell, and will represent how
|
|
130
|
+
* many rows below it's being called from. Otherwise it's undefined.
|
|
131
|
+
* @returns {String} The representation of this line.
|
|
132
|
+
*/
|
|
133
|
+
draw(lineNum, spanningCell) {
|
|
134
|
+
if (lineNum == 'top') return this.drawTop(this.drawRight);
|
|
135
|
+
if (lineNum == 'bottom') return this.drawBottom(this.drawRight);
|
|
136
|
+
let content = utils.truncate(this.content, 10, this.truncate);
|
|
137
|
+
if (!lineNum) {
|
|
138
|
+
info(`${this.y}-${this.x}: ${this.rowSpan - lineNum}x${this.colSpan} Cell ${content}`);
|
|
139
|
+
} else {
|
|
140
|
+
// debug(`${lineNum}-${this.x}: 1x${this.colSpan} RowSpanCell ${content}`);
|
|
141
|
+
}
|
|
142
|
+
let padLen = Math.max(this.height - this.lines.length, 0);
|
|
143
|
+
let padTop;
|
|
144
|
+
switch (this.vAlign) {
|
|
145
|
+
case 'center':
|
|
146
|
+
padTop = Math.ceil(padLen / 2);
|
|
147
|
+
break;
|
|
148
|
+
case 'bottom':
|
|
149
|
+
padTop = padLen;
|
|
150
|
+
break;
|
|
151
|
+
default:
|
|
152
|
+
padTop = 0;
|
|
153
|
+
}
|
|
154
|
+
if (lineNum < padTop || lineNum >= padTop + this.lines.length) {
|
|
155
|
+
return this.drawEmpty(this.drawRight, spanningCell);
|
|
156
|
+
}
|
|
157
|
+
let forceTruncation = this.lines.length > this.height && lineNum + 1 >= this.height;
|
|
158
|
+
return this.drawLine(lineNum - padTop, this.drawRight, forceTruncation, spanningCell);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Renders the top line of the cell.
|
|
163
|
+
* @param drawRight - true if this method should render the right edge of the cell.
|
|
164
|
+
* @returns {String}
|
|
165
|
+
*/
|
|
166
|
+
drawTop(drawRight) {
|
|
167
|
+
let content = [];
|
|
168
|
+
if (this.cells) {
|
|
169
|
+
//TODO: cells should always exist - some tests don't fill it in though
|
|
170
|
+
this.widths.forEach(function (width, index) {
|
|
171
|
+
content.push(this._topLeftChar(index));
|
|
172
|
+
content.push(utils.repeat(this.chars[this.y == 0 ? 'top' : 'mid'], width));
|
|
173
|
+
}, this);
|
|
174
|
+
} else {
|
|
175
|
+
content.push(this._topLeftChar(0));
|
|
176
|
+
content.push(utils.repeat(this.chars[this.y == 0 ? 'top' : 'mid'], this.width));
|
|
177
|
+
}
|
|
178
|
+
if (drawRight) {
|
|
179
|
+
content.push(this.chars[this.y == 0 ? 'topRight' : 'rightMid']);
|
|
180
|
+
}
|
|
181
|
+
return this.wrapWithStyleColors('border', content.join(''));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
_topLeftChar(offset) {
|
|
185
|
+
let x = this.x + offset;
|
|
186
|
+
let leftChar;
|
|
187
|
+
if (this.y == 0) {
|
|
188
|
+
leftChar = x == 0 ? 'topLeft' : offset == 0 ? 'topMid' : 'top';
|
|
189
|
+
} else {
|
|
190
|
+
if (x == 0) {
|
|
191
|
+
leftChar = 'leftMid';
|
|
192
|
+
} else {
|
|
193
|
+
leftChar = offset == 0 ? 'midMid' : 'bottomMid';
|
|
194
|
+
if (this.cells) {
|
|
195
|
+
//TODO: cells should always exist - some tests don't fill it in though
|
|
196
|
+
let spanAbove = this.cells[this.y - 1][x] instanceof Cell.ColSpanCell;
|
|
197
|
+
if (spanAbove) {
|
|
198
|
+
leftChar = offset == 0 ? 'topMid' : 'mid';
|
|
199
|
+
}
|
|
200
|
+
if (offset == 0) {
|
|
201
|
+
let i = 1;
|
|
202
|
+
while (this.cells[this.y][x - i] instanceof Cell.ColSpanCell) {
|
|
203
|
+
i++;
|
|
204
|
+
}
|
|
205
|
+
if (this.cells[this.y][x - i] instanceof Cell.RowSpanCell) {
|
|
206
|
+
leftChar = 'leftMid';
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return this.chars[leftChar];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
wrapWithStyleColors(styleProperty, content) {
|
|
216
|
+
if (this[styleProperty] && this[styleProperty].length) {
|
|
217
|
+
try {
|
|
218
|
+
let colors = require('@colors/colors/safe');
|
|
219
|
+
for (let i = this[styleProperty].length - 1; i >= 0; i--) {
|
|
220
|
+
colors = colors[this[styleProperty][i]];
|
|
221
|
+
}
|
|
222
|
+
return colors(content);
|
|
223
|
+
} catch (e) {
|
|
224
|
+
return content;
|
|
225
|
+
}
|
|
226
|
+
} else {
|
|
227
|
+
return content;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Renders a line of text.
|
|
233
|
+
* @param lineNum - Which line of text to render. This is not necessarily the line within the cell.
|
|
234
|
+
* There may be top-padding above the first line of text.
|
|
235
|
+
* @param drawRight - true if this method should render the right edge of the cell.
|
|
236
|
+
* @param forceTruncationSymbol - `true` if the rendered text should end with the truncation symbol even
|
|
237
|
+
* if the text fits. This is used when the cell is vertically truncated. If `false` the text should
|
|
238
|
+
* only include the truncation symbol if the text will not fit horizontally within the cell width.
|
|
239
|
+
* @param spanningCell - a number of if being called from a RowSpanCell. (how many rows below). otherwise undefined.
|
|
240
|
+
* @returns {String}
|
|
241
|
+
*/
|
|
242
|
+
drawLine(lineNum, drawRight, forceTruncationSymbol, spanningCell) {
|
|
243
|
+
let left = this.chars[this.x == 0 ? 'left' : 'middle'];
|
|
244
|
+
if (this.x && spanningCell && this.cells) {
|
|
245
|
+
let cellLeft = this.cells[this.y + spanningCell][this.x - 1];
|
|
246
|
+
while (cellLeft instanceof ColSpanCell) {
|
|
247
|
+
cellLeft = this.cells[cellLeft.y][cellLeft.x - 1];
|
|
248
|
+
}
|
|
249
|
+
if (!(cellLeft instanceof RowSpanCell)) {
|
|
250
|
+
left = this.chars['rightMid'];
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
let leftPadding = utils.repeat(' ', this.paddingLeft);
|
|
254
|
+
let right = drawRight ? this.chars['right'] : '';
|
|
255
|
+
let rightPadding = utils.repeat(' ', this.paddingRight);
|
|
256
|
+
let line = this.lines[lineNum];
|
|
257
|
+
let len = this.width - (this.paddingLeft + this.paddingRight);
|
|
258
|
+
if (forceTruncationSymbol) line += this.truncate || '…';
|
|
259
|
+
let content = utils.truncate(line, len, this.truncate);
|
|
260
|
+
content = utils.pad(content, len, ' ', this.hAlign);
|
|
261
|
+
content = leftPadding + content + rightPadding;
|
|
262
|
+
return this.stylizeLine(left, content, right);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
stylizeLine(left, content, right) {
|
|
266
|
+
left = this.wrapWithStyleColors('border', left);
|
|
267
|
+
right = this.wrapWithStyleColors('border', right);
|
|
268
|
+
if (this.y === 0) {
|
|
269
|
+
content = this.wrapWithStyleColors('head', content);
|
|
270
|
+
}
|
|
271
|
+
return left + content + right;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Renders the bottom line of the cell.
|
|
276
|
+
* @param drawRight - true if this method should render the right edge of the cell.
|
|
277
|
+
* @returns {String}
|
|
278
|
+
*/
|
|
279
|
+
drawBottom(drawRight) {
|
|
280
|
+
let left = this.chars[this.x == 0 ? 'bottomLeft' : 'bottomMid'];
|
|
281
|
+
let content = utils.repeat(this.chars.bottom, this.width);
|
|
282
|
+
let right = drawRight ? this.chars['bottomRight'] : '';
|
|
283
|
+
return this.wrapWithStyleColors('border', left + content + right);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Renders a blank line of text within the cell. Used for top and/or bottom padding.
|
|
288
|
+
* @param drawRight - true if this method should render the right edge of the cell.
|
|
289
|
+
* @param spanningCell - a number of if being called from a RowSpanCell. (how many rows below). otherwise undefined.
|
|
290
|
+
* @returns {String}
|
|
291
|
+
*/
|
|
292
|
+
drawEmpty(drawRight, spanningCell) {
|
|
293
|
+
let left = this.chars[this.x == 0 ? 'left' : 'middle'];
|
|
294
|
+
if (this.x && spanningCell && this.cells) {
|
|
295
|
+
let cellLeft = this.cells[this.y + spanningCell][this.x - 1];
|
|
296
|
+
while (cellLeft instanceof ColSpanCell) {
|
|
297
|
+
cellLeft = this.cells[cellLeft.y][cellLeft.x - 1];
|
|
298
|
+
}
|
|
299
|
+
if (!(cellLeft instanceof RowSpanCell)) {
|
|
300
|
+
left = this.chars['rightMid'];
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
let right = drawRight ? this.chars['right'] : '';
|
|
304
|
+
let content = utils.repeat(' ', this.width);
|
|
305
|
+
return this.stylizeLine(left, content, right);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
class ColSpanCell {
|
|
310
|
+
/**
|
|
311
|
+
* A Cell that doesn't do anything. It just draws empty lines.
|
|
312
|
+
* Used as a placeholder in column spanning.
|
|
313
|
+
* @constructor
|
|
314
|
+
*/
|
|
315
|
+
constructor() {}
|
|
316
|
+
|
|
317
|
+
draw(lineNum) {
|
|
318
|
+
if (typeof lineNum === 'number') {
|
|
319
|
+
debug(`${this.y}-${this.x}: 1x1 ColSpanCell`);
|
|
320
|
+
}
|
|
321
|
+
return '';
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
init() {}
|
|
325
|
+
|
|
326
|
+
mergeTableOptions() {}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
class RowSpanCell {
|
|
330
|
+
/**
|
|
331
|
+
* A placeholder Cell for a Cell that spans multiple rows.
|
|
332
|
+
* It delegates rendering to the original cell, but adds the appropriate offset.
|
|
333
|
+
* @param originalCell
|
|
334
|
+
* @constructor
|
|
335
|
+
*/
|
|
336
|
+
constructor(originalCell) {
|
|
337
|
+
this.originalCell = originalCell;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
init(tableOptions) {
|
|
341
|
+
let y = this.y;
|
|
342
|
+
let originalY = this.originalCell.y;
|
|
343
|
+
this.cellOffset = y - originalY;
|
|
344
|
+
this.offset = findDimension(tableOptions.rowHeights, originalY, this.cellOffset);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
draw(lineNum) {
|
|
348
|
+
if (lineNum == 'top') {
|
|
349
|
+
return this.originalCell.draw(this.offset, this.cellOffset);
|
|
350
|
+
}
|
|
351
|
+
if (lineNum == 'bottom') {
|
|
352
|
+
return this.originalCell.draw('bottom');
|
|
353
|
+
}
|
|
354
|
+
debug(`${this.y}-${this.x}: 1x${this.colSpan} RowSpanCell for ${this.originalCell.content}`);
|
|
355
|
+
return this.originalCell.draw(this.offset + 1 + lineNum);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
mergeTableOptions() {}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function firstDefined(...args) {
|
|
362
|
+
return args.filter((v) => v !== undefined && v !== null).shift();
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// HELPER FUNCTIONS
|
|
366
|
+
function setOption(objA, objB, nameB, targetObj) {
|
|
367
|
+
let nameA = nameB.split('-');
|
|
368
|
+
if (nameA.length > 1) {
|
|
369
|
+
nameA[1] = nameA[1].charAt(0).toUpperCase() + nameA[1].substr(1);
|
|
370
|
+
nameA = nameA.join('');
|
|
371
|
+
targetObj[nameA] = firstDefined(objA[nameA], objA[nameB], objB[nameA], objB[nameB]);
|
|
372
|
+
} else {
|
|
373
|
+
targetObj[nameB] = firstDefined(objA[nameB], objB[nameB]);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
function findDimension(dimensionTable, startingIndex, span) {
|
|
378
|
+
let ret = dimensionTable[startingIndex];
|
|
379
|
+
for (let i = 1; i < span; i++) {
|
|
380
|
+
ret += 1 + dimensionTable[startingIndex + i];
|
|
381
|
+
}
|
|
382
|
+
return ret;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
function sumPlusOne(a, b) {
|
|
386
|
+
return a + b + 1;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
let CHAR_NAMES = [
|
|
390
|
+
'top',
|
|
391
|
+
'top-mid',
|
|
392
|
+
'top-left',
|
|
393
|
+
'top-right',
|
|
394
|
+
'bottom',
|
|
395
|
+
'bottom-mid',
|
|
396
|
+
'bottom-left',
|
|
397
|
+
'bottom-right',
|
|
398
|
+
'left',
|
|
399
|
+
'left-mid',
|
|
400
|
+
'mid',
|
|
401
|
+
'mid-mid',
|
|
402
|
+
'right',
|
|
403
|
+
'right-mid',
|
|
404
|
+
'middle',
|
|
405
|
+
];
|
|
406
|
+
|
|
407
|
+
module.exports = Cell;
|
|
408
|
+
module.exports.ColSpanCell = ColSpanCell;
|
|
409
|
+
module.exports.RowSpanCell = RowSpanCell;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
let messages = [];
|
|
2
|
+
let level = 0;
|
|
3
|
+
|
|
4
|
+
const debug = (msg, min) => {
|
|
5
|
+
if (level >= min) {
|
|
6
|
+
messages.push(msg);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
debug.WARN = 1;
|
|
11
|
+
debug.INFO = 2;
|
|
12
|
+
debug.DEBUG = 3;
|
|
13
|
+
|
|
14
|
+
debug.reset = () => {
|
|
15
|
+
messages = [];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
debug.setDebugLevel = (v) => {
|
|
19
|
+
level = v;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
debug.warn = (msg) => debug(msg, debug.WARN);
|
|
23
|
+
debug.info = (msg) => debug(msg, debug.INFO);
|
|
24
|
+
debug.debug = (msg) => debug(msg, debug.DEBUG);
|
|
25
|
+
|
|
26
|
+
debug.debugMessages = () => messages;
|
|
27
|
+
|
|
28
|
+
module.exports = debug;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
const { warn, debug } = require('./debug');
|
|
2
|
+
const Cell = require('./cell');
|
|
3
|
+
const { ColSpanCell, RowSpanCell } = Cell;
|
|
4
|
+
|
|
5
|
+
(function () {
|
|
6
|
+
function next(alloc, col) {
|
|
7
|
+
if (alloc[col] > 0) {
|
|
8
|
+
return next(alloc, col + 1);
|
|
9
|
+
}
|
|
10
|
+
return col;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function layoutTable(table) {
|
|
14
|
+
let alloc = {};
|
|
15
|
+
table.forEach(function (row, rowIndex) {
|
|
16
|
+
let col = 0;
|
|
17
|
+
row.forEach(function (cell) {
|
|
18
|
+
cell.y = rowIndex;
|
|
19
|
+
// Avoid erroneous call to next() on first row
|
|
20
|
+
cell.x = rowIndex ? next(alloc, col) : col;
|
|
21
|
+
const rowSpan = cell.rowSpan || 1;
|
|
22
|
+
const colSpan = cell.colSpan || 1;
|
|
23
|
+
if (rowSpan > 1) {
|
|
24
|
+
for (let cs = 0; cs < colSpan; cs++) {
|
|
25
|
+
alloc[cell.x + cs] = rowSpan;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
col = cell.x + colSpan;
|
|
29
|
+
});
|
|
30
|
+
Object.keys(alloc).forEach((idx) => {
|
|
31
|
+
alloc[idx]--;
|
|
32
|
+
if (alloc[idx] < 1) delete alloc[idx];
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function maxWidth(table) {
|
|
38
|
+
let mw = 0;
|
|
39
|
+
table.forEach(function (row) {
|
|
40
|
+
row.forEach(function (cell) {
|
|
41
|
+
mw = Math.max(mw, cell.x + (cell.colSpan || 1));
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
return mw;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function maxHeight(table) {
|
|
48
|
+
return table.length;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function cellsConflict(cell1, cell2) {
|
|
52
|
+
let yMin1 = cell1.y;
|
|
53
|
+
let yMax1 = cell1.y - 1 + (cell1.rowSpan || 1);
|
|
54
|
+
let yMin2 = cell2.y;
|
|
55
|
+
let yMax2 = cell2.y - 1 + (cell2.rowSpan || 1);
|
|
56
|
+
let yConflict = !(yMin1 > yMax2 || yMin2 > yMax1);
|
|
57
|
+
|
|
58
|
+
let xMin1 = cell1.x;
|
|
59
|
+
let xMax1 = cell1.x - 1 + (cell1.colSpan || 1);
|
|
60
|
+
let xMin2 = cell2.x;
|
|
61
|
+
let xMax2 = cell2.x - 1 + (cell2.colSpan || 1);
|
|
62
|
+
let xConflict = !(xMin1 > xMax2 || xMin2 > xMax1);
|
|
63
|
+
|
|
64
|
+
return yConflict && xConflict;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function conflictExists(rows, x, y) {
|
|
68
|
+
let i_max = Math.min(rows.length - 1, y);
|
|
69
|
+
let cell = { x: x, y: y };
|
|
70
|
+
for (let i = 0; i <= i_max; i++) {
|
|
71
|
+
let row = rows[i];
|
|
72
|
+
for (let j = 0; j < row.length; j++) {
|
|
73
|
+
if (cellsConflict(cell, row[j])) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function allBlank(rows, y, xMin, xMax) {
|
|
82
|
+
for (let x = xMin; x < xMax; x++) {
|
|
83
|
+
if (conflictExists(rows, x, y)) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function addRowSpanCells(table) {
|
|
91
|
+
table.forEach(function (row, rowIndex) {
|
|
92
|
+
row.forEach(function (cell) {
|
|
93
|
+
for (let i = 1; i < cell.rowSpan; i++) {
|
|
94
|
+
let rowSpanCell = new RowSpanCell(cell);
|
|
95
|
+
rowSpanCell.x = cell.x;
|
|
96
|
+
rowSpanCell.y = cell.y + i;
|
|
97
|
+
rowSpanCell.colSpan = cell.colSpan;
|
|
98
|
+
insertCell(rowSpanCell, table[rowIndex + i]);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function addColSpanCells(cellRows) {
|
|
105
|
+
for (let rowIndex = cellRows.length - 1; rowIndex >= 0; rowIndex--) {
|
|
106
|
+
let cellColumns = cellRows[rowIndex];
|
|
107
|
+
for (let columnIndex = 0; columnIndex < cellColumns.length; columnIndex++) {
|
|
108
|
+
let cell = cellColumns[columnIndex];
|
|
109
|
+
for (let k = 1; k < cell.colSpan; k++) {
|
|
110
|
+
let colSpanCell = new ColSpanCell();
|
|
111
|
+
colSpanCell.x = cell.x + k;
|
|
112
|
+
colSpanCell.y = cell.y;
|
|
113
|
+
cellColumns.splice(columnIndex + 1, 0, colSpanCell);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function insertCell(cell, row) {
|
|
120
|
+
let x = 0;
|
|
121
|
+
while (x < row.length && row[x].x < cell.x) {
|
|
122
|
+
x++;
|
|
123
|
+
}
|
|
124
|
+
row.splice(x, 0, cell);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function fillInTable(table) {
|
|
128
|
+
let h_max = maxHeight(table);
|
|
129
|
+
let w_max = maxWidth(table);
|
|
130
|
+
debug(`Max rows: ${h_max}; Max cols: ${w_max}`);
|
|
131
|
+
for (let y = 0; y < h_max; y++) {
|
|
132
|
+
for (let x = 0; x < w_max; x++) {
|
|
133
|
+
if (!conflictExists(table, x, y)) {
|
|
134
|
+
let opts = { x: x, y: y, colSpan: 1, rowSpan: 1 };
|
|
135
|
+
x++;
|
|
136
|
+
while (x < w_max && !conflictExists(table, x, y)) {
|
|
137
|
+
opts.colSpan++;
|
|
138
|
+
x++;
|
|
139
|
+
}
|
|
140
|
+
let y2 = y + 1;
|
|
141
|
+
while (y2 < h_max && allBlank(table, y2, opts.x, opts.x + opts.colSpan)) {
|
|
142
|
+
opts.rowSpan++;
|
|
143
|
+
y2++;
|
|
144
|
+
}
|
|
145
|
+
let cell = new Cell(opts);
|
|
146
|
+
cell.x = opts.x;
|
|
147
|
+
cell.y = opts.y;
|
|
148
|
+
warn(`Missing cell at ${cell.y}-${cell.x}.`);
|
|
149
|
+
insertCell(cell, table[y]);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function generateCells(rows) {
|
|
156
|
+
return rows.map(function (row) {
|
|
157
|
+
if (!Array.isArray(row)) {
|
|
158
|
+
let key = Object.keys(row)[0];
|
|
159
|
+
row = row[key];
|
|
160
|
+
if (Array.isArray(row)) {
|
|
161
|
+
row = row.slice();
|
|
162
|
+
row.unshift(key);
|
|
163
|
+
} else {
|
|
164
|
+
row = [key, row];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return row.map(function (cell) {
|
|
168
|
+
return new Cell(cell);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function makeTableLayout(rows) {
|
|
174
|
+
let cellRows = generateCells(rows);
|
|
175
|
+
layoutTable(cellRows);
|
|
176
|
+
fillInTable(cellRows);
|
|
177
|
+
addRowSpanCells(cellRows);
|
|
178
|
+
addColSpanCells(cellRows);
|
|
179
|
+
return cellRows;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
module.exports = {
|
|
183
|
+
makeTableLayout: makeTableLayout,
|
|
184
|
+
layoutTable: layoutTable,
|
|
185
|
+
addRowSpanCells: addRowSpanCells,
|
|
186
|
+
maxWidth: maxWidth,
|
|
187
|
+
fillInTable: fillInTable,
|
|
188
|
+
computeWidths: makeComputeWidths('colSpan', 'desiredWidth', 'x', 1),
|
|
189
|
+
computeHeights: makeComputeWidths('rowSpan', 'desiredHeight', 'y', 1),
|
|
190
|
+
};
|
|
191
|
+
})();
|
|
192
|
+
|
|
193
|
+
function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) {
|
|
194
|
+
return function (vals, table) {
|
|
195
|
+
let result = [];
|
|
196
|
+
let spanners = [];
|
|
197
|
+
let auto = {};
|
|
198
|
+
table.forEach(function (row) {
|
|
199
|
+
row.forEach(function (cell) {
|
|
200
|
+
if ((cell[colSpan] || 1) > 1) {
|
|
201
|
+
spanners.push(cell);
|
|
202
|
+
} else {
|
|
203
|
+
result[cell[x]] = Math.max(result[cell[x]] || 0, cell[desiredWidth] || 0, forcedMin);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
vals.forEach(function (val, index) {
|
|
209
|
+
if (typeof val === 'number') {
|
|
210
|
+
result[index] = val;
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
//spanners.forEach(function(cell){
|
|
215
|
+
for (let k = spanners.length - 1; k >= 0; k--) {
|
|
216
|
+
let cell = spanners[k];
|
|
217
|
+
let span = cell[colSpan];
|
|
218
|
+
let col = cell[x];
|
|
219
|
+
let existingWidth = result[col];
|
|
220
|
+
let editableCols = typeof vals[col] === 'number' ? 0 : 1;
|
|
221
|
+
if (typeof existingWidth === 'number') {
|
|
222
|
+
for (let i = 1; i < span; i++) {
|
|
223
|
+
existingWidth += 1 + result[col + i];
|
|
224
|
+
if (typeof vals[col + i] !== 'number') {
|
|
225
|
+
editableCols++;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
} else {
|
|
229
|
+
existingWidth = desiredWidth === 'desiredWidth' ? cell.desiredWidth - 1 : 1;
|
|
230
|
+
if (!auto[col] || auto[col] < existingWidth) {
|
|
231
|
+
auto[col] = existingWidth;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (cell[desiredWidth] > existingWidth) {
|
|
236
|
+
let i = 0;
|
|
237
|
+
while (editableCols > 0 && cell[desiredWidth] > existingWidth) {
|
|
238
|
+
if (typeof vals[col + i] !== 'number') {
|
|
239
|
+
let dif = Math.round((cell[desiredWidth] - existingWidth) / editableCols);
|
|
240
|
+
existingWidth += dif;
|
|
241
|
+
result[col + i] += dif;
|
|
242
|
+
editableCols--;
|
|
243
|
+
}
|
|
244
|
+
i++;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
Object.assign(vals, result, auto);
|
|
250
|
+
for (let j = 0; j < vals.length; j++) {
|
|
251
|
+
vals[j] = Math.max(forcedMin, vals[j] || 0);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
}
|