@plitzi/sdk-shared 0.37.2 → 0.37.3
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 +1146 -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 -0
- package/dist/auth/index.mjs +2 -1
- 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 -0
- package/dist/helpers/index.mjs +18 -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 +77 -66
- 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/Space/SpaceFixIssuesMutation.d.ts +14 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceFixIssuesMutation.mjs +16 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdatePluginMutation.d.ts +4 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdatePluginMutation.mjs +2 -2
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRunActionMutation.mjs +1 -0
- 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/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/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/index.d.ts +28 -0
- package/dist/network/graphql/builder/Mutations/index.mjs +108 -84
- 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/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/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/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 +172 -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
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { formatDate as e } from "../../helpers/formatDate.mjs";
|
|
2
1
|
//#region src/devTools/utils/PlitziConsole.ts
|
|
3
|
-
var t = class {
|
|
2
|
+
var e = (e, t = 2) => String(e).padStart(t, "0"), t = (t) => `${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(), 3)}`, n = () => typeof window < "u", r = class {
|
|
4
3
|
callbackInternal;
|
|
5
4
|
callbackAddProvider;
|
|
6
5
|
callbackRemoveProvider;
|
|
@@ -34,30 +33,31 @@ var t = class {
|
|
|
34
33
|
flush(e = !1) {
|
|
35
34
|
this.logsListened = [], e && (this.pendingLogs = []);
|
|
36
35
|
}
|
|
37
|
-
#n(e, t,
|
|
38
|
-
|
|
36
|
+
#n(e, t, r, i) {
|
|
37
|
+
if (!this.callbackInternal && !n()) return;
|
|
38
|
+
let a = this.getTime(!0);
|
|
39
39
|
if (!this.callbackInternal) {
|
|
40
40
|
this.pendingLogs.push({
|
|
41
41
|
logType: e,
|
|
42
42
|
category: t,
|
|
43
|
-
message:
|
|
44
|
-
params:
|
|
45
|
-
time:
|
|
43
|
+
message: r,
|
|
44
|
+
params: i,
|
|
45
|
+
time: a
|
|
46
46
|
}), this.pendingLogs.length > this.pendingLimit && this.pendingLogs.shift();
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
this.listening ? this.logsListened.push({
|
|
50
50
|
logType: e,
|
|
51
51
|
category: t,
|
|
52
|
-
message:
|
|
53
|
-
params:
|
|
54
|
-
time:
|
|
52
|
+
message: r,
|
|
53
|
+
params: i,
|
|
54
|
+
time: a
|
|
55
55
|
}) : (this.#e.push({
|
|
56
56
|
logType: e,
|
|
57
57
|
category: t,
|
|
58
|
-
message:
|
|
59
|
-
params:
|
|
60
|
-
time:
|
|
58
|
+
message: r,
|
|
59
|
+
params: i,
|
|
60
|
+
time: a
|
|
61
61
|
}), this.#r()), this.logsListened.length > this.logsListenedLimit && this.logsListened.shift();
|
|
62
62
|
}
|
|
63
63
|
#r() {
|
|
@@ -73,9 +73,9 @@ var t = class {
|
|
|
73
73
|
removeProviderMethod(e) {
|
|
74
74
|
typeof this.callbackRemoveProvider == "function" && this.callbackRemoveProvider(e);
|
|
75
75
|
}
|
|
76
|
-
getTime(
|
|
76
|
+
getTime(e = !1) {
|
|
77
77
|
let n = /* @__PURE__ */ new Date();
|
|
78
|
-
return
|
|
78
|
+
return e ? t(n) : n;
|
|
79
79
|
}
|
|
80
80
|
info(e, t, n) {
|
|
81
81
|
this.#n("info", e, t, n);
|
|
@@ -95,16 +95,16 @@ var t = class {
|
|
|
95
95
|
end() {
|
|
96
96
|
this.listening = !1, this.listeningCategory && this.logsListened.length > 0 && this.callbackInternal?.("info", this.listeningCategory, `${this.logsListened.length} Log${this.logsListened.length === 1 ? "" : "s"}`, { logs: this.logsListened }), this.logsListened = [], this.listeningCategory = void 0;
|
|
97
97
|
}
|
|
98
|
-
},
|
|
99
|
-
function
|
|
100
|
-
return ({ path: t, prevValue:
|
|
101
|
-
|
|
98
|
+
}, i = new r();
|
|
99
|
+
function a(e = "store") {
|
|
100
|
+
return ({ path: t, prevValue: n, nextValue: r }) => {
|
|
101
|
+
i.info("store", e, {
|
|
102
102
|
storeName: e,
|
|
103
103
|
path: t,
|
|
104
|
-
prev:
|
|
105
|
-
next:
|
|
104
|
+
prev: n,
|
|
105
|
+
next: r
|
|
106
106
|
});
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
109
|
//#endregion
|
|
110
|
-
export {
|
|
110
|
+
export { a as createStoreDevToolsLogger, r as default, i as pConsole };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One cookie's value out of a `Cookie` header — or out of `document.cookie`, which is written the same way.
|
|
3
|
+
*
|
|
4
|
+
* One function for both halves of the SDK, because the cookies it reads this way are the ones a server reads to render
|
|
5
|
+
* what the browser is about to hydrate: two parsers are two chances to disagree about a value, and a disagreement there
|
|
6
|
+
* is a page thrown away and drawn again. Undecodable values answer `undefined`, like absent ones.
|
|
7
|
+
*/
|
|
8
|
+
export declare const cookieFromHeader: (header: string | undefined, name: string) => string | undefined;
|
|
9
|
+
/** `document.cookie`, or nothing where there is no document or it may not be read (a sandboxed frame throws). */
|
|
10
|
+
export declare const documentCookies: () => string | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/helpers/cookies.ts
|
|
2
|
+
var e = (e, t) => {
|
|
3
|
+
if (e) for (let n of e.split(";")) {
|
|
4
|
+
let e = n.indexOf("=");
|
|
5
|
+
if (e > -1 && n.slice(0, e).trim() === t) try {
|
|
6
|
+
return decodeURIComponent(n.slice(e + 1).trim());
|
|
7
|
+
} catch {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}, t = () => {
|
|
12
|
+
try {
|
|
13
|
+
return typeof document > "u" ? void 0 : document.cookie;
|
|
14
|
+
} catch {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { e as cookieFromHeader, t as documentCookies };
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A plugin's `plugin-manifest.json`, or `undefined` when it cannot be had.
|
|
3
|
+
*
|
|
4
|
+
* Plugins live on hosts of their own — a CDN, a bucket, the builder's resources — so this is nearly always a
|
|
5
|
+
* cross-origin request, and it is kept a SIMPLE one: `Accept` says what is wanted, where the `Content-Type` this used to
|
|
6
|
+
* send (on a GET, with no body to describe) made the browser ask the host's permission first. A host that allows plain
|
|
7
|
+
* cross-origin reads — the usual CORS setting of a bucket — refused that preflight, and the element rendered "Not
|
|
8
|
+
* Found" with the manifest sitting right there.
|
|
9
|
+
*/
|
|
1
10
|
declare const fetchManifest: <T extends object>(manifestUrl: string) => Promise<T | undefined>;
|
|
2
11
|
export default fetchManifest;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
//#region src/helpers/fetchManifest.ts
|
|
2
2
|
var e = async (e) => {
|
|
3
|
-
let t;
|
|
4
3
|
try {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
headers: { "Content-Type": "application/json" }
|
|
8
|
-
})).json(), t;
|
|
4
|
+
let t = await fetch(e, { headers: { Accept: "application/json" } });
|
|
5
|
+
return t.ok ? await t.json() : void 0;
|
|
9
6
|
} catch {
|
|
10
|
-
return
|
|
7
|
+
return;
|
|
11
8
|
}
|
|
12
9
|
};
|
|
13
10
|
//#endregion
|
|
@@ -25,7 +25,11 @@ export declare const parseDate: (date: string | number | Date) => Date;
|
|
|
25
25
|
*/
|
|
26
26
|
export declare function formatDate(date?: string | number | Date, formatStr?: string, locale?: SupportedLocale): string;
|
|
27
27
|
export declare function formatDateUTC(date?: string | number | Date, formatStr?: string, locale?: SupportedLocale): string;
|
|
28
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Formats a UTC timestamp/string in the local timezone. A `Date` is an instant and `format` reads its local fields, so
|
|
30
|
+
* there is nothing to convert: moving it first is what printed the repeated hour at the end of daylight saving time an
|
|
31
|
+
* hour off.
|
|
32
|
+
*/
|
|
29
33
|
export declare function formatUTCToLocal(date?: string | number | Date, formatStr?: string, locale?: SupportedLocale): string;
|
|
30
34
|
/**
|
|
31
35
|
* Returns the difference between two dates in milliseconds
|
|
@@ -52,5 +56,3 @@ export declare function getDurationMs(start: string | number | Date, end: string
|
|
|
52
56
|
export declare function formatFromNow(date?: string | number | Date, locale?: SupportedLocale, options?: FormatDistanceToNowOptions): string;
|
|
53
57
|
export declare function isValidFormat(formatStr: string): boolean;
|
|
54
58
|
export declare const toUnixSeconds: (input: string | number | Date) => string;
|
|
55
|
-
/** Strictly validates whether a string matches a given date-fns format. */
|
|
56
|
-
export declare function isDate(value: string, formatStr: string): boolean;
|
|
@@ -1,58 +1,56 @@
|
|
|
1
|
-
import { differenceInMilliseconds as e
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { differenceInMilliseconds as e } from "date-fns/differenceInMilliseconds";
|
|
2
|
+
import { format as t } from "date-fns/format";
|
|
3
|
+
import { formatDistanceToNow as n } from "date-fns/formatDistanceToNow";
|
|
4
|
+
import { getTime as r } from "date-fns/getTime";
|
|
5
|
+
import { enUS as i } from "date-fns/locale/en-US";
|
|
6
|
+
import { es as a } from "date-fns/locale/es";
|
|
7
|
+
import { pt as o } from "date-fns/locale/pt";
|
|
8
|
+
import { parseISO as s } from "date-fns/parseISO";
|
|
4
9
|
//#region src/helpers/formatDate.ts
|
|
5
|
-
var
|
|
6
|
-
en:
|
|
7
|
-
es:
|
|
8
|
-
pt:
|
|
9
|
-
},
|
|
10
|
+
var c = {
|
|
11
|
+
en: i,
|
|
12
|
+
es: a,
|
|
13
|
+
pt: o
|
|
14
|
+
}, l = (e) => {
|
|
10
15
|
let t;
|
|
11
|
-
return t = typeof e == "number" ? e < 0xe8d4a51000 ? /* @__PURE__ */ new Date(e * 1e3) : new Date(e) : typeof e == "string" ?
|
|
16
|
+
return t = typeof e == "number" ? e < 0xe8d4a51000 ? /* @__PURE__ */ new Date(e * 1e3) : new Date(e) : typeof e == "string" ? s(e) : e, t;
|
|
12
17
|
};
|
|
13
|
-
function
|
|
18
|
+
function u(e, n = "dd MMMM, yyyy", r = "en") {
|
|
14
19
|
if (!e) return "";
|
|
15
|
-
let i =
|
|
16
|
-
return t(i, n, { locale:
|
|
20
|
+
let i = l(e);
|
|
21
|
+
return t(i, n, { locale: c[r] });
|
|
17
22
|
}
|
|
18
|
-
|
|
23
|
+
var d = (e) => {
|
|
24
|
+
let t = new Date(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate(), e.getUTCHours(), e.getUTCMinutes(), e.getUTCSeconds(), e.getUTCMilliseconds());
|
|
25
|
+
return t.setFullYear(e.getUTCFullYear()), t;
|
|
26
|
+
};
|
|
27
|
+
function f(e, n = "dd MMMM, yyyy", r = "en") {
|
|
19
28
|
if (!e) return "";
|
|
20
|
-
let i =
|
|
21
|
-
return t(
|
|
29
|
+
let i = l(e);
|
|
30
|
+
return t(d(i), n, { locale: c[r] });
|
|
22
31
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
let i = f(e), a = Intl.DateTimeFormat().resolvedOptions().timeZone, o = u(i, a);
|
|
26
|
-
return t(o, n, { locale: d[r] });
|
|
32
|
+
function p(e, n = "dd MMMM, yyyy HH:mm", r = "en") {
|
|
33
|
+
return e ? t(l(e), n, { locale: c[r] }) : "";
|
|
27
34
|
}
|
|
28
|
-
function
|
|
29
|
-
let r =
|
|
35
|
+
function m(t, n) {
|
|
36
|
+
let r = l(t), i = l(n);
|
|
30
37
|
return e(i, r);
|
|
31
38
|
}
|
|
32
|
-
function
|
|
39
|
+
function h(e, t = "en", r) {
|
|
33
40
|
if (!e) return "";
|
|
34
|
-
let i =
|
|
41
|
+
let i = l(e);
|
|
35
42
|
return isNaN(i.getTime()) ? "" : n(i, {
|
|
36
43
|
...r,
|
|
37
|
-
locale:
|
|
44
|
+
locale: c[t]
|
|
38
45
|
});
|
|
39
46
|
}
|
|
40
|
-
function
|
|
47
|
+
function g(e) {
|
|
41
48
|
try {
|
|
42
49
|
return t(/* @__PURE__ */ new Date(), e), !0;
|
|
43
50
|
} catch {
|
|
44
51
|
return !1;
|
|
45
52
|
}
|
|
46
53
|
}
|
|
47
|
-
var
|
|
48
|
-
function b(e, n) {
|
|
49
|
-
if (typeof e != "string") return !1;
|
|
50
|
-
try {
|
|
51
|
-
let r = a(e, n, /* @__PURE__ */ new Date());
|
|
52
|
-
return i(r) ? t(r, n) === e : !1;
|
|
53
|
-
} catch {
|
|
54
|
-
return !1;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
54
|
+
var _ = (e) => Math.floor(r(l(e)) / 1e3).toString();
|
|
57
55
|
//#endregion
|
|
58
|
-
export {
|
|
56
|
+
export { u as formatDate, f as formatDateUTC, h as formatFromNow, p as formatUTCToLocal, m as getDurationMs, g as isValidFormat, l as parseDate, _ as toUnixSeconds };
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { default as fetchManifest } from './fetchManifest';
|
|
2
2
|
import { default as generateFacade } from './generateFacade';
|
|
3
3
|
import { default as syntaxHighlight } from './syntaxHighlight';
|
|
4
|
+
export * from './cookies';
|
|
4
5
|
export * from './fetchManifest';
|
|
5
6
|
export * from './formatDate';
|
|
7
|
+
export * from './isDate';
|
|
6
8
|
export * from './generateFacade';
|
|
7
9
|
export * from './reducerOrigin';
|
|
8
10
|
export * from './ruleEvaluator';
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { filters as e } from "./twigWrapper/filters/filters.mjs";
|
|
2
|
-
import { processTwig as t } from "./twigWrapper/processTwig/processTwig.mjs";
|
|
3
|
-
import { hasTemplateSyntax as
|
|
4
|
-
import { hasValidToken as
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
2
|
+
import { processTwig as t, processTwigParam as n, processTwigValue as r } from "./twigWrapper/processTwig/processTwig.mjs";
|
|
3
|
+
import { hasTemplateSyntax as i } from "./twigWrapper/tokens/hasTemplateSyntax.mjs";
|
|
4
|
+
import { hasValidToken as a } from "./twigWrapper/tokens/hasValidToken.mjs";
|
|
5
|
+
import { MAX_PARAM_PASSES as o, resolveStepParam as s } from "./twigWrapper/processTwig/resolveStepParam.mjs";
|
|
6
|
+
import { inspectTemplate as c } from "./twigWrapper/inspectTemplate.mjs";
|
|
7
|
+
import { templatePaths as l, templateRootNames as u } from "./twigWrapper/templateRoots.mjs";
|
|
8
|
+
import d from "./fetchManifest.mjs";
|
|
9
|
+
import f from "./generateFacade.mjs";
|
|
10
|
+
import p from "./syntaxHighlight.mjs";
|
|
11
|
+
import { cookieFromHeader as m, documentCookies as h } from "./cookies.mjs";
|
|
12
|
+
import { formatDate as g, formatDateUTC as _, formatFromNow as v, formatUTCToLocal as y, getDurationMs as b, isValidFormat as x, parseDate as S, toUnixSeconds as C } from "./formatDate.mjs";
|
|
13
|
+
import { isDate as w } from "./isDate.mjs";
|
|
14
|
+
import { isUserEdit as T } from "./reducerOrigin.mjs";
|
|
15
|
+
import { evaluateRuleGroup as E } from "./ruleEvaluator.mjs";
|
|
16
|
+
import { ParamsFromURL as D, delay as O, emptyObject as k, getDisplayName as A, getKeyDecoded as j, getPathsFromObeject as M, hexToRGB as N, isInViewport as P, makeId as F } from "./utils.mjs";
|
|
17
|
+
import { disableReactDevTools as I } from "./security.mjs";
|
|
18
|
+
import { createStripTypenameLink as L, stripTypenameDeep as R } from "./stripTypename.mjs";
|
|
19
|
+
export { o as MAX_PARAM_PASSES, D as ParamsFromURL, m as cookieFromHeader, L as createStripTypenameLink, O as delay, I as disableReactDevTools, h as documentCookies, k as emptyObject, E as evaluateRuleGroup, d as fetchManifest, e as filters, g as formatDate, _ as formatDateUTC, v as formatFromNow, y as formatUTCToLocal, f as generateFacade, A as getDisplayName, b as getDurationMs, j as getKeyDecoded, M as getPathsFromObeject, i as hasTemplateSyntax, a as hasValidToken, N as hexToRGB, c as inspectTemplate, w as isDate, P as isInViewport, T as isUserEdit, x as isValidFormat, F as makeId, S as parseDate, t as processTwig, n as processTwigParam, r as processTwigValue, s as resolveStepParam, R as stripTypenameDeep, p as syntaxHighlight, l as templatePaths, u as templateRootNames, C as toUnixSeconds };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A module of its own because `parse` is the heaviest thing in date-fns — it compiles every token parser the format
|
|
3
|
+
* language has, about 100 MB of memory on the way in — and nothing that formats a date should pay for it. Imported from
|
|
4
|
+
* `formatDate`, it was paid by every page server at start, for a function no renderer calls.
|
|
5
|
+
*/
|
|
6
|
+
/** Strictly validates whether a string matches a given date-fns format. */
|
|
7
|
+
export declare function isDate(value: string, formatStr: string): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { format as e } from "date-fns/format";
|
|
2
|
+
import { isValid as t } from "date-fns/isValid";
|
|
3
|
+
import { parse as n } from "date-fns/parse";
|
|
4
|
+
//#region src/helpers/isDate.ts
|
|
5
|
+
function r(r, i) {
|
|
6
|
+
if (typeof r != "string") return !1;
|
|
7
|
+
try {
|
|
8
|
+
let a = n(r, i, /* @__PURE__ */ new Date());
|
|
9
|
+
return t(a) ? e(a, i) === r : !1;
|
|
10
|
+
} catch {
|
|
11
|
+
return !1;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { r as isDate };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keyboard shortcuts, as a space writes them: `'f'`, `'shift+f'`, `'mod+k'`, `'escape'`, several at once with commas
|
|
3
|
+
* (`'plus, ='`).
|
|
4
|
+
*
|
|
5
|
+
* Both halves of matching live here — reading what an author wrote and reading what a key press was — so they meet
|
|
6
|
+
* in one canonical form: modifiers in a fixed order, then the key, lower case (`ctrl+shift+f`). Authoring reads the
|
|
7
|
+
* first half to refuse a shortcut that could never fire; the element listening reads both.
|
|
8
|
+
*/
|
|
9
|
+
/** The trigger a shortcut starts: fired once per key press, with every shortcut it matched. */
|
|
10
|
+
export declare const KEY_TRIGGER = "onKey";
|
|
11
|
+
export type KeyTriggerPayload = {
|
|
12
|
+
/** The key pressed, canonical — `shift+f`. */
|
|
13
|
+
key: string;
|
|
14
|
+
/** Each `keys` param, exactly as written, that the press matched: the flows that run are the ones written so. */
|
|
15
|
+
shortcuts: string[];
|
|
16
|
+
};
|
|
17
|
+
export type ParsedKeys = {
|
|
18
|
+
/** Each shortcut, canonical: `ctrl+alt+shift+meta+key`, with only the modifiers it uses. */
|
|
19
|
+
combos: string[];
|
|
20
|
+
/** Each part that is not a shortcut, with why — empty when all of it is. */
|
|
21
|
+
problems: string[];
|
|
22
|
+
};
|
|
23
|
+
/** Every shortcut in what an author wrote, canonical, and what in it is not one. */
|
|
24
|
+
export declare const parseKeys: (spec: string, isMac?: boolean) => ParsedKeys;
|
|
25
|
+
export type KeyPress = Pick<KeyboardEvent, 'key' | 'code' | 'ctrlKey' | 'altKey' | 'shiftKey' | 'metaKey'>;
|
|
26
|
+
/**
|
|
27
|
+
* A key press, in the form {@link parseKeys} writes.
|
|
28
|
+
*
|
|
29
|
+
* Two keyboard facts decide it. Shift is part of a LETTER's shortcut (`shift+f`), but a symbol is typed with whatever
|
|
30
|
+
* it takes — `+` is Shift+= on one keyboard and a key of its own on another — so for a symbol Shift is not counted.
|
|
31
|
+
* And with Alt, Ctrl or ⌘ held, `key` can be another character altogether (Option+F is `ƒ` on a Mac): the physical
|
|
32
|
+
* letter or digit is read from `code` instead.
|
|
33
|
+
*/
|
|
34
|
+
export declare const keyPressCombo: (press: KeyPress) => string;
|
|
35
|
+
/**
|
|
36
|
+
* Whether a press, made in a text field, is the field's own editing — so a shortcut must not take it.
|
|
37
|
+
*
|
|
38
|
+
* With ⌘, Ctrl or Alt held a press in a field is otherwise a shortcut's, which is what lets `mod+k` open a palette
|
|
39
|
+
* from a search box. But `mod+a` in a title field is "select this text", not "select everything on the board", and
|
|
40
|
+
* `alt+backspace` deletes a word: a shortcut that took those would break typing wherever the page has one.
|
|
41
|
+
*/
|
|
42
|
+
export declare const isFieldEditing: (combo: string) => boolean;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
//#region src/helpers/keys.ts
|
|
2
|
+
var e = "onKey", t = [
|
|
3
|
+
"ctrl",
|
|
4
|
+
"alt",
|
|
5
|
+
"shift",
|
|
6
|
+
"meta"
|
|
7
|
+
], n = {
|
|
8
|
+
ctrl: "ctrl",
|
|
9
|
+
control: "ctrl",
|
|
10
|
+
alt: "alt",
|
|
11
|
+
option: "alt",
|
|
12
|
+
shift: "shift",
|
|
13
|
+
meta: "meta",
|
|
14
|
+
cmd: "meta",
|
|
15
|
+
command: "meta",
|
|
16
|
+
mod: "mod"
|
|
17
|
+
}, r = {
|
|
18
|
+
esc: "escape",
|
|
19
|
+
space: "space",
|
|
20
|
+
spacebar: "space",
|
|
21
|
+
plus: "+",
|
|
22
|
+
minus: "-",
|
|
23
|
+
up: "arrowup",
|
|
24
|
+
down: "arrowdown",
|
|
25
|
+
left: "arrowleft",
|
|
26
|
+
right: "arrowright",
|
|
27
|
+
del: "delete",
|
|
28
|
+
return: "enter"
|
|
29
|
+
}, i = /* @__PURE__ */ new Set([
|
|
30
|
+
"escape",
|
|
31
|
+
"enter",
|
|
32
|
+
"tab",
|
|
33
|
+
"space",
|
|
34
|
+
"backspace",
|
|
35
|
+
"delete",
|
|
36
|
+
"insert",
|
|
37
|
+
"arrowup",
|
|
38
|
+
"arrowdown",
|
|
39
|
+
"arrowleft",
|
|
40
|
+
"arrowright",
|
|
41
|
+
"home",
|
|
42
|
+
"end",
|
|
43
|
+
"pageup",
|
|
44
|
+
"pagedown",
|
|
45
|
+
...Array.from({ length: 12 }, (e, t) => `f${t + 1}`)
|
|
46
|
+
]), a = (e, n) => [...t.filter((t) => e.has(t)), n].join("+"), o = (e, t) => {
|
|
47
|
+
let o = e.trim().toLowerCase();
|
|
48
|
+
if (!o) return { problem: "an empty shortcut (two commas in a row, or one at the end)" };
|
|
49
|
+
let s = o.endsWith("++") ? [...o.slice(0, -2).split("+"), "+"] : o.split("+"), c = o === "+" ? ["+"] : s.filter((e) => e !== ""), l = /* @__PURE__ */ new Set(), u = [];
|
|
50
|
+
for (let e of c) {
|
|
51
|
+
if (Object.hasOwn(n, e)) {
|
|
52
|
+
let r = n[e];
|
|
53
|
+
l.add(r === "mod" ? t ? "meta" : "ctrl" : r);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
u.push(Object.hasOwn(r, e) ? r[e] : e);
|
|
57
|
+
}
|
|
58
|
+
if (u.length !== 1) return { problem: `"${e.trim()}" names ${u.length ? `${u.length} keys (${u.join(", ")})` : "no key, only modifiers"}: a shortcut is modifiers and ONE key, like "shift+f"` };
|
|
59
|
+
let [d] = u;
|
|
60
|
+
return d.length !== 1 && !i.has(d) ? { problem: `"${d}" in "${e.trim()}" is not a key: use one character ("f", "?", "+") or a key's name (${[...i].slice(0, 15).join(", ")}, f1…f12)` } : { combo: a(l, d) };
|
|
61
|
+
}, s = (e, t = !1) => {
|
|
62
|
+
let n = e.split(",").map((e) => o(e, t));
|
|
63
|
+
return {
|
|
64
|
+
combos: n.flatMap((e) => e.combo ? [e.combo] : []),
|
|
65
|
+
problems: n.flatMap((e) => e.problem ? [e.problem] : [])
|
|
66
|
+
};
|
|
67
|
+
}, c = (e) => {
|
|
68
|
+
let t = e.ctrlKey || e.altKey || e.metaKey, n = /^(?:Key|Digit)([A-Z0-9])$/.exec(e.code), r = t && n ? n[1] : e.key, i = r === " " ? "space" : r.toLowerCase(), o = i.length === 1 && !/[a-z0-9]/.test(i), s = /* @__PURE__ */ new Set();
|
|
69
|
+
return e.ctrlKey && s.add("ctrl"), e.altKey && s.add("alt"), e.shiftKey && !o && s.add("shift"), e.metaKey && s.add("meta"), a(s, i);
|
|
70
|
+
}, l = /* @__PURE__ */ new Set([
|
|
71
|
+
"a",
|
|
72
|
+
"z",
|
|
73
|
+
"y",
|
|
74
|
+
"c",
|
|
75
|
+
"x",
|
|
76
|
+
"v"
|
|
77
|
+
]), u = /* @__PURE__ */ new Set([
|
|
78
|
+
"arrowleft",
|
|
79
|
+
"arrowright",
|
|
80
|
+
"arrowup",
|
|
81
|
+
"arrowdown",
|
|
82
|
+
"home",
|
|
83
|
+
"end",
|
|
84
|
+
"backspace",
|
|
85
|
+
"delete"
|
|
86
|
+
]), d = (e) => {
|
|
87
|
+
let t = e.split("+"), n = e.endsWith("++") ? "+" : t[t.length - 1];
|
|
88
|
+
return u.has(n) || l.has(n) && (e.includes("ctrl+") || e.includes("meta+"));
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
export { e as KEY_TRIGGER, d as isFieldEditing, c as keyPressCombo, s as parseKeys };
|
|
@@ -47,7 +47,7 @@ export type ContinueNode = {
|
|
|
47
47
|
export type Expression = LiteralNode | ArrayLiteralNode | ObjectLiteralNode | RangeNode | PathNode | IndexNode | FunctionNode | FilterExpression | ConcatNode | UnaryNode | BinaryNode | DefaultNode | TernaryNode | ArrowFunctionNode;
|
|
48
48
|
export type LiteralNode = {
|
|
49
49
|
readonly type: 'literal';
|
|
50
|
-
readonly value: string | number | boolean;
|
|
50
|
+
readonly value: string | number | boolean | null;
|
|
51
51
|
};
|
|
52
52
|
export type ArrayLiteralNode = {
|
|
53
53
|
readonly type: 'array';
|
|
@@ -117,7 +117,7 @@ export type DefaultNode = {
|
|
|
117
117
|
export type TernaryNode = {
|
|
118
118
|
readonly type: 'ternary';
|
|
119
119
|
readonly condition: Expression;
|
|
120
|
-
readonly trueExpr: Expression;
|
|
120
|
+
readonly trueExpr: Expression | null;
|
|
121
121
|
readonly falseExpr: Expression;
|
|
122
122
|
};
|
|
123
123
|
export type ArrowFunctionNode = {
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import { ASTNode } from '../AST';
|
|
1
|
+
import { ASTNode, Expression } from '../AST';
|
|
2
2
|
export type EvalResult = {
|
|
3
3
|
readonly output: string;
|
|
4
4
|
readonly variables: Record<string, unknown>;
|
|
5
5
|
readonly hasSet: boolean;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Renders `nodes` against `context`.
|
|
9
|
+
*
|
|
10
|
+
* `jsonStrings` is for a template the author wrote as a JSON document — `{ "city": "{{ values.city }}" }`: a value
|
|
11
|
+
* printed inside one of its string literals is escaped for it, so a city typed with a quote or on two lines is still
|
|
12
|
+
* that document, not text the reader has to give up on. A value printed anywhere else is printed as always: it IS the
|
|
13
|
+
* JSON value there (`"seen": {{ count }}`).
|
|
14
|
+
*/
|
|
15
|
+
export declare const evaluate: (nodes: readonly ASTNode[], context: Record<string, unknown>, keepEmptyTokens?: boolean, jsonStrings?: boolean) => EvalResult;
|
|
16
|
+
/** One expression's value, as it is — not rendered to text. What `processTwigValue` answers a `{{ expr }}` with. */
|
|
17
|
+
export declare const evaluateExpression: (expression: Expression, context: Record<string, unknown>) => unknown;
|