@plitzi/sdk-shared 0.39.11 → 0.39.12
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 +7 -0
- package/dist/audiences/audiences.d.ts +64 -0
- package/dist/audiences/audiences.mjs +66 -0
- package/dist/audiences/index.d.ts +1 -0
- package/dist/audiences/index.mjs +1 -0
- package/dist/authoring/spaceCallbacks.mjs +46 -33
- package/dist/dataSource/globalSources.d.ts +4 -4
- package/dist/dataSource/globalSources.mjs +1 -0
- package/dist/experimentEvents/experimentEvents.d.ts +24 -0
- package/dist/experimentEvents/experimentEvents.mjs +28 -0
- package/dist/experimentEvents/index.d.ts +1 -0
- package/dist/experimentEvents/index.mjs +1 -0
- package/dist/experiments/experiments.d.ts +73 -0
- package/dist/experiments/experiments.mjs +74 -0
- package/dist/experiments/experimentsCookie.d.ts +26 -0
- package/dist/experiments/experimentsCookie.mjs +25 -0
- package/dist/experiments/forcedExperiments.d.ts +31 -0
- package/dist/experiments/forcedExperiments.mjs +41 -0
- package/dist/experiments/index.d.ts +3 -0
- package/dist/experiments/index.mjs +4 -0
- package/dist/flags/index.d.ts +1 -0
- package/dist/flags/index.mjs +6 -5
- package/dist/flags/react/index.d.ts +1 -0
- package/dist/flags/react/index.mjs +3 -1
- package/dist/flags/react/useFlagResolution.mjs +22 -19
- package/dist/flags/react/useRolloutBuckets.d.ts +9 -0
- package/dist/flags/react/useRolloutBuckets.mjs +19 -0
- package/dist/flags/resolveFlags.d.ts +10 -3
- package/dist/flags/resolveFlags.mjs +19 -9
- package/dist/flags/rollout.d.ts +41 -0
- package/dist/flags/rollout.mjs +53 -0
- package/dist/flags/schemaFlag.d.ts +3 -1
- package/dist/flags/schemaFlag.mjs +2 -2
- package/dist/helpers/index.mjs +17 -17
- package/dist/schema/serverElements.mjs +18 -18
- package/dist/schema/serverInput.mjs +6 -6
- package/dist/store/renderSettings.d.ts +1 -0
- package/dist/store/renderSettings.mjs +16 -12
- package/dist/store/storeHooks.d.ts +45 -45
- package/dist/timeWindows/index.d.ts +1 -0
- package/dist/timeWindows/index.mjs +1 -0
- package/dist/timeWindows/timeWindows.d.ts +16 -0
- package/dist/timeWindows/timeWindows.mjs +10 -0
- package/dist/types/DataSourceTypes.d.ts +1 -1
- package/dist/types/ElementTypes.d.ts +1 -1
- package/dist/types/PluginTypes.d.ts +5 -0
- package/dist/types/SchemaTypes.d.ts +11 -1
- package/dist/types/StoreTypes.d.ts +59 -0
- package/dist/variants/index.d.ts +1 -0
- package/dist/variants/index.mjs +1 -0
- package/dist/variants/variants.d.ts +23 -0
- package/dist/variants/variants.mjs +9 -0
- package/package.json +1 -1
package/dist/flags/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { FLAG_GATE_PATTERN as e, FLAG_NAME_PATTERN as t, isFlagName as n,
|
|
2
|
-
import { FLAG_LAYERS as
|
|
3
|
-
import { flagsCookieName as
|
|
4
|
-
import { forcedFlagsFor as
|
|
5
|
-
|
|
1
|
+
import { FLAG_GATE_PATTERN as e, FLAG_NAME_PATTERN as t, isFlagName as n, isFlagRollout as r, isSchemaFlag as i } from "./schemaFlag.mjs";
|
|
2
|
+
import { FLAG_LAYERS as a, flagUserFrom as o, flagUserFromSSR as s, flagValues as c, hasConditions as l, passesFlagGate as u, resolveFlags as d, undeclaredFlagOverrides as f } from "./resolveFlags.mjs";
|
|
3
|
+
import { flagsCookieName as p, forcedFlagsFromCookies as m, parseFlagList as h, serializeFlagList as g, withForcedFlag as _, writeForcedFlags as v } from "./flagsCookie.mjs";
|
|
4
|
+
import { forcedFlagsFor as y, requestFlagOverrides as b, serverFlagsFor as x } from "./overrides.mjs";
|
|
5
|
+
import { assignRollout as S, browserRollout as C, keptRollout as w, parseRolloutList as T, rolledOutFlags as E, rolloutCookie as D, rolloutCookieName as O, serializeRolloutList as k, writeRollout as A } from "./rollout.mjs";
|
|
6
|
+
export { e as FLAG_GATE_PATTERN, a as FLAG_LAYERS, t as FLAG_NAME_PATTERN, S as assignRollout, C as browserRollout, o as flagUserFrom, s as flagUserFromSSR, c as flagValues, p as flagsCookieName, y as forcedFlagsFor, m as forcedFlagsFromCookies, l as hasConditions, n as isFlagName, r as isFlagRollout, i as isSchemaFlag, w as keptRollout, h as parseFlagList, T as parseRolloutList, u as passesFlagGate, b as requestFlagOverrides, d as resolveFlags, E as rolledOutFlags, D as rolloutCookie, O as rolloutCookieName, g as serializeFlagList, k as serializeRolloutList, x as serverFlagsFor, f as undeclaredFlagOverrides, _ as withForcedFlag, v as writeForcedFlags, A as writeRollout };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/** flags's React bindings — apart from `@plitzi/sdk-shared/flags`, which a server imports without React's hooks and contexts. */
|
|
2
2
|
export { default as useFlagResolution } from './useFlagResolution';
|
|
3
3
|
export * from './useFlagResolution';
|
|
4
|
+
export { default as useRolloutBuckets } from './useRolloutBuckets';
|
|
@@ -2,33 +2,36 @@ import e from "../../hooks/useStableValue.mjs";
|
|
|
2
2
|
import { flagUserFrom as t, resolveFlags as n } from "../resolveFlags.mjs";
|
|
3
3
|
import { useCommonStore as r } from "../../store/storeHooks.mjs";
|
|
4
4
|
import i from "../../store/renderSettings.mjs";
|
|
5
|
-
import
|
|
5
|
+
import a from "./useRolloutBuckets.mjs";
|
|
6
|
+
import { useMemo as o } from "react";
|
|
6
7
|
// src/flags/react/useFlagResolution.ts
|
|
7
|
-
var
|
|
8
|
-
let { environment:
|
|
8
|
+
var s = (s) => {
|
|
9
|
+
let { environment: c } = i(), [[l, u, d, f, p]] = r([
|
|
9
10
|
"schema.flags",
|
|
10
11
|
"navigation.routeParams",
|
|
11
12
|
"navigation.queryParams",
|
|
12
13
|
"navigation.hostname",
|
|
13
14
|
"flags.overrides"
|
|
14
|
-
]), { authenticated:
|
|
15
|
-
authenticated:
|
|
16
|
-
user: m
|
|
17
|
-
}), [p, m]);
|
|
18
|
-
return e(a(() => n(c, {
|
|
19
|
-
environment: s,
|
|
20
|
-
hostname: d,
|
|
21
|
-
routeParams: l,
|
|
22
|
-
queryParams: u,
|
|
15
|
+
]), { authenticated: m, user: h } = s, g = o(() => t({
|
|
16
|
+
authenticated: m,
|
|
23
17
|
user: h
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
}), [m, h]), _ = a();
|
|
19
|
+
return e(o(() => n(l, {
|
|
20
|
+
environment: c,
|
|
21
|
+
hostname: f,
|
|
22
|
+
routeParams: u,
|
|
23
|
+
queryParams: d,
|
|
24
|
+
user: g,
|
|
25
|
+
rollout: _
|
|
26
|
+
}, p), [
|
|
28
27
|
l,
|
|
28
|
+
c,
|
|
29
|
+
f,
|
|
29
30
|
u,
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
d,
|
|
32
|
+
g,
|
|
33
|
+
_,
|
|
34
|
+
p
|
|
32
35
|
]));
|
|
33
36
|
};
|
|
34
|
-
export {
|
|
37
|
+
export { s as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RolloutBuckets } from '../rollout';
|
|
2
|
+
/**
|
|
3
|
+
* Where this visitor stands in the space's gradual rollouts, for whoever resolves the flags in the browser — the
|
|
4
|
+
* `flags` source and the router alike: the places the server answered the page with, the ones the visitor kept, and one
|
|
5
|
+
* drawn once per page for a flag none of those has, kept in the cookie from then on. In the builder there is no
|
|
6
|
+
* visitor: no place, and a rollout's flag answers its own value (forced from the Feature Flags panel to see the other).
|
|
7
|
+
*/
|
|
8
|
+
declare const useRolloutBuckets: () => RolloutBuckets;
|
|
9
|
+
export default useRolloutBuckets;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { browserRollout as e, writeRollout as t } from "../rollout.mjs";
|
|
2
|
+
import { useCommonStore as n } from "../../store/storeHooks.mjs";
|
|
3
|
+
import r from "../../store/renderSettings.mjs";
|
|
4
|
+
import { useEffect as i, useMemo as a } from "react";
|
|
5
|
+
// src/flags/react/useRolloutBuckets.ts
|
|
6
|
+
var o = {}, s = () => {
|
|
7
|
+
let { builder: s } = r(), [[c, l]] = n(["schema.flags", "flags.rollout"]), { buckets: u, drawn: d } = a(() => s ? {
|
|
8
|
+
buckets: o,
|
|
9
|
+
drawn: []
|
|
10
|
+
} : e(c, l), [
|
|
11
|
+
s,
|
|
12
|
+
c,
|
|
13
|
+
l
|
|
14
|
+
]);
|
|
15
|
+
return i(() => {
|
|
16
|
+
d.length > 0 && t(u);
|
|
17
|
+
}, [u, d]), u;
|
|
18
|
+
};
|
|
19
|
+
export { s as default };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RuleGroup } from '../conditions';
|
|
2
|
+
import { RolloutBuckets } from './rollout';
|
|
2
3
|
import { VariableScope } from '../dataSource/variables';
|
|
3
4
|
import { AuthContextValue, Schema, SSRUser } from '../types';
|
|
4
5
|
/**
|
|
@@ -21,18 +22,24 @@ export type FlagUser = {
|
|
|
21
22
|
export declare const flagUserFrom: ({ authenticated, user }: Partial<Pick<AuthContextValue, "authenticated" | "user">>) => FlagUser;
|
|
22
23
|
/** The visitor a server resolved, as a flag's rule sees them — the same fields the browser's rules see. */
|
|
23
24
|
export declare const flagUserFromSSR: (user: Pick<SSRUser, "email" | "username" | "roles"> | undefined) => FlagUser;
|
|
24
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* What a flag's rules are matched against: everything a variable's are, and who is visiting — with where the visitor
|
|
27
|
+
* stands in the space's gradual rollouts (`rollout`, their place 0–99 per flag; none, a rollout gives its flag's value).
|
|
28
|
+
*/
|
|
25
29
|
export type FlagScope = VariableScope & {
|
|
26
30
|
user?: FlagUser;
|
|
31
|
+
rollout?: RolloutBuckets;
|
|
27
32
|
};
|
|
28
33
|
/**
|
|
29
34
|
* One flag's answer, and where it came from: the layer that decided, and — when the space did — the index of the
|
|
30
|
-
* rule that matched,
|
|
35
|
+
* rule that matched, or `rollout` when its gradual rollout took the visitor in or left them out; neither when it was
|
|
36
|
+
* the flag's own default. What the dev tools show beside the value.
|
|
31
37
|
*/
|
|
32
38
|
export type FlagResolution = {
|
|
33
39
|
value: boolean;
|
|
34
40
|
layer: FlagLayer;
|
|
35
41
|
rule?: number;
|
|
42
|
+
rollout?: true;
|
|
36
43
|
};
|
|
37
44
|
/**
|
|
38
45
|
* Whether a rule says anything at all. A rule just added in the builder has an empty group, and the evaluator reads
|
|
@@ -43,7 +50,7 @@ export declare const hasConditions: (when: unknown) => when is RuleGroup;
|
|
|
43
50
|
/**
|
|
44
51
|
* Every flag the space declares, resolved for this render: `{ newCheckout: { value: true, layer: 'space', rule: 0 } }`.
|
|
45
52
|
*
|
|
46
|
-
* The space answers first — the first of a flag's rules that matches, or its default — and each layer above it may
|
|
53
|
+
* The space answers first — the first of a flag's rules that matches, its rollout, or its default — and each layer above it may
|
|
47
54
|
* replace that answer, in order. An override for a flag the space does not declare is not an answer to anything and
|
|
48
55
|
* is dropped here; {@link undeclaredFlagOverrides} names those so whoever set one can be told.
|
|
49
56
|
*/
|
|
@@ -22,15 +22,25 @@ var t = [
|
|
|
22
22
|
"server",
|
|
23
23
|
"sdk",
|
|
24
24
|
"qa"
|
|
25
|
-
], a = (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)), o = (t, n) => Array.isArray(t.rules) ? t.rules.findIndex((t) => a(t.when) && e(t.when, n)) : -1, s = (e, t) => {
|
|
26
|
-
let
|
|
27
|
-
|
|
28
|
-
value:
|
|
29
|
-
layer: "space"
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
], a = (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)), o = (t, n) => Array.isArray(t.rules) ? t.rules.findIndex((t) => a(t.when) && e(t.when, n)) : -1, s = (e, t, n) => {
|
|
26
|
+
let r = o(t, n);
|
|
27
|
+
if (r !== -1) return {
|
|
28
|
+
value: t.rules[r].value,
|
|
29
|
+
layer: "space",
|
|
30
|
+
rule: r
|
|
31
|
+
};
|
|
32
|
+
let i = n.rollout && Object.hasOwn(n.rollout, e) ? n.rollout[e] : void 0;
|
|
33
|
+
return t.rollout && i !== void 0 ? {
|
|
34
|
+
value: i < t.rollout.percent ? t.rollout.value : t.value,
|
|
32
35
|
layer: "space",
|
|
33
|
-
|
|
36
|
+
rollout: !0
|
|
37
|
+
} : t.rollout?.percent === 100 ? {
|
|
38
|
+
value: t.rollout.value,
|
|
39
|
+
layer: "space",
|
|
40
|
+
rollout: !0
|
|
41
|
+
} : {
|
|
42
|
+
value: t.value,
|
|
43
|
+
layer: "space"
|
|
34
44
|
};
|
|
35
45
|
}, c = (e, t = {}, n = {}) => Object.fromEntries(Object.entries(e ?? {}).map(([e, r]) => [e, i.reduce((t, r) => {
|
|
36
46
|
let i = n[r]?.[e];
|
|
@@ -38,7 +48,7 @@ var t = [
|
|
|
38
48
|
value: i,
|
|
39
49
|
layer: r
|
|
40
50
|
} : t;
|
|
41
|
-
}, s(r, t))])), l = (e) => Object.fromEntries(Object.entries(e).map(([e, { value: t }]) => [e, t])), u = (e, t) => i.flatMap((n) => Object.keys(t[n] ?? {}).filter((t) => !Object.hasOwn(e ?? {}, t)).map((e) => ({
|
|
51
|
+
}, s(e, r, t))])), l = (e) => Object.fromEntries(Object.entries(e).map(([e, { value: t }]) => [e, t])), u = (e, t) => i.flatMap((n) => Object.keys(t[n] ?? {}).filter((t) => !Object.hasOwn(e ?? {}, t)).map((e) => ({
|
|
42
52
|
layer: n,
|
|
43
53
|
name: e
|
|
44
54
|
}))), d = (e, t) => !e || (t[e.name] ?? !1) === e.is;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Schema } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Where each visitor stands in the space's gradual rollouts: a number from 0 to 99 per flag, drawn once. A rollout at
|
|
4
|
+
* `percent` takes in the visitors below it, so raising the percent keeps everyone who was in — and lowering it lets go
|
|
5
|
+
* of the last taken in first.
|
|
6
|
+
*/
|
|
7
|
+
export type RolloutBuckets = Record<string, number>;
|
|
8
|
+
/**
|
|
9
|
+
* The cookie a visitor's places are kept in, so a reload — or the next visit — keeps them in the same rollouts.
|
|
10
|
+
*
|
|
11
|
+
* A cookie for the reason the variants of an A/B test are kept in one: the server answers the flags before the page
|
|
12
|
+
* exists. Named with the port, as theirs is, because a cookie's scope has none.
|
|
13
|
+
*/
|
|
14
|
+
export declare const rolloutCookieName: (host: string | undefined) => string;
|
|
15
|
+
/** `newCheckout:37,beta:5` — a flag's name and the visitor's place; nothing else survives the parse. */
|
|
16
|
+
export declare const parseRolloutList: (value: string | undefined) => RolloutBuckets;
|
|
17
|
+
export declare const serializeRolloutList: (buckets: RolloutBuckets) => string;
|
|
18
|
+
/** The places a visitor kept, from a `Cookie` header or `document.cookie`. */
|
|
19
|
+
export declare const keptRollout: (cookies: string | undefined, host: string | undefined) => RolloutBuckets;
|
|
20
|
+
/** The cookie's whole text, as a `Set-Cookie` header and `document.cookie` take it: one writer for both. */
|
|
21
|
+
export declare const rolloutCookie: (host: string | undefined, buckets: RolloutBuckets, { secure }: {
|
|
22
|
+
secure: boolean;
|
|
23
|
+
}) => string;
|
|
24
|
+
/** The flags a space rolls out to part of its visitors: a rollout neither at 0 nor at 100, which need no place. */
|
|
25
|
+
export declare const rolledOutFlags: (declared: Schema["flags"]) => string[];
|
|
26
|
+
export type RolloutAssignment = {
|
|
27
|
+
/** The visitor's place in every flag rolled out to part of the visitors. */
|
|
28
|
+
buckets: RolloutBuckets;
|
|
29
|
+
/** The flags a place was drawn in just now — a page answered with any is the visitor's alone, and they keep it. */
|
|
30
|
+
drawn: string[];
|
|
31
|
+
};
|
|
32
|
+
/** A visitor's place in each flag rolled out: the one they kept, or one drawn now. */
|
|
33
|
+
export declare const assignRollout: (declared: Schema["flags"], kept: RolloutBuckets, random?: () => number) => RolloutAssignment;
|
|
34
|
+
/**
|
|
35
|
+
* A visitor's places in the browser: the server's (it answered the page with them), then what the cookie kept, then a
|
|
36
|
+
* place drawn here — once per page, whoever asks — for a flag none of those has: a space rendered with no server in
|
|
37
|
+
* front. `drawn` names what has to be kept in the cookie.
|
|
38
|
+
*/
|
|
39
|
+
export declare const browserRollout: (declared: Schema["flags"], server: RolloutBuckets | undefined) => RolloutAssignment;
|
|
40
|
+
/** Keeps a visitor's places in the browser, over what the cookie holds already. */
|
|
41
|
+
export declare const writeRollout: (buckets: RolloutBuckets) => void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { isFlagName as e } from "./schemaFlag.mjs";
|
|
2
|
+
import { cookieFromHeader as t } from "../helpers/cookies.mjs";
|
|
3
|
+
// src/flags/rollout.ts
|
|
4
|
+
var n = 100, r = (e) => Number.isInteger(e) && e >= 0 && e < n, i = (e) => {
|
|
5
|
+
let t = e?.split(":")[1];
|
|
6
|
+
return t ? `plitzi_rollout_${t}` : "plitzi_rollout";
|
|
7
|
+
}, a = 15552e3, o = (t) => {
|
|
8
|
+
let n = {};
|
|
9
|
+
for (let i of t?.split(",") ?? []) {
|
|
10
|
+
let [t = "", a = ""] = i.split(":"), o = Number(a);
|
|
11
|
+
e(t) && a !== "" && r(o) && (n[t] = o);
|
|
12
|
+
}
|
|
13
|
+
return n;
|
|
14
|
+
}, s = (t) => Object.entries(t).filter(([t, n]) => e(t) && r(n)).sort(([e], [t]) => e.localeCompare(t)).map(([e, t]) => `${e}:${String(t)}`).join(","), c = (e, n) => o(t(e, i(n))), l = (e, t, { secure: n }) => [
|
|
15
|
+
`${i(e)}=${encodeURIComponent(s(t))}`,
|
|
16
|
+
"Path=/",
|
|
17
|
+
`Max-Age=${String(a)}`,
|
|
18
|
+
"SameSite=Lax",
|
|
19
|
+
...n ? ["Secure"] : []
|
|
20
|
+
].join("; "), u = (e) => Object.entries(e ?? {}).filter(([, e]) => e.rollout !== void 0 && e.rollout.percent > 0 && e.rollout.percent < 100).map(([e]) => e), d = (e, t, r = Math.random) => {
|
|
21
|
+
let i = {}, a = [];
|
|
22
|
+
for (let o of u(e)) {
|
|
23
|
+
let e = Object.hasOwn(t, o) ? t[o] : void 0;
|
|
24
|
+
e === void 0 ? (i[o] = Math.min(n - 1, Math.floor(r() * n)), a.push(o)) : i[o] = e;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
buckets: i,
|
|
28
|
+
drawn: a
|
|
29
|
+
};
|
|
30
|
+
}, f = {}, p = (e, t) => {
|
|
31
|
+
let n = typeof window > "u" ? void 0 : window.location.host, r;
|
|
32
|
+
try {
|
|
33
|
+
r = typeof document > "u" ? void 0 : document.cookie;
|
|
34
|
+
} catch {
|
|
35
|
+
r = void 0;
|
|
36
|
+
}
|
|
37
|
+
let i = d(e, {
|
|
38
|
+
...c(r, n),
|
|
39
|
+
...f,
|
|
40
|
+
...t
|
|
41
|
+
});
|
|
42
|
+
for (let e of i.drawn) f[e] = i.buckets[e];
|
|
43
|
+
return i;
|
|
44
|
+
}, m = (e) => {
|
|
45
|
+
try {
|
|
46
|
+
let t = window.location.host;
|
|
47
|
+
document.cookie = l(t, {
|
|
48
|
+
...c(document.cookie, t),
|
|
49
|
+
...e
|
|
50
|
+
}, { secure: window.location.protocol === "https:" });
|
|
51
|
+
} catch {}
|
|
52
|
+
};
|
|
53
|
+
export { d as assignRollout, p as browserRollout, c as keptRollout, o as parseRolloutList, u as rolledOutFlags, l as rolloutCookie, i as rolloutCookieName, s as serializeRolloutList, m as writeRollout };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { SchemaFlag } from '../types';
|
|
1
|
+
import { SchemaFlag, SchemaFlagRollout } from '../types';
|
|
2
2
|
/** A flag name: what `{{ flags.<name> }}` reads, so it has to be a valid key in a template path. */
|
|
3
3
|
export declare const FLAG_NAME_PATTERN: RegExp;
|
|
4
4
|
/** A gate as authoring and MCP write it: `name` while the flag is on, `!name` while it is off. */
|
|
5
5
|
export declare const FLAG_GATE_PATTERN: RegExp;
|
|
6
6
|
export declare const isFlagName: (name: string) => boolean;
|
|
7
|
+
/** A rollout as the resolver reads one: a whole share from 0 to 100, and the answer it gives. */
|
|
8
|
+
export declare const isFlagRollout: (value: unknown) => value is SchemaFlagRollout;
|
|
7
9
|
/**
|
|
8
10
|
* Whether a value is a flag as the resolver reads it — what every writer checks before storing one: a mutation, the
|
|
9
11
|
* live channel, the linter. A rule's `when` has to be a group; whether it says anything is the linter's to warn about.
|
|
@@ -4,5 +4,5 @@ var t = "[A-Za-z_][A-Za-z0-9_]*", n = RegExp(`^${t}$`), r = RegExp(`^!?${t}$`),
|
|
|
4
4
|
"__proto__",
|
|
5
5
|
"constructor",
|
|
6
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
|
-
export { r as FLAG_GATE_PATTERN, n as FLAG_NAME_PATTERN, a as isFlagName, o as isSchemaFlag };
|
|
7
|
+
]), a = (e) => n.test(e) && !i.has(e), o = (t) => e(t) && typeof t.percent == "number" && Number.isInteger(t.percent) && t.percent >= 0 && t.percent <= 100 && typeof t.value == "boolean", s = (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)) && (t.rollout === void 0 || o(t.rollout));
|
|
8
|
+
export { r as FLAG_GATE_PATTERN, n as FLAG_NAME_PATTERN, a as isFlagName, o as isFlagRollout, s as isSchemaFlag };
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import e from "./fetchManifest.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
2
|
+
import { get as t } from "./lodash/get.mjs";
|
|
3
|
+
import { set as n } from "./lodash/set.mjs";
|
|
4
|
+
import { has as r } from "./lodash/has.mjs";
|
|
5
|
+
import { omit as i } from "./lodash/omit.mjs";
|
|
6
|
+
import { capitalize as a } from "./lodash/capitalize.mjs";
|
|
7
|
+
import { camelCase as o } from "./lodash/camelCase.mjs";
|
|
8
|
+
import s from "./syntaxHighlight.mjs";
|
|
9
|
+
import { filters as c } from "./twigWrapper/filters/filters.mjs";
|
|
10
|
+
import { processTwig as l, processTwigParam as u, processTwigValue as d } from "./twigWrapper/processTwig/processTwig.mjs";
|
|
11
|
+
import { hasTemplateSyntax as f } from "./twigWrapper/tokens/hasTemplateSyntax.mjs";
|
|
12
|
+
import { hasValidToken as p } from "./twigWrapper/tokens/hasValidToken.mjs";
|
|
13
|
+
import { MAX_PARAM_PASSES as m, resolveStepParam as h } from "./twigWrapper/processTwig/resolveStepParam.mjs";
|
|
14
|
+
import { inspectTemplate as g } from "./twigWrapper/inspectTemplate.mjs";
|
|
15
|
+
import { templatePaths as _, templateRootNames as v } from "./twigWrapper/templateRoots.mjs";
|
|
16
|
+
import { cookieFromHeader as y, documentCookies as b } from "./cookies.mjs";
|
|
17
|
+
import { deepEqual as x } from "./deepEqual/deepEqual.mjs";
|
|
18
18
|
import { elementOf as S, isElementTarget as C, isNodeTarget as w, nodeOf as T } from "./eventTarget.mjs";
|
|
19
19
|
import { INTERVAL_TRIGGER as E, MIN_INTERVAL_MS as D, intervalOf as O } from "./interval.mjs";
|
|
20
20
|
import { isRecord as k } from "./isRecord.mjs";
|
|
@@ -28,4 +28,4 @@ import { KEY_TRIGGER as Q, isFieldEditing as $, keyPressCombo as ee, parseKeys a
|
|
|
28
28
|
import { SCROLL_BEHAVIORS as ne, SCROLL_POSITIONS as re, SCROLL_TRIGGER as ie, VIEW_TRIGGER as ae, scrollDistance as oe, scrollPosition as se, scrollState as ce } from "./scroll.mjs";
|
|
29
29
|
import { NOT_COPIED_REASON as le, clipboardWriter as ue, copyText as de } from "./clipboard.mjs";
|
|
30
30
|
import { MEMORY_STEPS as fe, VCPU_STEPS as pe, memoryWords as me, mibOf as he, millicoresOf as ge, quantityWords as _e, sizeWords as ve, vcpuWords as ye } from "./resources.mjs";
|
|
31
|
-
export { G as IMAGE_PATH, K as IMAGE_WIDTHS, E as INTERVAL_TRIGGER, Q as KEY_TRIGGER,
|
|
31
|
+
export { G as IMAGE_PATH, K as IMAGE_WIDTHS, E as INTERVAL_TRIGGER, Q as KEY_TRIGGER, m as MAX_PARAM_PASSES, fe as MEMORY_STEPS, D as MIN_INTERVAL_MS, le as NOT_COPIED_REASON, j as ParamsFromURL, ne as SCROLL_BEHAVIORS, re as SCROLL_POSITIONS, ie as SCROLL_TRIGGER, U as SPACE_ROOT_CLASS, B as TRUSTED_TYPES_POLICIES, pe as VCPU_STEPS, ae as VIEW_TRIGGER, o as camelCase, H as canonicalJson, a as capitalize, ue as clipboardWriter, y as cookieFromHeader, de as copyText, x as deepEqual, M as delay, V as disableReactDevTools, b as documentCookies, S as elementOf, N as emptyObject, e as fetchManifest, c as filters, t as get, P as getDisplayName, F as getKeyDecoded, I as getPathsFromObject, r as has, f as hasTemplateSyntax, p as hasValidToken, L as hexToRGB, q as imageSrcSet, J as imageUrl, g as inspectTemplate, O as intervalOf, C as isElementTarget, $ as isFieldEditing, Y as isImageWidth, R as isInViewport, w as isNodeTarget, k as isRecord, X as isRemoteImage, Z as isResizableImage, A as isUserEdit, ee as keyPressCombo, z as makeId, me as memoryWords, he as mibOf, ge as millicoresOf, T as nodeOf, i as omit, te as parseKeys, l as processTwig, u as processTwigParam, d as processTwigValue, _e as quantityWords, h as resolveStepParam, oe as scrollDistance, se as scrollPosition, ce as scrollState, n as set, ve as sizeWords, W as spaceRootOf, s as syntaxHighlight, _ as templatePaths, v as templateRootNames, ye as vcpuWords };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { resolveLayoutChain as e } from "./layoutChain.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { pageWithheldOf as t, withheldPageOf as n } from "./pageAccess.mjs";
|
|
3
|
+
import { processTwigValue as r } from "../helpers/twigWrapper/processTwig/processTwig.mjs";
|
|
4
4
|
import i from "../dataSource/helpers/getSourceName.mjs";
|
|
5
5
|
import { passesFlagGate as a } from "../flags/resolveFlags.mjs";
|
|
6
6
|
import { isRecord as o } from "../helpers/isRecord.mjs";
|
|
7
7
|
// src/schema/serverElements.ts
|
|
8
|
-
var s = /* @__PURE__ */ new WeakMap(), c = (
|
|
9
|
-
let a = [], o = /* @__PURE__ */ new Set(), s =
|
|
8
|
+
var s = /* @__PURE__ */ new WeakMap(), c = (r, i) => {
|
|
9
|
+
let a = [], o = /* @__PURE__ */ new Set(), s = r.flat[i], c = (e) => typeof e == "string" ? e : "", l = s ? e((e) => r.flat[e], c(s.attributes.layout), c(s.attributes.layoutContainer)).map((e) => e.layout) : [], u = t(s?.attributes) ? n(r) : void 0, d = [
|
|
10
10
|
i,
|
|
11
11
|
...l,
|
|
12
12
|
...u === void 0 ? [] : [u]
|
|
@@ -18,11 +18,11 @@ var s = /* @__PURE__ */ new WeakMap(), c = (t, i) => {
|
|
|
18
18
|
let e = d.pop();
|
|
19
19
|
if (e === void 0 || o.has(e.id)) continue;
|
|
20
20
|
o.add(e.id);
|
|
21
|
-
let
|
|
22
|
-
if (!
|
|
23
|
-
let { flag:
|
|
21
|
+
let t = r.flat[e.id];
|
|
22
|
+
if (!t) continue;
|
|
23
|
+
let { flag: n, items: i, runtime: s } = t.definition, c = n ? [...e.gates, n] : e.gates;
|
|
24
24
|
s === "server" && a.push({
|
|
25
|
-
element:
|
|
25
|
+
element: t,
|
|
26
26
|
gates: c
|
|
27
27
|
}), i && d.push(...i.map((e) => ({
|
|
28
28
|
id: e,
|
|
@@ -45,25 +45,25 @@ var s = /* @__PURE__ */ new WeakMap(), c = (t, i) => {
|
|
|
45
45
|
if (t === void 0) return [];
|
|
46
46
|
let i = n ? new Set(n) : void 0;
|
|
47
47
|
return l(e, t).filter(({ element: e }) => !i || i.has(e.id)).filter(({ gates: e }) => !r || e.every((e) => a(e, r))).map(({ element: e }) => e);
|
|
48
|
-
}, d = (e, t, n) => u(e, t, void 0, n).length > 0, f = (e,
|
|
48
|
+
}, d = (e, t, n) => u(e, t, void 0, n).length > 0, f = (e, t, n) => e.find((e) => {
|
|
49
49
|
let i = e.attributes.notFound;
|
|
50
|
-
return typeof i == "string" && i !== "" && Object.hasOwn(
|
|
51
|
-
source:
|
|
52
|
-
navigation:
|
|
50
|
+
return typeof i == "string" && i !== "" && Object.hasOwn(t, e.id) && r(i, {
|
|
51
|
+
source: t[e.id],
|
|
52
|
+
navigation: n
|
|
53
53
|
}) === !0;
|
|
54
54
|
})?.id, p = (e, t, n) => ({
|
|
55
55
|
...Object.fromEntries(e.filter((e) => Object.hasOwn(t, e.id)).map((e) => [i(e.definition.type, e.id), t[e.id]])),
|
|
56
56
|
navigation: n
|
|
57
|
-
}), m = /\{[{%]/, h = (e,
|
|
57
|
+
}), m = /\{[{%]/, h = (e, t) => {
|
|
58
58
|
if (typeof e != "string") return;
|
|
59
|
-
let
|
|
59
|
+
let n = m.test(e) ? r(e, t) : e, i = typeof n == "string" || typeof n == "number" ? String(n).trim() : "";
|
|
60
60
|
return i === "" || m.test(i) ? void 0 : i;
|
|
61
|
-
}, g = (e,
|
|
61
|
+
}, g = (e, t) => typeof e == "string" && e !== "" && r(e, t) === !0, _ = (e, t) => {
|
|
62
62
|
if (typeof e == "string") {
|
|
63
63
|
if (!m.test(e)) return e;
|
|
64
|
-
let
|
|
65
|
-
return
|
|
64
|
+
let n = r(e, t);
|
|
65
|
+
return n === void 0 || typeof n == "string" && (n.trim() === "" || m.test(n)) ? void 0 : n;
|
|
66
66
|
}
|
|
67
|
-
return Array.isArray(e) ? e.map((e) => _(e,
|
|
67
|
+
return Array.isArray(e) ? e.map((e) => _(e, t)).filter((e) => e !== void 0) : o(e) ? Object.fromEntries(Object.entries(e).map(([e, n]) => [e, _(n, t)]).filter(([, e]) => e !== void 0)) : e;
|
|
68
68
|
}, v = (e, t) => (Array.isArray(e) ? e : []).filter(o).map((e) => _(e, t)).filter(o), y = (e) => JSON.stringify(e).replace(/</g, "\\u003c"), b = "$failed", x = (e) => o(e) && typeof e.$failed == "string" ? e[b] : void 0;
|
|
69
69
|
export { b as RSC_FAILURE, u as collectServerElements, d as hasServerElements, y as jsonForScript, f as notFoundProvider, g as pageNotFound, h as pageSeoText, p as pageServerContext, v as pageStructuredData, x as rscFailureOf };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { serverProviderSource as e } from "./providerWhen.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { get as t } from "../helpers/lodash/get.mjs";
|
|
3
|
+
import { templatePaths as n } from "../helpers/twigWrapper/templateRoots.mjs";
|
|
4
4
|
import r from "../dataSource/getBindingsDetails.mjs";
|
|
5
5
|
import i from "../dataSource/helpers/getSourceName.mjs";
|
|
6
6
|
import { isRecord as a } from "../helpers/isRecord.mjs";
|
|
7
7
|
// src/schema/serverInput.ts
|
|
8
|
-
var o = /^navigation\.(routeParams|queryParams)(\.|$)/, s = "apiContainer", c = (e) => e.split(/[.[]/)[0] ?? e, l = (e) => [e.source, ...(e.transformers ?? []).flatMap(({ action: e, params:
|
|
8
|
+
var o = /^navigation\.(routeParams|queryParams)(\.|$)/, s = "apiContainer", c = (e) => e.split(/[.[]/)[0] ?? e, l = (e) => [e.source, ...(e.transformers ?? []).flatMap(({ action: e, params: t }) => e === "twigTemplate" && typeof t.template == "string" ? n(t.template).filter((e) => e !== "source" && !e.startsWith("source.")) : [])], u = (e) => e.to === "input" || e.to.startsWith("input."), d = (e, t) => (e.definition.bindings?.attributes ?? []).filter((e) => e.enabled !== !1 && u(e) && e.when === void 0 && l(e).every((e) => o.test(e) || t(c(e)))), f = (e, t) => {
|
|
9
9
|
let n = (e) => {
|
|
10
10
|
let n = e.startsWith(`${s}_`) ? e.slice(s.length + 1) : void 0;
|
|
11
11
|
return n !== void 0 && t.has(n) && i(s, n) === e ? n : void 0;
|
|
@@ -28,14 +28,14 @@ var o = /^navigation\.(routeParams|queryParams)(\.|$)/, s = "apiContainer", c =
|
|
|
28
28
|
if (e == null || e === "") return "empty";
|
|
29
29
|
let t = JSON.stringify(e);
|
|
30
30
|
return t.length > 60 ? `${t.slice(0, 57)}…` : t;
|
|
31
|
-
}, h = (e,
|
|
31
|
+
}, h = (e, n, i = {}) => {
|
|
32
32
|
let a = new Set(d(e, (e) => Object.hasOwn(i, e)));
|
|
33
33
|
return (e.definition.bindings?.attributes ?? []).filter((e) => e.enabled !== !1 && u(e)).map((o) => {
|
|
34
34
|
let u = `${o.to} ← ${o.source}`;
|
|
35
35
|
if (a.has(o)) {
|
|
36
36
|
let a = r({
|
|
37
37
|
...i,
|
|
38
|
-
navigation:
|
|
38
|
+
navigation: n
|
|
39
39
|
}, {
|
|
40
40
|
attributes: e.attributes,
|
|
41
41
|
definition: {
|
|
@@ -43,7 +43,7 @@ var o = /^navigation\.(routeParams|queryParams)(\.|$)/, s = "apiContainer", c =
|
|
|
43
43
|
bindings: { attributes: [o] }
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
|
-
return `${u}: ${m(
|
|
46
|
+
return `${u}: ${m(t(a.attributes, o.to))}`;
|
|
47
47
|
}
|
|
48
48
|
let d = l(o).map(c).find((e) => e.startsWith(`${s}_`) && !Object.hasOwn(i, e));
|
|
49
49
|
return o.when === void 0 ? d === void 0 ? `${u}: not read on the server (the visitor's state), the input as saved` : `${u}: not read on the server — ${d} gave it no answer (not a server provider, or it failed)` : `${u}: not read on the server (it has a \`when\`), the input as saved`;
|
|
@@ -4,6 +4,7 @@ import { useMemo as t } from "react";
|
|
|
4
4
|
var n = {
|
|
5
5
|
previewMode: !0,
|
|
6
6
|
debugMode: !1,
|
|
7
|
+
builder: !1,
|
|
7
8
|
renderMode: "raw",
|
|
8
9
|
environment: "main",
|
|
9
10
|
isHydrating: !1,
|
|
@@ -15,9 +16,10 @@ var n = {
|
|
|
15
16
|
ownsHead: !0,
|
|
16
17
|
enclosed: !1
|
|
17
18
|
}, r = () => {
|
|
18
|
-
let [[r, i, a, o, s, c, l, u, d, f, p, m]] = e([
|
|
19
|
+
let [[r, i, a, o, s, c, l, u, d, f, p, m, h]] = e([
|
|
19
20
|
"render.previewMode",
|
|
20
21
|
"render.debugMode",
|
|
22
|
+
"render.builder",
|
|
21
23
|
"render.renderMode",
|
|
22
24
|
"render.environment",
|
|
23
25
|
"render.isHydrating",
|
|
@@ -32,16 +34,17 @@ var n = {
|
|
|
32
34
|
return t(() => ({
|
|
33
35
|
previewMode: r ?? n.previewMode,
|
|
34
36
|
debugMode: i ?? n.debugMode,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
builder: a ?? n.builder,
|
|
38
|
+
renderMode: o ?? n.renderMode,
|
|
39
|
+
environment: s ?? n.environment,
|
|
40
|
+
isHydrating: c ?? n.isHydrating,
|
|
41
|
+
hydrated: l ?? n.hydrated,
|
|
42
|
+
overQuota: u ?? n.overQuota,
|
|
43
|
+
quotaNear: d ?? n.quotaNear,
|
|
44
|
+
badge: f ?? n.badge,
|
|
45
|
+
testAttributes: p ?? n.testAttributes,
|
|
46
|
+
ownsHead: m ?? n.ownsHead,
|
|
47
|
+
enclosed: h ?? n.enclosed
|
|
45
48
|
}), [
|
|
46
49
|
r,
|
|
47
50
|
i,
|
|
@@ -54,7 +57,8 @@ var n = {
|
|
|
54
57
|
d,
|
|
55
58
|
f,
|
|
56
59
|
p,
|
|
57
|
-
m
|
|
60
|
+
m,
|
|
61
|
+
h
|
|
58
62
|
]);
|
|
59
63
|
}, i = (e) => {
|
|
60
64
|
let n = r();
|