@octanejs/dexie 0.1.45 → 0.1.46

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octanejs/dexie",
3
- "version": "0.1.45",
3
+ "version": "0.1.46",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "engines": {
@@ -53,7 +53,7 @@
53
53
  "react-dom": "^19.2.7",
54
54
  "vite": "^8.1.5",
55
55
  "vitest": "^4.1.10",
56
- "octane": "0.2.0"
56
+ "octane": "0.2.3"
57
57
  },
58
58
  "scripts": {
59
59
  "test": "vitest run"
@@ -32,10 +32,13 @@ export function useDocument<TDoc extends object>(
32
32
  doc: TDoc | null | undefined,
33
33
  ...rest: [symbol?]
34
34
  ): DexieYProvider<TDoc> | null {
35
- const [args, slot] = splitSlot(rest);
36
- if (args.length !== 0) {
35
+ const [args, callerSlot] = splitSlot(rest);
36
+ // The authored second argument precedes any slot appended by the compiler adapter.
37
+ const explicitSlot = args[0];
38
+ if (args.length !== 0 && !(args.length === 1 && typeof explicitSlot === 'symbol')) {
37
39
  throw new TypeError('useDocument() accepts one document argument.');
38
40
  }
41
+ const slot = typeof explicitSlot === 'symbol' ? explicitSlot : callerSlot;
39
42
  if (!finalizationRegistry) {
40
43
  throw new TypeError('useDocument() requires FinalizationRegistry support.');
41
44
  }
@@ -41,10 +41,15 @@ export function useObservable<T, TDefault>(
41
41
  observableOrFactory: InteropableObservable<T> | ObservableFactory<T>,
42
42
  ...rest: [unknown?, unknown?, symbol?]
43
43
  ): T | TDefault | undefined {
44
- const [args, slot] = splitSlot(rest);
45
- const deps = typeof observableOrFactory === 'function' ? ((args[0] as unknown[]) ?? []) : [];
46
- const defaultResult = (typeof observableOrFactory === 'function' ? args[1] : args[0]) as
47
- TDefault | undefined;
44
+ const [args, callerSlot] = splitSlot(rest);
45
+ const isFactory = typeof observableOrFactory === 'function';
46
+ // An authored explicit slot can precede the compiler's call-site slot.
47
+ // Keep that identity when one helper reads multiple observables, while
48
+ // preserving Symbol defaults in their public argument positions.
49
+ const explicitSlot = args[isFactory ? 2 : 1];
50
+ const slot = typeof explicitSlot === 'symbol' ? explicitSlot : callerSlot;
51
+ const deps = isFactory ? ((args[0] as unknown[]) ?? []) : [];
52
+ const defaultResult = args[isFactory ? 1 : 0] as TDefault | undefined;
48
53
  const monitor = useRef(
49
54
  {
50
55
  hasResult: false,