@annotorious/annotorious
Advanced tools
@@ -7,3 +7,4 @@ import { Rectangle, RectangleGeometry } from '../../core'; | ||
| } | ||
| export declare const isFragmentSelector: (selector: any) => boolean; | ||
| export declare const parseFragmentSelector: (fragmentOrSelector: FragmentSelector | string, invertY?: boolean) => Rectangle; | ||
| export declare const serializeFragmentSelector: (geometry: RectangleGeometry) => FragmentSelector; |
@@ -5,3 +5,3 @@ import { W3CAnnotation, W3CAnnotationTarget } from '@annotorious/core'; | ||
| export interface W3CImageAnnotation extends W3CAnnotation { | ||
| target: W3CImageAnnotationTarget | W3CImageAnnotationTarget[]; | ||
| target: W3CImageAnnotationTarget | W3CImageAnnotationTarget[] | string; | ||
| } | ||
@@ -8,0 +8,0 @@ export interface W3CImageAnnotationTarget extends W3CAnnotationTarget { |
+2
-2
| { | ||
| "name": "@annotorious/annotorious", | ||
| "version": "3.7.14-beta", | ||
| "version": "3.7.15", | ||
| "description": "Add image annotation functionality to any web page with a few lines of JavaScript", | ||
@@ -54,3 +54,3 @@ "author": "Rainer Simon", | ||
| "dependencies": { | ||
| "@annotorious/core": "3.7.14-beta", | ||
| "@annotorious/core": "3.7.15", | ||
| "dequal": "^2.0.3", | ||
@@ -57,0 +57,0 @@ "rbush": "^4.0.1", |
@@ -14,2 +14,19 @@ import type { Rectangle, RectangleGeometry } from '../../core'; | ||
| export const isFragmentSelector = ( | ||
| selector: any | ||
| ): boolean => { | ||
| if (selector?.type === 'FragmentSelector') | ||
| return true; | ||
| if (typeof selector === 'string') { | ||
| const hashIndex = selector.indexOf("#"); | ||
| if (hashIndex < 0) return false; | ||
| const xywh = /^#xywh(?:=(?:pixel:|percent:)?)\s*\d+(\.\d*)?,\s*\d+(\.\d*)?,\s*\d+(\.\d*)?,\s*\d+(\.\d*)?$/i; | ||
| return xywh.test(selector); | ||
| } | ||
| return false; | ||
| } | ||
| export const parseFragmentSelector = ( | ||
@@ -25,2 +42,5 @@ fragmentOrSelector: FragmentSelector | string, | ||
| const matches = [...fragment.matchAll(regex)][0]; | ||
| if (!matches) throw new Error('Not a MediaFragment: ' + fragment); | ||
| const [_, prefix, unit, a, b, c, d] = matches; | ||
@@ -27,0 +47,0 @@ |
@@ -7,3 +7,3 @@ import type { W3CAnnotation, W3CAnnotationTarget } from '@annotorious/core'; | ||
| target: W3CImageAnnotationTarget | W3CImageAnnotationTarget[]; | ||
| target: W3CImageAnnotationTarget | W3CImageAnnotationTarget[] | string; | ||
@@ -10,0 +10,0 @@ } |
@@ -7,3 +7,3 @@ import { v4 as uuidv4 } from 'uuid'; | ||
| import type {FragmentSelector } from './fragment'; | ||
| import { parseFragmentSelector, serializeFragmentSelector } from './fragment'; | ||
| import { isFragmentSelector, parseFragmentSelector, serializeFragmentSelector } from './fragment'; | ||
| import type { SVGSelector } from './svg'; | ||
@@ -62,3 +62,3 @@ import { parseSVGSelector, serializeSVGSelector } from './svg'; | ||
| const selector = | ||
| typeof w3cSelector === 'string' || w3cSelector?.type === 'FragmentSelector' ? | ||
| isFragmentSelector(w3cSelector) ? | ||
| parseFragmentSelector(w3cSelector as FragmentSelector, opts.invertY) : | ||
@@ -138,3 +138,3 @@ w3cSelector?.type === 'SvgSelector' ? | ||
| if ('annotation' in serialized.target) | ||
| if (typeof serialized.target !== 'string' && 'annotation' in serialized.target) | ||
| delete serialized.target.annotation; | ||
@@ -141,0 +141,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1294199
0.22%9879
0.21%2
-33.33%+ Added
- Removed
Updated