o-spreadsheet icon indicating copy to clipboard operation
o-spreadsheet copied to clipboard

npm version doesn't work: "This is a abstract store for Notifications, it cannot be instantiated."

Open valpackett opened this issue 10 months ago • 4 comments

Version (please indicate which version you are using): 17.2.5, tried some others as well

Platform (OS and Browser + version): Linux, Firefox 125

Describe the bug

The code published on npm crashes in the following way upon instantiation:

Error: This is a abstract store for Notifications, it cannot be instantiated.
Did you forget to inject your store instance?

const stores = useStoreProvider();
stores.inject(MyMetaStore, storeInstance);
    MetaStore o-spreadsheet.esm.js:8084
    build o-spreadsheet.esm.js:8064
    instantiate o-spreadsheet.esm.js:8041
    get o-spreadsheet.esm.js:8036
    useStore o-spreadsheet.esm.js:8132
    setup o-spreadsheet.esm.js:56731
    ComponentNode owl.es.js:2354
    createComponent owl.es.js:5758
    template chunk-JBWWRFNB.js:23
    _render owl.es.js:1719
    render owl.es.js:1711
    initiateRender owl.es.js:2376
    mountComponent owl.es.js:2360
    mountNode owl.es.js:5688
    mount owl.es.js:5659
    <anonymous> index.html:269
    whenReady owl.es.js:306
    <anonymous> index.html:259

Spreadsheet.setup is defined like this in 17.2.5 npm release:

    setup() {
        const stores = useStoreProvider();
        stores.inject(ModelStore, this.model);
        this.notificationStore = useStore(NotificationStore);
        this.composerFocusStore = useStore(ComposerFocusStore);
        this.sidePanel = useStore(SidePanelStore);
        this.keyDownMapping = {
            "CTRL+H": () => this.sidePanel.toggle("FindAndReplace", {}),
            "CTRL+F": () => this.sidePanel.toggle("FindAndReplace", {}),
        };
        const fileStore = this.model.config.external.fileStore;

The 17.2.5 tag on GitHub, which actually refers to the 17.0.20 commit right now, does not contain any NotificationStore lines:

https://github.com/odoo/o-spreadsheet/blob/065ac988cd2fdf18bf2cd8b1d68660c3a45c387f/src/components/spreadsheet/spreadsheet.ts#L286-L297

and does work fine.

To Reproduce Steps to reproduce the behavior:

  1. npm i --save @odoo/o-spreadsheet
  2. Try to build a basic example using the documentation

valpackett avatar May 02 '24 22:05 valpackett

Thanks for the report :) The release script seems to be at fault here, I will investigate it right away.

rrahir avatar May 06 '24 10:05 rrahir

Hi! Just to let you know that we updated the documentation properly with the minimal setup required to start a spreadsheet. Specifically, there was a missing step concerning the setup of the NotificationStore. In the meantime, we also changed that behaviour so you don't have to setup any store before instanciating a Spreadsheet component.

Could you let us know if you can manage to build a basic example with these changes?

Regards,

rrahir avatar Jun 19 '24 09:06 rrahir

Thanks!! Seems to no longer be an issue in npm release 17.3.4.

Another issue though is that the package.json "module" field does not match the actual ESM build file name (.es.js vs .esm.js), breaking tools like Vite that parse npm packages. (One letter to fix…)

image

valpackett avatar Jun 24 '24 21:06 valpackett

Indeed, I will fix that right away :)

rrahir avatar Aug 09 '24 12:08 rrahir