mockaton 13.7.0 → 13.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -8
- package/package.json +5 -3
- package/src/client/ApiConstants.js +0 -2
- package/src/client/Filename.js +2 -2
- package/src/client/app-payload-viewer.js +4 -2
- package/src/client/dir/groupByFolder.js +16 -14
- package/src/server/MockBroker.js +7 -2
- package/src/server/MockDispatcher.js +3 -2
- package/src/server/Mockaton.js +10 -12
- package/src/server/Mockaton.test.js +42 -0
- package/src/server/cli.js +9 -8
- package/src/server/importResolver.js +35 -0
- package/src/server/utils/logger.js +2 -4
- package/src/server/utils/openInBrowser.js +1 -1
- package/vite-plugin/README.md +29 -0
- package/vite-plugin/index.ts +21 -0
- package/vite-plugin/node_modules/.package-lock.json +356 -0
- package/vite-plugin/node_modules/@oxc-project/types/LICENSE +22 -0
- package/vite-plugin/node_modules/@oxc-project/types/README.md +3 -0
- package/vite-plugin/node_modules/@oxc-project/types/package.json +26 -0
- package/vite-plugin/node_modules/@oxc-project/types/types.d.ts +1912 -0
- package/vite-plugin/node_modules/@rolldown/binding-darwin-arm64/README.md +3 -0
- package/vite-plugin/node_modules/@rolldown/binding-darwin-arm64/package.json +37 -0
- package/vite-plugin/node_modules/@rolldown/binding-darwin-arm64/rolldown-binding.darwin-arm64.node +0 -0
- package/vite-plugin/node_modules/@rolldown/pluginutils/LICENSE +25 -0
- package/vite-plugin/node_modules/@rolldown/pluginutils/README.md +83 -0
- package/vite-plugin/node_modules/@rolldown/pluginutils/dist/filter/composable-filters.d.ts +90 -0
- package/vite-plugin/node_modules/@rolldown/pluginutils/dist/filter/composable-filters.js +256 -0
- package/vite-plugin/node_modules/@rolldown/pluginutils/dist/filter/filter-vite-plugins.d.ts +28 -0
- package/vite-plugin/node_modules/@rolldown/pluginutils/dist/filter/filter-vite-plugins.js +75 -0
- package/vite-plugin/node_modules/@rolldown/pluginutils/dist/filter/index.d.ts +3 -0
- package/vite-plugin/node_modules/@rolldown/pluginutils/dist/filter/index.js +3 -0
- package/vite-plugin/node_modules/@rolldown/pluginutils/dist/filter/simple-filters.d.ts +71 -0
- package/vite-plugin/node_modules/@rolldown/pluginutils/dist/filter/simple-filters.js +70 -0
- package/vite-plugin/node_modules/@rolldown/pluginutils/dist/index.d.ts +1 -0
- package/vite-plugin/node_modules/@rolldown/pluginutils/dist/index.js +1 -0
- package/vite-plugin/node_modules/@rolldown/pluginutils/dist/utils.d.ts +2 -0
- package/vite-plugin/node_modules/@rolldown/pluginutils/dist/utils.js +17 -0
- package/vite-plugin/node_modules/@rolldown/pluginutils/package.json +37 -0
- package/vite-plugin/node_modules/detect-libc/LICENSE +201 -0
- package/vite-plugin/node_modules/detect-libc/README.md +163 -0
- package/vite-plugin/node_modules/detect-libc/index.d.ts +14 -0
- package/vite-plugin/node_modules/detect-libc/lib/detect-libc.js +313 -0
- package/vite-plugin/node_modules/detect-libc/lib/elf.js +39 -0
- package/vite-plugin/node_modules/detect-libc/lib/filesystem.js +51 -0
- package/vite-plugin/node_modules/detect-libc/lib/process.js +24 -0
- package/vite-plugin/node_modules/detect-libc/package.json +44 -0
- package/vite-plugin/node_modules/fdir/LICENSE +7 -0
- package/vite-plugin/node_modules/fdir/README.md +91 -0
- package/vite-plugin/node_modules/fdir/dist/index.cjs +588 -0
- package/vite-plugin/node_modules/fdir/dist/index.d.cts +155 -0
- package/vite-plugin/node_modules/fdir/dist/index.d.mts +155 -0
- package/vite-plugin/node_modules/fdir/dist/index.mjs +570 -0
- package/vite-plugin/node_modules/fdir/package.json +103 -0
- package/vite-plugin/node_modules/fsevents/LICENSE +22 -0
- package/vite-plugin/node_modules/fsevents/README.md +89 -0
- package/vite-plugin/node_modules/fsevents/fsevents.d.ts +46 -0
- package/vite-plugin/node_modules/fsevents/fsevents.js +83 -0
- package/vite-plugin/node_modules/fsevents/fsevents.node +0 -0
- package/vite-plugin/node_modules/fsevents/package.json +62 -0
- package/vite-plugin/node_modules/lightningcss/LICENSE +373 -0
- package/vite-plugin/node_modules/lightningcss/README.md +105 -0
- package/vite-plugin/node_modules/lightningcss/node/ast.d.ts +9892 -0
- package/vite-plugin/node_modules/lightningcss/node/ast.js.flow +10539 -0
- package/vite-plugin/node_modules/lightningcss/node/browserslistToTargets.js +48 -0
- package/vite-plugin/node_modules/lightningcss/node/composeVisitors.js +450 -0
- package/vite-plugin/node_modules/lightningcss/node/flags.js +28 -0
- package/vite-plugin/node_modules/lightningcss/node/index.d.ts +494 -0
- package/vite-plugin/node_modules/lightningcss/node/index.js +59 -0
- package/vite-plugin/node_modules/lightningcss/node/index.js.flow +843 -0
- package/vite-plugin/node_modules/lightningcss/node/index.mjs +4 -0
- package/vite-plugin/node_modules/lightningcss/node/targets.d.ts +40 -0
- package/vite-plugin/node_modules/lightningcss/node/targets.js.flow +39 -0
- package/vite-plugin/node_modules/lightningcss/package.json +110 -0
- package/vite-plugin/node_modules/lightningcss-darwin-arm64/LICENSE +373 -0
- package/vite-plugin/node_modules/lightningcss-darwin-arm64/README.md +1 -0
- package/vite-plugin/node_modules/lightningcss-darwin-arm64/lightningcss.darwin-arm64.node +0 -0
- package/vite-plugin/node_modules/lightningcss-darwin-arm64/package.json +34 -0
- package/vite-plugin/node_modules/nanoid/LICENSE +20 -0
- package/vite-plugin/node_modules/nanoid/README.md +39 -0
- package/vite-plugin/node_modules/nanoid/async/index.browser.cjs +69 -0
- package/vite-plugin/node_modules/nanoid/async/index.browser.js +34 -0
- package/vite-plugin/node_modules/nanoid/async/index.cjs +71 -0
- package/vite-plugin/node_modules/nanoid/async/index.d.ts +56 -0
- package/vite-plugin/node_modules/nanoid/async/index.js +35 -0
- package/vite-plugin/node_modules/nanoid/async/index.native.js +26 -0
- package/vite-plugin/node_modules/nanoid/async/package.json +12 -0
- package/vite-plugin/node_modules/nanoid/bin/nanoid.cjs +55 -0
- package/vite-plugin/node_modules/nanoid/index.browser.cjs +72 -0
- package/vite-plugin/node_modules/nanoid/index.browser.js +34 -0
- package/vite-plugin/node_modules/nanoid/index.cjs +85 -0
- package/vite-plugin/node_modules/nanoid/index.d.cts +91 -0
- package/vite-plugin/node_modules/nanoid/index.d.ts +91 -0
- package/vite-plugin/node_modules/nanoid/index.js +45 -0
- package/vite-plugin/node_modules/nanoid/nanoid.js +1 -0
- package/vite-plugin/node_modules/nanoid/non-secure/index.cjs +34 -0
- package/vite-plugin/node_modules/nanoid/non-secure/index.d.ts +33 -0
- package/vite-plugin/node_modules/nanoid/non-secure/index.js +21 -0
- package/vite-plugin/node_modules/nanoid/non-secure/package.json +6 -0
- package/vite-plugin/node_modules/nanoid/package.json +89 -0
- package/vite-plugin/node_modules/nanoid/url-alphabet/index.cjs +7 -0
- package/vite-plugin/node_modules/nanoid/url-alphabet/index.js +3 -0
- package/vite-plugin/node_modules/nanoid/url-alphabet/package.json +6 -0
- package/vite-plugin/node_modules/picocolors/LICENSE +15 -0
- package/vite-plugin/node_modules/picocolors/README.md +21 -0
- package/vite-plugin/node_modules/picocolors/package.json +25 -0
- package/vite-plugin/node_modules/picocolors/picocolors.browser.js +4 -0
- package/vite-plugin/node_modules/picocolors/picocolors.d.ts +5 -0
- package/vite-plugin/node_modules/picocolors/picocolors.js +75 -0
- package/vite-plugin/node_modules/picocolors/types.d.ts +51 -0
- package/vite-plugin/node_modules/picomatch/LICENSE +21 -0
- package/vite-plugin/node_modules/picomatch/README.md +749 -0
- package/vite-plugin/node_modules/picomatch/index.js +17 -0
- package/vite-plugin/node_modules/picomatch/lib/constants.js +184 -0
- package/vite-plugin/node_modules/picomatch/lib/parse.js +1386 -0
- package/vite-plugin/node_modules/picomatch/lib/picomatch.js +349 -0
- package/vite-plugin/node_modules/picomatch/lib/scan.js +391 -0
- package/vite-plugin/node_modules/picomatch/lib/utils.js +72 -0
- package/vite-plugin/node_modules/picomatch/package.json +82 -0
- package/vite-plugin/node_modules/picomatch/posix.js +3 -0
- package/vite-plugin/node_modules/postcss/LICENSE +20 -0
- package/vite-plugin/node_modules/postcss/README.md +28 -0
- package/vite-plugin/node_modules/postcss/lib/at-rule.d.ts +139 -0
- package/vite-plugin/node_modules/postcss/lib/at-rule.js +25 -0
- package/vite-plugin/node_modules/postcss/lib/comment.d.ts +67 -0
- package/vite-plugin/node_modules/postcss/lib/comment.js +13 -0
- package/vite-plugin/node_modules/postcss/lib/container.d.ts +478 -0
- package/vite-plugin/node_modules/postcss/lib/container.js +447 -0
- package/vite-plugin/node_modules/postcss/lib/css-syntax-error.d.ts +247 -0
- package/vite-plugin/node_modules/postcss/lib/css-syntax-error.js +133 -0
- package/vite-plugin/node_modules/postcss/lib/declaration.d.ts +150 -0
- package/vite-plugin/node_modules/postcss/lib/declaration.js +24 -0
- package/vite-plugin/node_modules/postcss/lib/document.d.ts +68 -0
- package/vite-plugin/node_modules/postcss/lib/document.js +33 -0
- package/vite-plugin/node_modules/postcss/lib/fromJSON.d.ts +9 -0
- package/vite-plugin/node_modules/postcss/lib/fromJSON.js +54 -0
- package/vite-plugin/node_modules/postcss/lib/input.d.ts +226 -0
- package/vite-plugin/node_modules/postcss/lib/input.js +273 -0
- package/vite-plugin/node_modules/postcss/lib/lazy-result.d.ts +189 -0
- package/vite-plugin/node_modules/postcss/lib/lazy-result.js +550 -0
- package/vite-plugin/node_modules/postcss/lib/list.d.ts +60 -0
- package/vite-plugin/node_modules/postcss/lib/list.js +58 -0
- package/vite-plugin/node_modules/postcss/lib/map-generator.js +376 -0
- package/vite-plugin/node_modules/postcss/lib/no-work-result.d.ts +45 -0
- package/vite-plugin/node_modules/postcss/lib/no-work-result.js +137 -0
- package/vite-plugin/node_modules/postcss/lib/node.d.ts +555 -0
- package/vite-plugin/node_modules/postcss/lib/node.js +449 -0
- package/vite-plugin/node_modules/postcss/lib/parse.d.ts +9 -0
- package/vite-plugin/node_modules/postcss/lib/parse.js +42 -0
- package/vite-plugin/node_modules/postcss/lib/parser.js +611 -0
- package/vite-plugin/node_modules/postcss/lib/postcss.d.mts +66 -0
- package/vite-plugin/node_modules/postcss/lib/postcss.d.ts +456 -0
- package/vite-plugin/node_modules/postcss/lib/postcss.js +101 -0
- package/vite-plugin/node_modules/postcss/lib/postcss.mjs +30 -0
- package/vite-plugin/node_modules/postcss/lib/previous-map.d.ts +80 -0
- package/vite-plugin/node_modules/postcss/lib/previous-map.js +145 -0
- package/vite-plugin/node_modules/postcss/lib/processor.d.ts +114 -0
- package/vite-plugin/node_modules/postcss/lib/processor.js +67 -0
- package/vite-plugin/node_modules/postcss/lib/result.d.ts +204 -0
- package/vite-plugin/node_modules/postcss/lib/result.js +42 -0
- package/vite-plugin/node_modules/postcss/lib/root.d.ts +86 -0
- package/vite-plugin/node_modules/postcss/lib/root.js +61 -0
- package/vite-plugin/node_modules/postcss/lib/rule.d.ts +126 -0
- package/vite-plugin/node_modules/postcss/lib/rule.js +27 -0
- package/vite-plugin/node_modules/postcss/lib/stringifier.d.ts +45 -0
- package/vite-plugin/node_modules/postcss/lib/stringifier.js +370 -0
- package/vite-plugin/node_modules/postcss/lib/stringify.d.ts +9 -0
- package/vite-plugin/node_modules/postcss/lib/stringify.js +11 -0
- package/vite-plugin/node_modules/postcss/lib/symbols.js +5 -0
- package/vite-plugin/node_modules/postcss/lib/terminal-highlight.js +70 -0
- package/vite-plugin/node_modules/postcss/lib/tokenize.js +266 -0
- package/vite-plugin/node_modules/postcss/lib/warn-once.js +13 -0
- package/vite-plugin/node_modules/postcss/lib/warning.d.ts +146 -0
- package/vite-plugin/node_modules/postcss/lib/warning.js +37 -0
- package/vite-plugin/node_modules/postcss/package.json +88 -0
- package/vite-plugin/node_modules/rolldown/LICENSE +25 -0
- package/vite-plugin/node_modules/rolldown/README.md +11 -0
- package/vite-plugin/node_modules/rolldown/bin/cli.mjs +2 -0
- package/vite-plugin/node_modules/rolldown/dist/cli.d.mts +1 -0
- package/vite-plugin/node_modules/rolldown/dist/cli.mjs +1191 -0
- package/vite-plugin/node_modules/rolldown/dist/config.d.mts +14 -0
- package/vite-plugin/node_modules/rolldown/dist/config.mjs +4 -0
- package/vite-plugin/node_modules/rolldown/dist/experimental-index.d.mts +253 -0
- package/vite-plugin/node_modules/rolldown/dist/experimental-index.mjs +320 -0
- package/vite-plugin/node_modules/rolldown/dist/experimental-runtime-types.d.ts +98 -0
- package/vite-plugin/node_modules/rolldown/dist/filter-index.d.mts +196 -0
- package/vite-plugin/node_modules/rolldown/dist/filter-index.mjs +386 -0
- package/vite-plugin/node_modules/rolldown/dist/get-log-filter.d.mts +3 -0
- package/vite-plugin/node_modules/rolldown/dist/get-log-filter.mjs +68 -0
- package/vite-plugin/node_modules/rolldown/dist/index.d.mts +4 -0
- package/vite-plugin/node_modules/rolldown/dist/index.mjs +50 -0
- package/vite-plugin/node_modules/rolldown/dist/parallel-plugin-worker.d.mts +1 -0
- package/vite-plugin/node_modules/rolldown/dist/parallel-plugin-worker.mjs +28 -0
- package/vite-plugin/node_modules/rolldown/dist/parallel-plugin.d.mts +13 -0
- package/vite-plugin/node_modules/rolldown/dist/parallel-plugin.mjs +6 -0
- package/vite-plugin/node_modules/rolldown/dist/parse-ast-index.d.mts +32 -0
- package/vite-plugin/node_modules/rolldown/dist/parse-ast-index.mjs +60 -0
- package/vite-plugin/node_modules/rolldown/dist/plugins-index.d.mts +33 -0
- package/vite-plugin/node_modules/rolldown/dist/plugins-index.mjs +40 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/binding-BeU_1iEk.mjs +582 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/binding-zH1vcmbM.d.mts +1899 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/bindingify-input-options-DbbBhzky.mjs +2211 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/constructors-C2EWPKW3.mjs +68 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/constructors-D0W3rNfA.d.mts +37 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/define-config-5HJ1b9vG.d.mts +3829 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/define-config-DJOr6Iwt.mjs +6 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/error-DL-e8-oE.mjs +85 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/get-log-filter-semyr3Lj.d.mts +35 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/load-config-BoVO31Un.mjs +120 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/logging-C6h4g8dA.d.mts +50 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/logs-D80CXhvg.mjs +180 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/misc-DJYbNKZX.mjs +21 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/normalize-string-or-regex-CbQQ69gT.mjs +66 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/parse-B_ZnWxLZ.mjs +74 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/prompt-U5ajztzG.mjs +847 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/resolve-tsconfig-CfYpGzid.mjs +113 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/rolldown-D3JZ9rMt.mjs +40 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/rolldown-build-DSxL8qiP.mjs +3325 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/transform-DgZ3paSD.d.mts +149 -0
- package/vite-plugin/node_modules/rolldown/dist/shared/watch-Bd8v9ewv.mjs +374 -0
- package/vite-plugin/node_modules/rolldown/dist/utils-index.d.mts +376 -0
- package/vite-plugin/node_modules/rolldown/dist/utils-index.mjs +2414 -0
- package/vite-plugin/node_modules/rolldown/package.json +153 -0
- package/vite-plugin/node_modules/source-map-js/LICENSE +28 -0
- package/vite-plugin/node_modules/source-map-js/README.md +765 -0
- package/vite-plugin/node_modules/source-map-js/lib/array-set.js +121 -0
- package/vite-plugin/node_modules/source-map-js/lib/base64-vlq.js +140 -0
- package/vite-plugin/node_modules/source-map-js/lib/base64.js +67 -0
- package/vite-plugin/node_modules/source-map-js/lib/binary-search.js +111 -0
- package/vite-plugin/node_modules/source-map-js/lib/mapping-list.js +79 -0
- package/vite-plugin/node_modules/source-map-js/lib/quick-sort.js +132 -0
- package/vite-plugin/node_modules/source-map-js/lib/source-map-consumer.d.ts +1 -0
- package/vite-plugin/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
- package/vite-plugin/node_modules/source-map-js/lib/source-map-generator.d.ts +1 -0
- package/vite-plugin/node_modules/source-map-js/lib/source-map-generator.js +444 -0
- package/vite-plugin/node_modules/source-map-js/lib/source-node.d.ts +1 -0
- package/vite-plugin/node_modules/source-map-js/lib/source-node.js +413 -0
- package/vite-plugin/node_modules/source-map-js/lib/util.js +594 -0
- package/vite-plugin/node_modules/source-map-js/package.json +71 -0
- package/vite-plugin/node_modules/source-map-js/source-map.d.ts +104 -0
- package/vite-plugin/node_modules/source-map-js/source-map.js +8 -0
- package/vite-plugin/node_modules/tinyglobby/LICENSE +21 -0
- package/vite-plugin/node_modules/tinyglobby/README.md +25 -0
- package/vite-plugin/node_modules/tinyglobby/dist/index.cjs +334 -0
- package/vite-plugin/node_modules/tinyglobby/dist/index.d.cts +148 -0
- package/vite-plugin/node_modules/tinyglobby/dist/index.d.mts +148 -0
- package/vite-plugin/node_modules/tinyglobby/dist/index.mjs +306 -0
- package/vite-plugin/node_modules/tinyglobby/package.json +73 -0
- package/vite-plugin/node_modules/vite/LICENSE.md +2230 -0
- package/vite-plugin/node_modules/vite/README.md +20 -0
- package/vite-plugin/node_modules/vite/bin/openChrome.js +68 -0
- package/vite-plugin/node_modules/vite/bin/vite.js +79 -0
- package/vite-plugin/node_modules/vite/client.d.ts +282 -0
- package/vite-plugin/node_modules/vite/dist/client/client.mjs +1237 -0
- package/vite-plugin/node_modules/vite/dist/client/env.mjs +18 -0
- package/vite-plugin/node_modules/vite/dist/node/chunks/build.js +5381 -0
- package/vite-plugin/node_modules/vite/dist/node/chunks/chunk.js +37 -0
- package/vite-plugin/node_modules/vite/dist/node/chunks/dist.js +6784 -0
- package/vite-plugin/node_modules/vite/dist/node/chunks/lib.js +371 -0
- package/vite-plugin/node_modules/vite/dist/node/chunks/logger.js +322 -0
- package/vite-plugin/node_modules/vite/dist/node/chunks/moduleRunnerTransport.d.ts +96 -0
- package/vite-plugin/node_modules/vite/dist/node/chunks/node.js +34874 -0
- package/vite-plugin/node_modules/vite/dist/node/chunks/postcss-import.js +467 -0
- package/vite-plugin/node_modules/vite/dist/node/cli.js +837 -0
- package/vite-plugin/node_modules/vite/dist/node/index.d.ts +3867 -0
- package/vite-plugin/node_modules/vite/dist/node/index.js +3 -0
- package/vite-plugin/node_modules/vite/dist/node/internal.d.ts +2 -0
- package/vite-plugin/node_modules/vite/dist/node/internal.js +2 -0
- package/vite-plugin/node_modules/vite/dist/node/module-runner.d.ts +315 -0
- package/vite-plugin/node_modules/vite/dist/node/module-runner.js +1262 -0
- package/vite-plugin/node_modules/vite/misc/false.js +1 -0
- package/vite-plugin/node_modules/vite/misc/true.js +1 -0
- package/vite-plugin/node_modules/vite/package.json +192 -0
- package/vite-plugin/node_modules/vite/types/customEvent.d.ts +79 -0
- package/vite-plugin/node_modules/vite/types/hmrPayload.d.ts +80 -0
- package/vite-plugin/node_modules/vite/types/hot.d.ts +39 -0
- package/vite-plugin/node_modules/vite/types/import-meta.d.ts +5 -0
- package/vite-plugin/node_modules/vite/types/importGlob.d.ts +89 -0
- package/vite-plugin/node_modules/vite/types/importMeta.d.ts +30 -0
- package/vite-plugin/node_modules/vite/types/internal/cssPreprocessorOptions.d.ts +44 -0
- package/vite-plugin/node_modules/vite/types/internal/esbuildOptions.d.ts +28 -0
- package/vite-plugin/node_modules/vite/types/internal/lightningcssOptions.d.ts +18 -0
- package/vite-plugin/node_modules/vite/types/internal/rollupTypeCompat.d.ts +24 -0
- package/vite-plugin/node_modules/vite/types/internal/terserOptions.d.ts +11 -0
- package/vite-plugin/node_modules/vite/types/metadata.d.ts +47 -0
- package/vite-plugin/package.json +14 -0
- package/www/src/{assets → .well-known/agent-skills/mockaton}/SKILLS.md +21 -9
- package/src/server/cacheBustResolver.js +0 -19
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
let Container = require('./container')
|
|
4
|
+
|
|
5
|
+
let LazyResult, Processor
|
|
6
|
+
|
|
7
|
+
class Root extends Container {
|
|
8
|
+
constructor(defaults) {
|
|
9
|
+
super(defaults)
|
|
10
|
+
this.type = 'root'
|
|
11
|
+
if (!this.nodes) this.nodes = []
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
normalize(child, sample, type) {
|
|
15
|
+
let nodes = super.normalize(child)
|
|
16
|
+
|
|
17
|
+
if (sample) {
|
|
18
|
+
if (type === 'prepend') {
|
|
19
|
+
if (this.nodes.length > 1) {
|
|
20
|
+
sample.raws.before = this.nodes[1].raws.before
|
|
21
|
+
} else {
|
|
22
|
+
delete sample.raws.before
|
|
23
|
+
}
|
|
24
|
+
} else if (this.first !== sample) {
|
|
25
|
+
for (let node of nodes) {
|
|
26
|
+
node.raws.before = sample.raws.before
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return nodes
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
removeChild(child, ignore) {
|
|
35
|
+
let index = this.index(child)
|
|
36
|
+
|
|
37
|
+
if (!ignore && index === 0 && this.nodes.length > 1) {
|
|
38
|
+
this.nodes[1].raws.before = this.nodes[index].raws.before
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return super.removeChild(child)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
toResult(opts = {}) {
|
|
45
|
+
let lazy = new LazyResult(new Processor(), this, opts)
|
|
46
|
+
return lazy.stringify()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
Root.registerLazyResult = dependant => {
|
|
51
|
+
LazyResult = dependant
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
Root.registerProcessor = dependant => {
|
|
55
|
+
Processor = dependant
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = Root
|
|
59
|
+
Root.default = Root
|
|
60
|
+
|
|
61
|
+
Container.registerRoot(Root)
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import Container, {
|
|
2
|
+
ContainerProps,
|
|
3
|
+
ContainerWithChildren
|
|
4
|
+
} from './container.js'
|
|
5
|
+
|
|
6
|
+
declare namespace Rule {
|
|
7
|
+
export interface RuleRaws extends Record<string, unknown> {
|
|
8
|
+
/**
|
|
9
|
+
* The space symbols after the last child of the node to the end of the node.
|
|
10
|
+
*/
|
|
11
|
+
after?: string
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The space symbols before the node. It also stores `*`
|
|
15
|
+
* and `_` symbols before the declaration (IE hack).
|
|
16
|
+
*/
|
|
17
|
+
before?: string
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The symbols between the selector and `{` for rules.
|
|
21
|
+
*/
|
|
22
|
+
between?: string
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Contains the text of the semicolon after this rule.
|
|
26
|
+
*/
|
|
27
|
+
ownSemicolon?: string
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The rule’s selector with comments.
|
|
31
|
+
*/
|
|
32
|
+
selector?: {
|
|
33
|
+
raw: string
|
|
34
|
+
value: string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Contains `true` if the last child has an (optional) semicolon.
|
|
39
|
+
*/
|
|
40
|
+
semicolon?: boolean
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type RuleProps = {
|
|
44
|
+
/** Information used to generate byte-to-byte equal node string as it was in the origin input. */
|
|
45
|
+
raws?: RuleRaws
|
|
46
|
+
} & (
|
|
47
|
+
| {
|
|
48
|
+
/** Selector or selectors of the rule. */
|
|
49
|
+
selector: string
|
|
50
|
+
selectors?: never
|
|
51
|
+
}
|
|
52
|
+
| {
|
|
53
|
+
selector?: never
|
|
54
|
+
/** Selectors of the rule represented as an array of strings. */
|
|
55
|
+
selectors: readonly string[]
|
|
56
|
+
}
|
|
57
|
+
) &
|
|
58
|
+
ContainerProps
|
|
59
|
+
|
|
60
|
+
export { Rule_ as default }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Represents a CSS rule: a selector followed by a declaration block.
|
|
65
|
+
*
|
|
66
|
+
* ```js
|
|
67
|
+
* Once (root, { Rule }) {
|
|
68
|
+
* let a = new Rule({ selector: 'a' })
|
|
69
|
+
* a.append(…)
|
|
70
|
+
* root.append(a)
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* ```js
|
|
75
|
+
* const root = postcss.parse('a{}')
|
|
76
|
+
* const rule = root.first
|
|
77
|
+
* rule.type //=> 'rule'
|
|
78
|
+
* rule.toString() //=> 'a{}'
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
declare class Rule_ extends Container {
|
|
82
|
+
nodes: NonNullable<Container['nodes']>
|
|
83
|
+
parent: ContainerWithChildren | undefined
|
|
84
|
+
raws: Rule.RuleRaws
|
|
85
|
+
type: 'rule'
|
|
86
|
+
/**
|
|
87
|
+
* The rule’s full selector represented as a string.
|
|
88
|
+
*
|
|
89
|
+
* ```js
|
|
90
|
+
* const root = postcss.parse('a, b { }')
|
|
91
|
+
* const rule = root.first
|
|
92
|
+
* rule.selector //=> 'a, b'
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
get selector(): string
|
|
96
|
+
|
|
97
|
+
set selector(value: string)
|
|
98
|
+
/**
|
|
99
|
+
* An array containing the rule’s individual selectors.
|
|
100
|
+
* Groups of selectors are split at commas.
|
|
101
|
+
*
|
|
102
|
+
* ```js
|
|
103
|
+
* const root = postcss.parse('a, b { }')
|
|
104
|
+
* const rule = root.first
|
|
105
|
+
*
|
|
106
|
+
* rule.selector //=> 'a, b'
|
|
107
|
+
* rule.selectors //=> ['a', 'b']
|
|
108
|
+
*
|
|
109
|
+
* rule.selectors = ['a', 'strong']
|
|
110
|
+
* rule.selector //=> 'a, strong'
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
get selectors(): string[]
|
|
114
|
+
|
|
115
|
+
set selectors(values: string[])
|
|
116
|
+
|
|
117
|
+
constructor(defaults?: Rule.RuleProps)
|
|
118
|
+
assign(overrides: object | Rule.RuleProps): this
|
|
119
|
+
clone(overrides?: Partial<Rule.RuleProps>): this
|
|
120
|
+
cloneAfter(overrides?: Partial<Rule.RuleProps>): this
|
|
121
|
+
cloneBefore(overrides?: Partial<Rule.RuleProps>): this
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare class Rule extends Rule_ {}
|
|
125
|
+
|
|
126
|
+
export = Rule
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
let Container = require('./container')
|
|
4
|
+
let list = require('./list')
|
|
5
|
+
|
|
6
|
+
class Rule extends Container {
|
|
7
|
+
get selectors() {
|
|
8
|
+
return list.comma(this.selector)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
set selectors(values) {
|
|
12
|
+
let match = this.selector ? this.selector.match(/,\s*/) : null
|
|
13
|
+
let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen')
|
|
14
|
+
this.selector = values.join(sep)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
constructor(defaults) {
|
|
18
|
+
super(defaults)
|
|
19
|
+
this.type = 'rule'
|
|
20
|
+
if (!this.nodes) this.nodes = []
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = Rule
|
|
25
|
+
Rule.default = Rule
|
|
26
|
+
|
|
27
|
+
Container.registerRule(Rule)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AnyNode,
|
|
3
|
+
AtRule,
|
|
4
|
+
Builder,
|
|
5
|
+
Comment,
|
|
6
|
+
Container,
|
|
7
|
+
Declaration,
|
|
8
|
+
Document,
|
|
9
|
+
Root,
|
|
10
|
+
Rule
|
|
11
|
+
} from './postcss.js'
|
|
12
|
+
|
|
13
|
+
declare namespace Stringifier {
|
|
14
|
+
export { Stringifier_ as default }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare class Stringifier_ {
|
|
18
|
+
builder: Builder
|
|
19
|
+
constructor(builder: Builder)
|
|
20
|
+
atrule(node: AtRule, semicolon?: boolean): void
|
|
21
|
+
beforeAfter(node: AnyNode, detect: 'after' | 'before'): string
|
|
22
|
+
block(node: AnyNode, start: string): void
|
|
23
|
+
body(node: Container): void
|
|
24
|
+
comment(node: Comment): void
|
|
25
|
+
decl(node: Declaration, semicolon?: boolean): void
|
|
26
|
+
document(node: Document): void
|
|
27
|
+
raw(node: AnyNode, own: null | string, detect?: string): boolean | string
|
|
28
|
+
rawBeforeClose(root: Root): string | undefined
|
|
29
|
+
rawBeforeComment(root: Root, node: Comment): string | undefined
|
|
30
|
+
rawBeforeDecl(root: Root, node: Declaration): string | undefined
|
|
31
|
+
rawBeforeOpen(root: Root): string | undefined
|
|
32
|
+
rawBeforeRule(root: Root): string | undefined
|
|
33
|
+
rawColon(root: Root): string | undefined
|
|
34
|
+
rawEmptyBody(root: Root): string | undefined
|
|
35
|
+
rawIndent(root: Root): string | undefined
|
|
36
|
+
rawSemicolon(root: Root): boolean | undefined
|
|
37
|
+
rawValue(node: AnyNode, prop: string): number | string
|
|
38
|
+
root(node: Root): void
|
|
39
|
+
rule(node: Rule): void
|
|
40
|
+
stringify(node: AnyNode, semicolon?: boolean): void
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
declare class Stringifier extends Stringifier_ {}
|
|
44
|
+
|
|
45
|
+
export = Stringifier
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// Escapes sequences that could break out of an HTML <style> context.
|
|
4
|
+
// Uses CSS unicode escaping (\3c = '<') which is valid CSS and parsed
|
|
5
|
+
// correctly by all compliant CSS consumers.
|
|
6
|
+
const STYLE_TAG = /(<)(\/?style\b)/gi
|
|
7
|
+
const COMMENT_OPEN = /(<)(!--)/g
|
|
8
|
+
|
|
9
|
+
function escapeHTMLInCSS(str) {
|
|
10
|
+
if (typeof str !== 'string') return str
|
|
11
|
+
if (!str.includes('<')) return str
|
|
12
|
+
return str.replace(STYLE_TAG, '\\3c $2').replace(COMMENT_OPEN, '\\3c $2')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const DEFAULT_RAW = {
|
|
16
|
+
after: '\n',
|
|
17
|
+
beforeClose: '\n',
|
|
18
|
+
beforeComment: '\n',
|
|
19
|
+
beforeDecl: '\n',
|
|
20
|
+
beforeOpen: ' ',
|
|
21
|
+
beforeRule: '\n',
|
|
22
|
+
colon: ': ',
|
|
23
|
+
commentLeft: ' ',
|
|
24
|
+
commentRight: ' ',
|
|
25
|
+
emptyBody: '',
|
|
26
|
+
indent: ' ',
|
|
27
|
+
semicolon: false
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function capitalize(str) {
|
|
31
|
+
return str[0].toUpperCase() + str.slice(1)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class Stringifier {
|
|
35
|
+
constructor(builder) {
|
|
36
|
+
this.builder = builder
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
atrule(node, semicolon) {
|
|
40
|
+
let name = '@' + node.name
|
|
41
|
+
let params = node.params ? this.rawValue(node, 'params') : ''
|
|
42
|
+
|
|
43
|
+
if (typeof node.raws.afterName !== 'undefined') {
|
|
44
|
+
name += node.raws.afterName
|
|
45
|
+
} else if (params) {
|
|
46
|
+
name += ' '
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (node.nodes) {
|
|
50
|
+
this.block(node, name + params)
|
|
51
|
+
} else {
|
|
52
|
+
let end = (node.raws.between || '') + (semicolon ? ';' : '')
|
|
53
|
+
this.builder(escapeHTMLInCSS(name + params + end), node)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
beforeAfter(node, detect) {
|
|
58
|
+
let value
|
|
59
|
+
if (node.type === 'decl') {
|
|
60
|
+
value = this.raw(node, null, 'beforeDecl')
|
|
61
|
+
} else if (node.type === 'comment') {
|
|
62
|
+
value = this.raw(node, null, 'beforeComment')
|
|
63
|
+
} else if (detect === 'before') {
|
|
64
|
+
value = this.raw(node, null, 'beforeRule')
|
|
65
|
+
} else {
|
|
66
|
+
value = this.raw(node, null, 'beforeClose')
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let buf = node.parent
|
|
70
|
+
let depth = 0
|
|
71
|
+
while (buf && buf.type !== 'root') {
|
|
72
|
+
depth += 1
|
|
73
|
+
buf = buf.parent
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (value.includes('\n')) {
|
|
77
|
+
let indent = this.raw(node, null, 'indent')
|
|
78
|
+
if (indent.length) {
|
|
79
|
+
for (let step = 0; step < depth; step++) value += indent
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return value
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
block(node, start) {
|
|
87
|
+
let between = this.raw(node, 'between', 'beforeOpen')
|
|
88
|
+
this.builder(escapeHTMLInCSS(start + between) + '{', node, 'start')
|
|
89
|
+
|
|
90
|
+
let after
|
|
91
|
+
if (node.nodes && node.nodes.length) {
|
|
92
|
+
this.body(node)
|
|
93
|
+
after = this.raw(node, 'after')
|
|
94
|
+
} else {
|
|
95
|
+
after = this.raw(node, 'after', 'emptyBody')
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (after) this.builder(escapeHTMLInCSS(after))
|
|
99
|
+
this.builder('}', node, 'end')
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
body(node) {
|
|
103
|
+
let last = node.nodes.length - 1
|
|
104
|
+
while (last > 0) {
|
|
105
|
+
if (node.nodes[last].type !== 'comment') break
|
|
106
|
+
last -= 1
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let semicolon = this.raw(node, 'semicolon')
|
|
110
|
+
let isDocument = node.type === 'document'
|
|
111
|
+
for (let i = 0; i < node.nodes.length; i++) {
|
|
112
|
+
let child = node.nodes[i]
|
|
113
|
+
let before = this.raw(child, 'before')
|
|
114
|
+
if (before) this.builder(isDocument ? before : escapeHTMLInCSS(before))
|
|
115
|
+
this.stringify(child, last !== i || semicolon)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
comment(node) {
|
|
120
|
+
let left = this.raw(node, 'left', 'commentLeft')
|
|
121
|
+
let right = this.raw(node, 'right', 'commentRight')
|
|
122
|
+
this.builder(escapeHTMLInCSS('/*' + left + node.text + right + '*/'), node)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
decl(node, semicolon) {
|
|
126
|
+
let between = this.raw(node, 'between', 'colon')
|
|
127
|
+
let string = node.prop + between + this.rawValue(node, 'value')
|
|
128
|
+
|
|
129
|
+
if (node.important) {
|
|
130
|
+
string += node.raws.important || ' !important'
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (semicolon) string += ';'
|
|
134
|
+
this.builder(escapeHTMLInCSS(string), node)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
document(node) {
|
|
138
|
+
this.body(node)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
raw(node, own, detect) {
|
|
142
|
+
let value
|
|
143
|
+
if (!detect) detect = own
|
|
144
|
+
|
|
145
|
+
// Already had
|
|
146
|
+
if (own) {
|
|
147
|
+
value = node.raws[own]
|
|
148
|
+
if (typeof value !== 'undefined') return value
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
let parent = node.parent
|
|
152
|
+
|
|
153
|
+
if (detect === 'before') {
|
|
154
|
+
// Hack for first rule in CSS
|
|
155
|
+
if (!parent || (parent.type === 'root' && parent.first === node)) {
|
|
156
|
+
return ''
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// `root` nodes in `document` should use only their own raws
|
|
160
|
+
if (parent && parent.type === 'document') {
|
|
161
|
+
return ''
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Floating child without parent
|
|
166
|
+
if (!parent) return DEFAULT_RAW[detect]
|
|
167
|
+
|
|
168
|
+
// Detect style by other nodes
|
|
169
|
+
let root = node.root()
|
|
170
|
+
if (!root.rawCache) root.rawCache = {}
|
|
171
|
+
if (typeof root.rawCache[detect] !== 'undefined') {
|
|
172
|
+
return root.rawCache[detect]
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (detect === 'before' || detect === 'after') {
|
|
176
|
+
return this.beforeAfter(node, detect)
|
|
177
|
+
} else {
|
|
178
|
+
let method = 'raw' + capitalize(detect)
|
|
179
|
+
if (this[method]) {
|
|
180
|
+
value = this[method](root, node)
|
|
181
|
+
} else {
|
|
182
|
+
root.walk(i => {
|
|
183
|
+
value = i.raws[own]
|
|
184
|
+
if (typeof value !== 'undefined') return false
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (typeof value === 'undefined') value = DEFAULT_RAW[detect]
|
|
190
|
+
|
|
191
|
+
root.rawCache[detect] = value
|
|
192
|
+
return value
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
rawBeforeClose(root) {
|
|
196
|
+
let value
|
|
197
|
+
root.walk(i => {
|
|
198
|
+
if (i.nodes && i.nodes.length > 0) {
|
|
199
|
+
if (typeof i.raws.after !== 'undefined') {
|
|
200
|
+
value = i.raws.after
|
|
201
|
+
if (value.includes('\n')) {
|
|
202
|
+
value = value.replace(/[^\n]+$/, '')
|
|
203
|
+
}
|
|
204
|
+
return false
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
})
|
|
208
|
+
if (value) value = value.replace(/\S/g, '')
|
|
209
|
+
return value
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
rawBeforeComment(root, node) {
|
|
213
|
+
let value
|
|
214
|
+
root.walkComments(i => {
|
|
215
|
+
if (typeof i.raws.before !== 'undefined') {
|
|
216
|
+
value = i.raws.before
|
|
217
|
+
if (value.includes('\n')) {
|
|
218
|
+
value = value.replace(/[^\n]+$/, '')
|
|
219
|
+
}
|
|
220
|
+
return false
|
|
221
|
+
}
|
|
222
|
+
})
|
|
223
|
+
if (typeof value === 'undefined') {
|
|
224
|
+
value = this.raw(node, null, 'beforeDecl')
|
|
225
|
+
} else if (value) {
|
|
226
|
+
value = value.replace(/\S/g, '')
|
|
227
|
+
}
|
|
228
|
+
return value
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
rawBeforeDecl(root, node) {
|
|
232
|
+
let value
|
|
233
|
+
root.walkDecls(i => {
|
|
234
|
+
if (typeof i.raws.before !== 'undefined') {
|
|
235
|
+
value = i.raws.before
|
|
236
|
+
if (value.includes('\n')) {
|
|
237
|
+
value = value.replace(/[^\n]+$/, '')
|
|
238
|
+
}
|
|
239
|
+
return false
|
|
240
|
+
}
|
|
241
|
+
})
|
|
242
|
+
if (typeof value === 'undefined') {
|
|
243
|
+
value = this.raw(node, null, 'beforeRule')
|
|
244
|
+
} else if (value) {
|
|
245
|
+
value = value.replace(/\S/g, '')
|
|
246
|
+
}
|
|
247
|
+
return value
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
rawBeforeOpen(root) {
|
|
251
|
+
let value
|
|
252
|
+
root.walk(i => {
|
|
253
|
+
if (i.type !== 'decl') {
|
|
254
|
+
value = i.raws.between
|
|
255
|
+
if (typeof value !== 'undefined') return false
|
|
256
|
+
}
|
|
257
|
+
})
|
|
258
|
+
return value
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
rawBeforeRule(root) {
|
|
262
|
+
let value
|
|
263
|
+
root.walk(i => {
|
|
264
|
+
if (i.nodes && (i.parent !== root || root.first !== i)) {
|
|
265
|
+
if (typeof i.raws.before !== 'undefined') {
|
|
266
|
+
value = i.raws.before
|
|
267
|
+
if (value.includes('\n')) {
|
|
268
|
+
value = value.replace(/[^\n]+$/, '')
|
|
269
|
+
}
|
|
270
|
+
return false
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
})
|
|
274
|
+
if (value) value = value.replace(/\S/g, '')
|
|
275
|
+
return value
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
rawColon(root) {
|
|
279
|
+
let value
|
|
280
|
+
root.walkDecls(i => {
|
|
281
|
+
if (typeof i.raws.between !== 'undefined') {
|
|
282
|
+
value = i.raws.between.replace(/[^\s:]/g, '')
|
|
283
|
+
return false
|
|
284
|
+
}
|
|
285
|
+
})
|
|
286
|
+
return value
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
rawEmptyBody(root) {
|
|
290
|
+
let value
|
|
291
|
+
root.walk(i => {
|
|
292
|
+
if (i.nodes && i.nodes.length === 0) {
|
|
293
|
+
value = i.raws.after
|
|
294
|
+
if (typeof value !== 'undefined') return false
|
|
295
|
+
}
|
|
296
|
+
})
|
|
297
|
+
return value
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
rawIndent(root) {
|
|
301
|
+
if (root.raws.indent) return root.raws.indent
|
|
302
|
+
let value
|
|
303
|
+
root.walk(i => {
|
|
304
|
+
let p = i.parent
|
|
305
|
+
if (p && p !== root && p.parent && p.parent === root) {
|
|
306
|
+
if (typeof i.raws.before !== 'undefined') {
|
|
307
|
+
let parts = i.raws.before.split('\n')
|
|
308
|
+
value = parts[parts.length - 1]
|
|
309
|
+
value = value.replace(/\S/g, '')
|
|
310
|
+
return false
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
})
|
|
314
|
+
return value
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
rawSemicolon(root) {
|
|
318
|
+
let value
|
|
319
|
+
root.walk(i => {
|
|
320
|
+
if (i.nodes && i.nodes.length && i.last.type === 'decl') {
|
|
321
|
+
value = i.raws.semicolon
|
|
322
|
+
if (typeof value !== 'undefined') return false
|
|
323
|
+
}
|
|
324
|
+
})
|
|
325
|
+
return value
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
rawValue(node, prop) {
|
|
329
|
+
let value = node[prop]
|
|
330
|
+
let raw = node.raws[prop]
|
|
331
|
+
if (raw && raw.value === value) {
|
|
332
|
+
return raw.raw
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
return value
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
root(node) {
|
|
339
|
+
this.body(node)
|
|
340
|
+
if (node.raws.after) {
|
|
341
|
+
let after = node.raws.after
|
|
342
|
+
let isDocument = node.parent && node.parent.type === 'document'
|
|
343
|
+
this.builder(isDocument ? after : escapeHTMLInCSS(after))
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
rule(node) {
|
|
348
|
+
this.block(node, this.rawValue(node, 'selector'))
|
|
349
|
+
if (node.raws.ownSemicolon) {
|
|
350
|
+
this.builder(escapeHTMLInCSS(node.raws.ownSemicolon), node, 'end')
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
stringify(node, semicolon) {
|
|
355
|
+
/* c8 ignore start */
|
|
356
|
+
if (!this[node.type]) {
|
|
357
|
+
throw new Error(
|
|
358
|
+
'Unknown AST node type ' +
|
|
359
|
+
node.type +
|
|
360
|
+
'. ' +
|
|
361
|
+
'Maybe you need to change PostCSS stringifier.'
|
|
362
|
+
)
|
|
363
|
+
}
|
|
364
|
+
/* c8 ignore stop */
|
|
365
|
+
this[node.type](node, semicolon)
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
module.exports = Stringifier
|
|
370
|
+
Stringifier.default = Stringifier
|