@123usmanhaider321/ui 0.1.6 → 1.0.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/README.md +416 -31
- package/dist/images/icon/1LINK.svg +50 -0
- package/dist/images/icon/CreditCard.svg +83 -0
- package/dist/images/icon/Easypaisa.png +0 -0
- package/dist/images/icon/MobileWallet.png +0 -0
- package/dist/images/icon/Raast-Logo.png +0 -0
- package/dist/images/icon/VISA.png +0 -0
- package/dist/images/icon/add-circle-1.svg +5 -0
- package/dist/images/icon/check-circle-broken.svg +3 -0
- package/dist/images/icon/close-circle.svg +5 -0
- package/dist/images/icon/jazzcash.png +0 -0
- package/dist/images/icon/loading_icon.json +3347 -0
- package/dist/images/icon/mastercard-logo.webp +0 -0
- package/dist/images/icon/paymo.jpeg +0 -0
- package/dist/images/icon/preview-svgrepo-com.svg +36 -0
- package/dist/images/icon/trash.svg +7 -0
- package/dist/images/icon/unionpay-logo.svg +9 -0
- package/dist/index-87FQZHOs.js +11119 -0
- package/dist/index-87FQZHOs.js.map +1 -0
- package/dist/index-Tl9g213f.js +60475 -0
- package/dist/index-Tl9g213f.js.map +1 -0
- package/dist/index.d.ts +1 -10
- package/dist/index.es-CpgTaa1Y.js +16734 -0
- package/dist/index.es-CpgTaa1Y.js.map +1 -0
- package/dist/index.js +40 -12
- package/dist/index.js.map +1 -1
- package/dist/loading_icon-n5H5dQBl.js +3375 -0
- package/dist/loading_icon-n5H5dQBl.js.map +1 -0
- package/dist/src/components/Alert/ErrorAlert.d.ts +6 -0
- package/dist/src/components/Alert/SuccessAlert.d.ts +6 -0
- package/dist/{components → src/components}/FormBuilder/DiscountInput.d.ts +3 -6
- package/dist/{components → src/components}/FormBuilder/FormBuilder.d.ts +2 -11
- package/dist/{components → src/components}/FormBuilder/QuestionCard.d.ts +0 -5
- package/dist/{components → src/components}/FormBuilder/QuestionEditor.d.ts +0 -5
- package/dist/{components → src/components}/FormBuilder/SortableQuestionList.d.ts +0 -5
- package/dist/src/components/FormBuilder/questionIcons.d.ts +5 -0
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/AddEventLayout.d.ts +2 -1
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/AddEventStepper.d.ts +2 -2
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/common/ConfirmationModal.d.ts +1 -1
- package/dist/src/components/NewAddEvent/components/EventSubmissionConfirmationModal.d.ts +14 -0
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/StepTwo/TicketTierSection.d.ts +1 -1
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/TicketTierForm.d.ts +1 -1
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/hooks/useStepperForm.d.ts +22 -22
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/hooks/useTicketTierForm.d.ts +63 -15
- package/dist/src/components/NewAddEvent/schemas/step1.d.ts +211 -0
- package/dist/src/components/NewAddEvent/schemas/step2.d.ts +411 -0
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/schemas/utils.d.ts +8 -2
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/steps/IndividualFormStep.d.ts +1 -1
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/steps/SocialProfilesStep.d.ts +1 -1
- package/dist/{components/EventAddForm → src/components/NewAddEvent}/steps/TeamFormStep.d.ts +1 -1
- package/dist/src/components/Spinner/spinner.d.ts +4 -0
- package/dist/src/components/TicketlyUIProvider.d.ts +35 -0
- package/dist/src/components/common/Loader/index.d.ts +8 -0
- package/dist/src/components/common/Modals/ConfirmationModal.d.ts +7 -0
- package/dist/{components/FormInput → src/components/ui}/FormInput.d.ts +1 -1
- package/dist/src/components/ui/Loader.d.ts +4 -0
- package/dist/{components/Button/Button.d.ts → src/components/ui/button.d.ts} +1 -1
- package/dist/src/index.d.ts +10 -0
- package/dist/{lib → src/lib}/actions.d.ts +0 -126
- package/dist/src/lib/dom-utils.d.ts +2 -0
- package/dist/src/lib/storage-utils.d.ts +5 -0
- package/dist/src/lib/types.d.ts +258 -0
- package/dist/src/redux/baseQuery.d.ts +16 -0
- package/dist/{services → src/redux/features}/eventApi.d.ts +1053 -1745
- package/dist/src/redux/features/globalSlice.d.ts +17 -0
- package/dist/{services → src/redux/features/single-event}/single-event-api.d.ts +856 -1190
- package/dist/src/redux/types.d.ts +2 -0
- package/dist/src/services/library-services.d.ts +15 -0
- package/dist/src/services/remote-config.d.ts +27 -0
- package/dist/{services → src/services}/utils.d.ts +1 -1
- package/dist/src/theme/colors.d.ts +127 -0
- package/dist/src/theme/typography.d.ts +13 -0
- package/dist/src/types/api.d.ts +18 -0
- package/dist/style.css +2984 -0
- package/dist/styles.css +3758 -3636
- package/package.json +78 -68
- package/dist/_virtual/_commonjsHelpers.js +0 -9
- package/dist/_virtual/_commonjsHelpers.js.map +0 -1
- package/dist/_virtual/customParseFormat.js +0 -5
- package/dist/_virtual/customParseFormat.js.map +0 -1
- package/dist/_virtual/dayjs.min.js +0 -5
- package/dist/_virtual/dayjs.min.js.map +0 -1
- package/dist/_virtual/duration.js +0 -5
- package/dist/_virtual/duration.js.map +0 -1
- package/dist/_virtual/index.js +0 -5
- package/dist/_virtual/index.js.map +0 -1
- package/dist/_virtual/isBetween.js +0 -5
- package/dist/_virtual/isBetween.js.map +0 -1
- package/dist/_virtual/relativeTime.js +0 -5
- package/dist/_virtual/relativeTime.js.map +0 -1
- package/dist/_virtual/use-sync-external-store-shim.development.js +0 -5
- package/dist/_virtual/use-sync-external-store-shim.development.js.map +0 -1
- package/dist/_virtual/use-sync-external-store-shim.production.js +0 -5
- package/dist/_virtual/use-sync-external-store-shim.production.js.map +0 -1
- package/dist/_virtual/with-selector.development.js +0 -5
- package/dist/_virtual/with-selector.development.js.map +0 -1
- package/dist/_virtual/with-selector.js +0 -5
- package/dist/_virtual/with-selector.js.map +0 -1
- package/dist/_virtual/with-selector.production.js +0 -5
- package/dist/_virtual/with-selector.production.js.map +0 -1
- package/dist/components/Alert/Alert.js +0 -51
- package/dist/components/Alert/Alert.js.map +0 -1
- package/dist/components/Button/Button.js +0 -52
- package/dist/components/Button/Button.js.map +0 -1
- package/dist/components/Button/Button.test.d.ts +0 -1
- package/dist/components/Button/index.d.ts +0 -1
- package/dist/components/Checkbox/Checkbox.js +0 -50
- package/dist/components/Checkbox/Checkbox.js.map +0 -1
- package/dist/components/Checkbox/Checkbox.test.d.ts +0 -1
- package/dist/components/Checkbox/index.d.ts +0 -1
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +0 -25
- package/dist/components/CheckboxGroup/CheckboxGroup.js +0 -99
- package/dist/components/CheckboxGroup/CheckboxGroup.js.map +0 -1
- package/dist/components/ConfirmationModal/ConfirmationModal.d.ts +0 -15
- package/dist/components/ConfirmationModal/ConfirmationModal.js +0 -136
- package/dist/components/ConfirmationModal/ConfirmationModal.js.map +0 -1
- package/dist/components/ConfirmationModal/index.d.ts +0 -2
- package/dist/components/CustomSelect/CustomSelect.js +0 -259
- package/dist/components/CustomSelect/CustomSelect.js.map +0 -1
- package/dist/components/EventAddForm/AddEventLayout.js +0 -227
- package/dist/components/EventAddForm/AddEventLayout.js.map +0 -1
- package/dist/components/EventAddForm/AddEventStepper.js +0 -719
- package/dist/components/EventAddForm/AddEventStepper.js.map +0 -1
- package/dist/components/EventAddForm/common/ConfirmationModal.js +0 -136
- package/dist/components/EventAddForm/common/ConfirmationModal.js.map +0 -1
- package/dist/components/EventAddForm/common/DescriptionModal.js +0 -70
- package/dist/components/EventAddForm/common/DescriptionModal.js.map +0 -1
- package/dist/components/EventAddForm/components/AnimatedBackground.d.ts +0 -8
- package/dist/components/EventAddForm/components/ApprovalConfirmationModal.d.ts +0 -7
- package/dist/components/EventAddForm/components/CheckboxGroup.js +0 -92
- package/dist/components/EventAddForm/components/CheckboxGroup.js.map +0 -1
- package/dist/components/EventAddForm/components/CustomMeetingForm.js +0 -237
- package/dist/components/EventAddForm/components/CustomMeetingForm.js.map +0 -1
- package/dist/components/EventAddForm/components/DateTimeField.js +0 -173
- package/dist/components/EventAddForm/components/DateTimeField.js.map +0 -1
- package/dist/components/EventAddForm/components/EventSubmissionConfirmationModal.d.ts +0 -33
- package/dist/components/EventAddForm/components/EventSubmissionConfirmationModal.js +0 -366
- package/dist/components/EventAddForm/components/EventSubmissionConfirmationModal.js.map +0 -1
- package/dist/components/EventAddForm/components/FileUpload.js +0 -412
- package/dist/components/EventAddForm/components/FileUpload.js.map +0 -1
- package/dist/components/EventAddForm/components/FormBuilderProceedModal.js +0 -197
- package/dist/components/EventAddForm/components/FormBuilderProceedModal.js.map +0 -1
- package/dist/components/EventAddForm/components/GoogleMapsAutocompleteInput.js +0 -1179
- package/dist/components/EventAddForm/components/GoogleMapsAutocompleteInput.js.map +0 -1
- package/dist/components/EventAddForm/components/InputField.d.ts +0 -15
- package/dist/components/EventAddForm/components/RadioGroupButton.d.ts +0 -14
- package/dist/components/EventAddForm/components/SelectField.d.ts +0 -19
- package/dist/components/EventAddForm/components/SingleDateTimeInput.js +0 -102
- package/dist/components/EventAddForm/components/SingleDateTimeInput.js.map +0 -1
- package/dist/components/EventAddForm/components/StepTwo/CustomFormSection.js +0 -277
- package/dist/components/EventAddForm/components/StepTwo/CustomFormSection.js.map +0 -1
- package/dist/components/EventAddForm/components/StepTwo/TicketTierSection.js +0 -148
- package/dist/components/EventAddForm/components/StepTwo/TicketTierSection.js.map +0 -1
- package/dist/components/EventAddForm/components/TicketTierForm.js +0 -418
- package/dist/components/EventAddForm/components/TicketTierForm.js.map +0 -1
- package/dist/components/EventAddForm/components/TicketTypeSelection.js +0 -93
- package/dist/components/EventAddForm/components/TicketTypeSelection.js.map +0 -1
- package/dist/components/EventAddForm/hooks/useStepperForm.js +0 -371
- package/dist/components/EventAddForm/hooks/useStepperForm.js.map +0 -1
- package/dist/components/EventAddForm/hooks/useTicketTierForm.js +0 -237
- package/dist/components/EventAddForm/hooks/useTicketTierForm.js.map +0 -1
- package/dist/components/EventAddForm/index.d.ts +0 -3
- package/dist/components/EventAddForm/index.js +0 -41
- package/dist/components/EventAddForm/index.js.map +0 -1
- package/dist/components/EventAddForm/schemas/index.d.ts +0 -2
- package/dist/components/EventAddForm/schemas/step1.d.ts +0 -47
- package/dist/components/EventAddForm/schemas/step1.js +0 -135
- package/dist/components/EventAddForm/schemas/step1.js.map +0 -1
- package/dist/components/EventAddForm/schemas/step2.d.ts +0 -138
- package/dist/components/EventAddForm/schemas/step2.js +0 -94
- package/dist/components/EventAddForm/schemas/step2.js.map +0 -1
- package/dist/components/EventAddForm/schemas/utils.js +0 -28
- package/dist/components/EventAddForm/schemas/utils.js.map +0 -1
- package/dist/components/EventAddForm/steps/IndividualFormStep.js +0 -85
- package/dist/components/EventAddForm/steps/IndividualFormStep.js.map +0 -1
- package/dist/components/EventAddForm/steps/SocialProfilesStep.js +0 -123
- package/dist/components/EventAddForm/steps/SocialProfilesStep.js.map +0 -1
- package/dist/components/EventAddForm/steps/StepOne.js +0 -462
- package/dist/components/EventAddForm/steps/StepOne.js.map +0 -1
- package/dist/components/EventAddForm/steps/StepTwo.js +0 -173
- package/dist/components/EventAddForm/steps/StepTwo.js.map +0 -1
- package/dist/components/EventAddForm/steps/TeamFormStep.js +0 -13
- package/dist/components/EventAddForm/steps/TeamFormStep.js.map +0 -1
- package/dist/components/FormBuilder/CategoryList.js +0 -242
- package/dist/components/FormBuilder/CategoryList.js.map +0 -1
- package/dist/components/FormBuilder/DiscountInput.js +0 -366
- package/dist/components/FormBuilder/DiscountInput.js.map +0 -1
- package/dist/components/FormBuilder/FormBuilder.js +0 -918
- package/dist/components/FormBuilder/FormBuilder.js.map +0 -1
- package/dist/components/FormBuilder/OptionList.js +0 -120
- package/dist/components/FormBuilder/OptionList.js.map +0 -1
- package/dist/components/FormBuilder/PaymentPreview.d.ts +0 -12
- package/dist/components/FormBuilder/PaymentPreview.js +0 -70
- package/dist/components/FormBuilder/PaymentPreview.js.map +0 -1
- package/dist/components/FormBuilder/PreviewInput.d.ts +0 -10
- package/dist/components/FormBuilder/PreviewInput.js +0 -143
- package/dist/components/FormBuilder/PreviewInput.js.map +0 -1
- package/dist/components/FormBuilder/QuestionCard.js +0 -252
- package/dist/components/FormBuilder/QuestionCard.js.map +0 -1
- package/dist/components/FormBuilder/QuestionEditor.js +0 -166
- package/dist/components/FormBuilder/QuestionEditor.js.map +0 -1
- package/dist/components/FormBuilder/RequiredToggle.js +0 -43
- package/dist/components/FormBuilder/RequiredToggle.js.map +0 -1
- package/dist/components/FormBuilder/SortableQuestionList.js +0 -137
- package/dist/components/FormBuilder/SortableQuestionList.js.map +0 -1
- package/dist/components/FormBuilder/index.d.ts +0 -4
- package/dist/components/FormBuilder/utils.js +0 -229
- package/dist/components/FormBuilder/utils.js.map +0 -1
- package/dist/components/FormInput/FormInput.js +0 -126
- package/dist/components/FormInput/FormInput.js.map +0 -1
- package/dist/components/FormInput/FormInput.test.d.ts +0 -1
- package/dist/components/FormInput/index.d.ts +0 -2
- package/dist/components/ImageCropModal/index.js +0 -464
- package/dist/components/ImageCropModal/index.js.map +0 -1
- package/dist/components/InformationPopover/InformationPopover.d.ts +0 -7
- package/dist/components/InformationPopover/InformationPopover.js +0 -19
- package/dist/components/InformationPopover/InformationPopover.js.map +0 -1
- package/dist/components/InformationPopover.js +0 -19
- package/dist/components/InformationPopover.js.map +0 -1
- package/dist/components/InputErrorMessage/InputErrorMessage.js +0 -21
- package/dist/components/InputErrorMessage/InputErrorMessage.js.map +0 -1
- package/dist/components/Modal/Modal.d.ts +0 -15
- package/dist/components/Modal/Modal.js +0 -73
- package/dist/components/Modal/Modal.js.map +0 -1
- package/dist/components/Radio/Radio.js +0 -35
- package/dist/components/Radio/Radio.js.map +0 -1
- package/dist/components/Spinner/spinner.d.ts +0 -2
- package/dist/components/Spinner/spinner.js +0 -22
- package/dist/components/Spinner/spinner.js.map +0 -1
- package/dist/components/Toggle/Toggle.d.ts +0 -16
- package/dist/components/Toggle/index.d.ts +0 -2
- package/dist/components/Tooltip/Tooltip.d.ts +0 -12
- package/dist/components/Tooltip/Tooltip.js +0 -134
- package/dist/components/Tooltip/Tooltip.js.map +0 -1
- package/dist/components/common/FallbackImage.js +0 -47
- package/dist/components/common/FallbackImage.js.map +0 -1
- package/dist/components/ui/Calendar/calendar-utils.js +0 -51
- package/dist/components/ui/Calendar/calendar-utils.js.map +0 -1
- package/dist/components/ui/Calendar/index.js +0 -142
- package/dist/components/ui/Calendar/index.js.map +0 -1
- package/dist/components/ui/Checkbox.d.ts +0 -9
- package/dist/components/ui/Checkbox.js +0 -50
- package/dist/components/ui/Checkbox.js.map +0 -1
- package/dist/components/ui/DatePicker/index.js +0 -188
- package/dist/components/ui/DatePicker/index.js.map +0 -1
- package/dist/components/ui/FormInput.js +0 -129
- package/dist/components/ui/FormInput.js.map +0 -1
- package/dist/components/ui/InputErrorMessage.d.ts +0 -7
- package/dist/components/ui/InputErrorMessage.js +0 -21
- package/dist/components/ui/InputErrorMessage.js.map +0 -1
- package/dist/components/ui/Modal/index.js +0 -73
- package/dist/components/ui/Modal/index.js.map +0 -1
- package/dist/components/ui/Radio.d.ts +0 -6
- package/dist/components/ui/Radio.js +0 -35
- package/dist/components/ui/Radio.js.map +0 -1
- package/dist/components/ui/RichTextEditor.js +0 -242
- package/dist/components/ui/RichTextEditor.js.map +0 -1
- package/dist/components/ui/TimePicker/index.js +0 -215
- package/dist/components/ui/TimePicker/index.js.map +0 -1
- package/dist/components/ui/TimeSelector/index.js +0 -138
- package/dist/components/ui/TimeSelector/index.js.map +0 -1
- package/dist/components/ui/Tooltip.d.ts +0 -12
- package/dist/components/ui/Tooltip.js +0 -136
- package/dist/components/ui/Tooltip.js.map +0 -1
- package/dist/hooks/useDropdownPosition.d.ts +0 -11
- package/dist/hooks/useFirebaseAuthState.d.ts +0 -6
- package/dist/hooks/useFirebaseAuthState.js +0 -23
- package/dist/hooks/useFirebaseAuthState.js.map +0 -1
- package/dist/hooks/useTicketTierForm.d.ts +0 -61
- package/dist/lib/actions.js +0 -32
- package/dist/lib/actions.js.map +0 -1
- package/dist/lib/cropImage.js +0 -113
- package/dist/lib/cropImage.js.map +0 -1
- package/dist/lib/imageAnalysis.js +0 -58
- package/dist/lib/imageAnalysis.js.map +0 -1
- package/dist/lib/utils.js +0 -9
- package/dist/lib/utils.js.map +0 -1
- package/dist/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.js +0 -60
- package/dist/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.js.map +0 -1
- package/dist/node_modules/@dnd-kit/core/dist/core.esm.js +0 -3458
- package/dist/node_modules/@dnd-kit/core/dist/core.esm.js.map +0 -1
- package/dist/node_modules/@dnd-kit/sortable/dist/sortable.esm.js +0 -593
- package/dist/node_modules/@dnd-kit/sortable/dist/sortable.esm.js.map +0 -1
- package/dist/node_modules/@dnd-kit/utilities/dist/utilities.esm.js +0 -302
- package/dist/node_modules/@dnd-kit/utilities/dist/utilities.esm.js.map +0 -1
- package/dist/node_modules/@firebase/app/dist/esm/index.esm.js +0 -768
- package/dist/node_modules/@firebase/app/dist/esm/index.esm.js.map +0 -1
- package/dist/node_modules/@firebase/component/dist/esm/index.esm.js +0 -340
- package/dist/node_modules/@firebase/component/dist/esm/index.esm.js.map +0 -1
- package/dist/node_modules/@firebase/logger/dist/esm/index.esm.js +0 -123
- package/dist/node_modules/@firebase/logger/dist/esm/index.esm.js.map +0 -1
- package/dist/node_modules/@firebase/storage/dist/index.esm.js +0 -2623
- package/dist/node_modules/@firebase/storage/dist/index.esm.js.map +0 -1
- package/dist/node_modules/@firebase/util/dist/index.esm.js +0 -658
- package/dist/node_modules/@firebase/util/dist/index.esm.js.map +0 -1
- package/dist/node_modules/@firebase/util/dist/postinstall.js +0 -5
- package/dist/node_modules/@firebase/util/dist/postinstall.js.map +0 -1
- package/dist/node_modules/@fortawesome/fontawesome-svg-core/index.js +0 -3179
- package/dist/node_modules/@fortawesome/fontawesome-svg-core/index.js.map +0 -1
- package/dist/node_modules/@fortawesome/free-solid-svg-icons/index.js +0 -60
- package/dist/node_modules/@fortawesome/free-solid-svg-icons/index.js.map +0 -1
- package/dist/node_modules/@fortawesome/react-fontawesome/dist/index.js +0 -400
- package/dist/node_modules/@fortawesome/react-fontawesome/dist/index.js.map +0 -1
- package/dist/node_modules/@heroicons/react/20/solid/esm/CheckIcon.js +0 -27
- package/dist/node_modules/@heroicons/react/20/solid/esm/CheckIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/20/solid/esm/ChevronDownIcon.js +0 -27
- package/dist/node_modules/@heroicons/react/20/solid/esm/ChevronDownIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/ArrowRightIcon.js +0 -29
- package/dist/node_modules/@heroicons/react/24/outline/esm/ArrowRightIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/ClockIcon.js +0 -29
- package/dist/node_modules/@heroicons/react/24/outline/esm/ClockIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/DocumentDuplicateIcon.js +0 -29
- package/dist/node_modules/@heroicons/react/24/outline/esm/DocumentDuplicateIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/InformationCircleIcon.js +0 -29
- package/dist/node_modules/@heroicons/react/24/outline/esm/InformationCircleIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/LinkIcon.js +0 -29
- package/dist/node_modules/@heroicons/react/24/outline/esm/LinkIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/MagnifyingGlassIcon.js +0 -29
- package/dist/node_modules/@heroicons/react/24/outline/esm/MagnifyingGlassIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/MapPinIcon.js +0 -33
- package/dist/node_modules/@heroicons/react/24/outline/esm/MapPinIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/VideoCameraIcon.js +0 -29
- package/dist/node_modules/@heroicons/react/24/outline/esm/VideoCameraIcon.js.map +0 -1
- package/dist/node_modules/@heroicons/react/24/outline/esm/XMarkIcon.js +0 -29
- package/dist/node_modules/@heroicons/react/24/outline/esm/XMarkIcon.js.map +0 -1
- package/dist/node_modules/@tiptap/core/dist/index.js +0 -5446
- package/dist/node_modules/@tiptap/core/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js +0 -21
- package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-blockquote/dist/index.js +0 -78
- package/dist/node_modules/@tiptap/extension-blockquote/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-bold/dist/index.js +0 -100
- package/dist/node_modules/@tiptap/extension-bold/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-code/dist/index.js +0 -70
- package/dist/node_modules/@tiptap/extension-code/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-code-block/dist/index.js +0 -317
- package/dist/node_modules/@tiptap/extension-code-block/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-document/dist/index.js +0 -16
- package/dist/node_modules/@tiptap/extension-document/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js +0 -66
- package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-heading/dist/index.js +0 -86
- package/dist/node_modules/@tiptap/extension-heading/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js +0 -80
- package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-italic/dist/index.js +0 -98
- package/dist/node_modules/@tiptap/extension-italic/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-link/dist/index.js +0 -423
- package/dist/node_modules/@tiptap/extension-link/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-list/dist/index.js +0 -1039
- package/dist/node_modules/@tiptap/extension-list/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js +0 -61
- package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-placeholder/dist/index.js +0 -7
- package/dist/node_modules/@tiptap/extension-placeholder/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-strike/dist/index.js +0 -79
- package/dist/node_modules/@tiptap/extension-strike/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-text/dist/index.js +0 -16
- package/dist/node_modules/@tiptap/extension-text/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extension-underline/dist/index.js +0 -76
- package/dist/node_modules/@tiptap/extension-underline/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/extensions/dist/index.js +0 -376
- package/dist/node_modules/@tiptap/extensions/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/react/dist/index.js +0 -650
- package/dist/node_modules/@tiptap/react/dist/index.js.map +0 -1
- package/dist/node_modules/@tiptap/starter-kit/dist/index.js +0 -97
- package/dist/node_modules/@tiptap/starter-kit/dist/index.js.map +0 -1
- package/dist/node_modules/dayjs/dayjs.min.js +0 -283
- package/dist/node_modules/dayjs/dayjs.min.js.map +0 -1
- package/dist/node_modules/dayjs/plugin/customParseFormat.js +0 -130
- package/dist/node_modules/dayjs/plugin/customParseFormat.js.map +0 -1
- package/dist/node_modules/dayjs/plugin/duration.js +0 -137
- package/dist/node_modules/dayjs/plugin/duration.js.map +0 -1
- package/dist/node_modules/dayjs/plugin/isBetween.js +0 -20
- package/dist/node_modules/dayjs/plugin/isBetween.js.map +0 -1
- package/dist/node_modules/dayjs/plugin/relativeTime.js +0 -49
- package/dist/node_modules/dayjs/plugin/relativeTime.js.map +0 -1
- package/dist/node_modules/fast-equals/dist/es/index.js +0 -442
- package/dist/node_modules/fast-equals/dist/es/index.js.map +0 -1
- package/dist/node_modules/idb/build/index.js +0 -70
- package/dist/node_modules/idb/build/index.js.map +0 -1
- package/dist/node_modules/idb/build/wrap-idb-value.js +0 -149
- package/dist/node_modules/idb/build/wrap-idb-value.js.map +0 -1
- package/dist/node_modules/linkifyjs/dist/linkify.js +0 -1159
- package/dist/node_modules/linkifyjs/dist/linkify.js.map +0 -1
- package/dist/node_modules/orderedmap/dist/index.js +0 -120
- package/dist/node_modules/orderedmap/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-commands/dist/index.js +0 -527
- package/dist/node_modules/prosemirror-commands/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-dropcursor/dist/index.js +0 -137
- package/dist/node_modules/prosemirror-dropcursor/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-gapcursor/dist/index.js +0 -221
- package/dist/node_modules/prosemirror-gapcursor/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-history/dist/index.js +0 -357
- package/dist/node_modules/prosemirror-history/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-keymap/dist/index.js +0 -84
- package/dist/node_modules/prosemirror-keymap/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-model/dist/index.js +0 -3209
- package/dist/node_modules/prosemirror-model/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-schema-list/dist/index.js +0 -131
- package/dist/node_modules/prosemirror-schema-list/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-state/dist/index.js +0 -936
- package/dist/node_modules/prosemirror-state/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-transform/dist/index.js +0 -1881
- package/dist/node_modules/prosemirror-transform/dist/index.js.map +0 -1
- package/dist/node_modules/prosemirror-view/dist/index.js +0 -5232
- package/dist/node_modules/prosemirror-view/dist/index.js.map +0 -1
- package/dist/node_modules/rope-sequence/dist/index.js +0 -184
- package/dist/node_modules/rope-sequence/dist/index.js.map +0 -1
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +0 -82
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +0 -1
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +0 -78
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js.map +0 -1
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +0 -78
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +0 -1
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +0 -63
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js.map +0 -1
- package/dist/node_modules/use-sync-external-store/shim/index.js +0 -13
- package/dist/node_modules/use-sync-external-store/shim/index.js.map +0 -1
- package/dist/node_modules/use-sync-external-store/shim/with-selector.js +0 -13
- package/dist/node_modules/use-sync-external-store/shim/with-selector.js.map +0 -1
- package/dist/node_modules/w3c-keyname/index.js +0 -106
- package/dist/node_modules/w3c-keyname/index.js.map +0 -1
- package/dist/node_modules/zod/v4/classic/coerce.js +0 -10
- package/dist/node_modules/zod/v4/classic/coerce.js.map +0 -1
- package/dist/node_modules/zod/v4/classic/compat.js +0 -8
- package/dist/node_modules/zod/v4/classic/compat.js.map +0 -1
- package/dist/node_modules/zod/v4/classic/errors.js +0 -45
- package/dist/node_modules/zod/v4/classic/errors.js.map +0 -1
- package/dist/node_modules/zod/v4/classic/iso.js +0 -44
- package/dist/node_modules/zod/v4/classic/iso.js.map +0 -1
- package/dist/node_modules/zod/v4/classic/parse.js +0 -30
- package/dist/node_modules/zod/v4/classic/parse.js.map +0 -1
- package/dist/node_modules/zod/v4/classic/schemas.js +0 -711
- package/dist/node_modules/zod/v4/classic/schemas.js.map +0 -1
- package/dist/node_modules/zod/v4/core/api.js +0 -588
- package/dist/node_modules/zod/v4/core/api.js.map +0 -1
- package/dist/node_modules/zod/v4/core/checks.js +0 -411
- package/dist/node_modules/zod/v4/core/checks.js.map +0 -1
- package/dist/node_modules/zod/v4/core/core.js +0 -75
- package/dist/node_modules/zod/v4/core/core.js.map +0 -1
- package/dist/node_modules/zod/v4/core/doc.js +0 -38
- package/dist/node_modules/zod/v4/core/doc.js.map +0 -1
- package/dist/node_modules/zod/v4/core/errors.js +0 -73
- package/dist/node_modules/zod/v4/core/errors.js.map +0 -1
- package/dist/node_modules/zod/v4/core/json-schema-processors.js +0 -359
- package/dist/node_modules/zod/v4/core/json-schema-processors.js.map +0 -1
- package/dist/node_modules/zod/v4/core/parse.js +0 -96
- package/dist/node_modules/zod/v4/core/parse.js.map +0 -1
- package/dist/node_modules/zod/v4/core/regexes.js +0 -84
- package/dist/node_modules/zod/v4/core/regexes.js.map +0 -1
- package/dist/node_modules/zod/v4/core/registries.js +0 -52
- package/dist/node_modules/zod/v4/core/registries.js.map +0 -1
- package/dist/node_modules/zod/v4/core/schemas.js +0 -1391
- package/dist/node_modules/zod/v4/core/schemas.js.map +0 -1
- package/dist/node_modules/zod/v4/core/to-json-schema.js +0 -363
- package/dist/node_modules/zod/v4/core/to-json-schema.js.map +0 -1
- package/dist/node_modules/zod/v4/core/util.js +0 -431
- package/dist/node_modules/zod/v4/core/util.js.map +0 -1
- package/dist/node_modules/zod/v4/core/versions.js +0 -9
- package/dist/node_modules/zod/v4/core/versions.js.map +0 -1
- package/dist/redux/baseQuery.d.ts +0 -1
- package/dist/redux/baseQuery.js +0 -24
- package/dist/redux/baseQuery.js.map +0 -1
- package/dist/services/eventApi.js +0 -411
- package/dist/services/eventApi.js.map +0 -1
- package/dist/services/helpers.js +0 -115
- package/dist/services/helpers.js.map +0 -1
- package/dist/services/initialize-firebase.d.ts +0 -2
- package/dist/services/initialize-firebase.js +0 -20
- package/dist/services/initialize-firebase.js.map +0 -1
- package/dist/services/process-image-on-server.js +0 -30
- package/dist/services/process-image-on-server.js.map +0 -1
- package/dist/services/remote-config.d.ts +0 -5
- package/dist/services/remote-config.js +0 -9
- package/dist/services/remote-config.js.map +0 -1
- package/dist/services/single-event-api.js +0 -301
- package/dist/services/single-event-api.js.map +0 -1
- package/dist/services/utils.js +0 -107
- package/dist/services/utils.js.map +0 -1
- package/dist/setupTests.d.ts +0 -1
- package/dist/stories/Alert.stories.d.ts +0 -10
- package/dist/stories/Button.stories.d.ts +0 -13
- package/dist/types/redux-types.d.ts +0 -15
- package/dist/types/types.d.ts +0 -60
- package/dist/types/types.js +0 -10
- package/dist/types/types.js.map +0 -1
- package/dist/utils/cn.d.ts +0 -6
- package/dist/utils/cn.js +0 -9
- package/dist/utils/cn.js.map +0 -1
- package/dist/utils/date-range.d.ts +0 -4
- package/dist/utils/date-range.js +0 -13
- package/dist/utils/date-range.js.map +0 -1
- package/dist/utils/single-event-helpers.d.ts +0 -50
- package/dist/utils/single-event-helpers.js +0 -18
- package/dist/utils/single-event-helpers.js.map +0 -1
- package/dist/utils/social-validation.js +0 -42
- package/dist/utils/social-validation.js.map +0 -1
- package/dist/utils/utils.js +0 -20
- package/dist/utils/utils.js.map +0 -1
- /package/dist/{components/Alert/Alert.d.ts → src/components/Alert/index.d.ts} +0 -0
- /package/dist/{components → src/components}/FormBuilder/CategoryList.d.ts +0 -0
- /package/dist/{components → src/components}/FormBuilder/OptionList.d.ts +0 -0
- /package/dist/{components → src/components}/FormBuilder/RequiredToggle.d.ts +0 -0
- /package/dist/{components → src/components}/FormBuilder/types.d.ts +0 -0
- /package/dist/{components → src/components}/FormBuilder/utils.d.ts +0 -0
- /package/dist/{components → src/components}/ImageCropModal/index.d.ts +0 -0
- /package/dist/{components → src/components}/InformationPopover.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/common/DescriptionModal.d.ts +0 -0
- /package/dist/{components/ui/FormInput.d.ts → src/components/NewAddEvent/components/AddEventFormInput.d.ts} +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/CheckboxGroup.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/CustomMeetingForm.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/DateTimeField.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/FileUpload.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/FormBuilderProceedModal.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/GoogleMapsAutocompleteInput.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/SingleDateTimeInput.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/StepTwo/CustomFormSection.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/components/TicketTypeSelection.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/steps/StepOne.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/steps/StepTwo.d.ts +0 -0
- /package/dist/{components/EventAddForm → src/components/NewAddEvent}/types.d.ts +0 -0
- /package/dist/{components → src/components}/common/FallbackImage.d.ts +0 -0
- /package/dist/{components → src/components}/ui/Calendar/calendar-utils.d.ts +0 -0
- /package/dist/{components → src/components}/ui/Calendar/index.d.ts +0 -0
- /package/dist/{components/Checkbox → src/components/ui}/Checkbox.d.ts +0 -0
- /package/dist/{components/CustomSelect → src/components/ui}/CustomSelect.d.ts +0 -0
- /package/dist/{components → src/components}/ui/DatePicker/index.d.ts +0 -0
- /package/dist/{components/InputErrorMessage → src/components/ui}/InputErrorMessage.d.ts +0 -0
- /package/dist/{components → src/components}/ui/Modal/index.d.ts +0 -0
- /package/dist/{components/Radio → src/components/ui}/Radio.d.ts +0 -0
- /package/dist/{components → src/components}/ui/RichTextEditor.d.ts +0 -0
- /package/dist/{components → src/components}/ui/TimePicker/index.d.ts +0 -0
- /package/dist/{components → src/components}/ui/TimeSelector/index.d.ts +0 -0
- /package/dist/{components → src/components}/ui/Tooltip/index.d.ts +0 -0
- /package/dist/{lib → src/lib}/constants.d.ts +0 -0
- /package/dist/{lib → src/lib}/cropImage.d.ts +0 -0
- /package/dist/{lib → src/lib}/imageAnalysis.d.ts +0 -0
- /package/dist/{utils → src/lib}/social-validation.d.ts +0 -0
- /package/dist/{lib/utils.d.ts → src/lib/tailwind-merge.d.ts} +0 -0
- /package/dist/{utils → src/lib}/utils.d.ts +0 -0
- /package/dist/{services → src/redux/features/single-event}/helpers.d.ts +0 -0
- /package/dist/{services → src/services}/process-image-on-server.d.ts +0 -0
- /package/dist/{types → src/types}/events.d.ts +0 -0
- /package/dist/{types → src/types}/question.d.ts +0 -0
|
@@ -1,2623 +0,0 @@
|
|
|
1
|
-
import { _getProvider, getApp, _isFirebaseServerApp, _registerComponent, registerVersion, SDK_VERSION } from "../../app/dist/esm/index.esm.js";
|
|
2
|
-
import { getModularInstance, getDefaultEmulatorHostnameAndPort, FirebaseError, isCloudWorkstation, pingServer, createMockUserToken } from "../../util/dist/index.esm.js";
|
|
3
|
-
import { Component } from "../../component/dist/esm/index.esm.js";
|
|
4
|
-
/**
|
|
5
|
-
* @license
|
|
6
|
-
* Copyright 2017 Google LLC
|
|
7
|
-
*
|
|
8
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
-
* you may not use this file except in compliance with the License.
|
|
10
|
-
* You may obtain a copy of the License at
|
|
11
|
-
*
|
|
12
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
*
|
|
14
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
-
* See the License for the specific language governing permissions and
|
|
18
|
-
* limitations under the License.
|
|
19
|
-
*/
|
|
20
|
-
const DEFAULT_HOST = "firebasestorage.googleapis.com";
|
|
21
|
-
const CONFIG_STORAGE_BUCKET_KEY = "storageBucket";
|
|
22
|
-
const DEFAULT_MAX_OPERATION_RETRY_TIME = 2 * 60 * 1e3;
|
|
23
|
-
const DEFAULT_MAX_UPLOAD_RETRY_TIME = 10 * 60 * 1e3;
|
|
24
|
-
const DEFAULT_MIN_SLEEP_TIME_MILLIS = 1e3;
|
|
25
|
-
/**
|
|
26
|
-
* @license
|
|
27
|
-
* Copyright 2017 Google LLC
|
|
28
|
-
*
|
|
29
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
30
|
-
* you may not use this file except in compliance with the License.
|
|
31
|
-
* You may obtain a copy of the License at
|
|
32
|
-
*
|
|
33
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
34
|
-
*
|
|
35
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
36
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
37
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
38
|
-
* See the License for the specific language governing permissions and
|
|
39
|
-
* limitations under the License.
|
|
40
|
-
*/
|
|
41
|
-
class StorageError extends FirebaseError {
|
|
42
|
-
/**
|
|
43
|
-
* @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and
|
|
44
|
-
* added to the end of the message.
|
|
45
|
-
* @param message - Error message.
|
|
46
|
-
* @param status_ - Corresponding HTTP Status Code
|
|
47
|
-
*/
|
|
48
|
-
constructor(code, message, status_ = 0) {
|
|
49
|
-
super(prependCode(code), `Firebase Storage: ${message} (${prependCode(code)})`);
|
|
50
|
-
this.status_ = status_;
|
|
51
|
-
this.customData = { serverResponse: null };
|
|
52
|
-
this._baseMessage = this.message;
|
|
53
|
-
Object.setPrototypeOf(this, StorageError.prototype);
|
|
54
|
-
}
|
|
55
|
-
get status() {
|
|
56
|
-
return this.status_;
|
|
57
|
-
}
|
|
58
|
-
set status(status) {
|
|
59
|
-
this.status_ = status;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Compares a `StorageErrorCode` against this error's code, filtering out the prefix.
|
|
63
|
-
*/
|
|
64
|
-
_codeEquals(code) {
|
|
65
|
-
return prependCode(code) === this.code;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Optional response message that was added by the server.
|
|
69
|
-
*/
|
|
70
|
-
get serverResponse() {
|
|
71
|
-
return this.customData.serverResponse;
|
|
72
|
-
}
|
|
73
|
-
set serverResponse(serverResponse) {
|
|
74
|
-
this.customData.serverResponse = serverResponse;
|
|
75
|
-
if (this.customData.serverResponse) {
|
|
76
|
-
this.message = `${this._baseMessage}
|
|
77
|
-
${this.customData.serverResponse}`;
|
|
78
|
-
} else {
|
|
79
|
-
this.message = this._baseMessage;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
var StorageErrorCode;
|
|
84
|
-
(function(StorageErrorCode2) {
|
|
85
|
-
StorageErrorCode2["UNKNOWN"] = "unknown";
|
|
86
|
-
StorageErrorCode2["OBJECT_NOT_FOUND"] = "object-not-found";
|
|
87
|
-
StorageErrorCode2["BUCKET_NOT_FOUND"] = "bucket-not-found";
|
|
88
|
-
StorageErrorCode2["PROJECT_NOT_FOUND"] = "project-not-found";
|
|
89
|
-
StorageErrorCode2["QUOTA_EXCEEDED"] = "quota-exceeded";
|
|
90
|
-
StorageErrorCode2["UNAUTHENTICATED"] = "unauthenticated";
|
|
91
|
-
StorageErrorCode2["UNAUTHORIZED"] = "unauthorized";
|
|
92
|
-
StorageErrorCode2["UNAUTHORIZED_APP"] = "unauthorized-app";
|
|
93
|
-
StorageErrorCode2["RETRY_LIMIT_EXCEEDED"] = "retry-limit-exceeded";
|
|
94
|
-
StorageErrorCode2["INVALID_CHECKSUM"] = "invalid-checksum";
|
|
95
|
-
StorageErrorCode2["CANCELED"] = "canceled";
|
|
96
|
-
StorageErrorCode2["INVALID_EVENT_NAME"] = "invalid-event-name";
|
|
97
|
-
StorageErrorCode2["INVALID_URL"] = "invalid-url";
|
|
98
|
-
StorageErrorCode2["INVALID_DEFAULT_BUCKET"] = "invalid-default-bucket";
|
|
99
|
-
StorageErrorCode2["NO_DEFAULT_BUCKET"] = "no-default-bucket";
|
|
100
|
-
StorageErrorCode2["CANNOT_SLICE_BLOB"] = "cannot-slice-blob";
|
|
101
|
-
StorageErrorCode2["SERVER_FILE_WRONG_SIZE"] = "server-file-wrong-size";
|
|
102
|
-
StorageErrorCode2["NO_DOWNLOAD_URL"] = "no-download-url";
|
|
103
|
-
StorageErrorCode2["INVALID_ARGUMENT"] = "invalid-argument";
|
|
104
|
-
StorageErrorCode2["INVALID_ARGUMENT_COUNT"] = "invalid-argument-count";
|
|
105
|
-
StorageErrorCode2["APP_DELETED"] = "app-deleted";
|
|
106
|
-
StorageErrorCode2["INVALID_ROOT_OPERATION"] = "invalid-root-operation";
|
|
107
|
-
StorageErrorCode2["INVALID_FORMAT"] = "invalid-format";
|
|
108
|
-
StorageErrorCode2["INTERNAL_ERROR"] = "internal-error";
|
|
109
|
-
StorageErrorCode2["UNSUPPORTED_ENVIRONMENT"] = "unsupported-environment";
|
|
110
|
-
})(StorageErrorCode || (StorageErrorCode = {}));
|
|
111
|
-
function prependCode(code) {
|
|
112
|
-
return "storage/" + code;
|
|
113
|
-
}
|
|
114
|
-
function unknown() {
|
|
115
|
-
const message = "An unknown error occurred, please check the error payload for server response.";
|
|
116
|
-
return new StorageError(StorageErrorCode.UNKNOWN, message);
|
|
117
|
-
}
|
|
118
|
-
function objectNotFound(path) {
|
|
119
|
-
return new StorageError(StorageErrorCode.OBJECT_NOT_FOUND, "Object '" + path + "' does not exist.");
|
|
120
|
-
}
|
|
121
|
-
function quotaExceeded(bucket) {
|
|
122
|
-
return new StorageError(StorageErrorCode.QUOTA_EXCEEDED, "Quota for bucket '" + bucket + "' exceeded, please view quota on https://firebase.google.com/pricing/.");
|
|
123
|
-
}
|
|
124
|
-
function unauthenticated() {
|
|
125
|
-
const message = "User is not authenticated, please authenticate using Firebase Authentication and try again.";
|
|
126
|
-
return new StorageError(StorageErrorCode.UNAUTHENTICATED, message);
|
|
127
|
-
}
|
|
128
|
-
function unauthorizedApp() {
|
|
129
|
-
return new StorageError(StorageErrorCode.UNAUTHORIZED_APP, "This app does not have permission to access Firebase Storage on this project.");
|
|
130
|
-
}
|
|
131
|
-
function unauthorized(path) {
|
|
132
|
-
return new StorageError(StorageErrorCode.UNAUTHORIZED, "User does not have permission to access '" + path + "'.");
|
|
133
|
-
}
|
|
134
|
-
function retryLimitExceeded() {
|
|
135
|
-
return new StorageError(StorageErrorCode.RETRY_LIMIT_EXCEEDED, "Max retry time for operation exceeded, please try again.");
|
|
136
|
-
}
|
|
137
|
-
function canceled() {
|
|
138
|
-
return new StorageError(StorageErrorCode.CANCELED, "User canceled the upload/download.");
|
|
139
|
-
}
|
|
140
|
-
function invalidUrl(url) {
|
|
141
|
-
return new StorageError(StorageErrorCode.INVALID_URL, "Invalid URL '" + url + "'.");
|
|
142
|
-
}
|
|
143
|
-
function invalidDefaultBucket(bucket) {
|
|
144
|
-
return new StorageError(StorageErrorCode.INVALID_DEFAULT_BUCKET, "Invalid default bucket '" + bucket + "'.");
|
|
145
|
-
}
|
|
146
|
-
function noDefaultBucket() {
|
|
147
|
-
return new StorageError(StorageErrorCode.NO_DEFAULT_BUCKET, "No default bucket found. Did you set the '" + CONFIG_STORAGE_BUCKET_KEY + "' property when initializing the app?");
|
|
148
|
-
}
|
|
149
|
-
function cannotSliceBlob() {
|
|
150
|
-
return new StorageError(StorageErrorCode.CANNOT_SLICE_BLOB, "Cannot slice blob for upload. Please retry the upload.");
|
|
151
|
-
}
|
|
152
|
-
function serverFileWrongSize() {
|
|
153
|
-
return new StorageError(StorageErrorCode.SERVER_FILE_WRONG_SIZE, "Server recorded incorrect upload file size, please retry the upload.");
|
|
154
|
-
}
|
|
155
|
-
function noDownloadURL() {
|
|
156
|
-
return new StorageError(StorageErrorCode.NO_DOWNLOAD_URL, "The given file does not have any download URLs.");
|
|
157
|
-
}
|
|
158
|
-
function missingPolyFill(polyFill) {
|
|
159
|
-
return new StorageError(StorageErrorCode.UNSUPPORTED_ENVIRONMENT, `${polyFill} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`);
|
|
160
|
-
}
|
|
161
|
-
function invalidArgument(message) {
|
|
162
|
-
return new StorageError(StorageErrorCode.INVALID_ARGUMENT, message);
|
|
163
|
-
}
|
|
164
|
-
function appDeleted() {
|
|
165
|
-
return new StorageError(StorageErrorCode.APP_DELETED, "The Firebase app was deleted.");
|
|
166
|
-
}
|
|
167
|
-
function invalidRootOperation(name2) {
|
|
168
|
-
return new StorageError(StorageErrorCode.INVALID_ROOT_OPERATION, "The operation '" + name2 + "' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').");
|
|
169
|
-
}
|
|
170
|
-
function invalidFormat(format, message) {
|
|
171
|
-
return new StorageError(StorageErrorCode.INVALID_FORMAT, "String does not match format '" + format + "': " + message);
|
|
172
|
-
}
|
|
173
|
-
function internalError(message) {
|
|
174
|
-
throw new StorageError(StorageErrorCode.INTERNAL_ERROR, "Internal error: " + message);
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* @license
|
|
178
|
-
* Copyright 2017 Google LLC
|
|
179
|
-
*
|
|
180
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
-
* you may not use this file except in compliance with the License.
|
|
182
|
-
* You may obtain a copy of the License at
|
|
183
|
-
*
|
|
184
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
-
*
|
|
186
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
187
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
-
* See the License for the specific language governing permissions and
|
|
190
|
-
* limitations under the License.
|
|
191
|
-
*/
|
|
192
|
-
class Location {
|
|
193
|
-
constructor(bucket, path) {
|
|
194
|
-
this.bucket = bucket;
|
|
195
|
-
this.path_ = path;
|
|
196
|
-
}
|
|
197
|
-
get path() {
|
|
198
|
-
return this.path_;
|
|
199
|
-
}
|
|
200
|
-
get isRoot() {
|
|
201
|
-
return this.path.length === 0;
|
|
202
|
-
}
|
|
203
|
-
fullServerUrl() {
|
|
204
|
-
const encode = encodeURIComponent;
|
|
205
|
-
return "/b/" + encode(this.bucket) + "/o/" + encode(this.path);
|
|
206
|
-
}
|
|
207
|
-
bucketOnlyServerUrl() {
|
|
208
|
-
const encode = encodeURIComponent;
|
|
209
|
-
return "/b/" + encode(this.bucket) + "/o";
|
|
210
|
-
}
|
|
211
|
-
static makeFromBucketSpec(bucketString, host) {
|
|
212
|
-
let bucketLocation;
|
|
213
|
-
try {
|
|
214
|
-
bucketLocation = Location.makeFromUrl(bucketString, host);
|
|
215
|
-
} catch (e) {
|
|
216
|
-
return new Location(bucketString, "");
|
|
217
|
-
}
|
|
218
|
-
if (bucketLocation.path === "") {
|
|
219
|
-
return bucketLocation;
|
|
220
|
-
} else {
|
|
221
|
-
throw invalidDefaultBucket(bucketString);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
static makeFromUrl(url, host) {
|
|
225
|
-
let location = null;
|
|
226
|
-
const bucketDomain = "([A-Za-z0-9.\\-_]+)";
|
|
227
|
-
function gsModify(loc) {
|
|
228
|
-
if (loc.path.charAt(loc.path.length - 1) === "/") {
|
|
229
|
-
loc.path_ = loc.path_.slice(0, -1);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
const gsPath = "(/(.*))?$";
|
|
233
|
-
const gsRegex = new RegExp("^gs://" + bucketDomain + gsPath, "i");
|
|
234
|
-
const gsIndices = { bucket: 1, path: 3 };
|
|
235
|
-
function httpModify(loc) {
|
|
236
|
-
loc.path_ = decodeURIComponent(loc.path);
|
|
237
|
-
}
|
|
238
|
-
const version2 = "v[A-Za-z0-9_]+";
|
|
239
|
-
const firebaseStorageHost = host.replace(/[.]/g, "\\.");
|
|
240
|
-
const firebaseStoragePath = "(/([^?#]*).*)?$";
|
|
241
|
-
const firebaseStorageRegExp = new RegExp(`^https?://${firebaseStorageHost}/${version2}/b/${bucketDomain}/o${firebaseStoragePath}`, "i");
|
|
242
|
-
const firebaseStorageIndices = { bucket: 1, path: 3 };
|
|
243
|
-
const cloudStorageHost = host === DEFAULT_HOST ? "(?:storage.googleapis.com|storage.cloud.google.com)" : host;
|
|
244
|
-
const cloudStoragePath = "([^?#]*)";
|
|
245
|
-
const cloudStorageRegExp = new RegExp(`^https?://${cloudStorageHost}/${bucketDomain}/${cloudStoragePath}`, "i");
|
|
246
|
-
const cloudStorageIndices = { bucket: 1, path: 2 };
|
|
247
|
-
const groups = [
|
|
248
|
-
{ regex: gsRegex, indices: gsIndices, postModify: gsModify },
|
|
249
|
-
{
|
|
250
|
-
regex: firebaseStorageRegExp,
|
|
251
|
-
indices: firebaseStorageIndices,
|
|
252
|
-
postModify: httpModify
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
regex: cloudStorageRegExp,
|
|
256
|
-
indices: cloudStorageIndices,
|
|
257
|
-
postModify: httpModify
|
|
258
|
-
}
|
|
259
|
-
];
|
|
260
|
-
for (let i = 0; i < groups.length; i++) {
|
|
261
|
-
const group = groups[i];
|
|
262
|
-
const captures = group.regex.exec(url);
|
|
263
|
-
if (captures) {
|
|
264
|
-
const bucketValue = captures[group.indices.bucket];
|
|
265
|
-
let pathValue = captures[group.indices.path];
|
|
266
|
-
if (!pathValue) {
|
|
267
|
-
pathValue = "";
|
|
268
|
-
}
|
|
269
|
-
location = new Location(bucketValue, pathValue);
|
|
270
|
-
group.postModify(location);
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
if (location == null) {
|
|
275
|
-
throw invalidUrl(url);
|
|
276
|
-
}
|
|
277
|
-
return location;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
class FailRequest {
|
|
281
|
-
constructor(error) {
|
|
282
|
-
this.promise_ = Promise.reject(error);
|
|
283
|
-
}
|
|
284
|
-
/** @inheritDoc */
|
|
285
|
-
getPromise() {
|
|
286
|
-
return this.promise_;
|
|
287
|
-
}
|
|
288
|
-
/** @inheritDoc */
|
|
289
|
-
cancel(_appDelete = false) {
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* @license
|
|
294
|
-
* Copyright 2017 Google LLC
|
|
295
|
-
*
|
|
296
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
297
|
-
* you may not use this file except in compliance with the License.
|
|
298
|
-
* You may obtain a copy of the License at
|
|
299
|
-
*
|
|
300
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
301
|
-
*
|
|
302
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
303
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
304
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
305
|
-
* See the License for the specific language governing permissions and
|
|
306
|
-
* limitations under the License.
|
|
307
|
-
*/
|
|
308
|
-
function start(doRequest, backoffCompleteCb, timeout) {
|
|
309
|
-
let waitSeconds = 1;
|
|
310
|
-
let retryTimeoutId = null;
|
|
311
|
-
let globalTimeoutId = null;
|
|
312
|
-
let hitTimeout = false;
|
|
313
|
-
let cancelState = 0;
|
|
314
|
-
function canceled2() {
|
|
315
|
-
return cancelState === 2;
|
|
316
|
-
}
|
|
317
|
-
let triggeredCallback = false;
|
|
318
|
-
function triggerCallback(...args) {
|
|
319
|
-
if (!triggeredCallback) {
|
|
320
|
-
triggeredCallback = true;
|
|
321
|
-
backoffCompleteCb.apply(null, args);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
function callWithDelay(millis) {
|
|
325
|
-
retryTimeoutId = setTimeout(() => {
|
|
326
|
-
retryTimeoutId = null;
|
|
327
|
-
doRequest(responseHandler, canceled2());
|
|
328
|
-
}, millis);
|
|
329
|
-
}
|
|
330
|
-
function clearGlobalTimeout() {
|
|
331
|
-
if (globalTimeoutId) {
|
|
332
|
-
clearTimeout(globalTimeoutId);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
function responseHandler(success, ...args) {
|
|
336
|
-
if (triggeredCallback) {
|
|
337
|
-
clearGlobalTimeout();
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
if (success) {
|
|
341
|
-
clearGlobalTimeout();
|
|
342
|
-
triggerCallback.call(null, success, ...args);
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
const mustStop = canceled2() || hitTimeout;
|
|
346
|
-
if (mustStop) {
|
|
347
|
-
clearGlobalTimeout();
|
|
348
|
-
triggerCallback.call(null, success, ...args);
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
|
-
if (waitSeconds < 64) {
|
|
352
|
-
waitSeconds *= 2;
|
|
353
|
-
}
|
|
354
|
-
let waitMillis;
|
|
355
|
-
if (cancelState === 1) {
|
|
356
|
-
cancelState = 2;
|
|
357
|
-
waitMillis = 0;
|
|
358
|
-
} else {
|
|
359
|
-
waitMillis = (waitSeconds + Math.random()) * 1e3;
|
|
360
|
-
}
|
|
361
|
-
callWithDelay(waitMillis);
|
|
362
|
-
}
|
|
363
|
-
let stopped = false;
|
|
364
|
-
function stop2(wasTimeout) {
|
|
365
|
-
if (stopped) {
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
stopped = true;
|
|
369
|
-
clearGlobalTimeout();
|
|
370
|
-
if (triggeredCallback) {
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
if (retryTimeoutId !== null) {
|
|
374
|
-
if (!wasTimeout) {
|
|
375
|
-
cancelState = 2;
|
|
376
|
-
}
|
|
377
|
-
clearTimeout(retryTimeoutId);
|
|
378
|
-
callWithDelay(0);
|
|
379
|
-
} else {
|
|
380
|
-
if (!wasTimeout) {
|
|
381
|
-
cancelState = 1;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
callWithDelay(0);
|
|
386
|
-
globalTimeoutId = setTimeout(() => {
|
|
387
|
-
hitTimeout = true;
|
|
388
|
-
stop2(true);
|
|
389
|
-
}, timeout);
|
|
390
|
-
return stop2;
|
|
391
|
-
}
|
|
392
|
-
function stop(id) {
|
|
393
|
-
id(false);
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* @license
|
|
397
|
-
* Copyright 2017 Google LLC
|
|
398
|
-
*
|
|
399
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
400
|
-
* you may not use this file except in compliance with the License.
|
|
401
|
-
* You may obtain a copy of the License at
|
|
402
|
-
*
|
|
403
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
404
|
-
*
|
|
405
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
406
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
407
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
408
|
-
* See the License for the specific language governing permissions and
|
|
409
|
-
* limitations under the License.
|
|
410
|
-
*/
|
|
411
|
-
function isJustDef(p) {
|
|
412
|
-
return p !== void 0;
|
|
413
|
-
}
|
|
414
|
-
function isFunction(p) {
|
|
415
|
-
return typeof p === "function";
|
|
416
|
-
}
|
|
417
|
-
function isNonArrayObject(p) {
|
|
418
|
-
return typeof p === "object" && !Array.isArray(p);
|
|
419
|
-
}
|
|
420
|
-
function isString(p) {
|
|
421
|
-
return typeof p === "string" || p instanceof String;
|
|
422
|
-
}
|
|
423
|
-
function isNativeBlob(p) {
|
|
424
|
-
return isNativeBlobDefined() && p instanceof Blob;
|
|
425
|
-
}
|
|
426
|
-
function isNativeBlobDefined() {
|
|
427
|
-
return typeof Blob !== "undefined";
|
|
428
|
-
}
|
|
429
|
-
function validateNumber(argument, minValue, maxValue, value) {
|
|
430
|
-
if (value < minValue) {
|
|
431
|
-
throw invalidArgument(`Invalid value for '${argument}'. Expected ${minValue} or greater.`);
|
|
432
|
-
}
|
|
433
|
-
if (value > maxValue) {
|
|
434
|
-
throw invalidArgument(`Invalid value for '${argument}'. Expected ${maxValue} or less.`);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
/**
|
|
438
|
-
* @license
|
|
439
|
-
* Copyright 2017 Google LLC
|
|
440
|
-
*
|
|
441
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
442
|
-
* you may not use this file except in compliance with the License.
|
|
443
|
-
* You may obtain a copy of the License at
|
|
444
|
-
*
|
|
445
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
446
|
-
*
|
|
447
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
448
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
449
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
450
|
-
* See the License for the specific language governing permissions and
|
|
451
|
-
* limitations under the License.
|
|
452
|
-
*/
|
|
453
|
-
function makeUrl(urlPart, host, protocol) {
|
|
454
|
-
let origin = host;
|
|
455
|
-
if (protocol == null) {
|
|
456
|
-
origin = `https://${host}`;
|
|
457
|
-
}
|
|
458
|
-
return `${protocol}://${origin}/v0${urlPart}`;
|
|
459
|
-
}
|
|
460
|
-
function makeQueryString(params) {
|
|
461
|
-
const encode = encodeURIComponent;
|
|
462
|
-
let queryPart = "?";
|
|
463
|
-
for (const key in params) {
|
|
464
|
-
if (params.hasOwnProperty(key)) {
|
|
465
|
-
const nextPart = encode(key) + "=" + encode(params[key]);
|
|
466
|
-
queryPart = queryPart + nextPart + "&";
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
queryPart = queryPart.slice(0, -1);
|
|
470
|
-
return queryPart;
|
|
471
|
-
}
|
|
472
|
-
var ErrorCode;
|
|
473
|
-
(function(ErrorCode2) {
|
|
474
|
-
ErrorCode2[ErrorCode2["NO_ERROR"] = 0] = "NO_ERROR";
|
|
475
|
-
ErrorCode2[ErrorCode2["NETWORK_ERROR"] = 1] = "NETWORK_ERROR";
|
|
476
|
-
ErrorCode2[ErrorCode2["ABORT"] = 2] = "ABORT";
|
|
477
|
-
})(ErrorCode || (ErrorCode = {}));
|
|
478
|
-
/**
|
|
479
|
-
* @license
|
|
480
|
-
* Copyright 2022 Google LLC
|
|
481
|
-
*
|
|
482
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
483
|
-
* you may not use this file except in compliance with the License.
|
|
484
|
-
* You may obtain a copy of the License at
|
|
485
|
-
*
|
|
486
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
487
|
-
*
|
|
488
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
489
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
490
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
491
|
-
* See the License for the specific language governing permissions and
|
|
492
|
-
* limitations under the License.
|
|
493
|
-
*/
|
|
494
|
-
function isRetryStatusCode(status, additionalRetryCodes) {
|
|
495
|
-
const isFiveHundredCode = status >= 500 && status < 600;
|
|
496
|
-
const extraRetryCodes = [
|
|
497
|
-
// Request Timeout: web server didn't receive full request in time.
|
|
498
|
-
408,
|
|
499
|
-
// Too Many Requests: you're getting rate-limited, basically.
|
|
500
|
-
429
|
|
501
|
-
];
|
|
502
|
-
const isExtraRetryCode = extraRetryCodes.indexOf(status) !== -1;
|
|
503
|
-
const isAdditionalRetryCode = additionalRetryCodes.indexOf(status) !== -1;
|
|
504
|
-
return isFiveHundredCode || isExtraRetryCode || isAdditionalRetryCode;
|
|
505
|
-
}
|
|
506
|
-
/**
|
|
507
|
-
* @license
|
|
508
|
-
* Copyright 2017 Google LLC
|
|
509
|
-
*
|
|
510
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
511
|
-
* you may not use this file except in compliance with the License.
|
|
512
|
-
* You may obtain a copy of the License at
|
|
513
|
-
*
|
|
514
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
515
|
-
*
|
|
516
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
517
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
518
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
519
|
-
* See the License for the specific language governing permissions and
|
|
520
|
-
* limitations under the License.
|
|
521
|
-
*/
|
|
522
|
-
class NetworkRequest {
|
|
523
|
-
constructor(url_, method_, headers_, body_, successCodes_, additionalRetryCodes_, callback_, errorCallback_, timeout_, progressCallback_, connectionFactory_, retry = true, isUsingEmulator = false) {
|
|
524
|
-
this.url_ = url_;
|
|
525
|
-
this.method_ = method_;
|
|
526
|
-
this.headers_ = headers_;
|
|
527
|
-
this.body_ = body_;
|
|
528
|
-
this.successCodes_ = successCodes_;
|
|
529
|
-
this.additionalRetryCodes_ = additionalRetryCodes_;
|
|
530
|
-
this.callback_ = callback_;
|
|
531
|
-
this.errorCallback_ = errorCallback_;
|
|
532
|
-
this.timeout_ = timeout_;
|
|
533
|
-
this.progressCallback_ = progressCallback_;
|
|
534
|
-
this.connectionFactory_ = connectionFactory_;
|
|
535
|
-
this.retry = retry;
|
|
536
|
-
this.isUsingEmulator = isUsingEmulator;
|
|
537
|
-
this.pendingConnection_ = null;
|
|
538
|
-
this.backoffId_ = null;
|
|
539
|
-
this.canceled_ = false;
|
|
540
|
-
this.appDelete_ = false;
|
|
541
|
-
this.promise_ = new Promise((resolve, reject) => {
|
|
542
|
-
this.resolve_ = resolve;
|
|
543
|
-
this.reject_ = reject;
|
|
544
|
-
this.start_();
|
|
545
|
-
});
|
|
546
|
-
}
|
|
547
|
-
/**
|
|
548
|
-
* Actually starts the retry loop.
|
|
549
|
-
*/
|
|
550
|
-
start_() {
|
|
551
|
-
const doTheRequest = (backoffCallback, canceled2) => {
|
|
552
|
-
if (canceled2) {
|
|
553
|
-
backoffCallback(false, new RequestEndStatus(false, null, true));
|
|
554
|
-
return;
|
|
555
|
-
}
|
|
556
|
-
const connection = this.connectionFactory_();
|
|
557
|
-
this.pendingConnection_ = connection;
|
|
558
|
-
const progressListener = (progressEvent) => {
|
|
559
|
-
const loaded = progressEvent.loaded;
|
|
560
|
-
const total = progressEvent.lengthComputable ? progressEvent.total : -1;
|
|
561
|
-
if (this.progressCallback_ !== null) {
|
|
562
|
-
this.progressCallback_(loaded, total);
|
|
563
|
-
}
|
|
564
|
-
};
|
|
565
|
-
if (this.progressCallback_ !== null) {
|
|
566
|
-
connection.addUploadProgressListener(progressListener);
|
|
567
|
-
}
|
|
568
|
-
connection.send(this.url_, this.method_, this.isUsingEmulator, this.body_, this.headers_).then(() => {
|
|
569
|
-
if (this.progressCallback_ !== null) {
|
|
570
|
-
connection.removeUploadProgressListener(progressListener);
|
|
571
|
-
}
|
|
572
|
-
this.pendingConnection_ = null;
|
|
573
|
-
const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;
|
|
574
|
-
const status = connection.getStatus();
|
|
575
|
-
if (!hitServer || isRetryStatusCode(status, this.additionalRetryCodes_) && this.retry) {
|
|
576
|
-
const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;
|
|
577
|
-
backoffCallback(false, new RequestEndStatus(false, null, wasCanceled));
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
|
-
const successCode = this.successCodes_.indexOf(status) !== -1;
|
|
581
|
-
backoffCallback(true, new RequestEndStatus(successCode, connection));
|
|
582
|
-
});
|
|
583
|
-
};
|
|
584
|
-
const backoffDone = (requestWentThrough, status) => {
|
|
585
|
-
const resolve = this.resolve_;
|
|
586
|
-
const reject = this.reject_;
|
|
587
|
-
const connection = status.connection;
|
|
588
|
-
if (status.wasSuccessCode) {
|
|
589
|
-
try {
|
|
590
|
-
const result = this.callback_(connection, connection.getResponse());
|
|
591
|
-
if (isJustDef(result)) {
|
|
592
|
-
resolve(result);
|
|
593
|
-
} else {
|
|
594
|
-
resolve();
|
|
595
|
-
}
|
|
596
|
-
} catch (e) {
|
|
597
|
-
reject(e);
|
|
598
|
-
}
|
|
599
|
-
} else {
|
|
600
|
-
if (connection !== null) {
|
|
601
|
-
const err = unknown();
|
|
602
|
-
err.serverResponse = connection.getErrorText();
|
|
603
|
-
if (this.errorCallback_) {
|
|
604
|
-
reject(this.errorCallback_(connection, err));
|
|
605
|
-
} else {
|
|
606
|
-
reject(err);
|
|
607
|
-
}
|
|
608
|
-
} else {
|
|
609
|
-
if (status.canceled) {
|
|
610
|
-
const err = this.appDelete_ ? appDeleted() : canceled();
|
|
611
|
-
reject(err);
|
|
612
|
-
} else {
|
|
613
|
-
const err = retryLimitExceeded();
|
|
614
|
-
reject(err);
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
};
|
|
619
|
-
if (this.canceled_) {
|
|
620
|
-
backoffDone(false, new RequestEndStatus(false, null, true));
|
|
621
|
-
} else {
|
|
622
|
-
this.backoffId_ = start(doTheRequest, backoffDone, this.timeout_);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
/** @inheritDoc */
|
|
626
|
-
getPromise() {
|
|
627
|
-
return this.promise_;
|
|
628
|
-
}
|
|
629
|
-
/** @inheritDoc */
|
|
630
|
-
cancel(appDelete) {
|
|
631
|
-
this.canceled_ = true;
|
|
632
|
-
this.appDelete_ = appDelete || false;
|
|
633
|
-
if (this.backoffId_ !== null) {
|
|
634
|
-
stop(this.backoffId_);
|
|
635
|
-
}
|
|
636
|
-
if (this.pendingConnection_ !== null) {
|
|
637
|
-
this.pendingConnection_.abort();
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
class RequestEndStatus {
|
|
642
|
-
constructor(wasSuccessCode, connection, canceled2) {
|
|
643
|
-
this.wasSuccessCode = wasSuccessCode;
|
|
644
|
-
this.connection = connection;
|
|
645
|
-
this.canceled = !!canceled2;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
function addAuthHeader_(headers, authToken) {
|
|
649
|
-
if (authToken !== null && authToken.length > 0) {
|
|
650
|
-
headers["Authorization"] = "Firebase " + authToken;
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
function addVersionHeader_(headers, firebaseVersion) {
|
|
654
|
-
headers["X-Firebase-Storage-Version"] = "webjs/" + (firebaseVersion ?? "AppManager");
|
|
655
|
-
}
|
|
656
|
-
function addGmpidHeader_(headers, appId) {
|
|
657
|
-
if (appId) {
|
|
658
|
-
headers["X-Firebase-GMPID"] = appId;
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
function addAppCheckHeader_(headers, appCheckToken) {
|
|
662
|
-
if (appCheckToken !== null) {
|
|
663
|
-
headers["X-Firebase-AppCheck"] = appCheckToken;
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
function makeRequest(requestInfo, appId, authToken, appCheckToken, requestFactory, firebaseVersion, retry = true, isUsingEmulator = false) {
|
|
667
|
-
const queryPart = makeQueryString(requestInfo.urlParams);
|
|
668
|
-
const url = requestInfo.url + queryPart;
|
|
669
|
-
const headers = Object.assign({}, requestInfo.headers);
|
|
670
|
-
addGmpidHeader_(headers, appId);
|
|
671
|
-
addAuthHeader_(headers, authToken);
|
|
672
|
-
addVersionHeader_(headers, firebaseVersion);
|
|
673
|
-
addAppCheckHeader_(headers, appCheckToken);
|
|
674
|
-
return new NetworkRequest(url, requestInfo.method, headers, requestInfo.body, requestInfo.successCodes, requestInfo.additionalRetryCodes, requestInfo.handler, requestInfo.errorHandler, requestInfo.timeout, requestInfo.progressCallback, requestFactory, retry, isUsingEmulator);
|
|
675
|
-
}
|
|
676
|
-
/**
|
|
677
|
-
* @license
|
|
678
|
-
* Copyright 2017 Google LLC
|
|
679
|
-
*
|
|
680
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
681
|
-
* you may not use this file except in compliance with the License.
|
|
682
|
-
* You may obtain a copy of the License at
|
|
683
|
-
*
|
|
684
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
685
|
-
*
|
|
686
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
687
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
688
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
689
|
-
* See the License for the specific language governing permissions and
|
|
690
|
-
* limitations under the License.
|
|
691
|
-
*/
|
|
692
|
-
function getBlobBuilder() {
|
|
693
|
-
if (typeof BlobBuilder !== "undefined") {
|
|
694
|
-
return BlobBuilder;
|
|
695
|
-
} else if (typeof WebKitBlobBuilder !== "undefined") {
|
|
696
|
-
return WebKitBlobBuilder;
|
|
697
|
-
} else {
|
|
698
|
-
return void 0;
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
function getBlob$1(...args) {
|
|
702
|
-
const BlobBuilder2 = getBlobBuilder();
|
|
703
|
-
if (BlobBuilder2 !== void 0) {
|
|
704
|
-
const bb = new BlobBuilder2();
|
|
705
|
-
for (let i = 0; i < args.length; i++) {
|
|
706
|
-
bb.append(args[i]);
|
|
707
|
-
}
|
|
708
|
-
return bb.getBlob();
|
|
709
|
-
} else {
|
|
710
|
-
if (isNativeBlobDefined()) {
|
|
711
|
-
return new Blob(args);
|
|
712
|
-
} else {
|
|
713
|
-
throw new StorageError(StorageErrorCode.UNSUPPORTED_ENVIRONMENT, "This browser doesn't seem to support creating Blobs");
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
function sliceBlob(blob, start2, end) {
|
|
718
|
-
if (blob.webkitSlice) {
|
|
719
|
-
return blob.webkitSlice(start2, end);
|
|
720
|
-
} else if (blob.mozSlice) {
|
|
721
|
-
return blob.mozSlice(start2, end);
|
|
722
|
-
} else if (blob.slice) {
|
|
723
|
-
return blob.slice(start2, end);
|
|
724
|
-
}
|
|
725
|
-
return null;
|
|
726
|
-
}
|
|
727
|
-
/**
|
|
728
|
-
* @license
|
|
729
|
-
* Copyright 2021 Google LLC
|
|
730
|
-
*
|
|
731
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
732
|
-
* you may not use this file except in compliance with the License.
|
|
733
|
-
* You may obtain a copy of the License at
|
|
734
|
-
*
|
|
735
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
736
|
-
*
|
|
737
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
738
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
739
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
740
|
-
* See the License for the specific language governing permissions and
|
|
741
|
-
* limitations under the License.
|
|
742
|
-
*/
|
|
743
|
-
function decodeBase64(encoded) {
|
|
744
|
-
if (typeof atob === "undefined") {
|
|
745
|
-
throw missingPolyFill("base-64");
|
|
746
|
-
}
|
|
747
|
-
return atob(encoded);
|
|
748
|
-
}
|
|
749
|
-
/**
|
|
750
|
-
* @license
|
|
751
|
-
* Copyright 2017 Google LLC
|
|
752
|
-
*
|
|
753
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
754
|
-
* you may not use this file except in compliance with the License.
|
|
755
|
-
* You may obtain a copy of the License at
|
|
756
|
-
*
|
|
757
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
758
|
-
*
|
|
759
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
760
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
761
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
762
|
-
* See the License for the specific language governing permissions and
|
|
763
|
-
* limitations under the License.
|
|
764
|
-
*/
|
|
765
|
-
const StringFormat = {
|
|
766
|
-
/**
|
|
767
|
-
* Indicates the string should be interpreted "raw", that is, as normal text.
|
|
768
|
-
* The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte
|
|
769
|
-
* sequence.
|
|
770
|
-
* Example: The string 'Hello! \\ud83d\\ude0a' becomes the byte sequence
|
|
771
|
-
* 48 65 6c 6c 6f 21 20 f0 9f 98 8a
|
|
772
|
-
*/
|
|
773
|
-
RAW: "raw",
|
|
774
|
-
/**
|
|
775
|
-
* Indicates the string should be interpreted as base64-encoded data.
|
|
776
|
-
* Padding characters (trailing '='s) are optional.
|
|
777
|
-
* Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence
|
|
778
|
-
* ad 69 8e fb e1 3a b7 bf eb 97
|
|
779
|
-
*/
|
|
780
|
-
BASE64: "base64",
|
|
781
|
-
/**
|
|
782
|
-
* Indicates the string should be interpreted as base64url-encoded data.
|
|
783
|
-
* Padding characters (trailing '='s) are optional.
|
|
784
|
-
* Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence
|
|
785
|
-
* ad 69 8e fb e1 3a b7 bf eb 97
|
|
786
|
-
*/
|
|
787
|
-
BASE64URL: "base64url",
|
|
788
|
-
/**
|
|
789
|
-
* Indicates the string is a data URL, such as one obtained from
|
|
790
|
-
* canvas.toDataURL().
|
|
791
|
-
* Example: the string 'data:application/octet-stream;base64,aaaa'
|
|
792
|
-
* becomes the byte sequence
|
|
793
|
-
* 69 a6 9a
|
|
794
|
-
* (the content-type "application/octet-stream" is also applied, but can
|
|
795
|
-
* be overridden in the metadata object).
|
|
796
|
-
*/
|
|
797
|
-
DATA_URL: "data_url"
|
|
798
|
-
};
|
|
799
|
-
class StringData {
|
|
800
|
-
constructor(data, contentType) {
|
|
801
|
-
this.data = data;
|
|
802
|
-
this.contentType = contentType || null;
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
function dataFromString(format, stringData) {
|
|
806
|
-
switch (format) {
|
|
807
|
-
case StringFormat.RAW:
|
|
808
|
-
return new StringData(utf8Bytes_(stringData));
|
|
809
|
-
case StringFormat.BASE64:
|
|
810
|
-
case StringFormat.BASE64URL:
|
|
811
|
-
return new StringData(base64Bytes_(format, stringData));
|
|
812
|
-
case StringFormat.DATA_URL:
|
|
813
|
-
return new StringData(dataURLBytes_(stringData), dataURLContentType_(stringData));
|
|
814
|
-
}
|
|
815
|
-
throw unknown();
|
|
816
|
-
}
|
|
817
|
-
function utf8Bytes_(value) {
|
|
818
|
-
const b = [];
|
|
819
|
-
for (let i = 0; i < value.length; i++) {
|
|
820
|
-
let c = value.charCodeAt(i);
|
|
821
|
-
if (c <= 127) {
|
|
822
|
-
b.push(c);
|
|
823
|
-
} else {
|
|
824
|
-
if (c <= 2047) {
|
|
825
|
-
b.push(192 | c >> 6, 128 | c & 63);
|
|
826
|
-
} else {
|
|
827
|
-
if ((c & 64512) === 55296) {
|
|
828
|
-
const valid = i < value.length - 1 && (value.charCodeAt(i + 1) & 64512) === 56320;
|
|
829
|
-
if (!valid) {
|
|
830
|
-
b.push(239, 191, 189);
|
|
831
|
-
} else {
|
|
832
|
-
const hi = c;
|
|
833
|
-
const lo = value.charCodeAt(++i);
|
|
834
|
-
c = 65536 | (hi & 1023) << 10 | lo & 1023;
|
|
835
|
-
b.push(240 | c >> 18, 128 | c >> 12 & 63, 128 | c >> 6 & 63, 128 | c & 63);
|
|
836
|
-
}
|
|
837
|
-
} else {
|
|
838
|
-
if ((c & 64512) === 56320) {
|
|
839
|
-
b.push(239, 191, 189);
|
|
840
|
-
} else {
|
|
841
|
-
b.push(224 | c >> 12, 128 | c >> 6 & 63, 128 | c & 63);
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
return new Uint8Array(b);
|
|
848
|
-
}
|
|
849
|
-
function percentEncodedBytes_(value) {
|
|
850
|
-
let decoded;
|
|
851
|
-
try {
|
|
852
|
-
decoded = decodeURIComponent(value);
|
|
853
|
-
} catch (e) {
|
|
854
|
-
throw invalidFormat(StringFormat.DATA_URL, "Malformed data URL.");
|
|
855
|
-
}
|
|
856
|
-
return utf8Bytes_(decoded);
|
|
857
|
-
}
|
|
858
|
-
function base64Bytes_(format, value) {
|
|
859
|
-
switch (format) {
|
|
860
|
-
case StringFormat.BASE64: {
|
|
861
|
-
const hasMinus = value.indexOf("-") !== -1;
|
|
862
|
-
const hasUnder = value.indexOf("_") !== -1;
|
|
863
|
-
if (hasMinus || hasUnder) {
|
|
864
|
-
const invalidChar = hasMinus ? "-" : "_";
|
|
865
|
-
throw invalidFormat(format, "Invalid character '" + invalidChar + "' found: is it base64url encoded?");
|
|
866
|
-
}
|
|
867
|
-
break;
|
|
868
|
-
}
|
|
869
|
-
case StringFormat.BASE64URL: {
|
|
870
|
-
const hasPlus = value.indexOf("+") !== -1;
|
|
871
|
-
const hasSlash = value.indexOf("/") !== -1;
|
|
872
|
-
if (hasPlus || hasSlash) {
|
|
873
|
-
const invalidChar = hasPlus ? "+" : "/";
|
|
874
|
-
throw invalidFormat(format, "Invalid character '" + invalidChar + "' found: is it base64 encoded?");
|
|
875
|
-
}
|
|
876
|
-
value = value.replace(/-/g, "+").replace(/_/g, "/");
|
|
877
|
-
break;
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
let bytes;
|
|
881
|
-
try {
|
|
882
|
-
bytes = decodeBase64(value);
|
|
883
|
-
} catch (e) {
|
|
884
|
-
if (e.message.includes("polyfill")) {
|
|
885
|
-
throw e;
|
|
886
|
-
}
|
|
887
|
-
throw invalidFormat(format, "Invalid character found");
|
|
888
|
-
}
|
|
889
|
-
const array = new Uint8Array(bytes.length);
|
|
890
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
891
|
-
array[i] = bytes.charCodeAt(i);
|
|
892
|
-
}
|
|
893
|
-
return array;
|
|
894
|
-
}
|
|
895
|
-
class DataURLParts {
|
|
896
|
-
constructor(dataURL) {
|
|
897
|
-
this.base64 = false;
|
|
898
|
-
this.contentType = null;
|
|
899
|
-
const matches = dataURL.match(/^data:([^,]+)?,/);
|
|
900
|
-
if (matches === null) {
|
|
901
|
-
throw invalidFormat(StringFormat.DATA_URL, "Must be formatted 'data:[<mediatype>][;base64],<data>");
|
|
902
|
-
}
|
|
903
|
-
const middle = matches[1] || null;
|
|
904
|
-
if (middle != null) {
|
|
905
|
-
this.base64 = endsWith(middle, ";base64");
|
|
906
|
-
this.contentType = this.base64 ? middle.substring(0, middle.length - ";base64".length) : middle;
|
|
907
|
-
}
|
|
908
|
-
this.rest = dataURL.substring(dataURL.indexOf(",") + 1);
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
function dataURLBytes_(dataUrl) {
|
|
912
|
-
const parts = new DataURLParts(dataUrl);
|
|
913
|
-
if (parts.base64) {
|
|
914
|
-
return base64Bytes_(StringFormat.BASE64, parts.rest);
|
|
915
|
-
} else {
|
|
916
|
-
return percentEncodedBytes_(parts.rest);
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
function dataURLContentType_(dataUrl) {
|
|
920
|
-
const parts = new DataURLParts(dataUrl);
|
|
921
|
-
return parts.contentType;
|
|
922
|
-
}
|
|
923
|
-
function endsWith(s, end) {
|
|
924
|
-
const longEnough = s.length >= end.length;
|
|
925
|
-
if (!longEnough) {
|
|
926
|
-
return false;
|
|
927
|
-
}
|
|
928
|
-
return s.substring(s.length - end.length) === end;
|
|
929
|
-
}
|
|
930
|
-
/**
|
|
931
|
-
* @license
|
|
932
|
-
* Copyright 2017 Google LLC
|
|
933
|
-
*
|
|
934
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
935
|
-
* you may not use this file except in compliance with the License.
|
|
936
|
-
* You may obtain a copy of the License at
|
|
937
|
-
*
|
|
938
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
939
|
-
*
|
|
940
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
941
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
942
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
943
|
-
* See the License for the specific language governing permissions and
|
|
944
|
-
* limitations under the License.
|
|
945
|
-
*/
|
|
946
|
-
class FbsBlob {
|
|
947
|
-
constructor(data, elideCopy) {
|
|
948
|
-
let size = 0;
|
|
949
|
-
let blobType = "";
|
|
950
|
-
if (isNativeBlob(data)) {
|
|
951
|
-
this.data_ = data;
|
|
952
|
-
size = data.size;
|
|
953
|
-
blobType = data.type;
|
|
954
|
-
} else if (data instanceof ArrayBuffer) {
|
|
955
|
-
if (elideCopy) {
|
|
956
|
-
this.data_ = new Uint8Array(data);
|
|
957
|
-
} else {
|
|
958
|
-
this.data_ = new Uint8Array(data.byteLength);
|
|
959
|
-
this.data_.set(new Uint8Array(data));
|
|
960
|
-
}
|
|
961
|
-
size = this.data_.length;
|
|
962
|
-
} else if (data instanceof Uint8Array) {
|
|
963
|
-
if (elideCopy) {
|
|
964
|
-
this.data_ = data;
|
|
965
|
-
} else {
|
|
966
|
-
this.data_ = new Uint8Array(data.length);
|
|
967
|
-
this.data_.set(data);
|
|
968
|
-
}
|
|
969
|
-
size = data.length;
|
|
970
|
-
}
|
|
971
|
-
this.size_ = size;
|
|
972
|
-
this.type_ = blobType;
|
|
973
|
-
}
|
|
974
|
-
size() {
|
|
975
|
-
return this.size_;
|
|
976
|
-
}
|
|
977
|
-
type() {
|
|
978
|
-
return this.type_;
|
|
979
|
-
}
|
|
980
|
-
slice(startByte, endByte) {
|
|
981
|
-
if (isNativeBlob(this.data_)) {
|
|
982
|
-
const realBlob = this.data_;
|
|
983
|
-
const sliced = sliceBlob(realBlob, startByte, endByte);
|
|
984
|
-
if (sliced === null) {
|
|
985
|
-
return null;
|
|
986
|
-
}
|
|
987
|
-
return new FbsBlob(sliced);
|
|
988
|
-
} else {
|
|
989
|
-
const slice = new Uint8Array(this.data_.buffer, startByte, endByte - startByte);
|
|
990
|
-
return new FbsBlob(slice, true);
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
static getBlob(...args) {
|
|
994
|
-
if (isNativeBlobDefined()) {
|
|
995
|
-
const blobby = args.map((val) => {
|
|
996
|
-
if (val instanceof FbsBlob) {
|
|
997
|
-
return val.data_;
|
|
998
|
-
} else {
|
|
999
|
-
return val;
|
|
1000
|
-
}
|
|
1001
|
-
});
|
|
1002
|
-
return new FbsBlob(getBlob$1.apply(null, blobby));
|
|
1003
|
-
} else {
|
|
1004
|
-
const uint8Arrays = args.map((val) => {
|
|
1005
|
-
if (isString(val)) {
|
|
1006
|
-
return dataFromString(StringFormat.RAW, val).data;
|
|
1007
|
-
} else {
|
|
1008
|
-
return val.data_;
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
let finalLength = 0;
|
|
1012
|
-
uint8Arrays.forEach((array) => {
|
|
1013
|
-
finalLength += array.byteLength;
|
|
1014
|
-
});
|
|
1015
|
-
const merged = new Uint8Array(finalLength);
|
|
1016
|
-
let index = 0;
|
|
1017
|
-
uint8Arrays.forEach((array) => {
|
|
1018
|
-
for (let i = 0; i < array.length; i++) {
|
|
1019
|
-
merged[index++] = array[i];
|
|
1020
|
-
}
|
|
1021
|
-
});
|
|
1022
|
-
return new FbsBlob(merged, true);
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
uploadData() {
|
|
1026
|
-
return this.data_;
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
/**
|
|
1030
|
-
* @license
|
|
1031
|
-
* Copyright 2017 Google LLC
|
|
1032
|
-
*
|
|
1033
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1034
|
-
* you may not use this file except in compliance with the License.
|
|
1035
|
-
* You may obtain a copy of the License at
|
|
1036
|
-
*
|
|
1037
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1038
|
-
*
|
|
1039
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1040
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1041
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1042
|
-
* See the License for the specific language governing permissions and
|
|
1043
|
-
* limitations under the License.
|
|
1044
|
-
*/
|
|
1045
|
-
function jsonObjectOrNull(s) {
|
|
1046
|
-
let obj;
|
|
1047
|
-
try {
|
|
1048
|
-
obj = JSON.parse(s);
|
|
1049
|
-
} catch (e) {
|
|
1050
|
-
return null;
|
|
1051
|
-
}
|
|
1052
|
-
if (isNonArrayObject(obj)) {
|
|
1053
|
-
return obj;
|
|
1054
|
-
} else {
|
|
1055
|
-
return null;
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
/**
|
|
1059
|
-
* @license
|
|
1060
|
-
* Copyright 2017 Google LLC
|
|
1061
|
-
*
|
|
1062
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1063
|
-
* you may not use this file except in compliance with the License.
|
|
1064
|
-
* You may obtain a copy of the License at
|
|
1065
|
-
*
|
|
1066
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1067
|
-
*
|
|
1068
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1069
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1070
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1071
|
-
* See the License for the specific language governing permissions and
|
|
1072
|
-
* limitations under the License.
|
|
1073
|
-
*/
|
|
1074
|
-
function parent(path) {
|
|
1075
|
-
if (path.length === 0) {
|
|
1076
|
-
return null;
|
|
1077
|
-
}
|
|
1078
|
-
const index = path.lastIndexOf("/");
|
|
1079
|
-
if (index === -1) {
|
|
1080
|
-
return "";
|
|
1081
|
-
}
|
|
1082
|
-
const newPath = path.slice(0, index);
|
|
1083
|
-
return newPath;
|
|
1084
|
-
}
|
|
1085
|
-
function child(path, childPath) {
|
|
1086
|
-
const canonicalChildPath = childPath.split("/").filter((component) => component.length > 0).join("/");
|
|
1087
|
-
if (path.length === 0) {
|
|
1088
|
-
return canonicalChildPath;
|
|
1089
|
-
} else {
|
|
1090
|
-
return path + "/" + canonicalChildPath;
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
function lastComponent(path) {
|
|
1094
|
-
const index = path.lastIndexOf("/", path.length - 2);
|
|
1095
|
-
if (index === -1) {
|
|
1096
|
-
return path;
|
|
1097
|
-
} else {
|
|
1098
|
-
return path.slice(index + 1);
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
/**
|
|
1102
|
-
* @license
|
|
1103
|
-
* Copyright 2017 Google LLC
|
|
1104
|
-
*
|
|
1105
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1106
|
-
* you may not use this file except in compliance with the License.
|
|
1107
|
-
* You may obtain a copy of the License at
|
|
1108
|
-
*
|
|
1109
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1110
|
-
*
|
|
1111
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1112
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1113
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1114
|
-
* See the License for the specific language governing permissions and
|
|
1115
|
-
* limitations under the License.
|
|
1116
|
-
*/
|
|
1117
|
-
function noXform_(metadata, value) {
|
|
1118
|
-
return value;
|
|
1119
|
-
}
|
|
1120
|
-
class Mapping {
|
|
1121
|
-
constructor(server, local, writable, xform) {
|
|
1122
|
-
this.server = server;
|
|
1123
|
-
this.local = local || server;
|
|
1124
|
-
this.writable = !!writable;
|
|
1125
|
-
this.xform = xform || noXform_;
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
let mappings_ = null;
|
|
1129
|
-
function xformPath(fullPath) {
|
|
1130
|
-
if (!isString(fullPath) || fullPath.length < 2) {
|
|
1131
|
-
return fullPath;
|
|
1132
|
-
} else {
|
|
1133
|
-
return lastComponent(fullPath);
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
function getMappings() {
|
|
1137
|
-
if (mappings_) {
|
|
1138
|
-
return mappings_;
|
|
1139
|
-
}
|
|
1140
|
-
const mappings = [];
|
|
1141
|
-
mappings.push(new Mapping("bucket"));
|
|
1142
|
-
mappings.push(new Mapping("generation"));
|
|
1143
|
-
mappings.push(new Mapping("metageneration"));
|
|
1144
|
-
mappings.push(new Mapping("name", "fullPath", true));
|
|
1145
|
-
function mappingsXformPath(_metadata, fullPath) {
|
|
1146
|
-
return xformPath(fullPath);
|
|
1147
|
-
}
|
|
1148
|
-
const nameMapping = new Mapping("name");
|
|
1149
|
-
nameMapping.xform = mappingsXformPath;
|
|
1150
|
-
mappings.push(nameMapping);
|
|
1151
|
-
function xformSize(_metadata, size) {
|
|
1152
|
-
if (size !== void 0) {
|
|
1153
|
-
return Number(size);
|
|
1154
|
-
} else {
|
|
1155
|
-
return size;
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
const sizeMapping = new Mapping("size");
|
|
1159
|
-
sizeMapping.xform = xformSize;
|
|
1160
|
-
mappings.push(sizeMapping);
|
|
1161
|
-
mappings.push(new Mapping("timeCreated"));
|
|
1162
|
-
mappings.push(new Mapping("updated"));
|
|
1163
|
-
mappings.push(new Mapping("md5Hash", null, true));
|
|
1164
|
-
mappings.push(new Mapping("cacheControl", null, true));
|
|
1165
|
-
mappings.push(new Mapping("contentDisposition", null, true));
|
|
1166
|
-
mappings.push(new Mapping("contentEncoding", null, true));
|
|
1167
|
-
mappings.push(new Mapping("contentLanguage", null, true));
|
|
1168
|
-
mappings.push(new Mapping("contentType", null, true));
|
|
1169
|
-
mappings.push(new Mapping("metadata", "customMetadata", true));
|
|
1170
|
-
mappings_ = mappings;
|
|
1171
|
-
return mappings_;
|
|
1172
|
-
}
|
|
1173
|
-
function addRef(metadata, service) {
|
|
1174
|
-
function generateRef() {
|
|
1175
|
-
const bucket = metadata["bucket"];
|
|
1176
|
-
const path = metadata["fullPath"];
|
|
1177
|
-
const loc = new Location(bucket, path);
|
|
1178
|
-
return service._makeStorageReference(loc);
|
|
1179
|
-
}
|
|
1180
|
-
Object.defineProperty(metadata, "ref", { get: generateRef });
|
|
1181
|
-
}
|
|
1182
|
-
function fromResource(service, resource, mappings) {
|
|
1183
|
-
const metadata = {};
|
|
1184
|
-
metadata["type"] = "file";
|
|
1185
|
-
const len = mappings.length;
|
|
1186
|
-
for (let i = 0; i < len; i++) {
|
|
1187
|
-
const mapping = mappings[i];
|
|
1188
|
-
metadata[mapping.local] = mapping.xform(metadata, resource[mapping.server]);
|
|
1189
|
-
}
|
|
1190
|
-
addRef(metadata, service);
|
|
1191
|
-
return metadata;
|
|
1192
|
-
}
|
|
1193
|
-
function fromResourceString(service, resourceString, mappings) {
|
|
1194
|
-
const obj = jsonObjectOrNull(resourceString);
|
|
1195
|
-
if (obj === null) {
|
|
1196
|
-
return null;
|
|
1197
|
-
}
|
|
1198
|
-
const resource = obj;
|
|
1199
|
-
return fromResource(service, resource, mappings);
|
|
1200
|
-
}
|
|
1201
|
-
function downloadUrlFromResourceString(metadata, resourceString, host, protocol) {
|
|
1202
|
-
const obj = jsonObjectOrNull(resourceString);
|
|
1203
|
-
if (obj === null) {
|
|
1204
|
-
return null;
|
|
1205
|
-
}
|
|
1206
|
-
if (!isString(obj["downloadTokens"])) {
|
|
1207
|
-
return null;
|
|
1208
|
-
}
|
|
1209
|
-
const tokens = obj["downloadTokens"];
|
|
1210
|
-
if (tokens.length === 0) {
|
|
1211
|
-
return null;
|
|
1212
|
-
}
|
|
1213
|
-
const encode = encodeURIComponent;
|
|
1214
|
-
const tokensList = tokens.split(",");
|
|
1215
|
-
const urls = tokensList.map((token) => {
|
|
1216
|
-
const bucket = metadata["bucket"];
|
|
1217
|
-
const path = metadata["fullPath"];
|
|
1218
|
-
const urlPart = "/b/" + encode(bucket) + "/o/" + encode(path);
|
|
1219
|
-
const base = makeUrl(urlPart, host, protocol);
|
|
1220
|
-
const queryString = makeQueryString({
|
|
1221
|
-
alt: "media",
|
|
1222
|
-
token
|
|
1223
|
-
});
|
|
1224
|
-
return base + queryString;
|
|
1225
|
-
});
|
|
1226
|
-
return urls[0];
|
|
1227
|
-
}
|
|
1228
|
-
function toResourceString(metadata, mappings) {
|
|
1229
|
-
const resource = {};
|
|
1230
|
-
const len = mappings.length;
|
|
1231
|
-
for (let i = 0; i < len; i++) {
|
|
1232
|
-
const mapping = mappings[i];
|
|
1233
|
-
if (mapping.writable) {
|
|
1234
|
-
resource[mapping.server] = metadata[mapping.local];
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
return JSON.stringify(resource);
|
|
1238
|
-
}
|
|
1239
|
-
class RequestInfo {
|
|
1240
|
-
constructor(url, method, handler, timeout) {
|
|
1241
|
-
this.url = url;
|
|
1242
|
-
this.method = method;
|
|
1243
|
-
this.handler = handler;
|
|
1244
|
-
this.timeout = timeout;
|
|
1245
|
-
this.urlParams = {};
|
|
1246
|
-
this.headers = {};
|
|
1247
|
-
this.body = null;
|
|
1248
|
-
this.errorHandler = null;
|
|
1249
|
-
this.progressCallback = null;
|
|
1250
|
-
this.successCodes = [200];
|
|
1251
|
-
this.additionalRetryCodes = [];
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
/**
|
|
1255
|
-
* @license
|
|
1256
|
-
* Copyright 2017 Google LLC
|
|
1257
|
-
*
|
|
1258
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1259
|
-
* you may not use this file except in compliance with the License.
|
|
1260
|
-
* You may obtain a copy of the License at
|
|
1261
|
-
*
|
|
1262
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1263
|
-
*
|
|
1264
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1265
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1266
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1267
|
-
* See the License for the specific language governing permissions and
|
|
1268
|
-
* limitations under the License.
|
|
1269
|
-
*/
|
|
1270
|
-
function handlerCheck(cndn) {
|
|
1271
|
-
if (!cndn) {
|
|
1272
|
-
throw unknown();
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
function metadataHandler(service, mappings) {
|
|
1276
|
-
function handler(xhr, text) {
|
|
1277
|
-
const metadata = fromResourceString(service, text, mappings);
|
|
1278
|
-
handlerCheck(metadata !== null);
|
|
1279
|
-
return metadata;
|
|
1280
|
-
}
|
|
1281
|
-
return handler;
|
|
1282
|
-
}
|
|
1283
|
-
function downloadUrlHandler(service, mappings) {
|
|
1284
|
-
function handler(xhr, text) {
|
|
1285
|
-
const metadata = fromResourceString(service, text, mappings);
|
|
1286
|
-
handlerCheck(metadata !== null);
|
|
1287
|
-
return downloadUrlFromResourceString(metadata, text, service.host, service._protocol);
|
|
1288
|
-
}
|
|
1289
|
-
return handler;
|
|
1290
|
-
}
|
|
1291
|
-
function sharedErrorHandler(location) {
|
|
1292
|
-
function errorHandler(xhr, err) {
|
|
1293
|
-
let newErr;
|
|
1294
|
-
if (xhr.getStatus() === 401) {
|
|
1295
|
-
if (
|
|
1296
|
-
// This exact message string is the only consistent part of the
|
|
1297
|
-
// server's error response that identifies it as an App Check error.
|
|
1298
|
-
xhr.getErrorText().includes("Firebase App Check token is invalid")
|
|
1299
|
-
) {
|
|
1300
|
-
newErr = unauthorizedApp();
|
|
1301
|
-
} else {
|
|
1302
|
-
newErr = unauthenticated();
|
|
1303
|
-
}
|
|
1304
|
-
} else {
|
|
1305
|
-
if (xhr.getStatus() === 402) {
|
|
1306
|
-
newErr = quotaExceeded(location.bucket);
|
|
1307
|
-
} else {
|
|
1308
|
-
if (xhr.getStatus() === 403) {
|
|
1309
|
-
newErr = unauthorized(location.path);
|
|
1310
|
-
} else {
|
|
1311
|
-
newErr = err;
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
newErr.status = xhr.getStatus();
|
|
1316
|
-
newErr.serverResponse = err.serverResponse;
|
|
1317
|
-
return newErr;
|
|
1318
|
-
}
|
|
1319
|
-
return errorHandler;
|
|
1320
|
-
}
|
|
1321
|
-
function objectErrorHandler(location) {
|
|
1322
|
-
const shared = sharedErrorHandler(location);
|
|
1323
|
-
function errorHandler(xhr, err) {
|
|
1324
|
-
let newErr = shared(xhr, err);
|
|
1325
|
-
if (xhr.getStatus() === 404) {
|
|
1326
|
-
newErr = objectNotFound(location.path);
|
|
1327
|
-
}
|
|
1328
|
-
newErr.serverResponse = err.serverResponse;
|
|
1329
|
-
return newErr;
|
|
1330
|
-
}
|
|
1331
|
-
return errorHandler;
|
|
1332
|
-
}
|
|
1333
|
-
function getMetadata$2(service, location, mappings) {
|
|
1334
|
-
const urlPart = location.fullServerUrl();
|
|
1335
|
-
const url = makeUrl(urlPart, service.host, service._protocol);
|
|
1336
|
-
const method = "GET";
|
|
1337
|
-
const timeout = service.maxOperationRetryTime;
|
|
1338
|
-
const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout);
|
|
1339
|
-
requestInfo.errorHandler = objectErrorHandler(location);
|
|
1340
|
-
return requestInfo;
|
|
1341
|
-
}
|
|
1342
|
-
function getDownloadUrl(service, location, mappings) {
|
|
1343
|
-
const urlPart = location.fullServerUrl();
|
|
1344
|
-
const url = makeUrl(urlPart, service.host, service._protocol);
|
|
1345
|
-
const method = "GET";
|
|
1346
|
-
const timeout = service.maxOperationRetryTime;
|
|
1347
|
-
const requestInfo = new RequestInfo(url, method, downloadUrlHandler(service, mappings), timeout);
|
|
1348
|
-
requestInfo.errorHandler = objectErrorHandler(location);
|
|
1349
|
-
return requestInfo;
|
|
1350
|
-
}
|
|
1351
|
-
function deleteObject$2(service, location) {
|
|
1352
|
-
const urlPart = location.fullServerUrl();
|
|
1353
|
-
const url = makeUrl(urlPart, service.host, service._protocol);
|
|
1354
|
-
const method = "DELETE";
|
|
1355
|
-
const timeout = service.maxOperationRetryTime;
|
|
1356
|
-
function handler(_xhr, _text) {
|
|
1357
|
-
}
|
|
1358
|
-
const requestInfo = new RequestInfo(url, method, handler, timeout);
|
|
1359
|
-
requestInfo.successCodes = [200, 204];
|
|
1360
|
-
requestInfo.errorHandler = objectErrorHandler(location);
|
|
1361
|
-
return requestInfo;
|
|
1362
|
-
}
|
|
1363
|
-
function determineContentType_(metadata, blob) {
|
|
1364
|
-
return metadata && metadata["contentType"] || blob && blob.type() || "application/octet-stream";
|
|
1365
|
-
}
|
|
1366
|
-
function metadataForUpload_(location, blob, metadata) {
|
|
1367
|
-
const metadataClone = Object.assign({}, metadata);
|
|
1368
|
-
metadataClone["fullPath"] = location.path;
|
|
1369
|
-
metadataClone["size"] = blob.size();
|
|
1370
|
-
if (!metadataClone["contentType"]) {
|
|
1371
|
-
metadataClone["contentType"] = determineContentType_(null, blob);
|
|
1372
|
-
}
|
|
1373
|
-
return metadataClone;
|
|
1374
|
-
}
|
|
1375
|
-
function multipartUpload(service, location, mappings, blob, metadata) {
|
|
1376
|
-
const urlPart = location.bucketOnlyServerUrl();
|
|
1377
|
-
const headers = {
|
|
1378
|
-
"X-Goog-Upload-Protocol": "multipart"
|
|
1379
|
-
};
|
|
1380
|
-
function genBoundary() {
|
|
1381
|
-
let str = "";
|
|
1382
|
-
for (let i = 0; i < 2; i++) {
|
|
1383
|
-
str = str + Math.random().toString().slice(2);
|
|
1384
|
-
}
|
|
1385
|
-
return str;
|
|
1386
|
-
}
|
|
1387
|
-
const boundary = genBoundary();
|
|
1388
|
-
headers["Content-Type"] = "multipart/related; boundary=" + boundary;
|
|
1389
|
-
const metadata_ = metadataForUpload_(location, blob, metadata);
|
|
1390
|
-
const metadataString = toResourceString(metadata_, mappings);
|
|
1391
|
-
const preBlobPart = "--" + boundary + "\r\nContent-Type: application/json; charset=utf-8\r\n\r\n" + metadataString + "\r\n--" + boundary + "\r\nContent-Type: " + metadata_["contentType"] + "\r\n\r\n";
|
|
1392
|
-
const postBlobPart = "\r\n--" + boundary + "--";
|
|
1393
|
-
const body = FbsBlob.getBlob(preBlobPart, blob, postBlobPart);
|
|
1394
|
-
if (body === null) {
|
|
1395
|
-
throw cannotSliceBlob();
|
|
1396
|
-
}
|
|
1397
|
-
const urlParams = { name: metadata_["fullPath"] };
|
|
1398
|
-
const url = makeUrl(urlPart, service.host, service._protocol);
|
|
1399
|
-
const method = "POST";
|
|
1400
|
-
const timeout = service.maxUploadRetryTime;
|
|
1401
|
-
const requestInfo = new RequestInfo(url, method, metadataHandler(service, mappings), timeout);
|
|
1402
|
-
requestInfo.urlParams = urlParams;
|
|
1403
|
-
requestInfo.headers = headers;
|
|
1404
|
-
requestInfo.body = body.uploadData();
|
|
1405
|
-
requestInfo.errorHandler = sharedErrorHandler(location);
|
|
1406
|
-
return requestInfo;
|
|
1407
|
-
}
|
|
1408
|
-
class ResumableUploadStatus {
|
|
1409
|
-
constructor(current, total, finalized, metadata) {
|
|
1410
|
-
this.current = current;
|
|
1411
|
-
this.total = total;
|
|
1412
|
-
this.finalized = !!finalized;
|
|
1413
|
-
this.metadata = metadata || null;
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
|
-
function checkResumeHeader_(xhr, allowed) {
|
|
1417
|
-
let status = null;
|
|
1418
|
-
try {
|
|
1419
|
-
status = xhr.getResponseHeader("X-Goog-Upload-Status");
|
|
1420
|
-
} catch (e) {
|
|
1421
|
-
handlerCheck(false);
|
|
1422
|
-
}
|
|
1423
|
-
const allowedStatus = allowed || ["active"];
|
|
1424
|
-
handlerCheck(!!status && allowedStatus.indexOf(status) !== -1);
|
|
1425
|
-
return status;
|
|
1426
|
-
}
|
|
1427
|
-
function createResumableUpload(service, location, mappings, blob, metadata) {
|
|
1428
|
-
const urlPart = location.bucketOnlyServerUrl();
|
|
1429
|
-
const metadataForUpload = metadataForUpload_(location, blob, metadata);
|
|
1430
|
-
const urlParams = { name: metadataForUpload["fullPath"] };
|
|
1431
|
-
const url = makeUrl(urlPart, service.host, service._protocol);
|
|
1432
|
-
const method = "POST";
|
|
1433
|
-
const headers = {
|
|
1434
|
-
"X-Goog-Upload-Protocol": "resumable",
|
|
1435
|
-
"X-Goog-Upload-Command": "start",
|
|
1436
|
-
"X-Goog-Upload-Header-Content-Length": `${blob.size()}`,
|
|
1437
|
-
"X-Goog-Upload-Header-Content-Type": metadataForUpload["contentType"],
|
|
1438
|
-
"Content-Type": "application/json; charset=utf-8"
|
|
1439
|
-
};
|
|
1440
|
-
const body = toResourceString(metadataForUpload, mappings);
|
|
1441
|
-
const timeout = service.maxUploadRetryTime;
|
|
1442
|
-
function handler(xhr) {
|
|
1443
|
-
checkResumeHeader_(xhr);
|
|
1444
|
-
let url2;
|
|
1445
|
-
try {
|
|
1446
|
-
url2 = xhr.getResponseHeader("X-Goog-Upload-URL");
|
|
1447
|
-
} catch (e) {
|
|
1448
|
-
handlerCheck(false);
|
|
1449
|
-
}
|
|
1450
|
-
handlerCheck(isString(url2));
|
|
1451
|
-
return url2;
|
|
1452
|
-
}
|
|
1453
|
-
const requestInfo = new RequestInfo(url, method, handler, timeout);
|
|
1454
|
-
requestInfo.urlParams = urlParams;
|
|
1455
|
-
requestInfo.headers = headers;
|
|
1456
|
-
requestInfo.body = body;
|
|
1457
|
-
requestInfo.errorHandler = sharedErrorHandler(location);
|
|
1458
|
-
return requestInfo;
|
|
1459
|
-
}
|
|
1460
|
-
function getResumableUploadStatus(service, location, url, blob) {
|
|
1461
|
-
const headers = { "X-Goog-Upload-Command": "query" };
|
|
1462
|
-
function handler(xhr) {
|
|
1463
|
-
const status = checkResumeHeader_(xhr, ["active", "final"]);
|
|
1464
|
-
let sizeString = null;
|
|
1465
|
-
try {
|
|
1466
|
-
sizeString = xhr.getResponseHeader("X-Goog-Upload-Size-Received");
|
|
1467
|
-
} catch (e) {
|
|
1468
|
-
handlerCheck(false);
|
|
1469
|
-
}
|
|
1470
|
-
if (!sizeString) {
|
|
1471
|
-
handlerCheck(false);
|
|
1472
|
-
}
|
|
1473
|
-
const size = Number(sizeString);
|
|
1474
|
-
handlerCheck(!isNaN(size));
|
|
1475
|
-
return new ResumableUploadStatus(size, blob.size(), status === "final");
|
|
1476
|
-
}
|
|
1477
|
-
const method = "POST";
|
|
1478
|
-
const timeout = service.maxUploadRetryTime;
|
|
1479
|
-
const requestInfo = new RequestInfo(url, method, handler, timeout);
|
|
1480
|
-
requestInfo.headers = headers;
|
|
1481
|
-
requestInfo.errorHandler = sharedErrorHandler(location);
|
|
1482
|
-
return requestInfo;
|
|
1483
|
-
}
|
|
1484
|
-
const RESUMABLE_UPLOAD_CHUNK_SIZE = 256 * 1024;
|
|
1485
|
-
function continueResumableUpload(location, service, url, blob, chunkSize, mappings, status, progressCallback) {
|
|
1486
|
-
const status_ = new ResumableUploadStatus(0, 0);
|
|
1487
|
-
if (status) {
|
|
1488
|
-
status_.current = status.current;
|
|
1489
|
-
status_.total = status.total;
|
|
1490
|
-
} else {
|
|
1491
|
-
status_.current = 0;
|
|
1492
|
-
status_.total = blob.size();
|
|
1493
|
-
}
|
|
1494
|
-
if (blob.size() !== status_.total) {
|
|
1495
|
-
throw serverFileWrongSize();
|
|
1496
|
-
}
|
|
1497
|
-
const bytesLeft = status_.total - status_.current;
|
|
1498
|
-
let bytesToUpload = bytesLeft;
|
|
1499
|
-
if (chunkSize > 0) {
|
|
1500
|
-
bytesToUpload = Math.min(bytesToUpload, chunkSize);
|
|
1501
|
-
}
|
|
1502
|
-
const startByte = status_.current;
|
|
1503
|
-
const endByte = startByte + bytesToUpload;
|
|
1504
|
-
let uploadCommand = "";
|
|
1505
|
-
if (bytesToUpload === 0) {
|
|
1506
|
-
uploadCommand = "finalize";
|
|
1507
|
-
} else if (bytesLeft === bytesToUpload) {
|
|
1508
|
-
uploadCommand = "upload, finalize";
|
|
1509
|
-
} else {
|
|
1510
|
-
uploadCommand = "upload";
|
|
1511
|
-
}
|
|
1512
|
-
const headers = {
|
|
1513
|
-
"X-Goog-Upload-Command": uploadCommand,
|
|
1514
|
-
"X-Goog-Upload-Offset": `${status_.current}`
|
|
1515
|
-
};
|
|
1516
|
-
const body = blob.slice(startByte, endByte);
|
|
1517
|
-
if (body === null) {
|
|
1518
|
-
throw cannotSliceBlob();
|
|
1519
|
-
}
|
|
1520
|
-
function handler(xhr, text) {
|
|
1521
|
-
const uploadStatus = checkResumeHeader_(xhr, ["active", "final"]);
|
|
1522
|
-
const newCurrent = status_.current + bytesToUpload;
|
|
1523
|
-
const size = blob.size();
|
|
1524
|
-
let metadata;
|
|
1525
|
-
if (uploadStatus === "final") {
|
|
1526
|
-
metadata = metadataHandler(service, mappings)(xhr, text);
|
|
1527
|
-
} else {
|
|
1528
|
-
metadata = null;
|
|
1529
|
-
}
|
|
1530
|
-
return new ResumableUploadStatus(newCurrent, size, uploadStatus === "final", metadata);
|
|
1531
|
-
}
|
|
1532
|
-
const method = "POST";
|
|
1533
|
-
const timeout = service.maxUploadRetryTime;
|
|
1534
|
-
const requestInfo = new RequestInfo(url, method, handler, timeout);
|
|
1535
|
-
requestInfo.headers = headers;
|
|
1536
|
-
requestInfo.body = body.uploadData();
|
|
1537
|
-
requestInfo.progressCallback = progressCallback || null;
|
|
1538
|
-
requestInfo.errorHandler = sharedErrorHandler(location);
|
|
1539
|
-
return requestInfo;
|
|
1540
|
-
}
|
|
1541
|
-
const TaskState = {
|
|
1542
|
-
/** The task is currently transferring data. */
|
|
1543
|
-
RUNNING: "running",
|
|
1544
|
-
/** The task was paused by the user. */
|
|
1545
|
-
PAUSED: "paused",
|
|
1546
|
-
/** The task completed successfully. */
|
|
1547
|
-
SUCCESS: "success",
|
|
1548
|
-
/** The task was canceled. */
|
|
1549
|
-
CANCELED: "canceled",
|
|
1550
|
-
/** The task failed with an error. */
|
|
1551
|
-
ERROR: "error"
|
|
1552
|
-
};
|
|
1553
|
-
function taskStateFromInternalTaskState(state) {
|
|
1554
|
-
switch (state) {
|
|
1555
|
-
case "running":
|
|
1556
|
-
case "pausing":
|
|
1557
|
-
case "canceling":
|
|
1558
|
-
return TaskState.RUNNING;
|
|
1559
|
-
case "paused":
|
|
1560
|
-
return TaskState.PAUSED;
|
|
1561
|
-
case "success":
|
|
1562
|
-
return TaskState.SUCCESS;
|
|
1563
|
-
case "canceled":
|
|
1564
|
-
return TaskState.CANCELED;
|
|
1565
|
-
case "error":
|
|
1566
|
-
return TaskState.ERROR;
|
|
1567
|
-
default:
|
|
1568
|
-
return TaskState.ERROR;
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
/**
|
|
1572
|
-
* @license
|
|
1573
|
-
* Copyright 2017 Google LLC
|
|
1574
|
-
*
|
|
1575
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1576
|
-
* you may not use this file except in compliance with the License.
|
|
1577
|
-
* You may obtain a copy of the License at
|
|
1578
|
-
*
|
|
1579
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1580
|
-
*
|
|
1581
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1582
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1583
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1584
|
-
* See the License for the specific language governing permissions and
|
|
1585
|
-
* limitations under the License.
|
|
1586
|
-
*/
|
|
1587
|
-
class Observer {
|
|
1588
|
-
constructor(nextOrObserver, error, complete) {
|
|
1589
|
-
const asFunctions = isFunction(nextOrObserver) || error != null || complete != null;
|
|
1590
|
-
if (asFunctions) {
|
|
1591
|
-
this.next = nextOrObserver;
|
|
1592
|
-
this.error = error ?? void 0;
|
|
1593
|
-
this.complete = complete ?? void 0;
|
|
1594
|
-
} else {
|
|
1595
|
-
const observer = nextOrObserver;
|
|
1596
|
-
this.next = observer.next;
|
|
1597
|
-
this.error = observer.error;
|
|
1598
|
-
this.complete = observer.complete;
|
|
1599
|
-
}
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
/**
|
|
1603
|
-
* @license
|
|
1604
|
-
* Copyright 2017 Google LLC
|
|
1605
|
-
*
|
|
1606
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1607
|
-
* you may not use this file except in compliance with the License.
|
|
1608
|
-
* You may obtain a copy of the License at
|
|
1609
|
-
*
|
|
1610
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1611
|
-
*
|
|
1612
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1613
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1614
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1615
|
-
* See the License for the specific language governing permissions and
|
|
1616
|
-
* limitations under the License.
|
|
1617
|
-
*/
|
|
1618
|
-
function async(f) {
|
|
1619
|
-
return (...argsToForward) => {
|
|
1620
|
-
Promise.resolve().then(() => f(...argsToForward));
|
|
1621
|
-
};
|
|
1622
|
-
}
|
|
1623
|
-
class XhrConnection {
|
|
1624
|
-
constructor() {
|
|
1625
|
-
this.sent_ = false;
|
|
1626
|
-
this.xhr_ = new XMLHttpRequest();
|
|
1627
|
-
this.initXhr();
|
|
1628
|
-
this.errorCode_ = ErrorCode.NO_ERROR;
|
|
1629
|
-
this.sendPromise_ = new Promise((resolve) => {
|
|
1630
|
-
this.xhr_.addEventListener("abort", () => {
|
|
1631
|
-
this.errorCode_ = ErrorCode.ABORT;
|
|
1632
|
-
resolve();
|
|
1633
|
-
});
|
|
1634
|
-
this.xhr_.addEventListener("error", () => {
|
|
1635
|
-
this.errorCode_ = ErrorCode.NETWORK_ERROR;
|
|
1636
|
-
resolve();
|
|
1637
|
-
});
|
|
1638
|
-
this.xhr_.addEventListener("load", () => {
|
|
1639
|
-
resolve();
|
|
1640
|
-
});
|
|
1641
|
-
});
|
|
1642
|
-
}
|
|
1643
|
-
send(url, method, isUsingEmulator, body, headers) {
|
|
1644
|
-
if (this.sent_) {
|
|
1645
|
-
throw internalError("cannot .send() more than once");
|
|
1646
|
-
}
|
|
1647
|
-
if (isCloudWorkstation(url) && isUsingEmulator) {
|
|
1648
|
-
this.xhr_.withCredentials = true;
|
|
1649
|
-
}
|
|
1650
|
-
this.sent_ = true;
|
|
1651
|
-
this.xhr_.open(method, url, true);
|
|
1652
|
-
if (headers !== void 0) {
|
|
1653
|
-
for (const key in headers) {
|
|
1654
|
-
if (headers.hasOwnProperty(key)) {
|
|
1655
|
-
this.xhr_.setRequestHeader(key, headers[key].toString());
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
}
|
|
1659
|
-
if (body !== void 0) {
|
|
1660
|
-
this.xhr_.send(body);
|
|
1661
|
-
} else {
|
|
1662
|
-
this.xhr_.send();
|
|
1663
|
-
}
|
|
1664
|
-
return this.sendPromise_;
|
|
1665
|
-
}
|
|
1666
|
-
getErrorCode() {
|
|
1667
|
-
if (!this.sent_) {
|
|
1668
|
-
throw internalError("cannot .getErrorCode() before sending");
|
|
1669
|
-
}
|
|
1670
|
-
return this.errorCode_;
|
|
1671
|
-
}
|
|
1672
|
-
getStatus() {
|
|
1673
|
-
if (!this.sent_) {
|
|
1674
|
-
throw internalError("cannot .getStatus() before sending");
|
|
1675
|
-
}
|
|
1676
|
-
try {
|
|
1677
|
-
return this.xhr_.status;
|
|
1678
|
-
} catch (e) {
|
|
1679
|
-
return -1;
|
|
1680
|
-
}
|
|
1681
|
-
}
|
|
1682
|
-
getResponse() {
|
|
1683
|
-
if (!this.sent_) {
|
|
1684
|
-
throw internalError("cannot .getResponse() before sending");
|
|
1685
|
-
}
|
|
1686
|
-
return this.xhr_.response;
|
|
1687
|
-
}
|
|
1688
|
-
getErrorText() {
|
|
1689
|
-
if (!this.sent_) {
|
|
1690
|
-
throw internalError("cannot .getErrorText() before sending");
|
|
1691
|
-
}
|
|
1692
|
-
return this.xhr_.statusText;
|
|
1693
|
-
}
|
|
1694
|
-
/** Aborts the request. */
|
|
1695
|
-
abort() {
|
|
1696
|
-
this.xhr_.abort();
|
|
1697
|
-
}
|
|
1698
|
-
getResponseHeader(header) {
|
|
1699
|
-
return this.xhr_.getResponseHeader(header);
|
|
1700
|
-
}
|
|
1701
|
-
addUploadProgressListener(listener) {
|
|
1702
|
-
if (this.xhr_.upload != null) {
|
|
1703
|
-
this.xhr_.upload.addEventListener("progress", listener);
|
|
1704
|
-
}
|
|
1705
|
-
}
|
|
1706
|
-
removeUploadProgressListener(listener) {
|
|
1707
|
-
if (this.xhr_.upload != null) {
|
|
1708
|
-
this.xhr_.upload.removeEventListener("progress", listener);
|
|
1709
|
-
}
|
|
1710
|
-
}
|
|
1711
|
-
}
|
|
1712
|
-
class XhrTextConnection extends XhrConnection {
|
|
1713
|
-
initXhr() {
|
|
1714
|
-
this.xhr_.responseType = "text";
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
function newTextConnection() {
|
|
1718
|
-
return new XhrTextConnection();
|
|
1719
|
-
}
|
|
1720
|
-
/**
|
|
1721
|
-
* @license
|
|
1722
|
-
* Copyright 2017 Google LLC
|
|
1723
|
-
*
|
|
1724
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1725
|
-
* you may not use this file except in compliance with the License.
|
|
1726
|
-
* You may obtain a copy of the License at
|
|
1727
|
-
*
|
|
1728
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1729
|
-
*
|
|
1730
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
1731
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1732
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1733
|
-
* See the License for the specific language governing permissions and
|
|
1734
|
-
* limitations under the License.
|
|
1735
|
-
*/
|
|
1736
|
-
class UploadTask {
|
|
1737
|
-
isExponentialBackoffExpired() {
|
|
1738
|
-
return this.sleepTime > this.maxSleepTime;
|
|
1739
|
-
}
|
|
1740
|
-
/**
|
|
1741
|
-
* @param ref - The firebaseStorage.Reference object this task came
|
|
1742
|
-
* from, untyped to avoid cyclic dependencies.
|
|
1743
|
-
* @param blob - The blob to upload.
|
|
1744
|
-
*/
|
|
1745
|
-
constructor(ref2, blob, metadata = null) {
|
|
1746
|
-
this._transferred = 0;
|
|
1747
|
-
this._needToFetchStatus = false;
|
|
1748
|
-
this._needToFetchMetadata = false;
|
|
1749
|
-
this._observers = [];
|
|
1750
|
-
this._error = void 0;
|
|
1751
|
-
this._uploadUrl = void 0;
|
|
1752
|
-
this._request = void 0;
|
|
1753
|
-
this._chunkMultiplier = 1;
|
|
1754
|
-
this._resolve = void 0;
|
|
1755
|
-
this._reject = void 0;
|
|
1756
|
-
this._ref = ref2;
|
|
1757
|
-
this._blob = blob;
|
|
1758
|
-
this._metadata = metadata;
|
|
1759
|
-
this._mappings = getMappings();
|
|
1760
|
-
this._resumable = this._shouldDoResumable(this._blob);
|
|
1761
|
-
this._state = "running";
|
|
1762
|
-
this._errorHandler = (error) => {
|
|
1763
|
-
this._request = void 0;
|
|
1764
|
-
this._chunkMultiplier = 1;
|
|
1765
|
-
if (error._codeEquals(StorageErrorCode.CANCELED)) {
|
|
1766
|
-
this._needToFetchStatus = true;
|
|
1767
|
-
this.completeTransitions_();
|
|
1768
|
-
} else {
|
|
1769
|
-
const backoffExpired = this.isExponentialBackoffExpired();
|
|
1770
|
-
if (isRetryStatusCode(error.status, [])) {
|
|
1771
|
-
if (backoffExpired) {
|
|
1772
|
-
error = retryLimitExceeded();
|
|
1773
|
-
} else {
|
|
1774
|
-
this.sleepTime = Math.max(this.sleepTime * 2, DEFAULT_MIN_SLEEP_TIME_MILLIS);
|
|
1775
|
-
this._needToFetchStatus = true;
|
|
1776
|
-
this.completeTransitions_();
|
|
1777
|
-
return;
|
|
1778
|
-
}
|
|
1779
|
-
}
|
|
1780
|
-
this._error = error;
|
|
1781
|
-
this._transition(
|
|
1782
|
-
"error"
|
|
1783
|
-
/* InternalTaskState.ERROR */
|
|
1784
|
-
);
|
|
1785
|
-
}
|
|
1786
|
-
};
|
|
1787
|
-
this._metadataErrorHandler = (error) => {
|
|
1788
|
-
this._request = void 0;
|
|
1789
|
-
if (error._codeEquals(StorageErrorCode.CANCELED)) {
|
|
1790
|
-
this.completeTransitions_();
|
|
1791
|
-
} else {
|
|
1792
|
-
this._error = error;
|
|
1793
|
-
this._transition(
|
|
1794
|
-
"error"
|
|
1795
|
-
/* InternalTaskState.ERROR */
|
|
1796
|
-
);
|
|
1797
|
-
}
|
|
1798
|
-
};
|
|
1799
|
-
this.sleepTime = 0;
|
|
1800
|
-
this.maxSleepTime = this._ref.storage.maxUploadRetryTime;
|
|
1801
|
-
this._promise = new Promise((resolve, reject) => {
|
|
1802
|
-
this._resolve = resolve;
|
|
1803
|
-
this._reject = reject;
|
|
1804
|
-
this._start();
|
|
1805
|
-
});
|
|
1806
|
-
this._promise.then(null, () => {
|
|
1807
|
-
});
|
|
1808
|
-
}
|
|
1809
|
-
_makeProgressCallback() {
|
|
1810
|
-
const sizeBefore = this._transferred;
|
|
1811
|
-
return (loaded) => this._updateProgress(sizeBefore + loaded);
|
|
1812
|
-
}
|
|
1813
|
-
_shouldDoResumable(blob) {
|
|
1814
|
-
return blob.size() > 256 * 1024;
|
|
1815
|
-
}
|
|
1816
|
-
_start() {
|
|
1817
|
-
if (this._state !== "running") {
|
|
1818
|
-
return;
|
|
1819
|
-
}
|
|
1820
|
-
if (this._request !== void 0) {
|
|
1821
|
-
return;
|
|
1822
|
-
}
|
|
1823
|
-
if (this._resumable) {
|
|
1824
|
-
if (this._uploadUrl === void 0) {
|
|
1825
|
-
this._createResumable();
|
|
1826
|
-
} else {
|
|
1827
|
-
if (this._needToFetchStatus) {
|
|
1828
|
-
this._fetchStatus();
|
|
1829
|
-
} else {
|
|
1830
|
-
if (this._needToFetchMetadata) {
|
|
1831
|
-
this._fetchMetadata();
|
|
1832
|
-
} else {
|
|
1833
|
-
this.pendingTimeout = setTimeout(() => {
|
|
1834
|
-
this.pendingTimeout = void 0;
|
|
1835
|
-
this._continueUpload();
|
|
1836
|
-
}, this.sleepTime);
|
|
1837
|
-
}
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
} else {
|
|
1841
|
-
this._oneShotUpload();
|
|
1842
|
-
}
|
|
1843
|
-
}
|
|
1844
|
-
_resolveToken(callback) {
|
|
1845
|
-
Promise.all([
|
|
1846
|
-
this._ref.storage._getAuthToken(),
|
|
1847
|
-
this._ref.storage._getAppCheckToken()
|
|
1848
|
-
]).then(([authToken, appCheckToken]) => {
|
|
1849
|
-
switch (this._state) {
|
|
1850
|
-
case "running":
|
|
1851
|
-
callback(authToken, appCheckToken);
|
|
1852
|
-
break;
|
|
1853
|
-
case "canceling":
|
|
1854
|
-
this._transition(
|
|
1855
|
-
"canceled"
|
|
1856
|
-
/* InternalTaskState.CANCELED */
|
|
1857
|
-
);
|
|
1858
|
-
break;
|
|
1859
|
-
case "pausing":
|
|
1860
|
-
this._transition(
|
|
1861
|
-
"paused"
|
|
1862
|
-
/* InternalTaskState.PAUSED */
|
|
1863
|
-
);
|
|
1864
|
-
break;
|
|
1865
|
-
}
|
|
1866
|
-
});
|
|
1867
|
-
}
|
|
1868
|
-
// TODO(andysoto): assert false
|
|
1869
|
-
_createResumable() {
|
|
1870
|
-
this._resolveToken((authToken, appCheckToken) => {
|
|
1871
|
-
const requestInfo = createResumableUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata);
|
|
1872
|
-
const createRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
|
|
1873
|
-
this._request = createRequest;
|
|
1874
|
-
createRequest.getPromise().then((url) => {
|
|
1875
|
-
this._request = void 0;
|
|
1876
|
-
this._uploadUrl = url;
|
|
1877
|
-
this._needToFetchStatus = false;
|
|
1878
|
-
this.completeTransitions_();
|
|
1879
|
-
}, this._errorHandler);
|
|
1880
|
-
});
|
|
1881
|
-
}
|
|
1882
|
-
_fetchStatus() {
|
|
1883
|
-
const url = this._uploadUrl;
|
|
1884
|
-
this._resolveToken((authToken, appCheckToken) => {
|
|
1885
|
-
const requestInfo = getResumableUploadStatus(this._ref.storage, this._ref._location, url, this._blob);
|
|
1886
|
-
const statusRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
|
|
1887
|
-
this._request = statusRequest;
|
|
1888
|
-
statusRequest.getPromise().then((status) => {
|
|
1889
|
-
status = status;
|
|
1890
|
-
this._request = void 0;
|
|
1891
|
-
this._updateProgress(status.current);
|
|
1892
|
-
this._needToFetchStatus = false;
|
|
1893
|
-
if (status.finalized) {
|
|
1894
|
-
this._needToFetchMetadata = true;
|
|
1895
|
-
}
|
|
1896
|
-
this.completeTransitions_();
|
|
1897
|
-
}, this._errorHandler);
|
|
1898
|
-
});
|
|
1899
|
-
}
|
|
1900
|
-
_continueUpload() {
|
|
1901
|
-
const chunkSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier;
|
|
1902
|
-
const status = new ResumableUploadStatus(this._transferred, this._blob.size());
|
|
1903
|
-
const url = this._uploadUrl;
|
|
1904
|
-
this._resolveToken((authToken, appCheckToken) => {
|
|
1905
|
-
let requestInfo;
|
|
1906
|
-
try {
|
|
1907
|
-
requestInfo = continueResumableUpload(this._ref._location, this._ref.storage, url, this._blob, chunkSize, this._mappings, status, this._makeProgressCallback());
|
|
1908
|
-
} catch (e) {
|
|
1909
|
-
this._error = e;
|
|
1910
|
-
this._transition(
|
|
1911
|
-
"error"
|
|
1912
|
-
/* InternalTaskState.ERROR */
|
|
1913
|
-
);
|
|
1914
|
-
return;
|
|
1915
|
-
}
|
|
1916
|
-
const uploadRequest = this._ref.storage._makeRequest(
|
|
1917
|
-
requestInfo,
|
|
1918
|
-
newTextConnection,
|
|
1919
|
-
authToken,
|
|
1920
|
-
appCheckToken,
|
|
1921
|
-
/*retry=*/
|
|
1922
|
-
false
|
|
1923
|
-
// Upload requests should not be retried as each retry should be preceded by another query request. Which is handled in this file.
|
|
1924
|
-
);
|
|
1925
|
-
this._request = uploadRequest;
|
|
1926
|
-
uploadRequest.getPromise().then((newStatus) => {
|
|
1927
|
-
this._increaseMultiplier();
|
|
1928
|
-
this._request = void 0;
|
|
1929
|
-
this._updateProgress(newStatus.current);
|
|
1930
|
-
if (newStatus.finalized) {
|
|
1931
|
-
this._metadata = newStatus.metadata;
|
|
1932
|
-
this._transition(
|
|
1933
|
-
"success"
|
|
1934
|
-
/* InternalTaskState.SUCCESS */
|
|
1935
|
-
);
|
|
1936
|
-
} else {
|
|
1937
|
-
this.completeTransitions_();
|
|
1938
|
-
}
|
|
1939
|
-
}, this._errorHandler);
|
|
1940
|
-
});
|
|
1941
|
-
}
|
|
1942
|
-
_increaseMultiplier() {
|
|
1943
|
-
const currentSize = RESUMABLE_UPLOAD_CHUNK_SIZE * this._chunkMultiplier;
|
|
1944
|
-
if (currentSize * 2 < 32 * 1024 * 1024) {
|
|
1945
|
-
this._chunkMultiplier *= 2;
|
|
1946
|
-
}
|
|
1947
|
-
}
|
|
1948
|
-
_fetchMetadata() {
|
|
1949
|
-
this._resolveToken((authToken, appCheckToken) => {
|
|
1950
|
-
const requestInfo = getMetadata$2(this._ref.storage, this._ref._location, this._mappings);
|
|
1951
|
-
const metadataRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
|
|
1952
|
-
this._request = metadataRequest;
|
|
1953
|
-
metadataRequest.getPromise().then((metadata) => {
|
|
1954
|
-
this._request = void 0;
|
|
1955
|
-
this._metadata = metadata;
|
|
1956
|
-
this._transition(
|
|
1957
|
-
"success"
|
|
1958
|
-
/* InternalTaskState.SUCCESS */
|
|
1959
|
-
);
|
|
1960
|
-
}, this._metadataErrorHandler);
|
|
1961
|
-
});
|
|
1962
|
-
}
|
|
1963
|
-
_oneShotUpload() {
|
|
1964
|
-
this._resolveToken((authToken, appCheckToken) => {
|
|
1965
|
-
const requestInfo = multipartUpload(this._ref.storage, this._ref._location, this._mappings, this._blob, this._metadata);
|
|
1966
|
-
const multipartRequest = this._ref.storage._makeRequest(requestInfo, newTextConnection, authToken, appCheckToken);
|
|
1967
|
-
this._request = multipartRequest;
|
|
1968
|
-
multipartRequest.getPromise().then((metadata) => {
|
|
1969
|
-
this._request = void 0;
|
|
1970
|
-
this._metadata = metadata;
|
|
1971
|
-
this._updateProgress(this._blob.size());
|
|
1972
|
-
this._transition(
|
|
1973
|
-
"success"
|
|
1974
|
-
/* InternalTaskState.SUCCESS */
|
|
1975
|
-
);
|
|
1976
|
-
}, this._errorHandler);
|
|
1977
|
-
});
|
|
1978
|
-
}
|
|
1979
|
-
_updateProgress(transferred) {
|
|
1980
|
-
const old = this._transferred;
|
|
1981
|
-
this._transferred = transferred;
|
|
1982
|
-
if (this._transferred !== old) {
|
|
1983
|
-
this._notifyObservers();
|
|
1984
|
-
}
|
|
1985
|
-
}
|
|
1986
|
-
_transition(state) {
|
|
1987
|
-
if (this._state === state) {
|
|
1988
|
-
return;
|
|
1989
|
-
}
|
|
1990
|
-
switch (state) {
|
|
1991
|
-
case "canceling":
|
|
1992
|
-
case "pausing":
|
|
1993
|
-
this._state = state;
|
|
1994
|
-
if (this._request !== void 0) {
|
|
1995
|
-
this._request.cancel();
|
|
1996
|
-
} else if (this.pendingTimeout) {
|
|
1997
|
-
clearTimeout(this.pendingTimeout);
|
|
1998
|
-
this.pendingTimeout = void 0;
|
|
1999
|
-
this.completeTransitions_();
|
|
2000
|
-
}
|
|
2001
|
-
break;
|
|
2002
|
-
case "running":
|
|
2003
|
-
const wasPaused = this._state === "paused";
|
|
2004
|
-
this._state = state;
|
|
2005
|
-
if (wasPaused) {
|
|
2006
|
-
this._notifyObservers();
|
|
2007
|
-
this._start();
|
|
2008
|
-
}
|
|
2009
|
-
break;
|
|
2010
|
-
case "paused":
|
|
2011
|
-
this._state = state;
|
|
2012
|
-
this._notifyObservers();
|
|
2013
|
-
break;
|
|
2014
|
-
case "canceled":
|
|
2015
|
-
this._error = canceled();
|
|
2016
|
-
this._state = state;
|
|
2017
|
-
this._notifyObservers();
|
|
2018
|
-
break;
|
|
2019
|
-
case "error":
|
|
2020
|
-
this._state = state;
|
|
2021
|
-
this._notifyObservers();
|
|
2022
|
-
break;
|
|
2023
|
-
case "success":
|
|
2024
|
-
this._state = state;
|
|
2025
|
-
this._notifyObservers();
|
|
2026
|
-
break;
|
|
2027
|
-
}
|
|
2028
|
-
}
|
|
2029
|
-
completeTransitions_() {
|
|
2030
|
-
switch (this._state) {
|
|
2031
|
-
case "pausing":
|
|
2032
|
-
this._transition(
|
|
2033
|
-
"paused"
|
|
2034
|
-
/* InternalTaskState.PAUSED */
|
|
2035
|
-
);
|
|
2036
|
-
break;
|
|
2037
|
-
case "canceling":
|
|
2038
|
-
this._transition(
|
|
2039
|
-
"canceled"
|
|
2040
|
-
/* InternalTaskState.CANCELED */
|
|
2041
|
-
);
|
|
2042
|
-
break;
|
|
2043
|
-
case "running":
|
|
2044
|
-
this._start();
|
|
2045
|
-
break;
|
|
2046
|
-
}
|
|
2047
|
-
}
|
|
2048
|
-
/**
|
|
2049
|
-
* A snapshot of the current task state.
|
|
2050
|
-
*/
|
|
2051
|
-
get snapshot() {
|
|
2052
|
-
const externalState = taskStateFromInternalTaskState(this._state);
|
|
2053
|
-
return {
|
|
2054
|
-
bytesTransferred: this._transferred,
|
|
2055
|
-
totalBytes: this._blob.size(),
|
|
2056
|
-
state: externalState,
|
|
2057
|
-
metadata: this._metadata,
|
|
2058
|
-
task: this,
|
|
2059
|
-
ref: this._ref
|
|
2060
|
-
};
|
|
2061
|
-
}
|
|
2062
|
-
/**
|
|
2063
|
-
* Adds a callback for an event.
|
|
2064
|
-
* @param type - The type of event to listen for.
|
|
2065
|
-
* @param nextOrObserver -
|
|
2066
|
-
* The `next` function, which gets called for each item in
|
|
2067
|
-
* the event stream, or an observer object with some or all of these three
|
|
2068
|
-
* properties (`next`, `error`, `complete`).
|
|
2069
|
-
* @param error - A function that gets called with a `StorageError`
|
|
2070
|
-
* if the event stream ends due to an error.
|
|
2071
|
-
* @param completed - A function that gets called if the
|
|
2072
|
-
* event stream ends normally.
|
|
2073
|
-
* @returns
|
|
2074
|
-
* If only the event argument is passed, returns a function you can use to
|
|
2075
|
-
* add callbacks (see the examples above). If more than just the event
|
|
2076
|
-
* argument is passed, returns a function you can call to unregister the
|
|
2077
|
-
* callbacks.
|
|
2078
|
-
*/
|
|
2079
|
-
on(type, nextOrObserver, error, completed) {
|
|
2080
|
-
const observer = new Observer(nextOrObserver || void 0, error || void 0, completed || void 0);
|
|
2081
|
-
this._addObserver(observer);
|
|
2082
|
-
return () => {
|
|
2083
|
-
this._removeObserver(observer);
|
|
2084
|
-
};
|
|
2085
|
-
}
|
|
2086
|
-
/**
|
|
2087
|
-
* This object behaves like a Promise, and resolves with its snapshot data
|
|
2088
|
-
* when the upload completes.
|
|
2089
|
-
* @param onFulfilled - The fulfillment callback. Promise chaining works as normal.
|
|
2090
|
-
* @param onRejected - The rejection callback.
|
|
2091
|
-
*/
|
|
2092
|
-
then(onFulfilled, onRejected) {
|
|
2093
|
-
return this._promise.then(onFulfilled, onRejected);
|
|
2094
|
-
}
|
|
2095
|
-
/**
|
|
2096
|
-
* Equivalent to calling `then(null, onRejected)`.
|
|
2097
|
-
*/
|
|
2098
|
-
catch(onRejected) {
|
|
2099
|
-
return this.then(null, onRejected);
|
|
2100
|
-
}
|
|
2101
|
-
/**
|
|
2102
|
-
* Adds the given observer.
|
|
2103
|
-
*/
|
|
2104
|
-
_addObserver(observer) {
|
|
2105
|
-
this._observers.push(observer);
|
|
2106
|
-
this._notifyObserver(observer);
|
|
2107
|
-
}
|
|
2108
|
-
/**
|
|
2109
|
-
* Removes the given observer.
|
|
2110
|
-
*/
|
|
2111
|
-
_removeObserver(observer) {
|
|
2112
|
-
const i = this._observers.indexOf(observer);
|
|
2113
|
-
if (i !== -1) {
|
|
2114
|
-
this._observers.splice(i, 1);
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2117
|
-
_notifyObservers() {
|
|
2118
|
-
this._finishPromise();
|
|
2119
|
-
const observers = this._observers.slice();
|
|
2120
|
-
observers.forEach((observer) => {
|
|
2121
|
-
this._notifyObserver(observer);
|
|
2122
|
-
});
|
|
2123
|
-
}
|
|
2124
|
-
_finishPromise() {
|
|
2125
|
-
if (this._resolve !== void 0) {
|
|
2126
|
-
let triggered = true;
|
|
2127
|
-
switch (taskStateFromInternalTaskState(this._state)) {
|
|
2128
|
-
case TaskState.SUCCESS:
|
|
2129
|
-
async(this._resolve.bind(null, this.snapshot))();
|
|
2130
|
-
break;
|
|
2131
|
-
case TaskState.CANCELED:
|
|
2132
|
-
case TaskState.ERROR:
|
|
2133
|
-
const toCall = this._reject;
|
|
2134
|
-
async(toCall.bind(null, this._error))();
|
|
2135
|
-
break;
|
|
2136
|
-
default:
|
|
2137
|
-
triggered = false;
|
|
2138
|
-
break;
|
|
2139
|
-
}
|
|
2140
|
-
if (triggered) {
|
|
2141
|
-
this._resolve = void 0;
|
|
2142
|
-
this._reject = void 0;
|
|
2143
|
-
}
|
|
2144
|
-
}
|
|
2145
|
-
}
|
|
2146
|
-
_notifyObserver(observer) {
|
|
2147
|
-
const externalState = taskStateFromInternalTaskState(this._state);
|
|
2148
|
-
switch (externalState) {
|
|
2149
|
-
case TaskState.RUNNING:
|
|
2150
|
-
case TaskState.PAUSED:
|
|
2151
|
-
if (observer.next) {
|
|
2152
|
-
async(observer.next.bind(observer, this.snapshot))();
|
|
2153
|
-
}
|
|
2154
|
-
break;
|
|
2155
|
-
case TaskState.SUCCESS:
|
|
2156
|
-
if (observer.complete) {
|
|
2157
|
-
async(observer.complete.bind(observer))();
|
|
2158
|
-
}
|
|
2159
|
-
break;
|
|
2160
|
-
case TaskState.CANCELED:
|
|
2161
|
-
case TaskState.ERROR:
|
|
2162
|
-
if (observer.error) {
|
|
2163
|
-
async(observer.error.bind(observer, this._error))();
|
|
2164
|
-
}
|
|
2165
|
-
break;
|
|
2166
|
-
default:
|
|
2167
|
-
if (observer.error) {
|
|
2168
|
-
async(observer.error.bind(observer, this._error))();
|
|
2169
|
-
}
|
|
2170
|
-
}
|
|
2171
|
-
}
|
|
2172
|
-
/**
|
|
2173
|
-
* Resumes a paused task. Has no effect on a currently running or failed task.
|
|
2174
|
-
* @returns True if the operation took effect, false if ignored.
|
|
2175
|
-
*/
|
|
2176
|
-
resume() {
|
|
2177
|
-
const valid = this._state === "paused" || this._state === "pausing";
|
|
2178
|
-
if (valid) {
|
|
2179
|
-
this._transition(
|
|
2180
|
-
"running"
|
|
2181
|
-
/* InternalTaskState.RUNNING */
|
|
2182
|
-
);
|
|
2183
|
-
}
|
|
2184
|
-
return valid;
|
|
2185
|
-
}
|
|
2186
|
-
/**
|
|
2187
|
-
* Pauses a currently running task. Has no effect on a paused or failed task.
|
|
2188
|
-
* @returns True if the operation took effect, false if ignored.
|
|
2189
|
-
*/
|
|
2190
|
-
pause() {
|
|
2191
|
-
const valid = this._state === "running";
|
|
2192
|
-
if (valid) {
|
|
2193
|
-
this._transition(
|
|
2194
|
-
"pausing"
|
|
2195
|
-
/* InternalTaskState.PAUSING */
|
|
2196
|
-
);
|
|
2197
|
-
}
|
|
2198
|
-
return valid;
|
|
2199
|
-
}
|
|
2200
|
-
/**
|
|
2201
|
-
* Cancels a currently running or paused task. Has no effect on a complete or
|
|
2202
|
-
* failed task.
|
|
2203
|
-
* @returns True if the operation took effect, false if ignored.
|
|
2204
|
-
*/
|
|
2205
|
-
cancel() {
|
|
2206
|
-
const valid = this._state === "running" || this._state === "pausing";
|
|
2207
|
-
if (valid) {
|
|
2208
|
-
this._transition(
|
|
2209
|
-
"canceling"
|
|
2210
|
-
/* InternalTaskState.CANCELING */
|
|
2211
|
-
);
|
|
2212
|
-
}
|
|
2213
|
-
return valid;
|
|
2214
|
-
}
|
|
2215
|
-
}
|
|
2216
|
-
/**
|
|
2217
|
-
* @license
|
|
2218
|
-
* Copyright 2019 Google LLC
|
|
2219
|
-
*
|
|
2220
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2221
|
-
* you may not use this file except in compliance with the License.
|
|
2222
|
-
* You may obtain a copy of the License at
|
|
2223
|
-
*
|
|
2224
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2225
|
-
*
|
|
2226
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2227
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2228
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2229
|
-
* See the License for the specific language governing permissions and
|
|
2230
|
-
* limitations under the License.
|
|
2231
|
-
*/
|
|
2232
|
-
class Reference {
|
|
2233
|
-
constructor(_service, location) {
|
|
2234
|
-
this._service = _service;
|
|
2235
|
-
if (location instanceof Location) {
|
|
2236
|
-
this._location = location;
|
|
2237
|
-
} else {
|
|
2238
|
-
this._location = Location.makeFromUrl(location, _service.host);
|
|
2239
|
-
}
|
|
2240
|
-
}
|
|
2241
|
-
/**
|
|
2242
|
-
* Returns the URL for the bucket and path this object references,
|
|
2243
|
-
* in the form gs://<bucket>/<object-path>
|
|
2244
|
-
* @override
|
|
2245
|
-
*/
|
|
2246
|
-
toString() {
|
|
2247
|
-
return "gs://" + this._location.bucket + "/" + this._location.path;
|
|
2248
|
-
}
|
|
2249
|
-
_newRef(service, location) {
|
|
2250
|
-
return new Reference(service, location);
|
|
2251
|
-
}
|
|
2252
|
-
/**
|
|
2253
|
-
* A reference to the root of this object's bucket.
|
|
2254
|
-
*/
|
|
2255
|
-
get root() {
|
|
2256
|
-
const location = new Location(this._location.bucket, "");
|
|
2257
|
-
return this._newRef(this._service, location);
|
|
2258
|
-
}
|
|
2259
|
-
/**
|
|
2260
|
-
* The name of the bucket containing this reference's object.
|
|
2261
|
-
*/
|
|
2262
|
-
get bucket() {
|
|
2263
|
-
return this._location.bucket;
|
|
2264
|
-
}
|
|
2265
|
-
/**
|
|
2266
|
-
* The full path of this object.
|
|
2267
|
-
*/
|
|
2268
|
-
get fullPath() {
|
|
2269
|
-
return this._location.path;
|
|
2270
|
-
}
|
|
2271
|
-
/**
|
|
2272
|
-
* The short name of this object, which is the last component of the full path.
|
|
2273
|
-
* For example, if fullPath is 'full/path/image.png', name is 'image.png'.
|
|
2274
|
-
*/
|
|
2275
|
-
get name() {
|
|
2276
|
-
return lastComponent(this._location.path);
|
|
2277
|
-
}
|
|
2278
|
-
/**
|
|
2279
|
-
* The `StorageService` instance this `StorageReference` is associated with.
|
|
2280
|
-
*/
|
|
2281
|
-
get storage() {
|
|
2282
|
-
return this._service;
|
|
2283
|
-
}
|
|
2284
|
-
/**
|
|
2285
|
-
* A `StorageReference` pointing to the parent location of this `StorageReference`, or null if
|
|
2286
|
-
* this reference is the root.
|
|
2287
|
-
*/
|
|
2288
|
-
get parent() {
|
|
2289
|
-
const newPath = parent(this._location.path);
|
|
2290
|
-
if (newPath === null) {
|
|
2291
|
-
return null;
|
|
2292
|
-
}
|
|
2293
|
-
const location = new Location(this._location.bucket, newPath);
|
|
2294
|
-
return new Reference(this._service, location);
|
|
2295
|
-
}
|
|
2296
|
-
/**
|
|
2297
|
-
* Utility function to throw an error in methods that do not accept a root reference.
|
|
2298
|
-
*/
|
|
2299
|
-
_throwIfRoot(name2) {
|
|
2300
|
-
if (this._location.path === "") {
|
|
2301
|
-
throw invalidRootOperation(name2);
|
|
2302
|
-
}
|
|
2303
|
-
}
|
|
2304
|
-
}
|
|
2305
|
-
function uploadBytesResumable$1(ref2, data, metadata) {
|
|
2306
|
-
ref2._throwIfRoot("uploadBytesResumable");
|
|
2307
|
-
return new UploadTask(ref2, new FbsBlob(data), metadata);
|
|
2308
|
-
}
|
|
2309
|
-
function getDownloadURL$1(ref2) {
|
|
2310
|
-
ref2._throwIfRoot("getDownloadURL");
|
|
2311
|
-
const requestInfo = getDownloadUrl(ref2.storage, ref2._location, getMappings());
|
|
2312
|
-
return ref2.storage.makeRequestWithTokens(requestInfo, newTextConnection).then((url) => {
|
|
2313
|
-
if (url === null) {
|
|
2314
|
-
throw noDownloadURL();
|
|
2315
|
-
}
|
|
2316
|
-
return url;
|
|
2317
|
-
});
|
|
2318
|
-
}
|
|
2319
|
-
function deleteObject$1(ref2) {
|
|
2320
|
-
ref2._throwIfRoot("deleteObject");
|
|
2321
|
-
const requestInfo = deleteObject$2(ref2.storage, ref2._location);
|
|
2322
|
-
return ref2.storage.makeRequestWithTokens(requestInfo, newTextConnection);
|
|
2323
|
-
}
|
|
2324
|
-
function _getChild$1(ref2, childPath) {
|
|
2325
|
-
const newPath = child(ref2._location.path, childPath);
|
|
2326
|
-
const location = new Location(ref2._location.bucket, newPath);
|
|
2327
|
-
return new Reference(ref2.storage, location);
|
|
2328
|
-
}
|
|
2329
|
-
/**
|
|
2330
|
-
* @license
|
|
2331
|
-
* Copyright 2017 Google LLC
|
|
2332
|
-
*
|
|
2333
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2334
|
-
* you may not use this file except in compliance with the License.
|
|
2335
|
-
* You may obtain a copy of the License at
|
|
2336
|
-
*
|
|
2337
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2338
|
-
*
|
|
2339
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2340
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2341
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2342
|
-
* See the License for the specific language governing permissions and
|
|
2343
|
-
* limitations under the License.
|
|
2344
|
-
*/
|
|
2345
|
-
function isUrl(path) {
|
|
2346
|
-
return /^[A-Za-z]+:\/\//.test(path);
|
|
2347
|
-
}
|
|
2348
|
-
function refFromURL(service, url) {
|
|
2349
|
-
return new Reference(service, url);
|
|
2350
|
-
}
|
|
2351
|
-
function refFromPath(ref2, path) {
|
|
2352
|
-
if (ref2 instanceof FirebaseStorageImpl) {
|
|
2353
|
-
const service = ref2;
|
|
2354
|
-
if (service._bucket == null) {
|
|
2355
|
-
throw noDefaultBucket();
|
|
2356
|
-
}
|
|
2357
|
-
const reference = new Reference(service, service._bucket);
|
|
2358
|
-
if (path != null) {
|
|
2359
|
-
return refFromPath(reference, path);
|
|
2360
|
-
} else {
|
|
2361
|
-
return reference;
|
|
2362
|
-
}
|
|
2363
|
-
} else {
|
|
2364
|
-
if (path !== void 0) {
|
|
2365
|
-
return _getChild$1(ref2, path);
|
|
2366
|
-
} else {
|
|
2367
|
-
return ref2;
|
|
2368
|
-
}
|
|
2369
|
-
}
|
|
2370
|
-
}
|
|
2371
|
-
function ref$1(serviceOrRef, pathOrUrl) {
|
|
2372
|
-
if (pathOrUrl && isUrl(pathOrUrl)) {
|
|
2373
|
-
if (serviceOrRef instanceof FirebaseStorageImpl) {
|
|
2374
|
-
return refFromURL(serviceOrRef, pathOrUrl);
|
|
2375
|
-
} else {
|
|
2376
|
-
throw invalidArgument("To use ref(service, url), the first argument must be a Storage instance.");
|
|
2377
|
-
}
|
|
2378
|
-
} else {
|
|
2379
|
-
return refFromPath(serviceOrRef, pathOrUrl);
|
|
2380
|
-
}
|
|
2381
|
-
}
|
|
2382
|
-
function extractBucket(host, config) {
|
|
2383
|
-
const bucketString = config == null ? void 0 : config[CONFIG_STORAGE_BUCKET_KEY];
|
|
2384
|
-
if (bucketString == null) {
|
|
2385
|
-
return null;
|
|
2386
|
-
}
|
|
2387
|
-
return Location.makeFromBucketSpec(bucketString, host);
|
|
2388
|
-
}
|
|
2389
|
-
function connectStorageEmulator$1(storage, host, port, options = {}) {
|
|
2390
|
-
storage.host = `${host}:${port}`;
|
|
2391
|
-
const useSsl = isCloudWorkstation(host);
|
|
2392
|
-
if (useSsl) {
|
|
2393
|
-
void pingServer(`https://${storage.host}/b`);
|
|
2394
|
-
}
|
|
2395
|
-
storage._isUsingEmulator = true;
|
|
2396
|
-
storage._protocol = useSsl ? "https" : "http";
|
|
2397
|
-
const { mockUserToken } = options;
|
|
2398
|
-
if (mockUserToken) {
|
|
2399
|
-
storage._overrideAuthToken = typeof mockUserToken === "string" ? mockUserToken : createMockUserToken(mockUserToken, storage.app.options.projectId);
|
|
2400
|
-
}
|
|
2401
|
-
}
|
|
2402
|
-
class FirebaseStorageImpl {
|
|
2403
|
-
constructor(app, _authProvider, _appCheckProvider, _url, _firebaseVersion, _isUsingEmulator = false) {
|
|
2404
|
-
this.app = app;
|
|
2405
|
-
this._authProvider = _authProvider;
|
|
2406
|
-
this._appCheckProvider = _appCheckProvider;
|
|
2407
|
-
this._url = _url;
|
|
2408
|
-
this._firebaseVersion = _firebaseVersion;
|
|
2409
|
-
this._isUsingEmulator = _isUsingEmulator;
|
|
2410
|
-
this._bucket = null;
|
|
2411
|
-
this._host = DEFAULT_HOST;
|
|
2412
|
-
this._protocol = "https";
|
|
2413
|
-
this._appId = null;
|
|
2414
|
-
this._deleted = false;
|
|
2415
|
-
this._maxOperationRetryTime = DEFAULT_MAX_OPERATION_RETRY_TIME;
|
|
2416
|
-
this._maxUploadRetryTime = DEFAULT_MAX_UPLOAD_RETRY_TIME;
|
|
2417
|
-
this._requests = /* @__PURE__ */ new Set();
|
|
2418
|
-
if (_url != null) {
|
|
2419
|
-
this._bucket = Location.makeFromBucketSpec(_url, this._host);
|
|
2420
|
-
} else {
|
|
2421
|
-
this._bucket = extractBucket(this._host, this.app.options);
|
|
2422
|
-
}
|
|
2423
|
-
}
|
|
2424
|
-
/**
|
|
2425
|
-
* The host string for this service, in the form of `host` or
|
|
2426
|
-
* `host:port`.
|
|
2427
|
-
*/
|
|
2428
|
-
get host() {
|
|
2429
|
-
return this._host;
|
|
2430
|
-
}
|
|
2431
|
-
set host(host) {
|
|
2432
|
-
this._host = host;
|
|
2433
|
-
if (this._url != null) {
|
|
2434
|
-
this._bucket = Location.makeFromBucketSpec(this._url, host);
|
|
2435
|
-
} else {
|
|
2436
|
-
this._bucket = extractBucket(host, this.app.options);
|
|
2437
|
-
}
|
|
2438
|
-
}
|
|
2439
|
-
/**
|
|
2440
|
-
* The maximum time to retry uploads in milliseconds.
|
|
2441
|
-
*/
|
|
2442
|
-
get maxUploadRetryTime() {
|
|
2443
|
-
return this._maxUploadRetryTime;
|
|
2444
|
-
}
|
|
2445
|
-
set maxUploadRetryTime(time) {
|
|
2446
|
-
validateNumber(
|
|
2447
|
-
"time",
|
|
2448
|
-
/* minValue=*/
|
|
2449
|
-
0,
|
|
2450
|
-
/* maxValue= */
|
|
2451
|
-
Number.POSITIVE_INFINITY,
|
|
2452
|
-
time
|
|
2453
|
-
);
|
|
2454
|
-
this._maxUploadRetryTime = time;
|
|
2455
|
-
}
|
|
2456
|
-
/**
|
|
2457
|
-
* The maximum time to retry operations other than uploads or downloads in
|
|
2458
|
-
* milliseconds.
|
|
2459
|
-
*/
|
|
2460
|
-
get maxOperationRetryTime() {
|
|
2461
|
-
return this._maxOperationRetryTime;
|
|
2462
|
-
}
|
|
2463
|
-
set maxOperationRetryTime(time) {
|
|
2464
|
-
validateNumber(
|
|
2465
|
-
"time",
|
|
2466
|
-
/* minValue=*/
|
|
2467
|
-
0,
|
|
2468
|
-
/* maxValue= */
|
|
2469
|
-
Number.POSITIVE_INFINITY,
|
|
2470
|
-
time
|
|
2471
|
-
);
|
|
2472
|
-
this._maxOperationRetryTime = time;
|
|
2473
|
-
}
|
|
2474
|
-
async _getAuthToken() {
|
|
2475
|
-
if (this._overrideAuthToken) {
|
|
2476
|
-
return this._overrideAuthToken;
|
|
2477
|
-
}
|
|
2478
|
-
const auth = this._authProvider.getImmediate({ optional: true });
|
|
2479
|
-
if (auth) {
|
|
2480
|
-
const tokenData = await auth.getToken();
|
|
2481
|
-
if (tokenData !== null) {
|
|
2482
|
-
return tokenData.accessToken;
|
|
2483
|
-
}
|
|
2484
|
-
}
|
|
2485
|
-
return null;
|
|
2486
|
-
}
|
|
2487
|
-
async _getAppCheckToken() {
|
|
2488
|
-
if (_isFirebaseServerApp(this.app) && this.app.settings.appCheckToken) {
|
|
2489
|
-
return this.app.settings.appCheckToken;
|
|
2490
|
-
}
|
|
2491
|
-
const appCheck = this._appCheckProvider.getImmediate({ optional: true });
|
|
2492
|
-
if (appCheck) {
|
|
2493
|
-
const result = await appCheck.getToken();
|
|
2494
|
-
return result.token;
|
|
2495
|
-
}
|
|
2496
|
-
return null;
|
|
2497
|
-
}
|
|
2498
|
-
/**
|
|
2499
|
-
* Stop running requests and prevent more from being created.
|
|
2500
|
-
*/
|
|
2501
|
-
_delete() {
|
|
2502
|
-
if (!this._deleted) {
|
|
2503
|
-
this._deleted = true;
|
|
2504
|
-
this._requests.forEach((request) => request.cancel());
|
|
2505
|
-
this._requests.clear();
|
|
2506
|
-
}
|
|
2507
|
-
return Promise.resolve();
|
|
2508
|
-
}
|
|
2509
|
-
/**
|
|
2510
|
-
* Returns a new firebaseStorage.Reference object referencing this StorageService
|
|
2511
|
-
* at the given Location.
|
|
2512
|
-
*/
|
|
2513
|
-
_makeStorageReference(loc) {
|
|
2514
|
-
return new Reference(this, loc);
|
|
2515
|
-
}
|
|
2516
|
-
/**
|
|
2517
|
-
* @param requestInfo - HTTP RequestInfo object
|
|
2518
|
-
* @param authToken - Firebase auth token
|
|
2519
|
-
*/
|
|
2520
|
-
_makeRequest(requestInfo, requestFactory, authToken, appCheckToken, retry = true) {
|
|
2521
|
-
if (!this._deleted) {
|
|
2522
|
-
const request = makeRequest(requestInfo, this._appId, authToken, appCheckToken, requestFactory, this._firebaseVersion, retry, this._isUsingEmulator);
|
|
2523
|
-
this._requests.add(request);
|
|
2524
|
-
request.getPromise().then(() => this._requests.delete(request), () => this._requests.delete(request));
|
|
2525
|
-
return request;
|
|
2526
|
-
} else {
|
|
2527
|
-
return new FailRequest(appDeleted());
|
|
2528
|
-
}
|
|
2529
|
-
}
|
|
2530
|
-
async makeRequestWithTokens(requestInfo, requestFactory) {
|
|
2531
|
-
const [authToken, appCheckToken] = await Promise.all([
|
|
2532
|
-
this._getAuthToken(),
|
|
2533
|
-
this._getAppCheckToken()
|
|
2534
|
-
]);
|
|
2535
|
-
return this._makeRequest(requestInfo, requestFactory, authToken, appCheckToken).getPromise();
|
|
2536
|
-
}
|
|
2537
|
-
}
|
|
2538
|
-
const name = "@firebase/storage";
|
|
2539
|
-
const version = "0.14.2";
|
|
2540
|
-
/**
|
|
2541
|
-
* @license
|
|
2542
|
-
* Copyright 2020 Google LLC
|
|
2543
|
-
*
|
|
2544
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2545
|
-
* you may not use this file except in compliance with the License.
|
|
2546
|
-
* You may obtain a copy of the License at
|
|
2547
|
-
*
|
|
2548
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2549
|
-
*
|
|
2550
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2551
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2552
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2553
|
-
* See the License for the specific language governing permissions and
|
|
2554
|
-
* limitations under the License.
|
|
2555
|
-
*/
|
|
2556
|
-
const STORAGE_TYPE = "storage";
|
|
2557
|
-
function uploadBytesResumable(ref2, data, metadata) {
|
|
2558
|
-
ref2 = getModularInstance(ref2);
|
|
2559
|
-
return uploadBytesResumable$1(ref2, data, metadata);
|
|
2560
|
-
}
|
|
2561
|
-
function getDownloadURL(ref2) {
|
|
2562
|
-
ref2 = getModularInstance(ref2);
|
|
2563
|
-
return getDownloadURL$1(ref2);
|
|
2564
|
-
}
|
|
2565
|
-
function deleteObject(ref2) {
|
|
2566
|
-
ref2 = getModularInstance(ref2);
|
|
2567
|
-
return deleteObject$1(ref2);
|
|
2568
|
-
}
|
|
2569
|
-
function ref(serviceOrRef, pathOrUrl) {
|
|
2570
|
-
serviceOrRef = getModularInstance(serviceOrRef);
|
|
2571
|
-
return ref$1(serviceOrRef, pathOrUrl);
|
|
2572
|
-
}
|
|
2573
|
-
function getStorage(app = getApp(), bucketUrl) {
|
|
2574
|
-
app = getModularInstance(app);
|
|
2575
|
-
const storageProvider = _getProvider(app, STORAGE_TYPE);
|
|
2576
|
-
const storageInstance = storageProvider.getImmediate({
|
|
2577
|
-
identifier: bucketUrl
|
|
2578
|
-
});
|
|
2579
|
-
const emulator = getDefaultEmulatorHostnameAndPort("storage");
|
|
2580
|
-
if (emulator) {
|
|
2581
|
-
connectStorageEmulator(storageInstance, ...emulator);
|
|
2582
|
-
}
|
|
2583
|
-
return storageInstance;
|
|
2584
|
-
}
|
|
2585
|
-
function connectStorageEmulator(storage, host, port, options = {}) {
|
|
2586
|
-
connectStorageEmulator$1(storage, host, port, options);
|
|
2587
|
-
}
|
|
2588
|
-
function factory(container, { instanceIdentifier: url }) {
|
|
2589
|
-
const app = container.getProvider("app").getImmediate();
|
|
2590
|
-
const authProvider = container.getProvider("auth-internal");
|
|
2591
|
-
const appCheckProvider = container.getProvider("app-check-internal");
|
|
2592
|
-
return new FirebaseStorageImpl(app, authProvider, appCheckProvider, url, SDK_VERSION);
|
|
2593
|
-
}
|
|
2594
|
-
function registerStorage() {
|
|
2595
|
-
_registerComponent(new Component(
|
|
2596
|
-
STORAGE_TYPE,
|
|
2597
|
-
factory,
|
|
2598
|
-
"PUBLIC"
|
|
2599
|
-
/* ComponentType.PUBLIC */
|
|
2600
|
-
).setMultipleInstances(true));
|
|
2601
|
-
registerVersion(name, version, "");
|
|
2602
|
-
registerVersion(name, version, "esm2020");
|
|
2603
|
-
}
|
|
2604
|
-
registerStorage();
|
|
2605
|
-
export {
|
|
2606
|
-
StorageError,
|
|
2607
|
-
StorageErrorCode,
|
|
2608
|
-
StringFormat,
|
|
2609
|
-
FbsBlob as _FbsBlob,
|
|
2610
|
-
Location as _Location,
|
|
2611
|
-
TaskState as _TaskState,
|
|
2612
|
-
UploadTask as _UploadTask,
|
|
2613
|
-
dataFromString as _dataFromString,
|
|
2614
|
-
invalidArgument as _invalidArgument,
|
|
2615
|
-
invalidRootOperation as _invalidRootOperation,
|
|
2616
|
-
connectStorageEmulator,
|
|
2617
|
-
deleteObject,
|
|
2618
|
-
getDownloadURL,
|
|
2619
|
-
getStorage,
|
|
2620
|
-
ref,
|
|
2621
|
-
uploadBytesResumable
|
|
2622
|
-
};
|
|
2623
|
-
//# sourceMappingURL=index.esm.js.map
|