@plitzi/sdk-shared 0.39.12 → 0.39.13

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/audiences/audiences.d.ts +18 -4
  3. package/dist/audiences/audiences.mjs +30 -21
  4. package/dist/audiences/index.mjs +1 -1
  5. package/dist/authoring/elementCallbacks.d.ts +22 -0
  6. package/dist/authoring/elementCallbacks.mjs +20 -5
  7. package/dist/authoring/index.mjs +4 -4
  8. package/dist/dataSource/globalSources.d.ts +6 -2
  9. package/dist/dataSource/globalSources.mjs +5 -0
  10. package/dist/helpers/index.mjs +24 -23
  11. package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +28 -27
  12. package/dist/helpers/twigWrapper/filters/catalog/index.mjs +1 -1
  13. package/dist/helpers/twigWrapper/filters/dates.mjs +6 -6
  14. package/dist/helpers/twigWrapper/filters/filters.mjs +3 -3
  15. package/dist/helpers/twigWrapper/filters/index.mjs +4 -4
  16. package/dist/helpers/twigWrapper/filters/types.d.ts +16 -1
  17. package/dist/helpers/twigWrapper/filters/types.mjs +11 -2
  18. package/dist/helpers/twigWrapper/index.d.ts +2 -1
  19. package/dist/helpers/twigWrapper/index.mjs +4 -3
  20. package/dist/helpers/twigWrapper/templateRoots.mjs +19 -18
  21. package/dist/store/storeHooks.d.ts +33 -33
  22. package/dist/style/styleStates.d.ts +7 -2
  23. package/dist/style/styleStates.mjs +2 -2
  24. package/dist/timeWindows/clock.d.ts +11 -0
  25. package/dist/timeWindows/clock.mjs +6 -0
  26. package/dist/timeWindows/countdown.d.ts +31 -0
  27. package/dist/timeWindows/countdown.mjs +57 -0
  28. package/dist/timeWindows/index.d.ts +2 -0
  29. package/dist/timeWindows/index.mjs +4 -1
  30. package/dist/timeWindows/timeWindows.d.ts +0 -3
  31. package/dist/timeWindows/timeWindows.mjs +2 -2
  32. package/dist/types/CommonTypes.d.ts +5 -0
  33. package/dist/types/StoreTypes.d.ts +5 -1
  34. package/package.json +1 -1
