bippy 0.2.24 → 0.3.1

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.
Files changed (43) hide show
  1. package/README.md +24 -0
  2. package/dist/{chunk-N23WFCSF.js → chunk-5A4BJBVW.cjs} +4 -7
  3. package/dist/chunk-7YG3CYCA.js +2240 -0
  4. package/dist/chunk-AQ674A4M.cjs +38 -0
  5. package/dist/chunk-EPG3GO3H.js +35 -0
  6. package/dist/{chunk-HQYIPSLJ.cjs → chunk-I3GVATOW.js} +2 -9
  7. package/dist/{chunk-347RWTP3.js → chunk-MSOPLAJ4.js} +58 -14
  8. package/dist/chunk-MVK3AG63.cjs +2246 -0
  9. package/dist/{chunk-GVWERSAB.cjs → chunk-QHE5F4UP.cjs} +60 -13
  10. package/dist/core.cjs +80 -67
  11. package/dist/core.d.cts +15 -70
  12. package/dist/core.d.ts +15 -70
  13. package/dist/core.js +2 -1
  14. package/dist/experiments/inspect.cjs +26 -14
  15. package/dist/experiments/inspect.js +14 -2
  16. package/dist/experiments/shrinkwrap.cjs +375 -0
  17. package/dist/experiments/shrinkwrap.d.cts +10 -0
  18. package/dist/experiments/shrinkwrap.d.ts +10 -0
  19. package/dist/experiments/shrinkwrap.js +370 -0
  20. package/dist/index.cjs +81 -68
  21. package/dist/index.d.cts +3 -1
  22. package/dist/index.d.ts +3 -1
  23. package/dist/index.global.js +1 -1
  24. package/dist/index.js +3 -2
  25. package/dist/jsx-dev-runtime.cjs +47 -0
  26. package/dist/jsx-dev-runtime.d.cts +8 -0
  27. package/dist/jsx-dev-runtime.d.ts +8 -0
  28. package/dist/jsx-dev-runtime.js +37 -0
  29. package/dist/jsx-runtime-LhDmw-G0.d.cts +71 -0
  30. package/dist/jsx-runtime-LhDmw-G0.d.ts +71 -0
  31. package/dist/jsx-runtime.cjs +15 -0
  32. package/dist/jsx-runtime.d.cts +3 -0
  33. package/dist/jsx-runtime.d.ts +3 -0
  34. package/dist/jsx-runtime.js +4 -0
  35. package/dist/shrinkwrap.global.js +9 -0
  36. package/dist/source.cjs +289 -0
  37. package/dist/source.d.cts +15 -0
  38. package/dist/source.d.ts +15 -0
  39. package/dist/source.global.js +22 -0
  40. package/dist/source.js +4 -0
  41. package/package.json +29 -7
  42. package/dist/sw.cjs +0 -56
  43. package/dist/sw.js +0 -54
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * @license bippy
5
+ *
6
+ * Copyright (c) Aiden Bai, Million Software, Inc.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */
11
+ var __create = Object.create;
12
+ var __defProp = Object.defineProperty;
13
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
14
+ var __getOwnPropNames = Object.getOwnPropertyNames;
15
+ var __getProtoOf = Object.getPrototypeOf;
16
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
17
+ var __commonJS = (cb, mod) => function __require() {
18
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+
37
+ exports.__commonJS = __commonJS;
38
+ exports.__toESM = __toESM;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @license bippy
3
+ *
4
+ * Copyright (c) Aiden Bai, Million Software, Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ var __create = Object.create;
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __getProtoOf = Object.getPrototypeOf;
14
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
15
+ var __commonJS = (cb, mod) => function __require() {
16
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
+ // If the importer is in node compatibility mode or this is not an ESM
28
+ // file that has been converted to a CommonJS file using a Babel-
29
+ // compatible transform (i.e. "__esModule" has not been set), then set
30
+ // "default" to the CommonJS "module.exports" for node compatibility.
31
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
+ mod
33
+ ));
34
+
35
+ export { __commonJS, __toESM };
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- var chunkGVWERSAB_cjs = require('./chunk-GVWERSAB.cjs');
1
+ import { safelyInstallRDTHook } from './chunk-MSOPLAJ4.js';
4
2
 
5
3
  /**
6
4
  * @license bippy
@@ -12,9 +10,4 @@ var chunkGVWERSAB_cjs = require('./chunk-GVWERSAB.cjs');
12
10
  */
13
11
 
14
12
  // src/index.ts
15
- try {
16
- if (chunkGVWERSAB_cjs.isClientEnvironment()) {
17
- chunkGVWERSAB_cjs.getRDTHook();
18
- }
19
- } catch {
20
- }
13
+ safelyInstallRDTHook();
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  // src/rdt-hook.ts
11
- var version = "0.2.24";
11
+ var version = "0.3.1";
12
12
  var BIPPY_INSTRUMENTATION_STRING = `bippy-${version}`;
13
13
  var objectDefineProperty = Object.defineProperty;
