@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,1188 @@
|
|
|
1
|
+
import "../chunk-ClPoSABd.mjs";
|
|
2
|
+
import { C as reWireGetterSetter, E as Env, T as BUILD, _ as setAssetPath, a as bootstrapLazy, c as renderVdom, d as getMode, g as getAssetPath, h, i as Fragment, l as createEvent, m as Host, o as forceUpdate, r as Mixin, s as getRenderingRef, t as insertVdomAnnotations, u as getElement } from "../client-DR9zhmKG.mjs";
|
|
3
|
+
import { D as CMP_FLAGS, G as EVENT_FLAGS, y as noop } from "../serialize-BJvhE9aQ.mjs";
|
|
4
|
+
import { f as createInMemoryFs, g as getBuildFeatures, m as BuildContext, p as Cache, r as createSystem, s as createWorkerContext } from "../transpile-CJQcQEVa.mjs";
|
|
5
|
+
import { St as formatLazyBundleRuntimeMeta } from "../validation-BdcPruW_.mjs";
|
|
6
|
+
import { o as buildEvents } from "../node-sys-BGURUNOZ.mjs";
|
|
7
|
+
import "../compiler/index.mjs";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
import path$1 from "path";
|
|
10
|
+
import { MockWindow, setupGlobal } from "@stencil/mock-doc";
|
|
11
|
+
import { createHash } from "crypto";
|
|
12
|
+
import { afterAll, vi } from "vitest";
|
|
13
|
+
|
|
14
|
+
//#region src/testing/testing-logger.ts
|
|
15
|
+
var TestingLogger = class {
|
|
16
|
+
isEnabled = false;
|
|
17
|
+
enable() {
|
|
18
|
+
this.isEnabled = true;
|
|
19
|
+
}
|
|
20
|
+
setLevel(_level) {}
|
|
21
|
+
getLevel() {
|
|
22
|
+
return "info";
|
|
23
|
+
}
|
|
24
|
+
enableColors(_useColors) {}
|
|
25
|
+
emoji(_) {
|
|
26
|
+
return "";
|
|
27
|
+
}
|
|
28
|
+
info(...msg) {
|
|
29
|
+
if (this.isEnabled) console.log(...msg);
|
|
30
|
+
}
|
|
31
|
+
warn(...msg) {
|
|
32
|
+
if (this.isEnabled) console.warn(...msg);
|
|
33
|
+
}
|
|
34
|
+
error(...msg) {
|
|
35
|
+
if (this.isEnabled) console.error(...msg);
|
|
36
|
+
}
|
|
37
|
+
debug(...msg) {
|
|
38
|
+
if (this.isEnabled) console.log(...msg);
|
|
39
|
+
}
|
|
40
|
+
color(_msg, _color) {}
|
|
41
|
+
red(msg) {
|
|
42
|
+
return msg;
|
|
43
|
+
}
|
|
44
|
+
green(msg) {
|
|
45
|
+
return msg;
|
|
46
|
+
}
|
|
47
|
+
yellow(msg) {
|
|
48
|
+
return msg;
|
|
49
|
+
}
|
|
50
|
+
blue(msg) {
|
|
51
|
+
return msg;
|
|
52
|
+
}
|
|
53
|
+
magenta(msg) {
|
|
54
|
+
return msg;
|
|
55
|
+
}
|
|
56
|
+
cyan(msg) {
|
|
57
|
+
return msg;
|
|
58
|
+
}
|
|
59
|
+
gray(msg) {
|
|
60
|
+
return msg;
|
|
61
|
+
}
|
|
62
|
+
bold(msg) {
|
|
63
|
+
return msg;
|
|
64
|
+
}
|
|
65
|
+
dim(msg) {
|
|
66
|
+
return msg;
|
|
67
|
+
}
|
|
68
|
+
bgRed(msg) {
|
|
69
|
+
return msg;
|
|
70
|
+
}
|
|
71
|
+
createTimeSpan(_startMsg, _debug = false) {
|
|
72
|
+
return {
|
|
73
|
+
duration() {
|
|
74
|
+
return 0;
|
|
75
|
+
},
|
|
76
|
+
finish() {
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
printDiagnostics(_diagnostics) {}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/testing/testing-sys.ts
|
|
86
|
+
function isTestingSystem(sys) {
|
|
87
|
+
return "diskReads" in sys && "diskWrites" in sys;
|
|
88
|
+
}
|
|
89
|
+
const createTestingSystem = () => {
|
|
90
|
+
let diskReads = 0;
|
|
91
|
+
let diskWrites = 0;
|
|
92
|
+
const sys = createSystem();
|
|
93
|
+
sys.platformPath = path$1;
|
|
94
|
+
sys.generateContentHash = (content, length) => {
|
|
95
|
+
let hash = createHash("sha1").update(content).digest("hex").toLowerCase();
|
|
96
|
+
if (typeof length === "number") hash = hash.slice(0, length);
|
|
97
|
+
return Promise.resolve(hash);
|
|
98
|
+
};
|
|
99
|
+
const wrapRead = (fn) => {
|
|
100
|
+
const orgFn = fn;
|
|
101
|
+
return (...args) => {
|
|
102
|
+
diskReads++;
|
|
103
|
+
return orgFn.apply(orgFn, args);
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
const wrapWrite = (fn) => {
|
|
107
|
+
const orgFn = fn;
|
|
108
|
+
return (...args) => {
|
|
109
|
+
diskWrites++;
|
|
110
|
+
return orgFn.apply(orgFn, args);
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
sys.access = wrapRead(sys.access);
|
|
114
|
+
sys.accessSync = wrapRead(sys.accessSync);
|
|
115
|
+
sys.homeDir = wrapRead(sys.homeDir);
|
|
116
|
+
sys.readFile = wrapRead(sys.readFile);
|
|
117
|
+
sys.readFileSync = wrapRead(sys.readFileSync);
|
|
118
|
+
sys.readDir = wrapRead(sys.readDir);
|
|
119
|
+
sys.readDirSync = wrapRead(sys.readDirSync);
|
|
120
|
+
sys.stat = wrapRead(sys.stat);
|
|
121
|
+
sys.statSync = wrapRead(sys.statSync);
|
|
122
|
+
sys.copyFile = wrapWrite(sys.copyFile);
|
|
123
|
+
sys.createDir = wrapWrite(sys.createDir);
|
|
124
|
+
sys.createDirSync = wrapWrite(sys.createDirSync);
|
|
125
|
+
sys.removeFile = wrapWrite(sys.removeFile);
|
|
126
|
+
sys.removeFileSync = wrapWrite(sys.removeFileSync);
|
|
127
|
+
sys.writeFile = wrapWrite(sys.writeFile);
|
|
128
|
+
sys.writeFileSync = wrapWrite(sys.writeFileSync);
|
|
129
|
+
sys.getCompilerExecutingPath = () => "bin/stencil.js";
|
|
130
|
+
Object.defineProperties(sys, {
|
|
131
|
+
diskReads: {
|
|
132
|
+
get() {
|
|
133
|
+
return diskReads;
|
|
134
|
+
},
|
|
135
|
+
set(val) {
|
|
136
|
+
diskReads = val;
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
diskWrites: {
|
|
140
|
+
get() {
|
|
141
|
+
return diskWrites;
|
|
142
|
+
},
|
|
143
|
+
set(val) {
|
|
144
|
+
diskWrites = val;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
if (!isTestingSystem(sys)) throw new Error("could not generate TestingSystem");
|
|
149
|
+
return sys;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/testing/mocks.ts
|
|
154
|
+
/**
|
|
155
|
+
* Generates a stub {@link d.ComponentCompilerMeta}. This function uses sensible defaults for the initial stub. However,
|
|
156
|
+
* any field in the object may be overridden via the `overrides` argument.
|
|
157
|
+
* @param overrides a partial implementation of `ComponentCompilerMeta`. Any provided fields will override the
|
|
158
|
+
* defaults provided by this function.
|
|
159
|
+
* @returns the stubbed `ComponentCompilerMeta`
|
|
160
|
+
*/
|
|
161
|
+
const mockComponentMeta = (overrides = {}) => ({
|
|
162
|
+
assetsDirs: [],
|
|
163
|
+
attachInternalsMemberName: null,
|
|
164
|
+
attachInternalsCustomStates: [],
|
|
165
|
+
componentClassName: "StubCmp",
|
|
166
|
+
dependencies: [],
|
|
167
|
+
dependents: [],
|
|
168
|
+
deserializers: [],
|
|
169
|
+
directDependencies: [],
|
|
170
|
+
directDependents: [],
|
|
171
|
+
docs: {
|
|
172
|
+
text: "docs",
|
|
173
|
+
tags: []
|
|
174
|
+
},
|
|
175
|
+
doesExtend: false,
|
|
176
|
+
elementRef: "",
|
|
177
|
+
encapsulation: "none",
|
|
178
|
+
events: [],
|
|
179
|
+
excludeFromCollection: false,
|
|
180
|
+
formAssociated: false,
|
|
181
|
+
hasAttribute: false,
|
|
182
|
+
hasAttributeChangedCallbackFn: false,
|
|
183
|
+
hasComponentDidLoadFn: false,
|
|
184
|
+
hasComponentDidRenderFn: false,
|
|
185
|
+
hasComponentDidUpdateFn: false,
|
|
186
|
+
hasComponentShouldUpdateFn: false,
|
|
187
|
+
hasComponentWillLoadFn: false,
|
|
188
|
+
hasComponentWillRenderFn: false,
|
|
189
|
+
hasComponentWillUpdateFn: false,
|
|
190
|
+
hasConnectedCallbackFn: false,
|
|
191
|
+
hasDeserializer: false,
|
|
192
|
+
hasDisconnectedCallbackFn: false,
|
|
193
|
+
hasElement: false,
|
|
194
|
+
hasEvent: false,
|
|
195
|
+
hasLifecycle: false,
|
|
196
|
+
hasListener: false,
|
|
197
|
+
hasListenerTarget: false,
|
|
198
|
+
hasListenerTargetBody: false,
|
|
199
|
+
hasListenerTargetDocument: false,
|
|
200
|
+
hasListenerTargetParent: false,
|
|
201
|
+
hasListenerTargetWindow: false,
|
|
202
|
+
hasMember: false,
|
|
203
|
+
hasMethod: false,
|
|
204
|
+
hasMode: false,
|
|
205
|
+
hasModernPropertyDecls: false,
|
|
206
|
+
hasProp: false,
|
|
207
|
+
hasPropBoolean: false,
|
|
208
|
+
hasPropMutable: false,
|
|
209
|
+
hasPropNumber: false,
|
|
210
|
+
hasPropString: false,
|
|
211
|
+
hasReflect: false,
|
|
212
|
+
hasRenderFn: false,
|
|
213
|
+
hasSerializer: false,
|
|
214
|
+
hasSlot: false,
|
|
215
|
+
hasState: false,
|
|
216
|
+
hasStyle: false,
|
|
217
|
+
hasVdomAttribute: false,
|
|
218
|
+
hasVdomClass: false,
|
|
219
|
+
hasVdomFunctional: false,
|
|
220
|
+
hasVdomKey: false,
|
|
221
|
+
hasVdomListener: false,
|
|
222
|
+
hasVdomPropOrAttr: false,
|
|
223
|
+
hasVdomRef: false,
|
|
224
|
+
hasVdomRender: false,
|
|
225
|
+
hasVdomStyle: false,
|
|
226
|
+
hasVdomText: false,
|
|
227
|
+
hasVdomXlink: false,
|
|
228
|
+
hasWatchCallback: false,
|
|
229
|
+
htmlAttrNames: [],
|
|
230
|
+
htmlParts: [],
|
|
231
|
+
htmlTagNames: [],
|
|
232
|
+
internal: false,
|
|
233
|
+
isCollectionDependency: false,
|
|
234
|
+
isPlain: false,
|
|
235
|
+
isUpdateable: false,
|
|
236
|
+
jsFilePath: "/some/stubbed/path/my-component.js",
|
|
237
|
+
listeners: [],
|
|
238
|
+
methods: [],
|
|
239
|
+
potentialCmpRefs: [],
|
|
240
|
+
properties: [],
|
|
241
|
+
serializers: [],
|
|
242
|
+
shadowDelegatesFocus: false,
|
|
243
|
+
slotAssignment: null,
|
|
244
|
+
sourceFilePath: "/some/stubbed/path/my-component.tsx",
|
|
245
|
+
sourceMapPath: "/some/stubbed/path/my-component.js.map",
|
|
246
|
+
states: [],
|
|
247
|
+
styleDocs: [],
|
|
248
|
+
styles: [],
|
|
249
|
+
tagName: "stub-cmp",
|
|
250
|
+
virtualProperties: [],
|
|
251
|
+
watchers: [],
|
|
252
|
+
...overrides
|
|
253
|
+
});
|
|
254
|
+
/**
|
|
255
|
+
* Creates a mock instance of an internal, validated Stencil configuration object
|
|
256
|
+
* the caller
|
|
257
|
+
* @param overrides a partial implementation of `ValidatedConfig`. Any provided fields will override the defaults
|
|
258
|
+
* provided by this function.
|
|
259
|
+
* @returns the mock Stencil configuration
|
|
260
|
+
*/
|
|
261
|
+
function mockValidatedConfig(overrides = {}) {
|
|
262
|
+
const baseConfig = mockConfig(overrides);
|
|
263
|
+
const rootDir = path.resolve("/");
|
|
264
|
+
return {
|
|
265
|
+
...baseConfig,
|
|
266
|
+
buildEs5: false,
|
|
267
|
+
cacheDir: ".stencil",
|
|
268
|
+
devMode: true,
|
|
269
|
+
devServer: {},
|
|
270
|
+
extras: {},
|
|
271
|
+
fsNamespace: "testing",
|
|
272
|
+
hashFileNames: false,
|
|
273
|
+
hashedFileNameLength: 8,
|
|
274
|
+
hydratedFlag: null,
|
|
275
|
+
logLevel: "info",
|
|
276
|
+
logger: mockLogger(),
|
|
277
|
+
minifyCss: false,
|
|
278
|
+
minifyJs: false,
|
|
279
|
+
namespace: "Testing",
|
|
280
|
+
outputTargets: baseConfig.outputTargets ?? [],
|
|
281
|
+
packageJsonFilePath: path.join(rootDir, "package.json"),
|
|
282
|
+
rootDir,
|
|
283
|
+
sourceMap: true,
|
|
284
|
+
srcDir: "/src",
|
|
285
|
+
srcIndexHtml: "src/index.html",
|
|
286
|
+
suppressReservedPublicNameWarnings: false,
|
|
287
|
+
sys: createTestingSystem(),
|
|
288
|
+
testing: {},
|
|
289
|
+
transformAliasedImportPaths: true,
|
|
290
|
+
rollupConfig: {
|
|
291
|
+
inputOptions: {},
|
|
292
|
+
outputOptions: {}
|
|
293
|
+
},
|
|
294
|
+
validatePrimaryPackageOutputTarget: false,
|
|
295
|
+
...overrides
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Creates a mock instance of a Stencil configuration entity. The mocked configuration has no guarantees around the
|
|
300
|
+
* types/validity of its data.
|
|
301
|
+
* @param overrides a partial implementation of `UnvalidatedConfig`. Any provided fields will override the defaults
|
|
302
|
+
* provided by this function.
|
|
303
|
+
* @returns the mock Stencil configuration
|
|
304
|
+
*/
|
|
305
|
+
function mockConfig(overrides = {}) {
|
|
306
|
+
const rootDir = path.resolve("/");
|
|
307
|
+
let { sys } = overrides;
|
|
308
|
+
if (!sys) sys = createTestingSystem();
|
|
309
|
+
sys.getCurrentDirectory = () => rootDir;
|
|
310
|
+
return {
|
|
311
|
+
_isTesting: true,
|
|
312
|
+
buildAppCore: false,
|
|
313
|
+
buildDist: true,
|
|
314
|
+
buildEs5: false,
|
|
315
|
+
bundles: null,
|
|
316
|
+
devMode: true,
|
|
317
|
+
enableCache: false,
|
|
318
|
+
extras: {},
|
|
319
|
+
globalScript: null,
|
|
320
|
+
hashFileNames: false,
|
|
321
|
+
logger: new TestingLogger(),
|
|
322
|
+
maxConcurrentWorkers: 0,
|
|
323
|
+
minifyCss: false,
|
|
324
|
+
minifyJs: false,
|
|
325
|
+
namespace: "Testing",
|
|
326
|
+
nodeResolve: { customResolveOptions: {} },
|
|
327
|
+
outputTargets: null,
|
|
328
|
+
rollupPlugins: {
|
|
329
|
+
before: [],
|
|
330
|
+
after: []
|
|
331
|
+
},
|
|
332
|
+
rootDir,
|
|
333
|
+
sourceMap: true,
|
|
334
|
+
suppressReservedPublicNameWarnings: false,
|
|
335
|
+
sys,
|
|
336
|
+
testing: null,
|
|
337
|
+
validateTypes: false,
|
|
338
|
+
...overrides
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Creates a configuration object used to bootstrap a Stencil task invocation
|
|
343
|
+
*
|
|
344
|
+
* Several fields are intentionally undefined for this entity. While it would be trivial to stub them out, this mock
|
|
345
|
+
* generation function operates under the assumption that entities like loggers and compiler system abstractions will
|
|
346
|
+
* be shared by multiple entities in a test suite, who should provide those entities to this function
|
|
347
|
+
*
|
|
348
|
+
* @param overrides the properties on the default entity to manually override
|
|
349
|
+
* @returns the default configuration initialization object, with any overrides applied
|
|
350
|
+
*/
|
|
351
|
+
const mockLoadConfigInit = (overrides) => {
|
|
352
|
+
return {
|
|
353
|
+
config: {},
|
|
354
|
+
configPath: void 0,
|
|
355
|
+
initTsConfig: true,
|
|
356
|
+
logger: void 0,
|
|
357
|
+
sys: void 0,
|
|
358
|
+
...overrides
|
|
359
|
+
};
|
|
360
|
+
};
|
|
361
|
+
function mockCompilerCtx(config) {
|
|
362
|
+
const innerConfig = config || mockValidatedConfig();
|
|
363
|
+
const compilerCtx = {
|
|
364
|
+
version: 1,
|
|
365
|
+
activeBuildId: 0,
|
|
366
|
+
activeDirsAdded: [],
|
|
367
|
+
activeDirsDeleted: [],
|
|
368
|
+
activeFilesAdded: [],
|
|
369
|
+
activeFilesDeleted: [],
|
|
370
|
+
activeFilesUpdated: [],
|
|
371
|
+
addWatchDir: noop,
|
|
372
|
+
addWatchFile: noop,
|
|
373
|
+
cachedGlobalStyle: null,
|
|
374
|
+
changedFiles: /* @__PURE__ */ new Set(),
|
|
375
|
+
changedModules: /* @__PURE__ */ new Set(),
|
|
376
|
+
collections: [],
|
|
377
|
+
compilerOptions: null,
|
|
378
|
+
cache: null,
|
|
379
|
+
cssModuleImports: /* @__PURE__ */ new Map(),
|
|
380
|
+
events: buildEvents(),
|
|
381
|
+
fs: null,
|
|
382
|
+
hasSuccessfulBuild: false,
|
|
383
|
+
isActivelyBuilding: false,
|
|
384
|
+
lastBuildResults: null,
|
|
385
|
+
moduleMap: /* @__PURE__ */ new Map(),
|
|
386
|
+
nodeMap: /* @__PURE__ */ new WeakMap(),
|
|
387
|
+
reset: noop,
|
|
388
|
+
resolvedCollections: /* @__PURE__ */ new Set(),
|
|
389
|
+
rollupCache: /* @__PURE__ */ new Map(),
|
|
390
|
+
rollupCacheHydrate: null,
|
|
391
|
+
rollupCacheLazy: null,
|
|
392
|
+
rollupCacheNative: null,
|
|
393
|
+
styleModeNames: /* @__PURE__ */ new Set(),
|
|
394
|
+
worker: createWorkerContext(innerConfig.sys)
|
|
395
|
+
};
|
|
396
|
+
Object.defineProperty(compilerCtx, "fs", { get() {
|
|
397
|
+
if (this._fs == null) this._fs = createInMemoryFs(innerConfig.sys);
|
|
398
|
+
return this._fs;
|
|
399
|
+
} });
|
|
400
|
+
Object.defineProperty(compilerCtx, "cache", { get() {
|
|
401
|
+
if (this._cache == null) this._cache = mockCache(innerConfig, compilerCtx);
|
|
402
|
+
return this._cache;
|
|
403
|
+
} });
|
|
404
|
+
return compilerCtx;
|
|
405
|
+
}
|
|
406
|
+
function mockBuildCtx(config, compilerCtx) {
|
|
407
|
+
const validatedConfig = config || mockValidatedConfig();
|
|
408
|
+
return new BuildContext(validatedConfig, compilerCtx || mockCompilerCtx(validatedConfig));
|
|
409
|
+
}
|
|
410
|
+
function mockCache(config, compilerCtx) {
|
|
411
|
+
config.enableCache = true;
|
|
412
|
+
const cache = new Cache(config, compilerCtx.fs);
|
|
413
|
+
cache.initCacheDir();
|
|
414
|
+
return cache;
|
|
415
|
+
}
|
|
416
|
+
function mockLogger() {
|
|
417
|
+
return new TestingLogger();
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Create a {@link d.CompilerSystem} entity for testing the compiler.
|
|
421
|
+
*
|
|
422
|
+
* This function acts as a thin wrapper around a {@link TestingSystem} entity creation. It exists to provide a logical
|
|
423
|
+
* place in the codebase where we might expect Stencil engineers to reach for when attempting to mock a
|
|
424
|
+
* {@link d.CompilerSystem} base type. Should there prove to be usage of both this function and the one it wraps,
|
|
425
|
+
* reconsider if this wrapper is necessary.
|
|
426
|
+
*
|
|
427
|
+
* @returns a System instance for testing purposes.
|
|
428
|
+
*/
|
|
429
|
+
function mockCompilerSystem() {
|
|
430
|
+
return createTestingSystem();
|
|
431
|
+
}
|
|
432
|
+
function mockDocument(html = null) {
|
|
433
|
+
return new MockWindow(html).document;
|
|
434
|
+
}
|
|
435
|
+
function mockWindow(html) {
|
|
436
|
+
return new MockWindow(html);
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* This gives you a mock Module, an interface which is the internal compiler
|
|
440
|
+
* representation of a module. It includes a bunch of information necessary for
|
|
441
|
+
* compilation, this mock basically sets sane defaults for all those values.
|
|
442
|
+
*
|
|
443
|
+
* @param mod is an override module that you can supply to set particular values
|
|
444
|
+
* @returns a module object ready to use in tests!
|
|
445
|
+
*/
|
|
446
|
+
const mockModule = (mod = {}) => ({
|
|
447
|
+
cmps: [],
|
|
448
|
+
isExtended: false,
|
|
449
|
+
isMixin: false,
|
|
450
|
+
hasExportableMixins: false,
|
|
451
|
+
coreRuntimeApis: [],
|
|
452
|
+
outputTargetCoreRuntimeApis: {},
|
|
453
|
+
collectionName: "",
|
|
454
|
+
dtsFilePath: "",
|
|
455
|
+
excludeFromCollection: false,
|
|
456
|
+
externalImports: [],
|
|
457
|
+
htmlAttrNames: [],
|
|
458
|
+
htmlTagNames: [],
|
|
459
|
+
htmlParts: [],
|
|
460
|
+
isCollectionDependency: false,
|
|
461
|
+
isLegacy: false,
|
|
462
|
+
jsFilePath: "",
|
|
463
|
+
localImports: [],
|
|
464
|
+
functionalComponentDeps: [],
|
|
465
|
+
originalImports: [],
|
|
466
|
+
originalCollectionComponentPath: "",
|
|
467
|
+
potentialCmpRefs: [],
|
|
468
|
+
sourceFilePath: "",
|
|
469
|
+
staticSourceFile: "",
|
|
470
|
+
staticSourceFileText: "",
|
|
471
|
+
sourceMapPath: "",
|
|
472
|
+
sourceMapFileText: "",
|
|
473
|
+
hasVdomAttribute: false,
|
|
474
|
+
hasVdomClass: false,
|
|
475
|
+
hasVdomFunctional: false,
|
|
476
|
+
hasVdomKey: false,
|
|
477
|
+
hasVdomListener: false,
|
|
478
|
+
hasVdomPropOrAttr: false,
|
|
479
|
+
hasVdomRef: false,
|
|
480
|
+
hasVdomRender: false,
|
|
481
|
+
hasVdomStyle: false,
|
|
482
|
+
hasVdomText: false,
|
|
483
|
+
hasVdomXlink: false,
|
|
484
|
+
...mod
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
//#endregion
|
|
488
|
+
//#region src/testing/platform/testing-constants.ts
|
|
489
|
+
const styles = /* @__PURE__ */ new Map();
|
|
490
|
+
const modeResolutionChain = [];
|
|
491
|
+
/**
|
|
492
|
+
* A mapping of custom element tags (e.g. `my-component`) to their constructor
|
|
493
|
+
*/
|
|
494
|
+
const cstrs = /* @__PURE__ */ new Map();
|
|
495
|
+
/**
|
|
496
|
+
* A collection of callbacks to run on a NodeJS process 'tick'
|
|
497
|
+
*/
|
|
498
|
+
const queuedTicks = [];
|
|
499
|
+
const queuedWriteTasks = [];
|
|
500
|
+
const queuedReadTasks = [];
|
|
501
|
+
const moduleLoaded = /* @__PURE__ */ new Map();
|
|
502
|
+
const queuedLoadModules = [];
|
|
503
|
+
/**
|
|
504
|
+
* A collection of errors that were detected to surface during the rendering process
|
|
505
|
+
*/
|
|
506
|
+
const caughtErrors = [];
|
|
507
|
+
|
|
508
|
+
//#endregion
|
|
509
|
+
//#region src/testing/platform/testing-build.ts
|
|
510
|
+
const Build = {
|
|
511
|
+
isDev: true,
|
|
512
|
+
isBrowser: false,
|
|
513
|
+
isServer: true,
|
|
514
|
+
isTesting: true
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
//#endregion
|
|
518
|
+
//#region src/testing/platform/testing-host-ref.ts
|
|
519
|
+
/**
|
|
520
|
+
* Retrieve the data structure tracking the component by its runtime reference
|
|
521
|
+
* @param elm the reference to the element
|
|
522
|
+
* @returns the corresponding Stencil reference data structure, or undefined if one cannot be found
|
|
523
|
+
*/
|
|
524
|
+
const getHostRef = (elm) => {
|
|
525
|
+
if (elm.__stencil__getHostRef) return elm.__stencil__getHostRef();
|
|
526
|
+
};
|
|
527
|
+
/**
|
|
528
|
+
* Add the provided `hostRef` instance to the global {@link hostRefs} map, using the provided `lazyInstance` as a key.
|
|
529
|
+
* @param lazyInstance a Stencil component instance
|
|
530
|
+
* @param hostRef an optional reference to Stencil's tracking data for the component. If none is provided, one will be created.
|
|
531
|
+
* @throws if the provided `lazyInstance` coerces to `null`, or if the `lazyInstance` does not have a `constructor`
|
|
532
|
+
* property
|
|
533
|
+
*/
|
|
534
|
+
const registerInstance = (lazyInstance, hostRef) => {
|
|
535
|
+
if (lazyInstance == null || lazyInstance.constructor == null) throw new Error(`Invalid component constructor`);
|
|
536
|
+
if (hostRef == null) {
|
|
537
|
+
const Cstr = lazyInstance.constructor;
|
|
538
|
+
const tagName = Cstr.COMPILER_META && Cstr.COMPILER_META.tagName ? Cstr.COMPILER_META.tagName : "div";
|
|
539
|
+
const elm = document.createElement(tagName);
|
|
540
|
+
registerHost(elm, {
|
|
541
|
+
$flags$: 0,
|
|
542
|
+
$tagName$: tagName
|
|
543
|
+
});
|
|
544
|
+
hostRef = getHostRef(elm);
|
|
545
|
+
}
|
|
546
|
+
lazyInstance.__stencil__getHostRef = () => hostRef;
|
|
547
|
+
hostRef.$lazyInstance$ = lazyInstance;
|
|
548
|
+
if (hostRef.$cmpMeta$?.$flags$ & CMP_FLAGS.hasModernPropertyDecls && (BUILD.state || BUILD.prop)) reWireGetterSetter(lazyInstance, hostRef);
|
|
549
|
+
const Cstr = lazyInstance.constructor;
|
|
550
|
+
const allEvents = [];
|
|
551
|
+
const seenEventMethods = /* @__PURE__ */ new Set();
|
|
552
|
+
if (Cstr.COMPILER_META && Cstr.COMPILER_META.events) Cstr.COMPILER_META.events.forEach((event) => {
|
|
553
|
+
if (!seenEventMethods.has(event.method)) {
|
|
554
|
+
allEvents.push(event);
|
|
555
|
+
seenEventMethods.add(event.method);
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
let currentProto = Object.getPrototypeOf(Cstr);
|
|
559
|
+
while (currentProto && currentProto !== Function.prototype && currentProto.name) {
|
|
560
|
+
if (typeof currentProto.events === "object" && Array.isArray(currentProto.events)) currentProto.events.forEach((event) => {
|
|
561
|
+
if (!seenEventMethods.has(event.method)) {
|
|
562
|
+
allEvents.push(event);
|
|
563
|
+
seenEventMethods.add(event.method);
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
currentProto = Object.getPrototypeOf(currentProto);
|
|
567
|
+
}
|
|
568
|
+
allEvents.forEach((eventMeta) => {
|
|
569
|
+
if (!lazyInstance[eventMeta.method]) {
|
|
570
|
+
let flags = 0;
|
|
571
|
+
if (eventMeta.bubbles) flags |= EVENT_FLAGS.Bubbles;
|
|
572
|
+
if (eventMeta.composed) flags |= EVENT_FLAGS.Composed;
|
|
573
|
+
if (eventMeta.cancelable) flags |= EVENT_FLAGS.Cancellable;
|
|
574
|
+
lazyInstance[eventMeta.method] = createEvent(lazyInstance, eventMeta.name, flags);
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
};
|
|
578
|
+
/**
|
|
579
|
+
* Create a new {@link d.HostRef} instance to the global {@link hostRefs} map, using the provided `elm` as a key.
|
|
580
|
+
* @param elm an HTMLElement instance associated with the Stencil component
|
|
581
|
+
* @param cmpMeta the component compiler metadata associated with the component
|
|
582
|
+
*/
|
|
583
|
+
const registerHost = (elm, cmpMeta) => {
|
|
584
|
+
const hostRef = {
|
|
585
|
+
$flags$: 0,
|
|
586
|
+
$hostElement$: elm,
|
|
587
|
+
$cmpMeta$: cmpMeta,
|
|
588
|
+
$instanceValues$: /* @__PURE__ */ new Map(),
|
|
589
|
+
$serializerValues$: /* @__PURE__ */ new Map(),
|
|
590
|
+
$renderCount$: 0
|
|
591
|
+
};
|
|
592
|
+
hostRef.$fetchedCbList$ = [];
|
|
593
|
+
hostRef.$onInstancePromise$ = new Promise((r) => hostRef.$onInstanceResolve$ = r);
|
|
594
|
+
hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
|
|
595
|
+
elm["s-p"] = [];
|
|
596
|
+
elm["s-rc"] = [];
|
|
597
|
+
elm.__stencil__getHostRef = () => hostRef;
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
//#endregion
|
|
601
|
+
//#region src/testing/platform/testing-log.ts
|
|
602
|
+
let customError;
|
|
603
|
+
const setErrorHandler = (handler) => customError = handler;
|
|
604
|
+
|
|
605
|
+
//#endregion
|
|
606
|
+
//#region src/testing/platform/testing-task-queue.ts
|
|
607
|
+
/**
|
|
608
|
+
* Reset the various data structures related to the testing rendering pipeline
|
|
609
|
+
*/
|
|
610
|
+
function resetTaskQueue() {
|
|
611
|
+
queuedTicks.length = 0;
|
|
612
|
+
queuedWriteTasks.length = 0;
|
|
613
|
+
queuedReadTasks.length = 0;
|
|
614
|
+
moduleLoaded.clear();
|
|
615
|
+
queuedLoadModules.length = 0;
|
|
616
|
+
caughtErrors.length = 0;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Execute the callbacks in {@link queuedTicks} on the next NodeJS tick.
|
|
620
|
+
*
|
|
621
|
+
* Callbacks are invoked in the order that they appear in `queuedTasks` at the time this function is invoked.
|
|
622
|
+
* Async callbacks are not `await`ed.
|
|
623
|
+
*
|
|
624
|
+
* Any callbacks that are added to `queuedTasks` while this function is running are scheduled to be flushed on the
|
|
625
|
+
* next tick.
|
|
626
|
+
*/
|
|
627
|
+
function flushTicks() {
|
|
628
|
+
return new Promise((resolve, reject) => {
|
|
629
|
+
function drain() {
|
|
630
|
+
try {
|
|
631
|
+
if (queuedTicks.length > 0) {
|
|
632
|
+
const writeTasks = queuedTicks.slice();
|
|
633
|
+
queuedTicks.length = 0;
|
|
634
|
+
let cb;
|
|
635
|
+
while (cb = writeTasks.shift()) cb(Date.now());
|
|
636
|
+
}
|
|
637
|
+
if (queuedTicks.length > 0) process.nextTick(drain);
|
|
638
|
+
else resolve();
|
|
639
|
+
} catch (e) {
|
|
640
|
+
reject(`flushTicks: ${e}`);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
process.nextTick(drain);
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Push a RequestAnimationFrame callback onto the {@link queuedWriteTasks} data structure
|
|
648
|
+
* @param cb the callback to push onto `queuedWriteTasks`
|
|
649
|
+
*/
|
|
650
|
+
function writeTask(cb) {
|
|
651
|
+
queuedWriteTasks.push(cb);
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Push a RequestAnimationFrame callback onto the {@link queuedReadTasks} data structure
|
|
655
|
+
* @param cb the callback to push onto `queuedReadTasks`
|
|
656
|
+
*/
|
|
657
|
+
function readTask(cb) {
|
|
658
|
+
queuedReadTasks.push(cb);
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Flush the {@link queuedReadTasks} and {@link queuedWriteTasks} data structures on the next NodeJS process tick.
|
|
662
|
+
*
|
|
663
|
+
* The read task queue is drained first, followed by the write task queue.
|
|
664
|
+
* For each queue:
|
|
665
|
+
* - Each task is processed in the order it is found in its respective data structure at the time `queuedReadTasks` and
|
|
666
|
+
* `queuedWriteTasks` are read (note: these queues are not read at the same time).
|
|
667
|
+
* - When a task queue is processed, it is marked as empty before acting on the entries in the queue.
|
|
668
|
+
* - Items added to either queue after it has been read for processing will be handled on the subsequent tick.
|
|
669
|
+
* - Async items will be `await`ed
|
|
670
|
+
*/
|
|
671
|
+
function flushQueue() {
|
|
672
|
+
return new Promise((resolve, reject) => {
|
|
673
|
+
async function drain() {
|
|
674
|
+
try {
|
|
675
|
+
if (queuedReadTasks.length > 0) {
|
|
676
|
+
const readTasks = queuedReadTasks.slice();
|
|
677
|
+
queuedReadTasks.length = 0;
|
|
678
|
+
let cb;
|
|
679
|
+
while (cb = readTasks.shift()) {
|
|
680
|
+
const result = cb(Date.now());
|
|
681
|
+
if (result != null && typeof result.then === "function") await result;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
if (queuedWriteTasks.length > 0) {
|
|
685
|
+
const writeTasks = queuedWriteTasks.slice();
|
|
686
|
+
queuedWriteTasks.length = 0;
|
|
687
|
+
let cb;
|
|
688
|
+
while (cb = writeTasks.shift()) {
|
|
689
|
+
const result = cb(Date.now());
|
|
690
|
+
if (result != null && typeof result.then === "function") await result;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
if (queuedReadTasks.length + queuedWriteTasks.length > 0) process.nextTick(drain);
|
|
694
|
+
else resolve();
|
|
695
|
+
} catch (e) {
|
|
696
|
+
reject(`flushQueue: ${e}`);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
process.nextTick(drain);
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
async function flushAll() {
|
|
703
|
+
while (queuedTicks.length + queuedLoadModules.length + queuedWriteTasks.length + queuedReadTasks.length > 0) {
|
|
704
|
+
await flushTicks();
|
|
705
|
+
await flushLoadModule();
|
|
706
|
+
await flushQueue();
|
|
707
|
+
}
|
|
708
|
+
if (caughtErrors.length > 0) {
|
|
709
|
+
const err = caughtErrors[0];
|
|
710
|
+
if (err == null) throw new Error("Error!");
|
|
711
|
+
if (typeof err === "string") throw new Error(err);
|
|
712
|
+
throw err;
|
|
713
|
+
}
|
|
714
|
+
return new Promise((resolve) => process.nextTick(resolve));
|
|
715
|
+
}
|
|
716
|
+
function flushLoadModule(bundleId) {
|
|
717
|
+
return new Promise((resolve, reject) => {
|
|
718
|
+
try {
|
|
719
|
+
process.nextTick(() => {
|
|
720
|
+
if (bundleId != null) {
|
|
721
|
+
for (let i = 0; i < queuedLoadModules.length; i++) if (queuedLoadModules[i].bundleId === bundleId) {
|
|
722
|
+
queuedLoadModules[i].resolve();
|
|
723
|
+
queuedLoadModules.splice(i, 1);
|
|
724
|
+
i--;
|
|
725
|
+
}
|
|
726
|
+
} else {
|
|
727
|
+
let queuedLoadModule;
|
|
728
|
+
while (queuedLoadModule = queuedLoadModules.shift()) queuedLoadModule.resolve();
|
|
729
|
+
}
|
|
730
|
+
resolve();
|
|
731
|
+
});
|
|
732
|
+
} catch (e) {
|
|
733
|
+
reject(`flushLoadModule: ${e}`);
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
//#endregion
|
|
739
|
+
//#region src/testing/platform/testing-window.ts
|
|
740
|
+
const isVitestEnvironment = typeof process !== "undefined" && process.env?.VITEST;
|
|
741
|
+
const existingWindow = typeof globalThis !== "undefined" && globalThis.window;
|
|
742
|
+
const win = isVitestEnvironment && existingWindow ? existingWindow : setupGlobal(global);
|
|
743
|
+
|
|
744
|
+
//#endregion
|
|
745
|
+
//#region src/testing/platform/testing-platform.ts
|
|
746
|
+
let supportsShadow = true;
|
|
747
|
+
const plt = {
|
|
748
|
+
$flags$: 0,
|
|
749
|
+
$resourcesUrl$: "",
|
|
750
|
+
jmp: (h) => h(),
|
|
751
|
+
raf: (h) => requestAnimationFrame(h),
|
|
752
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
753
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
754
|
+
ce: (eventName, opts) => new win.CustomEvent(eventName, opts)
|
|
755
|
+
};
|
|
756
|
+
/**
|
|
757
|
+
* Helper function to programmatically set shadow DOM support in testing scenarios.
|
|
758
|
+
*
|
|
759
|
+
* This function modifies the global {@link supportsShadow} variable.
|
|
760
|
+
*
|
|
761
|
+
* @param supports `true` if shadow DOM is supported, `false` otherwise
|
|
762
|
+
*/
|
|
763
|
+
const setSupportsShadowDom = (supports) => {
|
|
764
|
+
supportsShadow = supports;
|
|
765
|
+
};
|
|
766
|
+
/**
|
|
767
|
+
* Resets global testing variables and collections, so that a new set of tests can be started with a "clean slate".
|
|
768
|
+
*
|
|
769
|
+
* It is expected that this function be called between spec tests, and should be automatically configured by Stencil to
|
|
770
|
+
* do so.
|
|
771
|
+
*
|
|
772
|
+
* @param defaults default options for the {@link d.PlatformRuntime} used during testing. The values in this object
|
|
773
|
+
* with be assigned to the global {@link plt} object used during testing.
|
|
774
|
+
*/
|
|
775
|
+
function resetPlatform(defaults = {}) {
|
|
776
|
+
if (win && typeof win.close === "function") win.close();
|
|
777
|
+
styles.clear();
|
|
778
|
+
plt.$flags$ = 0;
|
|
779
|
+
Object.assign(plt, defaults);
|
|
780
|
+
if (plt.$orgLocNodes$ != null) {
|
|
781
|
+
plt.$orgLocNodes$.clear();
|
|
782
|
+
plt.$orgLocNodes$ = void 0;
|
|
783
|
+
}
|
|
784
|
+
resetTaskQueue();
|
|
785
|
+
stopAutoApplyChanges();
|
|
786
|
+
cstrs.clear();
|
|
787
|
+
}
|
|
788
|
+
let isAutoApplyingChanges = false;
|
|
789
|
+
let autoApplyTimer = void 0;
|
|
790
|
+
/**
|
|
791
|
+
* Cancels the JavaScript task of automatically flushing the render queue & applying DOM changes in tests
|
|
792
|
+
*/
|
|
793
|
+
function stopAutoApplyChanges() {
|
|
794
|
+
isAutoApplyingChanges = false;
|
|
795
|
+
if (autoApplyTimer) {
|
|
796
|
+
clearTimeout(autoApplyTimer);
|
|
797
|
+
autoApplyTimer = void 0;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* Creates a JavaScript task to flush the render pipeline without the user having to do so manually in their tests.
|
|
802
|
+
*/
|
|
803
|
+
async function startAutoApplyChanges() {
|
|
804
|
+
isAutoApplyingChanges = true;
|
|
805
|
+
flushAll().then(() => {
|
|
806
|
+
if (isAutoApplyingChanges) autoApplyTimer = setTimeout(() => {
|
|
807
|
+
startAutoApplyChanges();
|
|
808
|
+
}, 100);
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Registers a collection of component constructors with the global {@link cstrs} data structure
|
|
813
|
+
* @param Cstrs the component constructors to register
|
|
814
|
+
*/
|
|
815
|
+
const registerComponents = (Cstrs) => {
|
|
816
|
+
Cstrs.filter((Cstr) => Cstr.COMPILER_META).forEach((Cstr) => {
|
|
817
|
+
cstrs.set(Cstr.COMPILER_META.tagName, Cstr);
|
|
818
|
+
});
|
|
819
|
+
};
|
|
820
|
+
/**
|
|
821
|
+
* Add the provided component constructor, `Cstr`, to the {@link moduleLoaded} mapping, using the provided `bundleId`
|
|
822
|
+
* as the key
|
|
823
|
+
* @param bundleId the bundle identifier to use to store/retrieve the component constructor
|
|
824
|
+
* @param Cstr the component constructor to store
|
|
825
|
+
*/
|
|
826
|
+
function registerModule(bundleId, Cstr) {
|
|
827
|
+
moduleLoaded.set(bundleId, Cstr);
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
//#endregion
|
|
831
|
+
//#region src/testing/platform/index.ts
|
|
832
|
+
const setMode = (handler) => {
|
|
833
|
+
modeResolutionChain.length = 0;
|
|
834
|
+
modeResolutionChain.push(handler);
|
|
835
|
+
};
|
|
836
|
+
|
|
837
|
+
//#endregion
|
|
838
|
+
//#region src/testing/reset-build-conditionals.ts
|
|
839
|
+
/**
|
|
840
|
+
* Reset build conditionals used for testing to a known "good state".
|
|
841
|
+
*
|
|
842
|
+
* This function does not return a value, but rather mutates its argument in place.
|
|
843
|
+
* Certain values are set to `true` or `false` for testing purpose (see this function's implementation for the full
|
|
844
|
+
* list). Build conditional options _not_ in that list that are set to `true` when this function is invoked will remain
|
|
845
|
+
* set to `true`.
|
|
846
|
+
*
|
|
847
|
+
* @param b the build conditionals to reset.
|
|
848
|
+
*/
|
|
849
|
+
function resetBuildConditionals(b) {
|
|
850
|
+
Object.keys(b).forEach((key) => {
|
|
851
|
+
b[key] = true;
|
|
852
|
+
});
|
|
853
|
+
b.isDev = true;
|
|
854
|
+
b.isTesting = true;
|
|
855
|
+
b.isDebug = false;
|
|
856
|
+
b.lazyLoad = true;
|
|
857
|
+
b.member = true;
|
|
858
|
+
b.reflect = true;
|
|
859
|
+
b.scoped = true;
|
|
860
|
+
b.shadowDom = true;
|
|
861
|
+
b.slotRelocation = true;
|
|
862
|
+
b.asyncLoading = true;
|
|
863
|
+
b.svg = true;
|
|
864
|
+
b.updatable = true;
|
|
865
|
+
b.vdomAttribute = true;
|
|
866
|
+
b.vdomClass = true;
|
|
867
|
+
b.vdomFunctional = true;
|
|
868
|
+
b.vdomKey = true;
|
|
869
|
+
b.vdomPropOrAttr = true;
|
|
870
|
+
b.vdomRef = true;
|
|
871
|
+
b.vdomListener = true;
|
|
872
|
+
b.vdomStyle = true;
|
|
873
|
+
b.vdomText = true;
|
|
874
|
+
b.vdomXlink = true;
|
|
875
|
+
b.allRenderFn = false;
|
|
876
|
+
b.devTools = false;
|
|
877
|
+
b.hydrateClientSide = false;
|
|
878
|
+
b.hydrateServerSide = false;
|
|
879
|
+
b.cssAnnotations = false;
|
|
880
|
+
b.style = false;
|
|
881
|
+
b.hydratedAttribute = false;
|
|
882
|
+
b.hydratedClass = true;
|
|
883
|
+
b.invisiblePrehydration = true;
|
|
884
|
+
b.appendChildSlotFix = false;
|
|
885
|
+
b.cloneNodeFix = false;
|
|
886
|
+
b.hotModuleReplacement = false;
|
|
887
|
+
b.scopedSlotTextContentFix = false;
|
|
888
|
+
b.slotChildNodesFix = false;
|
|
889
|
+
b.experimentalSlotFixes = false;
|
|
890
|
+
b.experimentalScopedSlotChanges = false;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
//#endregion
|
|
894
|
+
//#region src/testing/spec-page.ts
|
|
895
|
+
/**
|
|
896
|
+
* Generates a random number for use in generating a bundle id
|
|
897
|
+
* @returns a random number between 100000 and 999999
|
|
898
|
+
*/
|
|
899
|
+
const generateRandBundleId = () => Math.round(Math.random() * 899999) + 1e5;
|
|
900
|
+
/**
|
|
901
|
+
* Creates a new spec page for unit testing
|
|
902
|
+
* @param opts the options to apply to the spec page that influence its configuration and operation
|
|
903
|
+
* @returns the created spec page
|
|
904
|
+
*/
|
|
905
|
+
async function newSpecPage(opts) {
|
|
906
|
+
if (opts == null) throw new Error(`NewSpecPageOptions required`);
|
|
907
|
+
resetPlatform(opts.platform ?? {});
|
|
908
|
+
resetBuildConditionals(BUILD);
|
|
909
|
+
if (Array.isArray(opts.components)) registerComponents(opts.components);
|
|
910
|
+
if (opts.hydrateClientSide) opts.includeAnnotations = true;
|
|
911
|
+
if (opts.hydrateServerSide) {
|
|
912
|
+
opts.includeAnnotations = true;
|
|
913
|
+
setSupportsShadowDom(false);
|
|
914
|
+
} else {
|
|
915
|
+
opts.includeAnnotations = !!opts.includeAnnotations;
|
|
916
|
+
if (opts.supportsShadowDom === false) setSupportsShadowDom(false);
|
|
917
|
+
else setSupportsShadowDom(true);
|
|
918
|
+
}
|
|
919
|
+
BUILD.cssAnnotations = opts.includeAnnotations;
|
|
920
|
+
const cmpTags = /* @__PURE__ */ new Set();
|
|
921
|
+
win["__stencil_spec_options"] = opts;
|
|
922
|
+
const doc = win.document;
|
|
923
|
+
const page = {
|
|
924
|
+
win,
|
|
925
|
+
doc,
|
|
926
|
+
body: doc.body,
|
|
927
|
+
build: BUILD,
|
|
928
|
+
styles,
|
|
929
|
+
setContent: (html) => {
|
|
930
|
+
doc.body.innerHTML = html;
|
|
931
|
+
return flushAll();
|
|
932
|
+
},
|
|
933
|
+
waitForChanges: flushAll,
|
|
934
|
+
flushLoadModule,
|
|
935
|
+
flushQueue
|
|
936
|
+
};
|
|
937
|
+
const lazyBundles = opts.components.map((Cstr) => {
|
|
938
|
+
/**
|
|
939
|
+
* just pass through functional components that don't have styles nor any other metadata
|
|
940
|
+
*/
|
|
941
|
+
if (Cstr.COMPILER_META == null) return formatLazyBundleRuntimeMeta(`fc.${generateRandBundleId()}`, []);
|
|
942
|
+
cmpTags.add(Cstr.COMPILER_META.tagName);
|
|
943
|
+
Cstr.isProxied = false;
|
|
944
|
+
proxyComponentLifeCycles(Cstr);
|
|
945
|
+
const bundleId = `${Cstr.COMPILER_META.tagName}.${generateRandBundleId()}`;
|
|
946
|
+
const stylesMeta = Cstr.COMPILER_META.styles;
|
|
947
|
+
if (Array.isArray(stylesMeta)) {
|
|
948
|
+
if (stylesMeta.length > 1) {
|
|
949
|
+
const styles = {};
|
|
950
|
+
stylesMeta.forEach((style) => {
|
|
951
|
+
styles[style.modeName] = style.styleStr;
|
|
952
|
+
});
|
|
953
|
+
Cstr.style = styles;
|
|
954
|
+
} else if (stylesMeta.length === 1) Cstr.style = stylesMeta[0].styleStr;
|
|
955
|
+
}
|
|
956
|
+
registerModule(bundleId, Cstr);
|
|
957
|
+
return formatLazyBundleRuntimeMeta(bundleId, [Cstr.COMPILER_META]);
|
|
958
|
+
});
|
|
959
|
+
const cmpBuild = getBuildFeatures(opts.components.filter((Cstr) => Cstr.COMPILER_META != null).map((Cstr) => Cstr.COMPILER_META));
|
|
960
|
+
if (opts.strictBuild) Object.assign(BUILD, cmpBuild);
|
|
961
|
+
else Object.keys(cmpBuild).forEach((key) => {
|
|
962
|
+
if (cmpBuild[key] === true) BUILD[key] = true;
|
|
963
|
+
});
|
|
964
|
+
BUILD.asyncLoading = true;
|
|
965
|
+
if (opts.hydrateClientSide) {
|
|
966
|
+
BUILD.hydrateClientSide = true;
|
|
967
|
+
BUILD.hydrateServerSide = false;
|
|
968
|
+
} else if (opts.hydrateServerSide) {
|
|
969
|
+
BUILD.hydrateServerSide = true;
|
|
970
|
+
BUILD.hydrateClientSide = false;
|
|
971
|
+
}
|
|
972
|
+
BUILD.cloneNodeFix = false;
|
|
973
|
+
BUILD.shadowDomShim = false;
|
|
974
|
+
BUILD.attachStyles = !!opts.attachStyles;
|
|
975
|
+
if (typeof opts.url === "string") page.win.location.href = opts.url;
|
|
976
|
+
if (typeof opts.direction === "string") page.doc.documentElement.setAttribute("dir", opts.direction);
|
|
977
|
+
if (typeof opts.language === "string") page.doc.documentElement.setAttribute("lang", opts.language);
|
|
978
|
+
if (typeof opts.cookie === "string") try {
|
|
979
|
+
page.doc.cookie = opts.cookie;
|
|
980
|
+
} catch (e) {}
|
|
981
|
+
if (typeof opts.referrer === "string") try {
|
|
982
|
+
page.doc.referrer = opts.referrer;
|
|
983
|
+
} catch (e) {}
|
|
984
|
+
if (typeof opts.userAgent === "string") try {
|
|
985
|
+
page.win.navigator.userAgent = opts.userAgent;
|
|
986
|
+
} catch (e) {}
|
|
987
|
+
bootstrapLazy(lazyBundles);
|
|
988
|
+
if (typeof opts.template === "function") renderVdom({
|
|
989
|
+
$ancestorComponent$: void 0,
|
|
990
|
+
$flags$: 0,
|
|
991
|
+
$modeName$: void 0,
|
|
992
|
+
$cmpMeta$: {
|
|
993
|
+
$flags$: 0,
|
|
994
|
+
$tagName$: "body"
|
|
995
|
+
},
|
|
996
|
+
$hostElement$: page.body
|
|
997
|
+
}, opts.template());
|
|
998
|
+
else if (typeof opts.html === "string") page.body.innerHTML = opts.html;
|
|
999
|
+
if (opts.flushQueue !== false) await page.waitForChanges();
|
|
1000
|
+
let rootComponent = null;
|
|
1001
|
+
Object.defineProperty(page, "root", { get() {
|
|
1002
|
+
if (rootComponent == null) rootComponent = findRootComponent(cmpTags, page.body);
|
|
1003
|
+
if (rootComponent != null) return rootComponent;
|
|
1004
|
+
const firstElementChild = page.body.firstElementChild;
|
|
1005
|
+
if (firstElementChild != null) return firstElementChild;
|
|
1006
|
+
return null;
|
|
1007
|
+
} });
|
|
1008
|
+
Object.defineProperty(page, "rootInstance", { get() {
|
|
1009
|
+
const hostRef = getHostRef(page.root);
|
|
1010
|
+
if (hostRef != null) return hostRef.$lazyInstance$;
|
|
1011
|
+
return null;
|
|
1012
|
+
} });
|
|
1013
|
+
if (opts.hydrateServerSide) insertVdomAnnotations(doc, []);
|
|
1014
|
+
if (opts.autoApplyChanges) {
|
|
1015
|
+
startAutoApplyChanges();
|
|
1016
|
+
page.waitForChanges = () => {
|
|
1017
|
+
console.error("waitForChanges() cannot be used manually if the \"startAutoApplyChanges\" option is enabled");
|
|
1018
|
+
return Promise.resolve();
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
return page;
|
|
1022
|
+
}
|
|
1023
|
+
/**
|
|
1024
|
+
* A helper method that proxies Stencil lifecycle methods by mutating the provided component class
|
|
1025
|
+
* @param Cstr the component class whose lifecycle methods will be proxied
|
|
1026
|
+
*/
|
|
1027
|
+
function proxyComponentLifeCycles(Cstr) {
|
|
1028
|
+
if (typeof Cstr.prototype?.__componentWillLoad === "function") {
|
|
1029
|
+
Cstr.prototype.componentWillLoad = Cstr.prototype.__componentWillLoad;
|
|
1030
|
+
Cstr.prototype.__componentWillLoad = null;
|
|
1031
|
+
}
|
|
1032
|
+
if (typeof Cstr.prototype?.__componentWillUpdate === "function") {
|
|
1033
|
+
Cstr.prototype.componentWillUpdate = Cstr.prototype.__componentWillUpdate;
|
|
1034
|
+
Cstr.prototype.__componentWillUpdate = null;
|
|
1035
|
+
}
|
|
1036
|
+
if (typeof Cstr.prototype?.__componentWillRender === "function") {
|
|
1037
|
+
Cstr.prototype.componentWillRender = Cstr.prototype.__componentWillRender;
|
|
1038
|
+
Cstr.prototype.__componentWillRender = null;
|
|
1039
|
+
}
|
|
1040
|
+
if (typeof Cstr.prototype?.componentWillLoad === "function") {
|
|
1041
|
+
Cstr.prototype.__componentWillLoad = Cstr.prototype.componentWillLoad;
|
|
1042
|
+
Cstr.prototype.componentWillLoad = function() {
|
|
1043
|
+
const result = this.__componentWillLoad();
|
|
1044
|
+
if (result != null && typeof result.then === "function") writeTask(() => result);
|
|
1045
|
+
else writeTask(() => Promise.resolve());
|
|
1046
|
+
return result;
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
if (typeof Cstr.prototype?.componentWillUpdate === "function") {
|
|
1050
|
+
Cstr.prototype.__componentWillUpdate = Cstr.prototype.componentWillUpdate;
|
|
1051
|
+
Cstr.prototype.componentWillUpdate = function() {
|
|
1052
|
+
const result = this.__componentWillUpdate();
|
|
1053
|
+
if (result != null && typeof result.then === "function") writeTask(() => result);
|
|
1054
|
+
else writeTask(() => Promise.resolve());
|
|
1055
|
+
return result;
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
if (typeof Cstr.prototype?.componentWillRender === "function") {
|
|
1059
|
+
Cstr.prototype.__componentWillRender = Cstr.prototype.componentWillRender;
|
|
1060
|
+
Cstr.prototype.componentWillRender = function() {
|
|
1061
|
+
const result = this.__componentWillRender();
|
|
1062
|
+
if (result != null && typeof result.then === "function") writeTask(() => result);
|
|
1063
|
+
else writeTask(() => Promise.resolve());
|
|
1064
|
+
return result;
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Return the first Element whose {@link Element#nodeName} property matches a tag found in the provided `cmpTags`
|
|
1070
|
+
* argument.
|
|
1071
|
+
*
|
|
1072
|
+
* If the `nodeName` property on the element matches any of the names found in the provided `cmpTags` argument, that
|
|
1073
|
+
* element is returned. If no match is found on the current element, the children will be inspected in a depth-first
|
|
1074
|
+
* search manner. This process continues until either:
|
|
1075
|
+
* - an element is found (and execution ends)
|
|
1076
|
+
* - no element is found after an exhaustive search
|
|
1077
|
+
*
|
|
1078
|
+
* @param cmpTags component tag names to use in the match criteria
|
|
1079
|
+
* @param node the node whose children are to be inspected
|
|
1080
|
+
* @returns An element whose name matches one of the strings in the provided `cmpTags`. If no match is found, `null` is
|
|
1081
|
+
* returned
|
|
1082
|
+
*/
|
|
1083
|
+
function findRootComponent(cmpTags, node) {
|
|
1084
|
+
if (node != null) {
|
|
1085
|
+
const children = node.children;
|
|
1086
|
+
const childrenLength = children.length;
|
|
1087
|
+
for (let i = 0; i < childrenLength; i++) {
|
|
1088
|
+
const elm = children[i];
|
|
1089
|
+
if (cmpTags.has(elm.nodeName.toLowerCase())) return elm;
|
|
1090
|
+
}
|
|
1091
|
+
for (let i = 0; i < childrenLength; i++) {
|
|
1092
|
+
const r = findRootComponent(cmpTags, children[i]);
|
|
1093
|
+
if (r != null) return r;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
return null;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
//#endregion
|
|
1100
|
+
//#region src/testing/testing-utils.ts
|
|
1101
|
+
/**
|
|
1102
|
+
* Shuffle an array using Fisher-Yates algorithm
|
|
1103
|
+
* http://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array
|
|
1104
|
+
*/
|
|
1105
|
+
function shuffleArray(array) {
|
|
1106
|
+
let currentIndex = array.length;
|
|
1107
|
+
let temporaryValue;
|
|
1108
|
+
let randomIndex;
|
|
1109
|
+
while (0 !== currentIndex) {
|
|
1110
|
+
randomIndex = Math.floor(Math.random() * currentIndex);
|
|
1111
|
+
currentIndex -= 1;
|
|
1112
|
+
temporaryValue = array[currentIndex];
|
|
1113
|
+
array[currentIndex] = array[randomIndex];
|
|
1114
|
+
array[randomIndex] = temporaryValue;
|
|
1115
|
+
}
|
|
1116
|
+
return array;
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Utility for silencing `console` functions in tests.
|
|
1120
|
+
*
|
|
1121
|
+
* When this function is first called it grabs a reference to the `log`,
|
|
1122
|
+
* `error`, and `warn` functions on `console` and then returns a per-test setup
|
|
1123
|
+
* function which sets up a fresh set of mocks (via `jest.fn()`) and then
|
|
1124
|
+
* assigns them to each of these functions. This setup function will return a
|
|
1125
|
+
* reference to each of the three mock functions so tests can make assertions
|
|
1126
|
+
* about their calls and so on.
|
|
1127
|
+
*
|
|
1128
|
+
* Because references to the original `.log`, `.error`, and `.warn` functions
|
|
1129
|
+
* exist in closure within the function, it can use an `afterAll` call to clean
|
|
1130
|
+
* up after itself and ensure that the original implementations are restored
|
|
1131
|
+
* after the test suite finishes.
|
|
1132
|
+
*
|
|
1133
|
+
* An example of using this to silence log statements in a single test could look
|
|
1134
|
+
* like this:
|
|
1135
|
+
*
|
|
1136
|
+
* ```ts
|
|
1137
|
+
* describe("my-test-suite", () => {
|
|
1138
|
+
* const { setupConsoleMocks, teardownConsoleMocks } = setupConsoleMocker()
|
|
1139
|
+
*
|
|
1140
|
+
* it("should log a message", () => {
|
|
1141
|
+
* const { logMock } = setupConsoleMocks();
|
|
1142
|
+
* myFunctionWhichLogs(foo, bar);
|
|
1143
|
+
* expect(logMock).toBeCalledWith('my log message');
|
|
1144
|
+
* teardownConsoleMocks();
|
|
1145
|
+
* })
|
|
1146
|
+
* })
|
|
1147
|
+
* ```
|
|
1148
|
+
*
|
|
1149
|
+
* @returns a per-test mock setup function
|
|
1150
|
+
*/
|
|
1151
|
+
function setupConsoleMocker() {
|
|
1152
|
+
const originalLog = console.log;
|
|
1153
|
+
const originalWarn = console.warn;
|
|
1154
|
+
const originalError = console.error;
|
|
1155
|
+
/**
|
|
1156
|
+
* Function to tear down console mocks where you're done with them! Ideally
|
|
1157
|
+
* this would be called right after the assertion you're looking to make in
|
|
1158
|
+
* your test.
|
|
1159
|
+
*/
|
|
1160
|
+
function teardownConsoleMocks() {
|
|
1161
|
+
console.log = originalLog;
|
|
1162
|
+
console.warn = originalWarn;
|
|
1163
|
+
console.error = originalError;
|
|
1164
|
+
}
|
|
1165
|
+
afterAll(() => {
|
|
1166
|
+
teardownConsoleMocks();
|
|
1167
|
+
});
|
|
1168
|
+
function setupConsoleMocks() {
|
|
1169
|
+
const logMock = vi.fn();
|
|
1170
|
+
const warnMock = vi.fn();
|
|
1171
|
+
const errorMock = vi.fn();
|
|
1172
|
+
console.log = logMock;
|
|
1173
|
+
console.warn = warnMock;
|
|
1174
|
+
console.error = errorMock;
|
|
1175
|
+
return {
|
|
1176
|
+
logMock,
|
|
1177
|
+
warnMock,
|
|
1178
|
+
errorMock
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
return {
|
|
1182
|
+
setupConsoleMocks,
|
|
1183
|
+
teardownConsoleMocks
|
|
1184
|
+
};
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
//#endregion
|
|
1188
|
+
export { Build, Env, Fragment, Host, Mixin, createEvent, createTestingSystem, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, h, mockBuildCtx, mockCompilerCtx, mockCompilerSystem, mockComponentMeta, mockConfig, mockDocument, mockLoadConfigInit, mockLogger, mockModule, mockValidatedConfig, mockWindow, newSpecPage, readTask, registerHost, registerInstance, setAssetPath, setErrorHandler, setMode, setupConsoleMocker, shuffleArray, writeTask };
|