@plitzi/sdk-shared 0.37.8 → 0.37.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/CHANGELOG.md +817 -0
  2. package/dist/actions/functions.d.ts +12 -3
  3. package/dist/actions/functions.mjs +8 -5
  4. package/dist/actions/index.d.ts +2 -2
  5. package/dist/actions/index.mjs +6 -6
  6. package/dist/actions/triggerParams.mjs +7 -6
  7. package/dist/actions/validateDocument.d.ts +3 -0
  8. package/dist/actions/validateDocument.mjs +89 -88
  9. package/dist/auth/failureChannel.d.ts +8 -2
  10. package/dist/auth/failureChannel.mjs +1 -3
  11. package/dist/authoring/elementCallbacks.d.ts +65 -0
  12. package/dist/authoring/elementCallbacks.mjs +72 -8
  13. package/dist/authoring/index.mjs +3 -3
  14. package/dist/builder/contexts/BuilderContext.d.ts +18 -7
  15. package/dist/builder/contexts/BuilderContext.mjs +2 -3
  16. package/dist/connectors/index.d.ts +1 -1
  17. package/dist/connectors/index.mjs +2 -2
  18. package/dist/connectors/validateManifest.d.ts +3 -0
  19. package/dist/connectors/validateManifest.mjs +77 -76
  20. package/dist/dataSource/computed.mjs +25 -29
  21. package/dist/dataSource/globalSources.d.ts +15 -0
  22. package/dist/dataSource/globalSources.mjs +13 -0
  23. package/dist/dataSource/index.d.ts +2 -0
  24. package/dist/dataSource/index.mjs +8 -7
  25. package/dist/devTools/DevToolsContext.mjs +2 -3
  26. package/dist/devTools/utils/PlitziConsole.d.ts +9 -0
  27. package/dist/devTools/utils/PlitziConsole.mjs +27 -7
  28. package/dist/elements/ComponentContext.mjs +2 -3
  29. package/dist/flags/flagsCookie.d.ts +26 -0
  30. package/dist/flags/flagsCookie.mjs +20 -0
  31. package/dist/flags/index.d.ts +3 -0
  32. package/dist/flags/index.mjs +4 -0
  33. package/dist/flags/resolveFlags.d.ts +60 -0
  34. package/dist/flags/resolveFlags.mjs +38 -0
  35. package/dist/flags/schemaFlag.d.ts +11 -0
  36. package/dist/flags/schemaFlag.mjs +9 -0
  37. package/dist/flags/useFlagResolution.d.ts +13 -0
  38. package/dist/flags/useFlagResolution.mjs +43 -0
  39. package/dist/helpers/eventTarget.d.ts +10 -0
  40. package/dist/helpers/eventTarget.mjs +4 -0
  41. package/dist/helpers/images.d.ts +18 -0
  42. package/dist/helpers/images.mjs +13 -0
  43. package/dist/helpers/index.d.ts +3 -0
  44. package/dist/helpers/index.mjs +21 -18
  45. package/dist/helpers/interval.d.ts +18 -0
  46. package/dist/helpers/interval.mjs +7 -0
  47. package/dist/helpers/isRecord.d.ts +2 -0
  48. package/dist/helpers/isRecord.mjs +4 -0
  49. package/dist/helpers/scroll.d.ts +42 -0
  50. package/dist/helpers/scroll.mjs +30 -0
  51. package/dist/helpers/sharedContext.d.ts +14 -0
  52. package/dist/helpers/sharedContext.mjs +9 -0
  53. package/dist/helpers/twigWrapper/Evaluator/Evaluator.d.ts +9 -1
  54. package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +13 -8
  55. package/dist/helpers/twigWrapper/Evaluator/index.d.ts +1 -1
  56. package/dist/helpers/twigWrapper/TemplateCache/TemplateCache.mjs +1 -1
  57. package/dist/helpers/twigWrapper/filters/filters.mjs +38 -2
  58. package/dist/helpers/twigWrapper/index.d.ts +1 -0
  59. package/dist/helpers/twigWrapper/processTwig/processTwig.d.ts +2 -1
  60. package/dist/helpers/twigWrapper/processTwig/processTwig.mjs +3 -3
  61. package/dist/helpers/utils.mjs +4 -2
  62. package/dist/history/describe.mjs +4 -1
  63. package/dist/history/diff.d.ts +1 -1
  64. package/dist/history/diff.mjs +11 -9
  65. package/dist/history/types.d.ts +1 -1
  66. package/dist/hooks/index.mjs +5 -5
  67. package/dist/hooks/usePlitziServiceContext.d.ts +1 -2
  68. package/dist/hooks/usePlitziServiceContext.mjs +3 -4
  69. package/dist/index.d.ts +1 -1
  70. package/dist/index.mjs +90 -77
  71. package/dist/navigation/routes.mjs +6 -4
  72. package/dist/network/NetworkContext.mjs +2 -3
  73. package/dist/network/NetworkInternalContext.d.ts +2 -4
  74. package/dist/network/NetworkInternalContext.mjs +2 -3
  75. package/dist/network/graphql/builder/Mutations/Space/SpaceAddSnippetMutation.d.ts +2 -0
  76. package/dist/network/graphql/builder/Mutations/Space/SpaceAddSnippetMutation.mjs +4 -0
  77. package/dist/network/graphql/builder/Mutations/Space/components/SpaceAddComponentMutation.d.ts +4 -0
  78. package/dist/network/graphql/builder/Mutations/Space/components/SpaceAddComponentMutation.mjs +4 -0
  79. package/dist/network/graphql/builder/Mutations/Space/components/SpaceDetachInstanceMutation.d.ts +4 -0
  80. package/dist/network/graphql/builder/Mutations/Space/components/SpaceDetachInstanceMutation.mjs +4 -0
  81. package/dist/network/graphql/builder/Mutations/Space/components/SpaceRemoveComponentMutation.d.ts +4 -0
  82. package/dist/network/graphql/builder/Mutations/Space/components/SpaceRemoveComponentMutation.mjs +4 -0
  83. package/dist/network/graphql/builder/Mutations/Space/components/SpaceUpdateComponentMutation.d.ts +4 -0
  84. package/dist/network/graphql/builder/Mutations/Space/components/SpaceUpdateComponentMutation.mjs +4 -0
  85. package/dist/network/graphql/builder/Mutations/Space/flags/SpacePublishFlagsMutation.d.ts +12 -0
  86. package/dist/network/graphql/builder/Mutations/Space/flags/SpacePublishFlagsMutation.mjs +4 -0
  87. package/dist/network/graphql/builder/Mutations/Space/flags/SpaceRemoveFlagMutation.d.ts +2 -0
  88. package/dist/network/graphql/builder/Mutations/Space/flags/SpaceRemoveFlagMutation.mjs +4 -0
  89. package/dist/network/graphql/builder/Mutations/Space/flags/SpaceSetFlagMutation.d.ts +3 -0
  90. package/dist/network/graphql/builder/Mutations/Space/flags/SpaceSetFlagMutation.mjs +4 -0
  91. package/dist/network/graphql/builder/Mutations/index.d.ts +13 -30
  92. package/dist/network/graphql/builder/Mutations/index.mjs +164 -200
  93. package/dist/network/graphql/builder/Queries/InitQuery.d.ts +4 -3
  94. package/dist/network/graphql/builder/Queries/InitQuery.mjs +1 -1
  95. package/dist/network/graphql/builder/Queries/Space/SpaceActionTasksQuery.d.ts +1 -1
  96. package/dist/network/graphql/builder/Queries/Space/SpaceActionTasksQuery.mjs +1 -1
  97. package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.d.ts +16 -2
  98. package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.mjs +1 -1
  99. package/dist/network/graphql/builder/Queries/Space/SpaceVersionContentsQuery.d.ts +7 -0
  100. package/dist/network/graphql/builder/Queries/Space/SpaceVersionContentsQuery.mjs +4 -0
  101. package/dist/network/graphql/builder/Queries/index.d.ts +3 -5
  102. package/dist/network/graphql/builder/Queries/index.mjs +36 -38
  103. package/dist/network/graphql/builder/Subscriptions/SpaceEventSubscription.d.ts +1 -1
  104. package/dist/network/graphql/sdk/Queries/InitQuery.d.ts +2 -3
  105. package/dist/network/graphql/sdk/Queries/InitQuery.mjs +1 -1
  106. package/dist/network/graphql/sdk/Queries/index.d.ts +0 -4
  107. package/dist/network/graphql/sdk/Queries/index.mjs +2 -8
  108. package/dist/network/index.mjs +8 -7
  109. package/dist/network/spaceEvents.d.ts +25 -195
  110. package/dist/network/spaceEvents.mjs +156 -241
  111. package/dist/realtime/client.mjs +123 -95
  112. package/dist/realtime/topics.mjs +18 -17
  113. package/dist/schema/SchemaContext.mjs +2 -3
  114. package/dist/schema/anchor.d.ts +8 -0
  115. package/dist/schema/anchor.mjs +4 -0
  116. package/dist/schema/index.d.ts +2 -0
  117. package/dist/schema/index.mjs +6 -4
  118. package/dist/schema/schemaConstants.d.ts +2 -0
  119. package/dist/schema/schemaConstants.mjs +4 -3
  120. package/dist/schema/serverElements.d.ts +6 -2
  121. package/dist/schema/serverElements.mjs +17 -16
  122. package/dist/schema/snippet.d.ts +7 -0
  123. package/dist/schema/snippet.mjs +9 -0
  124. package/dist/schema/wire.d.ts +11 -0
  125. package/dist/schema/wire.mjs +27 -0
  126. package/dist/server/actions/useImagesSync.d.ts +9 -0
  127. package/dist/server/actions/useImagesSync.mjs +7 -0
  128. package/dist/server/rsc/refreshRsc.d.ts +3 -1
  129. package/dist/server/rsc/refreshRsc.mjs +17 -16
  130. package/dist/source/export.d.ts +107 -0
  131. package/dist/source/export.mjs +4 -0
  132. package/dist/source/index.d.ts +4 -0
  133. package/dist/source/index.mjs +3 -0
  134. package/dist/source/snapshot.d.ts +51 -0
  135. package/dist/source/snapshot.mjs +81 -0
  136. package/dist/state/paintedState.mjs +13 -12
  137. package/dist/state/runtimeStatePersist.mjs +50 -49
  138. package/dist/store/index.d.ts +45 -45
  139. package/dist/store/renderSettings.d.ts +1 -0
  140. package/dist/store/renderSettings.mjs +9 -5
  141. package/dist/style/breakpoints.d.ts +11 -0
  142. package/dist/style/breakpoints.mjs +8 -0
  143. package/dist/style/displayModes.d.ts +5 -0
  144. package/dist/style/displayModes.mjs +8 -0
  145. package/dist/style/fontValidation.mjs +52 -51
  146. package/dist/style/fonts.d.ts +0 -12
  147. package/dist/style/fonts.mjs +11 -11
  148. package/dist/style/index.d.ts +4 -0
  149. package/dist/style/index.mjs +11 -7
  150. package/dist/style/layoutGrid.d.ts +30 -0
  151. package/dist/style/layoutGrid.mjs +33 -0
  152. package/dist/style/notifications.d.ts +52 -0
  153. package/dist/style/notifications.mjs +55 -0
  154. package/dist/style/snippetStyle.d.ts +23 -0
  155. package/dist/style/snippetStyle.mjs +32 -0
  156. package/dist/style/styleConstants.d.ts +7 -2
  157. package/dist/style/styleConstants.mjs +10 -0
  158. package/dist/style/styleStates.d.ts +11 -2
  159. package/dist/style/styleStates.mjs +12 -9
  160. package/dist/theme/ThemeProvider.mjs +20 -20
  161. package/dist/theme/ThemeScope.mjs +4 -3
  162. package/dist/types/ActionTypes.d.ts +5 -0
  163. package/dist/types/CommonTypes.d.ts +3 -0
  164. package/dist/types/DevToolsTypes.d.ts +29 -4
  165. package/dist/types/ElementTypes.d.ts +6 -5
  166. package/dist/types/EventBridgeTypes.d.ts +2 -2
  167. package/dist/types/FunctionTypes.d.ts +13 -0
  168. package/dist/types/InteractionTypes.d.ts +5 -0
  169. package/dist/types/PluginTypes.d.ts +1 -1
  170. package/dist/types/ResourceTypes.d.ts +2 -2
  171. package/dist/types/SchemaTypes.d.ts +100 -3
  172. package/dist/types/SdkTypes.d.ts +0 -2
  173. package/dist/types/ServerTypes.d.ts +47 -0
  174. package/dist/types/SnippetTypes.d.ts +28 -0
  175. package/dist/types/SpaceTypes.d.ts +36 -0
  176. package/dist/types/StoreTypes.d.ts +39 -3
  177. package/dist/types/StyleTypes.d.ts +1 -1
  178. package/dist/types/index.d.ts +1 -2
  179. package/package.json +143 -138
  180. package/tailwind.config.js +1 -6
  181. package/vite.config.ts +16 -4
  182. package/dist/network/graphql/builder/Mutations/Segment/SegmentAddMutation.d.ts +0 -4
  183. package/dist/network/graphql/builder/Mutations/Segment/SegmentAddMutation.mjs +0 -4
  184. package/dist/network/graphql/builder/Mutations/Segment/SegmentAddTemplateMutation.d.ts +0 -2
  185. package/dist/network/graphql/builder/Mutations/Segment/SegmentAddTemplateMutation.mjs +0 -4
  186. package/dist/network/graphql/builder/Mutations/Segment/SegmentPublishMutation.d.ts +0 -8
  187. package/dist/network/graphql/builder/Mutations/Segment/SegmentPublishMutation.mjs +0 -4
  188. package/dist/network/graphql/builder/Mutations/Segment/SegmentRemoveMutation.d.ts +0 -2
  189. package/dist/network/graphql/builder/Mutations/Segment/SegmentRemoveMutation.mjs +0 -4
  190. package/dist/network/graphql/builder/Mutations/Segment/SegmentUpdateMutation.d.ts +0 -4
  191. package/dist/network/graphql/builder/Mutations/Segment/SegmentUpdateMutation.mjs +0 -4
  192. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentAddElementMutation.d.ts +0 -2
  193. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentAddElementMutation.mjs +0 -4
  194. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentCloneElementMutation.d.ts +0 -2
  195. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentCloneElementMutation.mjs +0 -4
  196. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentMoveElementMutation.d.ts +0 -2
  197. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentMoveElementMutation.mjs +0 -4
  198. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRemoveElementMutation.d.ts +0 -2
  199. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRemoveElementMutation.mjs +0 -4
  200. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRenameElementMutation.d.ts +0 -3
  201. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRenameElementMutation.mjs +0 -4
  202. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementMutation.d.ts +0 -2
  203. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementMutation.mjs +0 -4
  204. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementsMutation.d.ts +0 -2
  205. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementsMutation.mjs +0 -4
  206. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceAddVariableMutation.d.ts +0 -2
  207. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceAddVariableMutation.mjs +0 -4
  208. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceRemoveVariableMutation.d.ts +0 -2
  209. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceRemoveVariableMutation.mjs +0 -4
  210. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceUpdateVariableMutation.d.ts +0 -2
  211. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceUpdateVariableMutation.mjs +0 -4
  212. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleAddSelectorVariableMutation.d.ts +0 -2
  213. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleAddSelectorVariableMutation.mjs +0 -4
  214. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleRemoveSelectorVariableMutation.d.ts +0 -2
  215. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleRemoveSelectorVariableMutation.mjs +0 -4
  216. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleUpdateSelectorVariableMutation.d.ts +0 -2
  217. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleUpdateSelectorVariableMutation.mjs +0 -4
  218. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleAddSelectorMutation.d.ts +0 -2
  219. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleAddSelectorMutation.mjs +0 -4
  220. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorMutation.d.ts +0 -2
  221. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorMutation.mjs +0 -4
  222. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorsMutation.d.ts +0 -2
  223. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorsMutation.mjs +0 -4
  224. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleUpdateSelectorMutation.d.ts +0 -2
  225. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleUpdateSelectorMutation.mjs +0 -4
  226. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleAddVariableMutation.d.ts +0 -2
  227. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleAddVariableMutation.mjs +0 -4
  228. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleRemoveVariableMutation.d.ts +0 -2
  229. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleRemoveVariableMutation.mjs +0 -4
  230. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleUpdateVariableMutation.d.ts +0 -2
  231. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleUpdateVariableMutation.mjs +0 -4
  232. package/dist/network/graphql/builder/Mutations/Space/SpaceAddTemplateMutation.d.ts +0 -2
  233. package/dist/network/graphql/builder/Mutations/Space/SpaceAddTemplateMutation.mjs +0 -4
  234. package/dist/network/graphql/builder/Queries/Segment/SegmentQuery.d.ts +0 -6
  235. package/dist/network/graphql/builder/Queries/Segment/SegmentQuery.mjs +0 -4
  236. package/dist/network/graphql/builder/Queries/Segment/SegmentsQuery.d.ts +0 -9
  237. package/dist/network/graphql/builder/Queries/Segment/SegmentsQuery.mjs +0 -4
  238. package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.d.ts +0 -6
  239. package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.mjs +0 -4
  240. package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.d.ts +0 -9
  241. package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.mjs +0 -4
  242. package/dist/segments/SegmentsContext.d.ts +0 -2
  243. package/dist/segments/SegmentsContext.mjs +0 -6
  244. package/dist/segments/index.d.ts +0 -3
  245. package/dist/segments/index.mjs +0 -2
  246. package/dist/types/SegmentTypes.d.ts +0 -41
  247. package/dist/types/TemplateTypes.d.ts +0 -20
  248. package/dist/types/TemplateTypes.mjs +0 -0
  249. /package/dist/types/{SegmentTypes.mjs → SnippetTypes.mjs} +0 -0
