Skip to content

Updated Social Share button Integration Prompt - #213

Open
PrithvijitBose wants to merge 9 commits into
AOSSIE-Org:mainfrom
PrithvijitBose:feat/integrate-social-share-button
Open

Updated Social Share button Integration Prompt#213
PrithvijitBose wants to merge 9 commits into
AOSSIE-Org:mainfrom
PrithvijitBose:feat/integrate-social-share-button

Conversation

@PrithvijitBose

@PrithvijitBose PrithvijitBose commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Additional Notes:

Changed integrate-social-share-button.prompt.md

Checklist

  • My code follows the project's code style and conventions
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contributing Guidelines

⚠️ AI Notice - Important!

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.

Summary by CodeRabbit

  • Documentation
    • Reworked social share button integration guidance to detect frontend directories and supported frameworks.
    • Added concise npm and CDN setup examples for React, Next.js, Preact, Vue 3, Angular, and vanilla HTML/JavaScript.
    • Clarified placement, styling, imports, CSS inclusion, and Next.js client-side requirements.
    • Simplified integration instructions to encourage direct updates to existing application files.

@github-actions github-actions Bot added no-issue-linked PR is not linked to any issue ci-cd CI/CD pipeline changes documentation Changes to documentation files size/XL Extra large PR (>500 lines changed) repeat-contributor PR from an external contributor who already had PRs merged needs-review labels Aug 1, 2026
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@PrithvijitBose, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7dc74db8-7516-4123-9628-44d9ed3d9f6b

📥 Commits

Reviewing files that changed from the base of the PR and between 598639c and 893e44d.

📒 Files selected for processing (1)
  • .github/copilot/integrate-social-share-button.prompt.md

Walkthrough

The Copilot integration prompt now detects frontend frameworks and package managers, defines setup requirements, and provides framework-specific npm, ESM, and CDN examples for SocialShareButton.

Changes

Integration prompt

Layer / File(s) Summary
Detection and setup workflow
.github/copilot/integrate-social-share-button.prompt.md
The prompt detects frontend directories and package managers. It collects integration preferences and enforces ESM imports, CSS inclusion, and Next.js client directives.
Framework integration examples
.github/copilot/integrate-social-share-button.prompt.md
The prompt adds React, Next.js, Preact, Vue 3, Angular, and vanilla HTML and JavaScript examples. The examples cover initialization, styling, stylesheet loading, lifecycle cleanup, and CDN usage.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: Documentation

Suggested reviewers: kpj2006

Poem

A rabbit maps each framework path,
With imports, styles, and buttons bright.
Effects begin and cleanly end,
While CDN scripts load just right.
Share links hop into the light.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the updated Social Share button integration prompt, which matches the main change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 10

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/copilot/integrate-social-share-button.prompt.md:
- Line 10: Update the Markdown formatting in the prompt document by adding blank
lines before and after every affected heading and fenced code block, including
the locations listed in the review comment, so markdownlint-cli2 no longer
reports MD022 or MD031.
- Around line 4-5: Update the social-share-button integration prompt so the user
only provides the button placement: detect the project’s package manager to
choose the installation method automatically and apply a default button style
without requesting npm/CDN or style selections. Keep this contract consistent in
the corresponding sections around the installation and placement steps.
- Around line 97-123: Update the useEffect initialization flow so its single
cleanup function both clears any active CDN polling timer and destroys the
current instanceRef instance, including one created by init after polling
completes. Preserve the existing initialization and dependency behavior while
ensuring cleanup handles both immediately available and asynchronously loaded
SocialShareButton globals.
- Around line 36-37: Replace the invalid
`@aossie-org/social-share-button/src/social-share-button.css` reference by first
exposing a supported CSS export in the package, then update the mandatory CSS
Import rule and every npm-based React, Vue, Angular, and vanilla example to use
that published export; leave CDN examples unchanged.
- Around line 214-232: Update ShareButtonComponent to implement Angular’s
OnChanges lifecycle and handle changes to buttonStyle, url, and title after
initialization. In ngOnChanges, update the existing SocialShareButton instance
through its updateOptions API when available, or reinitialize it while
preserving the existing container setup and cleanup behavior.
- Around line 83-87: Add the Next.js Script import to both the App Router
app/layout.tsx snippet and the Pages Router pages/_app.tsx snippet before their
respective <Script> usages, using the standard next/script module import and
leaving the other template instructions unchanged.
- Around line 240-248: Update the “npm Method (Vite/Webpack)” example to move
the SocialShareButton and stylesheet imports into a source module such as
src/main.js, and have the HTML template load that module instead of importing
packages from the inline script. Preserve the existing container initialization
and buttonStyle configuration.
- Around line 204-208: Update the example around the share-button.component.ts
import so it does not rely on the package without TypeScript declarations:
either convert the example to a supported JavaScript wrapper or ensure
`@aossie-org/social-share-button` publishes valid .d.ts declarations before
retaining the TypeScript component. Preserve the example’s intended integration
behavior and do not leave strict Angular users with a missing-declaration error.
- Around line 49-56: Separate the Preact guidance from the generic React/Next.js
section around the ShareButton example. Keep the React imports and JSX example
under React/Next.js, and add a distinct Preact setup showing the required
Preact-compatible imports or configuration/aliases so it works without implicit
React compatibility.
- Around line 197-198: Update the CDN Method guidance to guard
`window.SocialShareButton` before instantiation in `onMounted`, and add an
`onUnmounted` cleanup that disposes the initialized share-button instance when
available. Keep the existing container configuration and ensure cleanup handles
the unavailable or uninitialized case safely.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 79b58653-e8f4-4120-8d7f-82db1a9038a1

