@preprio/toolkit 0.5.0-rc.6 → 0.5.0-rc.8
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.
- package/README.md +14 -6
- package/dist/astro/index.cjs +1 -1
- package/dist/astro/index.js +1 -1
- package/dist/{chunk-L3SDL6MP.js → chunk-4OXPPBVF.js} +22 -22
- package/dist/{chunk-KZIRM54F.js → chunk-VNKYFJJS.js} +1 -1
- package/dist/{chunk-WHZNCYUS.js → chunk-Y4NMRYHE.js} +1 -1
- package/dist/codegen/index.cjs +16 -13
- package/dist/codegen/index.d.cts +42 -18
- package/dist/codegen/index.d.ts +42 -18
- package/dist/codegen/index.js +15 -13
- package/dist/index.cjs +22 -22
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/nextjs/components.cjs +22 -22
- package/dist/nextjs/components.js +2 -2
- package/dist/nextjs/index.cjs +1 -1
- package/dist/nextjs/index.js +1 -1
- package/dist/nextjs/live-action.js +2 -2
- package/dist/nuxt/index.cjs +1 -1
- package/dist/nuxt/index.js +1 -1
- package/dist/react/components.cjs +22 -22
- package/dist/react/components.js +22 -22
- package/dist/sveltekit/index.cjs +1 -1
- package/dist/sveltekit/index.js +1 -1
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -737,12 +737,13 @@ There are three ways to get them there. Pick the first that fits your setup.
|
|
|
737
737
|
|
|
738
738
|
#### Option 1: GraphQL Codegen (recommended)
|
|
739
739
|
|
|
740
|
-
Add the `preprIds` document transform to your Codegen output. `_id`
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
740
|
+
Add the `preprIds` document transform to your Codegen output. `_id` is
|
|
741
|
+
added wherever your schema has one: on models and components, and inside
|
|
742
|
+
each member of a dynamic content field. Collections like `Pages` and unions
|
|
743
|
+
themselves never get an `_id`, so the queries stay valid. Your `.graphql`
|
|
744
|
+
files stay as they are; the generated documents and types include the field,
|
|
745
|
+
at no runtime cost. Adding a field never breaks code that compiles today, so
|
|
746
|
+
this is safe to turn on in an existing project.
|
|
746
747
|
|
|
747
748
|
```ts
|
|
748
749
|
// codegen.ts
|
|
@@ -766,6 +767,13 @@ export default config;
|
|
|
766
767
|
Run Codegen again after adding it. Needs `graphql` 16 or later, which a
|
|
767
768
|
Codegen setup already has.
|
|
768
769
|
|
|
770
|
+
To add `__typename` everywhere too, use `createPreprIds({ typename: true })`
|
|
771
|
+
instead. It is off by default because a selected `__typename` changes the
|
|
772
|
+
generated types: each member of a union is typed on its own, so code that
|
|
773
|
+
reads a union's fields without checking `__typename` first stops compiling.
|
|
774
|
+
Live preview only needs it on dynamic content entries, where you select it
|
|
775
|
+
already to render them.
|
|
776
|
+
|
|
769
777
|
#### Option 2: at runtime, without Codegen
|
|
770
778
|
|
|
771
779
|
`addPreprIds(document, schema)` does the same to a parsed query. It needs
|
package/dist/astro/index.cjs
CHANGED
package/dist/astro/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
ALL_FEATURES_ENABLED,
|
|
3
3
|
VERSION,
|
|
4
4
|
resolveFeatures
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-Y4NMRYHE.js";
|
|
6
6
|
import {
|
|
7
7
|
createIframeBridge,
|
|
8
8
|
isLocale,
|
|
@@ -659,7 +659,7 @@ var StegaElements = class {
|
|
|
659
659
|
};
|
|
660
660
|
|
|
661
661
|
// src/core/stega/stega.generated.ts
|
|
662
|
-
var STEGA_STYLES = '@property --prepr-presence{syntax:"<number>";inherits:true;initial-value:1}[data-prepr-encoded]{outline:1px dashed
|
|
662
|
+
var STEGA_STYLES = '@property --prepr-presence{syntax:"<number>";inherits:true;initial-value:1}[data-prepr-encoded]{outline:1px dashed rgb(79 70 229/calc(.3 * var(--prepr-presence,1)));outline-offset:2px}';
|
|
663
663
|
|
|
664
664
|
// src/core/stega/styles.ts
|
|
665
665
|
var STEGA_STYLE_MARKER = "data-prepr-stega";
|
|
@@ -1052,7 +1052,7 @@ function createToolbarStore(initial = {}) {
|
|
|
1052
1052
|
return { get, set, subscribe };
|
|
1053
1053
|
}
|
|
1054
1054
|
|
|
1055
|
-
// ../../node_modules/.pnpm/preact@10.29.
|
|
1055
|
+
// ../../node_modules/.pnpm/preact@10.29.8/node_modules/preact/dist/preact.mjs
|
|
1056
1056
|
var n;
|
|
1057
1057
|
var l;
|
|
1058
1058
|
var u;
|
|
@@ -1123,8 +1123,8 @@ function H() {
|
|
|
1123
1123
|
}
|
|
1124
1124
|
}
|
|
1125
1125
|
function L(n2, l2, u3, t3, i2, r2, o2, e2, f3, c2, a2) {
|
|
1126
|
-
var s2, h2, p2, v2, y2, _2, g2
|
|
1127
|
-
for (f3 = T(u3, l2,
|
|
1126
|
+
var s2, h2, p2, v2, y2, _2, g2 = t3 && t3.__k || w, m2 = l2.length;
|
|
1127
|
+
for (f3 = T(u3, l2, g2, f3, m2), s2 = 0; s2 < m2; s2++) null != (p2 = u3.__k[s2]) && (h2 = -1 != p2.__i && g2[p2.__i] || d, p2.__i = s2, _2 = q(n2, p2, h2, i2, r2, o2, e2, f3, c2, a2), v2 = p2.__e, p2.ref && h2.ref != p2.ref && (h2.ref && J(h2.ref, null, p2), a2.push(p2.ref, p2.__c || v2, p2)), null == y2 && null != v2 && (y2 = v2), 4 & p2.__u ? (f3 = j(p2, f3, n2), h2.__e && (h2.__e = null)) : "function" == typeof p2.type && void 0 !== _2 ? f3 = _2 : v2 && (f3 = v2.nextSibling), p2.__u &= -7);
|
|
1128
1128
|
return u3.__e = y2, f3;
|
|
1129
1129
|
}
|
|
1130
1130
|
function T(n2, l2, u3, t3, i2) {
|
|
@@ -1133,13 +1133,13 @@ function T(n2, l2, u3, t3, i2) {
|
|
|
1133
1133
|
if (s2) for (r2 = 0; r2 < a2; r2++) null != (e2 = u3[r2]) && 0 == (2 & e2.__u) && (e2.__e == t3 && (t3 = $(e2)), K(e2, e2));
|
|
1134
1134
|
return t3;
|
|
1135
1135
|
}
|
|
1136
|
-
function j(n2, l2, u3
|
|
1137
|
-
var
|
|
1136
|
+
function j(n2, l2, u3) {
|
|
1137
|
+
var t3, i2;
|
|
1138
1138
|
if ("function" == typeof n2.type) {
|
|
1139
|
-
for (
|
|
1139
|
+
for (t3 = n2.__k, i2 = 0; t3 && i2 < t3.length; i2++) t3[i2] && (t3[i2].__ = n2, l2 = j(t3[i2], l2, u3));
|
|
1140
1140
|
return l2;
|
|
1141
1141
|
}
|
|
1142
|
-
n2.__e != l2 && (
|
|
1142
|
+
n2.__e != l2 && (l2 && n2.type && !l2.parentNode && (l2 = $(n2)), l2 = u3.insertBefore(n2.__e, l2 || null));
|
|
1143
1143
|
do {
|
|
1144
1144
|
l2 = l2 && l2.nextSibling;
|
|
1145
1145
|
} while (null != l2 && 8 == l2.nodeType);
|
|
@@ -1185,35 +1185,35 @@ function V(n2) {
|
|
|
1185
1185
|
};
|
|
1186
1186
|
}
|
|
1187
1187
|
function q(n2, u3, t3, i2, r2, o2, e2, f3, c2, a2) {
|
|
1188
|
-
var s2, h2, p2, v2, y2, d2, _2, k2, x2, M,
|
|
1188
|
+
var s2, h2, p2, v2, y2, d2, _2, k2, x2, M, I2, P2, A2, H2, T2, j2, F = u3.type;
|
|
1189
1189
|
if (void 0 !== u3.constructor) return null;
|
|
1190
1190
|
128 & t3.__u && (c2 = !!(32 & t3.__u), o2 = [f3 = u3.__e = t3.__e]), (s2 = l.__b) && s2(u3);
|
|
1191
|
-
n: if ("function" == typeof
|
|
1191
|
+
n: if ("function" == typeof F) {
|
|
1192
1192
|
h2 = e2.length;
|
|
1193
1193
|
try {
|
|
1194
|
-
if (x2 = u3.props, M =
|
|
1194
|
+
if (x2 = u3.props, M = F.prototype && F.prototype.render, I2 = (s2 = F.contextType) && i2[s2.__c], P2 = s2 ? I2 ? I2.props.value : s2.__ : i2, t3.__c ? k2 = (p2 = u3.__c = t3.__c).__ = p2.__E : (M ? u3.__c = p2 = new F(x2, P2) : (u3.__c = p2 = new C(x2, P2), p2.constructor = F, p2.render = Q), I2 && I2.sub(p2), p2.state || (p2.state = {}), p2.__n = i2, v2 = p2.__d = true, p2.__h = [], p2._sb = []), M && null == p2.__s && (p2.__s = p2.state), M && null != F.getDerivedStateFromProps && (p2.__s == p2.state && (p2.__s = m({}, p2.__s)), m(p2.__s, F.getDerivedStateFromProps(x2, p2.__s))), y2 = p2.props, d2 = p2.state, p2.__v = u3, v2) M && null == F.getDerivedStateFromProps && null != p2.componentWillMount && p2.componentWillMount(), M && null != p2.componentDidMount && p2.__h.push(p2.componentDidMount);
|
|
1195
1195
|
else {
|
|
1196
|
-
if (M && null ==
|
|
1196
|
+
if (M && null == F.getDerivedStateFromProps && x2 !== y2 && null != p2.componentWillReceiveProps && p2.componentWillReceiveProps(x2, P2), u3.__v == t3.__v || !p2.__e && null != p2.shouldComponentUpdate && false === p2.shouldComponentUpdate(x2, p2.__s, P2)) {
|
|
1197
1197
|
u3.__v != t3.__v && (p2.props = x2, p2.state = p2.__s, p2.__d = false), u3.__e = t3.__e, u3.__k = t3.__k, u3.__k.some(function(n3) {
|
|
1198
1198
|
n3 && (n3.__ = u3);
|
|
1199
|
-
}), w.push.apply(p2.__h, p2._sb), p2._sb = [], p2.__h.length && e2.push(p2);
|
|
1199
|
+
}), w.push.apply(p2.__h, p2._sb), p2._sb = [], p2.__h.length && e2.push(p2), f3 = $(t3);
|
|
1200
1200
|
break n;
|
|
1201
1201
|
}
|
|
1202
|
-
null != p2.componentWillUpdate && p2.componentWillUpdate(x2, p2.__s,
|
|
1202
|
+
null != p2.componentWillUpdate && p2.componentWillUpdate(x2, p2.__s, P2), M && null != p2.componentDidUpdate && p2.__h.push(function() {
|
|
1203
1203
|
p2.componentDidUpdate(y2, d2, _2);
|
|
1204
1204
|
});
|
|
1205
1205
|
}
|
|
1206
|
-
if (p2.context =
|
|
1206
|
+
if (p2.context = P2, p2.props = x2, p2.__P = n2, p2.__e = false, A2 = l.__r, H2 = 0, M) p2.state = p2.__s, p2.__d = false, A2 && A2(u3), s2 = p2.render(p2.props, p2.state, p2.context), w.push.apply(p2.__h, p2._sb), p2._sb = [];
|
|
1207
1207
|
else do {
|
|
1208
|
-
p2.__d = false,
|
|
1209
|
-
} while (p2.__d && ++
|
|
1210
|
-
p2.state = p2.__s, null != p2.getChildContext && (i2 = m(m({}, i2), p2.getChildContext())), M && !v2 && null != p2.getSnapshotBeforeUpdate && (_2 = p2.getSnapshotBeforeUpdate(y2, d2)),
|
|
1208
|
+
p2.__d = false, A2 && A2(u3), s2 = p2.render(p2.props, p2.state, p2.context), p2.state = p2.__s;
|
|
1209
|
+
} while (p2.__d && ++H2 < 25);
|
|
1210
|
+
p2.state = p2.__s, null != p2.getChildContext && (i2 = m(m({}, i2), p2.getChildContext())), M && !v2 && null != p2.getSnapshotBeforeUpdate && (_2 = p2.getSnapshotBeforeUpdate(y2, d2)), T2 = null != s2 && s2.type === S && null == s2.key ? E(s2.props.children) : s2, f3 = L(n2, g(T2) ? T2 : [T2], u3, t3, i2, r2, o2, e2, f3, c2, a2), p2.base = u3.__e, u3.__u &= -161, p2.__h.length && e2.push(p2), k2 && (p2.__E = p2.__ = null);
|
|
1211
1211
|
} catch (n3) {
|
|
1212
1212
|
if (e2.length = h2, u3.__v = null, c2 || null != o2) {
|
|
1213
1213
|
if (n3.then) {
|
|
1214
1214
|
for (u3.__u |= c2 ? 160 : 128; f3 && 8 == f3.nodeType && f3.nextSibling; ) f3 = f3.nextSibling;
|
|
1215
1215
|
null != o2 && (o2[o2.indexOf(f3)] = null), u3.__e = f3;
|
|
1216
|
-
} else if (null != o2) for (
|
|
1216
|
+
} else if (null != o2) for (j2 = o2.length; j2--; ) b(o2[j2]);
|
|
1217
1217
|
} else u3.__e = t3.__e;
|
|
1218
1218
|
null == u3.__k && (u3.__k = t3.__k || []), n3.then || B(u3), l.__e(n3, u3, t3);
|
|
1219
1219
|
}
|
|
@@ -1334,9 +1334,9 @@ var CLOSE_ICON_SVG = `<svg width="10" height="10" viewBox="0 0 10 10" fill="none
|
|
|
1334
1334
|
</svg>`;
|
|
1335
1335
|
|
|
1336
1336
|
// src/core/ui/toolbar.generated.ts
|
|
1337
|
-
var TOOLBAR_CSS = ":host{--prepr-primary:#4338ca;--prepr-bg:#eef2ff;--prepr-text:#1f2937;--prepr-radius:8px;--prepr-shadow:0px 0px 40px 0px #1f29373d;--prepr-z-index:10000;--prepr-primary-50:#eef2ff;--prepr-primary-100:#e0e7ff;--prepr-primary-800:#3730a3;--prepr-indigo-600:#4f46e5;--prepr-indigo-50:#eef2ff;--prepr-indigo-700:#4338ca;--prepr-secondary-400:#fb923c;--prepr-secondary-500:#f97316;--prepr-gray-100:#f3f4f6;--prepr-gray-200:#e5e7eb;--prepr-gray-300:#d1d5db;--prepr-gray-400:#9ca3af;--prepr-gray-500:#6b7280;--prepr-gray-700:#374151;--prepr-gray-800:#1f2937;--prepr-gray-900:#111827;--prepr-shadow-sm:0px 0px 12px 0px #c3c3c3cc;color:var(--prepr-text);box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-size:14px;line-height:1.5}:host *,:host :before,:host :after,*,:before,:after{box-sizing:border-box}button{font-family:inherit;font-size:inherit;margin:0}.prepr-regular-text{font-size:.875rem;font-weight:500;line-height:1.5}.prepr-backdrop{z-index:calc(var(--prepr-z-index) - 1);opacity:0;pointer-events:none;background:#0000001a;transition:opacity .2s ease-in-out;position:fixed;top:0;bottom:0;left:0;right:0}.prepr-backdrop[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-container{z-index:var(--prepr-z-index);justify-content:flex-end;align-items:center;display:flex;position:fixed;top:calc(50% - 64px);right:0}.prepr-toggle-holder{padding:.5rem}.prepr-toggle{cursor:pointer;background:var(--prepr-primary);color:#fff;border:none;border-radius:9999px;justify-content:center;align-items:center;width:2.25rem;height:2.25rem;display:flex}.prepr-toggle>span{display:flex}.prepr-toggle svg{color:#fff}.prepr-panel{z-index:var(--prepr-z-index);opacity:0;pointer-events:none;justify-content:flex-end;padding:.75rem;transition:opacity .2s ease-in-out;display:flex;position:fixed;top:50%;right:0;transform:translateY(-50%)}.prepr-panel[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-content{box-shadow:var(--prepr-shadow);border-radius:var(--prepr-radius);background:var(--prepr-bg);flex-direction:column;gap:2.5rem;width:100%;padding:1.5rem;display:flex}@media (min-width:640px){.prepr-panel{margin-right:4rem;padding:0}.prepr-content{width:502px;padding:2.5rem}}.prepr-header{justify-content:space-between;align-items:center;gap:.5rem;display:flex}.prepr-header-left{align-items:flex-start;gap:.75rem;display:flex}.prepr-badge{background:var(--prepr-primary-100);height:1.5rem;color:var(--prepr-primary);border-radius:4px;align-items:center;padding:.25rem .75rem;font-size:.875rem;display:flex}.prepr-header-close{cursor:pointer;background:var(--prepr-primary-100);width:2rem;height:2rem;color:var(--prepr-gray-700);border:none;border-radius:6px;justify-content:center;align-items:center;display:flex}.prepr-section{flex-direction:column;gap:.5rem;display:flex}.prepr-section-label{color:var(--prepr-gray-400);font-size:.875rem}.prepr-row{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:.5rem 1.5rem;display:flex}.prepr-row-title{color:var(--prepr-gray-800);margin:0;font-size:1rem;font-weight:600}.prepr-radiogroup{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);background:#fff;align-items:center;gap:.25rem;height:2.5rem;padding:.25rem;display:flex}.prepr-radiogroup[data-disabled=true]{cursor:not-allowed;opacity:.5}.prepr-radiogroup[data-disabled=true] .prepr-radio{pointer-events:none}.prepr-radio{cursor:pointer;white-space:nowrap;text-align:center;height:2rem;color:var(--prepr-gray-900);background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;padding:.5rem 1.125rem;font-size:.875rem;font-weight:500;transition:all .2s ease-in-out;display:flex}.prepr-radio[data-checked=true]{background:var(--prepr-indigo-600);color:#fff;box-shadow:var(--prepr-shadow-sm)}.prepr-radio[data-checked=true][data-off=true]{background:var(--prepr-gray-800);color:#fff}.prepr-radio-variant{width:82px}.prepr-listbox{position:relative}.prepr-segment-button{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);width:240px;height:2.5rem;color:var(--prepr-gray-500);cursor:pointer;background:#fff;flex-shrink:0;align-items:center;gap:.5rem;padding:0 .5rem;font-size:.875rem;font-weight:500;display:flex;overflow:hidden}@media (min-width:768px){.prepr-segment-button{padding:0 1rem}}.prepr-segment-button:disabled{cursor:not-allowed;background:var(--prepr-gray-200);color:var(--prepr-gray-400)}.prepr-segment-button[aria-expanded=true]{border-bottom-color:#fff;border-bottom-right-radius:0;border-bottom-left-radius:0}.prepr-segment-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-segment-caret{color:var(--prepr-gray-800);display:flex}.prepr-options{z-index:calc(var(--prepr-z-index) + 1);border-left:1px solid var(--prepr-gray-300);border-right:1px solid var(--prepr-gray-300);border-bottom:1px solid var(--prepr-gray-300);-ms-overflow-style:none;scrollbar-width:none;background:#fff;border-radius:0 0 6px 6px;width:240px;max-height:300px;margin:0;padding:0;list-style:none;position:absolute;top:100%;left:0;overflow-y:auto;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-options::-webkit-scrollbar{display:none}.prepr-options[hidden]{display:none}.prepr-option-search{background:#fff;padding:.5rem;position
|
|
1337
|
+
var TOOLBAR_CSS = ":host{--prepr-primary:#4338ca;--prepr-bg:#eef2ff;--prepr-text:#1f2937;--prepr-radius:8px;--prepr-shadow:0px 0px 40px 0px #1f29373d;--prepr-z-index:10000;--prepr-primary-50:#eef2ff;--prepr-primary-100:#e0e7ff;--prepr-primary-800:#3730a3;--prepr-indigo-600:#4f46e5;--prepr-indigo-50:#eef2ff;--prepr-indigo-700:#4338ca;--prepr-secondary-400:#fb923c;--prepr-secondary-500:#f97316;--prepr-gray-100:#f3f4f6;--prepr-gray-200:#e5e7eb;--prepr-gray-300:#d1d5db;--prepr-gray-400:#9ca3af;--prepr-gray-500:#6b7280;--prepr-gray-700:#374151;--prepr-gray-800:#1f2937;--prepr-gray-900:#111827;--prepr-shadow-sm:0px 0px 12px 0px #c3c3c3cc;color:var(--prepr-text);box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-size:14px;line-height:1.5}:host *,:host :before,:host :after,*,:before,:after{box-sizing:border-box}button{font-family:inherit;font-size:inherit;margin:0}.prepr-regular-text{font-size:.875rem;font-weight:500;line-height:1.5}.prepr-backdrop{z-index:calc(var(--prepr-z-index) - 1);opacity:0;pointer-events:none;background:#0000001a;transition:opacity .2s ease-in-out;position:fixed;top:0;bottom:0;left:0;right:0}.prepr-backdrop[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-container{z-index:var(--prepr-z-index);justify-content:flex-end;align-items:center;display:flex;position:fixed;top:calc(50% - 64px);right:0}.prepr-toggle-holder{padding:.5rem}.prepr-toggle{cursor:pointer;background:var(--prepr-primary);color:#fff;border:none;border-radius:9999px;justify-content:center;align-items:center;width:2.25rem;height:2.25rem;display:flex}.prepr-toggle>span{display:flex}.prepr-toggle svg{color:#fff}.prepr-panel{z-index:var(--prepr-z-index);opacity:0;pointer-events:none;justify-content:flex-end;padding:.75rem;transition:opacity .2s ease-in-out;display:flex;position:fixed;top:50%;right:0;transform:translateY(-50%)}.prepr-panel[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-content{box-shadow:var(--prepr-shadow);border-radius:var(--prepr-radius);background:var(--prepr-bg);flex-direction:column;gap:2.5rem;width:100%;padding:1.5rem;display:flex}@media (min-width:640px){.prepr-panel{margin-right:4rem;padding:0}.prepr-content{width:502px;padding:2.5rem}}.prepr-header{justify-content:space-between;align-items:center;gap:.5rem;display:flex}.prepr-header-left{align-items:flex-start;gap:.75rem;display:flex}.prepr-badge{background:var(--prepr-primary-100);height:1.5rem;color:var(--prepr-primary);border-radius:4px;align-items:center;padding:.25rem .75rem;font-size:.875rem;display:flex}.prepr-header-close{cursor:pointer;background:var(--prepr-primary-100);width:2rem;height:2rem;color:var(--prepr-gray-700);border:none;border-radius:6px;justify-content:center;align-items:center;display:flex}.prepr-section{flex-direction:column;gap:.5rem;display:flex}.prepr-section-label{color:var(--prepr-gray-400);font-size:.875rem}.prepr-row{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:.5rem 1.5rem;display:flex}.prepr-row-title{color:var(--prepr-gray-800);margin:0;font-size:1rem;font-weight:600}.prepr-radiogroup{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);background:#fff;align-items:center;gap:.25rem;height:2.5rem;padding:.25rem;display:flex}.prepr-radiogroup[data-disabled=true]{cursor:not-allowed;opacity:.5}.prepr-radiogroup[data-disabled=true] .prepr-radio{pointer-events:none}.prepr-radio{cursor:pointer;white-space:nowrap;text-align:center;height:2rem;color:var(--prepr-gray-900);background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;padding:.5rem 1.125rem;font-size:.875rem;font-weight:500;transition:all .2s ease-in-out;display:flex}.prepr-radio[data-checked=true]{background:var(--prepr-indigo-600);color:#fff;box-shadow:var(--prepr-shadow-sm)}.prepr-radio[data-checked=true][data-off=true]{background:var(--prepr-gray-800);color:#fff}.prepr-radio-variant{width:82px}.prepr-listbox{position:relative}.prepr-segment-button{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);width:240px;height:2.5rem;color:var(--prepr-gray-500);cursor:pointer;background:#fff;flex-shrink:0;align-items:center;gap:.5rem;padding:0 .5rem;font-size:.875rem;font-weight:500;display:flex;overflow:hidden}@media (min-width:768px){.prepr-segment-button{padding:0 1rem}}.prepr-segment-button:disabled{cursor:not-allowed;background:var(--prepr-gray-200);color:var(--prepr-gray-400)}.prepr-segment-button[aria-expanded=true]{border-bottom-color:#fff;border-bottom-right-radius:0;border-bottom-left-radius:0}.prepr-segment-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-segment-caret{color:var(--prepr-gray-800);display:flex}.prepr-options{z-index:calc(var(--prepr-z-index) + 1);border-left:1px solid var(--prepr-gray-300);border-right:1px solid var(--prepr-gray-300);border-bottom:1px solid var(--prepr-gray-300);-ms-overflow-style:none;scrollbar-width:none;background:#fff;border-radius:0 0 6px 6px;width:240px;max-height:300px;margin:0;padding:0;list-style:none;position:absolute;top:100%;left:0;overflow-y:auto;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-options::-webkit-scrollbar{display:none}.prepr-options[hidden]{display:none}.prepr-option-search{background:#fff;padding:.5rem;position:sticky;top:0}.prepr-segment-search{border:1px solid var(--prepr-gray-300);border-radius:var(--prepr-radius);width:100%;height:2rem;font:inherit;color:var(--prepr-gray-900);box-sizing:border-box;background:#fff;padding:0 .5rem;font-size:.875rem}@media (pointer:coarse){.prepr-segment-search{font-size:16px}}.prepr-segment-search::placeholder{color:var(--prepr-gray-400)}.prepr-segment-search:focus{border-color:var(--prepr-gray-400);outline:none}.prepr-option{cursor:pointer;width:100%;color:var(--prepr-gray-900);background:#fff;align-items:center;padding:.5rem 1rem;font-size:.875rem;font-weight:500;display:flex}.prepr-option:hover{background:var(--prepr-gray-100)}.prepr-option[aria-selected=true]{background:var(--prepr-indigo-50);color:var(--prepr-indigo-700)}.prepr-option-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-reset{background:var(--prepr-secondary-400);color:#fff;cursor:pointer;border:none;border-radius:6px;justify-content:center;align-items:center;gap:.5rem;width:100%;height:2.5rem;padding:.5rem .75rem;font-size:.875rem;font-weight:500;display:flex}.prepr-reset:hover:not(:disabled){background:var(--prepr-secondary-500)}.prepr-reset:disabled{background:var(--prepr-gray-400);color:var(--prepr-gray-500);cursor:not-allowed}@media (min-width:768px){.prepr-reset{width:108px}}.prepr-indicators{z-index:var(--prepr-z-index);gap:.75rem;display:flex;position:fixed;bottom:1.5rem;right:1.5rem}.prepr-status-pill{background:var(--prepr-primary);color:#fff;cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-status-pill[data-interactive=false]{cursor:default;opacity:1;color:#fff}.prepr-status-pill[data-interactive=true]:hover{background:var(--prepr-primary-800)}.prepr-status-pill[hidden]{display:none}.prepr-status-viewing{color:#fff9;font-size:10px}.prepr-status-segment{text-overflow:ellipsis;white-space:nowrap;max-width:120px;display:inline-block;overflow:hidden}.prepr-status-variant{text-overflow:ellipsis;white-space:nowrap;background:#fff3;border-radius:4px;max-width:80px;padding:0 .5rem;display:inline-block;overflow:hidden}.prepr-status-x{color:#fff;width:.75rem;height:.75rem}.prepr-close-edit-pill{background:var(--prepr-primary-50);color:var(--prepr-gray-800);cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-close-edit-pill:hover{background:var(--prepr-primary-100)}.prepr-close-edit-pill[hidden]{display:none}.prepr-close-edit-x{width:1rem;height:1rem;color:var(--prepr-gray-500);transition:color .15s}.prepr-close-edit-pill:hover .prepr-close-edit-x{color:var(--prepr-gray-700)}.prepr-tip{z-index:calc(var(--prepr-z-index) + 2);overflow-wrap:break-word;background:var(--prepr-gray-900);color:#fff;pointer-events:none;border-radius:6px;width:auto;max-width:min(420px,100vw - 16px);padding:.5rem .75rem;font-size:.75rem;font-weight:500;position:fixed;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-tip-arrow{border-left:6px solid #0000;border-right:6px solid #0000;border-top:6px solid var(--prepr-gray-900);width:0;height:0;position:absolute;top:100%;transform:translate(-50%)}[hidden]{display:none!important}@keyframes prepr-fade-in{0%{opacity:0}to{opacity:1}}";
|
|
1338
1338
|
|
|
1339
|
-
// ../../node_modules/.pnpm/preact@10.29.
|
|
1339
|
+
// ../../node_modules/.pnpm/preact@10.29.8/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs
|
|
1340
1340
|
var f2 = 0;
|
|
1341
1341
|
function u2(e2, t3, n2, o2, i2, u3) {
|
|
1342
1342
|
t3 || (t3 = {});
|
package/dist/codegen/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var codegen_exports = {};
|
|
22
22
|
__export(codegen_exports, {
|
|
23
23
|
addPreprIds: () => addPreprIds,
|
|
24
|
+
createPreprIds: () => createPreprIds,
|
|
24
25
|
preprIds: () => preprIds
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(codegen_exports);
|
|
@@ -33,7 +34,8 @@ function hasResponseKey(set, key) {
|
|
|
33
34
|
(s) => s.kind === import_graphql.Kind.FIELD && (s.alias ?? s.name).value === key
|
|
34
35
|
);
|
|
35
36
|
}
|
|
36
|
-
function addPreprIds(document, schema) {
|
|
37
|
+
function addPreprIds(document, schema, options = {}) {
|
|
38
|
+
const typename = options.typename ?? false;
|
|
37
39
|
const roots = new Set(
|
|
38
40
|
[
|
|
39
41
|
schema.getQueryType(),
|
|
@@ -52,7 +54,7 @@ function addPreprIds(document, schema) {
|
|
|
52
54
|
if (((0, import_graphql.isObjectType)(type) || (0, import_graphql.isInterfaceType)(type)) && "_id" in type.getFields() && !hasResponseKey(node, "_id")) {
|
|
53
55
|
added.push(field("_id"));
|
|
54
56
|
}
|
|
55
|
-
if (!hasResponseKey(node, "__typename")) {
|
|
57
|
+
if (typename && !hasResponseKey(node, "__typename")) {
|
|
56
58
|
added.push(field("__typename"));
|
|
57
59
|
}
|
|
58
60
|
if (!added.length) return;
|
|
@@ -61,19 +63,20 @@ function addPreprIds(document, schema) {
|
|
|
61
63
|
})
|
|
62
64
|
);
|
|
63
65
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
documents,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
function createPreprIds(options = {}) {
|
|
67
|
+
return {
|
|
68
|
+
transform({ documents, schema }) {
|
|
69
|
+
const built = (0, import_graphql.buildASTSchema)(schema, { assumeValidSDL: true });
|
|
70
|
+
return documents.map(
|
|
71
|
+
(file) => file.document ? { ...file, document: addPreprIds(file.document, built, options) } : file
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
var preprIds = createPreprIds();
|
|
75
77
|
// Annotate the CommonJS export names for ESM import in node:
|
|
76
78
|
0 && (module.exports = {
|
|
77
79
|
addPreprIds,
|
|
80
|
+
createPreprIds,
|
|
78
81
|
preprIds
|
|
79
82
|
});
|
package/dist/codegen/index.d.cts
CHANGED
|
@@ -6,23 +6,50 @@ import { DocumentNode, GraphQLSchema } from 'graphql';
|
|
|
6
6
|
*/
|
|
7
7
|
interface CodegenDocumentFile {
|
|
8
8
|
document?: DocumentNode;
|
|
9
|
-
|
|
9
|
+
}
|
|
10
|
+
interface PreprIdsOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Also select `__typename` on every object, interface and union below the
|
|
13
|
+
* root. Default `false`: a selected `__typename` changes the types Codegen
|
|
14
|
+
* generates (each union member is typed separately, and objects built by
|
|
15
|
+
* hand must carry one), which can break code that compiles today. Live
|
|
16
|
+
* preview only needs it on dynamic content entries, where you select it
|
|
17
|
+
* already to render them.
|
|
18
|
+
*/
|
|
19
|
+
typename?: boolean;
|
|
10
20
|
}
|
|
11
21
|
/**
|
|
12
|
-
* Select `_id`
|
|
13
|
-
*
|
|
14
|
-
* them by hand.
|
|
22
|
+
* Select `_id` on every level of a query that has one, so live preview and
|
|
23
|
+
* click-to-edit can find each item without you selecting it by hand.
|
|
15
24
|
*
|
|
16
|
-
* The schema decides where
|
|
17
|
-
* (models and components, not collections like `Pages` or unions
|
|
18
|
-
*
|
|
19
|
-
*
|
|
25
|
+
* The schema decides where it goes: only on types that have an `_id`
|
|
26
|
+
* (models and components, not collections like `Pages` or unions; inside a
|
|
27
|
+
* union, on each member). Adding a field never breaks the types Codegen
|
|
28
|
+
* generates. With `typename: true`, `__typename` is added on every object,
|
|
29
|
+
* interface and union below the root too. Fields already selected are left
|
|
30
|
+
* as they are.
|
|
20
31
|
*/
|
|
21
|
-
declare function addPreprIds(document: DocumentNode, schema: GraphQLSchema): DocumentNode;
|
|
32
|
+
declare function addPreprIds(document: DocumentNode, schema: GraphQLSchema, options?: PreprIdsOptions): DocumentNode;
|
|
33
|
+
/** A GraphQL Codegen document transform. */
|
|
34
|
+
interface CodegenDocumentTransform {
|
|
35
|
+
transform<File extends CodegenDocumentFile>(options: {
|
|
36
|
+
documents: File[];
|
|
37
|
+
schema: DocumentNode;
|
|
38
|
+
}): File[];
|
|
39
|
+
}
|
|
22
40
|
/**
|
|
23
41
|
* GraphQL Codegen document transform that runs `addPreprIds` on every
|
|
24
|
-
* document,
|
|
25
|
-
*
|
|
42
|
+
* document, with options:
|
|
43
|
+
*
|
|
44
|
+
* ```ts
|
|
45
|
+
* documentTransforms: [createPreprIds({ typename: true })],
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
declare function createPreprIds(options?: PreprIdsOptions): CodegenDocumentTransform;
|
|
49
|
+
/**
|
|
50
|
+
* GraphQL Codegen document transform that runs `addPreprIds` on every
|
|
51
|
+
* document, so the generated documents and types include `_id` wherever the
|
|
52
|
+
* schema has one:
|
|
26
53
|
*
|
|
27
54
|
* ```ts
|
|
28
55
|
* // codegen.ts
|
|
@@ -35,12 +62,9 @@ declare function addPreprIds(document: DocumentNode, schema: GraphQLSchema): Doc
|
|
|
35
62
|
* },
|
|
36
63
|
* },
|
|
37
64
|
* ```
|
|
65
|
+
*
|
|
66
|
+
* `createPreprIds({ typename: true })` adds `__typename` as well.
|
|
38
67
|
*/
|
|
39
|
-
declare const preprIds:
|
|
40
|
-
transform({ documents, schema, }: {
|
|
41
|
-
documents: CodegenDocumentFile[];
|
|
42
|
-
schema: DocumentNode;
|
|
43
|
-
}): CodegenDocumentFile[];
|
|
44
|
-
};
|
|
68
|
+
declare const preprIds: CodegenDocumentTransform;
|
|
45
69
|
|
|
46
|
-
export { type CodegenDocumentFile, addPreprIds, preprIds };
|
|
70
|
+
export { type CodegenDocumentFile, type CodegenDocumentTransform, type PreprIdsOptions, addPreprIds, createPreprIds, preprIds };
|
package/dist/codegen/index.d.ts
CHANGED
|
@@ -6,23 +6,50 @@ import { DocumentNode, GraphQLSchema } from 'graphql';
|
|
|
6
6
|
*/
|
|
7
7
|
interface CodegenDocumentFile {
|
|
8
8
|
document?: DocumentNode;
|
|
9
|
-
|
|
9
|
+
}
|
|
10
|
+
interface PreprIdsOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Also select `__typename` on every object, interface and union below the
|
|
13
|
+
* root. Default `false`: a selected `__typename` changes the types Codegen
|
|
14
|
+
* generates (each union member is typed separately, and objects built by
|
|
15
|
+
* hand must carry one), which can break code that compiles today. Live
|
|
16
|
+
* preview only needs it on dynamic content entries, where you select it
|
|
17
|
+
* already to render them.
|
|
18
|
+
*/
|
|
19
|
+
typename?: boolean;
|
|
10
20
|
}
|
|
11
21
|
/**
|
|
12
|
-
* Select `_id`
|
|
13
|
-
*
|
|
14
|
-
* them by hand.
|
|
22
|
+
* Select `_id` on every level of a query that has one, so live preview and
|
|
23
|
+
* click-to-edit can find each item without you selecting it by hand.
|
|
15
24
|
*
|
|
16
|
-
* The schema decides where
|
|
17
|
-
* (models and components, not collections like `Pages` or unions
|
|
18
|
-
*
|
|
19
|
-
*
|
|
25
|
+
* The schema decides where it goes: only on types that have an `_id`
|
|
26
|
+
* (models and components, not collections like `Pages` or unions; inside a
|
|
27
|
+
* union, on each member). Adding a field never breaks the types Codegen
|
|
28
|
+
* generates. With `typename: true`, `__typename` is added on every object,
|
|
29
|
+
* interface and union below the root too. Fields already selected are left
|
|
30
|
+
* as they are.
|
|
20
31
|
*/
|
|
21
|
-
declare function addPreprIds(document: DocumentNode, schema: GraphQLSchema): DocumentNode;
|
|
32
|
+
declare function addPreprIds(document: DocumentNode, schema: GraphQLSchema, options?: PreprIdsOptions): DocumentNode;
|
|
33
|
+
/** A GraphQL Codegen document transform. */
|
|
34
|
+
interface CodegenDocumentTransform {
|
|
35
|
+
transform<File extends CodegenDocumentFile>(options: {
|
|
36
|
+
documents: File[];
|
|
37
|
+
schema: DocumentNode;
|
|
38
|
+
}): File[];
|
|
39
|
+
}
|
|
22
40
|
/**
|
|
23
41
|
* GraphQL Codegen document transform that runs `addPreprIds` on every
|
|
24
|
-
* document,
|
|
25
|
-
*
|
|
42
|
+
* document, with options:
|
|
43
|
+
*
|
|
44
|
+
* ```ts
|
|
45
|
+
* documentTransforms: [createPreprIds({ typename: true })],
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
declare function createPreprIds(options?: PreprIdsOptions): CodegenDocumentTransform;
|
|
49
|
+
/**
|
|
50
|
+
* GraphQL Codegen document transform that runs `addPreprIds` on every
|
|
51
|
+
* document, so the generated documents and types include `_id` wherever the
|
|
52
|
+
* schema has one:
|
|
26
53
|
*
|
|
27
54
|
* ```ts
|
|
28
55
|
* // codegen.ts
|
|
@@ -35,12 +62,9 @@ declare function addPreprIds(document: DocumentNode, schema: GraphQLSchema): Doc
|
|
|
35
62
|
* },
|
|
36
63
|
* },
|
|
37
64
|
* ```
|
|
65
|
+
*
|
|
66
|
+
* `createPreprIds({ typename: true })` adds `__typename` as well.
|
|
38
67
|
*/
|
|
39
|
-
declare const preprIds:
|
|
40
|
-
transform({ documents, schema, }: {
|
|
41
|
-
documents: CodegenDocumentFile[];
|
|
42
|
-
schema: DocumentNode;
|
|
43
|
-
}): CodegenDocumentFile[];
|
|
44
|
-
};
|
|
68
|
+
declare const preprIds: CodegenDocumentTransform;
|
|
45
69
|
|
|
46
|
-
export { type CodegenDocumentFile, addPreprIds, preprIds };
|
|
70
|
+
export { type CodegenDocumentFile, type CodegenDocumentTransform, type PreprIdsOptions, addPreprIds, createPreprIds, preprIds };
|
package/dist/codegen/index.js
CHANGED
|
@@ -17,7 +17,8 @@ function hasResponseKey(set, key) {
|
|
|
17
17
|
(s) => s.kind === Kind.FIELD && (s.alias ?? s.name).value === key
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
|
-
function addPreprIds(document, schema) {
|
|
20
|
+
function addPreprIds(document, schema, options = {}) {
|
|
21
|
+
const typename = options.typename ?? false;
|
|
21
22
|
const roots = new Set(
|
|
22
23
|
[
|
|
23
24
|
schema.getQueryType(),
|
|
@@ -36,7 +37,7 @@ function addPreprIds(document, schema) {
|
|
|
36
37
|
if ((isObjectType(type) || isInterfaceType(type)) && "_id" in type.getFields() && !hasResponseKey(node, "_id")) {
|
|
37
38
|
added.push(field("_id"));
|
|
38
39
|
}
|
|
39
|
-
if (!hasResponseKey(node, "__typename")) {
|
|
40
|
+
if (typename && !hasResponseKey(node, "__typename")) {
|
|
40
41
|
added.push(field("__typename"));
|
|
41
42
|
}
|
|
42
43
|
if (!added.length) return;
|
|
@@ -45,18 +46,19 @@ function addPreprIds(document, schema) {
|
|
|
45
46
|
})
|
|
46
47
|
);
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
documents,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
function createPreprIds(options = {}) {
|
|
50
|
+
return {
|
|
51
|
+
transform({ documents, schema }) {
|
|
52
|
+
const built = buildASTSchema(schema, { assumeValidSDL: true });
|
|
53
|
+
return documents.map(
|
|
54
|
+
(file) => file.document ? { ...file, document: addPreprIds(file.document, built, options) } : file
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
var preprIds = createPreprIds();
|
|
59
60
|
export {
|
|
60
61
|
addPreprIds,
|
|
62
|
+
createPreprIds,
|
|
61
63
|
preprIds
|
|
62
64
|
};
|