@plitzi/sdk-shared 0.38.2 → 0.38.4

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.
@@ -10,5 +10,5 @@ export type TInitQuery = {
10
10
  };
11
11
  };
12
12
  };
13
- declare const InitQuery = "\n query InitQuery($environment: String!, $revision: Int) {\n Space(environment: $environment, revision: $revision) {\n schema {\n settings\n rsc\n flat {\n id\n definition {\n label\n type\n initialState\n styleSelectors\n bindings\n interactions\n parentId\n rootId\n items\n runtime\n loadStrategy\n flag {\n name\n is\n }\n anchor\n }\n attributes\n }\n pages\n components\n flags\n pageFolders {\n id\n name\n slug\n parentId\n }\n variables {\n name\n type\n value\n subValues {\n when\n value\n }\n }\n }\n plugins {\n type\n resource\n settings\n }\n style {\n variables\n cache\n }\n # The schema fetch is the one moment a client-side render hears from the server at all, so the decision it\n # would have been handed in an SSR bootstrap travels here instead.\n render {\n overQuota\n }\n }\n }\n";
13
+ declare const InitQuery = "\n query InitQuery($environment: String!, $revision: Int) {\n Space(environment: $environment, revision: $revision) {\n schema {\n settings\n rsc\n flat {\n id\n definition {\n label\n type\n initialState\n styleSelectors\n bindings\n interactions\n parentId\n rootId\n items\n runtime\n loadStrategy\n flag {\n name\n is\n }\n anchor\n motion {\n enter\n on\n duration\n delay\n stagger\n loop\n }\n }\n attributes\n }\n pages\n components\n flags\n pageFolders {\n id\n name\n slug\n parentId\n }\n variables {\n name\n type\n value\n subValues {\n when\n value\n }\n }\n }\n plugins {\n type\n resource\n settings\n }\n style {\n variables\n cache\n }\n # The schema fetch is the one moment a client-side render hears from the server at all, so the decision it\n # would have been handed in an SSR bootstrap travels here instead.\n render {\n overQuota\n }\n }\n }\n";
14
14
  export default InitQuery;
@@ -1,4 +1,4 @@
1
1
  //#region src/network/graphql/sdk/Queries/InitQuery.ts
2
- var e = "\n query InitQuery($environment: String!, $revision: Int) {\n Space(environment: $environment, revision: $revision) {\n schema {\n settings\n rsc\n flat {\n id\n definition {\n label\n type\n initialState\n styleSelectors\n bindings\n interactions\n parentId\n rootId\n items\n runtime\n loadStrategy\n flag {\n name\n is\n }\n anchor\n }\n attributes\n }\n pages\n components\n flags\n pageFolders {\n id\n name\n slug\n parentId\n }\n variables {\n name\n type\n value\n subValues {\n when\n value\n }\n }\n }\n plugins {\n type\n resource\n settings\n }\n style {\n variables\n cache\n }\n # The schema fetch is the one moment a client-side render hears from the server at all, so the decision it\n # would have been handed in an SSR bootstrap travels here instead.\n render {\n overQuota\n }\n }\n }\n";
2
+ var e = "\n query InitQuery($environment: String!, $revision: Int) {\n Space(environment: $environment, revision: $revision) {\n schema {\n settings\n rsc\n flat {\n id\n definition {\n label\n type\n initialState\n styleSelectors\n bindings\n interactions\n parentId\n rootId\n items\n runtime\n loadStrategy\n flag {\n name\n is\n }\n anchor\n motion {\n enter\n on\n duration\n delay\n stagger\n loop\n }\n }\n attributes\n }\n pages\n components\n flags\n pageFolders {\n id\n name\n slug\n parentId\n }\n variables {\n name\n type\n value\n subValues {\n when\n value\n }\n }\n }\n plugins {\n type\n resource\n settings\n }\n style {\n variables\n cache\n }\n # The schema fetch is the one moment a client-side render hears from the server at all, so the decision it\n # would have been handed in an SSR bootstrap travels here instead.\n render {\n overQuota\n }\n }\n }\n";
3
3
  //#endregion
