@xaviele/ag-kit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/bin/cli.js +63 -0
- package/package.json +27 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/template/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/template/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
- package/template/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
- package/template/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
- package/template/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/template/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
- package/template/.agent/ARCHITECTURE.md +281 -0
- package/template/.agent/agents/backend-specialist.md +263 -0
- package/template/.agent/agents/code-archaeologist.md +106 -0
- package/template/.agent/agents/database-architect.md +226 -0
- package/template/.agent/agents/debugger.md +225 -0
- package/template/.agent/agents/devops-engineer.md +242 -0
- package/template/.agent/agents/documentation-writer.md +104 -0
- package/template/.agent/agents/explorer-agent.md +73 -0
- package/template/.agent/agents/frontend-specialist.md +593 -0
- package/template/.agent/agents/game-developer.md +162 -0
- package/template/.agent/agents/mobile-developer.md +377 -0
- package/template/.agent/agents/orchestrator.md +416 -0
- package/template/.agent/agents/penetration-tester.md +188 -0
- package/template/.agent/agents/performance-optimizer.md +187 -0
- package/template/.agent/agents/product-manager.md +112 -0
- package/template/.agent/agents/product-owner.md +95 -0
- package/template/.agent/agents/project-planner.md +406 -0
- package/template/.agent/agents/qa-automation-engineer.md +103 -0
- package/template/.agent/agents/security-auditor.md +170 -0
- package/template/.agent/agents/seo-specialist.md +111 -0
- package/template/.agent/agents/test-engineer.md +158 -0
- package/template/.agent/mcp_config.json +24 -0
- package/template/.agent/rules/GEMINI.md +273 -0
- package/template/.agent/scripts/auto_preview.py +148 -0
- package/template/.agent/scripts/checklist.py +217 -0
- package/template/.agent/scripts/session_manager.py +120 -0
- package/template/.agent/scripts/verify_all.py +327 -0
- package/template/.agent/skills/adr/SKILL.md +282 -0
- package/template/.agent/skills/alirezarezvani-code-to-prd/SKILL.md +499 -0
- package/template/.agent/skills/api-patterns/SKILL.md +81 -0
- package/template/.agent/skills/api-patterns/api-style.md +42 -0
- package/template/.agent/skills/api-patterns/auth.md +24 -0
- package/template/.agent/skills/api-patterns/documentation.md +26 -0
- package/template/.agent/skills/api-patterns/graphql.md +41 -0
- package/template/.agent/skills/api-patterns/rate-limiting.md +31 -0
- package/template/.agent/skills/api-patterns/response.md +37 -0
- package/template/.agent/skills/api-patterns/rest.md +40 -0
- package/template/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
- package/template/.agent/skills/api-patterns/security-testing.md +122 -0
- package/template/.agent/skills/api-patterns/trpc.md +41 -0
- package/template/.agent/skills/api-patterns/versioning.md +22 -0
- package/template/.agent/skills/app-builder/SKILL.md +75 -0
- package/template/.agent/skills/app-builder/agent-coordination.md +71 -0
- package/template/.agent/skills/app-builder/feature-building.md +53 -0
- package/template/.agent/skills/app-builder/project-detection.md +34 -0
- package/template/.agent/skills/app-builder/scaffolding.md +118 -0
- package/template/.agent/skills/app-builder/tech-stack.md +41 -0
- package/template/.agent/skills/app-builder/templates/SKILL.md +39 -0
- package/template/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/template/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/template/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/template/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/template/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/template/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/template/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/template/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
- package/template/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
- package/template/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
- package/template/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
- package/template/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/template/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
- package/template/.agent/skills/architecture/SKILL.md +55 -0
- package/template/.agent/skills/architecture/context-discovery.md +43 -0
- package/template/.agent/skills/architecture/examples.md +94 -0
- package/template/.agent/skills/architecture/pattern-selection.md +68 -0
- package/template/.agent/skills/architecture/patterns-reference.md +50 -0
- package/template/.agent/skills/architecture/trade-off-analysis.md +77 -0
- package/template/.agent/skills/bash-linux/SKILL.md +199 -0
- package/template/.agent/skills/behavioral-modes/SKILL.md +242 -0
- package/template/.agent/skills/brainstorming/SKILL.md +163 -0
- package/template/.agent/skills/brainstorming/dynamic-questioning.md +350 -0
- package/template/.agent/skills/claudekit-ai-multimodal/SKILL.md +353 -0
- package/template/.agent/skills/clean-code/SKILL.md +201 -0
- package/template/.agent/skills/code-review-checklist/SKILL.md +109 -0
- package/template/.agent/skills/database-design/SKILL.md +52 -0
- package/template/.agent/skills/database-design/database-selection.md +43 -0
- package/template/.agent/skills/database-design/indexing.md +39 -0
- package/template/.agent/skills/database-design/migrations.md +48 -0
- package/template/.agent/skills/database-design/optimization.md +36 -0
- package/template/.agent/skills/database-design/orm-selection.md +30 -0
- package/template/.agent/skills/database-design/schema-design.md +56 -0
- package/template/.agent/skills/database-design/scripts/schema_validator.py +172 -0
- package/template/.agent/skills/deployment-procedures/SKILL.md +241 -0
- package/template/.agent/skills/doc.md +177 -0
- package/template/.agent/skills/document/SKILL.md +250 -0
- package/template/.agent/skills/documentation-templates/SKILL.md +194 -0
- package/template/.agent/skills/frontend-design/SKILL.md +452 -0
- package/template/.agent/skills/frontend-design/animation-guide.md +331 -0
- package/template/.agent/skills/frontend-design/color-system.md +311 -0
- package/template/.agent/skills/frontend-design/decision-trees.md +418 -0
- package/template/.agent/skills/frontend-design/motion-graphics.md +306 -0
- package/template/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/template/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/template/.agent/skills/frontend-design/typography-system.md +345 -0
- package/template/.agent/skills/frontend-design/ux-psychology.md +1116 -0
- package/template/.agent/skills/frontend-design/visual-effects.md +383 -0
- package/template/.agent/skills/game-development/2d-games/SKILL.md +119 -0
- package/template/.agent/skills/game-development/3d-games/SKILL.md +135 -0
- package/template/.agent/skills/game-development/SKILL.md +167 -0
- package/template/.agent/skills/game-development/game-art/SKILL.md +185 -0
- package/template/.agent/skills/game-development/game-audio/SKILL.md +190 -0
- package/template/.agent/skills/game-development/game-design/SKILL.md +129 -0
- package/template/.agent/skills/game-development/mobile-games/SKILL.md +108 -0
- package/template/.agent/skills/game-development/multiplayer/SKILL.md +132 -0
- package/template/.agent/skills/game-development/pc-games/SKILL.md +144 -0
- package/template/.agent/skills/game-development/vr-ar/SKILL.md +123 -0
- package/template/.agent/skills/game-development/web-games/SKILL.md +150 -0
- package/template/.agent/skills/geo-fundamentals/SKILL.md +156 -0
- package/template/.agent/skills/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/template/.agent/skills/i18n-localization/SKILL.md +154 -0
- package/template/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/template/.agent/skills/intelligent-routing/SKILL.md +335 -0
- package/template/.agent/skills/lint-and-validate/SKILL.md +45 -0
- package/template/.agent/skills/lint-and-validate/scripts/lint_runner.py +184 -0
- package/template/.agent/skills/lint-and-validate/scripts/type_coverage.py +173 -0
- package/template/.agent/skills/mcp-builder/SKILL.md +176 -0
- package/template/.agent/skills/mindrally-meta-prompt/SKILL.md +129 -0
- package/template/.agent/skills/mobile-design/SKILL.md +394 -0
- package/template/.agent/skills/mobile-design/decision-trees.md +516 -0
- package/template/.agent/skills/mobile-design/mobile-backend.md +491 -0
- package/template/.agent/skills/mobile-design/mobile-color-system.md +420 -0
- package/template/.agent/skills/mobile-design/mobile-debugging.md +122 -0
- package/template/.agent/skills/mobile-design/mobile-design-thinking.md +357 -0
- package/template/.agent/skills/mobile-design/mobile-navigation.md +458 -0
- package/template/.agent/skills/mobile-design/mobile-performance.md +767 -0
- package/template/.agent/skills/mobile-design/mobile-testing.md +356 -0
- package/template/.agent/skills/mobile-design/mobile-typography.md +433 -0
- package/template/.agent/skills/mobile-design/platform-android.md +666 -0
- package/template/.agent/skills/mobile-design/platform-ios.md +561 -0
- package/template/.agent/skills/mobile-design/scripts/mobile_audit.py +670 -0
- package/template/.agent/skills/mobile-design/touch-psychology.md +537 -0
- package/template/.agent/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +351 -0
- package/template/.agent/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
- package/template/.agent/skills/nextjs-react-expert/3-server-server-side-performance.md +490 -0
- package/template/.agent/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
- package/template/.agent/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
- package/template/.agent/skills/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
- package/template/.agent/skills/nextjs-react-expert/7-js-javascript-performance.md +684 -0
- package/template/.agent/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
- package/template/.agent/skills/nextjs-react-expert/9-cache-components.md +103 -0
- package/template/.agent/skills/nextjs-react-expert/SKILL.md +293 -0
- package/template/.agent/skills/nextjs-react-expert/scripts/convert_rules.py +222 -0
- package/template/.agent/skills/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
- package/template/.agent/skills/nodejs-best-practices/SKILL.md +333 -0
- package/template/.agent/skills/parallel-agents/SKILL.md +175 -0
- package/template/.agent/skills/performance-profiling/SKILL.md +143 -0
- package/template/.agent/skills/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/template/.agent/skills/plan-writing/SKILL.md +152 -0
- package/template/.agent/skills/pm-skills-create-prd/SKILL.md +88 -0
- package/template/.agent/skills/powershell-windows/SKILL.md +167 -0
- package/template/.agent/skills/prompt-engineering/SKILL.md +566 -0
- package/template/.agent/skills/python-patterns/SKILL.md +441 -0
- package/template/.agent/skills/red-team-tactics/SKILL.md +199 -0
- package/template/.agent/skills/rust-pro/SKILL.md +176 -0
- package/template/.agent/skills/seo-fundamentals/SKILL.md +129 -0
- package/template/.agent/skills/seo-fundamentals/scripts/seo_checker.py +219 -0
- package/template/.agent/skills/server-management/SKILL.md +161 -0
- package/template/.agent/skills/skills/adr/SKILL.md +282 -0
- package/template/.agent/skills/skills/alirezarezvani-code-to-prd/SKILL.md +499 -0
- package/template/.agent/skills/skills/claudekit-ai-multimodal/SKILL.md +353 -0
- package/template/.agent/skills/skills/document/SKILL.md +250 -0
- package/template/.agent/skills/skills/mindrally-meta-prompt/SKILL.md +129 -0
- package/template/.agent/skills/skills/pm-skills-create-prd/SKILL.md +88 -0
- package/template/.agent/skills/skills/prompt-engineering/SKILL.md +566 -0
- package/template/.agent/skills/systematic-debugging/SKILL.md +109 -0
- package/template/.agent/skills/tailwind-patterns/SKILL.md +269 -0
- package/template/.agent/skills/tdd-workflow/SKILL.md +149 -0
- package/template/.agent/skills/testing-patterns/SKILL.md +178 -0
- package/template/.agent/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/template/.agent/skills/vulnerability-scanner/SKILL.md +276 -0
- package/template/.agent/skills/vulnerability-scanner/checklists.md +121 -0
- package/template/.agent/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/template/.agent/skills/web-design-guidelines/SKILL.md +57 -0
- package/template/.agent/skills/webapp-testing/SKILL.md +187 -0
- package/template/.agent/skills/webapp-testing/scripts/playwright_runner.py +173 -0
- package/template/.agent/skills/zalo-mini-app/SKILL.md +81 -0
- package/template/.agent/skills/zalo-mini-app/references/api-device.md +121 -0
- package/template/.agent/skills/zalo-mini-app/references/api-overview.md +88 -0
- package/template/.agent/skills/zalo-mini-app/references/api-storage.md +74 -0
- package/template/.agent/skills/zalo-mini-app/references/api-ui.md +124 -0
- package/template/.agent/skills/zalo-mini-app/references/api-user.md +113 -0
- package/template/.agent/skills/zalo-mini-app/references/api-zalo.md +127 -0
- package/template/.agent/skills/zalo-mini-app/references/design-guidelines.md +70 -0
- package/template/.agent/skills/zalo-mini-app/references/getting-started.md +95 -0
- package/template/.agent/skills/zalo-mini-app/references/react-best-practices.md +790 -0
- package/template/.agent/skills/zalo-mini-app/references/web-design-guidelines.md +591 -0
- package/template/.agent/skills/zalo-mini-app/references/zaui-display.md +103 -0
- package/template/.agent/skills/zalo-mini-app/references/zaui-form.md +108 -0
- package/template/.agent/skills/zalo-mini-app/references/zaui-layout.md +94 -0
- package/template/.agent/skills/zalo-mini-app/references/zaui-overlay.md +98 -0
- package/template/.agent/skills/zalo-mini-app/references/zaui-overview.md +82 -0
- package/template/.agent/workflows/brainstorm.md +113 -0
- package/template/.agent/workflows/create.md +59 -0
- package/template/.agent/workflows/debug.md +103 -0
- package/template/.agent/workflows/deploy.md +176 -0
- package/template/.agent/workflows/enhance.md +63 -0
- package/template/.agent/workflows/orchestrate.md +237 -0
- package/template/.agent/workflows/plan.md +89 -0
- package/template/.agent/workflows/preview.md +81 -0
- package/template/.agent/workflows/status.md +86 -0
- package/template/.agent/workflows/test.md +144 -0
- package/template/.agent/workflows/ui-ux-pro-max.md +296 -0
- package/template/.agent/workflows/veo-marketing.md +46 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Skill: webapp-testing
|
|
4
|
+
Script: playwright_runner.py
|
|
5
|
+
Purpose: Run basic Playwright browser tests
|
|
6
|
+
Usage: python playwright_runner.py <url> [--screenshot]
|
|
7
|
+
Output: JSON with page info, health status, and optional screenshot path
|
|
8
|
+
Note: Requires playwright (pip install playwright && playwright install chromium)
|
|
9
|
+
Screenshots: Saved to system temp directory (auto-cleaned by OS)
|
|
10
|
+
"""
|
|
11
|
+
import sys
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
import tempfile
|
|
15
|
+
from datetime import datetime
|
|
16
|
+
|
|
17
|
+
# Fix Windows console encoding for Unicode output
|
|
18
|
+
try:
|
|
19
|
+
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
|
20
|
+
sys.stderr.reconfigure(encoding='utf-8', errors='replace')
|
|
21
|
+
except AttributeError:
|
|
22
|
+
pass # Python < 3.7
|
|
23
|
+
|
|
24
|
+
try:
|
|
25
|
+
from playwright.sync_api import sync_playwright
|
|
26
|
+
PLAYWRIGHT_AVAILABLE = True
|
|
27
|
+
except ImportError:
|
|
28
|
+
PLAYWRIGHT_AVAILABLE = False
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def run_basic_test(url: str, take_screenshot: bool = False) -> dict:
|
|
32
|
+
"""Run basic browser test on URL."""
|
|
33
|
+
if not PLAYWRIGHT_AVAILABLE:
|
|
34
|
+
return {
|
|
35
|
+
"error": "Playwright not installed",
|
|
36
|
+
"fix": "pip install playwright && playwright install chromium"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
result = {
|
|
40
|
+
"url": url,
|
|
41
|
+
"timestamp": datetime.now().isoformat(),
|
|
42
|
+
"status": "pending"
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
try:
|
|
46
|
+
with sync_playwright() as p:
|
|
47
|
+
browser = p.chromium.launch(headless=True)
|
|
48
|
+
context = browser.new_context(
|
|
49
|
+
viewport={"width": 1280, "height": 720},
|
|
50
|
+
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
|
51
|
+
)
|
|
52
|
+
page = context.new_page()
|
|
53
|
+
|
|
54
|
+
# Navigate
|
|
55
|
+
response = page.goto(url, wait_until="networkidle", timeout=30000)
|
|
56
|
+
|
|
57
|
+
# Basic info
|
|
58
|
+
result["page"] = {
|
|
59
|
+
"title": page.title(),
|
|
60
|
+
"url": page.url,
|
|
61
|
+
"status_code": response.status if response else None
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
# Health checks
|
|
65
|
+
result["health"] = {
|
|
66
|
+
"loaded": response.ok if response else False,
|
|
67
|
+
"has_title": bool(page.title()),
|
|
68
|
+
"has_h1": page.locator("h1").count() > 0,
|
|
69
|
+
"has_links": page.locator("a").count() > 0,
|
|
70
|
+
"has_images": page.locator("img").count() > 0
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
# Console errors
|
|
74
|
+
console_errors = []
|
|
75
|
+
page.on("console", lambda msg: console_errors.append(msg.text) if msg.type == "error" else None)
|
|
76
|
+
|
|
77
|
+
# Performance metrics
|
|
78
|
+
result["performance"] = {
|
|
79
|
+
"dom_content_loaded": page.evaluate("window.performance.timing.domContentLoadedEventEnd - window.performance.timing.navigationStart"),
|
|
80
|
+
"load_complete": page.evaluate("window.performance.timing.loadEventEnd - window.performance.timing.navigationStart")
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# Screenshot - uses system temp directory (cross-platform, auto-cleaned)
|
|
84
|
+
if take_screenshot:
|
|
85
|
+
# Cross-platform: Windows=%TEMP%, Linux/macOS=/tmp
|
|
86
|
+
screenshot_dir = os.path.join(tempfile.gettempdir(), "maestro_screenshots")
|
|
87
|
+
os.makedirs(screenshot_dir, exist_ok=True)
|
|
88
|
+
screenshot_path = os.path.join(screenshot_dir, f"screenshot_{datetime.now().strftime('%Y%m%d_%H%M%S')}.png")
|
|
89
|
+
page.screenshot(path=screenshot_path, full_page=True)
|
|
90
|
+
result["screenshot"] = screenshot_path
|
|
91
|
+
result["screenshot_note"] = "Saved to temp directory (auto-cleaned by OS)"
|
|
92
|
+
|
|
93
|
+
# Element counts
|
|
94
|
+
result["elements"] = {
|
|
95
|
+
"links": page.locator("a").count(),
|
|
96
|
+
"buttons": page.locator("button").count(),
|
|
97
|
+
"inputs": page.locator("input").count(),
|
|
98
|
+
"images": page.locator("img").count(),
|
|
99
|
+
"forms": page.locator("form").count()
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
browser.close()
|
|
103
|
+
|
|
104
|
+
result["status"] = "success" if result["health"]["loaded"] else "failed"
|
|
105
|
+
result["summary"] = "[OK] Page loaded successfully" if result["status"] == "success" else "[X] Page failed to load"
|
|
106
|
+
|
|
107
|
+
except Exception as e:
|
|
108
|
+
result["status"] = "error"
|
|
109
|
+
result["error"] = str(e)
|
|
110
|
+
result["summary"] = f"[X] Error: {str(e)[:100]}"
|
|
111
|
+
|
|
112
|
+
return result
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def run_accessibility_check(url: str) -> dict:
|
|
116
|
+
"""Run basic accessibility check."""
|
|
117
|
+
if not PLAYWRIGHT_AVAILABLE:
|
|
118
|
+
return {"error": "Playwright not installed"}
|
|
119
|
+
|
|
120
|
+
result = {"url": url, "accessibility": {}}
|
|
121
|
+
|
|
122
|
+
try:
|
|
123
|
+
with sync_playwright() as p:
|
|
124
|
+
browser = p.chromium.launch(headless=True)
|
|
125
|
+
page = browser.new_page()
|
|
126
|
+
page.goto(url, wait_until="networkidle", timeout=30000)
|
|
127
|
+
|
|
128
|
+
# Basic a11y checks
|
|
129
|
+
result["accessibility"] = {
|
|
130
|
+
"images_with_alt": page.locator("img[alt]").count(),
|
|
131
|
+
"images_without_alt": page.locator("img:not([alt])").count(),
|
|
132
|
+
"buttons_with_label": page.locator("button[aria-label], button:has-text('')").count(),
|
|
133
|
+
"links_with_text": page.locator("a:has-text('')").count(),
|
|
134
|
+
"form_labels": page.locator("label").count(),
|
|
135
|
+
"headings": {
|
|
136
|
+
"h1": page.locator("h1").count(),
|
|
137
|
+
"h2": page.locator("h2").count(),
|
|
138
|
+
"h3": page.locator("h3").count()
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
browser.close()
|
|
143
|
+
result["status"] = "success"
|
|
144
|
+
|
|
145
|
+
except Exception as e:
|
|
146
|
+
result["status"] = "error"
|
|
147
|
+
result["error"] = str(e)
|
|
148
|
+
|
|
149
|
+
return result
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
if __name__ == "__main__":
|
|
153
|
+
if len(sys.argv) < 2:
|
|
154
|
+
print(json.dumps({
|
|
155
|
+
"error": "Usage: python playwright_runner.py <url> [--screenshot] [--a11y]",
|
|
156
|
+
"examples": [
|
|
157
|
+
"python playwright_runner.py https://example.com",
|
|
158
|
+
"python playwright_runner.py https://example.com --screenshot",
|
|
159
|
+
"python playwright_runner.py https://example.com --a11y"
|
|
160
|
+
]
|
|
161
|
+
}, indent=2))
|
|
162
|
+
sys.exit(1)
|
|
163
|
+
|
|
164
|
+
url = sys.argv[1]
|
|
165
|
+
take_screenshot = "--screenshot" in sys.argv
|
|
166
|
+
check_a11y = "--a11y" in sys.argv
|
|
167
|
+
|
|
168
|
+
if check_a11y:
|
|
169
|
+
result = run_accessibility_check(url)
|
|
170
|
+
else:
|
|
171
|
+
result = run_basic_test(url, take_screenshot)
|
|
172
|
+
|
|
173
|
+
print(json.dumps(result, indent=2))
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: zalo-mini-app
|
|
3
|
+
description: Build Zalo Mini Apps - lightweight web apps running inside Zalo super-app. This skill provides ZaUI components (Button, Input, Modal, Tabs, Avatar, etc.), JavaScript APIs (authorize, getUserInfo, getPhoneNumber, getLocation, Storage, Camera), Checkout SDK for payments, design guidelines, and development tools. Use when building Mini Apps, using ZaUI components, calling Zalo APIs, integrating payments, converting web apps to Mini Apps, or following Zalo design standards.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Zalo Mini App Development
|
|
7
|
+
|
|
8
|
+
Build Mini Apps for the Zalo platform using React, ZaUI components, and Zalo SDK APIs.
|
|
9
|
+
|
|
10
|
+
## Quick Start
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g zmp-cli
|
|
13
|
+
zmp create my-app && cd my-app && zmp start
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
See [getting-started.md](./references/getting-started.md) for full setup, deployment, and app-config.json.
|
|
17
|
+
|
|
18
|
+
## Core Packages
|
|
19
|
+
```bash
|
|
20
|
+
npm install zmp-ui zmp-sdk
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import { Button, Input, Modal } from "zmp-ui";
|
|
25
|
+
import "zmp-ui/zaui.css";
|
|
26
|
+
import { getUserInfo, authorize } from "zmp-sdk/apis";
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## References
|
|
30
|
+
|
|
31
|
+
### APIs
|
|
32
|
+
- [api-overview.md](./references/api-overview.md) - API categories & patterns
|
|
33
|
+
- [api-user.md](./references/api-user.md) - authorize, getUserInfo, getPhoneNumber
|
|
34
|
+
- [api-storage.md](./references/api-storage.md) - setItem, getItem, storage APIs
|
|
35
|
+
- [api-ui.md](./references/api-ui.md) - showToast, navigation, routing
|
|
36
|
+
- [api-device.md](./references/api-device.md) - location, camera, QR, NFC
|
|
37
|
+
- [api-zalo.md](./references/api-zalo.md) - followOA, openChat, share
|
|
38
|
+
|
|
39
|
+
### ZaUI Components
|
|
40
|
+
- [zaui-overview.md](./references/zaui-overview.md) - Component list & design tokens
|
|
41
|
+
- [zaui-layout.md](./references/zaui-layout.md) - App, Page, Header, Tabs, Router
|
|
42
|
+
- [zaui-display.md](./references/zaui-display.md) - Avatar, Icon, List, Swiper
|
|
43
|
+
- [zaui-form.md](./references/zaui-form.md) - Button, Input, Select, DatePicker
|
|
44
|
+
- [zaui-overlay.md](./references/zaui-overlay.md) - Modal, Sheet, ActionSheet
|
|
45
|
+
|
|
46
|
+
### Design & Setup
|
|
47
|
+
- [design-guidelines.md](./references/design-guidelines.md) - Colors, typography, UX
|
|
48
|
+
- [getting-started.md](./references/getting-started.md) - Setup, deploy, publish
|
|
49
|
+
- [web-design-guidelines.md](./references/web-design-guidelines.md) - Accessibility, forms, animations, touch, i18n
|
|
50
|
+
|
|
51
|
+
### Performance & React
|
|
52
|
+
- [react-best-practices.md](./references/react-best-practices.md) - Waterfalls, bundle size, re-renders, JS performance
|
|
53
|
+
|
|
54
|
+
## Common Patterns
|
|
55
|
+
|
|
56
|
+
### Get User Info
|
|
57
|
+
```js
|
|
58
|
+
const { userInfo } = await getUserInfo({ autoRequestPermission: true });
|
|
59
|
+
// { id, name, avatar, followedOA }
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Basic Page Layout
|
|
63
|
+
```jsx
|
|
64
|
+
<App>
|
|
65
|
+
<Page>
|
|
66
|
+
<Header title="Home" />
|
|
67
|
+
<List>
|
|
68
|
+
<List.Item title="Item" suffix={<Icon icon="zi-chevron-right" />} />
|
|
69
|
+
</List>
|
|
70
|
+
</Page>
|
|
71
|
+
<BottomNavigation fixed>
|
|
72
|
+
<BottomNavigation.Item key="home" label="Home" icon={<Icon icon="zi-home" />} />
|
|
73
|
+
</BottomNavigation>
|
|
74
|
+
</App>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Resources
|
|
78
|
+
- Docs: https://miniapp.zaloplatforms.com/documents/
|
|
79
|
+
- Mini App Center: https://miniapp.zaloplatforms.com/
|
|
80
|
+
- React Best Practices: https://react.dev
|
|
81
|
+
- SWR: https://swr.vercel.app
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Device & Media APIs
|
|
2
|
+
|
|
3
|
+
## Location
|
|
4
|
+
|
|
5
|
+
### getLocation
|
|
6
|
+
Get GPS coordinates (requires permission).
|
|
7
|
+
```js
|
|
8
|
+
import { getLocation } from "zmp-sdk/apis";
|
|
9
|
+
|
|
10
|
+
const { latitude, longitude, accuracy } = await getLocation({});
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Camera
|
|
14
|
+
|
|
15
|
+
### createCameraContext
|
|
16
|
+
Create camera controller for streaming.
|
|
17
|
+
```js
|
|
18
|
+
import { createCameraContext } from "zmp-sdk/apis";
|
|
19
|
+
|
|
20
|
+
const camera = createCameraContext();
|
|
21
|
+
|
|
22
|
+
await camera.start({
|
|
23
|
+
targetElement: document.getElementById("camera-view"),
|
|
24
|
+
facing: "back" // "front" | "back"
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const photo = await camera.takePhoto({});
|
|
28
|
+
await camera.stop();
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Camera methods:
|
|
32
|
+
- `start()` - Start streaming
|
|
33
|
+
- `stop()` - Stop streaming
|
|
34
|
+
- `pause()` / `resume()`
|
|
35
|
+
- `takePhoto()` - Capture image
|
|
36
|
+
- `flip()` - Switch front/back
|
|
37
|
+
- `setMirror(true)` - Mirror mode
|
|
38
|
+
|
|
39
|
+
### requestCameraPermission
|
|
40
|
+
Request camera access.
|
|
41
|
+
```js
|
|
42
|
+
import { requestCameraPermission } from "zmp-sdk/apis";
|
|
43
|
+
|
|
44
|
+
await requestCameraPermission({});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## File & Media
|
|
48
|
+
|
|
49
|
+
### chooseImage
|
|
50
|
+
Select images from gallery.
|
|
51
|
+
```js
|
|
52
|
+
import { chooseImage } from "zmp-sdk/apis";
|
|
53
|
+
|
|
54
|
+
const { tempFilePaths } = await chooseImage({
|
|
55
|
+
count: 9,
|
|
56
|
+
sourceType: ["album", "camera"]
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### openMediaPicker
|
|
61
|
+
Open media picker.
|
|
62
|
+
```js
|
|
63
|
+
import { openMediaPicker } from "zmp-sdk/apis";
|
|
64
|
+
|
|
65
|
+
const { files } = await openMediaPicker({
|
|
66
|
+
type: "image", // "image" | "video" | "file"
|
|
67
|
+
maxSelection: 5
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### saveImageToGallery / saveVideoToGallery
|
|
72
|
+
Save media to device gallery.
|
|
73
|
+
```js
|
|
74
|
+
import { saveImageToGallery } from "zmp-sdk/apis";
|
|
75
|
+
|
|
76
|
+
await saveImageToGallery({
|
|
77
|
+
imageUrl: "https://example.com/image.jpg"
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Scanning
|
|
82
|
+
|
|
83
|
+
### scanQRCode
|
|
84
|
+
Scan QR/barcode.
|
|
85
|
+
```js
|
|
86
|
+
import { scanQRCode } from "zmp-sdk/apis";
|
|
87
|
+
|
|
88
|
+
const { content } = await scanQRCode({});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### scanNFC
|
|
92
|
+
Read NFC tag.
|
|
93
|
+
```js
|
|
94
|
+
import { checkNFC, scanNFC } from "zmp-sdk/apis";
|
|
95
|
+
|
|
96
|
+
const { available } = await checkNFC({});
|
|
97
|
+
if (available) {
|
|
98
|
+
const { data } = await scanNFC({});
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Network
|
|
103
|
+
|
|
104
|
+
### getNetworkType
|
|
105
|
+
Check connection type.
|
|
106
|
+
```js
|
|
107
|
+
import { getNetworkType } from "zmp-sdk/apis";
|
|
108
|
+
|
|
109
|
+
const { networkType } = await getNetworkType({});
|
|
110
|
+
// "wifi" | "4g" | "3g" | "2g" | "none"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Screen
|
|
114
|
+
|
|
115
|
+
### keepScreen / vibrate
|
|
116
|
+
```js
|
|
117
|
+
import { keepScreen, vibrate } from "zmp-sdk/apis";
|
|
118
|
+
|
|
119
|
+
keepScreen({ on: true }); // Keep screen awake
|
|
120
|
+
vibrate({}); // Vibrate device
|
|
121
|
+
```
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Zalo Mini App API Overview
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
```bash
|
|
5
|
+
npm install zmp-sdk
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## Import Pattern
|
|
9
|
+
```js
|
|
10
|
+
import { apiName } from "zmp-sdk/apis";
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## API Categories
|
|
14
|
+
|
|
15
|
+
### User & Authorization
|
|
16
|
+
See [api-user.md](./api-user.md)
|
|
17
|
+
- `authorize` - Request permissions
|
|
18
|
+
- `getUserID` - Get user ID
|
|
19
|
+
- `getUserInfo` - Get user name, avatar
|
|
20
|
+
- `getPhoneNumber` - Get phone number
|
|
21
|
+
- `getAccessToken` - Get auth token
|
|
22
|
+
- `getSetting` - Get user settings
|
|
23
|
+
|
|
24
|
+
### Storage
|
|
25
|
+
See [api-storage.md](./api-storage.md)
|
|
26
|
+
- `setItem`, `getItem`, `removeItem`, `clear`
|
|
27
|
+
- `getStorageInfo`
|
|
28
|
+
|
|
29
|
+
### UI & Navigation
|
|
30
|
+
See [api-ui.md](./api-ui.md)
|
|
31
|
+
- `showToast`, `closeLoading`
|
|
32
|
+
- `configAppView`, `setNavigationBarColor/Title/LeftButton`
|
|
33
|
+
- `hideKeyboard`
|
|
34
|
+
|
|
35
|
+
### Routing
|
|
36
|
+
- `closeApp` - Close mini app
|
|
37
|
+
- `openMiniApp` - Open another mini app
|
|
38
|
+
- `openWebview` - Open external URL
|
|
39
|
+
- `sendDataToPreviousMiniApp` - Send data back
|
|
40
|
+
- `getRouteParams` - Get URL params
|
|
41
|
+
|
|
42
|
+
### Device & Media
|
|
43
|
+
See [api-device.md](./api-device.md)
|
|
44
|
+
- `getLocation` - GPS location
|
|
45
|
+
- `createCameraContext` - Camera control
|
|
46
|
+
- `chooseImage`, `openMediaPicker`
|
|
47
|
+
- `saveImageToGallery`, `saveVideoToGallery`
|
|
48
|
+
- `scanQRCode`, `scanNFC`
|
|
49
|
+
- `getNetworkType`, `vibrate`, `keepScreen`
|
|
50
|
+
|
|
51
|
+
### Zalo Features
|
|
52
|
+
See [api-zalo.md](./api-zalo.md)
|
|
53
|
+
- `followOA`, `unfollowOA`, `interactOA`
|
|
54
|
+
- `openChat`, `openProfile`, `openShareSheet`
|
|
55
|
+
- `createShortcut`, `addRating`
|
|
56
|
+
|
|
57
|
+
## Events
|
|
58
|
+
```js
|
|
59
|
+
import { events, EventName } from "zmp-sdk/apis";
|
|
60
|
+
|
|
61
|
+
events.on(EventName.NetworkChanged, (data) => {});
|
|
62
|
+
events.on(EventName.AppPaused, () => {});
|
|
63
|
+
events.on(EventName.AppResumed, () => {});
|
|
64
|
+
events.on(EventName.OpenApp, () => {});
|
|
65
|
+
events.on(EventName.OnDataCallback, (data) => {});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Error Handling
|
|
69
|
+
```js
|
|
70
|
+
import { AppError } from "zmp-sdk";
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
const result = await someApi();
|
|
74
|
+
} catch (error) {
|
|
75
|
+
if (error instanceof AppError) {
|
|
76
|
+
console.log(error.code, error.message);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Common error codes:
|
|
82
|
+
- `-1401`: User denied permission
|
|
83
|
+
- `-1`: Unknown error
|
|
84
|
+
|
|
85
|
+
## Permission Notes
|
|
86
|
+
- Some APIs require Zalo approval before use
|
|
87
|
+
- Admin accounts can test all APIs without approval
|
|
88
|
+
- User-sensitive APIs (phone, location) need user consent
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Storage APIs
|
|
2
|
+
|
|
3
|
+
Local storage on user's device, persists across sessions.
|
|
4
|
+
|
|
5
|
+
## setItem
|
|
6
|
+
Save data to storage.
|
|
7
|
+
```js
|
|
8
|
+
import { setItem } from "zmp-sdk/apis";
|
|
9
|
+
|
|
10
|
+
await setItem({
|
|
11
|
+
data: {
|
|
12
|
+
key1: "value1",
|
|
13
|
+
key2: { nested: "object" },
|
|
14
|
+
key3: [1, 2, 3]
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## getItem
|
|
20
|
+
Retrieve stored data.
|
|
21
|
+
```js
|
|
22
|
+
import { getItem } from "zmp-sdk/apis";
|
|
23
|
+
|
|
24
|
+
const { key1, key2 } = await getItem({
|
|
25
|
+
keys: ["key1", "key2"]
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## removeItem
|
|
30
|
+
Delete specific keys.
|
|
31
|
+
```js
|
|
32
|
+
import { removeItem } from "zmp-sdk/apis";
|
|
33
|
+
|
|
34
|
+
await removeItem({
|
|
35
|
+
keys: ["key1", "key2"]
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## clear
|
|
40
|
+
Clear all storage.
|
|
41
|
+
```js
|
|
42
|
+
import { clear } from "zmp-sdk/apis";
|
|
43
|
+
|
|
44
|
+
await clear({});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## getStorageInfo
|
|
48
|
+
Get storage usage info.
|
|
49
|
+
```js
|
|
50
|
+
import { getStorageInfo } from "zmp-sdk/apis";
|
|
51
|
+
|
|
52
|
+
const { keys, currentSize, limitSize } = await getStorageInfo({});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Best Practices
|
|
56
|
+
- Store only essential data
|
|
57
|
+
- Use JSON for complex objects
|
|
58
|
+
- Check storage limits before saving
|
|
59
|
+
- Handle errors for quota exceeded
|
|
60
|
+
|
|
61
|
+
## Example: Address Book Cache
|
|
62
|
+
```js
|
|
63
|
+
async function getAddresses() {
|
|
64
|
+
const { addresses } = await getItem({ keys: ["addresses"] });
|
|
65
|
+
return addresses || [];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function saveAddress(address) {
|
|
69
|
+
const addresses = await getAddresses();
|
|
70
|
+
addresses.push(address);
|
|
71
|
+
await setItem({ data: { addresses } });
|
|
72
|
+
return addresses;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# UI & Navigation APIs
|
|
2
|
+
|
|
3
|
+
## showToast
|
|
4
|
+
Display a toast message.
|
|
5
|
+
```js
|
|
6
|
+
import { showToast } from "zmp-sdk/apis";
|
|
7
|
+
|
|
8
|
+
showToast({
|
|
9
|
+
message: "Operation successful",
|
|
10
|
+
duration: 2000 // ms
|
|
11
|
+
});
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## closeLoading
|
|
15
|
+
Hide splash loading screen.
|
|
16
|
+
```js
|
|
17
|
+
import { closeLoading } from "zmp-sdk/apis";
|
|
18
|
+
|
|
19
|
+
closeLoading({});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## configAppView
|
|
23
|
+
Configure status bar, action bar, and safe area.
|
|
24
|
+
```js
|
|
25
|
+
import { configAppView } from "zmp-sdk/apis";
|
|
26
|
+
|
|
27
|
+
configAppView({
|
|
28
|
+
headerColor: "#1843EF",
|
|
29
|
+
headerTextColor: "white",
|
|
30
|
+
statusBarType: "normal", // "normal" | "transparent"
|
|
31
|
+
actionBarHidden: false,
|
|
32
|
+
hideAndroidBottomNavigationBar: true,
|
|
33
|
+
hideIOSSafeAreaBottom: false
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## setNavigationBarColor
|
|
38
|
+
Change navigation bar color.
|
|
39
|
+
```js
|
|
40
|
+
import { setNavigationBarColor } from "zmp-sdk/apis";
|
|
41
|
+
|
|
42
|
+
setNavigationBarColor({
|
|
43
|
+
color: "#FF5722"
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## setNavigationBarTitle
|
|
48
|
+
Change navigation bar title.
|
|
49
|
+
```js
|
|
50
|
+
import { setNavigationBarTitle } from "zmp-sdk/apis";
|
|
51
|
+
|
|
52
|
+
setNavigationBarTitle({
|
|
53
|
+
title: "New Title"
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## setNavigationBarLeftButton
|
|
58
|
+
Set left button type.
|
|
59
|
+
```js
|
|
60
|
+
import { setNavigationBarLeftButton } from "zmp-sdk/apis";
|
|
61
|
+
|
|
62
|
+
setNavigationBarLeftButton({
|
|
63
|
+
type: "back" // "back" | "home"
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## hideKeyboard
|
|
68
|
+
Dismiss the keyboard.
|
|
69
|
+
```js
|
|
70
|
+
import { hideKeyboard } from "zmp-sdk/apis";
|
|
71
|
+
|
|
72
|
+
hideKeyboard({});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Routing APIs
|
|
76
|
+
|
|
77
|
+
### closeApp
|
|
78
|
+
Close mini app.
|
|
79
|
+
```js
|
|
80
|
+
import { closeApp } from "zmp-sdk/apis";
|
|
81
|
+
|
|
82
|
+
closeApp({});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### openMiniApp
|
|
86
|
+
Open another mini app.
|
|
87
|
+
```js
|
|
88
|
+
import { openMiniApp } from "zmp-sdk/apis";
|
|
89
|
+
|
|
90
|
+
openMiniApp({
|
|
91
|
+
appId: "other-mini-app-id",
|
|
92
|
+
path: "/page?param=value"
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### openWebview
|
|
97
|
+
Open URL in webview.
|
|
98
|
+
```js
|
|
99
|
+
import { openWebview } from "zmp-sdk/apis";
|
|
100
|
+
|
|
101
|
+
openWebview({
|
|
102
|
+
url: "https://example.com"
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### sendDataToPreviousMiniApp
|
|
107
|
+
Send data back to calling mini app.
|
|
108
|
+
```js
|
|
109
|
+
import { sendDataToPreviousMiniApp } from "zmp-sdk/apis";
|
|
110
|
+
|
|
111
|
+
sendDataToPreviousMiniApp({
|
|
112
|
+
data: { result: "success" }
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### getRouteParams
|
|
117
|
+
Get URL parameters.
|
|
118
|
+
```js
|
|
119
|
+
import { getRouteParams } from "zmp-sdk/apis";
|
|
120
|
+
|
|
121
|
+
const params = getRouteParams();
|
|
122
|
+
// For URL: /page?id=123&type=product
|
|
123
|
+
// Returns: { id: "123", type: "product" }
|
|
124
|
+
```
|