📥 Commits

Reviewing files that changed from the base of the PR and between 4715415 and 9f7767e.

📒 Files selected for processing (1)
  • .github/copilot/integrate-social-share-button.prompt.md

Comment thread .github/copilot/integrate-social-share-button.prompt.md
Comment thread .github/copilot/integrate-social-share-button.prompt.md
Comment thread .github/copilot/integrate-social-share-button.prompt.md Outdated
Comment thread .github/copilot/integrate-social-share-button.prompt.md Outdated
Comment thread .github/copilot/integrate-social-share-button.prompt.md Outdated
Comment thread .github/copilot/integrate-social-share-button.prompt.md Outdated
Comment thread .github/copilot/integrate-social-share-button.prompt.md Outdated
Comment thread .github/copilot/integrate-social-share-button.prompt.md Outdated
Comment thread .github/copilot/integrate-social-share-button.prompt.md Outdated
Comment thread .github/copilot/integrate-social-share-button.prompt.md Outdated
@PrithvijitBose

PrithvijitBose commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Markdown Formatting:

  • Added proper blank lines around headings and code blocks to fix all markdownlint (MD022 & MD031) errors.

Framework-Specific Improvements:

  • Preact: Created a dedicated Preact section using native preact/hooks and class attributes instead of generic React imports.
  • Next.js: Added explicit import Script from "next/script"; instructions before <Script> usage in CDN templates.
  • Vue 3: Added window.SocialShareButton guards and onUnmounted cleanup hooks.
  • Angular: Added // @ts-ignore to prevent TypeScript missing-declaration errors when importing the package.
  • Vanilla JS: Separated JS imports into src/main.js and loaded it via <script type="module"> in index.html.

Safer Lifecycle Cleanup:

  • Improved useEffect cleanup in React/Preact CDN examples to reliably clear polling timers and destroy component instances on unmount.

Token Optimization:

  • Compacted code blocks to reduce prompt length by 27 lines (~500 tokens saved per LLM call) while preserving 100% of instructions and rules.

Standardized CSS Import Paths:

  • Updated Rule 5 and all npm framework examples (React, Preact, Vue 3, Angular, and Vanilla JS) in .github/copilot/integrate-social-share-button.prompt.md
    to import @aossie-org/social-share-button/css instead of internal source paths. CDN URLs were left unchanged.

Angular Dynamic Prop Updates (OnChanges):

  • Updated ShareButtonComponent to implement Angular's OnChanges interface.
  • Added ngOnChanges() so when inputs (buttonStyle, url, or title) change after initialization, the component automatically updates the share button instance via updateOptions() (or re-initializes safely).

Deterministic Specific-to-Generic Framework Matching:

  • Updated Step 1 to match Next.js before React and Preact before React when scanning package.json, ensuring projects with both specific and generic dependencies use the specific framework guide.

Expanded Bun Lockfile Detection:

  • Updated Step 2 to recognize bun.lock alongside bun.lockb and classify either as Bun.

Corrected Preact Alias Direction:

  • Corrected the parenthetical note in Preact’s guide to state that bundlers should alias react and react-dom to preact/compat (not preact/compat to react), while preserving direct preact/hooks imports.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
.github/copilot/integrate-social-share-button.prompt.md (2)

106-124: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Bound CDN readiness polling.

If the CDN script never loads, each mounted wrapper keeps a 100 ms interval until unmount. This creates an avoidable timer leak and scales with the number of mounted buttons. Use a script-load callback or stop polling after a defined timeout or attempt limit.

Also applies to: 181-199

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/copilot/integrate-social-share-button.prompt.md around lines 106 -
124, Update the SocialShareButton initialization flow around init and the
interval-based CDN readiness polling so it cannot run indefinitely when the
script never loads. Prefer a script-load callback, or enforce a defined timeout
or maximum attempt count before clearing the timer; preserve initialization when
the CDN becomes ready and existing cleanup on unmount.

221-226: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Track Qwik inputs before initializing the widget.

