-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmmc: cleanup; +ActualLineItem.timeModified cmmc: no slider if only one item
- Loading branch information
1 parent
28278be
commit effcbf9
Showing
25 changed files
with
708 additions
and
653 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
packages/commerce/service/impls/standalone/get-instance.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { enableStaticRendering } from 'mobx-react-lite' | ||
|
||
import type { CommerceService, CommerceConfig } from '../../../types' | ||
import { StandaloneService } from './index' | ||
import { initSelectionUI } from '../../../util' | ||
|
||
import { readSnapshot, writeSnapshotsOnChange } from './persistence' | ||
|
||
enableStaticRendering(typeof window === "undefined") | ||
|
||
const _LOG = false | ||
const _log = (s: string) => { | ||
if (!_LOG) return; | ||
const d = new Date() | ||
console.log(`TIMESTAMPED: ${d.getUTCMinutes()}:${d.getUTCSeconds()}:${d.getUTCMilliseconds()}`) | ||
console.log(s) | ||
} | ||
|
||
// https://dev.to/ivandotv/mobx-server-side-rendering-with-next-js-4m18 | ||
|
||
let instance: StandaloneService | undefined = undefined | ||
|
||
export const getInstance = ({ | ||
families, | ||
rootNode, | ||
options, | ||
uiSpecifiers | ||
}: CommerceConfig) : CommerceService => { | ||
|
||
if (!options) { | ||
throw new Error('cmmc getInstance(): Standalone Commerce Service requires config options!') | ||
} | ||
|
||
if (typeof window === "undefined") { | ||
if (uiSpecifiers) { | ||
initSelectionUI(uiSpecifiers) | ||
} | ||
_log("NEW INSTANCE: SERVER") ////////// | ||
return new StandaloneService( | ||
families, | ||
rootNode, | ||
options | ||
) | ||
} | ||
|
||
// Client side, create the store only once in the client | ||
if (!instance) { | ||
if (uiSpecifiers) { | ||
initSelectionUI(uiSpecifiers) | ||
} | ||
_log("NEW INSTANCE: CLIENT") /////////// | ||
const snapShot = readSnapshot(options.localStorageKey) | ||
instance = new StandaloneService( | ||
families, | ||
rootNode, | ||
options, | ||
snapShot | ||
) | ||
writeSnapshotsOnChange(instance, options.localStorageKey) | ||
} | ||
|
||
return instance | ||
} | ||
|
Oops, something went wrong.