@@ -6,6 +6,7 @@ import { SSRRealtimeConfig } from './RealtimeTypes';
6
6
  import { Schema } from './SchemaTypes';
7
7
  import { AnalyticsConfig, OfflineDataRaw } from './SdkTypes';
8
8
  import { FontHead, Style } from './StyleTypes';
9
+ import { FlagOverrides } from '../flags/resolveFlags';
9
10
  import { SpaceChange } from '../history/types';
10
11
  import { IncomingHttpHeaders } from 'node:http';
11
12
  import { FC } from 'react';
@@ -153,6 +154,24 @@ export type SSRTemplateProps = {
153
154
  */
154
155
  fonts?: FontHead;
155
156
  };
157
+ /**
158
+ * Remote pictures this server fetches, resizes and keeps, at `/_plitzi/img`.
159
+ *
160
+ * A picture from a dozen other sites, some 1500 px wide for a 360 px card, is the heaviest part of most pages; with
161
+ * this on, an `image` whose `src` is another site's offers the browser a `srcset` of sizes this server makes — in
162
+ * AVIF or WebP when the browser takes them, and with `sharp` installed (without it the picture is passed through,
163
+ * still cached).
164
+ */
165
+ export type SSRImagesConfig = {
166
+ /**
167
+ * The hosts a picture may come from: `images.example.com`, or `*.example.com` for every subdomain. Nothing else is
168
+ * fetched — the endpoint is otherwise a way to make this server download anything — and each address is also held
169
+ * to the rule every outbound request is (no private network, every redirect judged).
170
+ */
171
+ domains: readonly string[];
172
+ /** Where the resized files are kept. Default: `.plitzi/images` under the working directory. */
173
+ cacheDir?: string;
174
+ };
156
175
  /**
157
176
  * How a store-relative font path becomes a URL a browser can fetch.
158
177
  *
@@ -256,6 +275,13 @@ export type SSRSpaceDeployment = {
256
275
  credential?: SSRCredential;
257
276
  spaceId?: number | null;
258
277
  revision?: number;
278
+ /**
279
+ * What this space's feature flags are at, for a deployment that keeps them apart from its revisions — a hash that
280
+ * changes exactly when they do. Part of every cache key a render is kept under (the page, its server data, the space
281
+ * read for it), so a flag turned in production reaches the next request while the revision stays the same. Absent,
282
+ * the flags change only with the revision, and the revision alone keys the caches.
283
+ */
284
+ flagsVersion?: string;
259
285
  /**
260
286
  * This render is an author looking at their own work — the builder's preview — rather than a visitor being
261
287
  * served. Metering skips it: nobody should be billed for editing.
@@ -489,6 +515,12 @@ export interface SSRRscContext {
489
515
  * doing so. Awaiting this joins the read already under way; it never starts a second one.
490
516
  */
