@agent-native/core-corpus 0.218.0 → 0.219.0
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/corpus/README.md +1 -1
- package/corpus/templates/analytics/.agents/skills/hubspot/SKILL.md +5 -3
- package/corpus/templates/community/qr/package.json +1 -1
- package/corpus/templates/content/CHANGELOG.md +5 -0
- package/corpus/templates/content/app/components/editor/CommentStack.tsx +301 -0
- package/corpus/templates/content/app/components/editor/CommentsSidebar.tsx +651 -149
- package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +19 -14
- package/corpus/templates/content/app/components/editor/block-field-comment-threads.ts +15 -0
- package/corpus/templates/content/app/components/editor/block-field-comments.tsx +5 -9
- package/corpus/templates/content/app/components/editor/comment-stacks.ts +143 -0
- package/corpus/templates/content/app/i18n-data.ts +8 -0
- package/corpus/templates/content/changelog/2026-10-22-blocks-with-several-comment-threads-fold-into-one-stack-in-t.md +6 -0
- package/corpus/templates/content/changelog/2026-10-22-opening-a-page-no-longer-saves-an-edit-again-after-another-o.md +6 -0
- package/corpus/templates/content/docs/product/capabilities/content.comment.page-owned.md +8 -1
- package/corpus/templates/design/.generated/bridge/interact-links.generated.ts +8 -8
- package/corpus/templates/design/CHANGELOG.md +5 -0
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +18 -1
- package/corpus/templates/design/app/components/design/bridge/interact-links.bridge.ts +8 -8
- package/corpus/templates/design/app/components/editor/PromptDialog.tsx +15 -13
- package/corpus/templates/design/app/i18n/en-US.ts +1 -1
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-modes.ts +15 -6
- package/corpus/templates/design/app/pages/design-editor/domains/use-editor-screen-rendering.tsx +29 -5
- package/corpus/templates/design/app/pages/design-editor/prototype-navigation-transition.ts +423 -0
- package/corpus/templates/design/app/pages/design-editor/view/single-screen-canvas.tsx +35 -9
- package/corpus/templates/design/changelog/2026-10-20-the-design-full-app-toggle-on-the-home-page-no-longer-hides-.md +6 -0
- package/corpus/templates/design/changelog/2026-10-22-prototype-links-can-play-code-authored-screen-transitions.md +6 -0
- package/corpus/templates/design/shared/motion-authored-css-import.ts +938 -7
- package/corpus/templates/design/shared/motion-html-source.ts +1689 -135
- package/corpus/templates/design/shared/motion-prototype-transition.ts +329 -0
- package/corpus/templates/design/shared/motion-react-source.ts +2154 -126
- package/corpus/templates/design/shared/motion-text-runtime-v1.fixture.txt +221 -0
- package/package.json +1 -1
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
(function (source) {
|
|
2
|
+
var animations = source.animations;
|
|
3
|
+
var playbackMode = source.playbackMode;
|
|
4
|
+
if (typeof window !== "undefined" && window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
|
|
5
|
+
if (!document || typeof document.querySelectorAll !== "function") throw new Error("Motion text runtime requires a document.");
|
|
6
|
+
var previewBridge = typeof window !== "undefined" && window.__designMotionPreviewBridge === true;
|
|
7
|
+
var previewAnimations = [];
|
|
8
|
+
var allTargets = Array.prototype.slice.call(document.querySelectorAll("[data-agent-native-node-id]"));
|
|
9
|
+
var paragraphTags = { blockquote: true, h1: true, h2: true, h3: true, h4: true, h5: true, h6: true, li: true, p: true };
|
|
10
|
+
function textTokens(value, kind) {
|
|
11
|
+
var Segmenter = typeof Intl !== "undefined" ? Intl.Segmenter : null;
|
|
12
|
+
if (kind === "character") {
|
|
13
|
+
var characters = Segmenter ? Array.from(new Segmenter(undefined, { granularity: "grapheme" }).segment(value), function (part) { return part.segment; }) : Array.from(value);
|
|
14
|
+
return characters.map(function (part) { return { value: part, animated: !/^\s+$/u.test(part) }; });
|
|
15
|
+
}
|
|
16
|
+
var chunks;
|
|
17
|
+
if (Segmenter) {
|
|
18
|
+
chunks = Array.from(new Segmenter(undefined, { granularity: "word" }).segment(value), function (part) { return { value: part.segment, word: !!part.isWordLike }; });
|
|
19
|
+
} else {
|
|
20
|
+
chunks = (value.match(/\s+|[^\s]+/gu) || []).map(function (part) { return { value: part, word: !/^\s+$/u.test(part) }; });
|
|
21
|
+
}
|
|
22
|
+
var tokens = [];
|
|
23
|
+
for (var index = 0; index < chunks.length; index += 1) {
|
|
24
|
+
var chunk = chunks[index];
|
|
25
|
+
if (/^\s+$/u.test(chunk.value)) {
|
|
26
|
+
tokens.push({ value: chunk.value, animated: false });
|
|
27
|
+
} else if (chunk.word) {
|
|
28
|
+
tokens.push({ value: chunk.value, animated: true });
|
|
29
|
+
} else if (tokens.length && tokens[tokens.length - 1].animated) {
|
|
30
|
+
tokens[tokens.length - 1].value += chunk.value;
|
|
31
|
+
} else {
|
|
32
|
+
var nextWord = chunks.slice(index + 1).findIndex(function (candidate) { return candidate.word; });
|
|
33
|
+
if (nextWord >= 0) {
|
|
34
|
+
var punctuation = chunk.value;
|
|
35
|
+
while (index + 1 < chunks.length && !chunks[index + 1].word && !/^\s+$/u.test(chunks[index + 1].value)) punctuation += chunks[++index].value;
|
|
36
|
+
tokens.push({ value: punctuation, animated: true });
|
|
37
|
+
} else {
|
|
38
|
+
tokens.push({ value: chunk.value, animated: false });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return tokens;
|
|
43
|
+
}
|
|
44
|
+
function descendantTextNodes(target) {
|
|
45
|
+
var nodes = [];
|
|
46
|
+
function visit(node) {
|
|
47
|
+
if (node.nodeName === "#text") { nodes.push(node); return; }
|
|
48
|
+
Array.prototype.slice.call(node.childNodes || []).forEach(visit);
|
|
49
|
+
}
|
|
50
|
+
visit(target);
|
|
51
|
+
return nodes;
|
|
52
|
+
}
|
|
53
|
+
function nodeText(node) {
|
|
54
|
+
return typeof node.nodeValue === "string" ? node.nodeValue : (node.value || "");
|
|
55
|
+
}
|
|
56
|
+
function splitTextTarget(target, kind) {
|
|
57
|
+
var leaves = descendantTextNodes(target);
|
|
58
|
+
var value = leaves.map(nodeText).join("");
|
|
59
|
+
var tokens = textTokens(value, kind === "line" ? "word" : kind);
|
|
60
|
+
var units = [];
|
|
61
|
+
var sourceOffset = 0;
|
|
62
|
+
tokens.forEach(function (token) {
|
|
63
|
+
var start = sourceOffset;
|
|
64
|
+
var end = start + token.value.length;
|
|
65
|
+
sourceOffset = end;
|
|
66
|
+
if (token.animated) units.push({ start: start, end: end, index: units.length, fragments: [] });
|
|
67
|
+
});
|
|
68
|
+
if (units.length === 0) throw new Error("Motion text target has no animatable text units.");
|
|
69
|
+
if (units.length > 512) throw new Error("Motion text target exceeds the 512-unit runtime limit.");
|
|
70
|
+
|
|
71
|
+
var leafOffset = 0;
|
|
72
|
+
leaves.forEach(function (leaf) {
|
|
73
|
+
var text = nodeText(leaf);
|
|
74
|
+
var leafStart = leafOffset;
|
|
75
|
+
var leafEnd = leafStart + text.length;
|
|
76
|
+
leafOffset = leafEnd;
|
|
77
|
+
if (!text.length) return;
|
|
78
|
+
|
|
79
|
+
var fragment = document.createDocumentFragment();
|
|
80
|
+
var cursor = 0;
|
|
81
|
+
tokens.forEach(function (token) {
|
|
82
|
+
var tokenStart = cursor;
|
|
83
|
+
var tokenEnd = tokenStart + token.value.length;
|
|
84
|
+
cursor = tokenEnd;
|
|
85
|
+
var start = Math.max(leafStart, tokenStart);
|
|
86
|
+
var end = Math.min(leafEnd, tokenEnd);
|
|
87
|
+
if (start >= end) return;
|
|
88
|
+
var part = text.slice(start - leafStart, end - leafStart);
|
|
89
|
+
if (!token.animated) {
|
|
90
|
+
fragment.appendChild(document.createTextNode(part));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
var unitIndex = units.findIndex(function (unit) { return unit.start === tokenStart; });
|
|
94
|
+
var unit = units[unitIndex];
|
|
95
|
+
var span = document.createElement("span");
|
|
96
|
+
span.setAttribute("data-agent-native-motion-text-unit", String(unit.index));
|
|
97
|
+
span.style.display = "inline-block";
|
|
98
|
+
span.appendChild(document.createTextNode(part));
|
|
99
|
+
fragment.appendChild(span);
|
|
100
|
+
unit.fragments.push(span);
|
|
101
|
+
});
|
|
102
|
+
if (leaf.parentNode) leaf.parentNode.replaceChild(fragment, leaf);
|
|
103
|
+
});
|
|
104
|
+
return units;
|
|
105
|
+
}
|
|
106
|
+
function paragraphUnits(target) {
|
|
107
|
+
var tag = String(target.tagName || "").toLowerCase();
|
|
108
|
+
if (paragraphTags[tag]) return [target];
|
|
109
|
+
var children = Array.prototype.slice.call(target.children || []);
|
|
110
|
+
if (children.length && children.every(function (child) { return paragraphTags[String(child.tagName || "").toLowerCase()]; })) return children;
|
|
111
|
+
if (children.length) throw new Error("Paragraph Text animation found unsupported nested elements.");
|
|
112
|
+
return [target];
|
|
113
|
+
}
|
|
114
|
+
function lineGroups(units) {
|
|
115
|
+
var tops = [];
|
|
116
|
+
return units.map(function (unit, index) {
|
|
117
|
+
var top = unit.getBoundingClientRect().top;
|
|
118
|
+
var found = tops.findIndex(function (existing) { return Math.abs(existing - top) < 0.5; });
|
|
119
|
+
if (found < 0) { tops.push(top); found = tops.length - 1; }
|
|
120
|
+
return { unit: unit, index: found };
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function springSample(bounce, settle, x) {
|
|
124
|
+
if (x <= 0) return 0;
|
|
125
|
+
var u = x / settle;
|
|
126
|
+
if (u >= 1) return 1;
|
|
127
|
+
var zeta = Math.min(1, Math.max(0.02, 1 - bounce));
|
|
128
|
+
var omega = Math.log(1 / 0.001) / zeta;
|
|
129
|
+
if (zeta >= 1) return 1 - Math.exp(-omega * u) * (1 + omega * u);
|
|
130
|
+
var omegaD = omega * Math.sqrt(1 - zeta * zeta);
|
|
131
|
+
var decay = Math.exp(-zeta * omega * u);
|
|
132
|
+
return 1 - decay * (Math.cos(omegaD * u) + ((zeta * omega) / omegaD) * Math.sin(omegaD * u));
|
|
133
|
+
}
|
|
134
|
+
function springToLinear(bounce, settle) {
|
|
135
|
+
var sampleCount = 16 + Math.round(bounce * 34);
|
|
136
|
+
var stops = [];
|
|
137
|
+
for (var index = 0; index <= sampleCount; index += 1) {
|
|
138
|
+
var value = index === sampleCount ? 1 : springSample(bounce, settle, index / sampleCount);
|
|
139
|
+
stops.push((Math.round(value * 10000) / 10000).toString());
|
|
140
|
+
}
|
|
141
|
+
return "linear(" + stops.join(", ") + ")";
|
|
142
|
+
}
|
|
143
|
+
function motionEaseForWebAnimations(ease, element) {
|
|
144
|
+
var resolved = ease;
|
|
145
|
+
var reference = /^var\(--an-motion-ease-([a-z0-9][a-z0-9-]{0,63})\)$/.exec(String(ease));
|
|
146
|
+
if (reference) {
|
|
147
|
+
var property = "--an-motion-ease-" + reference[1];
|
|
148
|
+
resolved = window.getComputedStyle(element).getPropertyValue(property).trim();
|
|
149
|
+
if (!resolved || /^var\(/i.test(resolved)) throw new Error("Motion easing variable " + property + " is not defined or does not resolve to a concrete easing.");
|
|
150
|
+
}
|
|
151
|
+
var normalized = String(resolved).trim();
|
|
152
|
+
if (normalized.toLowerCase() === "spring") return springToLinear(0.25, 1);
|
|
153
|
+
var spring = /^spring\(\s*([+-]?(?:\d+\.?\d*|\.\d+))\s*(?:,\s*([+-]?(?:\d+\.?\d*|\.\d+))\s*)?\)$/i.exec(normalized);
|
|
154
|
+
if (/^spring/i.test(normalized) && !spring) throw new Error("Motion text easing is not supported: " + normalized);
|
|
155
|
+
if (spring) return springToLinear(Number(spring[1]), Number(spring[2] || 1));
|
|
156
|
+
return resolved;
|
|
157
|
+
}
|
|
158
|
+
var targetGroups = [];
|
|
159
|
+
animations.forEach(function (animation) {
|
|
160
|
+
var group = targetGroups.find(function (candidate) { return candidate.targetNodeId === animation.targetNodeId; });
|
|
161
|
+
if (!group) { group = { targetNodeId: animation.targetNodeId, animations: [] }; targetGroups.push(group); }
|
|
162
|
+
group.animations.push(animation);
|
|
163
|
+
});
|
|
164
|
+
targetGroups.forEach(function (targetGroup) {
|
|
165
|
+
var animation = targetGroup.animations[0];
|
|
166
|
+
var matches = allTargets.filter(function (candidate) { return candidate.getAttribute("data-agent-native-node-id") === targetGroup.targetNodeId; });
|
|
167
|
+
if (matches.length !== 1) throw new Error("Motion text target " + targetGroup.targetNodeId + " resolved to " + matches.length + " elements.");
|
|
168
|
+
var target = matches[0];
|
|
169
|
+
var entries;
|
|
170
|
+
if (animation.unit === "paragraph") {
|
|
171
|
+
entries = paragraphUnits(target).map(function (unit, index) { return { unit: unit, index: index }; });
|
|
172
|
+
} else {
|
|
173
|
+
var units = splitTextTarget(target, animation.unit);
|
|
174
|
+
var fragments = units.reduce(function (all, unit) { return all.concat(unit.fragments); }, []);
|
|
175
|
+
entries = animation.unit === "line"
|
|
176
|
+
? lineGroups(fragments)
|
|
177
|
+
: fragments.map(function (unit) { return { unit: unit, index: Number(unit.getAttribute("data-agent-native-motion-text-unit")) }; });
|
|
178
|
+
}
|
|
179
|
+
var groupCount = entries.reduce(function (count, entry) { return Math.max(count, entry.index + 1); }, 0);
|
|
180
|
+
if ((groupCount - 1) * animation.staggerMs > 120000) throw new Error("Motion text stagger exceeds the 120000ms runtime limit.");
|
|
181
|
+
targetGroup.animations.forEach(function (track) {
|
|
182
|
+
entries.forEach(function (entry) {
|
|
183
|
+
if (typeof entry.unit.animate !== "function") throw new Error("Motion text requires the Web Animations API.");
|
|
184
|
+
var delayIndex = track.direction === "reverse" ? groupCount - 1 - entry.index : entry.index;
|
|
185
|
+
var keyframes = track.keyframes.map(function (keyframe) {
|
|
186
|
+
var frame = { offset: keyframe.t, easing: motionEaseForWebAnimations(keyframe.ease || "ease", entry.unit) };
|
|
187
|
+
frame[track.property] = keyframe.value;
|
|
188
|
+
return frame;
|
|
189
|
+
});
|
|
190
|
+
var delay = track.delayMs + delayIndex * track.staggerMs;
|
|
191
|
+
var options = { duration: track.durationMs, delay: delay, fill: "both" };
|
|
192
|
+
if (!previewBridge && playbackMode !== "once") {
|
|
193
|
+
options.iterations = Infinity;
|
|
194
|
+
if (playbackMode === "ping-pong") options.direction = "alternate";
|
|
195
|
+
}
|
|
196
|
+
var runningAnimation = entry.unit.animate(keyframes, options);
|
|
197
|
+
if (previewBridge) {
|
|
198
|
+
runningAnimation.pause();
|
|
199
|
+
runningAnimation.currentTime = 0;
|
|
200
|
+
previewAnimations.push({ animation: runningAnimation, delay: delay, duration: track.durationMs });
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
if (previewBridge && typeof window.addEventListener === "function") {
|
|
206
|
+
window.addEventListener("message", function (event) {
|
|
207
|
+
if (event.source !== window.parent || !event.data || typeof event.data.type !== "string") return;
|
|
208
|
+
if (event.data.type === "motion-preview") {
|
|
209
|
+
var t = Number(event.data.t);
|
|
210
|
+
var timelineDuration = Number(event.data.durationMs);
|
|
211
|
+
if (!Number.isFinite(t) || !Number.isFinite(timelineDuration) || timelineDuration <= 0) return;
|
|
212
|
+
var timelineTime = Math.max(0, Math.min(1, t)) * timelineDuration;
|
|
213
|
+
previewAnimations.forEach(function (entry) {
|
|
214
|
+
entry.animation.currentTime = Math.max(0, Math.min(entry.duration, timelineTime - entry.delay));
|
|
215
|
+
});
|
|
216
|
+
} else if (event.data.type === "motion-preview-clear") {
|
|
217
|
+
previewAnimations.forEach(function (entry) { entry.animation.currentTime = 0; });
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
})(__MOTION_TEXT_SOURCE__);
|
package/package.json
CHANGED