@stackframe/stack-shared 2.8.7 → 2.8.10
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 +10 -0
- package/dist/config/format.d.cts +39 -0
- package/dist/config/format.d.ts +14 -13
- package/dist/config/format.js +147 -206
- package/dist/config/format.js.map +1 -0
- package/dist/config/schema.d.cts +724 -0
- package/dist/config/schema.d.ts +51 -48
- package/dist/config/schema.js +230 -172
- package/dist/config/schema.js.map +1 -0
- package/dist/crud.d.cts +102 -0
- package/dist/crud.d.ts +15 -13
- package/dist/crud.js +83 -128
- package/dist/crud.js.map +1 -0
- package/dist/esm/config/format.js +135 -0
- package/dist/esm/config/format.js.map +1 -0
- package/dist/esm/config/schema.js +199 -0
- package/dist/esm/config/schema.js.map +1 -0
- package/dist/esm/crud.js +60 -0
- package/dist/esm/crud.js.map +1 -0
- package/dist/esm/global.d.js +1 -0
- package/dist/esm/global.d.js.map +1 -0
- package/dist/esm/helpers/password.js +17 -0
- package/dist/esm/helpers/password.js.map +1 -0
- package/dist/esm/helpers/production-mode.js +50 -0
- package/dist/esm/helpers/production-mode.js.map +1 -0
- package/dist/esm/hooks/use-async-callback.js +38 -0
- package/dist/esm/hooks/use-async-callback.js.map +1 -0
- package/dist/esm/hooks/use-async-external-store.js +23 -0
- package/dist/esm/hooks/use-async-external-store.js.map +1 -0
- package/dist/esm/hooks/use-hash.js +17 -0
- package/dist/esm/hooks/use-hash.js.map +1 -0
- package/dist/esm/hooks/use-strict-memo.js +61 -0
- package/dist/esm/hooks/use-strict-memo.js.map +1 -0
- package/dist/esm/index.js +22 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/interface/adminInterface.js +244 -0
- package/dist/esm/interface/adminInterface.js.map +1 -0
- package/dist/esm/interface/clientInterface.js +2041 -0
- package/dist/esm/interface/clientInterface.js.map +1 -0
- package/dist/esm/interface/crud/contact-channels.js +77 -0
- package/dist/esm/interface/crud/contact-channels.js.map +1 -0
- package/dist/esm/interface/crud/current-user.js +65 -0
- package/dist/esm/interface/crud/current-user.js.map +1 -0
- package/dist/esm/interface/crud/email-templates.js +52 -0
- package/dist/esm/interface/crud/email-templates.js.map +1 -0
- package/dist/esm/interface/crud/emails.js +20 -0
- package/dist/esm/interface/crud/emails.js.map +1 -0
- package/dist/esm/interface/crud/internal-api-keys.js +69 -0
- package/dist/esm/interface/crud/internal-api-keys.js.map +1 -0
- package/dist/esm/interface/crud/oauth.js +24 -0
- package/dist/esm/interface/crud/oauth.js.map +1 -0
- package/dist/esm/interface/crud/project-api-keys.js +93 -0
- package/dist/esm/interface/crud/project-api-keys.js.map +1 -0
- package/dist/esm/interface/crud/project-permissions.js +113 -0
- package/dist/esm/interface/crud/project-permissions.js.map +1 -0
- package/dist/esm/interface/crud/projects.js +188 -0
- package/dist/esm/interface/crud/projects.js.map +1 -0
- package/dist/esm/interface/crud/sessions.js +62 -0
- package/dist/esm/interface/crud/sessions.js.map +1 -0
- package/dist/esm/interface/crud/svix-token.js +22 -0
- package/dist/esm/interface/crud/svix-token.js.map +1 -0
- package/dist/esm/interface/crud/team-invitation-details.js +23 -0
- package/dist/esm/interface/crud/team-invitation-details.js.map +1 -0
- package/dist/esm/interface/crud/team-invitation.js +36 -0
- package/dist/esm/interface/crud/team-invitation.js.map +1 -0
- package/dist/esm/interface/crud/team-member-profiles.js +62 -0
- package/dist/esm/interface/crud/team-member-profiles.js.map +1 -0
- package/dist/esm/interface/crud/team-memberships.js +60 -0
- package/dist/esm/interface/crud/team-memberships.js.map +1 -0
- package/dist/esm/interface/crud/team-permissions.js +114 -0
- package/dist/esm/interface/crud/team-permissions.js.map +1 -0
- package/dist/esm/interface/crud/teams.js +143 -0
- package/dist/esm/interface/crud/teams.js.map +1 -0
- package/dist/esm/interface/crud/users.js +139 -0
- package/dist/esm/interface/crud/users.js.map +1 -0
- package/dist/esm/interface/serverInterface.js +485 -0
- package/dist/esm/interface/serverInterface.js.map +1 -0
- package/dist/esm/interface/webhooks.js +21 -0
- package/dist/esm/interface/webhooks.js.map +1 -0
- package/dist/esm/known-errors.js +1223 -0
- package/dist/esm/known-errors.js.map +1 -0
- package/dist/esm/schema-fields.js +484 -0
- package/dist/esm/schema-fields.js.map +1 -0
- package/dist/esm/sessions.js +168 -0
- package/dist/esm/sessions.js.map +1 -0
- package/dist/esm/utils/api-keys.js +79 -0
- package/dist/esm/utils/api-keys.js.map +1 -0
- package/dist/esm/utils/arrays.js +78 -0
- package/dist/esm/utils/arrays.js.map +1 -0
- package/dist/esm/utils/base64.js +18 -0
- package/dist/esm/utils/base64.js.map +1 -0
- package/dist/esm/utils/booleans.js +12 -0
- package/dist/esm/utils/booleans.js.map +1 -0
- package/dist/esm/utils/browser-compat.js +21 -0
- package/dist/esm/utils/browser-compat.js.map +1 -0
- package/dist/esm/utils/bytes.js +160 -0
- package/dist/esm/utils/bytes.js.map +1 -0
- package/dist/esm/utils/caches.js +167 -0
- package/dist/esm/utils/caches.js.map +1 -0
- package/dist/esm/utils/compile-time.js +11 -0
- package/dist/esm/utils/compile-time.js.map +1 -0
- package/dist/esm/utils/crypto.js +25 -0
- package/dist/esm/utils/crypto.js.map +1 -0
- package/dist/esm/utils/dates.js +64 -0
- package/dist/esm/utils/dates.js.map +1 -0
- package/dist/esm/utils/dom.js +11 -0
- package/dist/esm/utils/dom.js.map +1 -0
- package/dist/esm/utils/env.js +58 -0
- package/dist/esm/utils/env.js.map +1 -0
- package/dist/esm/utils/errors.js +174 -0
- package/dist/esm/utils/errors.js.map +1 -0
- package/dist/esm/utils/fs.js +37 -0
- package/dist/esm/utils/fs.js.map +1 -0
- package/dist/esm/utils/functions.js +12 -0
- package/dist/esm/utils/functions.js.map +1 -0
- package/dist/esm/utils/geo.js +15 -0
- package/dist/esm/utils/geo.js.map +1 -0
- package/dist/esm/utils/globals.js +18 -0
- package/dist/esm/utils/globals.js.map +1 -0
- package/dist/esm/utils/hashes.js +55 -0
- package/dist/esm/utils/hashes.js.map +1 -0
- package/dist/esm/utils/html.js +13 -0
- package/dist/esm/utils/html.js.map +1 -0
- package/dist/esm/utils/http.js +60 -0
- package/dist/esm/utils/http.js.map +1 -0
- package/dist/esm/utils/ips.js +15 -0
- package/dist/esm/utils/ips.js.map +1 -0
- package/dist/esm/utils/json.js +31 -0
- package/dist/esm/utils/json.js.map +1 -0
- package/dist/esm/utils/jwt.js +87 -0
- package/dist/esm/utils/jwt.js.map +1 -0
- package/dist/esm/utils/locks.js +57 -0
- package/dist/esm/utils/locks.js.map +1 -0
- package/dist/esm/utils/maps.js +181 -0
- package/dist/esm/utils/maps.js.map +1 -0
- package/dist/esm/utils/math.js +8 -0
- package/dist/esm/utils/math.js.map +1 -0
- package/dist/esm/utils/node-http.js +42 -0
- package/dist/esm/utils/node-http.js.map +1 -0
- package/dist/esm/utils/numbers.js +32 -0
- package/dist/esm/utils/numbers.js.map +1 -0
- package/dist/esm/utils/oauth.js +10 -0
- package/dist/esm/utils/oauth.js.map +1 -0
- package/dist/esm/utils/objects.js +153 -0
- package/dist/esm/utils/objects.js.map +1 -0
- package/dist/esm/utils/passkey.js +1 -0
- package/dist/esm/utils/passkey.js.map +1 -0
- package/dist/esm/utils/promises.js +233 -0
- package/dist/esm/utils/promises.js.map +1 -0
- package/dist/esm/utils/proxies.js +128 -0
- package/dist/esm/utils/proxies.js.map +1 -0
- package/dist/esm/utils/react.js +78 -0
- package/dist/esm/utils/react.js.map +1 -0
- package/dist/esm/utils/results.js +141 -0
- package/dist/esm/utils/results.js.map +1 -0
- package/dist/esm/utils/sentry.js +20 -0
- package/dist/esm/utils/sentry.js.map +1 -0
- package/dist/esm/utils/stores.js +195 -0
- package/dist/esm/utils/stores.js.map +1 -0
- package/dist/esm/utils/strings.js +294 -0
- package/dist/esm/utils/strings.js.map +1 -0
- package/dist/esm/utils/strings.nicify.test.js +222 -0
- package/dist/esm/utils/strings.nicify.test.js.map +1 -0
- package/dist/esm/utils/types.js +1 -0
- package/dist/esm/utils/types.js.map +1 -0
- package/dist/esm/utils/unicode.js +11 -0
- package/dist/esm/utils/unicode.js.map +1 -0
- package/dist/esm/utils/urls.js +53 -0
- package/dist/esm/utils/urls.js.map +1 -0
- package/dist/esm/utils/uuids.js +16 -0
- package/dist/esm/utils/uuids.js.map +1 -0
- package/dist/global.d.d.cts +1 -0
- package/dist/global.d.d.ts +1 -0
- package/dist/global.d.js +2 -0
- package/dist/global.d.js.map +1 -0
- package/dist/helpers/password.d.cts +11 -0
- package/dist/helpers/password.d.ts +11 -2
- package/dist/helpers/password.js +41 -11
- package/dist/helpers/password.js.map +1 -0
- package/dist/helpers/production-mode.d.cts +12 -0
- package/dist/helpers/production-mode.d.ts +9 -3
- package/dist/helpers/production-mode.js +72 -45
- package/dist/helpers/production-mode.js.map +1 -0
- package/dist/hooks/use-async-callback.d.cts +6 -0
- package/dist/hooks/use-async-callback.d.ts +6 -3
- package/dist/hooks/use-async-callback.js +72 -30
- package/dist/hooks/use-async-callback.js.map +1 -0
- package/dist/hooks/use-async-external-store.d.cts +7 -0
- package/dist/hooks/use-async-external-store.d.ts +5 -2
- package/dist/hooks/use-async-external-store.js +47 -19
- package/dist/hooks/use-async-external-store.js.map +1 -0
- package/dist/hooks/use-hash.d.cts +3 -0
- package/dist/hooks/use-hash.d.ts +3 -1
- package/dist/hooks/use-hash.js +41 -8
- package/dist/hooks/use-hash.js.map +1 -0
- package/dist/hooks/use-strict-memo.d.cts +8 -0
- package/dist/hooks/use-strict-memo.d.ts +3 -1
- package/dist/hooks/use-strict-memo.js +78 -131
- package/dist/hooks/use-strict-memo.js.map +1 -0
- package/dist/index.d.cts +30 -0
- package/dist/index.d.ts +30 -4
- package/dist/index.js +42 -4
- package/dist/index.js.map +1 -0
- package/dist/interface/adminInterface.d.cts +94 -0
- package/dist/interface/adminInterface.d.ts +38 -15
- package/dist/interface/adminInterface.js +269 -174
- package/dist/interface/adminInterface.js.map +1 -0
- package/dist/interface/clientInterface.d.cts +260 -0
- package/dist/interface/clientInterface.d.ts +25 -18
- package/dist/interface/clientInterface.js +2054 -995
- package/dist/interface/clientInterface.js.map +1 -0
- package/dist/interface/crud/contact-channels.d.cts +180 -0
- package/dist/interface/crud/contact-channels.d.ts +30 -25
- package/dist/interface/crud/contact-channels.js +101 -59
- package/dist/interface/crud/contact-channels.js.map +1 -0
- package/dist/interface/crud/current-user.d.cts +205 -0
- package/dist/interface/crud/current-user.d.ts +17 -12
- package/dist/interface/crud/current-user.js +86 -56
- package/dist/interface/crud/current-user.js.map +1 -0
- package/dist/interface/crud/email-templates.d.cts +84 -0
- package/dist/interface/crud/email-templates.d.ts +24 -19
- package/dist/interface/crud/email-templates.js +77 -37
- package/dist/interface/crud/email-templates.js.map +1 -0
- package/dist/interface/crud/emails.d.cts +69 -0
- package/dist/interface/crud/emails.d.ts +12 -7
- package/dist/interface/crud/emails.js +54 -12
- package/dist/interface/crud/emails.js.map +1 -0
- package/dist/interface/crud/internal-api-keys.d.cts +139 -0
- package/dist/interface/crud/internal-api-keys.d.ts +22 -17
- package/dist/interface/crud/internal-api-keys.js +92 -54
- package/dist/interface/crud/internal-api-keys.js.map +1 -0
- package/dist/interface/crud/oauth.d.cts +34 -0
- package/dist/interface/crud/oauth.d.ts +16 -11
- package/dist/interface/crud/oauth.js +48 -14
- package/dist/interface/crud/oauth.js.map +1 -0
- package/dist/interface/crud/project-api-keys.d.cts +196 -0
- package/dist/interface/crud/project-api-keys.d.ts +18 -10
- package/dist/interface/crud/project-api-keys.js +121 -74
- package/dist/interface/crud/project-api-keys.js.map +1 -0
- package/dist/interface/crud/project-permissions.d.cts +160 -0
- package/dist/interface/crud/project-permissions.d.ts +38 -33
- package/dist/interface/crud/project-permissions.js +148 -90
- package/dist/interface/crud/project-permissions.js.map +1 -0
- package/dist/interface/crud/projects.d.cts +640 -0
- package/dist/interface/crud/projects.d.ts +36 -31
- package/dist/interface/crud/projects.js +218 -156
- package/dist/interface/crud/projects.js.map +1 -0
- package/dist/interface/crud/sessions.d.cts +149 -0
- package/dist/interface/crud/sessions.d.ts +21 -16
- package/dist/interface/crud/sessions.js +86 -50
- package/dist/interface/crud/sessions.js.map +1 -0
- package/dist/interface/crud/svix-token.d.cts +26 -0
- package/dist/interface/crud/svix-token.d.ts +14 -9
- package/dist/interface/crud/svix-token.js +46 -12
- package/dist/interface/crud/svix-token.js.map +1 -0
- package/dist/interface/crud/team-invitation-details.d.cts +30 -0
- package/dist/interface/crud/team-invitation-details.d.ts +12 -7
- package/dist/interface/crud/team-invitation-details.js +57 -15
- package/dist/interface/crud/team-invitation-details.js.map +1 -0
- package/dist/interface/crud/team-invitation.d.cts +49 -0
- package/dist/interface/crud/team-invitation.d.ts +13 -8
- package/dist/interface/crud/team-invitation.js +69 -27
- package/dist/interface/crud/team-invitation.js.map +1 -0
- package/dist/interface/crud/team-member-profiles.d.cts +229 -0
- package/dist/interface/crud/team-member-profiles.d.ts +20 -15
- package/dist/interface/crud/team-member-profiles.js +95 -49
- package/dist/interface/crud/team-member-profiles.js.map +1 -0
- package/dist/interface/crud/team-memberships.d.cts +74 -0
- package/dist/interface/crud/team-memberships.d.ts +22 -17
- package/dist/interface/crud/team-memberships.js +85 -45
- package/dist/interface/crud/team-memberships.js.map +1 -0
- package/dist/interface/crud/team-permissions.d.cts +168 -0
- package/dist/interface/crud/team-permissions.d.ts +38 -33
- package/dist/interface/crud/team-permissions.js +149 -91
- package/dist/interface/crud/team-permissions.js.map +1 -0
- package/dist/interface/crud/teams.d.cts +298 -0
- package/dist/interface/crud/teams.d.ts +45 -40
- package/dist/interface/crud/teams.js +177 -119
- package/dist/interface/crud/teams.js.map +1 -0
- package/dist/interface/crud/users.d.cts +469 -0
- package/dist/interface/crud/users.d.ts +31 -26
- package/dist/interface/crud/users.js +172 -118
- package/dist/interface/crud/users.js.map +1 -0
- package/dist/interface/serverInterface.d.cts +128 -0
- package/dist/interface/serverInterface.d.ts +29 -17
- package/dist/interface/serverInterface.js +506 -339
- package/dist/interface/serverInterface.js.map +1 -0
- package/dist/interface/webhooks.d.cts +292 -0
- package/dist/interface/webhooks.d.ts +6 -3
- package/dist/interface/webhooks.js +45 -15
- package/dist/interface/webhooks.js.map +1 -0
- package/dist/known-errors.d.cts +444 -0
- package/dist/known-errors.d.ts +12 -9
- package/dist/known-errors.js +1088 -561
- package/dist/known-errors.js.map +1 -0
- package/dist/schema-fields.d.cts +163 -0
- package/dist/schema-fields.d.ts +116 -114
- package/dist/schema-fields.js +593 -427
- package/dist/schema-fields.js.map +1 -0
- package/dist/sessions.d.cts +109 -0
- package/dist/sessions.d.ts +6 -3
- package/dist/sessions.js +201 -172
- package/dist/sessions.js.map +1 -0
- package/dist/utils/api-keys.d.cts +24 -0
- package/dist/utils/api-keys.d.ts +5 -4
- package/dist/utils/api-keys.js +106 -66
- package/dist/utils/api-keys.js.map +1 -0
- package/dist/utils/arrays.d.cts +18 -0
- package/dist/utils/arrays.d.ts +15 -13
- package/dist/utils/arrays.js +101 -168
- package/dist/utils/arrays.js.map +1 -0
- package/dist/utils/base64.d.cts +4 -0
- package/dist/utils/base64.d.ts +4 -2
- package/dist/utils/base64.js +41 -20
- package/dist/utils/base64.js.map +1 -0
- package/dist/utils/booleans.d.cts +6 -0
- package/dist/utils/booleans.d.ts +6 -4
- package/dist/utils/booleans.js +35 -27
- package/dist/utils/booleans.js.map +1 -0
- package/dist/utils/browser-compat.d.cts +8 -0
- package/dist/utils/browser-compat.d.ts +3 -1
- package/dist/utils/browser-compat.js +45 -16
- package/dist/utils/browser-compat.js.map +1 -0
- package/dist/utils/bytes.d.cts +15 -0
- package/dist/utils/bytes.d.ts +15 -13
- package/dist/utils/bytes.js +182 -270
- package/dist/utils/bytes.js.map +1 -0
- package/dist/utils/caches.d.cts +98 -0
- package/dist/utils/caches.d.ts +17 -14
- package/dist/utils/caches.js +188 -193
- package/dist/utils/caches.js.map +1 -0
- package/dist/utils/compile-time.d.cts +8 -0
- package/dist/utils/compile-time.d.ts +3 -1
- package/dist/utils/compile-time.js +35 -10
- package/dist/utils/compile-time.js.map +1 -0
- package/dist/utils/crypto.d.cts +8 -0
- package/dist/utils/crypto.d.ts +4 -2
- package/dist/utils/crypto.js +49 -21
- package/dist/utils/crypto.js.map +1 -0
- package/dist/utils/dates.d.cts +15 -0
- package/dist/utils/dates.d.ts +6 -4
- package/dist/utils/dates.js +83 -105
- package/dist/utils/dates.js.map +1 -0
- package/dist/utils/dom.d.cts +3 -0
- package/dist/utils/dom.d.ts +3 -1
- package/dist/utils/dom.js +35 -7
- package/dist/utils/dom.js.map +1 -0
- package/dist/utils/env.d.cts +9 -0
- package/dist/utils/env.d.ts +6 -4
- package/dist/utils/env.js +70 -43
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/errors.d.cts +223 -0
- package/dist/utils/errors.d.ts +14 -11
- package/dist/utils/errors.js +148 -126
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/fs.d.cts +7 -0
- package/dist/utils/fs.d.ts +5 -3
- package/dist/utils/fs.js +70 -27
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/functions.d.cts +4 -0
- package/dist/utils/functions.d.ts +4 -2
- package/dist/utils/functions.js +35 -18
- package/dist/utils/functions.js.map +1 -0
- package/dist/utils/geo.d.cts +22 -0
- package/dist/utils/geo.d.ts +6 -3
- package/dist/utils/geo.js +39 -9
- package/dist/utils/geo.js.map +1 -0
- package/dist/utils/globals.d.cts +5 -0
- package/dist/utils/globals.d.ts +4 -2
- package/dist/utils/globals.js +41 -14
- package/dist/utils/globals.js.map +1 -0
- package/dist/utils/hashes.d.cts +7 -0
- package/dist/utils/hashes.d.ts +7 -5
- package/dist/utils/hashes.js +87 -41
- package/dist/utils/hashes.js.map +1 -0
- package/dist/utils/html.d.cts +4 -0
- package/dist/utils/html.d.ts +4 -2
- package/dist/utils/html.js +36 -37
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/http.d.cts +43 -0
- package/dist/utils/http.d.ts +6 -4
- package/dist/utils/http.js +83 -83
- package/dist/utils/http.js.map +1 -0
- package/dist/utils/ips.d.cts +6 -0
- package/dist/utils/ips.d.ts +6 -4
- package/dist/utils/ips.js +48 -35
- package/dist/utils/ips.js.map +1 -0
- package/dist/utils/json.d.cts +13 -0
- package/dist/utils/json.d.ts +9 -6
- package/dist/utils/json.js +54 -157
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/jwt.d.cts +44 -0
- package/dist/utils/jwt.d.ts +14 -11
- package/dist/utils/jwt.js +119 -84
- package/dist/utils/jwt.js.map +1 -0
- package/dist/utils/locks.d.cts +15 -0
- package/dist/utils/locks.d.ts +3 -2
- package/dist/utils/locks.js +76 -56
- package/dist/utils/locks.js.map +1 -0
- package/dist/utils/maps.d.cts +59 -0
- package/dist/utils/maps.d.ts +6 -4
- package/dist/utils/maps.js +207 -343
- package/dist/utils/maps.js.map +1 -0
- package/dist/utils/math.d.cts +6 -0
- package/dist/utils/math.d.ts +3 -1
- package/dist/utils/math.js +31 -16
- package/dist/utils/math.js.map +1 -0
- package/dist/utils/node-http.d.cts +15 -0
- package/dist/utils/node-http.d.ts +5 -5
- package/dist/utils/node-http.js +65 -36
- package/dist/utils/node-http.js.map +1 -0
- package/dist/utils/numbers.d.cts +5 -0
- package/dist/utils/numbers.d.ts +5 -3
- package/dist/utils/numbers.js +53 -66
- package/dist/utils/numbers.js.map +1 -0
- package/dist/utils/oauth.d.cts +8 -0
- package/dist/utils/oauth.d.ts +8 -6
- package/dist/utils/oauth.js +37 -4
- package/dist/utils/oauth.js.map +1 -0
- package/dist/utils/objects.d.cts +65 -0
- package/dist/utils/objects.d.ts +31 -30
- package/dist/utils/objects.js +196 -374
- package/dist/utils/objects.js.map +1 -0
- package/dist/utils/passkey.d.cts +1 -0
- package/dist/utils/passkey.d.ts +1 -1
- package/dist/utils/passkey.js +19 -1
- package/dist/utils/passkey.js.map +1 -0
- package/dist/utils/promises.d.cts +74 -0
- package/dist/utils/promises.d.ts +20 -18
- package/dist/utils/promises.js +252 -393
- package/dist/utils/promises.js.map +1 -0
- package/dist/utils/proxies.d.cts +4 -0
- package/dist/utils/proxies.d.ts +4 -2
- package/dist/utils/proxies.js +150 -161
- package/dist/utils/proxies.js.map +1 -0
- package/dist/utils/react.d.cts +25 -0
- package/dist/utils/react.d.ts +9 -6
- package/dist/utils/react.js +88 -134
- package/dist/utils/react.js.map +1 -0
- package/dist/utils/results.d.cts +78 -0
- package/dist/utils/results.d.ts +10 -9
- package/dist/utils/results.js +143 -324
- package/dist/utils/results.js.map +1 -0
- package/dist/utils/sentry.d.cts +5 -0
- package/dist/utils/sentry.d.ts +5 -2
- package/dist/utils/sentry.js +44 -14
- package/dist/utils/sentry.js.map +1 -0
- package/dist/utils/stores.d.cts +102 -0
- package/dist/utils/stores.d.ts +12 -9
- package/dist/utils/stores.js +219 -189
- package/dist/utils/stores.js.map +1 -0
- package/dist/utils/strings.d.cts +72 -0
- package/dist/utils/strings.d.ts +22 -20
- package/dist/utils/strings.js +299 -580
- package/dist/utils/strings.js.map +1 -0
- package/dist/utils/strings.nicify.test.d.cts +2 -0
- package/dist/utils/strings.nicify.test.d.ts +2 -1
- package/dist/utils/strings.nicify.test.js +168 -158
- package/dist/utils/strings.nicify.test.js.map +1 -0
- package/dist/utils/types.d.cts +23 -0
- package/dist/utils/types.d.ts +8 -6
- package/dist/utils/types.js +19 -1
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/unicode.d.cts +3 -0
- package/dist/utils/unicode.d.ts +3 -1
- package/dist/utils/unicode.js +34 -21
- package/dist/utils/unicode.js.map +1 -0
- package/dist/utils/urls.d.cts +20 -0
- package/dist/utils/urls.d.ts +10 -8
- package/dist/utils/urls.js +76 -165
- package/dist/utils/urls.js.map +1 -0
- package/dist/utils/uuids.d.cts +4 -0
- package/dist/utils/uuids.d.ts +4 -2
- package/dist/utils/uuids.js +39 -35
- package/dist/utils/uuids.js.map +1 -0
- package/package.json +5 -5
package/dist/utils/strings.js
CHANGED
|
@@ -1,616 +1,335 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/strings.tsx
|
|
21
|
+
var strings_exports = {};
|
|
22
|
+
__export(strings_exports, {
|
|
23
|
+
deindent: () => deindent,
|
|
24
|
+
deindentTemplate: () => deindentTemplate,
|
|
25
|
+
escapeTemplateLiteral: () => escapeTemplateLiteral,
|
|
26
|
+
extractScopes: () => extractScopes,
|
|
27
|
+
getWhitespacePrefix: () => getWhitespacePrefix,
|
|
28
|
+
getWhitespaceSuffix: () => getWhitespaceSuffix,
|
|
29
|
+
mergeScopeStrings: () => mergeScopeStrings,
|
|
30
|
+
nicify: () => nicify,
|
|
31
|
+
replaceAll: () => replaceAll,
|
|
32
|
+
stringCompare: () => stringCompare,
|
|
33
|
+
templateIdentity: () => templateIdentity,
|
|
34
|
+
trimEmptyLinesEnd: () => trimEmptyLinesEnd,
|
|
35
|
+
trimEmptyLinesStart: () => trimEmptyLinesStart,
|
|
36
|
+
trimLines: () => trimLines,
|
|
37
|
+
typedCapitalize: () => typedCapitalize,
|
|
38
|
+
typedToLowercase: () => typedToLowercase,
|
|
39
|
+
typedToUppercase: () => typedToUppercase
|
|
18
40
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
41
|
+
module.exports = __toCommonJS(strings_exports);
|
|
42
|
+
var import_arrays = require("./arrays");
|
|
43
|
+
var import_errors = require("./errors");
|
|
44
|
+
var import_objects = require("./objects");
|
|
45
|
+
function typedToLowercase(s) {
|
|
46
|
+
if (typeof s !== "string") throw new import_errors.StackAssertionError("Expected a string for typedToLowercase", { s });
|
|
47
|
+
return s.toLowerCase();
|
|
23
48
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
expect(typedToUppercase("Hello World")).toBe("HELLO WORLD");
|
|
28
|
-
expect(typedToUppercase("HELLO")).toBe("HELLO");
|
|
29
|
-
expect(typedToUppercase("123")).toBe("123");
|
|
30
|
-
expect(typedToUppercase("mixed123Case")).toBe("MIXED123CASE");
|
|
31
|
-
expect(typedToUppercase("special@chars!")).toBe("SPECIAL@CHARS!");
|
|
32
|
-
expect(() => typedToUppercase(123)).toThrow("Expected a string for typedToUppercase");
|
|
33
|
-
});
|
|
34
|
-
export function typedCapitalize(s) {
|
|
35
|
-
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
49
|
+
function typedToUppercase(s) {
|
|
50
|
+
if (typeof s !== "string") throw new import_errors.StackAssertionError("Expected a string for typedToUppercase", { s });
|
|
51
|
+
return s.toUpperCase();
|
|
36
52
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
expect(typedCapitalize("hello")).toBe("Hello");
|
|
40
|
-
expect(typedCapitalize("hello world")).toBe("Hello world");
|
|
41
|
-
expect(typedCapitalize("HELLO")).toBe("HELLO");
|
|
42
|
-
expect(typedCapitalize("123test")).toBe("123test");
|
|
43
|
-
expect(typedCapitalize("already Capitalized")).toBe("Already Capitalized");
|
|
44
|
-
expect(typedCapitalize("h")).toBe("H");
|
|
45
|
-
});
|
|
46
|
-
/**
|
|
47
|
-
* Compares two strings in a way that is not dependent on the current locale.
|
|
48
|
-
*/
|
|
49
|
-
export function stringCompare(a, b) {
|
|
50
|
-
const cmp = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
51
|
-
return cmp(a.toUpperCase(), b.toUpperCase()) || cmp(b, a);
|
|
53
|
+
function typedCapitalize(s) {
|
|
54
|
+
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
52
55
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
expect(stringCompare("", "")).toBe(0);
|
|
57
|
-
// Case comparison - note that this function is NOT case-insensitive
|
|
58
|
-
// It compares uppercase versions first, then original strings
|
|
59
|
-
expect(stringCompare("a", "A")).toBe(-1); // lowercase comes after uppercase
|
|
60
|
-
expect(stringCompare("A", "a")).toBe(1); // uppercase comes before lowercase
|
|
61
|
-
expect(stringCompare("abc", "ABC")).toBe(-1);
|
|
62
|
-
expect(stringCompare("ABC", "abc")).toBe(1);
|
|
63
|
-
// Different strings
|
|
64
|
-
expect(stringCompare("a", "b")).toBe(-1);
|
|
65
|
-
expect(stringCompare("b", "a")).toBe(1);
|
|
66
|
-
// Strings with different lengths
|
|
67
|
-
expect(stringCompare("abc", "abcd")).toBe(-1);
|
|
68
|
-
expect(stringCompare("abcd", "abc")).toBe(1);
|
|
69
|
-
// Strings with numbers
|
|
70
|
-
expect(stringCompare("a1", "a2")).toBe(-1);
|
|
71
|
-
expect(stringCompare("a10", "a2")).toBe(-1);
|
|
72
|
-
// Strings with special characters
|
|
73
|
-
expect(stringCompare("a", "a!")).toBe(-1);
|
|
74
|
-
expect(stringCompare("a!", "a")).toBe(1);
|
|
75
|
-
});
|
|
76
|
-
/**
|
|
77
|
-
* Returns all whitespace character at the start of the string.
|
|
78
|
-
*
|
|
79
|
-
* Uses the same definition for whitespace as `String.prototype.trim()`.
|
|
80
|
-
*/
|
|
81
|
-
export function getWhitespacePrefix(s) {
|
|
82
|
-
return s.substring(0, s.length - s.trimStart().length);
|
|
56
|
+
function stringCompare(a, b) {
|
|
57
|
+
const cmp = (a2, b2) => a2 < b2 ? -1 : a2 > b2 ? 1 : 0;
|
|
58
|
+
return cmp(a.toUpperCase(), b.toUpperCase()) || cmp(b, a);
|
|
83
59
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
expect(getWhitespacePrefix("hello")).toBe("");
|
|
87
|
-
expect(getWhitespacePrefix(" hello")).toBe(" ");
|
|
88
|
-
expect(getWhitespacePrefix(" hello")).toBe(" ");
|
|
89
|
-
expect(getWhitespacePrefix("\thello")).toBe("\t");
|
|
90
|
-
expect(getWhitespacePrefix("\n hello")).toBe("\n ");
|
|
91
|
-
expect(getWhitespacePrefix(" ")).toBe(" ");
|
|
92
|
-
expect(getWhitespacePrefix(" \t\n\r")).toBe(" \t\n\r");
|
|
93
|
-
});
|
|
94
|
-
/**
|
|
95
|
-
* Returns all whitespace character at the end of the string.
|
|
96
|
-
*
|
|
97
|
-
* Uses the same definition for whitespace as `String.prototype.trim()`.
|
|
98
|
-
*/
|
|
99
|
-
export function getWhitespaceSuffix(s) {
|
|
100
|
-
return s.substring(s.trimEnd().length);
|
|
60
|
+
function getWhitespacePrefix(s) {
|
|
61
|
+
return s.substring(0, s.length - s.trimStart().length);
|
|
101
62
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
expect(getWhitespaceSuffix("hello")).toBe("");
|
|
105
|
-
expect(getWhitespaceSuffix("hello ")).toBe(" ");
|
|
106
|
-
expect(getWhitespaceSuffix("hello ")).toBe(" ");
|
|
107
|
-
expect(getWhitespaceSuffix("hello\t")).toBe("\t");
|
|
108
|
-
expect(getWhitespaceSuffix("hello \n")).toBe(" \n");
|
|
109
|
-
expect(getWhitespaceSuffix(" ")).toBe(" ");
|
|
110
|
-
expect(getWhitespaceSuffix(" \t\n\r")).toBe(" \t\n\r");
|
|
111
|
-
});
|
|
112
|
-
/**
|
|
113
|
-
* Returns a string with all empty or whitespace-only lines at the start removed.
|
|
114
|
-
*
|
|
115
|
-
* Uses the same definition for whitespace as `String.prototype.trim()`.
|
|
116
|
-
*/
|
|
117
|
-
export function trimEmptyLinesStart(s) {
|
|
118
|
-
const lines = s.split("\n");
|
|
119
|
-
const firstNonEmptyLineIndex = lines.findIndex((line) => line.trim() !== "");
|
|
120
|
-
// If all lines are empty or whitespace-only, return an empty string
|
|
121
|
-
if (firstNonEmptyLineIndex === -1)
|
|
122
|
-
return "";
|
|
123
|
-
return lines.slice(firstNonEmptyLineIndex).join("\n");
|
|
63
|
+
function getWhitespaceSuffix(s) {
|
|
64
|
+
return s.substring(s.trimEnd().length);
|
|
124
65
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
expect(trimEmptyLinesStart(" \n\t\nhello")).toBe("hello");
|
|
131
|
-
expect(trimEmptyLinesStart("\n\nhello\nworld")).toBe("hello\nworld");
|
|
132
|
-
expect(trimEmptyLinesStart("hello\n\nworld")).toBe("hello\n\nworld");
|
|
133
|
-
expect(trimEmptyLinesStart("hello\nworld\n")).toBe("hello\nworld\n");
|
|
134
|
-
expect(trimEmptyLinesStart("\n \n\nhello\n \nworld")).toBe("hello\n \nworld");
|
|
135
|
-
// Edge case: all lines are empty
|
|
136
|
-
expect(trimEmptyLinesStart("\n\n \n\t")).toBe("");
|
|
137
|
-
});
|
|
138
|
-
/**
|
|
139
|
-
* Returns a string with all empty or whitespace-only lines at the end removed.
|
|
140
|
-
*
|
|
141
|
-
* Uses the same definition for whitespace as `String.prototype.trim()`.
|
|
142
|
-
*/
|
|
143
|
-
export function trimEmptyLinesEnd(s) {
|
|
144
|
-
const lines = s.split("\n");
|
|
145
|
-
const lastNonEmptyLineIndex = findLastIndex(lines, (line) => line.trim() !== "");
|
|
146
|
-
return lines.slice(0, lastNonEmptyLineIndex + 1).join("\n");
|
|
66
|
+
function trimEmptyLinesStart(s) {
|
|
67
|
+
const lines = s.split("\n");
|
|
68
|
+
const firstNonEmptyLineIndex = lines.findIndex((line) => line.trim() !== "");
|
|
69
|
+
if (firstNonEmptyLineIndex === -1) return "";
|
|
70
|
+
return lines.slice(firstNonEmptyLineIndex).join("\n");
|
|
147
71
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
expect(trimEmptyLinesEnd("hello\n\n")).toBe("hello");
|
|
153
|
-
expect(trimEmptyLinesEnd("hello\n \n\t")).toBe("hello");
|
|
154
|
-
expect(trimEmptyLinesEnd("hello\nworld\n\n")).toBe("hello\nworld");
|
|
155
|
-
expect(trimEmptyLinesEnd("hello\n\nworld")).toBe("hello\n\nworld");
|
|
156
|
-
expect(trimEmptyLinesEnd("\nhello\nworld")).toBe("\nhello\nworld");
|
|
157
|
-
expect(trimEmptyLinesEnd("hello\n \nworld\n\n ")).toBe("hello\n \nworld");
|
|
158
|
-
// Edge case: all lines are empty
|
|
159
|
-
expect(trimEmptyLinesEnd("\n\n \n\t")).toBe("");
|
|
160
|
-
});
|
|
161
|
-
/**
|
|
162
|
-
* Returns a string with all empty or whitespace-only lines trimmed at the start and end.
|
|
163
|
-
*
|
|
164
|
-
* Uses the same definition for whitespace as `String.prototype.trim()`.
|
|
165
|
-
*/
|
|
166
|
-
export function trimLines(s) {
|
|
167
|
-
return trimEmptyLinesEnd(trimEmptyLinesStart(s));
|
|
72
|
+
function trimEmptyLinesEnd(s) {
|
|
73
|
+
const lines = s.split("\n");
|
|
74
|
+
const lastNonEmptyLineIndex = (0, import_arrays.findLastIndex)(lines, (line) => line.trim() !== "");
|
|
75
|
+
return lines.slice(0, lastNonEmptyLineIndex + 1).join("\n");
|
|
168
76
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
expect(trimLines(" ")).toBe("");
|
|
172
|
-
expect(trimLines(" \n ")).toBe("");
|
|
173
|
-
expect(trimLines(" abc ")).toBe(" abc ");
|
|
174
|
-
expect(trimLines("\n \nLine1\nLine2\n \n")).toBe("Line1\nLine2");
|
|
175
|
-
expect(trimLines("Line1\n \nLine2")).toBe("Line1\n \nLine2");
|
|
176
|
-
expect(trimLines(" \n \n\t")).toBe("");
|
|
177
|
-
expect(trimLines(" Hello World")).toBe(" Hello World");
|
|
178
|
-
expect(trimLines("\n")).toBe("");
|
|
179
|
-
expect(trimLines("\t \n\t\tLine1 \n \nLine2\t\t\n\t ")).toBe("\t\tLine1 \n \nLine2\t\t");
|
|
180
|
-
});
|
|
181
|
-
/**
|
|
182
|
-
* A template literal tag that returns the same string as the template literal without a tag.
|
|
183
|
-
*
|
|
184
|
-
* Useful for implementing your own template literal tags.
|
|
185
|
-
*/
|
|
186
|
-
export function templateIdentity(strings, ...values) {
|
|
187
|
-
if (values.length !== strings.length - 1)
|
|
188
|
-
throw new StackAssertionError("Invalid number of values; must be one less than strings", { strings, values });
|
|
189
|
-
return strings.reduce((result, str, i) => result + str + (values[i] ?? ''), '');
|
|
77
|
+
function trimLines(s) {
|
|
78
|
+
return trimEmptyLinesEnd(trimEmptyLinesStart(s));
|
|
190
79
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
const greeting = "Hello";
|
|
195
|
-
const subject = "World";
|
|
196
|
-
expect(templateIdentity `${greeting}, ${subject}!`).toBe("Hello, World!");
|
|
197
|
-
expect(templateIdentity `${"A"}${"B"}${"C"}`).toBe("ABC");
|
|
198
|
-
expect(templateIdentity `Start${""}Middle${""}End`).toBe("StartMiddleEnd");
|
|
199
|
-
expect(templateIdentity ``).toBe("");
|
|
200
|
-
expect(templateIdentity `Line1
|
|
201
|
-
Line2`).toBe("Line1\nLine2");
|
|
202
|
-
expect(templateIdentity(["a ", " scientific ", "gun"], "certain", "rail")).toBe("a certain scientific railgun");
|
|
203
|
-
expect(templateIdentity(["only one part"])).toBe("only one part");
|
|
204
|
-
expect(() => templateIdentity(["a ", "b", "c"], "only one")).toThrow("Invalid number of values");
|
|
205
|
-
expect(() => templateIdentity(["a", "b"], "x", "y")).toThrow("Invalid number of values");
|
|
206
|
-
});
|
|
207
|
-
export function deindent(strings, ...values) {
|
|
208
|
-
if (typeof strings === "string")
|
|
209
|
-
return deindent([strings]);
|
|
210
|
-
return templateIdentity(...deindentTemplate(strings, ...values));
|
|
80
|
+
function templateIdentity(strings, ...values) {
|
|
81
|
+
if (values.length !== strings.length - 1) throw new import_errors.StackAssertionError("Invalid number of values; must be one less than strings", { strings, values });
|
|
82
|
+
return strings.reduce((result, str, i) => result + str + (values[i] ?? ""), "");
|
|
211
83
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const trimmedStrings = [...strings];
|
|
216
|
-
trimmedStrings[0] = trimEmptyLinesStart(trimmedStrings[0] + "+").slice(0, -1);
|
|
217
|
-
trimmedStrings[trimmedStrings.length - 1] = trimEmptyLinesEnd("+" + trimmedStrings[trimmedStrings.length - 1]).slice(1);
|
|
218
|
-
const indentation = trimmedStrings
|
|
219
|
-
.join("${SOME_VALUE}")
|
|
220
|
-
.split("\n")
|
|
221
|
-
.filter((line) => line.trim() !== "")
|
|
222
|
-
.map((line) => getWhitespacePrefix(line).length)
|
|
223
|
-
.reduce((min, current) => Math.min(min, current), Infinity);
|
|
224
|
-
const deindentedStrings = trimmedStrings
|
|
225
|
-
.map((string, stringIndex) => {
|
|
226
|
-
return string
|
|
227
|
-
.split("\n")
|
|
228
|
-
.map((line, lineIndex) => stringIndex !== 0 && lineIndex === 0 ? line : line.substring(indentation))
|
|
229
|
-
.join("\n");
|
|
230
|
-
});
|
|
231
|
-
const indentedValues = values.map((value, i) => {
|
|
232
|
-
const firstLineIndentation = getWhitespacePrefix(deindentedStrings[i].split("\n").at(-1));
|
|
233
|
-
return `${value}`.replaceAll("\n", `\n${firstLineIndentation}`);
|
|
234
|
-
});
|
|
235
|
-
return [deindentedStrings, ...indentedValues];
|
|
84
|
+
function deindent(strings, ...values) {
|
|
85
|
+
if (typeof strings === "string") return deindent([strings]);
|
|
86
|
+
return templateIdentity(...deindentTemplate(strings, ...values));
|
|
236
87
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
world
|
|
253
|
-
`).toBe("hello\n world");
|
|
254
|
-
// Test with values
|
|
255
|
-
const value = "test";
|
|
256
|
-
expect(deindent `
|
|
257
|
-
hello ${value}
|
|
258
|
-
world
|
|
259
|
-
`).toBe(`hello ${value}\nworld`);
|
|
260
|
-
// Test with multiline values
|
|
261
|
-
expect(deindent `
|
|
262
|
-
hello
|
|
263
|
-
to ${"line1\n line2"}
|
|
264
|
-
world
|
|
265
|
-
`).toBe(`hello\n to line1\n line2\nworld`);
|
|
266
|
-
// Leading whitespace values
|
|
267
|
-
expect(deindent `
|
|
268
|
-
${" "}A
|
|
269
|
-
${" "}B
|
|
270
|
-
${" "}C
|
|
271
|
-
`).toBe(` A\n B\n C`);
|
|
272
|
-
// Trailing whitespaces (note: there are two whitespaces each after A and after C)
|
|
273
|
-
expect(deindent `
|
|
274
|
-
A
|
|
275
|
-
B ${" "}
|
|
276
|
-
C
|
|
277
|
-
`).toBe(`A \nB \nC `);
|
|
278
|
-
// Test with mixed indentation
|
|
279
|
-
expect(deindent `
|
|
280
|
-
hello
|
|
281
|
-
world
|
|
282
|
-
!
|
|
283
|
-
`).toBe("hello\n world\n !");
|
|
284
|
-
// Test error cases
|
|
285
|
-
expect(() => deindent(["a", "b", "c"], "too", "many", "values")).toThrow("Invalid number of values");
|
|
286
|
-
});
|
|
287
|
-
export function extractScopes(scope, removeDuplicates = true) {
|
|
288
|
-
// TODO what is this for? can we move this into the OAuth code in the backend?
|
|
289
|
-
const trimmedString = scope.trim();
|
|
290
|
-
const scopesArray = trimmedString.split(/\s+/);
|
|
291
|
-
const filtered = scopesArray.filter(scope => scope.length > 0);
|
|
292
|
-
return removeDuplicates ? [...new Set(filtered)] : filtered;
|
|
88
|
+
function deindentTemplate(strings, ...values) {
|
|
89
|
+
if (values.length !== strings.length - 1) throw new import_errors.StackAssertionError("Invalid number of values; must be one less than strings", { strings, values });
|
|
90
|
+
const trimmedStrings = [...strings];
|
|
91
|
+
trimmedStrings[0] = trimEmptyLinesStart(trimmedStrings[0] + "+").slice(0, -1);
|
|
92
|
+
trimmedStrings[trimmedStrings.length - 1] = trimEmptyLinesEnd("+" + trimmedStrings[trimmedStrings.length - 1]).slice(1);
|
|
93
|
+
const indentation = trimmedStrings.join("${SOME_VALUE}").split("\n").filter((line) => line.trim() !== "").map((line) => getWhitespacePrefix(line).length).reduce((min, current) => Math.min(min, current), Infinity);
|
|
94
|
+
const deindentedStrings = trimmedStrings.map((string, stringIndex) => {
|
|
95
|
+
return string.split("\n").map((line, lineIndex) => stringIndex !== 0 && lineIndex === 0 ? line : line.substring(indentation)).join("\n");
|
|
96
|
+
});
|
|
97
|
+
const indentedValues = values.map((value, i) => {
|
|
98
|
+
const firstLineIndentation = getWhitespacePrefix(deindentedStrings[i].split("\n").at(-1));
|
|
99
|
+
return `${value}`.replaceAll("\n", `
|
|
100
|
+
${firstLineIndentation}`);
|
|
101
|
+
});
|
|
102
|
+
return [deindentedStrings, ...indentedValues];
|
|
293
103
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
// Test with multiple scopes
|
|
300
|
-
expect(extractScopes("read write")).toEqual(["read", "write"]);
|
|
301
|
-
// Test with extra whitespace
|
|
302
|
-
expect(extractScopes(" read write ")).toEqual(["read", "write"]);
|
|
303
|
-
// Test with newlines and tabs
|
|
304
|
-
expect(extractScopes("read\nwrite\tdelete")).toEqual(["read", "write", "delete"]);
|
|
305
|
-
// Test with duplicates (default behavior)
|
|
306
|
-
expect(extractScopes("read write read")).toEqual(["read", "write"]);
|
|
307
|
-
// Test with duplicates (explicitly set to remove)
|
|
308
|
-
expect(extractScopes("read write read", true)).toEqual(["read", "write"]);
|
|
309
|
-
// Test with duplicates (explicitly set to keep)
|
|
310
|
-
expect(extractScopes("read write read", false)).toEqual(["read", "write", "read"]);
|
|
311
|
-
});
|
|
312
|
-
export function mergeScopeStrings(...scopes) {
|
|
313
|
-
// TODO what is this for? can we move this into the OAuth code in the backend?
|
|
314
|
-
const allScope = scopes.map((s) => extractScopes(s)).flat().join(" ");
|
|
315
|
-
return extractScopes(allScope).join(" ");
|
|
104
|
+
function extractScopes(scope, removeDuplicates = true) {
|
|
105
|
+
const trimmedString = scope.trim();
|
|
106
|
+
const scopesArray = trimmedString.split(/\s+/);
|
|
107
|
+
const filtered = scopesArray.filter((scope2) => scope2.length > 0);
|
|
108
|
+
return removeDuplicates ? [...new Set(filtered)] : filtered;
|
|
316
109
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
// Test with single scope string
|
|
321
|
-
expect(mergeScopeStrings("read write")).toBe("read write");
|
|
322
|
-
// Test with multiple scope strings
|
|
323
|
-
expect(mergeScopeStrings("read", "write")).toBe("read write");
|
|
324
|
-
// Test with overlapping scopes
|
|
325
|
-
expect(mergeScopeStrings("read write", "write delete")).toBe("read write delete");
|
|
326
|
-
// Test with extra whitespace
|
|
327
|
-
expect(mergeScopeStrings(" read write ", " delete ")).toBe("read write delete");
|
|
328
|
-
// Test with duplicates across strings
|
|
329
|
-
expect(mergeScopeStrings("read write", "write delete", "read")).toBe("read write delete");
|
|
330
|
-
// Test with empty strings
|
|
331
|
-
expect(mergeScopeStrings("read write", "", "delete")).toBe("read write delete");
|
|
332
|
-
});
|
|
333
|
-
export function escapeTemplateLiteral(s) {
|
|
334
|
-
return s.replaceAll("`", "\\`").replaceAll("\\", "\\\\").replaceAll("$", "\\$");
|
|
110
|
+
function mergeScopeStrings(...scopes) {
|
|
111
|
+
const allScope = scopes.map((s) => extractScopes(s)).flat().join(" ");
|
|
112
|
+
return extractScopes(allScope).join(" ");
|
|
335
113
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
// Test with backtick
|
|
342
|
-
const input1 = "hello `world`";
|
|
343
|
-
const output1 = escapeTemplateLiteral(input1);
|
|
344
|
-
// Verify backticks are escaped
|
|
345
|
-
expect(output1.includes("\\`")).toBe(true);
|
|
346
|
-
expect(output1).not.toBe(input1);
|
|
347
|
-
// Test with backslash
|
|
348
|
-
const input2 = "hello \\world";
|
|
349
|
-
const output2 = escapeTemplateLiteral(input2);
|
|
350
|
-
// Verify backslashes are escaped
|
|
351
|
-
expect(output2.includes("\\\\")).toBe(true);
|
|
352
|
-
expect(output2).not.toBe(input2);
|
|
353
|
-
// Test with dollar sign
|
|
354
|
-
const input3 = "hello $world";
|
|
355
|
-
const output3 = escapeTemplateLiteral(input3);
|
|
356
|
-
// Verify dollar signs are escaped
|
|
357
|
-
expect(output3.includes("\\$")).toBe(true);
|
|
358
|
-
expect(output3).not.toBe(input3);
|
|
359
|
-
// Test with multiple special characters
|
|
360
|
-
const input4 = "`hello` $world\\";
|
|
361
|
-
const output4 = escapeTemplateLiteral(input4);
|
|
362
|
-
// Verify all special characters are escaped
|
|
363
|
-
expect(output4.includes("\\`")).toBe(true);
|
|
364
|
-
expect(output4.includes("\\$")).toBe(true);
|
|
365
|
-
expect(output4.includes("\\\\")).toBe(true);
|
|
366
|
-
expect(output4).not.toBe(input4);
|
|
367
|
-
// Test with already escaped characters
|
|
368
|
-
const input5 = "\\`hello\\`";
|
|
369
|
-
const output5 = escapeTemplateLiteral(input5);
|
|
370
|
-
// Verify already escaped characters are properly escaped
|
|
371
|
-
expect(output5).not.toBe(input5);
|
|
372
|
-
});
|
|
373
|
-
/**
|
|
374
|
-
* Some classes have different constructor names in different environments (eg. `Headers` is sometimes called `_Headers`,
|
|
375
|
-
* so we create an object of overrides to handle these cases.
|
|
376
|
-
*/
|
|
377
|
-
const nicifiableClassNameOverrides = new Map(Object.entries({
|
|
378
|
-
Headers,
|
|
114
|
+
function escapeTemplateLiteral(s) {
|
|
115
|
+
return s.replaceAll("`", "\\`").replaceAll("\\", "\\\\").replaceAll("$", "\\$");
|
|
116
|
+
}
|
|
117
|
+
var nicifiableClassNameOverrides = new Map(Object.entries({
|
|
118
|
+
Headers
|
|
379
119
|
}).map(([k, v]) => [v, k]));
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
120
|
+
function nicify(value, options = {}) {
|
|
121
|
+
const fullOptions = {
|
|
122
|
+
maxDepth: 5,
|
|
123
|
+
currentIndent: "",
|
|
124
|
+
lineIndent: " ",
|
|
125
|
+
multiline: true,
|
|
126
|
+
refs: /* @__PURE__ */ new Map(),
|
|
127
|
+
path: "value",
|
|
128
|
+
parent: null,
|
|
129
|
+
overrides: () => null,
|
|
130
|
+
keyInParent: null,
|
|
131
|
+
hideFields: [],
|
|
132
|
+
...(0, import_objects.filterUndefined)(options)
|
|
133
|
+
};
|
|
134
|
+
const {
|
|
135
|
+
maxDepth,
|
|
136
|
+
currentIndent,
|
|
137
|
+
lineIndent,
|
|
138
|
+
multiline,
|
|
139
|
+
refs,
|
|
140
|
+
path,
|
|
141
|
+
overrides,
|
|
142
|
+
hideFields
|
|
143
|
+
} = fullOptions;
|
|
144
|
+
const nl = `
|
|
145
|
+
${currentIndent}`;
|
|
146
|
+
const overrideResult = overrides(value, options);
|
|
147
|
+
if (overrideResult !== null) return overrideResult;
|
|
148
|
+
if (["function", "object", "symbol"].includes(typeof value) && value !== null) {
|
|
149
|
+
if (refs.has(value)) {
|
|
150
|
+
return `Ref<${refs.get(value)}>`;
|
|
404
151
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
152
|
+
refs.set(value, path);
|
|
153
|
+
}
|
|
154
|
+
const newOptions = {
|
|
155
|
+
maxDepth: maxDepth - 1,
|
|
156
|
+
currentIndent,
|
|
157
|
+
lineIndent,
|
|
158
|
+
multiline,
|
|
159
|
+
refs,
|
|
160
|
+
path: path + "->[unknown property]",
|
|
161
|
+
overrides,
|
|
162
|
+
parent: { value, options: fullOptions },
|
|
163
|
+
keyInParent: null,
|
|
164
|
+
hideFields: []
|
|
165
|
+
};
|
|
166
|
+
const nestedNicify = (newValue, newPath, keyInParent, options2 = {}) => {
|
|
167
|
+
return nicify(newValue, {
|
|
168
|
+
...newOptions,
|
|
169
|
+
path: newPath,
|
|
170
|
+
currentIndent: currentIndent + lineIndent,
|
|
171
|
+
keyInParent,
|
|
172
|
+
...options2
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
switch (typeof value) {
|
|
176
|
+
case "boolean":
|
|
177
|
+
case "number": {
|
|
178
|
+
return JSON.stringify(value);
|
|
179
|
+
}
|
|
180
|
+
case "string": {
|
|
181
|
+
const isDeindentable = (v) => deindent(v) === v && v.includes("\n");
|
|
182
|
+
const wrapInDeindent = (v) => deindent`
|
|
434
183
|
deindent\`
|
|
435
184
|
${currentIndent + lineIndent}${escapeTemplateLiteral(v).replaceAll("\n", nl + lineIndent)}
|
|
436
185
|
${currentIndent}\`
|
|
437
186
|
`;
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
187
|
+
if (isDeindentable(value)) {
|
|
188
|
+
return wrapInDeindent(value);
|
|
189
|
+
} else if (value.endsWith("\n") && isDeindentable(value.slice(0, -1))) {
|
|
190
|
+
return wrapInDeindent(value.slice(0, -1)) + ' + "\\n"';
|
|
191
|
+
} else {
|
|
192
|
+
return JSON.stringify(value);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
case "undefined": {
|
|
196
|
+
return "undefined";
|
|
197
|
+
}
|
|
198
|
+
case "symbol": {
|
|
199
|
+
return value.toString();
|
|
200
|
+
}
|
|
201
|
+
case "bigint": {
|
|
202
|
+
return `${value}n`;
|
|
203
|
+
}
|
|
204
|
+
case "function": {
|
|
205
|
+
if (value.name) return `function ${value.name}(...) { ... }`;
|
|
206
|
+
return `(...) => { ... }`;
|
|
207
|
+
}
|
|
208
|
+
case "object": {
|
|
209
|
+
if (value === null) return "null";
|
|
210
|
+
if (Array.isArray(value)) {
|
|
211
|
+
const extraLines2 = getNicifiedObjectExtraLines(value);
|
|
212
|
+
const resValueLength2 = value.length + extraLines2.length;
|
|
213
|
+
if (maxDepth <= 0 && resValueLength2 === 0) return "[...]";
|
|
214
|
+
const resValues2 = value.map((v, i) => nestedNicify(v, `${path}[${i}]`, i));
|
|
215
|
+
resValues2.push(...extraLines2);
|
|
216
|
+
if (resValues2.length !== resValueLength2) throw new import_errors.StackAssertionError("nicify of object: resValues.length !== resValueLength", { value, resValues: resValues2, resValueLength: resValueLength2 });
|
|
217
|
+
const shouldIndent2 = resValues2.length > 4 || resValues2.some((x) => resValues2.length > 1 && x.length > 4 || x.includes("\n"));
|
|
218
|
+
if (shouldIndent2) {
|
|
219
|
+
return `[${nl}${resValues2.map((x) => `${lineIndent}${x},${nl}`).join("")}]`;
|
|
220
|
+
} else {
|
|
221
|
+
return `[${resValues2.join(", ")}]`;
|
|
456
222
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
223
|
+
}
|
|
224
|
+
if (value instanceof URL) {
|
|
225
|
+
return `URL(${nestedNicify(value.toString(), `${path}.toString()`, null)})`;
|
|
226
|
+
}
|
|
227
|
+
if (ArrayBuffer.isView(value)) {
|
|
228
|
+
return `${value.constructor.name}([${value.toString()}])`;
|
|
229
|
+
}
|
|
230
|
+
if (value instanceof Error) {
|
|
231
|
+
let stack = value.stack ?? "";
|
|
232
|
+
const toString = value.toString();
|
|
233
|
+
if (!stack.startsWith(toString)) stack = `${toString}
|
|
234
|
+
${stack}`;
|
|
235
|
+
stack = stack.trimEnd();
|
|
236
|
+
stack = stack.replace(/\n\s+/g, `
|
|
237
|
+
${lineIndent}${lineIndent}`);
|
|
238
|
+
stack = stack.replace("\n", `
|
|
239
|
+
${lineIndent}Stack:
|
|
240
|
+
`);
|
|
241
|
+
if (Object.keys(value).length > 0) {
|
|
242
|
+
stack += `
|
|
243
|
+
${lineIndent}Extra properties: ${nestedNicify(Object.fromEntries(Object.entries(value)), path, null)}`;
|
|
461
244
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
const extraLines = getNicifiedObjectExtraLines(value);
|
|
467
|
-
const resValueLength = value.length + extraLines.length;
|
|
468
|
-
if (maxDepth <= 0 && resValueLength === 0)
|
|
469
|
-
return "[...]";
|
|
470
|
-
const resValues = value.map((v, i) => nestedNicify(v, `${path}[${i}]`, i));
|
|
471
|
-
resValues.push(...extraLines);
|
|
472
|
-
if (resValues.length !== resValueLength)
|
|
473
|
-
throw new StackAssertionError("nicify of object: resValues.length !== resValueLength", { value, resValues, resValueLength });
|
|
474
|
-
const shouldIndent = resValues.length > 4 || resValues.some(x => (resValues.length > 1 && x.length > 4) || x.includes("\n"));
|
|
475
|
-
if (shouldIndent) {
|
|
476
|
-
return `[${nl}${resValues.map(x => `${lineIndent}${x},${nl}`).join("")}]`;
|
|
477
|
-
}
|
|
478
|
-
else {
|
|
479
|
-
return `[${resValues.join(", ")}]`;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
if (value instanceof URL) {
|
|
483
|
-
return `URL(${nestedNicify(value.toString(), `${path}.toString()`, null)})`;
|
|
484
|
-
}
|
|
485
|
-
if (ArrayBuffer.isView(value)) {
|
|
486
|
-
return `${value.constructor.name}([${value.toString()}])`;
|
|
487
|
-
}
|
|
488
|
-
if (value instanceof Error) {
|
|
489
|
-
let stack = value.stack ?? "";
|
|
490
|
-
const toString = value.toString();
|
|
491
|
-
if (!stack.startsWith(toString))
|
|
492
|
-
stack = `${toString}\n${stack}`; // some browsers don't include the error message in the stack, some do
|
|
493
|
-
stack = stack.trimEnd();
|
|
494
|
-
stack = stack.replace(/\n\s+/g, `\n${lineIndent}${lineIndent}`);
|
|
495
|
-
stack = stack.replace("\n", `\n${lineIndent}Stack:\n`);
|
|
496
|
-
if (Object.keys(value).length > 0) {
|
|
497
|
-
stack += `\n${lineIndent}Extra properties: ${nestedNicify(Object.fromEntries(Object.entries(value)), path, null)}`;
|
|
498
|
-
}
|
|
499
|
-
if (value.cause) {
|
|
500
|
-
stack += `\n${lineIndent}Cause:\n${lineIndent}${lineIndent}${nestedNicify(value.cause, path, null, { currentIndent: currentIndent + lineIndent + lineIndent })}`;
|
|
501
|
-
}
|
|
502
|
-
stack = stack.replaceAll("\n", `\n${currentIndent}`);
|
|
503
|
-
return stack;
|
|
504
|
-
}
|
|
505
|
-
const constructorName = [null, Object.prototype].includes(Object.getPrototypeOf(value)) ? null : (nicifiableClassNameOverrides.get(value.constructor) ?? value.constructor.name);
|
|
506
|
-
const constructorString = constructorName ? `${constructorName} ` : "";
|
|
507
|
-
const entries = getNicifiableEntries(value).filter(([k]) => !hideFields.includes(k));
|
|
508
|
-
const extraLines = [
|
|
509
|
-
...getNicifiedObjectExtraLines(value),
|
|
510
|
-
...hideFields.length > 0 ? [`<some fields may have been hidden>`] : [],
|
|
511
|
-
];
|
|
512
|
-
const resValueLength = entries.length + extraLines.length;
|
|
513
|
-
if (resValueLength === 0)
|
|
514
|
-
return `${constructorString}{}`;
|
|
515
|
-
if (maxDepth <= 0)
|
|
516
|
-
return `${constructorString}{ ... }`;
|
|
517
|
-
const resValues = entries.map(([k, v], keyIndex) => {
|
|
518
|
-
const keyNicified = nestedNicify(k, `Object.keys(${path})[${keyIndex}]`, null);
|
|
519
|
-
const keyInObjectLiteral = typeof k === "string" ? nicifyPropertyString(k) : `[${keyNicified}]`;
|
|
520
|
-
if (typeof v === "function" && v.name === k) {
|
|
521
|
-
return `${keyInObjectLiteral}(...): { ... }`;
|
|
522
|
-
}
|
|
523
|
-
else {
|
|
524
|
-
return `${keyInObjectLiteral}: ${nestedNicify(v, `${path}[${keyNicified}]`, k)}`;
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
resValues.push(...extraLines);
|
|
528
|
-
if (resValues.length !== resValueLength)
|
|
529
|
-
throw new StackAssertionError("nicify of object: resValues.length !== resValueLength", { value, resValues, resValueLength });
|
|
530
|
-
const shouldIndent = resValues.length > 1 || resValues.some(x => x.includes("\n"));
|
|
531
|
-
if (resValues.length === 0)
|
|
532
|
-
return `${constructorString}{}`;
|
|
533
|
-
if (shouldIndent) {
|
|
534
|
-
return `${constructorString}{${nl}${resValues.map(x => `${lineIndent}${x},${nl}`).join("")}}`;
|
|
535
|
-
}
|
|
536
|
-
else {
|
|
537
|
-
return `${constructorString}{ ${resValues.join(", ")} }`;
|
|
538
|
-
}
|
|
245
|
+
if (value.cause) {
|
|
246
|
+
stack += `
|
|
247
|
+
${lineIndent}Cause:
|
|
248
|
+
${lineIndent}${lineIndent}${nestedNicify(value.cause, path, null, { currentIndent: currentIndent + lineIndent + lineIndent })}`;
|
|
539
249
|
}
|
|
540
|
-
|
|
541
|
-
|
|
250
|
+
stack = stack.replaceAll("\n", `
|
|
251
|
+
${currentIndent}`);
|
|
252
|
+
return stack;
|
|
253
|
+
}
|
|
254
|
+
const constructorName = [null, Object.prototype].includes(Object.getPrototypeOf(value)) ? null : nicifiableClassNameOverrides.get(value.constructor) ?? value.constructor.name;
|
|
255
|
+
const constructorString = constructorName ? `${constructorName} ` : "";
|
|
256
|
+
const entries = getNicifiableEntries(value).filter(([k]) => !hideFields.includes(k));
|
|
257
|
+
const extraLines = [
|
|
258
|
+
...getNicifiedObjectExtraLines(value),
|
|
259
|
+
...hideFields.length > 0 ? [`<some fields may have been hidden>`] : []
|
|
260
|
+
];
|
|
261
|
+
const resValueLength = entries.length + extraLines.length;
|
|
262
|
+
if (resValueLength === 0) return `${constructorString}{}`;
|
|
263
|
+
if (maxDepth <= 0) return `${constructorString}{ ... }`;
|
|
264
|
+
const resValues = entries.map(([k, v], keyIndex) => {
|
|
265
|
+
const keyNicified = nestedNicify(k, `Object.keys(${path})[${keyIndex}]`, null);
|
|
266
|
+
const keyInObjectLiteral = typeof k === "string" ? nicifyPropertyString(k) : `[${keyNicified}]`;
|
|
267
|
+
if (typeof v === "function" && v.name === k) {
|
|
268
|
+
return `${keyInObjectLiteral}(...): { ... }`;
|
|
269
|
+
} else {
|
|
270
|
+
return `${keyInObjectLiteral}: ${nestedNicify(v, `${path}[${keyNicified}]`, k)}`;
|
|
542
271
|
}
|
|
272
|
+
});
|
|
273
|
+
resValues.push(...extraLines);
|
|
274
|
+
if (resValues.length !== resValueLength) throw new import_errors.StackAssertionError("nicify of object: resValues.length !== resValueLength", { value, resValues, resValueLength });
|
|
275
|
+
const shouldIndent = resValues.length > 1 || resValues.some((x) => x.includes("\n"));
|
|
276
|
+
if (resValues.length === 0) return `${constructorString}{}`;
|
|
277
|
+
if (shouldIndent) {
|
|
278
|
+
return `${constructorString}{${nl}${resValues.map((x) => `${lineIndent}${x},${nl}`).join("")}}`;
|
|
279
|
+
} else {
|
|
280
|
+
return `${constructorString}{ ${resValues.join(", ")} }`;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
default: {
|
|
284
|
+
return `${typeof value}<${value}>`;
|
|
543
285
|
}
|
|
286
|
+
}
|
|
544
287
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
return input.split(searchValue).join(replaceValue);
|
|
288
|
+
function replaceAll(input, searchValue, replaceValue) {
|
|
289
|
+
if (searchValue === "") throw new import_errors.StackAssertionError("replaceAll: searchValue is empty");
|
|
290
|
+
return input.split(searchValue).join(replaceValue);
|
|
549
291
|
}
|
|
550
|
-
import.meta.vitest?.test("replaceAll", ({ expect }) => {
|
|
551
|
-
expect(replaceAll("hello world", "o", "x")).toBe("hellx wxrld");
|
|
552
|
-
expect(replaceAll("aaa", "a", "b")).toBe("bbb");
|
|
553
|
-
expect(replaceAll("", "a", "b")).toBe("");
|
|
554
|
-
expect(replaceAll("abc", "b", "")).toBe("ac");
|
|
555
|
-
expect(replaceAll("test.test.test", ".", "_")).toBe("test_test_test");
|
|
556
|
-
expect(replaceAll("a.b*c", ".", "x")).toBe("axb*c");
|
|
557
|
-
expect(replaceAll("a*b*c", "*", "x")).toBe("axbxc");
|
|
558
|
-
expect(replaceAll("hello hello", "hello", "hi")).toBe("hi hi");
|
|
559
|
-
});
|
|
560
292
|
function nicifyPropertyString(str) {
|
|
561
|
-
|
|
293
|
+
return JSON.stringify(str);
|
|
562
294
|
}
|
|
563
|
-
import.meta.vitest?.test("nicifyPropertyString", ({ expect }) => {
|
|
564
|
-
// Test valid identifiers
|
|
565
|
-
expect(nicifyPropertyString("validName")).toBe('"validName"');
|
|
566
|
-
expect(nicifyPropertyString("_validName")).toBe('"_validName"');
|
|
567
|
-
expect(nicifyPropertyString("valid123Name")).toBe('"valid123Name"');
|
|
568
|
-
// Test invalid identifiers
|
|
569
|
-
expect(nicifyPropertyString("123invalid")).toBe('"123invalid"');
|
|
570
|
-
expect(nicifyPropertyString("invalid-name")).toBe('"invalid-name"');
|
|
571
|
-
expect(nicifyPropertyString("invalid space")).toBe('"invalid space"');
|
|
572
|
-
expect(nicifyPropertyString("$invalid")).toBe('"$invalid"');
|
|
573
|
-
expect(nicifyPropertyString("")).toBe('""');
|
|
574
|
-
// Test with special characters
|
|
575
|
-
expect(nicifyPropertyString("property!")).toBe('"property!"');
|
|
576
|
-
expect(nicifyPropertyString("property.name")).toBe('"property.name"');
|
|
577
|
-
// Test with escaped characters
|
|
578
|
-
expect(nicifyPropertyString("\\")).toBe('"\\\\"');
|
|
579
|
-
expect(nicifyPropertyString('"')).toBe('"\\""');
|
|
580
|
-
});
|
|
581
295
|
function getNicifiableKeys(value) {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
return unique(keys);
|
|
296
|
+
const overridden = ("getNicifiableKeys" in value ? value.getNicifiableKeys?.bind(value) : null)?.();
|
|
297
|
+
if (overridden != null) return overridden;
|
|
298
|
+
const keys = Object.keys(value).sort();
|
|
299
|
+
return (0, import_arrays.unique)(keys);
|
|
587
300
|
}
|
|
588
|
-
import.meta.vitest?.test("getNicifiableKeys", ({ expect }) => {
|
|
589
|
-
// Test regular object
|
|
590
|
-
expect(getNicifiableKeys({ b: 1, a: 2, c: 3 })).toEqual(["a", "b", "c"]);
|
|
591
|
-
// Test empty object
|
|
592
|
-
expect(getNicifiableKeys({})).toEqual([]);
|
|
593
|
-
// Test object with custom getNicifiableKeys
|
|
594
|
-
const customObject = {
|
|
595
|
-
a: 1,
|
|
596
|
-
b: 2,
|
|
597
|
-
getNicifiableKeys() {
|
|
598
|
-
return ["customKey1", "customKey2"];
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
expect(getNicifiableKeys(customObject)).toEqual(["customKey1", "customKey2"]);
|
|
602
|
-
});
|
|
603
301
|
function getNicifiableEntries(value) {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
302
|
+
const recordLikes = [Headers];
|
|
303
|
+
function isRecordLike(value2) {
|
|
304
|
+
return recordLikes.some((x) => value2 instanceof x);
|
|
305
|
+
}
|
|
306
|
+
if (isRecordLike(value)) {
|
|
307
|
+
return [...value.entries()].sort(([a], [b]) => stringCompare(`${a}`, `${b}`));
|
|
308
|
+
}
|
|
309
|
+
const keys = getNicifiableKeys(value);
|
|
310
|
+
return keys.map((k) => [k, value[k]]);
|
|
613
311
|
}
|
|
614
312
|
function getNicifiedObjectExtraLines(value) {
|
|
615
|
-
|
|
313
|
+
return ("getNicifiedObjectExtraLines" in value ? value.getNicifiedObjectExtraLines : null)?.() ?? [];
|
|
616
314
|
}
|
|
315
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
316
|
+
0 && (module.exports = {
|
|
317
|
+
deindent,
|
|
318
|
+
deindentTemplate,
|
|
319
|
+
escapeTemplateLiteral,
|
|
320
|
+
extractScopes,
|
|
321
|
+
getWhitespacePrefix,
|
|
322
|
+
getWhitespaceSuffix,
|
|
323
|
+
mergeScopeStrings,
|
|
324
|
+
nicify,
|
|
325
|
+
replaceAll,
|
|
326
|
+
stringCompare,
|
|
327
|
+
templateIdentity,
|
|
328
|
+
trimEmptyLinesEnd,
|
|
329
|
+
trimEmptyLinesStart,
|
|
330
|
+
trimLines,
|
|
331
|
+
typedCapitalize,
|
|
332
|
+
typedToLowercase,
|
|
333
|
+
typedToUppercase
|
|
334
|
+
});
|
|
335
|
+
//# sourceMappingURL=strings.js.map
|