491
517
  loadOfflineData: () => Promise<OfflineDataRaw | undefined>;
518
+ /**
519
+ * What the layers above the space decide about its flags for this request: the server's own and, on a page allowed
520
+ * to debug, a tester's. An element gated off by a flag is not resolved — `resolveRscData` resolves the flags
521
+ * against the page it matched and skips it — so a feature that is off puts nothing in the payload.
522
+ */
523
+ flagOverrides?: FlagOverrides;
492
524
  }
493
525
  /**
494
526
  * Which published version of a space is asking.
@@ -520,6 +552,8 @@ export type ActionLookupsConfig = {
520
552
  getConnector?: (spaceId: number, connectorId: string, at?: SpaceRevision) => Promise<unknown>;
521
553
  /** The space's own functions as of that revision — `SpaceFunctions` in `@plitzi/sdk-server/functions`. */
522
554
  getFunctions?: (spaceId: number, at?: SpaceRevision) => Promise<unknown>;
555
+ /** The feature flags the space declares as of that revision — what a flow reads as `{{ flags.<name> }}`. */
556
+ getFlags?: (spaceId: number, at?: SpaceRevision) => Promise<Schema['flags']>;
523
557
  };
524
558
  export type SSRActionConfig = {
525
559
  /** URL path for the write endpoint, and the base for the action-addressed routes. Defaults to '/_action'. */
@@ -876,6 +910,17 @@ export type SSRServerConfig = {
876
910
  * so does a space whose settings switched `devTools` on. Set, it decides for every space: `false` is a refusal
877
911
  * no space can turn around. */
878
912
  debugMode?: boolean;
913
+ /**
914
+ * The feature flags this deployment decides, by name — the `server` layer: above what each space declares, below
915
+ * the SDK embedding a page and a tester with the dev tools. Only for flags a space declares; an override of one it
916
+ * does not is ignored, and the page says so in its console.
917
+ *
918
+ * A function when one server renders several spaces and they do not share their flags: it is asked per render.
919
+ */
920
+ flags?: Record<string, boolean> | ((space: {
921
+ spaceId: number;
922
+ environment: Environment;
923
+ }) => Record<string, boolean>);
879
924
  cacheTtlMs?: number;
880
925
  loginPath?: string | false;
881
926
  middlewares?: SSRMiddleware[];
@@ -905,6 +950,8 @@ export type SSRServerConfig = {
905
950
  allowPrivatePluginHosts?: boolean;
906
951
  /** Where this deployment serves the font files a space uploaded — see {@link SSRFontsConfig}. */
907
952
  fonts?: SSRFontsConfig;
953
+ /** Remote pictures resized by this server — see {@link SSRImagesConfig}. Absent, images keep their own `src`. */
954
+ images?: SSRImagesConfig;
908
955
  /** Omit client-side JS from the rendered page — useful for verifying SSR HTML without hydration. Default: false. */
909
956
  ssrOnly?: boolean;
910
957
  /** Stream HTML to the client as React renders, reducing TTFB. Default: false. */
@@ -0,0 +1,28 @@
1
+ import { Element, Schema } from './SchemaTypes';
2
+ import { Style, StyleVariables } from './StyleTypes';
3
+ /**
4
+ * A published snippet: a subtree, the style that dresses it, and the element a builder instantiates.
5
+ *
6
+ * The artefact someone hosts when they are not building a space — fetched by URL, shown in the Resources panel,
7
+ * dragged onto a canvas — which is why it lives beside the schema and the style rather than with the builder's own
8
+ * types: it is a document, produced and consumed by processes that never open a builder.
9
+ */
10
+ export type Snippet = {
11
+ id?: string;
12
+ definition: {
13
+ name: string;
14
+ description: string;
15
+ /** Root of what travels. Its subtree is the whole of `schema.flat`, and it answers to no parent. */
16
+ baseElementId: Element['id'];
17
+ };
18
+ /**
19
+ * Only what travels: the subtree and the variables its rules read. Nothing else of the space it was cut from — its
20
+ * pages, settings or components — comes along, and a builder showing or dropping it reads nothing else.
21
+ */
22
+ schema: Pick<Schema, 'flat' | 'variables'>;
23
+ style: Style;
24
+ };
25
+ /** The part of a style a snippet brings into a space: its rules, by display mode, and the tokens they read. */
26
+ export type SnippetStyle = Pick<Style, 'platform'> & {
27
+ variables?: Partial<StyleVariables>;
28
+ };
@@ -108,3 +108,39 @@ export type SpaceDeployment = {
108
108
  createdAt: number;
109
109
  updatedAt: number;
110
110
  };
111
+ /**
112
+ * What one version of a space is made of: the draft (`main`) a snapshot would freeze, or a snapshot as it was frozen.
113
+ * Counts and names, never contents — what the builder shows before a snapshot is made, and what `plitzi create --from`
114
+ * says it is taking out.
115
+ */
116
+ export type SpaceVersionContents = {
117
+ environment: Environment;
118
+ /** 0 for the draft. */
119
+ revision: number;
120
+ /** A snapshot's own words and moment; none for the draft. */
121
+ snapshot: {
122
+ description: string;
123
+ publishedAt: string;
124
+ } | null;
125
+ pages: number;
126
+ layouts: number;
127
+ /** The space's components, each its own tree — frozen with the version like the pages. */
128
+ components: number;
129
+ elements: number;
130
+ /** Every plugin installed, and whether the source it was built from is kept with this version. */
131
+ plugins: {
132
+ type: string;
133
+ source: boolean;
134
+ }[];
135
+ actions: number;
136
+ connectors: number;
137
+ /** What the space's functions declare, or none when it has none. */
138
+ functions: {
139
+ tasks: number;
140
+ routes: number;
141
+ } | null;
142
+ /** Its runtime, and whether the source it was packed from is kept with this version — none when it has none. */
143
+ runtime: {
144
+ source: boolean;
145
+ } | null;
146
+ };
@@ -5,10 +5,10 @@ import { Source } from './DataSourceTypes';
5
5
  import { QueryParams, RouteParams } from './NavigationTypes';
6
6
  import { RealtimeTransport } from './RealtimeTypes';
7
7
  import { Schema, Element } from './SchemaTypes';
8
- import { Segment } from './SegmentTypes';
9
8
  import { SpaceConnector } from './SpaceTypes';
10
9
  import { DisplayMode, Style, StyleState } from './StyleTypes';
11
10
  import { ColorScheme, Theme } from './ThemeTypes';
11
+ import { FlagOverrides, FlagResolution } from '../flags/resolveFlags';
12
12
  export type RuntimeSourceValues = {
13
13
  variables?: Record<string, unknown>;
14
14
  navigation?: {
@@ -22,13 +22,24 @@ export type RuntimeSourceValues = {
22
22
  mode: Theme;
23
23
  resolved: ColorScheme;
24
24
  };
25
+ flags?: Record<string, boolean>;
26
+ };
27
+ /**
28
+ * The feature flags of this render: what each layer above the space says, and how every flag resolved.
29
+ *
30
+ * Top-level for the reason `rsc` is: the overrides are written at the root — by whoever mounts the SDK, by the builder
31
+ * forcing one — and an element scope owning `runtime` would keep a write from any depth to itself.
32
+ */
33
+ export type FlagsState = {
34
+ overrides?: FlagOverrides;
35
+ /** Each declared flag's answer and the layer that gave it — what the dev tools show. The values alone are the
36
+ * `flags` source. */
37
+ resolved?: Record<string, FlagResolution>;
25
38
  };
26
39
  export type CommonState = {
27
- prevSchema?: Schema;
28
40
  schema: Schema;
29
41
  pageDefinitions: Record<string, Element>;
30
42
  style: Style;
31
- segments: Record<string, Segment>;
32
43
  runtime?: {
33
44
  sources: RuntimeSourceValues & Record<string, unknown>;
34
45
  state?: Record<string, unknown>;
@@ -44,12 +55,17 @@ export type CommonState = {
44
55
  };
45
56
  sources?: Record<string, Source>;
46
57
  rsc?: RscState;
58
+ flags?: FlagsState;
47
59
  actions?: ActionsState;
48
60
  /** Where this origin's realtime channels answer — absent in a render with no server, where no channel opens. */
49
61
  realtime?: {
50
62
  endpoint?: string;
51
63
  transport?: RealtimeTransport;
52
64
  };
65
+ /** Where this origin resizes remote pictures — absent in a render with no server, where an image keeps its `src`. */
66
+ images?: {
67
+ endpoint?: string;
68
+ };
53
69
  render?: RenderSettings;
54
70
  /**
55
71
  * The theme, mirrored from `themeStore` so the devtools store viewer answers "which theme is this" in one line.
@@ -127,6 +143,15 @@ export type RenderSettings = {
127
143
  * has to keep in step with the document by hand.
128
144
  */
129
145
  testAttributes?: boolean;
146
+ /**
147
+ * Whether the page may write the document's head — its SEO title and description. On, as a page's own document is.
148
+ *
149
+ * Off where the page is drawn in a frame of a host whose document is not the page's: the builder's canvas. A head
150
+ * manager writes the head of the document its code runs in, which there is the editor's — and the builder is itself
151
+ * mounted in a page that manages that head, so a second manager under it rewrote the host's tags and took the
152
+ * builder's own stylesheet away the moment a preview showed a page with SEO.
153
+ */
154
+ ownsHead?: boolean;
130
155
  };
131
156
  /** Absent `endpoint` is the whole feature switch: a render with no server tier leaves every `serverAction` step
132
157
  * inert instead of letting each click discover a 404. */
@@ -208,6 +233,12 @@ export type BuilderState = CommonState & {
208
233
  queryParams: QueryParams;
209
234
  hostname: string;
210
235
  };
236
+ /**
237
+ * The builder's OWN feature flags — Plitzi's, not the space's: which parts of the editor this person is shown, as the
238
+ * platform resolved them for them when the editor opened (`PlatformFlags` in the builder's first query). Never
239
+ * authored, never published.
240
+ */
241
+ platformFlags?: Record<string, boolean>;
211
242
  displayMode: DisplayMode;
212
243
  selector?: string;
213
244
  styleSelector?: string;
@@ -217,6 +248,11 @@ export type BuilderState = CommonState & {
217
248
  styleAncestor?: string;
218
249
  elementHovered?: string;
219
250
  elementSelected?: string;
251
+ /**
252
+ * The component open in the canvas instead of a page, by id. Editor-only: what the author is editing, never part
253
+ * of the document — the canvas, the layers and the element tools then read the component's tree.
254
+ */
255
+ componentOpen?: string;
220
256
  setHovered: (elementId?: string) => void;
221
257
  setSelected: (elementId?: string, iframeDOM?: HTMLIFrameElement | null, force?: boolean) => void;
222
258
  };
@@ -149,6 +149,6 @@ export type StyleContextValue = {
149
149
  styleAddFont?: unknown;
150
150
  styleUpdateFont?: unknown;
151
151
  styleRemoveFont?: unknown;
152
- styleAddTemplate?: unknown;
152
+ styleAddSnippet?: unknown;
153
153
  styleUpdateSettings?: unknown;
154
154
  };
@@ -1,12 +1,11 @@
1
1
  export * from './SchemaTypes';
2
2
  export * from './StyleTypes';
3
- export * from './TemplateTypes';
3
+ export * from './SnippetTypes';
4
4
  export * from './InteractionTypes';
5
5
  export * from './PluginTypes';
6
6
  export * from './ElementTypes';
7
7
  export * from './DataSourceTypes';
8
8
  export * from './EventBridgeTypes';
9
- export * from './SegmentTypes';
10
9
  export * from './BuilderTypes';
11
10
  export * from './NavigationTypes';
12
11
  export * from './CollectionTypes';