@plitzi/sdk-shared 0.37.1 → 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.
Files changed (195) hide show
  1. package/CHANGELOG.md +1288 -0
  2. package/dist/actions/access.d.ts +12 -0
  3. package/dist/actions/access.mjs +13 -0
  4. package/dist/actions/cron.d.ts +21 -12
  5. package/dist/actions/cron.mjs +48 -17
  6. package/dist/actions/functions.d.ts +27 -0
  7. package/dist/actions/functions.mjs +18 -0
  8. package/dist/actions/index.d.ts +5 -1
  9. package/dist/actions/index.mjs +9 -7
  10. package/dist/actions/triggers.d.ts +4 -0
  11. package/dist/actions/triggers.mjs +4 -1
  12. package/dist/auth/index.d.ts +2 -0
  13. package/dist/auth/index.mjs +2 -1
  14. package/dist/auth/visitorRoles.d.ts +27 -0
  15. package/dist/auth/visitorRoles.mjs +48 -0
  16. package/dist/authoring/builder.mjs +1 -0
  17. package/dist/authoring/declare.d.ts +74 -0
  18. package/dist/authoring/declare.mjs +2 -2
  19. package/dist/authoring/index.mjs +5 -5
  20. package/dist/authoring/paramSpec.d.ts +1 -1
  21. package/dist/authoring/paramSpec.mjs +1 -0
  22. package/dist/authoring/spaceCallbacks.mjs +2 -2
  23. package/dist/dataSource/computed.d.ts +21 -0
  24. package/dist/dataSource/computed.mjs +45 -0
  25. package/dist/dataSource/getBindingsDetails.mjs +35 -33
  26. package/dist/dataSource/index.d.ts +1 -0
  27. package/dist/dataSource/index.mjs +7 -6
  28. package/dist/dataSource/utility/checkboxParams.d.ts +11 -0
  29. package/dist/dataSource/utility/checkboxParams.mjs +12 -0
  30. package/dist/dataSource/utility/not.mjs +4 -7
  31. package/dist/dataSource/utility/stringToArray.mjs +1 -1
  32. package/dist/dataSource/utility/truthiness.d.ts +1 -0
  33. package/dist/dataSource/utility/truthiness.mjs +8 -0
  34. package/dist/dataSource/utility/twigTemplate.d.ts +2 -1
  35. package/dist/dataSource/utility/twigTemplate.mjs +29 -17
  36. package/dist/devTools/utils/PlitziConsole.mjs +22 -22
  37. package/dist/helpers/cookies.d.ts +10 -0
  38. package/dist/helpers/cookies.mjs +19 -0
  39. package/dist/helpers/fetchManifest.d.ts +9 -0
  40. package/dist/helpers/fetchManifest.mjs +3 -6
  41. package/dist/helpers/formatDate.d.ts +5 -3
  42. package/dist/helpers/formatDate.mjs +34 -36
  43. package/dist/helpers/index.d.ts +2 -0
  44. package/dist/helpers/index.mjs +18 -13
  45. package/dist/helpers/isDate.d.ts +7 -0
  46. package/dist/helpers/isDate.mjs +15 -0
  47. package/dist/helpers/keys.d.ts +42 -0
  48. package/dist/helpers/keys.mjs +91 -0
  49. package/dist/helpers/twigWrapper/AST.d.ts +2 -2
  50. package/dist/helpers/twigWrapper/Evaluator/Evaluator.d.ts +12 -2
  51. package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +69 -31
  52. package/dist/helpers/twigWrapper/Evaluator/index.d.ts +1 -1
  53. package/dist/helpers/twigWrapper/Evaluator/index.mjs +2 -2
  54. package/dist/helpers/twigWrapper/Parser/ExpressionParser.d.ts +2 -2
  55. package/dist/helpers/twigWrapper/Parser/ExpressionParser.mjs +147 -34
  56. package/dist/helpers/twigWrapper/Parser/Parser.d.ts +2 -1
  57. package/dist/helpers/twigWrapper/Parser/Parser.mjs +21 -20
  58. package/dist/helpers/twigWrapper/filters/filters.mjs +134 -111
  59. package/dist/helpers/twigWrapper/index.d.ts +6 -2
  60. package/dist/helpers/twigWrapper/index.mjs +7 -4
  61. package/dist/helpers/twigWrapper/inspectTemplate.d.ts +23 -0
  62. package/dist/helpers/twigWrapper/inspectTemplate.mjs +110 -0
  63. package/dist/helpers/twigWrapper/processTwig/helpers.d.ts +7 -0
  64. package/dist/helpers/twigWrapper/processTwig/helpers.mjs +2 -1
  65. package/dist/helpers/twigWrapper/processTwig/index.d.ts +2 -1
  66. package/dist/helpers/twigWrapper/processTwig/index.mjs +3 -2
  67. package/dist/helpers/twigWrapper/processTwig/processTwig.d.ts +28 -0
  68. package/dist/helpers/twigWrapper/processTwig/processTwig.mjs +73 -16
  69. package/dist/helpers/twigWrapper/processTwig/resolveStepParam.d.ts +17 -0
  70. package/dist/helpers/twigWrapper/processTwig/resolveStepParam.mjs +14 -0
  71. package/dist/helpers/twigWrapper/templateRoots.d.ts +11 -0
  72. package/dist/helpers/twigWrapper/templateRoots.mjs +4 -4
  73. package/dist/helpers/twigWrapper/tokens/hasTemplateSyntax.d.ts +9 -0
  74. package/dist/helpers/twigWrapper/tokens/hasTemplateSyntax.mjs +4 -0
  75. package/dist/history/describe.d.ts +29 -0
  76. package/dist/history/describe.mjs +93 -0
  77. package/dist/history/diff.d.ts +33 -0
  78. package/dist/history/diff.mjs +73 -0
  79. package/dist/history/index.d.ts +3 -0
  80. package/dist/history/index.mjs +3 -0
  81. package/dist/history/types.d.ts +48 -0
  82. package/dist/history/types.mjs +0 -0
  83. package/dist/hooks/usePlitziServiceContext.d.ts +1 -1
  84. package/dist/index.d.ts +1 -0
  85. package/dist/index.mjs +77 -65
  86. package/dist/navigation/index.d.ts +1 -1
  87. package/dist/navigation/index.mjs +2 -2
  88. package/dist/navigation/routes.d.ts +11 -1
  89. package/dist/navigation/routes.mjs +35 -30
  90. package/dist/network/graphql/builder/Mutations/Space/SpaceFixIssuesMutation.d.ts +14 -0
  91. package/dist/network/graphql/builder/Mutations/Space/SpaceFixIssuesMutation.mjs +16 -0
  92. package/dist/network/graphql/builder/Mutations/Space/SpaceUpdatePluginMutation.d.ts +4 -0
  93. package/dist/network/graphql/builder/Mutations/Space/SpaceUpdatePluginMutation.mjs +2 -2
  94. package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRunActionMutation.mjs +1 -0
  95. package/dist/network/graphql/builder/Mutations/Space/functions/SpaceRemoveFunctionsMutation.d.ts +3 -0
  96. package/dist/network/graphql/builder/Mutations/Space/functions/SpaceRemoveFunctionsMutation.mjs +9 -0
  97. package/dist/network/graphql/builder/Mutations/Space/functions/SpaceSaveFunctionsMutation.d.ts +11 -0
  98. package/dist/network/graphql/builder/Mutations/Space/functions/SpaceSaveFunctionsMutation.mjs +24 -0
  99. package/dist/network/graphql/builder/Mutations/Space/functions/SpaceTryFunctionMutation.d.ts +4 -0
  100. package/dist/network/graphql/builder/Mutations/Space/functions/SpaceTryFunctionMutation.mjs +15 -0
  101. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeMutation.d.ts +2 -0
  102. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeMutation.mjs +9 -0
  103. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeVariableMutation.d.ts +2 -0
  104. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeVariableMutation.mjs +9 -0
  105. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeSizeMutation.d.ts +2 -0
  106. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeSizeMutation.mjs +9 -0
  107. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeVariableMutation.d.ts +2 -0
  108. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeVariableMutation.mjs +9 -0
  109. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStartRuntimeMutation.d.ts +2 -0
  110. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStartRuntimeMutation.mjs +9 -0
  111. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStopRuntimeMutation.d.ts +2 -0
  112. package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStopRuntimeMutation.mjs +9 -0
  113. package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceAddVisitorMutation.d.ts +2 -0
  114. package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceAddVisitorMutation.mjs +11 -0
  115. package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceRemoveVisitorMutation.d.ts +2 -0
  116. package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceRemoveVisitorMutation.mjs +11 -0
  117. package/dist/network/graphql/builder/Mutations/index.d.ts +28 -0
  118. package/dist/network/graphql/builder/Mutations/index.mjs +108 -84
  119. package/dist/network/graphql/builder/Queries/Space/SpaceChangesQuery.d.ts +23 -0
  120. package/dist/network/graphql/builder/Queries/Space/SpaceChangesQuery.mjs +49 -0
  121. package/dist/network/graphql/builder/Queries/Space/SpaceFunctionsQuery.d.ts +6 -0
  122. package/dist/network/graphql/builder/Queries/Space/SpaceFunctionsQuery.mjs +13 -0
  123. package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.d.ts +17 -0
  124. package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.mjs +22 -0
  125. package/dist/network/graphql/builder/Queries/Space/SpaceRuntimeQuery.d.ts +6 -0
  126. package/dist/network/graphql/builder/Queries/Space/SpaceRuntimeQuery.mjs +32 -0
  127. package/dist/network/graphql/builder/Queries/Space/SpaceVisitorsQuery.d.ts +6 -0
  128. package/dist/network/graphql/builder/Queries/Space/SpaceVisitorsQuery.mjs +16 -0
  129. package/dist/network/graphql/builder/Queries/index.d.ts +17 -3
  130. package/dist/network/graphql/builder/Queries/index.mjs +30 -22
  131. package/dist/network/graphql/sdk/Mutations/index.d.ts +1 -1
  132. package/dist/network/graphql/sdk/Queries/InitQuery.d.ts +1 -1
  133. package/dist/network/graphql/sdk/Queries/InitQuery.mjs +2 -91
  134. package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.d.ts +1 -1
  135. package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.mjs +2 -44
  136. package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.d.ts +1 -1
  137. package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.mjs +2 -55
  138. package/dist/network/graphql/sdk/Queries/index.d.ts +1 -5
  139. package/dist/network/index.mjs +7 -7
  140. package/dist/network/spaceEvents.d.ts +33 -3
  141. package/dist/network/spaceEvents.mjs +102 -89
  142. package/dist/realtime/client.d.ts +46 -0
  143. package/dist/realtime/client.mjs +192 -0
  144. package/dist/realtime/index.d.ts +6 -0
  145. package/dist/realtime/index.mjs +4 -0
  146. package/dist/realtime/presence.d.ts +38 -0
  147. package/dist/realtime/presence.mjs +70 -0
  148. package/dist/realtime/topics.d.ts +36 -0
  149. package/dist/realtime/topics.mjs +25 -0
  150. package/dist/schema/serverElements.d.ts +5 -0
  151. package/dist/schema/serverElements.mjs +15 -14
  152. package/dist/server/actions/useRealtimeSync.d.ts +9 -0
  153. package/dist/server/actions/useRealtimeSync.mjs +7 -0
  154. package/dist/state/index.d.ts +1 -0
  155. package/dist/state/index.mjs +3 -2
  156. package/dist/state/paintedState.d.ts +52 -0
  157. package/dist/state/paintedState.mjs +37 -0
  158. package/dist/state/runtimeStatePersist.d.ts +24 -0
  159. package/dist/state/runtimeStatePersist.mjs +113 -10
  160. package/dist/store/index.d.ts +45 -45
  161. package/dist/store/renderSettings.d.ts +6 -3
  162. package/dist/store/tracing/index.d.ts +1 -0
  163. package/dist/store/tracing/tracingCollector.d.ts +17 -1
  164. package/dist/store/tracing/tracingCollector.mjs +5 -0
  165. package/dist/style/index.d.ts +1 -0
  166. package/dist/style/index.mjs +3 -2
  167. package/dist/style/runtimeStyle.d.ts +29 -0
  168. package/dist/style/runtimeStyle.mjs +7 -0
  169. package/dist/style/styleConstants.d.ts +3 -2
  170. package/dist/style/styleConstants.mjs +2 -0
  171. package/dist/style/styleStates.d.ts +14 -1
  172. package/dist/style/styleStates.mjs +10 -7
  173. package/dist/theme/ThemeProvider.d.ts +1 -1
  174. package/dist/theme/ThemeProvider.mjs +35 -29
  175. package/dist/theme/themeCookie.mjs +11 -15
  176. package/dist/types/ActionTypes.d.ts +193 -0
  177. package/dist/types/AuthTypes.d.ts +11 -1
  178. package/dist/types/CommonTypes.d.ts +6 -0
  179. package/dist/types/FunctionTypes.d.ts +52 -0
  180. package/dist/types/FunctionTypes.mjs +0 -0
  181. package/dist/types/PluginTypes.d.ts +0 -1
  182. package/dist/types/RealtimeTypes.d.ts +94 -0
  183. package/dist/types/RealtimeTypes.mjs +0 -0
  184. package/dist/types/SchemaTypes.d.ts +54 -0
  185. package/dist/types/SchemaTypes.mjs +8 -0
  186. package/dist/types/ServerTypes.d.ts +310 -15
  187. package/dist/types/SpaceTypes.d.ts +53 -0
  188. package/dist/types/StateTypes.d.ts +6 -0
  189. package/dist/types/StoreTypes.d.ts +12 -1
  190. package/dist/types/index.d.ts +2 -0
  191. package/dist/types/index.mjs +3 -2
  192. package/package.json +190 -21
  193. package/vite.config.ts +0 -12
  194. package/dist/network/graphql/builder/Queries/PluginsQuery.d.ts +0 -9
  195. package/dist/network/graphql/builder/Queries/PluginsQuery.mjs +0 -54
