@plitzi/sdk-shared 0.37.8 → 0.37.9

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 (147) hide show
  1. package/CHANGELOG.md +232 -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 +1 -1
  5. package/dist/actions/index.mjs +6 -6
  6. package/dist/auth/failureChannel.d.ts +8 -2
  7. package/dist/auth/failureChannel.mjs +1 -3
  8. package/dist/builder/contexts/BuilderContext.d.ts +1 -1
  9. package/dist/builder/contexts/BuilderContext.mjs +2 -3
  10. package/dist/devTools/DevToolsContext.mjs +2 -3
  11. package/dist/elements/ComponentContext.mjs +2 -3
  12. package/dist/helpers/sharedContext.d.ts +14 -0
  13. package/dist/helpers/sharedContext.mjs +9 -0
  14. package/dist/helpers/twigWrapper/Evaluator/Evaluator.d.ts +9 -1
  15. package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +13 -8
  16. package/dist/helpers/twigWrapper/Evaluator/index.d.ts +1 -1
  17. package/dist/helpers/twigWrapper/index.d.ts +1 -0
  18. package/dist/helpers/twigWrapper/processTwig/processTwig.d.ts +2 -1
  19. package/dist/helpers/twigWrapper/processTwig/processTwig.mjs +3 -3
  20. package/dist/helpers/utils.mjs +4 -2
  21. package/dist/history/describe.mjs +1 -0
  22. package/dist/history/diff.d.ts +1 -1
  23. package/dist/history/diff.mjs +10 -9
  24. package/dist/history/types.d.ts +1 -1
  25. package/dist/hooks/usePlitziServiceContext.d.ts +1 -2
  26. package/dist/hooks/usePlitziServiceContext.mjs +3 -4
  27. package/dist/index.d.ts +0 -1
  28. package/dist/index.mjs +12 -13
  29. package/dist/network/NetworkContext.mjs +2 -3
  30. package/dist/network/NetworkInternalContext.d.ts +2 -4
  31. package/dist/network/NetworkInternalContext.mjs +2 -3
  32. package/dist/network/graphql/builder/Mutations/Space/components/SpaceAddComponentMutation.d.ts +4 -0
  33. package/dist/network/graphql/builder/Mutations/Space/components/SpaceAddComponentMutation.mjs +4 -0
  34. package/dist/network/graphql/builder/Mutations/Space/components/SpaceDetachInstanceMutation.d.ts +4 -0
  35. package/dist/network/graphql/builder/Mutations/Space/components/SpaceDetachInstanceMutation.mjs +4 -0
  36. package/dist/network/graphql/builder/Mutations/Space/components/SpaceRemoveComponentMutation.d.ts +4 -0
  37. package/dist/network/graphql/builder/Mutations/Space/components/SpaceRemoveComponentMutation.mjs +4 -0
  38. package/dist/network/graphql/builder/Mutations/Space/components/SpaceUpdateComponentMutation.d.ts +4 -0
  39. package/dist/network/graphql/builder/Mutations/Space/components/SpaceUpdateComponentMutation.mjs +4 -0
  40. package/dist/network/graphql/builder/Mutations/index.d.ts +8 -29
  41. package/dist/network/graphql/builder/Mutations/index.mjs +158 -200
  42. package/dist/network/graphql/builder/Queries/InitQuery.d.ts +2 -3
  43. package/dist/network/graphql/builder/Queries/InitQuery.mjs +1 -1
  44. package/dist/network/graphql/builder/Queries/Space/SpaceActionTasksQuery.d.ts +1 -1
  45. package/dist/network/graphql/builder/Queries/Space/SpaceActionTasksQuery.mjs +1 -1
  46. package/dist/network/graphql/builder/Queries/Space/SpaceVersionContentsQuery.d.ts +7 -0
  47. package/dist/network/graphql/builder/Queries/Space/SpaceVersionContentsQuery.mjs +4 -0
  48. package/dist/network/graphql/builder/Queries/index.d.ts +2 -4
  49. package/dist/network/graphql/builder/Queries/index.mjs +36 -38
  50. package/dist/network/graphql/builder/Subscriptions/SpaceEventSubscription.d.ts +1 -1
  51. package/dist/network/graphql/sdk/Queries/InitQuery.d.ts +2 -3
  52. package/dist/network/graphql/sdk/Queries/InitQuery.mjs +1 -1
  53. package/dist/network/graphql/sdk/Queries/index.d.ts +0 -4
  54. package/dist/network/graphql/sdk/Queries/index.mjs +2 -8
  55. package/dist/network/spaceEvents.d.ts +14 -190
  56. package/dist/network/spaceEvents.mjs +48 -132
  57. package/dist/schema/SchemaContext.mjs +2 -3
  58. package/dist/schema/index.mjs +4 -4
  59. package/dist/schema/schemaConstants.d.ts +2 -0
  60. package/dist/schema/schemaConstants.mjs +4 -3
  61. package/dist/server/rsc/refreshRsc.d.ts +3 -1
  62. package/dist/server/rsc/refreshRsc.mjs +15 -14
  63. package/dist/source/export.d.ts +107 -0
  64. package/dist/source/export.mjs +4 -0
  65. package/dist/source/index.d.ts +4 -0
  66. package/dist/source/index.mjs +3 -0
  67. package/dist/source/snapshot.d.ts +51 -0
  68. package/dist/source/snapshot.mjs +80 -0
  69. package/dist/store/index.d.ts +45 -45
  70. package/dist/store/renderSettings.d.ts +1 -0
  71. package/dist/store/renderSettings.mjs +9 -5
  72. package/dist/theme/ThemeScope.mjs +4 -3
  73. package/dist/types/ActionTypes.d.ts +5 -0
  74. package/dist/types/ElementTypes.d.ts +6 -5
  75. package/dist/types/EventBridgeTypes.d.ts +2 -2
  76. package/dist/types/FunctionTypes.d.ts +13 -0
  77. package/dist/types/InteractionTypes.d.ts +5 -0
  78. package/dist/types/SchemaTypes.d.ts +38 -0
  79. package/dist/types/SdkTypes.d.ts +0 -2
  80. package/dist/types/SpaceTypes.d.ts +36 -0
  81. package/dist/types/StoreTypes.d.ts +14 -3
  82. package/dist/types/index.d.ts +0 -1
  83. package/package.json +43 -134
  84. package/dist/network/graphql/builder/Mutations/Segment/SegmentAddMutation.d.ts +0 -4
  85. package/dist/network/graphql/builder/Mutations/Segment/SegmentAddMutation.mjs +0 -4
  86. package/dist/network/graphql/builder/Mutations/Segment/SegmentAddTemplateMutation.d.ts +0 -2
  87. package/dist/network/graphql/builder/Mutations/Segment/SegmentAddTemplateMutation.mjs +0 -4
  88. package/dist/network/graphql/builder/Mutations/Segment/SegmentPublishMutation.d.ts +0 -8
  89. package/dist/network/graphql/builder/Mutations/Segment/SegmentPublishMutation.mjs +0 -4
  90. package/dist/network/graphql/builder/Mutations/Segment/SegmentRemoveMutation.d.ts +0 -2
  91. package/dist/network/graphql/builder/Mutations/Segment/SegmentRemoveMutation.mjs +0 -4
  92. package/dist/network/graphql/builder/Mutations/Segment/SegmentUpdateMutation.d.ts +0 -4
  93. package/dist/network/graphql/builder/Mutations/Segment/SegmentUpdateMutation.mjs +0 -4
  94. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentAddElementMutation.d.ts +0 -2
  95. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentAddElementMutation.mjs +0 -4
  96. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentCloneElementMutation.d.ts +0 -2
  97. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentCloneElementMutation.mjs +0 -4
  98. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentMoveElementMutation.d.ts +0 -2
  99. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentMoveElementMutation.mjs +0 -4
  100. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRemoveElementMutation.d.ts +0 -2
  101. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRemoveElementMutation.mjs +0 -4
  102. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRenameElementMutation.d.ts +0 -3
  103. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRenameElementMutation.mjs +0 -4
  104. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementMutation.d.ts +0 -2
  105. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementMutation.mjs +0 -4
  106. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementsMutation.d.ts +0 -2
  107. package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementsMutation.mjs +0 -4
  108. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceAddVariableMutation.d.ts +0 -2
  109. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceAddVariableMutation.mjs +0 -4
  110. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceRemoveVariableMutation.d.ts +0 -2
  111. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceRemoveVariableMutation.mjs +0 -4
  112. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceUpdateVariableMutation.d.ts +0 -2
  113. package/dist/network/graphql/builder/Mutations/Segment/space/variables/SegmentSpaceUpdateVariableMutation.mjs +0 -4
  114. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleAddSelectorVariableMutation.d.ts +0 -2
  115. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleAddSelectorVariableMutation.mjs +0 -4
  116. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleRemoveSelectorVariableMutation.d.ts +0 -2
  117. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleRemoveSelectorVariableMutation.mjs +0 -4
  118. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleUpdateSelectorVariableMutation.d.ts +0 -2
  119. package/dist/network/graphql/builder/Mutations/Segment/style/selectorVariables/SegmentStyleUpdateSelectorVariableMutation.mjs +0 -4
  120. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleAddSelectorMutation.d.ts +0 -2
  121. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleAddSelectorMutation.mjs +0 -4
  122. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorMutation.d.ts +0 -2
  123. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorMutation.mjs +0 -4
  124. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorsMutation.d.ts +0 -2
  125. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorsMutation.mjs +0 -4
  126. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleUpdateSelectorMutation.d.ts +0 -2
  127. package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleUpdateSelectorMutation.mjs +0 -4
  128. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleAddVariableMutation.d.ts +0 -2
  129. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleAddVariableMutation.mjs +0 -4
  130. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleRemoveVariableMutation.d.ts +0 -2
  131. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleRemoveVariableMutation.mjs +0 -4
  132. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleUpdateVariableMutation.d.ts +0 -2
  133. package/dist/network/graphql/builder/Mutations/Segment/style/variables/SegmentStyleUpdateVariableMutation.mjs +0 -4
  134. package/dist/network/graphql/builder/Queries/Segment/SegmentQuery.d.ts +0 -6
  135. package/dist/network/graphql/builder/Queries/Segment/SegmentQuery.mjs +0 -4
  136. package/dist/network/graphql/builder/Queries/Segment/SegmentsQuery.d.ts +0 -9
  137. package/dist/network/graphql/builder/Queries/Segment/SegmentsQuery.mjs +0 -4
  138. package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.d.ts +0 -6
  139. package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.mjs +0 -4
  140. package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.d.ts +0 -9
  141. package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.mjs +0 -4
  142. package/dist/segments/SegmentsContext.d.ts +0 -2
  143. package/dist/segments/SegmentsContext.mjs +0 -6
  144. package/dist/segments/index.d.ts +0 -3
  145. package/dist/segments/index.mjs +0 -2
  146. package/dist/types/SegmentTypes.d.ts +0 -41
  147. package/dist/types/SegmentTypes.mjs +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,237 @@