4
4
  export { e as default };
@@ -0,0 +1,109 @@
1
+ /**
2
+ * An element's declared motion — how it arrives, when, and whether it keeps moving — which the SDK's own stylesheet
3
+ * plays (`_motion.scss`). Every preset moves only `opacity` and `transform`, which the compositor animates without
4
+ * laying the page out again, and every one is stilled for a visitor who asked for less motion: the motion good
5
+ * practices, kept by construction rather than by the author.
6
+ *
7
+ * The one description the authoring package, the builder's Motion tab, the MCP and the validator all read; the
8
+ * stylesheet mirrors its presets and frames, and a test in `apps/sdk` holds the two together.
9
+ */
10
+ export declare const MOTION_ENTERS: readonly ["fade", "fade-up", "fade-down", "slide-left", "slide-right", "slide-up", "scale", "zoom-in", "zoom-out", "pop", "bounce-in", "tilt", "spin-in"];
11
+ export type MotionEnter = (typeof MOTION_ENTERS)[number];
12
+ /**
13
+ * When an arrival plays: as the page loads (`load`); once, as the element first comes into view, and then it stays
14
+ * (`view`); or with the scroll itself, at the reader's pace — played backwards when the reader scrolls back up past it
15
+ * (`scroll`).
16
+ */
17
+ export declare const MOTION_TRIGGERS: readonly ["load", "view", "scroll"];
18
+ export type MotionTrigger = (typeof MOTION_TRIGGERS)[number];
19
+ /**
20
+ * A motion that repeats: a gentle rise and fall, a breath, a turn, a sway — a bounce, a wobble, a small orbit, a
21
+ * heartbeat, a drift. Held until the page is live.
22
+ */
23
+ export declare const MOTION_LOOPS: readonly ["float", "pulse", "spin", "sway", "bounce", "wobble", "orbit", "heartbeat", "drift"];
24
+ export type MotionLoop = (typeof MOTION_LOOPS)[number];
25
+ export interface ElementMotion {
26
+ /** How it arrives. */
27
+ enter?: MotionEnter;
28
+ /** When it arrives: `load` (the default), `view` (once, as it comes into view) or `scroll` (with the scroll). */
29
+ on?: MotionTrigger;
30
+ /** How long it takes to arrive, in ms (600 by default). Ignored under `scroll`, which follows the scroll. */
31
+ duration?: number;
32
+ /** How long it waits before it does, in ms. */
33
+ delay?: number;
34
+ /**
35
+ * Its CHILDREN arrive one after another, this many ms apart — a grid of cards, a list's rows — rather than the
36
+ * element itself. Up to the first 24; the rest arrive with the 24th.
37
+ */
38
+ stagger?: number;
39
+ /** Keeps moving after it arrived. */
40
+ loop?: MotionLoop;
41
+ }
42
+ /** How long an arrival takes when it does not say, and the curve every arrival follows: quick out, gentle in. */
43
+ export declare const MOTION_DEFAULT_DURATION = 600;
44
+ export declare const MOTION_ENTER_EASING = "cubic-bezier(0.2, 0.7, 0.2, 1)";
45
+ /**
46
+ * One frame of an arrival, `at` a percentage of its duration. It moves the individual `translate`, `scale` and `rotate`
47
+ * properties — never `transform` — so it composes with a `transform` the element has of its own and with a loop.
48
+ */
49
+ export interface MotionEnterFrame {
50
+ at: number;
51
+ opacity?: number;
52
+ translate?: string;
53
+ scale?: string;
54
+ rotate?: string;
55
+ }
56
+ /**
57
+ * Each arrival's frames, from where it starts (`at: 0`) through any it passes on the way — an overshoot, a bounce. It
58
+ * always ends where the element is, which is why no frame says so.
59
+ */
60
+ export declare const MOTION_ENTER_FRAMES: Record<MotionEnter, MotionEnterFrame[]>;
61
+ /** Where each arrival starts from — its first frame. */
62
+ export declare const MOTION_ENTER_FROM: Record<MotionEnter, Omit<MotionEnterFrame, "at">>;
63
+ /** One frame of a loop: its `transform` at a percentage of its period. A frame no loop names is the element at rest. */
64
+ export interface MotionLoopFrame {
65
+ at: number;
66
+ transform: string;
67
+ }
68
+ /**
69
+ * Each loop's frames, its period and its curve. A loop that swings starts and ends at rest; one that keeps turning
70
+ * (`spin`) ends a full turn on, which is the same place.
71
+ */
72
+ export declare const MOTION_LOOP_FRAMES: Record<MotionLoop, {
73
+ frames: MotionLoopFrame[];
74
+ periodMs: number;
75
+ easing: string;
76
+ }>;
77
+ /** The longest a duration, a delay or a stagger may be: past it, a page is waiting on its decoration. */
78
+ export declare const MOTION_MAX_MS = 10000;
79
+ /** What is wrong with a value given as an element's `motion`, one sentence each — empty when it is one. */
80
+ export declare const motionProblems: (value: unknown) => string[];
81
+ export declare const isMotion: (value: unknown) => value is ElementMotion;
82
+ /**
83
+ * What an element with `motion` carries in the DOM: the presets as `data-motion-*` — what the stylesheet animates by —
84
+ * and its timings as custom properties. Nothing at all for an element with none, so its markup stays as it was.
85
+ */
86
+ export declare const motionAttributes: (motion: ElementMotion | undefined) => {
87
+ attributes: Record<string, string>;
88
+ style: Record<string, string>;
89
+ };
90
+ /** Every element the SDK's stylesheet moves: an arrival, a staggered child, a loop. */
91
+ export declare const MOVING_SELECTOR = "[data-motion-enter], [data-motion-stagger] > *, [data-motion-loop]";
92
+ /**
93
+ * The builder's canvas, held still: what is being edited is shown as it ends up, rather than arriving again on every
94
+ * change. `MOTION_PLAY_CSS` is the canvas playing — loops included, which a page holds until it is live and an editor
95
+ * never is.
96
+ */
97
+ export declare const MOTION_STILL_CSS = "[data-motion-enter], [data-motion-stagger] > *, [data-motion-loop] { animation: none !important; }";
98
+ /** The attribute an arrival waiting to be seen (`on: 'view'`) gets once it has been, and then keeps (`revealOnView`). */
99
+ export declare const MOTION_SEEN_ATTRIBUTE = "data-motion-seen";
100
+ /** Every element whose arrival waits to be seen: what `revealOnView` watches. */
101
+ export declare const MOTION_VIEW_SELECTOR = "[data-motion-on=\"view\"]";
102
+ /**
103
+ * Every arrival waiting to be seen, played as if it had been: a surface with nobody scrolling it and no SDK root to
104
+ * watch it — a preview of an element, a thumbnail — would hold it at its start, unseen.
105
+ */
106
+ export declare const MOTION_SEEN_CSS = "[data-motion-on=\"view\"][data-motion-enter], [data-motion-on=\"view\"][data-motion-stagger] > * { animation-play-state: running, running !important; }";
107
+ export declare const MOTION_PLAY_CSS: string;
108
+ /** Whether an animation is one of the declared motion's — what replaying the canvas restarts, and nothing else. */
109
+ export declare const isMotionAnimation: (animation: object) => boolean;
@@ -0,0 +1,271 @@
1
+ import { isRecord as e } from "../helpers/isRecord.mjs";
2
+ //#region src/schema/motion.ts
3
+ var t = [
4
+ "fade",
5
+ "fade-up",
6
+ "fade-down",
7
+ "slide-left",
8
+ "slide-right",
9
+ "slide-up",
10
+ "scale",
11
+ "zoom-in",
12
+ "zoom-out",
13
+ "pop",
14
+ "bounce-in",
15
+ "tilt",
16
+ "spin-in"
17
+ ], n = [
18
+ "load",
19
+ "view",
20
+ "scroll"
21
+ ], r = [
22
+ "float",
23
+ "pulse",
24
+ "spin",
25
+ "sway",
26
+ "bounce",
27
+ "wobble",
28
+ "orbit",
29
+ "heartbeat",
30
+ "drift"
31
+ ], i = 600, a = "cubic-bezier(0.2, 0.7, 0.2, 1)", o = {
32
+ fade: [{
33
+ at: 0,
34
+ opacity: 0
35
+ }],
36
+ "fade-up": [{
37
+ at: 0,
38
+ opacity: 0,
39
+ translate: "0 24px"
40
+ }],
41
+ "fade-down": [{
42
+ at: 0,
43
+ opacity: 0,
44
+ translate: "0 -24px"
45
+ }],
46
+ "slide-left": [{
47
+ at: 0,
48
+ opacity: 0,
49
+ translate: "32px 0"
50
+ }],
51
+ "slide-right": [{
52
+ at: 0,
53
+ opacity: 0,
54
+ translate: "-32px 0"
55
+ }],
56
+ "slide-up": [{
57
+ at: 0,
58
+ opacity: 0,
59
+ translate: "0 72px"
60
+ }],
61
+ scale: [{
62
+ at: 0,
63
+ opacity: 0,
64
+ scale: "0.94"
65
+ }],
66
+ "zoom-in": [{
67
+ at: 0,
68
+ opacity: 0,
69
+ scale: "0.6"
70
+ }],
71
+ "zoom-out": [{
72
+ at: 0,
73
+ opacity: 0,
74
+ scale: "1.25"
75
+ }],
76
+ pop: [
77
+ {
78
+ at: 0,
79
+ opacity: 0,
80
+ scale: "0.5"
81
+ },
82
+ {
83
+ at: 55,
84
+ opacity: 1,
85
+ scale: "1.08"
86
+ },
87
+ {
88
+ at: 78,
89
+ scale: "0.97"
90
+ }
91
+ ],
92
+ "bounce-in": [
93
+ {
94
+ at: 0,
95
+ opacity: 0,
96
+ translate: "0 -64px"
97
+ },
98
+ {
99
+ at: 55,
100
+ opacity: 1,
101
+ translate: "0 10px"
102
+ },
103
+ {
104
+ at: 75,
105
+ translate: "0 -5px"
106
+ },
107
+ {
108
+ at: 90,
109
+ translate: "0 2px"
110
+ }
111
+ ],
112
+ tilt: [{
113
+ at: 0,
114
+ opacity: 0,
115
+ translate: "0 32px",
116
+ rotate: "-6deg"
117
+ }],
118
+ "spin-in": [{
119
+ at: 0,
120
+ opacity: 0,
121
+ scale: "0.4",
122
+ rotate: "-180deg"
123
+ }]
124
+ }, s = Object.fromEntries(t.map((e) => {
125
+ let [{ at: t, ...n }] = o[e];
126
+ return [e, n];
127
+ })), c = (e, t) => {
128
+ let n = t * 2 * Math.PI, r = Math.round(Math.sin(n) * e * 10) / 10, i = Math.round(-Math.cos(n) * e * 10) / 10;
129
+ return `translate(${String(r)}px, ${String(i)}px)`;
130
+ }, l = {
131
+ float: {
132
+ frames: [{
133
+ at: 50,
134
+ transform: "translateY(-8px)"
135
+ }],
136
+ periodMs: 6e3,
137
+ easing: "ease-in-out"
138
+ },
139
+ pulse: {
140
+ frames: [{
141
+ at: 50,
142
+ transform: "scale(1.04)"
143
+ }],
144
+ periodMs: 3e3,
145
+ easing: "ease-in-out"
146
+ },
147
+ spin: {
148
+ frames: [{
149
+ at: 100,
150
+ transform: "rotate(360deg)"
151
+ }],
152
+ periodMs: 12e3,
153
+ easing: "linear"
154
+ },
155
+ sway: {
156
+ frames: [{
157
+ at: 50,
158
+ transform: "rotate(2deg)"
159
+ }],
160
+ periodMs: 5e3,
161
+ easing: "ease-in-out"
162
+ },
163
+ bounce: {
164
+ frames: [
165
+ {
166
+ at: 0,
167
+ transform: "translateY(0) scale(1.03, 0.97)"
168
+ },
169
+ {
170
+ at: 45,
171
+ transform: "translateY(-14px) scale(0.98, 1.02)"
172
+ },
173
+ {
174
+ at: 55,
175
+ transform: "translateY(-14px) scale(0.98, 1.02)"
176
+ },
177
+ {
178
+ at: 100,
179
+ transform: "translateY(0) scale(1.03, 0.97)"
180
+ }
181
+ ],
182
+ periodMs: 1400,
183
+ easing: "ease-in-out"
184
+ },
185
+ wobble: {
186
+ frames: [{
187
+ at: 25,
188
+ transform: "rotate(-5deg)"
189
+ }, {
190
+ at: 75,
191
+ transform: "rotate(5deg)"
192
+ }],
193
+ periodMs: 2400,
194
+ easing: "ease-in-out"
195
+ },
196
+ orbit: {
197
+ frames: Array.from({ length: 9 }, (e, t) => ({
198
+ at: t * 100 / 8,
199
+ transform: c(6, t / 8)
200
+ })),
201
+ periodMs: 8e3,
202
+ easing: "linear"
203
+ },
204
+ heartbeat: {
205
+ frames: [
206
+ {
207
+ at: 14,
208
+ transform: "scale(1.1)"
209
+ },
210
+ {
211
+ at: 28,
212
+ transform: "scale(1)"
213
+ },
214
+ {
215
+ at: 42,
216
+ transform: "scale(1.07)"
217
+ },
218
+ {
219
+ at: 70,
220
+ transform: "scale(1)"
221
+ }
222
+ ],
223
+ periodMs: 1600,
224
+ easing: "ease-in-out"
225
+ },
226
+ drift: {
227
+ frames: [{
228
+ at: 50,
229
+ transform: "translateX(12px)"
230
+ }],
231
+ periodMs: 7e3,
232
+ easing: "ease-in-out"
233
+ }
234
+ }, u = 1e4, d = (e, t) => typeof t == "string" && e.includes(t), f = /* @__PURE__ */ new Set([
235
+ "enter",
236
+ "on",
237
+ "duration",
238
+ "delay",
239
+ "stagger",
240
+ "loop"
241
+ ]), p = (i) => {
242
+ if (!e(i)) return ["motion is an object: `{ enter: 'fade-up', on: 'view' }`"];
243
+ let a = [];
244
+ for (let e of Object.keys(i)) f.has(e) || a.push(`motion has no "${e}" — it takes enter, on, duration, delay, stagger and loop`);
245
+ i.enter !== void 0 && !d(t, i.enter) && a.push(`motion.enter is one of ${t.join(", ")}`), i.on !== void 0 && !d(n, i.on) && a.push(`motion.on is ${n.slice(0, -1).join(", ")} or ${String(n.at(-1))}`), i.loop !== void 0 && !d(r, i.loop) && a.push(`motion.loop is one of ${r.join(", ")}`);
246
+ for (let e of [
247
+ "duration",
248
+ "delay",
249
+ "stagger"
250
+ ]) {
251
+ let t = i[e];
252
+ t !== void 0 && (typeof t != "number" || !Number.isFinite(t) || t < 0 || t > 1e4) && a.push(`motion.${e} is a number of ms from 0 to ${String(u)}`);
253
+ }
254
+ return i.enter === void 0 && i.loop === void 0 && a.push("motion says nothing to play: give it an `enter`, a `loop`, or both"), i.stagger !== void 0 && i.enter === void 0 && a.push("motion.stagger staggers the children’s `enter`: give it one"), a;
255
+ }, m = (e) => p(e).length === 0, h = (e) => {
256
+ if (!e) return {
257
+ attributes: {},
258
+ style: {}
259
+ };
260
+ let t = {}, n = {};
261
+ return e.enter && (t[e.stagger === void 0 ? "data-motion-enter" : "data-motion-stagger"] = e.enter, t["data-motion-on"] = e.on ?? "load"), e.loop && (t["data-motion-loop"] = e.loop), e.duration !== void 0 && (n["--plitzi-motion-duration"] = `${String(e.duration)}ms`), e.delay !== void 0 && (n["--plitzi-motion-delay"] = `${String(e.delay)}ms`), e.stagger !== void 0 && (n["--plitzi-motion-stagger"] = `${String(e.stagger)}ms`), {
262
+ attributes: t,
263
+ style: n
264
+ };
265
+ }, g = "[data-motion-enter], [data-motion-stagger] > *, [data-motion-loop]", _ = `${g} { animation: none !important; }`, v = "data-motion-seen", y = "[data-motion-on=\"view\"]", b = "[data-motion-on=\"view\"][data-motion-enter], [data-motion-on=\"view\"][data-motion-stagger] > * { animation-play-state: running, running !important; }", x = [
266
+ "[data-motion-loop] { animation-play-state: running, running !important; }",
267
+ b,
268
+ "[data-motion-on=\"scroll\"][data-motion-enter], [data-motion-on=\"scroll\"][data-motion-stagger] > * { animation-timeline: auto, auto !important; }"
269
+ ].join("\n"), S = (e) => "animationName" in e && typeof e.animationName == "string" && e.animationName.startsWith("plitzi-motion-");
270
+ //#endregion
271
+ export { i as MOTION_DEFAULT_DURATION, t as MOTION_ENTERS, a as MOTION_ENTER_EASING, o as MOTION_ENTER_FRAMES, s as MOTION_ENTER_FROM, r as MOTION_LOOPS, l as MOTION_LOOP_FRAMES, u as MOTION_MAX_MS, x as MOTION_PLAY_CSS, v as MOTION_SEEN_ATTRIBUTE, b as MOTION_SEEN_CSS, _ as MOTION_STILL_CSS, n as MOTION_TRIGGERS, y as MOTION_VIEW_SELECTOR, g as MOVING_SELECTOR, m as isMotion, S as isMotionAnimation, h as motionAttributes, p as motionProblems };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Plays every arrival under `root` that waits to be seen (`motion: { on: 'view' }`) the first time it comes into view,
3
+ * and never again: the stylesheet holds it at its start until the element carries `data-motion-seen`, which this sets
4
+ * and nothing takes off. Elements added later — a page navigated to, a list's new rows — are watched as they arrive.
5
+ * Answers the function that stops watching.
6
+ *
7
+ * One observer for the whole tree rather than one per element: a page of cards is hundreds of them. A browser without
8
+ * `IntersectionObserver` shows each arrival at once, as one that cannot know what is on screen.
9
+ */
10
+ export declare const revealOnView: (root: Element) => (() => void);
@@ -0,0 +1,23 @@
1
+ import { MOTION_SEEN_ATTRIBUTE as e, MOTION_VIEW_SELECTOR as t } from "./motion.mjs";
2
+ //#region src/schema/motionReveal.ts
3
+ var n = `${t}:not([${e}])`, r = (t) => {
4
+ let r = (t) => t.setAttribute(e, ""), i = (e) => [...e.matches(n) ? [e] : [], ...Array.from(e.querySelectorAll(n))];
5
+ if (typeof Reflect.get(globalThis, "IntersectionObserver") != "function") return i(t).forEach(r), () => void 0;
6
+ let a = new IntersectionObserver((e) => {
7
+ for (let t of e) t.isIntersecting && (r(t.target), a.unobserve(t.target));
8
+ }), o = (e) => i(e).forEach((e) => a.observe(e)), s = new MutationObserver((e) => {
9
+ for (let t of e) t.type === "attributes" && t.target instanceof Element && o(t.target), t.addedNodes.forEach((e) => {
10
+ e instanceof Element && o(e);
11
+ });
12
+ });
13
+ return o(t), s.observe(t, {
14
+ childList: !0,
15
+ subtree: !0,
16
+ attributes: !0,
17
+ attributeFilter: ["data-motion-on"]
18
+ }), () => {
19
+ a.disconnect(), s.disconnect();
20
+ };
21
+ };
22
+ //#endregion
23
+ export { r as revealOnView };
@@ -2,26 +2,35 @@
2
2
  var e = (e) => ({
3
3
  ...e,
4
4
  flat: Object.values(e.flat)
5
- }), t = ({ definition: e, ...t }) => {
6
- let { parentId: n, items: r, bindings: i, interactions: a, initialState: o, runtime: s, loadStrategy: c, flag: l, anchor: u, ...d } = e;
5
+ }), t = (e) => ({
6
+ ...e.enter ? { enter: e.enter } : {},
7
+ ...e.on ? { on: e.on } : {},
8
+ ...typeof e.duration == "number" ? { duration: e.duration } : {},
9
+ ...typeof e.delay == "number" ? { delay: e.delay } : {},
10
+ ...typeof e.stagger == "number" ? { stagger: e.stagger } : {},
11
+ ...e.loop ? { loop: e.loop } : {}
12
+ }), n = ({ definition: e, ...n }) => {
13
+ let { parentId: r, items: i, bindings: a, interactions: o, initialState: s, runtime: c, loadStrategy: l, flag: u, anchor: d, motion: f, quiet: p, ...m } = e;
7
14
  return {
8
- ...t,
15
+ ...n,
9
16
  definition: {
10
- ...d,
11
- ...n == null ? {} : { parentId: n },
12
- ...r == null ? {} : { items: r },
13
- ...i == null ? {} : { bindings: i },
14
- ...a == null ? {} : { interactions: a },
15
- ...o == null ? {} : { initialState: o },
16
- ...s == null ? {} : { runtime: s },
17
- ...c == null ? {} : { loadStrategy: c },
18
- ...l == null ? {} : { flag: l },
19
- ...u == null ? {} : { anchor: u }
17
+ ...m,
18
+ ...r == null ? {} : { parentId: r },
19
+ ...i == null ? {} : { items: i },
20
+ ...a == null ? {} : { bindings: a },
21
+ ...o == null ? {} : { interactions: o },
22
+ ...s == null ? {} : { initialState: s },
23
+ ...c == null ? {} : { runtime: c },
24
+ ...l == null ? {} : { loadStrategy: l },
25
+ ...u == null ? {} : { flag: u },
26
+ ...d == null ? {} : { anchor: d },
27
+ ...f == null ? {} : { motion: t(f) },
28
+ ...p == null ? {} : { quiet: p }
20
29
  }
21
30
  };
22
- }, n = (e) => ({
31
+ }, r = (e) => ({
23
32
  ...e,
24
- flat: Object.fromEntries(e.flat.map((e) => [e.id, t(e)]))
33
+ flat: Object.fromEntries(e.flat.map((e) => [e.id, n(e)]))
25
34
  });
26
35
  //#endregion
27
- export { t as elementFromWire, n as schemaFromWire, e as schemaToWire };
36
+ export { n as elementFromWire, r as schemaFromWire, e as schemaToWire };
@@ -28,6 +28,11 @@ export type SpaceExport = {
28
28
  };
29
29
  /** The version taken out: the draft (`main`, revision 0), or a snapshot an environment holds. */
30
30
  version: Pick<SpaceVersionContents, 'environment' | 'revision' | 'snapshot'>;
31
+ /**
32
+ * Which state of the draft's documents this is — its schema, style, actions and connectors — what `plitzi push`
33
+ * checks the space's draft has not moved on from. `null` for a snapshot, which no push writes.
34
+ */
35
+ draft: string | null;
31
36
  /** The space as authoring code, by path (`index.ts`, a file per page): none for a project that reads it from Plitzi. */
32
37
  authoring: {
33
38
  exportName: string;
@@ -0,0 +1,55 @@
1
+ import { Schema, Style } from '../types';
2
+ /**
3
+ * A project's space put back on Plitzi as the space's draft (docs/en/projects-from-spaces.md): what `plitzi push` sends
4
+ * to `PUT /spaces/:spaceId/import`, and what it is answered. The way back of `SpaceExport` — one shape for both ends.
5
+ */
6
+ export declare const SPACE_IMPORT_FORMAT = 1;
7
+ export type SpaceImport = {
8
+ format: typeof SPACE_IMPORT_FORMAT;
9
+ /** The space as the project authors it: the two documents the draft is made of, replaced whole. */
10
+ documents: {
11
+ schema: Schema;
12
+ style: Style;
13
+ };
14
+ /**
15
+ * Every server action the project keeps, and every connector: the space's become exactly these. Left out, the project
16
+ * keeps none of its own, and the space's are left as they are.
17
+ */
18
+ actions?: {
19
+ identifier: string;
20
+ name: string;
21
+ document: unknown;
22
+ }[];
23
+ connectors?: {
24
+ identifier: string;
25
+ name: string;
26
+ manifest: unknown;
27
+ }[];
28
+ /**
29
+ * The draft the project was last given or last pushed (`SpaceExport.draft`): the push is refused when the space's has
30
+ * moved on since. `null` for a project that never had one — refused unless the space is still as it was created.
31
+ */
32
+ base: string | null;
33
+ /** Replace the draft whatever it holds now. */
34
+ force: boolean;
35
+ };
36
+ /** Why a push was not taken, before anything was checked: the draft is not the one the project knows. */
37
+ export type SpaceImportRefusalCode = 'DRAFT_MOVED' | 'DRAFT_NOT_EMPTY';
38
+ export type SpaceImportResult =
39
+ /** Taken: `draft` is what the project knows from now on; `changed` false when it already was the space's draft. */
40
+ {
41
+ ok: true;
42
+ changed: boolean;
43
+ draft: string;
44
+ } | {
45
+ ok: false;
46
+ refusal: {
47
+ code: SpaceImportRefusalCode;
48
+ error: string;
49
+ };
50
+ }
51
+ /** Not taken: what is wrong with what was sent, each problem where it is. */
52
+ | {
53
+ ok: false;
54
+ problems: string[];
55
+ };
@@ -0,0 +1,4 @@
1
+ //#region src/source/import.ts
2
+ var e = 1;
3
+ //#endregion
4
+ export { e as SPACE_IMPORT_FORMAT };
@@ -1,4 +1,6 @@
1
1
  export { readSourceSnapshot, secretIn, sourcePathProblem, SOURCE_SNAPSHOT_FORMAT, SOURCE_SNAPSHOT_LIMITS } from './snapshot';
2
2
  export { SPACE_EXPORT_FORMAT } from './export';
3
+ export { SPACE_IMPORT_FORMAT } from './import';
3
4
  export type { SourceSnapshot, SourceSnapshotKind, SourceSnapshotReading } from './snapshot';
4
5
  export type { SpaceExport, SpaceExportConflict, SpaceExportFile } from './export';
6
+ export type { SpaceImport, SpaceImportRefusalCode, SpaceImportResult } from './import';
@@ -1,3 +1,4 @@
1
1
  import { SPACE_EXPORT_FORMAT as e } from "./export.mjs";
2
- import { SOURCE_SNAPSHOT_FORMAT as t, SOURCE_SNAPSHOT_LIMITS as n, readSourceSnapshot as r, secretIn as i, sourcePathProblem as a } from "./snapshot.mjs";
3
- export { t as SOURCE_SNAPSHOT_FORMAT, n as SOURCE_SNAPSHOT_LIMITS, e as SPACE_EXPORT_FORMAT, r as readSourceSnapshot, i as secretIn, a as sourcePathProblem };
2
+ import { SPACE_IMPORT_FORMAT as t } from "./import.mjs";
3
+ import { SOURCE_SNAPSHOT_FORMAT as n, SOURCE_SNAPSHOT_LIMITS as r, readSourceSnapshot as i, secretIn as a, sourcePathProblem as o } from "./snapshot.mjs";
4
+ export { n as SOURCE_SNAPSHOT_FORMAT, r as SOURCE_SNAPSHOT_LIMITS, e as SPACE_EXPORT_FORMAT, t as SPACE_IMPORT_FORMAT, i as readSourceSnapshot, a as secretIn, o as sourcePathProblem };