diff --git a/.codesandbox/ci.json b/.codesandbox/ci.json deleted file mode 100644 index c0ed497..0000000 --- a/.codesandbox/ci.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "sandboxes": [ - "new", - "simple-parser-2xxljf" - ], - "node": "18" -} diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 16eda10..d46434c 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -31,3 +31,5 @@ jobs: - run: node pkg-tests/node-load.cjs - run: node pkg-tests/node-load.mjs - run: node pkg-tests/node-umd.mjs + - run: pnpm dlx pkg-pr-new publish + if: matrix.node == '22' diff --git a/__tests__/presentation-3-parser/utilities.test.ts b/__tests__/presentation-3-parser/utilities.test.ts index 7e9297f..a6a3d72 100644 --- a/__tests__/presentation-3-parser/utilities.test.ts +++ b/__tests__/presentation-3-parser/utilities.test.ts @@ -53,6 +53,35 @@ describe('Misc Utilites', function () { `); }); + test('compressSpecificResource (with styleClass)', () => { + const state: SpecificResource = { + id: 'https://iiif.io/api/cookbook/recipe/0015-start/canvas-start/segment1', + type: 'SpecificResource', + source: { + id: 'https://iiif.io/api/cookbook/recipe/0015-start/canvas/segment1', + type: 'Canvas', + }, + selector: { + type: 'FragmentSelector', + value: 'xywh=225,70,750,150', + }, + styleClass: 'some-class', + }; + + expect(compressSpecificResource(state, { allowString: true, allowSourceString: true, allowedStringType: 'Canvas' })).toMatchInlineSnapshot(` + { + "id": "https://iiif.io/api/cookbook/recipe/0015-start/canvas-start/segment1", + "selector": { + "type": "FragmentSelector", + "value": "xywh=225,70,750,150", + }, + "source": "https://iiif.io/api/cookbook/recipe/0015-start/canvas/segment1", + "styleClass": "some-class", + "type": "SpecificResource", + } + `); + }); + test('compressSpecificResource (single content resource)', () => { const state: SpecificResource = { type: 'SpecificResource', diff --git a/src/shared/compress-specific-resource.ts b/src/shared/compress-specific-resource.ts index 5b74bc5..7743671 100644 --- a/src/shared/compress-specific-resource.ts +++ b/src/shared/compress-specific-resource.ts @@ -39,6 +39,7 @@ export function compressSpecificResource( if ( !Array.isArray(target.selector) && typeof target.selector !== 'string' && + typeof target.styleClass !== 'string' && target.selector.type === 'FragmentSelector' ) { const newId = `${target.source.id}#${target.selector.value}`;