UniversalViewer / universalviewer

A community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎
http://universalviewer.io
Other
490 stars 184 forks source link

sort-by-date button in tree view does not work anymore #953

Open nicolasfranck opened 8 months ago

nicolasfranck commented 8 months ago

UV version:

 universalviewer@4.0.25

I'm submitting a:

Current behavior:

In the tree view of the left panel, when you click "sort by date", nothing seems to happen. In the console you'll see something like this:

6305.0c443d34834424452b37.js:2 Uncaught TypeError: Cannot read properties of undefined (reading 'label')
    at s.init (6305.0c443d34834424452b37.js:2:82657)
    at _tag (4864.b0b319b4f29542847e0e.js:2:53823)
    at Object.eval [as fn] (eval at be (4864.b0b319b4f29542847e0e.js:2:51498), <anonymous>:7:2)
    at ge (4864.b0b319b4f29542847e0e.js:2:45686)
    at Object.de [as render] (4864.b0b319b4f29542847e0e.js:2:44661)
    at s.render (4864.b0b319b4f29542847e0e.js:2:56986)
    at _tag (4864.b0b319b4f29542847e0e.js:2:53943)
    at Function.eval [as fn] (eval at be (4864.b0b319b4f29542847e0e.js:2:51498), <anonymous>:6:2)
    at ge (4864.b0b319b4f29542847e0e.js:2:45822)
    at Function.de [as render] (4864.b0b319b4f29542847e0e.js:2:44661)

Example: https://www.universalviewer.dev/#?xywh=-5354%2C-211%2C13632%2C4199&iiifManifestId=https%3A%2F%2Fadore.ugent.be%2FIIIF%2Fcollections%2FRUG01-001643403&m=&cv=&rid=https%3A%2F%2Fiiif.wellcomecollection.org%2Fpresentation%2Fb18031511_0001%2Franges%2FLOG_0006

nicolasfranck commented 6 months ago

When I reset the node dependency on @iiif/iiif-tree-component to 2.0.3 it works again for my use case. But possibly that breaks other stuff too?

I see that the latest months support was added for automatic RTL support based on the reported @language, but I cannot see anywhere in my manifest were I should add this. You already checked if the jsonld and underlying label are there, so I do not see why this would fail.

