@stacksjs/stx 0.1.16 → 0.2.3
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.d.ts +109 -5
- package/dist/analytics.d.ts +40 -0
- package/dist/animation.d.ts +91 -1
- package/dist/app.d.ts +51 -0
- package/dist/ast.d.ts +286 -0
- package/dist/async-components.d.ts +101 -0
- package/dist/auth.d.ts +1 -3
- package/dist/browser-composables.d.ts +314 -0
- package/dist/build-optimizer.d.ts +126 -0
- package/dist/build-views.d.ts +37 -0
- package/dist/bundle-analyzer/collector.d.ts +66 -0
- package/dist/bundle-analyzer/index.d.ts +60 -0
- package/dist/bundle-analyzer/report.d.ts +39 -0
- package/dist/bundle-analyzer/treemap.d.ts +19 -0
- package/dist/bundle-analyzer.js +499 -0
- package/dist/caching.d.ts +7 -0
- package/dist/cli.js +10885 -1203
- package/dist/client/directive.d.ts +10 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/router.d.ts +36 -0
- package/dist/client/stx-router.browser.d.ts +0 -0
- package/dist/client-script.d.ts +22 -0
- package/dist/component-hmr.d.ts +120 -0
- package/dist/components.d.ts +23 -1
- package/dist/composables/index.d.ts +277 -0
- package/dist/composables/use-battery.d.ts +46 -0
- package/dist/composables/use-broadcast-channel.d.ts +58 -0
- package/dist/composables/use-clipboard.d.ts +34 -0
- package/dist/composables/use-cookie.d.ts +70 -0
- package/dist/composables/use-device-orientation.d.ts +109 -0
- package/dist/composables/use-event-source.d.ts +77 -0
- package/dist/composables/use-eye-dropper.d.ts +107 -0
- package/dist/composables/use-fetch.d.ts +84 -0
- package/dist/composables/use-fullscreen.d.ts +47 -0
- package/dist/composables/use-geolocation.d.ts +62 -0
- package/dist/composables/use-idle.d.ts +84 -0
- package/dist/composables/use-intersection-observer.d.ts +81 -0
- package/dist/composables/use-keyboard.d.ts +100 -0
- package/dist/composables/use-media-query.d.ts +56 -0
- package/dist/composables/use-mouse.d.ts +64 -0
- package/dist/composables/use-mutation-observer.d.ts +101 -0
- package/dist/composables/use-network.d.ts +40 -0
- package/dist/composables/use-notification.d.ts +89 -0
- package/dist/composables/use-permissions.d.ts +109 -0
- package/dist/composables/use-resize-observer.d.ts +60 -0
- package/dist/composables/use-share.d.ts +70 -0
- package/dist/composables/use-speech.d.ts +117 -0
- package/dist/composables/use-storage.d.ts +64 -0
- package/dist/composables/use-text-selection.d.ts +97 -0
- package/dist/composables/use-wake-lock.d.ts +85 -0
- package/dist/composables/use-websocket.d.ts +69 -0
- package/dist/composables/use-window.d.ts +84 -0
- package/dist/composables.d.ts +268 -0
- package/dist/composition-api.d.ts +190 -0
- package/dist/computed.d.ts +137 -0
- package/dist/conditionals.d.ts +14 -2
- package/dist/config.d.ts +36 -3
- package/dist/craft-bridge.d.ts +319 -0
- package/dist/craft-compiler.d.ts +229 -0
- package/dist/craft-components.d.ts +411 -0
- package/dist/craft-entry.d.ts +5 -0
- package/dist/craft-ssr.d.ts +134 -0
- package/dist/craft.js +1553 -0
- package/dist/csp.d.ts +229 -0
- package/dist/database.d.ts +407 -0
- package/dist/database.js +5 -0
- package/dist/defer.d.ts +4 -0
- package/dist/deploy/config-generators.d.ts +75 -0
- package/dist/deploy/index.d.ts +84 -0
- package/dist/deploy/netlify.d.ts +109 -0
- package/dist/dev-server/crosswind.d.ts +54 -0
- package/dist/dev-server/index.d.ts +7 -0
- package/dist/dev-server/keyboard-shortcuts.d.ts +34 -0
- package/dist/dev-server/native-window.d.ts +40 -0
- package/dist/dev-server/port-utils.d.ts +27 -0
- package/dist/dev-server/terminal-colors.d.ts +60 -0
- package/dist/dev-server/theme-selector.d.ts +32 -0
- package/dist/dev-server/types.d.ts +92 -0
- package/dist/dev-server.d.ts +21 -0
- package/dist/devtools.d.ts +142 -0
- package/dist/directive-api.d.ts +111 -0
- package/dist/dynamic-components.d.ts +14 -0
- package/dist/edge-runtime.d.ts +200 -0
- package/dist/env.d.ts +9 -0
- package/dist/error-boundaries.d.ts +71 -0
- package/dist/error-handling.d.ts +1 -101
- package/dist/errors/codes.d.ts +99 -0
- package/dist/errors/formatter.d.ts +64 -0
- package/dist/errors/index.d.ts +56 -0
- package/dist/errors/logger.d.ts +74 -0
- package/dist/errors/sanitizer.d.ts +43 -0
- package/dist/errors/types.d.ts +79 -0
- package/dist/events.d.ts +106 -0
- package/dist/expressions.d.ts +86 -11
- package/dist/formatter.d.ts +4 -0
- package/dist/forms-validation.d.ts +173 -0
- package/dist/forms.d.ts +157 -8
- package/dist/head.d.ts +225 -0
- package/dist/heatmap.d.ts +125 -0
- package/dist/hot-reload.d.ts +87 -0
- package/dist/hydration-runtime.d.ts +47 -0
- package/dist/hydration.d.ts +161 -0
- package/dist/i18n.d.ts +240 -4
- package/dist/image-optimization/build-plugin.d.ts +53 -0
- package/dist/image-optimization/component.d.ts +46 -0
- package/dist/image-optimization/directive.d.ts +30 -0
- package/dist/image-optimization/index.d.ts +86 -0
- package/dist/image-optimization/processor.d.ts +112 -0
- package/dist/includes.d.ts +94 -9
- package/dist/index.d.ts +63 -3
- package/dist/index.js +11604 -1318
- package/dist/init.d.ts +32 -2
- package/dist/interactive.d.ts +14 -0
- package/dist/internal-markdown.d.ts +22 -0
- package/dist/jsx-runtime.d.ts +110 -0
- package/dist/keep-alive.d.ts +87 -0
- package/dist/lazy-loader.d.ts +122 -0
- package/dist/loading-indicator.d.ts +40 -0
- package/dist/loops.d.ts +22 -1
- package/dist/media/client/blur-up.d.ts +65 -0
- package/dist/media/client/index.d.ts +77 -0
- package/dist/media/client/lazy-load.d.ts +73 -0
- package/dist/media/client/upload-handler.d.ts +79 -0
- package/dist/media/image/component.d.ts +46 -0
- package/dist/media/image/directive.d.ts +9 -0
- package/dist/media/image/editing.d.ts +212 -0
- package/dist/media/image/index.d.ts +118 -0
- package/dist/media/image/placeholder.d.ts +78 -0
- package/dist/media/image/processor/cache.d.ts +32 -0
- package/dist/media/image/processor/index.d.ts +12 -0
- package/dist/media/image/processor/optimizer.d.ts +13 -0
- package/dist/media/image/processor/responsive.d.ts +17 -0
- package/dist/media/image/srcset.d.ts +158 -0
- package/dist/media/index.d.ts +295 -0
- package/dist/media/manager/embed.d.ts +25 -0
- package/dist/media/protected/component.d.ts +34 -0
- package/dist/media/protected/index.d.ts +34 -0
- package/dist/media/protected/signature.d.ts +72 -0
- package/dist/media/shared/cache.d.ts +54 -0
- package/dist/media/shared/hash.d.ts +24 -0
- package/dist/media/shared/index.d.ts +2 -0
- package/dist/media/types.d.ts +1051 -0
- package/dist/media/upload/component.d.ts +23 -0
- package/dist/media/upload/index.d.ts +1 -0
- package/dist/media/video/directive.d.ts +9 -0
- package/dist/media/video/index.d.ts +47 -0
- package/dist/media/video/processor/cache.d.ts +33 -0
- package/dist/media/video/processor/index.d.ts +21 -0
- package/dist/media/video/processor/streaming.d.ts +19 -0
- package/dist/media/video/processor/thumbnail.d.ts +28 -0
- package/dist/media/video/processor/transcoder.d.ts +9 -0
- package/dist/middleware.d.ts +42 -3
- package/dist/native-build.d.ts +74 -0
- package/dist/parser/directive-parser.d.ts +79 -0
- package/dist/parser/expression-parser.d.ts +59 -0
- package/dist/parser/index.d.ts +35 -0
- package/dist/parser/tokenizer.d.ts +81 -0
- package/dist/partial-hydration.d.ts +88 -0
- package/dist/performance-utils.d.ts +146 -3
- package/dist/plugin-system.d.ts +128 -0
- package/dist/plugin.d.ts +1 -0
- package/dist/precompiler.d.ts +108 -0
- package/dist/production-build.d.ts +199 -0
- package/dist/props.d.ts +199 -0
- package/dist/pwa/audit.d.ts +42 -0
- package/dist/pwa/directives.d.ts +29 -0
- package/dist/pwa/icons.d.ts +39 -0
- package/dist/pwa/index.d.ts +59 -0
- package/dist/pwa/inject.d.ts +22 -0
- package/dist/pwa/manifest.d.ts +104 -0
- package/dist/pwa/offline.d.ts +8 -0
- package/dist/pwa/precache.d.ts +29 -0
- package/dist/pwa/service-worker.d.ts +21 -0
- package/dist/pwa/workbox-strategies.d.ts +100 -0
- package/dist/pwa/workbox.d.ts +52 -0
- package/dist/pwa.d.ts +51 -0
- package/dist/pwa.js +8124 -0
- package/dist/reactive-bindings.d.ts +24 -0
- package/dist/reactive.d.ts +100 -0
- package/dist/reactivity.d.ts +253 -0
- package/dist/route-middleware.d.ts +232 -0
- package/dist/router.d.ts +31 -0
- package/dist/routes.d.ts +0 -7
- package/dist/runtime.d.ts +140 -0
- package/dist/safe-evaluator.d.ts +117 -3
- package/dist/scaffolding.d.ts +113 -0
- package/dist/seo.d.ts +120 -7
- package/dist/server-components.d.ts +134 -0
- package/dist/signals.d.ts +501 -0
- package/dist/slots.d.ts +63 -0
- package/dist/source-maps.d.ts +117 -0
- package/dist/ssg.d.ts +157 -0
- package/dist/ssg.js +6831 -0
- package/dist/ssr.d.ts +107 -0
- package/dist/state-management.d.ts +324 -0
- package/dist/stores-client.d.ts +70 -0
- package/dist/story/addons.d.ts +123 -0
- package/dist/story/analytics.d.ts +92 -0
- package/dist/story/auto-stories.d.ts +38 -0
- package/dist/story/bookmarks.d.ts +53 -0
- package/dist/story/bun-test.d.ts +44 -0
- package/dist/story/cli.d.ts +34 -0
- package/dist/story/collect/analyzer.d.ts +33 -0
- package/dist/story/collect/index.d.ts +27 -0
- package/dist/story/collect/parser.d.ts +17 -0
- package/dist/story/collect/scanner.d.ts +13 -0
- package/dist/story/collect/tree.d.ts +17 -0
- package/dist/story/commands/build.d.ts +14 -0
- package/dist/story/commands/dev.d.ts +16 -0
- package/dist/story/commands/index.d.ts +6 -0
- package/dist/story/commands/preview.d.ts +15 -0
- package/dist/story/compiled-output.d.ts +26 -0
- package/dist/story/composition.d.ts +47 -0
- package/dist/story/config-watcher.d.ts +26 -0
- package/dist/story/config.d.ts +26 -0
- package/dist/story/context.d.ts +21 -0
- package/dist/story/controls/index.d.ts +54 -0
- package/dist/story/crosswind.d.ts +29 -0
- package/dist/story/desktop-preview.d.ts +34 -0
- package/dist/story/docs-generator.d.ts +30 -0
- package/dist/story/errors.d.ts +47 -0
- package/dist/story/figma-export.d.ts +169 -0
- package/dist/story/generator.d.ts +21 -0
- package/dist/story/hmr.d.ts +64 -0
- package/dist/story/hot-swap.d.ts +35 -0
- package/dist/story/index.d.ts +51 -0
- package/dist/story/interactions.d.ts +52 -0
- package/dist/story/keyboard-shortcuts.d.ts +34 -0
- package/dist/story/output.d.ts +85 -0
- package/dist/story/performance.d.ts +76 -0
- package/dist/story/presets.d.ts +62 -0
- package/dist/story/props-validation.d.ts +45 -0
- package/dist/story/renderer.d.ts +53 -0
- package/dist/story/search-index.d.ts +47 -0
- package/dist/story/search.d.ts +45 -0
- package/dist/story/server.d.ts +21 -0
- package/dist/story/setup.d.ts +47 -0
- package/dist/story/snapshots.d.ts +65 -0
- package/dist/story/testing.d.ts +58 -0
- package/dist/story/theme.d.ts +68 -0
- package/dist/story/types.d.ts +249 -0
- package/dist/story/ui/code-panel.d.ts +42 -0
- package/dist/story/ui/controls-panel.d.ts +25 -0
- package/dist/story/ui/index.d.ts +4 -0
- package/dist/story/ui/navigation.d.ts +55 -0
- package/dist/story/ui/preview.d.ts +46 -0
- package/dist/story/visual-testing.d.ts +45 -0
- package/dist/streaming.d.ts +82 -2
- package/dist/suspense.d.ts +83 -0
- package/dist/teleport.d.ts +9 -0
- package/dist/testing.d.ts +289 -0
- package/dist/transitions.d.ts +87 -0
- package/dist/type-checker.d.ts +109 -0
- package/dist/types/component-types.d.ts +129 -0
- package/dist/types/config-types.d.ts +336 -0
- package/dist/types/context-types.d.ts +99 -0
- package/dist/types/csp-types.d.ts +79 -0
- package/dist/types/directive-types.d.ts +259 -0
- package/dist/types/index.d.ts +98 -0
- package/dist/types/pwa-types.d.ts +218 -0
- package/dist/types.d.ts +1 -315
- package/dist/typescript-templates.d.ts +178 -0
- package/dist/utils.d.ts +52 -6
- package/dist/validator.d.ts +77 -0
- package/dist/variable-extractor.d.ts +39 -0
- package/dist/view-composers.d.ts +154 -9
- package/dist/virtual-scrolling.d.ts +103 -0
- package/dist/visual-editor.d.ts +209 -0
- package/dist/visual-testing.d.ts +109 -0
- package/dist/visual-testing.js +126 -0
- package/dist/vue-template.d.ts +16 -0
- package/dist/web-components/css-scoping.d.ts +54 -0
- package/dist/web-components/index.d.ts +20 -0
- package/dist/web-components/reactive-generator.d.ts +72 -0
- package/dist/web-components.d.ts +222 -2
- package/dist/x-element.d.ts +35 -0
- package/package.json +41 -10
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import B from"fs";import $ from"path";import k from"crypto";var V=[{name:"mobile",width:375,height:667,isMobile:!0,hasTouch:!0},{name:"tablet",width:768,height:1024,isMobile:!0,hasTouch:!0},{name:"desktop",width:1280,height:800,isMobile:!1,hasTouch:!1},{name:"wide",width:1920,height:1080,isMobile:!1,hasTouch:!1}];function J(N={}){let Y={snapshotDir:N.snapshotDir||"__snapshots__",screenshotDir:N.screenshotDir||"__screenshots__",updateSnapshots:N.updateSnapshots||process.env.UPDATE_SNAPSHOTS==="true",threshold:N.threshold??0.01,viewports:N.viewports||V,generateDiff:N.generateDiff??!0,diffDir:N.diffDir||"__diffs__",compare:N.compare||b,ci:N.ci??process.env.CI==="true",retries:N.retries??(N.ci?3:1)};return{async snapshot(M,X){let q=$.join(Y.snapshotDir,`${X}.html`),G=C(M),Q=K(G);if(B.existsSync(q)){let W=await Bun.file(q).text(),Z=K(C(W));if(Q===Z)return{passed:!0,snapshotPath:q,message:"Snapshot matches"};if(Y.updateSnapshots)return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"Snapshot updated"};let F=$.join(Y.diffDir,`${X}.actual.html`),U=$.join(Y.diffDir,`${X}.diff.html`);return await B.promises.mkdir(Y.diffDir,{recursive:!0}),await Bun.write(F,G),await Bun.write(U,I(W,G)),{passed:!1,snapshotPath:q,actualPath:F,diffPath:U,message:"Snapshot does not match"}}return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"New snapshot created"}},async snapshotJson(M,X){let q=$.join(Y.snapshotDir,`${X}.json`),G=JSON.stringify(M,null,2);if(B.existsSync(q)){let Q=await Bun.file(q).text();if(G===Q)return{passed:!0,snapshotPath:q};if(Y.updateSnapshots)return await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"Snapshot updated"};return{passed:!1,snapshotPath:q,message:`JSON snapshot mismatch:
|
|
3
|
+
${z(Q,G)}`}}return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"New snapshot created"}},matchInlineSnapshot(M,X){let q=C(M);if(X===void 0)return{passed:!0,expected:q};let G=C(X);return{passed:q===G,expected:q}},getConfig(){return Y}}}function D(N={}){let Y=J(N),M=Y.getConfig();return{async compareScreenshots(X,q,G="desktop"){let Q=$.join(M.screenshotDir,G,`${X}.png`),W=$.join(M.diffDir,G,`${X}.actual.png`),Z=$.join(M.diffDir,G,`${X}.diff.png`);if(B.existsSync(Q)){let F=await Bun.file(Q).arrayBuffer(),U=Buffer.from(F),_=await M.compare(q,U);if(_.match||_.diffPercentage<=M.threshold)return{viewport:G,passed:!0,baselinePath:Q};if(M.updateSnapshots)return await B.promises.mkdir($.dirname(Q),{recursive:!0}),await Bun.write(Q,q),{viewport:G,passed:!0,baselinePath:Q};if(await B.promises.mkdir($.dirname(W),{recursive:!0}),await Bun.write(W,q),_.diffImage&&M.generateDiff)await Bun.write(Z,_.diffImage);return{viewport:G,passed:!1,baselinePath:Q,actualPath:W,diffPath:M.generateDiff?Z:void 0,diffPercentage:_.diffPercentage}}return await B.promises.mkdir($.dirname(Q),{recursive:!0}),await Bun.write(Q,q),{viewport:G,passed:!0,baselinePath:Q}},async testViewports(X,q,G=M.viewports){let Q=[];for(let W of G){let Z=null;for(let F=0;F<M.retries;F++)try{let U=await q(W),_=await this.compareScreenshots(X,U,W.name);Q.push(_),Z=null;break}catch(U){if(Z=U,F<M.retries-1)await new Promise((_)=>setTimeout(_,100*(F+1)))}if(Z)Q.push({viewport:W.name,passed:!1,baselinePath:"",diffPercentage:100})}return Q},getSnapshotTester(){return Y}}}function L(N={}){let M=D(N).getSnapshotTester(),X=new Map;return{addStory(q){X.set(`${q.component}/${q.name}`,q)},addStories(q){for(let G of q)this.addStory(G)},getStories(){return Array.from(X.values())},getStoriesForComponent(q){return Array.from(X.values()).filter((G)=>G.component===q)},async testStory(q){let G=X.get(q);if(!G)return{name:q,passed:!1,duration:0,snapshots:[],screenshots:[],errors:[Error(`Story not found: ${q}`)]};let Q=Date.now(),W={name:q,passed:!0,duration:0,snapshots:[],screenshots:[],errors:[]};try{let Z=await G.render(),F=await M.snapshot(Z,q.replace(/\//g,"-"));if(W.snapshots.push(F),!F.passed)W.passed=!1}catch(Z){W.passed=!1,W.errors.push(Z)}return W.duration=Date.now()-Q,W},async testAllStories(){let q=[];for(let G of X.keys()){let Q=await this.testStory(G);q.push(Q)}return q},async generateStoryIndex(){let q={};for(let G of X.values()){if(!q[G.component])q[G.component]=[];q[G.component].push({name:G.name,args:G.args})}return JSON.stringify(q,null,2)}}}async function S(N,Y={}){let M={outputDir:Y.outputDir||"visual-test-report",format:Y.format||"html",title:Y.title||"Visual Test Report",includeScreenshots:Y.includeScreenshots??!0};await B.promises.mkdir(M.outputDir,{recursive:!0});let X=N.length,q=N.filter((F)=>F.passed).length,G=X-q,Q=N.reduce((F,U)=>F+U.duration,0);if(M.format==="json"){let F={title:M.title,summary:{total:X,passed:q,failed:G,duration:Q},results:N,generatedAt:new Date().toISOString()},U=$.join(M.outputDir,"report.json");return await Bun.write(U,JSON.stringify(F,null,2)),U}if(M.format==="markdown"){let F=`# ${M.title}
|
|
4
|
+
|
|
5
|
+
`;F+=`## Summary
|
|
6
|
+
|
|
7
|
+
`,F+=`- Total: ${X}
|
|
8
|
+
`,F+=`- Passed: ${q}
|
|
9
|
+
`,F+=`- Failed: ${G}
|
|
10
|
+
`,F+=`- Duration: ${Q}ms
|
|
11
|
+
|
|
12
|
+
`,F+=`## Results
|
|
13
|
+
|
|
14
|
+
`;for(let _ of N){let R=_.passed?"\u2705":"\u274C";if(F+=`### ${R} ${_.name}
|
|
15
|
+
|
|
16
|
+
`,F+=`Duration: ${_.duration}ms
|
|
17
|
+
|
|
18
|
+
`,_.errors.length>0){F+=`**Errors:**
|
|
19
|
+
`;for(let A of _.errors)F+=`- ${A.message}
|
|
20
|
+
`;F+=`
|
|
21
|
+
`}if(_.snapshots.length>0){F+=`**Snapshots:**
|
|
22
|
+
`;for(let A of _.snapshots){let j=A.passed?"\u2705":"\u274C";F+=`- ${j} ${A.snapshotPath}
|
|
23
|
+
`}F+=`
|
|
24
|
+
`}}let U=$.join(M.outputDir,"report.md");return await Bun.write(U,F),U}let W=`<!DOCTYPE html>
|
|
25
|
+
<html lang="en">
|
|
26
|
+
<head>
|
|
27
|
+
<meta charset="UTF-8">
|
|
28
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
29
|
+
<title>${M.title}</title>
|
|
30
|
+
<style>
|
|
31
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
32
|
+
body { font-family: system-ui, sans-serif; line-height: 1.6; color: #333; max-width: 1200px; margin: 0 auto; padding: 2rem; }
|
|
33
|
+
h1 { margin-bottom: 1rem; }
|
|
34
|
+
.summary { display: flex; gap: 2rem; margin-bottom: 2rem; padding: 1rem; background: #f5f5f5; border-radius: 8px; }
|
|
35
|
+
.stat { text-align: center; }
|
|
36
|
+
.stat-value { font-size: 2rem; font-weight: bold; }
|
|
37
|
+
.stat-label { font-size: 0.875rem; color: #666; }
|
|
38
|
+
.passed { color: #22c55e; }
|
|
39
|
+
.failed { color: #ef4444; }
|
|
40
|
+
.results { display: flex; flex-direction: column; gap: 1rem; }
|
|
41
|
+
.result { border: 1px solid #ddd; border-radius: 8px; overflow: hidden; }
|
|
42
|
+
.result-header { padding: 1rem; background: #f9f9f9; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
|
|
43
|
+
.result-header:hover { background: #f0f0f0; }
|
|
44
|
+
.result-body { padding: 1rem; display: none; }
|
|
45
|
+
.result.expanded .result-body { display: block; }
|
|
46
|
+
.status { padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.875rem; }
|
|
47
|
+
.status.pass { background: #dcfce7; color: #166534; }
|
|
48
|
+
.status.fail { background: #fee2e2; color: #991b1b; }
|
|
49
|
+
.error { background: #fef2f2; padding: 0.5rem; border-radius: 4px; margin-top: 0.5rem; font-family: monospace; font-size: 0.875rem; }
|
|
50
|
+
.diff-view { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; margin-top: 1rem; }
|
|
51
|
+
.diff-view img { max-width: 100%; border: 1px solid #ddd; border-radius: 4px; }
|
|
52
|
+
.diff-label { font-size: 0.875rem; color: #666; margin-bottom: 0.5rem; }
|
|
53
|
+
</style>
|
|
54
|
+
</head>
|
|
55
|
+
<body>
|
|
56
|
+
<h1>${M.title}</h1>
|
|
57
|
+
|
|
58
|
+
<div class="summary">
|
|
59
|
+
<div class="stat">
|
|
60
|
+
<div class="stat-value">${X}</div>
|
|
61
|
+
<div class="stat-label">Total Tests</div>
|
|
62
|
+
</div>
|
|
63
|
+
<div class="stat">
|
|
64
|
+
<div class="stat-value passed">${q}</div>
|
|
65
|
+
<div class="stat-label">Passed</div>
|
|
66
|
+
</div>
|
|
67
|
+
<div class="stat">
|
|
68
|
+
<div class="stat-value failed">${G}</div>
|
|
69
|
+
<div class="stat-label">Failed</div>
|
|
70
|
+
</div>
|
|
71
|
+
<div class="stat">
|
|
72
|
+
<div class="stat-value">${Q}ms</div>
|
|
73
|
+
<div class="stat-label">Duration</div>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<div class="results">
|
|
78
|
+
${N.map((F)=>`
|
|
79
|
+
<div class="result ${F.passed?"":"expanded"}">
|
|
80
|
+
<div class="result-header" onclick="this.parentElement.classList.toggle('expanded')">
|
|
81
|
+
<span>${F.name}</span>
|
|
82
|
+
<span class="status ${F.passed?"pass":"fail"}">${F.passed?"PASS":"FAIL"}</span>
|
|
83
|
+
</div>
|
|
84
|
+
<div class="result-body">
|
|
85
|
+
<p>Duration: ${F.duration}ms</p>
|
|
86
|
+
${F.errors.length>0?`
|
|
87
|
+
<div class="error">
|
|
88
|
+
${F.errors.map((U)=>`<div>${E(U.message)}</div>`).join("")}
|
|
89
|
+
</div>
|
|
90
|
+
`:""}
|
|
91
|
+
${F.snapshots.filter((U)=>!U.passed).map((U)=>`
|
|
92
|
+
<div class="snapshot-diff">
|
|
93
|
+
<p>Snapshot: ${U.snapshotPath}</p>
|
|
94
|
+
${U.diffPath?`<p><a href="file://${U.diffPath}">View diff</a></p>`:""}
|
|
95
|
+
</div>
|
|
96
|
+
`).join("")}
|
|
97
|
+
${F.screenshots.filter((U)=>!U.passed).map((U)=>`
|
|
98
|
+
<div class="diff-view">
|
|
99
|
+
<div>
|
|
100
|
+
<div class="diff-label">Baseline</div>
|
|
101
|
+
${M.includeScreenshots?`<img src="file://${U.baselinePath}" alt="baseline">`:`<p>${U.baselinePath}</p>`}
|
|
102
|
+
</div>
|
|
103
|
+
<div>
|
|
104
|
+
<div class="diff-label">Actual</div>
|
|
105
|
+
${M.includeScreenshots&&U.actualPath?`<img src="file://${U.actualPath}" alt="actual">`:`<p>${U.actualPath||"N/A"}</p>`}
|
|
106
|
+
</div>
|
|
107
|
+
<div>
|
|
108
|
+
<div class="diff-label">Diff (${(U.diffPercentage||0).toFixed(2)}%)</div>
|
|
109
|
+
${M.includeScreenshots&&U.diffPath?`<img src="file://${U.diffPath}" alt="diff">`:`<p>${U.diffPath||"N/A"}</p>`}
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
`).join("")}
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
`).join("")}
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
<script>
|
|
119
|
+
// Auto-expand failed tests
|
|
120
|
+
document.querySelectorAll('.result.fail').forEach(el => el.classList.add('expanded'));
|
|
121
|
+
</script>
|
|
122
|
+
</body>
|
|
123
|
+
</html>`,Z=$.join(M.outputDir,"report.html");return await Bun.write(Z,W),Z}function C(N){return N.replace(/<!--[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/>\s+/g,">").replace(/\s+</g,"<").replace(/"/g,'"').replace(/"/g,'"').trim()}function K(N){return k.createHash("md5").update(N).digest("hex")}function I(N,Y){let M=N.split(`
|
|
124
|
+
`),X=Y.split(`
|
|
125
|
+
`),q="<html><head><style>";q+=".diff { font-family: monospace; white-space: pre; }",q+=".add { background: #dcfce7; }",q+=".remove { background: #fee2e2; }",q+=".line-num { color: #888; width: 3em; display: inline-block; }",q+='</style></head><body><div class="diff">';let G=Math.max(M.length,X.length);for(let Q=0;Q<G;Q++){let W=M[Q]||"",Z=X[Q]||"";if(W===Z)q+=`<div><span class="line-num">${Q+1}</span> ${E(W)}</div>`;else{if(W)q+=`<div class="remove"><span class="line-num">${Q+1}</span>-${E(W)}</div>`;if(Z)q+=`<div class="add"><span class="line-num">${Q+1}</span>+${E(Z)}</div>`}}return q+="</div></body></html>",q}function z(N,Y){let M=JSON.parse(N),X=JSON.parse(Y),q=[];function G(Q,W,Z){if(typeof W!==typeof Z){q.push(`${Q}: type changed from ${typeof W} to ${typeof Z}`);return}if(W===null||Z===null){if(W!==Z)q.push(`${Q}: ${JSON.stringify(W)} \u2192 ${JSON.stringify(Z)}`);return}if(typeof W==="object"){let F=Object.keys(W),U=Object.keys(Z);for(let _ of F)if(!U.includes(_))q.push(`${Q}.${_}: removed`);else G(`${Q}.${_}`,W[_],Z[_]);for(let _ of U)if(!F.includes(_))q.push(`${Q}.${_}: added`)}else if(W!==Z)q.push(`${Q}: ${JSON.stringify(W)} \u2192 ${JSON.stringify(Z)}`)}return G("root",M,X),q.join(`
|
|
126
|
+
`)}function E(N){return N.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async function b(N,Y){if(N.length!==Y.length)return{match:!1,diffPercentage:100,diffPixels:Math.max(N.length,Y.length)};let M=0;for(let q=0;q<N.length;q++)if(N[q]!==Y[q])M++;let X=M/N.length*100;return{match:M===0,diffPercentage:X,diffPixels:M}}var O=null;async function H(N,Y){if(!O)O=J();return O.snapshot(N,Y)}async function v(N,Y){if(!O)O=J();return O.snapshotJson(N,Y)}function P(){O=null}var x={createSnapshotTester:J,createVisualRegressionTester:D,createStoryTester:L,generateReport:S,snapshot:H,snapshotJson:v,defaultViewports:V};export{v as snapshotJson,H as snapshot,P as resetDefaultTester,S as generateReport,V as defaultViewports,x as default,D as createVisualRegressionTester,L as createStoryTester,J as createSnapshotTester};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if template contains any Vue-style directives.
|
|
3
|
+
* Quick check to avoid unnecessary processing.
|
|
4
|
+
*/
|
|
5
|
+
export declare function hasVueTemplateSyntax(template: string): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Process Vue template syntax and convert to stx directives.
|
|
8
|
+
*
|
|
9
|
+
* This is designed to be called early in the processing pipeline,
|
|
10
|
+
* before any stx directive processing. It transforms Vue-style syntax
|
|
11
|
+
* into stx's native directive format.
|
|
12
|
+
*
|
|
13
|
+
* @param template - The template string potentially containing Vue directives
|
|
14
|
+
* @returns The template with Vue directives converted to stx equivalents
|
|
15
|
+
*/
|
|
16
|
+
export declare function processVueTemplate(template: string): string;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate a unique component ID based on hash
|
|
3
|
+
*/
|
|
4
|
+
export declare function generateComponentId(componentName: string, salt?: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Scope CSS to a specific component
|
|
7
|
+
*
|
|
8
|
+
* @param css - Raw CSS string
|
|
9
|
+
* @param componentId - Unique component identifier
|
|
10
|
+
* @param options - Scoping options
|
|
11
|
+
* @returns Scoped CSS string
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const scoped = scopeCss('.button { color: red; }', 'stx-abc123')
|
|
16
|
+
* // Returns: '.stx-abc123 .button { color: red; }'
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function scopeCss(css: string, componentId: string, options?: CssScopingOptions): string;
|
|
20
|
+
/**
|
|
21
|
+
* Extract CSS from a template
|
|
22
|
+
*
|
|
23
|
+
* @param template - The template string
|
|
24
|
+
* @returns Object with CSS content and template without style tags
|
|
25
|
+
*/
|
|
26
|
+
export declare function extractStyleFromTemplate(template: string): {
|
|
27
|
+
css: string
|
|
28
|
+
templateWithoutStyle: string
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Inject scoped CSS into a template
|
|
32
|
+
*
|
|
33
|
+
* @param template - The template string
|
|
34
|
+
* @param scopedCss - The scoped CSS to inject
|
|
35
|
+
* @param position - Where to inject: 'head', 'body-start', 'body-end'
|
|
36
|
+
* @returns Template with injected CSS
|
|
37
|
+
*/
|
|
38
|
+
export declare function injectScopedCss(template: string, scopedCss: string, position?: 'head' | 'body-start' | 'body-end'): string;
|
|
39
|
+
/**
|
|
40
|
+
* Generate CSS for Shadow DOM encapsulation
|
|
41
|
+
*
|
|
42
|
+
* @param css - Raw CSS
|
|
43
|
+
* @returns CSS suitable for Shadow DOM
|
|
44
|
+
*/
|
|
45
|
+
export declare function generateShadowDomCss(css: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Options for CSS scoping
|
|
48
|
+
*/
|
|
49
|
+
export declare interface CssScopingOptions {
|
|
50
|
+
prefix?: string
|
|
51
|
+
preserveHost?: boolean
|
|
52
|
+
scopeKeyframes?: boolean
|
|
53
|
+
scopeCustomProperties?: boolean
|
|
54
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type { CssScopingOptions } from './css-scoping';
|
|
2
|
+
export type {
|
|
3
|
+
ComputedProperty,
|
|
4
|
+
ReactiveComponentOptions,
|
|
5
|
+
ReactiveProperty,
|
|
6
|
+
WatchDefinition,
|
|
7
|
+
} from './reactive-generator';
|
|
8
|
+
export {
|
|
9
|
+
extractStyleFromTemplate,
|
|
10
|
+
generateComponentId,
|
|
11
|
+
generateShadowDomCss,
|
|
12
|
+
injectScopedCss,
|
|
13
|
+
scopeCss,
|
|
14
|
+
} from './css-scoping';
|
|
15
|
+
export {
|
|
16
|
+
generateReactiveComponentJS,
|
|
17
|
+
generateReactiveComponentTS,
|
|
18
|
+
generateReactiveMixin,
|
|
19
|
+
generateReactiveRuntime,
|
|
20
|
+
} from './reactive-generator';
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { WebComponent } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Generate the reactive mixin for web components
|
|
4
|
+
*
|
|
5
|
+
* @returns JavaScript code for the reactive mixin
|
|
6
|
+
*/
|
|
7
|
+
export declare function generateReactiveMixin(): string;
|
|
8
|
+
/**
|
|
9
|
+
* Generate reactive component JavaScript code
|
|
10
|
+
*
|
|
11
|
+
* @param component - Web component configuration
|
|
12
|
+
* @param template - Component template HTML
|
|
13
|
+
* @param options - Reactive options
|
|
14
|
+
* @returns JavaScript code for the reactive component
|
|
15
|
+
*/
|
|
16
|
+
export declare function generateReactiveComponentJS(component: WebComponent, template: string, options?: ReactiveComponentOptions): string;
|
|
17
|
+
/**
|
|
18
|
+
* Generate reactive component TypeScript code
|
|
19
|
+
*
|
|
20
|
+
* @param component - Web component configuration
|
|
21
|
+
* @param template - Component template HTML
|
|
22
|
+
* @param options - Reactive options
|
|
23
|
+
* @returns TypeScript code for the reactive component
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateReactiveComponentTS(component: WebComponent, template: string, options?: ReactiveComponentOptions): string;
|
|
26
|
+
/**
|
|
27
|
+
* Generate the reactive runtime script for browser inclusion
|
|
28
|
+
*
|
|
29
|
+
* @returns Minified runtime script
|
|
30
|
+
*/
|
|
31
|
+
export declare function generateReactiveRuntime(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Reactive property definition
|
|
34
|
+
*/
|
|
35
|
+
export declare interface ReactiveProperty {
|
|
36
|
+
name: string
|
|
37
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array'
|
|
38
|
+
default?: unknown
|
|
39
|
+
reflect?: boolean
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Computed property definition
|
|
43
|
+
*/
|
|
44
|
+
export declare interface ComputedProperty {
|
|
45
|
+
name: string
|
|
46
|
+
dependencies: string[]
|
|
47
|
+
getter: string
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Watch definition
|
|
51
|
+
*/
|
|
52
|
+
export declare interface WatchDefinition {
|
|
53
|
+
property: string
|
|
54
|
+
handler: string
|
|
55
|
+
immediate?: boolean
|
|
56
|
+
deep?: boolean
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Reactive component options
|
|
60
|
+
*/
|
|
61
|
+
export declare interface ReactiveComponentOptions {
|
|
62
|
+
properties?: ReactiveProperty[]
|
|
63
|
+
computed?: ComputedProperty[]
|
|
64
|
+
watchers?: WatchDefinition[]
|
|
65
|
+
methods?: Record<string, string>
|
|
66
|
+
lifecycle?: {
|
|
67
|
+
connected?: string
|
|
68
|
+
disconnected?: string
|
|
69
|
+
adopted?: string
|
|
70
|
+
attributeChanged?: string
|
|
71
|
+
}
|
|
72
|
+
}
|
package/dist/web-components.d.ts
CHANGED
|
@@ -4,6 +4,226 @@ import type { StxOptions } from './types';
|
|
|
4
4
|
*/
|
|
5
5
|
export declare function buildWebComponents(options: StxOptions, dependencies: Set<string>): Promise<string[]>;
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Generate a unique scope ID for a component
|
|
8
8
|
*/
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function generateScopeId(componentName: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Scope CSS for a web component.
|
|
12
|
+
*
|
|
13
|
+
* This function transforms CSS to be scoped to a specific component,
|
|
14
|
+
* preventing style leakage in non-shadow DOM scenarios.
|
|
15
|
+
*
|
|
16
|
+
* @param css - Original CSS content
|
|
17
|
+
* @param componentTag - Component tag name
|
|
18
|
+
* @param config - Scoping configuration
|
|
19
|
+
* @returns Scoped CSS
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Attribute scoping (default)
|
|
23
|
+
* scopeCSS('.btn { color: red; }', 'my-button')
|
|
24
|
+
* // => '.btn[data-v-a1b2c3d4] { color: red; }'
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Prefix scoping
|
|
28
|
+
* scopeCSS('.btn { color: red; }', 'my-button', { strategy: 'prefix', prefix: 'my-button' })
|
|
29
|
+
* // => '.my-button-btn { color: red; }'
|
|
30
|
+
*/
|
|
31
|
+
export declare function scopeCSS(css: string, componentTag: string, config?: Partial<CssScopingConfig>): string;
|
|
32
|
+
/**
|
|
33
|
+
* Transform HTML to include scope attributes
|
|
34
|
+
*
|
|
35
|
+
* @param html - Original HTML content
|
|
36
|
+
* @param componentTag - Component tag name
|
|
37
|
+
* @param config - Scoping configuration
|
|
38
|
+
* @returns HTML with scope attributes added
|
|
39
|
+
*/
|
|
40
|
+
export declare function scopeHTML(html: string, componentTag: string, config?: Partial<CssScopingConfig>): string;
|
|
41
|
+
/**
|
|
42
|
+
* Get the scope attribute for a component
|
|
43
|
+
*/
|
|
44
|
+
export declare function getScopeAttribute(componentTag: string, config?: Partial<CssScopingConfig>): string;
|
|
45
|
+
/**
|
|
46
|
+
* Extract and scope inline styles from HTML
|
|
47
|
+
*
|
|
48
|
+
* @param html - HTML content with style tags
|
|
49
|
+
* @param componentTag - Component tag name
|
|
50
|
+
* @param config - Scoping configuration
|
|
51
|
+
* @returns Object with scoped HTML and extracted scoped CSS
|
|
52
|
+
*/
|
|
53
|
+
export declare function extractAndScopeStyles(html: string, componentTag: string, config?: Partial<CssScopingConfig>): { html: string, css: string };
|
|
54
|
+
/**
|
|
55
|
+
* Generate a reactive web component with full lifecycle management.
|
|
56
|
+
*
|
|
57
|
+
* Features:
|
|
58
|
+
* - Reactive properties with automatic re-rendering
|
|
59
|
+
* - Property observers for side effects
|
|
60
|
+
* - Attribute reflection (property <-> attribute sync)
|
|
61
|
+
* - Internal state management with setState()
|
|
62
|
+
* - Batched rendering with requestAnimationFrame
|
|
63
|
+
* - Full lifecycle hooks (connected, disconnected, adopted)
|
|
64
|
+
* - Event handling system
|
|
65
|
+
* - Template interpolation with property values
|
|
66
|
+
*
|
|
67
|
+
* @param config - Reactive web component configuration
|
|
68
|
+
* @returns JavaScript code for the web component
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const code = generateReactiveWebComponent({
|
|
73
|
+
* name: 'CounterButton',
|
|
74
|
+
* tag: 'counter-button',
|
|
75
|
+
* template: '<button>Count: {{count}}</button>',
|
|
76
|
+
* properties: {
|
|
77
|
+
* count: { type: 'number', default: 0, reflect: true, render: true },
|
|
78
|
+
* label: { type: 'string', default: 'Click me' }
|
|
79
|
+
* },
|
|
80
|
+
* state: { clicks: 0 },
|
|
81
|
+
* events: {
|
|
82
|
+
* click: 'this._handleClick()'
|
|
83
|
+
* },
|
|
84
|
+
* methods: {
|
|
85
|
+
* _handleClick: `this.count++; this.setState({ clicks: this._state.clicks + 1 });`
|
|
86
|
+
* }
|
|
87
|
+
* })
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function generateReactiveWebComponent(config: ReactiveWebComponentConfig): string;
|
|
91
|
+
/**
|
|
92
|
+
* Generate TypeScript version of reactive web component
|
|
93
|
+
*/
|
|
94
|
+
export declare function generateReactiveWebComponentTS(config: ReactiveWebComponentConfig): string;
|
|
95
|
+
/**
|
|
96
|
+
* Create a mixin for adding reactivity to existing web components.
|
|
97
|
+
*
|
|
98
|
+
* @returns JavaScript code for a ReactiveElement mixin
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```javascript
|
|
102
|
+
* // Generated mixin usage:
|
|
103
|
+
* class MyComponent extends ReactiveElement(HTMLElement) {
|
|
104
|
+
* static get properties() {
|
|
105
|
+
* return {
|
|
106
|
+
* name: { type: 'string', default: 'World' }
|
|
107
|
+
* }
|
|
108
|
+
* }
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export declare function generateReactiveMixin(): string;
|
|
113
|
+
/**
|
|
114
|
+
* Generate a complete reactive web component runtime that can be included in pages.
|
|
115
|
+
* This provides the base classes and utilities for reactive components.
|
|
116
|
+
*
|
|
117
|
+
* @returns JavaScript runtime code
|
|
118
|
+
*/
|
|
119
|
+
export declare function generateReactiveRuntime(): string;
|
|
120
|
+
/**
|
|
121
|
+
* Parse an SFC-style web component file
|
|
122
|
+
*
|
|
123
|
+
* Expected format:
|
|
124
|
+
* ```html
|
|
125
|
+
* <script>
|
|
126
|
+
* export default {
|
|
127
|
+
* tag: 'my-button',
|
|
128
|
+
* props: ['type', 'text'],
|
|
129
|
+
* shadowDOM: true // optional, defaults to true
|
|
130
|
+
* }
|
|
131
|
+
* </script>
|
|
132
|
+
*
|
|
133
|
+
* <button class="{{ type }}">{{ text }}</button>
|
|
134
|
+
*
|
|
135
|
+
* <style>
|
|
136
|
+
* button { padding: 8px 16px; }
|
|
137
|
+
* </style>
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export declare function parseSFCComponent(source: string, defaultTag: string): ParsedSFCComponent;
|
|
141
|
+
/**
|
|
142
|
+
* Generate a web component class from parsed SFC
|
|
143
|
+
*/
|
|
144
|
+
export declare function generateSFCWebComponent(parsed: ParsedSFCComponent): string;
|
|
145
|
+
/**
|
|
146
|
+
* Directive handler for embedding web components in templates.
|
|
147
|
+
*
|
|
148
|
+
* The directive looks for an SFC-style component file and generates
|
|
149
|
+
* an inline script with the web component class.
|
|
150
|
+
*
|
|
151
|
+
* Usage:
|
|
152
|
+
* ```html
|
|
153
|
+
* @webcomponent('my-button')
|
|
154
|
+
* <my-button type="primary" text="Click Me"></my-button>
|
|
155
|
+
* ```
|
|
156
|
+
*
|
|
157
|
+
* Component file (components/my-button.stx):
|
|
158
|
+
* ```html
|
|
159
|
+
* <script>
|
|
160
|
+
* export default {
|
|
161
|
+
* tag: 'my-button',
|
|
162
|
+
* props: ['type', 'text']
|
|
163
|
+
* }
|
|
164
|
+
* </script>
|
|
165
|
+
*
|
|
166
|
+
* <button class="{{ type }}">{{ text }}</button>
|
|
167
|
+
*
|
|
168
|
+
* <style>
|
|
169
|
+
* button { padding: 8px 16px; }
|
|
170
|
+
* </style>
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
export declare function webComponentDirectiveHandler(content: string, params: string[], context: Record<string, any>, filePath: string): Promise<string>;
|
|
174
|
+
/**
|
|
175
|
+
* Property definition for reactive web components
|
|
176
|
+
*/
|
|
177
|
+
export declare interface ReactivePropertyDefinition {
|
|
178
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array'
|
|
179
|
+
default?: unknown
|
|
180
|
+
reflect?: boolean
|
|
181
|
+
attribute?: string | false
|
|
182
|
+
observer?: string
|
|
183
|
+
render?: boolean
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Reactive web component configuration
|
|
187
|
+
*/
|
|
188
|
+
export declare interface ReactiveWebComponentConfig {
|
|
189
|
+
name: string
|
|
190
|
+
tag: string
|
|
191
|
+
baseElement?: string
|
|
192
|
+
template: string
|
|
193
|
+
styles?: string
|
|
194
|
+
shadowDOM?: boolean
|
|
195
|
+
properties?: Record<string, ReactivePropertyDefinition>
|
|
196
|
+
lifecycle?: {
|
|
197
|
+
connected?: string
|
|
198
|
+
disconnected?: string
|
|
199
|
+
adopted?: string
|
|
200
|
+
attributeChanged?: string
|
|
201
|
+
}
|
|
202
|
+
events?: Record<string, string>
|
|
203
|
+
methods?: Record<string, string>
|
|
204
|
+
state?: Record<string, unknown>
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* CSS scoping configuration
|
|
208
|
+
*/
|
|
209
|
+
export declare interface CssScopingConfig {
|
|
210
|
+
strategy: CssScopingStrategy
|
|
211
|
+
prefix?: string
|
|
212
|
+
attributeName?: string
|
|
213
|
+
preserveOriginal?: boolean
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Parsed SFC web component structure
|
|
217
|
+
*/
|
|
218
|
+
export declare interface ParsedSFCComponent {
|
|
219
|
+
tag: string
|
|
220
|
+
props: string[]
|
|
221
|
+
template: string
|
|
222
|
+
styles: string
|
|
223
|
+
script: string
|
|
224
|
+
shadowDOM: boolean
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* CSS scoping strategy
|
|
228
|
+
*/
|
|
229
|
+
export type CssScopingStrategy = 'shadow' | 'prefix' | 'attribute' | 'bem'
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* x-element: Lightweight two-way binding for STX
|
|
3
|
+
*
|
|
4
|
+
* Provides client-side reactivity for forms and interactive elements:
|
|
5
|
+
* - x-data: Define reactive data scope
|
|
6
|
+
* - x-model: Two-way binding for inputs
|
|
7
|
+
* - x-text: Reactive text content
|
|
8
|
+
* - @event: Event handling (e.g., @click, @submit)
|
|
9
|
+
*
|
|
10
|
+
* Note: Use @if, @for, @foreach for server-side rendering.
|
|
11
|
+
* x-element is only for client-side interactivity that SSR can't handle.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```html
|
|
15
|
+
* <div x-data="{ name: '', count: 0 }">
|
|
16
|
+
* <input x-model="name" />
|
|
17
|
+
* <p>Hello, <span x-text="name"></span>!</p>
|
|
18
|
+
* <button @click="count++">Count: <span x-text="count"></span></button>
|
|
19
|
+
* </div>
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Generate the x-element runtime script
|
|
24
|
+
* This is injected once per page that uses x-* directives
|
|
25
|
+
*/
|
|
26
|
+
export declare function generateXElementRuntime(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Check if template uses x-* directives
|
|
29
|
+
*/
|
|
30
|
+
export declare function hasXElementDirectives(template: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Process x-element directives in template
|
|
33
|
+
* Injects the runtime if x-* directives are found
|
|
34
|
+
*/
|
|
35
|
+
export declare function processXElementDirectives(template: string): string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.3",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -28,6 +28,38 @@
|
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
29
|
"import": "./dist/index.js"
|
|
30
30
|
},
|
|
31
|
+
"./jsx-runtime": {
|
|
32
|
+
"types": "./dist/jsx-runtime.d.ts",
|
|
33
|
+
"import": "./dist/jsx-runtime.js"
|
|
34
|
+
},
|
|
35
|
+
"./jsx-dev-runtime": {
|
|
36
|
+
"types": "./dist/jsx-runtime.d.ts",
|
|
37
|
+
"import": "./dist/jsx-runtime.js"
|
|
38
|
+
},
|
|
39
|
+
"./craft": {
|
|
40
|
+
"types": "./dist/craft-entry.d.ts",
|
|
41
|
+
"import": "./dist/craft.js"
|
|
42
|
+
},
|
|
43
|
+
"./database": {
|
|
44
|
+
"types": "./dist/database.d.ts",
|
|
45
|
+
"import": "./dist/database.js"
|
|
46
|
+
},
|
|
47
|
+
"./ssg": {
|
|
48
|
+
"types": "./dist/ssg.d.ts",
|
|
49
|
+
"import": "./dist/ssg.js"
|
|
50
|
+
},
|
|
51
|
+
"./pwa": {
|
|
52
|
+
"types": "./dist/pwa.d.ts",
|
|
53
|
+
"import": "./dist/pwa.js"
|
|
54
|
+
},
|
|
55
|
+
"./visual-testing": {
|
|
56
|
+
"types": "./dist/visual-testing.d.ts",
|
|
57
|
+
"import": "./dist/visual-testing.js"
|
|
58
|
+
},
|
|
59
|
+
"./bundle-analyzer": {
|
|
60
|
+
"types": "./dist/bundle-analyzer.d.ts",
|
|
61
|
+
"import": "./dist/bundle-analyzer.js"
|
|
62
|
+
},
|
|
31
63
|
"./*": {
|
|
32
64
|
"import": "./dist/*"
|
|
33
65
|
}
|
|
@@ -60,11 +92,11 @@
|
|
|
60
92
|
"zip:windows-x64": "zip -j bin/stx-windows-x64.zip bin/stx-windows-x64.exe",
|
|
61
93
|
"zip:darwin-x64": "zip -j bin/stx-darwin-x64.zip bin/stx-darwin-x64",
|
|
62
94
|
"zip:darwin-arm64": "zip -j bin/stx-darwin-arm64.zip bin/stx-darwin-arm64",
|
|
63
|
-
"lint": "bunx
|
|
64
|
-
"lint:fix": "bunx
|
|
95
|
+
"lint": "bunx --bun pickier lint",
|
|
96
|
+
"lint:fix": "bunx --bun pickier lint --fix",
|
|
65
97
|
"fresh": "bunx rimraf node_modules/ bun.lock && bun i",
|
|
66
98
|
"changelog": "bunx changelogen --output CHANGELOG.md",
|
|
67
|
-
"prepublishOnly": "bun run build
|
|
99
|
+
"prepublishOnly": "bun run build",
|
|
68
100
|
"test": "bun test --preload ./happy-dom.ts",
|
|
69
101
|
"test:watch": "bun test --watch --preload ./happy-dom.ts",
|
|
70
102
|
"test:coverage": "bun test --coverage --preload ./happy-dom.ts",
|
|
@@ -72,11 +104,10 @@
|
|
|
72
104
|
},
|
|
73
105
|
"dependencies": {
|
|
74
106
|
"@stacksjs/clapp": "^0.2.0",
|
|
75
|
-
"@stacksjs/
|
|
76
|
-
"@stacksjs/
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"ts-syntax-highlighter": "^0.1.0"
|
|
107
|
+
"@stacksjs/desktop": "workspace:*",
|
|
108
|
+
"@stacksjs/sanitizer": "workspace:*",
|
|
109
|
+
"bun-plugin-stx": "workspace:*",
|
|
110
|
+
"bunfig": "^0.15.6",
|
|
111
|
+
"ts-syntax-highlighter": "^0.2.1"
|
|
81
112
|
}
|
|
82
113
|
}
|