@stencil/core 4.43.2 → 5.0.0-next.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/bin/stencil.mjs +2 -0
- package/dist/chunk-ClPoSABd.mjs +21 -0
- package/dist/client-DR9zhmKG.mjs +4449 -0
- package/dist/compiler/index.d.mts +187 -0
- package/dist/compiler/index.mjs +9 -0
- package/dist/compiler/utils/index.d.mts +3 -0
- package/dist/compiler/utils/index.mjs +5 -0
- package/dist/declarations/stencil-public-compiler.d.ts +4401 -0
- package/dist/declarations/stencil-public-compiler.js +53 -0
- package/dist/declarations/stencil-public-runtime.d.ts +1857 -0
- package/dist/index-Bxo2jCf6.d.mts +77 -0
- package/dist/index-szczUd2l.d.mts +6851 -0
- package/{internal/stencil-core/index.d.ts → dist/index.d.mts} +7 -3
- package/dist/index.mjs +4 -0
- package/dist/mock-doc.d.mts +1 -0
- package/dist/mock-doc.mjs +3 -0
- package/dist/node-sys-BGURUNOZ.mjs +1954 -0
- package/{internal → dist/runtime}/app-data/index.d.ts +11 -7
- package/dist/runtime/app-data/index.js +100 -0
- package/dist/runtime/app-globals/index.d.ts +5 -0
- package/dist/runtime/app-globals/index.js +6 -0
- package/dist/runtime/client/index.d.ts +2286 -0
- package/dist/runtime/client/index.js +4839 -0
- package/dist/runtime/index.d.ts +221 -0
- package/dist/runtime/index.js +4819 -0
- package/dist/runtime/server/index.d.mts +1277 -0
- package/dist/runtime/server/index.mjs +5376 -0
- package/dist/runtime/server/runner.d.mts +298 -0
- package/dist/runtime/server/runner.mjs +1976 -0
- package/dist/serialize-BJvhE9aQ.mjs +775 -0
- package/dist/stencil-private-Cgcr414u.d.ts +1893 -0
- package/dist/sys/node/index.d.mts +33 -0
- package/dist/sys/node/index.mjs +7 -0
- package/dist/sys/node/worker.d.mts +1 -0
- package/dist/sys/node/worker.mjs +60 -0
- package/dist/testing/index.d.mts +207 -0
- package/dist/testing/index.mjs +1188 -0
- package/dist/transpile-CJQcQEVa.mjs +21854 -0
- package/dist/validation-BdcPruW_.mjs +1451 -0
- package/package.json +88 -232
- package/bin/stencil +0 -57
- package/cli/config-flags.d.ts +0 -132
- package/cli/index.cjs +0 -5816
- package/cli/index.d.ts +0 -19
- package/cli/index.js +0 -5809
- package/cli/package.json +0 -14
- package/compiler/lib.d.ts +0 -22
- package/compiler/lib.decorators.d.ts +0 -384
- package/compiler/lib.decorators.legacy.d.ts +0 -22
- package/compiler/lib.dom.asynciterable.d.ts +0 -41
- package/compiler/lib.dom.d.ts +0 -29610
- package/compiler/lib.dom.iterable.d.ts +0 -493
- package/compiler/lib.es2015.collection.d.ts +0 -147
- package/compiler/lib.es2015.core.d.ts +0 -597
- package/compiler/lib.es2015.d.ts +0 -28
- package/compiler/lib.es2015.generator.d.ts +0 -77
- package/compiler/lib.es2015.iterable.d.ts +0 -605
- package/compiler/lib.es2015.promise.d.ts +0 -81
- package/compiler/lib.es2015.proxy.d.ts +0 -128
- package/compiler/lib.es2015.reflect.d.ts +0 -144
- package/compiler/lib.es2015.symbol.d.ts +0 -46
- package/compiler/lib.es2015.symbol.wellknown.d.ts +0 -326
- package/compiler/lib.es2016.array.include.d.ts +0 -116
- package/compiler/lib.es2016.d.ts +0 -21
- package/compiler/lib.es2016.full.d.ts +0 -23
- package/compiler/lib.es2016.intl.d.ts +0 -31
- package/compiler/lib.es2017.arraybuffer.d.ts +0 -21
- package/compiler/lib.es2017.d.ts +0 -26
- package/compiler/lib.es2017.date.d.ts +0 -31
- package/compiler/lib.es2017.full.d.ts +0 -23
- package/compiler/lib.es2017.intl.d.ts +0 -44
- package/compiler/lib.es2017.object.d.ts +0 -49
- package/compiler/lib.es2017.sharedmemory.d.ts +0 -135
- package/compiler/lib.es2017.string.d.ts +0 -45
- package/compiler/lib.es2017.typedarrays.d.ts +0 -53
- package/compiler/lib.es2018.asyncgenerator.d.ts +0 -77
- package/compiler/lib.es2018.asynciterable.d.ts +0 -53
- package/compiler/lib.es2018.d.ts +0 -24
- package/compiler/lib.es2018.full.d.ts +0 -24
- package/compiler/lib.es2018.intl.d.ts +0 -83
- package/compiler/lib.es2018.promise.d.ts +0 -30
- package/compiler/lib.es2018.regexp.d.ts +0 -37
- package/compiler/lib.es2019.array.d.ts +0 -79
- package/compiler/lib.es2019.d.ts +0 -24
- package/compiler/lib.es2019.full.d.ts +0 -24
- package/compiler/lib.es2019.intl.d.ts +0 -23
- package/compiler/lib.es2019.object.d.ts +0 -33
- package/compiler/lib.es2019.string.d.ts +0 -37
- package/compiler/lib.es2019.symbol.d.ts +0 -24
- package/compiler/lib.es2020.bigint.d.ts +0 -765
- package/compiler/lib.es2020.d.ts +0 -27
- package/compiler/lib.es2020.date.d.ts +0 -42
- package/compiler/lib.es2020.full.d.ts +0 -24
- package/compiler/lib.es2020.intl.d.ts +0 -474
- package/compiler/lib.es2020.number.d.ts +0 -28
- package/compiler/lib.es2020.promise.d.ts +0 -47
- package/compiler/lib.es2020.sharedmemory.d.ts +0 -99
- package/compiler/lib.es2020.string.d.ts +0 -44
- package/compiler/lib.es2020.symbol.wellknown.d.ts +0 -41
- package/compiler/lib.es2021.d.ts +0 -23
- package/compiler/lib.es2021.full.d.ts +0 -24
- package/compiler/lib.es2021.intl.d.ts +0 -166
- package/compiler/lib.es2021.promise.d.ts +0 -48
- package/compiler/lib.es2021.string.d.ts +0 -33
- package/compiler/lib.es2021.weakref.d.ts +0 -78
- package/compiler/lib.es2022.array.d.ts +0 -121
- package/compiler/lib.es2022.d.ts +0 -25
- package/compiler/lib.es2022.error.d.ts +0 -75
- package/compiler/lib.es2022.full.d.ts +0 -24
- package/compiler/lib.es2022.intl.d.ts +0 -121
- package/compiler/lib.es2022.object.d.ts +0 -26
- package/compiler/lib.es2022.regexp.d.ts +0 -39
- package/compiler/lib.es2022.string.d.ts +0 -25
- package/compiler/lib.es2023.array.d.ts +0 -924
- package/compiler/lib.es2023.collection.d.ts +0 -21
- package/compiler/lib.es2023.d.ts +0 -22
- package/compiler/lib.es2023.full.d.ts +0 -24
- package/compiler/lib.es2023.intl.d.ts +0 -56
- package/compiler/lib.es2024.arraybuffer.d.ts +0 -65
- package/compiler/lib.es2024.collection.d.ts +0 -29
- package/compiler/lib.es2024.d.ts +0 -26
- package/compiler/lib.es2024.full.d.ts +0 -24
- package/compiler/lib.es2024.object.d.ts +0 -29
- package/compiler/lib.es2024.promise.d.ts +0 -35
- package/compiler/lib.es2024.regexp.d.ts +0 -25
- package/compiler/lib.es2024.sharedmemory.d.ts +0 -68
- package/compiler/lib.es2024.string.d.ts +0 -29
- package/compiler/lib.es5.d.ts +0 -4594
- package/compiler/lib.es6.d.ts +0 -23
- package/compiler/lib.esnext.array.d.ts +0 -35
- package/compiler/lib.esnext.collection.d.ts +0 -96
- package/compiler/lib.esnext.d.ts +0 -27
- package/compiler/lib.esnext.decorators.d.ts +0 -28
- package/compiler/lib.esnext.disposable.d.ts +0 -193
- package/compiler/lib.esnext.float16.d.ts +0 -443
- package/compiler/lib.esnext.full.d.ts +0 -24
- package/compiler/lib.esnext.intl.d.ts +0 -21
- package/compiler/lib.esnext.iterator.d.ts +0 -148
- package/compiler/lib.esnext.promise.d.ts +0 -34
- package/compiler/lib.scripthost.d.ts +0 -322
- package/compiler/lib.webworker.asynciterable.d.ts +0 -41
- package/compiler/lib.webworker.d.ts +0 -9894
- package/compiler/lib.webworker.importscripts.d.ts +0 -23
- package/compiler/lib.webworker.iterable.d.ts +0 -287
- package/compiler/package.json +0 -8
- package/compiler/stencil.d.ts +0 -73
- package/compiler/stencil.js +0 -287816
- package/compiler/sys/in-memory-fs.d.ts +0 -227
- package/compiler/transpile.d.ts +0 -32
- package/dev-server/client/app-error.d.ts +0 -20
- package/dev-server/client/events.d.ts +0 -6
- package/dev-server/client/hmr-components.d.ts +0 -12
- package/dev-server/client/hmr-external-styles.d.ts +0 -1
- package/dev-server/client/hmr-images.d.ts +0 -1
- package/dev-server/client/hmr-inline-styles.d.ts +0 -1
- package/dev-server/client/hmr-util.d.ts +0 -39
- package/dev-server/client/hmr-window.d.ts +0 -10
- package/dev-server/client/index.d.ts +0 -6
- package/dev-server/client/index.js +0 -793
- package/dev-server/client/logger.d.ts +0 -6
- package/dev-server/client/package.json +0 -8
- package/dev-server/client/progress.d.ts +0 -3
- package/dev-server/client/status.d.ts +0 -4
- package/dev-server/client/test/hmr-util.spec.d.ts +0 -1
- package/dev-server/client/test/status.spec.d.ts +0 -1
- package/dev-server/connector.html +0 -6
- package/dev-server/index.d.ts +0 -3
- package/dev-server/index.js +0 -247
- package/dev-server/package.json +0 -8
- package/dev-server/server-process.js +0 -12095
- package/dev-server/server-worker-thread.js +0 -39
- package/dev-server/static/favicon.ico +0 -0
- package/dev-server/templates/directory-index.html +0 -176
- package/dev-server/templates/initial-load.html +0 -168
- package/dev-server/visualstudio.vbs +0 -82
- package/dev-server/xdg-open +0 -1066
- package/internal/app-data/index.cjs +0 -119
- package/internal/app-data/index.js +0 -92
- package/internal/app-data/package.json +0 -15
- package/internal/app-globals/index.d.ts +0 -2
- package/internal/app-globals/index.js +0 -14
- package/internal/app-globals/package.json +0 -14
- package/internal/child_process.d.ts +0 -7
- package/internal/client/index.js +0 -4736
- package/internal/client/package.json +0 -10
- package/internal/client/patch-browser.js +0 -45
- package/internal/client/polyfills/core-js.js +0 -11
- package/internal/client/polyfills/dom.js +0 -79
- package/internal/client/polyfills/es5-html-element.js +0 -1
- package/internal/client/polyfills/index.js +0 -34
- package/internal/client/polyfills/system.js +0 -6
- package/internal/client/shadow-css.js +0 -414
- package/internal/hydrate/index.js +0 -6671
- package/internal/hydrate/package.json +0 -7
- package/internal/hydrate/runner.d.ts +0 -287
- package/internal/hydrate/runner.js +0 -17950
- package/internal/index.d.ts +0 -4
- package/internal/index.js +0 -2
- package/internal/package.json +0 -9
- package/internal/stencil-core/index.cjs +0 -1
- package/internal/stencil-core/index.js +0 -18
- package/internal/stencil-core/jsx-dev-runtime.cjs +0 -7
- package/internal/stencil-core/jsx-dev-runtime.d.ts +0 -41
- package/internal/stencil-core/jsx-dev-runtime.js +0 -2
- package/internal/stencil-core/jsx-runtime.cjs +0 -8
- package/internal/stencil-core/jsx-runtime.d.ts +0 -40
- package/internal/stencil-core/jsx-runtime.js +0 -2
- package/internal/stencil-private.d.ts +0 -2549
- package/internal/stencil-public-compiler.d.ts +0 -2867
- package/internal/stencil-public-runtime.d.ts +0 -1860
- package/internal/testing/index.js +0 -6528
- package/internal/testing/jsx-dev-runtime.d.ts +0 -2
- package/internal/testing/jsx-dev-runtime.js +0 -8
- package/internal/testing/jsx-runtime.d.ts +0 -2
- package/internal/testing/jsx-runtime.js +0 -9
- package/internal/testing/package.json +0 -7
- package/internal/utils/index.d.ts +0 -1
- package/internal/utils/result.d.ts +0 -112
- package/mock-doc/index.cjs +0 -10165
- package/mock-doc/index.d.ts +0 -1172
- package/mock-doc/index.js +0 -10144
- package/mock-doc/package.json +0 -15
- package/readme.md +0 -94
- package/screenshot/compare/assets/favicon.ico +0 -0
- package/screenshot/compare/assets/logo.png +0 -0
- package/screenshot/compare/build/app.css +0 -1
- package/screenshot/compare/build/app.esm.js +0 -1
- package/screenshot/compare/build/app.js +0 -33
- package/screenshot/compare/build/p-081b0641.js +0 -1
- package/screenshot/compare/build/p-227a1e18.entry.js +0 -1
- package/screenshot/compare/build/p-2c298727.entry.js +0 -1
- package/screenshot/compare/build/p-5479268c.entry.js +0 -1
- package/screenshot/compare/build/p-573ec8a4.entry.js +0 -1
- package/screenshot/compare/build/p-6ba08604.entry.js +0 -1
- package/screenshot/compare/build/p-6bc63295.entry.js +0 -1
- package/screenshot/compare/build/p-7a3759fd.entry.js +0 -1
- package/screenshot/compare/build/p-7b4e3ba7.js +0 -1
- package/screenshot/compare/build/p-988eb362.css +0 -1
- package/screenshot/compare/build/p-9b6a9315.js +0 -1
- package/screenshot/compare/build/p-b4cc611c.entry.js +0 -1
- package/screenshot/compare/build/p-d1bf53f5.entry.js +0 -1
- package/screenshot/compare/build/p-e2efe0df.js +0 -1
- package/screenshot/compare/build/p-e8ca6d97.entry.js +0 -1
- package/screenshot/compare/build/p-ec2f13e0.entry.js +0 -1
- package/screenshot/compare/build/p-f0b99977.entry.js +0 -1
- package/screenshot/compare/build/p-f4745c2f.entry.js +0 -1
- package/screenshot/compare/build/p-fbbae598.js +0 -1
- package/screenshot/compare/host.config.json +0 -15
- package/screenshot/compare/index.html +0 -1
- package/screenshot/compare/manifest.json +0 -13
- package/screenshot/connector-base.d.ts +0 -42
- package/screenshot/connector-local.d.ts +0 -7
- package/screenshot/connector.js +0 -2
- package/screenshot/index.d.ts +0 -3
- package/screenshot/index.js +0 -2433
- package/screenshot/local-connector.js +0 -2
- package/screenshot/package.json +0 -15
- package/screenshot/pixel-match.d.ts +0 -1
- package/screenshot/pixel-match.js +0 -2315
- package/screenshot/screenshot-compare.d.ts +0 -20
- package/screenshot/screenshot-fs.d.ts +0 -14
- package/sys/node/460.node-fetch.js +0 -451
- package/sys/node/autoprefixer.js +0 -9
- package/sys/node/glob.js +0 -1
- package/sys/node/graceful-fs.js +0 -1
- package/sys/node/index.d.ts +0 -39
- package/sys/node/index.js +0 -64
- package/sys/node/node-fetch.js +0 -12
- package/sys/node/package.json +0 -8
- package/sys/node/prompts.js +0 -1
- package/sys/node/worker.js +0 -4
- package/testing/index.d.ts +0 -9
- package/testing/index.js +0 -13064
- package/testing/jest/jest-27-and-under/jest-config.d.ts +0 -16
- package/testing/jest/jest-27-and-under/jest-environment.d.ts +0 -2
- package/testing/jest/jest-27-and-under/jest-facade.d.ts +0 -155
- package/testing/jest/jest-27-and-under/jest-preprocessor.d.ts +0 -59
- package/testing/jest/jest-27-and-under/jest-preset.d.ts +0 -3
- package/testing/jest/jest-27-and-under/jest-runner.d.ts +0 -11
- package/testing/jest/jest-27-and-under/jest-screenshot.d.ts +0 -2
- package/testing/jest/jest-27-and-under/jest-serializer.d.ts +0 -4
- package/testing/jest/jest-27-and-under/jest-setup-test-framework.d.ts +0 -9
- package/testing/jest/jest-27-and-under/matchers/attributes.d.ts +0 -14
- package/testing/jest/jest-27-and-under/matchers/class-list.d.ts +0 -12
- package/testing/jest/jest-27-and-under/matchers/events.d.ts +0 -25
- package/testing/jest/jest-27-and-under/matchers/html.d.ts +0 -13
- package/testing/jest/jest-27-and-under/matchers/index.d.ts +0 -24
- package/testing/jest/jest-27-and-under/matchers/screenshot.d.ts +0 -5
- package/testing/jest/jest-27-and-under/matchers/text.d.ts +0 -4
- package/testing/jest/jest-27-and-under/test/jest-config.spec.d.ts +0 -1
- package/testing/jest/jest-27-and-under/test/jest-preprocessor.spec.d.ts +0 -1
- package/testing/jest/jest-27-and-under/test/jest-runner.spec.d.ts +0 -1
- package/testing/jest/jest-27-and-under/test/jest-serializer.spec.d.ts +0 -1
- package/testing/jest/jest-27-and-under/test/jest-setup-test-framework.spec.d.ts +0 -1
- package/testing/jest/jest-28/jest-config.d.ts +0 -16
- package/testing/jest/jest-28/jest-environment.d.ts +0 -2
- package/testing/jest/jest-28/jest-facade.d.ts +0 -134
- package/testing/jest/jest-28/jest-preprocessor.d.ts +0 -35
- package/testing/jest/jest-28/jest-preset.d.ts +0 -3
- package/testing/jest/jest-28/jest-runner.d.ts +0 -11
- package/testing/jest/jest-28/jest-screenshot.d.ts +0 -2
- package/testing/jest/jest-28/jest-serializer.d.ts +0 -4
- package/testing/jest/jest-28/jest-setup-test-framework.d.ts +0 -9
- package/testing/jest/jest-28/matchers/attributes.d.ts +0 -14
- package/testing/jest/jest-28/matchers/class-list.d.ts +0 -12
- package/testing/jest/jest-28/matchers/events.d.ts +0 -25
- package/testing/jest/jest-28/matchers/html.d.ts +0 -13
- package/testing/jest/jest-28/matchers/index.d.ts +0 -24
- package/testing/jest/jest-28/matchers/screenshot.d.ts +0 -5
- package/testing/jest/jest-28/matchers/text.d.ts +0 -4
- package/testing/jest/jest-28/test/jest-config.spec.d.ts +0 -1
- package/testing/jest/jest-28/test/jest-preprocessor.spec.d.ts +0 -1
- package/testing/jest/jest-28/test/jest-runner.spec.d.ts +0 -1
- package/testing/jest/jest-28/test/jest-serializer.spec.d.ts +0 -1
- package/testing/jest/jest-28/test/jest-setup-test-framework.spec.d.ts +0 -1
- package/testing/jest/jest-29/jest-config.d.ts +0 -16
- package/testing/jest/jest-29/jest-environment.d.ts +0 -2
- package/testing/jest/jest-29/jest-facade.d.ts +0 -136
- package/testing/jest/jest-29/jest-preprocessor.d.ts +0 -35
- package/testing/jest/jest-29/jest-preset.d.ts +0 -3
- package/testing/jest/jest-29/jest-runner.d.ts +0 -11
- package/testing/jest/jest-29/jest-screenshot.d.ts +0 -2
- package/testing/jest/jest-29/jest-serializer.d.ts +0 -4
- package/testing/jest/jest-29/jest-setup-test-framework.d.ts +0 -9
- package/testing/jest/jest-29/matchers/attributes.d.ts +0 -14
- package/testing/jest/jest-29/matchers/class-list.d.ts +0 -12
- package/testing/jest/jest-29/matchers/events.d.ts +0 -25
- package/testing/jest/jest-29/matchers/html.d.ts +0 -13
- package/testing/jest/jest-29/matchers/index.d.ts +0 -24
- package/testing/jest/jest-29/matchers/screenshot.d.ts +0 -5
- package/testing/jest/jest-29/matchers/text.d.ts +0 -4
- package/testing/jest/jest-29/test/jest-config.spec.d.ts +0 -1
- package/testing/jest/jest-29/test/jest-preprocessor.spec.d.ts +0 -1
- package/testing/jest/jest-29/test/jest-runner.spec.d.ts +0 -1
- package/testing/jest/jest-29/test/jest-serializer.spec.d.ts +0 -1
- package/testing/jest/jest-29/test/jest-setup-test-framework.spec.d.ts +0 -1
- package/testing/jest/jest-apis.d.ts +0 -86
- package/testing/jest/jest-facade.d.ts +0 -74
- package/testing/jest/jest-stencil-connector.d.ts +0 -65
- package/testing/jest/test/jest-stencil-connector.spec.d.ts +0 -1
- package/testing/jest-environment.js +0 -3
- package/testing/jest-preprocessor.js +0 -3
- package/testing/jest-preset.js +0 -2
- package/testing/jest-runner.js +0 -3
- package/testing/jest-setuptestframework.js +0 -3
- package/testing/mock-fetch.d.ts +0 -11
- package/testing/mocks.d.ts +0 -56
- package/testing/package.json +0 -8
- package/testing/puppeteer/index.d.ts +0 -2
- package/testing/puppeteer/puppeteer-browser.d.ts +0 -6
- package/testing/puppeteer/puppeteer-declarations.d.ts +0 -414
- package/testing/puppeteer/puppeteer-element.d.ts +0 -67
- package/testing/puppeteer/puppeteer-emulate.d.ts +0 -2
- package/testing/puppeteer/puppeteer-events.d.ts +0 -21
- package/testing/puppeteer/puppeteer-page.d.ts +0 -2
- package/testing/puppeteer/puppeteer-screenshot.d.ts +0 -27
- package/testing/puppeteer/test/puppeteer-screenshot.spec.d.ts +0 -1
- package/testing/reset-build-conditionals.d.ts +0 -12
- package/testing/spec-page.d.ts +0 -7
- package/testing/test/testing-utils.spec.d.ts +0 -1
- package/testing/test-transpile.d.ts +0 -2
- package/testing/testing-logger.d.ts +0 -26
- package/testing/testing-sys.d.ts +0 -6
- package/testing/testing-utils.d.ts +0 -80
- package/testing/testing.d.ts +0 -2
- /package/{internal → dist/declarations}/stencil-ext-modules.d.ts +0 -0
- /package/{internal → dist/declarations}/stencil-public-docs.d.ts +0 -0
- /package/{screenshot/compare/build/index.esm.js → dist/declarations/stencil-public-runtime.js} +0 -0
|
@@ -0,0 +1,1451 @@
|
|
|
1
|
+
import { t as __exportAll } from "./chunk-ClPoSABd.mjs";
|
|
2
|
+
import { A as CUSTOM, B as DOCS_CUSTOM, C as toDashCase, D as CMP_FLAGS, F as DIST_GLOBAL_STYLES, H as DOCS_JSON, I as DIST_HYDRATE_SCRIPT, K as GENERATED_DTS, L as DIST_LAZY, M as DIST, N as DIST_COLLECTION, P as DIST_CUSTOM_ELEMENTS, R as DIST_LAZY_LOADER, U as DOCS_README, V as DOCS_CUSTOM_ELEMENTS_MANIFEST, W as DOCS_VSCODE, X as MEMBER_FLAGS, Y as LISTENER_FLAGS, _ as isString, c as flatOne, it as VALID_CONFIG_OUTPUT_TARGETS, k as COPY, m as isIterable, o as dashToPascalCase, ot as WATCH_FLAGS, s as escapeWithPattern, st as WWW, tt as STATS, w as toTitleCase, x as sortBy, z as DIST_TYPES } from "./serialize-BJvhE9aQ.mjs";
|
|
3
|
+
import path, { basename, dirname, relative } from "node:path";
|
|
4
|
+
import { minimatch } from "minimatch";
|
|
5
|
+
|
|
6
|
+
//#region src/utils/byte-size.ts
|
|
7
|
+
/**
|
|
8
|
+
* Used to learn the size of a string in bytes.
|
|
9
|
+
*
|
|
10
|
+
* @param str The string to measure
|
|
11
|
+
* @returns number
|
|
12
|
+
*/
|
|
13
|
+
const byteSize = (str) => Buffer.byteLength(str, "utf8");
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/utils/format-component-runtime-meta.ts
|
|
17
|
+
const formatLazyBundleRuntimeMeta = (bundleId, cmps) => {
|
|
18
|
+
return [bundleId, cmps.map((cmp) => formatComponentRuntimeMeta(cmp, true))];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Transform metadata about a component from the compiler to a compact form for
|
|
22
|
+
* use at runtime.
|
|
23
|
+
*
|
|
24
|
+
* @param compilerMeta component metadata gathered during compilation
|
|
25
|
+
* @param includeMethods include methods in the component's members or not
|
|
26
|
+
* @returns a compact format for component metadata, intended for runtime use
|
|
27
|
+
*/
|
|
28
|
+
const formatComponentRuntimeMeta = (compilerMeta, includeMethods) => {
|
|
29
|
+
let flags = 0;
|
|
30
|
+
if (compilerMeta.encapsulation === "shadow") {
|
|
31
|
+
flags |= CMP_FLAGS.shadowDomEncapsulation;
|
|
32
|
+
if (compilerMeta.shadowDelegatesFocus) flags |= CMP_FLAGS.shadowDelegatesFocus;
|
|
33
|
+
if (compilerMeta.slotAssignment === "manual") flags |= CMP_FLAGS.shadowSlotAssignmentManual;
|
|
34
|
+
} else if (compilerMeta.encapsulation === "scoped") flags |= CMP_FLAGS.scopedCssEncapsulation;
|
|
35
|
+
if (compilerMeta.formAssociated) flags |= CMP_FLAGS.formAssociated;
|
|
36
|
+
if (compilerMeta.encapsulation !== "shadow" && compilerMeta.htmlTagNames.includes("slot")) flags |= CMP_FLAGS.hasSlotRelocation;
|
|
37
|
+
if (compilerMeta.hasSlot) flags |= CMP_FLAGS.hasSlot;
|
|
38
|
+
if (compilerMeta.hasMode) flags |= CMP_FLAGS.hasMode;
|
|
39
|
+
if (compilerMeta.hasModernPropertyDecls) flags |= CMP_FLAGS.hasModernPropertyDecls;
|
|
40
|
+
const members = formatComponentRuntimeMembers(compilerMeta, includeMethods);
|
|
41
|
+
const hostListeners = formatHostListeners(compilerMeta);
|
|
42
|
+
const watchers = formatComponentRuntimeReactiveHandlers(compilerMeta, "watchers");
|
|
43
|
+
const serializers = formatComponentRuntimeReactiveHandlers(compilerMeta, "serializers");
|
|
44
|
+
const deserializers = formatComponentRuntimeReactiveHandlers(compilerMeta, "deserializers");
|
|
45
|
+
return trimFalsy([
|
|
46
|
+
flags,
|
|
47
|
+
compilerMeta.tagName,
|
|
48
|
+
Object.keys(members).length > 0 ? members : void 0,
|
|
49
|
+
hostListeners.length > 0 ? hostListeners : void 0,
|
|
50
|
+
Object.keys(watchers).length > 0 ? watchers : void 0,
|
|
51
|
+
Object.keys(serializers).length > 0 ? serializers : void 0,
|
|
52
|
+
Object.keys(deserializers).length > 0 ? deserializers : void 0
|
|
53
|
+
]);
|
|
54
|
+
};
|
|
55
|
+
const stringifyRuntimeData = (data) => {
|
|
56
|
+
const json = JSON.stringify(data);
|
|
57
|
+
if (json.length > 1e4) return `JSON.parse(${JSON.stringify(json)})`;
|
|
58
|
+
return json;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Transforms Stencil compiler metadata into a {@link d.ComponentCompilerMeta} object.
|
|
62
|
+
* This handles processing any compiler metadata transformed from components' uses of `@Watch()`, `@PropSerialize()`, and `@AttrDeserialize()`.
|
|
63
|
+
* The map of watched properties to their callback(s) will be immediately available
|
|
64
|
+
* to the runtime at bootstrap.
|
|
65
|
+
*
|
|
66
|
+
* @param compilerMeta Component metadata gathered during compilation
|
|
67
|
+
* @param decorator The decorator type to be processed: 'watchers', 'serializers', or 'deserializers'
|
|
68
|
+
* @returns An object mapping watched properties to their respective callback(s)
|
|
69
|
+
*/
|
|
70
|
+
const formatComponentRuntimeReactiveHandlers = (compilerMeta, decorator) => {
|
|
71
|
+
const handlers = {};
|
|
72
|
+
compilerMeta[decorator]?.forEach(({ propName, methodName, handlerOptions }) => {
|
|
73
|
+
let watcherFlags = 0;
|
|
74
|
+
if (handlerOptions?.immediate) watcherFlags |= WATCH_FLAGS.Immediate;
|
|
75
|
+
handlers[propName] = [...handlers[propName] ?? [], { [methodName]: watcherFlags }];
|
|
76
|
+
});
|
|
77
|
+
return handlers;
|
|
78
|
+
};
|
|
79
|
+
const formatComponentRuntimeMembers = (compilerMeta, includeMethods = true) => {
|
|
80
|
+
return {
|
|
81
|
+
...formatPropertiesRuntimeMember(compilerMeta.properties),
|
|
82
|
+
...formatStatesRuntimeMember(compilerMeta.states),
|
|
83
|
+
...includeMethods ? formatMethodsRuntimeMember(compilerMeta.methods) : {}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
const formatPropertiesRuntimeMember = (properties) => {
|
|
87
|
+
const runtimeMembers = {};
|
|
88
|
+
properties.forEach((member) => {
|
|
89
|
+
runtimeMembers[member.name] = trimFalsy([formatFlags(member), formatAttrName(member)]);
|
|
90
|
+
});
|
|
91
|
+
return runtimeMembers;
|
|
92
|
+
};
|
|
93
|
+
const formatFlags = (compilerProperty) => {
|
|
94
|
+
let type = formatPropType(compilerProperty.type);
|
|
95
|
+
if (compilerProperty.mutable) type |= MEMBER_FLAGS.Mutable;
|
|
96
|
+
if (compilerProperty.reflect) type |= MEMBER_FLAGS.ReflectAttr;
|
|
97
|
+
if (compilerProperty.getter) type |= MEMBER_FLAGS.Getter;
|
|
98
|
+
if (compilerProperty.setter) type |= MEMBER_FLAGS.Setter;
|
|
99
|
+
return type;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* We mainly add the alternative kebab-case attribute name because it might
|
|
103
|
+
* be used in an HTML environment (non JSX). Since we support hydration of
|
|
104
|
+
* complex types we provide a kebab-case attribute name for properties with
|
|
105
|
+
* these types.
|
|
106
|
+
*/
|
|
107
|
+
const kebabCaseSupportForTypes = ["string", "unknown"];
|
|
108
|
+
const formatAttrName = (compilerProperty) => {
|
|
109
|
+
if (kebabCaseSupportForTypes.includes(typeof compilerProperty.attribute)) {
|
|
110
|
+
if (compilerProperty.name === compilerProperty.attribute) return;
|
|
111
|
+
return compilerProperty.attribute;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const formatPropType = (type) => {
|
|
115
|
+
if (type === "string") return MEMBER_FLAGS.String;
|
|
116
|
+
if (type === "number") return MEMBER_FLAGS.Number;
|
|
117
|
+
if (type === "boolean") return MEMBER_FLAGS.Boolean;
|
|
118
|
+
if (type === "any") return MEMBER_FLAGS.Any;
|
|
119
|
+
return MEMBER_FLAGS.Unknown;
|
|
120
|
+
};
|
|
121
|
+
const formatStatesRuntimeMember = (states) => {
|
|
122
|
+
const runtimeMembers = {};
|
|
123
|
+
states.forEach((member) => {
|
|
124
|
+
runtimeMembers[member.name] = [MEMBER_FLAGS.State];
|
|
125
|
+
});
|
|
126
|
+
return runtimeMembers;
|
|
127
|
+
};
|
|
128
|
+
const formatMethodsRuntimeMember = (methods) => {
|
|
129
|
+
const runtimeMembers = {};
|
|
130
|
+
methods.forEach((member) => {
|
|
131
|
+
runtimeMembers[member.name] = [MEMBER_FLAGS.Method];
|
|
132
|
+
});
|
|
133
|
+
return runtimeMembers;
|
|
134
|
+
};
|
|
135
|
+
const formatHostListeners = (compilerMeta) => {
|
|
136
|
+
return compilerMeta.listeners.map((compilerListener) => {
|
|
137
|
+
return [
|
|
138
|
+
computeListenerFlags(compilerListener),
|
|
139
|
+
compilerListener.name,
|
|
140
|
+
compilerListener.method
|
|
141
|
+
];
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
const computeListenerFlags = (listener) => {
|
|
145
|
+
let flags = 0;
|
|
146
|
+
if (listener.capture) flags |= LISTENER_FLAGS.Capture;
|
|
147
|
+
if (listener.passive) flags |= LISTENER_FLAGS.Passive;
|
|
148
|
+
switch (listener.target) {
|
|
149
|
+
case "document":
|
|
150
|
+
flags |= LISTENER_FLAGS.TargetDocument;
|
|
151
|
+
break;
|
|
152
|
+
case "window":
|
|
153
|
+
flags |= LISTENER_FLAGS.TargetWindow;
|
|
154
|
+
break;
|
|
155
|
+
case "body":
|
|
156
|
+
flags |= LISTENER_FLAGS.TargetBody;
|
|
157
|
+
break;
|
|
158
|
+
case "parent":
|
|
159
|
+
flags |= LISTENER_FLAGS.TargetParent;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
return flags;
|
|
163
|
+
};
|
|
164
|
+
const trimFalsy = (data) => {
|
|
165
|
+
const arr = data;
|
|
166
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
167
|
+
if (arr[i]) break;
|
|
168
|
+
arr.pop();
|
|
169
|
+
}
|
|
170
|
+
return arr;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/utils/is-glob.ts
|
|
175
|
+
/**
|
|
176
|
+
* Check if a string is a glob pattern (e.g. 'src/*.js' or something like that)
|
|
177
|
+
*
|
|
178
|
+
* @param str a string to check
|
|
179
|
+
* @returns whether the string is a glob pattern or not
|
|
180
|
+
*/
|
|
181
|
+
const isGlob = (str) => {
|
|
182
|
+
const chars = {
|
|
183
|
+
"{": "}",
|
|
184
|
+
"(": ")",
|
|
185
|
+
"[": "]"
|
|
186
|
+
};
|
|
187
|
+
const regex = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/;
|
|
188
|
+
if (str === "") return false;
|
|
189
|
+
let match;
|
|
190
|
+
while (match = regex.exec(str)) {
|
|
191
|
+
if (match[2]) return true;
|
|
192
|
+
let idx = match.index + match[0].length;
|
|
193
|
+
const open = match[1];
|
|
194
|
+
const close = open ? chars[open] : null;
|
|
195
|
+
if (open && close) {
|
|
196
|
+
const n = str.indexOf(close, idx);
|
|
197
|
+
if (n !== -1) idx = n + 1;
|
|
198
|
+
}
|
|
199
|
+
str = str.slice(idx);
|
|
200
|
+
}
|
|
201
|
+
return false;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/utils/is-root-path.ts
|
|
206
|
+
/**
|
|
207
|
+
* Checks if the path is the Operating System (OS) root path, such as "/" or "C:\". This function does not take the OS
|
|
208
|
+
* the code is running on into account when performing this evaluation.
|
|
209
|
+
* @param p the path to check
|
|
210
|
+
* @returns `true` if the path is an OS root path, `false` otherwise
|
|
211
|
+
*/
|
|
212
|
+
const isRootPath = (p) => p === "/" || windowsPathRegex.test(p);
|
|
213
|
+
const windowsPathRegex = /^(?:[a-zA-Z]:|[\\/]{2}[^\\/]+[\\/]+[^\\/]+)?[\\/]$/;
|
|
214
|
+
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region src/utils/message-utils.ts
|
|
217
|
+
/**
|
|
218
|
+
* Builds a template `Diagnostic` entity for a build error. The created `Diagnostic` is returned, and have little
|
|
219
|
+
* detail attached to it regarding the specifics of the error - it is the responsibility of the caller of this method
|
|
220
|
+
* to attach the specifics of the error message.
|
|
221
|
+
*
|
|
222
|
+
* The created `Diagnostic` is pushed to the `diagnostics` argument as a side effect of calling this method.
|
|
223
|
+
*
|
|
224
|
+
* @param diagnostics the existing diagnostics that the created template `Diagnostic` should be added to
|
|
225
|
+
* @returns the created `Diagnostic`
|
|
226
|
+
*/
|
|
227
|
+
const buildError = (diagnostics) => {
|
|
228
|
+
const diagnostic = {
|
|
229
|
+
level: "error",
|
|
230
|
+
type: "build",
|
|
231
|
+
header: "Build Error",
|
|
232
|
+
messageText: "build error",
|
|
233
|
+
relFilePath: void 0,
|
|
234
|
+
absFilePath: void 0,
|
|
235
|
+
lines: []
|
|
236
|
+
};
|
|
237
|
+
if (diagnostics) diagnostics.push(diagnostic);
|
|
238
|
+
return diagnostic;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Builds a template `Diagnostic` entity for a build warning. The created `Diagnostic` is returned, and have little
|
|
242
|
+
* detail attached to it regarding the specifics of the warning - it is the responsibility of the caller of this method
|
|
243
|
+
* to attach the specifics of the warning message.
|
|
244
|
+
*
|
|
245
|
+
* The created `Diagnostic` is pushed to the `diagnostics` argument as a side effect of calling this method.
|
|
246
|
+
*
|
|
247
|
+
* @param diagnostics the existing diagnostics that the created template `Diagnostic` should be added to
|
|
248
|
+
* @returns the created `Diagnostic`
|
|
249
|
+
*/
|
|
250
|
+
const buildWarn = (diagnostics) => {
|
|
251
|
+
const diagnostic = {
|
|
252
|
+
level: "warn",
|
|
253
|
+
type: "build",
|
|
254
|
+
header: "Build Warn",
|
|
255
|
+
messageText: "build warn",
|
|
256
|
+
lines: []
|
|
257
|
+
};
|
|
258
|
+
diagnostics.push(diagnostic);
|
|
259
|
+
return diagnostic;
|
|
260
|
+
};
|
|
261
|
+
/**
|
|
262
|
+
* Create a diagnostic message suited for representing an error in a JSON
|
|
263
|
+
* file. This includes information about the exact lines in the JSON file which
|
|
264
|
+
* caused the error and the path to the file.
|
|
265
|
+
*
|
|
266
|
+
* @param compilerCtx the current compiler context
|
|
267
|
+
* @param diagnostics a list of diagnostics used as a return param
|
|
268
|
+
* @param jsonFilePath the path to the JSON file where the error occurred
|
|
269
|
+
* @param msg the error message
|
|
270
|
+
* @param jsonField the key for the field which caused the error, used for finding
|
|
271
|
+
* the error line in the original JSON file
|
|
272
|
+
* @returns a reference to the newly-created diagnostic
|
|
273
|
+
*/
|
|
274
|
+
const buildJsonFileError = (compilerCtx, diagnostics, jsonFilePath, msg, jsonField) => {
|
|
275
|
+
const err = buildError(diagnostics);
|
|
276
|
+
err.messageText = msg;
|
|
277
|
+
err.absFilePath = jsonFilePath;
|
|
278
|
+
if (typeof jsonField === "string") try {
|
|
279
|
+
const lines = compilerCtx.fs.readFileSync(jsonFilePath).replace(/\r/g, "\n").split("\n");
|
|
280
|
+
for (let i = 0; i < lines.length; i++) {
|
|
281
|
+
const txtLine = lines[i];
|
|
282
|
+
const txtIndex = txtLine.indexOf(jsonField);
|
|
283
|
+
if (txtIndex > -1) {
|
|
284
|
+
const warnLine = {
|
|
285
|
+
lineIndex: i,
|
|
286
|
+
lineNumber: i + 1,
|
|
287
|
+
text: txtLine,
|
|
288
|
+
errorCharStart: txtIndex,
|
|
289
|
+
errorLength: jsonField.length
|
|
290
|
+
};
|
|
291
|
+
err.lineNumber = warnLine.lineNumber;
|
|
292
|
+
err.columnNumber = txtIndex + 1;
|
|
293
|
+
err.lines.push(warnLine);
|
|
294
|
+
if (i >= 0) {
|
|
295
|
+
const beforeWarnLine = {
|
|
296
|
+
lineIndex: warnLine.lineIndex - 1,
|
|
297
|
+
lineNumber: warnLine.lineNumber - 1,
|
|
298
|
+
text: lines[i - 1],
|
|
299
|
+
errorCharStart: -1,
|
|
300
|
+
errorLength: -1
|
|
301
|
+
};
|
|
302
|
+
err.lines.unshift(beforeWarnLine);
|
|
303
|
+
}
|
|
304
|
+
if (i < lines.length) {
|
|
305
|
+
const afterWarnLine = {
|
|
306
|
+
lineIndex: warnLine.lineIndex + 1,
|
|
307
|
+
lineNumber: warnLine.lineNumber + 1,
|
|
308
|
+
text: lines[i + 1],
|
|
309
|
+
errorCharStart: -1,
|
|
310
|
+
errorLength: -1
|
|
311
|
+
};
|
|
312
|
+
err.lines.push(afterWarnLine);
|
|
313
|
+
}
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
} catch (e) {}
|
|
318
|
+
return err;
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* Builds a diagnostic from an `Error`, appends it to the `diagnostics` parameter, and returns the created diagnostic
|
|
322
|
+
* @param diagnostics the series of diagnostics the newly created diagnostics should be added to
|
|
323
|
+
* @param err the error to derive information from in generating the diagnostic
|
|
324
|
+
* @param msg an optional message to use in place of `err` to generate the diagnostic
|
|
325
|
+
* @returns the generated diagnostic
|
|
326
|
+
*/
|
|
327
|
+
const catchError = (diagnostics, err, msg) => {
|
|
328
|
+
const diagnostic = {
|
|
329
|
+
level: "error",
|
|
330
|
+
type: "build",
|
|
331
|
+
header: "Build Error",
|
|
332
|
+
messageText: "build error",
|
|
333
|
+
lines: []
|
|
334
|
+
};
|
|
335
|
+
if (isString(msg)) diagnostic.messageText = msg.length ? msg : "UNKNOWN ERROR";
|
|
336
|
+
else if (err != null) if (err.stack != null) diagnostic.messageText = err.stack.toString();
|
|
337
|
+
else if (err.message != null) diagnostic.messageText = err.message.length ? err.message : "UNKNOWN ERROR";
|
|
338
|
+
else diagnostic.messageText = err.toString();
|
|
339
|
+
if (diagnostics != null && !shouldIgnoreError(diagnostic.messageText)) diagnostics.push(diagnostic);
|
|
340
|
+
return diagnostic;
|
|
341
|
+
};
|
|
342
|
+
/**
|
|
343
|
+
* Determine if the provided diagnostics have any build errors
|
|
344
|
+
* @param diagnostics the diagnostics to inspect
|
|
345
|
+
* @returns true if any of the diagnostics in the list provided are errors that did not occur at runtime. false
|
|
346
|
+
* otherwise.
|
|
347
|
+
*/
|
|
348
|
+
const hasError = (diagnostics) => {
|
|
349
|
+
if (diagnostics == null || diagnostics.length === 0) return false;
|
|
350
|
+
return diagnostics.some((d) => d.level === "error" && d.type !== "runtime");
|
|
351
|
+
};
|
|
352
|
+
/**
|
|
353
|
+
* Determine if the provided diagnostics have any warnings
|
|
354
|
+
* @param diagnostics the diagnostics to inspect
|
|
355
|
+
* @returns true if any of the diagnostics in the list provided are warnings. false otherwise.
|
|
356
|
+
*/
|
|
357
|
+
const hasWarning = (diagnostics) => {
|
|
358
|
+
if (diagnostics == null || diagnostics.length === 0) return false;
|
|
359
|
+
return diagnostics.some((d) => d.level === "warn");
|
|
360
|
+
};
|
|
361
|
+
const shouldIgnoreError = (msg) => {
|
|
362
|
+
return msg === TASK_CANCELED_MSG;
|
|
363
|
+
};
|
|
364
|
+
const TASK_CANCELED_MSG = `task canceled`;
|
|
365
|
+
|
|
366
|
+
//#endregion
|
|
367
|
+
//#region src/utils/logger/logger-utils.ts
|
|
368
|
+
/**
|
|
369
|
+
* Iterate through a series of diagnostics to provide minor fix-ups for various edge cases, deduplicate messages, etc.
|
|
370
|
+
* @param compilerCtx the current compiler context
|
|
371
|
+
* @param diagnostics the diagnostics to normalize
|
|
372
|
+
* @returns the normalize documents
|
|
373
|
+
*/
|
|
374
|
+
const normalizeDiagnostics = (compilerCtx, diagnostics) => {
|
|
375
|
+
const maxErrorsToNormalize = 25;
|
|
376
|
+
const normalizedErrors = [];
|
|
377
|
+
const normalizedOthers = [];
|
|
378
|
+
const dups = /* @__PURE__ */ new Set();
|
|
379
|
+
for (let i = 0; i < diagnostics.length; i++) {
|
|
380
|
+
const diagnostic = normalizeDiagnostic(compilerCtx, diagnostics[i]);
|
|
381
|
+
const key = (diagnostic.absFilePath ?? "") + (diagnostic.code ?? "") + diagnostic.messageText + diagnostic.type;
|
|
382
|
+
if (dups.has(key)) continue;
|
|
383
|
+
dups.add(key);
|
|
384
|
+
const total = normalizedErrors.length + normalizedOthers.length;
|
|
385
|
+
if (diagnostic.level === "error") normalizedErrors.push(diagnostic);
|
|
386
|
+
else if (total < maxErrorsToNormalize) normalizedOthers.push(diagnostic);
|
|
387
|
+
}
|
|
388
|
+
return [...normalizedErrors, ...normalizedOthers];
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* Perform post-processing on a `Diagnostic` to handle a few message edge cases, massaging error message text and
|
|
392
|
+
* updating build failure contexts
|
|
393
|
+
* @param compilerCtx the current compiler
|
|
394
|
+
* @param diagnostic the diagnostic to normalize
|
|
395
|
+
* @returns the altered diagnostic
|
|
396
|
+
*/
|
|
397
|
+
const normalizeDiagnostic = (compilerCtx, diagnostic) => {
|
|
398
|
+
if (diagnostic.messageText) {
|
|
399
|
+
if (typeof diagnostic.messageText.message === "string") diagnostic.messageText = diagnostic.messageText.message;
|
|
400
|
+
else if (typeof diagnostic.messageText === "string" && diagnostic.messageText.indexOf("Error: ") === 0) diagnostic.messageText = diagnostic.messageText.slice(7);
|
|
401
|
+
}
|
|
402
|
+
if (diagnostic.messageText) {
|
|
403
|
+
if (diagnostic.messageText.includes(`Cannot find name 'h'`)) {
|
|
404
|
+
diagnostic.header = `Missing "h" import for JSX types`;
|
|
405
|
+
diagnostic.messageText = `In order to load accurate JSX types for components, the "h" function must be imported from "@stencil/core" by each component using JSX. For example: import { Component, h } from '@stencil/core';`;
|
|
406
|
+
if (diagnostic.absFilePath) try {
|
|
407
|
+
const srcLines = splitLineBreaks(compilerCtx.fs.readFileSync(diagnostic.absFilePath));
|
|
408
|
+
for (let i = 0; i < srcLines.length; i++) {
|
|
409
|
+
const srcLine = srcLines[i];
|
|
410
|
+
if (srcLine.includes("@stencil/core")) {
|
|
411
|
+
const msgLines = [];
|
|
412
|
+
const beforeLineIndex = i - 1;
|
|
413
|
+
if (beforeLineIndex > -1) {
|
|
414
|
+
const beforeLine = {
|
|
415
|
+
lineIndex: beforeLineIndex,
|
|
416
|
+
lineNumber: beforeLineIndex + 1,
|
|
417
|
+
text: srcLines[beforeLineIndex],
|
|
418
|
+
errorCharStart: -1,
|
|
419
|
+
errorLength: -1
|
|
420
|
+
};
|
|
421
|
+
msgLines.push(beforeLine);
|
|
422
|
+
}
|
|
423
|
+
const errorLine = {
|
|
424
|
+
lineIndex: i,
|
|
425
|
+
lineNumber: i + 1,
|
|
426
|
+
text: srcLine,
|
|
427
|
+
errorCharStart: 0,
|
|
428
|
+
errorLength: -1
|
|
429
|
+
};
|
|
430
|
+
msgLines.push(errorLine);
|
|
431
|
+
diagnostic.lineNumber = errorLine.lineNumber;
|
|
432
|
+
diagnostic.columnNumber = srcLine.indexOf("}");
|
|
433
|
+
const afterLineIndex = i + 1;
|
|
434
|
+
if (afterLineIndex < srcLines.length) {
|
|
435
|
+
const afterLine = {
|
|
436
|
+
lineIndex: afterLineIndex,
|
|
437
|
+
lineNumber: afterLineIndex + 1,
|
|
438
|
+
text: srcLines[afterLineIndex],
|
|
439
|
+
errorCharStart: -1,
|
|
440
|
+
errorLength: -1
|
|
441
|
+
};
|
|
442
|
+
msgLines.push(afterLine);
|
|
443
|
+
}
|
|
444
|
+
diagnostic.lines = msgLines;
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
} catch (e) {}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return diagnostic;
|
|
452
|
+
};
|
|
453
|
+
/**
|
|
454
|
+
* Split a corpus by newlines. Carriage returns are treated a newlines.
|
|
455
|
+
* @param sourceText the corpus to split
|
|
456
|
+
* @returns the split text
|
|
457
|
+
*/
|
|
458
|
+
const splitLineBreaks = (sourceText) => {
|
|
459
|
+
if (typeof sourceText !== "string") return [];
|
|
460
|
+
sourceText = sourceText.replace(/\\r/g, "\n");
|
|
461
|
+
return sourceText.split("\n");
|
|
462
|
+
};
|
|
463
|
+
const escapeHtml = (unsafe) => {
|
|
464
|
+
if (unsafe === void 0) return "undefined";
|
|
465
|
+
if (unsafe === null) return "null";
|
|
466
|
+
if (typeof unsafe !== "string") unsafe = unsafe.toString();
|
|
467
|
+
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
//#endregion
|
|
471
|
+
//#region src/utils/logger/logger-rollup.ts
|
|
472
|
+
const loadRollupDiagnostics = (config, compilerCtx, buildCtx, rollupError) => {
|
|
473
|
+
const formattedCode = formatErrorCode(rollupError.code);
|
|
474
|
+
const diagnostic = {
|
|
475
|
+
level: "error",
|
|
476
|
+
type: "bundling",
|
|
477
|
+
language: "javascript",
|
|
478
|
+
code: rollupError.code,
|
|
479
|
+
header: `Rollup${formattedCode.length > 0 ? ": " + formattedCode : ""}`,
|
|
480
|
+
messageText: formattedCode,
|
|
481
|
+
relFilePath: void 0,
|
|
482
|
+
absFilePath: void 0,
|
|
483
|
+
lines: []
|
|
484
|
+
};
|
|
485
|
+
if (config.logLevel === "debug" && rollupError.stack) diagnostic.messageText = rollupError.stack;
|
|
486
|
+
else if (rollupError.message) diagnostic.messageText = rollupError.message;
|
|
487
|
+
if (rollupError.plugin) diagnostic.messageText += ` (plugin: ${rollupError.plugin}${rollupError.hook ? `, ${rollupError.hook}` : ""})`;
|
|
488
|
+
const loc = rollupError.loc;
|
|
489
|
+
if (loc != null) {
|
|
490
|
+
const srcFile = loc.file || rollupError.id;
|
|
491
|
+
if (isString(srcFile)) try {
|
|
492
|
+
const sourceText = compilerCtx.fs.readFileSync(srcFile);
|
|
493
|
+
if (sourceText) {
|
|
494
|
+
diagnostic.absFilePath = srcFile;
|
|
495
|
+
try {
|
|
496
|
+
const srcLines = splitLineBreaks(sourceText);
|
|
497
|
+
const errorLine = {
|
|
498
|
+
lineIndex: loc.line - 1,
|
|
499
|
+
lineNumber: loc.line,
|
|
500
|
+
text: srcLines[loc.line - 1],
|
|
501
|
+
errorCharStart: loc.column,
|
|
502
|
+
errorLength: 0
|
|
503
|
+
};
|
|
504
|
+
diagnostic.lineNumber = errorLine.lineNumber;
|
|
505
|
+
diagnostic.columnNumber = errorLine.errorCharStart;
|
|
506
|
+
const highlightLine = errorLine.text?.slice(loc.column) ?? "";
|
|
507
|
+
for (let i = 0; i < highlightLine.length; i++) {
|
|
508
|
+
if (charBreak.has(highlightLine.charAt(i))) break;
|
|
509
|
+
errorLine.errorLength++;
|
|
510
|
+
}
|
|
511
|
+
diagnostic.lines.push(errorLine);
|
|
512
|
+
if (errorLine.errorLength === 0 && errorLine.errorCharStart > 0) {
|
|
513
|
+
errorLine.errorLength = 1;
|
|
514
|
+
errorLine.errorCharStart--;
|
|
515
|
+
}
|
|
516
|
+
if (errorLine.lineIndex > 0) {
|
|
517
|
+
const previousLine = {
|
|
518
|
+
lineIndex: errorLine.lineIndex - 1,
|
|
519
|
+
lineNumber: errorLine.lineNumber - 1,
|
|
520
|
+
text: srcLines[errorLine.lineIndex - 1],
|
|
521
|
+
errorCharStart: -1,
|
|
522
|
+
errorLength: -1
|
|
523
|
+
};
|
|
524
|
+
diagnostic.lines.unshift(previousLine);
|
|
525
|
+
}
|
|
526
|
+
if (errorLine.lineIndex + 1 < srcLines.length) {
|
|
527
|
+
const nextLine = {
|
|
528
|
+
lineIndex: errorLine.lineIndex + 1,
|
|
529
|
+
lineNumber: errorLine.lineNumber + 1,
|
|
530
|
+
text: srcLines[errorLine.lineIndex + 1],
|
|
531
|
+
errorCharStart: -1,
|
|
532
|
+
errorLength: -1
|
|
533
|
+
};
|
|
534
|
+
diagnostic.lines.push(nextLine);
|
|
535
|
+
}
|
|
536
|
+
} catch (e) {
|
|
537
|
+
diagnostic.messageText += `\nError parsing: ${diagnostic.absFilePath}, line: ${loc.line}, column: ${loc.column}`;
|
|
538
|
+
diagnostic.debugText = sourceText;
|
|
539
|
+
}
|
|
540
|
+
} else if (typeof rollupError.frame === "string") diagnostic.messageText += "\n" + rollupError.frame;
|
|
541
|
+
} catch (e) {}
|
|
542
|
+
}
|
|
543
|
+
buildCtx.diagnostics.push(diagnostic);
|
|
544
|
+
};
|
|
545
|
+
const createOnWarnFn = (diagnostics, bundleModulesFiles) => {
|
|
546
|
+
const previousWarns = /* @__PURE__ */ new Set();
|
|
547
|
+
return function onWarningMessage(warning) {
|
|
548
|
+
if (warning == null || warning.code && ignoreWarnCodes.has(warning.code) || warning.message && previousWarns.has(warning.message)) return;
|
|
549
|
+
if (warning.message) previousWarns.add(warning.message);
|
|
550
|
+
let label = "";
|
|
551
|
+
if (bundleModulesFiles) {
|
|
552
|
+
label = bundleModulesFiles.reduce((cmps, m) => {
|
|
553
|
+
cmps.push(...m.cmps);
|
|
554
|
+
return cmps;
|
|
555
|
+
}, []).join(", ").trim();
|
|
556
|
+
if (label.length) label += ": ";
|
|
557
|
+
}
|
|
558
|
+
const diagnostic = buildWarn(diagnostics);
|
|
559
|
+
diagnostic.header = `Bundling Warning ${warning.code}`;
|
|
560
|
+
diagnostic.messageText = label + (warning.message || warning);
|
|
561
|
+
};
|
|
562
|
+
};
|
|
563
|
+
const ignoreWarnCodes = new Set([
|
|
564
|
+
"THIS_IS_UNDEFINED",
|
|
565
|
+
"NON_EXISTENT_EXPORT",
|
|
566
|
+
"CIRCULAR_DEPENDENCY",
|
|
567
|
+
"EMPTY_BUNDLE",
|
|
568
|
+
"UNUSED_EXTERNAL_IMPORT"
|
|
569
|
+
]);
|
|
570
|
+
const charBreak = new Set([
|
|
571
|
+
" ",
|
|
572
|
+
"=",
|
|
573
|
+
".",
|
|
574
|
+
",",
|
|
575
|
+
"?",
|
|
576
|
+
":",
|
|
577
|
+
";",
|
|
578
|
+
"(",
|
|
579
|
+
")",
|
|
580
|
+
"{",
|
|
581
|
+
"}",
|
|
582
|
+
"[",
|
|
583
|
+
"]",
|
|
584
|
+
"|",
|
|
585
|
+
`'`,
|
|
586
|
+
`"`,
|
|
587
|
+
"`"
|
|
588
|
+
]);
|
|
589
|
+
const formatErrorCode = (errorCode) => {
|
|
590
|
+
if (typeof errorCode === "string") return errorCode.split("_").map((c) => {
|
|
591
|
+
return toTitleCase(c.toLowerCase());
|
|
592
|
+
}).join(" ");
|
|
593
|
+
return (errorCode || "").trim();
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
//#endregion
|
|
597
|
+
//#region src/utils/path.ts
|
|
598
|
+
/**
|
|
599
|
+
* Convert Windows backslash paths to slash paths: foo\\bar ➔ foo/bar
|
|
600
|
+
* Forward-slash paths can be used in Windows as long as they're not
|
|
601
|
+
* extended-length paths and don't contain any non-ascii characters.
|
|
602
|
+
* This was created since the path methods in Node.js outputs \\ paths on Windows.
|
|
603
|
+
* @param path the Windows-based path to convert
|
|
604
|
+
* @param relativize whether or not a relative path should have `./` prepended
|
|
605
|
+
* @returns the converted path
|
|
606
|
+
*/
|
|
607
|
+
const normalizePath = (path, relativize = true) => {
|
|
608
|
+
if (typeof path !== "string") throw new Error(`invalid path to normalize`);
|
|
609
|
+
path = normalizeSlashes(path.trim());
|
|
610
|
+
const reducedComponents = reducePathComponents(pathComponents(path, getRootLength(path)));
|
|
611
|
+
const rootPart = reducedComponents[0];
|
|
612
|
+
const secondPart = reducedComponents[1];
|
|
613
|
+
const normalized = rootPart + reducedComponents.slice(1).join("/");
|
|
614
|
+
if (normalized === "") return ".";
|
|
615
|
+
if (rootPart === "" && secondPart && path.includes("/") && !secondPart.startsWith(".") && !secondPart.startsWith("@") && relativize) return "./" + normalized;
|
|
616
|
+
return normalized;
|
|
617
|
+
};
|
|
618
|
+
const normalizeSlashes = (path) => path.replace(backslashRegExp, "/");
|
|
619
|
+
const altDirectorySeparator = "\\";
|
|
620
|
+
const urlSchemeSeparator = "://";
|
|
621
|
+
const backslashRegExp = /\\/g;
|
|
622
|
+
const reducePathComponents = (components) => {
|
|
623
|
+
if (!Array.isArray(components) || components.length === 0) return [];
|
|
624
|
+
const reduced = [components[0]];
|
|
625
|
+
for (let i = 1; i < components.length; i++) {
|
|
626
|
+
const component = components[i];
|
|
627
|
+
if (!component) continue;
|
|
628
|
+
if (component === ".") continue;
|
|
629
|
+
if (component === "..") {
|
|
630
|
+
if (reduced.length > 1) {
|
|
631
|
+
if (reduced[reduced.length - 1] !== "..") {
|
|
632
|
+
reduced.pop();
|
|
633
|
+
continue;
|
|
634
|
+
}
|
|
635
|
+
} else if (reduced[0]) continue;
|
|
636
|
+
}
|
|
637
|
+
reduced.push(component);
|
|
638
|
+
}
|
|
639
|
+
return reduced;
|
|
640
|
+
};
|
|
641
|
+
const getRootLength = (path) => {
|
|
642
|
+
const rootLength = getEncodedRootLength(path);
|
|
643
|
+
return rootLength < 0 ? ~rootLength : rootLength;
|
|
644
|
+
};
|
|
645
|
+
const getEncodedRootLength = (path) => {
|
|
646
|
+
if (!path) return 0;
|
|
647
|
+
const ch0 = path.charCodeAt(0);
|
|
648
|
+
if (ch0 === CharacterCodes.slash || ch0 === CharacterCodes.backslash) {
|
|
649
|
+
if (path.charCodeAt(1) !== ch0) return 1;
|
|
650
|
+
const p1 = path.indexOf(ch0 === CharacterCodes.slash ? "/" : altDirectorySeparator, 2);
|
|
651
|
+
if (p1 < 0) return path.length;
|
|
652
|
+
return p1 + 1;
|
|
653
|
+
}
|
|
654
|
+
if (isVolumeCharacter(ch0) && path.charCodeAt(1) === CharacterCodes.colon) {
|
|
655
|
+
const ch2 = path.charCodeAt(2);
|
|
656
|
+
if (ch2 === CharacterCodes.slash || ch2 === CharacterCodes.backslash) return 3;
|
|
657
|
+
if (path.length === 2) return 2;
|
|
658
|
+
}
|
|
659
|
+
const schemeEnd = path.indexOf(urlSchemeSeparator);
|
|
660
|
+
if (schemeEnd !== -1) {
|
|
661
|
+
const authorityStart = schemeEnd + 3;
|
|
662
|
+
const authorityEnd = path.indexOf("/", authorityStart);
|
|
663
|
+
if (authorityEnd !== -1) {
|
|
664
|
+
const scheme = path.slice(0, schemeEnd);
|
|
665
|
+
const authority = path.slice(authorityStart, authorityEnd);
|
|
666
|
+
if (scheme === "file" && (authority === "" || authority === "localhost") && isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
|
|
667
|
+
const volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
|
|
668
|
+
if (volumeSeparatorEnd !== -1) {
|
|
669
|
+
if (path.charCodeAt(volumeSeparatorEnd) === CharacterCodes.slash) return ~(volumeSeparatorEnd + 1);
|
|
670
|
+
if (volumeSeparatorEnd === path.length) return ~volumeSeparatorEnd;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
return ~(authorityEnd + 1);
|
|
674
|
+
}
|
|
675
|
+
return ~path.length;
|
|
676
|
+
}
|
|
677
|
+
return 0;
|
|
678
|
+
};
|
|
679
|
+
const isVolumeCharacter = (charCode) => charCode >= CharacterCodes.a && charCode <= CharacterCodes.z || charCode >= CharacterCodes.A && charCode <= CharacterCodes.Z;
|
|
680
|
+
const getFileUrlVolumeSeparatorEnd = (url, start) => {
|
|
681
|
+
const ch0 = url.charCodeAt(start);
|
|
682
|
+
if (ch0 === CharacterCodes.colon) return start + 1;
|
|
683
|
+
if (ch0 === CharacterCodes.percent && url.charCodeAt(start + 1) === CharacterCodes._3) {
|
|
684
|
+
const ch2 = url.charCodeAt(start + 2);
|
|
685
|
+
if (ch2 === CharacterCodes.a || ch2 === CharacterCodes.A) return start + 3;
|
|
686
|
+
}
|
|
687
|
+
return -1;
|
|
688
|
+
};
|
|
689
|
+
const pathComponents = (path, rootLength) => {
|
|
690
|
+
const root = path.substring(0, rootLength);
|
|
691
|
+
const rest = path.substring(rootLength).split("/");
|
|
692
|
+
const restLen = rest.length;
|
|
693
|
+
if (restLen > 0 && !rest[restLen - 1]) rest.pop();
|
|
694
|
+
return [root, ...rest];
|
|
695
|
+
};
|
|
696
|
+
/**
|
|
697
|
+
* Same as normalizePath(), expect it'll also strip any query strings
|
|
698
|
+
* from the path name. So /dir/file.css?tag=cmp-a becomes /dir/file.css
|
|
699
|
+
* @param p the path to normalize
|
|
700
|
+
* @returns the normalized path, sans any query strings
|
|
701
|
+
*/
|
|
702
|
+
const normalizeFsPath = (p) => normalizePath(p.split("?")[0].replace(/\0/g, ""));
|
|
703
|
+
const normalizeFsPathQuery = (importPath) => {
|
|
704
|
+
const pathParts = importPath.split("?");
|
|
705
|
+
const filePath = normalizePath(pathParts[0]);
|
|
706
|
+
const filePathParts = filePath.split(".");
|
|
707
|
+
const ext = filePathParts.length > 1 ? filePathParts.pop().toLowerCase() : null;
|
|
708
|
+
const params = pathParts.length > 1 ? new URLSearchParams(pathParts[1]) : null;
|
|
709
|
+
return {
|
|
710
|
+
filePath,
|
|
711
|
+
ext,
|
|
712
|
+
format: params ? params.get("format") : null
|
|
713
|
+
};
|
|
714
|
+
};
|
|
715
|
+
var CharacterCodes = /* @__PURE__ */ function(CharacterCodes) {
|
|
716
|
+
CharacterCodes[CharacterCodes["a"] = 97] = "a";
|
|
717
|
+
CharacterCodes[CharacterCodes["A"] = 65] = "A";
|
|
718
|
+
CharacterCodes[CharacterCodes["z"] = 122] = "z";
|
|
719
|
+
CharacterCodes[CharacterCodes["Z"] = 90] = "Z";
|
|
720
|
+
CharacterCodes[CharacterCodes["_3"] = 51] = "_3";
|
|
721
|
+
CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash";
|
|
722
|
+
CharacterCodes[CharacterCodes["colon"] = 58] = "colon";
|
|
723
|
+
CharacterCodes[CharacterCodes["dot"] = 46] = "dot";
|
|
724
|
+
CharacterCodes[CharacterCodes["percent"] = 37] = "percent";
|
|
725
|
+
CharacterCodes[CharacterCodes["slash"] = 47] = "slash";
|
|
726
|
+
return CharacterCodes;
|
|
727
|
+
}(CharacterCodes || {});
|
|
728
|
+
/**
|
|
729
|
+
* A wrapped version of node.js' {@link path.relative} which adds our custom
|
|
730
|
+
* normalization logic. This solves the relative path between `from` and `to`!
|
|
731
|
+
*
|
|
732
|
+
* The calculation of the returned path follows that of Node's logic, with one exception - if the calculated path
|
|
733
|
+
* results in an empty string, a string of length one with a period (`'.'`) is returned.
|
|
734
|
+
*
|
|
735
|
+
* @throws the underlying node.js function can throw if either path is not a
|
|
736
|
+
* string
|
|
737
|
+
* @param from the path where relative resolution starts
|
|
738
|
+
* @param to the destination path
|
|
739
|
+
* @returns the resolved relative path
|
|
740
|
+
*/
|
|
741
|
+
function relative$1(from, to) {
|
|
742
|
+
/**
|
|
743
|
+
* When normalizing, we should _not_ attempt to relativize the path returned by the native Node `relative` method.
|
|
744
|
+
* When finding the relative path between `from` and `to`, Node does not prepend './' to a non-zero length calculated
|
|
745
|
+
* path. However, our algorithm does differ from that of Node's, as described in this function's JSDoc when a zero
|
|
746
|
+
* length string is encountered.
|
|
747
|
+
*/
|
|
748
|
+
return normalizePath(path.relative(from, to), false);
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* A wrapped version of node.js' {@link path.join} which adds our custom
|
|
752
|
+
* normalization logic. This joins all the arguments (path fragments) into a
|
|
753
|
+
* single path.
|
|
754
|
+
*
|
|
755
|
+
* The calculation of the returned path follows that of Node's logic, with one exception - any trailing slashes will
|
|
756
|
+
* be removed from the calculated path.
|
|
757
|
+
*
|
|
758
|
+
* @throws the underlying node function will throw if any argument is not a
|
|
759
|
+
* string
|
|
760
|
+
* @param paths the paths to join together
|
|
761
|
+
* @returns a joined path!
|
|
762
|
+
*/
|
|
763
|
+
function join$1(...paths) {
|
|
764
|
+
/**
|
|
765
|
+
* When normalizing, we should _not_ attempt to relativize the path returned by the native Node `join` method. When
|
|
766
|
+
* calculating the path from each of the string-based parts, Node does not prepend './' to any calculated path.
|
|
767
|
+
*
|
|
768
|
+
* Note that our algorithm does differ from Node's, as described in this function's JSDoc regarding trailing
|
|
769
|
+
* slashes.
|
|
770
|
+
*/
|
|
771
|
+
return normalizePath(path.join(...paths), false);
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* A wrapped version of node.js' {@link path.resolve} which adds our custom
|
|
775
|
+
* normalization logic. This resolves a path to a given (relative or absolute)
|
|
776
|
+
* path.
|
|
777
|
+
*
|
|
778
|
+
* @throws the underlying node function will throw if any argument is not a
|
|
779
|
+
* string
|
|
780
|
+
* @param paths a path or path fragments to resolve
|
|
781
|
+
* @returns a resolved path!
|
|
782
|
+
*/
|
|
783
|
+
function resolve(...paths) {
|
|
784
|
+
/**
|
|
785
|
+
* When normalizing, we should _not_ attempt to relativize the path returned by the native Node `resolve` method. When
|
|
786
|
+
* calculating the path from each of the string-based parts, Node does not prepend './' to the calculated path.
|
|
787
|
+
*/
|
|
788
|
+
return normalizePath(path.resolve(...paths), false);
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* A wrapped version of node.js' {@link path.normalize} which adds our custom
|
|
792
|
+
* normalization logic. This normalizes a path, de-duping repeated segment
|
|
793
|
+
* separators and resolving `'..'` segments.
|
|
794
|
+
*
|
|
795
|
+
* @throws the underlying node function will throw if the argument is not a
|
|
796
|
+
* string
|
|
797
|
+
* @param toNormalize a path to normalize
|
|
798
|
+
* @returns a normalized path!
|
|
799
|
+
*/
|
|
800
|
+
function normalize(toNormalize) {
|
|
801
|
+
/**
|
|
802
|
+
* When normalizing, we should _not_ attempt to relativize the path returned by the native Node `normalize` method.
|
|
803
|
+
* When calculating the path from each of the string-based parts, Node does not prepend './' to the calculated path.
|
|
804
|
+
*/
|
|
805
|
+
return normalizePath(path.normalize(toNormalize), false);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
//#endregion
|
|
809
|
+
//#region src/utils/logger/logger-typescript.ts
|
|
810
|
+
/**
|
|
811
|
+
* Augment a `Diagnostic` with information from a `Node` in the AST to provide richer error information
|
|
812
|
+
* @param d the diagnostic to augment
|
|
813
|
+
* @param node the node to augment with additional information
|
|
814
|
+
* @returns the augmented diagnostic
|
|
815
|
+
*/
|
|
816
|
+
const augmentDiagnosticWithNode = (d, node) => {
|
|
817
|
+
if (!node) return d;
|
|
818
|
+
const sourceFile = node.getSourceFile();
|
|
819
|
+
if (!sourceFile) return d;
|
|
820
|
+
d.absFilePath = normalizePath(sourceFile.fileName);
|
|
821
|
+
const sourceText = sourceFile.text;
|
|
822
|
+
const srcLines = splitLineBreaks(sourceText);
|
|
823
|
+
const start = node.getStart();
|
|
824
|
+
const end = node.getEnd();
|
|
825
|
+
const posStart = sourceFile.getLineAndCharacterOfPosition(start);
|
|
826
|
+
const errorLine = {
|
|
827
|
+
lineIndex: posStart.line,
|
|
828
|
+
lineNumber: posStart.line + 1,
|
|
829
|
+
text: srcLines[posStart.line],
|
|
830
|
+
errorCharStart: posStart.character,
|
|
831
|
+
errorLength: Math.max(end - start, 1)
|
|
832
|
+
};
|
|
833
|
+
d.lineNumber = errorLine.lineNumber;
|
|
834
|
+
d.columnNumber = errorLine.errorCharStart + 1;
|
|
835
|
+
d.lines.push(errorLine);
|
|
836
|
+
if (errorLine.errorLength === 0 && errorLine.errorCharStart > 0) {
|
|
837
|
+
errorLine.errorLength = 1;
|
|
838
|
+
errorLine.errorCharStart--;
|
|
839
|
+
}
|
|
840
|
+
if (errorLine.lineIndex > 0) {
|
|
841
|
+
const previousLine = {
|
|
842
|
+
lineIndex: errorLine.lineIndex - 1,
|
|
843
|
+
lineNumber: errorLine.lineNumber - 1,
|
|
844
|
+
text: srcLines[errorLine.lineIndex - 1],
|
|
845
|
+
errorCharStart: -1,
|
|
846
|
+
errorLength: -1
|
|
847
|
+
};
|
|
848
|
+
d.lines.unshift(previousLine);
|
|
849
|
+
}
|
|
850
|
+
if (errorLine.lineIndex + 1 < srcLines.length) {
|
|
851
|
+
const nextLine = {
|
|
852
|
+
lineIndex: errorLine.lineIndex + 1,
|
|
853
|
+
lineNumber: errorLine.lineNumber + 1,
|
|
854
|
+
text: srcLines[errorLine.lineIndex + 1],
|
|
855
|
+
errorCharStart: -1,
|
|
856
|
+
errorLength: -1
|
|
857
|
+
};
|
|
858
|
+
d.lines.push(nextLine);
|
|
859
|
+
}
|
|
860
|
+
return d;
|
|
861
|
+
};
|
|
862
|
+
/**
|
|
863
|
+
* Ok, so formatting overkill, we know. But whatever, it makes for great
|
|
864
|
+
* error reporting within a terminal. So, yeah, let's code it up, shall we?
|
|
865
|
+
*/
|
|
866
|
+
const loadTypeScriptDiagnostics = (tsDiagnostics) => {
|
|
867
|
+
const diagnostics = [];
|
|
868
|
+
const maxErrors = Math.min(tsDiagnostics.length, 50);
|
|
869
|
+
for (let i = 0; i < maxErrors; i++) diagnostics.push(loadTypeScriptDiagnostic(tsDiagnostics[i]));
|
|
870
|
+
return diagnostics;
|
|
871
|
+
};
|
|
872
|
+
/**
|
|
873
|
+
* Convert a TypeScript diagnostic object into our internal, Stencil-specific
|
|
874
|
+
* diagnostic format
|
|
875
|
+
*
|
|
876
|
+
* @param tsDiagnostic a TypeScript diagnostic message record
|
|
877
|
+
* @returns a Stencil diagnostic, suitable for showing an error to the user
|
|
878
|
+
*/
|
|
879
|
+
const loadTypeScriptDiagnostic = (tsDiagnostic) => {
|
|
880
|
+
const d = {
|
|
881
|
+
absFilePath: void 0,
|
|
882
|
+
code: tsDiagnostic.code.toString(),
|
|
883
|
+
columnNumber: void 0,
|
|
884
|
+
header: "TypeScript",
|
|
885
|
+
language: "typescript",
|
|
886
|
+
level: "warn",
|
|
887
|
+
lineNumber: void 0,
|
|
888
|
+
lines: [],
|
|
889
|
+
messageText: flattenDiagnosticMessageText(tsDiagnostic, tsDiagnostic.messageText),
|
|
890
|
+
relFilePath: void 0,
|
|
891
|
+
type: "typescript"
|
|
892
|
+
};
|
|
893
|
+
if (tsDiagnostic.category === 1) d.level = "error";
|
|
894
|
+
if (tsDiagnostic.file && typeof tsDiagnostic.start === "number") {
|
|
895
|
+
d.absFilePath = tsDiagnostic.file.fileName;
|
|
896
|
+
const sourceText = tsDiagnostic.file.text;
|
|
897
|
+
const srcLines = splitLineBreaks(sourceText);
|
|
898
|
+
const posData = tsDiagnostic.file.getLineAndCharacterOfPosition(tsDiagnostic.start);
|
|
899
|
+
const errorLine = {
|
|
900
|
+
lineIndex: posData.line,
|
|
901
|
+
lineNumber: posData.line + 1,
|
|
902
|
+
text: srcLines[posData.line],
|
|
903
|
+
errorCharStart: posData.character,
|
|
904
|
+
errorLength: Math.max(tsDiagnostic.length ?? 0, 1)
|
|
905
|
+
};
|
|
906
|
+
d.lineNumber = errorLine.lineNumber;
|
|
907
|
+
d.columnNumber = errorLine.errorCharStart + 1;
|
|
908
|
+
d.lines.push(errorLine);
|
|
909
|
+
if (errorLine.errorLength === 0 && errorLine.errorCharStart > 0) {
|
|
910
|
+
errorLine.errorLength = 1;
|
|
911
|
+
errorLine.errorCharStart--;
|
|
912
|
+
}
|
|
913
|
+
if (errorLine.lineIndex > 0) {
|
|
914
|
+
const previousLine = {
|
|
915
|
+
lineIndex: errorLine.lineIndex - 1,
|
|
916
|
+
lineNumber: errorLine.lineNumber - 1,
|
|
917
|
+
text: srcLines[errorLine.lineIndex - 1],
|
|
918
|
+
errorCharStart: -1,
|
|
919
|
+
errorLength: -1
|
|
920
|
+
};
|
|
921
|
+
d.lines.unshift(previousLine);
|
|
922
|
+
}
|
|
923
|
+
if (errorLine.lineIndex + 1 < srcLines.length) {
|
|
924
|
+
const nextLine = {
|
|
925
|
+
lineIndex: errorLine.lineIndex + 1,
|
|
926
|
+
lineNumber: errorLine.lineNumber + 1,
|
|
927
|
+
text: srcLines[errorLine.lineIndex + 1],
|
|
928
|
+
errorCharStart: -1,
|
|
929
|
+
errorLength: -1
|
|
930
|
+
};
|
|
931
|
+
d.lines.push(nextLine);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
return d;
|
|
935
|
+
};
|
|
936
|
+
/**
|
|
937
|
+
* Flatten a TypeScript diagnostic object into a string which can be easily
|
|
938
|
+
* included in a Stencil diagnostic record.
|
|
939
|
+
*
|
|
940
|
+
* @param tsDiagnostic a TypeScript diagnostic record
|
|
941
|
+
* @param diag a {@link DiagnosticMessageChain} or a string with further info
|
|
942
|
+
* @returns a string with the relevant error message
|
|
943
|
+
*/
|
|
944
|
+
const flattenDiagnosticMessageText = (tsDiagnostic, diag) => {
|
|
945
|
+
if (typeof diag === "string") return diag;
|
|
946
|
+
else if (diag === void 0) return "";
|
|
947
|
+
const ignoreCodes = [];
|
|
948
|
+
const isStencilConfig = (tsDiagnostic.file?.fileName ?? "").includes("stencil.config");
|
|
949
|
+
if (isStencilConfig) ignoreCodes.push(2322);
|
|
950
|
+
let result = "";
|
|
951
|
+
if (!ignoreCodes.includes(diag.code)) {
|
|
952
|
+
result = diag.messageText;
|
|
953
|
+
if (isIterable(diag.next)) for (const kid of diag.next) result += flattenDiagnosticMessageText(tsDiagnostic, kid);
|
|
954
|
+
}
|
|
955
|
+
if (isStencilConfig) {
|
|
956
|
+
result = result.replace(`type 'StencilConfig'`, `Stencil Config`);
|
|
957
|
+
result = result.replace(`Object literal may only specify known properties, but `, ``);
|
|
958
|
+
result = result.replace(`Object literal may only specify known properties, and `, ``);
|
|
959
|
+
}
|
|
960
|
+
return result.trim();
|
|
961
|
+
};
|
|
962
|
+
|
|
963
|
+
//#endregion
|
|
964
|
+
//#region src/utils/output-target.ts
|
|
965
|
+
/**
|
|
966
|
+
* Checks if a component tag name matches any of the exclude patterns.
|
|
967
|
+
* Supports glob patterns using minimatch.
|
|
968
|
+
*
|
|
969
|
+
* @param tagName The component's tag name to check
|
|
970
|
+
* @param excludePatterns Array of patterns to match against (supports globs)
|
|
971
|
+
* @returns true if the component should be excluded, false otherwise
|
|
972
|
+
*/
|
|
973
|
+
const shouldExcludeComponent = (tagName, excludePatterns) => {
|
|
974
|
+
if (!excludePatterns || excludePatterns.length === 0) return false;
|
|
975
|
+
return excludePatterns.some((pattern) => {
|
|
976
|
+
if (isGlob(pattern)) return minimatch(tagName, pattern);
|
|
977
|
+
return pattern === tagName;
|
|
978
|
+
});
|
|
979
|
+
};
|
|
980
|
+
/**
|
|
981
|
+
* Filters out components that match the excludeComponents patterns from the config.
|
|
982
|
+
* Only applies filtering to production builds (when devMode is false) - dev builds include all components.
|
|
983
|
+
*
|
|
984
|
+
* @param components Array of component metadata
|
|
985
|
+
* @param config The validated Stencil configuration
|
|
986
|
+
* @returns Object containing filtered components and excluded components
|
|
987
|
+
*/
|
|
988
|
+
const filterExcludedComponents = (components, config) => {
|
|
989
|
+
if (config.devMode) return {
|
|
990
|
+
components,
|
|
991
|
+
excludedComponents: []
|
|
992
|
+
};
|
|
993
|
+
const excludePatterns = config.excludeComponents;
|
|
994
|
+
if (!excludePatterns || excludePatterns.length === 0) return {
|
|
995
|
+
components,
|
|
996
|
+
excludedComponents: []
|
|
997
|
+
};
|
|
998
|
+
const excludedComponents = [];
|
|
999
|
+
const excludedTags = [];
|
|
1000
|
+
const filtered = components.filter((cmp) => {
|
|
1001
|
+
const shouldExclude = shouldExcludeComponent(cmp.tagName, excludePatterns);
|
|
1002
|
+
if (shouldExclude) {
|
|
1003
|
+
excludedComponents.push(cmp);
|
|
1004
|
+
excludedTags.push(cmp.tagName);
|
|
1005
|
+
config.logger.debug(`Excluding component from build: ${cmp.tagName}`);
|
|
1006
|
+
}
|
|
1007
|
+
return !shouldExclude;
|
|
1008
|
+
});
|
|
1009
|
+
if (excludedTags.length > 0) {
|
|
1010
|
+
const tagList = excludedTags.join(", ");
|
|
1011
|
+
config.logger.info(`Excluding ${excludedTags.length} component${excludedTags.length === 1 ? "" : "s"} from production build: ${tagList}`);
|
|
1012
|
+
}
|
|
1013
|
+
return {
|
|
1014
|
+
components: filtered,
|
|
1015
|
+
excludedComponents
|
|
1016
|
+
};
|
|
1017
|
+
};
|
|
1018
|
+
const relativeImport = (pathFrom, pathTo, ext, addPrefix = true) => {
|
|
1019
|
+
let relativePath = relative(dirname(pathFrom), dirname(pathTo));
|
|
1020
|
+
if (addPrefix) {
|
|
1021
|
+
if (relativePath === "") relativePath = ".";
|
|
1022
|
+
else if (relativePath[0] !== ".") relativePath = "./" + relativePath;
|
|
1023
|
+
}
|
|
1024
|
+
return normalizePath(`${relativePath}/${basename(pathTo, ext)}`);
|
|
1025
|
+
};
|
|
1026
|
+
const getComponentsDtsSrcFilePath = (config) => join$1(config.srcDir, GENERATED_DTS);
|
|
1027
|
+
/**
|
|
1028
|
+
* Helper to get an appropriate file path for `components.d.ts` for a `"dist"`
|
|
1029
|
+
* or `"dist-types"` output target.
|
|
1030
|
+
*
|
|
1031
|
+
* @param outputTarget the output target of interest
|
|
1032
|
+
* @returns a properly-formatted path
|
|
1033
|
+
*/
|
|
1034
|
+
const getComponentsDtsTypesFilePath = (outputTarget) => join$1(outputTarget.typesDir, GENERATED_DTS);
|
|
1035
|
+
const isOutputTargetDist = (o) => o.type === DIST;
|
|
1036
|
+
const isOutputTargetDistCollection = (o) => o.type === DIST_COLLECTION;
|
|
1037
|
+
const isOutputTargetDistCustomElements = (o) => o.type === DIST_CUSTOM_ELEMENTS;
|
|
1038
|
+
const isOutputTargetCopy = (o) => o.type === COPY;
|
|
1039
|
+
const isOutputTargetDistLazy = (o) => o.type === DIST_LAZY;
|
|
1040
|
+
const isOutputTargetDistLazyLoader = (o) => o.type === DIST_LAZY_LOADER;
|
|
1041
|
+
const isOutputTargetDistGlobalStyles = (o) => o.type === DIST_GLOBAL_STYLES;
|
|
1042
|
+
const isOutputTargetHydrate = (o) => o.type === DIST_HYDRATE_SCRIPT;
|
|
1043
|
+
const isOutputTargetCustom = (o) => o.type === CUSTOM;
|
|
1044
|
+
const isOutputTargetDocs = (o) => o.type === DOCS_README || o.type === DOCS_JSON || o.type === DOCS_CUSTOM || o.type === DOCS_VSCODE || o.type === DOCS_CUSTOM_ELEMENTS_MANIFEST;
|
|
1045
|
+
const isOutputTargetDocsReadme = (o) => o.type === DOCS_README;
|
|
1046
|
+
const isOutputTargetDocsJson = (o) => o.type === DOCS_JSON;
|
|
1047
|
+
const isOutputTargetDocsCustom = (o) => o.type === DOCS_CUSTOM;
|
|
1048
|
+
const isOutputTargetDocsVscode = (o) => o.type === DOCS_VSCODE;
|
|
1049
|
+
const isOutputTargetDocsCustomElementsManifest = (o) => o.type === DOCS_CUSTOM_ELEMENTS_MANIFEST;
|
|
1050
|
+
const isOutputTargetWww = (o) => o.type === WWW;
|
|
1051
|
+
const isOutputTargetStats = (o) => o.type === STATS;
|
|
1052
|
+
const isOutputTargetDistTypes = (o) => o.type === DIST_TYPES;
|
|
1053
|
+
/**
|
|
1054
|
+
* Checks whether or not the supplied output target's type matches one of the eligible primary
|
|
1055
|
+
* package output target types (i.e. it can have `isPrimaryPackageOutputTarget: true` in its config).
|
|
1056
|
+
*
|
|
1057
|
+
* @param o The output target to check.
|
|
1058
|
+
* @returns Whether the output target type is one of the "primary" output targets.
|
|
1059
|
+
*/
|
|
1060
|
+
const isEligiblePrimaryPackageOutputTarget = (o) => isOutputTargetDist(o) || isOutputTargetDistCollection(o) || isOutputTargetDistCustomElements(o) || isOutputTargetDistTypes(o);
|
|
1061
|
+
/**
|
|
1062
|
+
* Retrieve the Stencil component compiler metadata from a collection of Stencil {@link d.Module}s
|
|
1063
|
+
* @param moduleFiles the collection of `Module`s to retrieve the metadata from
|
|
1064
|
+
* @returns the metadata, lexicographically sorted by the tag names of the components
|
|
1065
|
+
*/
|
|
1066
|
+
const getComponentsFromModules = (moduleFiles) => sortBy(flatOne(moduleFiles.map((m) => m.cmps)), (c) => c.tagName);
|
|
1067
|
+
/**
|
|
1068
|
+
* Check whether a given output target is a valid one to be set in a Stencil config
|
|
1069
|
+
*
|
|
1070
|
+
* @param targetType the type which we want to check
|
|
1071
|
+
* @returns whether or not the targetType is a valid, configurable output target.
|
|
1072
|
+
*/
|
|
1073
|
+
function isValidConfigOutputTarget(targetType) {
|
|
1074
|
+
return VALID_CONFIG_OUTPUT_TARGETS.includes(targetType);
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
//#endregion
|
|
1078
|
+
//#region src/utils/result.ts
|
|
1079
|
+
var result_exports = /* @__PURE__ */ __exportAll({
|
|
1080
|
+
err: () => err,
|
|
1081
|
+
map: () => map,
|
|
1082
|
+
ok: () => ok,
|
|
1083
|
+
unwrap: () => unwrap,
|
|
1084
|
+
unwrapErr: () => unwrapErr
|
|
1085
|
+
});
|
|
1086
|
+
/**
|
|
1087
|
+
* Create an `Ok` given a value. This doesn't do any checking that the value is
|
|
1088
|
+
* 'ok-ish' since doing so would make an undue assumption about what is 'ok'.
|
|
1089
|
+
* Instead, this trusts the user to determine, at the call site, whether
|
|
1090
|
+
* something is `ok()` or `err()`.
|
|
1091
|
+
*
|
|
1092
|
+
* @param value the value to wrap up in an `Ok`
|
|
1093
|
+
* @returns an Ok wrapping the value
|
|
1094
|
+
*/
|
|
1095
|
+
const ok = (value) => ({
|
|
1096
|
+
isOk: true,
|
|
1097
|
+
isErr: false,
|
|
1098
|
+
value
|
|
1099
|
+
});
|
|
1100
|
+
/**
|
|
1101
|
+
* Create an `Err` given a value.
|
|
1102
|
+
*
|
|
1103
|
+
* @param value the value to wrap up in an `Err`
|
|
1104
|
+
* @returns an Ok wrapping the value
|
|
1105
|
+
*/
|
|
1106
|
+
const err = (value) => ({
|
|
1107
|
+
isOk: false,
|
|
1108
|
+
isErr: true,
|
|
1109
|
+
value
|
|
1110
|
+
});
|
|
1111
|
+
function map(result, fn) {
|
|
1112
|
+
if (result.isOk) {
|
|
1113
|
+
const val = fn(result.value);
|
|
1114
|
+
if (val instanceof Promise) return val.then((newVal) => ok(newVal));
|
|
1115
|
+
else return ok(val);
|
|
1116
|
+
}
|
|
1117
|
+
if (result.isErr) {
|
|
1118
|
+
const value = result.value;
|
|
1119
|
+
return err(value);
|
|
1120
|
+
}
|
|
1121
|
+
throw "should never get here";
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* Unwrap a {@link Result}, return the value inside if it is an `Ok` and
|
|
1125
|
+
* throw with the wrapped value if it is an `Err`.
|
|
1126
|
+
*
|
|
1127
|
+
* @throws with the wrapped value if it is an `Err`.
|
|
1128
|
+
* @param result a result to peer inside of
|
|
1129
|
+
* @returns the wrapped value, if `Ok`
|
|
1130
|
+
*/
|
|
1131
|
+
const unwrap = (result) => {
|
|
1132
|
+
if (result.isOk) return result.value;
|
|
1133
|
+
else throw result.value;
|
|
1134
|
+
};
|
|
1135
|
+
/**
|
|
1136
|
+
* Unwrap a {@link Result}, return the value inside if it is an `Err` and
|
|
1137
|
+
* throw with the wrapped value if it is an `Ok`.
|
|
1138
|
+
*
|
|
1139
|
+
* @throws with the wrapped value if it is an `Ok`.
|
|
1140
|
+
* @param result a result to peer inside of
|
|
1141
|
+
* @returns the wrapped value, if `Err`
|
|
1142
|
+
*/
|
|
1143
|
+
const unwrapErr = (result) => {
|
|
1144
|
+
if (result.isErr) return result.value;
|
|
1145
|
+
else throw result.value;
|
|
1146
|
+
};
|
|
1147
|
+
|
|
1148
|
+
//#endregion
|
|
1149
|
+
//#region src/utils/sourcemaps.ts
|
|
1150
|
+
function rollupToStencilSourceMap(rollupSourceMap) {
|
|
1151
|
+
if (!rollupSourceMap || !rollupSourceMap.file) return null;
|
|
1152
|
+
return {
|
|
1153
|
+
file: rollupSourceMap.file,
|
|
1154
|
+
mappings: rollupSourceMap.mappings,
|
|
1155
|
+
names: rollupSourceMap.names,
|
|
1156
|
+
sources: rollupSourceMap.sources,
|
|
1157
|
+
sourcesContent: rollupSourceMap.sourcesContent,
|
|
1158
|
+
version: rollupSourceMap.version
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
/**
|
|
1162
|
+
* A JavaScript formatted string used to link generated code back to the original. This string follows the guidelines
|
|
1163
|
+
* found in the [Linking generated code to source maps](https://sourcemaps.info/spec.html#h.lmz475t4mvbx) section of
|
|
1164
|
+
* the Sourcemaps V3 specification proposal.
|
|
1165
|
+
*/
|
|
1166
|
+
const JS_SOURCE_MAPPING_URL_LINKER = "//# sourceMappingURL=";
|
|
1167
|
+
/**
|
|
1168
|
+
* Generates an RFC-3986 compliant string for the given input.
|
|
1169
|
+
* More information about RFC-3986 can be found [here](https://datatracker.ietf.org/doc/html/rfc3986)
|
|
1170
|
+
* This function's original source is derived from
|
|
1171
|
+
* [MDN's encodeURIComponent documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent#description)
|
|
1172
|
+
* @param filename the filename to encode
|
|
1173
|
+
* @returns the encoded URI
|
|
1174
|
+
*/
|
|
1175
|
+
const encodeToRfc3986 = (filename) => {
|
|
1176
|
+
return encodeURIComponent(filename).replace(/[!'()*]/g, (matchedCharacter) => {
|
|
1177
|
+
return "%" + matchedCharacter.charCodeAt(0).toString(16);
|
|
1178
|
+
});
|
|
1179
|
+
};
|
|
1180
|
+
/**
|
|
1181
|
+
* Generates a string used to link generated code with the original source, to be placed at the end of the generated
|
|
1182
|
+
* code.
|
|
1183
|
+
* @param url the url of the source map
|
|
1184
|
+
* @returns a linker string, of the format {@link JS_SOURCE_MAPPING_URL_LINKER}=<url>
|
|
1185
|
+
*/
|
|
1186
|
+
const getSourceMappingUrlLinker = (url) => {
|
|
1187
|
+
return `${JS_SOURCE_MAPPING_URL_LINKER}${encodeToRfc3986(url)}`;
|
|
1188
|
+
};
|
|
1189
|
+
/**
|
|
1190
|
+
* Generates a string used to link generated code with the original source, to be placed at the end of the generated
|
|
1191
|
+
* code as an inline source map.
|
|
1192
|
+
* @param sourceMapContents the sourceMapContents of the source map
|
|
1193
|
+
* @returns a linker string, of the format {@link JS_SOURCE_MAPPING_URL_LINKER}<dataUriPrefixAndMime><sourceMapContents>
|
|
1194
|
+
*/
|
|
1195
|
+
const getInlineSourceMappingUrlLinker = (sourceMapContents) => {
|
|
1196
|
+
return `${JS_SOURCE_MAPPING_URL_LINKER}data:application/json;charset=utf-8;base64,${Buffer.from(sourceMapContents, "utf8").toString("base64")}`;
|
|
1197
|
+
};
|
|
1198
|
+
/**
|
|
1199
|
+
* Generates a string used to link generated code with the original source, to be placed at the end of the generated
|
|
1200
|
+
* code. This function prepends a newline to the string.
|
|
1201
|
+
* @param url the url of the source map
|
|
1202
|
+
* @returns a linker string, of the format {@link JS_SOURCE_MAPPING_URL_LINKER}=<url>.map, prepended with a newline
|
|
1203
|
+
*/
|
|
1204
|
+
const getSourceMappingUrlForEndOfFile = (url) => {
|
|
1205
|
+
return `\n${getSourceMappingUrlLinker(url)}.map`;
|
|
1206
|
+
};
|
|
1207
|
+
|
|
1208
|
+
//#endregion
|
|
1209
|
+
//#region src/utils/url-paths.ts
|
|
1210
|
+
/**
|
|
1211
|
+
* Determines whether a string should be considered a remote url or not.
|
|
1212
|
+
*
|
|
1213
|
+
* This helper only checks the provided string to evaluate is one of a few pre-defined schemes, and should not be
|
|
1214
|
+
* considered all-encompassing
|
|
1215
|
+
*
|
|
1216
|
+
* @param p the string to evaluate
|
|
1217
|
+
* @returns `true` if the provided string is a remote url, `false` otherwise
|
|
1218
|
+
*/
|
|
1219
|
+
const isRemoteUrl = (p) => {
|
|
1220
|
+
if (isString(p)) {
|
|
1221
|
+
p = p.toLowerCase();
|
|
1222
|
+
return p.startsWith("https://") || p.startsWith("http://");
|
|
1223
|
+
}
|
|
1224
|
+
return false;
|
|
1225
|
+
};
|
|
1226
|
+
|
|
1227
|
+
//#endregion
|
|
1228
|
+
//#region src/utils/util.ts
|
|
1229
|
+
/**
|
|
1230
|
+
* A set of JSDoc tags which should be excluded from JSDoc comments
|
|
1231
|
+
* included in output typedefs.
|
|
1232
|
+
*/
|
|
1233
|
+
const SUPPRESSED_JSDOC_TAGS = [
|
|
1234
|
+
"virtualProp",
|
|
1235
|
+
"slot",
|
|
1236
|
+
"part",
|
|
1237
|
+
"internal"
|
|
1238
|
+
];
|
|
1239
|
+
const LINE_BREAK_REGEX = /\r?\n|\r/g;
|
|
1240
|
+
/**
|
|
1241
|
+
* Create a stylistically-appropriate JS variable name from a filename
|
|
1242
|
+
*
|
|
1243
|
+
* If the filename has any of the special characters "?", "#", "&" and "=" it
|
|
1244
|
+
* will take the string before the left-most instance of one of those
|
|
1245
|
+
* characters.
|
|
1246
|
+
*
|
|
1247
|
+
* @param fileName the filename which serves as starting material
|
|
1248
|
+
* @returns a JS variable name based on the filename
|
|
1249
|
+
*/
|
|
1250
|
+
const createJsVarName = (fileName) => {
|
|
1251
|
+
if (isString(fileName)) {
|
|
1252
|
+
fileName = fileName.split("?")[0];
|
|
1253
|
+
fileName = fileName.split("#")[0];
|
|
1254
|
+
fileName = fileName.split("&")[0];
|
|
1255
|
+
fileName = fileName.split("=")[0];
|
|
1256
|
+
fileName = toDashCase(fileName);
|
|
1257
|
+
fileName = fileName.replace(/[|;$%@"<>()+,.{}_\!\/\\]/g, "-");
|
|
1258
|
+
fileName = dashToPascalCase(fileName);
|
|
1259
|
+
if (fileName.length > 1) fileName = fileName[0].toLowerCase() + fileName.slice(1);
|
|
1260
|
+
else fileName = fileName.toLowerCase();
|
|
1261
|
+
if (fileName.length > 0 && !isNaN(fileName[0])) fileName = "_" + fileName;
|
|
1262
|
+
}
|
|
1263
|
+
return fileName;
|
|
1264
|
+
};
|
|
1265
|
+
/**
|
|
1266
|
+
* Create a function that lowercases the first string parameter before passing it to the provided function
|
|
1267
|
+
* @param fn the function to pass the lowercased path to
|
|
1268
|
+
* @returns the result of the provided function
|
|
1269
|
+
*/
|
|
1270
|
+
const lowerPathParam = (fn) => (p) => fn(p.toLowerCase());
|
|
1271
|
+
/**
|
|
1272
|
+
* Determine if a stringified file path is a TypeScript declaration file based on the extension at the end of the path.
|
|
1273
|
+
* @param p the path to evaluate
|
|
1274
|
+
* @returns `true` if the path ends in `.d.ts` (case-sensitive), `false` otherwise.
|
|
1275
|
+
*/
|
|
1276
|
+
const isDtsFile = lowerPathParam((p) => p.endsWith(".d.ts") || p.endsWith(".d.mts") || p.endsWith(".d.cts"));
|
|
1277
|
+
/**
|
|
1278
|
+
* Determine if a stringified file path is a TypeScript file based on the extension at the end of the path. This
|
|
1279
|
+
* function does _not_ consider type declaration files (`.d.ts` files) to be TypeScript files.
|
|
1280
|
+
* @param p the path to evaluate
|
|
1281
|
+
* @returns `true` if the path ends in `.ts` (case-sensitive) but does _not_ end in `.d.ts`, `false` otherwise.
|
|
1282
|
+
*/
|
|
1283
|
+
const isTsFile = lowerPathParam((p) => !isDtsFile(p) && (p.endsWith(".ts") || p.endsWith(".mts") || p.endsWith(".cts")));
|
|
1284
|
+
/**
|
|
1285
|
+
* Determine if a stringified file path is a TSX file based on the extension at the end of the path
|
|
1286
|
+
* @param p the path to evaluate
|
|
1287
|
+
* @returns `true` if the path ends in `.tsx` (case-sensitive), `false` otherwise.
|
|
1288
|
+
*/
|
|
1289
|
+
const isTsxFile = lowerPathParam((p) => p.endsWith(".tsx") || p.endsWith(".mtsx") || p.endsWith(".ctsx"));
|
|
1290
|
+
/**
|
|
1291
|
+
* Determine if a stringified file path is a JSX file based on the extension at the end of the path
|
|
1292
|
+
* @param p the path to evaluate
|
|
1293
|
+
* @returns `true` if the path ends in `.jsx` (case-sensitive), `false` otherwise.
|
|
1294
|
+
*/
|
|
1295
|
+
const isJsxFile = lowerPathParam((p) => p.endsWith(".jsx") || p.endsWith(".mjsx") || p.endsWith(".cjsx"));
|
|
1296
|
+
/**
|
|
1297
|
+
* Determine if a stringified file path is a JavaScript file based on the extension at the end of the path
|
|
1298
|
+
* @param p the path to evaluate
|
|
1299
|
+
* @returns `true` if the path ends in `.js` (case-sensitive), `false` otherwise.
|
|
1300
|
+
*/
|
|
1301
|
+
const isJsFile = lowerPathParam((p) => p.endsWith(".js") || p.endsWith(".mjs") || p.endsWith(".cjs"));
|
|
1302
|
+
/**
|
|
1303
|
+
* Generate the preamble to be placed atop the main file of the build
|
|
1304
|
+
* @param config the Stencil configuration file
|
|
1305
|
+
* @returns the generated preamble
|
|
1306
|
+
*/
|
|
1307
|
+
const generatePreamble = (config) => {
|
|
1308
|
+
const { preamble } = config;
|
|
1309
|
+
if (!preamble) return "";
|
|
1310
|
+
const preambleComment = preamble.split("\n").map((l) => ` * ${l}`);
|
|
1311
|
+
preambleComment.unshift(`/*!`);
|
|
1312
|
+
preambleComment.push(` */`);
|
|
1313
|
+
return preambleComment.join("\n");
|
|
1314
|
+
};
|
|
1315
|
+
function getTextDocs(docs) {
|
|
1316
|
+
if (docs == null) return "";
|
|
1317
|
+
return [escapeWithPattern(docs.text.replace(LINE_BREAK_REGEX, " "), /\*\//, "*\\/", true), ...docs.tags.filter((tag) => tag.name !== "internal").map((tag) => {
|
|
1318
|
+
const tagText = escapeWithPattern((tag.text || "").replace(LINE_BREAK_REGEX, " "), /\*\//, "*\\/", true);
|
|
1319
|
+
return `@${tag.name} ${tagText}`;
|
|
1320
|
+
})].join("\n").trim();
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* Adds a doc block to a string
|
|
1324
|
+
* @param str the string to add a doc block to
|
|
1325
|
+
* @param docs the compiled JS docs
|
|
1326
|
+
* @param indentation number of spaces to indent the block with
|
|
1327
|
+
* @returns the doc block
|
|
1328
|
+
*/
|
|
1329
|
+
function addDocBlock(str, docs, indentation = 0) {
|
|
1330
|
+
if (!docs) return str;
|
|
1331
|
+
return [formatDocBlock(docs, indentation), str].filter(Boolean).join(`\n`);
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Formats the given compiled docs to a JavaScript doc block
|
|
1335
|
+
* @param docs the compiled JS docs
|
|
1336
|
+
* @param indentation number of spaces to indent the block with
|
|
1337
|
+
* @returns the formatted doc block
|
|
1338
|
+
*/
|
|
1339
|
+
function formatDocBlock(docs, indentation = 0) {
|
|
1340
|
+
const textDocs = getDocBlockLines(docs);
|
|
1341
|
+
if (!textDocs.filter(Boolean).length) return "";
|
|
1342
|
+
const spaces = new Array(indentation + 1).join(" ");
|
|
1343
|
+
return [
|
|
1344
|
+
spaces + "/**",
|
|
1345
|
+
...textDocs.map((line) => spaces + ` * ${line}`),
|
|
1346
|
+
spaces + " */"
|
|
1347
|
+
].join(`\n`);
|
|
1348
|
+
}
|
|
1349
|
+
/**
|
|
1350
|
+
* Get all lines which are part of the doc block
|
|
1351
|
+
*
|
|
1352
|
+
* @param docs the compiled JS docs
|
|
1353
|
+
* @returns list of lines part of the doc block
|
|
1354
|
+
*/
|
|
1355
|
+
function getDocBlockLines(docs) {
|
|
1356
|
+
return [...docs.text.split(LINE_BREAK_REGEX), ...docs.tags.filter((tag) => !SUPPRESSED_JSDOC_TAGS.includes(tag.name)).map((tag) => `@${tag.name} ${tag.text || ""}`.split(LINE_BREAK_REGEX))].flat().filter(Boolean);
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* Retrieve a project's dependencies from the current build context
|
|
1360
|
+
* @param buildCtx the current build context to query for a specific package
|
|
1361
|
+
* @returns a list of package names the project is dependent on
|
|
1362
|
+
*/
|
|
1363
|
+
const getDependencies = (buildCtx) => Object.keys(buildCtx?.packageJson?.dependencies ?? {}).filter((pkgName) => !SKIP_DEPS.includes(pkgName));
|
|
1364
|
+
/**
|
|
1365
|
+
* Utility to determine whether a project has a dependency on a package
|
|
1366
|
+
* @param buildCtx the current build context to query for a specific package
|
|
1367
|
+
* @param depName the name of the dependency/package
|
|
1368
|
+
* @returns `true` if the project has a dependency a packaged with the provided name, `false` otherwise
|
|
1369
|
+
*/
|
|
1370
|
+
const hasDependency = (buildCtx, depName) => {
|
|
1371
|
+
return getDependencies(buildCtx).includes(depName);
|
|
1372
|
+
};
|
|
1373
|
+
const readPackageJson = async (config, compilerCtx, buildCtx) => {
|
|
1374
|
+
try {
|
|
1375
|
+
const pkgJson = await compilerCtx.fs.readFile(config.packageJsonFilePath);
|
|
1376
|
+
if (pkgJson) {
|
|
1377
|
+
const parseResults = parsePackageJson(pkgJson, config.packageJsonFilePath);
|
|
1378
|
+
if (parseResults.diagnostic) buildCtx.diagnostics.push(parseResults.diagnostic);
|
|
1379
|
+
else buildCtx.packageJson = parseResults.data;
|
|
1380
|
+
}
|
|
1381
|
+
} catch (e) {
|
|
1382
|
+
if (!config.outputTargets.some((o) => o.type.includes("dist"))) {
|
|
1383
|
+
const diagnostic = buildError(buildCtx.diagnostics);
|
|
1384
|
+
diagnostic.header = `Missing "package.json"`;
|
|
1385
|
+
diagnostic.messageText = `Valid "package.json" file is required for distribution: ${config.packageJsonFilePath}`;
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
};
|
|
1389
|
+
/**
|
|
1390
|
+
* Parse a string read from a `package.json` file
|
|
1391
|
+
* @param pkgJsonStr the string read from a `package.json` file
|
|
1392
|
+
* @param pkgJsonFilePath the path to the already read `package.json` file
|
|
1393
|
+
* @returns the results of parsing the provided contents of the `package.json` file
|
|
1394
|
+
*/
|
|
1395
|
+
const parsePackageJson = (pkgJsonStr, pkgJsonFilePath) => {
|
|
1396
|
+
const parseResult = {
|
|
1397
|
+
diagnostic: null,
|
|
1398
|
+
data: null,
|
|
1399
|
+
filePath: pkgJsonFilePath
|
|
1400
|
+
};
|
|
1401
|
+
try {
|
|
1402
|
+
parseResult.data = JSON.parse(pkgJsonStr);
|
|
1403
|
+
} catch (e) {
|
|
1404
|
+
parseResult.diagnostic = buildError();
|
|
1405
|
+
parseResult.diagnostic.absFilePath = isString(pkgJsonFilePath) ? pkgJsonFilePath : void 0;
|
|
1406
|
+
parseResult.diagnostic.header = `Error Parsing JSON`;
|
|
1407
|
+
if (e instanceof Error) parseResult.diagnostic.messageText = e.message;
|
|
1408
|
+
}
|
|
1409
|
+
return parseResult;
|
|
1410
|
+
};
|
|
1411
|
+
const SKIP_DEPS = ["@stencil/core"];
|
|
1412
|
+
/**
|
|
1413
|
+
* Check whether a string is a member of a ReadonlyArray<string>
|
|
1414
|
+
*
|
|
1415
|
+
* We need a little helper for this because unfortunately `includes` is typed
|
|
1416
|
+
* on `ReadonlyArray<T>` as `(el: T): boolean` so a `string` cannot be passed
|
|
1417
|
+
* to `includes` on a `ReadonlyArray` 😢 thus we have a little helper function
|
|
1418
|
+
* where we do the type coercion just once.
|
|
1419
|
+
*
|
|
1420
|
+
* see microsoft/TypeScript#31018 for some discussion of this
|
|
1421
|
+
*
|
|
1422
|
+
* @param readOnlyArray the array we're checking
|
|
1423
|
+
* @param maybeMember a value which is possibly a member of the array
|
|
1424
|
+
* @returns whether the array contains the member or not
|
|
1425
|
+
*/
|
|
1426
|
+
const readOnlyArrayHasStringMember = (readOnlyArray, maybeMember) => readOnlyArray.includes(maybeMember);
|
|
1427
|
+
|
|
1428
|
+
//#endregion
|
|
1429
|
+
//#region src/utils/validation.ts
|
|
1430
|
+
/**
|
|
1431
|
+
* Validates that a component tag meets required naming conventions to be used for a web component
|
|
1432
|
+
* @param tag the tag to validate
|
|
1433
|
+
* @returns an error message if the tag has an invalid name, undefined if the tag name passes all checks
|
|
1434
|
+
*/
|
|
1435
|
+
const validateComponentTag = (tag) => {
|
|
1436
|
+
if (typeof tag !== "string") return `Tag "${tag}" must be a string type`;
|
|
1437
|
+
if (tag !== tag.trim()) return `Tag can not contain white spaces`;
|
|
1438
|
+
if (tag !== tag.toLowerCase()) return `Tag can not contain upper case characters`;
|
|
1439
|
+
if (tag.length === 0) return `Received empty tag value`;
|
|
1440
|
+
if (tag.indexOf(" ") > -1) return `"${tag}" tag cannot contain a space`;
|
|
1441
|
+
if (tag.indexOf(",") > -1) return `"${tag}" tag cannot be used for multiple tags`;
|
|
1442
|
+
const invalidChars = tag.replace(/\w|-/g, "");
|
|
1443
|
+
if (invalidChars !== "") return `"${tag}" tag contains invalid characters: ${invalidChars}`;
|
|
1444
|
+
if (tag.indexOf("-") === -1) return `"${tag}" tag must contain a dash (-) to work as a valid web component`;
|
|
1445
|
+
if (tag.indexOf("--") > -1) return `"${tag}" tag cannot contain multiple dashes (--) next to each other`;
|
|
1446
|
+
if (tag.indexOf("-") === 0) return `"${tag}" tag cannot start with a dash (-)`;
|
|
1447
|
+
if (tag.lastIndexOf("-") === tag.length - 1) return `"${tag}" tag cannot end with a dash (-)`;
|
|
1448
|
+
};
|
|
1449
|
+
|
|
1450
|
+
//#endregion
|
|
1451
|
+
export { join$1 as $, isOutputTargetCustom as A, isOutputTargetDocsCustomElementsManifest as B, result_exports as C, stringifyRuntimeData as Ct, getComponentsFromModules as D, getComponentsDtsTypesFilePath as E, isOutputTargetDistLazy as F, isOutputTargetStats as G, isOutputTargetDocsReadme as H, isOutputTargetDistLazyLoader as I, relativeImport as J, isOutputTargetWww as K, isOutputTargetDistTypes as L, isOutputTargetDistCollection as M, isOutputTargetDistCustomElements as N, isEligiblePrimaryPackageOutputTarget as O, isOutputTargetDistGlobalStyles as P, loadTypeScriptDiagnostics as Q, isOutputTargetDocs as R, ok as S, formatLazyBundleRuntimeMeta as St, getComponentsDtsSrcFilePath as T, isOutputTargetDocsVscode as U, isOutputTargetDocsJson as V, isOutputTargetHydrate as W, augmentDiagnosticWithNode as X, shouldExcludeComponent as Y, loadTypeScriptDiagnostic as Z, getSourceMappingUrlForEndOfFile as _, hasWarning as _t, getTextDocs as a, resolve as at, err as b, isGlob as bt, isJsFile as c, escapeHtml as ct, isTsxFile as d, TASK_CANCELED_MSG as dt, normalize as et, parsePackageJson as f, buildError as ft, getInlineSourceMappingUrlLinker as g, hasError as gt, isRemoteUrl as h, catchError as ht, generatePreamble as i, relative$1 as it, isOutputTargetDist as j, isOutputTargetCopy as k, isJsxFile as l, normalizeDiagnostics as lt, readPackageJson as m, buildWarn as mt, addDocBlock as n, normalizeFsPathQuery as nt, hasDependency as o, createOnWarnFn as ot, readOnlyArrayHasStringMember as p, buildJsonFileError as pt, isValidConfigOutputTarget as q, createJsVarName as r, normalizePath as rt, isDtsFile as s, loadRollupDiagnostics as st, validateComponentTag as t, normalizeFsPath as tt, isTsFile as u, splitLineBreaks as ut, getSourceMappingUrlLinker as v, shouldIgnoreError as vt, filterExcludedComponents as w, byteSize as wt, map as x, formatComponentRuntimeMeta as xt, rollupToStencilSourceMap as y, isRootPath as yt, isOutputTargetDocsCustom as z };
|