design-pact 0.2.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/README.md +67 -0
- package/SKILL.md +253 -0
- package/dist/cli.js +2540 -0
- package/package.json +44 -0
- package/web/404.html +1 -0
- package/web/__next.__PAGE__.txt +9 -0
- package/web/__next._full.txt +20 -0
- package/web/__next._head.txt +6 -0
- package/web/__next._index.txt +5 -0
- package/web/__next._tree.txt +4 -0
- package/web/_next/static/PuB4TNuzsXn-CMEz1oKNJ/_buildManifest.js +11 -0
- package/web/_next/static/PuB4TNuzsXn-CMEz1oKNJ/_clientMiddlewareManifest.js +1 -0
- package/web/_next/static/PuB4TNuzsXn-CMEz1oKNJ/_ssgManifest.js +1 -0
- package/web/_next/static/chunks/0-l9p_pd2v836.js +5 -0
- package/web/_next/static/chunks/012lv2-viu5_..js +187 -0
- package/web/_next/static/chunks/03~yq9q893hmn.js +1 -0
- package/web/_next/static/chunks/0rp7qr3afex.u.js +31 -0
- package/web/_next/static/chunks/0uyeui9y_zv_0.css +3 -0
- package/web/_next/static/chunks/0x72peuimhbw-.js +1 -0
- package/web/_next/static/chunks/15356_01bt_3u.js +1 -0
- package/web/_next/static/chunks/turbopack-0y3s-y83i3.06.js +1 -0
- package/web/_next/static/media/4fa387ec64143e14-s.0wkzw~je483f-.woff2 +0 -0
- package/web/_next/static/media/53b9e256198e5412-s.0-wfv7uh4i7h9.woff2 +0 -0
- package/web/_next/static/media/5ce348bf30bf5439-s.0zgw-jeven.3w.woff2 +0 -0
- package/web/_next/static/media/6306c77e7c8268e4-s.0rhz0arwfsn~5.woff2 +0 -0
- package/web/_next/static/media/7178b3e590c64307-s.0nx0ww8fni_q3.woff2 +0 -0
- package/web/_next/static/media/797e433ab948586e-s.p.08e28id.o-okb.woff2 +0 -0
- package/web/_next/static/media/7d817b4c03b0c5f1-s.0l76wvqk9d84w.woff2 +0 -0
- package/web/_next/static/media/8a480f0b521d4e75-s.0jzbimsg8vl84.woff2 +0 -0
- package/web/_next/static/media/bbc41e54d2fcbd21-s.0k4k9394f2q-k.woff2 +0 -0
- package/web/_next/static/media/caa3a2e1cccd8315-s.p.09~u27dqhyhd6.woff2 +0 -0
- package/web/_next/static/media/favicon.0x3dzn~oxb6tn.ico +0 -0
- package/web/_next/static/media/fef07dbb0973bf53-s.12tyk43_3sh9u.woff2 +0 -0
- package/web/_not-found/__next._full.txt +16 -0
- package/web/_not-found/__next._head.txt +6 -0
- package/web/_not-found/__next._index.txt +5 -0
- package/web/_not-found/__next._not-found.__PAGE__.txt +5 -0
- package/web/_not-found/__next._not-found.txt +5 -0
- package/web/_not-found/__next._tree.txt +2 -0
- package/web/_not-found.html +1 -0
- package/web/_not-found.txt +16 -0
- package/web/favicon.ico +0 -0
- package/web/file.svg +1 -0
- package/web/globe.svg +1 -0
- package/web/index.html +1 -0
- package/web/index.txt +20 -0
- package/web/next.svg +1 -0
- package/web/templates.json +3168 -0
- package/web/vercel.svg +1 -0
- package/web/window.svg +1 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,2540 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
|
|
28
|
+
// ../../node_modules/react/cjs/react.production.js
|
|
29
|
+
var require_react_production = __commonJS({
|
|
30
|
+
"../../node_modules/react/cjs/react.production.js"(exports) {
|
|
31
|
+
"use strict";
|
|
32
|
+
var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element");
|
|
33
|
+
var REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal");
|
|
34
|
+
var REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
35
|
+
var REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode");
|
|
36
|
+
var REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler");
|
|
37
|
+
var REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer");
|
|
38
|
+
var REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context");
|
|
39
|
+
var REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref");
|
|
40
|
+
var REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense");
|
|
41
|
+
var REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo");
|
|
42
|
+
var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
|
|
43
|
+
var REACT_ACTIVITY_TYPE = /* @__PURE__ */ Symbol.for("react.activity");
|
|
44
|
+
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
|
45
|
+
function getIteratorFn(maybeIterable) {
|
|
46
|
+
if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
|
|
47
|
+
maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
|
|
48
|
+
return "function" === typeof maybeIterable ? maybeIterable : null;
|
|
49
|
+
}
|
|
50
|
+
var ReactNoopUpdateQueue = {
|
|
51
|
+
isMounted: function() {
|
|
52
|
+
return false;
|
|
53
|
+
},
|
|
54
|
+
enqueueForceUpdate: function() {
|
|
55
|
+
},
|
|
56
|
+
enqueueReplaceState: function() {
|
|
57
|
+
},
|
|
58
|
+
enqueueSetState: function() {
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var assign = Object.assign;
|
|
62
|
+
var emptyObject = {};
|
|
63
|
+
function Component(props, context, updater) {
|
|
64
|
+
this.props = props;
|
|
65
|
+
this.context = context;
|
|
66
|
+
this.refs = emptyObject;
|
|
67
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
68
|
+
}
|
|
69
|
+
Component.prototype.isReactComponent = {};
|
|
70
|
+
Component.prototype.setState = function(partialState, callback) {
|
|
71
|
+
if ("object" !== typeof partialState && "function" !== typeof partialState && null != partialState)
|
|
72
|
+
throw Error(
|
|
73
|
+
"takes an object of state variables to update or a function which returns an object of state variables."
|
|
74
|
+
);
|
|
75
|
+
this.updater.enqueueSetState(this, partialState, callback, "setState");
|
|
76
|
+
};
|
|
77
|
+
Component.prototype.forceUpdate = function(callback) {
|
|
78
|
+
this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
|
|
79
|
+
};
|
|
80
|
+
function ComponentDummy() {
|
|
81
|
+
}
|
|
82
|
+
ComponentDummy.prototype = Component.prototype;
|
|
83
|
+
function PureComponent(props, context, updater) {
|
|
84
|
+
this.props = props;
|
|
85
|
+
this.context = context;
|
|
86
|
+
this.refs = emptyObject;
|
|
87
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
88
|
+
}
|
|
89
|
+
var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
|
|
90
|
+
pureComponentPrototype.constructor = PureComponent;
|
|
91
|
+
assign(pureComponentPrototype, Component.prototype);
|
|
92
|
+
pureComponentPrototype.isPureReactComponent = true;
|
|
93
|
+
var isArrayImpl = Array.isArray;
|
|
94
|
+
function noop() {
|
|
95
|
+
}
|
|
96
|
+
var ReactSharedInternals = { H: null, A: null, T: null, S: null };
|
|
97
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
98
|
+
function ReactElement(type, key, props) {
|
|
99
|
+
var refProp = props.ref;
|
|
100
|
+
return {
|
|
101
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
102
|
+
type,
|
|
103
|
+
key,
|
|
104
|
+
ref: void 0 !== refProp ? refProp : null,
|
|
105
|
+
props
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function cloneAndReplaceKey(oldElement, newKey) {
|
|
109
|
+
return ReactElement(oldElement.type, newKey, oldElement.props);
|
|
110
|
+
}
|
|
111
|
+
function isValidElement(object) {
|
|
112
|
+
return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
113
|
+
}
|
|
114
|
+
function escape(key) {
|
|
115
|
+
var escaperLookup = { "=": "=0", ":": "=2" };
|
|
116
|
+
return "$" + key.replace(/[=:]/g, function(match) {
|
|
117
|
+
return escaperLookup[match];
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
var userProvidedKeyEscapeRegex = /\/+/g;
|
|
121
|
+
function getElementKey(element, index) {
|
|
122
|
+
return "object" === typeof element && null !== element && null != element.key ? escape("" + element.key) : index.toString(36);
|
|
123
|
+
}
|
|
124
|
+
function resolveThenable(thenable) {
|
|
125
|
+
switch (thenable.status) {
|
|
126
|
+
case "fulfilled":
|
|
127
|
+
return thenable.value;
|
|
128
|
+
case "rejected":
|
|
129
|
+
throw thenable.reason;
|
|
130
|
+
default:
|
|
131
|
+
switch ("string" === typeof thenable.status ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(
|
|
132
|
+
function(fulfilledValue) {
|
|
133
|
+
"pending" === thenable.status && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
|
|
134
|
+
},
|
|
135
|
+
function(error) {
|
|
136
|
+
"pending" === thenable.status && (thenable.status = "rejected", thenable.reason = error);
|
|
137
|
+
}
|
|
138
|
+
)), thenable.status) {
|
|
139
|
+
case "fulfilled":
|
|
140
|
+
return thenable.value;
|
|
141
|
+
case "rejected":
|
|
142
|
+
throw thenable.reason;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
throw thenable;
|
|
146
|
+
}
|
|
147
|
+
function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
|
|
148
|
+
var type = typeof children;
|
|
149
|
+
if ("undefined" === type || "boolean" === type) children = null;
|
|
150
|
+
var invokeCallback = false;
|
|
151
|
+
if (null === children) invokeCallback = true;
|
|
152
|
+
else
|
|
153
|
+
switch (type) {
|
|
154
|
+
case "bigint":
|
|
155
|
+
case "string":
|
|
156
|
+
case "number":
|
|
157
|
+
invokeCallback = true;
|
|
158
|
+
break;
|
|
159
|
+
case "object":
|
|
160
|
+
switch (children.$$typeof) {
|
|
161
|
+
case REACT_ELEMENT_TYPE:
|
|
162
|
+
case REACT_PORTAL_TYPE:
|
|
163
|
+
invokeCallback = true;
|
|
164
|
+
break;
|
|
165
|
+
case REACT_LAZY_TYPE:
|
|
166
|
+
return invokeCallback = children._init, mapIntoArray(
|
|
167
|
+
invokeCallback(children._payload),
|
|
168
|
+
array,
|
|
169
|
+
escapedPrefix,
|
|
170
|
+
nameSoFar,
|
|
171
|
+
callback
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (invokeCallback)
|
|
176
|
+
return callback = callback(children), invokeCallback = "" === nameSoFar ? "." + getElementKey(children, 0) : nameSoFar, isArrayImpl(callback) ? (escapedPrefix = "", null != invokeCallback && (escapedPrefix = invokeCallback.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
|
|
177
|
+
return c;
|
|
178
|
+
})) : null != callback && (isValidElement(callback) && (callback = cloneAndReplaceKey(
|
|
179
|
+
callback,
|
|
180
|
+
escapedPrefix + (null == callback.key || children && children.key === callback.key ? "" : ("" + callback.key).replace(
|
|
181
|
+
userProvidedKeyEscapeRegex,
|
|
182
|
+
"$&/"
|
|
183
|
+
) + "/") + invokeCallback
|
|
184
|
+
)), array.push(callback)), 1;
|
|
185
|
+
invokeCallback = 0;
|
|
186
|
+
var nextNamePrefix = "" === nameSoFar ? "." : nameSoFar + ":";
|
|
187
|
+
if (isArrayImpl(children))
|
|
188
|
+
for (var i = 0; i < children.length; i++)
|
|
189
|
+
nameSoFar = children[i], type = nextNamePrefix + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(
|
|
190
|
+
nameSoFar,
|
|
191
|
+
array,
|
|
192
|
+
escapedPrefix,
|
|
193
|
+
type,
|
|
194
|
+
callback
|
|
195
|
+
);
|
|
196
|
+
else if (i = getIteratorFn(children), "function" === typeof i)
|
|
197
|
+
for (children = i.call(children), i = 0; !(nameSoFar = children.next()).done; )
|
|
198
|
+
nameSoFar = nameSoFar.value, type = nextNamePrefix + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(
|
|
199
|
+
nameSoFar,
|
|
200
|
+
array,
|
|
201
|
+
escapedPrefix,
|
|
202
|
+
type,
|
|
203
|
+
callback
|
|
204
|
+
);
|
|
205
|
+
else if ("object" === type) {
|
|
206
|
+
if ("function" === typeof children.then)
|
|
207
|
+
return mapIntoArray(
|
|
208
|
+
resolveThenable(children),
|
|
209
|
+
array,
|
|
210
|
+
escapedPrefix,
|
|
211
|
+
nameSoFar,
|
|
212
|
+
callback
|
|
213
|
+
);
|
|
214
|
+
array = String(children);
|
|
215
|
+
throw Error(
|
|
216
|
+
"Objects are not valid as a React child (found: " + ("[object Object]" === array ? "object with keys {" + Object.keys(children).join(", ") + "}" : array) + "). If you meant to render a collection of children, use an array instead."
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
return invokeCallback;
|
|
220
|
+
}
|
|
221
|
+
function mapChildren(children, func, context) {
|
|
222
|
+
if (null == children) return children;
|
|
223
|
+
var result = [], count = 0;
|
|
224
|
+
mapIntoArray(children, result, "", "", function(child) {
|
|
225
|
+
return func.call(context, child, count++);
|
|
226
|
+
});
|
|
227
|
+
return result;
|
|
228
|
+
}
|
|
229
|
+
function lazyInitializer(payload) {
|
|
230
|
+
if (-1 === payload._status) {
|
|
231
|
+
var ctor = payload._result;
|
|
232
|
+
ctor = ctor();
|
|
233
|
+
ctor.then(
|
|
234
|
+
function(moduleObject) {
|
|
235
|
+
if (0 === payload._status || -1 === payload._status)
|
|
236
|
+
payload._status = 1, payload._result = moduleObject;
|
|
237
|
+
},
|
|
238
|
+
function(error) {
|
|
239
|
+
if (0 === payload._status || -1 === payload._status)
|
|
240
|
+
payload._status = 2, payload._result = error;
|
|
241
|
+
}
|
|
242
|
+
);
|
|
243
|
+
-1 === payload._status && (payload._status = 0, payload._result = ctor);
|
|
244
|
+
}
|
|
245
|
+
if (1 === payload._status) return payload._result.default;
|
|
246
|
+
throw payload._result;
|
|
247
|
+
}
|
|
248
|
+
var reportGlobalError = "function" === typeof reportError ? reportError : function(error) {
|
|
249
|
+
if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
|
|
250
|
+
var event = new window.ErrorEvent("error", {
|
|
251
|
+
bubbles: true,
|
|
252
|
+
cancelable: true,
|
|
253
|
+
message: "object" === typeof error && null !== error && "string" === typeof error.message ? String(error.message) : String(error),
|
|
254
|
+
error
|
|
255
|
+
});
|
|
256
|
+
if (!window.dispatchEvent(event)) return;
|
|
257
|
+
} else if ("object" === typeof process && "function" === typeof process.emit) {
|
|
258
|
+
process.emit("uncaughtException", error);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
console.error(error);
|
|
262
|
+
};
|
|
263
|
+
var Children = {
|
|
264
|
+
map: mapChildren,
|
|
265
|
+
forEach: function(children, forEachFunc, forEachContext) {
|
|
266
|
+
mapChildren(
|
|
267
|
+
children,
|
|
268
|
+
function() {
|
|
269
|
+
forEachFunc.apply(this, arguments);
|
|
270
|
+
},
|
|
271
|
+
forEachContext
|
|
272
|
+
);
|
|
273
|
+
},
|
|
274
|
+
count: function(children) {
|
|
275
|
+
var n = 0;
|
|
276
|
+
mapChildren(children, function() {
|
|
277
|
+
n++;
|
|
278
|
+
});
|
|
279
|
+
return n;
|
|
280
|
+
},
|
|
281
|
+
toArray: function(children) {
|
|
282
|
+
return mapChildren(children, function(child) {
|
|
283
|
+
return child;
|
|
284
|
+
}) || [];
|
|
285
|
+
},
|
|
286
|
+
only: function(children) {
|
|
287
|
+
if (!isValidElement(children))
|
|
288
|
+
throw Error(
|
|
289
|
+
"React.Children.only expected to receive a single React element child."
|
|
290
|
+
);
|
|
291
|
+
return children;
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
exports.Activity = REACT_ACTIVITY_TYPE;
|
|
295
|
+
exports.Children = Children;
|
|
296
|
+
exports.Component = Component;
|
|
297
|
+
exports.Fragment = REACT_FRAGMENT_TYPE;
|
|
298
|
+
exports.Profiler = REACT_PROFILER_TYPE;
|
|
299
|
+
exports.PureComponent = PureComponent;
|
|
300
|
+
exports.StrictMode = REACT_STRICT_MODE_TYPE;
|
|
301
|
+
exports.Suspense = REACT_SUSPENSE_TYPE;
|
|
302
|
+
exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
|
|
303
|
+
exports.__COMPILER_RUNTIME = {
|
|
304
|
+
__proto__: null,
|
|
305
|
+
c: function(size) {
|
|
306
|
+
return ReactSharedInternals.H.useMemoCache(size);
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
exports.cache = function(fn) {
|
|
310
|
+
return function() {
|
|
311
|
+
return fn.apply(null, arguments);
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
exports.cacheSignal = function() {
|
|
315
|
+
return null;
|
|
316
|
+
};
|
|
317
|
+
exports.cloneElement = function(element, config, children) {
|
|
318
|
+
if (null === element || void 0 === element)
|
|
319
|
+
throw Error(
|
|
320
|
+
"The argument must be a React element, but you passed " + element + "."
|
|
321
|
+
);
|
|
322
|
+
var props = assign({}, element.props), key = element.key;
|
|
323
|
+
if (null != config)
|
|
324
|
+
for (propName in void 0 !== config.key && (key = "" + config.key), config)
|
|
325
|
+
!hasOwnProperty.call(config, propName) || "key" === propName || "__self" === propName || "__source" === propName || "ref" === propName && void 0 === config.ref || (props[propName] = config[propName]);
|
|
326
|
+
var propName = arguments.length - 2;
|
|
327
|
+
if (1 === propName) props.children = children;
|
|
328
|
+
else if (1 < propName) {
|
|
329
|
+
for (var childArray = Array(propName), i = 0; i < propName; i++)
|
|
330
|
+
childArray[i] = arguments[i + 2];
|
|
331
|
+
props.children = childArray;
|
|
332
|
+
}
|
|
333
|
+
return ReactElement(element.type, key, props);
|
|
334
|
+
};
|
|
335
|
+
exports.createContext = function(defaultValue) {
|
|
336
|
+
defaultValue = {
|
|
337
|
+
$$typeof: REACT_CONTEXT_TYPE,
|
|
338
|
+
_currentValue: defaultValue,
|
|
339
|
+
_currentValue2: defaultValue,
|
|
340
|
+
_threadCount: 0,
|
|
341
|
+
Provider: null,
|
|
342
|
+
Consumer: null
|
|
343
|
+
};
|
|
344
|
+
defaultValue.Provider = defaultValue;
|
|
345
|
+
defaultValue.Consumer = {
|
|
346
|
+
$$typeof: REACT_CONSUMER_TYPE,
|
|
347
|
+
_context: defaultValue
|
|
348
|
+
};
|
|
349
|
+
return defaultValue;
|
|
350
|
+
};
|
|
351
|
+
exports.createElement = function(type, config, children) {
|
|
352
|
+
var propName, props = {}, key = null;
|
|
353
|
+
if (null != config)
|
|
354
|
+
for (propName in void 0 !== config.key && (key = "" + config.key), config)
|
|
355
|
+
hasOwnProperty.call(config, propName) && "key" !== propName && "__self" !== propName && "__source" !== propName && (props[propName] = config[propName]);
|
|
356
|
+
var childrenLength = arguments.length - 2;
|
|
357
|
+
if (1 === childrenLength) props.children = children;
|
|
358
|
+
else if (1 < childrenLength) {
|
|
359
|
+
for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++)
|
|
360
|
+
childArray[i] = arguments[i + 2];
|
|
361
|
+
props.children = childArray;
|
|
362
|
+
}
|
|
363
|
+
if (type && type.defaultProps)
|
|
364
|
+
for (propName in childrenLength = type.defaultProps, childrenLength)
|
|
365
|
+
void 0 === props[propName] && (props[propName] = childrenLength[propName]);
|
|
366
|
+
return ReactElement(type, key, props);
|
|
367
|
+
};
|
|
368
|
+
exports.createRef = function() {
|
|
369
|
+
return { current: null };
|
|
370
|
+
};
|
|
371
|
+
exports.forwardRef = function(render) {
|
|
372
|
+
return { $$typeof: REACT_FORWARD_REF_TYPE, render };
|
|
373
|
+
};
|
|
374
|
+
exports.isValidElement = isValidElement;
|
|
375
|
+
exports.lazy = function(ctor) {
|
|
376
|
+
return {
|
|
377
|
+
$$typeof: REACT_LAZY_TYPE,
|
|
378
|
+
_payload: { _status: -1, _result: ctor },
|
|
379
|
+
_init: lazyInitializer
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
exports.memo = function(type, compare) {
|
|
383
|
+
return {
|
|
384
|
+
$$typeof: REACT_MEMO_TYPE,
|
|
385
|
+
type,
|
|
386
|
+
compare: void 0 === compare ? null : compare
|
|
387
|
+
};
|
|
388
|
+
};
|
|
389
|
+
exports.startTransition = function(scope) {
|
|
390
|
+
var prevTransition = ReactSharedInternals.T, currentTransition = {};
|
|
391
|
+
ReactSharedInternals.T = currentTransition;
|
|
392
|
+
try {
|
|
393
|
+
var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
|
|
394
|
+
null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
|
|
395
|
+
"object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && returnValue.then(noop, reportGlobalError);
|
|
396
|
+
} catch (error) {
|
|
397
|
+
reportGlobalError(error);
|
|
398
|
+
} finally {
|
|
399
|
+
null !== prevTransition && null !== currentTransition.types && (prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
exports.unstable_useCacheRefresh = function() {
|
|
403
|
+
return ReactSharedInternals.H.useCacheRefresh();
|
|
404
|
+
};
|
|
405
|
+
exports.use = function(usable) {
|
|
406
|
+
return ReactSharedInternals.H.use(usable);
|
|
407
|
+
};
|
|
408
|
+
exports.useActionState = function(action, initialState, permalink) {
|
|
409
|
+
return ReactSharedInternals.H.useActionState(action, initialState, permalink);
|
|
410
|
+
};
|
|
411
|
+
exports.useCallback = function(callback, deps) {
|
|
412
|
+
return ReactSharedInternals.H.useCallback(callback, deps);
|
|
413
|
+
};
|
|
414
|
+
exports.useContext = function(Context) {
|
|
415
|
+
return ReactSharedInternals.H.useContext(Context);
|
|
416
|
+
};
|
|
417
|
+
exports.useDebugValue = function() {
|
|
418
|
+
};
|
|
419
|
+
exports.useDeferredValue = function(value2, initialValue) {
|
|
420
|
+
return ReactSharedInternals.H.useDeferredValue(value2, initialValue);
|
|
421
|
+
};
|
|
422
|
+
exports.useEffect = function(create2, deps) {
|
|
423
|
+
return ReactSharedInternals.H.useEffect(create2, deps);
|
|
424
|
+
};
|
|
425
|
+
exports.useEffectEvent = function(callback) {
|
|
426
|
+
return ReactSharedInternals.H.useEffectEvent(callback);
|
|
427
|
+
};
|
|
428
|
+
exports.useId = function() {
|
|
429
|
+
return ReactSharedInternals.H.useId();
|
|
430
|
+
};
|
|
431
|
+
exports.useImperativeHandle = function(ref, create2, deps) {
|
|
432
|
+
return ReactSharedInternals.H.useImperativeHandle(ref, create2, deps);
|
|
433
|
+
};
|
|
434
|
+
exports.useInsertionEffect = function(create2, deps) {
|
|
435
|
+
return ReactSharedInternals.H.useInsertionEffect(create2, deps);
|
|
436
|
+
};
|
|
437
|
+
exports.useLayoutEffect = function(create2, deps) {
|
|
438
|
+
return ReactSharedInternals.H.useLayoutEffect(create2, deps);
|
|
439
|
+
};
|
|
440
|
+
exports.useMemo = function(create2, deps) {
|
|
441
|
+
return ReactSharedInternals.H.useMemo(create2, deps);
|
|
442
|
+
};
|
|
443
|
+
exports.useOptimistic = function(passthrough, reducer) {
|
|
444
|
+
return ReactSharedInternals.H.useOptimistic(passthrough, reducer);
|
|
445
|
+
};
|
|
446
|
+
exports.useReducer = function(reducer, initialArg, init) {
|
|
447
|
+
return ReactSharedInternals.H.useReducer(reducer, initialArg, init);
|
|
448
|
+
};
|
|
449
|
+
exports.useRef = function(initialValue) {
|
|
450
|
+
return ReactSharedInternals.H.useRef(initialValue);
|
|
451
|
+
};
|
|
452
|
+
exports.useState = function(initialState) {
|
|
453
|
+
return ReactSharedInternals.H.useState(initialState);
|
|
454
|
+
};
|
|
455
|
+
exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
|
|
456
|
+
return ReactSharedInternals.H.useSyncExternalStore(
|
|
457
|
+
subscribe,
|
|
458
|
+
getSnapshot,
|
|
459
|
+
getServerSnapshot
|
|
460
|
+
);
|
|
461
|
+
};
|
|
462
|
+
exports.useTransition = function() {
|
|
463
|
+
return ReactSharedInternals.H.useTransition();
|
|
464
|
+
};
|
|
465
|
+
exports.version = "19.2.4";
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
// ../../node_modules/react/cjs/react.development.js
|
|
470
|
+
var require_react_development = __commonJS({
|
|
471
|
+
"../../node_modules/react/cjs/react.development.js"(exports, module) {
|
|
472
|
+
"use strict";
|
|
473
|
+
"production" !== process.env.NODE_ENV && (function() {
|
|
474
|
+
function defineDeprecationWarning(methodName, info) {
|
|
475
|
+
Object.defineProperty(Component.prototype, methodName, {
|
|
476
|
+
get: function() {
|
|
477
|
+
console.warn(
|
|
478
|
+
"%s(...) is deprecated in plain JavaScript React classes. %s",
|
|
479
|
+
info[0],
|
|
480
|
+
info[1]
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
function getIteratorFn(maybeIterable) {
|
|
486
|
+
if (null === maybeIterable || "object" !== typeof maybeIterable)
|
|
487
|
+
return null;
|
|
488
|
+
maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
|
|
489
|
+
return "function" === typeof maybeIterable ? maybeIterable : null;
|
|
490
|
+
}
|
|
491
|
+
function warnNoop(publicInstance, callerName) {
|
|
492
|
+
publicInstance = (publicInstance = publicInstance.constructor) && (publicInstance.displayName || publicInstance.name) || "ReactClass";
|
|
493
|
+
var warningKey = publicInstance + "." + callerName;
|
|
494
|
+
didWarnStateUpdateForUnmountedComponent[warningKey] || (console.error(
|
|
495
|
+
"Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",
|
|
496
|
+
callerName,
|
|
497
|
+
publicInstance
|
|
498
|
+
), didWarnStateUpdateForUnmountedComponent[warningKey] = true);
|
|
499
|
+
}
|
|
500
|
+
function Component(props, context, updater) {
|
|
501
|
+
this.props = props;
|
|
502
|
+
this.context = context;
|
|
503
|
+
this.refs = emptyObject;
|
|
504
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
505
|
+
}
|
|
506
|
+
function ComponentDummy() {
|
|
507
|
+
}
|
|
508
|
+
function PureComponent(props, context, updater) {
|
|
509
|
+
this.props = props;
|
|
510
|
+
this.context = context;
|
|
511
|
+
this.refs = emptyObject;
|
|
512
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
513
|
+
}
|
|
514
|
+
function noop() {
|
|
515
|
+
}
|
|
516
|
+
function testStringCoercion(value2) {
|
|
517
|
+
return "" + value2;
|
|
518
|
+
}
|
|
519
|
+
function checkKeyStringCoercion(value2) {
|
|
520
|
+
try {
|
|
521
|
+
testStringCoercion(value2);
|
|
522
|
+
var JSCompiler_inline_result = false;
|
|
523
|
+
} catch (e) {
|
|
524
|
+
JSCompiler_inline_result = true;
|
|
525
|
+
}
|
|
526
|
+
if (JSCompiler_inline_result) {
|
|
527
|
+
JSCompiler_inline_result = console;
|
|
528
|
+
var JSCompiler_temp_const = JSCompiler_inline_result.error;
|
|
529
|
+
var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value2[Symbol.toStringTag] || value2.constructor.name || "Object";
|
|
530
|
+
JSCompiler_temp_const.call(
|
|
531
|
+
JSCompiler_inline_result,
|
|
532
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
533
|
+
JSCompiler_inline_result$jscomp$0
|
|
534
|
+
);
|
|
535
|
+
return testStringCoercion(value2);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
function getComponentNameFromType(type) {
|
|
539
|
+
if (null == type) return null;
|
|
540
|
+
if ("function" === typeof type)
|
|
541
|
+
return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
|
|
542
|
+
if ("string" === typeof type) return type;
|
|
543
|
+
switch (type) {
|
|
544
|
+
case REACT_FRAGMENT_TYPE:
|
|
545
|
+
return "Fragment";
|
|
546
|
+
case REACT_PROFILER_TYPE:
|
|
547
|
+
return "Profiler";
|
|
548
|
+
case REACT_STRICT_MODE_TYPE:
|
|
549
|
+
return "StrictMode";
|
|
550
|
+
case REACT_SUSPENSE_TYPE:
|
|
551
|
+
return "Suspense";
|
|
552
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
553
|
+
return "SuspenseList";
|
|
554
|
+
case REACT_ACTIVITY_TYPE:
|
|
555
|
+
return "Activity";
|
|
556
|
+
}
|
|
557
|
+
if ("object" === typeof type)
|
|
558
|
+
switch ("number" === typeof type.tag && console.error(
|
|
559
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
560
|
+
), type.$$typeof) {
|
|
561
|
+
case REACT_PORTAL_TYPE:
|
|
562
|
+
return "Portal";
|
|
563
|
+
case REACT_CONTEXT_TYPE:
|
|
564
|
+
return type.displayName || "Context";
|
|
565
|
+
case REACT_CONSUMER_TYPE:
|
|
566
|
+
return (type._context.displayName || "Context") + ".Consumer";
|
|
567
|
+
case REACT_FORWARD_REF_TYPE:
|
|
568
|
+
var innerType = type.render;
|
|
569
|
+
type = type.displayName;
|
|
570
|
+
type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
|
|
571
|
+
return type;
|
|
572
|
+
case REACT_MEMO_TYPE:
|
|
573
|
+
return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
|
|
574
|
+
case REACT_LAZY_TYPE:
|
|
575
|
+
innerType = type._payload;
|
|
576
|
+
type = type._init;
|
|
577
|
+
try {
|
|
578
|
+
return getComponentNameFromType(type(innerType));
|
|
579
|
+
} catch (x) {
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
return null;
|
|
583
|
+
}
|
|
584
|
+
function getTaskName(type) {
|
|
585
|
+
if (type === REACT_FRAGMENT_TYPE) return "<>";
|
|
586
|
+
if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE)
|
|
587
|
+
return "<...>";
|
|
588
|
+
try {
|
|
589
|
+
var name = getComponentNameFromType(type);
|
|
590
|
+
return name ? "<" + name + ">" : "<...>";
|
|
591
|
+
} catch (x) {
|
|
592
|
+
return "<...>";
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
function getOwner() {
|
|
596
|
+
var dispatcher = ReactSharedInternals.A;
|
|
597
|
+
return null === dispatcher ? null : dispatcher.getOwner();
|
|
598
|
+
}
|
|
599
|
+
function UnknownOwner() {
|
|
600
|
+
return Error("react-stack-top-frame");
|
|
601
|
+
}
|
|
602
|
+
function hasValidKey(config) {
|
|
603
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
604
|
+
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
605
|
+
if (getter && getter.isReactWarning) return false;
|
|
606
|
+
}
|
|
607
|
+
return void 0 !== config.key;
|
|
608
|
+
}
|
|
609
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
610
|
+
function warnAboutAccessingKey() {
|
|
611
|
+
specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error(
|
|
612
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
613
|
+
displayName
|
|
614
|
+
));
|
|
615
|
+
}
|
|
616
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
617
|
+
Object.defineProperty(props, "key", {
|
|
618
|
+
get: warnAboutAccessingKey,
|
|
619
|
+
configurable: true
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
function elementRefGetterWithDeprecationWarning() {
|
|
623
|
+
var componentName = getComponentNameFromType(this.type);
|
|
624
|
+
didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error(
|
|
625
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
626
|
+
));
|
|
627
|
+
componentName = this.props.ref;
|
|
628
|
+
return void 0 !== componentName ? componentName : null;
|
|
629
|
+
}
|
|
630
|
+
function ReactElement(type, key, props, owner, debugStack, debugTask) {
|
|
631
|
+
var refProp = props.ref;
|
|
632
|
+
type = {
|
|
633
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
634
|
+
type,
|
|
635
|
+
key,
|
|
636
|
+
props,
|
|
637
|
+
_owner: owner
|
|
638
|
+
};
|
|
639
|
+
null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
|
|
640
|
+
enumerable: false,
|
|
641
|
+
get: elementRefGetterWithDeprecationWarning
|
|
642
|
+
}) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
|
|
643
|
+
type._store = {};
|
|
644
|
+
Object.defineProperty(type._store, "validated", {
|
|
645
|
+
configurable: false,
|
|
646
|
+
enumerable: false,
|
|
647
|
+
writable: true,
|
|
648
|
+
value: 0
|
|
649
|
+
});
|
|
650
|
+
Object.defineProperty(type, "_debugInfo", {
|
|
651
|
+
configurable: false,
|
|
652
|
+
enumerable: false,
|
|
653
|
+
writable: true,
|
|
654
|
+
value: null
|
|
655
|
+
});
|
|
656
|
+
Object.defineProperty(type, "_debugStack", {
|
|
657
|
+
configurable: false,
|
|
658
|
+
enumerable: false,
|
|
659
|
+
writable: true,
|
|
660
|
+
value: debugStack
|
|
661
|
+
});
|
|
662
|
+
Object.defineProperty(type, "_debugTask", {
|
|
663
|
+
configurable: false,
|
|
664
|
+
enumerable: false,
|
|
665
|
+
writable: true,
|
|
666
|
+
value: debugTask
|
|
667
|
+
});
|
|
668
|
+
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
|
|
669
|
+
return type;
|
|
670
|
+
}
|
|
671
|
+
function cloneAndReplaceKey(oldElement, newKey) {
|
|
672
|
+
newKey = ReactElement(
|
|
673
|
+
oldElement.type,
|
|
674
|
+
newKey,
|
|
675
|
+
oldElement.props,
|
|
676
|
+
oldElement._owner,
|
|
677
|
+
oldElement._debugStack,
|
|
678
|
+
oldElement._debugTask
|
|
679
|
+
);
|
|
680
|
+
oldElement._store && (newKey._store.validated = oldElement._store.validated);
|
|
681
|
+
return newKey;
|
|
682
|
+
}
|
|
683
|
+
function validateChildKeys(node) {
|
|
684
|
+
isValidElement(node) ? node._store && (node._store.validated = 1) : "object" === typeof node && null !== node && node.$$typeof === REACT_LAZY_TYPE && ("fulfilled" === node._payload.status ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
|
|
685
|
+
}
|
|
686
|
+
function isValidElement(object) {
|
|
687
|
+
return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
688
|
+
}
|
|
689
|
+
function escape(key) {
|
|
690
|
+
var escaperLookup = { "=": "=0", ":": "=2" };
|
|
691
|
+
return "$" + key.replace(/[=:]/g, function(match) {
|
|
692
|
+
return escaperLookup[match];
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
function getElementKey(element, index) {
|
|
696
|
+
return "object" === typeof element && null !== element && null != element.key ? (checkKeyStringCoercion(element.key), escape("" + element.key)) : index.toString(36);
|
|
697
|
+
}
|
|
698
|
+
function resolveThenable(thenable) {
|
|
699
|
+
switch (thenable.status) {
|
|
700
|
+
case "fulfilled":
|
|
701
|
+
return thenable.value;
|
|
702
|
+
case "rejected":
|
|
703
|
+
throw thenable.reason;
|
|
704
|
+
default:
|
|
705
|
+
switch ("string" === typeof thenable.status ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(
|
|
706
|
+
function(fulfilledValue) {
|
|
707
|
+
"pending" === thenable.status && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
|
|
708
|
+
},
|
|
709
|
+
function(error) {
|
|
710
|
+
"pending" === thenable.status && (thenable.status = "rejected", thenable.reason = error);
|
|
711
|
+
}
|
|
712
|
+
)), thenable.status) {
|
|
713
|
+
case "fulfilled":
|
|
714
|
+
return thenable.value;
|
|
715
|
+
case "rejected":
|
|
716
|
+
throw thenable.reason;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
throw thenable;
|
|
720
|
+
}
|
|
721
|
+
function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
|
|
722
|
+
var type = typeof children;
|
|
723
|
+
if ("undefined" === type || "boolean" === type) children = null;
|
|
724
|
+
var invokeCallback = false;
|
|
725
|
+
if (null === children) invokeCallback = true;
|
|
726
|
+
else
|
|
727
|
+
switch (type) {
|
|
728
|
+
case "bigint":
|
|
729
|
+
case "string":
|
|
730
|
+
case "number":
|
|
731
|
+
invokeCallback = true;
|
|
732
|
+
break;
|
|
733
|
+
case "object":
|
|
734
|
+
switch (children.$$typeof) {
|
|
735
|
+
case REACT_ELEMENT_TYPE:
|
|
736
|
+
case REACT_PORTAL_TYPE:
|
|
737
|
+
invokeCallback = true;
|
|
738
|
+
break;
|
|
739
|
+
case REACT_LAZY_TYPE:
|
|
740
|
+
return invokeCallback = children._init, mapIntoArray(
|
|
741
|
+
invokeCallback(children._payload),
|
|
742
|
+
array,
|
|
743
|
+
escapedPrefix,
|
|
744
|
+
nameSoFar,
|
|
745
|
+
callback
|
|
746
|
+
);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
if (invokeCallback) {
|
|
750
|
+
invokeCallback = children;
|
|
751
|
+
callback = callback(invokeCallback);
|
|
752
|
+
var childKey = "" === nameSoFar ? "." + getElementKey(invokeCallback, 0) : nameSoFar;
|
|
753
|
+
isArrayImpl(callback) ? (escapedPrefix = "", null != childKey && (escapedPrefix = childKey.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
|
|
754
|
+
return c;
|
|
755
|
+
})) : null != callback && (isValidElement(callback) && (null != callback.key && (invokeCallback && invokeCallback.key === callback.key || checkKeyStringCoercion(callback.key)), escapedPrefix = cloneAndReplaceKey(
|
|
756
|
+
callback,
|
|
757
|
+
escapedPrefix + (null == callback.key || invokeCallback && invokeCallback.key === callback.key ? "" : ("" + callback.key).replace(
|
|
758
|
+
userProvidedKeyEscapeRegex,
|
|
759
|
+
"$&/"
|
|
760
|
+
) + "/") + childKey
|
|
761
|
+
), "" !== nameSoFar && null != invokeCallback && isValidElement(invokeCallback) && null == invokeCallback.key && invokeCallback._store && !invokeCallback._store.validated && (escapedPrefix._store.validated = 2), callback = escapedPrefix), array.push(callback));
|
|
762
|
+
return 1;
|
|
763
|
+
}
|
|
764
|
+
invokeCallback = 0;
|
|
765
|
+
childKey = "" === nameSoFar ? "." : nameSoFar + ":";
|
|
766
|
+
if (isArrayImpl(children))
|
|
767
|
+
for (var i = 0; i < children.length; i++)
|
|
768
|
+
nameSoFar = children[i], type = childKey + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(
|
|
769
|
+
nameSoFar,
|
|
770
|
+
array,
|
|
771
|
+
escapedPrefix,
|
|
772
|
+
type,
|
|
773
|
+
callback
|
|
774
|
+
);
|
|
775
|
+
else if (i = getIteratorFn(children), "function" === typeof i)
|
|
776
|
+
for (i === children.entries && (didWarnAboutMaps || console.warn(
|
|
777
|
+
"Using Maps as children is not supported. Use an array of keyed ReactElements instead."
|
|
778
|
+
), didWarnAboutMaps = true), children = i.call(children), i = 0; !(nameSoFar = children.next()).done; )
|
|
779
|
+
nameSoFar = nameSoFar.value, type = childKey + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(
|
|
780
|
+
nameSoFar,
|
|
781
|
+
array,
|
|
782
|
+
escapedPrefix,
|
|
783
|
+
type,
|
|
784
|
+
callback
|
|
785
|
+
);
|
|
786
|
+
else if ("object" === type) {
|
|
787
|
+
if ("function" === typeof children.then)
|
|
788
|
+
return mapIntoArray(
|
|
789
|
+
resolveThenable(children),
|
|
790
|
+
array,
|
|
791
|
+
escapedPrefix,
|
|
792
|
+
nameSoFar,
|
|
793
|
+
callback
|
|
794
|
+
);
|
|
795
|
+
array = String(children);
|
|
796
|
+
throw Error(
|
|
797
|
+
"Objects are not valid as a React child (found: " + ("[object Object]" === array ? "object with keys {" + Object.keys(children).join(", ") + "}" : array) + "). If you meant to render a collection of children, use an array instead."
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
return invokeCallback;
|
|
801
|
+
}
|
|
802
|
+
function mapChildren(children, func, context) {
|
|
803
|
+
if (null == children) return children;
|
|
804
|
+
var result = [], count = 0;
|
|
805
|
+
mapIntoArray(children, result, "", "", function(child) {
|
|
806
|
+
return func.call(context, child, count++);
|
|
807
|
+
});
|
|
808
|
+
return result;
|
|
809
|
+
}
|
|
810
|
+
function lazyInitializer(payload) {
|
|
811
|
+
if (-1 === payload._status) {
|
|
812
|
+
var ioInfo = payload._ioInfo;
|
|
813
|
+
null != ioInfo && (ioInfo.start = ioInfo.end = performance.now());
|
|
814
|
+
ioInfo = payload._result;
|
|
815
|
+
var thenable = ioInfo();
|
|
816
|
+
thenable.then(
|
|
817
|
+
function(moduleObject) {
|
|
818
|
+
if (0 === payload._status || -1 === payload._status) {
|
|
819
|
+
payload._status = 1;
|
|
820
|
+
payload._result = moduleObject;
|
|
821
|
+
var _ioInfo = payload._ioInfo;
|
|
822
|
+
null != _ioInfo && (_ioInfo.end = performance.now());
|
|
823
|
+
void 0 === thenable.status && (thenable.status = "fulfilled", thenable.value = moduleObject);
|
|
824
|
+
}
|
|
825
|
+
},
|
|
826
|
+
function(error) {
|
|
827
|
+
if (0 === payload._status || -1 === payload._status) {
|
|
828
|
+
payload._status = 2;
|
|
829
|
+
payload._result = error;
|
|
830
|
+
var _ioInfo2 = payload._ioInfo;
|
|
831
|
+
null != _ioInfo2 && (_ioInfo2.end = performance.now());
|
|
832
|
+
void 0 === thenable.status && (thenable.status = "rejected", thenable.reason = error);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
);
|
|
836
|
+
ioInfo = payload._ioInfo;
|
|
837
|
+
if (null != ioInfo) {
|
|
838
|
+
ioInfo.value = thenable;
|
|
839
|
+
var displayName = thenable.displayName;
|
|
840
|
+
"string" === typeof displayName && (ioInfo.name = displayName);
|
|
841
|
+
}
|
|
842
|
+
-1 === payload._status && (payload._status = 0, payload._result = thenable);
|
|
843
|
+
}
|
|
844
|
+
if (1 === payload._status)
|
|
845
|
+
return ioInfo = payload._result, void 0 === ioInfo && console.error(
|
|
846
|
+
"lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))\n\nDid you accidentally put curly braces around the import?",
|
|
847
|
+
ioInfo
|
|
848
|
+
), "default" in ioInfo || console.error(
|
|
849
|
+
"lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))",
|
|
850
|
+
ioInfo
|
|
851
|
+
), ioInfo.default;
|
|
852
|
+
throw payload._result;
|
|
853
|
+
}
|
|
854
|
+
function resolveDispatcher() {
|
|
855
|
+
var dispatcher = ReactSharedInternals.H;
|
|
856
|
+
null === dispatcher && console.error(
|
|
857
|
+
"Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."
|
|
858
|
+
);
|
|
859
|
+
return dispatcher;
|
|
860
|
+
}
|
|
861
|
+
function releaseAsyncTransition() {
|
|
862
|
+
ReactSharedInternals.asyncTransitions--;
|
|
863
|
+
}
|
|
864
|
+
function enqueueTask(task) {
|
|
865
|
+
if (null === enqueueTaskImpl)
|
|
866
|
+
try {
|
|
867
|
+
var requireString = ("require" + Math.random()).slice(0, 7);
|
|
868
|
+
enqueueTaskImpl = (module && module[requireString]).call(
|
|
869
|
+
module,
|
|
870
|
+
"timers"
|
|
871
|
+
).setImmediate;
|
|
872
|
+
} catch (_err) {
|
|
873
|
+
enqueueTaskImpl = function(callback) {
|
|
874
|
+
false === didWarnAboutMessageChannel && (didWarnAboutMessageChannel = true, "undefined" === typeof MessageChannel && console.error(
|
|
875
|
+
"This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."
|
|
876
|
+
));
|
|
877
|
+
var channel = new MessageChannel();
|
|
878
|
+
channel.port1.onmessage = callback;
|
|
879
|
+
channel.port2.postMessage(void 0);
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
return enqueueTaskImpl(task);
|
|
883
|
+
}
|
|
884
|
+
function aggregateErrors(errors) {
|
|
885
|
+
return 1 < errors.length && "function" === typeof AggregateError ? new AggregateError(errors) : errors[0];
|
|
886
|
+
}
|
|
887
|
+
function popActScope(prevActQueue, prevActScopeDepth) {
|
|
888
|
+
prevActScopeDepth !== actScopeDepth - 1 && console.error(
|
|
889
|
+
"You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "
|
|
890
|
+
);
|
|
891
|
+
actScopeDepth = prevActScopeDepth;
|
|
892
|
+
}
|
|
893
|
+
function recursivelyFlushAsyncActWork(returnValue, resolve3, reject) {
|
|
894
|
+
var queue = ReactSharedInternals.actQueue;
|
|
895
|
+
if (null !== queue)
|
|
896
|
+
if (0 !== queue.length)
|
|
897
|
+
try {
|
|
898
|
+
flushActQueue(queue);
|
|
899
|
+
enqueueTask(function() {
|
|
900
|
+
return recursivelyFlushAsyncActWork(returnValue, resolve3, reject);
|
|
901
|
+
});
|
|
902
|
+
return;
|
|
903
|
+
} catch (error) {
|
|
904
|
+
ReactSharedInternals.thrownErrors.push(error);
|
|
905
|
+
}
|
|
906
|
+
else ReactSharedInternals.actQueue = null;
|
|
907
|
+
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve3(returnValue);
|
|
908
|
+
}
|
|
909
|
+
function flushActQueue(queue) {
|
|
910
|
+
if (!isFlushing) {
|
|
911
|
+
isFlushing = true;
|
|
912
|
+
var i = 0;
|
|
913
|
+
try {
|
|
914
|
+
for (; i < queue.length; i++) {
|
|
915
|
+
var callback = queue[i];
|
|
916
|
+
do {
|
|
917
|
+
ReactSharedInternals.didUsePromise = false;
|
|
918
|
+
var continuation = callback(false);
|
|
919
|
+
if (null !== continuation) {
|
|
920
|
+
if (ReactSharedInternals.didUsePromise) {
|
|
921
|
+
queue[i] = callback;
|
|
922
|
+
queue.splice(0, i);
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
callback = continuation;
|
|
926
|
+
} else break;
|
|
927
|
+
} while (1);
|
|
928
|
+
}
|
|
929
|
+
queue.length = 0;
|
|
930
|
+
} catch (error) {
|
|
931
|
+
queue.splice(0, i + 1), ReactSharedInternals.thrownErrors.push(error);
|
|
932
|
+
} finally {
|
|
933
|
+
isFlushing = false;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
938
|
+
var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo"), REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = /* @__PURE__ */ Symbol.for("react.activity"), MAYBE_ITERATOR_SYMBOL = Symbol.iterator, didWarnStateUpdateForUnmountedComponent = {}, ReactNoopUpdateQueue = {
|
|
939
|
+
isMounted: function() {
|
|
940
|
+
return false;
|
|
941
|
+
},
|
|
942
|
+
enqueueForceUpdate: function(publicInstance) {
|
|
943
|
+
warnNoop(publicInstance, "forceUpdate");
|
|
944
|
+
},
|
|
945
|
+
enqueueReplaceState: function(publicInstance) {
|
|
946
|
+
warnNoop(publicInstance, "replaceState");
|
|
947
|
+
},
|
|
948
|
+
enqueueSetState: function(publicInstance) {
|
|
949
|
+
warnNoop(publicInstance, "setState");
|
|
950
|
+
}
|
|
951
|
+
}, assign = Object.assign, emptyObject = {};
|
|
952
|
+
Object.freeze(emptyObject);
|
|
953
|
+
Component.prototype.isReactComponent = {};
|
|
954
|
+
Component.prototype.setState = function(partialState, callback) {
|
|
955
|
+
if ("object" !== typeof partialState && "function" !== typeof partialState && null != partialState)
|
|
956
|
+
throw Error(
|
|
957
|
+
"takes an object of state variables to update or a function which returns an object of state variables."
|
|
958
|
+
);
|
|
959
|
+
this.updater.enqueueSetState(this, partialState, callback, "setState");
|
|
960
|
+
};
|
|
961
|
+
Component.prototype.forceUpdate = function(callback) {
|
|
962
|
+
this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
|
|
963
|
+
};
|
|
964
|
+
var deprecatedAPIs = {
|
|
965
|
+
isMounted: [
|
|
966
|
+
"isMounted",
|
|
967
|
+
"Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
|
|
968
|
+
],
|
|
969
|
+
replaceState: [
|
|
970
|
+
"replaceState",
|
|
971
|
+
"Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
|
|
972
|
+
]
|
|
973
|
+
};
|
|
974
|
+
for (fnName in deprecatedAPIs)
|
|
975
|
+
deprecatedAPIs.hasOwnProperty(fnName) && defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
|
976
|
+
ComponentDummy.prototype = Component.prototype;
|
|
977
|
+
deprecatedAPIs = PureComponent.prototype = new ComponentDummy();
|
|
978
|
+
deprecatedAPIs.constructor = PureComponent;
|
|
979
|
+
assign(deprecatedAPIs, Component.prototype);
|
|
980
|
+
deprecatedAPIs.isPureReactComponent = true;
|
|
981
|
+
var isArrayImpl = Array.isArray, REACT_CLIENT_REFERENCE = /* @__PURE__ */ Symbol.for("react.client.reference"), ReactSharedInternals = {
|
|
982
|
+
H: null,
|
|
983
|
+
A: null,
|
|
984
|
+
T: null,
|
|
985
|
+
S: null,
|
|
986
|
+
actQueue: null,
|
|
987
|
+
asyncTransitions: 0,
|
|
988
|
+
isBatchingLegacy: false,
|
|
989
|
+
didScheduleLegacyUpdate: false,
|
|
990
|
+
didUsePromise: false,
|
|
991
|
+
thrownErrors: [],
|
|
992
|
+
getCurrentStack: null,
|
|
993
|
+
recentlyCreatedOwnerStacks: 0
|
|
994
|
+
}, hasOwnProperty = Object.prototype.hasOwnProperty, createTask = console.createTask ? console.createTask : function() {
|
|
995
|
+
return null;
|
|
996
|
+
};
|
|
997
|
+
deprecatedAPIs = {
|
|
998
|
+
react_stack_bottom_frame: function(callStackForError) {
|
|
999
|
+
return callStackForError();
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
var specialPropKeyWarningShown, didWarnAboutOldJSXRuntime;
|
|
1003
|
+
var didWarnAboutElementRef = {};
|
|
1004
|
+
var unknownOwnerDebugStack = deprecatedAPIs.react_stack_bottom_frame.bind(
|
|
1005
|
+
deprecatedAPIs,
|
|
1006
|
+
UnknownOwner
|
|
1007
|
+
)();
|
|
1008
|
+
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
1009
|
+
var didWarnAboutMaps = false, userProvidedKeyEscapeRegex = /\/+/g, reportGlobalError = "function" === typeof reportError ? reportError : function(error) {
|
|
1010
|
+
if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
|
|
1011
|
+
var event = new window.ErrorEvent("error", {
|
|
1012
|
+
bubbles: true,
|
|
1013
|
+
cancelable: true,
|
|
1014
|
+
message: "object" === typeof error && null !== error && "string" === typeof error.message ? String(error.message) : String(error),
|
|
1015
|
+
error
|
|
1016
|
+
});
|
|
1017
|
+
if (!window.dispatchEvent(event)) return;
|
|
1018
|
+
} else if ("object" === typeof process && "function" === typeof process.emit) {
|
|
1019
|
+
process.emit("uncaughtException", error);
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
console.error(error);
|
|
1023
|
+
}, didWarnAboutMessageChannel = false, enqueueTaskImpl = null, actScopeDepth = 0, didWarnNoAwaitAct = false, isFlushing = false, queueSeveralMicrotasks = "function" === typeof queueMicrotask ? function(callback) {
|
|
1024
|
+
queueMicrotask(function() {
|
|
1025
|
+
return queueMicrotask(callback);
|
|
1026
|
+
});
|
|
1027
|
+
} : enqueueTask;
|
|
1028
|
+
deprecatedAPIs = Object.freeze({
|
|
1029
|
+
__proto__: null,
|
|
1030
|
+
c: function(size) {
|
|
1031
|
+
return resolveDispatcher().useMemoCache(size);
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
1034
|
+
var fnName = {
|
|
1035
|
+
map: mapChildren,
|
|
1036
|
+
forEach: function(children, forEachFunc, forEachContext) {
|
|
1037
|
+
mapChildren(
|
|
1038
|
+
children,
|
|
1039
|
+
function() {
|
|
1040
|
+
forEachFunc.apply(this, arguments);
|
|
1041
|
+
},
|
|
1042
|
+
forEachContext
|
|
1043
|
+
);
|
|
1044
|
+
},
|
|
1045
|
+
count: function(children) {
|
|
1046
|
+
var n = 0;
|
|
1047
|
+
mapChildren(children, function() {
|
|
1048
|
+
n++;
|
|
1049
|
+
});
|
|
1050
|
+
return n;
|
|
1051
|
+
},
|
|
1052
|
+
toArray: function(children) {
|
|
1053
|
+
return mapChildren(children, function(child) {
|
|
1054
|
+
return child;
|
|
1055
|
+
}) || [];
|
|
1056
|
+
},
|
|
1057
|
+
only: function(children) {
|
|
1058
|
+
if (!isValidElement(children))
|
|
1059
|
+
throw Error(
|
|
1060
|
+
"React.Children.only expected to receive a single React element child."
|
|
1061
|
+
);
|
|
1062
|
+
return children;
|
|
1063
|
+
}
|
|
1064
|
+
};
|
|
1065
|
+
exports.Activity = REACT_ACTIVITY_TYPE;
|
|
1066
|
+
exports.Children = fnName;
|
|
1067
|
+
exports.Component = Component;
|
|
1068
|
+
exports.Fragment = REACT_FRAGMENT_TYPE;
|
|
1069
|
+
exports.Profiler = REACT_PROFILER_TYPE;
|
|
1070
|
+
exports.PureComponent = PureComponent;
|
|
1071
|
+
exports.StrictMode = REACT_STRICT_MODE_TYPE;
|
|
1072
|
+
exports.Suspense = REACT_SUSPENSE_TYPE;
|
|
1073
|
+
exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
|
|
1074
|
+
exports.__COMPILER_RUNTIME = deprecatedAPIs;
|
|
1075
|
+
exports.act = function(callback) {
|
|
1076
|
+
var prevActQueue = ReactSharedInternals.actQueue, prevActScopeDepth = actScopeDepth;
|
|
1077
|
+
actScopeDepth++;
|
|
1078
|
+
var queue = ReactSharedInternals.actQueue = null !== prevActQueue ? prevActQueue : [], didAwaitActCall = false;
|
|
1079
|
+
try {
|
|
1080
|
+
var result = callback();
|
|
1081
|
+
} catch (error) {
|
|
1082
|
+
ReactSharedInternals.thrownErrors.push(error);
|
|
1083
|
+
}
|
|
1084
|
+
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
1085
|
+
throw popActScope(prevActQueue, prevActScopeDepth), callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
|
1086
|
+
if (null !== result && "object" === typeof result && "function" === typeof result.then) {
|
|
1087
|
+
var thenable = result;
|
|
1088
|
+
queueSeveralMicrotasks(function() {
|
|
1089
|
+
didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error(
|
|
1090
|
+
"You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"
|
|
1091
|
+
));
|
|
1092
|
+
});
|
|
1093
|
+
return {
|
|
1094
|
+
then: function(resolve3, reject) {
|
|
1095
|
+
didAwaitActCall = true;
|
|
1096
|
+
thenable.then(
|
|
1097
|
+
function(returnValue) {
|
|
1098
|
+
popActScope(prevActQueue, prevActScopeDepth);
|
|
1099
|
+
if (0 === prevActScopeDepth) {
|
|
1100
|
+
try {
|
|
1101
|
+
flushActQueue(queue), enqueueTask(function() {
|
|
1102
|
+
return recursivelyFlushAsyncActWork(
|
|
1103
|
+
returnValue,
|
|
1104
|
+
resolve3,
|
|
1105
|
+
reject
|
|
1106
|
+
);
|
|
1107
|
+
});
|
|
1108
|
+
} catch (error$0) {
|
|
1109
|
+
ReactSharedInternals.thrownErrors.push(error$0);
|
|
1110
|
+
}
|
|
1111
|
+
if (0 < ReactSharedInternals.thrownErrors.length) {
|
|
1112
|
+
var _thrownError = aggregateErrors(
|
|
1113
|
+
ReactSharedInternals.thrownErrors
|
|
1114
|
+
);
|
|
1115
|
+
ReactSharedInternals.thrownErrors.length = 0;
|
|
1116
|
+
reject(_thrownError);
|
|
1117
|
+
}
|
|
1118
|
+
} else resolve3(returnValue);
|
|
1119
|
+
},
|
|
1120
|
+
function(error) {
|
|
1121
|
+
popActScope(prevActQueue, prevActScopeDepth);
|
|
1122
|
+
0 < ReactSharedInternals.thrownErrors.length ? (error = aggregateErrors(
|
|
1123
|
+
ReactSharedInternals.thrownErrors
|
|
1124
|
+
), ReactSharedInternals.thrownErrors.length = 0, reject(error)) : reject(error);
|
|
1125
|
+
}
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
var returnValue$jscomp$0 = result;
|
|
1131
|
+
popActScope(prevActQueue, prevActScopeDepth);
|
|
1132
|
+
0 === prevActScopeDepth && (flushActQueue(queue), 0 !== queue.length && queueSeveralMicrotasks(function() {
|
|
1133
|
+
didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error(
|
|
1134
|
+
"A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"
|
|
1135
|
+
));
|
|
1136
|
+
}), ReactSharedInternals.actQueue = null);
|
|
1137
|
+
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
1138
|
+
throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
|
1139
|
+
return {
|
|
1140
|
+
then: function(resolve3, reject) {
|
|
1141
|
+
didAwaitActCall = true;
|
|
1142
|
+
0 === prevActScopeDepth ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
|
|
1143
|
+
return recursivelyFlushAsyncActWork(
|
|
1144
|
+
returnValue$jscomp$0,
|
|
1145
|
+
resolve3,
|
|
1146
|
+
reject
|
|
1147
|
+
);
|
|
1148
|
+
})) : resolve3(returnValue$jscomp$0);
|
|
1149
|
+
}
|
|
1150
|
+
};
|
|
1151
|
+
};
|
|
1152
|
+
exports.cache = function(fn) {
|
|
1153
|
+
return function() {
|
|
1154
|
+
return fn.apply(null, arguments);
|
|
1155
|
+
};
|
|
1156
|
+
};
|
|
1157
|
+
exports.cacheSignal = function() {
|
|
1158
|
+
return null;
|
|
1159
|
+
};
|
|
1160
|
+
exports.captureOwnerStack = function() {
|
|
1161
|
+
var getCurrentStack = ReactSharedInternals.getCurrentStack;
|
|
1162
|
+
return null === getCurrentStack ? null : getCurrentStack();
|
|
1163
|
+
};
|
|
1164
|
+
exports.cloneElement = function(element, config, children) {
|
|
1165
|
+
if (null === element || void 0 === element)
|
|
1166
|
+
throw Error(
|
|
1167
|
+
"The argument must be a React element, but you passed " + element + "."
|
|
1168
|
+
);
|
|
1169
|
+
var props = assign({}, element.props), key = element.key, owner = element._owner;
|
|
1170
|
+
if (null != config) {
|
|
1171
|
+
var JSCompiler_inline_result;
|
|
1172
|
+
a: {
|
|
1173
|
+
if (hasOwnProperty.call(config, "ref") && (JSCompiler_inline_result = Object.getOwnPropertyDescriptor(
|
|
1174
|
+
config,
|
|
1175
|
+
"ref"
|
|
1176
|
+
).get) && JSCompiler_inline_result.isReactWarning) {
|
|
1177
|
+
JSCompiler_inline_result = false;
|
|
1178
|
+
break a;
|
|
1179
|
+
}
|
|
1180
|
+
JSCompiler_inline_result = void 0 !== config.ref;
|
|
1181
|
+
}
|
|
1182
|
+
JSCompiler_inline_result && (owner = getOwner());
|
|
1183
|
+
hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key);
|
|
1184
|
+
for (propName in config)
|
|
1185
|
+
!hasOwnProperty.call(config, propName) || "key" === propName || "__self" === propName || "__source" === propName || "ref" === propName && void 0 === config.ref || (props[propName] = config[propName]);
|
|
1186
|
+
}
|
|
1187
|
+
var propName = arguments.length - 2;
|
|
1188
|
+
if (1 === propName) props.children = children;
|
|
1189
|
+
else if (1 < propName) {
|
|
1190
|
+
JSCompiler_inline_result = Array(propName);
|
|
1191
|
+
for (var i = 0; i < propName; i++)
|
|
1192
|
+
JSCompiler_inline_result[i] = arguments[i + 2];
|
|
1193
|
+
props.children = JSCompiler_inline_result;
|
|
1194
|
+
}
|
|
1195
|
+
props = ReactElement(
|
|
1196
|
+
element.type,
|
|
1197
|
+
key,
|
|
1198
|
+
props,
|
|
1199
|
+
owner,
|
|
1200
|
+
element._debugStack,
|
|
1201
|
+
element._debugTask
|
|
1202
|
+
);
|
|
1203
|
+
for (key = 2; key < arguments.length; key++)
|
|
1204
|
+
validateChildKeys(arguments[key]);
|
|
1205
|
+
return props;
|
|
1206
|
+
};
|
|
1207
|
+
exports.createContext = function(defaultValue) {
|
|
1208
|
+
defaultValue = {
|
|
1209
|
+
$$typeof: REACT_CONTEXT_TYPE,
|
|
1210
|
+
_currentValue: defaultValue,
|
|
1211
|
+
_currentValue2: defaultValue,
|
|
1212
|
+
_threadCount: 0,
|
|
1213
|
+
Provider: null,
|
|
1214
|
+
Consumer: null
|
|
1215
|
+
};
|
|
1216
|
+
defaultValue.Provider = defaultValue;
|
|
1217
|
+
defaultValue.Consumer = {
|
|
1218
|
+
$$typeof: REACT_CONSUMER_TYPE,
|
|
1219
|
+
_context: defaultValue
|
|
1220
|
+
};
|
|
1221
|
+
defaultValue._currentRenderer = null;
|
|
1222
|
+
defaultValue._currentRenderer2 = null;
|
|
1223
|
+
return defaultValue;
|
|
1224
|
+
};
|
|
1225
|
+
exports.createElement = function(type, config, children) {
|
|
1226
|
+
for (var i = 2; i < arguments.length; i++)
|
|
1227
|
+
validateChildKeys(arguments[i]);
|
|
1228
|
+
i = {};
|
|
1229
|
+
var key = null;
|
|
1230
|
+
if (null != config)
|
|
1231
|
+
for (propName in didWarnAboutOldJSXRuntime || !("__self" in config) || "key" in config || (didWarnAboutOldJSXRuntime = true, console.warn(
|
|
1232
|
+
"Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform"
|
|
1233
|
+
)), hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key), config)
|
|
1234
|
+
hasOwnProperty.call(config, propName) && "key" !== propName && "__self" !== propName && "__source" !== propName && (i[propName] = config[propName]);
|
|
1235
|
+
var childrenLength = arguments.length - 2;
|
|
1236
|
+
if (1 === childrenLength) i.children = children;
|
|
1237
|
+
else if (1 < childrenLength) {
|
|
1238
|
+
for (var childArray = Array(childrenLength), _i = 0; _i < childrenLength; _i++)
|
|
1239
|
+
childArray[_i] = arguments[_i + 2];
|
|
1240
|
+
Object.freeze && Object.freeze(childArray);
|
|
1241
|
+
i.children = childArray;
|
|
1242
|
+
}
|
|
1243
|
+
if (type && type.defaultProps)
|
|
1244
|
+
for (propName in childrenLength = type.defaultProps, childrenLength)
|
|
1245
|
+
void 0 === i[propName] && (i[propName] = childrenLength[propName]);
|
|
1246
|
+
key && defineKeyPropWarningGetter(
|
|
1247
|
+
i,
|
|
1248
|
+
"function" === typeof type ? type.displayName || type.name || "Unknown" : type
|
|
1249
|
+
);
|
|
1250
|
+
var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
1251
|
+
return ReactElement(
|
|
1252
|
+
type,
|
|
1253
|
+
key,
|
|
1254
|
+
i,
|
|
1255
|
+
getOwner(),
|
|
1256
|
+
propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
|
|
1257
|
+
propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
1258
|
+
);
|
|
1259
|
+
};
|
|
1260
|
+
exports.createRef = function() {
|
|
1261
|
+
var refObject = { current: null };
|
|
1262
|
+
Object.seal(refObject);
|
|
1263
|
+
return refObject;
|
|
1264
|
+
};
|
|
1265
|
+
exports.forwardRef = function(render) {
|
|
1266
|
+
null != render && render.$$typeof === REACT_MEMO_TYPE ? console.error(
|
|
1267
|
+
"forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."
|
|
1268
|
+
) : "function" !== typeof render ? console.error(
|
|
1269
|
+
"forwardRef requires a render function but was given %s.",
|
|
1270
|
+
null === render ? "null" : typeof render
|
|
1271
|
+
) : 0 !== render.length && 2 !== render.length && console.error(
|
|
1272
|
+
"forwardRef render functions accept exactly two parameters: props and ref. %s",
|
|
1273
|
+
1 === render.length ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined."
|
|
1274
|
+
);
|
|
1275
|
+
null != render && null != render.defaultProps && console.error(
|
|
1276
|
+
"forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?"
|
|
1277
|
+
);
|
|
1278
|
+
var elementType = { $$typeof: REACT_FORWARD_REF_TYPE, render }, ownName;
|
|
1279
|
+
Object.defineProperty(elementType, "displayName", {
|
|
1280
|
+
enumerable: false,
|
|
1281
|
+
configurable: true,
|
|
1282
|
+
get: function() {
|
|
1283
|
+
return ownName;
|
|
1284
|
+
},
|
|
1285
|
+
set: function(name) {
|
|
1286
|
+
ownName = name;
|
|
1287
|
+
render.name || render.displayName || (Object.defineProperty(render, "name", { value: name }), render.displayName = name);
|
|
1288
|
+
}
|
|
1289
|
+
});
|
|
1290
|
+
return elementType;
|
|
1291
|
+
};
|
|
1292
|
+
exports.isValidElement = isValidElement;
|
|
1293
|
+
exports.lazy = function(ctor) {
|
|
1294
|
+
ctor = { _status: -1, _result: ctor };
|
|
1295
|
+
var lazyType = {
|
|
1296
|
+
$$typeof: REACT_LAZY_TYPE,
|
|
1297
|
+
_payload: ctor,
|
|
1298
|
+
_init: lazyInitializer
|
|
1299
|
+
}, ioInfo = {
|
|
1300
|
+
name: "lazy",
|
|
1301
|
+
start: -1,
|
|
1302
|
+
end: -1,
|
|
1303
|
+
value: null,
|
|
1304
|
+
owner: null,
|
|
1305
|
+
debugStack: Error("react-stack-top-frame"),
|
|
1306
|
+
debugTask: console.createTask ? console.createTask("lazy()") : null
|
|
1307
|
+
};
|
|
1308
|
+
ctor._ioInfo = ioInfo;
|
|
1309
|
+
lazyType._debugInfo = [{ awaited: ioInfo }];
|
|
1310
|
+
return lazyType;
|
|
1311
|
+
};
|
|
1312
|
+
exports.memo = function(type, compare) {
|
|
1313
|
+
null == type && console.error(
|
|
1314
|
+
"memo: The first argument must be a component. Instead received: %s",
|
|
1315
|
+
null === type ? "null" : typeof type
|
|
1316
|
+
);
|
|
1317
|
+
compare = {
|
|
1318
|
+
$$typeof: REACT_MEMO_TYPE,
|
|
1319
|
+
type,
|
|
1320
|
+
compare: void 0 === compare ? null : compare
|
|
1321
|
+
};
|
|
1322
|
+
var ownName;
|
|
1323
|
+
Object.defineProperty(compare, "displayName", {
|
|
1324
|
+
enumerable: false,
|
|
1325
|
+
configurable: true,
|
|
1326
|
+
get: function() {
|
|
1327
|
+
return ownName;
|
|
1328
|
+
},
|
|
1329
|
+
set: function(name) {
|
|
1330
|
+
ownName = name;
|
|
1331
|
+
type.name || type.displayName || (Object.defineProperty(type, "name", { value: name }), type.displayName = name);
|
|
1332
|
+
}
|
|
1333
|
+
});
|
|
1334
|
+
return compare;
|
|
1335
|
+
};
|
|
1336
|
+
exports.startTransition = function(scope) {
|
|
1337
|
+
var prevTransition = ReactSharedInternals.T, currentTransition = {};
|
|
1338
|
+
currentTransition._updatedFibers = /* @__PURE__ */ new Set();
|
|
1339
|
+
ReactSharedInternals.T = currentTransition;
|
|
1340
|
+
try {
|
|
1341
|
+
var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
|
|
1342
|
+
null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
|
|
1343
|
+
"object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && (ReactSharedInternals.asyncTransitions++, returnValue.then(releaseAsyncTransition, releaseAsyncTransition), returnValue.then(noop, reportGlobalError));
|
|
1344
|
+
} catch (error) {
|
|
1345
|
+
reportGlobalError(error);
|
|
1346
|
+
} finally {
|
|
1347
|
+
null === prevTransition && currentTransition._updatedFibers && (scope = currentTransition._updatedFibers.size, currentTransition._updatedFibers.clear(), 10 < scope && console.warn(
|
|
1348
|
+
"Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."
|
|
1349
|
+
)), null !== prevTransition && null !== currentTransition.types && (null !== prevTransition.types && prevTransition.types !== currentTransition.types && console.error(
|
|
1350
|
+
"We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."
|
|
1351
|
+
), prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
|
|
1352
|
+
}
|
|
1353
|
+
};
|
|
1354
|
+
exports.unstable_useCacheRefresh = function() {
|
|
1355
|
+
return resolveDispatcher().useCacheRefresh();
|
|
1356
|
+
};
|
|
1357
|
+
exports.use = function(usable) {
|
|
1358
|
+
return resolveDispatcher().use(usable);
|
|
1359
|
+
};
|
|
1360
|
+
exports.useActionState = function(action, initialState, permalink) {
|
|
1361
|
+
return resolveDispatcher().useActionState(
|
|
1362
|
+
action,
|
|
1363
|
+
initialState,
|
|
1364
|
+
permalink
|
|
1365
|
+
);
|
|
1366
|
+
};
|
|
1367
|
+
exports.useCallback = function(callback, deps) {
|
|
1368
|
+
return resolveDispatcher().useCallback(callback, deps);
|
|
1369
|
+
};
|
|
1370
|
+
exports.useContext = function(Context) {
|
|
1371
|
+
var dispatcher = resolveDispatcher();
|
|
1372
|
+
Context.$$typeof === REACT_CONSUMER_TYPE && console.error(
|
|
1373
|
+
"Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"
|
|
1374
|
+
);
|
|
1375
|
+
return dispatcher.useContext(Context);
|
|
1376
|
+
};
|
|
1377
|
+
exports.useDebugValue = function(value2, formatterFn) {
|
|
1378
|
+
return resolveDispatcher().useDebugValue(value2, formatterFn);
|
|
1379
|
+
};
|
|
1380
|
+
exports.useDeferredValue = function(value2, initialValue) {
|
|
1381
|
+
return resolveDispatcher().useDeferredValue(value2, initialValue);
|
|
1382
|
+
};
|
|
1383
|
+
exports.useEffect = function(create2, deps) {
|
|
1384
|
+
null == create2 && console.warn(
|
|
1385
|
+
"React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
1386
|
+
);
|
|
1387
|
+
return resolveDispatcher().useEffect(create2, deps);
|
|
1388
|
+
};
|
|
1389
|
+
exports.useEffectEvent = function(callback) {
|
|
1390
|
+
return resolveDispatcher().useEffectEvent(callback);
|
|
1391
|
+
};
|
|
1392
|
+
exports.useId = function() {
|
|
1393
|
+
return resolveDispatcher().useId();
|
|
1394
|
+
};
|
|
1395
|
+
exports.useImperativeHandle = function(ref, create2, deps) {
|
|
1396
|
+
return resolveDispatcher().useImperativeHandle(ref, create2, deps);
|
|
1397
|
+
};
|
|
1398
|
+
exports.useInsertionEffect = function(create2, deps) {
|
|
1399
|
+
null == create2 && console.warn(
|
|
1400
|
+
"React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
1401
|
+
);
|
|
1402
|
+
return resolveDispatcher().useInsertionEffect(create2, deps);
|
|
1403
|
+
};
|
|
1404
|
+
exports.useLayoutEffect = function(create2, deps) {
|
|
1405
|
+
null == create2 && console.warn(
|
|
1406
|
+
"React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
1407
|
+
);
|
|
1408
|
+
return resolveDispatcher().useLayoutEffect(create2, deps);
|
|
1409
|
+
};
|
|
1410
|
+
exports.useMemo = function(create2, deps) {
|
|
1411
|
+
return resolveDispatcher().useMemo(create2, deps);
|
|
1412
|
+
};
|
|
1413
|
+
exports.useOptimistic = function(passthrough, reducer) {
|
|
1414
|
+
return resolveDispatcher().useOptimistic(passthrough, reducer);
|
|
1415
|
+
};
|
|
1416
|
+
exports.useReducer = function(reducer, initialArg, init) {
|
|
1417
|
+
return resolveDispatcher().useReducer(reducer, initialArg, init);
|
|
1418
|
+
};
|
|
1419
|
+
exports.useRef = function(initialValue) {
|
|
1420
|
+
return resolveDispatcher().useRef(initialValue);
|
|
1421
|
+
};
|
|
1422
|
+
exports.useState = function(initialState) {
|
|
1423
|
+
return resolveDispatcher().useState(initialState);
|
|
1424
|
+
};
|
|
1425
|
+
exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
|
|
1426
|
+
return resolveDispatcher().useSyncExternalStore(
|
|
1427
|
+
subscribe,
|
|
1428
|
+
getSnapshot,
|
|
1429
|
+
getServerSnapshot
|
|
1430
|
+
);
|
|
1431
|
+
};
|
|
1432
|
+
exports.useTransition = function() {
|
|
1433
|
+
return resolveDispatcher().useTransition();
|
|
1434
|
+
};
|
|
1435
|
+
exports.version = "19.2.4";
|
|
1436
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
1437
|
+
})();
|
|
1438
|
+
}
|
|
1439
|
+
});
|
|
1440
|
+
|
|
1441
|
+
// ../../node_modules/react/index.js
|
|
1442
|
+
var require_react = __commonJS({
|
|
1443
|
+
"../../node_modules/react/index.js"(exports, module) {
|
|
1444
|
+
"use strict";
|
|
1445
|
+
if (process.env.NODE_ENV === "production") {
|
|
1446
|
+
module.exports = require_react_production();
|
|
1447
|
+
} else {
|
|
1448
|
+
module.exports = require_react_development();
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
});
|
|
1452
|
+
|
|
1453
|
+
// src/cli.ts
|
|
1454
|
+
import { readFileSync as readFileSync2, writeFileSync, mkdirSync } from "fs";
|
|
1455
|
+
import { join as join3, resolve as resolve2 } from "path";
|
|
1456
|
+
|
|
1457
|
+
// src/locale.ts
|
|
1458
|
+
var envLang = (process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG || "").toLowerCase();
|
|
1459
|
+
var isZh = envLang.startsWith("zh");
|
|
1460
|
+
function t(en, zh) {
|
|
1461
|
+
return isZh ? zh : en;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
// src/parse.ts
|
|
1465
|
+
function fence(md, lang) {
|
|
1466
|
+
const re = new RegExp("```" + lang + "\\s*\\n([\\s\\S]*?)\\n```", "i");
|
|
1467
|
+
const m = md.match(re);
|
|
1468
|
+
return m ? m[1] : null;
|
|
1469
|
+
}
|
|
1470
|
+
function parseDesignSystem(md) {
|
|
1471
|
+
if (!/^---\s*\ndesign-system:/m.test(md) && !md.includes("# Design system")) {
|
|
1472
|
+
throw new Error(
|
|
1473
|
+
t(
|
|
1474
|
+
"This does not look like a design.md (missing the design-system frontmatter / Design system heading).",
|
|
1475
|
+
"\u8FD9\u770B\u8D77\u6765\u4E0D\u662F design.md\uFF08\u7F3A\u5C11 design-system frontmatter / Design system \u6807\u9898\uFF09\u3002"
|
|
1476
|
+
)
|
|
1477
|
+
);
|
|
1478
|
+
}
|
|
1479
|
+
const rootCss = fence(md, "css");
|
|
1480
|
+
if (!rootCss || !rootCss.includes(":root")) {
|
|
1481
|
+
throw new Error(t("No :root CSS contract block (```css) found.", "\u672A\u627E\u5230 :root CSS \u5951\u7EA6\u5757\uFF08```css\uFF09\u3002"));
|
|
1482
|
+
}
|
|
1483
|
+
const w3cText = fence(md, "json");
|
|
1484
|
+
if (!w3cText) {
|
|
1485
|
+
throw new Error(t("No machine-readable tokens block (```json) found.", "\u672A\u627E\u5230\u673A\u5668\u53EF\u8BFB tokens \u5757\uFF08```json\uFF09\u3002"));
|
|
1486
|
+
}
|
|
1487
|
+
let w3c;
|
|
1488
|
+
try {
|
|
1489
|
+
w3c = JSON.parse(w3cText);
|
|
1490
|
+
} catch {
|
|
1491
|
+
throw new Error(t("The machine-readable tokens block is not valid JSON.", "\u673A\u5668\u53EF\u8BFB tokens \u5757\u4E0D\u662F\u6709\u6548 JSON\u3002"));
|
|
1492
|
+
}
|
|
1493
|
+
return { rootCss: rootCss.trim() + "\n", w3c, w3cText: w3cText.trim() + "\n" };
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
// ../../lib/color.ts
|
|
1497
|
+
import { converter, formatHex, parse, formatCss } from "culori";
|
|
1498
|
+
var toOklch = converter("oklch");
|
|
1499
|
+
var toRgb = converter("rgb");
|
|
1500
|
+
|
|
1501
|
+
// ../../lib/scales.ts
|
|
1502
|
+
var SPACING_STEPS = [
|
|
1503
|
+
{ name: "xxs", mul: 1 },
|
|
1504
|
+
{ name: "xs", mul: 2 },
|
|
1505
|
+
{ name: "sm", mul: 3 },
|
|
1506
|
+
{ name: "md", mul: 4 },
|
|
1507
|
+
{ name: "lg", mul: 6 },
|
|
1508
|
+
{ name: "xl", mul: 8 },
|
|
1509
|
+
{ name: "xxl", mul: 12 },
|
|
1510
|
+
{ name: "section", mul: 24 }
|
|
1511
|
+
];
|
|
1512
|
+
var RADIUS_STEPS = [
|
|
1513
|
+
{ name: "sm", mul: 0.5 },
|
|
1514
|
+
{ name: "md", mul: 1 },
|
|
1515
|
+
{ name: "lg", mul: 1.5 },
|
|
1516
|
+
{ name: "xl", mul: 2 },
|
|
1517
|
+
{ name: "full", px: 9999 }
|
|
1518
|
+
];
|
|
1519
|
+
function buildSpacing(base) {
|
|
1520
|
+
return SPACING_STEPS.map(({ name, mul }) => ({
|
|
1521
|
+
name,
|
|
1522
|
+
px: Math.round(base * mul * 100) / 100
|
|
1523
|
+
}));
|
|
1524
|
+
}
|
|
1525
|
+
function buildRadius(base) {
|
|
1526
|
+
return RADIUS_STEPS.map((step) => ({
|
|
1527
|
+
name: step.name,
|
|
1528
|
+
px: "px" in step ? step.px : Math.round(base * step.mul * 100) / 100
|
|
1529
|
+
}));
|
|
1530
|
+
}
|
|
1531
|
+
var SHADOW_DEFAULTS = {
|
|
1532
|
+
sm: { blur: 4, offsetY: 1, opacity: 0.04 },
|
|
1533
|
+
md: { blur: 12, offsetY: 4, opacity: 0.08 },
|
|
1534
|
+
lg: { blur: 24, offsetY: 8, opacity: 0.12 }
|
|
1535
|
+
};
|
|
1536
|
+
function buildShadowsFromIntensity(intensity) {
|
|
1537
|
+
const scale = Math.max(0, intensity * 2);
|
|
1538
|
+
const apply = (d) => ({
|
|
1539
|
+
blur: Math.round(d.blur * scale),
|
|
1540
|
+
offsetY: Math.round(d.offsetY * scale * 10) / 10,
|
|
1541
|
+
opacity: Math.round(d.opacity * scale * 1e3) / 1e3
|
|
1542
|
+
});
|
|
1543
|
+
return {
|
|
1544
|
+
sm: apply(SHADOW_DEFAULTS.sm),
|
|
1545
|
+
md: apply(SHADOW_DEFAULTS.md),
|
|
1546
|
+
lg: apply(SHADOW_DEFAULTS.lg)
|
|
1547
|
+
};
|
|
1548
|
+
}
|
|
1549
|
+
function shadowToCss(s) {
|
|
1550
|
+
return `0 ${s.offsetY}px ${s.blur}px 0 rgba(0,0,0,${s.opacity.toFixed(3)})`;
|
|
1551
|
+
}
|
|
1552
|
+
var DURATION_STEPS = [
|
|
1553
|
+
{ name: "micro", mul: 0.4 },
|
|
1554
|
+
{ name: "fast", mul: 0.75 },
|
|
1555
|
+
{ name: "normal", mul: 1 },
|
|
1556
|
+
{ name: "slow", mul: 1.5 },
|
|
1557
|
+
{ name: "page", mul: 2.5 }
|
|
1558
|
+
];
|
|
1559
|
+
function buildDurations(base) {
|
|
1560
|
+
return DURATION_STEPS.map(({ name, mul }) => ({
|
|
1561
|
+
name,
|
|
1562
|
+
ms: Math.round(base * mul)
|
|
1563
|
+
}));
|
|
1564
|
+
}
|
|
1565
|
+
var EASING_PRESETS = {
|
|
1566
|
+
"ease-out": "cubic-bezier(0.0, 0, 0.2, 1)",
|
|
1567
|
+
"ease-in-out": "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
1568
|
+
spring: "cubic-bezier(0.34, 1.56, 0.64, 1)",
|
|
1569
|
+
linear: "linear",
|
|
1570
|
+
"ease-in": "cubic-bezier(0.4, 0, 1, 1)"
|
|
1571
|
+
};
|
|
1572
|
+
var round05 = (v) => Math.round(v * 2) / 2;
|
|
1573
|
+
function buildBorderScale(base) {
|
|
1574
|
+
return [
|
|
1575
|
+
{ name: "default", px: base },
|
|
1576
|
+
{ name: "strong", px: round05(base * 2) }
|
|
1577
|
+
];
|
|
1578
|
+
}
|
|
1579
|
+
function boldWeight(base) {
|
|
1580
|
+
return Math.min(900, Math.max(base + 300, 600));
|
|
1581
|
+
}
|
|
1582
|
+
function headingWeight(base) {
|
|
1583
|
+
return Math.min(900, base + 200);
|
|
1584
|
+
}
|
|
1585
|
+
function buildOpacityScale(base) {
|
|
1586
|
+
const r = (v) => Math.round(v * 1e3) / 1e3;
|
|
1587
|
+
return [
|
|
1588
|
+
{ name: "hover", value: r(base) },
|
|
1589
|
+
{ name: "pressed", value: r(base * 1.5) },
|
|
1590
|
+
{ name: "focus", value: r(base * 2) },
|
|
1591
|
+
{ name: "disabled", value: 0.38 },
|
|
1592
|
+
// Modal/drawer backdrop scrim — a fixed, perceptible dim (not tied to the
|
|
1593
|
+
// tiny interactive base, which made it ~0.04 = invisible).
|
|
1594
|
+
{ name: "overlay", value: 0.5 }
|
|
1595
|
+
];
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
// ../../lib/tokens-core.ts
|
|
1599
|
+
var defaultTypography = {
|
|
1600
|
+
base: 16,
|
|
1601
|
+
ratio: 1.25,
|
|
1602
|
+
fontFamily: "Inter, system-ui, sans-serif",
|
|
1603
|
+
headingFamily: "Inter, system-ui, sans-serif",
|
|
1604
|
+
fontWeight: 400,
|
|
1605
|
+
lineHeight: 1.5,
|
|
1606
|
+
letterSpacing: 0
|
|
1607
|
+
};
|
|
1608
|
+
var defaultSpacing = { base: 4 };
|
|
1609
|
+
var defaultRadius = { base: 8 };
|
|
1610
|
+
var defaultMotion = { base: 200, easing: "ease-out" };
|
|
1611
|
+
var defaultBorder = { base: 1 };
|
|
1612
|
+
var defaultOpacity = { base: 0.08 };
|
|
1613
|
+
var defaultShadow = {
|
|
1614
|
+
intensity: 0.5,
|
|
1615
|
+
advanced: false,
|
|
1616
|
+
...buildShadowsFromIntensity(0.5)
|
|
1617
|
+
};
|
|
1618
|
+
|
|
1619
|
+
// ../../lib/typography.ts
|
|
1620
|
+
var SCALE_STEPS = [
|
|
1621
|
+
{ name: "h1", step: 5 },
|
|
1622
|
+
{ name: "h2", step: 4 },
|
|
1623
|
+
{ name: "h3", step: 3 },
|
|
1624
|
+
{ name: "h4", step: 2 },
|
|
1625
|
+
{ name: "h5", step: 1 },
|
|
1626
|
+
{ name: "body", step: 0 },
|
|
1627
|
+
{ name: "small", step: -1 },
|
|
1628
|
+
{ name: "caption", step: -2 }
|
|
1629
|
+
];
|
|
1630
|
+
function buildScale(t2) {
|
|
1631
|
+
return SCALE_STEPS.map(({ name, step }) => {
|
|
1632
|
+
const px = Math.round(t2.base * Math.pow(t2.ratio, step) * 100) / 100;
|
|
1633
|
+
return { name, px, rem: Math.round(px / 16 * 1e3) / 1e3 };
|
|
1634
|
+
});
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
// ../../lib/export.ts
|
|
1638
|
+
function tailwindConfig(colors, typography, spacing, radius, shadow, motion, border, opacity) {
|
|
1639
|
+
const colorEntries = colors.map((c) => ` ${c.role === "unassigned" ? c.id : c.role}: "${c.displayHex}",`).join("\n");
|
|
1640
|
+
const sizeEntries = buildScale(typography).map((s) => ` "${s.name}": "${s.rem}rem",`).join("\n");
|
|
1641
|
+
const spacingEntries = buildSpacing(spacing.base).map((s) => ` ${s.name}: "${s.px}px",`).join("\n");
|
|
1642
|
+
const radiusEntries = buildRadius(radius.base).map((r) => ` ${r.name}: "${r.px}px",`).join("\n");
|
|
1643
|
+
const shadowEntries = ["sm", "md", "lg"].map((level) => ` ${level}: "${shadowToCss(shadow[level])}",`).join("\n");
|
|
1644
|
+
const durationEntries = buildDurations(motion.base).map((d) => ` ${d.name}: "${d.ms}ms",`).join("\n");
|
|
1645
|
+
const borderEntries = buildBorderScale(border.base).map((b) => ` ${b.name}: "${b.px}px",`).join("\n");
|
|
1646
|
+
const opacityEntries = buildOpacityScale(opacity.base).map((o) => ` ${o.name}: "${o.value}",`).join("\n");
|
|
1647
|
+
return `module.exports = {
|
|
1648
|
+
theme: {
|
|
1649
|
+
extend: {
|
|
1650
|
+
colors: {
|
|
1651
|
+
${colorEntries}
|
|
1652
|
+
},
|
|
1653
|
+
fontFamily: {
|
|
1654
|
+
sans: ${JSON.stringify(typography.fontFamily.split(",").map((s) => s.trim()))},
|
|
1655
|
+
heading: ${JSON.stringify(typography.headingFamily.split(",").map((s) => s.trim()))},
|
|
1656
|
+
},
|
|
1657
|
+
fontSize: {
|
|
1658
|
+
${sizeEntries}
|
|
1659
|
+
},
|
|
1660
|
+
fontWeight: {
|
|
1661
|
+
body: "${typography.fontWeight}",
|
|
1662
|
+
heading: "${headingWeight(typography.fontWeight)}",
|
|
1663
|
+
bold: "${boldWeight(typography.fontWeight)}",
|
|
1664
|
+
},
|
|
1665
|
+
lineHeight: {
|
|
1666
|
+
body: "${typography.lineHeight}",
|
|
1667
|
+
},
|
|
1668
|
+
letterSpacing: {
|
|
1669
|
+
body: "${typography.letterSpacing}em",
|
|
1670
|
+
},
|
|
1671
|
+
spacing: {
|
|
1672
|
+
${spacingEntries}
|
|
1673
|
+
},
|
|
1674
|
+
borderRadius: {
|
|
1675
|
+
${radiusEntries}
|
|
1676
|
+
},
|
|
1677
|
+
borderWidth: {
|
|
1678
|
+
${borderEntries}
|
|
1679
|
+
},
|
|
1680
|
+
boxShadow: {
|
|
1681
|
+
${shadowEntries}
|
|
1682
|
+
},
|
|
1683
|
+
transitionDuration: {
|
|
1684
|
+
${durationEntries}
|
|
1685
|
+
},
|
|
1686
|
+
transitionTimingFunction: {
|
|
1687
|
+
standard: "${EASING_PRESETS[motion.easing]}",
|
|
1688
|
+
},
|
|
1689
|
+
opacity: {
|
|
1690
|
+
${opacityEntries}
|
|
1691
|
+
},
|
|
1692
|
+
},
|
|
1693
|
+
},
|
|
1694
|
+
};
|
|
1695
|
+
`;
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
// ../../node_modules/zustand/esm/vanilla.mjs
|
|
1699
|
+
var createStoreImpl = (createState) => {
|
|
1700
|
+
let state;
|
|
1701
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
1702
|
+
const setState = (partial, replace) => {
|
|
1703
|
+
const nextState = typeof partial === "function" ? partial(state) : partial;
|
|
1704
|
+
if (!Object.is(nextState, state)) {
|
|
1705
|
+
const previousState = state;
|
|
1706
|
+
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
|
1707
|
+
listeners.forEach((listener) => listener(state, previousState));
|
|
1708
|
+
}
|
|
1709
|
+
};
|
|
1710
|
+
const getState = () => state;
|
|
1711
|
+
const getInitialState = () => initialState;
|
|
1712
|
+
const subscribe = (listener) => {
|
|
1713
|
+
listeners.add(listener);
|
|
1714
|
+
return () => listeners.delete(listener);
|
|
1715
|
+
};
|
|
1716
|
+
const api = { setState, getState, getInitialState, subscribe };
|
|
1717
|
+
const initialState = state = createState(setState, getState, api);
|
|
1718
|
+
return api;
|
|
1719
|
+
};
|
|
1720
|
+
var createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);
|
|
1721
|
+
|
|
1722
|
+
// ../../node_modules/zustand/esm/react.mjs
|
|
1723
|
+
var import_react = __toESM(require_react(), 1);
|
|
1724
|
+
var identity = (arg) => arg;
|
|
1725
|
+
function useStore(api, selector = identity) {
|
|
1726
|
+
const slice = import_react.default.useSyncExternalStore(
|
|
1727
|
+
api.subscribe,
|
|
1728
|
+
import_react.default.useCallback(() => selector(api.getState()), [api, selector]),
|
|
1729
|
+
import_react.default.useCallback(() => selector(api.getInitialState()), [api, selector])
|
|
1730
|
+
);
|
|
1731
|
+
import_react.default.useDebugValue(slice);
|
|
1732
|
+
return slice;
|
|
1733
|
+
}
|
|
1734
|
+
var createImpl = (createState) => {
|
|
1735
|
+
const api = createStore(createState);
|
|
1736
|
+
const useBoundStore = (selector) => useStore(api, selector);
|
|
1737
|
+
Object.assign(useBoundStore, api);
|
|
1738
|
+
return useBoundStore;
|
|
1739
|
+
};
|
|
1740
|
+
var create = ((createState) => createState ? createImpl(createState) : createImpl);
|
|
1741
|
+
|
|
1742
|
+
// ../../node_modules/zustand/esm/middleware.mjs
|
|
1743
|
+
function createJSONStorage(getStorage, options) {
|
|
1744
|
+
let storage;
|
|
1745
|
+
try {
|
|
1746
|
+
storage = getStorage();
|
|
1747
|
+
} catch (e) {
|
|
1748
|
+
return;
|
|
1749
|
+
}
|
|
1750
|
+
const persistStorage = {
|
|
1751
|
+
getItem: (name) => {
|
|
1752
|
+
var _a;
|
|
1753
|
+
const parse2 = (str2) => {
|
|
1754
|
+
if (str2 === null) {
|
|
1755
|
+
return null;
|
|
1756
|
+
}
|
|
1757
|
+
return JSON.parse(str2, options == null ? void 0 : options.reviver);
|
|
1758
|
+
};
|
|
1759
|
+
const str = (_a = storage.getItem(name)) != null ? _a : null;
|
|
1760
|
+
if (str instanceof Promise) {
|
|
1761
|
+
return str.then(parse2);
|
|
1762
|
+
}
|
|
1763
|
+
return parse2(str);
|
|
1764
|
+
},
|
|
1765
|
+
setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, options == null ? void 0 : options.replacer)),
|
|
1766
|
+
removeItem: (name) => storage.removeItem(name)
|
|
1767
|
+
};
|
|
1768
|
+
return persistStorage;
|
|
1769
|
+
}
|
|
1770
|
+
var toThenable = (fn) => (input) => {
|
|
1771
|
+
try {
|
|
1772
|
+
const result = fn(input);
|
|
1773
|
+
if (result instanceof Promise) {
|
|
1774
|
+
return result;
|
|
1775
|
+
}
|
|
1776
|
+
return {
|
|
1777
|
+
then(onFulfilled) {
|
|
1778
|
+
return toThenable(onFulfilled)(result);
|
|
1779
|
+
},
|
|
1780
|
+
catch(_onRejected) {
|
|
1781
|
+
return this;
|
|
1782
|
+
}
|
|
1783
|
+
};
|
|
1784
|
+
} catch (e) {
|
|
1785
|
+
return {
|
|
1786
|
+
then(_onFulfilled) {
|
|
1787
|
+
return this;
|
|
1788
|
+
},
|
|
1789
|
+
catch(onRejected) {
|
|
1790
|
+
return toThenable(onRejected)(e);
|
|
1791
|
+
}
|
|
1792
|
+
};
|
|
1793
|
+
}
|
|
1794
|
+
};
|
|
1795
|
+
var persistImpl = (config, baseOptions) => (set, get, api) => {
|
|
1796
|
+
let options = {
|
|
1797
|
+
storage: createJSONStorage(() => window.localStorage),
|
|
1798
|
+
partialize: (state) => state,
|
|
1799
|
+
version: 0,
|
|
1800
|
+
merge: (persistedState, currentState) => ({
|
|
1801
|
+
...currentState,
|
|
1802
|
+
...persistedState
|
|
1803
|
+
}),
|
|
1804
|
+
...baseOptions
|
|
1805
|
+
};
|
|
1806
|
+
let hasHydrated = false;
|
|
1807
|
+
let hydrationVersion = 0;
|
|
1808
|
+
const hydrationListeners = /* @__PURE__ */ new Set();
|
|
1809
|
+
const finishHydrationListeners = /* @__PURE__ */ new Set();
|
|
1810
|
+
let storage = options.storage;
|
|
1811
|
+
if (!storage) {
|
|
1812
|
+
return config(
|
|
1813
|
+
(...args) => {
|
|
1814
|
+
console.warn(
|
|
1815
|
+
`[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`
|
|
1816
|
+
);
|
|
1817
|
+
set(...args);
|
|
1818
|
+
},
|
|
1819
|
+
get,
|
|
1820
|
+
api
|
|
1821
|
+
);
|
|
1822
|
+
}
|
|
1823
|
+
const setItem = () => {
|
|
1824
|
+
const state = options.partialize({ ...get() });
|
|
1825
|
+
return storage.setItem(options.name, {
|
|
1826
|
+
state,
|
|
1827
|
+
version: options.version
|
|
1828
|
+
});
|
|
1829
|
+
};
|
|
1830
|
+
const savedSetState = api.setState;
|
|
1831
|
+
api.setState = (state, replace) => {
|
|
1832
|
+
savedSetState(state, replace);
|
|
1833
|
+
return setItem();
|
|
1834
|
+
};
|
|
1835
|
+
const configResult = config(
|
|
1836
|
+
(...args) => {
|
|
1837
|
+
set(...args);
|
|
1838
|
+
return setItem();
|
|
1839
|
+
},
|
|
1840
|
+
get,
|
|
1841
|
+
api
|
|
1842
|
+
);
|
|
1843
|
+
api.getInitialState = () => configResult;
|
|
1844
|
+
let stateFromStorage;
|
|
1845
|
+
const hydrate = () => {
|
|
1846
|
+
var _a, _b;
|
|
1847
|
+
if (!storage) return;
|
|
1848
|
+
const currentVersion = ++hydrationVersion;
|
|
1849
|
+
hasHydrated = false;
|
|
1850
|
+
hydrationListeners.forEach((cb) => {
|
|
1851
|
+
var _a2;
|
|
1852
|
+
return cb((_a2 = get()) != null ? _a2 : configResult);
|
|
1853
|
+
});
|
|
1854
|
+
const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get()) != null ? _a : configResult)) || void 0;
|
|
1855
|
+
return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {
|
|
1856
|
+
if (deserializedStorageValue) {
|
|
1857
|
+
if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) {
|
|
1858
|
+
if (options.migrate) {
|
|
1859
|
+
const migration = options.migrate(
|
|
1860
|
+
deserializedStorageValue.state,
|
|
1861
|
+
deserializedStorageValue.version
|
|
1862
|
+
);
|
|
1863
|
+
if (migration instanceof Promise) {
|
|
1864
|
+
return migration.then((result) => [true, result]);
|
|
1865
|
+
}
|
|
1866
|
+
return [true, migration];
|
|
1867
|
+
}
|
|
1868
|
+
console.error(
|
|
1869
|
+
`State loaded from storage couldn't be migrated since no migrate function was provided`
|
|
1870
|
+
);
|
|
1871
|
+
} else {
|
|
1872
|
+
return [false, deserializedStorageValue.state];
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
return [false, void 0];
|
|
1876
|
+
}).then((migrationResult) => {
|
|
1877
|
+
var _a2;
|
|
1878
|
+
if (currentVersion !== hydrationVersion) {
|
|
1879
|
+
return;
|
|
1880
|
+
}
|
|
1881
|
+
const [migrated, migratedState] = migrationResult;
|
|
1882
|
+
stateFromStorage = options.merge(
|
|
1883
|
+
migratedState,
|
|
1884
|
+
(_a2 = get()) != null ? _a2 : configResult
|
|
1885
|
+
);
|
|
1886
|
+
set(stateFromStorage, true);
|
|
1887
|
+
if (migrated) {
|
|
1888
|
+
return setItem();
|
|
1889
|
+
}
|
|
1890
|
+
}).then(() => {
|
|
1891
|
+
if (currentVersion !== hydrationVersion) {
|
|
1892
|
+
return;
|
|
1893
|
+
}
|
|
1894
|
+
postRehydrationCallback == null ? void 0 : postRehydrationCallback(get(), void 0);
|
|
1895
|
+
stateFromStorage = get();
|
|
1896
|
+
hasHydrated = true;
|
|
1897
|
+
finishHydrationListeners.forEach((cb) => cb(stateFromStorage));
|
|
1898
|
+
}).catch((e) => {
|
|
1899
|
+
if (currentVersion !== hydrationVersion) {
|
|
1900
|
+
return;
|
|
1901
|
+
}
|
|
1902
|
+
postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);
|
|
1903
|
+
});
|
|
1904
|
+
};
|
|
1905
|
+
api.persist = {
|
|
1906
|
+
setOptions: (newOptions) => {
|
|
1907
|
+
options = {
|
|
1908
|
+
...options,
|
|
1909
|
+
...newOptions
|
|
1910
|
+
};
|
|
1911
|
+
if (newOptions.storage) {
|
|
1912
|
+
storage = newOptions.storage;
|
|
1913
|
+
}
|
|
1914
|
+
},
|
|
1915
|
+
clearStorage: () => {
|
|
1916
|
+
storage == null ? void 0 : storage.removeItem(options.name);
|
|
1917
|
+
},
|
|
1918
|
+
getOptions: () => options,
|
|
1919
|
+
rehydrate: () => hydrate(),
|
|
1920
|
+
hasHydrated: () => hasHydrated,
|
|
1921
|
+
onHydrate: (cb) => {
|
|
1922
|
+
hydrationListeners.add(cb);
|
|
1923
|
+
return () => {
|
|
1924
|
+
hydrationListeners.delete(cb);
|
|
1925
|
+
};
|
|
1926
|
+
},
|
|
1927
|
+
onFinishHydration: (cb) => {
|
|
1928
|
+
finishHydrationListeners.add(cb);
|
|
1929
|
+
return () => {
|
|
1930
|
+
finishHydrationListeners.delete(cb);
|
|
1931
|
+
};
|
|
1932
|
+
}
|
|
1933
|
+
};
|
|
1934
|
+
if (!options.skipHydration) {
|
|
1935
|
+
hydrate();
|
|
1936
|
+
}
|
|
1937
|
+
return stateFromStorage || configResult;
|
|
1938
|
+
};
|
|
1939
|
+
var persist = persistImpl;
|
|
1940
|
+
|
|
1941
|
+
// ../../lib/i18n.ts
|
|
1942
|
+
var useLang = create()(
|
|
1943
|
+
persist(
|
|
1944
|
+
(set, get) => ({
|
|
1945
|
+
lang: "en",
|
|
1946
|
+
setLang: (lang) => set({ lang }),
|
|
1947
|
+
toggle: () => set({ lang: get().lang === "en" ? "zh" : "en" })
|
|
1948
|
+
}),
|
|
1949
|
+
// skipHydration: the static export prerenders with the "en" default, then
|
|
1950
|
+
// StoreHydration rehydrates from localStorage on the client (same pattern
|
|
1951
|
+
// as the tokens store) so there is no hydration mismatch.
|
|
1952
|
+
{ name: "design-system-lang", skipHydration: true }
|
|
1953
|
+
)
|
|
1954
|
+
);
|
|
1955
|
+
function trg(en, zh) {
|
|
1956
|
+
return useLang.getState().lang === "zh" ? zh : en;
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
// ../../lib/importTokens.ts
|
|
1960
|
+
var ROLES = /* @__PURE__ */ new Set([
|
|
1961
|
+
"primary",
|
|
1962
|
+
"accent",
|
|
1963
|
+
"background",
|
|
1964
|
+
"foreground",
|
|
1965
|
+
"muted",
|
|
1966
|
+
"border"
|
|
1967
|
+
]);
|
|
1968
|
+
var HEX_RE = /^#[0-9a-fA-F]{6}$/;
|
|
1969
|
+
var asObj = (x) => x && typeof x === "object" && !Array.isArray(x) ? x : void 0;
|
|
1970
|
+
var value = (node) => asObj(node)?.["$value"];
|
|
1971
|
+
var num = (x) => {
|
|
1972
|
+
if (typeof x === "number" && Number.isFinite(x)) return x;
|
|
1973
|
+
if (typeof x === "string") {
|
|
1974
|
+
const m = /^(-?\d+(?:\.\d+)?)/.exec(x.trim());
|
|
1975
|
+
if (m) return parseFloat(m[1]);
|
|
1976
|
+
}
|
|
1977
|
+
return void 0;
|
|
1978
|
+
};
|
|
1979
|
+
function parseW3CTokens(jsonText) {
|
|
1980
|
+
let root;
|
|
1981
|
+
try {
|
|
1982
|
+
root = asObj(JSON.parse(jsonText));
|
|
1983
|
+
} catch {
|
|
1984
|
+
throw new Error(trg("Not a valid JSON file", "\u4E0D\u662F\u6709\u6548\u7684 JSON \u6587\u4EF6"));
|
|
1985
|
+
}
|
|
1986
|
+
if (!root) throw new Error(trg("Not a valid JSON file", "\u4E0D\u662F\u6709\u6548\u7684 JSON \u6587\u4EF6"));
|
|
1987
|
+
const colorGroup = asObj(root.color);
|
|
1988
|
+
if (!colorGroup) throw new Error(trg("Missing the color group \u2014 is this a design.md exported by this tool?", "\u7F3A\u5C11 color \u5206\u7EC4\u2014\u2014\u8FD9\u4E0D\u662F\u672C\u5DE5\u5177\u5BFC\u51FA\u7684 design.md\uFF1F"));
|
|
1989
|
+
const colors = [];
|
|
1990
|
+
const darkHexes = [];
|
|
1991
|
+
for (const [key, node] of Object.entries(colorGroup)) {
|
|
1992
|
+
const hex = value(node);
|
|
1993
|
+
if (typeof hex !== "string" || !HEX_RE.test(hex)) continue;
|
|
1994
|
+
const lower = hex.toLowerCase();
|
|
1995
|
+
colors.push({
|
|
1996
|
+
id: key,
|
|
1997
|
+
hex: lower,
|
|
1998
|
+
baseHex: lower,
|
|
1999
|
+
proportion: 1,
|
|
2000
|
+
role: ROLES.has(key) ? key : "unassigned",
|
|
2001
|
+
name: key
|
|
2002
|
+
});
|
|
2003
|
+
const dark = asObj(asObj(asObj(node)?.["$extensions"])?.["design-system"])?.dark;
|
|
2004
|
+
darkHexes.push(typeof dark === "string" && HEX_RE.test(dark) ? dark.toLowerCase() : void 0);
|
|
2005
|
+
}
|
|
2006
|
+
if (colors.length === 0) throw new Error(trg("No recognizable colors in the color group", "color \u5206\u7EC4\u91CC\u6CA1\u6709\u53EF\u8BC6\u522B\u7684\u989C\u8272"));
|
|
2007
|
+
const out = { colors };
|
|
2008
|
+
if (darkHexes.some((d) => d !== void 0)) out.darkHexes = darkHexes;
|
|
2009
|
+
const typo = asObj(root.typography);
|
|
2010
|
+
if (typo) {
|
|
2011
|
+
const t2 = {};
|
|
2012
|
+
const ext = asObj(asObj(typo.$extensions)?.["design-system"]);
|
|
2013
|
+
const base = num(ext?.base);
|
|
2014
|
+
const ratio = num(ext?.ratio);
|
|
2015
|
+
if (base) t2.base = base;
|
|
2016
|
+
if (ratio) t2.ratio = ratio;
|
|
2017
|
+
const family = asObj(typo.fontFamily);
|
|
2018
|
+
const body = value(family?.body);
|
|
2019
|
+
const heading = value(family?.heading);
|
|
2020
|
+
if (typeof body === "string" && body) t2.fontFamily = body;
|
|
2021
|
+
if (typeof heading === "string" && heading) t2.headingFamily = heading;
|
|
2022
|
+
const weight = num(value(typo.fontWeight));
|
|
2023
|
+
if (weight) t2.fontWeight = weight;
|
|
2024
|
+
const lineHeight = num(value(typo.lineHeight));
|
|
2025
|
+
if (lineHeight) t2.lineHeight = lineHeight;
|
|
2026
|
+
const letterSpacing = num(value(typo.letterSpacing));
|
|
2027
|
+
if (letterSpacing !== void 0) t2.letterSpacing = letterSpacing;
|
|
2028
|
+
if (Object.keys(t2).length > 0) out.typography = t2;
|
|
2029
|
+
}
|
|
2030
|
+
const spacingBase = num(value(asObj(root.spacing)?.xxs));
|
|
2031
|
+
if (spacingBase) out.spacing = { base: spacingBase };
|
|
2032
|
+
const radiusBase = num(value(asObj(root.borderRadius)?.md));
|
|
2033
|
+
if (radiusBase) out.radius = { base: radiusBase };
|
|
2034
|
+
const borderBase = num(value(asObj(root.borderWidth)?.default));
|
|
2035
|
+
if (borderBase) out.border = { base: borderBase };
|
|
2036
|
+
const opacityBase = num(value(asObj(root.opacity)?.hover));
|
|
2037
|
+
if (opacityBase) out.opacity = { base: opacityBase };
|
|
2038
|
+
const shadowGroup = asObj(root.shadow);
|
|
2039
|
+
if (shadowGroup) {
|
|
2040
|
+
const levels = {};
|
|
2041
|
+
for (const level of ["sm", "md", "lg"]) {
|
|
2042
|
+
const css = value(shadowGroup[level]);
|
|
2043
|
+
if (typeof css !== "string") continue;
|
|
2044
|
+
const m = /^0\s+(-?[\d.]+)px\s+([\d.]+)px\s+0\s+rgba\(0,\s*0,\s*0,\s*([\d.]+)\)$/.exec(
|
|
2045
|
+
css.trim()
|
|
2046
|
+
);
|
|
2047
|
+
if (!m) continue;
|
|
2048
|
+
levels[level] = { offsetY: parseFloat(m[1]), blur: parseFloat(m[2]), opacity: parseFloat(m[3]) };
|
|
2049
|
+
}
|
|
2050
|
+
if (levels.sm && levels.md && levels.lg) {
|
|
2051
|
+
out.shadow = { intensity: 0.5, advanced: true, sm: levels.sm, md: levels.md, lg: levels.lg };
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
const motionGroup = asObj(root.motion);
|
|
2055
|
+
if (motionGroup) {
|
|
2056
|
+
const m = {};
|
|
2057
|
+
const baseMs = num(value(motionGroup["duration-normal"]));
|
|
2058
|
+
if (baseMs) m.base = baseMs;
|
|
2059
|
+
const easingVal = value(motionGroup.easing);
|
|
2060
|
+
if (typeof easingVal === "string") {
|
|
2061
|
+
const preset = Object.keys(EASING_PRESETS).find(
|
|
2062
|
+
(k) => EASING_PRESETS[k] === easingVal.trim() || k === easingVal.trim()
|
|
2063
|
+
);
|
|
2064
|
+
if (preset) m.easing = preset;
|
|
2065
|
+
}
|
|
2066
|
+
if (Object.keys(m).length > 0) out.motion = m;
|
|
2067
|
+
}
|
|
2068
|
+
return out;
|
|
2069
|
+
}
|
|
2070
|
+
|
|
2071
|
+
// src/tailwind.ts
|
|
2072
|
+
function tailwindFromW3C(jsonText) {
|
|
2073
|
+
const p = parseW3CTokens(jsonText);
|
|
2074
|
+
const resolved = p.colors.map((c) => ({ ...c, displayHex: c.hex }));
|
|
2075
|
+
return tailwindConfig(
|
|
2076
|
+
resolved,
|
|
2077
|
+
{ ...defaultTypography, ...p.typography },
|
|
2078
|
+
{ ...defaultSpacing, ...p.spacing },
|
|
2079
|
+
{ ...defaultRadius, ...p.radius },
|
|
2080
|
+
p.shadow ?? defaultShadow,
|
|
2081
|
+
{ ...defaultMotion, ...p.motion },
|
|
2082
|
+
{ ...defaultBorder, ...p.border },
|
|
2083
|
+
{ ...defaultOpacity, ...p.opacity }
|
|
2084
|
+
);
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
// src/studio.ts
|
|
2088
|
+
import { createServer, get as httpGet } from "http";
|
|
2089
|
+
import { mkdir, copyFile } from "fs/promises";
|
|
2090
|
+
import { createReadStream, existsSync, statSync } from "fs";
|
|
2091
|
+
import { fileURLToPath } from "url";
|
|
2092
|
+
import { dirname, join, normalize, extname } from "path";
|
|
2093
|
+
import { spawn } from "child_process";
|
|
2094
|
+
import { homedir } from "os";
|
|
2095
|
+
var PKG = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
2096
|
+
var WEB_DIR = join(PKG, "web");
|
|
2097
|
+
var SKILL_SRC = join(PKG, "SKILL.md");
|
|
2098
|
+
var PORT = Number(process.env.PORT) || 3e3;
|
|
2099
|
+
var MIME = {
|
|
2100
|
+
".html": "text/html; charset=utf-8",
|
|
2101
|
+
".js": "text/javascript; charset=utf-8",
|
|
2102
|
+
".mjs": "text/javascript; charset=utf-8",
|
|
2103
|
+
".css": "text/css; charset=utf-8",
|
|
2104
|
+
".json": "application/json; charset=utf-8",
|
|
2105
|
+
".txt": "text/plain; charset=utf-8",
|
|
2106
|
+
".svg": "image/svg+xml",
|
|
2107
|
+
".png": "image/png",
|
|
2108
|
+
".jpg": "image/jpeg",
|
|
2109
|
+
".jpeg": "image/jpeg",
|
|
2110
|
+
".webp": "image/webp",
|
|
2111
|
+
".ico": "image/x-icon",
|
|
2112
|
+
".woff2": "font/woff2",
|
|
2113
|
+
".woff": "font/woff",
|
|
2114
|
+
".map": "application/json"
|
|
2115
|
+
};
|
|
2116
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
2117
|
+
async function cmdInit(args) {
|
|
2118
|
+
const global = args.includes("--global");
|
|
2119
|
+
const base = global ? join(homedir(), ".claude") : join(process.cwd(), ".claude");
|
|
2120
|
+
const dir = join(base, "skills", "design-system");
|
|
2121
|
+
if (!existsSync(SKILL_SRC)) {
|
|
2122
|
+
console.error("\u2717 " + t("SKILL.md missing from the package (run bundle before publishing).", "\u5305\u5185\u7F3A\u5C11 SKILL.md\uFF08\u53D1\u5E03\u524D\u9700\u5148\u8FD0\u884C bundle\uFF09\u3002"));
|
|
2123
|
+
process.exit(1);
|
|
2124
|
+
}
|
|
2125
|
+
await mkdir(dir, { recursive: true });
|
|
2126
|
+
await copyFile(SKILL_SRC, join(dir, "SKILL.md"));
|
|
2127
|
+
console.log(t(`\u2713 Installed the design-system skill \u2192 ${join(dir, "SKILL.md")}`, `\u2713 \u5DF2\u5B89\u88C5 design-system skill \u2192 ${join(dir, "SKILL.md")}`));
|
|
2128
|
+
console.log(
|
|
2129
|
+
global ? t(" (global: available in every project)", " \uFF08\u5168\u5C40\uFF1A\u5BF9\u6240\u6709\u9879\u76EE\u53EF\u7528\uFF09") : t(" (project-level: this project only; add --global to install into ~/.claude)", " \uFF08\u9879\u76EE\u7EA7\uFF1A\u4EC5\u5F53\u524D\u9879\u76EE\u53EF\u7528\uFF0C\u52A0 --global \u53EF\u88C5\u5230 ~/.claude\uFF09")
|
|
2130
|
+
);
|
|
2131
|
+
console.log("\n" + t('Next: in Claude Code / Cursor, say "use the design-system skill".', "\u4E0B\u4E00\u6B65\uFF1A\u5728 Claude Code / Cursor \u91CC\u8BF4\u300C\u7528 design-system skill\u300D\u3002"));
|
|
2132
|
+
console.log(t("It clarifies direction, proposes palettes, and opens the local studio via `npx design-pact open`.", "\u5B83\u4F1A\u95EE\u6E05\u65B9\u5411\u3001\u4EA7\u51FA\u914D\u8272\uFF0C\u5E76\u7528 `npx design-pact open` \u5728\u672C\u5730\u6253\u5F00\u914D\u8272\u5DE5\u5177\u3002"));
|
|
2133
|
+
}
|
|
2134
|
+
function fileForUrl(urlPath) {
|
|
2135
|
+
let p = decodeURIComponent((urlPath || "/").split("?")[0]);
|
|
2136
|
+
if (p === "/" || p === "") p = "/index.html";
|
|
2137
|
+
const full = normalize(join(WEB_DIR, p));
|
|
2138
|
+
if (!full.startsWith(WEB_DIR)) return null;
|
|
2139
|
+
if (existsSync(full) && statSync(full).isFile()) return full;
|
|
2140
|
+
if (!extname(full)) return join(WEB_DIR, "index.html");
|
|
2141
|
+
return null;
|
|
2142
|
+
}
|
|
2143
|
+
function serveStatic(port) {
|
|
2144
|
+
const server = createServer((req, res) => {
|
|
2145
|
+
const file = fileForUrl(req.url || "/");
|
|
2146
|
+
if (!file || !existsSync(file)) {
|
|
2147
|
+
res.writeHead(404, { "content-type": "text/plain; charset=utf-8" });
|
|
2148
|
+
res.end("404");
|
|
2149
|
+
return;
|
|
2150
|
+
}
|
|
2151
|
+
res.writeHead(200, { "content-type": MIME[extname(file)] || "application/octet-stream" });
|
|
2152
|
+
createReadStream(file).pipe(res);
|
|
2153
|
+
});
|
|
2154
|
+
return new Promise((resolve3, reject) => {
|
|
2155
|
+
server.once("error", reject);
|
|
2156
|
+
server.listen(port, () => resolve3());
|
|
2157
|
+
});
|
|
2158
|
+
}
|
|
2159
|
+
function probe(port) {
|
|
2160
|
+
return new Promise((resolve3) => {
|
|
2161
|
+
const req = httpGet({ host: "localhost", port, path: "/", timeout: 700 }, (r) => {
|
|
2162
|
+
r.resume();
|
|
2163
|
+
resolve3(true);
|
|
2164
|
+
});
|
|
2165
|
+
req.on("error", () => resolve3(false));
|
|
2166
|
+
req.on("timeout", () => {
|
|
2167
|
+
req.destroy();
|
|
2168
|
+
resolve3(false);
|
|
2169
|
+
});
|
|
2170
|
+
});
|
|
2171
|
+
}
|
|
2172
|
+
function openBrowser(url) {
|
|
2173
|
+
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
2174
|
+
const args = process.platform === "win32" ? ["/c", "start", "", url] : [url];
|
|
2175
|
+
try {
|
|
2176
|
+
spawn(cmd, args, { stdio: "ignore", detached: true }).unref();
|
|
2177
|
+
} catch {
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
async function cmdOpen(args) {
|
|
2181
|
+
if (!existsSync(join(WEB_DIR, "index.html"))) {
|
|
2182
|
+
console.error("\u2717 " + t("Static web app missing from the package (run bundle before publishing).", "\u5305\u5185\u7F3A\u5C11\u9759\u6001\u7F51\u9875\uFF08\u53D1\u5E03\u524D\u9700\u5148\u8FD0\u884C bundle\uFF09\u3002"));
|
|
2183
|
+
process.exit(1);
|
|
2184
|
+
}
|
|
2185
|
+
const raw = args.find((a) => !a.startsWith("-")) || "";
|
|
2186
|
+
const q = raw ? raw.startsWith("?") ? raw : "?" + raw : "";
|
|
2187
|
+
const url = `http://localhost:${PORT}/${q}`;
|
|
2188
|
+
if (await probe(PORT)) {
|
|
2189
|
+
console.log(t(`\u21BB Reusing the running instance
|
|
2190
|
+
Open (palettes loaded): ${url}`, `\u21BB \u590D\u7528\u672C\u5730\u5B9E\u4F8B
|
|
2191
|
+
\u6253\u5F00\uFF08\u5DF2\u5E26\u914D\u8272\uFF09: ${url}`));
|
|
2192
|
+
openBrowser(url);
|
|
2193
|
+
return;
|
|
2194
|
+
}
|
|
2195
|
+
const child = spawn(process.execPath, [fileURLToPath(import.meta.url), "__serve", String(PORT)], {
|
|
2196
|
+
detached: true,
|
|
2197
|
+
stdio: "ignore"
|
|
2198
|
+
});
|
|
2199
|
+
child.unref();
|
|
2200
|
+
for (let i = 0; i < 40; i++) {
|
|
2201
|
+
if (await probe(PORT)) break;
|
|
2202
|
+
await sleep(150);
|
|
2203
|
+
}
|
|
2204
|
+
console.log(t(`Local studio started (port ${PORT}, running in the background).`, `\u672C\u5730\u914D\u8272\u5DE5\u5177\u5DF2\u542F\u52A8\uFF08\u7AEF\u53E3 ${PORT}\uFF0C\u540E\u53F0\u8FD0\u884C\uFF09\u3002`));
|
|
2205
|
+
console.log(t(`Open (palettes loaded): ${url}`, `\u6253\u5F00\uFF08\u5DF2\u5E26\u914D\u8272\uFF09: ${url}`));
|
|
2206
|
+
openBrowser(url);
|
|
2207
|
+
}
|
|
2208
|
+
|
|
2209
|
+
// src/check.ts
|
|
2210
|
+
import { readFileSync, readdirSync, statSync as statSync2 } from "fs";
|
|
2211
|
+
import { join as join2, relative, resolve } from "path";
|
|
2212
|
+
function normalizeHex(raw) {
|
|
2213
|
+
const h = raw.replace(/^#/, "").toLowerCase();
|
|
2214
|
+
if (/^[0-9a-f]{3,4}$/.test(h)) {
|
|
2215
|
+
return "#" + h.slice(0, 3).split("").map((c) => c + c).join("");
|
|
2216
|
+
}
|
|
2217
|
+
if (/^[0-9a-f]{6}$/.test(h)) return "#" + h;
|
|
2218
|
+
if (/^[0-9a-f]{8}$/.test(h)) return "#" + h.slice(0, 6);
|
|
2219
|
+
return null;
|
|
2220
|
+
}
|
|
2221
|
+
function rgbToHex(r, g, b) {
|
|
2222
|
+
if ([r, g, b].some((v) => !Number.isInteger(v) || v < 0 || v > 255)) return null;
|
|
2223
|
+
return "#" + [r, g, b].map((v) => v.toString(16).padStart(2, "0")).join("");
|
|
2224
|
+
}
|
|
2225
|
+
function tokenHexes(w3c) {
|
|
2226
|
+
const out = /* @__PURE__ */ new Set();
|
|
2227
|
+
const visit = (node) => {
|
|
2228
|
+
if (!node || typeof node !== "object") return;
|
|
2229
|
+
const obj = node;
|
|
2230
|
+
if (obj.$type === "color" && typeof obj.$value === "string") {
|
|
2231
|
+
const hex = normalizeHex(obj.$value);
|
|
2232
|
+
if (hex) out.add(hex);
|
|
2233
|
+
const dark = obj.$extensions?.["design-system"]?.dark;
|
|
2234
|
+
if (typeof dark === "string") {
|
|
2235
|
+
const dh = normalizeHex(dark);
|
|
2236
|
+
if (dh) out.add(dh);
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
for (const v of Object.values(obj)) visit(v);
|
|
2240
|
+
};
|
|
2241
|
+
visit(w3c);
|
|
2242
|
+
out.add("#000000");
|
|
2243
|
+
return out;
|
|
2244
|
+
}
|
|
2245
|
+
var HEX_LITERAL = /#[0-9a-fA-F]{3,8}\b/g;
|
|
2246
|
+
var RGB_LITERAL = /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?\)/g;
|
|
2247
|
+
function scanText(text, allowed) {
|
|
2248
|
+
const found = [];
|
|
2249
|
+
const lines = text.split("\n");
|
|
2250
|
+
for (let i = 0; i < lines.length; i++) {
|
|
2251
|
+
const lineText = lines[i];
|
|
2252
|
+
for (const m of lineText.matchAll(HEX_LITERAL)) {
|
|
2253
|
+
const hex = normalizeHex(m[0]);
|
|
2254
|
+
if (hex && !allowed.has(hex)) found.push({ line: i + 1, literal: m[0], hex });
|
|
2255
|
+
}
|
|
2256
|
+
for (const m of lineText.matchAll(RGB_LITERAL)) {
|
|
2257
|
+
const hex = rgbToHex(Number(m[1]), Number(m[2]), Number(m[3]));
|
|
2258
|
+
if (hex && !allowed.has(hex)) found.push({ line: i + 1, literal: m[0], hex });
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
return found;
|
|
2262
|
+
}
|
|
2263
|
+
var SCAN_EXT = /* @__PURE__ */ new Set([
|
|
2264
|
+
"css",
|
|
2265
|
+
"scss",
|
|
2266
|
+
"sass",
|
|
2267
|
+
"less",
|
|
2268
|
+
"tsx",
|
|
2269
|
+
"jsx",
|
|
2270
|
+
"ts",
|
|
2271
|
+
"js",
|
|
2272
|
+
"mjs",
|
|
2273
|
+
"cjs",
|
|
2274
|
+
"html",
|
|
2275
|
+
"vue",
|
|
2276
|
+
"svelte",
|
|
2277
|
+
"astro"
|
|
2278
|
+
]);
|
|
2279
|
+
var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
2280
|
+
"node_modules",
|
|
2281
|
+
".git",
|
|
2282
|
+
".next",
|
|
2283
|
+
"dist",
|
|
2284
|
+
"build",
|
|
2285
|
+
"out",
|
|
2286
|
+
"coverage",
|
|
2287
|
+
"vendor",
|
|
2288
|
+
".vercel",
|
|
2289
|
+
".turbo"
|
|
2290
|
+
]);
|
|
2291
|
+
function collectFiles(root) {
|
|
2292
|
+
const files = [];
|
|
2293
|
+
const walk = (dir) => {
|
|
2294
|
+
let entries;
|
|
2295
|
+
try {
|
|
2296
|
+
entries = readdirSync(dir);
|
|
2297
|
+
} catch {
|
|
2298
|
+
return;
|
|
2299
|
+
}
|
|
2300
|
+
for (const name of entries) {
|
|
2301
|
+
if (name.startsWith(".") && name !== ".") continue;
|
|
2302
|
+
const full = join2(dir, name);
|
|
2303
|
+
let st2;
|
|
2304
|
+
try {
|
|
2305
|
+
st2 = statSync2(full);
|
|
2306
|
+
} catch {
|
|
2307
|
+
continue;
|
|
2308
|
+
}
|
|
2309
|
+
if (st2.isDirectory()) {
|
|
2310
|
+
if (!SKIP_DIRS.has(name)) walk(full);
|
|
2311
|
+
} else if (st2.isFile()) {
|
|
2312
|
+
const ext = name.split(".").pop() ?? "";
|
|
2313
|
+
if (SCAN_EXT.has(ext) && st2.size < 2 * 1024 * 1024) files.push(full);
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
};
|
|
2317
|
+
const st = statSync2(root);
|
|
2318
|
+
if (st.isFile()) return [root];
|
|
2319
|
+
walk(root);
|
|
2320
|
+
return files;
|
|
2321
|
+
}
|
|
2322
|
+
function runCheck(w3c, targets, allowExtra = []) {
|
|
2323
|
+
const allowed = tokenHexes(w3c);
|
|
2324
|
+
for (const raw of allowExtra) {
|
|
2325
|
+
const hex = normalizeHex(raw.trim());
|
|
2326
|
+
if (hex) allowed.add(hex);
|
|
2327
|
+
}
|
|
2328
|
+
const violations = [];
|
|
2329
|
+
let filesScanned = 0;
|
|
2330
|
+
for (const target of targets) {
|
|
2331
|
+
const root = resolve(target);
|
|
2332
|
+
for (const file of collectFiles(root)) {
|
|
2333
|
+
filesScanned++;
|
|
2334
|
+
let text;
|
|
2335
|
+
try {
|
|
2336
|
+
text = readFileSync(file, "utf8");
|
|
2337
|
+
} catch {
|
|
2338
|
+
continue;
|
|
2339
|
+
}
|
|
2340
|
+
const rel = relative(process.cwd(), file) || file;
|
|
2341
|
+
for (const v of scanText(text, allowed)) {
|
|
2342
|
+
violations.push({ file: rel, ...v });
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
return { violations, filesScanned, tokens: allowed };
|
|
2347
|
+
}
|
|
2348
|
+
function reportCheck(result) {
|
|
2349
|
+
const { violations, filesScanned } = result;
|
|
2350
|
+
if (violations.length === 0) {
|
|
2351
|
+
console.log(
|
|
2352
|
+
"\u2713 " + t(
|
|
2353
|
+
`${filesScanned} file(s) scanned \u2014 every color literal is in the design.md contract.`,
|
|
2354
|
+
`\u626B\u63CF ${filesScanned} \u4E2A\u6587\u4EF6\u2014\u2014\u6240\u6709\u989C\u8272\u5B57\u9762\u91CF\u90FD\u5728 design.md \u5951\u7EA6\u5185\u3002`
|
|
2355
|
+
)
|
|
2356
|
+
);
|
|
2357
|
+
return 0;
|
|
2358
|
+
}
|
|
2359
|
+
const byFile = /* @__PURE__ */ new Map();
|
|
2360
|
+
for (const v of violations) {
|
|
2361
|
+
const list = byFile.get(v.file) ?? [];
|
|
2362
|
+
list.push(v);
|
|
2363
|
+
byFile.set(v.file, list);
|
|
2364
|
+
}
|
|
2365
|
+
console.error(
|
|
2366
|
+
"\u2717 " + t(
|
|
2367
|
+
`${violations.length} color(s) outside the contract in ${byFile.size} file(s):`,
|
|
2368
|
+
`\u53D1\u73B0 ${violations.length} \u4E2A\u5951\u7EA6\u5916\u989C\u8272\uFF0C\u5206\u5E03\u5728 ${byFile.size} \u4E2A\u6587\u4EF6\uFF1A`
|
|
2369
|
+
)
|
|
2370
|
+
);
|
|
2371
|
+
for (const [file, list] of byFile) {
|
|
2372
|
+
console.error(`
|
|
2373
|
+
${file}`);
|
|
2374
|
+
for (const v of list.slice(0, 20)) {
|
|
2375
|
+
console.error(` ${String(v.line).padStart(4)} ${v.literal}`);
|
|
2376
|
+
}
|
|
2377
|
+
if (list.length > 20) {
|
|
2378
|
+
console.error(" " + t(`\u2026 and ${list.length - 20} more`, `\u2026 \u53E6\u6709 ${list.length - 20} \u5904`));
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
console.error(
|
|
2382
|
+
"\n" + t(
|
|
2383
|
+
'Fix: reference tokens via var(--color-\u2026), or derive shades in OKLCH (lightness only). Intentional exceptions: --allow "#hex,#hex".',
|
|
2384
|
+
'\u4FEE\u590D\uFF1A\u6539\u7528 var(--color-\u2026) \u5F15\u7528 token\uFF0C\u6216\u5728 OKLCH \u91CC\u53EA\u8C03\u4EAE\u5EA6\u6D3E\u751F\u8272\u9636\u3002\u523B\u610F\u4F8B\u5916\u53EF\u7528 --allow "#hex,#hex" \u653E\u884C\u3002'
|
|
2385
|
+
)
|
|
2386
|
+
);
|
|
2387
|
+
return 1;
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
// src/cli.ts
|
|
2391
|
+
var FORMATS = ["css", "tailwind", "w3c"];
|
|
2392
|
+
function fail(msg) {
|
|
2393
|
+
console.error(`\u2717 ${msg}`);
|
|
2394
|
+
process.exit(1);
|
|
2395
|
+
}
|
|
2396
|
+
function parseArgs(argv) {
|
|
2397
|
+
const positional = [];
|
|
2398
|
+
const opts = {};
|
|
2399
|
+
for (let i = 0; i < argv.length; i++) {
|
|
2400
|
+
const a = argv[i];
|
|
2401
|
+
if (a.startsWith("--")) opts[a.slice(2)] = argv[++i] ?? "";
|
|
2402
|
+
else positional.push(a);
|
|
2403
|
+
}
|
|
2404
|
+
return { positional, opts };
|
|
2405
|
+
}
|
|
2406
|
+
function readMd(file) {
|
|
2407
|
+
if (!file)
|
|
2408
|
+
fail(
|
|
2409
|
+
t(
|
|
2410
|
+
"Usage: design-pact <add|inspect|check> <design.md> [options]",
|
|
2411
|
+
"\u7528\u6CD5\uFF1Adesign-pact <add|inspect|check> <design.md> [\u9009\u9879]"
|
|
2412
|
+
)
|
|
2413
|
+
);
|
|
2414
|
+
try {
|
|
2415
|
+
return readFileSync2(resolve2(file), "utf8");
|
|
2416
|
+
} catch {
|
|
2417
|
+
return fail(t(`Cannot read file: ${file}`, `\u8BFB\u4E0D\u5230\u6587\u4EF6\uFF1A${file}`));
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
function cmdInspect(file) {
|
|
2421
|
+
const { w3c } = parseDesignSystem(readMd(file));
|
|
2422
|
+
const color = w3c.color ?? {};
|
|
2423
|
+
const typo = w3c.typography ?? {};
|
|
2424
|
+
const ext = typo.$extensions?.["design-system"] ?? {};
|
|
2425
|
+
console.log(t("Design system summary", "\u8BBE\u8BA1\u7CFB\u7EDF\u6458\u8981"));
|
|
2426
|
+
console.log(t(" Colors:", " \u989C\u8272\uFF1A"));
|
|
2427
|
+
for (const [role, v] of Object.entries(color)) console.log(` ${role.padEnd(12)} ${v.$value}`);
|
|
2428
|
+
if (ext.base) console.log(t(` Type base ${ext.base} \xB7 ratio ${ext.ratio}`, ` \u5B57\u53F7 base ${ext.base} \xB7 ratio ${ext.ratio}`));
|
|
2429
|
+
const fam = typo.fontFamily ?? {};
|
|
2430
|
+
if (fam.body) console.log(t(` Body font ${fam.body.$value}`, ` \u6B63\u6587\u5B57\u4F53 ${fam.body.$value}`));
|
|
2431
|
+
if (fam.heading) console.log(t(` Heading font ${fam.heading.$value}`, ` \u6807\u9898\u5B57\u4F53 ${fam.heading.$value}`));
|
|
2432
|
+
}
|
|
2433
|
+
function cmdAdd(file, opts) {
|
|
2434
|
+
const ds = parseDesignSystem(readMd(file));
|
|
2435
|
+
const fmt = opts.format || "all";
|
|
2436
|
+
if (fmt !== "all" && !FORMATS.includes(fmt))
|
|
2437
|
+
fail(t(`Unknown format: ${fmt} (css|tailwind|w3c|all)`, `\u672A\u77E5\u683C\u5F0F\uFF1A${fmt}\uFF08css|tailwind|w3c|all\uFF09`));
|
|
2438
|
+
const want = fmt === "all" ? FORMATS : [fmt];
|
|
2439
|
+
const outDir = resolve2(opts.out || ".");
|
|
2440
|
+
mkdirSync(outDir, { recursive: true });
|
|
2441
|
+
const written = [];
|
|
2442
|
+
const write = (name, content) => {
|
|
2443
|
+
writeFileSync(join3(outDir, name), content, "utf8");
|
|
2444
|
+
written.push(name);
|
|
2445
|
+
};
|
|
2446
|
+
for (const f of want) {
|
|
2447
|
+
if (f === "css") write("tokens.css", ds.rootCss);
|
|
2448
|
+
else if (f === "w3c") write("design-tokens.json", ds.w3cText);
|
|
2449
|
+
else if (f === "tailwind") write("tailwind.config.js", tailwindFromW3C(ds.w3cText));
|
|
2450
|
+
}
|
|
2451
|
+
console.log(t(`\u2713 Wrote ${outDir}: ${written.join(", ")}`, `\u2713 \u5199\u5165 ${outDir}\uFF1A${written.join(", ")}`));
|
|
2452
|
+
}
|
|
2453
|
+
async function main() {
|
|
2454
|
+
const [cmd, ...rest] = process.argv.slice(2);
|
|
2455
|
+
const { positional, opts } = parseArgs(rest);
|
|
2456
|
+
switch (cmd) {
|
|
2457
|
+
case "init":
|
|
2458
|
+
return cmdInit(rest);
|
|
2459
|
+
case "open":
|
|
2460
|
+
return cmdOpen(rest);
|
|
2461
|
+
case "__serve":
|
|
2462
|
+
return serveStatic(Number(positional[0]) || 3e3);
|
|
2463
|
+
case "add":
|
|
2464
|
+
return cmdAdd(positional[0], opts);
|
|
2465
|
+
case "inspect":
|
|
2466
|
+
return cmdInspect(positional[0]);
|
|
2467
|
+
case "check": {
|
|
2468
|
+
const ds = parseDesignSystem(readMd(positional[0]));
|
|
2469
|
+
const targets = positional.slice(1);
|
|
2470
|
+
const allow = (opts.allow ?? "").split(",").filter(Boolean);
|
|
2471
|
+
const result = runCheck(ds.w3c, targets.length > 0 ? targets : ["."], allow);
|
|
2472
|
+
process.exit(reportCheck(result));
|
|
2473
|
+
}
|
|
2474
|
+
case void 0:
|
|
2475
|
+
case "-h":
|
|
2476
|
+
case "--help":
|
|
2477
|
+
console.log(
|
|
2478
|
+
[
|
|
2479
|
+
t(
|
|
2480
|
+
"design-pact \u2014 set up and use your design system (zero backend, zero account)",
|
|
2481
|
+
"design-pact \u2014 \u8BBE\u7F6E\u5E76\u4F7F\u7528\u4F60\u7684\u8BBE\u8BA1\u7CFB\u7EDF\uFF08\u96F6\u540E\u7AEF\u3001\u96F6\u8D26\u6237\uFF09"
|
|
2482
|
+
),
|
|
2483
|
+
"",
|
|
2484
|
+
t(
|
|
2485
|
+
" init [--global] install the skill into .claude/skills",
|
|
2486
|
+
" init [--global] \u628A skill \u88C5\u8FDB .claude/skills"
|
|
2487
|
+
),
|
|
2488
|
+
t(
|
|
2489
|
+
' open ["p=\u2026&p=\u2026"] start the local studio and open the browser',
|
|
2490
|
+
' open ["p=\u2026&p=\u2026"] \u672C\u5730\u8D77\u914D\u8272\u5DE5\u5177\u5E76\u6253\u5F00\u6D4F\u89C8\u5668'
|
|
2491
|
+
),
|
|
2492
|
+
t(
|
|
2493
|
+
" add <file> [--format css|tailwind|w3c|all] [--out .] convert design.md into token files",
|
|
2494
|
+
" add <file> [--format css|tailwind|w3c|all] [--out .] \u628A design.md \u8F6C\u6210 token \u6587\u4EF6"
|
|
2495
|
+
),
|
|
2496
|
+
t(
|
|
2497
|
+
" inspect <file> print a design-system summary",
|
|
2498
|
+
" inspect <file> \u6253\u5370\u8BBE\u8BA1\u7CFB\u7EDF\u6458\u8981"
|
|
2499
|
+
),
|
|
2500
|
+
t(
|
|
2501
|
+
' check <file> [paths\u2026] [--allow "#hex,#hex"] find color literals outside the contract',
|
|
2502
|
+
' check <file> [paths\u2026] [--allow "#hex,#hex"] \u627E\u51FA\u5951\u7EA6\u5916\u7684\u989C\u8272\u5B57\u9762\u91CF'
|
|
2503
|
+
),
|
|
2504
|
+
"",
|
|
2505
|
+
t(
|
|
2506
|
+
'design.md is exported from the studio ("Download design.md").',
|
|
2507
|
+
"design.md \u7531\u672C\u5DE5\u5177\u7F51\u9875\u300C\u4E0B\u8F7D design.md\u300D\u5BFC\u51FA\u3002"
|
|
2508
|
+
)
|
|
2509
|
+
].join("\n")
|
|
2510
|
+
);
|
|
2511
|
+
return;
|
|
2512
|
+
default:
|
|
2513
|
+
fail(t(`Unknown command: ${cmd} (init|open|add|inspect|check)`, `\u672A\u77E5\u547D\u4EE4\uFF1A${cmd}\uFF08init|open|add|inspect|check\uFF09`));
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
main().catch((e) => fail(e instanceof Error ? e.message : String(e)));
|
|
2517
|
+
/*! Bundled license information:
|
|
2518
|
+
|
|
2519
|
+
react/cjs/react.production.js:
|
|
2520
|
+
(**
|
|
2521
|
+
* @license React
|
|
2522
|
+
* react.production.js
|
|
2523
|
+
*
|
|
2524
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2525
|
+
*
|
|
2526
|
+
* This source code is licensed under the MIT license found in the
|
|
2527
|
+
* LICENSE file in the root directory of this source tree.
|
|
2528
|
+
*)
|
|
2529
|
+
|
|
2530
|
+
react/cjs/react.development.js:
|
|
2531
|
+
(**
|
|
2532
|
+
* @license React
|
|
2533
|
+
* react.development.js
|
|
2534
|
+
*
|
|
2535
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2536
|
+
*
|
|
2537
|
+
* This source code is licensed under the MIT license found in the
|
|
2538
|
+
* LICENSE file in the root directory of this source tree.
|
|
2539
|
+
*)
|
|
2540
|
+
*/
|