view-anchor 0.2.1 → 0.2.2-alpha.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 +2 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +1 -6
- package/package.json +8 -6
- package/src/react.ts +1 -6
package/README.md
CHANGED
|
@@ -181,6 +181,8 @@ The full contract is in [docs/protocol.md](./docs/protocol.md).
|
|
|
181
181
|
|
|
182
182
|
Issues and pull requests are welcome. Before submitting, run `pnpm lint`, `pnpm format:check`, `pnpm check-types`, `pnpm test`, and `pnpm build`. `pnpm benchmark` prints the data used to update the performance report.
|
|
183
183
|
|
|
184
|
+
Changes that affect a published version must include a Changeset. Run `pnpm changeset`, select the version bump, and describe the user-visible change. Merging it into `main` opens a version PR; merging that PR publishes the package.
|
|
185
|
+
|
|
184
186
|
## License
|
|
185
187
|
|
|
186
188
|
[MIT](./LICENSE) © lbb00
|
package/dist/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,MAAM,EAAoB,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE7E,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D;;;OAGG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;CAC9B;AAED,2EAA2E;AAC3E,MAAM,MAAM,aAAa,GAAG,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAA;AAE3E,MAAM,WAAW,yBAA0B,SAAQ,sBAAsB;IACvE;;;OAGG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;CAC9B;AAED,8DAA8D;AAC9D,MAAM,MAAM,kBAAkB,GAAG,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,MAAM,EAAoB,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE7E,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D;;;OAGG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;CAC9B;AAED,2EAA2E;AAC3E,MAAM,MAAM,aAAa,GAAG,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAA;AAE3E,MAAM,WAAW,yBAA0B,SAAQ,sBAAsB;IACvE;;;OAGG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;CAC9B;AAED,8DAA8D;AAC9D,MAAM,MAAM,kBAAkB,GAAG,aAAa,CAAA;AA+H9C,iEAAiE;AACjE,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAM1E;AAsBD,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,kBAAkB,CAazF;AAED,YAAY,EAAE,MAAM,EAAE,CAAA"}
|
package/dist/react.js
CHANGED
|
@@ -8,14 +8,11 @@ function useAnchorRef(options, applied, adapter) {
|
|
|
8
8
|
const handleRef = useRef(null);
|
|
9
9
|
const elementRef = useRef(null);
|
|
10
10
|
const optionsRef = useRef(options);
|
|
11
|
-
// eslint-disable-next-line react-hooks/refs
|
|
12
11
|
optionsRef.current = options;
|
|
13
12
|
const adapterRef = useRef(adapter);
|
|
14
|
-
// eslint-disable-next-line react-hooks/refs
|
|
15
13
|
adapterRef.current = adapter;
|
|
16
14
|
const appliedRef = useRef(applied);
|
|
17
15
|
const currentAppliedRef = useRef(applied);
|
|
18
|
-
// eslint-disable-next-line react-hooks/refs
|
|
19
16
|
currentAppliedRef.current = applied;
|
|
20
17
|
// Options handed to the adapter on the last create/update call.
|
|
21
18
|
// Tracks applied state across renders where the deps array reference changes.
|
|
@@ -73,7 +70,6 @@ function useAnchorRef(options, applied, adapter) {
|
|
|
73
70
|
return () => deferDetach(element);
|
|
74
71
|
}
|
|
75
72
|
return undefined;
|
|
76
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- helpers only read stable refs
|
|
77
73
|
}, []);
|
|
78
74
|
useEffect(() => {
|
|
79
75
|
const previous = appliedRef.current;
|
|
@@ -87,7 +83,7 @@ function useAnchorRef(options, applied, adapter) {
|
|
|
87
83
|
adapterRef.current.update(handle, optionsRef.current);
|
|
88
84
|
lastAppliedOptionsRef.current = optionsRef.current;
|
|
89
85
|
}
|
|
90
|
-
//
|
|
86
|
+
// oxlint-disable-next-line react/exhaustive-deps
|
|
91
87
|
}, applied);
|
|
92
88
|
useEffect(() => {
|
|
93
89
|
cancelPendingDetach();
|
|
@@ -96,7 +92,6 @@ function useAnchorRef(options, applied, adapter) {
|
|
|
96
92
|
if (element)
|
|
97
93
|
deferDetach(element);
|
|
98
94
|
};
|
|
99
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- helpers only read stable refs
|
|
100
95
|
}, []);
|
|
101
96
|
return ref;
|
|
102
97
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "view-anchor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2-alpha.0",
|
|
4
4
|
"description": "High-performance geometry bridge that keeps anything outside the DOM (an Electron WebContentsView, a native webview, a cross-origin iframe) aligned to a DOM element: synchronous, deduplicated updates, optional versioned message batching, React adapter, framework-free core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"electron",
|
|
@@ -73,6 +73,7 @@
|
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@testing-library/react": "^16.3.2",
|
|
76
|
+
"@changesets/cli": "^3.0.2",
|
|
76
77
|
"@types/node": "^26.5.1",
|
|
77
78
|
"@types/react": "^18.3.12",
|
|
78
79
|
"@vitejs/plugin-react": "^6.0.1",
|
|
@@ -91,16 +92,17 @@
|
|
|
91
92
|
},
|
|
92
93
|
"scripts": {
|
|
93
94
|
"build": "tsc -p tsconfig.build.json && pnpm run build:docs",
|
|
94
|
-
"build:docs": "node scripts/build-docs.
|
|
95
|
+
"build:docs": "node scripts/build-docs.js",
|
|
95
96
|
"check-types": "tsc --noEmit",
|
|
96
|
-
"lint": "oxlint . --deny-warnings",
|
|
97
|
+
"lint": "oxlint . --deny-warnings --report-unused-disable-directives",
|
|
97
98
|
"format": "oxfmt --write .",
|
|
98
99
|
"format:check": "oxfmt --check .",
|
|
99
100
|
"test": "vitest run --reporter=default --reporter=json --outputFile.json=test-report.json --coverage.enabled --coverage.reporter=json-summary --coverage.reportsDirectory=coverage",
|
|
100
101
|
"test:dev": "vitest",
|
|
101
102
|
"test:coverage": "vitest run --coverage",
|
|
102
|
-
"benchmark": "node --expose-gc scripts/performance-report.
|
|
103
|
-
"benchmark:v8": "node --trace-opt --trace-deopt --trace-turbo-inlining --expose-gc scripts/performance-report.
|
|
104
|
-
"check-package": "node scripts/check-package.
|
|
103
|
+
"benchmark": "node --expose-gc scripts/performance-report.js",
|
|
104
|
+
"benchmark:v8": "node --trace-opt --trace-deopt --trace-turbo-inlining --expose-gc scripts/performance-report.js",
|
|
105
|
+
"check-package": "node scripts/check-package.js",
|
|
106
|
+
"release": "pnpm run build && pnpm run test && pnpm run check-package && changeset publish"
|
|
105
107
|
}
|
|
106
108
|
}
|
package/src/react.ts
CHANGED
|
@@ -50,14 +50,11 @@ function useAnchorRef<Options, Handle extends AnchorHandle>(
|
|
|
50
50
|
const handleRef = useRef<Handle | null>(null)
|
|
51
51
|
const elementRef = useRef<HTMLElement | null>(null)
|
|
52
52
|
const optionsRef = useRef(options)
|
|
53
|
-
// eslint-disable-next-line react-hooks/refs
|
|
54
53
|
optionsRef.current = options
|
|
55
54
|
const adapterRef = useRef(adapter)
|
|
56
|
-
// eslint-disable-next-line react-hooks/refs
|
|
57
55
|
adapterRef.current = adapter
|
|
58
56
|
const appliedRef = useRef(applied)
|
|
59
57
|
const currentAppliedRef = useRef(applied)
|
|
60
|
-
// eslint-disable-next-line react-hooks/refs
|
|
61
58
|
currentAppliedRef.current = applied
|
|
62
59
|
// Options handed to the adapter on the last create/update call.
|
|
63
60
|
// Tracks applied state across renders where the deps array reference changes.
|
|
@@ -116,7 +113,6 @@ function useAnchorRef<Options, Handle extends AnchorHandle>(
|
|
|
116
113
|
return () => deferDetach(element)
|
|
117
114
|
}
|
|
118
115
|
return undefined
|
|
119
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- helpers only read stable refs
|
|
120
116
|
}, [])
|
|
121
117
|
|
|
122
118
|
useEffect(() => {
|
|
@@ -131,7 +127,7 @@ function useAnchorRef<Options, Handle extends AnchorHandle>(
|
|
|
131
127
|
adapterRef.current.update(handle, optionsRef.current)
|
|
132
128
|
lastAppliedOptionsRef.current = optionsRef.current
|
|
133
129
|
}
|
|
134
|
-
//
|
|
130
|
+
// oxlint-disable-next-line react/exhaustive-deps
|
|
135
131
|
}, applied)
|
|
136
132
|
|
|
137
133
|
useEffect(() => {
|
|
@@ -140,7 +136,6 @@ function useAnchorRef<Options, Handle extends AnchorHandle>(
|
|
|
140
136
|
const element = elementRef.current
|
|
141
137
|
if (element) deferDetach(element)
|
|
142
138
|
}
|
|
143
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- helpers only read stable refs
|
|
144
139
|
}, [])
|
|
145
140
|
|
|
146
141
|
return ref
|