x-twitter-scraper 0.12.3 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +73 -2
- package/README.md +66 -51
- package/client.d.mts +18 -15
- package/client.d.mts.map +1 -1
- package/client.d.ts +18 -15
- package/client.d.ts.map +1 -1
- package/client.js +3 -3
- package/client.js.map +1 -1
- package/client.mjs +4 -4
- package/client.mjs.map +1 -1
- package/core/streaming.d.mts +33 -0
- package/core/streaming.d.mts.map +1 -0
- package/core/streaming.d.ts +33 -0
- package/core/streaming.d.ts.map +1 -0
- package/core/streaming.js +270 -0
- package/core/streaming.js.map +1 -0
- package/core/streaming.mjs +265 -0
- package/core/streaming.mjs.map +1 -0
- package/internal/decoders/line.d.mts +17 -0
- package/internal/decoders/line.d.mts.map +1 -0
- package/internal/decoders/line.d.ts +17 -0
- package/internal/decoders/line.d.ts.map +1 -0
- package/internal/decoders/line.js +116 -0
- package/internal/decoders/line.js.map +1 -0
- package/internal/decoders/line.mjs +111 -0
- package/internal/decoders/line.mjs.map +1 -0
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +7 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +7 -0
- package/internal/parse.mjs.map +1 -1
- package/internal/tslib.js +18 -18
- package/package.json +23 -5
- package/resources/account.d.mts +35 -12
- package/resources/account.d.mts.map +1 -1
- package/resources/account.d.ts +35 -12
- package/resources/account.d.ts.map +1 -1
- package/resources/account.js +4 -3
- package/resources/account.js.map +1 -1
- package/resources/account.mjs +4 -3
- package/resources/account.mjs.map +1 -1
- package/resources/compose.d.mts +77 -21
- package/resources/compose.d.mts.map +1 -1
- package/resources/compose.d.ts +77 -21
- package/resources/compose.d.ts.map +1 -1
- package/resources/compose.js +3 -4
- package/resources/compose.js.map +1 -1
- package/resources/compose.mjs +3 -4
- package/resources/compose.mjs.map +1 -1
- package/resources/credits.d.mts +18 -10
- package/resources/credits.d.mts.map +1 -1
- package/resources/credits.d.ts +18 -10
- package/resources/credits.d.ts.map +1 -1
- package/resources/credits.js +5 -4
- package/resources/credits.js.map +1 -1
- package/resources/credits.mjs +5 -4
- package/resources/credits.mjs.map +1 -1
- package/resources/drafts.d.mts +13 -17
- package/resources/drafts.d.mts.map +1 -1
- package/resources/drafts.d.ts +13 -17
- package/resources/drafts.d.ts.map +1 -1
- package/resources/drafts.js +4 -4
- package/resources/drafts.mjs +4 -4
- package/resources/draws.d.mts +84 -28
- package/resources/draws.d.mts.map +1 -1
- package/resources/draws.d.ts +84 -28
- package/resources/draws.d.ts.map +1 -1
- package/resources/draws.js +24 -9
- package/resources/draws.js.map +1 -1
- package/resources/draws.mjs +24 -9
- package/resources/draws.mjs.map +1 -1
- package/resources/events.d.mts +2564 -21
- package/resources/events.d.mts.map +1 -1
- package/resources/events.d.ts +2564 -21
- package/resources/events.d.ts.map +1 -1
- package/resources/events.js +34 -2
- package/resources/events.js.map +1 -1
- package/resources/events.mjs +34 -2
- package/resources/events.mjs.map +1 -1
- package/resources/extractions.d.mts +410 -128
- package/resources/extractions.d.mts.map +1 -1
- package/resources/extractions.d.ts +410 -128
- package/resources/extractions.d.ts.map +1 -1
- package/resources/extractions.js +74 -12
- package/resources/extractions.js.map +1 -1
- package/resources/extractions.mjs +74 -12
- package/resources/extractions.mjs.map +1 -1
- package/resources/guest-wallets.d.mts +6 -5
- package/resources/guest-wallets.d.mts.map +1 -1
- package/resources/guest-wallets.d.ts +6 -5
- package/resources/guest-wallets.d.ts.map +1 -1
- package/resources/guest-wallets.js +2 -1
- package/resources/guest-wallets.js.map +1 -1
- package/resources/guest-wallets.mjs +2 -1
- package/resources/guest-wallets.mjs.map +1 -1
- package/resources/index.d.mts +6 -6
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +6 -6
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/monitors/index.d.mts +2 -2
- package/resources/monitors/index.d.mts.map +1 -1
- package/resources/monitors/index.d.ts +2 -2
- package/resources/monitors/index.d.ts.map +1 -1
- package/resources/monitors/index.js.map +1 -1
- package/resources/monitors/index.mjs.map +1 -1
- package/resources/monitors/keywords.d.mts +66 -14
- package/resources/monitors/keywords.d.mts.map +1 -1
- package/resources/monitors/keywords.d.ts +66 -14
- package/resources/monitors/keywords.d.ts.map +1 -1
- package/resources/monitors/keywords.js +16 -10
- package/resources/monitors/keywords.js.map +1 -1
- package/resources/monitors/keywords.mjs +16 -10
- package/resources/monitors/keywords.mjs.map +1 -1
- package/resources/monitors/monitors.d.mts +53 -16
- package/resources/monitors/monitors.d.mts.map +1 -1
- package/resources/monitors/monitors.d.ts +53 -16
- package/resources/monitors/monitors.d.ts.map +1 -1
- package/resources/monitors/monitors.js +12 -10
- package/resources/monitors/monitors.js.map +1 -1
- package/resources/monitors/monitors.mjs +12 -10
- package/resources/monitors/monitors.mjs.map +1 -1
- package/resources/radar.d.mts +32 -36
- package/resources/radar.d.mts.map +1 -1
- package/resources/radar.d.ts +32 -36
- package/resources/radar.d.ts.map +1 -1
- package/resources/radar.js +1 -1
- package/resources/radar.mjs +1 -1
- package/resources/shared.d.mts +1726 -233
- package/resources/shared.d.mts.map +1 -1
- package/resources/shared.d.ts +1726 -233
- package/resources/shared.d.ts.map +1 -1
- package/resources/styles.d.mts +34 -23
- package/resources/styles.d.mts.map +1 -1
- package/resources/styles.d.ts +34 -23
- package/resources/styles.d.ts.map +1 -1
- package/resources/styles.js +11 -13
- package/resources/styles.js.map +1 -1
- package/resources/styles.mjs +11 -13
- package/resources/styles.mjs.map +1 -1
- package/resources/subscribe.d.mts +1 -1
- package/resources/subscribe.d.ts +1 -1
- package/resources/subscribe.js +1 -1
- package/resources/subscribe.mjs +1 -1
- package/resources/support/index.d.mts +1 -1
- package/resources/support/index.d.mts.map +1 -1
- package/resources/support/index.d.ts +1 -1
- package/resources/support/index.d.ts.map +1 -1
- package/resources/support/index.js.map +1 -1
- package/resources/support/index.mjs.map +1 -1
- package/resources/support/support.d.mts +2 -2
- package/resources/support/support.d.mts.map +1 -1
- package/resources/support/support.d.ts +2 -2
- package/resources/support/support.d.ts.map +1 -1
- package/resources/support/support.js.map +1 -1
- package/resources/support/support.mjs.map +1 -1
- package/resources/support/tickets.d.mts +30 -10
- package/resources/support/tickets.d.mts.map +1 -1
- package/resources/support/tickets.d.ts +30 -10
- package/resources/support/tickets.d.ts.map +1 -1
- package/resources/support/tickets.js +7 -7
- package/resources/support/tickets.js.map +1 -1
- package/resources/support/tickets.mjs +7 -7
- package/resources/support/tickets.mjs.map +1 -1
- package/resources/trends.d.mts +21 -5
- package/resources/trends.d.mts.map +1 -1
- package/resources/trends.d.ts +21 -5
- package/resources/trends.d.ts.map +1 -1
- package/resources/trends.js +2 -1
- package/resources/trends.js.map +1 -1
- package/resources/trends.mjs +2 -1
- package/resources/trends.mjs.map +1 -1
- package/resources/webhooks.d.mts +80 -14
- package/resources/webhooks.d.mts.map +1 -1
- package/resources/webhooks.d.ts +80 -14
- package/resources/webhooks.d.ts.map +1 -1
- package/resources/webhooks.js +30 -11
- package/resources/webhooks.js.map +1 -1
- package/resources/webhooks.mjs +30 -11
- package/resources/webhooks.mjs.map +1 -1
- package/resources/x/account-connection-attempts.d.mts +1 -1
- package/resources/x/account-connection-attempts.d.ts +1 -1
- package/resources/x/account-connection-attempts.js +1 -1
- package/resources/x/account-connection-attempts.mjs +1 -1
- package/resources/x/account-connection-challenges.d.mts +30 -11
- package/resources/x/account-connection-challenges.d.mts.map +1 -1
- package/resources/x/account-connection-challenges.d.ts +30 -11
- package/resources/x/account-connection-challenges.d.ts.map +1 -1
- package/resources/x/account-connection-challenges.js +5 -4
- package/resources/x/account-connection-challenges.js.map +1 -1
- package/resources/x/account-connection-challenges.mjs +5 -4
- package/resources/x/account-connection-challenges.mjs.map +1 -1
- package/resources/x/accounts.d.mts +38 -10
- package/resources/x/accounts.d.mts.map +1 -1
- package/resources/x/accounts.d.ts +38 -10
- package/resources/x/accounts.d.ts.map +1 -1
- package/resources/x/accounts.js +8 -7
- package/resources/x/accounts.js.map +1 -1
- package/resources/x/accounts.mjs +8 -7
- package/resources/x/accounts.mjs.map +1 -1
- package/resources/x/analysis.d.mts +3274 -0
- package/resources/x/analysis.d.mts.map +1 -0
- package/resources/x/analysis.d.ts +3274 -0
- package/resources/x/analysis.d.ts.map +1 -0
- package/resources/x/analysis.js +132 -0
- package/resources/x/analysis.js.map +1 -0
- package/resources/x/analysis.mjs +128 -0
- package/resources/x/analysis.mjs.map +1 -0
- package/resources/x/bookmarks.d.mts +84 -9
- package/resources/x/bookmarks.d.mts.map +1 -1
- package/resources/x/bookmarks.d.ts +84 -9
- package/resources/x/bookmarks.d.ts.map +1 -1
- package/resources/x/bookmarks.js +6 -4
- package/resources/x/bookmarks.js.map +1 -1
- package/resources/x/bookmarks.mjs +6 -4
- package/resources/x/bookmarks.mjs.map +1 -1
- package/resources/x/broadcasts.d.mts +176 -0
- package/resources/x/broadcasts.d.mts.map +1 -0
- package/resources/x/broadcasts.d.ts +176 -0
- package/resources/x/broadcasts.d.ts.map +1 -0
- package/resources/x/broadcasts.js +29 -0
- package/resources/x/broadcasts.js.map +1 -0
- package/resources/x/broadcasts.mjs +25 -0
- package/resources/x/broadcasts.mjs.map +1 -0
- package/resources/x/communities/communities.d.mts +612 -128
- package/resources/x/communities/communities.d.mts.map +1 -1
- package/resources/x/communities/communities.d.ts +612 -128
- package/resources/x/communities/communities.d.ts.map +1 -1
- package/resources/x/communities/communities.js +96 -17
- package/resources/x/communities/communities.js.map +1 -1
- package/resources/x/communities/communities.mjs +96 -17
- package/resources/x/communities/communities.mjs.map +1 -1
- package/resources/x/communities/index.d.mts +2 -1
- package/resources/x/communities/index.d.mts.map +1 -1
- package/resources/x/communities/index.d.ts +2 -1
- package/resources/x/communities/index.d.ts.map +1 -1
- package/resources/x/communities/index.js +3 -1
- package/resources/x/communities/index.js.map +1 -1
- package/resources/x/communities/index.mjs +1 -0
- package/resources/x/communities/index.mjs.map +1 -1
- package/resources/x/communities/join.d.mts +46 -25
- package/resources/x/communities/join.d.mts.map +1 -1
- package/resources/x/communities/join.d.ts +46 -25
- package/resources/x/communities/join.d.ts.map +1 -1
- package/resources/x/communities/join.js +10 -7
- package/resources/x/communities/join.js.map +1 -1
- package/resources/x/communities/join.mjs +10 -7
- package/resources/x/communities/join.mjs.map +1 -1
- package/resources/x/communities/media.d.mts +197 -0
- package/resources/x/communities/media.d.mts.map +1 -0
- package/resources/x/communities/media.d.ts +197 -0
- package/resources/x/communities/media.d.ts.map +1 -0
- package/resources/x/communities/media.js +29 -0
- package/resources/x/communities/media.js.map +1 -0
- package/resources/x/communities/media.mjs +25 -0
- package/resources/x/communities/media.mjs.map +1 -0
- package/resources/x/communities/tweets.d.mts +350 -20
- package/resources/x/communities/tweets.d.mts.map +1 -1
- package/resources/x/communities/tweets.d.ts +350 -20
- package/resources/x/communities/tweets.d.ts.map +1 -1
- package/resources/x/communities/tweets.js +8 -7
- package/resources/x/communities/tweets.js.map +1 -1
- package/resources/x/communities/tweets.mjs +8 -7
- package/resources/x/communities/tweets.mjs.map +1 -1
- package/resources/x/dm.d.mts +245 -13
- package/resources/x/dm.d.mts.map +1 -1
- package/resources/x/dm.d.ts +245 -13
- package/resources/x/dm.d.ts.map +1 -1
- package/resources/x/dm.js +29 -2
- package/resources/x/dm.js.map +1 -1
- package/resources/x/dm.mjs +29 -2
- package/resources/x/dm.mjs.map +1 -1
- package/resources/x/followers.d.mts +31 -3
- package/resources/x/followers.d.mts.map +1 -1
- package/resources/x/followers.d.ts +31 -3
- package/resources/x/followers.d.ts.map +1 -1
- package/resources/x/followers.js +2 -1
- package/resources/x/followers.js.map +1 -1
- package/resources/x/followers.mjs +2 -1
- package/resources/x/followers.mjs.map +1 -1
- package/resources/x/index.d.mts +12 -8
- package/resources/x/index.d.mts.map +1 -1
- package/resources/x/index.d.ts +12 -8
- package/resources/x/index.d.ts.map +1 -1
- package/resources/x/index.js +9 -1
- package/resources/x/index.js.map +1 -1
- package/resources/x/index.mjs +5 -1
- package/resources/x/index.mjs.map +1 -1
- package/resources/x/jobs.d.mts +506 -0
- package/resources/x/jobs.d.mts.map +1 -0
- package/resources/x/jobs.d.ts +506 -0
- package/resources/x/jobs.d.ts.map +1 -0
- package/resources/x/jobs.js +60 -0
- package/resources/x/jobs.js.map +1 -0
- package/resources/x/jobs.mjs +56 -0
- package/resources/x/jobs.mjs.map +1 -0
- package/resources/x/lists.d.mts +1058 -27
- package/resources/x/lists.d.mts.map +1 -1
- package/resources/x/lists.d.ts +1058 -27
- package/resources/x/lists.d.ts.map +1 -1
- package/resources/x/lists.js +39 -9
- package/resources/x/lists.js.map +1 -1
- package/resources/x/lists.mjs +39 -9
- package/resources/x/lists.mjs.map +1 -1
- package/resources/x/media.d.mts +24 -13
- package/resources/x/media.d.mts.map +1 -1
- package/resources/x/media.d.ts +24 -13
- package/resources/x/media.d.ts.map +1 -1
- package/resources/x/media.js +2 -2
- package/resources/x/media.mjs +2 -2
- package/resources/x/profile.d.mts +60 -33
- package/resources/x/profile.d.mts.map +1 -1
- package/resources/x/profile.d.ts +60 -33
- package/resources/x/profile.d.ts.map +1 -1
- package/resources/x/profile.js +3 -3
- package/resources/x/profile.mjs +3 -3
- package/resources/x/spaces.d.mts +857 -0
- package/resources/x/spaces.d.mts.map +1 -0
- package/resources/x/spaces.d.ts +857 -0
- package/resources/x/spaces.d.ts.map +1 -0
- package/resources/x/spaces.js +58 -0
- package/resources/x/spaces.js.map +1 -0
- package/resources/x/spaces.mjs +54 -0
- package/resources/x/spaces.mjs.map +1 -0
- package/resources/x/tweets/index.d.mts +1 -1
- package/resources/x/tweets/index.d.mts.map +1 -1
- package/resources/x/tweets/index.d.ts +1 -1
- package/resources/x/tweets/index.d.ts.map +1 -1
- package/resources/x/tweets/index.js.map +1 -1
- package/resources/x/tweets/index.mjs.map +1 -1
- package/resources/x/tweets/like.d.mts +38 -20
- package/resources/x/tweets/like.d.mts.map +1 -1
- package/resources/x/tweets/like.d.ts +38 -20
- package/resources/x/tweets/like.d.ts.map +1 -1
- package/resources/x/tweets/like.js +2 -2
- package/resources/x/tweets/like.mjs +2 -2
- package/resources/x/tweets/retweet.d.mts +38 -20
- package/resources/x/tweets/retweet.d.mts.map +1 -1
- package/resources/x/tweets/retweet.d.ts +38 -20
- package/resources/x/tweets/retweet.d.ts.map +1 -1
- package/resources/x/tweets/retweet.js +2 -2
- package/resources/x/tweets/retweet.mjs +2 -2
- package/resources/x/tweets/tweets.d.mts +2639 -326
- package/resources/x/tweets/tweets.d.mts.map +1 -1
- package/resources/x/tweets/tweets.d.ts +2639 -326
- package/resources/x/tweets/tweets.d.ts.map +1 -1
- package/resources/x/tweets/tweets.js +147 -21
- package/resources/x/tweets/tweets.js.map +1 -1
- package/resources/x/tweets/tweets.mjs +147 -21
- package/resources/x/tweets/tweets.mjs.map +1 -1
- package/resources/x/users/follow.d.mts +38 -20
- package/resources/x/users/follow.d.mts.map +1 -1
- package/resources/x/users/follow.d.ts +38 -20
- package/resources/x/users/follow.d.ts.map +1 -1
- package/resources/x/users/follow.js +2 -2
- package/resources/x/users/follow.mjs +2 -2
- package/resources/x/users/index.d.mts +1 -1
- package/resources/x/users/index.d.mts.map +1 -1
- package/resources/x/users/index.d.ts +1 -1
- package/resources/x/users/index.d.ts.map +1 -1
- package/resources/x/users/index.js.map +1 -1
- package/resources/x/users/index.mjs.map +1 -1
- package/resources/x/users/users.d.mts +3068 -457
- package/resources/x/users/users.d.mts.map +1 -1
- package/resources/x/users/users.d.ts +3068 -457
- package/resources/x/users/users.d.ts.map +1 -1
- package/resources/x/users/users.js +205 -22
- package/resources/x/users/users.js.map +1 -1
- package/resources/x/users/users.mjs +205 -22
- package/resources/x/users/users.mjs.map +1 -1
- package/resources/x/write-actions.d.mts +13 -6
- package/resources/x/write-actions.d.mts.map +1 -1
- package/resources/x/write-actions.d.ts +13 -6
- package/resources/x/write-actions.d.ts.map +1 -1
- package/resources/x/write-actions.js +1 -1
- package/resources/x/write-actions.mjs +1 -1
- package/resources/x/x.d.mts +864 -27
- package/resources/x/x.d.mts.map +1 -1
- package/resources/x/x.d.ts +864 -27
- package/resources/x/x.d.ts.map +1 -1
- package/resources/x/x.js +78 -5
- package/resources/x/x.js.map +1 -1
- package/resources/x/x.mjs +80 -7
- package/resources/x/x.mjs.map +1 -1
- package/skills/x-twitter-scraper/SKILL.md +97 -350
- package/skills/x-twitter-scraper/metadata.json +3 -9
- package/skills/x-twitter-scraper/references/draws.md +24 -24
- package/skills/x-twitter-scraper/references/extractions.md +71 -62
- package/skills/x-twitter-scraper/references/mcp-setup.md +36 -39
- package/skills/x-twitter-scraper/references/mcp-tools.md +105 -166
- package/skills/x-twitter-scraper/references/python-examples.md +5 -5
- package/skills/x-twitter-scraper/references/security.md +8 -8
- package/skills/x-twitter-scraper/references/types-mcp-output-schemas.md +4 -4
- package/skills/x-twitter-scraper/references/types.md +0 -1
- package/skills/x-twitter-scraper/references/usage.md +5 -5
- package/skills/x-twitter-scraper/references/webhooks.md +28 -31
- package/skills/x-twitter-scraper/references/workflows.md +70 -71
- package/skills/x-twitter-scraper/skill-card.md +13 -14
- package/skills/x-twitter-scraper/skillspector-report.md +8 -5
- package/skills/xquik-account-automation/LICENSE +21 -0
- package/skills/xquik-account-automation/SKILL.md +91 -0
- package/skills/xquik-social-research/SKILL.md +49 -56
- package/src/client.ts +47 -4
- package/src/core/streaming.ts +328 -0
- package/src/internal/decoders/line.ts +140 -0
- package/src/internal/parse.ts +9 -0
- package/src/resources/account.ts +41 -12
- package/src/resources/compose.ts +77 -21
- package/src/resources/credits.ts +19 -10
- package/src/resources/drafts.ts +13 -22
- package/src/resources/draws.ts +94 -36
- package/src/resources/events.ts +3225 -68
- package/src/resources/extractions.ts +512 -125
- package/src/resources/guest-wallets.ts +6 -5
- package/src/resources/index.ts +24 -1
- package/src/resources/monitors/index.ts +2 -0
- package/src/resources/monitors/keywords.ts +82 -14
- package/src/resources/monitors/monitors.ts +66 -14
- package/src/resources/radar.ts +32 -36
- package/src/resources/shared.ts +2227 -351
- package/src/resources/styles.ts +43 -27
- package/src/resources/subscribe.ts +1 -1
- package/src/resources/support/index.ts +1 -0
- package/src/resources/support/support.ts +2 -0
- package/src/resources/support/tickets.ts +38 -10
- package/src/resources/trends.ts +23 -5
- package/src/resources/webhooks.ts +109 -15
- package/src/resources/x/account-connection-attempts.ts +1 -1
- package/src/resources/x/account-connection-challenges.ts +39 -11
- package/src/resources/x/accounts.ts +46 -10
- package/src/resources/x/analysis.ts +3947 -0
- package/src/resources/x/bookmarks.ts +103 -9
- package/src/resources/x/broadcasts.ts +225 -0
- package/src/resources/x/communities/communities.ts +743 -141
- package/src/resources/x/communities/index.ts +9 -0
- package/src/resources/x/communities/join.ts +46 -23
- package/src/resources/x/communities/media.ts +251 -0
- package/src/resources/x/communities/tweets.ts +427 -20
- package/src/resources/x/dm.ts +334 -11
- package/src/resources/x/followers.ts +35 -3
- package/src/resources/x/index.ts +106 -1
- package/src/resources/x/jobs.ts +627 -0
- package/src/resources/x/lists.ts +1307 -28
- package/src/resources/x/media.ts +24 -12
- package/src/resources/x/profile.ts +60 -30
- package/src/resources/x/spaces.ts +1076 -0
- package/src/resources/x/tweets/index.ts +18 -0
- package/src/resources/x/tweets/like.ts +38 -18
- package/src/resources/x/tweets/retweet.ts +38 -18
- package/src/resources/x/tweets/tweets.ts +3695 -843
- package/src/resources/x/users/follow.ts +38 -18
- package/src/resources/x/users/index.ts +22 -0
- package/src/resources/x/users/users.ts +3687 -465
- package/src/resources/x/write-actions.ts +13 -5
- package/src/resources/x/x.ts +1227 -15
- package/src/streaming.ts +6 -0
- package/src/version.ts +1 -1
- package/streaming.d.mts +3 -0
- package/streaming.d.mts.map +1 -0
- package/streaming.d.ts +3 -0
- package/streaming.d.ts.map +1 -0
- package/streaming.js +9 -0
- package/streaming.js.map +1 -0
- package/streaming.mjs +6 -0
- package/streaming.mjs.map +1 -0
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/skills/x-twitter-scraper/references/types-rest-api-vs-mcp-field-naming.md +0 -15
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 Xquik contributors
|
|
3
|
+
//
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
var _Stream_client;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.Stream = void 0;
|
|
8
|
+
exports._iterSSEMessages = _iterSSEMessages;
|
|
9
|
+
const tslib_1 = require("../internal/tslib.js");
|
|
10
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
11
|
+
const error_1 = require("./error.js");
|
|
12
|
+
const shims_1 = require("../internal/shims.js");
|
|
13
|
+
const line_1 = require("../internal/decoders/line.js");
|
|
14
|
+
const shims_2 = require("../internal/shims.js");
|
|
15
|
+
const errors_1 = require("../internal/errors.js");
|
|
16
|
+
const bytes_1 = require("../internal/utils/bytes.js");
|
|
17
|
+
const log_1 = require("../internal/utils/log.js");
|
|
18
|
+
class Stream {
|
|
19
|
+
constructor(iterator, controller, client) {
|
|
20
|
+
this.iterator = iterator;
|
|
21
|
+
_Stream_client.set(this, void 0);
|
|
22
|
+
this.controller = controller;
|
|
23
|
+
tslib_1.__classPrivateFieldSet(this, _Stream_client, client, "f");
|
|
24
|
+
}
|
|
25
|
+
static fromSSEResponse(response, controller, client) {
|
|
26
|
+
let consumed = false;
|
|
27
|
+
const logger = client ? (0, log_1.loggerFor)(client) : console;
|
|
28
|
+
async function* iterator() {
|
|
29
|
+
if (consumed) {
|
|
30
|
+
throw new error_1.XTwitterScraperError('Cannot iterate over a consumed stream, use `.tee()` to split the stream.');
|
|
31
|
+
}
|
|
32
|
+
consumed = true;
|
|
33
|
+
let done = false;
|
|
34
|
+
try {
|
|
35
|
+
for await (const sse of _iterSSEMessages(response, controller)) {
|
|
36
|
+
// Each event is named by its type, so every event with data is yielded.
|
|
37
|
+
if (!sse.data)
|
|
38
|
+
continue;
|
|
39
|
+
try {
|
|
40
|
+
yield JSON.parse(sse.data);
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
logger.error(`Could not parse message into JSON:`, sse.data);
|
|
44
|
+
logger.error(`From chunk:`, sse.raw);
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
done = true;
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
// If the user calls `stream.controller.abort()`, we should exit without throwing.
|
|
52
|
+
if ((0, errors_1.isAbortError)(e))
|
|
53
|
+
return;
|
|
54
|
+
throw e;
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
// If the user `break`s, abort the ongoing request.
|
|
58
|
+
if (!done)
|
|
59
|
+
controller.abort();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return new Stream(iterator, controller, client);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Generates a Stream from a newline-separated ReadableStream
|
|
66
|
+
* where each item is a JSON value.
|
|
67
|
+
*/
|
|
68
|
+
static fromReadableStream(readableStream, controller, client) {
|
|
69
|
+
let consumed = false;
|
|
70
|
+
async function* iterLines() {
|
|
71
|
+
const lineDecoder = new line_1.LineDecoder();
|
|
72
|
+
const iter = (0, shims_2.ReadableStreamToAsyncIterable)(readableStream);
|
|
73
|
+
for await (const chunk of iter) {
|
|
74
|
+
for (const line of lineDecoder.decode(chunk)) {
|
|
75
|
+
yield line;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (const line of lineDecoder.flush()) {
|
|
79
|
+
yield line;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function* iterator() {
|
|
83
|
+
if (consumed) {
|
|
84
|
+
throw new error_1.XTwitterScraperError('Cannot iterate over a consumed stream, use `.tee()` to split the stream.');
|
|
85
|
+
}
|
|
86
|
+
consumed = true;
|
|
87
|
+
let done = false;
|
|
88
|
+
try {
|
|
89
|
+
for await (const line of iterLines()) {
|
|
90
|
+
if (done)
|
|
91
|
+
continue;
|
|
92
|
+
if (line)
|
|
93
|
+
yield JSON.parse(line);
|
|
94
|
+
}
|
|
95
|
+
done = true;
|
|
96
|
+
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
// If the user calls `stream.controller.abort()`, we should exit without throwing.
|
|
99
|
+
if ((0, errors_1.isAbortError)(e))
|
|
100
|
+
return;
|
|
101
|
+
throw e;
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
// If the user `break`s, abort the ongoing request.
|
|
105
|
+
if (!done)
|
|
106
|
+
controller.abort();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return new Stream(iterator, controller, client);
|
|
110
|
+
}
|
|
111
|
+
[(_Stream_client = new WeakMap(), Symbol.asyncIterator)]() {
|
|
112
|
+
return this.iterator();
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Splits the stream into two streams which can be
|
|
116
|
+
* independently read from at different speeds.
|
|
117
|
+
*/
|
|
118
|
+
tee() {
|
|
119
|
+
const left = [];
|
|
120
|
+
const right = [];
|
|
121
|
+
const iterator = this.iterator();
|
|
122
|
+
const teeIterator = (queue) => {
|
|
123
|
+
return {
|
|
124
|
+
next: () => {
|
|
125
|
+
if (queue.length === 0) {
|
|
126
|
+
const result = iterator.next();
|
|
127
|
+
left.push(result);
|
|
128
|
+
right.push(result);
|
|
129
|
+
}
|
|
130
|
+
return queue.shift();
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
return [
|
|
135
|
+
new Stream(() => teeIterator(left), this.controller, tslib_1.__classPrivateFieldGet(this, _Stream_client, "f")),
|
|
136
|
+
new Stream(() => teeIterator(right), this.controller, tslib_1.__classPrivateFieldGet(this, _Stream_client, "f")),
|
|
137
|
+
];
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Converts this stream to a newline-separated ReadableStream of
|
|
141
|
+
* JSON stringified values in the stream
|
|
142
|
+
* which can be turned back into a Stream with `Stream.fromReadableStream()`.
|
|
143
|
+
*/
|
|
144
|
+
toReadableStream() {
|
|
145
|
+
const self = this;
|
|
146
|
+
let iter;
|
|
147
|
+
return (0, shims_1.makeReadableStream)({
|
|
148
|
+
async start() {
|
|
149
|
+
iter = self[Symbol.asyncIterator]();
|
|
150
|
+
},
|
|
151
|
+
async pull(ctrl) {
|
|
152
|
+
try {
|
|
153
|
+
const { value, done } = await iter.next();
|
|
154
|
+
if (done)
|
|
155
|
+
return ctrl.close();
|
|
156
|
+
const bytes = (0, bytes_1.encodeUTF8)(JSON.stringify(value) + '\n');
|
|
157
|
+
ctrl.enqueue(bytes);
|
|
158
|
+
}
|
|
159
|
+
catch (err) {
|
|
160
|
+
ctrl.error(err);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
async cancel() {
|
|
164
|
+
await iter.return?.();
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
exports.Stream = Stream;
|
|
170
|
+
async function* _iterSSEMessages(response, controller) {
|
|
171
|
+
if (!response.body) {
|
|
172
|
+
controller.abort();
|
|
173
|
+
if (typeof globalThis.navigator !== 'undefined' &&
|
|
174
|
+
globalThis.navigator.product === 'ReactNative') {
|
|
175
|
+
throw new error_1.XTwitterScraperError(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`);
|
|
176
|
+
}
|
|
177
|
+
throw new error_1.XTwitterScraperError(`Attempted to iterate over a response with no body`);
|
|
178
|
+
}
|
|
179
|
+
const sseDecoder = new SSEDecoder();
|
|
180
|
+
const lineDecoder = new line_1.LineDecoder();
|
|
181
|
+
const iter = (0, shims_2.ReadableStreamToAsyncIterable)(response.body);
|
|
182
|
+
for await (const sseChunk of iterSSEChunks(iter)) {
|
|
183
|
+
for (const line of lineDecoder.decode(sseChunk)) {
|
|
184
|
+
const sse = sseDecoder.decode(line);
|
|
185
|
+
if (sse)
|
|
186
|
+
yield sse;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
for (const line of lineDecoder.flush()) {
|
|
190
|
+
const sse = sseDecoder.decode(line);
|
|
191
|
+
if (sse)
|
|
192
|
+
yield sse;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Given an async iterable iterator, iterates over it and yields full
|
|
197
|
+
* SSE chunks, i.e. yields when a double new-line is encountered.
|
|
198
|
+
*/
|
|
199
|
+
async function* iterSSEChunks(iterator) {
|
|
200
|
+
let data = new Uint8Array();
|
|
201
|
+
for await (const chunk of iterator) {
|
|
202
|
+
if (chunk == null) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
const binaryChunk = chunk instanceof ArrayBuffer ? new Uint8Array(chunk)
|
|
206
|
+
: typeof chunk === 'string' ? (0, bytes_1.encodeUTF8)(chunk)
|
|
207
|
+
: chunk;
|
|
208
|
+
let newData = new Uint8Array(data.length + binaryChunk.length);
|
|
209
|
+
newData.set(data);
|
|
210
|
+
newData.set(binaryChunk, data.length);
|
|
211
|
+
data = newData;
|
|
212
|
+
let patternIndex;
|
|
213
|
+
while ((patternIndex = (0, line_1.findDoubleNewlineIndex)(data)) !== -1) {
|
|
214
|
+
yield data.slice(0, patternIndex);
|
|
215
|
+
data = data.slice(patternIndex);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (data.length > 0) {
|
|
219
|
+
yield data;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
class SSEDecoder {
|
|
223
|
+
constructor() {
|
|
224
|
+
this.event = null;
|
|
225
|
+
this.data = [];
|
|
226
|
+
this.chunks = [];
|
|
227
|
+
}
|
|
228
|
+
decode(line) {
|
|
229
|
+
if (line.endsWith('\r')) {
|
|
230
|
+
line = line.substring(0, line.length - 1);
|
|
231
|
+
}
|
|
232
|
+
if (!line) {
|
|
233
|
+
// empty line and we didn't previously encounter any messages
|
|
234
|
+
if (!this.event && !this.data.length)
|
|
235
|
+
return null;
|
|
236
|
+
const sse = {
|
|
237
|
+
event: this.event,
|
|
238
|
+
data: this.data.join('\n'),
|
|
239
|
+
raw: this.chunks,
|
|
240
|
+
};
|
|
241
|
+
this.event = null;
|
|
242
|
+
this.data = [];
|
|
243
|
+
this.chunks = [];
|
|
244
|
+
return sse;
|
|
245
|
+
}
|
|
246
|
+
this.chunks.push(line);
|
|
247
|
+
if (line.startsWith(':')) {
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
let [fieldname, _, value] = partition(line, ':');
|
|
251
|
+
if (value.startsWith(' ')) {
|
|
252
|
+
value = value.substring(1);
|
|
253
|
+
}
|
|
254
|
+
if (fieldname === 'event') {
|
|
255
|
+
this.event = value;
|
|
256
|
+
}
|
|
257
|
+
else if (fieldname === 'data') {
|
|
258
|
+
this.data.push(value);
|
|
259
|
+
}
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function partition(str, delimiter) {
|
|
264
|
+
const index = str.indexOf(delimiter);
|
|
265
|
+
if (index !== -1) {
|
|
266
|
+
return [str.substring(0, index), delimiter, str.substring(index + delimiter.length)];
|
|
267
|
+
}
|
|
268
|
+
return [str, '', ''];
|
|
269
|
+
}
|
|
270
|
+
//# sourceMappingURL=streaming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.js","sourceRoot":"","sources":["../src/core/streaming.ts"],"names":[],"mappings":";AAAA,kDAAkD;AAClD,EAAE;AACF,sCAAsC;;;;AAmMtC,4CAgCC;;AAjOD,sFAAsF;AAEtF,sCAA+C;AAE/C,gDAAuD;AACvD,uDAAgF;AAChF,gDAAkE;AAClE,kDAAkD;AAClD,sDAAqD;AACrD,kDAAkD;AAWlD,MAAa,MAAM;IAIjB,YACU,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0 +1,265 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Xquik contributors
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
var _Stream_client;
|
|
5
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "../internal/tslib.mjs";
|
|
6
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
7
|
+
import { XTwitterScraperError } from "./error.mjs";
|
|
8
|
+
import { makeReadableStream } from "../internal/shims.mjs";
|
|
9
|
+
import { findDoubleNewlineIndex, LineDecoder } from "../internal/decoders/line.mjs";
|
|
10
|
+
import { ReadableStreamToAsyncIterable } from "../internal/shims.mjs";
|
|
11
|
+
import { isAbortError } from "../internal/errors.mjs";
|
|
12
|
+
import { encodeUTF8 } from "../internal/utils/bytes.mjs";
|
|
13
|
+
import { loggerFor } from "../internal/utils/log.mjs";
|
|
14
|
+
export class Stream {
|
|
15
|
+
constructor(iterator, controller, client) {
|
|
16
|
+
this.iterator = iterator;
|
|
17
|
+
_Stream_client.set(this, void 0);
|
|
18
|
+
this.controller = controller;
|
|
19
|
+
__classPrivateFieldSet(this, _Stream_client, client, "f");
|
|
20
|
+
}
|
|
21
|
+
static fromSSEResponse(response, controller, client) {
|
|
22
|
+
let consumed = false;
|
|
23
|
+
const logger = client ? loggerFor(client) : console;
|
|
24
|
+
async function* iterator() {
|
|
25
|
+
if (consumed) {
|
|
26
|
+
throw new XTwitterScraperError('Cannot iterate over a consumed stream, use `.tee()` to split the stream.');
|
|
27
|
+
}
|
|
28
|
+
consumed = true;
|
|
29
|
+
let done = false;
|
|
30
|
+
try {
|
|
31
|
+
for await (const sse of _iterSSEMessages(response, controller)) {
|
|
32
|
+
// Each event is named by its type, so every event with data is yielded.
|
|
33
|
+
if (!sse.data)
|
|
34
|
+
continue;
|
|
35
|
+
try {
|
|
36
|
+
yield JSON.parse(sse.data);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
logger.error(`Could not parse message into JSON:`, sse.data);
|
|
40
|
+
logger.error(`From chunk:`, sse.raw);
|
|
41
|
+
throw e;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
done = true;
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
// If the user calls `stream.controller.abort()`, we should exit without throwing.
|
|
48
|
+
if (isAbortError(e))
|
|
49
|
+
return;
|
|
50
|
+
throw e;
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
// If the user `break`s, abort the ongoing request.
|
|
54
|
+
if (!done)
|
|
55
|
+
controller.abort();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return new Stream(iterator, controller, client);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Generates a Stream from a newline-separated ReadableStream
|
|
62
|
+
* where each item is a JSON value.
|
|
63
|
+
*/
|
|
64
|
+
static fromReadableStream(readableStream, controller, client) {
|
|
65
|
+
let consumed = false;
|
|
66
|
+
async function* iterLines() {
|
|
67
|
+
const lineDecoder = new LineDecoder();
|
|
68
|
+
const iter = ReadableStreamToAsyncIterable(readableStream);
|
|
69
|
+
for await (const chunk of iter) {
|
|
70
|
+
for (const line of lineDecoder.decode(chunk)) {
|
|
71
|
+
yield line;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
for (const line of lineDecoder.flush()) {
|
|
75
|
+
yield line;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function* iterator() {
|
|
79
|
+
if (consumed) {
|
|
80
|
+
throw new XTwitterScraperError('Cannot iterate over a consumed stream, use `.tee()` to split the stream.');
|
|
81
|
+
}
|
|
82
|
+
consumed = true;
|
|
83
|
+
let done = false;
|
|
84
|
+
try {
|
|
85
|
+
for await (const line of iterLines()) {
|
|
86
|
+
if (done)
|
|
87
|
+
continue;
|
|
88
|
+
if (line)
|
|
89
|
+
yield JSON.parse(line);
|
|
90
|
+
}
|
|
91
|
+
done = true;
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
// If the user calls `stream.controller.abort()`, we should exit without throwing.
|
|
95
|
+
if (isAbortError(e))
|
|
96
|
+
return;
|
|
97
|
+
throw e;
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
// If the user `break`s, abort the ongoing request.
|
|
101
|
+
if (!done)
|
|
102
|
+
controller.abort();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return new Stream(iterator, controller, client);
|
|
106
|
+
}
|
|
107
|
+
[(_Stream_client = new WeakMap(), Symbol.asyncIterator)]() {
|
|
108
|
+
return this.iterator();
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Splits the stream into two streams which can be
|
|
112
|
+
* independently read from at different speeds.
|
|
113
|
+
*/
|
|
114
|
+
tee() {
|
|
115
|
+
const left = [];
|
|
116
|
+
const right = [];
|
|
117
|
+
const iterator = this.iterator();
|
|
118
|
+
const teeIterator = (queue) => {
|
|
119
|
+
return {
|
|
120
|
+
next: () => {
|
|
121
|
+
if (queue.length === 0) {
|
|
122
|
+
const result = iterator.next();
|
|
123
|
+
left.push(result);
|
|
124
|
+
right.push(result);
|
|
125
|
+
}
|
|
126
|
+
return queue.shift();
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
return [
|
|
131
|
+
new Stream(() => teeIterator(left), this.controller, __classPrivateFieldGet(this, _Stream_client, "f")),
|
|
132
|
+
new Stream(() => teeIterator(right), this.controller, __classPrivateFieldGet(this, _Stream_client, "f")),
|
|
133
|
+
];
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Converts this stream to a newline-separated ReadableStream of
|
|
137
|
+
* JSON stringified values in the stream
|
|
138
|
+
* which can be turned back into a Stream with `Stream.fromReadableStream()`.
|
|
139
|
+
*/
|
|
140
|
+
toReadableStream() {
|
|
141
|
+
const self = this;
|
|
142
|
+
let iter;
|
|
143
|
+
return makeReadableStream({
|
|
144
|
+
async start() {
|
|
145
|
+
iter = self[Symbol.asyncIterator]();
|
|
146
|
+
},
|
|
147
|
+
async pull(ctrl) {
|
|
148
|
+
try {
|
|
149
|
+
const { value, done } = await iter.next();
|
|
150
|
+
if (done)
|
|
151
|
+
return ctrl.close();
|
|
152
|
+
const bytes = encodeUTF8(JSON.stringify(value) + '\n');
|
|
153
|
+
ctrl.enqueue(bytes);
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
ctrl.error(err);
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
async cancel() {
|
|
160
|
+
await iter.return?.();
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
export async function* _iterSSEMessages(response, controller) {
|
|
166
|
+
if (!response.body) {
|
|
167
|
+
controller.abort();
|
|
168
|
+
if (typeof globalThis.navigator !== 'undefined' &&
|
|
169
|
+
globalThis.navigator.product === 'ReactNative') {
|
|
170
|
+
throw new XTwitterScraperError(`The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api`);
|
|
171
|
+
}
|
|
172
|
+
throw new XTwitterScraperError(`Attempted to iterate over a response with no body`);
|
|
173
|
+
}
|
|
174
|
+
const sseDecoder = new SSEDecoder();
|
|
175
|
+
const lineDecoder = new LineDecoder();
|
|
176
|
+
const iter = ReadableStreamToAsyncIterable(response.body);
|
|
177
|
+
for await (const sseChunk of iterSSEChunks(iter)) {
|
|
178
|
+
for (const line of lineDecoder.decode(sseChunk)) {
|
|
179
|
+
const sse = sseDecoder.decode(line);
|
|
180
|
+
if (sse)
|
|
181
|
+
yield sse;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
for (const line of lineDecoder.flush()) {
|
|
185
|
+
const sse = sseDecoder.decode(line);
|
|
186
|
+
if (sse)
|
|
187
|
+
yield sse;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Given an async iterable iterator, iterates over it and yields full
|
|
192
|
+
* SSE chunks, i.e. yields when a double new-line is encountered.
|
|
193
|
+
*/
|
|
194
|
+
async function* iterSSEChunks(iterator) {
|
|
195
|
+
let data = new Uint8Array();
|
|
196
|
+
for await (const chunk of iterator) {
|
|
197
|
+
if (chunk == null) {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
const binaryChunk = chunk instanceof ArrayBuffer ? new Uint8Array(chunk)
|
|
201
|
+
: typeof chunk === 'string' ? encodeUTF8(chunk)
|
|
202
|
+
: chunk;
|
|
203
|
+
let newData = new Uint8Array(data.length + binaryChunk.length);
|
|
204
|
+
newData.set(data);
|
|
205
|
+
newData.set(binaryChunk, data.length);
|
|
206
|
+
data = newData;
|
|
207
|
+
let patternIndex;
|
|
208
|
+
while ((patternIndex = findDoubleNewlineIndex(data)) !== -1) {
|
|
209
|
+
yield data.slice(0, patternIndex);
|
|
210
|
+
data = data.slice(patternIndex);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (data.length > 0) {
|
|
214
|
+
yield data;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
class SSEDecoder {
|
|
218
|
+
constructor() {
|
|
219
|
+
this.event = null;
|
|
220
|
+
this.data = [];
|
|
221
|
+
this.chunks = [];
|
|
222
|
+
}
|
|
223
|
+
decode(line) {
|
|
224
|
+
if (line.endsWith('\r')) {
|
|
225
|
+
line = line.substring(0, line.length - 1);
|
|
226
|
+
}
|
|
227
|
+
if (!line) {
|
|
228
|
+
// empty line and we didn't previously encounter any messages
|
|
229
|
+
if (!this.event && !this.data.length)
|
|
230
|
+
return null;
|
|
231
|
+
const sse = {
|
|
232
|
+
event: this.event,
|
|
233
|
+
data: this.data.join('\n'),
|
|
234
|
+
raw: this.chunks,
|
|
235
|
+
};
|
|
236
|
+
this.event = null;
|
|
237
|
+
this.data = [];
|
|
238
|
+
this.chunks = [];
|
|
239
|
+
return sse;
|
|
240
|
+
}
|
|
241
|
+
this.chunks.push(line);
|
|
242
|
+
if (line.startsWith(':')) {
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
let [fieldname, _, value] = partition(line, ':');
|
|
246
|
+
if (value.startsWith(' ')) {
|
|
247
|
+
value = value.substring(1);
|
|
248
|
+
}
|
|
249
|
+
if (fieldname === 'event') {
|
|
250
|
+
this.event = value;
|
|
251
|
+
}
|
|
252
|
+
else if (fieldname === 'data') {
|
|
253
|
+
this.data.push(value);
|
|
254
|
+
}
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
function partition(str, delimiter) {
|
|
259
|
+
const index = str.indexOf(delimiter);
|
|
260
|
+
if (index !== -1) {
|
|
261
|
+
return [str.substring(0, index), delimiter, str.substring(index + delimiter.length)];
|
|
262
|
+
}
|
|
263
|
+
return [str, '', ''];
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=streaming.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming.mjs","sourceRoot":"","sources":["../src/core/streaming.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,EAAE;AACF,sCAAsC;;;AAEtC,sFAAsF;AAEtF,OAAO,EAAE,oBAAoB,EAAE,oBAAgB;AAE/C,OAAO,EAAE,kBAAkB,EAAE,8BAA0B;AACvD,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,sCAAkC;AAChF,OAAO,EAAE,6BAA6B,EAAE,8BAA0B;AAClE,OAAO,EAAE,YAAY,EAAE,+BAA2B;AAClD,OAAO,EAAE,UAAU,EAAE,oCAAgC;AACrD,OAAO,EAAE,SAAS,EAAE,kCAA8B;AAWlD,MAAM,OAAO,MAAM;IAIjB,YACU,QAAmC,EAC3C,UAA2B,EAC3B,MAAwB;QAFhB,aAAQ,GAAR,QAAQ,CAA2B;QAH7C,iCAAqC;QAOnC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,uBAAA,IAAI,kBAAW,MAAM,MAAA,CAAC;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vB,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,CAAC,SAAS,EAAE,CAAC,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAEjD,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC1B,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC;QAED,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;YAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;aAAM,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;YAChC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,SAAS,SAAS,CAAC,GAAW,EAAE,SAAiB;IAC/C,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IACvF,CAAC;IAED,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type Bytes = string | ArrayBuffer | Uint8Array | null | undefined;
|
|
2
|
+
/**
|
|
3
|
+
* A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
|
|
4
|
+
* reading lines from text.
|
|
5
|
+
*
|
|
6
|
+
* https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
|
|
7
|
+
*/
|
|
8
|
+
export declare class LineDecoder {
|
|
9
|
+
#private;
|
|
10
|
+
static NEWLINE_CHARS: Set<string>;
|
|
11
|
+
static NEWLINE_REGEXP: RegExp;
|
|
12
|
+
constructor();
|
|
13
|
+
decode(chunk: Bytes): string[];
|
|
14
|
+
flush(): string[];
|
|
15
|
+
}
|
|
16
|
+
export declare function findDoubleNewlineIndex(buffer: Uint8Array): number;
|
|
17
|
+
//# sourceMappingURL=line.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line.d.mts","sourceRoot":"","sources":["../../src/internal/decoders/line.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;AAEzE;;;;;GAKG;AACH,qBAAa,WAAW;;IACtB,MAAM,CAAC,aAAa,cAAyB;IAC7C,MAAM,CAAC,cAAc,SAAkB;;IAUvC,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE;IA6C9B,KAAK,IAAI,MAAM,EAAE;CAMlB;AA+BD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CA6BjE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type Bytes = string | ArrayBuffer | Uint8Array | null | undefined;
|
|
2
|
+
/**
|
|
3
|
+
* A re-implementation of httpx's `LineDecoder` in Python that handles incrementally
|
|
4
|
+
* reading lines from text.
|
|
5
|
+
*
|
|
6
|
+
* https://github.com/encode/httpx/blob/920333ea98118e9cf617f246905d7b202510941c/httpx/_decoders.py#L258
|
|
7
|
+
*/
|
|
8
|
+
export declare class LineDecoder {
|
|
9
|
+
#private;
|
|
10
|
+
static NEWLINE_CHARS: Set<string>;
|
|
11
|
+
static NEWLINE_REGEXP: RegExp;
|
|
12
|
+
constructor();
|
|
13
|
+
decode(chunk: Bytes): string[];
|
|
14
|
+
flush(): string[];
|
|
15
|
+
}
|
|
16
|
+
export declare function findDoubleNewlineIndex(buffer: Uint8Array): number;
|
|
17
|
+
//# sourceMappingURL=line.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../src/internal/decoders/line.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;AAEzE;;;;;GAKG;AACH,qBAAa,WAAW;;IACtB,MAAM,CAAC,aAAa,cAAyB;IAC7C,MAAM,CAAC,cAAc,SAAkB;;IAUvC,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE;IA6C9B,KAAK,IAAI,MAAM,EAAE;CAMlB;AA+BD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CA6BjE"}
|