useVisibleTask$ does not re-run when style, url, or title change unless they are tracked. Call track for these props, destroy the previous widget instance in cleanup, and create a new instance with the updated inputs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/copilot/integrate-social-share-button.prompt.md around lines 221 -
226, Update the useVisibleTask$ callback to accept track, explicitly track
style, url, and title before constructing the widget, and use those tracked
values for initialization. Ensure cleanup destroys the current SocialShareButton
instance so the task recreates it with updated inputs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/copilot/integrate-social-share-button.prompt.md:
- Around line 20-26: Update the technology detection instructions near the
package.json scan to require deterministic, specific-to-generic framework
matching: identify Next.js before React and Preact before React, while
preserving the directive to use only the detected framework’s guide. Ensure
projects containing both specific and generic dependencies select the specific
framework template.
- Line 137: Update the guidance near “Import hooks from preact/hooks” to remove
or correct the parenthetical alias direction: bundlers should alias react and
react-dom to preact/compat, not preact/compat to react. Preserve the direct
preact/hooks import guidance.
- Around line 23-26: Update the package-manager detection instructions in “Lock
File & Tech Detection” to recognize bun.lock alongside bun.lockb and classify
either as Bun. Preserve the existing detection for npm, pnpm, and yarn, and
ensure Bun projects proceed to the Bun technology guide.

---

Outside diff comments:
In @.github/copilot/integrate-social-share-button.prompt.md:
- Around line 106-124: Update the SocialShareButton initialization flow around
init and the interval-based CDN readiness polling so it cannot run indefinitely
when the script never loads. Prefer a script-load callback, or enforce a defined
timeout or maximum attempt count before clearing the timer; preserve
initialization when the CDN becomes ready and existing cleanup on unmount.
- Around line 221-226: Update the useVisibleTask$ callback to accept track,
explicitly track style, url, and title before constructing the widget, and use
those tracked values for initialization. Ensure cleanup destroys the current
SocialShareButton instance so the task recreates it with updated inputs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3cfec4b4-75de-45d8-a52e-9547155b3275

📥 Commits

Reviewing files that changed from the base of the PR and between 9f7767e and 5fd937a.

📒 Files selected for processing (1)
  • .github/copilot/integrate-social-share-button.prompt.md

Comment thread .github/copilot/integrate-social-share-button.prompt.md Outdated
Comment thread .github/copilot/integrate-social-share-button.prompt.md Outdated
Comment thread .github/copilot/integrate-social-share-button.prompt.md Outdated
@PrithvijitBose

Copy link
Copy Markdown
Contributor Author

@CodeRabbit what changes i made Remove the invalid npm CSS subpath.

docs/Roadmap.md, Lines [48-53], states that @aossie-org/social-share-button/src/social-share-button.css is not a valid published path. The mandatory rule and the React, Vue, Angular, and vanilla examples repeat it. Publish a supported CSS export, then use that path in every npm example.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- CSS path occurrences ---'
rg -n -C 2 '`@aossie-org/social-share-button/`(src/social-share-button\.css|css)' \
  .github/copilot/integrate-social-share-button.prompt.md docs/Roadmap.md || true

printf '%s\n' '--- Prompt npm-install and CSS-import context ---'
rg -n -C 5 '(npm install|from "`@aossie-org/social-share-button/css`"|`@aossie-org/social-share-button/css`)' \
  .github/copilot/integrate-social-share-button.prompt.md || true

printf '%s\n' '--- Remaining invalid CSS subpath references in repository ---'
rg -n -C 2 '`@aossie-org/social-share-button/src/social-share-button`\.css' \
  -g '!node_modules/**' -g '!dist/**' . || true

Length of output: 13042


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- Package manifests ---'
fd -a '^package\.json$' . -E node_modules -E dist -x sh -c '
  echo "### $1"
  jq "{name, version, main, module, style, files, exports}" "$1"
' sh {} 2>/dev/null || true

printf '%s\n' '--- CSS artifacts and export-related declarations ---'
rg -n -C 3 '"\./css"|social-share-button\.css|exports|files' \
  -g 'package.json' -g '!node_modules/**' -g '!dist/**' . || true

printf '%s\n' '--- README CSS import context ---'
sed -n '655,675p' README.md

Length of output: 2238


@PrithvijitBose The prompt change removes the old invalid src/social-share-button.css subpath. However, the replacement is not published yet.

The root package.json has no exports field. It also has no css entry point. Therefore, @aossie-org/social-share-button/css cannot currently resolve for npm consumers.

To resolve the finding:

  1. Publish the CSS file under a stable package path, such as dist/social-share-button.css.
  2. Add an exports entry for ./css in package.json.
  3. Keep the prompt imports as @aossie-org/social-share-button/css.
  4. Update README.md Line 666, which still uses @aossie-org/social-share-button/src/social-share-button.css.

The finding remains open until the package export exists.

You are interacting with an AI system.

@PrithvijitBose

Copy link
Copy Markdown
Contributor Author

@CodeRabbit what about Separate the Preact setup from the generic React/Next.js examples.

Grouping Preact with React/Next.js implies this code works without changes, but it imports hooks from react and uses React JSX. A plain Preact setup cannot use it unless compatibility aliases are configured; show the Preact-specific imports/config or split the guides.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

