@moonwitness/ui 7.3.0 → 8.0.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/CHANGELOG.md +16 -0
- package/dist/pixelfx-boundary.js +1 -1
- package/package.json +2 -3
- package/scripts/consumer-smoke.mjs +0 -45
- package/scripts/generate-icons.mjs +0 -110
- package/scripts/generate-token-artifacts.mjs +0 -90
- package/scripts/icon-svg-to-jsx.mjs +0 -249
- package/scripts/verification-diagnostics.mjs +0 -40
- package/scripts/verify-package.mjs +0 -412
- package/src/cartoon/anime-avatar.tsx +0 -628
- package/src/cartoon/anime-stage.tsx +0 -458
- package/src/cartoon/index.tsx +0 -542
- package/src/cartoon.tsx +0 -645
- package/src/characters.ts +0 -625
- package/src/components/accordion.tsx +0 -77
- package/src/components/alert.tsx +0 -139
- package/src/components/appearance-menu.tsx +0 -181
- package/src/components/artwork-frame.tsx +0 -49
- package/src/components/audio.tsx +0 -97
- package/src/components/avatar.tsx +0 -75
- package/src/components/badge.tsx +0 -94
- package/src/components/brand-mark.tsx +0 -73
- package/src/components/breadcrumbs.tsx +0 -98
- package/src/components/button.tsx +0 -340
- package/src/components/card.tsx +0 -171
- package/src/components/character-badge.tsx +0 -58
- package/src/components/character-preview.tsx +0 -104
- package/src/components/character-stage.tsx +0 -225
- package/src/components/chart.tsx +0 -481
- package/src/components/checkbox.tsx +0 -64
- package/src/components/comic-panel.tsx +0 -301
- package/src/components/comic-theater.tsx +0 -170
- package/src/components/command.tsx +0 -189
- package/src/components/confirm-dialog.tsx +0 -129
- package/src/components/copy-button.tsx +0 -62
- package/src/components/date-picker.tsx +0 -126
- package/src/components/dialog.tsx +0 -164
- package/src/components/dna-icon.tsx +0 -77
- package/src/components/dropdown-menu.tsx +0 -87
- package/src/components/effects.tsx +0 -1021
- package/src/components/empty-state.tsx +0 -93
- package/src/components/epistemic-branch-panel.tsx +0 -101
- package/src/components/error-state.tsx +0 -137
- package/src/components/field.tsx +0 -96
- package/src/components/filter-facet-bar.tsx +0 -91
- package/src/components/inbox-popover.tsx +0 -146
- package/src/components/input.tsx +0 -25
- package/src/components/kanban-board.tsx +0 -190
- package/src/components/label.tsx +0 -19
- package/src/components/layered-scene.tsx +0 -555
- package/src/components/log-console.tsx +0 -261
- package/src/components/metric-tile.tsx +0 -99
- package/src/components/mode-picker.tsx +0 -149
- package/src/components/motion-timeline.tsx +0 -848
- package/src/components/number-input.tsx +0 -104
- package/src/components/page-header.tsx +0 -123
- package/src/components/pagination.tsx +0 -83
- package/src/components/panel.tsx +0 -121
- package/src/components/paper-note.tsx +0 -77
- package/src/components/popover.tsx +0 -72
- package/src/components/progress.tsx +0 -127
- package/src/components/quest-card.tsx +0 -319
- package/src/components/radio-group.tsx +0 -50
- package/src/components/riot-sticker.tsx +0 -151
- package/src/components/scene-particles.tsx +0 -196
- package/src/components/scene-transitions.tsx +0 -130
- package/src/components/section-ribbon.tsx +0 -94
- package/src/components/select-field.tsx +0 -27
- package/src/components/select.tsx +0 -81
- package/src/components/separator.tsx +0 -58
- package/src/components/sheet.tsx +0 -96
- package/src/components/skeleton.tsx +0 -35
- package/src/components/sketch-annotation.tsx +0 -87
- package/src/components/smart-button-box.tsx +0 -114
- package/src/components/speech-bubble.tsx +0 -116
- package/src/components/spinner.tsx +0 -69
- package/src/components/sprite-player.tsx +0 -412
- package/src/components/status-bar.tsx +0 -63
- package/src/components/status-pill.tsx +0 -68
- package/src/components/switch.tsx +0 -76
- package/src/components/table.tsx +0 -163
- package/src/components/tabs.tsx +0 -101
- package/src/components/tag-input.tsx +0 -170
- package/src/components/textarea.tsx +0 -25
- package/src/components/toast.tsx +0 -14
- package/src/components/toolbar.tsx +0 -39
- package/src/components/tooltip.tsx +0 -49
- package/src/components/update-banner.tsx +0 -220
- package/src/components/xv-primitives.tsx +0 -256
- package/src/css-exports.ts +0 -142
- package/src/dna.tsx +0 -137
- package/src/game/boss-hud.tsx +0 -384
- package/src/game/index.tsx +0 -886
- package/src/game/tactical.tsx +0 -245
- package/src/game.tsx +0 -770
- package/src/icons/activity.tsx +0 -38
- package/src/icons/add.tsx +0 -38
- package/src/icons/addon.tsx +0 -37
- package/src/icons/anime-anger.tsx +0 -37
- package/src/icons/anime-shock.tsx +0 -37
- package/src/icons/anime-sparkle.tsx +0 -38
- package/src/icons/anime-sweatdrop.tsx +0 -38
- package/src/icons/archive.tsx +0 -37
- package/src/icons/arrow-left.tsx +0 -37
- package/src/icons/arrow-right.tsx +0 -37
- package/src/icons/attachment.tsx +0 -38
- package/src/icons/bank.tsx +0 -37
- package/src/icons/bolt.tsx +0 -37
- package/src/icons/book-open.tsx +0 -37
- package/src/icons/bookmark.tsx +0 -37
- package/src/icons/boss-skull.tsx +0 -40
- package/src/icons/calendar-clock.tsx +0 -40
- package/src/icons/calendar.tsx +0 -38
- package/src/icons/check-circle.tsx +0 -38
- package/src/icons/check-square.tsx +0 -38
- package/src/icons/check.tsx +0 -37
- package/src/icons/chevron-right.tsx +0 -37
- package/src/icons/chevrons-left.tsx +0 -37
- package/src/icons/chevrons-right.tsx +0 -37
- package/src/icons/clapperboard.tsx +0 -38
- package/src/icons/clock.tsx +0 -38
- package/src/icons/close.tsx +0 -37
- package/src/icons/code.tsx +0 -37
- package/src/icons/columns.tsx +0 -38
- package/src/icons/combo-flame.tsx +0 -38
- package/src/icons/company.tsx +0 -38
- package/src/icons/credit-card.tsx +0 -38
- package/src/icons/critical-star.tsx +0 -37
- package/src/icons/currency.tsx +0 -38
- package/src/icons/delete.tsx +0 -37
- package/src/icons/document.tsx +0 -38
- package/src/icons/download.tsx +0 -37
- package/src/icons/dpad.tsx +0 -38
- package/src/icons/edit.tsx +0 -38
- package/src/icons/element-fire.tsx +0 -37
- package/src/icons/element-ice.tsx +0 -38
- package/src/icons/element-solar.tsx +0 -38
- package/src/icons/element-void.tsx +0 -38
- package/src/icons/element-volt.tsx +0 -38
- package/src/icons/element-wind.tsx +0 -37
- package/src/icons/error.tsx +0 -38
- package/src/icons/external-link.tsx +0 -38
- package/src/icons/field.tsx +0 -38
- package/src/icons/file-spreadsheet.tsx +0 -38
- package/src/icons/filter.tsx +0 -37
- package/src/icons/gacha-ticket.tsx +0 -38
- package/src/icons/gamepad.tsx +0 -40
- package/src/icons/globe.tsx +0 -38
- package/src/icons/grid.tsx +0 -40
- package/src/icons/hash.tsx +0 -37
- package/src/icons/heart-hp.tsx +0 -38
- package/src/icons/history.tsx +0 -37
- package/src/icons/home.tsx +0 -37
- package/src/icons/image.tsx +0 -39
- package/src/icons/impact-slash.tsx +0 -38
- package/src/icons/inbox.tsx +0 -38
- package/src/icons/index.ts +0 -120
- package/src/icons/info.tsx +0 -38
- package/src/icons/jobs.tsx +0 -38
- package/src/icons/katana.tsx +0 -38
- package/src/icons/key.tsx +0 -38
- package/src/icons/keyboard.tsx +0 -38
- package/src/icons/keyframe-diamond.tsx +0 -38
- package/src/icons/knowledge.tsx +0 -38
- package/src/icons/language.tsx +0 -39
- package/src/icons/lock.tsx +0 -38
- package/src/icons/logout.tsx +0 -37
- package/src/icons/loot-chest.tsx +0 -39
- package/src/icons/mail.tsx +0 -38
- package/src/icons/mana-crystal.tsx +0 -38
- package/src/icons/map-pin.tsx +0 -38
- package/src/icons/mecha-helm.tsx +0 -38
- package/src/icons/menu.tsx +0 -37
- package/src/icons/message.tsx +0 -38
- package/src/icons/model.tsx +0 -38
- package/src/icons/moon.tsx +0 -37
- package/src/icons/notification.tsx +0 -38
- package/src/icons/partner.tsx +0 -41
- package/src/icons/pause.tsx +0 -37
- package/src/icons/phone.tsx +0 -37
- package/src/icons/play.tsx +0 -37
- package/src/icons/potion-flask.tsx +0 -40
- package/src/icons/quest-scroll.tsx +0 -39
- package/src/icons/radar-ping.tsx +0 -40
- package/src/icons/refresh.tsx +0 -38
- package/src/icons/relation.tsx +0 -40
- package/src/icons/save.tsx +0 -38
- package/src/icons/search.tsx +0 -38
- package/src/icons/security.tsx +0 -38
- package/src/icons/send.tsx +0 -38
- package/src/icons/settings.tsx +0 -39
- package/src/icons/shield-crest.tsx +0 -38
- package/src/icons/shuriken.tsx +0 -38
- package/src/icons/signal-off.tsx +0 -37
- package/src/icons/signal.tsx +0 -37
- package/src/icons/skill-node.tsx +0 -40
- package/src/icons/smartphone.tsx +0 -38
- package/src/icons/sort-ascending.tsx +0 -37
- package/src/icons/sort-descending.tsx +0 -37
- package/src/icons/sort.tsx +0 -37
- package/src/icons/sparkle.tsx +0 -38
- package/src/icons/speech-burst.tsx +0 -37
- package/src/icons/story.tsx +0 -37
- package/src/icons/sun.tsx +0 -38
- package/src/icons/tag.tsx +0 -38
- package/src/icons/team.tsx +0 -40
- package/src/icons/trophy-crown.tsx +0 -39
- package/src/icons/upload.tsx +0 -37
- package/src/icons/user.tsx +0 -38
- package/src/icons/users.tsx +0 -39
- package/src/icons/visibility-off.tsx +0 -38
- package/src/icons/visibility.tsx +0 -38
- package/src/icons/volume-off.tsx +0 -37
- package/src/icons/volume.tsx +0 -37
- package/src/icons/warning.tsx +0 -38
- package/src/icons/workflow.tsx +0 -40
- package/src/icons.tsx +0 -965
- package/src/index.ts +0 -89
- package/src/lib/asset-registry.ts +0 -534
- package/src/lib/audio-runtime.ts +0 -314
- package/src/lib/character-adapter.ts +0 -370
- package/src/lib/character-registry.ts +0 -2368
- package/src/lib/cn.ts +0 -6
- package/src/lib/compose-refs.ts +0 -16
- package/src/lib/sanitize-url.ts +0 -51
- package/src/lib/scene-camera.ts +0 -483
- package/src/lib/scene-playback.ts +0 -622
- package/src/lib/scene-soundscape.ts +0 -151
- package/src/lib/scene-test-harness.ts +0 -200
- package/src/lib/scene-timeline.ts +0 -398
- package/src/lib/use-animation-visibility.ts +0 -45
- package/src/lib/use-modal-focus.ts +0 -270
- package/src/lib/use-reduced-motion.ts +0 -37
- package/src/motion/easing-presets.ts +0 -262
- package/src/motion/index.tsx +0 -894
- package/src/motion/physics.ts +0 -259
- package/src/motion/timeline-math.ts +0 -358
- package/src/motion.tsx +0 -639
- package/src/pixelfx-boundary.ts +0 -188
- package/src/pixelfx-registry.ts +0 -1190
- package/src/pixelfx-types.d.ts +0 -73
- package/src/pixelfx.tsx +0 -1022
- package/src/provider.tsx +0 -63
- package/src/skin-catalog.ts +0 -306
- package/src/skin-tokens.ts +0 -425
- package/src/ssr/init-script.ts +0 -281
- package/src/ssr/resolve-skin.ts +0 -217
- package/src/ssr/theme-mismatch-dev.ts +0 -181
- package/src/templates/battle-arena.tsx +0 -688
- package/src/templates/index.tsx +0 -314
- package/src/templates.tsx +0 -225
- package/src/themes/dna-presets.ts +0 -119
- package/src/themes/index.ts +0 -56
- package/src/themes/provider.tsx +0 -183
- package/src/themes/types.ts +0 -111
- package/src/themes.ts +0 -9
- package/src/token-exporter.ts +0 -12
- package/src/token-exporters.ts +0 -343
- package/src/token-seeds.ts +0 -335
- package/src/token-snapshot.ts +0 -179
- package/src/utils.ts +0 -58
|
@@ -1,412 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { existsSync } from "node:fs";
|
|
3
|
-
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { execPath, platform, stdout } from "node:process";
|
|
6
|
-
import { join, resolve } from "node:path";
|
|
7
|
-
import { execFile } from "node:child_process";
|
|
8
|
-
import { promisify } from "node:util";
|
|
9
|
-
import {
|
|
10
|
-
extractPackageVerificationErrorCode,
|
|
11
|
-
renderPackageVerificationAnnotation,
|
|
12
|
-
} from "./verification-diagnostics.mjs";
|
|
13
|
-
|
|
14
|
-
const execFileAsync = promisify(execFile);
|
|
15
|
-
const isWindows = platform === "win32";
|
|
16
|
-
const packageRoot = resolve(import.meta.dirname, "..");
|
|
17
|
-
const workspaceRoot = resolve(packageRoot, "../..");
|
|
18
|
-
const tempRoot = await mkdtemp(join(tmpdir(), "moonwitness-ui-package-"));
|
|
19
|
-
let verificationPhase = "create package archive";
|
|
20
|
-
|
|
21
|
-
/** Run npm in a directory; wrap through cmd.exe on Windows because npm is a .cmd shim. */
|
|
22
|
-
function runNpm(args, options) {
|
|
23
|
-
const command = isWindows ? "cmd" : "npm";
|
|
24
|
-
const argv = isWindows ? ["/d", "/s", "/c", "npm", ...args] : args;
|
|
25
|
-
return execFileAsync(command, argv, { windowsHide: true, ...options });
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async function packPackage(directory) {
|
|
29
|
-
const packed = await runNpm(["pack", "--pack-destination", tempRoot], {
|
|
30
|
-
cwd: directory,
|
|
31
|
-
});
|
|
32
|
-
const archiveName = packed.stdout.match(/[\w.-]+\.tgz/u)?.[0];
|
|
33
|
-
assert.ok(archiveName, "npm pack should report the generated archive");
|
|
34
|
-
return join(tempRoot, archiveName);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** Read the installed version of a dependency resolvable from `directory`. */
|
|
38
|
-
async function readInstalledVersion(directory, dependencyName) {
|
|
39
|
-
let cursor = directory;
|
|
40
|
-
let resolvedPath;
|
|
41
|
-
while (true) {
|
|
42
|
-
const candidate = join(
|
|
43
|
-
cursor,
|
|
44
|
-
"node_modules",
|
|
45
|
-
dependencyName,
|
|
46
|
-
"package.json",
|
|
47
|
-
);
|
|
48
|
-
if (existsSync(candidate)) {
|
|
49
|
-
resolvedPath = candidate;
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
const parent = resolve(cursor, "..");
|
|
53
|
-
if (parent === cursor) {
|
|
54
|
-
throw new Error(
|
|
55
|
-
`Could not find installed package.json for ${dependencyName}`,
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
cursor = parent;
|
|
59
|
-
}
|
|
60
|
-
const dependencyPackage = JSON.parse(await readFile(resolvedPath, "utf8"));
|
|
61
|
-
assert.match(
|
|
62
|
-
dependencyPackage.version,
|
|
63
|
-
/^\d+\.\d+\.\d+(?:[-+][\w.-]+)?$/u,
|
|
64
|
-
`Expected an exact installed version for ${dependencyName}`,
|
|
65
|
-
);
|
|
66
|
-
return dependencyPackage.version;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async function createConsumer(name, dependencies) {
|
|
70
|
-
const consumerRoot = join(tempRoot, name);
|
|
71
|
-
await mkdir(consumerRoot);
|
|
72
|
-
// The packed UI declares @moonwitness/types as a regular dependency at its
|
|
73
|
-
// published version. Without an override npm resolves that transitive
|
|
74
|
-
// dependency from the registry, where the private workspace package does not
|
|
75
|
-
// exist. Point overrides at the same local archives supplied to the consumer.
|
|
76
|
-
const localOverrides = Object.fromEntries(
|
|
77
|
-
Object.entries(dependencies).filter(
|
|
78
|
-
([dependencyName, version]) =>
|
|
79
|
-
dependencyName === "@moonwitness/types" && version.startsWith("file:"),
|
|
80
|
-
),
|
|
81
|
-
);
|
|
82
|
-
await writeFile(
|
|
83
|
-
join(consumerRoot, "package.json"),
|
|
84
|
-
JSON.stringify({ private: true, type: "module" }, null, 2),
|
|
85
|
-
);
|
|
86
|
-
if (Object.keys(localOverrides).length > 0) {
|
|
87
|
-
await writeFile(
|
|
88
|
-
join(consumerRoot, "package.json"),
|
|
89
|
-
JSON.stringify(
|
|
90
|
-
{
|
|
91
|
-
private: true,
|
|
92
|
-
type: "module",
|
|
93
|
-
overrides: localOverrides,
|
|
94
|
-
},
|
|
95
|
-
null,
|
|
96
|
-
2,
|
|
97
|
-
),
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
const installTargets = Object.entries(dependencies)
|
|
101
|
-
.filter(([dependencyName]) => dependencyName !== "@moonwitness/types")
|
|
102
|
-
.map(([dependencyName, version]) =>
|
|
103
|
-
version.startsWith("file:") ? version : `${dependencyName}@${version}`,
|
|
104
|
-
);
|
|
105
|
-
verificationPhase = "install isolated consumer dependencies";
|
|
106
|
-
await runNpm(
|
|
107
|
-
[
|
|
108
|
-
"install",
|
|
109
|
-
"--prefer-offline",
|
|
110
|
-
"--save-exact",
|
|
111
|
-
"--no-audit",
|
|
112
|
-
"--no-fund",
|
|
113
|
-
...installTargets,
|
|
114
|
-
],
|
|
115
|
-
{ cwd: consumerRoot },
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
for (const [dependencyName, expectedVersion] of Object.entries(
|
|
119
|
-
dependencies,
|
|
120
|
-
)) {
|
|
121
|
-
if (expectedVersion.startsWith("file:")) continue;
|
|
122
|
-
assert.equal(
|
|
123
|
-
await readInstalledVersion(consumerRoot, dependencyName),
|
|
124
|
-
expectedVersion,
|
|
125
|
-
`${name} resolved an unexpected ${dependencyName} version`,
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
return consumerRoot;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const runtimeConsumerSource = `
|
|
132
|
-
import assert from 'node:assert/strict';
|
|
133
|
-
import { JSDOM } from 'jsdom';
|
|
134
|
-
import { act, createElement, createRef, Fragment } from 'react';
|
|
135
|
-
|
|
136
|
-
const dom = new JSDOM('<!doctype html><html><body><div id="root"></div></body></html>', {
|
|
137
|
-
url: 'http://localhost/',
|
|
138
|
-
});
|
|
139
|
-
for (const key of [
|
|
140
|
-
'window', 'document', 'navigator', 'getComputedStyle', 'requestAnimationFrame', 'cancelAnimationFrame',
|
|
141
|
-
]) {
|
|
142
|
-
Object.defineProperty(globalThis, key, { configurable: true, writable: true, value: dom.window[key] });
|
|
143
|
-
}
|
|
144
|
-
// Radix probes DOM constructors such as HTMLFormElement at module/render time.
|
|
145
|
-
// Mirror any window global Node does not already provide without clobbering
|
|
146
|
-
// Node's own primitives (setTimeout, process, ...).
|
|
147
|
-
for (const key of Object.getOwnPropertyNames(dom.window)) {
|
|
148
|
-
if (key in globalThis) continue;
|
|
149
|
-
try {
|
|
150
|
-
Object.defineProperty(globalThis, key, {
|
|
151
|
-
configurable: true,
|
|
152
|
-
writable: true,
|
|
153
|
-
value: dom.window[key],
|
|
154
|
-
});
|
|
155
|
-
} catch { /* some window properties cannot be redefined */ }
|
|
156
|
-
}
|
|
157
|
-
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
158
|
-
globalThis.ResizeObserver = class { observe() {} unobserve() {} disconnect() {} };
|
|
159
|
-
dom.window.ResizeObserver = globalThis.ResizeObserver;
|
|
160
|
-
dom.window.matchMedia = () => ({ matches: false, addEventListener() {}, removeEventListener() {} });
|
|
161
|
-
|
|
162
|
-
const { createRoot } = await import('react-dom/client');
|
|
163
|
-
const { Button } = await import('@moonwitness/ui/components/button');
|
|
164
|
-
const { Input } = await import('@moonwitness/ui/components/input');
|
|
165
|
-
const { Field } = await import('@moonwitness/ui/components/field');
|
|
166
|
-
const { Select, SelectTrigger } = await import('@moonwitness/ui/components/select');
|
|
167
|
-
const { UserIcon } = await import('@moonwitness/ui/icons/user');
|
|
168
|
-
const { Command } = await import('@moonwitness/ui/components/command');
|
|
169
|
-
const { ToastHost } = await import('@moonwitness/ui/components/toast');
|
|
170
|
-
const { themeRegistry } = await import('@moonwitness/ui/themes');
|
|
171
|
-
const { createSceneTimeline } = await import('@moonwitness/ui/lib/scene-timeline');
|
|
172
|
-
|
|
173
|
-
for (const component of [Button, Input, Field, Select, SelectTrigger, UserIcon, Command, ToastHost]) {
|
|
174
|
-
assert.ok(component, 'Public component exports must remain available');
|
|
175
|
-
}
|
|
176
|
-
assert.equal(typeof createSceneTimeline, 'function');
|
|
177
|
-
assert.ok(themeRegistry.list().length > 0);
|
|
178
|
-
|
|
179
|
-
const buttonRef = createRef();
|
|
180
|
-
const fieldRef = createRef();
|
|
181
|
-
const iconRef = createRef();
|
|
182
|
-
const selectRef = createRef();
|
|
183
|
-
let callbackInput;
|
|
184
|
-
const root = createRoot(document.getElementById('root'));
|
|
185
|
-
await act(async () => {
|
|
186
|
-
root.render(createElement(Fragment, null,
|
|
187
|
-
createElement(Button, { ref: buttonRef }, 'Save'),
|
|
188
|
-
createElement(Input, { ref: (node) => { callbackInput = node; }, 'aria-label': 'Name' }),
|
|
189
|
-
createElement(Field, { ref: fieldRef, label: 'Profile', htmlFor: 'consumer-profile' }, createElement(Input)),
|
|
190
|
-
createElement(UserIcon, { ref: iconRef }),
|
|
191
|
-
createElement(Select, null, createElement(SelectTrigger, { ref: selectRef }, 'Pick'))
|
|
192
|
-
));
|
|
193
|
-
});
|
|
194
|
-
assert.equal(buttonRef.current.tagName, 'BUTTON');
|
|
195
|
-
assert.equal(callbackInput.tagName, 'INPUT');
|
|
196
|
-
assert.equal(fieldRef.current.tagName, 'DIV');
|
|
197
|
-
assert.equal(iconRef.current.tagName, 'svg');
|
|
198
|
-
assert.equal(selectRef.current.tagName, 'BUTTON');
|
|
199
|
-
await act(async () => root.unmount());
|
|
200
|
-
|
|
201
|
-
for (const privatePath of [
|
|
202
|
-
'@moonwitness/ui/dist/components/button.js',
|
|
203
|
-
'@moonwitness/ui/src/components/button.tsx',
|
|
204
|
-
]) {
|
|
205
|
-
let rejected = false;
|
|
206
|
-
try { await import(privatePath); }
|
|
207
|
-
catch (error) { rejected = error.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED'; }
|
|
208
|
-
assert.equal(rejected, true, privatePath + ' must not be publicly importable');
|
|
209
|
-
}
|
|
210
|
-
`;
|
|
211
|
-
|
|
212
|
-
const typeConsumerSource = `
|
|
213
|
-
import { createRef } from 'react';
|
|
214
|
-
import { Button } from '@moonwitness/ui/components/button';
|
|
215
|
-
import { Field } from '@moonwitness/ui/components/field';
|
|
216
|
-
import { Input } from '@moonwitness/ui/components/input';
|
|
217
|
-
import { Select, SelectTrigger } from '@moonwitness/ui/components/select';
|
|
218
|
-
import { UserIcon } from '@moonwitness/ui/icons/user';
|
|
219
|
-
import '@moonwitness/ui/components.css';
|
|
220
|
-
|
|
221
|
-
const buttonRef = createRef<HTMLButtonElement>();
|
|
222
|
-
const fieldRef = createRef<HTMLDivElement>();
|
|
223
|
-
const inputRef = createRef<HTMLInputElement>();
|
|
224
|
-
const iconRef = createRef<SVGSVGElement>();
|
|
225
|
-
const selectRef = createRef<HTMLButtonElement>();
|
|
226
|
-
|
|
227
|
-
export const Fixture = () => (
|
|
228
|
-
<>
|
|
229
|
-
<Button ref={buttonRef}>Save</Button>
|
|
230
|
-
<Field ref={fieldRef} label="Name" htmlFor="consumer-name"><Input ref={inputRef} /></Field>
|
|
231
|
-
<UserIcon ref={iconRef} />
|
|
232
|
-
<Select><SelectTrigger ref={selectRef}>Pick</SelectTrigger></Select>
|
|
233
|
-
</>
|
|
234
|
-
);
|
|
235
|
-
`;
|
|
236
|
-
|
|
237
|
-
const minimalConsumerSource = `
|
|
238
|
-
import assert from 'node:assert/strict';
|
|
239
|
-
import { access } from 'node:fs/promises';
|
|
240
|
-
import { Button } from '@moonwitness/ui/components/button';
|
|
241
|
-
import { UserIcon } from '@moonwitness/ui/icons/user';
|
|
242
|
-
import { themeRegistry } from '@moonwitness/ui/themes';
|
|
243
|
-
|
|
244
|
-
assert.ok(Button);
|
|
245
|
-
assert.ok(UserIcon);
|
|
246
|
-
assert.ok(themeRegistry.list().length > 0);
|
|
247
|
-
for (const optionalPeer of ['cmdk', 'sonner']) {
|
|
248
|
-
await assert.rejects(access('node_modules/' + optionalPeer), { code: 'ENOENT' });
|
|
249
|
-
}
|
|
250
|
-
for (const [subpath, peerName] of [
|
|
251
|
-
['@moonwitness/ui/components/command', 'cmdk'],
|
|
252
|
-
['@moonwitness/ui/components/toast', 'sonner'],
|
|
253
|
-
]) {
|
|
254
|
-
await assert.rejects(import(subpath), (error) =>
|
|
255
|
-
error.code === 'ERR_MODULE_NOT_FOUND' && error.message.includes(peerName)
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
`;
|
|
259
|
-
|
|
260
|
-
try {
|
|
261
|
-
verificationPhase = "create package archive";
|
|
262
|
-
const typesArchive = await packPackage(resolve(packageRoot, "../types"));
|
|
263
|
-
const uiArchive = await packPackage(packageRoot);
|
|
264
|
-
verificationPhase = "validate package archive";
|
|
265
|
-
assert.ok(typesArchive.endsWith(".tgz"));
|
|
266
|
-
assert.ok(uiArchive.endsWith(".tgz"));
|
|
267
|
-
|
|
268
|
-
verificationPhase = "read locked consumer dependency versions";
|
|
269
|
-
const react19 = await readInstalledVersion(packageRoot, "react");
|
|
270
|
-
const reactDom19 = await readInstalledVersion(packageRoot, "react-dom");
|
|
271
|
-
const typesReact19 = await readInstalledVersion(packageRoot, "@types/react");
|
|
272
|
-
const typesReactDom19 = await readInstalledVersion(
|
|
273
|
-
packageRoot,
|
|
274
|
-
"@types/react-dom",
|
|
275
|
-
);
|
|
276
|
-
assert.match(react19, /^19\./u);
|
|
277
|
-
assert.match(reactDom19, /^19\./u);
|
|
278
|
-
const sharedVersions = {
|
|
279
|
-
"radix-ui": await readInstalledVersion(packageRoot, "radix-ui"),
|
|
280
|
-
cmdk: await readInstalledVersion(packageRoot, "cmdk"),
|
|
281
|
-
sonner: await readInstalledVersion(packageRoot, "sonner"),
|
|
282
|
-
typescript: await readInstalledVersion(workspaceRoot, "typescript"),
|
|
283
|
-
jsdom: await readInstalledVersion(workspaceRoot, "jsdom"),
|
|
284
|
-
};
|
|
285
|
-
const matrices = [
|
|
286
|
-
{
|
|
287
|
-
name: "consumer-react-18",
|
|
288
|
-
react: "18.3.1",
|
|
289
|
-
"react-dom": "18.3.1",
|
|
290
|
-
"@types/react": "18.3.24",
|
|
291
|
-
"@types/react-dom": "18.3.7",
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
name: "consumer-react-19",
|
|
295
|
-
react: react19,
|
|
296
|
-
"react-dom": reactDom19,
|
|
297
|
-
"@types/react": typesReact19,
|
|
298
|
-
"@types/react-dom": typesReactDom19,
|
|
299
|
-
},
|
|
300
|
-
];
|
|
301
|
-
|
|
302
|
-
for (const matrix of matrices) {
|
|
303
|
-
const consumerRoot = await createConsumer(matrix.name, {
|
|
304
|
-
"@moonwitness/types": `file:${typesArchive}`,
|
|
305
|
-
"@moonwitness/ui": `file:${uiArchive}`,
|
|
306
|
-
react: matrix.react,
|
|
307
|
-
"react-dom": matrix["react-dom"],
|
|
308
|
-
"@types/react": matrix["@types/react"],
|
|
309
|
-
"@types/react-dom": matrix["@types/react-dom"],
|
|
310
|
-
...sharedVersions,
|
|
311
|
-
});
|
|
312
|
-
await writeFile(join(consumerRoot, "consumer.mjs"), runtimeConsumerSource);
|
|
313
|
-
await writeFile(join(consumerRoot, "fixture.tsx"), typeConsumerSource);
|
|
314
|
-
await writeFile(
|
|
315
|
-
join(consumerRoot, "tsconfig.json"),
|
|
316
|
-
JSON.stringify(
|
|
317
|
-
{
|
|
318
|
-
compilerOptions: {
|
|
319
|
-
strict: true,
|
|
320
|
-
noEmit: true,
|
|
321
|
-
target: "ES2022",
|
|
322
|
-
lib: ["ES2022", "DOM", "DOM.Iterable"],
|
|
323
|
-
module: "ESNext",
|
|
324
|
-
moduleResolution: "Bundler",
|
|
325
|
-
jsx: "react-jsx",
|
|
326
|
-
skipLibCheck: false,
|
|
327
|
-
},
|
|
328
|
-
include: ["fixture.tsx"],
|
|
329
|
-
},
|
|
330
|
-
null,
|
|
331
|
-
2,
|
|
332
|
-
),
|
|
333
|
-
);
|
|
334
|
-
|
|
335
|
-
verificationPhase = "run consumer import smoke test";
|
|
336
|
-
await execFileAsync(execPath, [join(consumerRoot, "consumer.mjs")], {
|
|
337
|
-
cwd: consumerRoot,
|
|
338
|
-
windowsHide: true,
|
|
339
|
-
});
|
|
340
|
-
verificationPhase = "run consumer typecheck";
|
|
341
|
-
await runNpm(["exec", "--no", "--", "tsc", "-p", "tsconfig.json"], {
|
|
342
|
-
cwd: consumerRoot,
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
verificationPhase = "validate optional peer isolation";
|
|
347
|
-
const minimalConsumer = await createConsumer("consumer-minimal-peers", {
|
|
348
|
-
"@moonwitness/types": `file:${typesArchive}`,
|
|
349
|
-
"@moonwitness/ui": `file:${uiArchive}`,
|
|
350
|
-
react: "18.3.1",
|
|
351
|
-
"react-dom": "18.3.1",
|
|
352
|
-
"radix-ui": sharedVersions["radix-ui"],
|
|
353
|
-
});
|
|
354
|
-
await writeFile(join(minimalConsumer, "consumer.mjs"), minimalConsumerSource);
|
|
355
|
-
verificationPhase = "run consumer import smoke test";
|
|
356
|
-
await execFileAsync(execPath, [join(minimalConsumer, "consumer.mjs")], {
|
|
357
|
-
cwd: minimalConsumer,
|
|
358
|
-
windowsHide: true,
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
const installedUiRoot = join(
|
|
362
|
-
minimalConsumer,
|
|
363
|
-
"node_modules",
|
|
364
|
-
"@moonwitness",
|
|
365
|
-
"ui",
|
|
366
|
-
);
|
|
367
|
-
const packageJson = JSON.parse(
|
|
368
|
-
await readFile(join(installedUiRoot, "package.json"), "utf8"),
|
|
369
|
-
);
|
|
370
|
-
verificationPhase = "validate package peer metadata";
|
|
371
|
-
for (const requiredPeer of ["react", "react-dom", "radix-ui"]) {
|
|
372
|
-
assert.ok(
|
|
373
|
-
packageJson.peerDependencies[requiredPeer],
|
|
374
|
-
`${requiredPeer} must remain required`,
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
for (const optionalPeer of ["cmdk", "sonner"]) {
|
|
378
|
-
assert.equal(
|
|
379
|
-
packageJson.peerDependenciesMeta[optionalPeer]?.optional,
|
|
380
|
-
true,
|
|
381
|
-
);
|
|
382
|
-
}
|
|
383
|
-
assert.ok(
|
|
384
|
-
packageJson.dependencies["@moonwitness/types"],
|
|
385
|
-
"@moonwitness/types must remain declared",
|
|
386
|
-
);
|
|
387
|
-
|
|
388
|
-
verificationPhase = "validate public stylesheet exports";
|
|
389
|
-
for (const stylesheet of ["./components.css", "./styles/tokens.css"]) {
|
|
390
|
-
const exportPath = packageJson.exports[stylesheet];
|
|
391
|
-
assert.equal(
|
|
392
|
-
typeof exportPath,
|
|
393
|
-
"string",
|
|
394
|
-
`Missing public CSS export ${stylesheet}`,
|
|
395
|
-
);
|
|
396
|
-
assert.ok(
|
|
397
|
-
(await readFile(join(installedUiRoot, exportPath), "utf8")).length > 0,
|
|
398
|
-
);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
stdout.write(
|
|
402
|
-
`Packed consumers passed on React ${matrices.map((matrix) => matrix.react).join(" and ")}; refs, TypeScript, CSS, private paths, and optional peers verified.\n`,
|
|
403
|
-
);
|
|
404
|
-
} catch (error) {
|
|
405
|
-
const errorCode = extractPackageVerificationErrorCode(error);
|
|
406
|
-
stdout.write(
|
|
407
|
-
renderPackageVerificationAnnotation(verificationPhase, errorCode),
|
|
408
|
-
);
|
|
409
|
-
throw error;
|
|
410
|
-
} finally {
|
|
411
|
-
await rm(tempRoot, { recursive: true, force: true });
|
|
412
|
-
}
|