@@ -9,9 +9,12 @@ export declare const DEFAULT_RENDER_SETTINGS: Required<RenderSettings>;
9
9
  * A nested scope that seeds `render` SHADOWS the whole slice — reads do not fall through key by key, whichever way
10
10
  * they are written — so a subtree that overrides one flag must restate the rest ({@link useRenderOverride}). */
11
11
  declare const useRenderSettings: () => Required<RenderSettings>;
12
- /** Builds the value for a `<StoreProvider>` that renders a subtree under different settings — the builder's preview
13
- * pane being preview whatever the editor's own toggle says. Carries the surrounding settings over explicitly,
14
- * because the scope shadows the slice: what an override leaves out is NOT inherited, it is lost.
12
+ /** Builds the value for a `<StoreProvider inherit="live">` that renders a subtree under different settings — the
13
+ * builder's preview pane being preview whatever the editor's own toggle says. Carries the surrounding settings over
14
+ * explicitly, because the scope shadows the slice: what an override leaves out is NOT inherited, it is lost.
15
+ *
16
+ * `inherit="live"` is not optional. A nexus scope inherits nothing by default, so without it the subtree sees a store
17
+ * holding `render` and nothing else — no `schema`, no `style` — and every element in it fails to find itself.
15
18
  *
16
19
  * `overrides` has to be referentially stable (a module-level constant), like any memo input. */
