Test/node_modules/jotai-scope/dist/index.modern.mjs.map
2026-04-09 22:54:00 +07:00

1 line
No EOL
27 KiB
Text

{"version":3,"file":"index.modern.mjs","sources":["../src/createIsolation.tsx","../src/ScopeProvider/scope.ts","../src/ScopeProvider/patchedStore.ts","../src/ScopeProvider/ScopeProvider.tsx"],"sourcesContent":["import { createContext, useContext, useRef } from 'react';\nimport type { ReactNode } from 'react';\nimport { createStore } from 'jotai/vanilla';\nimport type { WritableAtom } from 'jotai/vanilla';\nimport {\n useAtom as useAtomOrig,\n useAtomValue as useAtomValueOrig,\n useSetAtom as useSetAtomOrig,\n useStore as useStoreOrig,\n} from 'jotai/react';\nimport { useHydrateAtoms } from 'jotai/react/utils';\n\ntype Store = ReturnType<typeof createStore>;\ntype AnyWritableAtom = WritableAtom<unknown, any[], any>;\n\nexport function createIsolation() {\n const StoreContext = createContext<Store | null>(null);\n\n function Provider({\n store,\n initialValues = [],\n children,\n }: {\n store?: Store;\n initialValues?: Iterable<readonly [AnyWritableAtom, unknown]>;\n children: ReactNode;\n }) {\n const storeRef = useRef(store);\n if (!storeRef.current) {\n storeRef.current = createStore();\n }\n useHydrateAtoms(initialValues as any, { store: storeRef.current });\n return (\n <StoreContext.Provider value={storeRef.current}>\n {children}\n </StoreContext.Provider>\n );\n }\n\n const useStore = ((options?: any) => {\n const store = useContext(StoreContext);\n if (!store) throw new Error('Missing Provider from createIsolation');\n return useStoreOrig({ store, ...options });\n }) as typeof useStoreOrig;\n\n const useAtom = ((anAtom: any, options?: any) => {\n const store = useStore();\n return useAtomOrig(anAtom, { store, ...options });\n }) as typeof useAtomOrig;\n\n const useAtomValue = ((anAtom: any, options?: any) => {\n const store = useStore();\n return useAtomValueOrig(anAtom, { store, ...options });\n }) as typeof useAtomValueOrig;\n\n const useSetAtom = ((anAtom: any, options?: any) => {\n const store = useStore();\n return useSetAtomOrig(anAtom, { store, ...options });\n }) as typeof useSetAtomOrig;\n\n return { Provider, useStore, useAtom, useAtomValue, useSetAtom };\n}\n","import { atom, type Atom } from 'jotai';\nimport type { AnyAtomFamily, AnyAtom, AnyWritableAtom, Scope } from './types';\n\nconst globalScopeKey: { name?: string } = {};\nif (process.env.NODE_ENV !== 'production') {\n globalScopeKey.name = 'unscoped';\n globalScopeKey.toString = toString;\n}\n\ntype GlobalScopeKey = typeof globalScopeKey;\n\nexport function createScope(\n atoms: Set<AnyAtom>,\n atomFamilies: Set<AnyAtomFamily>,\n parentScope: Scope | undefined,\n scopeName?: string | undefined,\n): Scope {\n const explicit = new WeakMap<AnyAtom, [AnyAtom, Scope?]>();\n const implicit = new WeakMap<AnyAtom, [AnyAtom, Scope?]>();\n type ScopeMap = WeakMap<AnyAtom, [AnyAtom, Scope?]>;\n const inherited = new WeakMap<Scope | GlobalScopeKey, ScopeMap>();\n\n const currentScope: Scope = {\n getAtom,\n cleanup() {},\n prepareWriteAtom(anAtom, originalAtom, implicitScope) {\n if (\n originalAtom.read === defaultRead &&\n isWritableAtom(originalAtom) &&\n isWritableAtom(anAtom) &&\n originalAtom.write !== defaultWrite &&\n currentScope !== implicitScope\n ) {\n // atom is writable with init and holds a value\n // we need to preserve the value, so we don't want to copy the atom\n // instead, we need to override write until the write is finished\n const { write } = originalAtom;\n anAtom.write = createScopedWrite(\n originalAtom.write.bind(\n originalAtom,\n ) as (typeof originalAtom)['write'],\n implicitScope,\n );\n return () => {\n anAtom.write = write;\n };\n }\n return undefined;\n },\n };\n\n if (scopeName && process.env.NODE_ENV !== 'production') {\n currentScope.name = scopeName;\n currentScope.toString = toString;\n }\n\n // populate explicitly scoped atoms\n for (const anAtom of atoms) {\n explicit.set(anAtom, [cloneAtom(anAtom, currentScope), currentScope]);\n }\n\n const cleanupFamiliesSet = new Set<() => void>();\n for (const atomFamily of atomFamilies) {\n for (const param of atomFamily.getParams()) {\n const anAtom = atomFamily(param);\n if (!explicit.has(anAtom)) {\n explicit.set(anAtom, [cloneAtom(anAtom, currentScope), currentScope]);\n }\n }\n const cleanupFamily = atomFamily.unstable_listen((e) => {\n if (e.type === 'CREATE' && !explicit.has(e.atom)) {\n explicit.set(e.atom, [cloneAtom(e.atom, currentScope), currentScope]);\n } else if (!atoms.has(e.atom)) {\n explicit.delete(e.atom);\n }\n });\n cleanupFamiliesSet.add(cleanupFamily);\n }\n currentScope.cleanup = combineVoidFunctions(\n currentScope.cleanup,\n ...Array.from(cleanupFamiliesSet),\n );\n\n /**\n * Returns a scoped atom from the original atom.\n * @param anAtom\n * @param implicitScope the atom is implicitly scoped in the provided scope\n * @returns the scoped atom and the scope of the atom\n */\n function getAtom<T extends AnyAtom>(\n anAtom: T,\n implicitScope?: Scope,\n ): [T, Scope?] {\n if (explicit.has(anAtom)) {\n return explicit.get(anAtom) as [T, Scope];\n }\n if (implicitScope === currentScope) {\n // dependencies of explicitly scoped atoms are implicitly scoped\n // implicitly scoped atoms are only accessed by implicit and explicit scoped atoms\n if (!implicit.has(anAtom)) {\n implicit.set(anAtom, [cloneAtom(anAtom, implicitScope), implicitScope]);\n }\n return implicit.get(anAtom) as [T, Scope];\n }\n const scopeKey = implicitScope ?? globalScopeKey;\n if (parentScope) {\n // inherited atoms are copied so they can access scoped atoms\n // but they are not explicitly scoped\n // dependencies of inherited atoms first check if they are explicitly scoped\n // otherwise they use their original scope's atom\n if (!inherited.get(scopeKey)?.has(anAtom)) {\n const [ancestorAtom, explicitScope] = parentScope.getAtom(\n anAtom,\n implicitScope,\n );\n setInheritedAtom(\n inheritAtom(ancestorAtom, anAtom, explicitScope),\n anAtom,\n implicitScope,\n explicitScope,\n );\n }\n return inherited.get(scopeKey)!.get(anAtom) as [T, Scope];\n }\n if (!inherited.get(scopeKey)?.has(anAtom)) {\n // non-primitive atoms may need to access scoped atoms\n // so we need to create a copy of the atom\n setInheritedAtom(inheritAtom(anAtom, anAtom), anAtom);\n }\n return inherited.get(scopeKey)!.get(anAtom) as [T, Scope?];\n }\n\n function setInheritedAtom<T extends AnyAtom>(\n scopedAtom: T,\n originalAtom: T,\n implicitScope?: Scope,\n explicitScope?: Scope,\n ) {\n const scopeKey = implicitScope ?? globalScopeKey;\n if (!inherited.has(scopeKey)) {\n inherited.set(scopeKey, new WeakMap());\n }\n inherited.get(scopeKey)!.set(\n originalAtom,\n [\n scopedAtom, //\n explicitScope,\n ].filter(Boolean) as [T, Scope?],\n );\n }\n\n /**\n * @returns a copy of the atom for derived atoms or the original atom for primitive and writable atoms\n */\n function inheritAtom<T>(\n anAtom: Atom<T>,\n originalAtom: Atom<T>,\n implicitScope?: Scope,\n ) {\n if (originalAtom.read !== defaultRead) {\n return cloneAtom(originalAtom, implicitScope);\n }\n return anAtom;\n }\n\n /**\n * @returns a scoped copy of the atom\n */\n function cloneAtom<T>(originalAtom: Atom<T>, implicitScope?: Scope) {\n // avoid reading `init` to preserve lazy initialization\n const scopedAtom: Atom<T> = Object.create(\n Object.getPrototypeOf(originalAtom),\n Object.getOwnPropertyDescriptors(originalAtom),\n );\n\n if (scopedAtom.read !== defaultRead) {\n scopedAtom.read = createScopedRead<typeof scopedAtom>(\n originalAtom.read.bind(originalAtom),\n implicitScope,\n );\n }\n\n if (\n isWritableAtom(scopedAtom) &&\n isWritableAtom(originalAtom) &&\n scopedAtom.write !== defaultWrite\n ) {\n scopedAtom.write = createScopedWrite(\n originalAtom.write.bind(originalAtom),\n implicitScope,\n );\n }\n\n return scopedAtom;\n }\n\n function createScopedRead<T extends Atom<unknown>>(\n read: T['read'],\n implicitScope?: Scope,\n ): T['read'] {\n return function scopedRead(get, opts) {\n return read(\n function scopedGet(a) {\n const [scopedAtom] = getAtom(a, implicitScope);\n return get(scopedAtom);\n }, //\n opts,\n );\n };\n }\n\n function createScopedWrite<T extends AnyWritableAtom>(\n write: T['write'],\n implicitScope?: Scope,\n ): T['write'] {\n return function scopedWrite(get, set, ...args) {\n return write(\n function scopedGet(a) {\n const [scopedAtom] = getAtom(a, implicitScope);\n return get(scopedAtom);\n },\n function scopedSet(a, ...v) {\n const [scopedAtom] = getAtom(a, implicitScope);\n return set(scopedAtom, ...v);\n },\n ...args,\n );\n };\n }\n\n return currentScope;\n}\n\nfunction isWritableAtom(anAtom: AnyAtom): anAtom is AnyWritableAtom {\n return 'write' in anAtom;\n}\n\nconst { read: defaultRead, write: defaultWrite } = atom<unknown>(null);\n\nfunction toString(this: { name: string }) {\n return this.name;\n}\n\nfunction combineVoidFunctions(...fns: (() => void)[]) {\n return function combinedFunctions() {\n for (const fn of fns) {\n fn();\n }\n };\n}\n","import type { Store, Scope } from './types';\n\nfunction PatchedStore() {}\n\n/**\n * @returns a patched store that intercepts get and set calls to apply the scope\n */\nexport function createPatchedStore(baseStore: Store, scope: Scope): Store {\n const store: Store = {\n ...baseStore,\n get(anAtom, ...args) {\n const [scopedAtom] = scope.getAtom(anAtom);\n return baseStore.get(scopedAtom, ...args);\n },\n set(anAtom, ...args) {\n const [scopedAtom, implicitScope] = scope.getAtom(anAtom);\n const restore = scope.prepareWriteAtom(scopedAtom, anAtom, implicitScope);\n try {\n return baseStore.set(scopedAtom, ...args);\n } finally {\n restore?.();\n }\n },\n sub(anAtom, ...args) {\n const [scopedAtom] = scope.getAtom(anAtom);\n return baseStore.sub(scopedAtom, ...args);\n },\n // TODO: update this patch to support devtools\n };\n return Object.assign(Object.create(PatchedStore.prototype), store);\n}\n\n/**\n * @returns true if the current scope is the first descendant scope under Provider\n */\nexport function isTopLevelScope(parentStore: Store) {\n return !(parentStore instanceof PatchedStore);\n}\n","import { Provider, useStore } from 'jotai/react';\nimport {\n type EffectCallback,\n createContext,\n useContext,\n useEffect,\n useRef,\n useState,\n type PropsWithChildren,\n} from 'react';\nimport { createScope } from './scope';\nimport type { AnyAtom, AnyAtomFamily, Store, Scope } from './types';\nimport { createPatchedStore, isTopLevelScope } from './patchedStore';\n\nconst ScopeContext = createContext<{\n scope: Scope | undefined;\n baseStore: Store | undefined;\n}>({ scope: undefined, baseStore: undefined });\n\nexport function ScopeProvider({\n atoms,\n atomFamilies,\n children,\n debugName,\n}: PropsWithChildren<{\n atoms: Iterable<AnyAtom>;\n atomFamilies?: Iterable<AnyAtomFamily>;\n debugName?: string;\n}>): JSX.Element;\nexport function ScopeProvider({\n atoms,\n atomFamilies,\n children,\n debugName,\n}: PropsWithChildren<{\n atoms?: Iterable<AnyAtom>;\n atomFamilies: Iterable<AnyAtomFamily>;\n debugName?: string;\n}>): JSX.Element;\nexport function ScopeProvider({\n atoms,\n atomFamilies,\n children,\n debugName,\n}: PropsWithChildren<{\n atoms?: Iterable<AnyAtom>;\n atomFamilies?: Iterable<AnyAtomFamily>;\n debugName?: string;\n}>) {\n const parentStore: Store = useStore();\n let { scope: parentScope, baseStore = parentStore } =\n useContext(ScopeContext);\n // if this ScopeProvider is the first descendant scope under Provider then it is the top level scope\n // https://github.com/jotaijs/jotai-scope/pull/33#discussion_r1604268003\n if (isTopLevelScope(parentStore)) {\n parentScope = undefined;\n baseStore = parentStore;\n }\n\n // atomSet is used to detect if the atoms prop has changed.\n const atomSet = new Set(atoms);\n const atomFamilySet = new Set(atomFamilies);\n\n function initialize() {\n const scope = createScope(atomSet, atomFamilySet, parentScope, debugName);\n return {\n patchedStore: createPatchedStore(baseStore, scope),\n scopeContext: { scope, baseStore },\n hasChanged(current: {\n baseStore: Store;\n parentScope: Scope | undefined;\n atomSet: Set<AnyAtom>;\n atomFamilySet: Set<AnyAtomFamily>;\n }) {\n return (\n parentScope !== current.parentScope ||\n baseStore !== current.baseStore ||\n !isEqualSet(atomSet, current.atomSet) ||\n !isEqualSet(atomFamilySet, current.atomFamilySet)\n );\n },\n };\n }\n\n const [state, setState] = useState(initialize);\n const { hasChanged, scopeContext, patchedStore } = state;\n if (hasChanged({ parentScope, atomSet, atomFamilySet, baseStore })) {\n scopeContext.scope?.cleanup();\n setState(initialize);\n }\n const { cleanup } = scopeContext.scope;\n useEvent(() => cleanup, []);\n return (\n <ScopeContext.Provider value={scopeContext}>\n <Provider store={patchedStore}>{children}</Provider>\n </ScopeContext.Provider>\n );\n}\n\nfunction isEqualSet(a: Set<unknown>, b: Set<unknown>) {\n return a === b || (a.size === b.size && Array.from(a).every((v) => b.has(v)));\n}\n\nfunction useEvent(fn: EffectCallback, deps: unknown[]) {\n const ref = useRef(fn);\n ref.current = fn;\n useEffect(() => ref.current(), deps);\n}\n"],"names":["createIsolation","StoreContext","createContext","Provider","store","initialValues","children","storeRef","useRef","current","createStore","useHydrateAtoms","_jsx","value","useStore","options","useContext","Error","useStoreOrig","_extends","useAtom","anAtom","useAtomOrig","useAtomValue","useAtomValueOrig","useSetAtom","useSetAtomOrig","globalScopeKey","process","env","NODE_ENV","name","toString","createScope","atoms","atomFamilies","parentScope","scopeName","explicit","WeakMap","implicit","inherited","currentScope","getAtom","cleanup","prepareWriteAtom","originalAtom","implicitScope","read","defaultRead","isWritableAtom","write","defaultWrite","createScopedWrite","bind","undefined","set","cloneAtom","cleanupFamiliesSet","Set","atomFamily","param","getParams","has","cleanupFamily","unstable_listen","e","type","atom","delete","add","combineVoidFunctions","Array","from","_inherited$get2","get","scopeKey","_inherited$get","ancestorAtom","explicitScope","setInheritedAtom","inheritAtom","scopedAtom","filter","Boolean","Object","create","getPrototypeOf","getOwnPropertyDescriptors","createScopedRead","scopedRead","opts","scopedGet","a","scopedWrite","args","scopedSet","v","fns","combinedFunctions","fn","PatchedStore","createPatchedStore","baseStore","scope","restore","sub","assign","prototype","isTopLevelScope","parentStore","ScopeContext","ScopeProvider","debugName","atomSet","atomFamilySet","initialize","patchedStore","scopeContext","hasChanged","isEqualSet","state","setState","useState","_scopeContext$scope","useEvent","b","size","every","deps","ref","useEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;SAegBA,eAAeA,GAAA;AAC7B,EAAA,MAAMC,YAAY,GAAGC,aAAa,CAAe,IAAI,CAAC,CAAA;AAEtD,EAAA,SAASC,QAAQA,CAAC;IAChBC,KAAK;AACLC,IAAAA,aAAa,GAAG,EAAE;AAClBC,IAAAA,QAAAA;AAKD,GAAA,EAAA;AACC,IAAA,MAAMC,QAAQ,GAAGC,MAAM,CAAC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