@@ -46,8 +46,13 @@ export declare const inCascadeOrder: <T>(states: Record<string, T>) => [string,
46
46
  * they are written: a new alternative must weigh no more than that, or every `current` rule gets heavier with it.
47
47
  */
48
48
  export declare const CURRENT_SELECTOR = ":is([aria-current]:not([aria-current=\"false\"]),[aria-pressed=\"true\"],[aria-selected=\"true\"],[role=\"tabpanel\"]:not([hidden]))";
49
- /** What the `expanded` state selects: the control whose panel is open. */
50
- export declare const EXPANDED_SELECTOR = "[aria-expanded=\"true\"]";
49
+ /**
50
+ * What the `expanded` state selects: the control whose panel is open — one that says so (`aria-expanded`), or the
51
+ * `<summary>` of an open `<details>` (a `disclosure`), which says it through its `<details>`: ARIA has no
52
+ * `aria-expanded` for a summary. The summary's alternative weighs nothing (`:where`), so the state weighs the one
53
+ * attribute it always has and keeps its place against `hover` and the rest: weighing more, it would beat them all.
54
+ */
55
+ export declare const EXPANDED_SELECTOR = ":is([aria-expanded=\"true\"],:where([open]>summary))";
51
56
  /**
52
57
  * How a state is written after the selector it modifies: its pseudo-class — or, for `hidden`, the class that hides; for
53
58
  * `current` and `expanded`, the attributes the element carries; for where it sits, the structural pseudo-class.
@@ -41,7 +41,7 @@ var e = [
41
41
  checked: "while a box or a radio is ticked",
42
42
  visited: "a link to a page the visitor has been to",
43
43
  current: "the chosen one of a set, as the element says it — the selected tab (aria-selected), the link to the page shown (aria-current), the pressed toggle (aria-pressed)",
44
- expanded: "the control of a panel while the panel is open — a dropdown trigger, an accordion header (aria-expanded)",
44
+ expanded: "the control of a panel while the panel is open — a dropdown trigger, a disclosure’s summary, a menu button (aria-expanded)",
45
45
  hidden: "how it looks while its `visible` says no — where it goes as it hides, with a transition on the class",
46
46
  first: "the first of its siblings",
47
47
  last: "the last of its siblings",
@@ -63,7 +63,7 @@ var e = [
63
63
  active: 12,
64
64
  disabled: 13,
65
65
  hidden: 14
66
- }, a = (e) => Object.hasOwn(i, e), o = (t) => a(t) ? i[t] : e.length, s = (e) => Object.entries(e).sort(([e], [t]) => o(e) - o(t)), c = ":is([aria-current]:not([aria-current=\"false\"]),[aria-pressed=\"true\"],[aria-selected=\"true\"],[role=\"tabpanel\"]:not([hidden]))", l = "[aria-expanded=\"true\"]", u = {
66
+ }, a = (e) => Object.hasOwn(i, e), o = (t) => a(t) ? i[t] : e.length, s = (e) => Object.entries(e).sort(([e], [t]) => o(e) - o(t)), c = ":is([aria-current]:not([aria-current=\"false\"]),[aria-pressed=\"true\"],[aria-selected=\"true\"],[role=\"tabpanel\"]:not([hidden]))", l = ":is([aria-expanded=\"true\"],:where([open]>summary))", u = {
67
67
  current: c,
68
68
  expanded: l,
69
69
  hidden: `.${t}`,
@@ -0,0 +1,11 @@
1
+ import { Schema } from '../types';
2
+ type SpaceTrees = Pick<Schema, 'flat'> & Partial<Pick<Schema, 'components'>> & {
3
+ settings?: Partial<Pick<Schema['settings'], 'computed'>>;
4
+ };
5
+ /**
6
+ * Whether a space shows or says anything by the time — a time window, a countdown, a template that reads the page's
7
+ * clock (`time.*`, `ago`), on its pages, in its components or its computed values: its pages are then drawn at an
8
+ * instant the browser hydrates at, and say on the server what they say in the browser.
9
+ */
10
+ export declare const readsTheClock: (schema: SpaceTrees) => boolean;
11
+ export {};
@@ -0,0 +1,6 @@
1
+ import { templatePaths as e } from "../helpers/twigWrapper/templateRoots.mjs";
2
+ import { COUNTDOWN_TYPE as t } from "./countdown.mjs";
3
+ import { TIME_WINDOW_TYPE as n } from "./timeWindows.mjs";
4
+ // src/timeWindows/clock.ts
5
+ var r = /* @__PURE__ */ new Set([n, t]), i = (e) => e === "time" || e.startsWith("time."), a = (t) => typeof t == "string" ? i(t) ? !0 : (t.includes("{{") || t.includes("{%")) && e(t).some(i) : Array.isArray(t) ? t.some(a) : typeof t == "object" && !!t && Object.values(t).some(a), o = (e) => [e.flat, ...Object.values(e.components ?? {}).map((e) => e.flat)].some((e) => Object.values(e).some((e) => r.has(e.definition.type) || a(e.attributes) || a(e.definition))) || a(e.settings?.computed);
6
+ export { o as readsTheClock };
@@ -0,0 +1,31 @@
1
+ /** The element that says how long is left until an instant. */
2
+ export declare const COUNTDOWN_TYPE = "countdown";
3
+ /** The units a countdown says what is left in, largest first. */
4
+ export declare const COUNTDOWN_UNITS: readonly ["days", "hours", "minutes", "seconds"];
5
+ export type CountdownUnit = (typeof COUNTDOWN_UNITS)[number];
6
+ /** How a countdown names its units: in words (`days`), short (`d`, `hr`), or not at all. */
7
+ export declare const COUNTDOWN_LABELS: readonly ["long", "short", "none"];
8
+ export type CountdownLabels = (typeof COUNTDOWN_LABELS)[number];
9
+ export type CountdownPart = {
10
+ unit: CountdownUnit;
11
+ amount: number;
12
+ };
13
+ /** The units from `largest` down to `smallest`, in order; one unit alone when they are written the other way round. */
14
+ export declare const countdownUnits: (largest: CountdownUnit, smallest: CountdownUnit) => CountdownUnit[];
15
+ /**
16
+ * What is left from `now` until `to`, in each unit from `largest` down to `smallest` — the largest holding whatever does
17
+ * not fit below it (49 hours with `largest: 'hours'`). Counted up to the smallest unit, so the last second reads 1, not
18
+ * 0, until it is over; every part 0 from then on.
19
+ */
20
+ export declare const countdownParts: (now: number, to: number, largest?: CountdownUnit, smallest?: CountdownUnit) => CountdownPart[];
21
+ /** The next instant after `now` what a countdown shows changes at — a second, or a minute, less — or none once over. */
22
+ export declare const nextCountdownTick: (now: number, to: number, smallest?: CountdownUnit) => number | undefined;
23
+ /** What is left as an ISO 8601 duration — `P2DT3H4M` — what a `<time datetime>` says it in. */
24
+ export declare const countdownDuration: (parts: readonly CountdownPart[]) => string;
25
+ /**
26
+ * A unit's name for an amount of it, in `locale` and its plural — `days`, `día`, `hr` — or `''` with no labels. A
27
+ * locale the runtime does not know is read as English.
28
+ */
29
+ export declare const countdownLabel: (unit: CountdownUnit, amount: number, labels: CountdownLabels, locale: string) => string;
30
+ /** The instant a countdown counts to: its own `to`, or the end of the time window around it. */
31
+ export declare const countdownTarget: (to: unknown, windowEnd: unknown) => number | undefined;
@@ -0,0 +1,57 @@
1
+ import { instantOf as e } from "./timeWindows.mjs";
2
+ // src/timeWindows/countdown.ts
3
+ var t = "countdown", n = [
4
+ "days",
5
+ "hours",
6
+ "minutes",
7
+ "seconds"
8
+ ], r = [
9
+ "long",
10
+ "short",
11
+ "none"
12
+ ], i = {
13
+ days: 864e5,
14
+ hours: 36e5,
15
+ minutes: 6e4,
16
+ seconds: 1e3
17
+ }, a = {
18
+ days: "day",
19
+ hours: "hour",
20
+ minutes: "minute",
21
+ seconds: "second"
22
+ }, o = (e, t) => {
23
+ let r = n.indexOf(e), i = n.indexOf(t);
24
+ return n.slice(r, Math.max(r, i) + 1);
25
+ }, s = (e, t, n = "days", r = "seconds") => {
26
+ let a = o(n, r), s = i[a[a.length - 1]], c = Math.max(0, Math.ceil((t - e) / s) * s);
27
+ return a.map((e) => {
28
+ let t = Math.floor(c / i[e]);
29
+ return c -= t * i[e], {
30
+ unit: e,
31
+ amount: t
32
+ };
33
+ });
34
+ }, c = (e, t, n = "seconds") => {
35
+ let r = i[n], a = t - e;
36
+ if (!(a <= 0)) return t - (Math.ceil(a / r) - 1) * r;
37
+ }, l = (e) => {
38
+ let t = (t) => e.find((e) => e.unit === t)?.amount ?? 0, n = [
39
+ [t("hours"), "H"],
40
+ [t("minutes"), "M"],
41
+ [t("seconds"), "S"]
42
+ ].filter(([e]) => e !== 0).map(([e, t]) => `${String(e)}${String(t)}`).join(""), r = t("days") > 0 ? `${String(t("days"))}D` : "";
43
+ return r || n ? `P${r}${n ? `T${n}` : ""}` : "PT0S";
44
+ }, u = (e, t, n, r) => {
45
+ if (n === "none") return "";
46
+ for (let i of [r || "en", "en"]) try {
47
+ return new Intl.NumberFormat(i, {
48
+ style: "unit",
49
+ unit: a[e],
50
+ unitDisplay: n
51
+ }).formatToParts(t).filter((e) => e.type === "unit").map((e) => e.value).join("").trim();
52
+ } catch {
53
+ continue;
54
+ }
55
+ return "";
56
+ }, d = (t, n) => e(t) ?? (t === void 0 || t === "" ? e(n) : void 0);
57
+ export { r as COUNTDOWN_LABELS, t as COUNTDOWN_TYPE, n as COUNTDOWN_UNITS, l as countdownDuration, u as countdownLabel, s as countdownParts, d as countdownTarget, o as countdownUnits, c as nextCountdownTick };
@@ -1 +1,3 @@
1
+ export * from './clock';
2
+ export * from './countdown';
1
3
  export * from './timeWindows';
@@ -1 +1,4 @@
1
- export { TIME_WINDOW_TYPE, hasTimeWindows, instantOf, isWindowBound, isWindowOpen, nextWindowChange } from "./timeWindows.mjs";
1
+ import { readsTheClock as e } from "./clock.mjs";
2
+ import { COUNTDOWN_LABELS as t, COUNTDOWN_TYPE as n, COUNTDOWN_UNITS as r, countdownDuration as i, countdownLabel as a, countdownParts as o, countdownTarget as s, countdownUnits as c, nextCountdownTick as l } from "./countdown.mjs";
3
+ import { TIME_WINDOW_TYPE as u, instantOf as d, isWindowBound as f, isWindowOpen as p, nextWindowChange as m } from "./timeWindows.mjs";
4
+ export { t as COUNTDOWN_LABELS, n as COUNTDOWN_TYPE, r as COUNTDOWN_UNITS, u as TIME_WINDOW_TYPE, i as countdownDuration, a as countdownLabel, o as countdownParts, s as countdownTarget, c as countdownUnits, d as instantOf, f as isWindowBound, p as isWindowOpen, l as nextCountdownTick, m as nextWindowChange, e as readsTheClock };
@@ -1,4 +1,3 @@
1
- import { Schema } from '../types';
2
1
  /** The element that shows what it holds only between two instants. */
3
2
  export declare const TIME_WINDOW_TYPE = "timeWindow";
4
3
  /**
@@ -12,5 +11,3 @@ export declare const isWindowBound: (value: unknown) => boolean;
12
11
  export declare const isWindowOpen: (now: number, from: unknown, until: unknown) => boolean;
13
12
  /** The next instant after `now` a window opens or closes at — what a page waits for to show or hide it — or none. */
14
13
  export declare const nextWindowChange: (now: number, from: unknown, until: unknown) => number | undefined;
15
- /** Whether a space has a time window, on its pages or in its components: its pages are drawn at an instant. */
16
- export declare const hasTimeWindows: (schema: Pick<Schema, "flat"> & Partial<Pick<Schema, "components">>) => boolean;
@@ -6,5 +6,5 @@ var e = "timeWindow", t = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-
6
6
  }, r = (e) => e === void 0 || e === "" || n(e) !== void 0, i = (e, t, r) => {
7
7
  let i = n(t), a = n(r);
8
8
  return (i === void 0 || e >= i) && (a === void 0 || e < a);
9
- }, a = (e, t, r) => [n(t), n(r)].filter((t) => t !== void 0 && t > e).sort((e, t) => e - t)[0], o = (t) => [t.flat, ...Object.values(t.components ?? {}).map((e) => e.flat)].some((t) => Object.values(t).some((t) => t.definition.type === e));
10
- export { e as TIME_WINDOW_TYPE, o as hasTimeWindows, n as instantOf, r as isWindowBound, i as isWindowOpen, a as nextWindowChange };
9
+ }, a = (e, t, r) => [n(t), n(r)].filter((t) => t !== void 0 && t > e).sort((e, t) => e - t)[0];
10
+ export { e as TIME_WINDOW_TYPE, n as instantOf, r as isWindowBound, i as isWindowOpen, a as nextWindowChange };
@@ -33,6 +33,11 @@ export type Server<T extends Record<string, unknown> = Record<string, unknown>>
33
33
  scriptPolicy?: 'report-only' | 'enforce';