17
20
  export declare const useRenderOverride: (overrides: RenderSettings) => {
@@ -5,4 +5,5 @@ export { MAX_COMMITS, createTracingState } from './tracingStore';
5
5
  export { previewValue, diffProps } from './preview';
6
6
  export { tracingMiddleware } from './tracingMiddleware';
7
7
  export type { UseTracingReturn } from './useTracing';
8
+ export type { TracingReader } from './tracingCollector';
8
9
  export { tracingStore, tracingCollector, useTracing };
@@ -1,7 +1,23 @@
1
- import { PropChange } from '../../types';
1
+ import { CommitEntry, PropChange } from '../../types';
2
2
  import { ProfilerOnRenderCallback } from 'react';
3
+ /**
4
+ * What the SDK publishes as `window.plitziTracing` while its render tracing is on (`debugMode`): the commits since a
5
+ * mark, for a test to ask which elements an interaction rendered — `inspectRenders` in `@plitzi/sdk-authoring/testing`.
6
+ */
7
+ export type TracingReader = {
8
+ lastCommitId: () => number;
9
+ commitsSince: (commitId: number) => CommitEntry[];
10
+ };
11
+ declare global {
12
+ interface Window {
13
+ /** Present while render tracing is on (`debugMode`) — see {@link TracingReader}. */
14
+ plitziTracing?: TracingReader;
15
+ }
16
+ }
3
17
  declare const tracingCollector: {
4
18
  onRender: ProfilerOnRenderCallback;
19
+ lastCommitId: () => number;
20
+ commitsSince: (commitId: number) => CommitEntry[];
5
21
  linkParent: (id: string, parentId: string | undefined, elementId: string) => void;
6
22
  markMounted: (id: string) => void;
7
23
  markUnmounted: (id: string) => void;
@@ -73,6 +73,11 @@ var r = n({ max: 30 }), i = [], a = /* @__PURE__ */ new Map(), o = /* @__PURE__
73
73
  causes: D()
74
74
  })), h && (u.set(e, a.get(f)?.commitId ?? g), l = !0), _ || (_ = !0, y(T));
75
75
  },
76
+ lastCommitId: () => g,
77
+ commitsSince: (e) => {
78
+ let t = [...a.values()].sort((e, t) => e.timestamp - t.timestamp);
79
+ return [...i, ...t].filter((t) => t.commitId > e);
80
+ },
76
81
  linkParent: E,
77
82
  markMounted: (e) => {
78
83
  d.delete(e) && (l = !0);
@@ -3,6 +3,7 @@ export * from './fontAssets';
3
3
  export * from './fontValidation';
4
4
  export * from './fonts';
5
5
  export * from './fontsFromCss';
6
+ export * from './runtimeStyle';
6
7
  export * from './styleConstants';
7
8
  export * from './styleStates';
8
9
  export { styleConstants };
@@ -3,5 +3,6 @@ import { fontLinkAssets as a } from "./fontAssets.mjs";
3
3
  import { SYSTEM_FONTS as o, availableFonts as s, familiesInCss as c, fontFamilyStack as l, fontUrlResolver as u, fontsToHead as d, googleCss2Url as f, googleTextSubsetUrl as p, isSafeFontUrl as m, primaryFamily as h } from "./fonts.mjs";
4
4
  import { FontValidationError as g, parseSpaceFont as _ } from "./fontValidation.mjs";
5
5
  import { fallbackForFamily as v, fontsFromCss as y } from "./fontsFromCss.mjs";
6
- import { STYLE_STATES as b, STYLE_STATE_LABELS as x, inCascadeOrder as S, isKnownState as C } from "./styleStates.mjs";
7
- export { t as EMPTY_STYLE_SCHEMA, g as FontValidationError, b as STYLE_STATES, x as STYLE_STATE_LABELS, o as SYSTEM_FONTS, n as StyleBindingsAllowed, s as availableFonts, r as baseDefaultValue, v as fallbackForFamily, c as familiesInCss, l as fontFamilyStack, a as fontLinkAssets, u as fontUrlResolver, y as fontsFromCss, d as fontsToHead, f as googleCss2Url, p as googleTextSubsetUrl, S as inCascadeOrder, i as inheritableAttributesBase, C as isKnownState, m as isSafeFontUrl, _ as parseSpaceFont, h as primaryFamily, e as styleConstants };
6
+ import { RUNTIME_STYLE_ID as b, markStyleCache as x, styleCacheFromDocument as S, styleCacheTravelsInDocument as C } from "./runtimeStyle.mjs";
7
+ import { HIDDEN_CLASS as w, STYLE_STATES as T, STYLE_STATE_LABELS as E, inCascadeOrder as D, isKnownState as O, isStartingState as k, stateSuffix as A } from "./styleStates.mjs";
8
+ export { t as EMPTY_STYLE_SCHEMA, g as FontValidationError, w as HIDDEN_CLASS, b as RUNTIME_STYLE_ID, T as STYLE_STATES, E as STYLE_STATE_LABELS, o as SYSTEM_FONTS, n as StyleBindingsAllowed, s as availableFonts, r as baseDefaultValue, v as fallbackForFamily, c as familiesInCss, l as fontFamilyStack, a as fontLinkAssets, u as fontUrlResolver, y as fontsFromCss, d as fontsToHead, f as googleCss2Url, p as googleTextSubsetUrl, D as inCascadeOrder, i as inheritableAttributesBase, O as isKnownState, m as isSafeFontUrl, k as isStartingState, x as markStyleCache, _ as parseSpaceFont, h as primaryFamily, A as stateSuffix, S as styleCacheFromDocument, C as styleCacheTravelsInDocument, e as styleConstants };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The space's compiled stylesheet (`style.cache`) on a server-rendered page, which carries it once.
3
+ *
4
+ * The runtime `<style>` the page renders already holds the cache, verbatim, so sending it again in the hydration payload
5
+ * made every page ship its stylesheet twice. Instead the server leaves it out of the payload, and the browser reads it
6
+ * back from that `<style>` before hydrating — the same string, so the client renders the same markup and the store
7
+ * holds the same cache it always did.
8
+ *
9
+ * The cache sits between two comment markers inside the runtime stylesheet: a comment changes nothing about the
10
+ * cascade, and the element and its place in the tree stay exactly what they were.
11
+ */
12
+ /** The `data-id` of the stylesheet the SDK renders into the page. */
13
+ export declare const RUNTIME_STYLE_ID = "plitzi-runtime-style";
14
+ /** The cache as the runtime stylesheet embeds it, between the markers `styleCacheFromDocument` reads it by. */
15
+ export declare const markStyleCache: (cache: string) => string;
16
+ /**
17
+ * Whether the cache reads back from the document byte for byte, so it can be left out of the payload.
18
+ *
19
+ * - `{{ token }}`: the stylesheet holds the cache with its tokens already replaced, and the browser needs the tokens to
20
+ * replace them again when a variable changes.
21
+ * - `<`: React escapes a `<style` inside a stylesheet as it renders it, so the text would not come back as it went.
22
+ * - `\r` and `\0`: the HTML parser normalises both.
23
+ * - The end marker: the cache would end early.
24
+ *
25
+ * An empty cache has nothing to save.
26
+ */
27
+ export declare const styleCacheTravelsInDocument: (cache: string) => boolean;
28
+ /** The cache the server left in the runtime stylesheet under `root`, or `undefined` when there is none to read. */
29
+ export declare const styleCacheFromDocument: (root: ParentNode) => string | undefined;
@@ -0,0 +1,7 @@
1
+ //#region src/style/runtimeStyle.ts
2
+ var e = "plitzi-runtime-style", t = "/*plitzi:style-cache*/", n = "/*plitzi:style-cache-end*/", r = (e) => `${t}${e}${n}`, i = (e) => e !== "" && !/\{\{|<|\r|\0/.test(e) && !e.includes(n), a = (e) => {
3
+ let r = e.querySelector("style[data-id=\"plitzi-runtime-style\"]")?.textContent ?? "", i = r.indexOf(t), a = r.indexOf(n, i);
4
+ if (!(i < 0 || a < 0)) return r.slice(i + 22, a);
5
+ };
6
+ //#endregion
7
+ export { e as RUNTIME_STYLE_ID, r as markStyleCache, a as styleCacheFromDocument, i as styleCacheTravelsInDocument };
@@ -69,6 +69,7 @@ declare const styleConstants: {
69
69
  readonly TRANSITION_DURATION: "transition-duration";
70
70
  readonly TRANSITION_TIMING_FUNCTION: "transition-timing-function";
71
71
  readonly TRANSITION_DELAY: "transition-delay";
72
+ readonly TRANSITION_BEHAVIOR: "transition-behavior";
72
73
  readonly ANIMATION: "animation";
73
74
  readonly ANIMATION_NAME: "animation-name";
74
75
  readonly ANIMATION_DURATION: "animation-duration";
@@ -176,8 +177,8 @@ declare const styleConstants: {
176
177
  };
177
178
  export declare const inheritableAttributesBase: StyleCategory[];
178
179
  export declare const StyleBindingsAllowed: {
179
- path: "filter" | "fill" | "color" | "cursor" | "display" | "flex-wrap" | "flex-direction" | "align-items" | "justify-items" | "justify-content" | "align-content" | "row-gap" | "column-gap" | "grid-row-gap" | "grid-column-gap" | "grid-template-areas" | "grid-template-columns" | "grid-template-rows" | "grid-auto-flow" | "grid-auto-rows" | "grid-auto-columns" | "grid-row-start" | "grid-column-start" | "grid-row-end" | "grid-column-end" | "align-self" | "justify-self" | "order" | "flex-grow" | "flex-shrink" | "flex-basis" | "list-style" | "list-style-type" | "list-style-position" | "list-style-image" | "background-color" | "background-image" | "background-position" | "background-size" | "background-repeat" | "background-origin" | "background-clip" | "background-attachment" | "background-blend-mode" | "mask-image" | "border-top-style" | "border-top-width" | "border-top-color" | "border-bottom-style" | "border-bottom-width" | "border-bottom-color" | "border-left-style" | "border-left-width" | "border-left-color" | "border-right-style" | "border-right-width" | "border-right-color" | "border-top-left-radius" | "border-top-right-radius" | "border-bottom-left-radius" | "border-bottom-right-radius" | "border-collapse" | "border-spacing" | "table-layout" | "opacity" | "visibility" | "transition" | "transition-property" | "transition-duration" | "transition-timing-function" | "transition-delay" | "animation" | "animation-name" | "animation-duration" | "animation-timing-function" | "animation-delay" | "animation-iteration-count" | "animation-direction" | "animation-fill-mode" | "animation-play-state" | "animation-timeline" | "animation-range" | "box-shadow" | "backdrop-filter" | "mix-blend-mode" | "isolation" | "clip-path" | "transform" | "transform-origin" | "perspective" | "will-change" | "outline-width" | "outline-style" | "outline-color" | "outline-offset" | "pointer-events" | "user-select" | "touch-action" | "resize" | "appearance" | "scroll-behavior" | "overscroll-behavior" | "accent-color" | "caret-color" | "color-scheme" | "position" | "float" | "clear" | "z-index" | "top" | "bottom" | "left" | "right" | "box-sizing" | "aspect-ratio" | "width" | "height" | "min-width" | "min-height" | "max-width" | "max-height" | "overflow" | "overflow-x" | "overflow-y" | "scrollbar-width" | "scrollbar-color" | "object-fit" | "object-position" | "column-width" | "column-count" | "margin-top" | "margin-bottom" | "margin-left" | "margin-right" | "padding-top" | "padding-bottom" | "padding-left" | "padding-right" | "font-family" | "font-weight" | "font-size" | "line-height" | "text-align" | "font-style" | "font-variant" | "font-variant-numeric" | "font-feature-settings" | "text-decoration" | "text-decoration-line" | "text-decoration-color" | "text-decoration-style" | "text-decoration-thickness" | "text-underline-offset" | "letter-spacing" | "word-spacing" | "text-indent" | "text-transform" | "direction" | "white-space" | "text-wrap" | "word-break" | "overflow-wrap" | "hyphens" | "vertical-align" | "text-overflow" | "text-shadow" | "line-clamp" | "-webkit-line-clamp" | "-webkit-box-orient" | "-webkit-text-fill-color" | "stroke" | "stroke-width";
180
- label: "filter" | "fill" | "color" | "cursor" | "display" | "flex-wrap" | "flex-direction" | "align-items" | "justify-items" | "justify-content" | "align-content" | "row-gap" | "column-gap" | "grid-row-gap" | "grid-column-gap" | "grid-template-areas" | "grid-template-columns" | "grid-template-rows" | "grid-auto-flow" | "grid-auto-rows" | "grid-auto-columns" | "grid-row-start" | "grid-column-start" | "grid-row-end" | "grid-column-end" | "align-self" | "justify-self" | "order" | "flex-grow" | "flex-shrink" | "flex-basis" | "list-style" | "list-style-type" | "list-style-position" | "list-style-image" | "background-color" | "background-image" | "background-position" | "background-size" | "background-repeat" | "background-origin" | "background-clip" | "background-attachment" | "background-blend-mode" | "mask-image" | "border-top-style" | "border-top-width" | "border-top-color" | "border-bottom-style" | "border-bottom-width" | "border-bottom-color" | "border-left-style" | "border-left-width" | "border-left-color" | "border-right-style" | "border-right-width" | "border-right-color" | "border-top-left-radius" | "border-top-right-radius" | "border-bottom-left-radius" | "border-bottom-right-radius" | "border-collapse" | "border-spacing" | "table-layout" | "opacity" | "visibility" | "transition" | "transition-property" | "transition-duration" | "transition-timing-function" | "transition-delay" | "animation" | "animation-name" | "animation-duration" | "animation-timing-function" | "animation-delay" | "animation-iteration-count" | "animation-direction" | "animation-fill-mode" | "animation-play-state" | "animation-timeline" | "animation-range" | "box-shadow" | "backdrop-filter" | "mix-blend-mode" | "isolation" | "clip-path" | "transform" | "transform-origin" | "perspective" | "will-change" | "outline-width" | "outline-style" | "outline-color" | "outline-offset" | "pointer-events" | "user-select" | "touch-action" | "resize" | "appearance" | "scroll-behavior" | "overscroll-behavior" | "accent-color" | "caret-color" | "color-scheme" | "position" | "float" | "clear" | "z-index" | "top" | "bottom" | "left" | "right" | "box-sizing" | "aspect-ratio" | "width" | "height" | "min-width" | "min-height" | "max-width" | "max-height" | "overflow" | "overflow-x" | "overflow-y" | "scrollbar-width" | "scrollbar-color" | "object-fit" | "object-position" | "column-width" | "column-count" | "margin-top" | "margin-bottom" | "margin-left" | "margin-right" | "padding-top" | "padding-bottom" | "padding-left" | "padding-right" | "font-family" | "font-weight" | "font-size" | "line-height" | "text-align" | "font-style" | "font-variant" | "font-variant-numeric" | "font-feature-settings" | "text-decoration" | "text-decoration-line" | "text-decoration-color" | "text-decoration-style" | "text-decoration-thickness" | "text-underline-offset" | "letter-spacing" | "word-spacing" | "text-indent" | "text-transform" | "direction" | "white-space" | "text-wrap" | "word-break" | "overflow-wrap" | "hyphens" | "vertical-align" | "text-overflow" | "text-shadow" | "line-clamp" | "-webkit-line-clamp" | "-webkit-box-orient" | "-webkit-text-fill-color" | "stroke" | "stroke-width";
180
+ path: "color" | "cursor" | "display" | "flex-wrap" | "flex-direction" | "align-items" | "justify-items" | "justify-content" | "align-content" | "row-gap" | "column-gap" | "grid-row-gap" | "grid-column-gap" | "grid-template-areas" | "grid-template-columns" | "grid-template-rows" | "grid-auto-flow" | "grid-auto-rows" | "grid-auto-columns" | "grid-row-start" | "grid-column-start" | "grid-row-end" | "grid-column-end" | "align-self" | "justify-self" | "order" | "flex-grow" | "flex-shrink" | "flex-basis" | "list-style" | "list-style-type" | "list-style-position" | "list-style-image" | "background-color" | "background-image" | "background-position" | "background-size" | "background-repeat" | "background-origin" | "background-clip" | "background-attachment" | "background-blend-mode" | "mask-image" | "border-top-style" | "border-top-width" | "border-top-color" | "border-bottom-style" | "border-bottom-width" | "border-bottom-color" | "border-left-style" | "border-left-width" | "border-left-color" | "border-right-style" | "border-right-width" | "border-right-color" | "border-top-left-radius" | "border-top-right-radius" | "border-bottom-left-radius" | "border-bottom-right-radius" | "border-collapse" | "border-spacing" | "table-layout" | "opacity" | "visibility" | "transition" | "transition-property" | "transition-duration" | "transition-timing-function" | "transition-delay" | "transition-behavior" | "animation" | "animation-name" | "animation-duration" | "animation-timing-function" | "animation-delay" | "animation-iteration-count" | "animation-direction" | "animation-fill-mode" | "animation-play-state" | "animation-timeline" | "animation-range" | "box-shadow" | "filter" | "backdrop-filter" | "mix-blend-mode" | "isolation" | "clip-path" | "transform" | "transform-origin" | "perspective" | "will-change" | "outline-width" | "outline-style" | "outline-color" | "outline-offset" | "pointer-events" | "user-select" | "touch-action" | "resize" | "appearance" | "scroll-behavior" | "overscroll-behavior" | "accent-color" | "caret-color" | "color-scheme" | "position" | "float" | "clear" | "z-index" | "top" | "bottom" | "left" | "right" | "box-sizing" | "aspect-ratio" | "width" | "height" | "min-width" | "min-height" | "max-width" | "max-height" | "overflow" | "overflow-x" | "overflow-y" | "scrollbar-width" | "scrollbar-color" | "object-fit" | "object-position" | "column-width" | "column-count" | "margin-top" | "margin-bottom" | "margin-left" | "margin-right" | "padding-top" | "padding-bottom" | "padding-left" | "padding-right" | "font-family" | "font-weight" | "font-size" | "line-height" | "text-align" | "font-style" | "font-variant" | "font-variant-numeric" | "font-feature-settings" | "text-decoration" | "text-decoration-line" | "text-decoration-color" | "text-decoration-style" | "text-decoration-thickness" | "text-underline-offset" | "letter-spacing" | "word-spacing" | "text-indent" | "text-transform" | "direction" | "white-space" | "text-wrap" | "word-break" | "overflow-wrap" | "hyphens" | "vertical-align" | "text-overflow" | "text-shadow" | "line-clamp" | "-webkit-line-clamp" | "-webkit-box-orient" | "-webkit-text-fill-color" | "fill" | "stroke" | "stroke-width";
181
+ label: "color" | "cursor" | "display" | "flex-wrap" | "flex-direction" | "align-items" | "justify-items" | "justify-content" | "align-content" | "row-gap" | "column-gap" | "grid-row-gap" | "grid-column-gap" | "grid-template-areas" | "grid-template-columns" | "grid-template-rows" | "grid-auto-flow" | "grid-auto-rows" | "grid-auto-columns" | "grid-row-start" | "grid-column-start" | "grid-row-end" | "grid-column-end" | "align-self" | "justify-self" | "order" | "flex-grow" | "flex-shrink" | "flex-basis" | "list-style" | "list-style-type" | "list-style-position" | "list-style-image" | "background-color" | "background-image" | "background-position" | "background-size" | "background-repeat" | "background-origin" | "background-clip" | "background-attachment" | "background-blend-mode" | "mask-image" | "border-top-style" | "border-top-width" | "border-top-color" | "border-bottom-style" | "border-bottom-width" | "border-bottom-color" | "border-left-style" | "border-left-width" | "border-left-color" | "border-right-style" | "border-right-width" | "border-right-color" | "border-top-left-radius" | "border-top-right-radius" | "border-bottom-left-radius" | "border-bottom-right-radius" | "border-collapse" | "border-spacing" | "table-layout" | "opacity" | "visibility" | "transition" | "transition-property" | "transition-duration" | "transition-timing-function" | "transition-delay" | "transition-behavior" | "animation" | "animation-name" | "animation-duration" | "animation-timing-function" | "animation-delay" | "animation-iteration-count" | "animation-direction" | "animation-fill-mode" | "animation-play-state" | "animation-timeline" | "animation-range" | "box-shadow" | "filter" | "backdrop-filter" | "mix-blend-mode" | "isolation" | "clip-path" | "transform" | "transform-origin" | "perspective" | "will-change" | "outline-width" | "outline-style" | "outline-color" | "outline-offset" | "pointer-events" | "user-select" | "touch-action" | "resize" | "appearance" | "scroll-behavior" | "overscroll-behavior" | "accent-color" | "caret-color" | "color-scheme" | "position" | "float" | "clear" | "z-index" | "top" | "bottom" | "left" | "right" | "box-sizing" | "aspect-ratio" | "width" | "height" | "min-width" | "min-height" | "max-width" | "max-height" | "overflow" | "overflow-x" | "overflow-y" | "scrollbar-width" | "scrollbar-color" | "object-fit" | "object-position" | "column-width" | "column-count" | "margin-top" | "margin-bottom" | "margin-left" | "margin-right" | "padding-top" | "padding-bottom" | "padding-left" | "padding-right" | "font-family" | "font-weight" | "font-size" | "line-height" | "text-align" | "font-style" | "font-variant" | "font-variant-numeric" | "font-feature-settings" | "text-decoration" | "text-decoration-line" | "text-decoration-color" | "text-decoration-style" | "text-decoration-thickness" | "text-underline-offset" | "letter-spacing" | "word-spacing" | "text-indent" | "text-transform" | "direction" | "white-space" | "text-wrap" | "word-break" | "overflow-wrap" | "hyphens" | "vertical-align" | "text-overflow" | "text-shadow" | "line-clamp" | "-webkit-line-clamp" | "-webkit-box-orient" | "-webkit-text-fill-color" | "fill" | "stroke" | "stroke-width";
181
182
  }[];
182
183
  export declare const baseDefaultValue: Record<StyleCategory, StyleValue>;
183
184
  export default styleConstants;
@@ -82,6 +82,7 @@ var e = {
82
82
  TRANSITION_DURATION: "transition-duration",
83
83
  TRANSITION_TIMING_FUNCTION: "transition-timing-function",
84
84
  TRANSITION_DELAY: "transition-delay",
85
+ TRANSITION_BEHAVIOR: "transition-behavior",
85
86
  ANIMATION: "animation",
86
87
  ANIMATION_NAME: "animation-name",
87
88
  ANIMATION_DURATION: "animation-duration",
@@ -281,6 +282,7 @@ var e = {
281
282
  [t.TRANSITION_DURATION]: "0s",
282
283
  [t.TRANSITION_TIMING_FUNCTION]: "ease",
283
284
  [t.TRANSITION_DELAY]: "0s",
285
+ [t.TRANSITION_BEHAVIOR]: "normal",
284
286
  [t.ANIMATION]: "none",
285
287
  [t.ANIMATION_NAME]: "none",
286
288
  [t.ANIMATION_DURATION]: "0s",
@@ -6,8 +6,14 @@
6
6
  *
7
7
  * `focus-visible` is the focus ring a keyboard user needs and a mouse user does not; `focus-within` dresses a
8
8
  * container while anything inside it has focus — a field wrapper around its input.
9
+ *
10
+ * `hidden` is not a pseudo-class: it is how an element looks while its `visible` says no — where it goes as it hides,
11
+ * and where it comes from as it shows. With a transition on the class (`display` among what it transitions, and
12
+ * `transition-behavior: allow-discrete`), a panel fades or slides in and out instead of blinking.
9
13
  */
10
- export declare const STYLE_STATES: readonly ["hover", "focus", "focus-visible", "focus-within", "active", "disabled", "checked", "visited"];
14
+ export declare const STYLE_STATES: readonly ["hover", "focus", "focus-visible", "focus-within", "active", "disabled", "checked", "visited", "hidden"];
15
+ /** What the SDK puts on an element whose `visible` says no: `display: none`, and what the `hidden` state selects. */
16
+ export declare const HIDDEN_CLASS = "plitzi-component--hidden";
11
17
  export declare const STYLE_STATE_LABELS: Record<(typeof STYLE_STATES)[number], string>;
12
18
  export declare const isKnownState: (state: string) => state is (typeof STYLE_STATES)[number];
13
19
  /**
@@ -15,3 +21,10 @@ export declare const isKnownState: (state: string) => state is (typeof STYLE_STA
15
21
  * A state outside the list keeps its place after the known ones.
16
22
  */
17
23
  export declare const inCascadeOrder: <T>(states: Record<string, T>) => [string, T][];
24
+ /** How a state is written after the selector it modifies: its pseudo-class, or for `hidden` the class that hides. */
25
+ export declare const stateSuffix: (state: string) => string;
26
+ /**
27
+ * Whether a state is also where an element starts from as it appears (`@starting-style`): `hidden` is — a panel that
28
+ * fades out to nothing fades in from it — and every pseudo-class is not.
29
+ */
30
+ export declare const isStartingState: (state: string) => boolean;
@@ -7,8 +7,9 @@ var e = [
7
7
  "active",
8
8
  "disabled",
9
9
  "checked",
10
- "visited"
11
- ], t = {
10
+ "visited",
11
+ "hidden"
12
+ ], t = "plitzi-component--hidden", n = {
12
13
  hover: "Hover",
13
14
  focus: "Focus",
14
15
  "focus-visible": "Focus visible",
@@ -16,8 +17,9 @@ var e = [
16
17
  active: "Active",
17
18
  disabled: "Disabled",
18
19
  checked: "Checked",
19
- visited: "Visited"
20
- }, n = {
20
+ visited: "Visited",
21
+ hidden: "Hidden"
22
+ }, r = {
21
23
  visited: 0,
22
24
  checked: 1,
23
25
  "focus-within": 2,
@@ -25,7 +27,8 @@ var e = [
25
27
  focus: 4,
26
28
  "focus-visible": 5,
27
29
  active: 6,
28
- disabled: 7
29
- }, r = (e) => Object.hasOwn(n, e), i = (t) => r(t) ? n[t] : e.length, a = (e) => Object.entries(e).sort(([e], [t]) => i(e) - i(t));
30
+ disabled: 7,
31
+ hidden: 8
32
+ }, i = (e) => Object.hasOwn(r, e), a = (t) => i(t) ? r[t] : e.length, o = (e) => Object.entries(e).sort(([e], [t]) => a(e) - a(t)), s = (e) => e === "hidden" ? `.${t}` : `:${e}`, c = (e) => e === "hidden";
30
33
  //#endregion
31
- export { e as STYLE_STATES, t as STYLE_STATE_LABELS, a as inCascadeOrder, r as isKnownState };
34
+ export { t as HIDDEN_CLASS, e as STYLE_STATES, n as STYLE_STATE_LABELS, o as inCascadeOrder, i as isKnownState, c as isStartingState, s as stateSuffix };
@@ -38,5 +38,5 @@ export type ThemeProviderProps = {
38
38
  * updating the moment the visitor changes their system setting, which is how a panel ends up dark inside a page
39
39
  * that is still light.
40
40
  */
41
- declare const ThemeProvider: ({ defaultTheme, theme, scope, cookieName, children }: ThemeProviderProps) => import("react").JSX.Element;
41
+ declare const ThemeProvider: ({ defaultTheme, theme, scope, cookieName, children }: ThemeProviderProps) => import('react').JSX.Element;
42
42
  export default ThemeProvider;
@@ -2,11 +2,11 @@ import { THEME_COOKIE_NAME as e, applyThemeClass as t, readThemeCookie as n, wri
2
2
  import i, { createThemeStore as a, resolveScheme as o, setMachineScheme as s, setThemeMode as c } from "./themeStore.mjs";
3
3
  import l from "./ThemeScope.mjs";
4
4
  import { useCommonStoreSync as u } from "../store/index.mjs";
5
- import { use as d, useEffect as f, useId as p, useState as m, useSyncExternalStore as h } from "react";
6
- import { StoreContext as g, useIsomorphicLayoutEffect as _ } from "@plitzi/nexus/react";
7
- import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
5
+ import { use as d, useEffect as f, useId as p, useRef as m, useState as h, useSyncExternalStore as g } from "react";
6
+ import { StoreContext as _, useIsomorphicLayoutEffect as v } from "@plitzi/nexus/react";
7
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
8
8
  //#region src/theme/ThemeProvider.tsx
9
- var x = "(prefers-color-scheme: dark)", S = () => window.matchMedia(x).matches ? "dark" : "light", C = ({ state: e }) => (u([
9
+ var S = "(prefers-color-scheme: dark)", C = () => window.matchMedia(S).matches ? "dark" : "light", w = ({ state: e }) => (u([
10
10
  "theme.mode",
11
11
  "theme.resolved",
12
12
  "theme.areas"
@@ -14,41 +14,47 @@ var x = "(prefers-color-scheme: dark)", S = () => window.matchMedia(x).matches ?
14
14
  e.mode,
15
15
  o(e.mode, e.scheme),
16
16
  e.areas
17
- ]), null), w = ({ defaultTheme: o = "system", theme: u, scope: w = "document", cookieName: T = e, children: E }) => {
18
- let D = w === "container", O = p(), [k] = m(() => D ? a(`theme${O}`) : void 0), A = k ?? i;
19
- _(() => {
20
- let e = D ? void 0 : n(T);
21
- A.batch(() => {
22
- s(S(), A), c(u ?? e ?? o, A);
17
+ ]), null), T = ({ defaultTheme: o = "system", theme: u, scope: T = "document", cookieName: E = e, children: D }) => {
18
+ let O = T === "container", k = p(), [A] = h(() => O ? a(`theme${k}`) : void 0), j = A ?? i, M = m({
19
+ mode: o,
20
+ remembered: !1
21
+ });
22
+ v(() => {
23
+ let e = O ? void 0 : n(E), t = u ?? e ?? o;
24
+ M.current = {
25
+ mode: t,
26
+ remembered: e !== void 0
27
+ }, j.batch(() => {
28
+ s(C(), j), c(t, j);
23
29
  });
24
30
  }, [
25
31
  o,
26
32
  u,
27
- T,
28
- D,
29
- A
33
+ E,
34
+ O,
35
+ j
30
36
  ]);
31
- let j = h(A.subscribe, A.getState, A.getState), M = d(g) !== void 0;
37
+ let N = g(j.subscribe, j.getState, j.getState), P = d(_) !== void 0;
32
38
  f(() => {
33
- let e = window.matchMedia(x), t = () => s(e.matches ? "dark" : "light", A);
39
+ let e = window.matchMedia(S), t = () => s(e.matches ? "dark" : "light", j);
34
40
  return e.addEventListener("change", t), t(), () => e.removeEventListener("change", t);
35
- }, [A]), f(() => {
36
- if (D) return;
41
+ }, [j]), f(() => {
42
+ if (O) return;
37
43
  let e = () => {
38
- let { mode: e } = A.getState();
39
- r(e, T), t(e, document.documentElement);
44
+ let { mode: e } = j.getState();
45
+ (M.current.remembered || e !== M.current.mode) && (r(e, E), M.current.remembered = !0), t(e, document.documentElement);
40
46
  };
41
- return e(), A.subscribe(e);
47
+ return e(), j.subscribe(e);
42
48
  }, [
43
- T,
44
- D,
45
- A
49
+ E,
50
+ O,
51
+ j
46
52
  ]);
47
- let N = M ? /* @__PURE__ */ y(C, { state: j }) : null;
48
- return D ? /* @__PURE__ */ b(l, {
49
- value: k,
50
- children: [N, E]
51
- }) : /* @__PURE__ */ b(v, { children: [N, E] });
53
+ let F = P ? /* @__PURE__ */ b(w, { state: N }) : null;
54
+ return O ? /* @__PURE__ */ x(l, {
55
+ value: A,
56
+ children: [F, D]
57
+ }) : /* @__PURE__ */ x(y, { children: [F, D] });
52
58
  };
53
59
  //#endregion
54
- export { w as default };
60
+ export { T as default };
@@ -1,24 +1,20 @@
1
+ import { cookieFromHeader as e } from "../helpers/cookies.mjs";
1
2
  //#region src/theme/themeCookie.ts
2
- var e = "theme", t = ["dark", "light"], n = [...t, "system"], r = 31536e3, i = (e) => n.includes(e), a = (e, n) => {
3
- for (let r of t) n.classList.toggle(r, e === r);
4
- }, o = (t, n = e) => {
5
- if (t) for (let e of t.split(";")) {
6
- let t = e.indexOf("=");
7
- if (t > -1 && e.slice(0, t).trim() === n) {
8
- let n = decodeURIComponent(e.slice(t + 1).trim());
9
- return i(n) ? n : void 0;
10
- }
11
- }
12
- }, s = (t = e) => {
3
+ var t = "theme", n = ["dark", "light"], r = [...n, "system"], i = 31536e3, a = (e) => r.includes(e), o = (e, t) => {
4
+ for (let r of n) t.classList.toggle(r, e === r);
5
+ }, s = (n, r = t) => {
6
+ let i = e(n, r);
7
+ return a(i) ? i : void 0;
8
+ }, c = (e = t) => {
13
9
  try {
14
- return o(document.cookie, t);
10
+ return s(document.cookie, e);
15
11
  } catch {
16
12
  return;
17
13
  }
18
- }, c = (t, n = e) => {
14
+ }, l = (e, n = t) => {
19
15
  try {
20
- document.cookie = `${n}=${encodeURIComponent(t)};path=/;max-age=${r};SameSite=Lax`;
16
+ document.cookie = `${n}=${encodeURIComponent(e)};path=/;max-age=${i};SameSite=Lax`;
21
17
  } catch {}
22
18
  };
23
19
  //#endregion
24
- export { t as THEME_CLASSES, e as THEME_COOKIE_NAME, a as applyThemeClass, i as isTheme, s as readThemeCookie, o as themeFromCookies, c as writeThemeCookie };
20
+ export { n as THEME_CLASSES, t as THEME_COOKIE_NAME, o as applyThemeClass, a as isTheme, c as readThemeCookie, s as themeFromCookies, l as writeThemeCookie };
@@ -221,6 +221,8 @@ export type ActionRunReport = {
221
221
  status: ActionRunStatus;
222
222
  output: Record<string, unknown>;
223
223
  trace: Record<string, unknown>[];
224
+ /** Each step as it ran — status, timing, error, and what it logged. */
225
+ steps: ActionRunStep[];
224
226
  };
225
227
  /**
226
228
  * Whether the CLIENT flow waits. The server side is synchronous in every mode: `detached` means the step does not
@@ -343,6 +345,8 @@ export type ActionRunStep = {
343
345
  endTime: number;
344
346
  /** Why it failed, redacted of every credential value the run resolved. */
345
347
  error?: string;
348
+ /** What the step logged (`ctx.log`), redacted the same way; at most a hundred lines of a thousand characters. */
349
+ logs?: string[];
346
350
  };
347
351
  /**
348
352
  * A run a page RENDER started, reported to a page whose debugging is authorized.
@@ -495,3 +499,192 @@ export type ActionStreamFrame = {
495
499
  event: 'error';
496
500
  data: ActionCallError;
497
501
  };
502
+ /**
503
+ * Where a job is, as the only durable answer to "did it happen".
504
+ *
505
+ * `pending` is waiting to be taken, `running` is held by a worker under a lease, and the other four are terminal —
506
+ * except that an operator may put a `failed`, `dead` or `cancelled` one back to `pending`. `dead` is a job that
507
+ * used up every attempt it was given: it stays, visibly, because the alternative is work that quietly evaporated.
508
+ */
509
+ export type ActionJobStatus = 'pending' | 'running' | 'succeeded' | 'failed' | 'dead' | 'cancelled';
510
+ /**
511
+ * One go at a job, kept forever on the job itself.
512
+ *
513
+ * `lost` is the attempt nobody reported: a worker took the job, its lease ran out, and another worker found it
514
+ * abandoned. It is the record of a replica that died mid-run, which is otherwise the one failure that leaves no
515
+ * trace anywhere — and the reason this list exists rather than a single `error` field.
516
+ */
517
+ export type ActionJobAttempt = {
518
+ attempt: number;
519
+ status: 'succeeded' | 'failed' | 'cancelled' | 'lost';
520
+ /** Epoch ms, from the QUEUE's clock — never a worker's own. */
521
+ startedAt: number;
522
+ endedAt: number;
523
+ /** Which worker held it, so a bad replica is identifiable from the history alone. */
524
+ workerId: string;
525
+ /** The run this attempt became, when it got far enough to be one. Joins to the run history. */
526
+ runId?: string;
527
+ error?: string;
528
+ };
529
+ /** What starting a job needs. Everything else is the queue's to fill in. */
530
+ export type ActionJobInput = {
531
+ /**
532
+ * The job's identity, and the whole of its exactly-once guarantee.
533
+ *
534
+ * A schedule derives it from the fire it belongs to — `schedule:<space>:<action>:<instant>` — so two replicas
535
+ * reaching the same fire write the same id and the second one is a no-op. Enqueue is idempotent by this, which
536
+ * is what lets a producer crash between enqueuing and recording that it did.
537
+ */
538
+ id: string;
539
+ spaceId: number;
540
+ actionId: string;
541
+ environment: Environment;
542
+ trigger: ActionTriggerType;
543
+ input: Record<string, unknown>;
544
+ /** The instant this job was due, as the schedule stored it. Epoch ms. */
545
+ dueAt: number;
546
+ maxAttempts: number;
547
+ /** Fires that went by unclaimed before this one. Shown to an operator; never acted on. */
548
+ missed?: number;
549
+ };
550
+ /** One unit of work the queue is holding, as an operator sees it. */
551
+ export type ActionJob = ActionJobInput & {
552
+ status: ActionJobStatus;
553
+ /** Epoch ms before which no worker may take it — a retry's backoff, or the moment it was enqueued. */
554
+ runAt: number;
555
+ attempts: number;
556
+ /** While `running`: the instant the holder's claim lapses and another worker may take it over. */
557
+ leaseUntil?: number;
558
+ workerId?: string;
559
+ runId?: string;
560
+ /** Set by an operator who wants it stopped; the worker holding it reads this and aborts. */
561
+ cancelRequested?: boolean;
562
+ createdAt: number;
563
+ updatedAt: number;
564
+ /** Why the last attempt ended badly. */
565
+ error?: string;
566
+ history: ActionJobAttempt[];
567
+ };
568
+ /**
569
+ * How a worker reports what became of a claim.
570
+ *
571
+ * `delayMs` rather than an instant, and no timestamps: every moment the queue records is read from the QUEUE's
572
+ * clock, because a cluster whose nodes sit in different countries agrees about durations and not about now.
573
+ */
574
+ export type ActionJobSettlement = {
575
+ jobId: string;
576
+ workerId: string;
577
+ status: Extract<ActionJobStatus, 'succeeded' | 'failed' | 'dead' | 'cancelled' | 'pending'>;
578
+ /** For a retry: how long from now before it may be claimed again. */
579
+ delayMs?: number;
580
+ runId?: string;
581
+ error?: string;
582
+ /** The attempt to append to the history. Omitted only when the claim is being handed back untouched. */
583
+ attempt?: Omit<ActionJobAttempt, 'attempt' | 'startedAt' | 'endedAt'>;
584
+ };
585
+ export type ActionJobQuery = {
586
+ spaceIds: number[];
587
+ actionId?: string;
588
+ status?: ActionJobStatus;
589
+ limit: number;
590
+ offset: number;
591
+ };
592
+ /**
593
+ * A recurring intent, as a row rather than as a timer.
594
+ *
595
+ * `nextRunAt` is the point of the whole design: the instant of the next fire is DECIDED ONCE and written down, so
596
+ * every replica afterwards reads the same number instead of asking its own clock whether the moment has come. Two
597
+ * nodes whose clocks differ by a minute then produce the same fires, in the same order, exactly once each — the
598
+ * disagreement moves the WHEN by their skew and can never move the WHETHER.
599
+ */
600
+ export type ActionSchedule = {
601
+ spaceId: number;
602
+ actionId: string;
603
+ cron: string;
604
+ timezone?: string;
605
+ environment: Environment;
606
+ enabled: boolean;
607
+ /** Epoch ms of the next fire this schedule owes. The queue's clock decides when that has arrived. */
608
+ nextRunAt: number;
609
+ /** The last fire actually enqueued. */
610
+ lastFireAt?: number;
611
+ /** Fires that went by while nothing was running to take them. Cumulative, and shown to an operator. */
612
+ missed: number;
613
+ maxAttempts: number;
614
+ updatedAt: number;
615
+ };
616
+ /** A schedule as it is derived from an action document — everything the queue does not own itself. */
617
+ export type ActionScheduleInput = Omit<ActionSchedule, 'missed' | 'updatedAt' | 'lastFireAt'>;
618
+ /**
619
+ * Where a deployment keeps its jobs and schedules.
620
+ *
621
+ * The same kind of seam as {@link ActionKvAdapter} and for the same reason — the server never learns where a
622
+ * deployment stores anything — but with one rule this one cannot be written without, and it is written here so no
623
+ * deployment has to rediscover it:
624
+ *
625
+ * **Every instant comes from the store.** `now` is the cluster's clock, and every comparison the queue makes
626
+ * internally — is this schedule due, has this lease lapsed, may this retry be claimed — is made against it, never
627
+ * against the caller's. That is why `settle` takes a `delayMs` and not a deadline, and why `claim` takes a
628
+ * `leaseMs` and not a `leaseUntil`: durations survive a cluster spread across time zones and machines whose clocks
629
+ * drift, and absolute instants minted by a caller do not.
630
+ *
631
+ * **`enqueue` is idempotent by `id`,** and answers whether it was the one that created the job. That, and nothing
632
+ * else, is what makes a fire happen exactly once when several replicas are racing to produce it.
633
+ *
634
+ * **`claim` is atomic, and it also reaps.** A job whose lease has lapsed is a job whose worker died, and it is
635
+ * taken by whoever claims next — the same operation, because a separate reaper is a second thing to deploy, to
636
+ * schedule and to forget.
637
+ */
638
+ export type ActionJobQueue = {
639
+ /** The cluster's clock. The only clock anything in the scheduling path is allowed to read. */
640
+ now: () => Promise<Date>;
641
+ /** True when this call created the job; false when that id was already there. Never throws on a duplicate. */
642
+ enqueue: (job: ActionJobInput) => Promise<boolean>;
643
+ /**
644
+ * Takes up to `limit` jobs that are due, and any whose lease has lapsed — atomically, one worker per job.
645
+ *
646
+ * A reclaimed job arrives with its previous holder's attempt already written to the history as `lost`.
647
+ */
648
+ claim: (params: {
649
+ workerId: string;
650
+ leaseMs: number;
651
+ limit: number;
652
+ }) => Promise<ActionJob[]>;
653
+ /** Extends the lease on jobs this worker still holds, and answers which of them an operator asked to cancel. */
654
+ heartbeat: (params: {
655
+ jobIds: string[];
656
+ workerId: string;
657
+ leaseMs: number;
658
+ }) => Promise<string[]>;
659
+ settle: (settlement: ActionJobSettlement) => Promise<void>;
660
+ /** Due schedules, oldest fire first. */
661
+ dueSchedules: (limit: number) => Promise<ActionSchedule[]>;
662
+ /**
663
+ * Moves a schedule forward, but only if it is still where the caller last saw it.
664
+ *
665
+ * The compare-and-set is what stops two replicas from advancing the same schedule twice. Answers false when
666
+ * somebody else got there first, which is not an error — it is the other replica having done the work.
667
+ */
668
+ advanceSchedule: (params: {
669
+ spaceId: number;
670
+ actionId: string;
671
+ from: number;
672
+ to: number;
673
+ missed: number;
674
+ }) => Promise<boolean>;
675
+ /** Replaces what this space has scheduled. An action no longer listed stops having a schedule at all. */
676
+ putSchedules: (params: {
677
+ spaceId: number;
678
+ schedules: ActionScheduleInput[];
679
+ }) => Promise<void>;
680
+ listJobs: (query: ActionJobQuery) => Promise<{
681
+ jobs: ActionJob[];
682
+ total: number;
683
+ }>;
684
+ getJob: (spaceIds: number[], jobId: string) => Promise<ActionJob | undefined>;
685
+ listSchedules: (spaceIds: number[]) => Promise<ActionSchedule[]>;
686
+ /** An operator putting a finished job back in the queue. Answers false when it is not in a state to go back. */
687
+ requeue: (spaceIds: number[], jobId: string) => Promise<boolean>;
688
+ /** An operator stopping a job: dropped if it is waiting, aborted at its next step if it is running. */
689
+ cancel: (spaceIds: number[], jobId: string) => Promise<boolean>;
690
+ };
@@ -33,6 +33,16 @@ export type AuthGrant<U = Record<string, unknown>> = {
33
33
  user?: U;
34
34
  token?: TokenResult;
35
35
  };
36
+ /**
37
+ * A right password that bought a CHALLENGE and not a session: the account has a second factor, and `mfaToken` is what
38
+ * the code is completed against (`auth.login` with `mode: 'mfa'`). Not a failure of the session — nothing was lost —
39
+ * which is why it is not one of the {@link AuthFailureReason}s.
40
+ */
41
+ export type MfaChallenge = {
42
+ ok: false;
43
+ reason: 'mfa';
44
+ mfaToken: string;
45
+ };
36
46
  export type AuthResult<U = Record<string, unknown>> = ({
37
47
  ok: true;
38
48
  } & AuthGrant<U>) | {
@@ -54,7 +64,7 @@ export type LoginResult = ({
54
64
  } & TokenResult) | {
55
65
  ok: false;
56
66
  reason: AuthFailureReason;
57
- };
67
+ } | MfaChallenge;
58
68
  export type AuthContextValue = {
59
69
  /** The credentials your login endpoint expects. Values arrive from interaction parameters, hence `unknown`. */
60
70
  login: (params: Record<string, unknown>) => Promise<LoginResult>;