14
14
  var objectHasOwnProperty = Object.prototype.hasOwnProperty;
@@ -66,9 +66,23 @@ var installRDTHook = (onActive) => {
66
66
  };
67
67
  try {
68
68
  objectDefineProperty(globalThis, "__REACT_DEVTOOLS_GLOBAL_HOOK__", {
69
- value: rdtHook,
69
+ get() {
70
+ return rdtHook;
71
+ },
72
+ set(newHook) {
73
+ if (newHook && typeof newHook === "object") {
74
+ const ourRenderers = rdtHook.renderers;
75
+ globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__ = newHook;
76
+ if (ourRenderers.size > 0) {
77
+ ourRenderers.forEach((renderer, id) => {
78
+ newHook.renderers.set(id, renderer);
79
+ });
80
+ patchRDTHook(onActive);
81
+ }
82
+ }
83
+ },
70
84
  configurable: true,
71
- writable: true
85
+ enumerable: true
72
86
  });
73
87
  const originalWindowHasOwnProperty = window.hasOwnProperty;
74
88
  let hasRanHack = false;
@@ -97,7 +111,6 @@ var patchRDTHook = (onActive) => {
97
111
  const rdtHook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
98
112
  if (!rdtHook) return;
99
113
  if (!rdtHook._instrumentationSource) {
100
- isReactRefreshOverride = isReactRefresh(rdtHook);
101
114
  rdtHook.checkDCE = checkDCE;
102
115
  rdtHook.supportsFiber = true;
103
116
  rdtHook.supportsFlight = true;
@@ -112,19 +125,21 @@ var patchRDTHook = (onActive) => {
112
125
  const prevInject = rdtHook.inject;
113
126
  if (isReactRefresh(rdtHook) && !isRealReactDevtools()) {
114
127
  isReactRefreshOverride = true;
115
- let nextID = rdtHook.inject(null);
128
+ const nextID = rdtHook.inject({
129
+ // @ts-expect-error this is not actually a ReactRenderer,
130
+ scheduleRefresh() {
131
+ }
132
+ });
116
133
  if (nextID) {
117
134
  rdtHook._instrumentationIsActive = true;
118
135
  }
119
- rdtHook.inject = () => nextID++;
120
- } else {
121
- rdtHook.inject = (renderer) => {
122
- const id = prevInject(renderer);
123
- rdtHook._instrumentationIsActive = true;
124
- onActiveListeners.forEach((listener) => listener());
125
- return id;
126
- };
127
136
  }
137
+ rdtHook.inject = (renderer) => {
138
+ const id = prevInject(renderer);
139
+ rdtHook._instrumentationIsActive = true;
140
+ onActiveListeners.forEach((listener) => listener());
141
+ return id;
142
+ };
128
143
  }
129
144
  if (rdtHook.renderers.size || rdtHook._instrumentationIsActive || // depending on this to inject is unsafe, since inject could occur before and we wouldn't know
130
145
  isReactRefresh()) {
@@ -151,6 +166,14 @@ var isClientEnvironment = () => {
151
166
  typeof window !== "undefined" && (window.document?.createElement || window.navigator?.product === "ReactNative")
152
167
  );
153
168
  };
169
+ var safelyInstallRDTHook = () => {
170
+ try {
171
+ if (isClientEnvironment()) {
172
+ getRDTHook();
173
+ }
174
+ } catch {
175
+ }
176
+ };
154
177
 
155
178
  // src/install-hook-script-string.ts
156
179
  var INSTALL_HOOK_SCRIPT_STRING = "(()=>{try{var t=()=>{};const n=new Map;let o=0;globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__={checkDCE:t,supportsFiber:!0,supportsFlight:!0,hasUnsupportedRendererAttached:!1,renderers:n,onCommitFiberRoot:t,onCommitFiberUnmount:t,onPostCommitFiberRoot:t,inject(t){var e=++o;return n.set(e,t),globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__._instrumentationIsActive=!0,e},_instrumentationIsActive:!1,_script:!0}}catch{}})()";
@@ -406,6 +429,9 @@ var getType = (type) => {
406
429
  };
407
430
  var getDisplayName = (type) => {
408
431
  const currentType = type;
432
+ if (typeof currentType === "string") {
433
+ return currentType;
434
+ }
409
435
  if (typeof currentType !== "function" && !(typeof currentType === "object" && currentType)) {
410
436
  return null;
411
437
  }
@@ -428,6 +454,20 @@ var isInstrumentationActive = () => {
428
454
  const rdtHook = getRDTHook();
429
455
  return Boolean(rdtHook._instrumentationIsActive) || isRealReactDevtools() || isReactRefresh();
430
456
  };
457
+ var getLatestFiber = (fiber) => {
458
+ const alternate = fiber.alternate;
459
+ if (!alternate) return fiber;
460
+ if (alternate.actualStartTime && fiber.actualStartTime) {
461
+ return alternate.actualStartTime > fiber.actualStartTime ? alternate : fiber;
462
+ }
463
+ for (const root of _fiberRoots) {
464
+ const latestFiber = traverseFiber(root.current, (innerFiber) => {
465
+ if (innerFiber === fiber) return true;
466
+ });
467
+ return latestFiber || alternate;
468
+ }
469
+ return fiber;
470
+ };
431
471
  var fiberId = 0;
432
472
  var fiberIdMap = /* @__PURE__ */ new WeakMap();
433
473
  var setFiberId = (fiber, id = fiberId++) => {
@@ -642,6 +682,7 @@ var getFiberFromHostInstance = (hostInstance) => {
642
682
  return null;
643
683
  };
644
684
  var INSTALL_ERROR = new Error();
685
+ var _fiberRoots = /* @__PURE__ */ new Set();
645
686
  var secure = (options, secureOptions = {}) => {
646
687
  const onActive = options.onActive;
647
688
  const isRDTHookInstalled = hasRDTHook();
@@ -682,6 +723,9 @@ var secure = (options, secureOptions = {}) => {
682
723
  const onCommitFiberRoot2 = options.onCommitFiberRoot;
683
724
  if (onCommitFiberRoot2) {
684
725
  options.onCommitFiberRoot = (rendererID, root, priority) => {
726
+ if (!_fiberRoots.has(root)) {
727
+ _fiberRoots.add(root);
728
+ }
685
729
  try {
686
730
  onCommitFiberRoot2(rendererID, root, priority);
687
731
  } catch (err) {
@@ -733,4 +777,4 @@ var onCommitFiberRoot = (handler) => {
733
777
  );
734
778
  };
735
779
 
736
- export { BIPPY_INSTRUMENTATION_STRING, CONCURRENT_MODE_NUMBER, CONCURRENT_MODE_SYMBOL_STRING, ClassComponentTag, ContextConsumerTag, DEPRECATED_ASYNC_MODE_SYMBOL_STRING, DehydratedSuspenseComponentTag, ELEMENT_TYPE_SYMBOL_STRING, ForwardRefTag, FragmentTag, FunctionComponentTag, HostComponentTag, HostHoistableTag, HostRootTag, HostSingletonTag, HostTextTag, INSTALL_ERROR, INSTALL_HOOK_SCRIPT_STRING, LegacyHiddenComponentTag, MemoComponentTag, OffscreenComponentTag, SimpleMemoComponentTag, SuspenseComponentTag, TRANSITIONAL_ELEMENT_TYPE_SYMBOL_STRING, createFiberVisitor, detectReactBuildType, didFiberCommit, didFiberRender, fiberIdMap, getDisplayName, getFiberFromHostInstance, getFiberId, getFiberStack, getMutatedHostFibers, getNearestHostFiber, getNearestHostFibers, getRDTHook, getTimings, getType, hasMemoCache, hasRDTHook, installRDTHook, instrument, isClientEnvironment, isCompositeFiber, isHostFiber, isInstrumentationActive, isReactRefresh, isRealReactDevtools, isValidElement, isValidFiber, mountFiberRecursively, onCommitFiberRoot, patchRDTHook, secure, setFiberId, shouldFilterFiber, traverseContexts, traverseFiber, traverseProps, traverseRenderedFibers, traverseState, unmountFiber, unmountFiberChildrenRecursively, updateFiberRecursively, version };
780
+ export { BIPPY_INSTRUMENTATION_STRING, CONCURRENT_MODE_NUMBER, CONCURRENT_MODE_SYMBOL_STRING, ClassComponentTag, ContextConsumerTag, DEPRECATED_ASYNC_MODE_SYMBOL_STRING, DehydratedSuspenseComponentTag, ELEMENT_TYPE_SYMBOL_STRING, ForwardRefTag, FragmentTag, FunctionComponentTag, HostComponentTag, HostHoistableTag, HostRootTag, HostSingletonTag, HostTextTag, INSTALL_ERROR, INSTALL_HOOK_SCRIPT_STRING, LegacyHiddenComponentTag, MemoComponentTag, OffscreenComponentTag, SimpleMemoComponentTag, SuspenseComponentTag, TRANSITIONAL_ELEMENT_TYPE_SYMBOL_STRING, _fiberRoots, createFiberVisitor, detectReactBuildType, didFiberCommit, didFiberRender, fiberIdMap, getDisplayName, getFiberFromHostInstance, getFiberId, getFiberStack, getLatestFiber, getMutatedHostFibers, getNearestHostFiber, getNearestHostFibers, getRDTHook, getTimings, getType, hasMemoCache, hasRDTHook, installRDTHook, instrument, isClientEnvironment, isCompositeFiber, isHostFiber, isInstrumentationActive, isReactRefresh, isRealReactDevtools, isValidElement, isValidFiber, mountFiberRecursively, onCommitFiberRoot, patchRDTHook, safelyInstallRDTHook, secure, setFiberId, shouldFilterFiber, traverseContexts, traverseFiber, traverseProps, traverseRenderedFibers, traverseState, unmountFiber, unmountFiberChildrenRecursively, updateFiberRecursively, version };