@plitzi/sdk-shared 0.37.8 → 0.37.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +817 -0
- package/dist/actions/functions.d.ts +12 -3
- package/dist/actions/functions.mjs +8 -5
- package/dist/actions/index.d.ts +2 -2
- package/dist/actions/index.mjs +6 -6
- package/dist/actions/triggerParams.mjs +7 -6
- package/dist/actions/validateDocument.d.ts +3 -0
- package/dist/actions/validateDocument.mjs +89 -88
- package/dist/auth/failureChannel.d.ts +8 -2
- package/dist/auth/failureChannel.mjs +1 -3
- package/dist/authoring/elementCallbacks.d.ts +65 -0
- package/dist/authoring/elementCallbacks.mjs +72 -8
- package/dist/authoring/index.mjs +3 -3
- package/dist/builder/contexts/BuilderContext.d.ts +18 -7
- package/dist/builder/contexts/BuilderContext.mjs +2 -3
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.mjs +2 -2
- package/dist/connectors/validateManifest.d.ts +3 -0
- package/dist/connectors/validateManifest.mjs +77 -76
- package/dist/dataSource/computed.mjs +25 -29
- package/dist/dataSource/globalSources.d.ts +15 -0
- package/dist/dataSource/globalSources.mjs +13 -0
- package/dist/dataSource/index.d.ts +2 -0
- package/dist/dataSource/index.mjs +8 -7
- package/dist/devTools/DevToolsContext.mjs +2 -3
- package/dist/devTools/utils/PlitziConsole.d.ts +9 -0
- package/dist/devTools/utils/PlitziConsole.mjs +27 -7
- package/dist/elements/ComponentContext.mjs +2 -3
- package/dist/flags/flagsCookie.d.ts +26 -0
- package/dist/flags/flagsCookie.mjs +20 -0
- package/dist/flags/index.d.ts +3 -0
- package/dist/flags/index.mjs +4 -0
- package/dist/flags/resolveFlags.d.ts +60 -0
- package/dist/flags/resolveFlags.mjs +38 -0
- package/dist/flags/schemaFlag.d.ts +11 -0
- package/dist/flags/schemaFlag.mjs +9 -0
- package/dist/flags/useFlagResolution.d.ts +13 -0
- package/dist/flags/useFlagResolution.mjs +43 -0
- package/dist/helpers/eventTarget.d.ts +10 -0
- package/dist/helpers/eventTarget.mjs +4 -0
- package/dist/helpers/images.d.ts +18 -0
- package/dist/helpers/images.mjs +13 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/index.mjs +21 -18
- package/dist/helpers/interval.d.ts +18 -0
- package/dist/helpers/interval.mjs +7 -0
- package/dist/helpers/isRecord.d.ts +2 -0
- package/dist/helpers/isRecord.mjs +4 -0
- package/dist/helpers/scroll.d.ts +42 -0
- package/dist/helpers/scroll.mjs +30 -0
- package/dist/helpers/sharedContext.d.ts +14 -0
- package/dist/helpers/sharedContext.mjs +9 -0
- package/dist/helpers/twigWrapper/Evaluator/Evaluator.d.ts +9 -1
- package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +13 -8
- package/dist/helpers/twigWrapper/Evaluator/index.d.ts +1 -1
- package/dist/helpers/twigWrapper/TemplateCache/TemplateCache.mjs +1 -1
- package/dist/helpers/twigWrapper/filters/filters.mjs +38 -2
- package/dist/helpers/twigWrapper/index.d.ts +1 -0
- package/dist/helpers/twigWrapper/processTwig/processTwig.d.ts +2 -1
- package/dist/helpers/twigWrapper/processTwig/processTwig.mjs +3 -3
- package/dist/helpers/utils.mjs +4 -2
- package/dist/history/describe.mjs +4 -1
- package/dist/history/diff.d.ts +1 -1
- package/dist/history/diff.mjs +11 -9
- package/dist/history/types.d.ts +1 -1
- package/dist/hooks/index.mjs +5 -5
- package/dist/hooks/usePlitziServiceContext.d.ts +1 -2
- package/dist/hooks/usePlitziServiceContext.mjs +3 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +90 -77
- package/dist/navigation/routes.mjs +6 -4
- package/dist/network/NetworkContext.mjs +2 -3
- package/dist/network/NetworkInternalContext.d.ts +2 -4
- package/dist/network/NetworkInternalContext.mjs +2 -3
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddSnippetMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddSnippetMutation.mjs +4 -0
- package/dist/network/graphql/builder/Mutations/Space/components/SpaceAddComponentMutation.d.ts +4 -0
- package/dist/network/graphql/builder/Mutations/Space/components/SpaceAddComponentMutation.mjs +4 -0
- package/dist/network/graphql/builder/Mutations/Space/components/SpaceDetachInstanceMutation.d.ts +4 -0
- package/dist/network/graphql/builder/Mutations/Space/components/SpaceDetachInstanceMutation.mjs +4 -0
- package/dist/network/graphql/builder/Mutations/Space/components/SpaceRemoveComponentMutation.d.ts +4 -0
- package/dist/network/graphql/builder/Mutations/Space/components/SpaceRemoveComponentMutation.mjs +4 -0
- package/dist/network/graphql/builder/Mutations/Space/components/SpaceUpdateComponentMutation.d.ts +4 -0
- package/dist/network/graphql/builder/Mutations/Space/components/SpaceUpdateComponentMutation.mjs +4 -0
- package/dist/network/graphql/builder/Mutations/Space/flags/SpacePublishFlagsMutation.d.ts +12 -0
- package/dist/network/graphql/builder/Mutations/Space/flags/SpacePublishFlagsMutation.mjs +4 -0
- package/dist/network/graphql/builder/Mutations/Space/flags/SpaceRemoveFlagMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/flags/SpaceRemoveFlagMutation.mjs +4 -0
- package/dist/network/graphql/builder/Mutations/Space/flags/SpaceSetFlagMutation.d.ts +3 -0
- package/dist/network/graphql/builder/Mutations/Space/flags/SpaceSetFlagMutation.mjs +4 -0
- package/dist/network/graphql/builder/Mutations/index.d.ts +13 -30
- package/dist/network/graphql/builder/Mutations/index.mjs +164 -200
- package/dist/network/graphql/builder/Queries/InitQuery.d.ts +4 -3
- package/dist/network/graphql/builder/Queries/InitQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceActionTasksQuery.d.ts +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceActionTasksQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.d.ts +16 -2
- package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.mjs +1 -1
- package/dist/network/graphql/builder/Queries/Space/SpaceVersionContentsQuery.d.ts +7 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceVersionContentsQuery.mjs +4 -0
- package/dist/network/graphql/builder/Queries/index.d.ts +3 -5
- package/dist/network/graphql/builder/Queries/index.mjs +36 -38
- package/dist/network/graphql/builder/Subscriptions/SpaceEventSubscription.d.ts +1 -1
- package/dist/network/graphql/sdk/Queries/InitQuery.d.ts +2 -3
- package/dist/network/graphql/sdk/Queries/InitQuery.mjs +1 -1
- package/dist/network/graphql/sdk/Queries/index.d.ts +0 -4
- package/dist/network/graphql/sdk/Queries/index.mjs +2 -8
- package/dist/network/index.mjs +8 -7
- package/dist/network/spaceEvents.d.ts +25 -195
- package/dist/network/spaceEvents.mjs +156 -241
- package/dist/realtime/client.mjs +123 -95
- package/dist/realtime/topics.mjs +18 -17
- package/dist/schema/SchemaContext.mjs +2 -3
- package/dist/schema/anchor.d.ts +8 -0
- package/dist/schema/anchor.mjs +4 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.mjs +6 -4
- package/dist/schema/schemaConstants.d.ts +2 -0
- package/dist/schema/schemaConstants.mjs +4 -3
- package/dist/schema/serverElements.d.ts +6 -2
- package/dist/schema/serverElements.mjs +17 -16
- package/dist/schema/snippet.d.ts +7 -0
- package/dist/schema/snippet.mjs +9 -0
- package/dist/schema/wire.d.ts +11 -0
- package/dist/schema/wire.mjs +27 -0
- package/dist/server/actions/useImagesSync.d.ts +9 -0
- package/dist/server/actions/useImagesSync.mjs +7 -0
- package/dist/server/rsc/refreshRsc.d.ts +3 -1
- package/dist/server/rsc/refreshRsc.mjs +17 -16
- package/dist/source/export.d.ts +107 -0
- package/dist/source/export.mjs +4 -0
- package/dist/source/index.d.ts +4 -0
- package/dist/source/index.mjs +3 -0
- package/dist/source/snapshot.d.ts +51 -0
- package/dist/source/snapshot.mjs +81 -0
- package/dist/state/paintedState.mjs +13 -12
- package/dist/state/runtimeStatePersist.mjs +50 -49
- package/dist/store/index.d.ts +45 -45
- package/dist/store/renderSettings.d.ts +1 -0
- package/dist/store/renderSettings.mjs +9 -5
- package/dist/style/breakpoints.d.ts +11 -0
- package/dist/style/breakpoints.mjs +8 -0
- package/dist/style/displayModes.d.ts +5 -0
- package/dist/style/displayModes.mjs +8 -0
- package/dist/style/fontValidation.mjs +52 -51
- package/dist/style/fonts.d.ts +0 -12
- package/dist/style/fonts.mjs +11 -11
- package/dist/style/index.d.ts +4 -0
- package/dist/style/index.mjs +11 -7
- package/dist/style/layoutGrid.d.ts +30 -0
- package/dist/style/layoutGrid.mjs +33 -0
- package/dist/style/notifications.d.ts +52 -0
- package/dist/style/notifications.mjs +55 -0
- package/dist/style/snippetStyle.d.ts +23 -0
- package/dist/style/snippetStyle.mjs +32 -0
- package/dist/style/styleConstants.d.ts +7 -2
- package/dist/style/styleConstants.mjs +10 -0
- package/dist/style/styleStates.d.ts +11 -2
- package/dist/style/styleStates.mjs +12 -9
- package/dist/theme/ThemeProvider.mjs +20 -20
- package/dist/theme/ThemeScope.mjs +4 -3
- package/dist/types/ActionTypes.d.ts +5 -0
- package/dist/types/CommonTypes.d.ts +3 -0
- package/dist/types/DevToolsTypes.d.ts +29 -4
- package/dist/types/ElementTypes.d.ts +6 -5
- package/dist/types/EventBridgeTypes.d.ts +2 -2
- package/dist/types/FunctionTypes.d.ts +13 -0
- package/dist/types/InteractionTypes.d.ts +5 -0
- package/dist/types/PluginTypes.d.ts +1 -1
- package/dist/types/ResourceTypes.d.ts +2 -2
- package/dist/types/SchemaTypes.d.ts +100 -3
- package/dist/types/SdkTypes.d.ts +0 -2
- package/dist/types/ServerTypes.d.ts +47 -0
- package/dist/types/SnippetTypes.d.ts +28 -0
- package/dist/types/SpaceTypes.d.ts +36 -0
- package/dist/types/StoreTypes.d.ts +39 -3
- package/dist/types/StyleTypes.d.ts +1 -1
- package/dist/types/index.d.ts +1 -2
- package/package.json +143 -138
- package/tailwind.config.js +1 -6
- package/vite.config.ts +16 -4
- package/dist/network/graphql/builder/Mutations/Segment/SegmentAddMutation.d.ts +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/SegmentAddMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/SegmentAddTemplateMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/SegmentAddTemplateMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/SegmentPublishMutation.d.ts +0 -8
- package/dist/network/graphql/builder/Mutations/Segment/SegmentPublishMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/SegmentRemoveMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/SegmentRemoveMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/SegmentUpdateMutation.d.ts +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/SegmentUpdateMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentAddElementMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentAddElementMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentCloneElementMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentCloneElementMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentMoveElementMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentMoveElementMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRemoveElementMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRemoveElementMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRenameElementMutation.d.ts +0 -3
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRenameElementMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementsMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementsMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceAddVariableMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceAddVariableMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceRemoveVariableMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceRemoveVariableMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceUpdateVariableMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceUpdateVariableMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleAddSelectorVariableMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleAddSelectorVariableMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleRemoveSelectorVariableMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleRemoveSelectorVariableMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleUpdateSelectorVariableMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleUpdateSelectorVariableMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleAddSelectorMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleAddSelectorMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorsMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorsMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleUpdateSelectorMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleUpdateSelectorMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleAddVariableMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleAddVariableMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleRemoveVariableMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleRemoveVariableMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleUpdateVariableMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleUpdateVariableMutation.mjs +0 -4
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddTemplateMutation.d.ts +0 -2
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddTemplateMutation.mjs +0 -4
- package/dist/network/graphql/builder/Queries/Segment/SegmentQuery.d.ts +0 -6
- package/dist/network/graphql/builder/Queries/Segment/SegmentQuery.mjs +0 -4
- package/dist/network/graphql/builder/Queries/Segment/SegmentsQuery.d.ts +0 -9
- package/dist/network/graphql/builder/Queries/Segment/SegmentsQuery.mjs +0 -4
- package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.d.ts +0 -6
- package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.mjs +0 -4
- package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.d.ts +0 -9
- package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.mjs +0 -4
- package/dist/segments/SegmentsContext.d.ts +0 -2
- package/dist/segments/SegmentsContext.mjs +0 -6
- package/dist/segments/index.d.ts +0 -3
- package/dist/segments/index.mjs +0 -2
- package/dist/types/SegmentTypes.d.ts +0 -41
- package/dist/types/TemplateTypes.d.ts +0 -20
- package/dist/types/TemplateTypes.mjs +0 -0
- /package/dist/types/{SegmentTypes.mjs → SnippetTypes.mjs} +0 -0
|
@@ -12,6 +12,9 @@ var e = (e, t = 2) => String(e).padStart(t, "0"), t = (t) => `${e(t.getHours())}
|
|
|
12
12
|
listeningParams;
|
|
13
13
|
#e = [];
|
|
14
14
|
#t = !1;
|
|
15
|
+
#n = /* @__PURE__ */ new Set();
|
|
16
|
+
#r = [];
|
|
17
|
+
recentLimit = 200;
|
|
15
18
|
constructor(e, t = 100) {
|
|
16
19
|
this.callbackInternal = e, this.pendingLimit = t;
|
|
17
20
|
}
|
|
@@ -24,6 +27,12 @@ var e = (e, t = 2) => String(e).padStart(t, "0"), t = (t) => `${e(t.getHours())}
|
|
|
24
27
|
this.pendingLogs = [];
|
|
25
28
|
}
|
|
26
29
|
}
|
|
30
|
+
addListener(e, { replay: t = !1 } = {}) {
|
|
31
|
+
if (t) for (let t of this.#r) e(t);
|
|
32
|
+
return this.#n.add(e), () => {
|
|
33
|
+
this.#n.delete(e);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
27
36
|
setCallbackAddProvider(e) {
|
|
28
37
|
this.callbackAddProvider = e;
|
|
29
38
|
}
|
|
@@ -33,9 +42,20 @@ var e = (e, t = 2) => String(e).padStart(t, "0"), t = (t) => `${e(t.getHours())}
|
|
|
33
42
|
flush(e = !1) {
|
|
34
43
|
this.logsListened = [], e && (this.pendingLogs = []);
|
|
35
44
|
}
|
|
36
|
-
#
|
|
45
|
+
#i(e, t, r, i) {
|
|
37
46
|
if (!this.callbackInternal && !n()) return;
|
|
38
47
|
let a = this.getTime(!0);
|
|
48
|
+
if (n()) {
|
|
49
|
+
let n = {
|
|
50
|
+
logType: e,
|
|
51
|
+
category: t,
|
|
52
|
+
message: r,
|
|
53
|
+
params: i,
|
|
54
|
+
time: a
|
|
55
|
+
};
|
|
56
|
+
this.#r.push(n), this.#r.length > this.recentLimit && this.#r.shift();
|
|
57
|
+
for (let e of this.#n) e(n);
|
|
58
|
+
}
|
|
39
59
|
if (!this.callbackInternal) {
|
|
40
60
|
this.pendingLogs.push({
|
|
41
61
|
logType: e,
|
|
@@ -58,9 +78,9 @@ var e = (e, t = 2) => String(e).padStart(t, "0"), t = (t) => `${e(t.getHours())}
|
|
|
58
78
|
message: r,
|
|
59
79
|
params: i,
|
|
60
80
|
time: a
|
|
61
|
-
}), this.#
|
|
81
|
+
}), this.#a()), this.logsListened.length > this.logsListenedLimit && this.logsListened.shift();
|
|
62
82
|
}
|
|
63
|
-
#
|
|
83
|
+
#a() {
|
|
64
84
|
this.#t || (this.#t = !0, queueMicrotask(() => {
|
|
65
85
|
this.#t = !1;
|
|
66
86
|
let e = this.callbackInternal, t = this.#e;
|
|
@@ -78,16 +98,16 @@ var e = (e, t = 2) => String(e).padStart(t, "0"), t = (t) => `${e(t.getHours())}
|
|
|
78
98
|
return e ? t(n) : n;
|
|
79
99
|
}
|
|
80
100
|
info(e, t, n) {
|
|
81
|
-
this.#
|
|
101
|
+
this.#i("info", e, t, n);
|
|
82
102
|
}
|
|
83
103
|
warning(e, t, n) {
|
|
84
|
-
this.#
|
|
104
|
+
this.#i("warning", e, t, n);
|
|
85
105
|
}
|
|
86
106
|
danger(e, t, n) {
|
|
87
|
-
this.#
|
|
107
|
+
this.#i("danger", e, t, n);
|
|
88
108
|
}
|
|
89
109
|
success(e, t, n) {
|
|
90
|
-
this.#
|
|
110
|
+
this.#i("success", e, t, n);
|
|
91
111
|
}
|
|
92
112
|
begin(e) {
|
|
93
113
|
this.listening = !0, this.listeningParams = { category: e };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cookie a tester forces flags with — the `qa` layer, the strongest there is.
|
|
3
|
+
*
|
|
4
|
+
* A cookie and not web storage for the reason the theme is one: the server renders with it, so the page a tester
|
|
5
|
+
* forced a flag on arrives drawn that way instead of being swapped after hydration. Named with the port, like the
|
|
6
|
+
* debug preference, because a cookie's scope has none (see `debugCookieName`).
|
|
7
|
+
*
|
|
8
|
+
* It is a preference that only means something where debugging is authorized. Everywhere else both halves ignore it
|
|
9
|
+
* — a published site's visitors could otherwise turn on any feature that is still behind a flag.
|
|
10
|
+
*/
|
|
11
|
+
export declare const flagsCookieName: (host: string | undefined) => string;
|
|
12
|
+
/**
|
|
13
|
+
* `newCheckout:1,legacyNav:0` — a flag name and its value, nothing else survives the parse. The cookie's format, and
|
|
14
|
+
* any other place flags are written as one line of text (an environment variable).
|
|
15
|
+
*/
|
|
16
|
+
export declare const parseFlagList: (value: string | undefined) => Record<string, boolean>;
|
|
17
|
+
export declare const serializeFlagList: (forced: Record<string, boolean>) => string;
|
|
18
|
+
/** What is forced once one flag is forced to `value` — or, with `undefined`, once it is no longer forced at all. */
|
|
19
|
+
export declare const withForcedFlag: (forced: Record<string, boolean>, name: string, value: boolean | undefined) => Record<string, boolean>;
|
|
20
|
+
/** The flags a tester forced, from a `Cookie` header or `document.cookie`. */
|
|
21
|
+
export declare const forcedFlagsFromCookies: (cookies: string | undefined, host: string | undefined) => Record<string, boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Keeps what a tester forced for the next page this browser asks for — every page of the site, so a forced feature is
|
|
24
|
+
* on wherever the tester goes, and the server draws it that way. Nothing forced removes the cookie.
|
|
25
|
+
*/
|
|
26
|
+
export declare const writeForcedFlags: (host: string, forced: Record<string, boolean>) => void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { cookieFromHeader as e } from "../helpers/cookies.mjs";
|
|
2
|
+
import { isFlagName as t } from "./schemaFlag.mjs";
|
|
3
|
+
//#region src/flags/flagsCookie.ts
|
|
4
|
+
var n = (e) => {
|
|
5
|
+
let t = e?.split(":")[1];
|
|
6
|
+
return t ? `plitzi_flags_${t}` : "plitzi_flags";
|
|
7
|
+
}, r = (e) => e ? Object.fromEntries(e.split(",").map((e) => e.split(":")).filter(([e, n]) => t(e) && (n === "1" || n === "0")).map(([e, t]) => [e, t === "1"])) : {}, i = (e) => Object.entries(e).filter(([e]) => t(e)).map(([e, t]) => `${e}:${t ? "1" : "0"}`).join(","), a = (e, t, n) => {
|
|
8
|
+
let { [t]: r, ...i } = e;
|
|
9
|
+
return n === void 0 ? i : {
|
|
10
|
+
...i,
|
|
11
|
+
[t]: n
|
|
12
|
+
};
|
|
13
|
+
}, o = (t, i) => r(e(t, n(i))), s = (e, t) => {
|
|
14
|
+
let r = n(e), a = i(t);
|
|
15
|
+
try {
|
|
16
|
+
document.cookie = a ? `${r}=${encodeURIComponent(a)};path=/;SameSite=Lax` : `${r}=;path=/;max-age=0;SameSite=Lax`;
|
|
17
|
+
} catch {}
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { n as flagsCookieName, o as forcedFlagsFromCookies, r as parseFlagList, i as serializeFlagList, a as withForcedFlag, s as writeForcedFlags };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FLAG_GATE_PATTERN as e, FLAG_NAME_PATTERN as t, isFlagName as n, isSchemaFlag as r } from "./schemaFlag.mjs";
|
|
2
|
+
import { flagsCookieName as i, forcedFlagsFromCookies as a, parseFlagList as o, serializeFlagList as s, withForcedFlag as c, writeForcedFlags as l } from "./flagsCookie.mjs";
|
|
3
|
+
import { FLAG_LAYERS as u, flagUserFromSSR as d, flagValues as f, hasConditions as p, passesFlagGate as m, resolveFlags as h, undeclaredFlagOverrides as g } from "./resolveFlags.mjs";
|
|
4
|
+
export { e as FLAG_GATE_PATTERN, u as FLAG_LAYERS, t as FLAG_NAME_PATTERN, d as flagUserFromSSR, f as flagValues, i as flagsCookieName, a as forcedFlagsFromCookies, p as hasConditions, n as isFlagName, r as isSchemaFlag, o as parseFlagList, m as passesFlagGate, h as resolveFlags, s as serializeFlagList, g as undeclaredFlagOverrides, c as withForcedFlag, l as writeForcedFlags };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { VariableScope } from '../dataSource/resolveVariables';
|
|
2
|
+
import { RuleGroup } from '../helpers/ruleEvaluator';
|
|
3
|
+
import { Schema, SSRUser } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Who decided a flag, weakest first: the space's own declaration, then the server rendering it, then the SDK
|
|
6
|
+
* embedding it, then a tester with the dev tools open. Each layer only ever answers for a flag the space declares.
|
|
7
|
+
*/
|
|
8
|
+
export declare const FLAG_LAYERS: readonly ["space", "server", "sdk", "qa"];
|
|
9
|
+
export type FlagLayer = (typeof FLAG_LAYERS)[number];
|
|
10
|
+
export type FlagOverrideLayer = Exclude<FlagLayer, 'space'>;
|
|
11
|
+
/** What each layer above the space says, by flag name. A layer that says nothing about a flag leaves it alone. */
|
|
12
|
+
export type FlagOverrides = Partial<Record<FlagOverrideLayer, Record<string, boolean>>>;
|
|
13
|
+
/** The visitor, as a flag's rule sees them: never a token, never anything the rules have no business matching on. */
|
|
14
|
+
export type FlagUser = {
|
|
15
|
+
authenticated: boolean;
|
|
16
|
+
email?: string;
|
|
17
|
+
username?: string;
|
|
18
|
+
roles?: string[];
|
|
19
|
+
};
|
|
20
|
+
/** The visitor a server resolved, as a flag's rule sees them — the same fields the browser's rules see. */
|
|
21
|
+
export declare const flagUserFromSSR: (user: Pick<SSRUser, "email" | "username" | "roles"> | undefined) => FlagUser;
|
|
22
|
+
/** What a flag's rules are matched against: everything a variable's are, and who is visiting. */
|
|
23
|
+
export type FlagScope = VariableScope & {
|
|
24
|
+
user?: FlagUser;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* One flag's answer, and where it came from: the layer that decided, and — when the space did — the index of the
|
|
28
|
+
* rule that matched, absent when it was the flag's own default. What the dev tools show beside the value.
|
|
29
|
+
*/
|
|
30
|
+
export type FlagResolution = {
|
|
31
|
+
value: boolean;
|
|
32
|
+
layer: FlagLayer;
|
|
33
|
+
rule?: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Whether a rule says anything at all. A rule just added in the builder has an empty group, and the evaluator reads
|
|
37
|
+
* an empty `and` as true — so an unfinished rule would turn the flag the moment it was added. It is skipped instead,
|
|
38
|
+
* and the linter says it is there.
|
|
39
|
+
*/
|
|
40
|
+
export declare const hasConditions: (when: unknown) => when is RuleGroup;
|
|
41
|
+
/**
|
|
42
|
+
* Every flag the space declares, resolved for this render: `{ newCheckout: { value: true, layer: 'space', rule: 0 } }`.
|
|
43
|
+
*
|
|
44
|
+
* The space answers first — the first of a flag's rules that matches, or its default — and each layer above it may
|
|
45
|
+
* replace that answer, in order. An override for a flag the space does not declare is not an answer to anything and
|
|
46
|
+
* is dropped here; {@link undeclaredFlagOverrides} names those so whoever set one can be told.
|
|
47
|
+
*/
|
|
48
|
+
export declare const resolveFlags: (declared: Schema["flags"], scope?: FlagScope, overrides?: FlagOverrides) => Record<string, FlagResolution>;
|
|
49
|
+
/** The answers alone, as the `flags` source publishes them: `{ newCheckout: true }`. */
|
|
50
|
+
export declare const flagValues: (resolutions: Record<string, FlagResolution>) => Record<string, boolean>;
|
|
51
|
+
/** Overrides naming a flag the space does not declare — each one a typo or a flag removed from the space. */
|
|
52
|
+
export declare const undeclaredFlagOverrides: (declared: Schema["flags"], overrides: FlagOverrides) => {
|
|
53
|
+
layer: FlagOverrideLayer;
|
|
54
|
+
name: string;
|
|
55
|
+
}[];
|
|
56
|
+
/** Whether a flag gate lets its element exist, given the flags as they resolved. An undeclared flag resolves off. */
|
|
57
|
+
export declare const passesFlagGate: (gate: {
|
|
58
|
+
name: string;
|
|
59
|
+
is: boolean;
|
|
60
|
+
} | undefined, values: Record<string, boolean>) => boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { evaluateRuleGroup as e } from "../helpers/ruleEvaluator.mjs";
|
|
2
|
+
//#region src/flags/resolveFlags.ts
|
|
3
|
+
var t = [
|
|
4
|
+
"space",
|
|
5
|
+
"server",
|
|
6
|
+
"sdk",
|
|
7
|
+
"qa"
|
|
8
|
+
], n = (e) => e ? {
|
|
9
|
+
authenticated: !0,
|
|
10
|
+
email: e.email,
|
|
11
|
+
username: e.username,
|
|
12
|
+
roles: e.roles
|
|
13
|
+
} : { authenticated: !1 }, r = [
|
|
14
|
+
"server",
|
|
15
|
+
"sdk",
|
|
16
|
+
"qa"
|
|
17
|
+
], i = (e) => typeof e == "object" && !!e && "rules" in e && Array.isArray(e.rules) && e.rules.some((e) => typeof e == "object" && !!e && !("enabled" in e && e.enabled === !1)), a = (t, n) => Array.isArray(t.rules) ? t.rules.findIndex((t) => i(t.when) && e(t.when, n)) : -1, o = (e, t) => {
|
|
18
|
+
let n = a(e, t);
|
|
19
|
+
return n === -1 ? {
|
|
20
|
+
value: e.value,
|
|
21
|
+
layer: "space"
|
|
22
|
+
} : {
|
|
23
|
+
value: e.rules[n].value,
|
|
24
|
+
layer: "space",
|
|
25
|
+
rule: n
|
|
26
|
+
};
|
|
27
|
+
}, s = (e, t = {}, n = {}) => Object.fromEntries(Object.entries(e ?? {}).map(([e, i]) => [e, r.reduce((t, r) => {
|
|
28
|
+
let i = n[r]?.[e];
|
|
29
|
+
return typeof i == "boolean" ? {
|
|
30
|
+
value: i,
|
|
31
|
+
layer: r
|
|
32
|
+
} : t;
|
|
33
|
+
}, o(i, t))])), c = (e) => Object.fromEntries(Object.entries(e).map(([e, { value: t }]) => [e, t])), l = (e, t) => r.flatMap((n) => Object.keys(t[n] ?? {}).filter((t) => !Object.hasOwn(e ?? {}, t)).map((e) => ({
|
|
34
|
+
layer: n,
|
|
35
|
+
name: e
|
|
36
|
+
}))), u = (e, t) => !e || (t[e.name] ?? !1) === e.is;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { t as FLAG_LAYERS, n as flagUserFromSSR, c as flagValues, i as hasConditions, u as passesFlagGate, s as resolveFlags, l as undeclaredFlagOverrides };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SchemaFlag } from '../types';
|
|
2
|
+
/** A flag name: what `{{ flags.<name> }}` reads, so it has to be a valid key in a template path. */
|
|
3
|
+
export declare const FLAG_NAME_PATTERN: RegExp;
|
|
4
|
+
/** A gate as authoring and MCP write it: `name` while the flag is on, `!name` while it is off. */
|
|
5
|
+
export declare const FLAG_GATE_PATTERN: RegExp;
|
|
6
|
+
export declare const isFlagName: (name: string) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Whether a value is a flag as the resolver reads it — what every writer checks before storing one: a mutation, the
|
|
9
|
+
* live channel, the linter. A rule's `when` has to be a group; whether it says anything is the linter's to warn about.
|
|
10
|
+
*/
|
|
11
|
+
export declare const isSchemaFlag: (value: unknown) => value is SchemaFlag;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { isRecord as e } from "../helpers/isRecord.mjs";
|
|
2
|
+
//#region src/flags/schemaFlag.ts
|
|
3
|
+
var t = "[A-Za-z_][A-Za-z0-9_]*", n = RegExp(`^${t}$`), r = RegExp(`^!?${t}$`), i = /* @__PURE__ */ new Set([
|
|
4
|
+
"__proto__",
|
|
5
|
+
"constructor",
|
|
6
|
+
"prototype"
|
|
7
|
+
]), a = (e) => n.test(e) && !i.has(e), o = (t) => e(t) && typeof t.value == "boolean" && (t.description === void 0 || typeof t.description == "string") && Array.isArray(t.rules) && t.rules.every((t) => e(t) && typeof t.value == "boolean" && e(t.when));
|
|
8
|
+
//#endregion
|
|
9
|
+
export { r as FLAG_GATE_PATTERN, n as FLAG_NAME_PATTERN, a as isFlagName, o as isSchemaFlag };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AuthContextValue } from '../types';
|
|
2
|
+
import { FlagResolution, FlagUser } from './resolveFlags';
|
|
3
|
+
/** The visitor as a flag's rule sees them, from what auth knows. */
|
|
4
|
+
export declare const flagUserFrom: ({ authenticated, user }: Partial<Pick<AuthContextValue, "authenticated" | "user">>) => FlagUser;
|
|
5
|
+
/**
|
|
6
|
+
* Every declared flag, resolved for where this render is and who is looking.
|
|
7
|
+
*
|
|
8
|
+
* What the `flags` source every element reads is published from. The router cannot wait for that source — it decides
|
|
9
|
+
* whether the page is gated off before any child renders — so it calls `resolveFlags` itself, with the same inputs.
|
|
10
|
+
* Stable while nothing changed, so the source is not written again on every navigation.
|
|
11
|
+
*/
|
|
12
|
+
declare const useFlagResolution: (auth: Partial<Pick<AuthContextValue, "authenticated" | "user">>) => Record<string, FlagResolution>;
|
|
13
|
+
export default useFlagResolution;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { resolveFlags as e } from "./resolveFlags.mjs";
|
|
2
|
+
import t from "../hooks/useStableValue.mjs";
|
|
3
|
+
import n from "../store/renderSettings.mjs";
|
|
4
|
+
import { useCommonStore as r } from "../store/index.mjs";
|
|
5
|
+
import { useMemo as i } from "react";
|
|
6
|
+
//#region src/flags/useFlagResolution.ts
|
|
7
|
+
var a = ({ authenticated: e, user: t }) => {
|
|
8
|
+
let n = t?.details, r = { authenticated: e === !0 };
|
|
9
|
+
return n ? {
|
|
10
|
+
...r,
|
|
11
|
+
email: n.email,
|
|
12
|
+
username: n.username,
|
|
13
|
+
roles: n.roles
|
|
14
|
+
} : r;
|
|
15
|
+
}, o = (o) => {
|
|
16
|
+
let { environment: s } = n(), [[c, l, u, d, f]] = r([
|
|
17
|
+
"schema.flags",
|
|
18
|
+
"navigation.routeParams",
|
|
19
|
+
"navigation.queryParams",
|
|
20
|
+
"navigation.hostname",
|
|
21
|
+
"flags.overrides"
|
|
22
|
+
]), { authenticated: p, user: m } = o, h = i(() => a({
|
|
23
|
+
authenticated: p,
|
|
24
|
+
user: m
|
|
25
|
+
}), [p, m]);
|
|
26
|
+
return t(i(() => e(c, {
|
|
27
|
+
environment: s,
|
|
28
|
+
hostname: d,
|
|
29
|
+
routeParams: l,
|
|
30
|
+
queryParams: u,
|
|
31
|
+
user: h
|
|
32
|
+
}, f), [
|
|
33
|
+
c,
|
|
34
|
+
s,
|
|
35
|
+
d,
|
|
36
|
+
l,
|
|
37
|
+
u,
|
|
38
|
+
h,
|
|
39
|
+
f
|
|
40
|
+
]));
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { o as default, a as flagUserFrom };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An event's target read as a DOM node. `instanceof Node` answers false for a target inside an iframe — each window has
|
|
3
|
+
* its own `Node` — and the builder listens on its canvas iframe's document, so these test the node's own type instead.
|
|
4
|
+
*/
|
|
5
|
+
export declare const isNodeTarget: (target: EventTarget | null) => target is Node;
|
|
6
|
+
/** An event's target as the node it is, for `contains`; null when it is not a node (a window, an XHR). */
|
|
7
|
+
export declare const nodeOf: (target: EventTarget | null) => Node | null;
|
|
8
|
+
export declare const isElementTarget: (target: EventTarget | null) => target is Element;
|
|
9
|
+
/** An event's target as the element it is, for `closest`; null when it is a text node or no node at all. */
|
|
10
|
+
export declare const elementOf: (target: EventTarget | null) => Element | null;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region src/helpers/eventTarget.ts
|
|
2
|
+
var e = (e) => e !== null && "nodeType" in e && typeof e.nodeType == "number", t = (t) => e(t) ? t : null, n = (t) => e(t) && t.nodeType === Node.ELEMENT_NODE, r = (e) => n(e) ? e : null;
|
|
3
|
+
//#endregion
|
|
4
|
+
export { r as elementOf, n as isElementTarget, e as isNodeTarget, t as nodeOf };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A remote picture resized by the server that renders the page — the one vocabulary both ends speak.
|
|
3
|
+
*
|
|
4
|
+
* The widths are a closed set rather than whatever a page asks for: each one is a file the server makes and keeps,
|
|
5
|
+
* so a free width would let anybody fill its disk one request at a time.
|
|
6
|
+
*/
|
|
7
|
+
/** Where a page server that resizes images answers. */
|
|
8
|
+
export declare const IMAGE_PATH = "/_plitzi/img";
|
|
9
|
+
/** Every width a picture is offered at, narrowest first. */
|
|
10
|
+
export declare const IMAGE_WIDTHS: readonly [320, 480, 640, 768, 960, 1280, 1600, 1920];
|
|
11
|
+
export type ImageWidth = (typeof IMAGE_WIDTHS)[number];
|
|
12
|
+
export declare const isImageWidth: (width: number) => width is ImageWidth;
|
|
13
|
+
/** A picture another site serves — the only kind there is anything to resize; a path of this site is served as it is. */
|
|
14
|
+
export declare const isRemoteImage: (src: string) => boolean;
|
|
15
|
+
/** The address of `src` at `width` on the endpoint. */
|
|
16
|
+
export declare const imageUrl: (endpoint: string, src: string, width: ImageWidth) => string;
|
|
17
|
+
/** Every width as a `srcset`, for the browser to pick the one its layout needs. */
|
|
18
|
+
export declare const imageSrcSet: (endpoint: string, src: string) => string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/helpers/images.ts
|
|
2
|
+
var e = "/_plitzi/img", t = [
|
|
3
|
+
320,
|
|
4
|
+
480,
|
|
5
|
+
640,
|
|
6
|
+
768,
|
|
7
|
+
960,
|
|
8
|
+
1280,
|
|
9
|
+
1600,
|
|
10
|
+
1920
|
|
11
|
+
], n = (e) => t.some((t) => t === e), r = (e) => /^https?:\/\//i.test(e), i = (e, t, n) => `${e}?url=${encodeURIComponent(t)}&w=${String(n)}`, a = (e, n) => t.map((t) => `${i(e, n, t)} ${String(t)}w`).join(", ");
|
|
12
|
+
//#endregion
|
|
13
|
+
export { e as IMAGE_PATH, t as IMAGE_WIDTHS, a as imageSrcSet, i as imageUrl, n as isImageWidth, r as isRemoteImage };
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -2,9 +2,12 @@ import { default as fetchManifest } from './fetchManifest';
|
|
|
2
2
|
import { default as generateFacade } from './generateFacade';
|
|
3
3
|
import { default as syntaxHighlight } from './syntaxHighlight';
|
|
4
4
|
export * from './cookies';
|
|
5
|
+
export * from './eventTarget';
|
|
5
6
|
export * from './fetchManifest';
|
|
6
7
|
export * from './formatDate';
|
|
8
|
+
export * from './interval';
|
|
7
9
|
export * from './isDate';
|
|
10
|
+
export * from './isRecord';
|
|
8
11
|
export * from './generateFacade';
|
|
9
12
|
export * from './reducerOrigin';
|
|
10
13
|
export * from './ruleEvaluator';
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import d from "./
|
|
9
|
-
import f from "./
|
|
10
|
-
import p from "./
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
1
|
+
import { isRecord as e } from "./isRecord.mjs";
|
|
2
|
+
import { filters as t } from "./twigWrapper/filters/filters.mjs";
|
|
3
|
+
import { processTwig as n, processTwigParam as r, processTwigValue as i } from "./twigWrapper/processTwig/processTwig.mjs";
|
|
4
|
+
import { hasTemplateSyntax as a } from "./twigWrapper/tokens/hasTemplateSyntax.mjs";
|
|
5
|
+
import { hasValidToken as o } from "./twigWrapper/tokens/hasValidToken.mjs";
|
|
6
|
+
import { MAX_PARAM_PASSES as s, resolveStepParam as c } from "./twigWrapper/processTwig/resolveStepParam.mjs";
|
|
7
|
+
import { inspectTemplate as l } from "./twigWrapper/inspectTemplate.mjs";
|
|
8
|
+
import { templatePaths as u, templateRootNames as d } from "./twigWrapper/templateRoots.mjs";
|
|
9
|
+
import f from "./fetchManifest.mjs";
|
|
10
|
+
import p from "./generateFacade.mjs";
|
|
11
|
+
import m from "./syntaxHighlight.mjs";
|
|
12
|
+
import { cookieFromHeader as h, documentCookies as g } from "./cookies.mjs";
|
|
13
|
+
import { elementOf as _, isElementTarget as v, isNodeTarget as y, nodeOf as b } from "./eventTarget.mjs";
|
|
14
|
+
import { formatDate as x, formatDateUTC as S, formatFromNow as C, formatUTCToLocal as w, getDurationMs as T, isValidFormat as E, parseDate as D, toUnixSeconds as O } from "./formatDate.mjs";
|
|
15
|
+
import { INTERVAL_TRIGGER as k, MIN_INTERVAL_MS as A, intervalOf as j } from "./interval.mjs";
|
|
16
|
+
import { isDate as M } from "./isDate.mjs";
|
|
17
|
+
import { isUserEdit as N } from "./reducerOrigin.mjs";
|
|
18
|
+
import { evaluateRuleGroup as P } from "./ruleEvaluator.mjs";
|
|
19
|
+
import { ParamsFromURL as F, delay as I, emptyObject as L, getDisplayName as R, getKeyDecoded as z, getPathsFromObeject as B, hexToRGB as V, isInViewport as H, makeId as U } from "./utils.mjs";
|
|
20
|
+
import { disableReactDevTools as W } from "./security.mjs";
|
|
21
|
+
export { k as INTERVAL_TRIGGER, s as MAX_PARAM_PASSES, A as MIN_INTERVAL_MS, F as ParamsFromURL, h as cookieFromHeader, I as delay, W as disableReactDevTools, g as documentCookies, _ as elementOf, L as emptyObject, P as evaluateRuleGroup, f as fetchManifest, t as filters, x as formatDate, S as formatDateUTC, C as formatFromNow, w as formatUTCToLocal, p as generateFacade, R as getDisplayName, T as getDurationMs, z as getKeyDecoded, B as getPathsFromObeject, a as hasTemplateSyntax, o as hasValidToken, V as hexToRGB, l as inspectTemplate, j as intervalOf, M as isDate, v as isElementTarget, H as isInViewport, y as isNodeTarget, e as isRecord, N as isUserEdit, E as isValidFormat, U as makeId, b as nodeOf, D as parseDate, n as processTwig, r as processTwigParam, i as processTwigValue, c as resolveStepParam, m as syntaxHighlight, u as templatePaths, d as templateRootNames, O as toUnixSeconds };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repeating a flow every so often — an autoplay, a clock, a poll of something on the page — with no plugin to write.
|
|
3
|
+
*
|
|
4
|
+
* The element listening, the interactions manager and authoring read this one module, so the trigger's name, its
|
|
5
|
+
* floor and what it carries cannot drift between them.
|
|
6
|
+
*/
|
|
7
|
+
/** The trigger a repeating flow starts on: fired once per tick of each interval its element's flows declare. */
|
|
8
|
+
export declare const INTERVAL_TRIGGER = "onInterval";
|
|
9
|
+
/** Below a quarter of a second, a flow that repeats is a busy loop that happens to wait. */
|
|
10
|
+
export declare const MIN_INTERVAL_MS = 250;
|
|
11
|
+
export type IntervalTriggerPayload = {
|
|
12
|
+
/** The interval that ticked, in milliseconds: the flows that run are the ones declared with it. */
|
|
13
|
+
interval: number;
|
|
14
|
+
/** How many times it has ticked since the element appeared — `{{ tick.count }}` with `named('tick', …)`. */
|
|
15
|
+
count: number;
|
|
16
|
+
};
|
|
17
|
+
/** An interval a flow declares, read as the trigger reads it: a whole number of milliseconds, at least the floor. */
|
|
18
|
+
export declare const intervalOf: (value: unknown) => number | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/helpers/interval.ts
|
|
2
|
+
var e = "onInterval", t = 250, n = (e) => {
|
|
3
|
+
let t = typeof e == "string" && e.trim() !== "" ? Number(e) : e;
|
|
4
|
+
return typeof t == "number" && Number.isInteger(t) && t >= 250 ? t : void 0;
|
|
5
|
+
};
|
|
6
|
+
//#endregion
|
|
7
|
+
export { e as INTERVAL_TRIGGER, t as MIN_INTERVAL_MS, n as intervalOf };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the scroll steps and the `onScroll` trigger read and write, as plain arithmetic over a box's sizes — so the
|
|
3
|
+
* meaning of `'80%'` or `'end'` is decided once, and tested without a browser.
|
|
4
|
+
*/
|
|
5
|
+
/** A box that scrolls, measured: what `Element` has, and all these functions read. */
|
|
6
|
+
export type ScrollBox = {
|
|
7
|
+
scrollLeft: number;
|
|
8
|
+
scrollTop: number;
|
|
9
|
+
scrollWidth: number;
|
|
10
|
+
scrollHeight: number;
|
|
11
|
+
clientWidth: number;
|
|
12
|
+
clientHeight: number;
|
|
13
|
+
};
|
|
14
|
+
/** What `onScroll` hands its flow: where the box is, and whether it is at either end of the way it scrolls. */
|
|
15
|
+
export type ScrollTriggerPayload = {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
atStart: boolean;
|
|
19
|
+
atEnd: boolean;
|
|
20
|
+
};
|
|
21
|
+
export declare const SCROLL_BEHAVIORS: readonly ["smooth", "auto"];
|
|
22
|
+
export type ScrollStepBehavior = (typeof SCROLL_BEHAVIORS)[number];
|
|
23
|
+
/** Where `scrollIntoView` lands an element, on each axis. */
|
|
24
|
+
export declare const SCROLL_POSITIONS: readonly ["start", "center", "end", "nearest"];
|
|
25
|
+
export type ScrollStepPosition = (typeof SCROLL_POSITIONS)[number];
|
|
26
|
+
/**
|
|
27
|
+
* A distance to move: pixels (`240`, `'240'`, `'240px'`) or a share of what the box shows (`'80%'` of its width) —
|
|
28
|
+
* negative goes back. `undefined` for nothing to move, or for text that is not a length.
|
|
29
|
+
*/
|
|
30
|
+
export declare const scrollDistance: (value: unknown, visible: number) => number | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* A place to go to on one axis: `'start'`, `'end'`, pixels from the start, or a share of the whole way (`'50%'` is
|
|
33
|
+
* half-way). `undefined` leaves that axis where it is.
|
|
34
|
+
*/
|
|
35
|
+
export declare const scrollPosition: (value: unknown, scrollSize: number, clientSize: number) => number | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Where a box is, for `onScroll`. The ends are those of the way it scrolls — across for a row wider than its box,
|
|
38
|
+
* down otherwise — which is what an arrow that hides at the end of a carousel asks.
|
|
39
|
+
*/
|
|
40
|
+
export declare const scrollState: (box: ScrollBox) => ScrollTriggerPayload;
|
|
41
|
+
/** The trigger a scroll fires, its action name in a flow. */
|
|
42
|
+
export declare const SCROLL_TRIGGER = "onScroll";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/helpers/scroll.ts
|
|
2
|
+
var e = ["smooth", "auto"], t = [
|
|
3
|
+
"start",
|
|
4
|
+
"center",
|
|
5
|
+
"end",
|
|
6
|
+
"nearest"
|
|
7
|
+
], n = 1, r = /^(-?\d+(?:\.\d+)?)(px|%)?$/, i = (e, t) => {
|
|
8
|
+
if (typeof e == "number") return Number.isFinite(e) ? e : void 0;
|
|
9
|
+
if (typeof e != "string") return;
|
|
10
|
+
let n = r.exec(e.trim());
|
|
11
|
+
if (!n) return;
|
|
12
|
+
let i = Number(n[1]);
|
|
13
|
+
return n[2] === "%" ? i / 100 * t : i;
|
|
14
|
+
}, a = (e, t, n) => {
|
|
15
|
+
let r = Math.max(t - n, 0);
|
|
16
|
+
if (e === "start") return 0;
|
|
17
|
+
if (e === "end") return r;
|
|
18
|
+
let a = i(e, r);
|
|
19
|
+
return a === void 0 ? void 0 : Math.min(Math.max(a, 0), r);
|
|
20
|
+
}, o = (e) => {
|
|
21
|
+
let t = e.scrollWidth - e.clientWidth > n, r = t ? e.scrollLeft : e.scrollTop, i = t ? e.scrollWidth - e.clientWidth : e.scrollHeight - e.clientHeight;
|
|
22
|
+
return {
|
|
23
|
+
x: Math.round(e.scrollLeft),
|
|
24
|
+
y: Math.round(e.scrollTop),
|
|
25
|
+
atStart: r <= n,
|
|
26
|
+
atEnd: r >= i - n
|
|
27
|
+
};
|
|
28
|
+
}, s = "onScroll";
|
|
29
|
+
//#endregion
|
|
30
|
+
export { e as SCROLL_BEHAVIORS, t as SCROLL_POSITIONS, s as SCROLL_TRIGGER, i as scrollDistance, a as scrollPosition, o as scrollState };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Context } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A React context every copy of the Plitzi runtime on a page agrees on.
|
|
4
|
+
*
|
|
5
|
+
* One page can hold more than one copy. The builder carries its own and renders a space's elements with it, while a
|
|
6
|
+
* remote plugin imports `@plitzi/plitzi-sdk` — the SDK's copy — through the page's import map; the builder embedded in
|
|
7
|
+
* Plitzi's own site is a third, the site's. A context made with `createContext` belongs to the copy that made it, so a
|
|
8
|
+
* plugin in the builder's canvas read none of the canvas's providers: it fell through to the site around the builder,
|
|
9
|
+
* took its element for the plugin's own, its live mode for the editor's and its store for the space's.
|
|
10
|
+
*
|
|
11
|
+
* Made once per page, under `name`, by whichever copy asks first, and handed to every other: a provider from any copy
|
|
12
|
+
* is then seen by a consumer from any copy, and the nearest one wins as it should.
|
|
13
|
+
*/
|
|
14
|
+
export declare const sharedContext: <T>(name: string, defaultValue: T) => Context<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createContext as e } from "react";
|
|
2
|
+
var t = Symbol.for("plitzi.sharedContexts.v1"), n = (e) => (e[t] ??= /* @__PURE__ */ new Map(), e[t]), r = (t, r) => {
|
|
3
|
+
let i = n(globalThis), a = i.get(t);
|
|
4
|
+
if (a) return a;
|
|
5
|
+
let o = e(r);
|
|
6
|
+
return o.displayName = t, i.set(t, o), o;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { r as sharedContext };
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { ASTNode, Expression } from '../AST';
|
|
2
|
+
/**
|
|
3
|
+
* Which empty tokens a render hands back as their own text, for a later pass that knows more: none, every one, or
|
|
4
|
+
* every one but those reading a SETTLED source — one whose value is final when the render runs, so that nothing later
|
|
5
|
+
* will fill it in. A component's `props` is one: every declared prop is in it, and an empty one is an answer.
|
|
6
|
+
*/
|
|
7
|
+
export type KeepEmptyTokens = boolean | {
|
|
8
|
+
settled: ReadonlySet<string>;
|
|
9
|
+
};
|
|
2
10
|
export type EvalResult = {
|
|
3
11
|
readonly output: string;
|
|
4
12
|
readonly variables: Record<string, unknown>;
|
|
@@ -12,6 +20,6 @@ export type EvalResult = {
|
|
|
12
20
|
* that document, not text the reader has to give up on. A value printed anywhere else is printed as always: it IS the
|
|
13
21
|
* JSON value there (`"seen": {{ count }}`).
|
|
14
22
|
*/
|
|
15
|
-
export declare const evaluate: (nodes: readonly ASTNode[], context: Record<string, unknown>, keepEmptyTokens?:
|
|
23
|
+
export declare const evaluate: (nodes: readonly ASTNode[], context: Record<string, unknown>, keepEmptyTokens?: KeepEmptyTokens, jsonStrings?: boolean) => EvalResult;
|
|
16
24
|
/** One expression's value, as it is — not rendered to text. What `processTwigValue` answers a `{{ expr }}` with. */
|
|
17
25
|
export declare const evaluateExpression: (expression: Expression, context: Record<string, unknown>) => unknown;
|