Maybe replace if (data.data.__jsonld.label) { by if (data.data.__jsonld?.label) { on https://github.com/IIIF-Commons/iiif-tree-component/blob/master/src/index.ts#L109? But that would mean that the jsonld isn't set anywhere properly?

demiankatz commented 6 months ago

@nicolasfranck, have you tried testing this in the iiif-tree-component in isolation? It looks like the repository has a built in test page in examples/index.html which you can use to look at your manifest in the component. This might be helpful both to confirm that it's a iiif-tree-component bug (as opposed to some kind of integration problem) and to quickly test whether your suggested fix will make a difference.

nicolasfranck commented 6 months ago

@demiankatz I cannot build that project. I am getting al kinds of errors, somewhere in the build step npm run build:commonjs. Something called tsc is complaining about syntax errors.

demiankatz commented 6 months ago

@nicolasfranck, I just tried it and I was able to build it successfully. Which branch were you working with (I had success on master, but it looks like dev is many years out of date)? Which versions of node/npm are you using? (I had success with npm 8.19.4 and node 16.20.2... which I realize are quite old; maybe something needs to be updated to work with newer versions).

nicolasfranck commented 6 months ago

w117h047:iiif-metadata-component njfranck$ node -v v16.20.2 w117h047:iiif-metadata-component njfranck$ npm run build

@iiif/iiif-metadata-component@1.1.19 build npm run clean && npm run build:css && npm run build:commonjs && npm run build:esmodule && npm run build:umd && npm run build:var && npm run build:types

@iiif/iiif-metadata-component@1.1.19 clean rimraf -rf dist-css dist-umd dist-commonjs dist-esmodule dist-var types

@iiif/iiif-metadata-component@1.1.19 build:css cross-env mkdir dist-css && npx lessc ./src/css/styles.less > ./dist-css/styles.css && cross-env cp ./dist-css/styles.css ./dist-css/styles.less

@iiif/iiif-metadata-component@1.1.19 build:commonjs tsc

../../node_modules/@types/chrome-remote-interface/index.d.ts:1:13 - error TS1005: '=' expected.

1 import type ProtocolMappingApi from "devtools-protocol/types/protocol-mapping";


../../node_modules/@types/chrome-remote-interface/index.d.ts:1:32 - error TS1005: ';' expected.

1 import type ProtocolMappingApi from "devtools-protocol/types/protocol-mapping";

../../node_modules/@types/chrome-remote-interface/index.d.ts:1:37 - error TS1005: ';' expected.

1 import type ProtocolMappingApi from "devtools-protocol/types/protocol-mapping";


../../node_modules/@types/chrome-remote-interface/index.d.ts:2:13 - error TS1005: '=' expected.

2 import type ProtocolProxyApi from "devtools-protocol/types/protocol-proxy-api";

../../node_modules/@types/chrome-remote-interface/index.d.ts:2:30 - error TS1005: ';' expected.

2 import type ProtocolProxyApi from "devtools-protocol/types/protocol-proxy-api";


../../node_modules/@types/chrome-remote-interface/index.d.ts:2:35 - error TS1005: ';' expected.

2 import type ProtocolProxyApi from "devtools-protocol/types/protocol-proxy-api";

../../node_modules/@types/chrome-remote-interface/index.d.ts:149:77 - error TS1110: Type expected.

149 type GetEventFromString<D extends string, S extends string> = S extends ${D}.${infer E} ? E : never;



../../node_modules/@types/chrome-remote-interface/index.d.ts:149:91 - error TS1005: '}' expected.

149     type GetEventFromString<D extends string, S extends string> = S extends `${D}.${infer E}` ? E : never;
                                                                                              ~

../../node_modules/@types/chrome-remote-interface/index.d.ts:151:63 - error TS1005: ';' expected.

151     type GetReturnType<D extends string, E extends string> = `${D}.${E}` extends keyof ProtocolMappingApi.Events
                                                                  ~

../../node_modules/@types/chrome-remote-interface/index.d.ts:151:64 - error TS1005: ';' expected.

151     type GetReturnType<D extends string, E extends string> = `${D}.${E}` extends keyof ProtocolMappingApi.Events
                                                                   ~

../../node_modules/@types/chrome-remote-interface/index.d.ts:151:67 - error TS1128: Declaration or statement expected.

151     type GetReturnType<D extends string, E extends string> = `${D}.${E}` extends keyof ProtocolMappingApi.Events
                                                                      ~

../../node_modules/@types/chrome-remote-interface/index.d.ts:151:69 - error TS1005: ';' expected.

151     type GetReturnType<D extends string, E extends string> = `${D}.${E}` extends keyof ProtocolMappingApi.Events
                                                                        ~

../../node_modules/@types/chrome-remote-interface/index.d.ts:152:38 - error TS1005: ';' expected.

152         ? ProtocolMappingApi.Events[`${D}.${E}`][0]
                                         ~

../../node_modules/@types/chrome-remote-interface/index.d.ts:152:39 - error TS1005: ';' expected.

152         ? ProtocolMappingApi.Events[`${D}.${E}`][0]
                                          ~

../../node_modules/@types/chrome-remote-interface/index.d.ts:152:42 - error TS1128: Declaration or statement expected.

152         ? ProtocolMappingApi.Events[`${D}.${E}`][0]
                                             ~

../../node_modules/@types/chrome-remote-interface/index.d.ts:152:44 - error TS1005: ';' expected.

152         ? ProtocolMappingApi.Events[`${D}.${E}`][0]
                                               ~

../../node_modules/@types/chrome-remote-interface/index.d.ts:168:46 - error TS1005: ';' expected.

168      * Checks whether the only parameter of `T[key]` is nullable i.e. all of
                                                 ~

../../node_modules/@types/chrome-remote-interface/index.d.ts:343:1 - error TS1160: Unterminated template literal.

343 

Found 18 errors.
demiankatz commented 6 months ago

@nicolasfranck, your message above seems to show iiif-metadata-component, but I was referring to iiif-tree-component. That's probably the difference. :-) I think we've discussed iiif-metadata-component in the context of a separate issue, but for this one, iiif-tree-component should be the relevant one.

nicolasfranck commented 6 months ago

My bad. But there I get the same errors. A small part of the log:

w117h047:iiif-tree-component njfranck$ npm run build

@iiif/iiif-tree-component@2.0.6 build npm run clean && npm run build:css && npm run build:commonjs && npm run build:esmodule && npm run build:umd && npm run build:var && npm run build:types

@iiif/iiif-tree-component@2.0.6 clean rimraf -rf dist-css dist-umd dist-commonjs dist-esmodule dist-var types

@iiif/iiif-tree-component@2.0.6 build:css cross-env mkdir dist-css && npx lessc ./src/css/styles.less > ./dist-css/styles.css && cross-env cp ./dist-css/styles.css ./dist-css/styles.less

@iiif/iiif-tree-component@2.0.6 build:commonjs tsc

../../node_modules/@types/chrome-remote-interface/index.d.ts:1:13 - error TS1005: '=' expected.

demiankatz commented 6 months ago

Very strange. Here's what I'm seeing:

git clone https://github.com/IIIF-Commons/iiif-tree-component
Cloning into 'iiif-tree-component'...
remote: Enumerating objects: 1171, done.
remote: Counting objects: 100% (170/170), done.
remote: Compressing objects: 100% (84/84), done.
remote: Total 1171 (delta 99), reused 139 (delta 76), pack-reused 1001
Receiving objects: 100% (1171/1171), 903.27 KiB | 7.92 MiB/s, done.
Resolving deltas: 100% (777/777), done.
dkatz@dkatz-VirtualBox:/tmp$ cd iiif-tree-component/
dkatz@dkatz-VirtualBox:/tmp/iiif-tree-component$ npm i
npm WARN deprecated ini@1.3.5: Please update to ini >=1.3.6 to avoid a prototype pollution issue
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated har-validator@5.1.3: this library is no longer supported
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated source-map-url@0.4.0: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated uuid@3.3.3: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated source-map-resolve@0.5.2: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated request@2.88.0: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated buffer@4.9.1: This version of 'buffer' is out-of-date. You must update to v4.9.2 or newer

added 540 packages, and audited 541 packages in 7s

40 vulnerabilities (1 low, 11 moderate, 23 high, 5 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
dkatz@dkatz-VirtualBox:/tmp/iiif-tree-component$ npm run build

> @iiif/iiif-tree-component@2.0.6 build
> npm run clean && npm run build:css && npm run build:commonjs && npm run build:esmodule && npm run build:umd && npm run build:var && npm run build:types

> @iiif/iiif-tree-component@2.0.6 clean
> rimraf -rf dist-css dist-umd dist-commonjs dist-esmodule dist-var types

> @iiif/iiif-tree-component@2.0.6 build:css
> cross-env mkdir dist-css && npx lessc ./src/css/styles.less > ./dist-css/styles.css && cross-env cp ./dist-css/styles.css ./dist-css/styles.less

> @iiif/iiif-tree-component@2.0.6 build:commonjs
> tsc

> @iiif/iiif-tree-component@2.0.6 build:esmodule
> tsc -m es6 --outDir dist-esmodule

> @iiif/iiif-tree-component@2.0.6 build:umd
> webpack

ℹ 「atl」: Using typescript@3.6.3 from typescript
ℹ 「atl」: Using tsconfig.json from /tmp/iiif-tree-component/tsconfig.json
ℹ 「atl」: Checking started in a separate process...
ℹ 「atl」: Time: 5ms
Hash: cff8380bd058889e0837
Version: webpack 4.41.2
Time: 2049ms
Built at: 03/15/2024 3:55:03 PM
                      Asset      Size  Chunks             Chunk Names
../dist-commonjs/index.d.ts  1.78 KiB          [emitted]  
       IIIFTreeComponent.js  99.5 KiB       0  [emitted]  IIIFTreeComponent
Entrypoint IIIFTreeComponent = IIIFTreeComponent.js
[2] multi ./src/index.ts 28 bytes {0} [built]
[3] ./src/index.ts 11.4 KiB {0} [built]
[5] ./node_modules/@iiif/manifold/dist-esmodule/index.js + 14 modules 71.4 KiB {0} [built]
    |    15 modules
    + 3 hidden modules

WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/

> @iiif/iiif-tree-component@2.0.6 build:var
> cross-env NODE_WEBPACK_LIBRARY_PATH=dist-var NODE_WEBPACK_LIBRARY_TARGET=var webpack

ℹ 「atl」: Using typescript@3.6.3 from typescript
ℹ 「atl」: Using tsconfig.json from /tmp/iiif-tree-component/tsconfig.json
ℹ 「atl」: Checking started in a separate process...
ℹ 「atl」: Time: 7ms
Hash: 03e2c3ee4b4852479142
Version: webpack 4.41.2
Time: 2027ms
Built at: 03/15/2024 3:55:06 PM
                      Asset      Size  Chunks             Chunk Names
../dist-commonjs/index.d.ts  1.78 KiB          [emitted]  
       IIIFTreeComponent.js  99.2 KiB       0  [emitted]  IIIFTreeComponent
Entrypoint IIIFTreeComponent = IIIFTreeComponent.js
[2] multi ./src/index.ts 28 bytes {0} [built]
[3] ./src/index.ts 11.4 KiB {0} [built]
[5] ./node_modules/@iiif/manifold/dist-esmodule/index.js + 14 modules 71.4 KiB {0} [built]
    |    15 modules
    + 3 hidden modules

WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/

> @iiif/iiif-tree-component@2.0.6 build:types
> dts-bundle-generator --umd-module-name IIIFTreeComponent -o types/index.d.ts dist-esmodule/index.d.ts

Compiling input files...
Compiler option `outDir` is not supported and will be removed while generating dts
Processing dist-esmodule/index.d.ts
Adding import with name "TreeNode" for library "manifesto.js"
Adding import with name "TreeSortType" for library "@iiif/manifold"
Adding import with name "Helper" for library "@iiif/manifold"
Adding import with name "MultiSelectableTreeNode" for library "@iiif/manifold"
Adding import with name "IBaseComponentOptions" for library "@iiif/base-component"
Adding import with name "BaseComponent" for library "@iiif/base-component"
Writing dist-esmodule/index.d.ts -> types/index.d.ts
Checking generated files...
Compiler option "skipLibCheck" is disabled to properly check generated output
Done in 2.04s