@react-devtools-plus/shared 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 webfansplz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @react-devtools-plus/shared
2
+
3
+ > Internal utility types shared across react-devtools packages.
package/dist/index.cjs ADDED
@@ -0,0 +1,279 @@
1
+ //#region rolldown:runtime
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() {
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") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
13
+ key = keys[i];
14
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target$1) => (target$1 = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target$1, "default", {
22
+ value: mod,
23
+ enumerable: true
24
+ }) : target$1, mod));
25
+
26
+ //#endregion
27
+
28
+ //#region src/constants.ts
29
+ const VIEW_MODE_STORAGE_KEY = "__react-devtools-view-mode__";
30
+ const VITE_PLUGIN_DETECTED_STORAGE_KEY = "__react-devtools-vite-plugin-detected__";
31
+ const VITE_PLUGIN_CLIENT_URL_STORAGE_KEY = "__react-devtools-vite-plugin-client-url__";
32
+ const BROADCAST_CHANNEL_NAME = "__react-devtools-broadcast-channel__";
33
+
34
+ //#endregion
35
+ //#region src/env.ts
36
+ var _navigator$userAgent;
37
+ const isBrowser = typeof navigator !== "undefined";
38
+ const target = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : typeof global !== "undefined" ? global : {};
39
+ const isInChromePanel = typeof target.chrome !== "undefined" && !!target.chrome.devtools;
40
+ const isInIframe = isBrowser && target.self !== target.top;
41
+ const isInElectron = typeof navigator !== "undefined" && ((_navigator$userAgent = navigator.userAgent) === null || _navigator$userAgent === void 0 ? void 0 : _navigator$userAgent.toLowerCase().includes("electron"));
42
+ const isNuxtApp = typeof window !== "undefined" && !!window.__NUXT__;
43
+ const isInSeparateWindow = !isInIframe && !isInChromePanel && !isInElectron;
44
+
45
+ //#endregion
46
+ //#region ../../node_modules/.pnpm/rfdc@1.4.1/node_modules/rfdc/index.js
47
+ var require_rfdc = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/rfdc@1.4.1/node_modules/rfdc/index.js": ((exports, module) => {
48
+ module.exports = rfdc$1;
49
+ function copyBuffer(cur) {
50
+ if (cur instanceof Buffer) return Buffer.from(cur);
51
+ return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length);
52
+ }
53
+ function rfdc$1(opts) {
54
+ opts = opts || {};
55
+ if (opts.circles) return rfdcCircles(opts);
56
+ const constructorHandlers = /* @__PURE__ */ new Map();
57
+ constructorHandlers.set(Date, (o) => new Date(o));
58
+ constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)));
59
+ constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)));
60
+ if (opts.constructorHandlers) for (const handler$1 of opts.constructorHandlers) constructorHandlers.set(handler$1[0], handler$1[1]);
61
+ let handler = null;
62
+ return opts.proto ? cloneProto : clone;
63
+ function cloneArray(a, fn) {
64
+ const keys = Object.keys(a);
65
+ const a2 = new Array(keys.length);
66
+ for (let i = 0; i < keys.length; i++) {
67
+ const k = keys[i];
68
+ const cur = a[k];
69
+ if (typeof cur !== "object" || cur === null) a2[k] = cur;
70
+ else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) a2[k] = handler(cur, fn);
71
+ else if (ArrayBuffer.isView(cur)) a2[k] = copyBuffer(cur);
72
+ else a2[k] = fn(cur);
73
+ }
74
+ return a2;
75
+ }
76
+ function clone(o) {
77
+ if (typeof o !== "object" || o === null) return o;
78
+ if (Array.isArray(o)) return cloneArray(o, clone);
79
+ if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) return handler(o, clone);
80
+ const o2 = {};
81
+ for (const k in o) {
82
+ if (Object.hasOwnProperty.call(o, k) === false) continue;
83
+ const cur = o[k];
84
+ if (typeof cur !== "object" || cur === null) o2[k] = cur;
85
+ else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) o2[k] = handler(cur, clone);
86
+ else if (ArrayBuffer.isView(cur)) o2[k] = copyBuffer(cur);
87
+ else o2[k] = clone(cur);
88
+ }
89
+ return o2;
90
+ }
91
+ function cloneProto(o) {
92
+ if (typeof o !== "object" || o === null) return o;
93
+ if (Array.isArray(o)) return cloneArray(o, cloneProto);
94
+ if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) return handler(o, cloneProto);
95
+ const o2 = {};
96
+ for (const k in o) {
97
+ const cur = o[k];
98
+ if (typeof cur !== "object" || cur === null) o2[k] = cur;
99
+ else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) o2[k] = handler(cur, cloneProto);
100
+ else if (ArrayBuffer.isView(cur)) o2[k] = copyBuffer(cur);
101
+ else o2[k] = cloneProto(cur);
102
+ }
103
+ return o2;
104
+ }
105
+ }
106
+ function rfdcCircles(opts) {
107
+ const refs = [];
108
+ const refsNew = [];
109
+ const constructorHandlers = /* @__PURE__ */ new Map();
110
+ constructorHandlers.set(Date, (o) => new Date(o));
111
+ constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)));
112
+ constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)));
113
+ if (opts.constructorHandlers) for (const handler$1 of opts.constructorHandlers) constructorHandlers.set(handler$1[0], handler$1[1]);
114
+ let handler = null;
115
+ return opts.proto ? cloneProto : clone;
116
+ function cloneArray(a, fn) {
117
+ const keys = Object.keys(a);
118
+ const a2 = new Array(keys.length);
119
+ for (let i = 0; i < keys.length; i++) {
120
+ const k = keys[i];
121
+ const cur = a[k];
122
+ if (typeof cur !== "object" || cur === null) a2[k] = cur;
123
+ else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) a2[k] = handler(cur, fn);
124
+ else if (ArrayBuffer.isView(cur)) a2[k] = copyBuffer(cur);
125
+ else {
126
+ const index = refs.indexOf(cur);
127
+ if (index !== -1) a2[k] = refsNew[index];
128
+ else a2[k] = fn(cur);
129
+ }
130
+ }
131
+ return a2;
132
+ }
133
+ function clone(o) {
134
+ if (typeof o !== "object" || o === null) return o;
135
+ if (Array.isArray(o)) return cloneArray(o, clone);
136
+ if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) return handler(o, clone);
137
+ const o2 = {};
138
+ refs.push(o);
139
+ refsNew.push(o2);
140
+ for (const k in o) {
141
+ if (Object.hasOwnProperty.call(o, k) === false) continue;
142
+ const cur = o[k];
143
+ if (typeof cur !== "object" || cur === null) o2[k] = cur;
144
+ else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) o2[k] = handler(cur, clone);
145
+ else if (ArrayBuffer.isView(cur)) o2[k] = copyBuffer(cur);
146
+ else {
147
+ const i = refs.indexOf(cur);
148
+ if (i !== -1) o2[k] = refsNew[i];
149
+ else o2[k] = clone(cur);
150
+ }
151
+ }
152
+ refs.pop();
153
+ refsNew.pop();
154
+ return o2;
155
+ }
156
+ function cloneProto(o) {
157
+ if (typeof o !== "object" || o === null) return o;
158
+ if (Array.isArray(o)) return cloneArray(o, cloneProto);
159
+ if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) return handler(o, cloneProto);
160
+ const o2 = {};
161
+ refs.push(o);
162
+ refsNew.push(o2);
163
+ for (const k in o) {
164
+ const cur = o[k];
165
+ if (typeof cur !== "object" || cur === null) o2[k] = cur;
166
+ else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) o2[k] = handler(cur, cloneProto);
167
+ else if (ArrayBuffer.isView(cur)) o2[k] = copyBuffer(cur);
168
+ else {
169
+ const i = refs.indexOf(cur);
170
+ if (i !== -1) o2[k] = refsNew[i];
171
+ else o2[k] = cloneProto(cur);
172
+ }
173
+ }
174
+ refs.pop();
175
+ refsNew.pop();
176
+ return o2;
177
+ }
178
+ }
179
+ }) });
180
+
181
+ //#endregion
182
+ //#region src/general.ts
183
+ var import_rfdc = /* @__PURE__ */ __toESM(require_rfdc(), 1);
184
+ function NOOP() {}
185
+ const isNumeric = (str) => `${+str}` === str;
186
+ const isMacOS = () => {
187
+ var _navigator, _navigator2;
188
+ return ((_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.platform) ? (_navigator2 = navigator) === null || _navigator2 === void 0 ? void 0 : _navigator2.platform.toLowerCase().includes("mac") : /Macintosh/.test(navigator.userAgent);
189
+ };
190
+ const classifyRE = /(?:^|[-_/])(\w)/g;
191
+ const camelizeRE = /-(\w)/g;
192
+ const kebabizeRE = /([a-z0-9])([A-Z])/g;
193
+ function toUpper(_, c) {
194
+ return c ? c.toUpperCase() : "";
195
+ }
196
+ function classify(str) {
197
+ return str && `${str}`.replace(classifyRE, toUpper);
198
+ }
199
+ function camelize(str) {
200
+ return str && str.replace(camelizeRE, toUpper);
201
+ }
202
+ function kebabize(str) {
203
+ return str && str.replace(kebabizeRE, (_, lowerCaseCharacter, upperCaseLetter) => {
204
+ return `${lowerCaseCharacter}-${upperCaseLetter}`;
205
+ }).toLowerCase();
206
+ }
207
+ function basename(filename, ext) {
208
+ let normalizedFilename = filename.replace(/^[a-z]:/i, "").replace(/\\/g, "/");
209
+ if (normalizedFilename.endsWith(`index${ext}`)) normalizedFilename = normalizedFilename.replace(`/index${ext}`, ext);
210
+ const lastSlashIndex = normalizedFilename.lastIndexOf("/");
211
+ const baseNameWithExt = normalizedFilename.substring(lastSlashIndex + 1);
212
+ if (ext) {
213
+ const extIndex = baseNameWithExt.lastIndexOf(ext);
214
+ return baseNameWithExt.substring(0, extIndex);
215
+ }
216
+ return "";
217
+ }
218
+ function sortByKey(state) {
219
+ return state && state.slice().sort((a, b) => {
220
+ if (a.key < b.key) return -1;
221
+ if (a.key > b.key) return 1;
222
+ return 0;
223
+ });
224
+ }
225
+ const HTTP_URL_RE = /^https?:\/\//;
226
+ /**
227
+ * Check a string is start with `/` or a valid http url
228
+ */
229
+ function isUrlString(str) {
230
+ return str.startsWith("/") || HTTP_URL_RE.test(str);
231
+ }
232
+ /**
233
+ * @copyright [rfdc](https://github.com/davidmarkclements/rfdc)
234
+ * @description A really fast deep clone alternative
235
+ */
236
+ const deepClone = (0, import_rfdc.default)({ circles: true });
237
+ function randomStr() {
238
+ return Math.random().toString(36).slice(2);
239
+ }
240
+ function isObject(value) {
241
+ return typeof value === "object" && !Array.isArray(value) && value !== null;
242
+ }
243
+ function isArray(value) {
244
+ return Array.isArray(value);
245
+ }
246
+ function isSet(value) {
247
+ return value instanceof Set;
248
+ }
249
+ function isMap(value) {
250
+ return value instanceof Map;
251
+ }
252
+
253
+ //#endregion
254
+ exports.BROADCAST_CHANNEL_NAME = BROADCAST_CHANNEL_NAME;
255
+ exports.NOOP = NOOP;
256
+ exports.VIEW_MODE_STORAGE_KEY = VIEW_MODE_STORAGE_KEY;
257
+ exports.VITE_PLUGIN_CLIENT_URL_STORAGE_KEY = VITE_PLUGIN_CLIENT_URL_STORAGE_KEY;
258
+ exports.VITE_PLUGIN_DETECTED_STORAGE_KEY = VITE_PLUGIN_DETECTED_STORAGE_KEY;
259
+ exports.basename = basename;
260
+ exports.camelize = camelize;
261
+ exports.classify = classify;
262
+ exports.deepClone = deepClone;
263
+ exports.isArray = isArray;
264
+ exports.isBrowser = isBrowser;
265
+ exports.isInChromePanel = isInChromePanel;
266
+ exports.isInElectron = isInElectron;
267
+ exports.isInIframe = isInIframe;
268
+ exports.isInSeparateWindow = isInSeparateWindow;
269
+ exports.isMacOS = isMacOS;
270
+ exports.isMap = isMap;
271
+ exports.isNumeric = isNumeric;
272
+ exports.isNuxtApp = isNuxtApp;
273
+ exports.isObject = isObject;
274
+ exports.isSet = isSet;
275
+ exports.isUrlString = isUrlString;
276
+ exports.kebabize = kebabize;
277
+ exports.randomStr = randomStr;
278
+ exports.sortByKey = sortByKey;
279
+ exports.target = target;
@@ -0,0 +1,40 @@
1
+ //#region src/constants.d.ts
2
+ declare const VIEW_MODE_STORAGE_KEY = "__react-devtools-view-mode__";
3
+ declare const VITE_PLUGIN_DETECTED_STORAGE_KEY = "__react-devtools-vite-plugin-detected__";
4
+ declare const VITE_PLUGIN_CLIENT_URL_STORAGE_KEY = "__react-devtools-vite-plugin-client-url__";
5
+ declare const BROADCAST_CHANNEL_NAME = "__react-devtools-broadcast-channel__";
6
+ //#endregion
7
+ //#region src/env.d.ts
8
+ declare const isBrowser: boolean;
9
+ declare const target: typeof globalThis;
10
+ declare const isInChromePanel: boolean;
11
+ declare const isInIframe: boolean;
12
+ declare const isInElectron: boolean;
13
+ declare const isNuxtApp: boolean;
14
+ declare const isInSeparateWindow: boolean;
15
+ //#endregion
16
+ //#region src/general.d.ts
17
+ declare function NOOP(): void;
18
+ declare const isNumeric: (str: string | number) => boolean;
19
+ declare const isMacOS: () => boolean;
20
+ declare function classify(str: string): string;
21
+ declare function camelize(str: string): string;
22
+ declare function kebabize(str: string): string;
23
+ declare function basename(filename: string, ext: string): string;
24
+ declare function sortByKey(state: unknown[]): Record<"key", number>[];
25
+ /**
26
+ * Check a string is start with `/` or a valid http url
27
+ */
28
+ declare function isUrlString(str: string): boolean;
29
+ /**
30
+ * @copyright [rfdc](https://github.com/davidmarkclements/rfdc)
31
+ * @description A really fast deep clone alternative
32
+ */
33
+ declare const deepClone: <T>(input: T) => T;
34
+ declare function randomStr(): string;
35
+ declare function isObject<T extends object>(value: any): value is T;
36
+ declare function isArray<T>(value: any): value is T[];
37
+ declare function isSet<T>(value: any): value is Set<T>;
38
+ declare function isMap<K, V>(value: any): value is Map<K, V>;
39
+ //#endregion
40
+ export { BROADCAST_CHANNEL_NAME, NOOP, VIEW_MODE_STORAGE_KEY, VITE_PLUGIN_CLIENT_URL_STORAGE_KEY, VITE_PLUGIN_DETECTED_STORAGE_KEY, basename, camelize, classify, deepClone, isArray, isBrowser, isInChromePanel, isInElectron, isInIframe, isInSeparateWindow, isMacOS, isMap, isNumeric, isNuxtApp, isObject, isSet, isUrlString, kebabize, randomStr, sortByKey, target };
@@ -0,0 +1,40 @@
1
+ //#region src/constants.d.ts
2
+ declare const VIEW_MODE_STORAGE_KEY = "__react-devtools-view-mode__";
3
+ declare const VITE_PLUGIN_DETECTED_STORAGE_KEY = "__react-devtools-vite-plugin-detected__";
4
+ declare const VITE_PLUGIN_CLIENT_URL_STORAGE_KEY = "__react-devtools-vite-plugin-client-url__";
5
+ declare const BROADCAST_CHANNEL_NAME = "__react-devtools-broadcast-channel__";
6
+ //#endregion
7
+ //#region src/env.d.ts
8
+ declare const isBrowser: boolean;
9
+ declare const target: typeof globalThis;
10
+ declare const isInChromePanel: boolean;
11
+ declare const isInIframe: boolean;
12
+ declare const isInElectron: boolean;
13
+ declare const isNuxtApp: boolean;
14
+ declare const isInSeparateWindow: boolean;
15
+ //#endregion
16
+ //#region src/general.d.ts
17
+ declare function NOOP(): void;
18
+ declare const isNumeric: (str: string | number) => boolean;
19
+ declare const isMacOS: () => boolean;
20
+ declare function classify(str: string): string;
21
+ declare function camelize(str: string): string;
22
+ declare function kebabize(str: string): string;
23
+ declare function basename(filename: string, ext: string): string;
24
+ declare function sortByKey(state: unknown[]): Record<"key", number>[];
25
+ /**
26
+ * Check a string is start with `/` or a valid http url
27
+ */
28
+ declare function isUrlString(str: string): boolean;
29
+ /**
30
+ * @copyright [rfdc](https://github.com/davidmarkclements/rfdc)
31
+ * @description A really fast deep clone alternative
32
+ */
33
+ declare const deepClone: <T>(input: T) => T;
34
+ declare function randomStr(): string;
35
+ declare function isObject<T extends object>(value: any): value is T;
36
+ declare function isArray<T>(value: any): value is T[];
37
+ declare function isSet<T>(value: any): value is Set<T>;
38
+ declare function isMap<K, V>(value: any): value is Map<K, V>;
39
+ //#endregion
40
+ export { BROADCAST_CHANNEL_NAME, NOOP, VIEW_MODE_STORAGE_KEY, VITE_PLUGIN_CLIENT_URL_STORAGE_KEY, VITE_PLUGIN_DETECTED_STORAGE_KEY, basename, camelize, classify, deepClone, isArray, isBrowser, isInChromePanel, isInElectron, isInIframe, isInSeparateWindow, isMacOS, isMap, isNumeric, isNuxtApp, isObject, isSet, isUrlString, kebabize, randomStr, sortByKey, target };
package/dist/index.js ADDED
@@ -0,0 +1,253 @@
1
+ //#region rolldown:runtime
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() {
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") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
13
+ key = keys[i];
14
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target$1) => (target$1 = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target$1, "default", {
22
+ value: mod,
23
+ enumerable: true
24
+ }) : target$1, mod));
25
+
26
+ //#endregion
27
+ //#region src/constants.ts
28
+ const VIEW_MODE_STORAGE_KEY = "__react-devtools-view-mode__";
29
+ const VITE_PLUGIN_DETECTED_STORAGE_KEY = "__react-devtools-vite-plugin-detected__";
30
+ const VITE_PLUGIN_CLIENT_URL_STORAGE_KEY = "__react-devtools-vite-plugin-client-url__";
31
+ const BROADCAST_CHANNEL_NAME = "__react-devtools-broadcast-channel__";
32
+
33
+ //#endregion
34
+ //#region src/env.ts
35
+ var _navigator$userAgent;
36
+ const isBrowser = typeof navigator !== "undefined";
37
+ const target = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : typeof global !== "undefined" ? global : {};
38
+ const isInChromePanel = typeof target.chrome !== "undefined" && !!target.chrome.devtools;
39
+ const isInIframe = isBrowser && target.self !== target.top;
40
+ const isInElectron = typeof navigator !== "undefined" && ((_navigator$userAgent = navigator.userAgent) === null || _navigator$userAgent === void 0 ? void 0 : _navigator$userAgent.toLowerCase().includes("electron"));
41
+ const isNuxtApp = typeof window !== "undefined" && !!window.__NUXT__;
42
+ const isInSeparateWindow = !isInIframe && !isInChromePanel && !isInElectron;
43
+
44
+ //#endregion
45
+ //#region ../../node_modules/.pnpm/rfdc@1.4.1/node_modules/rfdc/index.js
46
+ var require_rfdc = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/rfdc@1.4.1/node_modules/rfdc/index.js": ((exports, module) => {
47
+ module.exports = rfdc$1;
48
+ function copyBuffer(cur) {
49
+ if (cur instanceof Buffer) return Buffer.from(cur);
50
+ return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length);
51
+ }
52
+ function rfdc$1(opts) {
53
+ opts = opts || {};
54
+ if (opts.circles) return rfdcCircles(opts);
55
+ const constructorHandlers = /* @__PURE__ */ new Map();
56
+ constructorHandlers.set(Date, (o) => new Date(o));
57
+ constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)));
58
+ constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)));
59
+ if (opts.constructorHandlers) for (const handler$1 of opts.constructorHandlers) constructorHandlers.set(handler$1[0], handler$1[1]);
60
+ let handler = null;
61
+ return opts.proto ? cloneProto : clone;
62
+ function cloneArray(a, fn) {
63
+ const keys = Object.keys(a);
64
+ const a2 = new Array(keys.length);
65
+ for (let i = 0; i < keys.length; i++) {
66
+ const k = keys[i];
67
+ const cur = a[k];
68
+ if (typeof cur !== "object" || cur === null) a2[k] = cur;
69
+ else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) a2[k] = handler(cur, fn);
70
+ else if (ArrayBuffer.isView(cur)) a2[k] = copyBuffer(cur);
71
+ else a2[k] = fn(cur);
72
+ }
73
+ return a2;
74
+ }
75
+ function clone(o) {
76
+ if (typeof o !== "object" || o === null) return o;
77
+ if (Array.isArray(o)) return cloneArray(o, clone);
78
+ if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) return handler(o, clone);
79
+ const o2 = {};
80
+ for (const k in o) {
81
+ if (Object.hasOwnProperty.call(o, k) === false) continue;
82
+ const cur = o[k];
83
+ if (typeof cur !== "object" || cur === null) o2[k] = cur;
84
+ else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) o2[k] = handler(cur, clone);
85
+ else if (ArrayBuffer.isView(cur)) o2[k] = copyBuffer(cur);
86
+ else o2[k] = clone(cur);
87
+ }
88
+ return o2;
89
+ }
90
+ function cloneProto(o) {
91
+ if (typeof o !== "object" || o === null) return o;
92
+ if (Array.isArray(o)) return cloneArray(o, cloneProto);
93
+ if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) return handler(o, cloneProto);
94
+ const o2 = {};
95
+ for (const k in o) {
96
+ const cur = o[k];
97
+ if (typeof cur !== "object" || cur === null) o2[k] = cur;
98
+ else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) o2[k] = handler(cur, cloneProto);
99
+ else if (ArrayBuffer.isView(cur)) o2[k] = copyBuffer(cur);
100
+ else o2[k] = cloneProto(cur);
101
+ }
102
+ return o2;
103
+ }
104
+ }
105
+ function rfdcCircles(opts) {
106
+ const refs = [];
107
+ const refsNew = [];
108
+ const constructorHandlers = /* @__PURE__ */ new Map();
109
+ constructorHandlers.set(Date, (o) => new Date(o));
110
+ constructorHandlers.set(Map, (o, fn) => new Map(cloneArray(Array.from(o), fn)));
111
+ constructorHandlers.set(Set, (o, fn) => new Set(cloneArray(Array.from(o), fn)));
112
+ if (opts.constructorHandlers) for (const handler$1 of opts.constructorHandlers) constructorHandlers.set(handler$1[0], handler$1[1]);
113
+ let handler = null;
114
+ return opts.proto ? cloneProto : clone;
115
+ function cloneArray(a, fn) {
116
+ const keys = Object.keys(a);
117
+ const a2 = new Array(keys.length);
118
+ for (let i = 0; i < keys.length; i++) {
119
+ const k = keys[i];
120
+ const cur = a[k];
121
+ if (typeof cur !== "object" || cur === null) a2[k] = cur;
122
+ else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) a2[k] = handler(cur, fn);
123
+ else if (ArrayBuffer.isView(cur)) a2[k] = copyBuffer(cur);
124
+ else {
125
+ const index = refs.indexOf(cur);
126
+ if (index !== -1) a2[k] = refsNew[index];
127
+ else a2[k] = fn(cur);
128
+ }
129
+ }
130
+ return a2;
131
+ }
132
+ function clone(o) {
133
+ if (typeof o !== "object" || o === null) return o;
134
+ if (Array.isArray(o)) return cloneArray(o, clone);
135
+ if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) return handler(o, clone);
136
+ const o2 = {};
137
+ refs.push(o);
138
+ refsNew.push(o2);
139
+ for (const k in o) {
140
+ if (Object.hasOwnProperty.call(o, k) === false) continue;
141
+ const cur = o[k];
142
+ if (typeof cur !== "object" || cur === null) o2[k] = cur;
143
+ else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) o2[k] = handler(cur, clone);
144
+ else if (ArrayBuffer.isView(cur)) o2[k] = copyBuffer(cur);
145
+ else {
146
+ const i = refs.indexOf(cur);
147
+ if (i !== -1) o2[k] = refsNew[i];
148
+ else o2[k] = clone(cur);
149
+ }
150
+ }
151
+ refs.pop();
152
+ refsNew.pop();
153
+ return o2;
154
+ }
155
+ function cloneProto(o) {
156
+ if (typeof o !== "object" || o === null) return o;
157
+ if (Array.isArray(o)) return cloneArray(o, cloneProto);
158
+ if (o.constructor !== Object && (handler = constructorHandlers.get(o.constructor))) return handler(o, cloneProto);
159
+ const o2 = {};
160
+ refs.push(o);
161
+ refsNew.push(o2);
162
+ for (const k in o) {
163
+ const cur = o[k];
164
+ if (typeof cur !== "object" || cur === null) o2[k] = cur;
165
+ else if (cur.constructor !== Object && (handler = constructorHandlers.get(cur.constructor))) o2[k] = handler(cur, cloneProto);
166
+ else if (ArrayBuffer.isView(cur)) o2[k] = copyBuffer(cur);
167
+ else {
168
+ const i = refs.indexOf(cur);
169
+ if (i !== -1) o2[k] = refsNew[i];
170
+ else o2[k] = cloneProto(cur);
171
+ }
172
+ }
173
+ refs.pop();
174
+ refsNew.pop();
175
+ return o2;
176
+ }
177
+ }
178
+ }) });
179
+
180
+ //#endregion
181
+ //#region src/general.ts
182
+ var import_rfdc = /* @__PURE__ */ __toESM(require_rfdc(), 1);
183
+ function NOOP() {}
184
+ const isNumeric = (str) => `${+str}` === str;
185
+ const isMacOS = () => {
186
+ var _navigator, _navigator2;
187
+ return ((_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.platform) ? (_navigator2 = navigator) === null || _navigator2 === void 0 ? void 0 : _navigator2.platform.toLowerCase().includes("mac") : /Macintosh/.test(navigator.userAgent);
188
+ };
189
+ const classifyRE = /(?:^|[-_/])(\w)/g;
190
+ const camelizeRE = /-(\w)/g;
191
+ const kebabizeRE = /([a-z0-9])([A-Z])/g;
192
+ function toUpper(_, c) {
193
+ return c ? c.toUpperCase() : "";
194
+ }
195
+ function classify(str) {
196
+ return str && `${str}`.replace(classifyRE, toUpper);
197
+ }
198
+ function camelize(str) {
199
+ return str && str.replace(camelizeRE, toUpper);
200
+ }
201
+ function kebabize(str) {
202
+ return str && str.replace(kebabizeRE, (_, lowerCaseCharacter, upperCaseLetter) => {
203
+ return `${lowerCaseCharacter}-${upperCaseLetter}`;
204
+ }).toLowerCase();
205
+ }
206
+ function basename(filename, ext) {
207
+ let normalizedFilename = filename.replace(/^[a-z]:/i, "").replace(/\\/g, "/");
208
+ if (normalizedFilename.endsWith(`index${ext}`)) normalizedFilename = normalizedFilename.replace(`/index${ext}`, ext);
209
+ const lastSlashIndex = normalizedFilename.lastIndexOf("/");
210
+ const baseNameWithExt = normalizedFilename.substring(lastSlashIndex + 1);
211
+ if (ext) {
212
+ const extIndex = baseNameWithExt.lastIndexOf(ext);
213
+ return baseNameWithExt.substring(0, extIndex);
214
+ }
215
+ return "";
216
+ }
217
+ function sortByKey(state) {
218
+ return state && state.slice().sort((a, b) => {
219
+ if (a.key < b.key) return -1;
220
+ if (a.key > b.key) return 1;
221
+ return 0;
222
+ });
223
+ }
224
+ const HTTP_URL_RE = /^https?:\/\//;
225
+ /**
226
+ * Check a string is start with `/` or a valid http url
227
+ */
228
+ function isUrlString(str) {
229
+ return str.startsWith("/") || HTTP_URL_RE.test(str);
230
+ }
231
+ /**
232
+ * @copyright [rfdc](https://github.com/davidmarkclements/rfdc)
233
+ * @description A really fast deep clone alternative
234
+ */
235
+ const deepClone = (0, import_rfdc.default)({ circles: true });
236
+ function randomStr() {
237
+ return Math.random().toString(36).slice(2);
238
+ }
239
+ function isObject(value) {
240
+ return typeof value === "object" && !Array.isArray(value) && value !== null;
241
+ }
242
+ function isArray(value) {
243
+ return Array.isArray(value);
244
+ }
245
+ function isSet(value) {
246
+ return value instanceof Set;
247
+ }
248
+ function isMap(value) {
249
+ return value instanceof Map;
250
+ }
251
+
252
+ //#endregion
253
+ export { BROADCAST_CHANNEL_NAME, NOOP, VIEW_MODE_STORAGE_KEY, VITE_PLUGIN_CLIENT_URL_STORAGE_KEY, VITE_PLUGIN_DETECTED_STORAGE_KEY, basename, camelize, classify, deepClone, isArray, isBrowser, isInChromePanel, isInElectron, isInIframe, isInSeparateWindow, isMacOS, isMap, isNumeric, isNuxtApp, isObject, isSet, isUrlString, kebabize, randomStr, sortByKey, target };
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@react-devtools-plus/shared",
3
+ "type": "module",
4
+ "version": "0.2.0",
5
+ "author": "wzc520pyfm",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "directory": "packages/shared",
9
+ "type": "git",
10
+ "url": "git+https://github.com/vuejs/devtools.git"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.cjs"
16
+ }
17
+ },
18
+ "main": "./dist/index.cjs",
19
+ "module": "./dist/index.js",
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "dependencies": {
24
+ "rfdc": "^1.4.1"
25
+ },
26
+ "devDependencies": {
27
+ "@types/node": "^24.7.2"
28
+ },
29
+ "scripts": {
30
+ "build": "tsdown",
31
+ "prepare:type": "tsdown --dts-only",
32
+ "stub": "tsdown --watch --onSuccess 'tsdown --dts-only'"
33
+ }
34
+ }