1
1
  # @plitzi/sdk-shared
2
2
 
3
+ ## 0.37.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 3ae61a4: ## Components replace segments
8
+
9
+ - **What a component is:** a reusable block written once and placed anywhere as an instance. An edit to the component
10
+ is an edit to every instance.
11
+ - **Where it lives:** in the space document, as `schema.components`, one tree per component and never in
12
+ `schema.flat`. It is published, rolled back, copied by templates and exported with the space.
13
+ - **Props and slots:**
14
+ - A component declares props (`type`, `description`, `required`, `default`, `options`). An instance hands them in
15
+ as its own attributes, so templates and bindings reach them. Inside, they are read as `{{ props.<name> }}`.
16
+ - Slots are elements an instance fills; each child names its slot in `attributes.slot`.
17
+ - **A prop an instance leaves out prints nothing.** It is its `default`, or `null`. `props` is a settled source:
18
+ - `processTwig` takes `{ settled }` in place of `keepEmptyTokens: true`.
19
+ - Every other empty token is still kept for a later pass.
20
+ - `COMPONENT_PROPS_SOURCE` names the source.
21
+ - **Fixed: a flow in a list row or a component instance acts on its own copy.** A step's target resolves in the
22
+ replica the flow fired in first, then outwards. It used to reach whichever copy registered last.
23
+ - **Fixed: an instance's own `visible` hides it in preview.** The same goes for an element reference.
24
+ - **Fixed: a list row keeps its state with its record.** Rows are keyed by each record's unique `id`, so filtering no
25
+ longer moves one row's state onto another.
26
+ - **Closed scope:** inside, a component reads only its props and the globals. The validator, `lintSpace` and
27
+ `authorSpace` each refuse a read of the page around an instance. Components nest, and a cycle is refused.
28
+ - **Where to use them:**
29
+ - In code (`@plitzi/sdk-authoring`): `SpaceSpec.components` and `component(id, { props, children })`.
30
+ `specFromSpace` and `specToSource` read and write both.
31
+ - In the builder:
32
+ - a Components panel lists them, and an open component becomes the canvas;
33
+ - an element becomes a component with **Save as component**;
34
+ - in an instance's settings, an instance gets its props and slots, or is **detached** back into a copy.
35
+ - In the MCP: `upsertComponent` and `deleteComponent`. Element ops work inside a component through `pageRef`.
36
+ - **Schema helpers:** `@plitzi/sdk-schema` gains `addComponent`, `updateComponent`, `removeComponent`,
37
+ `detachInstance`, `renameElement`, `treeOf`, `flatMapOf` and `documentIds`.
38
+ - **GraphQL and live events:** `SpaceAddComponent`, `SpaceUpdateComponent`, `SpaceRemoveComponent` and
39
+ `SpaceDetachInstance`, each with a live event. History records a declaration change as a `component` entry.
40
+ - **Breaking: segments are removed.** This covers:
41
+ - `@plitzi/sdk-shared`'s segment types, queries, mutations, context and `SEGMENT_*` events;
42
+ - `referenceType: 'segment'`;
43
+ - the `Segments` builder module;
44
+ - `Space.segments` and the `Segment`/`Segments` queries;
45
+ - `CommonState.prevSchema`.
46
+ - **Breaking: `ElementLayout` and `LayoutBody` change shape.**
47
+ - `ElementLayout` is `{ slots, rootId, type }`; it was `{ containerId }`.
48
+ - `LayoutBody` takes `bodies` keyed by slot.
49
+ - `reference`'s `referenceContainer` attribute is removed.
50
+ - Guide: `docs/en/components.md`.
51
+
52
+ ## Functions ask for the time they need
53
+ - **What changes:** a task can ask for more CPU or wall time than the default with `limits`, in milliseconds. Example:
54
+ `limits: { cpuMs: 1000, wallMs: 20_000 }`. `defineFunctions({ limits })` asks it for every task and route at once,
55
+ and a task's own limits win over those.
56
+ - **What a run is given:** what it asked for, or the default (100 ms of CPU, 10 s) when it asked for nothing. Never
57
+ above the space's plan or the deployment's ceiling.
58
+ - **Deployment ceilings:** `functions.limits` sets them. `DEFAULT_FUNCTION_CEILINGS` covers each unset one, at 2 s of
59
+ CPU and 30 s.
60
+ - **Asking for more than the ceiling** is a problem when the functions are saved; it is never quietly cut down.
61
+ - **Manifest:** carries what each task asked for, and the builder shows it beside the task.
62
+
63
+ ## Functions answer under `/fn`, not `/api`
64
+
65
+ A space's routes are served at `/fn/<path>` (`FUNCTION_ROUTES_PREFIX`). `/api` is a slug a site wants for a page of its
66
+ own. A page under `/fn` is refused instead (`page-route-reserved`).
67
+
68
+ ## The builder's Functions panel
69
+
70
+ Rebuilt around the code. The panel reads `defineFunctions` as it is typed and writes into it, so the code stays the one
71
+ place a function is declared.
72
+
73
+ - **Layout:** the tasks, routes and files on the left, the code in the middle, the selected task on the right.
74
+ - **Live list:** tasks and routes are listed as the code declares them, including tasks imported from another file.
75
+ A task you have written but not saved says so. Tasks built by calling something are counted, and listed once saved.
76
+ - **Code and panel follow each other:** clicking a task or a route opens its file at its line. Putting the cursor inside
77
+ a task's code selects that task.
78
+ - **New task:** + in Tasks asks for its namespace, action and title. The task is written into `defineFunctions` with a
79
+ `run` to start from, in the file's own quotes, and the editor opens on it.
80
+ - **Time limit:** each task gets a slider from 100 ms to 1 s of CPU per run, with presets. The value is written into
81
+ the task as `limits: { cpuMs }`. "Use default" takes it out. `DEFAULT_FUNCTION_TIME_LIMITS` in
82
+ `@plitzi/sdk-shared/actions` is the default both the panel and the server use.
83
+ - **Test:** fills a task's params the way its step does, from their defaults: a select, a switch or text. JSON stays a
84
+ toggle away. With unsaved changes, the button reads "Save & run": it saves, then runs. If the save fails, it says why.
85
+ - **Header:** shows Saved, Unsaved (and in how many files) or the number of problems the last save found. ⌘S saves.
86
+ **Discard** asks first, then puts every file back to what was last saved, or back to nothing for functions never
87
+ saved. Removing the functions is a quiet button beside Save.
88
+ - **Problems:** clicking one opens its file at its line.
89
+ - **Editor:** each file has its own editor and undo history. Opening another file no longer marks the one you left as
90
+ changed. Before this, it could also write the newly opened file's text into the one you left. The cause was in
91
+ `@plitzi/plitzi-ui`'s CodeMirror, fixed in 1.6.25, which every package now depends on. That release also sets code
92
+ editors (several lines) in a monospaced face again. Long lines scroll inside the editor, and the line numbers stay
93
+ in place.
94
+
95
+ ## A space's own functions are their own category of steps
96
+
97
+ In the action editor's step picker, the space's own functions are listed under **Functions**, apart from the
98
+ platform's **Tasks**. The other headings now read Callbacks, Global callbacks and Utilities. The saved step is still a
99
+ `task` node.
100
+
101
+ - `@plitzi/sdk-server`: every registered task has an `origin`, `'deployment'` (shipped with the server or a native
102
+ function) or `'space'` (from the space's functions). `describeCatalog`, `/_action/catalog` and the builder's
103
+ `SpaceActionTasks` carry it (`ActionTaskDescriptor.origin`).
104
+ - `@plitzi/sdk-shared`: an `InteractionCallback` may name the `group` the picker lists it under.
105
+
106
+ ## Fixed: preview no longer breaks a builder that is embedded in a page
107
+
108
+ When the builder is mounted inside a Plitzi page (the platform's `/spaces/:id/update`), going to preview with a page
109
+ that has SEO turned on left the builder unstyled. The previewed page wrote its title and description through a head
110
+ manager of the builder's own, and that manager rewrote the host page's head, removing the builder's own stylesheet.
111
+
112
+ - `@plitzi/sdk-shared`: a new render setting, `ownsHead`, says whether the page may write the document head. It is on
113
+ by default (`DEFAULT_RENDER_SETTINGS`).
114
+ - `@plitzi/sdk-elements`: `Page` writes its SEO only where `ownsHead` is on.
115
+ - Builder: sets `ownsHead: false` for its canvas. A page drawn there is in a frame, and the document head is the
116
+ editor's. The canvas's own `HelmetProvider` is gone.
117
+
118
+ ## Fixed: the builder's plan usage panel shows the space being edited
119
+ - **The 404 is gone.** Opening Plan usage said "The account breakdown could not be read (The server answered 404.)".
120
+ The panel asked `/account/usage`, which went away when accounts became workspaces.
121
+ - **Only this space.** The panel listed every space of the workspace. It now reads `/spaces/:spaceId/usage`, which
122
+ now also answers the space's own `pages` (the heaviest ten), `pagesTotal` and `periodEndsAt`. The plan's ceilings
123
+ stay on top. Anyone who can edit the space can read it, including a guest of another workspace.
124
+ - **It scrolls.** A long breakdown scrolls inside the modal, where it used to overflow.
125
+ - **`getKeyDecoded(webKey, true)` reads the token's subject.** The function, in `@plitzi/sdk-shared`, looked for
126
+ `data.spaceId`, which space tokens no longer carry, so every space decoded as 0. The builder asked about space 0, and
127
+ the builder and the SDK kept every space's persisted state under the same key on a host. Pages served without a
128
+ `webKey` (SSR) still decode as 0, which is what their painted-state cookie is named after.
129
+
130
+ ## Fixed: a remote plugin in the builder reads the canvas it sits in
131
+
132
+ The builder carries its own copy of the Plitzi runtime. A remote plugin imports `@plitzi/plitzi-sdk`, which the page's
133
+ import map resolves to the SDK's copy. Each copy made its own React contexts, so on the builder's canvas a plugin read
134
+ none of the canvas's providers. In the builder embedded in Plitzi's site, it read the site around the builder instead:
135
+ the site's element as its own, the site's live mode (so it stayed interactive while being edited), and the site's store
136
+ and interactions.
137
+
138
+ - `@plitzi/sdk-shared` gains `sharedContext(name, default)`: a context made once per page and handed to every copy of
139
+ the runtime that asks for it.
140
+ - The runtime's contexts now go through it, so a provider from any copy reaches a consumer from any copy:
141
+ - `@plitzi/sdk-shared`: service, component, schema, network, theme scope, dev tools, builder.
142
+ - `@plitzi/sdk-elements`: element, element parent, layout body.
143
+ - interactions, plugins, event bridge, auth, variables and style.
144
+ - The store's contexts need `@plitzi/nexus` 1.4.0, which does the same. Every `@plitzi/*` package now asks for
145
+ `^1.4.0`, which is published.
146
+
147
+ ## The source of plugins and runtimes is kept on the space
148
+
149
+ What a plugin or a runtime is built from now goes up with it, so a space can be taken back out as a project
150
+ (`plitzi create --from`, below).
151
+
152
+ - `@plitzi/cli`:
153
+ - `plitzi pack plugin` writes the plugin's source beside its zip: every file of the project its elements import,
154
+ `import type` included, and the packages they need. `--source-root` names the project those paths are relative to.
155
+ - `plitzi upload plugin` and `plitzi runtime push` keep that source on the space, in its private bucket.
156
+ - `plitzi pack source` writes it to a file.
157
+ - A source that cannot be kept (a file outside the project, an undeclared package, a credential in the code) never
158
+ stops the upload or the push: they say why, and the artifact is kept built only.
159
+ - `@plitzi/sdk-shared/source`: the snapshot's format, the paths it may hold and the credential check, shared by the CLI
160
+ and the platform.
161
+
162
+ ## `plitzi create --from` and `plitzi pull`: a space on Plitzi as a project of your own
163
+
164
+ The way back from everything the CLI puts on Plitzi. `plitzi create my-board --from pizarra` writes a server project
165
+ holding what the space is made of, and runs it with nothing of Plitzi's: neither its servers nor its CDN. `plitzi pull`
166
+ keeps it in step with the space. See `docs/en/projects-from-spaces.md`.
167
+
168
+ - **What lands in the project:**
169
+ - its pages as authoring code;
170
+ - its server actions as `defineAction` code — JSON, with the reason said, for one that would not read back exactly;
171
+ - its plugins and runtime as the source they were uploaded from, and its functions;
172
+ - its files, downloaded into `public/`, with every CDN address rewritten to the project's.
173
+ - **`src/main.ts`** serves all of it, the runtime in the same process.
174
+ - **`.env`** gets a key made for the project's actions to sign with, and the names of the variables and credentials
175
+ the space had. Their values stay on Plitzi.
176
+ - **Who may run it:** the person must be signed in and able to change the space (owner, administrator or writer).
177
+ - **Plugins** are rebuilt against the project's SDK. One uploaded before sources were kept runs as it was built, from
178
+ `vendor/plugins/`, and the report says to upload it again.
179
+ - **The end of `create`** says what came across differently, including a space whose visitors sign in with Plitzi.
180
+ - `--source cloud` keeps the pages on Plitzi and runs the rest locally.
181
+ - **Any version:** `--environment` and `--revision` take out a published snapshot — its latest, or one revision pinned
182
+ — instead of the draft, with the source its plugins and runtime were built from then. A cloud project serves that
183
+ revision pinned.
184
+ - **`plitzi pull`** writes what changed on the space, keeps what changed in the project, and writes nothing when a
185
+ file changed on both — naming them, with `--force` to take the space's copy. It never touches `.env`, only adds to
186
+ `package.json`, and keeps `plitzi functions push` working from the project. It follows the version the project was
187
+ made from, and `--environment`/`--revision` move it.
188
+ - `@plitzi/sdk-authoring`:
189
+ - `actionSpecFromEntry` reads an action document back into its `defineAction` declaration, only when the round trip
190
+ is exact, and `actionToSource` writes it as a module.
191
+ - `defineAction` takes `limits`.
192
+ - `specToSource` takes `importExtension: '.ts'`, for split files that Node imports as they are.
193
+
194
+ ## The builder shows what a snapshot holds
195
+
196
+ **Make Snapshot** lists what it will freeze — pages, layouts and elements, server actions, connectors, functions, the
197
+ runtime and the plugins, each with whether its source is kept — and what no snapshot freezes: the space's files, its
198
+ variables and credentials. A space's components are part of its document, so they are frozen with its pages. **Publish Snapshot** lists what the chosen environment's snapshot holds.
199
+
200
+ ## Fixed: a space read from Plitzi kept its server elements
201
+ - **What happened:** a page server reading its space from Plitzi (`createCloudAdapters`) never ran an element's
202
+ `render` action, and a browser-rendered space ignored `loadStrategy`. The space's GraphQL answered neither
203
+ `runtime` nor `loadStrategy` of an element, nor the space's `rsc` settings.
204
+ - **Now:** the platform answers them, and the SDK, the builder and the cloud adapters ask for them.
205
+
206
+ ## A plugin the deployment registers is not looked for elsewhere
207
+
208
+ `@plitzi/sdk-server` used to fetch the manifest of every plugin the space lists on its CDN, even one the deployment
209
+ registers itself, and logged a warning when the CDN was out of reach. It now asks only for the ones it does not have.
210
+
211
+ ## Fixed: inline code in Markdown carries nothing of the syntax tree
212
+
213
+ A `markdown` element wrote every inline `` `code` `` as `<code node="[object Object]">`: `react-markdown` hands its
214
+ renderers the syntax-tree node as a prop, and the inline branch spread it onto the tag. Fixed in
215
+ `@plitzi/plitzi-ui` 1.6.26 (with a test), which every package now asks for.
216
+
217
+ ## Dev tools hear about the render run the page stopped waiting for
218
+
219
+ When a server element's action ran past the section's budget, the page was answered without it. The run ended a moment
220
+ later, after the page's runs had been sent, so the dev tools never showed the one run that needed debugging. It is now
221
+ told the moment the page stops waiting, as `aborted`, with the reason.
222
+
223
+ ## Fixed: a tab you come back to no longer loses its session
224
+ - **What happened:** a page left in another tab past its access token's life signed its visitor out on return. A
225
+ reload put them right back in.
226
+ - **Why:** the browser drops the cookie carrying the access token the moment the token expires, and the background
227
+ tab's renewal timer had not run. The first check on return was told `missing`, which the client took as no
228
+ session at all.
229
+ - **Now:** a `missing` refusal is renewed instead whenever the browser can still renew, meaning it holds a refresh
230
+ token or a session hint whose renewal window is open. The session ends only if that renewal fails.
231
+ - **Requests made in that moment:** `reportAuthFailure` now answers whether it renewed the session. A read refused
232
+ as the tab came back is asked again, once, once the session is renewed. This covers an api container's read and a
233
+ server section's refresh, so they no longer show a 401 that only a reload cleared.
234
+
3
235
  ## 0.37.8
4
236
 
5
237
  ### Patch Changes
@@ -1,8 +1,17 @@
1
1
  /**
2
- * Where a space's functions answer HTTP: `GET /feed/:id` declared, `GET /api/feed/42` served. The path is
3
- * the functions' and never a page's — the page server and the page linter both read it from here.
2
+ * Where a space's functions answer HTTP: `GET /feed/:id` declared, `GET /fn/feed/42` served. The path is the functions'
3
+ * and never a page's — the page server and the page linter both read it from here. `/fn`, not `/api`: a space's pages
4
+ * are its own to name, and `api` is a slug a site wants for a page about its API.
4
5
  */
5
- export declare const FUNCTION_ROUTES_PREFIX = "/api";
6
+ export declare const FUNCTION_ROUTES_PREFIX = "/fn";
7
+ /**
8
+ * The CPU and time an invocation gets when its task asks for none: what the server runs it with, and what the builder
9
+ * shows as "default". A task asks for more in its `limits`, up to what its deployment allows.
10
+ */
11
+ export declare const DEFAULT_FUNCTION_TIME_LIMITS: {
12
+ readonly cpuMs: 100;
13
+ readonly wallMs: 10000;
14
+ };
6
15
  /** Whether a page at `path` would sit where the space's functions answer. */
7
16
  export declare const isFunctionRoutePath: (path: string) => boolean;
8
17
  /**
@@ -1,6 +1,9 @@
1
1
  //#region src/actions/functions.ts
2
- var e = "/api", t = (e) => e === "/api" || e.startsWith("/api/"), n = (e) => /^[A-Za-z0-9_][A-Za-z0-9_./-]*\.(ts|js|mjs|json)$/.test(e) && !e.split("/").some((e) => e === ".." || e === "." || e === ""), r = async (e, t) => {
3
- let r = {}, i = async (a) => {
2
+ var e = "/fn", t = {
3
+ cpuMs: 100,
4
+ wallMs: 1e4
5
+ }, n = (e) => e === "/fn" || e.startsWith("/fn/"), r = (e) => /^[A-Za-z0-9_][A-Za-z0-9_./-]*\.(ts|js|mjs|json)$/.test(e) && !e.split("/").some((e) => e === ".." || e === "." || e === ""), i = async (e, t) => {
6
+ let n = {}, i = async (a) => {
4
7
  let o;
5
8
  try {
6
9
  o = await t.list(a ? `${e}/${a}` : e);
@@ -9,10 +12,10 @@ var e = "/api", t = (e) => e === "/api" || e.startsWith("/api/"), n = (e) => /^[
9
12
  }
10
13
  for (let s of o) {
11
14
  let o = a ? `${a}/${s.name}` : s.name;
12
- s.directory ? s.name !== "node_modules" && !s.name.startsWith(".") && await i(o) : n(o) && (r[o] = await t.read(`${e}/${o}`));
15
+ s.directory ? s.name !== "node_modules" && !s.name.startsWith(".") && await i(o) : r(o) && (n[o] = await t.read(`${e}/${o}`));
13
16
  }
14
17
  };
15
- return await i(""), r;
18
+ return await i(""), n;
16
19
  };
17
20
  //#endregion
18
- export { e as FUNCTION_ROUTES_PREFIX, t as isFunctionRoutePath, n as isFunctionsSourcePath, r as readFunctionsSource };
21
+ export { t as DEFAULT_FUNCTION_TIME_LIMITS, e as FUNCTION_ROUTES_PREFIX, n as isFunctionRoutePath, r as isFunctionsSourcePath, i as readFunctionsSource };
@@ -1,7 +1,7 @@
1
1
  export { accessRefusal } from './access';
2
2
  export { cronFiresBetween, cronMatches, cronNextFire, isKnownTimeZone, parseCron, zonedClock } from './cron';
3
3
  export { FAILURE_HANDLER_TASK } from './failureHandler';
4
- export { FUNCTION_ROUTES_PREFIX, isFunctionRoutePath, isFunctionsSourcePath, readFunctionsSource } from './functions';
4
+ export { DEFAULT_FUNCTION_TIME_LIMITS, FUNCTION_ROUTES_PREFIX, isFunctionRoutePath, isFunctionsSourcePath, readFunctionsSource } from './functions';
5
5
  export { triggerAccess, triggerCacheMs, triggerHasStaleVerify, triggerInput, triggerVerify } from './triggerParams';
6
6
  export { actionName, actionTriggers, isActionEnabled } from './triggers';
7
7
  export { validateActionDocument } from './validateDocument';
@@ -1,9 +1,9 @@
1
1
  import { accessRefusal as e } from "./access.mjs";
2
2
  import { cronFiresBetween as t, cronMatches as n, cronNextFire as r, isKnownTimeZone as i, parseCron as a, zonedClock as o } from "./cron.mjs";
3
3
  import { FAILURE_HANDLER_TASK as s } from "./failureHandler.mjs";
4
- import { FUNCTION_ROUTES_PREFIX as c, isFunctionRoutePath as l, isFunctionsSourcePath as u, readFunctionsSource as d } from "./functions.mjs";
5
- import { triggerAccess as f, triggerCacheMs as p, triggerHasStaleVerify as m, triggerInput as h, triggerVerify as g } from "./triggerParams.mjs";
6
- import { actionName as _, actionTriggers as v, isActionEnabled as y } from "./triggers.mjs";
7
- import { validateActionDocument as b } from "./validateDocument.mjs";
8
- import { SMTP_CREDENTIAL_KEYS as x, isSingleEmailAddress as S, readSmtpCredential as C } from "./smtp.mjs";
9
- export { s as FAILURE_HANDLER_TASK, c as FUNCTION_ROUTES_PREFIX, x as SMTP_CREDENTIAL_KEYS, e as accessRefusal, _ as actionName, v as actionTriggers, t as cronFiresBetween, n as cronMatches, r as cronNextFire, y as isActionEnabled, l as isFunctionRoutePath, u as isFunctionsSourcePath, i as isKnownTimeZone, S as isSingleEmailAddress, a as parseCron, d as readFunctionsSource, C as readSmtpCredential, f as triggerAccess, p as triggerCacheMs, m as triggerHasStaleVerify, h as triggerInput, g as triggerVerify, b as validateActionDocument, o as zonedClock };
4
+ import { DEFAULT_FUNCTION_TIME_LIMITS as c, FUNCTION_ROUTES_PREFIX as l, isFunctionRoutePath as u, isFunctionsSourcePath as d, readFunctionsSource as f } from "./functions.mjs";
5
+ import { triggerAccess as p, triggerCacheMs as m, triggerHasStaleVerify as h, triggerInput as g, triggerVerify as _ } from "./triggerParams.mjs";
6
+ import { actionName as v, actionTriggers as y, isActionEnabled as b } from "./triggers.mjs";
7
+ import { validateActionDocument as x } from "./validateDocument.mjs";
8
+ import { SMTP_CREDENTIAL_KEYS as S, isSingleEmailAddress as C, readSmtpCredential as w } from "./smtp.mjs";
9
+ export { c as DEFAULT_FUNCTION_TIME_LIMITS, s as FAILURE_HANDLER_TASK, l as FUNCTION_ROUTES_PREFIX, S as SMTP_CREDENTIAL_KEYS, e as accessRefusal, v as actionName, y as actionTriggers, t as cronFiresBetween, n as cronMatches, r as cronNextFire, b as isActionEnabled, u as isFunctionRoutePath, d as isFunctionsSourcePath, i as isKnownTimeZone, C as isSingleEmailAddress, a as parseCron, f as readFunctionsSource, w as readSmtpCredential, p as triggerAccess, m as triggerCacheMs, h as triggerHasStaleVerify, g as triggerInput, _ as triggerVerify, x as validateActionDocument, o as zonedClock };
@@ -4,13 +4,19 @@ export type AuthFailureSignal = {
4
4
  /** The request that was refused. Auth listens only to refusals from its own backend — see `sameRegistrableDomain`. */
5
5
  url?: string;
6
6
  };
7
- export type AuthFailureListener = (signal: AuthFailureSignal) => void;
7
+ /** Hears a refusal, and answers whether it renewed the session because of it — or nothing, for a listener that did not. */
8
+ export type AuthFailureListener = (signal: AuthFailureSignal) => Promise<boolean> | boolean | undefined;
8
9
  /**
9
10
  * Says that a backend refused a credential. A session can end between two checks — revoked from another device, an
10
11
  * account deactivated — and the first thing that notices is whatever request got refused, not a timer. Reporting it
11
12
  * here is how the network layers tell auth that reality moved on, without either knowing about the other.
13
+ *
14
+ * Answers whether the session was renewed because of it: a refusal that only meant "this credential expired" — a tab
15
+ * coming back after its token's life — is answered by a renewal, and the request that was refused can be asked again,
16
+ * once, instead of leaving its section in an error a reload would have cleared. A refused request never ran, so asking
17
+ * it again repeats nothing.
12
18
  */
13
- export declare const reportAuthFailure: (signal: AuthFailureSignal) => void;
19
+ export declare const reportAuthFailure: (signal: AuthFailureSignal) => Promise<boolean>;
14
20
  export declare const onAuthFailure: (listener: AuthFailureListener) => (() => void);
15
21
  /**
16
22
  * What an HTTP refusal means for the session. Stated once, because the provider and the network layers must not
@@ -1,7 +1,5 @@
1
1
  //#region src/auth/failureChannel.ts
2
- var e = /* @__PURE__ */ new Set(), t = (t) => {
3
- for (let n of e) n(t);
4
- }, n = (t) => (e.add(t), () => e.delete(t)), r = [
2
+ var e = /* @__PURE__ */ new Set(), t = async (t) => (await Promise.all([...e].map(async (e) => e(t)))).some((e) => e === !0), n = (t) => (e.add(t), () => e.delete(t)), r = [
5
3
  "missing",
6
4
  "expired",
7
5
  "revoked",
@@ -1,7 +1,7 @@
1
1
  import { ComponentPluginWithHOC, DropPosition, Element, EventBridgeEvent, PluginBuilder, Schema, Style } from '../../types';
2
2
  import { Dispatch, SetStateAction } from 'react';
3
3
  export type BuilderContextValue = {
4
- mode: 'normal' | 'template' | 'segment';
4
+ mode: 'normal' | 'template';
5
5
  schemaName: string;
6
6
  setMultiPagesMode: Dispatch<SetStateAction<boolean>>;
7
7
  multiPagesMode: boolean;
@@ -1,5 +1,4 @@
1
- import { createContext as e } from "react";
2
- var t = e({});
3
- t.displayName = "BuilderContext";
1
+ import { sharedContext as e } from "../../helpers/sharedContext.mjs";
2
+ var t = e("BuilderContext", {});
4
3
  //#endregion
5
4
  export { t as default };
@@ -1,8 +1,7 @@
1
- import { createContext as e } from "react";
2
- var t = e({
1
+ import { sharedContext as e } from "../helpers/sharedContext.mjs";
2
+ var t = e("DevToolsContext", {
3
3
  logs: [],
4
4
  providers: {}
5
5
  });
6
- t.displayName = "DevToolsContext";
7
6
  //#endregion
8
7
  export { t as default };
@@ -1,5 +1,4 @@
1
- import { createContext as e } from "react";
2
- var t = e({});
3
- t.displayName = "ComponentContext";
1
+ import { sharedContext as e } from "../helpers/sharedContext.mjs";
2
+ var t = e("ComponentContext", {});
4
3
  //#endregion
5
4
  export { t as default };
@@ -0,0 +1,14 @@
1
+ import { Context } from 'react';
2
+ /**
3
+ * A React context every copy of the Plitzi runtime on a page agrees on.
4
+ *
5
+ * One page can hold more than one copy. The builder carries its own and renders a space's elements with it, while a
6
+ * remote plugin imports `@plitzi/plitzi-sdk` — the SDK's copy — through the page's import map; the builder embedded in
7
+ * Plitzi's own site is a third, the site's. A context made with `createContext` belongs to the copy that made it, so a
8
+ * plugin in the builder's canvas read none of the canvas's providers: it fell through to the site around the builder,
9
+ * took its element for the plugin's own, its live mode for the editor's and its store for the space's.
10
+ *
11
+ * Made once per page, under `name`, by whichever copy asks first, and handed to every other: a provider from any copy
12
+ * is then seen by a consumer from any copy, and the nearest one wins as it should.
13
+ */
14
+ export declare const sharedContext: <T>(name: string, defaultValue: T) => Context<T>;
@@ -0,0 +1,9 @@
1
+ import { createContext as e } from "react";
2
+ var t = Symbol.for("plitzi.sharedContexts.v1"), n = (e) => (e[t] ??= /* @__PURE__ */ new Map(), e[t]), r = (t, r) => {
3
+ let i = n(globalThis), a = i.get(t);
4
+ if (a) return a;
5
+ let o = e(r);
6
+ return o.displayName = t, i.set(t, o), o;
7
+ };
8
+ //#endregion
9
+ export { r as sharedContext };
@@ -1,4 +1,12 @@
1
1
  import { ASTNode, Expression } from '../AST';
2
+ /**
3
+ * Which empty tokens a render hands back as their own text, for a later pass that knows more: none, every one, or
4
+ * every one but those reading a SETTLED source — one whose value is final when the render runs, so that nothing later
5
+ * will fill it in. A component's `props` is one: every declared prop is in it, and an empty one is an answer.
6
+ */
7
+ export type KeepEmptyTokens = boolean | {
8
+ settled: ReadonlySet<string>;
9
+ };
2
10
  export type EvalResult = {
3
11
  readonly output: string;
4
12
  readonly variables: Record<string, unknown>;
@@ -12,6 +20,6 @@ export type EvalResult = {
12
20
  * that document, not text the reader has to give up on. A value printed anywhere else is printed as always: it IS the
13
21
  * JSON value there (`"seen": {{ count }}`).
14
22
  */
15
- export declare const evaluate: (nodes: readonly ASTNode[], context: Record<string, unknown>, keepEmptyTokens?: boolean, jsonStrings?: boolean) => EvalResult;
23
+ export declare const evaluate: (nodes: readonly ASTNode[], context: Record<string, unknown>, keepEmptyTokens?: KeepEmptyTokens, jsonStrings?: boolean) => EvalResult;
16
24
  /** One expression's value, as it is — not rendered to text. What `processTwigValue` answers a `{{ expr }}` with. */
17
25
  export declare const evaluateExpression: (expression: Expression, context: Record<string, unknown>) => unknown;
@@ -10,14 +10,14 @@ var l = {
10
10
  iterable: (e) => Array.isArray(e) || typeof e == "object" && !!e,
11
11
  even: (e) => typeof e == "number" && e % 2 == 0,
12
12
  odd: (e) => typeof e == "number" && Math.abs(e % 2) === 1
13
- }, u = (e) => e.type === "path" || e.type === "filter" && u(e.subject), d = (e, t) => t == null || t === "" && u(e), f = (e) => e.type === "path" && e.segments.length === 1 ? e.segments[0] : e.type === "literal" && e.value === null ? "null" : void 0, p = [], m = (e, t, n = !1, r = !1) => {
14
- let i = new g(t, n, r);
13
+ }, u = (e) => e.type === "path" || e.type === "filter" && u(e.subject), d = (e, t) => t == null || t === "" && u(e), f = (e) => e.type === "path" ? e.segments[0] : e.type === "filter" ? f(e.subject) : void 0, p = (e) => e.type === "path" && e.segments.length === 1 ? e.segments[0] : e.type === "literal" && e.value === null ? "null" : void 0, m = [], h = (e, t, n = !1, r = !1) => {
14
+ let i = new _(t, n, r);
15
15
  return {
16
16
  output: i.evalNodes(e),
17
17
  variables: i.variables,
18
18
  hasSet: i.hasSet
19
19
  };
20
- }, h = (e, t) => new g(t).evalExpression(e), g = class u {
20
+ }, g = (e, t) => new _(t).evalExpression(e), _ = class u {
21
21
  variables;
22
22
  keepEmptyTokens;
23
23
  jsonStrings;
@@ -29,6 +29,11 @@ var l = {
29
29
  constructor(e, t = !1, n = !1) {
30
30
  this.variables = { ...e }, this.keepEmptyTokens = t, this.jsonStrings = n;
31
31
  }
32
+ keeps(e) {
33
+ if (typeof this.keepEmptyTokens == "boolean") return this.keepEmptyTokens;
34
+ let t = f(e);
35
+ return t === void 0 || !this.keepEmptyTokens.settled.has(t);
36
+ }
32
37
  evalNodes(e) {
33
38
  let t = e.length;
34
39
  if (t === 0) return "";
@@ -51,7 +56,7 @@ var l = {
51
56
  }
52
57
  evalVariable(e) {
53
58
  let t = this.evalExpression(e.expression);
54
- return this.keepEmptyTokens && d(e.expression, t) ? e.source : o(t) ? String(s(t)) : typeof t == "function" ? "" : t != null && typeof t != "object" ? String(t) : e.raw ? t == null ? "" : String(t) : typeof t == "object" && t ? JSON.stringify(t) : "";
59
+ return this.keeps(e.expression) && d(e.expression, t) ? e.source : o(t) ? String(s(t)) : typeof t == "function" ? "" : t != null && typeof t != "object" ? String(t) : e.raw ? t == null ? "" : String(t) : typeof t == "object" && t ? JSON.stringify(t) : "";
55
60
  }
56
61
  followQuotes(e) {
57
62
  for (let t = 0; t < e.length; t++) {
@@ -66,7 +71,7 @@ var l = {
66
71
  }
67
72
  evalFor(e) {
68
73
  let r = this.evalExpression(e.collection);
69
- if (e.source !== void 0 && r === void 0) return e.source;
74
+ if (e.source !== void 0 && r === void 0 && this.keeps(e.collection)) return e.source;
70
75
  let i, a = null;
71
76
  if (e.keyVar !== null) {
72
77
  let t = n(r);
@@ -112,7 +117,7 @@ var l = {
112
117
  let n = e;
113
118
  for (let e of t) {
114
119
  let t = a[e.name];
115
- t !== void 0 && (n = t(n, e.args.length === 0 ? p : this.evalArgs(e.args)));
120
+ t !== void 0 && (n = t(n, e.args.length === 0 ? m : this.evalArgs(e.args)));
116
121
  }
117
122
  return n;
118
123
  }
@@ -221,7 +226,7 @@ var l = {
221
226
  return a;
222
227
  }
223
228
  evalBinary(t, n, i) {
224
- let a = f(i);
229
+ let a = p(i);
225
230
  if ((t === "is" || t === "is not") && a !== void 0) {
226
231
  let e = l[a];
227
232
  if (e) {
@@ -262,4 +267,4 @@ var l = {
262
267
  }
263
268
  };
264
269
  //#endregion
265
- export { m as evaluate, h as evaluateExpression };
270
+ export { h as evaluate, g as evaluateExpression };
@@ -1,2 +1,2 @@
1
1
  export { evaluate, evaluateExpression } from './Evaluator';
2
- export type { EvalResult } from './Evaluator';
2
+ export type { EvalResult, KeepEmptyTokens } from './Evaluator';
@@ -6,5 +6,6 @@ export { inspectTemplate } from './inspectTemplate';
6
6
  export { templatePaths, templateRootNames } from './templateRoots';
7
7
  export { filters } from './filters/filters';
8
8
  export type { ASTNode, Expression } from './AST';
9
+ export type { KeepEmptyTokens } from './Evaluator';
9
10
  export type { TemplateInspection } from './inspectTemplate';
10
11
  export type { TwigFilter } from './filters/filters';
@@ -1,4 +1,5 @@
1
- export declare const processTwig: (template: string, variables?: Record<string, unknown>, keepEmptyTokens?: boolean, asRaw?: boolean) => unknown;
1
+ import { KeepEmptyTokens } from '../Evaluator';
2
+ export declare const processTwig: (template: string, variables?: Record<string, unknown>, keepEmptyTokens?: KeepEmptyTokens, asRaw?: boolean) => unknown;
2
3
  /**
3
4
  * A template's VALUE, where it has one: `{{ rows|filter(r => r.open) }}` is the filtered array, `{{ count > 0 }}` a
4
5
  * boolean, `{{ total }}` the number it holds.
@@ -8,14 +8,14 @@ var s = (i, s = {}, c = !1, l = !1) => {
8
8
  if (i.indexOf("{%") === -1 && i.indexOf("{{") === -1) return i;
9
9
  let u = "variables" in s ? t(s) : s, d = o(i);
10
10
  if (!d) return i;
11
- if (!c && !d.hasTags && d.allSimpleOrDotted) {
11
+ if (c === !1 && !d.hasTags && d.allSimpleOrDotted) {
12
12
  let t = n(d, u);
13
13
  return l ? e(t) : t;
14
14
  }
15
- let f = a(d, c);
15
+ let f = a(d, c !== !1);
16
16
  if (!f) return i;
17
17
  let { output: p, variables: m, hasSet: h } = r(f, u, c);
18
- return h && Object.assign(s, m), c && p === i ? i : l ? e(p) : p;
18
+ return h && Object.assign(s, m), c !== !1 && p === i ? i : l ? e(p) : p;
19
19
  } catch {
20
20
  return i;
21
21
  }
@@ -8,7 +8,7 @@ Object.freeze(n);
8
8
  var r = (e, t = "", n = ".", i = !1) => !e || typeof e != "object" ? [] : Object.keys(e).reduce((a, o) => {
9
9
  o = o.replaceAll(n, "").replaceAll(".", "");
10
10
  let s = `${t}${t ? n : ""}${o}`;
11
- return typeof e[o] != "object" || Array.isArray(e[o]) && i ? [...a, s] : [
11
+ return typeof e[o] != "object" || Array.isArray(e[o]) && (i || e[o].length > 5) ? [...a, s] : [
12
12
  ...a,
13
13
  s,
14
14
  ...r(e[o], s, n, i)
@@ -29,7 +29,9 @@ function a(t, n) {
29
29
  } catch {
30
30
  return 0;
31
31
  }
32
- return n ? e(r, "data.spaceId", 0) : r;
32
+ if (!n) return r;
33
+ let i = Number(e(r, "sub", 0));
34
+ return Number.isInteger(i) && i > 0 ? i : 0;
33
35
  }
34
36
  function o(e) {
35
37
  !e && typeof window < "u" && (e = window.location.search);
@@ -25,6 +25,7 @@ var e = (e) => typeof e == "object" && !!e && !Array.isArray(e), t = (n, r, i =
25
25
  };
26
26
  return Object.hasOwn(i, r) ? i[r] : r;
27
27
  }, s = (e, t = 3) => e.length > t ? `${e.slice(0, t).join(", ")} and ${e.length - t} more` : e.join(", "), c = {
28
+ component: "component",
28
29
  folder: "folder",
29
30
  variable: "variable",
30
31
  setting: "setting",
@@ -16,7 +16,7 @@ export declare const sameValue: (a: unknown, b: unknown) => boolean;
16
16
  */
17
17
  export declare const jsonCopy: <T>(value: T) => T;
18
18
  /** The part of a schema a history reads: what is stored, never what the runtime derives from it. */
19
- export type HistorySchema = Pick<Schema, 'flat' | 'pages' | 'pageFolders' | 'variables' | 'settings' | 'definition'>;
19
+ export type HistorySchema = Pick<Schema, 'flat' | 'pages' | 'pageFolders' | 'variables' | 'settings' | 'definition' | 'components'>;
20
20
  /**
21
21
  * What changed between two versions of a schema, entity by entity.
22
22
  *