34
34
  websocketServer: string;
35
35
  subscriptionServer: string;
36
+ /**
37
+ * Where this deployment's MCP server answers, `/mcp` included: what an agent is added with to work on a space as a
38
+ * collaborator (the builder's Claude panel). Absent where the host runs none.
39
+ */
40
+ mcpServer?: string;
36
41
  location?: Location;
37
42
  authenticated?: boolean;
38
43
  skipAuth?: boolean;
@@ -31,6 +31,10 @@ export type RuntimeSourceValues = {
31
31
  mode: Theme;
32
32
  resolved: ColorScheme;
33
33
  };
34
+ time?: {
35
+ now: number;
36
+ today: string;
37
+ };
34
38
  flags?: Record<string, boolean>;
35
39
  experiments?: ExperimentAssignments;
36
40
  };
@@ -109,7 +113,7 @@ export type CommonState = {
109
113
  */
110
114
  visitor?: VisitorFacts;
111
115
  /**
112
- * The instant this page is drawn at, for what shows by the time (`timeWindow`): the server's, when it drew the page —
116
+ * The instant this page is drawn at, for what shows or says things by the time (`timeWindow`, `countdown`): the server's, when it drew the page —
113
117
  * the page hydrates at it, then follows its own clock — or the one the builder simulates (`simulated`), which it keeps.
114
118
  */
115
119
  clock?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-shared",
3
- "version": "0.39.12",
3
+ "version": "0.39.13",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist",