@agentskillkit/agent-skills 1.0.1
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/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
- package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
- package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
- package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
- package/.agent/ARCHITECTURE.md +292 -0
- package/.agent/GEMINI.md +374 -0
- package/.agent/agents/backend-specialist.md +263 -0
- package/.agent/agents/code-archaeologist.md +106 -0
- package/.agent/agents/database-architect.md +226 -0
- package/.agent/agents/debugger.md +225 -0
- package/.agent/agents/devops-engineer.md +242 -0
- package/.agent/agents/documentation-writer.md +104 -0
- package/.agent/agents/explorer-agent.md +73 -0
- package/.agent/agents/frontend-specialist.md +556 -0
- package/.agent/agents/game-developer.md +162 -0
- package/.agent/agents/mobile-developer.md +377 -0
- package/.agent/agents/orchestrator.md +416 -0
- package/.agent/agents/penetration-tester.md +188 -0
- package/.agent/agents/performance-optimizer.md +187 -0
- package/.agent/agents/product-manager.md +112 -0
- package/.agent/agents/product-owner.md +95 -0
- package/.agent/agents/project-planner.md +406 -0
- package/.agent/agents/qa-automation-engineer.md +103 -0
- package/.agent/agents/security-auditor.md +170 -0
- package/.agent/agents/seo-specialist.md +111 -0
- package/.agent/agents/test-engineer.md +158 -0
- package/.agent/knowledge/lessons-learned.yaml +17 -0
- package/.agent/rules/GEMINI.md +253 -0
- package/.agent/scripts/auto_preview.py +148 -0
- package/.agent/scripts/checklist.py +217 -0
- package/.agent/scripts/session_manager.py +120 -0
- package/.agent/scripts/verify_all.py +327 -0
- package/.agent/skills/aesthetic/SKILL.md +121 -0
- package/.agent/skills/aesthetic/assets/design-guideline-template.md +163 -0
- package/.agent/skills/aesthetic/assets/design-story-template.md +135 -0
- package/.agent/skills/aesthetic/references/design-principles.md +62 -0
- package/.agent/skills/aesthetic/references/design-resources.md +75 -0
- package/.agent/skills/aesthetic/references/micro-interactions.md +53 -0
- package/.agent/skills/aesthetic/references/storytelling-design.md +50 -0
- package/.agent/skills/api-patterns/SKILL.md +81 -0
- package/.agent/skills/api-patterns/rules/api-style.md +42 -0
- package/.agent/skills/api-patterns/rules/auth.md +24 -0
- package/.agent/skills/api-patterns/rules/documentation.md +26 -0
- package/.agent/skills/api-patterns/rules/graphql.md +41 -0
- package/.agent/skills/api-patterns/rules/rate-limiting.md +31 -0
- package/.agent/skills/api-patterns/rules/response.md +37 -0
- package/.agent/skills/api-patterns/rules/rest.md +40 -0
- package/.agent/skills/api-patterns/rules/security-testing.md +122 -0
- package/.agent/skills/api-patterns/rules/trpc.md +41 -0
- package/.agent/skills/api-patterns/rules/versioning.md +22 -0
- package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
- package/.agent/skills/app-builder/SKILL.md +75 -0
- package/.agent/skills/app-builder/agent-coordination.md +71 -0
- package/.agent/skills/app-builder/feature-building.md +53 -0
- package/.agent/skills/app-builder/project-detection.md +34 -0
- package/.agent/skills/app-builder/scaffolding.md +118 -0
- package/.agent/skills/app-builder/tech-stack.md +40 -0
- package/.agent/skills/app-builder/templates/SKILL.md +39 -0
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +82 -0
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +100 -0
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +106 -0
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +101 -0
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +93 -0
- package/.agent/skills/architecture/SKILL.md +55 -0
- package/.agent/skills/architecture/context-discovery.md +43 -0
- package/.agent/skills/architecture/examples.md +94 -0
- package/.agent/skills/architecture/pattern-selection.md +68 -0
- package/.agent/skills/architecture/patterns-reference.md +50 -0
- package/.agent/skills/architecture/trade-off-analysis.md +77 -0
- package/.agent/skills/bash-linux/SKILL.md +199 -0
- package/.agent/skills/behavioral-modes/SKILL.md +242 -0
- package/.agent/skills/brainstorming/SKILL.md +163 -0
- package/.agent/skills/brainstorming/dynamic-questioning.md +350 -0
- package/.agent/skills/clean-code/SKILL.md +201 -0
- package/.agent/skills/code-review-checklist/SKILL.md +109 -0
- package/.agent/skills/code-reviewer/.skill-source.json +8 -0
- package/.agent/skills/code-reviewer/SKILL.md +32 -0
- package/.agent/skills/code-reviewer/enforcement/checklists/backend-api-review-checklist.md +5 -0
- package/.agent/skills/code-reviewer/examples/approved-pr/review-output.md +76 -0
- package/.agent/skills/code-reviewer/examples/rejected-pr/review-output.md +99 -0
- package/.agent/skills/code-reviewer/examples/scenarios.md +3 -0
- package/.agent/skills/code-reviewer/metadata/doctrine-mapping.yaml +167 -0
- package/.agent/skills/code-reviewer/metadata/intent-triggers.yaml +41 -0
- package/.agent/skills/code-reviewer/resources/links.md +59 -0
- package/.agent/skills/code-reviewer/scripts/audit_pr.js +8 -0
- package/.agent/skills/code-reviewer/scripts/audit_pr.v2.js +417 -0
- package/.agent/skills/code-reviewer/scripts/validate_doctrine.js +307 -0
- package/.agent/skills/context-engineering/SKILL.md +86 -0
- package/.agent/skills/context-engineering/references/context-compression.md +84 -0
- package/.agent/skills/context-engineering/references/context-degradation.md +93 -0
- package/.agent/skills/context-engineering/references/context-fundamentals.md +75 -0
- package/.agent/skills/context-engineering/references/context-optimization.md +82 -0
- package/.agent/skills/context-engineering/references/evaluation.md +89 -0
- package/.agent/skills/context-engineering/references/memory-systems.md +88 -0
- package/.agent/skills/context-engineering/references/multi-agent-patterns.md +90 -0
- package/.agent/skills/context-engineering/references/project-development.md +97 -0
- package/.agent/skills/context-engineering/references/tool-design.md +86 -0
- package/.agent/skills/context-engineering/scripts/compression_evaluator.py +329 -0
- package/.agent/skills/context-engineering/scripts/context_analyzer.py +294 -0
- package/.agent/skills/database-design/SKILL.md +52 -0
- package/.agent/skills/database-design/database-selection.md +43 -0
- package/.agent/skills/database-design/indexing.md +39 -0
- package/.agent/skills/database-design/migrations.md +48 -0
- package/.agent/skills/database-design/optimization.md +36 -0
- package/.agent/skills/database-design/orm-selection.md +30 -0
- package/.agent/skills/database-design/schema-design.md +56 -0
- package/.agent/skills/database-design/scripts/schema_validator.py +172 -0
- package/.agent/skills/debugging/SKILL.md +42 -0
- package/.agent/skills/debugging/defense-in-depth/SKILL.md +130 -0
- package/.agent/skills/debugging/root-cause-tracing/SKILL.md +177 -0
- package/.agent/skills/debugging/root-cause-tracing/find-polluter.sh +63 -0
- package/.agent/skills/debugging/verification-before-completion/SKILL.md +142 -0
- package/.agent/skills/deployment-procedures/SKILL.md +241 -0
- package/.agent/skills/doc.md +177 -0
- package/.agent/skills/document-skills/SKILL.md +49 -0
- package/.agent/skills/document-skills/docx/LICENSE.txt +30 -0
- package/.agent/skills/document-skills/docx/SKILL.md +197 -0
- package/.agent/skills/document-skills/docx/docx-js.md +350 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/mce/mc.xsd +75 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/.agent/skills/document-skills/docx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/.agent/skills/document-skills/docx/ooxml/scripts/pack.py +159 -0
- package/.agent/skills/document-skills/docx/ooxml/scripts/unpack.py +29 -0
- package/.agent/skills/document-skills/docx/ooxml/scripts/validate.py +69 -0
- package/.agent/skills/document-skills/docx/ooxml/scripts/validation/__init__.py +15 -0
- package/.agent/skills/document-skills/docx/ooxml/scripts/validation/base.py +951 -0
- package/.agent/skills/document-skills/docx/ooxml/scripts/validation/docx.py +274 -0
- package/.agent/skills/document-skills/docx/ooxml/scripts/validation/pptx.py +315 -0
- package/.agent/skills/document-skills/docx/ooxml/scripts/validation/redlining.py +279 -0
- package/.agent/skills/document-skills/docx/ooxml.md +610 -0
- package/.agent/skills/document-skills/docx/scripts/__init__.py +1 -0
- package/.agent/skills/document-skills/docx/scripts/document.py +1276 -0
- package/.agent/skills/document-skills/docx/scripts/templates/comments.xml +3 -0
- package/.agent/skills/document-skills/docx/scripts/templates/commentsExtended.xml +3 -0
- package/.agent/skills/document-skills/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/.agent/skills/document-skills/docx/scripts/templates/commentsIds.xml +3 -0
- package/.agent/skills/document-skills/docx/scripts/templates/people.xml +3 -0
- package/.agent/skills/document-skills/docx/scripts/utilities.py +374 -0
- package/.agent/skills/document-skills/pdf/LICENSE.txt +30 -0
- package/.agent/skills/document-skills/pdf/SKILL.md +294 -0
- package/.agent/skills/document-skills/pdf/forms.md +205 -0
- package/.agent/skills/document-skills/pdf/reference.md +612 -0
- package/.agent/skills/document-skills/pdf/scripts/check_bounding_boxes.py +70 -0
- package/.agent/skills/document-skills/pdf/scripts/check_bounding_boxes_test.py +226 -0
- package/.agent/skills/document-skills/pdf/scripts/check_fillable_fields.py +12 -0
- package/.agent/skills/document-skills/pdf/scripts/convert_pdf_to_images.py +35 -0
- package/.agent/skills/document-skills/pdf/scripts/create_validation_image.py +41 -0
- package/.agent/skills/document-skills/pdf/scripts/extract_form_field_info.py +152 -0
- package/.agent/skills/document-skills/pdf/scripts/fill_fillable_fields.py +114 -0
- package/.agent/skills/document-skills/pdf/scripts/fill_pdf_form_with_annotations.py +108 -0
- package/.agent/skills/document-skills/pptx/LICENSE.txt +30 -0
- package/.agent/skills/document-skills/pptx/SKILL.md +484 -0
- package/.agent/skills/document-skills/pptx/html2pptx.md +625 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/mce/mc.xsd +75 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/.agent/skills/document-skills/pptx/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/.agent/skills/document-skills/pptx/ooxml/scripts/pack.py +159 -0
- package/.agent/skills/document-skills/pptx/ooxml/scripts/unpack.py +29 -0
- package/.agent/skills/document-skills/pptx/ooxml/scripts/validate.py +69 -0
- package/.agent/skills/document-skills/pptx/ooxml/scripts/validation/__init__.py +15 -0
- package/.agent/skills/document-skills/pptx/ooxml/scripts/validation/base.py +951 -0
- package/.agent/skills/document-skills/pptx/ooxml/scripts/validation/docx.py +274 -0
- package/.agent/skills/document-skills/pptx/ooxml/scripts/validation/pptx.py +315 -0
- package/.agent/skills/document-skills/pptx/ooxml/scripts/validation/redlining.py +279 -0
- package/.agent/skills/document-skills/pptx/ooxml.md +427 -0
- package/.agent/skills/document-skills/pptx/scripts/html2pptx.js +979 -0
- package/.agent/skills/document-skills/pptx/scripts/inventory.py +1020 -0
- package/.agent/skills/document-skills/pptx/scripts/rearrange.py +231 -0
- package/.agent/skills/document-skills/pptx/scripts/replace.py +385 -0
- package/.agent/skills/document-skills/pptx/scripts/thumbnail.py +450 -0
- package/.agent/skills/document-skills/xlsx/LICENSE.txt +30 -0
- package/.agent/skills/document-skills/xlsx/SKILL.md +289 -0
- package/.agent/skills/document-skills/xlsx/recalc.py +178 -0
- package/.agent/skills/documentation-templates/SKILL.md +194 -0
- package/.agent/skills/frontend/SKILL.md +38 -0
- package/.agent/skills/frontend/rules/_sections.md +46 -0
- package/.agent/skills/frontend/rules/_template.md +28 -0
- package/.agent/skills/frontend/rules/advanced-event-handler-refs.md +55 -0
- package/.agent/skills/frontend/rules/advanced-init-once.md +42 -0
- package/.agent/skills/frontend/rules/advanced-use-latest.md +39 -0
- package/.agent/skills/frontend/rules/async-api-routes.md +38 -0
- package/.agent/skills/frontend/rules/async-defer-await.md +80 -0
- package/.agent/skills/frontend/rules/async-dependencies.md +51 -0
- package/.agent/skills/frontend/rules/async-parallel.md +28 -0
- package/.agent/skills/frontend/rules/async-suspense-boundaries.md +99 -0
- package/.agent/skills/frontend/rules/bundle-barrel-imports.md +59 -0
- package/.agent/skills/frontend/rules/bundle-conditional.md +31 -0
- package/.agent/skills/frontend/rules/bundle-defer-third-party.md +49 -0
- package/.agent/skills/frontend/rules/bundle-dynamic-imports.md +35 -0
- package/.agent/skills/frontend/rules/bundle-preload.md +50 -0
- package/.agent/skills/frontend/rules/client-event-listeners.md +74 -0
- package/.agent/skills/frontend/rules/client-localstorage-schema.md +71 -0
- package/.agent/skills/frontend/rules/client-passive-event-listeners.md +48 -0
- package/.agent/skills/frontend/rules/client-swr-dedup.md +56 -0
- package/.agent/skills/frontend/rules/js-batch-dom-css.md +107 -0
- package/.agent/skills/frontend/rules/js-cache-function-results.md +80 -0
- package/.agent/skills/frontend/rules/js-cache-property-access.md +28 -0
- package/.agent/skills/frontend/rules/js-cache-storage.md +70 -0
- package/.agent/skills/frontend/rules/js-combine-iterations.md +32 -0
- package/.agent/skills/frontend/rules/js-early-exit.md +50 -0
- package/.agent/skills/frontend/rules/js-hoist-regexp.md +45 -0
- package/.agent/skills/frontend/rules/js-index-maps.md +37 -0
- package/.agent/skills/frontend/rules/js-length-check-first.md +49 -0
- package/.agent/skills/frontend/rules/js-min-max-loop.md +82 -0
- package/.agent/skills/frontend/rules/js-set-map-lookups.md +24 -0
- package/.agent/skills/frontend/rules/js-tosorted-immutable.md +57 -0
- package/.agent/skills/frontend/rules/rendering-activity.md +26 -0
- package/.agent/skills/frontend/rules/rendering-animate-svg-wrapper.md +47 -0
- package/.agent/skills/frontend/rules/rendering-conditional-render.md +40 -0
- package/.agent/skills/frontend/rules/rendering-content-visibility.md +38 -0
- package/.agent/skills/frontend/rules/rendering-hoist-jsx.md +46 -0
- package/.agent/skills/frontend/rules/rendering-hydration-no-flicker.md +82 -0
- package/.agent/skills/frontend/rules/rendering-hydration-suppress-warning.md +30 -0
- package/.agent/skills/frontend/rules/rendering-svg-precision.md +28 -0
- package/.agent/skills/frontend/rules/rendering-usetransition-loading.md +75 -0
- package/.agent/skills/frontend/rules/rerender-defer-reads.md +39 -0
- package/.agent/skills/frontend/rules/rerender-dependencies.md +45 -0
- package/.agent/skills/frontend/rules/rerender-derived-state-no-effect.md +40 -0
- package/.agent/skills/frontend/rules/rerender-derived-state.md +29 -0
- package/.agent/skills/frontend/rules/rerender-functional-setstate.md +74 -0
- package/.agent/skills/frontend/rules/rerender-lazy-state-init.md +58 -0
- package/.agent/skills/frontend/rules/rerender-memo-with-default-value.md +38 -0
- package/.agent/skills/frontend/rules/rerender-memo.md +44 -0
- package/.agent/skills/frontend/rules/rerender-move-effect-to-event.md +45 -0
- package/.agent/skills/frontend/rules/rerender-simple-expression-in-memo.md +35 -0
- package/.agent/skills/frontend/rules/rerender-transitions.md +40 -0
- package/.agent/skills/frontend/rules/rerender-use-ref-transient-values.md +73 -0
- package/.agent/skills/frontend/rules/schema.json +34 -0
- package/.agent/skills/frontend/rules/server-after-nonblocking.md +73 -0
- package/.agent/skills/frontend/rules/server-auth-actions.md +96 -0
- package/.agent/skills/frontend/rules/server-cache-lru.md +41 -0
- package/.agent/skills/frontend/rules/server-cache-react.md +76 -0
- package/.agent/skills/frontend/rules/server-dedup-props.md +65 -0
- package/.agent/skills/frontend/rules/server-parallel-fetching.md +83 -0
- package/.agent/skills/frontend/rules/server-serialization.md +38 -0
- package/.agent/skills/frontend-design/SKILL.md +33 -0
- package/.agent/skills/frontend-design/rules/animation-guide.md +331 -0
- package/.agent/skills/frontend-design/rules/color-system.md +311 -0
- package/.agent/skills/frontend-design/rules/decision-trees.md +418 -0
- package/.agent/skills/frontend-design/rules/motion-graphics.md +306 -0
- package/.agent/skills/frontend-design/rules/typography-system.md +345 -0
- package/.agent/skills/frontend-design/rules/ux-psychology.md +541 -0
- package/.agent/skills/frontend-design/rules/visual-effects.md +383 -0
- package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/.agent/skills/game-development/2d-games/SKILL.md +119 -0
- package/.agent/skills/game-development/3d-games/SKILL.md +135 -0
- package/.agent/skills/game-development/SKILL.md +167 -0
- package/.agent/skills/game-development/game-art/SKILL.md +185 -0
- package/.agent/skills/game-development/game-audio/SKILL.md +190 -0
- package/.agent/skills/game-development/game-design/SKILL.md +129 -0
- package/.agent/skills/game-development/mobile-games/SKILL.md +108 -0
- package/.agent/skills/game-development/multiplayer/SKILL.md +132 -0
- package/.agent/skills/game-development/pc-games/SKILL.md +144 -0
- package/.agent/skills/game-development/vr-ar/SKILL.md +123 -0
- package/.agent/skills/game-development/web-games/SKILL.md +150 -0
- package/.agent/skills/geo-fundamentals/SKILL.md +156 -0
- package/.agent/skills/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/.agent/skills/git-conventions/.skill-source.json +8 -0
- package/.agent/skills/git-conventions/SKILL.md +28 -0
- package/.agent/skills/git-conventions/enforcement/commit-validation-rules.md +55 -0
- package/.agent/skills/git-conventions/examples/bad-commits.md +201 -0
- package/.agent/skills/git-conventions/examples/good-commits.md +135 -0
- package/.agent/skills/git-conventions/metadata/commit-config.yaml +79 -0
- package/.agent/skills/git-conventions/metadata/intent-triggers.yaml +25 -0
- package/.agent/skills/git-conventions/metadata/scope-mapping.yaml +83 -0
- package/.agent/skills/git-conventions/resources/BEST_PRACTICES.md +121 -0
- package/.agent/skills/git-conventions/resources/references.md +53 -0
- package/.agent/skills/git-conventions/scripts/format-commit.js +393 -0
- package/.agent/skills/git-conventions/scripts/validate-commit-msg.sh +27 -0
- package/.agent/skills/governance/.skill-source.json +8 -0
- package/.agent/skills/governance/CHANGELOG.md +222 -0
- package/.agent/skills/governance/README.md +250 -0
- package/.agent/skills/governance/SKILL.md +199 -0
- package/.agent/skills/governance/VERSION +4 -0
- package/.agent/skills/governance/examples/violation-backend-mutation/after.tsx +59 -0
- package/.agent/skills/governance/examples/violation-backend-mutation/before.tsx +42 -0
- package/.agent/skills/governance/examples/violation-backend-mutation/explanation.md +87 -0
- package/.agent/skills/governance/examples/violation-chart-injection/after.tsx +99 -0
- package/.agent/skills/governance/examples/violation-chart-injection/before.tsx +57 -0
- package/.agent/skills/governance/examples/violation-chart-injection/explanation.md +116 -0
- package/.agent/skills/governance/knowledge/lessons-learned.yaml +3 -0
- package/.agent/skills/governance/metadata/precedence.yaml +117 -0
- package/.agent/skills/governance/metadata/scope-map.yaml +156 -0
- package/.agent/skills/governance/proposals/v1.1-change-proposal-template.md +197 -0
- package/.agent/skills/governance/resources/AUTHORITY_MODEL.md +111 -0
- package/.agent/skills/governance/resources/ENFORCEMENT_GUIDE.md +242 -0
- package/.agent/skills/governance/resources/LOAD_ORDER.md +82 -0
- package/.agent/skills/governance/rules/constitution/coinpika-master-constitution.md +206 -0
- package/.agent/skills/governance/rules/doctrines/architecture/coinpika-architecture-doctrine.md +184 -0
- package/.agent/skills/governance/rules/doctrines/backend/coinpika-backend-data-engine-doctrine.md +214 -0
- package/.agent/skills/governance/rules/doctrines/commercial/coinpika-commercial-guardrails-doctrine.md +192 -0
- package/.agent/skills/governance/rules/doctrines/data/coinpika-chart-data-doctrine.md +198 -0
- package/.agent/skills/governance/rules/doctrines/frontend/coinpika-frontend-mobile-doctrine.md +165 -0
- package/.agent/skills/governance/rules/doctrines/frontend/coinpika-swipe-tabs-doctrine.md +172 -0
- package/.agent/skills/governance/rules/doctrines/learning/coinpika-learning-engine-doctrine.md +188 -0
- package/.agent/skills/governance/rules/doctrines/performance/coinpika-performance-doctrine.md +176 -0
- package/.agent/skills/governance/rules/doctrines/review/coinpika-code-review-doctrine.md +170 -0
- package/.agent/skills/governance/rules/enforcement/agents/coinpika-agent-enforcement-protocol.md +214 -0
- package/.agent/skills/governance/rules/enforcement/agents/coinpika-agent-system-prompt.md +192 -0
- package/.agent/skills/governance/rules/enforcement/checklists/backend-api-review-checklist.md +127 -0
- package/.agent/skills/governance/rules/enforcement/checklists/chart-component-review-checklist.md +143 -0
- package/.agent/skills/governance/rules/enforcement/checklists/coinpika-frontend-gesture-review-checklist.md +190 -0
- package/.agent/skills/governance/rules/enforcement/playbooks/doctrine-violation-playbook.md +232 -0
- package/.agent/skills/governance/scripts/audit_pr.js +218 -0
- package/.agent/skills/governance/scripts/learn.js +161 -0
- package/.agent/skills/governance/scripts/validate_doctrine.js +286 -0
- package/.agent/skills/i18n-localization/SKILL.md +154 -0
- package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/.agent/skills/intelligent-routing/SKILL.md +335 -0
- package/.agent/skills/lint-and-validate/SKILL.md +45 -0
- package/.agent/skills/lint-and-validate/scripts/lint_runner.py +172 -0
- package/.agent/skills/lint-and-validate/scripts/type_coverage.py +173 -0
- package/.agent/skills/mcp-builder/SKILL.md +176 -0
- package/.agent/skills/mermaidjs-v11/SKILL.md +115 -0
- package/.agent/skills/mermaidjs-v11/references/cli-usage.md +228 -0
- package/.agent/skills/mermaidjs-v11/references/configuration.md +232 -0
- package/.agent/skills/mermaidjs-v11/references/diagram-types.md +315 -0
- package/.agent/skills/mermaidjs-v11/references/examples.md +344 -0
- package/.agent/skills/mermaidjs-v11/references/integration.md +310 -0
- package/.agent/skills/mobile-design/SKILL.md +76 -0
- package/.agent/skills/mobile-design/references/anti-patterns.md +46 -0
- package/.agent/skills/mobile-design/references/decision-trees.md +516 -0
- package/.agent/skills/mobile-design/references/mobile-backend.md +491 -0
- package/.agent/skills/mobile-design/references/mobile-color-system.md +420 -0
- package/.agent/skills/mobile-design/references/mobile-debugging.md +122 -0
- package/.agent/skills/mobile-design/references/mobile-design-thinking.md +357 -0
- package/.agent/skills/mobile-design/references/mobile-navigation.md +458 -0
- package/.agent/skills/mobile-design/references/mobile-performance.md +767 -0
- package/.agent/skills/mobile-design/references/mobile-testing.md +356 -0
- package/.agent/skills/mobile-design/references/mobile-typography.md +433 -0
- package/.agent/skills/mobile-design/references/platform-android.md +666 -0
- package/.agent/skills/mobile-design/references/platform-ios.md +561 -0
- package/.agent/skills/mobile-design/references/touch-psychology.md +537 -0
- package/.agent/skills/mobile-design/scripts/mobile_audit.py +670 -0
- package/.agent/skills/nextjs-best-practices/SKILL.md +203 -0
- package/.agent/skills/nodejs-best-practices/SKILL.md +76 -0
- package/.agent/skills/nodejs-best-practices/references/architecture-patterns.md +34 -0
- package/.agent/skills/nodejs-best-practices/references/async-patterns.md +32 -0
- package/.agent/skills/nodejs-best-practices/references/error-handling.md +39 -0
- package/.agent/skills/nodejs-best-practices/references/framework-selection.md +39 -0
- package/.agent/skills/nodejs-best-practices/references/runtime-modules.md +33 -0
- package/.agent/skills/nodejs-best-practices/references/testing-strategy.md +25 -0
- package/.agent/skills/nodejs-best-practices/references/validation-security.md +45 -0
- package/.agent/skills/parallel-agents/SKILL.md +175 -0
- package/.agent/skills/performance-profiling/SKILL.md +143 -0
- package/.agent/skills/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/.agent/skills/plan-writing/SKILL.md +152 -0
- package/.agent/skills/powershell-windows/SKILL.md +167 -0
- package/.agent/skills/problem-solving/ABOUT.md +40 -0
- package/.agent/skills/problem-solving/SKILL.md +69 -0
- package/.agent/skills/problem-solving/collision-zone-thinking/SKILL.md +62 -0
- package/.agent/skills/problem-solving/inversion-exercise/SKILL.md +58 -0
- package/.agent/skills/problem-solving/meta-pattern-recognition/SKILL.md +54 -0
- package/.agent/skills/problem-solving/scale-game/SKILL.md +63 -0
- package/.agent/skills/problem-solving/simplification-cascades/SKILL.md +76 -0
- package/.agent/skills/problem-solving/when-stuck/SKILL.md +88 -0
- package/.agent/skills/python-patterns/SKILL.md +80 -0
- package/.agent/skills/python-patterns/references/async-patterns.md +57 -0
- package/.agent/skills/python-patterns/references/django-patterns.md +41 -0
- package/.agent/skills/python-patterns/references/fastapi-patterns.md +54 -0
- package/.agent/skills/python-patterns/references/framework-selection.md +39 -0
- package/.agent/skills/python-patterns/references/project-structure.md +80 -0
- package/.agent/skills/python-patterns/references/testing-patterns.md +34 -0
- package/.agent/skills/python-patterns/references/type-hints.md +51 -0
- package/.agent/skills/react-patterns/SKILL.md +198 -0
- package/.agent/skills/red-team-tactics/SKILL.md +199 -0
- package/.agent/skills/registry.json +367 -0
- package/.agent/skills/seo-fundamentals/SKILL.md +129 -0
- package/.agent/skills/seo-fundamentals/scripts/seo_checker.py +219 -0
- package/.agent/skills/sequential-thinking/README.md +118 -0
- package/.agent/skills/sequential-thinking/SKILL.md +93 -0
- package/.agent/skills/sequential-thinking/references/advanced.md +122 -0
- package/.agent/skills/sequential-thinking/references/examples.md +274 -0
- package/.agent/skills/server-management/SKILL.md +161 -0
- package/.agent/skills/skill-creator/LICENSE.txt +202 -0
- package/.agent/skills/skill-creator/SKILL.md +237 -0
- package/.agent/skills/skill-creator/scripts/init_skill.py +303 -0
- package/.agent/skills/skill-creator/scripts/package_skill.py +110 -0
- package/.agent/skills/skill-creator/scripts/quick_validate.py +65 -0
- package/.agent/skills/systematic-debugging/SKILL.md +109 -0
- package/.agent/skills/tailwind-patterns/SKILL.md +269 -0
- package/.agent/skills/tdd-workflow/SKILL.md +149 -0
- package/.agent/skills/testing-patterns/SKILL.md +178 -0
- package/.agent/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/.agent/skills/vulnerability-scanner/SKILL.md +276 -0
- package/.agent/skills/vulnerability-scanner/checklists.md +121 -0
- package/.agent/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/.agent/skills/webapp-testing/SKILL.md +187 -0
- package/.agent/skills/webapp-testing/scripts/playwright_runner.py +173 -0
- package/.agent/workflows/architect.md +200 -0
- package/.agent/workflows/autopilot.md +254 -0
- package/.agent/workflows/boost.md +163 -0
- package/.agent/workflows/build.md +192 -0
- package/.agent/workflows/chronicle.md +172 -0
- package/.agent/workflows/diagnose.md +207 -0
- package/.agent/workflows/forge.md +123 -0
- package/.agent/workflows/inspect.md +187 -0
- package/.agent/workflows/launch.md +208 -0
- package/.agent/workflows/pulse.md +115 -0
- package/.agent/workflows/stage.md +117 -0
- package/.agent/workflows/studio.md +319 -0
- package/.agent/workflows/think.md +173 -0
- package/.agent/workflows/validate.md +226 -0
- package/.editorconfig +21 -0
- package/.github/workflows/release.yml +39 -0
- package/CHANGELOG.md +38 -0
- package/LICENSE +16 -0
- package/README.md +294 -0
- package/VERSIONING.md +45 -0
- package/docs/PATTERNS_REFERENCE.md +93 -0
- package/docs/PLAN-consolidation-final.md +14 -0
- package/docs/PLAN-integration.md +28 -0
- package/docs/PLAN-rebrand-agent-skills-kit.md +104 -0
- package/docs/PLAN-refactor.md +48 -0
- package/docs/PYTHON_SCRIPTS.md +55 -0
- package/docs/awf-user-guide.md +436 -0
- package/docs/context-engineering-guide.md +99 -0
- package/package.json +38 -0
- package/packages/cli/.agent/knowledge/lessons-learned.yaml +32 -0
- package/packages/cli/bin/ag-smart.js +155 -0
- package/packages/cli/bin/ag-smart.v1.js +78 -0
- package/packages/cli/lib/audit.js +69 -0
- package/packages/cli/lib/audit.v2.js +151 -0
- package/packages/cli/lib/auto-learn.js +319 -0
- package/packages/cli/lib/auto_preview.py +148 -0
- package/packages/cli/lib/checklist.py +222 -0
- package/packages/cli/lib/config.js +29 -0
- package/packages/cli/lib/eslint-fix.js +238 -0
- package/packages/cli/lib/fix.js +278 -0
- package/packages/cli/lib/generate-registry.js +42 -0
- package/packages/cli/lib/hooks/install-hooks.js +176 -0
- package/packages/cli/lib/hooks/lint-learn.js +172 -0
- package/packages/cli/lib/learn.js +173 -0
- package/packages/cli/lib/learn.test.js +70 -0
- package/packages/cli/lib/learn.v2.js +255 -0
- package/packages/cli/lib/recall.js +75 -0
- package/packages/cli/lib/recall.v2.js +252 -0
- package/packages/cli/lib/session_manager.py +120 -0
- package/packages/cli/lib/skill-learn.js +296 -0
- package/packages/cli/lib/stats.js +143 -0
- package/packages/cli/lib/types.js +33 -0
- package/packages/cli/lib/verify_all.py +327 -0
- package/packages/cli/lib/watcher.js +181 -0
- package/packages/cli/package-lock.json +1837 -0
- package/packages/cli/package.json +23 -0
- package/packages/cli/vitest.config.js +9 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Preload Based on User Intent
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: reduces perceived latency
|
|
5
|
+
tags: bundle, preload, user-intent, hover
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Preload Based on User Intent
|
|
9
|
+
|
|
10
|
+
Preload heavy bundles before they're needed to reduce perceived latency.
|
|
11
|
+
|
|
12
|
+
**Example (preload on hover/focus):**
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
function EditorButton({ onClick }: { onClick: () => void }) {
|
|
16
|
+
const preload = () => {
|
|
17
|
+
if (typeof window !== 'undefined') {
|
|
18
|
+
void import('./monaco-editor')
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<button
|
|
24
|
+
onMouseEnter={preload}
|
|
25
|
+
onFocus={preload}
|
|
26
|
+
onClick={onClick}
|
|
27
|
+
>
|
|
28
|
+
Open Editor
|
|
29
|
+
</button>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Example (preload when feature flag is enabled):**
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
function FlagsProvider({ children, flags }: Props) {
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (flags.editorEnabled && typeof window !== 'undefined') {
|
|
40
|
+
void import('./monaco-editor').then(mod => mod.init())
|
|
41
|
+
}
|
|
42
|
+
}, [flags.editorEnabled])
|
|
43
|
+
|
|
44
|
+
return <FlagsContext.Provider value={flags}>
|
|
45
|
+
{children}
|
|
46
|
+
</FlagsContext.Provider>
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The `typeof window !== 'undefined'` check prevents bundling preloaded modules for SSR, optimizing server bundle size and build speed.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Deduplicate Global Event Listeners
|
|
3
|
+
impact: LOW
|
|
4
|
+
impactDescription: single listener for N components
|
|
5
|
+
tags: client, swr, event-listeners, subscription
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Deduplicate Global Event Listeners
|
|
9
|
+
|
|
10
|
+
Use `useSWRSubscription()` to share global event listeners across component instances.
|
|
11
|
+
|
|
12
|
+
**Incorrect (N instances = N listeners):**
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
function useKeyboardShortcut(key: string, callback: () => void) {
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const handler = (e: KeyboardEvent) => {
|
|
18
|
+
if (e.metaKey && e.key === key) {
|
|
19
|
+
callback()
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
window.addEventListener('keydown', handler)
|
|
23
|
+
return () => window.removeEventListener('keydown', handler)
|
|
24
|
+
}, [key, callback])
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
When using the `useKeyboardShortcut` hook multiple times, each instance will register a new listener.
|
|
29
|
+
|
|
30
|
+
**Correct (N instances = 1 listener):**
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import useSWRSubscription from 'swr/subscription'
|
|
34
|
+
|
|
35
|
+
// Module-level Map to track callbacks per key
|
|
36
|
+
const keyCallbacks = new Map<string, Set<() => void>>()
|
|
37
|
+
|
|
38
|
+
function useKeyboardShortcut(key: string, callback: () => void) {
|
|
39
|
+
// Register this callback in the Map
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!keyCallbacks.has(key)) {
|
|
42
|
+
keyCallbacks.set(key, new Set())
|
|
43
|
+
}
|
|
44
|
+
keyCallbacks.get(key)!.add(callback)
|
|
45
|
+
|
|
46
|
+
return () => {
|
|
47
|
+
const set = keyCallbacks.get(key)
|
|
48
|
+
if (set) {
|
|
49
|
+
set.delete(callback)
|
|
50
|
+
if (set.size === 0) {
|
|
51
|
+
keyCallbacks.delete(key)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}, [key, callback])
|
|
56
|
+
|
|
57
|
+
useSWRSubscription('global-keydown', () => {
|
|
58
|
+
const handler = (e: KeyboardEvent) => {
|
|
59
|
+
if (e.metaKey && keyCallbacks.has(e.key)) {
|
|
60
|
+
keyCallbacks.get(e.key)!.forEach(cb => cb())
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
window.addEventListener('keydown', handler)
|
|
64
|
+
return () => window.removeEventListener('keydown', handler)
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function Profile() {
|
|
69
|
+
// Multiple shortcuts will share the same listener
|
|
70
|
+
useKeyboardShortcut('p', () => { /* ... */ })
|
|
71
|
+
useKeyboardShortcut('k', () => { /* ... */ })
|
|
72
|
+
// ...
|
|
73
|
+
}
|
|
74
|
+
```
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Version and Minimize localStorage Data
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: prevents schema conflicts, reduces storage size
|
|
5
|
+
tags: client, localStorage, storage, versioning, data-minimization
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Version and Minimize localStorage Data
|
|
9
|
+
|
|
10
|
+
Add version prefix to keys and store only needed fields. Prevents schema conflicts and accidental storage of sensitive data.
|
|
11
|
+
|
|
12
|
+
**Incorrect:**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
// No version, stores everything, no error handling
|
|
16
|
+
localStorage.setItem('userConfig', JSON.stringify(fullUserObject))
|
|
17
|
+
const data = localStorage.getItem('userConfig')
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Correct:**
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
const VERSION = 'v2'
|
|
24
|
+
|
|
25
|
+
function saveConfig(config: { theme: string; language: string }) {
|
|
26
|
+
try {
|
|
27
|
+
localStorage.setItem(`userConfig:${VERSION}`, JSON.stringify(config))
|
|
28
|
+
} catch {
|
|
29
|
+
// Throws in incognito/private browsing, quota exceeded, or disabled
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function loadConfig() {
|
|
34
|
+
try {
|
|
35
|
+
const data = localStorage.getItem(`userConfig:${VERSION}`)
|
|
36
|
+
return data ? JSON.parse(data) : null
|
|
37
|
+
} catch {
|
|
38
|
+
return null
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Migration from v1 to v2
|
|
43
|
+
function migrate() {
|
|
44
|
+
try {
|
|
45
|
+
const v1 = localStorage.getItem('userConfig:v1')
|
|
46
|
+
if (v1) {
|
|
47
|
+
const old = JSON.parse(v1)
|
|
48
|
+
saveConfig({ theme: old.darkMode ? 'dark' : 'light', language: old.lang })
|
|
49
|
+
localStorage.removeItem('userConfig:v1')
|
|
50
|
+
}
|
|
51
|
+
} catch {}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Store minimal fields from server responses:**
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// User object has 20+ fields, only store what UI needs
|
|
59
|
+
function cachePrefs(user: FullUser) {
|
|
60
|
+
try {
|
|
61
|
+
localStorage.setItem('prefs:v1', JSON.stringify({
|
|
62
|
+
theme: user.preferences.theme,
|
|
63
|
+
notifications: user.preferences.notifications
|
|
64
|
+
}))
|
|
65
|
+
} catch {}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Always wrap in try-catch:** `getItem()` and `setItem()` throw in incognito/private browsing (Safari, Firefox), when quota exceeded, or when disabled.
|
|
70
|
+
|
|
71
|
+
**Benefits:** Schema evolution via versioning, reduced storage size, prevents storing tokens/PII/internal flags.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Use Passive Event Listeners for Scrolling Performance
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: eliminates scroll delay caused by event listeners
|
|
5
|
+
tags: client, event-listeners, scrolling, performance, touch, wheel
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Use Passive Event Listeners for Scrolling Performance
|
|
9
|
+
|
|
10
|
+
Add `{ passive: true }` to touch and wheel event listeners to enable immediate scrolling. Browsers normally wait for listeners to finish to check if `preventDefault()` is called, causing scroll delay.
|
|
11
|
+
|
|
12
|
+
**Incorrect:**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const handleTouch = (e: TouchEvent) => console.log(e.touches[0].clientX)
|
|
17
|
+
const handleWheel = (e: WheelEvent) => console.log(e.deltaY)
|
|
18
|
+
|
|
19
|
+
document.addEventListener('touchstart', handleTouch)
|
|
20
|
+
document.addEventListener('wheel', handleWheel)
|
|
21
|
+
|
|
22
|
+
return () => {
|
|
23
|
+
document.removeEventListener('touchstart', handleTouch)
|
|
24
|
+
document.removeEventListener('wheel', handleWheel)
|
|
25
|
+
}
|
|
26
|
+
}, [])
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Correct:**
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const handleTouch = (e: TouchEvent) => console.log(e.touches[0].clientX)
|
|
34
|
+
const handleWheel = (e: WheelEvent) => console.log(e.deltaY)
|
|
35
|
+
|
|
36
|
+
document.addEventListener('touchstart', handleTouch, { passive: true })
|
|
37
|
+
document.addEventListener('wheel', handleWheel, { passive: true })
|
|
38
|
+
|
|
39
|
+
return () => {
|
|
40
|
+
document.removeEventListener('touchstart', handleTouch)
|
|
41
|
+
document.removeEventListener('wheel', handleWheel)
|
|
42
|
+
}
|
|
43
|
+
}, [])
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Use passive when:** tracking/analytics, logging, any listener that doesn't call `preventDefault()`.
|
|
47
|
+
|
|
48
|
+
**Don't use passive when:** implementing custom swipe gestures, custom zoom controls, or any listener that needs `preventDefault()`.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Use SWR for Automatic Deduplication
|
|
3
|
+
impact: MEDIUM-HIGH
|
|
4
|
+
impactDescription: automatic deduplication
|
|
5
|
+
tags: client, swr, deduplication, data-fetching
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Use SWR for Automatic Deduplication
|
|
9
|
+
|
|
10
|
+
SWR enables request deduplication, caching, and revalidation across component instances.
|
|
11
|
+
|
|
12
|
+
**Incorrect (no deduplication, each instance fetches):**
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
function UserList() {
|
|
16
|
+
const [users, setUsers] = useState([])
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
fetch('/api/users')
|
|
19
|
+
.then(r => r.json())
|
|
20
|
+
.then(setUsers)
|
|
21
|
+
}, [])
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Correct (multiple instances share one request):**
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import useSWR from 'swr'
|
|
29
|
+
|
|
30
|
+
function UserList() {
|
|
31
|
+
const { data: users } = useSWR('/api/users', fetcher)
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**For immutable data:**
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { useImmutableSWR } from '@/lib/swr'
|
|
39
|
+
|
|
40
|
+
function StaticContent() {
|
|
41
|
+
const { data } = useImmutableSWR('/api/config', fetcher)
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**For mutations:**
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import { useSWRMutation } from 'swr/mutation'
|
|
49
|
+
|
|
50
|
+
function UpdateButton() {
|
|
51
|
+
const { trigger } = useSWRMutation('/api/user', updateUser)
|
|
52
|
+
return <button onClick={() => trigger()}>Update</button>
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Reference: [https://swr.vercel.app](https://swr.vercel.app)
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Avoid Layout Thrashing
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: prevents forced synchronous layouts and reduces performance bottlenecks
|
|
5
|
+
tags: javascript, dom, css, performance, reflow, layout-thrashing
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Avoid Layout Thrashing
|
|
9
|
+
|
|
10
|
+
Avoid interleaving style writes with layout reads. When you read a layout property (like `offsetWidth`, `getBoundingClientRect()`, or `getComputedStyle()`) between style changes, the browser is forced to trigger a synchronous reflow.
|
|
11
|
+
|
|
12
|
+
**This is OK (browser batches style changes):**
|
|
13
|
+
```typescript
|
|
14
|
+
function updateElementStyles(element: HTMLElement) {
|
|
15
|
+
// Each line invalidates style, but browser batches the recalculation
|
|
16
|
+
element.style.width = '100px'
|
|
17
|
+
element.style.height = '200px'
|
|
18
|
+
element.style.backgroundColor = 'blue'
|
|
19
|
+
element.style.border = '1px solid black'
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Incorrect (interleaved reads and writes force reflows):**
|
|
24
|
+
```typescript
|
|
25
|
+
function layoutThrashing(element: HTMLElement) {
|
|
26
|
+
element.style.width = '100px'
|
|
27
|
+
const width = element.offsetWidth // Forces reflow
|
|
28
|
+
element.style.height = '200px'
|
|
29
|
+
const height = element.offsetHeight // Forces another reflow
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Correct (batch writes, then read once):**
|
|
34
|
+
```typescript
|
|
35
|
+
function updateElementStyles(element: HTMLElement) {
|
|
36
|
+
// Batch all writes together
|
|
37
|
+
element.style.width = '100px'
|
|
38
|
+
element.style.height = '200px'
|
|
39
|
+
element.style.backgroundColor = 'blue'
|
|
40
|
+
element.style.border = '1px solid black'
|
|
41
|
+
|
|
42
|
+
// Read after all writes are done (single reflow)
|
|
43
|
+
const { width, height } = element.getBoundingClientRect()
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Correct (batch reads, then writes):**
|
|
48
|
+
```typescript
|
|
49
|
+
function avoidThrashing(element: HTMLElement) {
|
|
50
|
+
// Read phase - all layout queries first
|
|
51
|
+
const rect1 = element.getBoundingClientRect()
|
|
52
|
+
const offsetWidth = element.offsetWidth
|
|
53
|
+
const offsetHeight = element.offsetHeight
|
|
54
|
+
|
|
55
|
+
// Write phase - all style changes after
|
|
56
|
+
element.style.width = '100px'
|
|
57
|
+
element.style.height = '200px'
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Better: use CSS classes**
|
|
62
|
+
```css
|
|
63
|
+
.highlighted-box {
|
|
64
|
+
width: 100px;
|
|
65
|
+
height: 200px;
|
|
66
|
+
background-color: blue;
|
|
67
|
+
border: 1px solid black;
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
```typescript
|
|
71
|
+
function updateElementStyles(element: HTMLElement) {
|
|
72
|
+
element.classList.add('highlighted-box')
|
|
73
|
+
|
|
74
|
+
const { width, height } = element.getBoundingClientRect()
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**React example:**
|
|
79
|
+
```tsx
|
|
80
|
+
// Incorrect: interleaving style changes with layout queries
|
|
81
|
+
function Box({ isHighlighted }: { isHighlighted: boolean }) {
|
|
82
|
+
const ref = useRef<HTMLDivElement>(null)
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (ref.current && isHighlighted) {
|
|
86
|
+
ref.current.style.width = '100px'
|
|
87
|
+
const width = ref.current.offsetWidth // Forces layout
|
|
88
|
+
ref.current.style.height = '200px'
|
|
89
|
+
}
|
|
90
|
+
}, [isHighlighted])
|
|
91
|
+
|
|
92
|
+
return <div ref={ref}>Content</div>
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Correct: toggle class
|
|
96
|
+
function Box({ isHighlighted }: { isHighlighted: boolean }) {
|
|
97
|
+
return (
|
|
98
|
+
<div className={isHighlighted ? 'highlighted-box' : ''}>
|
|
99
|
+
Content
|
|
100
|
+
</div>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Prefer CSS classes over inline styles when possible. CSS files are cached by the browser, and classes provide better separation of concerns and are easier to maintain.
|
|
106
|
+
|
|
107
|
+
See [this gist](https://gist.github.com/paulirish/5d52fb081b3570c81e3a) and [CSS Triggers](https://csstriggers.com/) for more information on layout-forcing operations.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Cache Repeated Function Calls
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: avoid redundant computation
|
|
5
|
+
tags: javascript, cache, memoization, performance
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Cache Repeated Function Calls
|
|
9
|
+
|
|
10
|
+
Use a module-level Map to cache function results when the same function is called repeatedly with the same inputs during render.
|
|
11
|
+
|
|
12
|
+
**Incorrect (redundant computation):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
function ProjectList({ projects }: { projects: Project[] }) {
|
|
16
|
+
return (
|
|
17
|
+
<div>
|
|
18
|
+
{projects.map(project => {
|
|
19
|
+
// slugify() called 100+ times for same project names
|
|
20
|
+
const slug = slugify(project.name)
|
|
21
|
+
|
|
22
|
+
return <ProjectCard key={project.id} slug={slug} />
|
|
23
|
+
})}
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Correct (cached results):**
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
// Module-level cache
|
|
33
|
+
const slugifyCache = new Map<string, string>()
|
|
34
|
+
|
|
35
|
+
function cachedSlugify(text: string): string {
|
|
36
|
+
if (slugifyCache.has(text)) {
|
|
37
|
+
return slugifyCache.get(text)!
|
|
38
|
+
}
|
|
39
|
+
const result = slugify(text)
|
|
40
|
+
slugifyCache.set(text, result)
|
|
41
|
+
return result
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function ProjectList({ projects }: { projects: Project[] }) {
|
|
45
|
+
return (
|
|
46
|
+
<div>
|
|
47
|
+
{projects.map(project => {
|
|
48
|
+
// Computed only once per unique project name
|
|
49
|
+
const slug = cachedSlugify(project.name)
|
|
50
|
+
|
|
51
|
+
return <ProjectCard key={project.id} slug={slug} />
|
|
52
|
+
})}
|
|
53
|
+
</div>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Simpler pattern for single-value functions:**
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
let isLoggedInCache: boolean | null = null
|
|
62
|
+
|
|
63
|
+
function isLoggedIn(): boolean {
|
|
64
|
+
if (isLoggedInCache !== null) {
|
|
65
|
+
return isLoggedInCache
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
isLoggedInCache = document.cookie.includes('auth=')
|
|
69
|
+
return isLoggedInCache
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Clear cache when auth changes
|
|
73
|
+
function onAuthChange() {
|
|
74
|
+
isLoggedInCache = null
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Use a Map (not a hook) so it works everywhere: utilities, event handlers, not just React components.
|
|
79
|
+
|
|
80
|
+
Reference: [How we made the Vercel Dashboard twice as fast](https://vercel.com/blog/how-we-made-the-vercel-dashboard-twice-as-fast)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Cache Property Access in Loops
|
|
3
|
+
impact: LOW-MEDIUM
|
|
4
|
+
impactDescription: reduces lookups
|
|
5
|
+
tags: javascript, loops, optimization, caching
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Cache Property Access in Loops
|
|
9
|
+
|
|
10
|
+
Cache object property lookups in hot paths.
|
|
11
|
+
|
|
12
|
+
**Incorrect (3 lookups × N iterations):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
for (let i = 0; i < arr.length; i++) {
|
|
16
|
+
process(obj.config.settings.value)
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Correct (1 lookup total):**
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
const value = obj.config.settings.value
|
|
24
|
+
const len = arr.length
|
|
25
|
+
for (let i = 0; i < len; i++) {
|
|
26
|
+
process(value)
|
|
27
|
+
}
|
|
28
|
+
```
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Cache Storage API Calls
|
|
3
|
+
impact: LOW-MEDIUM
|
|
4
|
+
impactDescription: reduces expensive I/O
|
|
5
|
+
tags: javascript, localStorage, storage, caching, performance
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Cache Storage API Calls
|
|
9
|
+
|
|
10
|
+
`localStorage`, `sessionStorage`, and `document.cookie` are synchronous and expensive. Cache reads in memory.
|
|
11
|
+
|
|
12
|
+
**Incorrect (reads storage on every call):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
function getTheme() {
|
|
16
|
+
return localStorage.getItem('theme') ?? 'light'
|
|
17
|
+
}
|
|
18
|
+
// Called 10 times = 10 storage reads
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Correct (Map cache):**
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
const storageCache = new Map<string, string | null>()
|
|
25
|
+
|
|
26
|
+
function getLocalStorage(key: string) {
|
|
27
|
+
if (!storageCache.has(key)) {
|
|
28
|
+
storageCache.set(key, localStorage.getItem(key))
|
|
29
|
+
}
|
|
30
|
+
return storageCache.get(key)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function setLocalStorage(key: string, value: string) {
|
|
34
|
+
localStorage.setItem(key, value)
|
|
35
|
+
storageCache.set(key, value) // keep cache in sync
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Use a Map (not a hook) so it works everywhere: utilities, event handlers, not just React components.
|
|
40
|
+
|
|
41
|
+
**Cookie caching:**
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
let cookieCache: Record<string, string> | null = null
|
|
45
|
+
|
|
46
|
+
function getCookie(name: string) {
|
|
47
|
+
if (!cookieCache) {
|
|
48
|
+
cookieCache = Object.fromEntries(
|
|
49
|
+
document.cookie.split('; ').map(c => c.split('='))
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
return cookieCache[name]
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Important (invalidate on external changes):**
|
|
57
|
+
|
|
58
|
+
If storage can change externally (another tab, server-set cookies), invalidate cache:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
window.addEventListener('storage', (e) => {
|
|
62
|
+
if (e.key) storageCache.delete(e.key)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
document.addEventListener('visibilitychange', () => {
|
|
66
|
+
if (document.visibilityState === 'visible') {
|
|
67
|
+
storageCache.clear()
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
```
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Combine Multiple Array Iterations
|
|
3
|
+
impact: LOW-MEDIUM
|
|
4
|
+
impactDescription: reduces iterations
|
|
5
|
+
tags: javascript, arrays, loops, performance
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Combine Multiple Array Iterations
|
|
9
|
+
|
|
10
|
+
Multiple `.filter()` or `.map()` calls iterate the array multiple times. Combine into one loop.
|
|
11
|
+
|
|
12
|
+
**Incorrect (3 iterations):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
const admins = users.filter(u => u.isAdmin)
|
|
16
|
+
const testers = users.filter(u => u.isTester)
|
|
17
|
+
const inactive = users.filter(u => !u.isActive)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Correct (1 iteration):**
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
const admins: User[] = []
|
|
24
|
+
const testers: User[] = []
|
|
25
|
+
const inactive: User[] = []
|
|
26
|
+
|
|
27
|
+
for (const user of users) {
|
|
28
|
+
if (user.isAdmin) admins.push(user)
|
|
29
|
+
if (user.isTester) testers.push(user)
|
|
30
|
+
if (!user.isActive) inactive.push(user)
|
|
31
|
+
}
|
|
32
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Early Return from Functions
|
|
3
|
+
impact: LOW-MEDIUM
|
|
4
|
+
impactDescription: avoids unnecessary computation
|
|
5
|
+
tags: javascript, functions, optimization, early-return
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Early Return from Functions
|
|
9
|
+
|
|
10
|
+
Return early when result is determined to skip unnecessary processing.
|
|
11
|
+
|
|
12
|
+
**Incorrect (processes all items even after finding answer):**
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
function validateUsers(users: User[]) {
|
|
16
|
+
let hasError = false
|
|
17
|
+
let errorMessage = ''
|
|
18
|
+
|
|
19
|
+
for (const user of users) {
|
|
20
|
+
if (!user.email) {
|
|
21
|
+
hasError = true
|
|
22
|
+
errorMessage = 'Email required'
|
|
23
|
+
}
|
|
24
|
+
if (!user.name) {
|
|
25
|
+
hasError = true
|
|
26
|
+
errorMessage = 'Name required'
|
|
27
|
+
}
|
|
28
|
+
// Continues checking all users even after error found
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return hasError ? { valid: false, error: errorMessage } : { valid: true }
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Correct (returns immediately on first error):**
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
function validateUsers(users: User[]) {
|
|
39
|
+
for (const user of users) {
|
|
40
|
+
if (!user.email) {
|
|
41
|
+
return { valid: false, error: 'Email required' }
|
|
42
|
+
}
|
|
43
|
+
if (!user.name) {
|
|
44
|
+
return { valid: false, error: 'Name required' }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return { valid: true }
|
|
49
|
+
}
|
|
50
|
+
```
|