@plitzi/sdk-shared 0.37.2 → 0.37.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1162 -0
- package/dist/actions/access.d.ts +12 -0
- package/dist/actions/access.mjs +13 -0
- package/dist/actions/functions.d.ts +27 -0
- package/dist/actions/functions.mjs +18 -0
- package/dist/actions/index.d.ts +4 -0
- package/dist/actions/index.mjs +9 -7
- package/dist/auth/index.d.ts +2 -1
- package/dist/auth/index.mjs +2 -2
- package/dist/auth/visitorRoles.d.ts +27 -0
- package/dist/auth/visitorRoles.mjs +48 -0
- package/dist/authoring/builder.mjs +1 -0
- package/dist/authoring/declare.d.ts +53 -0
- package/dist/authoring/declare.mjs +2 -2
- package/dist/authoring/index.mjs +5 -5
- package/dist/authoring/paramSpec.d.ts +1 -1
- package/dist/authoring/paramSpec.mjs +1 -0
- package/dist/authoring/spaceCallbacks.mjs +2 -2
- package/dist/dataSource/computed.d.ts +21 -0
- package/dist/dataSource/computed.mjs +45 -0
- package/dist/dataSource/getBindingsDetails.mjs +35 -34
- package/dist/dataSource/index.d.ts +1 -0
- package/dist/dataSource/index.mjs +7 -6
- package/dist/dataSource/utility/not.mjs +4 -7
- package/dist/dataSource/utility/stringToArray.mjs +1 -1
- package/dist/dataSource/utility/truthiness.d.ts +1 -0
- package/dist/dataSource/utility/truthiness.mjs +8 -0
- package/dist/dataSource/utility/twigTemplate.d.ts +2 -1
- package/dist/dataSource/utility/twigTemplate.mjs +29 -17
- package/dist/devTools/utils/PlitziConsole.mjs +22 -22
- package/dist/helpers/cookies.d.ts +10 -0
- package/dist/helpers/cookies.mjs +19 -0
- package/dist/helpers/fetchManifest.d.ts +9 -0
- package/dist/helpers/fetchManifest.mjs +3 -6
- package/dist/helpers/formatDate.d.ts +5 -3
- package/dist/helpers/formatDate.mjs +34 -36
- package/dist/helpers/index.d.ts +2 -1
- package/dist/helpers/index.mjs +17 -14
- package/dist/helpers/isDate.d.ts +7 -0
- package/dist/helpers/isDate.mjs +15 -0
- package/dist/helpers/keys.d.ts +42 -0
- package/dist/helpers/keys.mjs +91 -0
- package/dist/helpers/twigWrapper/AST.d.ts +2 -2
- package/dist/helpers/twigWrapper/Evaluator/Evaluator.d.ts +12 -2
- package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +57 -34
- package/dist/helpers/twigWrapper/Evaluator/index.d.ts +1 -1
- package/dist/helpers/twigWrapper/Evaluator/index.mjs +2 -2
- package/dist/helpers/twigWrapper/Parser/ExpressionParser.d.ts +2 -2
- package/dist/helpers/twigWrapper/Parser/ExpressionParser.mjs +147 -34
- package/dist/helpers/twigWrapper/Parser/Parser.d.ts +2 -1
- package/dist/helpers/twigWrapper/Parser/Parser.mjs +21 -20
- package/dist/helpers/twigWrapper/filters/filters.mjs +130 -112
- package/dist/helpers/twigWrapper/index.d.ts +5 -2
- package/dist/helpers/twigWrapper/index.mjs +7 -5
- package/dist/helpers/twigWrapper/inspectTemplate.d.ts +23 -0
- package/dist/helpers/twigWrapper/inspectTemplate.mjs +110 -0
- package/dist/helpers/twigWrapper/processTwig/helpers.d.ts +7 -0
- package/dist/helpers/twigWrapper/processTwig/helpers.mjs +2 -1
- package/dist/helpers/twigWrapper/processTwig/index.d.ts +2 -1
- package/dist/helpers/twigWrapper/processTwig/index.mjs +3 -2
- package/dist/helpers/twigWrapper/processTwig/processTwig.d.ts +28 -0
- package/dist/helpers/twigWrapper/processTwig/processTwig.mjs +73 -16
- package/dist/helpers/twigWrapper/processTwig/resolveStepParam.d.ts +17 -0
- package/dist/helpers/twigWrapper/processTwig/resolveStepParam.mjs +14 -0
- package/dist/helpers/twigWrapper/templateRoots.d.ts +11 -0
- package/dist/helpers/twigWrapper/templateRoots.mjs +4 -4
- package/dist/helpers/twigWrapper/tokens/hasTemplateSyntax.d.ts +1 -1
- package/dist/history/describe.d.ts +29 -0
- package/dist/history/describe.mjs +93 -0
- package/dist/history/diff.d.ts +33 -0
- package/dist/history/diff.mjs +73 -0
- package/dist/history/index.d.ts +3 -0
- package/dist/history/index.mjs +3 -0
- package/dist/history/types.d.ts +48 -0
- package/dist/history/types.mjs +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +76 -67
- package/dist/navigation/index.d.ts +1 -1
- package/dist/navigation/index.mjs +2 -2
- package/dist/navigation/routes.d.ts +11 -1
- package/dist/navigation/routes.mjs +15 -10
- package/dist/network/graphql/builder/Mutations/Segment/SegmentAddMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/SegmentAddTemplateMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/SegmentPublishMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/SegmentRemoveMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/SegmentUpdateMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentAddElementMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentCloneElementMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentMoveElementMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRemoveElementMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRenameElementMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementsMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceAddVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceRemoveVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceUpdateVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleAddSelectorVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleRemoveSelectorVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleUpdateSelectorVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleAddSelectorMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorsMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleUpdateSelectorMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleAddVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleRemoveVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleUpdateVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddElementMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddPluginMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddTemplateMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceCloneElementMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceDeployMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceFixIssuesMutation.d.ts +14 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceFixIssuesMutation.mjs +16 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceMoveElementMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpacePublishMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceRemoveElementMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceRemovePluginMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceRenameElementMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateElementMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateElementsMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdatePluginMutation.d.ts +4 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdatePluginMutation.mjs +3 -3
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateSchemaMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateSettingsMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceAddActionMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRemoveActionMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRunActionMutation.mjs +2 -1
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceUpdateActionMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceAddCdnMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceRemoveCdnMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceSetCdnCredentialMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/cdns/SpaceUpdateCdnMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/connectors/SpaceAddConnectorMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/connectors/SpaceRemoveConnectorMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/connectors/SpaceUpdateConnectorMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/credentials/SpaceAddCredentialMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/credentials/SpaceRemoveCredentialMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/credentials/SpaceUpdateCredentialMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/folders/SpaceAddPageFolderMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/folders/SpaceRemovePageFolderMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/folders/SpaceUpdatePageFolderMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceRemoveFunctionsMutation.d.ts +3 -0
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceRemoveFunctionsMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceSaveFunctionsMutation.d.ts +11 -0
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceSaveFunctionsMutation.mjs +24 -0
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceTryFunctionMutation.d.ts +4 -0
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceTryFunctionMutation.mjs +15 -0
- package/dist/network/graphql/builder/Mutations/Space/pages/SpaceAddPageMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/pages/SpaceHomePageMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/pages/SpaceRemovePageMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/pages/SpaceUpdatePageMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/resources/SpaceAddResourceMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/resources/SpaceMoveResourceMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/resources/SpaceRemoveResourceMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeVariableMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeVariableMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeSizeMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeSizeMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeVariableMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeVariableMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStartRuntimeMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStartRuntimeMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStopRuntimeMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStopRuntimeMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/variables/SpaceAddVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/variables/SpaceRemoveVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/variables/SpaceUpdateVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceAddVisitorMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceAddVisitorMutation.mjs +11 -0
- package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceRemoveVisitorMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceRemoveVisitorMutation.mjs +11 -0
- package/dist/network/graphql/builder/Mutations/Style/StyleUpdateMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Style/StyleUpdateSettingsMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleAddFontMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleRemoveFontMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Style/fonts/StyleUpdateFontMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Style/selectorVariables/StyleAddSelectorVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Style/selectorVariables/StyleRemoveSelectorVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Style/selectorVariables/StyleUpdateSelectorVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Style/selectors/StyleAddSelectorMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Style/selectors/StyleRemoveSelectorMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Style/selectors/StyleRemoveSelectorsMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Style/selectors/StyleUpdateSelectorMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Style/variables/StyleAddVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Style/variables/StyleRemoveVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/Style/variables/StyleUpdateVariableMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/index.d.ts +28 -0
- package/dist/network/graphql/builder/Mutations/index.mjs +108 -84
- package/dist/network/graphql/builder/Queries/InitQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Segment/SegmentQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Segment/SegmentsQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceActionEventsQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceActionTasksQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceActionsQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceCdnsQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceChangesQuery.d.ts +23 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceChangesQuery.mjs +49 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceCheckActionQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceConnectorsQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceCredentialsQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceDeploymentsQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceFunctionsQuery.d.ts +6 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceFunctionsQuery.mjs +13 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.d.ts +17 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.mjs +22 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceLatestRevisionQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceQuotaQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceResourcesQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceRuntimeQuery.d.ts +6 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceRuntimeQuery.mjs +32 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceVisitorsQuery.d.ts +6 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceVisitorsQuery.mjs +16 -0
- package/dist/network/graphql/builder/Queries/index.d.ts +17 -3
- package/dist/network/graphql/builder/Queries/index.mjs +30 -22
- package/dist/network/graphql/builder/Subscriptions/SpaceEventSubscription.mjs +1 -1
- package/dist/network/graphql/sdk/Mutations/index.d.ts +1 -1
- package/dist/network/graphql/sdk/Queries/InitQuery.d.ts +1 -1
- package/dist/network/graphql/sdk/Queries/InitQuery.mjs +2 -91
- package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.d.ts +1 -1
- package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.mjs +2 -44
- package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.d.ts +1 -1
- package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.mjs +2 -55
- package/dist/network/graphql/sdk/Queries/index.d.ts +1 -5
- package/dist/network/index.mjs +7 -7
- package/dist/network/spaceEvents.d.ts +33 -3
- package/dist/network/spaceEvents.mjs +102 -89
- package/dist/realtime/client.d.ts +46 -0
- package/dist/realtime/client.mjs +192 -0
- package/dist/realtime/index.d.ts +6 -0
- package/dist/realtime/index.mjs +4 -0
- package/dist/realtime/presence.d.ts +38 -0
- package/dist/realtime/presence.mjs +70 -0
- package/dist/realtime/topics.d.ts +36 -0
- package/dist/realtime/topics.mjs +25 -0
- package/dist/server/actions/useRealtimeSync.d.ts +9 -0
- package/dist/server/actions/useRealtimeSync.mjs +7 -0
- package/dist/state/index.d.ts +1 -0
- package/dist/state/index.mjs +3 -2
- package/dist/state/paintedState.d.ts +52 -0
- package/dist/state/paintedState.mjs +37 -0
- package/dist/state/runtimeStatePersist.d.ts +8 -1
- package/dist/state/runtimeStatePersist.mjs +79 -29
- package/dist/store/index.d.ts +45 -45
- package/dist/store/renderSettings.d.ts +6 -3
- package/dist/store/tracing/index.d.ts +1 -0
- package/dist/store/tracing/tracingCollector.d.ts +17 -1
- package/dist/store/tracing/tracingCollector.mjs +5 -0
- package/dist/style/index.d.ts +1 -0
- package/dist/style/index.mjs +3 -2
- package/dist/style/runtimeStyle.d.ts +29 -0
- package/dist/style/runtimeStyle.mjs +7 -0
- package/dist/style/styleConstants.d.ts +3 -2
- package/dist/style/styleConstants.mjs +2 -0
- package/dist/style/styleStates.d.ts +14 -1
- package/dist/style/styleStates.mjs +10 -7
- package/dist/theme/ThemeProvider.mjs +35 -29
- package/dist/theme/themeCookie.mjs +11 -15
- package/dist/types/ActionTypes.d.ts +4 -0
- package/dist/types/AuthTypes.d.ts +11 -1
- package/dist/types/CommonTypes.d.ts +6 -0
- package/dist/types/FunctionTypes.d.ts +52 -0
- package/dist/types/FunctionTypes.mjs +0 -0
- package/dist/types/PluginTypes.d.ts +0 -1
- package/dist/types/RealtimeTypes.d.ts +94 -0
- package/dist/types/RealtimeTypes.mjs +0 -0
- package/dist/types/SchemaTypes.d.ts +54 -0
- package/dist/types/SchemaTypes.mjs +8 -0
- package/dist/types/ServerTypes.d.ts +259 -15
- package/dist/types/SpaceTypes.d.ts +53 -0
- package/dist/types/StateTypes.d.ts +6 -0
- package/dist/types/StoreTypes.d.ts +11 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.mjs +3 -2
- package/package.json +180 -11
- package/vite.config.ts +0 -12
- package/dist/network/graphql/builder/Queries/PluginsQuery.d.ts +0 -9
- package/dist/network/graphql/builder/Queries/PluginsQuery.mjs +0 -54
|
@@ -2,37 +2,47 @@ import { StyleVariableCategory as e } from "../types/StyleTypes.mjs";
|
|
|
2
2
|
import { STYLE_STATES as t } from "../style/styleStates.mjs";
|
|
3
3
|
import { z as n } from "zod";
|
|
4
4
|
//#region src/network/spaceEvents.ts
|
|
5
|
-
var r = (e) => typeof e == "object" && !!e && !Array.isArray(e), i = n.custom((e) => r(e) && typeof e.id == "string", { message: "expected an element with an id" }), a = n.array(i), o =
|
|
5
|
+
var r = (e) => typeof e == "object" && !!e && !Array.isArray(e), i = n.custom((e) => r(e) && typeof e.id == "string", { message: "expected an element with an id" }), a = n.array(i), o = (e) => ({
|
|
6
|
+
...e,
|
|
7
|
+
flat: Object.values(e.flat)
|
|
8
|
+
}), s = (e) => ({
|
|
9
|
+
...e,
|
|
10
|
+
flat: Object.fromEntries(e.flat.map((e) => [e.id, e]))
|
|
11
|
+
}), c = n.custom((e) => r(e) && Array.isArray(e.flat), { message: "expected a schema whose `flat` is a list of elements" }), l = n.custom((e) => r(e) && typeof e.id == "string", { message: "expected a page folder with an id" }), u = n.custom((e) => r(e) && typeof e.name == "string", { message: "expected a variable with a name" }), d = n.custom(r, { message: "expected a style attributes object" }), f = n.custom((e) => r(e) && typeof e.family == "string" && typeof e.source == "string", { message: "expected a font with a family and a source" }), p = n.custom((e) => typeof e == "string" || typeof e == "number" || r(e), { message: "expected a style variable value" }), m = n.enum([
|
|
6
12
|
"desktop",
|
|
7
13
|
"tablet",
|
|
8
14
|
"mobile"
|
|
9
|
-
]),
|
|
15
|
+
]), h = n.custom((e) => typeof e == "string", { message: "expected a drop position" }), g = n.custom((e) => typeof e == "string", { message: "expected a style category" }), _ = n.enum([
|
|
10
16
|
"class",
|
|
11
17
|
"element",
|
|
12
18
|
"id"
|
|
13
|
-
]),
|
|
19
|
+
]), v = n.enum(t), y = n.enum(e), b = n.object({
|
|
14
20
|
componentType: n.string().optional(),
|
|
15
21
|
styleSelector: n.string().optional(),
|
|
16
|
-
styleState:
|
|
22
|
+
styleState: v.optional(),
|
|
17
23
|
styleVariant: n.string().optional(),
|
|
18
24
|
styleAncestor: n.string().optional()
|
|
19
|
-
}),
|
|
20
|
-
displayMode:
|
|
25
|
+
}), x = b.extend({ styleSelector: n.string() }), S = { contextId: n.string() }, C = n.object({ variable: u }), w = n.object({
|
|
26
|
+
displayMode: m,
|
|
21
27
|
selector: n.string(),
|
|
22
|
-
category:
|
|
28
|
+
category: y,
|
|
23
29
|
name: n.string(),
|
|
24
|
-
value:
|
|
25
|
-
}),
|
|
26
|
-
displayMode:
|
|
30
|
+
value: p
|
|
31
|
+
}), T = n.object({
|
|
32
|
+
displayMode: m,
|
|
27
33
|
selector: n.string(),
|
|
28
|
-
category:
|
|
34
|
+
category: y,
|
|
29
35
|
name: n.string()
|
|
30
|
-
}),
|
|
31
|
-
category:
|
|
36
|
+
}), E = n.object({
|
|
37
|
+
category: y,
|
|
32
38
|
name: n.string(),
|
|
33
|
-
value:
|
|
34
|
-
}),
|
|
35
|
-
|
|
39
|
+
value: p
|
|
40
|
+
}), D = n.object({
|
|
41
|
+
type: n.string(),
|
|
42
|
+
resource: n.string(),
|
|
43
|
+
settings: n.custom(r, { message: "expected a plugin settings object" })
|
|
44
|
+
}), O = {
|
|
45
|
+
SPACE_UPDATED: n.object({ schema: c }),
|
|
36
46
|
STYLE_UPDATED: n.object({
|
|
37
47
|
platform: n.custom(r),
|
|
38
48
|
variables: n.custom(r),
|
|
@@ -42,18 +52,18 @@ var r = (e) => typeof e == "object" && !!e && !Array.isArray(e), i = n.custom((e
|
|
|
42
52
|
SPACE_UPDATE_PAGE: n.object({ page: i }),
|
|
43
53
|
SPACE_SET_HOME_PAGE: n.object({ page: i }),
|
|
44
54
|
SPACE_REMOVE_PAGE: n.object({ pageId: n.string() }),
|
|
45
|
-
SPACE_ADD_PAGE_FOLDER: n.object({ pageFolder:
|
|
46
|
-
SPACE_UPDATE_PAGE_FOLDER: n.object({ pageFolder:
|
|
55
|
+
SPACE_ADD_PAGE_FOLDER: n.object({ pageFolder: l }),
|
|
56
|
+
SPACE_UPDATE_PAGE_FOLDER: n.object({ pageFolder: l }),
|
|
47
57
|
SPACE_REMOVE_PAGE_FOLDER: n.object({ pageFolderId: n.string() }),
|
|
48
|
-
SPACE_ADD_VARIABLE:
|
|
49
|
-
SPACE_UPDATE_VARIABLE:
|
|
58
|
+
SPACE_ADD_VARIABLE: C,
|
|
59
|
+
SPACE_UPDATE_VARIABLE: C,
|
|
50
60
|
SPACE_REMOVE_VARIABLE: n.object({ name: n.string() }),
|
|
51
61
|
SPACE_ADD_ELEMENT: n.object({
|
|
52
62
|
element: i,
|
|
53
|
-
dropPosition:
|
|
63
|
+
dropPosition: h,
|
|
54
64
|
to: n.string(),
|
|
55
65
|
initialItems: a.optional(),
|
|
56
|
-
variables: n.array(
|
|
66
|
+
variables: n.array(u).optional()
|
|
57
67
|
}),
|
|
58
68
|
SPACE_UPDATE_ELEMENT: n.object({ element: i }),
|
|
59
69
|
SPACE_RENAME_ELEMENT: n.object({
|
|
@@ -66,22 +76,25 @@ var r = (e) => typeof e == "object" && !!e && !Array.isArray(e), i = n.custom((e
|
|
|
66
76
|
from: n.string(),
|
|
67
77
|
to: n.string(),
|
|
68
78
|
elementId: n.string(),
|
|
69
|
-
dropPosition:
|
|
79
|
+
dropPosition: h
|
|
70
80
|
}),
|
|
71
81
|
SPACE_CLONE_ELEMENT: n.object({
|
|
72
82
|
to: n.string(),
|
|
73
83
|
element: i,
|
|
74
|
-
dropPosition:
|
|
84
|
+
dropPosition: h,
|
|
75
85
|
initialItems: a
|
|
76
86
|
}),
|
|
77
87
|
SPACE_ADD_TEMPLATE: n.object({
|
|
78
88
|
element: i,
|
|
79
89
|
style: n.custom(r),
|
|
80
90
|
to: n.string(),
|
|
81
|
-
dropPosition:
|
|
91
|
+
dropPosition: h,
|
|
82
92
|
initialItems: a.optional(),
|
|
83
|
-
variables: n.array(
|
|
93
|
+
variables: n.array(u).optional()
|
|
84
94
|
}),
|
|
95
|
+
SPACE_ADD_PLUGIN: n.object({ plugin: D }),
|
|
96
|
+
SPACE_UPDATE_PLUGIN: n.object({ plugin: D }),
|
|
97
|
+
SPACE_REMOVE_PLUGIN: n.object({ pluginType: n.string() }),
|
|
85
98
|
SPACE_UPDATE_SETTINGS: n.object({
|
|
86
99
|
path: n.string(),
|
|
87
100
|
value: n.union([
|
|
@@ -91,146 +104,146 @@ var r = (e) => typeof e == "object" && !!e && !Array.isArray(e), i = n.custom((e
|
|
|
91
104
|
])
|
|
92
105
|
}),
|
|
93
106
|
STYLE_ADD_SELECTOR: n.object({
|
|
94
|
-
displayMode:
|
|
107
|
+
displayMode: m,
|
|
95
108
|
selector: n.string(),
|
|
96
|
-
path:
|
|
97
|
-
type:
|
|
98
|
-
style:
|
|
99
|
-
params:
|
|
109
|
+
path: g.optional(),
|
|
110
|
+
type: _,
|
|
111
|
+
style: d.optional(),
|
|
112
|
+
params: b
|
|
100
113
|
}),
|
|
101
114
|
STYLE_UPDATE_SELECTOR: n.object({
|
|
102
|
-
displayMode:
|
|
115
|
+
displayMode: m,
|
|
103
116
|
selector: n.string(),
|
|
104
|
-
path:
|
|
105
|
-
style:
|
|
106
|
-
params:
|
|
117
|
+
path: g.optional(),
|
|
118
|
+
style: d.optional(),
|
|
119
|
+
params: x
|
|
107
120
|
}),
|
|
108
121
|
STYLE_REMOVE_SELECTOR: n.object({
|
|
109
|
-
displayMode:
|
|
122
|
+
displayMode: m,
|
|
110
123
|
selector: n.string()
|
|
111
124
|
}),
|
|
112
125
|
STYLE_REMOVE_SELECTORS: n.object({
|
|
113
|
-
displayMode:
|
|
126
|
+
displayMode: m,
|
|
114
127
|
selectors: n.array(n.string())
|
|
115
128
|
}),
|
|
116
|
-
STYLE_ADD_SELECTOR_VARIABLE:
|
|
117
|
-
STYLE_UPDATE_SELECTOR_VARIABLE:
|
|
118
|
-
STYLE_REMOVE_SELECTOR_VARIABLE:
|
|
119
|
-
STYLE_ADD_VARIABLE:
|
|
120
|
-
STYLE_UPDATE_VARIABLE:
|
|
129
|
+
STYLE_ADD_SELECTOR_VARIABLE: w,
|
|
130
|
+
STYLE_UPDATE_SELECTOR_VARIABLE: w,
|
|
131
|
+
STYLE_REMOVE_SELECTOR_VARIABLE: T,
|
|
132
|
+
STYLE_ADD_VARIABLE: E,
|
|
133
|
+
STYLE_UPDATE_VARIABLE: E,
|
|
121
134
|
STYLE_REMOVE_VARIABLE: n.object({
|
|
122
|
-
category:
|
|
135
|
+
category: y,
|
|
123
136
|
name: n.string()
|
|
124
137
|
}),
|
|
125
138
|
STYLE_UPDATE_SETTINGS: n.object({
|
|
126
139
|
path: n.string(),
|
|
127
140
|
value: n.string()
|
|
128
141
|
}),
|
|
129
|
-
STYLE_ADD_FONT: n.object({ font:
|
|
142
|
+
STYLE_ADD_FONT: n.object({ font: f }),
|
|
130
143
|
STYLE_UPDATE_FONT: n.object({
|
|
131
144
|
family: n.string(),
|
|
132
|
-
font:
|
|
145
|
+
font: f
|
|
133
146
|
}),
|
|
134
147
|
STYLE_REMOVE_FONT: n.object({ family: n.string() }),
|
|
135
148
|
SEGMENT_ADD_ELEMENT: n.object({
|
|
136
|
-
...
|
|
149
|
+
...S,
|
|
137
150
|
element: i,
|
|
138
|
-
dropPosition:
|
|
151
|
+
dropPosition: h,
|
|
139
152
|
to: n.string(),
|
|
140
153
|
initialItems: a.optional(),
|
|
141
|
-
variables: n.array(
|
|
154
|
+
variables: n.array(u).optional()
|
|
142
155
|
}),
|
|
143
156
|
SEGMENT_UPDATE_ELEMENT: n.object({
|
|
144
|
-
...
|
|
157
|
+
...S,
|
|
145
158
|
element: i
|
|
146
159
|
}),
|
|
147
160
|
SEGMENT_RENAME_ELEMENT: n.object({
|
|
148
|
-
...
|
|
161
|
+
...S,
|
|
149
162
|
elementId: n.string(),
|
|
150
163
|
id: n.string()
|
|
151
164
|
}),
|
|
152
165
|
SEGMENT_UPDATE_ELEMENTS: n.object({
|
|
153
|
-
...
|
|
166
|
+
...S,
|
|
154
167
|
elements: a
|
|
155
168
|
}),
|
|
156
169
|
SEGMENT_REMOVE_ELEMENT: n.object({
|
|
157
|
-
...
|
|
170
|
+
...S,
|
|
158
171
|
elementId: n.string()
|
|
159
172
|
}),
|
|
160
173
|
SEGMENT_MOVE_ELEMENT: n.object({
|
|
161
|
-
...
|
|
174
|
+
...S,
|
|
162
175
|
elementId: n.string(),
|
|
163
176
|
from: n.string(),
|
|
164
177
|
to: n.string(),
|
|
165
|
-
dropPosition:
|
|
178
|
+
dropPosition: h
|
|
166
179
|
}),
|
|
167
180
|
SEGMENT_CLONE_ELEMENT: n.object({
|
|
168
|
-
...
|
|
181
|
+
...S,
|
|
169
182
|
element: i,
|
|
170
|
-
dropPosition:
|
|
183
|
+
dropPosition: h,
|
|
171
184
|
to: n.string(),
|
|
172
185
|
initialItems: a.optional()
|
|
173
186
|
}),
|
|
174
187
|
SEGMENT_ADD_TEMPLATE: n.object({
|
|
175
|
-
...
|
|
188
|
+
...S,
|
|
176
189
|
element: i,
|
|
177
190
|
style: n.custom(r),
|
|
178
191
|
to: n.string(),
|
|
179
|
-
dropPosition:
|
|
192
|
+
dropPosition: h,
|
|
180
193
|
initialItems: a.optional(),
|
|
181
|
-
variables: n.array(
|
|
194
|
+
variables: n.array(u).optional()
|
|
182
195
|
}),
|
|
183
196
|
SEGMENT_SPACE_ADD_VARIABLE: n.object({
|
|
184
|
-
...
|
|
185
|
-
variable:
|
|
197
|
+
...S,
|
|
198
|
+
variable: u
|
|
186
199
|
}),
|
|
187
200
|
SEGMENT_SPACE_UPDATE_VARIABLE: n.object({
|
|
188
|
-
...
|
|
189
|
-
variable:
|
|
201
|
+
...S,
|
|
202
|
+
variable: u
|
|
190
203
|
}),
|
|
191
204
|
SEGMENT_SPACE_REMOVE_VARIABLE: n.object({
|
|
192
|
-
...
|
|
205
|
+
...S,
|
|
193
206
|
variable: n.object({ name: n.string() })
|
|
194
207
|
}),
|
|
195
208
|
SEGMENT_STYLE_ADD_SELECTOR: n.object({
|
|
196
|
-
...
|
|
197
|
-
displayMode:
|
|
209
|
+
...S,
|
|
210
|
+
displayMode: m,
|
|
198
211
|
selector: n.string(),
|
|
199
|
-
type:
|
|
200
|
-
path:
|
|
201
|
-
style:
|
|
202
|
-
params:
|
|
212
|
+
type: _,
|
|
213
|
+
path: g.optional(),
|
|
214
|
+
style: d.optional(),
|
|
215
|
+
params: b
|
|
203
216
|
}),
|
|
204
217
|
SEGMENT_STYLE_UPDATE_SELECTOR: n.object({
|
|
205
|
-
...
|
|
206
|
-
displayMode:
|
|
218
|
+
...S,
|
|
219
|
+
displayMode: m,
|
|
207
220
|
selector: n.string(),
|
|
208
|
-
path:
|
|
209
|
-
style:
|
|
210
|
-
params:
|
|
221
|
+
path: g.optional(),
|
|
222
|
+
style: d.optional(),
|
|
223
|
+
params: x
|
|
211
224
|
}),
|
|
212
225
|
SEGMENT_STYLE_REMOVE_SELECTOR: n.object({
|
|
213
|
-
...
|
|
214
|
-
displayMode:
|
|
226
|
+
...S,
|
|
227
|
+
displayMode: m,
|
|
215
228
|
selector: n.string()
|
|
216
229
|
}),
|
|
217
230
|
SEGMENT_STYLE_REMOVE_SELECTORS: n.object({
|
|
218
|
-
...
|
|
219
|
-
displayMode:
|
|
231
|
+
...S,
|
|
232
|
+
displayMode: m,
|
|
220
233
|
selectors: n.array(n.string())
|
|
221
234
|
}),
|
|
222
|
-
SEGMENT_STYLE_ADD_SELECTOR_VARIABLE:
|
|
223
|
-
SEGMENT_STYLE_UPDATE_SELECTOR_VARIABLE:
|
|
224
|
-
SEGMENT_STYLE_REMOVE_SELECTOR_VARIABLE:
|
|
225
|
-
SEGMENT_STYLE_ADD_VARIABLE:
|
|
226
|
-
SEGMENT_STYLE_UPDATE_VARIABLE:
|
|
235
|
+
SEGMENT_STYLE_ADD_SELECTOR_VARIABLE: w.extend(S),
|
|
236
|
+
SEGMENT_STYLE_UPDATE_SELECTOR_VARIABLE: w.extend(S),
|
|
237
|
+
SEGMENT_STYLE_REMOVE_SELECTOR_VARIABLE: T.extend(S),
|
|
238
|
+
SEGMENT_STYLE_ADD_VARIABLE: E.extend(S),
|
|
239
|
+
SEGMENT_STYLE_UPDATE_VARIABLE: E.extend(S),
|
|
227
240
|
SEGMENT_STYLE_REMOVE_VARIABLE: n.object({
|
|
228
|
-
...
|
|
229
|
-
category:
|
|
241
|
+
...S,
|
|
242
|
+
category: y,
|
|
230
243
|
name: n.string()
|
|
231
244
|
})
|
|
232
|
-
},
|
|
233
|
-
let n =
|
|
245
|
+
}, k = Object.fromEntries(Object.keys(O).map((e) => [e, e])), A = (e, t) => {
|
|
246
|
+
let n = O[e];
|
|
234
247
|
if (!n) return {
|
|
235
248
|
ok: !1,
|
|
236
249
|
issues: [{
|
|
@@ -251,4 +264,4 @@ var r = (e) => typeof e == "object" && !!e && !Array.isArray(e), i = n.custom((e
|
|
|
251
264
|
};
|
|
252
265
|
};
|
|
253
266
|
//#endregion
|
|
254
|
-
export {
|
|
267
|
+
export { k as SpaceEvents, k as default, s as schemaFromWire, o as schemaToWire, O as spaceEventSchemas, A as validateSpaceEvent };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { RealtimeMessage, RealtimeTransport } from '../types/RealtimeTypes';
|
|
2
|
+
export type RealtimeStatus = 'idle' | 'connecting' | 'open' | 'closed';
|
|
3
|
+
type MessageListener = (message: RealtimeMessage) => void;
|
|
4
|
+
type StatusListener = (status: RealtimeStatus) => void;
|
|
5
|
+
export type RealtimeClient = {
|
|
6
|
+
/** Listens to a topic; the page's one connection is reopened to include it. Returns what stops listening. */
|
|
7
|
+
subscribe: (topic: string, listener: MessageListener) => () => void;
|
|
8
|
+
/**
|
|
9
|
+
* What opens a topic of a `grant: true` channel: the grant a flow's `realtime.grant` answered. Sent whenever the
|
|
10
|
+
* connection opens for as long as the topic is listened to — a grant is only asked for at the door, so a new one
|
|
11
|
+
* reopens nothing the server already let in. `undefined` forgets it.
|
|
12
|
+
*/
|
|
13
|
+
grant: (topic: string, grant: string | undefined) => void;
|
|
14
|
+
/** Sends on a topic this page listens to. `false` when the server refused it or there is no connection. */
|
|
15
|
+
publish: (topic: string, type: string, data: unknown) => Promise<boolean>;
|
|
16
|
+
onStatus: (listener: StatusListener) => () => void;
|
|
17
|
+
readonly status: RealtimeStatus;
|
|
18
|
+
/** This page's name on its channels — the `from` of what it sends — once connected. */
|
|
19
|
+
readonly me: string | undefined;
|
|
20
|
+
/** How this page is connected right now: a socket, or a stream (also where a socket could not open). */
|
|
21
|
+
readonly transport: RealtimeTransport;
|
|
22
|
+
/** Why the server would not open a topic, when it would not. */
|
|
23
|
+
refusal: (topic: string) => string | undefined;
|
|
24
|
+
};
|
|
25
|
+
export type RealtimeClientOptions = {
|
|
26
|
+
/** What to connect with. `websocket` falls back to `sse` for good the first time a socket cannot open. */
|
|
27
|
+
transport?: RealtimeTransport;
|
|
28
|
+
fetchImpl?: typeof fetch;
|
|
29
|
+
WebSocketImpl?: typeof WebSocket;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A page's realtime connection: every topic it listens to over ONE connection — a Server-Sent Events stream it
|
|
33
|
+
* publishes to with requests, or a WebSocket that carries both.
|
|
34
|
+
*
|
|
35
|
+
* The stream is read with `fetch` rather than `EventSource`: an `EventSource` reconnects on its own, with the same
|
|
36
|
+
* topics, to a server that may have just refused them. Reconnecting is this client's decision: after a dropped
|
|
37
|
+
* connection, with a growing wait; never after a refusal.
|
|
38
|
+
*
|
|
39
|
+
* A socket that closes before it was ever ready is a socket that cannot open here — HTTP/2, a proxy that drops
|
|
40
|
+
* upgrades, or a refusal, which a browser does not let a page read — so the client moves to the stream for good. The
|
|
41
|
+
* stream says which it was.
|
|
42
|
+
*/
|
|
43
|
+
export declare const createRealtimeClient: (endpoint: string, { transport: preferred, fetchImpl, WebSocketImpl }?: RealtimeClientOptions) => RealtimeClient;
|
|
44
|
+
/** The page's client for an endpoint: one connection, however many elements and plugins listen. */
|
|
45
|
+
export declare const realtimeClientFor: (endpoint: string, transport?: RealtimeTransport) => RealtimeClient;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import "./topics.mjs";
|
|
2
|
+
//#region src/realtime/client.ts
|
|
3
|
+
var e = 30, t = [
|
|
4
|
+
500,
|
|
5
|
+
1e3,
|
|
6
|
+
2e3,
|
|
7
|
+
5e3,
|
|
8
|
+
1e4
|
|
9
|
+
], n = 5e3, r = (e) => typeof e == "object" && !!e && "connection" in e && typeof e.connection == "string" && "refused" in e && Array.isArray(e.refused), i = (e) => typeof e == "object" && !!e && "topic" in e && typeof e.topic == "string" && "type" in e && typeof e.type == "string", a = (e) => typeof e == "object" && !!e && "id" in e && typeof e.id == "number" && "ok" in e && typeof e.ok == "boolean", o = (e) => {
|
|
10
|
+
let t = "message", n = [];
|
|
11
|
+
for (let r of e.split("\n")) r.startsWith("event: ") ? t = r.slice(7) : r.startsWith("data: ") && n.push(r.slice(6));
|
|
12
|
+
if (n.length) try {
|
|
13
|
+
return {
|
|
14
|
+
event: t,
|
|
15
|
+
data: JSON.parse(n.join("\n"))
|
|
16
|
+
};
|
|
17
|
+
} catch {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
}, s = (e) => {
|
|
21
|
+
try {
|
|
22
|
+
let t = JSON.parse(String(e));
|
|
23
|
+
return typeof t == "object" && t && "event" in t && typeof t.event == "string" ? {
|
|
24
|
+
event: t.event,
|
|
25
|
+
data: "data" in t ? t.data : void 0
|
|
26
|
+
} : void 0;
|
|
27
|
+
} catch {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
}, c = (e, t) => {
|
|
31
|
+
let n = new URL(`${e}?${t}`, globalThis.location.href);
|
|
32
|
+
return n.protocol = n.protocol === "https:" ? "wss:" : "ws:", n.href;
|
|
33
|
+
}, l = (l, { transport: u = "sse", fetchImpl: d = fetch, WebSocketImpl: f = globalThis.WebSocket } = {}) => {
|
|
34
|
+
let p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Set(), g = "idle", _, v = /* @__PURE__ */ new Map(), y, b, x = 0, S = u === "websocket" && typeof f == "function", C = (e) => {
|
|
35
|
+
g = e, h.forEach((t) => t(e));
|
|
36
|
+
}, w = () => [...p.keys()].sort().join(","), T = (e) => {
|
|
37
|
+
let t = e.split(",").flatMap((e) => m.get(e) ?? []);
|
|
38
|
+
return `topics=${encodeURIComponent(e)}${t.length ? `&grants=${encodeURIComponent(t.join(","))}` : ""}`;
|
|
39
|
+
}, E = (e) => {
|
|
40
|
+
e.type === "$revoked" && e.from === "server" && v.set(e.topic, "revoked"), p.get(e.topic)?.forEach((t) => t(e));
|
|
41
|
+
}, D = (e, t) => {
|
|
42
|
+
e.me = t.connection, v = new Map(t.refused.map((e) => [e.topic, e.reason])), x = 0, C("open");
|
|
43
|
+
}, O = (e) => {
|
|
44
|
+
if (_ !== e) return;
|
|
45
|
+
C("connecting");
|
|
46
|
+
let n = t[Math.min(x, t.length - 1)];
|
|
47
|
+
x += 1, b = setTimeout(j, n);
|
|
48
|
+
}, k = (e, t) => {
|
|
49
|
+
let n = new AbortController(), a, s = {
|
|
50
|
+
topics: e,
|
|
51
|
+
transport: "sse",
|
|
52
|
+
close: () => n.abort(),
|
|
53
|
+
publish: async (e, t, n) => {
|
|
54
|
+
if (!a) return !1;
|
|
55
|
+
let r = await d(l, {
|
|
56
|
+
method: "POST",
|
|
57
|
+
headers: { "content-type": "application/json" },
|
|
58
|
+
credentials: "same-origin",
|
|
59
|
+
body: JSON.stringify({
|
|
60
|
+
token: a,
|
|
61
|
+
topic: e,
|
|
62
|
+
type: t,
|
|
63
|
+
data: n
|
|
64
|
+
})
|
|
65
|
+
}).catch(() => void 0);
|
|
66
|
+
return r?.status === 401 && _ === s && j(), r?.ok ?? !1;
|
|
67
|
+
}
|
|
68
|
+
}, c = async (e) => {
|
|
69
|
+
let t = e.body?.getReader();
|
|
70
|
+
if (!t) return;
|
|
71
|
+
let n = new TextDecoder(), c = "";
|
|
72
|
+
for (;;) {
|
|
73
|
+
let { done: e, value: l } = await t.read();
|
|
74
|
+
if (e) return;
|
|
75
|
+
c += n.decode(l, { stream: !0 });
|
|
76
|
+
let u = c.indexOf("\n\n");
|
|
77
|
+
for (; u !== -1;) {
|
|
78
|
+
let e = o(c.slice(0, u));
|
|
79
|
+
c = c.slice(u + 2), u = c.indexOf("\n\n"), e?.event === "ready" && r(e.data) ? (a = e.data.token, D(s, e.data)) : e?.event === "message" && i(e.data) && E(e.data);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return d(`${l}?${t}`, {
|
|
84
|
+
headers: { accept: "text/event-stream" },
|
|
85
|
+
credentials: "same-origin",
|
|
86
|
+
signal: n.signal
|
|
87
|
+
}).then(async (t) => {
|
|
88
|
+
if (!t.ok) {
|
|
89
|
+
v = new Map(e.split(",").map((e) => [e, `http_${t.status}`])), C("closed");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
throw await c(t), Error("The realtime stream ended");
|
|
93
|
+
}).catch(() => {
|
|
94
|
+
n.signal.aborted || O(s);
|
|
95
|
+
}), s;
|
|
96
|
+
}, A = (e, t) => {
|
|
97
|
+
let o = new f(c(l, t)), u = /* @__PURE__ */ new Map(), d = 0, p = !1, m = !1, h = () => {
|
|
98
|
+
u.forEach((e) => e(!1)), u.clear();
|
|
99
|
+
}, g = {
|
|
100
|
+
topics: e,
|
|
101
|
+
transport: "websocket",
|
|
102
|
+
close: () => {
|
|
103
|
+
m = !0, h(), o.close();
|
|
104
|
+
},
|
|
105
|
+
publish: (e, t, r) => new Promise((i) => {
|
|
106
|
+
if (o.readyState !== o.OPEN) {
|
|
107
|
+
i(!1);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
d += 1;
|
|
111
|
+
let a = d, s = setTimeout(() => {
|
|
112
|
+
u.delete(a), i(!1);
|
|
113
|
+
}, n);
|
|
114
|
+
u.set(a, (e) => {
|
|
115
|
+
clearTimeout(s), i(e);
|
|
116
|
+
}), o.send(JSON.stringify({
|
|
117
|
+
id: a,
|
|
118
|
+
topic: e,
|
|
119
|
+
type: t,
|
|
120
|
+
data: r
|
|
121
|
+
}));
|
|
122
|
+
})
|
|
123
|
+
};
|
|
124
|
+
return o.onmessage = (e) => {
|
|
125
|
+
let t = s(e.data);
|
|
126
|
+
t?.event === "ready" && r(t.data) ? (p = !0, D(g, t.data)) : t?.event === "message" && i(t.data) ? E(t.data) : t?.event === "ack" && a(t.data) && (u.get(t.data.id)?.(t.data.ok), u.delete(t.data.id));
|
|
127
|
+
}, o.onclose = () => {
|
|
128
|
+
if (h(), !(m || _ !== g)) {
|
|
129
|
+
if (!p) {
|
|
130
|
+
S = !1, j();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
O(g);
|
|
134
|
+
}
|
|
135
|
+
}, g;
|
|
136
|
+
};
|
|
137
|
+
function j() {
|
|
138
|
+
_?.close(), _ = void 0;
|
|
139
|
+
let e = w();
|
|
140
|
+
if (!e) {
|
|
141
|
+
C("idle");
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
C("connecting");
|
|
145
|
+
let t = T(e);
|
|
146
|
+
_ = S ? A(e, t) : k(e, t);
|
|
147
|
+
}
|
|
148
|
+
let M = (t = !1) => {
|
|
149
|
+
clearTimeout(y), clearTimeout(b), y = setTimeout(() => {
|
|
150
|
+
(t || _?.topics !== w()) && j();
|
|
151
|
+
}, e);
|
|
152
|
+
}, N = (e) => g === "open" && _?.topics.split(",").includes(e) === !0, P = (e) => N(e) ? Promise.resolve(!0) : new Promise((t) => {
|
|
153
|
+
let r = setTimeout(() => {
|
|
154
|
+
i(), t(!1);
|
|
155
|
+
}, n), i = F.onStatus((n) => {
|
|
156
|
+
(n === "closed" || N(e)) && (clearTimeout(r), i(), t(n !== "closed"));
|
|
157
|
+
});
|
|
158
|
+
}), F = {
|
|
159
|
+
subscribe: (e, t) => {
|
|
160
|
+
let n = p.get(e) ?? /* @__PURE__ */ new Set();
|
|
161
|
+
return n.add(t), p.set(e, n), M(), () => {
|
|
162
|
+
n.delete(t), n.size || (p.delete(e), m.delete(e), M());
|
|
163
|
+
};
|
|
164
|
+
},
|
|
165
|
+
grant: (e, t) => {
|
|
166
|
+
if (m.get(e) === t) return;
|
|
167
|
+
t ? m.set(e, t) : m.delete(e);
|
|
168
|
+
let n = N(e) && !v.has(e);
|
|
169
|
+
t && p.has(e) && !n && M(!0);
|
|
170
|
+
},
|
|
171
|
+
publish: async (e, t, n) => !await P(e) || !_ ? !1 : _.publish(e, t, n),
|
|
172
|
+
onStatus: (e) => (h.add(e), () => h.delete(e)),
|
|
173
|
+
get status() {
|
|
174
|
+
return g;
|
|
175
|
+
},
|
|
176
|
+
get me() {
|
|
177
|
+
return _?.me;
|
|
178
|
+
},
|
|
179
|
+
get transport() {
|
|
180
|
+
return _?.transport ?? (S ? "websocket" : "sse");
|
|
181
|
+
},
|
|
182
|
+
refusal: (e) => v.get(e)
|
|
183
|
+
};
|
|
184
|
+
return F;
|
|
185
|
+
}, u = /* @__PURE__ */ new Map(), d = (e, t = "sse") => {
|
|
186
|
+
let n = `${t} ${e}`, r = u.get(n);
|
|
187
|
+
if (r) return r;
|
|
188
|
+
let i = l(e, { transport: t });
|
|
189
|
+
return u.set(n, i), i;
|
|
190
|
+
};
|
|
191
|
+
//#endregion
|
|
192
|
+
export { l as createRealtimeClient, d as realtimeClientFor };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createRealtimeClient, realtimeClientFor } from './client';
|
|
2
|
+
export { trackPresence } from './presence';
|
|
3
|
+
export { JOIN_TYPE, LEAVE_TYPE, PRESENCE_TYPE, REVOKED_TYPE, channelLimits, channelProblems, isValidTopic, matchChannel } from './topics';
|
|
4
|
+
export type { RealtimeClient, RealtimeClientOptions, RealtimeStatus } from './client';
|
|
5
|
+
export type { PresenceListeners, PresenceTracker, RealtimeMember } from './presence';
|
|
6
|
+
export type { ChannelMatch } from './topics';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { JOIN_TYPE as e, LEAVE_TYPE as t, PRESENCE_TYPE as n, REVOKED_TYPE as r, channelLimits as i, channelProblems as a, isValidTopic as o, matchChannel as s } from "./topics.mjs";
|
|
2
|
+
import { createRealtimeClient as c, realtimeClientFor as l } from "./client.mjs";
|
|
3
|
+
import { trackPresence as u } from "./presence.mjs";
|
|
4
|
+
export { e as JOIN_TYPE, t as LEAVE_TYPE, n as PRESENCE_TYPE, r as REVOKED_TYPE, i as channelLimits, a as channelProblems, c as createRealtimeClient, o as isValidTopic, s as matchChannel, l as realtimeClientFor, u as trackPresence };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RealtimeClient } from './client';
|
|
2
|
+
import { RealtimeMessage, RealtimeSender } from '../types/RealtimeTypes';
|
|
3
|
+
/** One member of a channel: who they are to the server, and what they announced. */
|
|
4
|
+
export type RealtimeMember = RealtimeSender & {
|
|
5
|
+
/** What the member announced — a name, a colour, a cursor. */
|
|
6
|
+
state: unknown;
|
|
7
|
+
/** Whether this member is this page. */
|
|
8
|
+
me: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type PresenceTracker = {
|
|
11
|
+
/** Announces this page's state — and keeps announcing it, so it is not taken for gone. */
|
|
12
|
+
set: (state: unknown) => void;
|
|
13
|
+
members: () => RealtimeMember[];
|
|
14
|
+
stop: () => void;
|
|
15
|
+
};
|
|
16
|
+
/** What a tracker is told: who is here, every message on the topic, and who came and went. */
|
|
17
|
+
export type PresenceListeners = {
|
|
18
|
+
onChange: (members: RealtimeMember[]) => void;
|
|
19
|
+
onMessage?: (message: RealtimeMessage) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Somebody who joined after this page, once they have said who they are — their first `$presence`. Those already
|
|
22
|
+
* here when this page came are not arrivals: they answer its `$join` with theirs, and it is they who were here first.
|
|
23
|
+
*/
|
|
24
|
+
onArrive?: (member: RealtimeMember) => void;
|
|
25
|
+
/** Somebody who was here went — the server said so, or they stopped being heard — as they last said they were. */
|
|
26
|
+
onDepart?: (member: RealtimeMember) => void;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Who is on a topic, kept from what the members say — nothing is stored anywhere.
|
|
30
|
+
*
|
|
31
|
+
* A member announces itself (`$presence`) when it sets its state, when somebody new arrives (`$join`) and every
|
|
32
|
+
* twenty seconds; the server says `$leave` when its connection closes. A member heard from in none of those ways for
|
|
33
|
+
* a minute is gone, which is what heals a leave that was lost.
|
|
34
|
+
*
|
|
35
|
+
* Every tracker of one topic on one client is a view of the same member: `set` from any of them is the page's state,
|
|
36
|
+
* and a tracker started late begins with everyone already known.
|
|
37
|
+
*/
|
|
38
|
+
export declare const trackPresence: (client: RealtimeClient, topic: string, listener: PresenceListeners) => PresenceTracker;
|