file=".github/copilot/integrate-social-share-button.prompt.md"

printf '%s\n' '--- Framework headings ---'
rg -n '^(#{1,4})\s+.*(React|Next\.js|Preact)' "$file" || true

printf '%s\n' '--- Preact section and nearby framework boundaries ---'
start=$(rg -n '^(#{1,4})\s+.*Preact' "$file" | head -n1 | cut -d: -f1 || true)
if [ -n "$start" ]; then
  end=$((start + 150))
  sed -n "${start},${end}p" "$file"
fi

printf '%s\n' '--- Imports, hooks, and alias guidance ---'
rg -n -C 3 '(from ["'\'']react["'\'']|from ["'\'']preact|preact/hooks|preact/compat|className|class=)' "$file" || true

Length of output: 8686


@PrithvijitBose The current prompt resolves this concern.

The Preact guide is separate from the React / Next.js guide. It imports hooks from preact/hooks and uses Preact class attributes. The React / Next.js examples retain react imports and className.

A plain Preact setup can use the Preact examples without React compatibility aliases. I am withdrawing this finding.


✏️ Learnings added
Learnt from: PrithvijitBose
URL: https://github.com/AOSSIE-Org/SocialShareButton/pull/213

Timestamp: 2026-08-06T12:41:45.670Z
Learning: In `.github/copilot/integrate-social-share-button.prompt.md`, keep the Preact integration guide separate from the React / Next.js guide. Preact examples must import hooks from `preact/hooks` and use Preact JSX `class` attributes. React / Next.js examples use `react` hooks and `className`.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

@PrithvijitBose

Copy link
Copy Markdown
Contributor Author

@CodeRabbit Destroy the instance created after CDN polling.

When the global is initially unavailable, the cleanup at Line [119] only clears the timer. If polling later creates an instance, unmount does not execute the destruction logic at Line [122]. Return one cleanup function that clears the timer and destroys the current instance...explain this issue and how its fixed now

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

file=".github/copilot/integrate-social-share-button.prompt.md"

printf '%s\n' '--- Prompt outline ---'
ast-grep outline "$file" --items all 2>/dev/null || true

printf '%s\n' '--- CDN polling and cleanup contexts ---'
rg -n -C 12 '(setInterval|clearInterval|destroy\(|useEffect|SocialShareButton)' "$file" || true

Length of output: 15133


@PrithvijitBose The issue occurred when the CDN script was not ready during the first useEffect execution.

Previously, the effect returned a cleanup function that only cleared the polling timer in that case. The polling callback could later create shareInstanceRef.current. React does not replace the existing cleanup function when that callback runs. Therefore, component unmount cleared the timer but did not call destroy() on the new instance.

The current CDN example fixes this at Line 144:

return () => { if (timer) clearInterval(timer); shareInstanceRef.current?.destroy?.(); };

This is one cleanup function for both cases:

  • It clears the polling timer if polling is active.
  • It reads shareInstanceRef.current during unmount.
  • If polling created an instance after the initial effect, it calls that instance’s destroy() method.

The cleanup is now reliable whether the CDN global is available immediately or becomes available later.

You are interacting with an AI system.

@PrithvijitBose

Copy link
Copy Markdown
Contributor Author

@CodeRabbit explain Import Script before using it in the Next.js snippets.

Next.js App Router and Pages Router examples reference <Script>, but the prompt does not show import Script from "next/script";. Add import Script from "next/script" to the app/layout.tsx and pages/_app.tsx snippets so copied code does not fail with an unresolved identifier. and tell me whats fixed

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

file=".github/copilot/integrate-social-share-button.prompt.md"

printf '%s\n' '--- Next.js section headings ---'
rg -n '^(#{1,4})\s+.*(Next\.js|App Router|Pages Router)' "$file" || true

printf '%s\n' '--- next/script imports and Script component contexts ---'
rg -n -C 10 'import Script from ["'"'"']next/script["'"'"'];|<Script\b|app/layout\.tsx|pages/_app\.tsx' "$file" || true

Length of output: 1618


@PrithvijitBose The issue is fixed in the prompt.

Before the correction, the Next.js snippets used <Script> but did not declare the Script identifier. Copied code could fail with an unresolved identifier error.

The prompt now gives the required import for both router types:

import Script from "next/script";

The corrected instructions are:

  • Line 120: The App Router app/layout.tsx instructions require the import before <Script src="..." strategy="beforeInteractive" />.
  • Line 121: The Pages Router pages/_app.tsx instructions require the import before <Script src="..." strategy="afterInteractive" />.

This ensures that <Script> refers to the Next.js Script component in both examples. The finding is resolved.

🐇🔎

You are interacting with an AI system.

@PrithvijitBose

Copy link
Copy Markdown
Contributor Author

@CodeRabbit Complete the Vue CDN lifecycle guidance.

The CDN section tells the model to instantiate window.SocialShareButton in onMounted, but it omits Vue lifecycle handling. Add cleanup in onUnmounted and guard initialization when window.SocialShareButton is not available.explain the issue and how it fixed

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

