@stacksjs/stx 0.2.94 → 0.2.96
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/dist/a11y.js +598 -2
- package/dist/analytics.js +159 -2
- package/dist/analyzer.js +240 -2
- package/dist/animation.js +688 -2
- package/dist/app-shell.js +220 -2
- package/dist/app.js +79 -2
- package/dist/assets.js +155 -2
- package/dist/ast.js +630 -2
- package/dist/async-components.js +428 -2
- package/dist/auth.js +12 -2
- package/dist/broadcasting.js +102 -2
- package/dist/browser-composables.js +565 -2
- package/dist/build-assets.js +29 -2
- package/dist/build-mode-detector.js +50 -2
- package/dist/build-optimizer.js +433 -2
- package/dist/build-views.js +180 -2
- package/dist/build.js +33 -2
- package/dist/builtins/drawer.js +37 -2
- package/dist/builtins/escape.js +3 -2
- package/dist/builtins/icon.js +83 -2
- package/dist/builtins/index.js +34 -2
- package/dist/builtins/modal.js +38 -2
- package/dist/builtins/safe-image.js +51 -2
- package/dist/builtins/stx-image.js +200 -2
- package/dist/builtins/stx-link.js +41 -2
- package/dist/builtins/stx-loading-indicator.js +35 -2
- package/dist/builtins/suspense.js +24 -2
- package/dist/builtins/toast.js +42 -2
- package/dist/builtins/tooltip.js +106 -2
- package/dist/builtins/transition-group.js +22 -2
- package/dist/bundle-analyzer/collector.js +233 -2
- package/dist/bundle-analyzer/index.js +82 -2
- package/dist/bundle-analyzer/report.js +318 -2
- package/dist/bundle-analyzer/treemap.js +594 -2
- package/dist/caching.js +131 -2
- package/dist/cli.js +11317 -10982
- package/dist/client/directive.js +14 -2
- package/dist/client/index.js +2 -2
- package/dist/client-helpers.js +312 -2
- package/dist/client-script-bundler.js +216 -6
- package/dist/client-script.js +754 -2
- package/dist/client.js +73 -4
- package/dist/component-hmr.js +585 -2
- package/dist/component-library.d.ts +6 -0
- package/dist/component-library.js +683 -0
- package/dist/component-processing.js +613 -2
- package/dist/component-registry.js +90 -2
- package/dist/component-renderer.js +660 -2
- package/dist/components.js +213 -2
- package/dist/composables/index.js +220 -2
- package/dist/composables/use-battery.js +101 -2
- package/dist/composables/use-broadcast-channel.js +80 -2
- package/dist/composables/use-channel.js +124 -2
- package/dist/composables/use-clipboard.js +79 -2
- package/dist/composables/use-color-mode.js +131 -2
- package/dist/composables/use-cookie.js +86 -2
- package/dist/composables/use-device-orientation.js +181 -2
- package/dist/composables/use-event-listener.js +27 -2
- package/dist/composables/use-event-source.js +166 -2
- package/dist/composables/use-eye-dropper.js +142 -2
- package/dist/composables/use-fetch.js +223 -2
- package/dist/composables/use-fullscreen.js +110 -2
- package/dist/composables/use-geolocation.js +101 -2
- package/dist/composables/use-idle.js +182 -2
- package/dist/composables/use-intersection-observer.js +168 -2
- package/dist/composables/use-keyboard.js +224 -2
- package/dist/composables/use-media-query.js +62 -2
- package/dist/composables/use-meta.js +48 -2
- package/dist/composables/use-mouse.js +286 -2
- package/dist/composables/use-mutation-observer.js +129 -2
- package/dist/composables/use-network.js +85 -2
- package/dist/composables/use-notification.js +94 -2
- package/dist/composables/use-permissions.js +132 -2
- package/dist/composables/use-query.js +0 -1
- package/dist/composables/use-resize-observer.js +157 -2
- package/dist/composables/use-router.js +51 -2
- package/dist/composables/use-share.js +104 -2
- package/dist/composables/use-speech.js +294 -2
- package/dist/composables/use-storage.js +130 -2
- package/dist/composables/use-text-selection.js +205 -4
- package/dist/composables/use-timer.js +183 -2
- package/dist/composables/use-utilities.js +176 -2
- package/dist/composables/use-wake-lock.js +122 -2
- package/dist/composables/use-websocket.js +165 -2
- package/dist/composables/use-window.js +163 -2
- package/dist/composables.js +552 -2
- package/dist/composition-api.js +190 -2
- package/dist/computed.js +376 -8
- package/dist/conditionals.js +599 -2
- package/dist/config.js +751 -2
- package/dist/craft-bridge.js +432 -2
- package/dist/craft-compiler.js +810 -2
- package/dist/craft-components.js +945 -2
- package/dist/craft-entry.js +5 -2
- package/dist/craft-ssr.js +559 -2
- package/dist/csp.js +220 -2
- package/dist/csrf.js +38 -2
- package/dist/custom-directives.js +136 -2
- package/dist/defer.js +156 -2
- package/dist/deploy/config-generators.js +214 -2
- package/dist/deploy/index.js +203 -2
- package/dist/deploy/netlify.js +167 -2
- package/dist/dev-server/crosswind.js +379 -2
- package/dist/dev-server/index.js +7 -2
- package/dist/dev-server/keyboard-shortcuts.js +81 -2
- package/dist/dev-server/native-window.js +91 -2
- package/dist/dev-server/port-utils.js +40 -2
- package/dist/dev-server/serve-app.js +682 -7
- package/dist/dev-server/serve-file.js +439 -7
- package/dist/dev-server/serve-markdown.js +281 -2
- package/dist/dev-server/serve-multi.js +424 -17
- package/dist/dev-server/terminal-colors.js +45 -2
- package/dist/dev-server/theme-selector.js +111 -2
- package/dist/dev-server/types.js +43 -2
- package/dist/dev-server.js +4 -2
- package/dist/devtools.js +462 -18
- package/dist/directive-api.js +355 -2
- package/dist/docs.js +567 -2
- package/dist/doctor.js +123 -2
- package/dist/document-shell.js +105 -2
- package/dist/dynamic-components.js +78 -2
- package/dist/edge-runtime.js +539 -2
- package/dist/env.js +9 -2
- package/dist/error-boundaries.js +62 -12
- package/dist/error-handling.js +1 -2
- package/dist/errors/codes.js +97 -2
- package/dist/errors/formatter.js +196 -2
- package/dist/errors/index.js +44 -2
- package/dist/errors/logger.js +250 -2
- package/dist/errors/sanitizer.js +181 -2
- package/dist/errors/types.js +86 -2
- package/dist/events.js +382 -2
- package/dist/expressions.js +650 -2
- package/dist/formatter.js +265 -2
- package/dist/forms-validation.js +510 -4
- package/dist/forms.js +709 -2
- package/dist/head.js +224 -2
- package/dist/heatmap.js +566 -2
- package/dist/hot-reload.js +367 -2
- package/dist/html-masking.js +73 -2
- package/dist/hydration-runtime.js +195 -2
- package/dist/hydration.js +654 -2
- package/dist/i18n.js +633 -2
- package/dist/image-optimization/auto-sibling.js +88 -2
- package/dist/image-optimization/build-plugin.js +241 -2
- package/dist/image-optimization/component.js +244 -2
- package/dist/image-optimization/directive.js +203 -2
- package/dist/image-optimization/index.js +54 -2
- package/dist/image-optimization/processor.js +262 -2
- package/dist/image-optimization/serve.js +102 -2
- package/dist/includes.js +733 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +134 -2
- package/dist/init.js +505 -2
- package/dist/inline-assets.js +82 -2
- package/dist/interactive.js +383 -2
- package/dist/internal-markdown.js +141 -2
- package/dist/island-chunking.js +52 -2
- package/dist/js-ts.js +57 -2
- package/dist/jsx-runtime.js +289 -2
- package/dist/keep-alive.js +421 -2
- package/dist/lazy-loader.js +245 -2
- package/dist/loading-indicator.js +322 -2
- package/dist/loops.js +643 -2
- package/dist/manifest.js +31 -2
- package/dist/markdown.js +68 -2
- package/dist/media/client/blur-up.js +217 -2
- package/dist/media/client/index.js +53 -2
- package/dist/media/client/lazy-load.js +283 -2
- package/dist/media/client/upload-handler.js +354 -2
- package/dist/media/image/component.js +574 -2
- package/dist/media/image/directive.js +160 -2
- package/dist/media/image/editing.js +193 -2
- package/dist/media/image/index.js +80 -2
- package/dist/media/image/placeholder.js +188 -2
- package/dist/media/image/processor/cache.js +51 -2
- package/dist/media/image/processor/index.js +3 -2
- package/dist/media/image/processor/optimizer.js +202 -2
- package/dist/media/image/processor/responsive.js +162 -2
- package/dist/media/image/srcset.js +194 -2
- package/dist/media/index.js +198 -2
- package/dist/media/manager/embed.js +253 -2
- package/dist/media/protected/component.js +235 -2
- package/dist/media/protected/index.js +20 -2
- package/dist/media/protected/signature.js +205 -2
- package/dist/media/shared/cache.js +132 -2
- package/dist/media/shared/hash.js +35 -2
- package/dist/media/shared/index.js +2 -2
- package/dist/media/types.js +0 -1
- package/dist/media/upload/component.js +320 -2
- package/dist/media/upload/index.js +1 -2
- package/dist/media/video/directive.js +142 -2
- package/dist/media/video/index.js +583 -2
- package/dist/media/video/processor/cache.js +52 -2
- package/dist/media/video/processor/index.js +4 -2
- package/dist/media/video/processor/streaming.js +197 -2
- package/dist/media/video/processor/thumbnail.js +134 -2
- package/dist/media/video/processor/transcoder.js +283 -2
- package/dist/method-spoofing.js +17 -2
- package/dist/middleware.js +40 -2
- package/dist/misc-directives.js +222 -2
- package/dist/native-build.js +511 -2
- package/dist/parser/directive-parser.js +239 -2
- package/dist/parser/expression-parser.js +358 -2
- package/dist/parser/index.js +23 -2
- package/dist/parser/tokenizer.js +534 -2
- package/dist/partial-hydration.js +427 -2
- package/dist/performance-utils.js +430 -2
- package/dist/placeholder.js +35 -2
- package/dist/plugin-system.js +214 -2
- package/dist/plugin.js +173 -2
- package/dist/precompiler.js +660 -81
- package/dist/process.js +711 -2
- package/dist/production-build.js +596 -2
- package/dist/production-builder.js +132 -2
- package/dist/production-server.js +188 -2
- package/dist/props.js +224 -2
- package/dist/public-env.js +19 -2
- package/dist/pwa/audit.js +255 -2
- package/dist/pwa/directives.js +332 -2
- package/dist/pwa/icons.js +109 -2
- package/dist/pwa/index.js +47 -2
- package/dist/pwa/inject.js +102 -2
- package/dist/pwa/manifest.js +186 -2
- package/dist/pwa/offline.js +259 -2
- package/dist/pwa/precache.js +116 -2
- package/dist/pwa/service-worker.js +860 -2
- package/dist/pwa/workbox-strategies.js +167 -2
- package/dist/pwa/workbox.js +382 -2
- package/dist/pwa.js +427 -427
- package/dist/reactive-bindings.js +266 -2
- package/dist/reactive.js +569 -2
- package/dist/reactivity.js +559 -2
- package/dist/release.js +1 -2
- package/dist/render.js +165 -2
- package/dist/route-middleware.js +17 -2
- package/dist/router.js +9 -2
- package/dist/routes.js +14 -2
- package/dist/runtime-injection.js +120 -2
- package/dist/runtime.js +94 -2
- package/dist/safe-evaluator.js +444 -2
- package/dist/scaffolding.js +897 -2
- package/dist/screenshot.js +87 -2
- package/dist/script-classifier.js +32 -2
- package/dist/script-validation.js +158 -2
- package/dist/seo.js +457 -2
- package/dist/serve.js +237 -2
- package/dist/server-bindings.js +108 -2
- package/dist/server-components.js +338 -11
- package/dist/signal-processing.js +946 -2
- package/dist/signals-api.js +154 -2
- package/dist/signals.js +5287 -2
- package/dist/site-builder/build.js +224 -2
- package/dist/site-builder/i18n.js +140 -2
- package/dist/site-builder/index.js +15 -2
- package/dist/site-builder/robots.js +26 -2
- package/dist/site-builder/router.js +27 -2
- package/dist/site-builder/seo.js +36 -2
- package/dist/site-builder/sitemap.js +26 -2
- package/dist/site-builder/theme.js +33 -2
- package/dist/site-builder/types.js +0 -1
- package/dist/slots.js +201 -2
- package/dist/source-maps.js +350 -2
- package/dist/spa-shell.js +34 -2
- package/dist/ssg.js +389 -389
- package/dist/ssr.js +355 -2
- package/dist/state-management.js +533 -2
- package/dist/store-imports.js +13 -2
- package/dist/store-loader.js +72 -5
- package/dist/stores-client.js +132 -2
- package/dist/story/addons.js +261 -2
- package/dist/story/analytics.js +235 -2
- package/dist/story/auto-stories.js +158 -2
- package/dist/story/bookmarks.js +277 -2
- package/dist/story/bun-test.js +102 -2
- package/dist/story/cli.js +155 -2
- package/dist/story/collect/analyzer.js +305 -2
- package/dist/story/collect/index.js +27 -2
- package/dist/story/collect/parser.js +129 -2
- package/dist/story/collect/scanner.js +101 -2
- package/dist/story/collect/tree.js +110 -2
- package/dist/story/commands/build.js +172 -2
- package/dist/story/commands/dev.js +78 -2
- package/dist/story/commands/index.js +3 -2
- package/dist/story/commands/preview.js +56 -2
- package/dist/story/compiled-output.js +151 -2
- package/dist/story/composition.js +261 -2
- package/dist/story/config-watcher.js +67 -2
- package/dist/story/config.js +64 -2
- package/dist/story/context.js +27 -2
- package/dist/story/controls/index.js +320 -2
- package/dist/story/crosswind.js +189 -2
- package/dist/story/desktop-preview.js +105 -2
- package/dist/story/docs-generator.js +186 -2
- package/dist/story/errors.js +239 -2
- package/dist/story/figma-export.js +224 -2
- package/dist/story/generator.js +165 -2
- package/dist/story/hmr.js +131 -2
- package/dist/story/hot-swap.js +207 -2
- package/dist/story/index.js +49 -2
- package/dist/story/interactions.js +225 -2
- package/dist/story/keyboard-shortcuts.js +345 -2
- package/dist/story/output.js +153 -2
- package/dist/story/performance.js +252 -2
- package/dist/story/presets.js +289 -2
- package/dist/story/props-validation.js +215 -2
- package/dist/story/renderer.js +209 -2
- package/dist/story/search-index.js +106 -2
- package/dist/story/search.js +140 -2
- package/dist/story/server.js +965 -2
- package/dist/story/setup.js +78 -2
- package/dist/story/snapshots.js +170 -2
- package/dist/story/testing.js +163 -2
- package/dist/story/theme.js +170 -2
- package/dist/story/types.js +0 -2
- package/dist/story/ui/code-panel.js +175 -2
- package/dist/story/ui/controls-panel.js +168 -2
- package/dist/story/ui/index.js +4 -2
- package/dist/story/ui/navigation.js +250 -2
- package/dist/story/ui/preview.js +251 -2
- package/dist/story/visual-testing.js +247 -2
- package/dist/streaming.js +537 -2
- package/dist/strict-lint.js +288 -2
- package/dist/style-scoping.js +50 -2
- package/dist/suspense.js +398 -2
- package/dist/teleport.js +109 -2
- package/dist/template-compiler.js +63 -2
- package/dist/template-hydrator.js +82 -2
- package/dist/template-tag-balance.js +93 -2
- package/dist/testing.js +581 -2
- package/dist/transitions.js +443 -2
- package/dist/type-checker.js +581 -2
- package/dist/types/component-types.d.ts +54 -0
- package/dist/types/component-types.js +0 -1
- package/dist/types/config-types.js +0 -1
- package/dist/types/context-types.js +0 -1
- package/dist/types/csp-types.js +0 -1
- package/dist/types/directive-types.js +3 -2
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +1 -2
- package/dist/types/pwa-types.js +0 -1
- package/dist/types.js +1 -2
- package/dist/typescript-templates.js +386 -4
- package/dist/utils.js +942 -2
- package/dist/validator.js +171 -2
- package/dist/variable-extractor.js +1094 -2
- package/dist/view-composers.js +29 -2
- package/dist/virtual-scrolling.js +454 -2
- package/dist/visual-editor.js +688 -28
- package/dist/vue-template.js +475 -2
- package/dist/web-components/css-scoping.js +177 -2
- package/dist/web-components/index.js +13 -2
- package/dist/web-components/reactive-generator.js +121 -56
- package/dist/web-components.js +1447 -2
- package/dist/x-element.js +17 -5
- package/package.json +6 -7
- package/dist/chunk-03c26pjz.js +0 -3
- package/dist/chunk-04mvcmcr.js +0 -106
- package/dist/chunk-05hgyyqc.js +0 -4
- package/dist/chunk-095s3972.js +0 -99
- package/dist/chunk-0b9w2w1y.js +0 -1
- package/dist/chunk-0dz85jrp.js +0 -3
- package/dist/chunk-0g4gece6.js +0 -4
- package/dist/chunk-0jd0pndq.js +0 -3
- package/dist/chunk-0jkwrcwj.js +0 -3
- package/dist/chunk-0m9tdm7t.js +0 -71
- package/dist/chunk-0qakwen3.js +0 -1
- package/dist/chunk-0qnz93q2.js +0 -3
- package/dist/chunk-0tatqxj2.js +0 -57
- package/dist/chunk-0wdar532.js +0 -102
- package/dist/chunk-13yz561y.js +0 -3
- package/dist/chunk-174z0cd0.js +0 -3
- package/dist/chunk-1mmykse5.js +0 -81
- package/dist/chunk-1z2yq9em.js +0 -3
- package/dist/chunk-1z5nhbjt.js +0 -90
- package/dist/chunk-1zgsgk4b.js +0 -1
- package/dist/chunk-25s7bckb.js +0 -171
- package/dist/chunk-268adc7r.js +0 -2230
- package/dist/chunk-26r6zh3t.js +0 -194
- package/dist/chunk-2w3302dh.js +0 -3
- package/dist/chunk-2xen423s.js +0 -3
- package/dist/chunk-39gm08bn.js +0 -39
- package/dist/chunk-3bjtemm6.js +0 -128
- package/dist/chunk-3jm3snz8.js +0 -3
- package/dist/chunk-3ngm57nt.js +0 -12
- package/dist/chunk-3rh7va1z.js +0 -3
- package/dist/chunk-3yg9hbmb.js +0 -4
- package/dist/chunk-44hd3kab.js +0 -1
- package/dist/chunk-46mkpbkk.js +0 -12
- package/dist/chunk-48cw2nde.js +0 -2
- package/dist/chunk-48r3qe0k.js +0 -3
- package/dist/chunk-4aj7ftqb.js +0 -1
- package/dist/chunk-4bt81cg3.js +0 -61
- package/dist/chunk-4j188175.js +0 -3
- package/dist/chunk-4k7d8p8d.js +0 -188
- package/dist/chunk-4qq8ffke.js +0 -28
- package/dist/chunk-50vqeesm.js +0 -142
- package/dist/chunk-52agge4n.js +0 -38
- package/dist/chunk-55yp0q8t.js +0 -201
- package/dist/chunk-57p201gb.js +0 -83
- package/dist/chunk-5ggw1dyv.js +0 -3
- package/dist/chunk-5kt3ay7x.js +0 -10
- package/dist/chunk-5p568px4.js +0 -1166
- package/dist/chunk-5ppkfyn2.js +0 -3
- package/dist/chunk-5q87fgkk.js +0 -3
- package/dist/chunk-5qb761h2.js +0 -3
- package/dist/chunk-5xvbq2gs.js +0 -30
- package/dist/chunk-647849kf.js +0 -34
- package/dist/chunk-6b5k6w2q.js +0 -7
- package/dist/chunk-6cr3eeh4.js +0 -23
- package/dist/chunk-6djgb0hr.js +0 -3
- package/dist/chunk-6dqzky7x.js +0 -35
- package/dist/chunk-6e4c6g46.js +0 -3
- package/dist/chunk-6w03t7h6.js +0 -3
- package/dist/chunk-6wn85hn6.js +0 -4
- package/dist/chunk-6y4gqs1q.js +0 -169
- package/dist/chunk-75rndzbd.js +0 -6
- package/dist/chunk-77tga15w.js +0 -3
- package/dist/chunk-7a51hkpf.js +0 -3
- package/dist/chunk-7b0xdy5h.js +0 -386
- package/dist/chunk-7cgmq685.js +0 -33
- package/dist/chunk-7dy588as.js +0 -6
- package/dist/chunk-7rvh2wwv.js +0 -721
- package/dist/chunk-7sm05m0j.js +0 -351
- package/dist/chunk-7sqdeqsw.js +0 -1
- package/dist/chunk-7xcfy2fn.js +0 -4
- package/dist/chunk-82t27pvd.js +0 -5
- package/dist/chunk-87kx8byz.js +0 -1115
- package/dist/chunk-8fgwhhb8.js +0 -6
- package/dist/chunk-8qbax8xn.js +0 -347
- package/dist/chunk-91s2hres.js +0 -8
- package/dist/chunk-94g3cahw.js +0 -11
- package/dist/chunk-957amb71.js +0 -8
- package/dist/chunk-95w08s8v.js +0 -3
- package/dist/chunk-9agvhp1x.js +0 -93
- package/dist/chunk-9tmbrwwx.js +0 -219
- package/dist/chunk-9yz5d003.js +0 -51
- package/dist/chunk-a3hyn4we.js +0 -79
- package/dist/chunk-a69tvya5.js +0 -53
- package/dist/chunk-adjcg6wa.js +0 -498
- package/dist/chunk-adqh2m9z.js +0 -45
- package/dist/chunk-asarebzq.js +0 -292
- package/dist/chunk-aw3rp9ac.js +0 -24
- package/dist/chunk-b0cyc09a.js +0 -109
- package/dist/chunk-b3kkjcdh.js +0 -3
- package/dist/chunk-b3prs7y0.js +0 -5
- package/dist/chunk-b5zc9y0y.js +0 -90
- package/dist/chunk-baa7h4yz.js +0 -3
- package/dist/chunk-bgec9r1v.js +0 -5224
- package/dist/chunk-bjnjpsgn.js +0 -3
- package/dist/chunk-bk8ew8ze.js +0 -24
- package/dist/chunk-bn08k7yy.js +0 -3
- package/dist/chunk-bpgg59wa.js +0 -3
- package/dist/chunk-bwxda6n1.js +0 -3
- package/dist/chunk-bykjk6vj.js +0 -4
- package/dist/chunk-c53hyw5c.js +0 -477
- package/dist/chunk-c7jg8w13.js +0 -3
- package/dist/chunk-ca6qd1dx.js +0 -3
- package/dist/chunk-cdbwprfv.js +0 -6
- package/dist/chunk-ceg2c2q2.js +0 -11
- package/dist/chunk-cn409b69.js +0 -3
- package/dist/chunk-cn8az1b4.js +0 -1
- package/dist/chunk-cp3kwv17.js +0 -8
- package/dist/chunk-cpcc11vp.js +0 -5
- package/dist/chunk-cr3wbrcr.js +0 -10
- package/dist/chunk-cygfdk1n.js +0 -3
- package/dist/chunk-cyp4m0vh.js +0 -16
- package/dist/chunk-cz25azze.js +0 -4
- package/dist/chunk-d77yxcds.js +0 -3
- package/dist/chunk-dvfs1h3c.js +0 -117
- package/dist/chunk-dyjnn5k8.js +0 -262
- package/dist/chunk-dzw95th7.js +0 -3
- package/dist/chunk-e0zytzdh.js +0 -179
- package/dist/chunk-e53h9qhd.js +0 -84
- package/dist/chunk-eds0f8f1.js +0 -3
- package/dist/chunk-eh8hact1.js +0 -5
- package/dist/chunk-epj957jf.js +0 -4
- package/dist/chunk-eqeyaq6g.js +0 -77
- package/dist/chunk-fbxt2mrx.js +0 -5
- package/dist/chunk-fch9tk1k.js +0 -3
- package/dist/chunk-fe7r1mq1.js +0 -9
- package/dist/chunk-fhawx87n.js +0 -8
- package/dist/chunk-fk51yyrw.js +0 -3
- package/dist/chunk-fms20x0n.js +0 -21
- package/dist/chunk-fs0qezn5.js +0 -341
- package/dist/chunk-fzm3y0r3.js +0 -267
- package/dist/chunk-g2hekckm.js +0 -161
- package/dist/chunk-g4ps1dj8.js +0 -140
- package/dist/chunk-g8b81pzc.js +0 -3
- package/dist/chunk-ganag9dm.js +0 -3
- package/dist/chunk-gc84b1d2.js +0 -58
- package/dist/chunk-gcf5v18y.js +0 -60
- package/dist/chunk-ghrx0hn1.js +0 -4
- package/dist/chunk-gqpkp459.js +0 -3
- package/dist/chunk-h45py5w5.js +0 -2
- package/dist/chunk-h5wa62ek.js +0 -145
- package/dist/chunk-h82kjdr4.js +0 -83
- package/dist/chunk-haecq01c.js +0 -3
- package/dist/chunk-hepg894w.js +0 -3
- package/dist/chunk-hjdc99kb.js +0 -3
- package/dist/chunk-hje9v2zh.js +0 -3
- package/dist/chunk-hjv76kcw.js +0 -1
- package/dist/chunk-hke99a0v.js +0 -3
- package/dist/chunk-hpqr9e3x.js +0 -3
- package/dist/chunk-hq5cem49.js +0 -236
- package/dist/chunk-hrampcrj.js +0 -3
- package/dist/chunk-ht4j68cs.js +0 -3
- package/dist/chunk-hxx3za24.js +0 -62
- package/dist/chunk-j4s5qwd7.js +0 -4
- package/dist/chunk-jbejwejg.js +0 -8
- package/dist/chunk-jc0fc4ht.js +0 -11
- package/dist/chunk-jcs0ymw7.js +0 -3
- package/dist/chunk-jfm69keq.js +0 -231
- package/dist/chunk-jfrn43vh.js +0 -2
- package/dist/chunk-jjamhxpm.js +0 -139
- package/dist/chunk-jjvp4t5w.js +0 -27
- package/dist/chunk-jt44av4j.js +0 -3
- package/dist/chunk-jt98jhpt.js +0 -10
- package/dist/chunk-k8440jxh.js +0 -6
- package/dist/chunk-kdxa9epn.js +0 -21
- package/dist/chunk-kfd2hf6f.js +0 -3
- package/dist/chunk-kgym7ch9.js +0 -8
- package/dist/chunk-kh6rfz2v.js +0 -4
- package/dist/chunk-kkp6rs2n.js +0 -36
- package/dist/chunk-ktkmvaa8.js +0 -1
- package/dist/chunk-m59y310j.js +0 -3
- package/dist/chunk-mgmyr1b9.js +0 -6
- package/dist/chunk-mqwbpamc.js +0 -3
- package/dist/chunk-mrehzhxv.js +0 -5
- package/dist/chunk-mv03qb75.js +0 -3
- package/dist/chunk-mv4fb50w.js +0 -1
- package/dist/chunk-mwbng54r.js +0 -2
- package/dist/chunk-n46a5g1g.js +0 -3
- package/dist/chunk-n944baxp.js +0 -3
- package/dist/chunk-nanw7yhz.js +0 -14
- package/dist/chunk-nap11ntr.js +0 -21
- package/dist/chunk-ncnfa8ae.js +0 -29
- package/dist/chunk-ngxfwzq3.js +0 -3
- package/dist/chunk-nvwb4x04.js +0 -3
- package/dist/chunk-nw34xajc.js +0 -8
- package/dist/chunk-payfb24w.js +0 -207
- package/dist/chunk-pc31m5x5.js +0 -398
- package/dist/chunk-pg1fvqb9.js +0 -167
- package/dist/chunk-q60knhjf.js +0 -3
- package/dist/chunk-q6h6yvzb.js +0 -10
- package/dist/chunk-qd5461tt.js +0 -3
- package/dist/chunk-qdc3aav1.js +0 -3
- package/dist/chunk-qfwzdffx.js +0 -3
- package/dist/chunk-qgxwmagw.js +0 -134
- package/dist/chunk-qhdtssn1.js +0 -19
- package/dist/chunk-qk584whs.js +0 -3
- package/dist/chunk-qm4yppj5.js +0 -57
- package/dist/chunk-qwyd9a1d.js +0 -2
- package/dist/chunk-qxs6et76.js +0 -196
- package/dist/chunk-rb1e4cnb.js +0 -3
- package/dist/chunk-rh80q1nd.js +0 -1
- package/dist/chunk-rkffm9sy.js +0 -128
- package/dist/chunk-rv002yn0.js +0 -14
- package/dist/chunk-s6ja2bdg.js +0 -66
- package/dist/chunk-sjagg9qz.js +0 -66
- package/dist/chunk-sn07azv3.js +0 -3
- package/dist/chunk-svahbw0w.js +0 -12
- package/dist/chunk-svhtdb0s.js +0 -6
- package/dist/chunk-t37dp99j.js +0 -3
- package/dist/chunk-tj6zfxeb.js +0 -64
- package/dist/chunk-tmgz5t2g.js +0 -3
- package/dist/chunk-tr0z0e1g.js +0 -3
- package/dist/chunk-tx6br9r4.js +0 -274
- package/dist/chunk-v97390pe.js +0 -1
- package/dist/chunk-vcr5pzpx.js +0 -233
- package/dist/chunk-vdfwv0fp.js +0 -6
- package/dist/chunk-vp2395eb.js +0 -3
- package/dist/chunk-vpe6napb.js +0 -28
- package/dist/chunk-vv9wfz1c.js +0 -12
- package/dist/chunk-vw6ejgmy.js +0 -21
- package/dist/chunk-vx22he47.js +0 -1
- package/dist/chunk-w01y57f5.js +0 -1539
- package/dist/chunk-w21mwxdd.js +0 -4
- package/dist/chunk-w4n8fqp7.js +0 -216
- package/dist/chunk-w959hm8j.js +0 -358
- package/dist/chunk-wf7zrjsw.js +0 -138
- package/dist/chunk-wk07pwtd.js +0 -321
- package/dist/chunk-wvef3ngh.js +0 -127
- package/dist/chunk-wxvyj65q.js +0 -2
- package/dist/chunk-x1hjv24z.js +0 -11
- package/dist/chunk-x39sfpvm.js +0 -302
- package/dist/chunk-x4fze3q2.js +0 -314
- package/dist/chunk-x64kb787.js +0 -15
- package/dist/chunk-xcb0pbr6.js +0 -4
- package/dist/chunk-xhkjhxsp.js +0 -3
- package/dist/chunk-xhnpsngj.js +0 -5
- package/dist/chunk-xsqbk4yk.js +0 -3
- package/dist/chunk-xygc53vr.js +0 -68
- package/dist/chunk-y0qg6rrv.js +0 -3
- package/dist/chunk-y25pr13j.js +0 -19
- package/dist/chunk-y4c744dk.js +0 -3
- package/dist/chunk-y4md9hp0.js +0 -3
- package/dist/chunk-y5wazw6j.js +0 -7
- package/dist/chunk-y5xz0jc4.js +0 -141
- package/dist/chunk-y86m1wr4.js +0 -4
- package/dist/chunk-yaan98dd.js +0 -3
- package/dist/chunk-yach037f.js +0 -32
- package/dist/chunk-yexjrg9d.js +0 -7
- package/dist/chunk-ygvyc6wv.js +0 -90
- package/dist/chunk-yj560gp8.js +0 -8
- package/dist/chunk-yn38c15w.js +0 -4
- package/dist/chunk-yr1gdceh.js +0 -3
- package/dist/chunk-yw2fzq86.js +0 -3
- package/dist/chunk-ywkrxp2h.js +0 -147
- package/dist/chunk-z37xq5rx.js +0 -3
- package/dist/chunk-z4djtgt0.js +0 -71
- package/dist/chunk-z8cjr9n9.js +0 -7
- package/dist/chunk-znxp3zha.js +0 -71
- package/dist/chunk-zt2yag10.js +0 -429
|
@@ -1,2 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const VOID_TAGS = new Set([
|
|
2
|
+
"area",
|
|
3
|
+
"base",
|
|
4
|
+
"br",
|
|
5
|
+
"col",
|
|
6
|
+
"embed",
|
|
7
|
+
"hr",
|
|
8
|
+
"img",
|
|
9
|
+
"input",
|
|
10
|
+
"link",
|
|
11
|
+
"meta",
|
|
12
|
+
"param",
|
|
13
|
+
"source",
|
|
14
|
+
"track",
|
|
15
|
+
"wbr"
|
|
16
|
+
]), OPTIONAL_CLOSE_TAGS = new Set([
|
|
17
|
+
"html",
|
|
18
|
+
"head",
|
|
19
|
+
"body",
|
|
20
|
+
"p",
|
|
21
|
+
"li",
|
|
22
|
+
"dt",
|
|
23
|
+
"dd",
|
|
24
|
+
"rt",
|
|
25
|
+
"rp",
|
|
26
|
+
"option",
|
|
27
|
+
"optgroup",
|
|
28
|
+
"thead",
|
|
29
|
+
"tbody",
|
|
30
|
+
"tfoot",
|
|
31
|
+
"tr",
|
|
32
|
+
"td",
|
|
33
|
+
"th",
|
|
34
|
+
"colgroup",
|
|
35
|
+
"caption"
|
|
36
|
+
]);
|
|
37
|
+
function blankKeepingLines(s) {
|
|
38
|
+
return s.replace(/[^\n]/g, " ");
|
|
39
|
+
}
|
|
40
|
+
export function findUnbalancedTags(template) {
|
|
41
|
+
const stripped = template.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, blankKeepingLines).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, blankKeepingLines).replace(/<!--[\s\S]*?-->/g, blankKeepingLines).replace(/\{\{\{[\s\S]*?\}\}\}/g, blankKeepingLines).replace(/\{\{[\s\S]*?\}\}/g, blankKeepingLines).replace(/\{!![\s\S]*?!!\}/g, blankKeepingLines).replace(/"[^"]*"/g, blankKeepingLines).replace(/'[^']*'/g, blankKeepingLines), opens = new Map, closes = new Map, tagRe = /<(\/?)([A-Za-z][\w-]*)\b[^>]*?(\/?)>/g;
|
|
42
|
+
let m;
|
|
43
|
+
while ((m = tagRe.exec(stripped)) !== null) {
|
|
44
|
+
const isClose = m[1] === "/", name = m[2], selfClose = m[3] === "/";
|
|
45
|
+
if (VOID_TAGS.has(name.toLowerCase()))
|
|
46
|
+
continue;
|
|
47
|
+
if (selfClose)
|
|
48
|
+
continue;
|
|
49
|
+
if (isClose)
|
|
50
|
+
closes.set(name, (closes.get(name) ?? 0) + 1);
|
|
51
|
+
else {
|
|
52
|
+
const existing = opens.get(name);
|
|
53
|
+
if (existing)
|
|
54
|
+
existing.count++;
|
|
55
|
+
else {
|
|
56
|
+
const line = stripped.slice(0, m.index).split(`
|
|
57
|
+
`).length;
|
|
58
|
+
opens.set(name, { count: 1, firstLine: line });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const issues = [];
|
|
63
|
+
for (const name of new Set([...opens.keys(), ...closes.keys()])) {
|
|
64
|
+
if (OPTIONAL_CLOSE_TAGS.has(name.toLowerCase()))
|
|
65
|
+
continue;
|
|
66
|
+
const opened = opens.get(name)?.count ?? 0, closed = closes.get(name) ?? 0;
|
|
67
|
+
if (opened !== closed)
|
|
68
|
+
issues.push({ tag: name, opened, closed, firstOpenLine: opens.get(name)?.firstLine ?? 0 });
|
|
69
|
+
}
|
|
70
|
+
return issues;
|
|
71
|
+
}
|
|
72
|
+
const warnedKeys = new Set;
|
|
73
|
+
export function warnUnbalancedTags(template, filePath) {
|
|
74
|
+
let issues;
|
|
75
|
+
try {
|
|
76
|
+
issues = findUnbalancedTags(template);
|
|
77
|
+
} catch {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (issues.length === 0)
|
|
81
|
+
return;
|
|
82
|
+
const dedupeKey = `${filePath}:${template.length}`;
|
|
83
|
+
if (warnedKeys.has(dedupeKey))
|
|
84
|
+
return;
|
|
85
|
+
warnedKeys.add(dedupeKey);
|
|
86
|
+
const label = filePath ? filePath.split(/[/\\]/).pop() || filePath : "template";
|
|
87
|
+
for (const { tag, opened, closed, firstOpenLine } of issues)
|
|
88
|
+
if (opened > closed) {
|
|
89
|
+
const where = firstOpenLine ? ` (first opened at line ${firstOpenLine})` : "";
|
|
90
|
+
console.warn(`[stx] ${label}: <${tag}> ${opened} opened, ${closed} closed \u2014 an unclosed <${tag}>${where} may swallow the content that follows it.`);
|
|
91
|
+
} else
|
|
92
|
+
console.warn(`[stx] ${label}: <${tag}> ${opened} opened, ${closed} closed \u2014 ${closed - opened} stray </${tag}>.`);
|
|
93
|
+
}
|
package/dist/testing.js
CHANGED
|
@@ -1,2 +1,581 @@
|
|
|
1
|
-
|
|
2
|
-
import{Ls as R}from"./chunk-w01y57f5.js";import"./chunk-x1hjv24z.js";import"./chunk-0g4gece6.js";import{et as V}from"./chunk-nap11ntr.js";import"./chunk-03c26pjz.js";import"./chunk-13yz561y.js";import"./chunk-nanw7yhz.js";import"./chunk-ghrx0hn1.js";import"./chunk-82t27pvd.js";import"./chunk-fhawx87n.js";import"./chunk-gc84b1d2.js";import"./chunk-yr1gdceh.js";import"./chunk-baa7h4yz.js";import"./chunk-kdxa9epn.js";import"./chunk-g2hekckm.js";import"./chunk-x39sfpvm.js";import"./chunk-tr0z0e1g.js";import"./chunk-4j188175.js";import"./chunk-eds0f8f1.js";import"./chunk-dyjnn5k8.js";import"./chunk-8fgwhhb8.js";import"./chunk-tj6zfxeb.js";import"./chunk-7xcfy2fn.js";import"./chunk-9yz5d003.js";import"./chunk-fms20x0n.js";import"./chunk-fe7r1mq1.js";import"./chunk-rb1e4cnb.js";import"./chunk-j4s5qwd7.js";import"./chunk-b0cyc09a.js";import"./chunk-0tatqxj2.js";import"./chunk-bykjk6vj.js";import"./chunk-7b0xdy5h.js";import"./chunk-ywkrxp2h.js";import"./chunk-y25pr13j.js";import"./chunk-q6h6yvzb.js";import"./chunk-qdc3aav1.js";import"./chunk-6wn85hn6.js";import"./chunk-qd5461tt.js";import"./chunk-77tga15w.js";import"./chunk-rv002yn0.js";import"./chunk-hke99a0v.js";import"./chunk-mwbng54r.js";import"./chunk-wxvyj65q.js";import"./chunk-yw2fzq86.js";import"./chunk-mrehzhxv.js";import"./chunk-1zgsgk4b.js";import"./chunk-48cw2nde.js";import"./chunk-jjvp4t5w.js";import"./chunk-94g3cahw.js";import"./chunk-ht4j68cs.js";import"./chunk-fch9tk1k.js";import"./chunk-cz25azze.js";import"./chunk-q60knhjf.js";import"./chunk-hrampcrj.js";import"./chunk-t37dp99j.js";import"./chunk-5kt3ay7x.js";import"./chunk-95w08s8v.js";import"./chunk-ceg2c2q2.js";import"./chunk-04mvcmcr.js";import"./chunk-n46a5g1g.js";import"./chunk-vv9wfz1c.js";import"./chunk-dzw95th7.js";import"./chunk-46mkpbkk.js";import"./chunk-3rh7va1z.js";import"./chunk-2xen423s.js";import"./chunk-cp3kwv17.js";import"./chunk-hpqr9e3x.js";import"./chunk-adqh2m9z.js";import"./chunk-8qbax8xn.js";import"./chunk-x64kb787.js";import"./chunk-gcf5v18y.js";import"./chunk-pc31m5x5.js";import"./chunk-3jm3snz8.js";function h(){let j=globalThis.Node||(globalThis.Node={});if(j.ELEMENT_NODE==null)j.ELEMENT_NODE=1;if(j.TEXT_NODE==null)j.TEXT_NODE=3;if(j.COMMENT_NODE==null)j.COMMENT_NODE=8;if(j.DOCUMENT_NODE==null)j.DOCUMENT_NODE=9;if(j.DOCUMENT_FRAGMENT_NODE==null)j.DOCUMENT_FRAGMENT_NODE=11}function T(j){if(!j)return;let A=[j,...j.querySelectorAll?Array.from(j.querySelectorAll("*")):[]];for(let z of A){if(!z||z.nodeType!==1||z.__attrShimmed)continue;let G=z.attributes;if(!(G instanceof Map))continue;z.__attrMap=G,Object.defineProperty(z,"attributes",{configurable:!0,get(){let H=z.__attrMap,L=[],X=0;for(let[U,K]of H)L[X++]={name:U,value:K};return L.length=X,L.get=(U)=>H.get(U),L.set=(U,K)=>H.set(U,K),L.delete=(U)=>H.delete(U),L.has=(U)=>H.has(U),L.keys=()=>H.keys(),L.values=()=>H.values(),L.entries=()=>H.entries(),L.forEach=(U)=>H.forEach(U),Object.defineProperty(L,"size",{get:()=>H.size}),L.item=(U)=>L[U]||null,L.getNamedItem=(U)=>H.has(U)?{name:U,value:H.get(U)}:null,L}}),z.__attrShimmed=!0}}function y(){if(h(),typeof globalThis.requestAnimationFrame>"u")globalThis.requestAnimationFrame=(j)=>setTimeout(j,0)}function x(j=30){return new Promise((A)=>setTimeout(A,j))}async function k(j,A={}){let z={...A.context,props:A.props||{}};if(A.mocks)Object.assign(z,A.mocks);if(A.slots)z.__slots__=A.slots;let G=j,H=/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/gi,L;while((L=H.exec(j))!==null){let I=L[1];await V(I,z,"test.stx"),G=G.replace(L[0],"")}G=G.replace(/<template\b[^>]*>/gi,"").replace(/<\/template>/gi,"");let X=new Set,U={debug:!1,...A.stxOptions};return await R(G,z,"test.stx",U,X)}async function g(j,A={}){let z={},G={...A.props},H={},L=(q,J)=>{if(!z[q])z[q]=[];z[q].push([J])},X={...A.context,props:G,$emit:L},U=j,K=/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/gi,I;while((I=K.exec(j))!==null){let q=I[1];await V(q,X,"test.stx"),U=U.replace(I[0],"")}let O=/<script\b(?!\s+(?:server|client|src))[^>]*>([\s\S]*?)<\/script>/gi;while((I=O.exec(U))!==null){let q=I[1];await V(q,X,"test.stx"),U=U.replace(I[0],"")}U=U.replace(/<template\b[^>]*>/gi,"").replace(/<\/template>/gi,"");let W=new Set,C={debug:!1,...A.stxOptions},D=await R(U,X,"test.stx",C,W),Q;if(A.attachTo)Q=typeof A.attachTo==="string"?document.querySelector(A.attachTo)||document.createElement("div"):A.attachTo;else Q=document.createElement("div"),Q.id=`stx-test-${Date.now()}`;Q.innerHTML=D;let M=async()=>{X.props=G,Object.assign(X,H),D=await R(j,X,"test.stx",C,W),Q.innerHTML=D},B=(q)=>({element:q,html:()=>q.innerHTML,text:()=>q.textContent||"",find:(J)=>{let Y=q.querySelector(J);return Y?B(Y):null},findAll:(J)=>{return Array.from(q.querySelectorAll(J)).map(B)},exists:()=>document.body.contains(q),isVisible:()=>{let J=window.getComputedStyle(q);return J.display!=="none"&&J.visibility!=="hidden"&&J.opacity!=="0"},attributes:(J)=>{if(J)return q.getAttribute(J);let Y={};for(let Z of q.attributes)Y[Z.name]=Z.value;return Y},classes:(J)=>{if(J)return q.classList.contains(J);return Array.from(q.classList)},trigger:async(J,Y)=>{let Z=new CustomEvent(J,{bubbles:!0,cancelable:!0,detail:Y});q.dispatchEvent(Z),L(J,Y),await _()},getValue:()=>{if(q instanceof HTMLInputElement){if(q.type==="checkbox")return q.checked;if(q.type==="radio")return q.checked;return q.value}if(q instanceof HTMLSelectElement){if(q.multiple)return Array.from(q.selectedOptions).map((J)=>J.value);return q.value}if(q instanceof HTMLTextAreaElement)return q.value;return""},setValue:async(J)=>{if(q instanceof HTMLInputElement){if(q.type==="checkbox"||q.type==="radio")q.checked=J;else q.value=J;q.dispatchEvent(new Event("input",{bubbles:!0})),q.dispatchEvent(new Event("change",{bubbles:!0}))}else if(q instanceof HTMLSelectElement||q instanceof HTMLTextAreaElement)q.value=J,q.dispatchEvent(new Event("input",{bubbles:!0})),q.dispatchEvent(new Event("change",{bubbles:!0}));await _()}}),P={element:Q.firstElementChild||Q,html:()=>Q.innerHTML,text:()=>Q.textContent||"",find:(q)=>{let J=Q.querySelector(q);return J?B(J):null},findAll:(q)=>{return Array.from(Q.querySelectorAll(q)).map(B)},findComponent:(q)=>{if(Q.querySelector(`[data-component="${q}"], ${q.toLowerCase()}, ${b(q)}`))return P;return null},findAllComponents:(q)=>{let J=Q.querySelectorAll(`[data-component="${q}"], ${q.toLowerCase()}, ${b(q)}`);return Array.from(J).map(()=>P)},exists:(q)=>{if(q)return Q.querySelector(q)!==null;return Q.children.length>0},isVisible:()=>{let q=Q.firstElementChild;if(!q)return!1;let J=window.getComputedStyle(q);return J.display!=="none"&&J.visibility!=="hidden"},attributes:(q)=>{if(!q){let Z=Q.firstElementChild;if(!Z)return{};let $={};for(let S of Z.attributes)$[S.name]=S.value;return $}let J=Q.querySelector(q);if(J){let Z={};for(let $ of J.attributes)Z[$.name]=$.value;return Z}let Y=Q.firstElementChild;return Y?Y.getAttribute(q):null},classes:(q)=>{let J=($)=>($.className||"").split(/\s+/).filter(Boolean);if(!q){let $=Q.firstElementChild;if(!$)return[];return J($)}let Y=Q.querySelector(q);if(Y)return J(Y);let Z=Q.firstElementChild;if(Z)return J(Z).includes(q);return!1},props:(q)=>{if(q)return G[q];return{...G}},emitted:(q)=>{if(q)return z[q];return{...z}},setProps:async(q)=>{G={...G,...q},await M()},setData:async(q)=>{H={...H,...q},await M()},trigger:async(q,J)=>{let Y=Q.firstElementChild;if(Y){let Z=new CustomEvent(q,{bubbles:!0,cancelable:!0,detail:J});Y.dispatchEvent(Z),L(q,J)}await _()},getValue:()=>{let q=Q.querySelector("input, select, textarea");if(q)return B(q).getValue();return""},setValue:async(q)=>{let J=Q.querySelector("input, select, textarea");if(J)await B(J).setValue(q)},unmount:()=>{if(Q.innerHTML="",Q.parentElement)Q.parentElement.removeChild(Q)},vm:{$nextTick:_}};return P}var u={async click(j,A){let z=F(j);if(!z)return;let G=new MouseEvent("click",{bubbles:!0,cancelable:!0,...A});z.dispatchEvent(G),await _()},async dblClick(j,A){let z=F(j);if(!z)return;let G=new MouseEvent("dblclick",{bubbles:!0,cancelable:!0,...A});z.dispatchEvent(G),await _()},async input(j,A){let z=F(j);if(!z)return;z.value=A,z.dispatchEvent(new Event("input",{bubbles:!0})),await _()},async change(j,A){let z=F(j);if(!z)return;if(A!==void 0)z.value=A;z.dispatchEvent(new Event("change",{bubbles:!0})),await _()},async submit(j){let A=F(j);if(!A)return;let z=new Event("submit",{bubbles:!0,cancelable:!0});A.dispatchEvent(z),await _()},async focus(j){let A=F(j);if(!A)return;A.focus(),A.dispatchEvent(new FocusEvent("focus",{bubbles:!0})),await _()},async blur(j){let A=F(j);if(!A)return;A.blur(),A.dispatchEvent(new FocusEvent("blur",{bubbles:!0})),await _()},async keyDown(j,A,z){let G=F(j);if(!G)return;let H=new KeyboardEvent("keydown",{bubbles:!0,cancelable:!0,key:A,...z});G.dispatchEvent(H),await _()},async keyUp(j,A,z){let G=F(j);if(!G)return;let H=new KeyboardEvent("keyup",{bubbles:!0,cancelable:!0,key:A,...z});G.dispatchEvent(H),await _()},async custom(j,A,z){let G=F(j);if(!G)return;let H=new CustomEvent(A,{bubbles:z?.bubbles??!0,cancelable:z?.cancelable??!0,detail:z?.detail});G.dispatchEvent(H),await _()}},d={toContainText(j,A){return j.text().includes(A)},toHaveClass(j,A){return j.classes(A)},toHaveAttribute(j,A,z){let G=j.attributes(A);if(z!==void 0)return G===z;return G!==null},toBeVisible(j){return j.isVisible()},toExist(j){return j!==null&&j.exists()},toHaveEmitted(j,A,z){let G=j.emitted(A);if(!G)return!1;if(z!==void 0)return G.length===z;return G.length>0},toHaveEmittedWith(j,A,z){let G=j.emitted(A);if(!G)return!1;return G.some((H)=>JSON.stringify(H[0])===JSON.stringify(z))}};function _(){return new Promise((j)=>{if(typeof requestAnimationFrame<"u")requestAnimationFrame(()=>j());else setTimeout(j,0)})}async function f(j,A={}){let{timeout:z=1000,interval:G=50}=A,H=Date.now();while(Date.now()-H<z){if(await j())return;await new Promise((L)=>setTimeout(L,G))}throw Error(`waitFor timed out after ${z}ms`)}async function v(j,A,z={}){let{timeout:G=1000}=z;return await f(()=>j.find(A)!==null,{timeout:G}),j.find(A)}async function m(){await new Promise((j)=>setTimeout(j,0)),await _()}function E(j){let A=[],z=[],G=j,H=(...L)=>{if(A.push(L),G){let X=G(...L);return z.push(X),X}return};return H.mock={calls:A,results:z},H.calls=A,H.reset=()=>{return A.length=0,z.length=0,G=j,H},H.mockImplementation=(L)=>{return G=L,H},H.mockReturnValue=(L)=>{return G=()=>L,H},H.mockClear=()=>{return A.length=0,z.length=0,H},H.mockReset=()=>{return A.length=0,z.length=0,G=void 0,H},H}function c(j){let A={...j},z={...j},G=[{...z}],H=new Set,L=()=>{for(let X of H)X({...z})};return{getState(){return{...z}},setState(X){z={...z,...X},G.push({...z}),L()},reset(){z={...A},G.length=0,G.push({...z}),L()},getHistory(){return G.map((X)=>({...X}))},subscribe(X){return H.add(X),()=>H.delete(X)}}}function F(j){if(!j)return null;if(j instanceof HTMLElement)return j;return j.element}function b(j){return j.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function i(j={}){return{props:j.props||{},context:j.context||{},mocks:Object.entries(j.mocks||{}).reduce((A,[z,G])=>{return A[z]=typeof G==="function"?E():G,A},{})}}function p(){document.querySelectorAll('[id^="stx-test-"]').forEach((j)=>j.remove())}export{v as waitForElement,f as waitFor,T as shimAttributes,y as setupStxTestDom,k as render,_ as nextTick,g as mount,d as matchers,h as installNodeConstants,m as flushPromises,x as flushEffects,u as fireEvent,i as createTestContext,c as createMockStore,E as createMockFn,p as cleanup};
|
|
1
|
+
import { processDirectives } from "./process.js";
|
|
2
|
+
import { extractVariables } from "./variable-extractor.js";
|
|
3
|
+
export function installNodeConstants() {
|
|
4
|
+
const N = globalThis.Node || (globalThis.Node = {});
|
|
5
|
+
if (N.ELEMENT_NODE == null)
|
|
6
|
+
N.ELEMENT_NODE = 1;
|
|
7
|
+
if (N.TEXT_NODE == null)
|
|
8
|
+
N.TEXT_NODE = 3;
|
|
9
|
+
if (N.COMMENT_NODE == null)
|
|
10
|
+
N.COMMENT_NODE = 8;
|
|
11
|
+
if (N.DOCUMENT_NODE == null)
|
|
12
|
+
N.DOCUMENT_NODE = 9;
|
|
13
|
+
if (N.DOCUMENT_FRAGMENT_NODE == null)
|
|
14
|
+
N.DOCUMENT_FRAGMENT_NODE = 11;
|
|
15
|
+
}
|
|
16
|
+
export function shimAttributes(root) {
|
|
17
|
+
if (!root)
|
|
18
|
+
return;
|
|
19
|
+
const els = [root, ...root.querySelectorAll ? Array.from(root.querySelectorAll("*")) : []];
|
|
20
|
+
for (const el of els) {
|
|
21
|
+
if (!el || el.nodeType !== 1 || el.__attrShimmed)
|
|
22
|
+
continue;
|
|
23
|
+
const map = el.attributes;
|
|
24
|
+
if (!(map instanceof Map))
|
|
25
|
+
continue;
|
|
26
|
+
el.__attrMap = map;
|
|
27
|
+
Object.defineProperty(el, "attributes", {
|
|
28
|
+
configurable: !0,
|
|
29
|
+
get() {
|
|
30
|
+
const m = el.__attrMap, arr = [];
|
|
31
|
+
let i = 0;
|
|
32
|
+
for (const [name, value] of m)
|
|
33
|
+
arr[i++] = { name, value };
|
|
34
|
+
arr.length = i;
|
|
35
|
+
arr.get = (k) => m.get(k);
|
|
36
|
+
arr.set = (k, v) => m.set(k, v);
|
|
37
|
+
arr.delete = (k) => m.delete(k);
|
|
38
|
+
arr.has = (k) => m.has(k);
|
|
39
|
+
arr.keys = () => m.keys();
|
|
40
|
+
arr.values = () => m.values();
|
|
41
|
+
arr.entries = () => m.entries();
|
|
42
|
+
arr.forEach = (cb) => m.forEach(cb);
|
|
43
|
+
Object.defineProperty(arr, "size", { get: () => m.size });
|
|
44
|
+
arr.item = (n) => arr[n] || null;
|
|
45
|
+
arr.getNamedItem = (k) => m.has(k) ? { name: k, value: m.get(k) } : null;
|
|
46
|
+
return arr;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
el.__attrShimmed = !0;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function setupStxTestDom() {
|
|
53
|
+
installNodeConstants();
|
|
54
|
+
if (typeof globalThis.requestAnimationFrame > "u")
|
|
55
|
+
globalThis.requestAnimationFrame = (cb) => setTimeout(cb, 0);
|
|
56
|
+
}
|
|
57
|
+
export function flushEffects(ms = 30) {
|
|
58
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
59
|
+
}
|
|
60
|
+
export async function render(template, options = {}) {
|
|
61
|
+
const context = {
|
|
62
|
+
...options.context,
|
|
63
|
+
props: options.props || {}
|
|
64
|
+
};
|
|
65
|
+
if (options.mocks)
|
|
66
|
+
Object.assign(context, options.mocks);
|
|
67
|
+
if (options.slots)
|
|
68
|
+
context.__slots__ = options.slots;
|
|
69
|
+
let processedTemplate = template;
|
|
70
|
+
const serverScriptRe = /<script\s+server\b[^>]*>([\s\S]*?)<\/script>/gi;
|
|
71
|
+
let match;
|
|
72
|
+
while ((match = serverScriptRe.exec(template)) !== null) {
|
|
73
|
+
const scriptBody = match[1];
|
|
74
|
+
await extractVariables(scriptBody, context, "test.stx");
|
|
75
|
+
processedTemplate = processedTemplate.replace(match[0], "");
|
|
76
|
+
}
|
|
77
|
+
processedTemplate = processedTemplate.replace(/<template\b[^>]*>/gi, "").replace(/<\/template>/gi, "");
|
|
78
|
+
const dependencies = new Set, stxOptions = {
|
|
79
|
+
debug: !1,
|
|
80
|
+
...options.stxOptions
|
|
81
|
+
};
|
|
82
|
+
return await processDirectives(processedTemplate, context, "test.stx", stxOptions, dependencies);
|
|
83
|
+
}
|
|
84
|
+
export async function mount(template, options = {}) {
|
|
85
|
+
const emittedEvents = {};
|
|
86
|
+
let currentProps = { ...options.props }, currentData = {};
|
|
87
|
+
const captureEvent = (event, payload) => {
|
|
88
|
+
if (!emittedEvents[event])
|
|
89
|
+
emittedEvents[event] = [];
|
|
90
|
+
emittedEvents[event].push([payload]);
|
|
91
|
+
}, context = {
|
|
92
|
+
...options.context,
|
|
93
|
+
props: currentProps,
|
|
94
|
+
$emit: captureEvent
|
|
95
|
+
};
|
|
96
|
+
let processedTemplate = template;
|
|
97
|
+
const serverScriptRe = /<script\s+server\b[^>]*>([\s\S]*?)<\/script>/gi;
|
|
98
|
+
let scriptMatch;
|
|
99
|
+
while ((scriptMatch = serverScriptRe.exec(template)) !== null) {
|
|
100
|
+
const scriptBody = scriptMatch[1];
|
|
101
|
+
await extractVariables(scriptBody, context, "test.stx");
|
|
102
|
+
processedTemplate = processedTemplate.replace(scriptMatch[0], "");
|
|
103
|
+
}
|
|
104
|
+
const plainScriptRe = /<script\b(?!\s+(?:server|client|src))[^>]*>([\s\S]*?)<\/script>/gi;
|
|
105
|
+
while ((scriptMatch = plainScriptRe.exec(processedTemplate)) !== null) {
|
|
106
|
+
const scriptBody = scriptMatch[1];
|
|
107
|
+
await extractVariables(scriptBody, context, "test.stx");
|
|
108
|
+
processedTemplate = processedTemplate.replace(scriptMatch[0], "");
|
|
109
|
+
}
|
|
110
|
+
processedTemplate = processedTemplate.replace(/<template\b[^>]*>/gi, "").replace(/<\/template>/gi, "");
|
|
111
|
+
const dependencies = new Set, stxOptions = {
|
|
112
|
+
debug: !1,
|
|
113
|
+
...options.stxOptions
|
|
114
|
+
};
|
|
115
|
+
let html = await processDirectives(processedTemplate, context, "test.stx", stxOptions, dependencies), container;
|
|
116
|
+
if (options.attachTo)
|
|
117
|
+
container = typeof options.attachTo === "string" ? document.querySelector(options.attachTo) || document.createElement("div") : options.attachTo;
|
|
118
|
+
else {
|
|
119
|
+
container = document.createElement("div");
|
|
120
|
+
container.id = `stx-test-${Date.now()}`;
|
|
121
|
+
}
|
|
122
|
+
container.innerHTML = html;
|
|
123
|
+
const rerender = async () => {
|
|
124
|
+
context.props = currentProps;
|
|
125
|
+
Object.assign(context, currentData);
|
|
126
|
+
html = await processDirectives(template, context, "test.stx", stxOptions, dependencies);
|
|
127
|
+
container.innerHTML = html;
|
|
128
|
+
}, createElementWrapper = (el) => ({
|
|
129
|
+
element: el,
|
|
130
|
+
html: () => el.innerHTML,
|
|
131
|
+
text: () => el.textContent || "",
|
|
132
|
+
find: (selector) => {
|
|
133
|
+
const found = el.querySelector(selector);
|
|
134
|
+
return found ? createElementWrapper(found) : null;
|
|
135
|
+
},
|
|
136
|
+
findAll: (selector) => {
|
|
137
|
+
return Array.from(el.querySelectorAll(selector)).map(createElementWrapper);
|
|
138
|
+
},
|
|
139
|
+
exists: () => document.body.contains(el),
|
|
140
|
+
isVisible: () => {
|
|
141
|
+
const style = window.getComputedStyle(el);
|
|
142
|
+
return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
|
|
143
|
+
},
|
|
144
|
+
attributes: (name) => {
|
|
145
|
+
if (name)
|
|
146
|
+
return el.getAttribute(name);
|
|
147
|
+
const attrs = {};
|
|
148
|
+
for (const attr of el.attributes)
|
|
149
|
+
attrs[attr.name] = attr.value;
|
|
150
|
+
return attrs;
|
|
151
|
+
},
|
|
152
|
+
classes: (name) => {
|
|
153
|
+
if (name)
|
|
154
|
+
return el.classList.contains(name);
|
|
155
|
+
return Array.from(el.classList);
|
|
156
|
+
},
|
|
157
|
+
trigger: async (event, payload) => {
|
|
158
|
+
const evt = new CustomEvent(event, {
|
|
159
|
+
bubbles: !0,
|
|
160
|
+
cancelable: !0,
|
|
161
|
+
detail: payload
|
|
162
|
+
});
|
|
163
|
+
el.dispatchEvent(evt);
|
|
164
|
+
captureEvent(event, payload);
|
|
165
|
+
await nextTick();
|
|
166
|
+
},
|
|
167
|
+
getValue: () => {
|
|
168
|
+
if (el instanceof HTMLInputElement) {
|
|
169
|
+
if (el.type === "checkbox")
|
|
170
|
+
return el.checked;
|
|
171
|
+
if (el.type === "radio")
|
|
172
|
+
return el.checked;
|
|
173
|
+
return el.value;
|
|
174
|
+
}
|
|
175
|
+
if (el instanceof HTMLSelectElement) {
|
|
176
|
+
if (el.multiple)
|
|
177
|
+
return Array.from(el.selectedOptions).map((o) => o.value);
|
|
178
|
+
return el.value;
|
|
179
|
+
}
|
|
180
|
+
if (el instanceof HTMLTextAreaElement)
|
|
181
|
+
return el.value;
|
|
182
|
+
return "";
|
|
183
|
+
},
|
|
184
|
+
setValue: async (value) => {
|
|
185
|
+
if (el instanceof HTMLInputElement) {
|
|
186
|
+
if (el.type === "checkbox" || el.type === "radio")
|
|
187
|
+
el.checked = value;
|
|
188
|
+
else
|
|
189
|
+
el.value = value;
|
|
190
|
+
el.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
191
|
+
el.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
192
|
+
} else if (el instanceof HTMLSelectElement || el instanceof HTMLTextAreaElement) {
|
|
193
|
+
el.value = value;
|
|
194
|
+
el.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
195
|
+
el.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
196
|
+
}
|
|
197
|
+
await nextTick();
|
|
198
|
+
}
|
|
199
|
+
}), wrapper = {
|
|
200
|
+
element: container.firstElementChild || container,
|
|
201
|
+
html: () => container.innerHTML,
|
|
202
|
+
text: () => container.textContent || "",
|
|
203
|
+
find: (selector) => {
|
|
204
|
+
const el = container.querySelector(selector);
|
|
205
|
+
return el ? createElementWrapper(el) : null;
|
|
206
|
+
},
|
|
207
|
+
findAll: (selector) => {
|
|
208
|
+
return Array.from(container.querySelectorAll(selector)).map(createElementWrapper);
|
|
209
|
+
},
|
|
210
|
+
findComponent: (name) => {
|
|
211
|
+
if (container.querySelector(`[data-component="${name}"], ${name.toLowerCase()}, ${toKebabCase(name)}`))
|
|
212
|
+
return wrapper;
|
|
213
|
+
return null;
|
|
214
|
+
},
|
|
215
|
+
findAllComponents: (name) => {
|
|
216
|
+
const els = container.querySelectorAll(`[data-component="${name}"], ${name.toLowerCase()}, ${toKebabCase(name)}`);
|
|
217
|
+
return Array.from(els).map(() => wrapper);
|
|
218
|
+
},
|
|
219
|
+
exists: (selector) => {
|
|
220
|
+
if (selector)
|
|
221
|
+
return container.querySelector(selector) !== null;
|
|
222
|
+
return container.children.length > 0;
|
|
223
|
+
},
|
|
224
|
+
isVisible: () => {
|
|
225
|
+
const el = container.firstElementChild;
|
|
226
|
+
if (!el)
|
|
227
|
+
return !1;
|
|
228
|
+
const style = window.getComputedStyle(el);
|
|
229
|
+
return style.display !== "none" && style.visibility !== "hidden";
|
|
230
|
+
},
|
|
231
|
+
attributes: (selectorOrName) => {
|
|
232
|
+
if (!selectorOrName) {
|
|
233
|
+
const el = container.firstElementChild;
|
|
234
|
+
if (!el)
|
|
235
|
+
return {};
|
|
236
|
+
const attrs = {};
|
|
237
|
+
for (const attr of el.attributes)
|
|
238
|
+
attrs[attr.name] = attr.value;
|
|
239
|
+
return attrs;
|
|
240
|
+
}
|
|
241
|
+
const found = container.querySelector(selectorOrName);
|
|
242
|
+
if (found) {
|
|
243
|
+
const attrs = {};
|
|
244
|
+
for (const attr of found.attributes)
|
|
245
|
+
attrs[attr.name] = attr.value;
|
|
246
|
+
return attrs;
|
|
247
|
+
}
|
|
248
|
+
const el = container.firstElementChild;
|
|
249
|
+
return el ? el.getAttribute(selectorOrName) : null;
|
|
250
|
+
},
|
|
251
|
+
classes: (selectorOrName) => {
|
|
252
|
+
const getClasses = (el) => (el.className || "").split(/\s+/).filter(Boolean);
|
|
253
|
+
if (!selectorOrName) {
|
|
254
|
+
const el = container.firstElementChild;
|
|
255
|
+
if (!el)
|
|
256
|
+
return [];
|
|
257
|
+
return getClasses(el);
|
|
258
|
+
}
|
|
259
|
+
const found = container.querySelector(selectorOrName);
|
|
260
|
+
if (found)
|
|
261
|
+
return getClasses(found);
|
|
262
|
+
const el = container.firstElementChild;
|
|
263
|
+
if (el)
|
|
264
|
+
return getClasses(el).includes(selectorOrName);
|
|
265
|
+
return !1;
|
|
266
|
+
},
|
|
267
|
+
props: (name) => {
|
|
268
|
+
if (name)
|
|
269
|
+
return currentProps[name];
|
|
270
|
+
return { ...currentProps };
|
|
271
|
+
},
|
|
272
|
+
emitted: (event) => {
|
|
273
|
+
if (event)
|
|
274
|
+
return emittedEvents[event];
|
|
275
|
+
return { ...emittedEvents };
|
|
276
|
+
},
|
|
277
|
+
setProps: async (props) => {
|
|
278
|
+
currentProps = { ...currentProps, ...props };
|
|
279
|
+
await rerender();
|
|
280
|
+
},
|
|
281
|
+
setData: async (data) => {
|
|
282
|
+
currentData = { ...currentData, ...data };
|
|
283
|
+
await rerender();
|
|
284
|
+
},
|
|
285
|
+
trigger: async (event, payload) => {
|
|
286
|
+
const el = container.firstElementChild;
|
|
287
|
+
if (el) {
|
|
288
|
+
const evt = new CustomEvent(event, {
|
|
289
|
+
bubbles: !0,
|
|
290
|
+
cancelable: !0,
|
|
291
|
+
detail: payload
|
|
292
|
+
});
|
|
293
|
+
el.dispatchEvent(evt);
|
|
294
|
+
captureEvent(event, payload);
|
|
295
|
+
}
|
|
296
|
+
await nextTick();
|
|
297
|
+
},
|
|
298
|
+
getValue: () => {
|
|
299
|
+
const el = container.querySelector("input, select, textarea");
|
|
300
|
+
if (el)
|
|
301
|
+
return createElementWrapper(el).getValue();
|
|
302
|
+
return "";
|
|
303
|
+
},
|
|
304
|
+
setValue: async (value) => {
|
|
305
|
+
const el = container.querySelector("input, select, textarea");
|
|
306
|
+
if (el)
|
|
307
|
+
await createElementWrapper(el).setValue(value);
|
|
308
|
+
},
|
|
309
|
+
unmount: () => {
|
|
310
|
+
container.innerHTML = "";
|
|
311
|
+
if (container.parentElement)
|
|
312
|
+
container.parentElement.removeChild(container);
|
|
313
|
+
},
|
|
314
|
+
vm: {
|
|
315
|
+
$nextTick: nextTick
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
return wrapper;
|
|
319
|
+
}
|
|
320
|
+
export const fireEvent = {
|
|
321
|
+
async click(target, options) {
|
|
322
|
+
const el = getElement(target);
|
|
323
|
+
if (!el)
|
|
324
|
+
return;
|
|
325
|
+
const event = new MouseEvent("click", {
|
|
326
|
+
bubbles: !0,
|
|
327
|
+
cancelable: !0,
|
|
328
|
+
...options
|
|
329
|
+
});
|
|
330
|
+
el.dispatchEvent(event);
|
|
331
|
+
await nextTick();
|
|
332
|
+
},
|
|
333
|
+
async dblClick(target, options) {
|
|
334
|
+
const el = getElement(target);
|
|
335
|
+
if (!el)
|
|
336
|
+
return;
|
|
337
|
+
const event = new MouseEvent("dblclick", {
|
|
338
|
+
bubbles: !0,
|
|
339
|
+
cancelable: !0,
|
|
340
|
+
...options
|
|
341
|
+
});
|
|
342
|
+
el.dispatchEvent(event);
|
|
343
|
+
await nextTick();
|
|
344
|
+
},
|
|
345
|
+
async input(target, value) {
|
|
346
|
+
const el = getElement(target);
|
|
347
|
+
if (!el)
|
|
348
|
+
return;
|
|
349
|
+
el.value = value;
|
|
350
|
+
el.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
351
|
+
await nextTick();
|
|
352
|
+
},
|
|
353
|
+
async change(target, value) {
|
|
354
|
+
const el = getElement(target);
|
|
355
|
+
if (!el)
|
|
356
|
+
return;
|
|
357
|
+
if (value !== void 0)
|
|
358
|
+
el.value = value;
|
|
359
|
+
el.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
360
|
+
await nextTick();
|
|
361
|
+
},
|
|
362
|
+
async submit(target) {
|
|
363
|
+
const el = getElement(target);
|
|
364
|
+
if (!el)
|
|
365
|
+
return;
|
|
366
|
+
const event = new Event("submit", { bubbles: !0, cancelable: !0 });
|
|
367
|
+
el.dispatchEvent(event);
|
|
368
|
+
await nextTick();
|
|
369
|
+
},
|
|
370
|
+
async focus(target) {
|
|
371
|
+
const el = getElement(target);
|
|
372
|
+
if (!el)
|
|
373
|
+
return;
|
|
374
|
+
el.focus();
|
|
375
|
+
el.dispatchEvent(new FocusEvent("focus", { bubbles: !0 }));
|
|
376
|
+
await nextTick();
|
|
377
|
+
},
|
|
378
|
+
async blur(target) {
|
|
379
|
+
const el = getElement(target);
|
|
380
|
+
if (!el)
|
|
381
|
+
return;
|
|
382
|
+
el.blur();
|
|
383
|
+
el.dispatchEvent(new FocusEvent("blur", { bubbles: !0 }));
|
|
384
|
+
await nextTick();
|
|
385
|
+
},
|
|
386
|
+
async keyDown(target, key, options) {
|
|
387
|
+
const el = getElement(target);
|
|
388
|
+
if (!el)
|
|
389
|
+
return;
|
|
390
|
+
const event = new KeyboardEvent("keydown", {
|
|
391
|
+
bubbles: !0,
|
|
392
|
+
cancelable: !0,
|
|
393
|
+
key,
|
|
394
|
+
...options
|
|
395
|
+
});
|
|
396
|
+
el.dispatchEvent(event);
|
|
397
|
+
await nextTick();
|
|
398
|
+
},
|
|
399
|
+
async keyUp(target, key, options) {
|
|
400
|
+
const el = getElement(target);
|
|
401
|
+
if (!el)
|
|
402
|
+
return;
|
|
403
|
+
const event = new KeyboardEvent("keyup", {
|
|
404
|
+
bubbles: !0,
|
|
405
|
+
cancelable: !0,
|
|
406
|
+
key,
|
|
407
|
+
...options
|
|
408
|
+
});
|
|
409
|
+
el.dispatchEvent(event);
|
|
410
|
+
await nextTick();
|
|
411
|
+
},
|
|
412
|
+
async custom(target, eventName, options) {
|
|
413
|
+
const el = getElement(target);
|
|
414
|
+
if (!el)
|
|
415
|
+
return;
|
|
416
|
+
const event = new CustomEvent(eventName, {
|
|
417
|
+
bubbles: options?.bubbles ?? !0,
|
|
418
|
+
cancelable: options?.cancelable ?? !0,
|
|
419
|
+
detail: options?.detail
|
|
420
|
+
});
|
|
421
|
+
el.dispatchEvent(event);
|
|
422
|
+
await nextTick();
|
|
423
|
+
}
|
|
424
|
+
}, matchers = {
|
|
425
|
+
toContainText(wrapper, text) {
|
|
426
|
+
return wrapper.text().includes(text);
|
|
427
|
+
},
|
|
428
|
+
toHaveClass(wrapper, className) {
|
|
429
|
+
return wrapper.classes(className);
|
|
430
|
+
},
|
|
431
|
+
toHaveAttribute(wrapper, name, value) {
|
|
432
|
+
const attr = wrapper.attributes(name);
|
|
433
|
+
if (value !== void 0)
|
|
434
|
+
return attr === value;
|
|
435
|
+
return attr !== null;
|
|
436
|
+
},
|
|
437
|
+
toBeVisible(wrapper) {
|
|
438
|
+
return wrapper.isVisible();
|
|
439
|
+
},
|
|
440
|
+
toExist(wrapper) {
|
|
441
|
+
return wrapper !== null && wrapper.exists();
|
|
442
|
+
},
|
|
443
|
+
toHaveEmitted(wrapper, event, times) {
|
|
444
|
+
const emitted = wrapper.emitted(event);
|
|
445
|
+
if (!emitted)
|
|
446
|
+
return !1;
|
|
447
|
+
if (times !== void 0)
|
|
448
|
+
return emitted.length === times;
|
|
449
|
+
return emitted.length > 0;
|
|
450
|
+
},
|
|
451
|
+
toHaveEmittedWith(wrapper, event, payload) {
|
|
452
|
+
const emitted = wrapper.emitted(event);
|
|
453
|
+
if (!emitted)
|
|
454
|
+
return !1;
|
|
455
|
+
return emitted.some((args) => JSON.stringify(args[0]) === JSON.stringify(payload));
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
export function nextTick() {
|
|
459
|
+
return new Promise((resolve) => {
|
|
460
|
+
if (typeof requestAnimationFrame < "u")
|
|
461
|
+
requestAnimationFrame(() => resolve());
|
|
462
|
+
else
|
|
463
|
+
setTimeout(resolve, 0);
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
export async function waitFor(condition, options = {}) {
|
|
467
|
+
const { timeout = 1000, interval = 50 } = options, start = Date.now();
|
|
468
|
+
while (Date.now() - start < timeout) {
|
|
469
|
+
if (await condition())
|
|
470
|
+
return;
|
|
471
|
+
await new Promise((r) => setTimeout(r, interval));
|
|
472
|
+
}
|
|
473
|
+
throw Error(`waitFor timed out after ${timeout}ms`);
|
|
474
|
+
}
|
|
475
|
+
export async function waitForElement(wrapper, selector, options = {}) {
|
|
476
|
+
const { timeout = 1000 } = options;
|
|
477
|
+
await waitFor(() => wrapper.find(selector) !== null, { timeout });
|
|
478
|
+
return wrapper.find(selector);
|
|
479
|
+
}
|
|
480
|
+
export async function flushPromises() {
|
|
481
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
482
|
+
await nextTick();
|
|
483
|
+
}
|
|
484
|
+
export function createMockFn(impl) {
|
|
485
|
+
const calls = [], results = [];
|
|
486
|
+
let implementation = impl;
|
|
487
|
+
const fn = (...args) => {
|
|
488
|
+
calls.push(args);
|
|
489
|
+
if (implementation) {
|
|
490
|
+
const result = implementation(...args);
|
|
491
|
+
results.push(result);
|
|
492
|
+
return result;
|
|
493
|
+
}
|
|
494
|
+
return;
|
|
495
|
+
};
|
|
496
|
+
fn.mock = {
|
|
497
|
+
calls,
|
|
498
|
+
results
|
|
499
|
+
};
|
|
500
|
+
fn.calls = calls;
|
|
501
|
+
fn.reset = () => {
|
|
502
|
+
calls.length = 0;
|
|
503
|
+
results.length = 0;
|
|
504
|
+
implementation = impl;
|
|
505
|
+
return fn;
|
|
506
|
+
};
|
|
507
|
+
fn.mockImplementation = (newImpl) => {
|
|
508
|
+
implementation = newImpl;
|
|
509
|
+
return fn;
|
|
510
|
+
};
|
|
511
|
+
fn.mockReturnValue = (value) => {
|
|
512
|
+
implementation = () => value;
|
|
513
|
+
return fn;
|
|
514
|
+
};
|
|
515
|
+
fn.mockClear = () => {
|
|
516
|
+
calls.length = 0;
|
|
517
|
+
results.length = 0;
|
|
518
|
+
return fn;
|
|
519
|
+
};
|
|
520
|
+
fn.mockReset = () => {
|
|
521
|
+
calls.length = 0;
|
|
522
|
+
results.length = 0;
|
|
523
|
+
implementation = void 0;
|
|
524
|
+
return fn;
|
|
525
|
+
};
|
|
526
|
+
return fn;
|
|
527
|
+
}
|
|
528
|
+
export function createMockStore(initialState) {
|
|
529
|
+
const initial = { ...initialState };
|
|
530
|
+
let state = { ...initialState };
|
|
531
|
+
const history = [{ ...state }], listeners = new Set, notify = () => {
|
|
532
|
+
for (const listener of listeners)
|
|
533
|
+
listener({ ...state });
|
|
534
|
+
};
|
|
535
|
+
return {
|
|
536
|
+
getState() {
|
|
537
|
+
return { ...state };
|
|
538
|
+
},
|
|
539
|
+
setState(partial) {
|
|
540
|
+
state = { ...state, ...partial };
|
|
541
|
+
history.push({ ...state });
|
|
542
|
+
notify();
|
|
543
|
+
},
|
|
544
|
+
reset() {
|
|
545
|
+
state = { ...initial };
|
|
546
|
+
history.length = 0;
|
|
547
|
+
history.push({ ...state });
|
|
548
|
+
notify();
|
|
549
|
+
},
|
|
550
|
+
getHistory() {
|
|
551
|
+
return history.map((s) => ({ ...s }));
|
|
552
|
+
},
|
|
553
|
+
subscribe(listener) {
|
|
554
|
+
listeners.add(listener);
|
|
555
|
+
return () => listeners.delete(listener);
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
function getElement(target) {
|
|
560
|
+
if (!target)
|
|
561
|
+
return null;
|
|
562
|
+
if (target instanceof HTMLElement)
|
|
563
|
+
return target;
|
|
564
|
+
return target.element;
|
|
565
|
+
}
|
|
566
|
+
function toKebabCase(str) {
|
|
567
|
+
return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
568
|
+
}
|
|
569
|
+
export function createTestContext(options = {}) {
|
|
570
|
+
return {
|
|
571
|
+
props: options.props || {},
|
|
572
|
+
context: options.context || {},
|
|
573
|
+
mocks: Object.entries(options.mocks || {}).reduce((acc, [key, value]) => {
|
|
574
|
+
acc[key] = typeof value === "function" ? createMockFn() : value;
|
|
575
|
+
return acc;
|
|
576
|
+
}, {})
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
export function cleanup() {
|
|
580
|
+
document.querySelectorAll('[id^="stx-test-"]').forEach((el) => el.remove());
|
|
581
|
+
}
|