Repository: ionic-team/stencil-store Branch: main Commit: 4a5628ade709 Files: 52 Total size: 94.3 KB Directory structure: gitextract_14714bwu/ ├── .github/ │ ├── CODEOWNERS │ ├── FUNDING.yml │ ├── ISSUE_TEMPLATE/ │ │ ├── bug_report.yml │ │ ├── config.yml │ │ └── feature_request.yml │ ├── PULL_REQUEST_TEMPLATE.md │ ├── dependabot.yml │ ├── ionic-issue-bot.yml │ └── workflows/ │ ├── build.yml │ ├── main.yml │ ├── publish-npm.yml │ ├── release-dev.yml │ ├── release-orchestrator.yml │ └── release-production.yml ├── .gitignore ├── .nvmrc ├── .prettierrc.json ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── package.json ├── rollup.config.js ├── src/ │ ├── index.test.ts │ ├── index.ts │ ├── observable-map.test.ts │ ├── observable-map.ts │ ├── store.test.ts │ ├── store.ts │ ├── subscriptions/ │ │ ├── stencil.test.ts │ │ └── stencil.ts │ ├── types.ts │ ├── utils.test.ts │ └── utils.ts ├── test-app/ │ ├── .editorconfig │ ├── .gitignore │ ├── .prettierrc.json │ ├── LICENSE │ ├── package.json │ ├── readme.md │ ├── src/ │ │ ├── components/ │ │ │ ├── change-store/ │ │ │ │ └── change-store.tsx │ │ │ ├── display-store/ │ │ │ │ ├── display-store.e2e.ts │ │ │ │ └── display-store.tsx │ │ │ └── simple-store/ │ │ │ ├── display-store.spec.ts │ │ │ └── display-store.tsx │ │ ├── components.d.ts │ │ ├── index.html │ │ ├── index.ts │ │ └── utils/ │ │ └── greeting-store.ts │ ├── stencil.config.ts │ └── tsconfig.json ├── tsconfig.json └── vitest.config.ts ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/CODEOWNERS ================================================ * @stenciljs/technical-steering-committee ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms github: [johnjenkins] ================================================ FILE: .github/ISSUE_TEMPLATE/bug_report.yml ================================================ name: 🐛 Bug Report description: Create a report to help us improve Stencil Store title: 'bug: ' body: - type: checkboxes attributes: label: Prerequisites description: Please ensure you have completed all of the following. options: - label: I have read the [Contributing Guidelines](https://github.com/stenciljs/core/blob/main/.github/CONTRIBUTING.md). required: true - label: I agree to follow the [Code of Conduct](https://github.com/stenciljs/.github/blob/main/CODE_OF_CONDUCT.md). required: true - label: I have searched for [existing issues](https://github.com/stenciljs/store/issues) that already report this problem, without success. required: true - type: input attributes: label: Stencil Store Version description: The version number of Stencil Store where the issue is occurring. validations: required: true - type: input attributes: label: Stencil Version description: The version number of Stencil where the issue is occurring. validations: required: true - type: textarea attributes: label: Current Behavior description: A clear description of what the bug is and how it manifests. validations: required: true - type: textarea attributes: label: Expected Behavior description: A clear description of what you expected to happen. validations: required: true - type: textarea attributes: label: Steps to Reproduce description: Please explain the steps required to duplicate this issue. validations: required: true - type: input attributes: label: Code Reproduction URL description: Please reproduce this issue in a blank Stencil starter application and provide a link to the repo. Run `npm init stencil` to quickly spin up a Stencil project. This is the best way to ensure this issue is triaged quickly. Issues without a code reproduction may be closed if the Stencil Team cannot reproduce the issue you are reporting. placeholder: https://github.com/... validations: required: true - type: textarea attributes: label: Additional Information description: List any other information that is relevant to your issue. Stack traces, related issues, suggestions on how to fix, Stack Overflow links, forum links, etc. ================================================ FILE: .github/ISSUE_TEMPLATE/config.yml ================================================ contact_links: - name: 💻 Stencil url: https://github.com/stenciljs/core/issues/new/choose about: This issue tracker is not for Stencil compiler issues. Please file compiler issues on the Stencil repo. - name: 📚 Documentation url: https://github.com/stenciljs/site/issues/new/choose about: This issue tracker is not for documentation issues. Please file documentation issues on the Stencil site repo. - name: 📝 Create Stencil CLI url: https://github.com/stenciljs/create-stencil/issues/new/choose about: This issue tracker is not for Create Stencil CLI issues. Please file CLI issues on the Create Stencil CLI repo. - name: 🤔 Support Question url: https://forum.ionicframework.com/ about: This issue tracker is not for support questions. Please post your question on the Ionic Forums. ================================================ FILE: .github/ISSUE_TEMPLATE/feature_request.yml ================================================ name: 💡 Feature Request description: Suggest an idea for Stencil Store title: 'feat: ' body: - type: checkboxes attributes: label: Prerequisites description: Please ensure you have completed all of the following. options: - label: I have read the [Contributing Guidelines](https://github.com/stenciljs/core/blob/main/.github/CONTRIBUTING.md). required: true - label: I agree to follow the [Code of Conduct](https://github.com/stenciljs/.github/blob/main/CODE_OF_CONDUCT.md). required: true - label: I have searched for [existing issues](https://github.com/stenciljs/store/issues) that already include this feature request, without success. required: true - type: textarea attributes: label: Describe the Feature Request description: A clear and concise description of what the feature does. validations: required: true - type: textarea attributes: label: Describe the Use Case description: A clear and concise use case for what problem this feature would solve. validations: required: true - type: textarea attributes: label: Describe Preferred Solution description: A clear and concise description of how you want this feature to be added to Stencil Store. - type: textarea attributes: label: Describe Alternatives description: A clear and concise description of any alternative solutions or features you have considered. - type: textarea attributes: label: Related Code description: If you are able to illustrate the feature request with an example, please provide a sample Stencil component(s). Run `npm init stencil` to quickly spin up a Stencil project. - type: textarea attributes: label: Additional Information description: List any other information that is relevant to your issue. Stack traces, related issues, suggestions on how to implement, Stack Overflow links, forum links, etc. ================================================ FILE: .github/PULL_REQUEST_TEMPLATE.md ================================================ ## Pull request checklist Please check if your PR fulfills the following requirements: - [ ] Docs have been reviewed and added / updated if needed (for bug fixes / features) - [ ] Build (`npm run build`) was run locally and any changes were pushed - [ ] Tests (`npm test`) were run locally and passed - [ ] Prettier (`npm run prettier`) was run locally and passed ## Pull request type Please check the type of change your PR introduces: - [ ] Bugfix - [ ] Feature - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? GitHub Issue Number: N/A ## What is the new behavior? - - - ## Does this introduce a breaking change? - [ ] Yes - [ ] No ## Testing ## Other information ================================================ FILE: .github/dependabot.yml ================================================ version: 2 updates: - package-ecosystem: npm directory: "/" schedule: interval: weekly open-pull-requests-limit: 10 groups: patch-deps-updates-main: update-types: - "patch" minor-deps-updates-main: update-types: - "minor" major-deps-updates-main: update-types: - "major" - package-ecosystem: github-actions directory: "/" schedule: interval: weekly time: "11:00" open-pull-requests-limit: 10 groups: patch-deps-updates: update-types: - "patch" minor-deps-updates: update-types: - "minor" major-deps-updates: update-types: - "major" ================================================ FILE: .github/ionic-issue-bot.yml ================================================ triage: label: triage dryRun: false closeAndLock: labels: - label: "ionitron: support" message: > Thanks for the issue! This issue appears to be a support request. We use this issue tracker exclusively for bug reports and feature requests. Please use our [discord channel](https://chat.stenciljs.com/) for questions about Stencil Store. Thank you for using Stencil Store! - label: "ionitron: missing template" message: > Thanks for the issue! It appears that you have not filled out the provided issue template. We use this issue template in order to gather more information and further assist you. Please create a new issue and ensure the template is fully filled out. Thank you for using Stencil Store! close: true lock: true dryRun: false comment: labels: - label: "ionitron: needs reproduction" message: > Thanks for the issue! This issue has been labeled as `needs reproduction`. This label is added to issues that need a code reproduction. Please reproduce this issue in an Stencil starter component library and Stencil Store. Please provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed. If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue. For a guide on how to create a good reproduction, see our [Contributing Guide](https://github.com/stenciljs/core/blob/main/.github/CONTRIBUTING.md). dryRun: false noReply: maxIssuesPerRun: 100 includePullRequests: false label: Awaiting Reply close: false lock: false dryRun: false noReproduction: days: 14 maxIssuesPerRun: 100 label: "ionitron: needs reproduction" responseLabel: triage exemptProjects: true exemptMilestones: true message: > Thanks for the issue! This issue is being closed due to the lack of a code reproduction. If this is still an issue with the latest version of Stencil & Stencil Store, please create a new issue and ensure the template is fully filled out. Thank you for using Stencil Store! close: true lock: true dryRun: false stale: days: 30 maxIssuesPerRun: 100 exemptLabels: - "Bug: Validated" - "Feature: Want this? Upvote it!" - good first issue - help wanted - Reply Received - Request For Comments - "Resolution: Needs Investigation" - "Resolution: Refine" - triage exemptAssigned: true exemptProjects: true exemptMilestones: true label: "ionitron: stale issue" message: > Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Stencil, please create a new issue and ensure the template is fully filled out. Thank you for using Stencil Store! close: true lock: true dryRun: false ================================================ FILE: .github/workflows/build.yml ================================================ name: Build Stencil Store on: workflow_call: # Make this a reusable workflow, no value needed # https://docs.github.com/en/actions/using-workflows/reusing-workflows jobs: build_stencil_store: name: Build Stencil Store runs-on: 'ubuntu-latest' steps: - name: 📥 Checkout Code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: # the pull_request_target event will consider the HEAD of `main` to be the SHA to use. # attempt to use the SHA associated with a pull request and fallback to HEAD of `main` ref: ${{ github.event_name == 'pull_request_target' && format('refs/pull/{0}/merge', github.event.number) || '' }} persist-credentials: false - name: 🕸️ Get Core Dependencies uses: stenciljs/.github/actions/get-core-dependencies@main - name: 📦 Stencil Store Build run: npm run build shell: bash - name: 🧪 Unit Tests run: npm test shell: bash - name: 📤 Upload Build Artifacts uses: stenciljs/.github/actions/upload-archive@main ================================================ FILE: .github/workflows/main.yml ================================================ name: CI on: push: branches: - 'main' pull_request: branches: - '**' jobs: build: name: (build stencil ${{ matrix.stencil_version }}) strategy: fail-fast: false matrix: # Run with multiple different versions of Stencil in parallel: # 1. DEFAULT - uses the version of Stencil written in `package-lock.json`, keeping the same version used by the # Stencil team as a source of truth # 2. 2 - will install the latest release under major version 2 of Stencil. This should be kept as long as this # library supports Stencil v2.Y.Z # 3. 3 - will install the latest release under major version 3 of Stencil. This should be kept as long as this # library supports Stencil v3.Y.Z # 4. 4 - will install the latest release under major version 4 of Stencil. This should be kept as long as this # library supports Stencil v4.Y.Z stencil_version: ['DEFAULT', '2', '3', '4'] runs-on: ubuntu-latest steps: - name: 📥 Checkout Code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - name: 🕸️ Get Core Dependencies uses: stenciljs/.github/actions/get-core-dependencies@main - name: 🧪 Test run: npm run test - name: 📦 Install Stencil ${{matrix.stencil_version}} run: npm install --save-dev @stencil/core@${{matrix.stencil_version}} shell: bash if: ${{ matrix.stencil_version != 'DEFAULT' }} - name: 📊 Report Stencil Version run: npm ls @stencil/core shell: bash - name: 🏗️ Build run: npm run build shell: bash - name: 🔗 Create Symlink run: npm link shell: bash - name: 📂 Enter test-app Directory run: cd test-app shell: bash - name: 📦 Install test-app Dependencies run: npm install shell: bash - name: 🔗 Link Stencil Store run: npm link @stencil/store - name: 🏗️ Build test-app run: npm run build shell: bash - name: 🧪 Test test-app run: npm test shell: bash ================================================ FILE: .github/workflows/publish-npm.yml ================================================ name: 'Publish Stencil Store' on: workflow_call: inputs: version: description: 'Version or semver bump to publish.' required: true type: string tag: description: 'npm dist-tag to publish under.' required: true type: string node-version: description: 'Node.js version used for publishing.' required: false type: string default: '20' registry-url: description: 'npm registry URL.' required: false type: string default: 'https://registry.npmjs.org' scope: description: 'npm scope that should use trusted publisher auth.' required: false type: string default: '@stencil' package-directory: description: 'Directory that contains the package to publish.' required: false type: string default: '.' install-command: description: 'Command used to install dependencies. Leave blank to skip.' required: false type: string default: 'npm ci' install-working-directory: description: 'Working directory for the install command.' required: false type: string default: '.' build-command: description: 'Command used to build the package. Leave blank to skip.' required: false type: string default: 'npm run build' build-working-directory: description: 'Working directory for the build command.' required: false type: string default: '.' permissions: contents: write id-token: write jobs: publish: runs-on: ubuntu-latest steps: - name: 📥 Checkout Code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: fetch-depth: 0 - name: 🟢 Configure Node for Publish if: ${{ inputs.scope == '' }} uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version: ${{ inputs.node-version }} registry-url: ${{ inputs.registry-url }} - name: 🟢 Configure Node for Publish (Scoped) if: ${{ inputs.scope != '' }} uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version: ${{ inputs.node-version }} registry-url: ${{ inputs.registry-url }} scope: ${{ inputs.scope }} - name: 🔄 Ensure Latest npm run: npm install -g npm@latest shell: bash - name: 📦 Install Dependencies if: ${{ inputs.install-command != '' }} run: ${{ inputs.install-command }} shell: bash working-directory: ${{ inputs.install-working-directory }} - name: 🛠️ Build Package if: ${{ inputs.build-command != '' }} run: ${{ inputs.build-command }} shell: bash working-directory: ${{ inputs.build-working-directory }} - name: 🏷️ Set Version run: npm version --no-git-tag-version --allow-same-version ${{ inputs.version }} shell: bash working-directory: ${{ inputs.package-directory }} - name: 🔎 Get Version from package.json id: get-version run: | # Normalize package directory path to prevent path traversal issues PKG_DIR="${{ inputs.package-directory }}" if [ "$PKG_DIR" = "." ] || [ -z "$PKG_DIR" ]; then PKG_DIR="." fi # Use path.resolve to safely construct the absolute path VERSION=$(node -e "const path = require('path'); const pkgPath = path.resolve('$PKG_DIR', 'package.json'); const pkg = require(pkgPath); console.log(pkg.version);") if [ -z "$VERSION" ]; then echo "❌ Failed to extract version from $PKG_DIR/package.json. Ensure the file exists and contains a valid 'version' field." >&2 exit 1 fi echo "VERSION=$VERSION" >> $GITHUB_OUTPUT echo "Extracted version: $VERSION from $PKG_DIR/package.json" shell: bash - name: 📝 Commit Version Changes run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" if [ "${{ inputs.package-directory }}" = "." ]; then git add package.json package-lock.json else git add ${{ inputs.package-directory }}/package.json ${{ inputs.package-directory }}/package-lock.json 2>/dev/null || true fi # Only commit if there are changes if ! git diff --staged --quiet; then git commit -m "chore: bump version to ${{ steps.get-version.outputs.VERSION }}" else echo "No changes to commit" fi shell: bash - name: 🏷️ Create Git Tag # Skip tag creation for dev builds to avoid cluttering the repository if: ${{ inputs.tag != 'dev' }} run: | TAG_NAME="v${{ steps.get-version.outputs.VERSION }}" echo "Checking for existing tag: $TAG_NAME" # Check if tag exists locally if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then echo "Tag $TAG_NAME already exists locally, skipping creation" exit 0 fi # Check if tag exists remotely if git ls-remote --tags origin "$TAG_NAME" | grep -q "$TAG_NAME"; then echo "Tag $TAG_NAME already exists on remote, skipping creation" exit 0 fi # Create the tag echo "Creating annotated tag $TAG_NAME" git tag -a "$TAG_NAME" -m "Release $TAG_NAME" echo "✓ Tag $TAG_NAME created successfully" shell: bash - name: 📤 Push Changes and Tag run: | # Push the commit to the current branch git push origin HEAD # Push the tag (only for non-dev builds) if [ "${{ inputs.tag }}" != "dev" ]; then git push origin "v${{ steps.get-version.outputs.VERSION }}" else echo "Skipping tag push for dev build" fi shell: bash - name: 🚀 Publish to npm run: npm publish --tag ${{ inputs.tag }} --provenance shell: bash working-directory: ${{ inputs.package-directory }} ================================================ FILE: .github/workflows/release-dev.yml ================================================ name: 'Stencil Store Dev Release' on: workflow_call: permissions: contents: write id-token: write jobs: build_stencil_store: name: 🏗️ Build Stencil Store uses: ./.github/workflows/build.yml get_dev_version: name: 🔍 Get Dev Build Version runs-on: ubuntu-latest needs: build_stencil_store outputs: dev-version: ${{ steps.generate-dev-version.outputs.DEV_VERSION }} steps: - name: 📥 Checkout Code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: ⚙️ Generate Dev Version id: generate-dev-version run: | PKG_JSON_VERSION=$(cat package.json | jq -r '.version') GIT_HASH=$(git rev-parse --short HEAD) DEV_VERSION=$PKG_JSON_VERSION-dev.$(date +"%s").$GIT_HASH echo "DEV_VERSION=$DEV_VERSION" >> $GITHUB_OUTPUT shell: bash publish_dev: name: 🚀 Publish Dev Build needs: get_dev_version uses: ./.github/workflows/publish-npm.yml with: tag: dev version: ${{ needs.get_dev_version.outputs.dev-version }} ================================================ FILE: .github/workflows/release-orchestrator.yml ================================================ name: 'Release - Stencil Store' on: workflow_dispatch: inputs: channel: description: 'Which release workflow should run?' required: true type: choice default: dev options: - dev - production bump: description: 'Semver bump for production releases.' required: false type: choice default: patch options: - patch - minor - major permissions: contents: read id-token: write jobs: run-dev: if: ${{ inputs.channel == 'dev' }} uses: ./.github/workflows/release-dev.yml secrets: inherit run-production: if: ${{ inputs.channel == 'production' }} uses: ./.github/workflows/release-production.yml secrets: inherit with: bump: ${{ inputs.bump }} ================================================ FILE: .github/workflows/release-production.yml ================================================ name: 'Stencil Store Production Release' on: workflow_call: inputs: bump: description: 'Semver bump to apply (patch, minor, major).' required: true type: string default: patch permissions: contents: write id-token: write jobs: validate_bump: name: ✅ Validate Bump Input runs-on: ubuntu-latest steps: - name: 🔎 Ensure bump is allowed env: BUMP: ${{ inputs.bump }} run: | case "$BUMP" in patch|minor|major) exit 0 ;; *) echo "::error::Invalid bump input: '$BUMP'. Allowed values: patch, minor, major." exit 1 ;; esac build_stencil_store: name: 🏗️ Build Stencil Store uses: ./.github/workflows/build.yml publish_production: name: 🚀 Publish Production Build needs: - build_stencil_store - validate_bump uses: ./.github/workflows/publish-npm.yml with: tag: latest version: ${{ inputs.bump }} ================================================ FILE: .gitignore ================================================ dist/ www/ loader/ build/ *~ *.sw[mnpcod] *.log *.lock *.tmp *.tmp.* log.txt *.sublime-project *.sublime-workspace *.tgz .stencil/ .idea/ .vscode/ .sass-cache/ .versions/ node_modules/ $RECYCLE.BIN/ .DS_Store Thumbs.db UserInterfaceState.xcuserstate .env coverage ================================================ FILE: .nvmrc ================================================ v22.14.0 ================================================ FILE: .prettierrc.json ================================================ { "parser": "typescript", "printWidth": 100, "semi": true, "singleQuote": true, "trailingComma": "es5" } ================================================ FILE: CONTRIBUTING.md ================================================ # Contributing to @stencil/store Thank you for your interest in contributing to @stencil/store! This document provides guidelines and information for contributors. ## Table of Contents - [Code of Conduct](#code-of-conduct) - [Getting Started](#getting-started) - [Development Setup](#development-setup) - [Making Changes](#making-changes) - [Testing](#testing) - [Pull Request Process](#pull-request-process) - [Release Process](#release-process) ## Code of Conduct This project follows the same code of conduct as the main StencilJS project. Please be respectful and inclusive in all interactions. ## Getting Started 1. Fork the repository on GitHub 2. Clone your fork locally: ```bash git clone https://github.com/YOUR_USERNAME/store.git cd store ``` 3. Add the upstream repository: ```bash git remote add upstream https://github.com/stenciljs/store.git ``` ## Development Setup ### Prerequisites - Node.js >= 22.14.0 - npm >= 9.x ### Installation ```bash npm install ``` ### Available Scripts - `npm run build` - Build the project - `npm test` - Run all tests - `npm run test.unit` - Run unit tests with Vitest - `npm run test.prettier` - Check code formatting - `npm run prettier` - Format code with Prettier ### Project Structure ``` src/ ├── index.ts # Main entry point ├── store.ts # Core store implementation ├── observable-map.ts # Observable map utilities ├── types.ts # TypeScript type definitions ├── utils.ts # Utility functions └── subscriptions/ └── stencil.ts # Stencil-specific subscriptions ``` ## Making Changes 1. Create a new branch from `main`: ```bash git checkout -b feature/your-feature-name ``` 2. Make your changes following these guidelines: - Write clear, readable code - Add tests for new functionality - Update documentation if needed - Follow the existing code style 3. Run tests to ensure everything works: ```bash npm test ``` 4. Commit your changes with a clear message: ```bash git commit -m "feat: add new feature description" ``` ### Commit Message Guidelines Use conventional commit format: - `feat:` - New features - `fix:` - Bug fixes - `docs:` - Documentation changes - `style:` - Code style changes (formatting, etc.) - `refactor:` - Code refactoring - `test:` - Adding or updating tests - `chore:` - Build process or auxiliary tool changes ## Testing ### Unit Tests The project uses Vitest for unit testing. Tests are located alongside the source files with `.test.ts` extensions. ```bash npm run test.unit ``` ### Test App There's a test application in the `test-app/` directory that demonstrates the store functionality: ```bash cd test-app npm install npm start ``` ### Writing Tests When adding new features or fixing bugs: 1. Add unit tests in the appropriate `.test.ts` file 2. Test both positive and negative cases 3. Include edge cases 4. Ensure tests are isolated and don't depend on external state ## Pull Request Process 1. Push your branch to your fork: ```bash git push origin feature/your-feature-name ``` 2. Create a Pull Request on GitHub with: - Clear title and description - Reference any related issues - Include tests for new functionality - Update documentation if needed 3. Ensure all checks pass: - All tests must pass - Code must be properly formatted - No linting errors 4. Address any review feedback 5. Once approved, a maintainer will merge your PR ## Release Process ### Release Types We follow [Semantic Versioning (SemVer)](https://semver.org/) for releases. Choose the appropriate release type based on your changes: #### Patch Release (x.x.X) Use for: - Bug fixes - Documentation updates - Internal refactoring that doesn't change the API - Performance improvements without API changes #### Minor Release (x.X.x) Use for: - New features that are backward compatible - New API methods or options - Deprecating functionality (without removing) - Significant internal improvements #### Major Release (X.x.x) Use for: - Breaking changes to the public API - Removing deprecated functionality - Changes that require users to modify their code - Major architectural changes ### Development Releases Development Releases (or "Dev Releases", "Dev Builds") are installable instances of Stencil Store that are: - Published to the npm registry for distribution within and outside the Stencil team - Built using the same infrastructure as production releases, with less safety checks - Used to verify a fix or change to the project prior to a production release #### How to Publish Dev Releases Only members of the Stencil team may create dev builds of Stencil Store. To publish a dev build: 1. Navigate to the [Stencil Store Release GitHub Action](https://github.com/stenciljs/store/actions/workflows/release.yml) in your browser. 2. Click the 'Run Workflow' dropdown on the right hand side of the page 3. Configure the workflow inputs: - **Release type**: Select `patch`, `minor`, or `major` (this won't affect the dev build version) - **Dev Release**: Select `yes` to create a dev build 4. Select the branch you want to build from 5. Click 'Run Workflow' 6. Allow the workflow to run. Upon completion, the output of the 'Publish Dev Build' action will report the published version string. Following a successful run of the workflow, the package can be installed from the npm registry like any other package. #### Dev Release Format Dev Builds are published to the NPM registry under the `@stencil/store` scope. Unlike production builds, dev builds use a specially formatted version string to express its origins. Dev builds follow the format `BASE_VERSION-dev.EPOCH_DATE.SHA`, where: - `BASE_VERSION` is the latest production release changes to the build were based off of - `EPOCH_DATE` is the number of seconds since January 1st, 1970 in UTC - `SHA` is the git short SHA of the commit used in the release As an example: `2.1.0-dev.1677185104.7c87e34` was built: - With v2.1.0 as the latest production build at the time of the dev build - On Fri, 26 Jan 2024 13:48:17 UTC - With the commit `7c87e34` ### Production Releases Only members of the Stencil team may create production releases of Stencil Store. #### How to Publish Production Releases 1. Navigate to the [Stencil Store Release GitHub Action](https://github.com/stenciljs/store/actions/workflows/release.yml) in your browser. 2. Click the 'Run Workflow' dropdown on the right hand side of the page 3. Configure the workflow inputs: - **Release type**: Select the appropriate type (`patch`, `minor`, or `major`) based on your changes - **Dev Release**: Select `no` for production releases 4. Select the `main` branch (production releases should only be made from main) 5. Click 'Run Workflow' 6. The workflow will: - Build and test the package - Bump the version according to the selected release type - Create a Git tag - Publish to NPM with the `latest` tag - Create a GitHub release #### Release Checklist Before creating a production release: - [ ] Ensure all intended changes are merged to `main` - [ ] All CI checks are passing - [ ] Update any relevant documentation - [ ] Consider if this should be a dev release first for testing - [ ] Choose the correct release type (patch/minor/major) - [ ] Notify the team of the planned release ## Questions or Issues? - Create an issue on GitHub for bugs or feature requests - Check existing issues before creating new ones - Provide detailed information including steps to reproduce for bugs Thank you for contributing to @stencil/store! 🎉 ================================================ FILE: LICENSE ================================================ Copyright 2015-present Drifty Co. http://drifty.com/ MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # @stencil/store Store is a lightweight shared state library by the [StencilJS](https://stenciljs.com/) core team. It implements a simple key/value map that efficiently re-renders components when necessary. **Highlights:** - 🪶 Lightweight - ⚡ Zero dependencies - 📦 Simple API, like a reactive Map - 🚀 Best performance ## Installation ``` npm install @stencil/store --save-dev ``` ## Example **store.ts:** ```ts import { createStore } from "@stencil/store"; const { state, onChange } = createStore({ clicks: 0, seconds: 0, squaredClicks: 0 }); onChange('clicks', value => { state.squaredClicks = value ** 2; }); export default state; ``` **component.tsx:** ```tsx import { Component, h } from '@stencil/core'; import state from '../store'; @Component({ tag: 'app-profile', }) export class AppProfile { componentWillLoad() { setInterval(() => state.seconds++, 1000); } render() { return (
Seconds: {state.seconds}
Squared Clicks: {state.squaredClicks}
(propName: P & string): T[P] => { handlers.get.forEach((cb) => cb(propName)); return states.get(propName); }; const set =
(propName: P & string, value: T[P]) => {
const oldValue = states.get(propName);
if (shouldUpdate(value, oldValue, propName)) {
states.set(propName, value);
if (!proxyAvailable) {
ensurePlainProperty(propName as string);
}
handlers.set.forEach((cb) => cb(propName, value, oldValue));
}
};
const state = (
proxyAvailable
? new Proxy(initialState, {
get(_, propName) {
return get(propName as any);
},
ownKeys(_) {
return Array.from(states.keys());
},
getOwnPropertyDescriptor() {
return {
enumerable: true,
configurable: true,
};
},
has(_, propName) {
return states.has(propName as any);
},
set(_, propName, value) {
set(propName as any, value);
return true;
},
})
: (() => {
syncPlainStateKeys();
return plainState!;
})()
) as T;
const on: OnHandler (propName: P & string): T[P];
}
export interface Setter (propName: P & string, value: T[P]): void;
}
export interface ObservableMap