file=".github/copilot/integrate-social-share-button.prompt.md"

printf '%s\n' '--- Vue section headings ---'
rg -n '^(#{1,4})\s+.*Vue' "$file" || true

printf '%s\n' '--- Vue CDN lifecycle references ---'
rg -n -C 12 '(onMounted|onUnmounted|window\.SocialShareButton|shareInstance|CDN)' "$file" || true

Length of output: 12425


@PrithvijitBose The Vue CDN lifecycle issue is not fixed in the current prompt.

The Vue 3 section includes cleanup only for the npm method:

onUnmounted(() => shareInstance?.destroy?.());

However, the Vue 3 section has no CDN Method example. Therefore, it does not instruct the model to do either required action for CDN use:

  1. Check that window.SocialShareButton exists before it creates an instance.
  2. Store the created instance and call destroy() from onUnmounted.

Without the guard, Vue can attempt new window.SocialShareButton(...) before the CDN script has loaded. This causes an unavailable-global error.

Without onUnmounted cleanup, the instance can remain attached after Vue removes the component. This can leave DOM handlers and instance state active.

The Vue CDN example should use this lifecycle pattern:

<script setup>
import { ref, onMounted, onUnmounted } from "vue";

const shareContainerRef = ref(null);
let shareInstance = null;

onMounted(() => {
  if (!window.SocialShareButton || !shareContainerRef.value) return;

  shareInstance = new window.SocialShareButton({
    container: shareContainerRef.value,
    buttonStyle: "default",
  });
});

onUnmounted(() => {
  shareInstance?.destroy?.();
});
</script>
  • Add a Vue 3 CDN Method subsection to .github/copilot/integrate-social-share-button.prompt.md.
  • Include the CDN stylesheet and script placement instructions.
  • Add the window.SocialShareButton availability guard.
  • Add onUnmounted cleanup for the created instance.

✏️ Learnings added
Learnt from: PrithvijitBose
URL: https://github.com/AOSSIE-Org/SocialShareButton/pull/213

Timestamp: 2026-08-06T13:27:03.104Z
Learning: In `.github/copilot/integrate-social-share-button.prompt.md`, Vue 3 CDN integration guidance must guard `window.SocialShareButton` before initialization and destroy the retained SocialShareButton instance in `onUnmounted`. The prompt must provide a dedicated Vue CDN example, not only Vue npm lifecycle guidance.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


  • 📌 Create a pull request with these changes

You are interacting with an AI system.

@PrithvijitBose

Copy link
Copy Markdown
Contributor Author

@CodeRabbit The package metadata and roadmap document state that @aossie-org/social-share-button has no .d.ts files. A user copy-pasting this TypeScript component into a strict Angular project can hit a missing-declaration error. Move this example to a supported JavaScript wrapper or publish package declarations before replacing it...explain and how its fixed now

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

prompt=".github/copilot/integrate-social-share-button.prompt.md"

printf '%s\n' '--- Angular prompt section ---'
start="$(rg -n '^#{3,4} .*Angular' "$prompt" | head -n 1 | cut -d: -f1 || true)"
if [ -n "$start" ]; then
  sed -n "${start},$((start + 130))p" "$prompt"
fi

printf '%s\n' '--- Type declaration and Angular import evidence ---'
rg -n -C 3 '(`@ts-ignore`|`@aossie-org/social-share-button`|\.d\.ts|declaration)' \
  "$prompt" package.json docs/Roadmap.md 2>/dev/null || true

printf '%s\n' '--- Published/type-related package metadata ---'
jq '{name, version, types, typings, files, main, module, exports}' package.json

Length of output: 21290


@PrithvijitBose The issue occurs because the published package has no TypeScript declaration file.

package.json has no types or typings field. It also publishes no .d.ts file. docs/Roadmap.md Line 51 records this as a known issue.

A strict Angular TypeScript project can report a missing-declaration diagnostic for:

import SocialShareButton from '`@aossie-org/social-share-button`';

The prompt now fixes the copied-example compile error by adding this line directly before that import:

// `@ts-ignore`
import SocialShareButton from '`@aossie-org/social-share-button`';

The prompt applies this change in both Angular examples:

  • The existing-component example.
  • The dedicated-component example.

// @ts-ignore`` suppresses the TypeScript diagnostic for the next line. Therefore, Angular can compile the example even though the package has no declarations.

This is a compatibility workaround. It does not provide type safety, API autocomplete, or typed constructor options. Publishing social-share-button.d.ts and adding a types field remains the complete package-level fix.

🐇🔍


✏️ Learnings added
Learnt from: PrithvijitBose
URL: https://github.com/AOSSIE-Org/SocialShareButton/pull/213

