@object-ui/components 3.1.3 → 3.1.4
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/.turbo/turbo-build.log +22 -14
- package/CHANGELOG.md +8 -0
- package/dist/index.css +3 -1
- package/dist/index.js +78016 -67064
- package/dist/index.umd.cjs +72 -77
- package/dist/src/lib/use-sync-external-store-shim.d.ts +10 -0
- package/dist/src/lib/use-sync-external-store-with-selector-shim.d.ts +1 -0
- package/package.json +11 -11
- package/src/lib/use-sync-external-store-shim.ts +10 -0
- package/src/lib/use-sync-external-store-with-selector-shim.ts +90 -0
- package/vite.config.ts +19 -11
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESM re-export of useSyncExternalStore from React.
|
|
3
|
+
*
|
|
4
|
+
* React 18+ ships useSyncExternalStore natively. The CJS shim package
|
|
5
|
+
* (`use-sync-external-store/shim`) uses `require("react")` which
|
|
6
|
+
* produces a Rolldown `require` polyfill incompatible with Next.js
|
|
7
|
+
* Turbopack SSR. This module provides the same API surface using a
|
|
8
|
+
* static ESM import instead.
|
|
9
|
+
*/
|
|
10
|
+
export { useSyncExternalStore } from 'react';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useSyncExternalStoreWithSelector<Snapshot, Selection>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => Snapshot, getServerSnapshot: undefined | null | (() => Snapshot), selector: (snapshot: Snapshot) => Selection, isEqual?: (a: Selection, b: Selection) => boolean): Selection;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/components",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Standard UI component library for Object UI, built with Shadcn UI + Tailwind CSS",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"next-themes": "^0.4.6",
|
|
37
37
|
"radix-ui": "^1.4.3",
|
|
38
38
|
"react-day-picker": "^9.14.0",
|
|
39
|
-
"react-hook-form": "^7.
|
|
40
|
-
"react-resizable-panels": "^4.7.
|
|
39
|
+
"react-hook-form": "^7.72.0",
|
|
40
|
+
"react-resizable-panels": "^4.7.5",
|
|
41
41
|
"recharts": "3.8.0",
|
|
42
42
|
"sonner": "^2.0.7",
|
|
43
43
|
"tailwind-merge": "^3.5.0",
|
|
44
44
|
"tailwindcss-animate": "^1.0.7",
|
|
45
45
|
"vaul": "^1.1.2",
|
|
46
|
-
"@object-ui/core": "3.1.
|
|
47
|
-
"@object-ui/react": "3.1.
|
|
48
|
-
"@object-ui/types": "3.1.
|
|
46
|
+
"@object-ui/core": "3.1.4",
|
|
47
|
+
"@object-ui/react": "3.1.4",
|
|
48
|
+
"@object-ui/types": "3.1.4"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -59,17 +59,17 @@
|
|
|
59
59
|
"@storybook/blocks": "^8.6.14",
|
|
60
60
|
"@storybook/react": "^8.6.18",
|
|
61
61
|
"@storybook/react-vite": "^8.6.18",
|
|
62
|
-
"@tailwindcss/postcss": "^4.2.
|
|
62
|
+
"@tailwindcss/postcss": "^4.2.2",
|
|
63
63
|
"@types/react": "19.2.14",
|
|
64
64
|
"@types/react-dom": "19.2.3",
|
|
65
|
-
"@vitejs/plugin-react": "^
|
|
65
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
66
66
|
"autoprefixer": "^10.4.27",
|
|
67
67
|
"postcss": "^8.5.8",
|
|
68
|
-
"shadcn": "^4.0
|
|
68
|
+
"shadcn": "^4.1.0",
|
|
69
69
|
"storybook": "^8.6.18",
|
|
70
|
-
"tailwindcss": "^4.2.
|
|
70
|
+
"tailwindcss": "^4.2.2",
|
|
71
71
|
"typescript": "^5.9.3",
|
|
72
|
-
"vite": "^
|
|
72
|
+
"vite": "^8.0.1",
|
|
73
73
|
"vite-plugin-dts": "^4.5.4"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESM re-export of useSyncExternalStore from React.
|
|
3
|
+
*
|
|
4
|
+
* React 18+ ships useSyncExternalStore natively. The CJS shim package
|
|
5
|
+
* (`use-sync-external-store/shim`) uses `require("react")` which
|
|
6
|
+
* produces a Rolldown `require` polyfill incompatible with Next.js
|
|
7
|
+
* Turbopack SSR. This module provides the same API surface using a
|
|
8
|
+
* static ESM import instead.
|
|
9
|
+
*/
|
|
10
|
+
export { useSyncExternalStore } from 'react';
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESM re-export of useSyncExternalStoreWithSelector.
|
|
3
|
+
*
|
|
4
|
+
* The CJS shim package uses `require("react")` which produces a
|
|
5
|
+
* Rolldown `require` polyfill incompatible with Next.js Turbopack SSR.
|
|
6
|
+
* This module provides a pure-ESM implementation using React 18+
|
|
7
|
+
* native useSyncExternalStore.
|
|
8
|
+
*/
|
|
9
|
+
import { useRef, useEffect, useMemo, useDebugValue, useSyncExternalStore } from 'react';
|
|
10
|
+
|
|
11
|
+
function is(x: unknown, y: unknown): boolean {
|
|
12
|
+
return (x === y && (0 !== x || 1 / (x as number) === 1 / (y as number))) || (x !== x && y !== y);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const objectIs: (x: unknown, y: unknown) => boolean =
|
|
16
|
+
typeof Object.is === 'function' ? Object.is : is;
|
|
17
|
+
|
|
18
|
+
export function useSyncExternalStoreWithSelector<Snapshot, Selection>(
|
|
19
|
+
subscribe: (onStoreChange: () => void) => () => void,
|
|
20
|
+
getSnapshot: () => Snapshot,
|
|
21
|
+
getServerSnapshot: undefined | null | (() => Snapshot),
|
|
22
|
+
selector: (snapshot: Snapshot) => Selection,
|
|
23
|
+
isEqual?: (a: Selection, b: Selection) => boolean,
|
|
24
|
+
): Selection {
|
|
25
|
+
const instRef = useRef<{
|
|
26
|
+
hasValue: boolean;
|
|
27
|
+
value: Selection;
|
|
28
|
+
} | null>(null);
|
|
29
|
+
let inst: { hasValue: boolean; value: Selection };
|
|
30
|
+
if (instRef.current === null) {
|
|
31
|
+
inst = { hasValue: false, value: null as Selection };
|
|
32
|
+
instRef.current = inst;
|
|
33
|
+
} else {
|
|
34
|
+
inst = instRef.current;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const [getSelection, getServerSelection] = useMemo(() => {
|
|
38
|
+
let hasMemo = false;
|
|
39
|
+
let memoizedSnapshot: Snapshot;
|
|
40
|
+
let memoizedSelection: Selection;
|
|
41
|
+
const memoizedSelector = (nextSnapshot: Snapshot): Selection => {
|
|
42
|
+
if (!hasMemo) {
|
|
43
|
+
hasMemo = true;
|
|
44
|
+
memoizedSnapshot = nextSnapshot;
|
|
45
|
+
const nextSelection = selector(nextSnapshot);
|
|
46
|
+
if (isEqual !== undefined) {
|
|
47
|
+
if (inst.hasValue) {
|
|
48
|
+
const currentSelection = inst.value;
|
|
49
|
+
if (isEqual(currentSelection, nextSelection)) {
|
|
50
|
+
memoizedSelection = currentSelection;
|
|
51
|
+
return currentSelection;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
memoizedSelection = nextSelection;
|
|
56
|
+
return nextSelection;
|
|
57
|
+
}
|
|
58
|
+
const prevSnapshot = memoizedSnapshot;
|
|
59
|
+
const prevSelection = memoizedSelection;
|
|
60
|
+
if (objectIs(prevSnapshot, nextSnapshot)) {
|
|
61
|
+
return prevSelection;
|
|
62
|
+
}
|
|
63
|
+
const nextSelection = selector(nextSnapshot);
|
|
64
|
+
if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {
|
|
65
|
+
memoizedSnapshot = nextSnapshot;
|
|
66
|
+
return prevSelection;
|
|
67
|
+
}
|
|
68
|
+
memoizedSnapshot = nextSnapshot;
|
|
69
|
+
memoizedSelection = nextSelection;
|
|
70
|
+
return nextSelection;
|
|
71
|
+
};
|
|
72
|
+
const maybeGetServerSelection =
|
|
73
|
+
getServerSnapshot === undefined || getServerSnapshot === null
|
|
74
|
+
? undefined
|
|
75
|
+
: () => memoizedSelector(getServerSnapshot());
|
|
76
|
+
return [() => memoizedSelector(getSnapshot()), maybeGetServerSelection];
|
|
77
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
|
+
}, [getSnapshot, getServerSnapshot, selector, isEqual]);
|
|
79
|
+
|
|
80
|
+
const value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
inst.hasValue = true;
|
|
84
|
+
inst.value = value;
|
|
85
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
86
|
+
}, [value]);
|
|
87
|
+
|
|
88
|
+
useDebugValue(value);
|
|
89
|
+
return value;
|
|
90
|
+
}
|
package/vite.config.ts
CHANGED
|
@@ -20,16 +20,22 @@ export default defineConfig({
|
|
|
20
20
|
}),
|
|
21
21
|
],
|
|
22
22
|
resolve: {
|
|
23
|
-
alias:
|
|
24
|
-
'@': resolve(__dirname, './src'),
|
|
25
|
-
'@object-ui/core': resolve(__dirname, '../core/src'),
|
|
26
|
-
'@object-ui/types': resolve(__dirname, '../types/src'),
|
|
27
|
-
'@object-ui/react': resolve(__dirname, '../react/src'),
|
|
28
|
-
'@object-ui/components': resolve(__dirname, './src'), // Self-reference for vitest.setup.tsx
|
|
29
|
-
'@object-ui/fields': resolve(__dirname, '../fields/src'),
|
|
30
|
-
'@object-ui/plugin-dashboard': resolve(__dirname, '../plugin-dashboard/src'),
|
|
31
|
-
'@object-ui/plugin-grid': resolve(__dirname, '../plugin-grid/src'),
|
|
32
|
-
|
|
23
|
+
alias: [
|
|
24
|
+
{ find: '@', replacement: resolve(__dirname, './src') },
|
|
25
|
+
{ find: '@object-ui/core', replacement: resolve(__dirname, '../core/src') },
|
|
26
|
+
{ find: '@object-ui/types', replacement: resolve(__dirname, '../types/src') },
|
|
27
|
+
{ find: '@object-ui/react', replacement: resolve(__dirname, '../react/src') },
|
|
28
|
+
{ find: '@object-ui/components', replacement: resolve(__dirname, './src') }, // Self-reference for vitest.setup.tsx
|
|
29
|
+
{ find: '@object-ui/fields', replacement: resolve(__dirname, '../fields/src') },
|
|
30
|
+
{ find: '@object-ui/plugin-dashboard', replacement: resolve(__dirname, '../plugin-dashboard/src') },
|
|
31
|
+
{ find: '@object-ui/plugin-grid', replacement: resolve(__dirname, '../plugin-grid/src') },
|
|
32
|
+
// The CJS shims use require("react") which produces a Rolldown
|
|
33
|
+
// require polyfill incompatible with Next.js Turbopack SSR.
|
|
34
|
+
// Alias to ESM modules that re-export from React 18+ directly.
|
|
35
|
+
{ find: /^use-sync-external-store\/shim\/with-selector(\.js)?$/, replacement: resolve(__dirname, 'src/lib/use-sync-external-store-with-selector-shim.ts') },
|
|
36
|
+
{ find: /^use-sync-external-store\/shim(\.js)?$/, replacement: resolve(__dirname, 'src/lib/use-sync-external-store-shim.ts') },
|
|
37
|
+
{ find: /^use-sync-external-store\/with-selector(\.js)?$/, replacement: resolve(__dirname, 'src/lib/use-sync-external-store-with-selector-shim.ts') },
|
|
38
|
+
],
|
|
33
39
|
},
|
|
34
40
|
build: {
|
|
35
41
|
lib: {
|
|
@@ -38,7 +44,9 @@ export default defineConfig({
|
|
|
38
44
|
fileName: 'index',
|
|
39
45
|
},
|
|
40
46
|
rollupOptions: {
|
|
41
|
-
|
|
47
|
+
// Use a function to match subpath imports (e.g. react/jsx-runtime)
|
|
48
|
+
// so Rolldown does not bundle CJS wrappers that use require().
|
|
49
|
+
external: (id) => /^(react|react-dom|@object-ui\/(core|react|types))(\/|$)/.test(id),
|
|
42
50
|
output: {
|
|
43
51
|
globals: {
|
|
44
52
|
react: 'React',
|