@revealui/core 0.2.1 → 0.5.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/dist/api/compression.d.ts.map +1 -1
- package/dist/api/payload-optimization.d.ts.map +1 -1
- package/dist/api/rate-limit.d.ts +29 -28
- package/dist/api/rate-limit.d.ts.map +1 -1
- package/dist/api/rate-limit.js +63 -3
- package/dist/api/response-cache.d.ts.map +1 -1
- package/dist/api/response-cache.js +1 -1
- package/dist/api/rest.d.ts.map +1 -1
- package/dist/api/rest.js +3 -2
- package/dist/auth/access.d.ts.map +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/cache/query-cache.d.ts +12 -10
- package/dist/cache/query-cache.d.ts.map +1 -1
- package/dist/cache/query-cache.js +38 -42
- package/dist/caching/index.d.ts +6 -0
- package/dist/caching/index.d.ts.map +1 -0
- package/dist/caching/index.js +5 -0
- package/dist/client/admin/RichText.d.ts +1 -1
- package/dist/client/admin/RichText.d.ts.map +1 -1
- package/dist/client/admin/components/AdminDashboard.d.ts.map +1 -1
- package/dist/client/admin/components/AdminDashboard.js +195 -205
- package/dist/client/admin/components/CollectionList.d.ts.map +1 -1
- package/dist/client/admin/components/DocumentForm.d.ts.map +1 -1
- package/dist/client/admin/components/DocumentForm.js +130 -6
- package/dist/client/admin/components/GlobalForm.d.ts.map +1 -1
- package/dist/client/admin/context/ServerFunctionContext.d.ts +8 -0
- package/dist/client/admin/context/ServerFunctionContext.d.ts.map +1 -0
- package/dist/client/admin/context/ServerFunctionContext.js +15 -0
- package/dist/client/admin/i18n/en.d.ts.map +1 -1
- package/dist/client/admin/index.d.ts +1 -0
- package/dist/client/admin/index.d.ts.map +1 -1
- package/dist/client/admin/index.js +1 -0
- package/dist/client/admin/layout.d.ts +1 -1
- package/dist/client/admin/layout.d.ts.map +1 -1
- package/dist/client/admin/layout.js +3 -2
- package/dist/client/admin/page.d.ts.map +1 -1
- package/dist/client/admin/utils/apiClient.d.ts.map +1 -1
- package/dist/client/admin/utils/apiClient.js +0 -4
- package/dist/client/admin/utils/index.d.ts +0 -1
- package/dist/client/admin/utils/index.d.ts.map +1 -1
- package/dist/client/admin/utils/index.js +0 -1
- package/dist/client/admin/utils/serializeConfig.d.ts.map +1 -1
- package/dist/client/hooks.d.ts.map +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/richtext/RichTextEditor.d.ts.map +1 -1
- package/dist/client/richtext/components/ImageNodeComponent.d.ts.map +1 -1
- package/dist/client/richtext/components/ImageNodeComponent.js +0 -1
- package/dist/client/richtext/components/ImageUploadButton.d.ts +2 -0
- package/dist/client/richtext/components/ImageUploadButton.d.ts.map +1 -1
- package/dist/client/richtext/components/ImageUploadButton.js +30 -15
- package/dist/client/richtext/index.d.ts.map +1 -1
- package/dist/client/richtext/nodes/DecoratorBlockNode.d.ts.map +1 -1
- package/dist/client/richtext/nodes/ImageNode.d.ts.map +1 -1
- package/dist/client/richtext/plugins/CollaborationPlugin.d.ts.map +1 -1
- package/dist/client/richtext/plugins/CursorsOverlayPlugin.d.ts.map +1 -1
- package/dist/client/richtext/plugins/FloatingToolbarPlugin.d.ts.map +1 -1
- package/dist/client/richtext/plugins/FloatingToolbarPlugin.js +1 -3
- package/dist/client/richtext/plugins/ImagePlugin.d.ts.map +1 -1
- package/dist/client/richtext/plugins/ToolbarPlugin.d.ts.map +1 -1
- package/dist/client/ui/index.d.ts.map +1 -1
- package/dist/client/ui/index.js +1 -1
- package/dist/collections/CollectionOperations.d.ts +7 -7
- package/dist/collections/CollectionOperations.d.ts.map +1 -1
- package/dist/collections/CollectionOperations.js +15 -1
- package/dist/collections/hooks.d.ts.map +1 -1
- package/dist/collections/index.d.ts.map +1 -1
- package/dist/collections/operations/create.d.ts +4 -5
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +35 -6
- package/dist/collections/operations/createMany.d.ts +12 -0
- package/dist/collections/operations/createMany.d.ts.map +1 -0
- package/dist/collections/operations/createMany.js +43 -0
- package/dist/collections/operations/delete.d.ts +1 -1
- package/dist/collections/operations/delete.d.ts.map +1 -1
- package/dist/collections/operations/delete.js +31 -2
- package/dist/collections/operations/deleteMany.d.ts +11 -0
- package/dist/collections/operations/deleteMany.d.ts.map +1 -0
- package/dist/collections/operations/deleteMany.js +50 -0
- package/dist/collections/operations/fieldHooks.d.ts +2 -2
- package/dist/collections/operations/fieldHooks.d.ts.map +1 -1
- package/dist/collections/operations/fieldHooks.js +4 -4
- package/dist/collections/operations/find.d.ts +2 -4
- package/dist/collections/operations/find.d.ts.map +1 -1
- package/dist/collections/operations/find.js +115 -8
- package/dist/collections/operations/findById.d.ts +3 -4
- package/dist/collections/operations/findById.d.ts.map +1 -1
- package/dist/collections/operations/findById.js +53 -1
- package/dist/collections/operations/sqlAdapter.d.ts +23 -0
- package/dist/collections/operations/sqlAdapter.d.ts.map +1 -0
- package/dist/collections/operations/sqlAdapter.js +76 -0
- package/dist/collections/operations/update.d.ts +3 -5
- package/dist/collections/operations/update.d.ts.map +1 -1
- package/dist/collections/operations/update.js +103 -11
- package/dist/collections/operations/updateMany.d.ts +11 -0
- package/dist/collections/operations/updateMany.d.ts.map +1 -0
- package/dist/collections/operations/updateMany.js +52 -0
- package/dist/collections/registry.d.ts +12 -0
- package/dist/collections/registry.d.ts.map +1 -0
- package/dist/collections/registry.js +38 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/runtime.d.ts.map +1 -1
- package/dist/config/utils.d.ts +0 -10
- package/dist/config/utils.d.ts.map +1 -1
- package/dist/config/utils.js +0 -13
- package/dist/database/index.d.ts +3 -0
- package/dist/database/index.d.ts.map +1 -1
- package/dist/database/index.js +1 -5
- package/dist/database/safe-parse.d.ts.map +1 -1
- package/dist/database/ssl-config.d.ts.map +1 -1
- package/dist/database/type-adapter.d.ts.map +1 -1
- package/dist/database/universal-postgres.d.ts.map +1 -1
- package/dist/database/universal-postgres.js +6 -1
- package/dist/dataloader.d.ts.map +1 -1
- package/dist/error-handling/error-boundary.d.ts.map +1 -1
- package/dist/error-handling/error-reporter.d.ts +1 -1
- package/dist/error-handling/error-reporter.d.ts.map +1 -1
- package/dist/error-handling/error-reporter.js +19 -5
- package/dist/error-handling/fallback-components.d.ts.map +1 -1
- package/dist/error-handling/fallback-components.js +1 -1
- package/dist/error-handling/index.d.ts +2 -4
- package/dist/error-handling/index.d.ts.map +1 -1
- package/dist/error-handling/index.js +1 -4
- package/dist/factories/builders.d.ts.map +1 -1
- package/dist/factories/index.d.ts.map +1 -1
- package/dist/features.d.ts +7 -7
- package/dist/features.d.ts.map +1 -1
- package/dist/features.js +2 -2
- package/dist/fieldTraversal.d.ts.map +1 -1
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/getDefaultValue.d.ts.map +1 -1
- package/dist/fields/getFieldPaths.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
- package/dist/generated/types/cms.d.ts.map +1 -1
- package/dist/generated/types/cms.js +0 -1
- package/dist/generated/types/neon.d.ts.map +1 -1
- package/dist/generated/types/neon.js +4 -2
- package/dist/globals/GlobalOperations.d.ts.map +1 -1
- package/dist/globals/GlobalOperations.js +16 -4
- package/dist/globals/index.d.ts.map +1 -1
- package/dist/index.d.ts +15 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -5
- package/dist/instance/RevealUIInstance.d.ts.map +1 -1
- package/dist/instance/RevealUIInstance.js +6 -19
- package/dist/instance/index.d.ts.map +1 -1
- package/dist/instance/logger.d.ts.map +1 -1
- package/dist/instance/methods/create.d.ts.map +1 -1
- package/dist/instance/methods/create.js +0 -3
- package/dist/instance/methods/delete.d.ts.map +1 -1
- package/dist/instance/methods/delete.js +1 -4
- package/dist/instance/methods/find.d.ts.map +1 -1
- package/dist/instance/methods/find.js +0 -3
- package/dist/instance/methods/findById.d.ts.map +1 -1
- package/dist/instance/methods/findById.js +0 -3
- package/dist/instance/methods/hooks.d.ts.map +1 -1
- package/dist/instance/methods/update.d.ts.map +1 -1
- package/dist/instance/methods/update.js +0 -3
- package/dist/jobs/index.d.ts +16 -0
- package/dist/jobs/index.d.ts.map +1 -0
- package/dist/jobs/index.js +14 -0
- package/dist/jobs/queue.d.ts +57 -0
- package/dist/jobs/queue.d.ts.map +1 -0
- package/dist/jobs/queue.js +134 -0
- package/dist/license-encryption.d.ts +21 -0
- package/dist/license-encryption.d.ts.map +1 -0
- package/dist/license-encryption.js +74 -0
- package/dist/license.d.ts +26 -3
- package/dist/license.d.ts.map +1 -1
- package/dist/license.js +87 -7
- package/dist/monitoring/alerts.d.ts +4 -4
- package/dist/monitoring/alerts.d.ts.map +1 -1
- package/dist/monitoring/cleanup-manager.d.ts.map +1 -1
- package/dist/monitoring/health-monitor.d.ts.map +1 -1
- package/dist/monitoring/index.d.ts.map +1 -1
- package/dist/monitoring/process-registry.d.ts.map +1 -1
- package/dist/monitoring/query-monitor.d.ts.map +1 -1
- package/dist/monitoring/types.d.ts.map +1 -1
- package/dist/monitoring/zombie-detector.d.ts.map +1 -1
- package/dist/monitoring/zombie-detector.js +5 -0
- package/dist/nextjs/index.d.ts.map +1 -1
- package/dist/nextjs/utilities.d.ts.map +1 -1
- package/dist/nextjs/withRevealUI.d.ts.map +1 -1
- package/dist/observability/alerts.d.ts.map +1 -1
- package/dist/observability/alerts.js +1 -2
- package/dist/observability/health-check.d.ts +0 -4
- package/dist/observability/health-check.d.ts.map +1 -1
- package/dist/observability/health-check.js +0 -36
- package/dist/observability/index.d.ts.map +1 -1
- package/dist/observability/logger.d.ts.map +1 -1
- package/dist/observability/logger.js +1 -1
- package/dist/observability/metrics.d.ts.map +1 -1
- package/dist/observability/tracing.d.ts.map +1 -1
- package/dist/observability/tracing.js +0 -1
- package/dist/plugins/form-builder.d.ts.map +1 -1
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/nested-docs.d.ts +4 -0
- package/dist/plugins/nested-docs.d.ts.map +1 -1
- package/dist/plugins/nested-docs.js +50 -6
- package/dist/plugins/redirects.d.ts.map +1 -1
- package/dist/queries/index.d.ts.map +1 -1
- package/dist/queries/queryBuilder.d.ts.map +1 -1
- package/dist/queries/queryBuilder.js +13 -5
- package/dist/relationships/analyzer.d.ts.map +1 -1
- package/dist/relationships/analyzer.js +8 -0
- package/dist/relationships/index.d.ts.map +1 -1
- package/dist/relationships/populate-core.d.ts +57 -0
- package/dist/relationships/populate-core.d.ts.map +1 -0
- package/dist/relationships/populate-core.js +116 -0
- package/dist/relationships/populate-helpers.d.ts +5 -51
- package/dist/relationships/populate-helpers.d.ts.map +1 -1
- package/dist/relationships/populate-helpers.js +4 -109
- package/dist/relationships/population.d.ts +1 -9
- package/dist/relationships/population.d.ts.map +1 -1
- package/dist/relationships/population.js +8 -3
- package/dist/revealui.d.ts.map +1 -1
- package/dist/richtext/exports/client/rcc.d.ts.map +1 -1
- package/dist/richtext/exports/client/rcc.js +1 -1
- package/dist/richtext/exports/server/rsc.d.ts +17 -0
- package/dist/richtext/exports/server/rsc.d.ts.map +1 -1
- package/dist/richtext/exports/server/rsc.js +61 -5
- package/dist/richtext/index.d.ts.map +1 -1
- package/dist/richtext/lexical.d.ts.map +1 -1
- package/dist/security/index.d.ts +3 -16
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +3 -16
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/renderPage.d.ts.map +1 -1
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +2 -4
- package/dist/storage/vercel-blob.d.ts.map +1 -1
- package/dist/storage/vercel-blob.js +3 -0
- package/dist/translations/index.d.ts.map +1 -1
- package/dist/types/access.d.ts.map +1 -1
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/cms.d.ts.map +1 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/core.d.ts +1 -1
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/extensions.d.ts.map +1 -1
- package/dist/types/frontend.d.ts.map +1 -1
- package/dist/types/generated.d.ts.map +1 -1
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interfaces/app.d.ts.map +1 -1
- package/dist/types/jobs.d.ts.map +1 -1
- package/dist/types/legacy.d.ts.map +1 -1
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/query.d.ts.map +1 -1
- package/dist/types/request.d.ts.map +1 -1
- package/dist/types/richtext.d.ts.map +1 -1
- package/dist/types/runtime.d.ts +60 -1
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/types/schema.d.ts.map +1 -1
- package/dist/types/user.d.ts.map +1 -1
- package/dist/utils/access-conversion.d.ts.map +1 -1
- package/dist/utils/api-wrapper.d.ts.map +1 -1
- package/dist/utils/api-wrapper.js +1 -1
- package/dist/utils/block-conversion.d.ts.map +1 -1
- package/dist/utils/cache.d.ts.map +1 -1
- package/dist/utils/deep-clone.js +0 -1
- package/dist/utils/error-responses.d.ts.map +1 -1
- package/dist/utils/error-responses.js +2 -3
- package/dist/utils/errors.d.ts +36 -0
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +103 -0
- package/dist/utils/field-conversion.d.ts +1 -1
- package/dist/utils/field-conversion.d.ts.map +1 -1
- package/dist/utils/flattenResult.d.ts.map +1 -1
- package/dist/utils/flattenResult.js +0 -1
- package/dist/utils/getBlockSelect.d.ts.map +1 -1
- package/dist/utils/getSelectMode.d.ts.map +1 -1
- package/dist/utils/isValidID.d.ts.map +1 -1
- package/dist/utils/json-parsing.d.ts.map +1 -1
- package/dist/utils/logger-client.d.ts.map +1 -1
- package/dist/utils/logger-server.d.ts.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/request-context.d.ts.map +1 -1
- package/dist/utils/stripUnselectedFields.d.ts.map +1 -1
- package/dist/utils/type-guards.d.ts.map +1 -1
- package/package.json +58 -26
- package/dist/caching/app-cache.d.ts +0 -237
- package/dist/caching/app-cache.d.ts.map +0 -1
- package/dist/caching/app-cache.js +0 -430
- package/dist/caching/cdn-config.d.ts +0 -155
- package/dist/caching/cdn-config.d.ts.map +0 -1
- package/dist/caching/cdn-config.js +0 -411
- package/dist/caching/edge-cache.d.ts +0 -177
- package/dist/caching/edge-cache.d.ts.map +0 -1
- package/dist/caching/edge-cache.js +0 -385
- package/dist/caching/service-worker.d.ts +0 -154
- package/dist/caching/service-worker.d.ts.map +0 -1
- package/dist/caching/service-worker.js +0 -437
- package/dist/client/admin/utils/auth.d.ts +0 -23
- package/dist/client/admin/utils/auth.d.ts.map +0 -1
- package/dist/client/admin/utils/auth.js +0 -52
- package/dist/client/http/client.d.ts +0 -15
- package/dist/client/http/client.d.ts.map +0 -1
- package/dist/client/http/client.js +0 -49
- package/dist/client/http/fetchBanner.d.ts +0 -18
- package/dist/client/http/fetchBanner.d.ts.map +0 -1
- package/dist/client/http/fetchBanner.js +0 -44
- package/dist/client/http/fetchCard.d.ts +0 -18
- package/dist/client/http/fetchCard.d.ts.map +0 -1
- package/dist/client/http/fetchCard.js +0 -46
- package/dist/client/http/fetchEvents.d.ts +0 -18
- package/dist/client/http/fetchEvents.d.ts.map +0 -1
- package/dist/client/http/fetchEvents.js +0 -44
- package/dist/client/http/fetchHero.d.ts +0 -17
- package/dist/client/http/fetchHero.d.ts.map +0 -1
- package/dist/client/http/fetchHero.js +0 -55
- package/dist/client/http/fetchMainInfos.d.ts +0 -17
- package/dist/client/http/fetchMainInfos.d.ts.map +0 -1
- package/dist/client/http/fetchMainInfos.js +0 -44
- package/dist/client/http/fetchVideos.d.ts +0 -13
- package/dist/client/http/fetchVideos.d.ts.map +0 -1
- package/dist/client/http/fetchVideos.js +0 -36
- package/dist/client/http/index.d.ts +0 -19
- package/dist/client/http/index.d.ts.map +0 -1
- package/dist/client/http/index.js +0 -11
- package/dist/error-handling/circuit-breaker.d.ts +0 -262
- package/dist/error-handling/circuit-breaker.d.ts.map +0 -1
- package/dist/error-handling/circuit-breaker.js +0 -542
- package/dist/error-handling/retry.d.ts +0 -194
- package/dist/error-handling/retry.d.ts.map +0 -1
- package/dist/error-handling/retry.js +0 -450
- package/dist/errors/index.d.ts +0 -23
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js +0 -40
- package/dist/generated/agents/index.d.ts +0 -8
- package/dist/generated/agents/index.d.ts.map +0 -1
- package/dist/generated/agents/index.js +0 -7
- package/dist/generated/components/index.d.ts +0 -8
- package/dist/generated/components/index.d.ts.map +0 -1
- package/dist/generated/components/index.js +0 -7
- package/dist/generated/functions/index.d.ts +0 -8
- package/dist/generated/functions/index.d.ts.map +0 -1
- package/dist/generated/functions/index.js +0 -7
- package/dist/generated/hooks/index.d.ts +0 -8
- package/dist/generated/hooks/index.d.ts.map +0 -1
- package/dist/generated/hooks/index.js +0 -7
- package/dist/generated/plans/index.d.ts +0 -8
- package/dist/generated/plans/index.d.ts.map +0 -1
- package/dist/generated/plans/index.js +0 -7
- package/dist/generated/prompts/index.d.ts +0 -8
- package/dist/generated/prompts/index.d.ts.map +0 -1
- package/dist/generated/prompts/index.js +0 -7
- package/dist/generated/tools/index.d.ts +0 -8
- package/dist/generated/tools/index.d.ts.map +0 -1
- package/dist/generated/tools/index.js +0 -7
- package/dist/generated/types/supabase.d.ts +0 -193
- package/dist/generated/types/supabase.d.ts.map +0 -1
- package/dist/generated/types/supabase.js +0 -5
- package/dist/optimization/asset-optimizer.d.ts +0 -202
- package/dist/optimization/asset-optimizer.d.ts.map +0 -1
- package/dist/optimization/asset-optimizer.js +0 -312
- package/dist/optimization/build-optimizer.d.ts +0 -202
- package/dist/optimization/build-optimizer.d.ts.map +0 -1
- package/dist/optimization/build-optimizer.js +0 -271
- package/dist/optimization/bundle-analyzer.d.ts +0 -98
- package/dist/optimization/bundle-analyzer.d.ts.map +0 -1
- package/dist/optimization/bundle-analyzer.js +0 -322
- package/dist/optimization/code-splitting.d.ts +0 -131
- package/dist/optimization/code-splitting.d.ts.map +0 -1
- package/dist/optimization/code-splitting.js +0 -277
- package/dist/plugin/index.d.ts +0 -12
- package/dist/plugin/index.d.ts.map +0 -1
- package/dist/plugin/index.js +0 -4
- package/dist/security/audit.d.ts +0 -188
- package/dist/security/audit.d.ts.map +0 -1
- package/dist/security/audit.js +0 -431
- package/dist/security/auth.d.ts +0 -241
- package/dist/security/auth.d.ts.map +0 -1
- package/dist/security/auth.js +0 -476
- package/dist/security/authorization.d.ts +0 -235
- package/dist/security/authorization.d.ts.map +0 -1
- package/dist/security/authorization.js +0 -434
- package/dist/security/encryption.d.ts +0 -214
- package/dist/security/encryption.d.ts.map +0 -1
- package/dist/security/encryption.js +0 -517
- package/dist/security/gdpr.d.ts +0 -300
- package/dist/security/gdpr.d.ts.map +0 -1
- package/dist/security/gdpr.js +0 -465
- package/dist/security/headers.d.ts +0 -182
- package/dist/security/headers.d.ts.map +0 -1
- package/dist/security/headers.js +0 -402
- package/dist/utils/jwt-validation.d.ts +0 -14
- package/dist/utils/jwt-validation.d.ts.map +0 -1
- package/dist/utils/jwt-validation.js +0 -36
- package/dist/utils/request-headers.d.ts +0 -15
- package/dist/utils/request-headers.d.ts.map +0 -1
- package/dist/utils/request-headers.js +0 -31
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Service Worker Utilities
|
|
3
|
-
*
|
|
4
|
-
* Utilities for service worker registration, caching strategies, and offline support
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Service Worker Configuration
|
|
8
|
-
*/
|
|
9
|
-
export interface ServiceWorkerConfig {
|
|
10
|
-
scope?: string;
|
|
11
|
-
updateViaCache?: 'all' | 'imports' | 'none';
|
|
12
|
-
scriptURL?: string;
|
|
13
|
-
}
|
|
14
|
-
export declare const DEFAULT_SW_CONFIG: ServiceWorkerConfig;
|
|
15
|
-
/**
|
|
16
|
-
* Register service worker
|
|
17
|
-
*/
|
|
18
|
-
export declare function registerServiceWorker(config?: ServiceWorkerConfig): Promise<ServiceWorkerRegistration | null>;
|
|
19
|
-
/**
|
|
20
|
-
* Unregister service worker
|
|
21
|
-
*/
|
|
22
|
-
export declare function unregisterServiceWorker(): Promise<boolean>;
|
|
23
|
-
/**
|
|
24
|
-
* Update service worker
|
|
25
|
-
*/
|
|
26
|
-
export declare function updateServiceWorker(): Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* Skip waiting and activate new service worker
|
|
29
|
-
*/
|
|
30
|
-
export declare function skipWaitingAndActivate(): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Cache Strategies
|
|
33
|
-
*/
|
|
34
|
-
export declare const CACHE_STRATEGIES: {
|
|
35
|
-
readonly networkFirst: "network-first";
|
|
36
|
-
readonly cacheFirst: "cache-first";
|
|
37
|
-
readonly networkOnly: "network-only";
|
|
38
|
-
readonly cacheOnly: "cache-only";
|
|
39
|
-
readonly staleWhileRevalidate: "stale-while-revalidate";
|
|
40
|
-
};
|
|
41
|
-
export type CacheStrategy = (typeof CACHE_STRATEGIES)[keyof typeof CACHE_STRATEGIES];
|
|
42
|
-
/**
|
|
43
|
-
* Cache Configuration
|
|
44
|
-
*/
|
|
45
|
-
export interface CacheConfig {
|
|
46
|
-
name: string;
|
|
47
|
-
version: number;
|
|
48
|
-
maxAge?: number;
|
|
49
|
-
maxEntries?: number;
|
|
50
|
-
strategy?: CacheStrategy;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Default cache configurations
|
|
54
|
-
*/
|
|
55
|
-
export declare const DEFAULT_CACHES: Record<string, CacheConfig>;
|
|
56
|
-
/**
|
|
57
|
-
* Generate cache name
|
|
58
|
-
*/
|
|
59
|
-
export declare function generateCacheName(config: CacheConfig): string;
|
|
60
|
-
/**
|
|
61
|
-
* Service worker message types
|
|
62
|
-
*/
|
|
63
|
-
export declare const SW_MESSAGES: {
|
|
64
|
-
readonly SKIP_WAITING: "SKIP_WAITING";
|
|
65
|
-
readonly CLAIM_CLIENTS: "CLAIM_CLIENTS";
|
|
66
|
-
readonly CLEAR_CACHE: "CLEAR_CACHE";
|
|
67
|
-
readonly CACHE_URLS: "CACHE_URLS";
|
|
68
|
-
readonly DELETE_CACHE: "DELETE_CACHE";
|
|
69
|
-
readonly GET_CACHE_SIZE: "GET_CACHE_SIZE";
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Post message to service worker
|
|
73
|
-
*/
|
|
74
|
-
export declare function postMessageToSW(type: string, payload?: unknown): Promise<unknown>;
|
|
75
|
-
/**
|
|
76
|
-
* Clear all caches
|
|
77
|
-
*/
|
|
78
|
-
export declare function clearAllCaches(): Promise<void>;
|
|
79
|
-
/**
|
|
80
|
-
* Clear specific cache
|
|
81
|
-
*/
|
|
82
|
-
export declare function clearCache(cacheName: string): Promise<void>;
|
|
83
|
-
/**
|
|
84
|
-
* Precache URLs
|
|
85
|
-
*/
|
|
86
|
-
export declare function precacheURLs(urls: string[]): Promise<void>;
|
|
87
|
-
/**
|
|
88
|
-
* Get cache size
|
|
89
|
-
*/
|
|
90
|
-
export declare function getCacheSize(): Promise<{
|
|
91
|
-
quota: number;
|
|
92
|
-
usage: number;
|
|
93
|
-
available: number;
|
|
94
|
-
}>;
|
|
95
|
-
/**
|
|
96
|
-
* Check if service worker is supported
|
|
97
|
-
*/
|
|
98
|
-
export declare function isServiceWorkerSupported(): boolean;
|
|
99
|
-
/**
|
|
100
|
-
* Check if service worker is registered
|
|
101
|
-
*/
|
|
102
|
-
export declare function isServiceWorkerRegistered(): Promise<boolean>;
|
|
103
|
-
/**
|
|
104
|
-
* Get service worker state
|
|
105
|
-
*/
|
|
106
|
-
export declare function getServiceWorkerState(): Promise<{
|
|
107
|
-
registered: boolean;
|
|
108
|
-
installing: boolean;
|
|
109
|
-
waiting: boolean;
|
|
110
|
-
active: boolean;
|
|
111
|
-
controller: boolean;
|
|
112
|
-
}>;
|
|
113
|
-
export interface ServiceWorkerHook {
|
|
114
|
-
register: () => Promise<ServiceWorkerRegistration | null>;
|
|
115
|
-
unregister: () => Promise<boolean>;
|
|
116
|
-
update: () => Promise<void>;
|
|
117
|
-
skipWaitingAndActivate: () => Promise<void>;
|
|
118
|
-
state: Promise<{
|
|
119
|
-
registered: boolean;
|
|
120
|
-
installing: boolean;
|
|
121
|
-
waiting: boolean;
|
|
122
|
-
active: boolean;
|
|
123
|
-
controller: boolean;
|
|
124
|
-
}>;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* React hook for service worker
|
|
128
|
-
*/
|
|
129
|
-
export declare function useServiceWorker(config?: ServiceWorkerConfig): ServiceWorkerHook;
|
|
130
|
-
/**
|
|
131
|
-
* Offline detection
|
|
132
|
-
*/
|
|
133
|
-
export declare function isOffline(): boolean;
|
|
134
|
-
/**
|
|
135
|
-
* Listen for online/offline events
|
|
136
|
-
*/
|
|
137
|
-
export declare function onNetworkChange(callback: (online: boolean) => void): () => void;
|
|
138
|
-
/**
|
|
139
|
-
* Background sync registration
|
|
140
|
-
*/
|
|
141
|
-
export declare function registerBackgroundSync(tag: string): Promise<void>;
|
|
142
|
-
/**
|
|
143
|
-
* Push notification permission
|
|
144
|
-
*/
|
|
145
|
-
export declare function requestNotificationPermission(): Promise<NotificationPermission>;
|
|
146
|
-
/**
|
|
147
|
-
* Subscribe to push notifications
|
|
148
|
-
*/
|
|
149
|
-
export declare function subscribeToPush(vapidPublicKey: string): Promise<PushSubscription | null>;
|
|
150
|
-
/**
|
|
151
|
-
* Unsubscribe from push notifications
|
|
152
|
-
*/
|
|
153
|
-
export declare function unsubscribeFromPush(): Promise<boolean>;
|
|
154
|
-
//# sourceMappingURL=service-worker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service-worker.d.ts","sourceRoot":"","sources":["../../src/caching/service-worker.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Service Worker Utilities
|
|
3
|
-
*
|
|
4
|
-
* Utilities for service worker registration, caching strategies, and offline support
|
|
5
|
-
*/
|
|
6
|
-
import { logger } from '../observability/logger.js';
|
|
7
|
-
export const DEFAULT_SW_CONFIG = {
|
|
8
|
-
scope: '/',
|
|
9
|
-
updateViaCache: 'none',
|
|
10
|
-
scriptURL: '/sw.js',
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Register service worker
|
|
14
|
-
*/
|
|
15
|
-
export async function registerServiceWorker(config = DEFAULT_SW_CONFIG) {
|
|
16
|
-
if (typeof window === 'undefined' || !('serviceWorker' in navigator)) {
|
|
17
|
-
logger.warn('Service workers are not supported');
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
const { scriptURL = '/sw.js', scope, updateViaCache } = config;
|
|
22
|
-
const registration = await navigator.serviceWorker.register(scriptURL, {
|
|
23
|
-
scope,
|
|
24
|
-
updateViaCache,
|
|
25
|
-
});
|
|
26
|
-
logger.info('Service worker registered', { scope: registration.scope });
|
|
27
|
-
// Check for updates
|
|
28
|
-
registration.addEventListener('updatefound', () => {
|
|
29
|
-
const newWorker = registration.installing;
|
|
30
|
-
if (newWorker) {
|
|
31
|
-
newWorker.addEventListener('statechange', () => {
|
|
32
|
-
if (newWorker.state === 'installed' && navigator.serviceWorker.controller) {
|
|
33
|
-
// New service worker available
|
|
34
|
-
logger.info('New service worker available');
|
|
35
|
-
// Trigger update notification
|
|
36
|
-
window.dispatchEvent(new CustomEvent('sw-update-available', {
|
|
37
|
-
detail: { registration },
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
return registration;
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
logger.error('Service worker registration failed', error instanceof Error ? error : new Error(String(error)));
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Unregister service worker
|
|
52
|
-
*/
|
|
53
|
-
export async function unregisterServiceWorker() {
|
|
54
|
-
if (typeof window === 'undefined' || !('serviceWorker' in navigator)) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
try {
|
|
58
|
-
const registration = await navigator.serviceWorker.ready;
|
|
59
|
-
return registration.unregister();
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
logger.error('Service worker unregistration failed', error instanceof Error ? error : new Error(String(error)));
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Update service worker
|
|
68
|
-
*/
|
|
69
|
-
export async function updateServiceWorker() {
|
|
70
|
-
if (typeof window === 'undefined' || !('serviceWorker' in navigator)) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
try {
|
|
74
|
-
const registration = await navigator.serviceWorker.ready;
|
|
75
|
-
await registration.update();
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
logger.error('Service worker update failed', error instanceof Error ? error : new Error(String(error)));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Skip waiting and activate new service worker
|
|
83
|
-
*/
|
|
84
|
-
export async function skipWaitingAndActivate() {
|
|
85
|
-
if (typeof window === 'undefined' || !('serviceWorker' in navigator)) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const registration = await navigator.serviceWorker.ready;
|
|
89
|
-
const waiting = registration.waiting;
|
|
90
|
-
if (waiting) {
|
|
91
|
-
// Tell service worker to skip waiting
|
|
92
|
-
waiting.postMessage({ type: 'SKIP_WAITING' });
|
|
93
|
-
// Reload when new service worker takes control
|
|
94
|
-
navigator.serviceWorker.addEventListener('controllerchange', () => {
|
|
95
|
-
window.location.reload();
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Cache Strategies
|
|
101
|
-
*/
|
|
102
|
-
export const CACHE_STRATEGIES = {
|
|
103
|
-
// Network first, fallback to cache
|
|
104
|
-
networkFirst: 'network-first',
|
|
105
|
-
// Cache first, fallback to network
|
|
106
|
-
cacheFirst: 'cache-first',
|
|
107
|
-
// Network only
|
|
108
|
-
networkOnly: 'network-only',
|
|
109
|
-
// Cache only
|
|
110
|
-
cacheOnly: 'cache-only',
|
|
111
|
-
// Stale while revalidate
|
|
112
|
-
staleWhileRevalidate: 'stale-while-revalidate',
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Default cache configurations
|
|
116
|
-
*/
|
|
117
|
-
export const DEFAULT_CACHES = {
|
|
118
|
-
static: {
|
|
119
|
-
name: 'static-assets',
|
|
120
|
-
version: 1,
|
|
121
|
-
maxAge: 31536000, // 1 year
|
|
122
|
-
maxEntries: 100,
|
|
123
|
-
strategy: CACHE_STRATEGIES.cacheFirst,
|
|
124
|
-
},
|
|
125
|
-
images: {
|
|
126
|
-
name: 'images',
|
|
127
|
-
version: 1,
|
|
128
|
-
maxAge: 2592000, // 30 days
|
|
129
|
-
maxEntries: 50,
|
|
130
|
-
strategy: CACHE_STRATEGIES.cacheFirst,
|
|
131
|
-
},
|
|
132
|
-
api: {
|
|
133
|
-
name: 'api',
|
|
134
|
-
version: 1,
|
|
135
|
-
maxAge: 300, // 5 minutes
|
|
136
|
-
maxEntries: 50,
|
|
137
|
-
strategy: CACHE_STRATEGIES.networkFirst,
|
|
138
|
-
},
|
|
139
|
-
pages: {
|
|
140
|
-
name: 'pages',
|
|
141
|
-
version: 1,
|
|
142
|
-
maxAge: 3600, // 1 hour
|
|
143
|
-
maxEntries: 20,
|
|
144
|
-
strategy: CACHE_STRATEGIES.staleWhileRevalidate,
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* Generate cache name
|
|
149
|
-
*/
|
|
150
|
-
export function generateCacheName(config) {
|
|
151
|
-
return `${config.name}-v${config.version}`;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Service worker message types
|
|
155
|
-
*/
|
|
156
|
-
export const SW_MESSAGES = {
|
|
157
|
-
SKIP_WAITING: 'SKIP_WAITING',
|
|
158
|
-
CLAIM_CLIENTS: 'CLAIM_CLIENTS',
|
|
159
|
-
CLEAR_CACHE: 'CLEAR_CACHE',
|
|
160
|
-
CACHE_URLS: 'CACHE_URLS',
|
|
161
|
-
DELETE_CACHE: 'DELETE_CACHE',
|
|
162
|
-
GET_CACHE_SIZE: 'GET_CACHE_SIZE',
|
|
163
|
-
};
|
|
164
|
-
/**
|
|
165
|
-
* Post message to service worker
|
|
166
|
-
*/
|
|
167
|
-
export async function postMessageToSW(type, payload) {
|
|
168
|
-
if (typeof window === 'undefined' || !('serviceWorker' in navigator)) {
|
|
169
|
-
throw new Error('Service workers not supported');
|
|
170
|
-
}
|
|
171
|
-
const registration = await navigator.serviceWorker.ready;
|
|
172
|
-
const sw = registration.active;
|
|
173
|
-
if (!sw) {
|
|
174
|
-
throw new Error('No active service worker');
|
|
175
|
-
}
|
|
176
|
-
return new Promise((resolve, reject) => {
|
|
177
|
-
const messageChannel = new MessageChannel();
|
|
178
|
-
messageChannel.port1.onmessage = (event) => {
|
|
179
|
-
if (event.data.error) {
|
|
180
|
-
reject(new Error(event.data.error));
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
resolve(event.data);
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
sw.postMessage({ type, payload }, [messageChannel.port2]);
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Clear all caches
|
|
191
|
-
*/
|
|
192
|
-
export async function clearAllCaches() {
|
|
193
|
-
try {
|
|
194
|
-
await postMessageToSW(SW_MESSAGES.CLEAR_CACHE);
|
|
195
|
-
}
|
|
196
|
-
catch (error) {
|
|
197
|
-
logger.error('Failed to clear caches', error instanceof Error ? error : new Error(String(error)));
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Clear specific cache
|
|
202
|
-
*/
|
|
203
|
-
export async function clearCache(cacheName) {
|
|
204
|
-
try {
|
|
205
|
-
await postMessageToSW(SW_MESSAGES.DELETE_CACHE, { cacheName });
|
|
206
|
-
}
|
|
207
|
-
catch (error) {
|
|
208
|
-
logger.error('Failed to clear cache', error instanceof Error ? error : new Error(String(error)), { cacheName });
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Precache URLs
|
|
213
|
-
*/
|
|
214
|
-
export async function precacheURLs(urls) {
|
|
215
|
-
try {
|
|
216
|
-
await postMessageToSW(SW_MESSAGES.CACHE_URLS, { urls });
|
|
217
|
-
}
|
|
218
|
-
catch (error) {
|
|
219
|
-
logger.error('Failed to precache URLs', error instanceof Error ? error : new Error(String(error)));
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Get cache size
|
|
224
|
-
*/
|
|
225
|
-
export async function getCacheSize() {
|
|
226
|
-
if (typeof navigator === 'undefined' || !navigator.storage?.estimate) {
|
|
227
|
-
return { quota: 0, usage: 0, available: 0 };
|
|
228
|
-
}
|
|
229
|
-
try {
|
|
230
|
-
const estimate = await navigator.storage.estimate();
|
|
231
|
-
const quota = estimate.quota || 0;
|
|
232
|
-
const usage = estimate.usage || 0;
|
|
233
|
-
const available = quota - usage;
|
|
234
|
-
return { quota, usage, available };
|
|
235
|
-
}
|
|
236
|
-
catch (error) {
|
|
237
|
-
logger.error('Failed to get cache size', error instanceof Error ? error : new Error(String(error)));
|
|
238
|
-
return { quota: 0, usage: 0, available: 0 };
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Check if service worker is supported
|
|
243
|
-
*/
|
|
244
|
-
export function isServiceWorkerSupported() {
|
|
245
|
-
return typeof window !== 'undefined' && 'serviceWorker' in navigator;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Check if service worker is registered
|
|
249
|
-
*/
|
|
250
|
-
export async function isServiceWorkerRegistered() {
|
|
251
|
-
if (!isServiceWorkerSupported()) {
|
|
252
|
-
return false;
|
|
253
|
-
}
|
|
254
|
-
try {
|
|
255
|
-
const registration = await navigator.serviceWorker.getRegistration();
|
|
256
|
-
return registration !== undefined;
|
|
257
|
-
}
|
|
258
|
-
catch {
|
|
259
|
-
return false;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Get service worker state
|
|
264
|
-
*/
|
|
265
|
-
export async function getServiceWorkerState() {
|
|
266
|
-
if (!isServiceWorkerSupported()) {
|
|
267
|
-
return {
|
|
268
|
-
registered: false,
|
|
269
|
-
installing: false,
|
|
270
|
-
waiting: false,
|
|
271
|
-
active: false,
|
|
272
|
-
controller: false,
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
try {
|
|
276
|
-
const registration = await navigator.serviceWorker.getRegistration();
|
|
277
|
-
if (!registration) {
|
|
278
|
-
return {
|
|
279
|
-
registered: false,
|
|
280
|
-
installing: false,
|
|
281
|
-
waiting: false,
|
|
282
|
-
active: false,
|
|
283
|
-
controller: false,
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
return {
|
|
287
|
-
registered: true,
|
|
288
|
-
installing: registration.installing !== null,
|
|
289
|
-
waiting: registration.waiting !== null,
|
|
290
|
-
active: registration.active !== null,
|
|
291
|
-
controller: navigator.serviceWorker.controller !== null,
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
catch {
|
|
295
|
-
return {
|
|
296
|
-
registered: false,
|
|
297
|
-
installing: false,
|
|
298
|
-
waiting: false,
|
|
299
|
-
active: false,
|
|
300
|
-
controller: false,
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* React hook for service worker
|
|
306
|
-
*/
|
|
307
|
-
export function useServiceWorker(config) {
|
|
308
|
-
if (typeof window === 'undefined') {
|
|
309
|
-
return {
|
|
310
|
-
register: async () => null,
|
|
311
|
-
unregister: async () => false,
|
|
312
|
-
update: async () => { },
|
|
313
|
-
skipWaitingAndActivate: async () => { },
|
|
314
|
-
state: Promise.resolve({
|
|
315
|
-
registered: false,
|
|
316
|
-
installing: false,
|
|
317
|
-
waiting: false,
|
|
318
|
-
active: false,
|
|
319
|
-
controller: false,
|
|
320
|
-
}),
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
|
-
return {
|
|
324
|
-
register: () => registerServiceWorker(config),
|
|
325
|
-
unregister: unregisterServiceWorker,
|
|
326
|
-
update: updateServiceWorker,
|
|
327
|
-
skipWaitingAndActivate,
|
|
328
|
-
state: getServiceWorkerState(),
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Offline detection
|
|
333
|
-
*/
|
|
334
|
-
export function isOffline() {
|
|
335
|
-
return typeof navigator !== 'undefined' && !navigator.onLine;
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Listen for online/offline events
|
|
339
|
-
*/
|
|
340
|
-
export function onNetworkChange(callback) {
|
|
341
|
-
if (typeof window === 'undefined') {
|
|
342
|
-
return () => { };
|
|
343
|
-
}
|
|
344
|
-
const handleOnline = () => callback(true);
|
|
345
|
-
const handleOffline = () => callback(false);
|
|
346
|
-
window.addEventListener('online', handleOnline);
|
|
347
|
-
window.addEventListener('offline', handleOffline);
|
|
348
|
-
return () => {
|
|
349
|
-
window.removeEventListener('online', handleOnline);
|
|
350
|
-
window.removeEventListener('offline', handleOffline);
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Background sync registration
|
|
355
|
-
*/
|
|
356
|
-
export async function registerBackgroundSync(tag) {
|
|
357
|
-
if (!isServiceWorkerSupported()) {
|
|
358
|
-
throw new Error('Service workers not supported');
|
|
359
|
-
}
|
|
360
|
-
const registration = await navigator.serviceWorker.ready;
|
|
361
|
-
if (!('sync' in registration)) {
|
|
362
|
-
throw new Error('Background sync not supported');
|
|
363
|
-
}
|
|
364
|
-
try {
|
|
365
|
-
// @ts-expect-error - sync API not in types yet
|
|
366
|
-
await registration.sync.register(tag);
|
|
367
|
-
}
|
|
368
|
-
catch (error) {
|
|
369
|
-
logger.error('Background sync registration failed', error instanceof Error ? error : new Error(String(error)));
|
|
370
|
-
throw error;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Push notification permission
|
|
375
|
-
*/
|
|
376
|
-
export async function requestNotificationPermission() {
|
|
377
|
-
if (typeof window === 'undefined' || !('Notification' in window)) {
|
|
378
|
-
throw new Error('Notifications not supported');
|
|
379
|
-
}
|
|
380
|
-
return Notification.requestPermission();
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* Subscribe to push notifications
|
|
384
|
-
*/
|
|
385
|
-
export async function subscribeToPush(vapidPublicKey) {
|
|
386
|
-
if (!isServiceWorkerSupported()) {
|
|
387
|
-
throw new Error('Service workers not supported');
|
|
388
|
-
}
|
|
389
|
-
const registration = await navigator.serviceWorker.ready;
|
|
390
|
-
if (!('pushManager' in registration)) {
|
|
391
|
-
throw new Error('Push notifications not supported');
|
|
392
|
-
}
|
|
393
|
-
try {
|
|
394
|
-
const subscription = await registration.pushManager.subscribe({
|
|
395
|
-
userVisibleOnly: true,
|
|
396
|
-
applicationServerKey: urlBase64ToUint8Array(vapidPublicKey),
|
|
397
|
-
});
|
|
398
|
-
return subscription;
|
|
399
|
-
}
|
|
400
|
-
catch (error) {
|
|
401
|
-
logger.error('Push subscription failed', error instanceof Error ? error : new Error(String(error)));
|
|
402
|
-
return null;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
/**
|
|
406
|
-
* Unsubscribe from push notifications
|
|
407
|
-
*/
|
|
408
|
-
export async function unsubscribeFromPush() {
|
|
409
|
-
if (!isServiceWorkerSupported()) {
|
|
410
|
-
return false;
|
|
411
|
-
}
|
|
412
|
-
try {
|
|
413
|
-
const registration = await navigator.serviceWorker.ready;
|
|
414
|
-
const subscription = await registration.pushManager.getSubscription();
|
|
415
|
-
if (subscription) {
|
|
416
|
-
return subscription.unsubscribe();
|
|
417
|
-
}
|
|
418
|
-
return false;
|
|
419
|
-
}
|
|
420
|
-
catch (error) {
|
|
421
|
-
logger.error('Push unsubscription failed', error instanceof Error ? error : new Error(String(error)));
|
|
422
|
-
return false;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Convert VAPID key
|
|
427
|
-
*/
|
|
428
|
-
function urlBase64ToUint8Array(base64String) {
|
|
429
|
-
const padding = '='.repeat((4 - (base64String.length % 4)) % 4);
|
|
430
|
-
const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/');
|
|
431
|
-
const rawData = window.atob(base64);
|
|
432
|
-
const outputArray = new Uint8Array(rawData.length);
|
|
433
|
-
for (let i = 0; i < rawData.length; ++i) {
|
|
434
|
-
outputArray[i] = rawData.charCodeAt(i);
|
|
435
|
-
}
|
|
436
|
-
return outputArray;
|
|
437
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authentication utilities for admin dashboard
|
|
3
|
-
* Handles JWT token retrieval and management
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Get JWT token from cookies or localStorage
|
|
7
|
-
* Priority: cookies > localStorage
|
|
8
|
-
*/
|
|
9
|
-
export declare function getAuthToken(): string | null;
|
|
10
|
-
/**
|
|
11
|
-
* Set JWT token in localStorage
|
|
12
|
-
* Note: Cookies are set server-side, this is for client-side fallback
|
|
13
|
-
*/
|
|
14
|
-
export declare function setAuthToken(token: string): void;
|
|
15
|
-
/**
|
|
16
|
-
* Remove JWT token from storage
|
|
17
|
-
*/
|
|
18
|
-
export declare function clearAuthToken(): void;
|
|
19
|
-
/**
|
|
20
|
-
* Get Authorization header value
|
|
21
|
-
*/
|
|
22
|
-
export declare function getAuthHeader(): string | null;
|
|
23
|
-
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/client/admin/utils/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,IAAI,CAoB5C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAIhD;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAKrC;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,GAAG,IAAI,CAG7C"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authentication utilities for admin dashboard
|
|
3
|
-
* Handles JWT token retrieval and management
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Get JWT token from cookies or localStorage
|
|
7
|
-
* Priority: cookies > localStorage
|
|
8
|
-
*/
|
|
9
|
-
export function getAuthToken() {
|
|
10
|
-
// Try to get from cookies first (server-side compatible)
|
|
11
|
-
if (typeof document !== 'undefined') {
|
|
12
|
-
const cookies = document.cookie.split(';');
|
|
13
|
-
const tokenCookie = cookies.find((cookie) => {
|
|
14
|
-
// Defensive check: cookie might be undefined or empty
|
|
15
|
-
if (!cookie || typeof cookie !== 'string') {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
return cookie.trim().startsWith('revealui-token=');
|
|
19
|
-
});
|
|
20
|
-
if (tokenCookie) {
|
|
21
|
-
return tokenCookie.split('=')[1]?.trim() || null;
|
|
22
|
-
}
|
|
23
|
-
// Fallback to localStorage
|
|
24
|
-
return localStorage.getItem('revealui-token');
|
|
25
|
-
}
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Set JWT token in localStorage
|
|
30
|
-
* Note: Cookies are set server-side, this is for client-side fallback
|
|
31
|
-
*/
|
|
32
|
-
export function setAuthToken(token) {
|
|
33
|
-
if (typeof localStorage !== 'undefined') {
|
|
34
|
-
localStorage.setItem('revealui-token', token);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Remove JWT token from storage
|
|
39
|
-
*/
|
|
40
|
-
export function clearAuthToken() {
|
|
41
|
-
if (typeof localStorage !== 'undefined') {
|
|
42
|
-
localStorage.removeItem('revealui-token');
|
|
43
|
-
}
|
|
44
|
-
// Note: Cookie clearing should be done server-side
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Get Authorization header value
|
|
48
|
-
*/
|
|
49
|
-
export function getAuthHeader() {
|
|
50
|
-
const token = getAuthToken();
|
|
51
|
-
return token ? `JWT ${token}` : null;
|
|
52
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base API client for fetching data from RevealUI CMS
|
|
3
|
-
* Uses environment variables to determine CMS URL
|
|
4
|
-
*/
|
|
5
|
-
export interface FetchOptions extends RequestInit {
|
|
6
|
-
params?: Record<string, string | number | boolean>;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Base function to fetch data from CMS API
|
|
10
|
-
* @param endpoint - API endpoint path (e.g., '/api/collections/pages')
|
|
11
|
-
* @param options - Fetch options including query parameters
|
|
12
|
-
* @returns Promise with parsed JSON response
|
|
13
|
-
*/
|
|
14
|
-
export declare function fetchFromCMS<T>(endpoint: string, options?: FetchOptions): Promise<T>;
|
|
15
|
-
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/client/http/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwBH,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;CACnD;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,CAyB1F"}
|