Timestamp: 2026-08-06T13:31:17.484Z
Learning: In `.github/copilot/integrate-social-share-button.prompt.md`, the Angular integration examples are TypeScript. The published `aossie-org/social-share-button` package has no `.d.ts` declarations or `types`/`typings` metadata. Each Angular example must place `// ts-ignore` immediately before the default package import to suppress the strict TypeScript missing-declaration diagnostic until the package publishes declarations.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

@PrithvijitBose

Copy link
Copy Markdown
Contributor Author

@CodeRabbit Move the npm package imports out of the inline HTML script.

This snippet is labeled Vite/Webpack, but a bare package specifier inside a <script type="module"> requires bundler entry/module support and will not run reliably as plain inline HTML. Put these imports in a source module such as src/main.js, then load that file from the template...explain this and how its fixed

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

file=".github/copilot/integrate-social-share-button.prompt.md"

printf '%s\n' '--- Vanilla section ---'
start="$(rg -n '^#{3,4} .*Vanilla HTML' "$file" | head -n 1 | cut -d: -f1 || true)"
if [ -n "$start" ]; then
  sed -n "${start},$((start + 100))p" "$file"
fi

printf '%s\n' '--- npm imports and template module scripts ---'
rg -n -C 4 'src/main\.js|<script type="module"|from ["'\'']`@aossie-org/social-share-button`["'\'']' "$file" || true

Length of output: 5833


@PrithvijitBose The main issue is fixed.

Previously, an inline HTML module contained this import:

import SocialShareButton from "`@aossie-org/social-share-button`";

A browser cannot resolve this bare npm package specifier by itself. Vite or Webpack must process the import from an application entry module. Otherwise, copied code in plain HTML can fail to load the package.

The prompt now separates the two responsibilities:

  • The HTML template contains the container:

    <div id="share-button"></div>
  • The existing JavaScript entry module, such as src/main.js, contains the npm imports and initialization:

    import SocialShareButton from "`@aossie-org/social-share-button`";
    import "`@aossie-org/social-share-button/css`";
    
    new SocialShareButton({ container: "`#share-button`", buttonStyle: "default" });

Vite or Webpack can resolve and bundle these imports when it processes src/main.js.

One detail remains implicit. The HTML template must load the existing entry module, for example in Vite:

<script type="module" src="/src/main.js"></script>

An existing Vite project usually already has this entry-script tag. The prompt should state this condition explicitly. This makes the example complete for users who add the integration to a template without an existing module entry reference.


✏️ Learnings added
Learnt from: PrithvijitBose
URL: https://github.com/AOSSIE-Org/SocialShareButton/pull/213

Timestamp: 2026-08-06T13:44:31.826Z
Learning: In `.github/copilot/integrate-social-share-button.prompt.md`, Vanilla HTML and JavaScript npm integrations must place `aossie-org/social-share-button` imports in the project’s existing bundler entry module, such as `src/main.js`, rather than in an inline HTML module. The HTML template must load that existing entry module when it does not already do so, for example with Vite’s `<script type="module" src="/src/main.js"></script>`.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

@PrithvijitBose

Copy link
Copy Markdown
Contributor Author

@CodeRabbit A Next.js project can contain both next and react. If the agent matches React first, it can skip the Next.js guide and generate the wrong template setup. Detect specific frameworks before generic ones, such as next before react and preact before react. explain and tell me how it fixed

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

file=".github/copilot/integrate-social-share-button.prompt.md"

printf '%s\n' '--- Framework detection workflow ---'
rg -n -C 5 '(Inspect Repo|Identify Frontend|specific-to-generic|Next\.js before React|Preact before React|dependencies)' "$file" || true

printf '%s\n' '--- Technology guide headings ---'
rg -n '^(#{2,4})\s+.*(React|Next\.js|Preact)' "$file" || true

Length of output: 1330


@PrithvijitBose The issue is fixed in the prompt.

A Next.js project normally lists both next and react in package.json. If the integration workflow checks for react first, it can classify the project as React. It can then skip the Next.js instructions. Those instructions include Next.js-specific requirements such as "use client" and the next/script CDN setup.

The same risk exists for Preact projects that use React-compatible dependencies. If the workflow checks for react first, it can select the React guide instead of the separate Preact guide. The React guide uses React hooks and className. The Preact guide uses preact/hooks and class.

The prompt now states this requirement at Line 20:

Use deterministic specific-to-generic framework matching. Identify Next.js before React, and Preact before React.

This order makes framework selection deterministic:

  1. Detect next first and use the React / Next.js guide.
  2. Detect preact before generic React and use the Preact guide.
  3. Use the generic React path only when no more specific framework matches.

This prevents the agent from generating an incompatible template for projects that declare both a specific framework and react.

🐇🔎


✏️ Learnings added
Learnt from: PrithvijitBose
URL: https://github.com/AOSSIE-Org/SocialShareButton/pull/213

Timestamp: 2026-08-06T13:48:48.124Z
Learning: In `.github/copilot/integrate-social-share-button.prompt.md`, framework detection must use deterministic specific-to-generic precedence. Detect Next.js before generic React, and detect Preact before generic React, because projects can declare `react` alongside a more specific framework. Use the specific framework guide when both dependencies are present.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/copilot/integrate-social-share-button.prompt.md:
- Around line 343-344: Move the SocialShareButton stylesheet out of
component-level styleUrls in the affected component definitions and register it
through Angular’s global stylesheet configuration so the body-appended modal
receives styling. Apply the same change to both occurrences referenced by the
review, and avoid relying on emulated component encapsulation.
- Line 43: Update the npm integration guidance around each required default
import so it matches a verified package entry point: either publish and verify
an ESM entry exporting SocialShareButton as the default, or replace the examples
with the package’s supported runtime integration. Do not mandate import
SocialShareButton from "`@aossie-org/social-share-button`" until the package
metadata and distributed source expose that default export.
- Around line 25-26: Update the package-manager detection instructions near the
lockfile checks to first read packageManager from the selected frontend app’s
package.json, then resolve lockfiles within that workspace rather than unrelated
repository directories. Define monorepo precedence and stop detection when
packageManager and lockfile signals conflict; preserve Bun classification for
bun.lock and bun.lockb before directing the agent to the matching Technology
Guide.
- Around line 405-423: Update ngOnChanges so a buttonStyle change destroys and
recreates the SocialShareButton instance instead of calling updateOptions.
Continue using updateOptions for changes to options it supports in place, while
preserving the existing container, URL, title, and buttonStyle values during
reinitialization.
- Line 241: Expand the Preact CDN instructions to require a complete
preact/hooks lifecycle implementation in the existing component: retain the
widget instance, poll or otherwise wait for the CDN global before
initialization, clean up any polling timer, and call destroy() on unmount. Keep
the CDN asset placement requirements and ensure the guide is self-contained
without relying on other examples.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f9628874-9463-4539-bd24-610c50d38f2a

📥 Commits

Reviewing files that changed from the base of the PR and between 5fd937a and 414a47f.

📒 Files selected for processing (1)
  • .github/copilot/integrate-social-share-button.prompt.md

Comment on lines +25 to +26
- Check `package-lock.json`, `pnpm-lock.yaml`, `yarn.lock`, or `bun.lock`/`bun.lockb` for package manager (`npm`|`pnpm`|`yarn`|`bun`, classifying `bun.lock` or `bun.lockb` as Bun).
- **CRITICAL DIRECTIVE**: Skip directly to the detected framework in **Technology Guides** below. Ignore all other guides.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Define package-manager precedence for monorepos.

Line [21] scopes the target to a frontend app, but Line [25] does not scope lockfile lookup to that workspace or resolve conflicting lockfiles. A root or backend lockfile can select the wrong install command. Read packageManager from the selected package.json, then resolve the workspace lockfile and stop when signals conflict.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/copilot/integrate-social-share-button.prompt.md around lines 25 -
26, Update the package-manager detection instructions near the lockfile checks
to first read packageManager from the selected frontend app’s package.json, then
resolve lockfiles within that workspace rather than unrelated repository
directories. Define monorepo precedence and stop detection when packageManager
and lockfile signals conflict; preserve Bun classification for bun.lock and
bun.lockb before directing the agent to the matching Technology Guide.

- 🛑 **No New Files in Existing Projects (CRITICAL DIRECTIVE)**:
- **Default Mode (Existing Projects)**: Do **NOT** create a new file (e.g., `ShareButton.jsx`, `ShareButton.tsx`). Inject imports, lifecycle hooks (`useEffect`, `onMounted`, etc.), and container element (`<div ref={...}></div>` or `<div id="..."></div>`) directly into the developer's existing component (e.g., `Header`, `Navbar`, `Footer`, `Article`, `page.tsx`).
- **Exception Mode (New Projects or Explicit User Request)**: ONLY create a separate dedicated component file (e.g., `ShareButton.jsx`, `ShareButton.vue`) when initializing a new project from scratch OR if the user explicitly asks for a dedicated wrapper file.
- **ESM Import**: MUST use default import `import SocialShareButton from "@aossie-org/social-share-button";` (Do NOT use named `{ SocialShareButton }`).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Publish a default ESM entry before mandating this import.

The prompt requires a default ESM import in every npm example. The current package metadata points to src/social-share-button.js, which has no export default; it conditionally assigns module.exports and window.SocialShareButton instead. ESM bundlers can reject these examples because the requested default export is missing. Publish a verified ESM entry or use the supported runtime integration. (raw.githubusercontent.com)

Verification script
#!/usr/bin/env bash
set -euo pipefail

meta="$(mktemp)"
trap 'rm -f "$meta"' EXIT

curl -fsSL 'https://registry.npmjs.org/%40aossie-org%2Fsocial-share-button' > "$meta"
version="$(jq -r '."dist-tags".latest' "$meta")"
tarball="$(jq -r --arg v "$version" '.versions[$v].dist.tarball' "$meta")"

curl -fsSL "$tarball" | tar -xzOf - package/package.json | jq '{type, main, exports, files}'
curl -fsSL "$tarball" | tar -xzOf - package/src/social-share-button.js \
  | rg -n 'export default|module\.exports|window\.SocialShareButton'

Also applies to: 65-65, 98-98, 184-184, 215-215, 261-261, 290-290, 333-333, 380-380, 448-448

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/copilot/integrate-social-share-button.prompt.md at line 43, Update
the npm integration guidance around each required default import so it matches a
verified package entry point: either publish and verify an ESM entry exporting
SocialShareButton as the default, or replace the examples with the package’s
supported runtime integration. Do not mandate import SocialShareButton from
"`@aossie-org/social-share-button`" until the package metadata and distributed
source expose that default export.

#### CDN Method

### CDN — Qwik
Add CDN `<link>` to `<head>` and `<script>` to `<body>` in `index.html`. Inline initialization logic into existing component using `preact/hooks`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Make the Preact CDN guide self-contained.

This section only instructs the agent to add CDN assets and inline initialization. It does not require instance retention, delayed-global polling, timer cleanup, or destroy() on unmount. Because Line [26] says to ignore other guides, the agent cannot rely on the React CDN example for these requirements. Add a complete preact/hooks lifecycle example.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/copilot/integrate-social-share-button.prompt.md at line 241, Expand
the Preact CDN instructions to require a complete preact/hooks lifecycle
implementation in the existing component: retain the widget instance, poll or
otherwise wait for the CDN global before initialization, clean up any polling
timer, and call destroy() on unmount. Keep the CDN asset placement requirements
and ensure the guide is self-contained without relying on other examples.

Comment on lines +343 to +344
styleUrls: ["../../node_modules/@aossie-org/social-share-button/css"],
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Load SocialShareButton CSS globally in Angular.

styleUrls attaches CSS to the component. Angular's default emulated encapsulation scopes component styles, while SocialShareButton appends its modal to document.body. The modal can therefore remain unstyled even if the path resolves. Import the stylesheet through the global stylesheet configuration, or explicitly document the trade-offs of ViewEncapsulation.None. (v18.angular.dev)

Verification script
#!/usr/bin/env bash
set -euo pipefail

curl -fsSL \
  'https://raw.githubusercontent.com/AOSSIE-Org/SocialShareButton/master/src/social-share-button.js' \
  | rg -n 'document\.body\.appendChild|this\.modal'

Also applies to: 385-386

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/copilot/integrate-social-share-button.prompt.md around lines 343 -
344, Move the SocialShareButton stylesheet out of component-level styleUrls in
the affected component definitions and register it through Angular’s global
stylesheet configuration so the body-appended modal receives styling. Apply the
same change to both occurrences referenced by the review, and avoid relying on
emulated component encapsulation.

Comment on lines +405 to +423
ngOnChanges(changes: SimpleChanges): void {
if (this.instance) {
if (this.instance.updateOptions) {
this.instance.updateOptions({
buttonStyle: this.buttonStyle,
url: this.url,
title: this.title,
});
} else {
this.instance.destroy?.();
if (this.container?.nativeElement) {
this.instance = new SocialShareButton({
container: this.container.nativeElement,
buttonStyle: this.buttonStyle,
url: this.url,
title: this.title,
});
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Recreate the Angular instance when buttonStyle changes.

The ngOnChanges branch calls updateOptions whenever that method exists. The package implementation merges options and refreshes URL and color state, but it does not rebuild the rendered button or update its style class. A changed buttonStyle input therefore leaves the old style visible. Reinitialize for buttonStyle changes and use updateOptions only for options that the API updates in place. (raw.githubusercontent.com)

Verification script
#!/usr/bin/env bash
set -euo pipefail

curl -fsSL \
  'https://raw.githubusercontent.com/AOSSIE-Org/SocialShareButton/master/src/social-share-button.js' \
  | sed -n '580,605p'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/copilot/integrate-social-share-button.prompt.md around lines 405 -
423, Update ngOnChanges so a buttonStyle change destroys and recreates the
SocialShareButton instance instead of calling updateOptions. Continue using
updateOptions for changes to options it supports in place, while preserving the
existing container, URL, title, and buttonStyle values during reinitialization.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/copilot/integrate-social-share-button.prompt.md:
- Line 39: Update the examples in the social share button prompt to use the
selected buttonStyle value from Step 4 instead of hardcoding "default". Apply
this consistently to every referenced example so generated code reflects the
user’s chosen style.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 2e94e4dc-2fc7-4d52-8df0-5a9709933c03

📥 Commits

Reviewing files that changed from the base of the PR and between 414a47f and 598639c.

📒 Files selected for processing (1)
  • .github/copilot/integrate-social-share-button.prompt.md

Comment thread .github/copilot/integrate-social-share-button.prompt.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-cd CI/CD pipeline changes documentation Changes to documentation files needs-review no-issue-linked PR is not linked to any issue repeat-contributor PR from an external contributor who already had PRs merged size/XL Extra large PR (>500 lines changed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant