securemark 0.253.0 → 0.253.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.253.1
4
+
5
+ - Refactoring.
6
+
3
7
  ## 0.253.0
4
8
 
5
9
  - Change annotation processing.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.253.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.253.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory(require("DOMPurify"), require("Prism"));
@@ -758,7 +758,26 @@ function run() {
758
758
 
759
759
  /***/ }),
760
760
 
761
- /***/ 413:
761
+ /***/ 5529:
762
+ /***/ ((__unused_webpack_module, exports) => {
763
+
764
+ "use strict";
765
+
766
+
767
+ Object.defineProperty(exports, "__esModule", ({
768
+ value: true
769
+ }));
770
+ exports.equal = void 0;
771
+
772
+ function equal(a, b) {
773
+ return a === a ? a === b : b !== b;
774
+ }
775
+
776
+ exports.equal = equal;
777
+
778
+ /***/ }),
779
+
780
+ /***/ 5084:
762
781
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
763
782
 
764
783
  "use strict";
@@ -863,25 +882,6 @@ exports.MultiMap = MultiMap;
863
882
 
864
883
  /***/ }),
865
884
 
866
- /***/ 5529:
867
- /***/ ((__unused_webpack_module, exports) => {
868
-
869
- "use strict";
870
-
871
-
872
- Object.defineProperty(exports, "__esModule", ({
873
- value: true
874
- }));
875
- exports.equal = void 0;
876
-
877
- function equal(a, b) {
878
- return a === a ? a === b : b !== b;
879
- }
880
-
881
- exports.equal = equal;
882
-
883
- /***/ }),
884
-
885
885
  /***/ 7822:
886
886
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
887
887
 
@@ -1417,7 +1417,7 @@ Object.defineProperty(exports, "__esModule", ({
1417
1417
  value: true
1418
1418
  }));
1419
1419
 
1420
- __exportStar(__webpack_require__(413), exports);
1420
+ __exportStar(__webpack_require__(5084), exports);
1421
1421
 
1422
1422
  /***/ }),
1423
1423
 
@@ -3314,7 +3314,7 @@ function bind(target, settings) {
3314
3314
  };
3315
3315
  }
3316
3316
 
3317
- for (const el of (0, footnote_1.footnote)(next(0)?.parentNode ?? target, settings.footnotes, context)) {
3317
+ for (const el of (0, footnote_1.footnote)(next(0)?.parentNode ?? target, settings.footnotes, context, bottom)) {
3318
3318
  el ? yield {
3319
3319
  type: 'footnote',
3320
3320
  value: el
@@ -4289,10 +4289,10 @@ exports.message = (0, combinator_1.block)((0, combinator_1.validate)('~~~', (0,
4289
4289
  }, `${opener}${body}${closer}`)];
4290
4290
  }
4291
4291
 
4292
- return [(0, dom_1.html)('div', {
4292
+ return [(0, dom_1.html)('section', {
4293
4293
  class: `message`,
4294
4294
  'data-type': type
4295
- }, (0, array_1.unshift)([(0, dom_1.html)('h6', title(type))], [...(0, segment_1.segment)(body)].reduce((acc, seg) => (0, array_1.push)(acc, (0, parser_1.eval)(content(seg, context), [])), [])))];
4295
+ }, (0, array_1.unshift)([(0, dom_1.html)('h1', title(type))], [...(0, segment_1.segment)(body)].reduce((acc, seg) => (0, array_1.push)(acc, (0, parser_1.eval)(content(seg, context), [])), [])))];
4296
4296
  })));
4297
4297
 
4298
4298
  function title(type) {
@@ -6997,7 +6997,7 @@ const multimap_1 = __webpack_require__(940);
6997
6997
  const array_1 = __webpack_require__(8112);
6998
6998
 
6999
6999
  function* figure(target, footnotes, opts = {}) {
7000
- const refs = new multimap_1.MultiMap((0, array_1.push)((0, array_1.push)((0, array_1.push)([], target.querySelectorAll('a.label:not(.disabled)[data-label]')), footnotes?.annotations?.querySelectorAll('a.label:not(.disabled)') ?? []), footnotes?.references.querySelectorAll('a.label:not(.disabled)') ?? []).map(el => [el.getAttribute('data-label'), el]));
7000
+ const refs = new multimap_1.MultiMap((0, array_1.push)((0, array_1.push)([], target.querySelectorAll('a.label:not(.disabled)[data-label]')), footnotes?.references.querySelectorAll('a.label:not(.disabled)') ?? []).map(el => [el.getAttribute('data-label'), el]));
7001
7001
  const labels = new global_1.Set();
7002
7002
  const numbers = new global_1.Map();
7003
7003
  let base = '0';
@@ -7191,9 +7191,9 @@ const multimap_1 = __webpack_require__(940);
7191
7191
 
7192
7192
  const array_1 = __webpack_require__(8112);
7193
7193
 
7194
- function* footnote(target, footnotes, opts = {}) {
7195
- yield* (0, exports.reference)(target, footnotes?.references, opts);
7196
- yield* (0, exports.annotation)(target, footnotes?.annotations, opts);
7194
+ function* footnote(target, footnotes, opts = {}, bottom = null) {
7195
+ yield* (0, exports.reference)(target, footnotes?.references, opts, bottom);
7196
+ yield* (0, exports.annotation)(target, footnotes?.annotations, opts, bottom);
7197
7197
  return;
7198
7198
  }
7199
7199
 
@@ -7204,8 +7204,7 @@ exports.reference = build('reference', (n, abbr) => `[${abbr || n}]`);
7204
7204
  function build(syntax, marker, splitter) {
7205
7205
  // Referenceを含むAnnotationの重複排除は両構文が互いに処理済みであることを必要とするため
7206
7206
  // 構文ごとに各1回の処理では不可能
7207
- return function* (target, footnote, opts = {}) {
7208
- //assert(syntax !== 'annotation' || !footnote);
7207
+ return function* (target, footnote, opts = {}, bottom = null) {
7209
7208
  const defs = new global_1.Map();
7210
7209
  const buffer = new multimap_1.MultiMap();
7211
7210
  const titles = new global_1.Map(); // Bug: Firefox
@@ -7312,7 +7311,7 @@ function build(syntax, marker, splitter) {
7312
7311
  if (defs.size > 0 || footnote) {
7313
7312
  yield* proc(defs, footnote ?? target.insertBefore((0, dom_1.html)('ol', {
7314
7313
  class: `${syntax}s`
7315
- }), splitters[0] ?? target.querySelector(':scope > :is(#annotations, #references)')));
7314
+ }), splitters[0] ?? bottom));
7316
7315
  }
7317
7316
 
7318
7317
  return;
@@ -8740,7 +8739,7 @@ function fix(h) {
8740
8739
  /***/ 3252:
8741
8740
  /***/ (function(module) {
8742
8741
 
8743
- /*! typed-dom v0.0.298 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
8742
+ /*! typed-dom v0.0.299 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
8744
8743
  (function webpackUniversalModuleDefinition(root, factory) {
8745
8744
  if(true)
8746
8745
  module.exports = factory();
@@ -9174,7 +9173,7 @@ exports.defrag = defrag;
9174
9173
  /***/ 6120:
9175
9174
  /***/ (function(module) {
9176
9175
 
9177
- /*! typed-dom v0.0.298 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
9176
+ /*! typed-dom v0.0.299 https://github.com/falsandtru/typed-dom | (c) 2016, falsandtru | (Apache-2.0 AND MPL-2.0) License */
9178
9177
  (function webpackUniversalModuleDefinition(root, factory) {
9179
9178
  if(true)
9180
9179
  module.exports = factory();
package/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * @author falsandtru https://github.com/falsandtru/securemark
6
6
  */
7
7
 
8
- import { Collection } from 'spica/collection';
8
+ import { Dict } from 'spica/dict';
9
9
 
10
10
  export function parse(source: string, options?: ParserOptions): DocumentFragment;
11
11
  export function bind(target: DocumentFragment | HTMLElement | ShadowRoot, settings: ParserSettings): {
@@ -33,7 +33,6 @@ export interface ParserSettings {
33
33
  // For editing.
34
34
  readonly caches?: Partial<Caches>;
35
35
  readonly footnotes: {
36
- readonly annotations?: HTMLOListElement;
37
36
  readonly references: HTMLOListElement;
38
37
  };
39
38
  readonly chunk?: boolean;
@@ -48,23 +47,23 @@ export type Progress =
48
47
  | { type: 'cancel' };
49
48
 
50
49
  export interface RenderingOptions {
51
- readonly code?: (target: HTMLElement, cache?: Collection<string, HTMLElement>) => void;
52
- readonly math?: (target: HTMLElement, cache?: Collection<string, HTMLElement>) => void;
50
+ readonly code?: (target: HTMLElement, cache?: Dict<string, HTMLElement>) => void;
51
+ readonly math?: (target: HTMLElement, cache?: Dict<string, HTMLElement>) => void;
53
52
  readonly media?: {
54
53
  readonly twitter?: (source: HTMLImageElement, url: URL) => HTMLElement | undefined;
55
54
  readonly youtube?: (source: HTMLImageElement, url: URL) => HTMLElement | undefined;
56
55
  readonly pdf?: (source: HTMLImageElement, url: URL) => HTMLElement | undefined;
57
56
  readonly video?: (source: HTMLImageElement, url: URL) => HTMLVideoElement | undefined;
58
57
  readonly audio?: (source: HTMLImageElement, url: URL) => HTMLAudioElement | undefined;
59
- readonly image?: (source: HTMLImageElement, url: URL, cache?: Collection<string, HTMLElement>) => HTMLImageElement;
58
+ readonly image?: (source: HTMLImageElement, url: URL, cache?: Dict<string, HTMLElement>) => HTMLImageElement;
60
59
  };
61
60
  readonly caches?: Partial<Caches>;
62
61
  }
63
62
 
64
63
  export interface Caches {
65
- readonly code: Collection<string, HTMLElement>;
66
- readonly math: Collection<string, HTMLElement>;
67
- readonly media: Collection<string, HTMLElement>;
64
+ readonly code: Dict<string, HTMLElement>;
65
+ readonly math: Dict<string, HTMLElement>;
66
+ readonly media: Dict<string, HTMLElement>;
68
67
  }
69
68
 
70
69
  export interface Info {
package/markdown.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Parser, Ctx } from './src/combinator/data/parser';
2
- import { Collection } from 'spica/collection';
2
+ import { Dict } from 'spica/dict';
3
3
 
4
4
  declare abstract class Markdown<T> {
5
5
  private parser?: T;
@@ -29,9 +29,9 @@ export namespace MarkdownParser {
29
29
  };
30
30
  };
31
31
  readonly caches?: {
32
- readonly code?: Collection<string, HTMLElement>;
33
- readonly math?: Collection<string, HTMLElement>;
34
- readonly media?: Collection<string, HTMLElement>;
32
+ readonly code?: Dict<string, HTMLElement>;
33
+ readonly math?: Dict<string, HTMLElement>;
34
+ readonly media?: Dict<string, HTMLElement>;
35
35
  };
36
36
  }
37
37
  export interface SegmentParser extends
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.253.0",
3
+ "version": "0.253.1",
4
4
  "description": "Secure markdown renderer working on browsers for user input data.",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/falsandtru/securemark",
@@ -34,29 +34,29 @@
34
34
  "@types/mocha": "9.1.1",
35
35
  "@types/power-assert": "1.5.8",
36
36
  "@types/prismjs": "1.26.0",
37
- "@typescript-eslint/parser": "^5.27.1",
37
+ "@typescript-eslint/parser": "^5.28.0",
38
38
  "babel-loader": "^8.2.5",
39
39
  "babel-plugin-unassert": "^3.2.0",
40
- "concurrently": "^7.2.1",
40
+ "concurrently": "^7.2.2",
41
41
  "eslint": "^8.17.0",
42
42
  "eslint-plugin-redos": "^4.4.0",
43
43
  "eslint-webpack-plugin": "^3.1.1",
44
44
  "glob": "^8.0.3",
45
- "karma": "^6.3.20",
45
+ "karma": "^6.4.0",
46
46
  "karma-chrome-launcher": "^3.1.1",
47
47
  "karma-coverage": "^2.2.0",
48
48
  "karma-firefox-launcher": "^2.1.2",
49
49
  "karma-mocha": "^2.0.1",
50
50
  "karma-power-assert": "^1.0.0",
51
51
  "mocha": "^10.0.0",
52
- "npm-check-updates": "^13.1.2",
52
+ "npm-check-updates": "^13.1.5",
53
53
  "semver": "^7.3.7",
54
- "spica": "0.0.567",
54
+ "spica": "0.0.570",
55
55
  "ts-loader": "^9.3.0",
56
- "typed-dom": "^0.0.298",
56
+ "typed-dom": "^0.0.299",
57
57
  "typescript": "4.7.3",
58
58
  "webpack": "^5.73.0",
59
- "webpack-cli": "^4.9.2",
59
+ "webpack-cli": "^4.10.0",
60
60
  "webpack-merge": "^5.8.0"
61
61
  },
62
62
  "scripts": {
@@ -1,4 +1,4 @@
1
- import { ParserSettings, Progress } from '../../..';
1
+ import { Progress } from '../../..';
2
2
  import { bind } from './bind';
3
3
  import { frag, html } from 'typed-dom/dom';
4
4
 
@@ -27,7 +27,7 @@ describe('Unit: parser/api/bind', () => {
27
27
  return acc;
28
28
  }
29
29
 
30
- const cfgs: ParserSettings = { footnotes: { annotations: html('ol'), references: html('ol') } };
30
+ const cfgs = { footnotes: { annotations: html('ol'), references: html('ol') } };
31
31
 
32
32
  it('huge input', () => {
33
33
  const iter = bind(html('div'), { ...cfgs, id: '' }).parse(`${'\n'.repeat(10 * 1000 ** 2)}`);
@@ -122,7 +122,7 @@ export function bind(target: DocumentFragment | HTMLElement | ShadowRoot, settin
122
122
  : yield { type: 'break' };
123
123
  if (rev !== revision) return yield { type: 'cancel' };
124
124
  }
125
- for (const el of footnote(next(0)?.parentNode ?? target, settings.footnotes, context)) {
125
+ for (const el of footnote(next(0)?.parentNode ?? target, settings.footnotes, context, bottom)) {
126
126
  assert(rev === revision);
127
127
  el
128
128
  ? yield { type: 'footnote', value: el }
@@ -40,7 +40,6 @@ export function parse(source: string, opts: Options = {}, context?: MarkdownPars
40
40
  for (const _ of figure(node, opts.footnotes, context));
41
41
  for (const _ of footnote(node, opts.footnotes, context));
42
42
  assert(opts.id !== '' || !node.querySelector('[id], .index[href], .label[href], .annotation > a[href], .reference > a[href]'));
43
- assert(opts.id !== '' || !opts.footnotes?.annotations?.querySelector('[id], .index[href], .label[href]'));
44
43
  assert(opts.id !== '' || !opts.footnotes?.references.querySelector('[id], .index[href], .label[href]'));
45
44
  return node;
46
45
  }
@@ -15,13 +15,13 @@ describe('Unit: parser/block/extension/message', () => {
15
15
  });
16
16
 
17
17
  it('valid', () => {
18
- assert.deepStrictEqual(inspect(parser('~~~message/note\n~~~')), [['<div class="message" data-type="note"><h6>Note</h6></div>'], '']);
19
- assert.deepStrictEqual(inspect(parser('~~~message/note\n\n~~~')), [['<div class="message" data-type="note"><h6>Note</h6></div>'], '']);
20
- assert.deepStrictEqual(inspect(parser('~~~message/note\na\n~~~')), [['<div class="message" data-type="note"><h6>Note</h6><p>a</p></div>'], '']);
21
- assert.deepStrictEqual(inspect(parser('~~~message/note\na\n\n- \n~~~')), [['<div class="message" data-type="note"><h6>Note</h6><p>a</p><ul><li></li></ul></div>'], '']);
22
- assert.deepStrictEqual(inspect(parser('~~~message/note\n# a\n~~~')), [['<div class="message" data-type="note"><h6>Note</h6><p># a</p></div>'], '']);
23
- assert.deepStrictEqual(inspect(parser('~~~message/caution\n~~~')), [['<div class="message" data-type="caution"><h6>Caution!</h6></div>'], '']);
24
- assert.deepStrictEqual(inspect(parser('~~~message/warning\n~~~')), [['<div class="message" data-type="warning"><h6>WARNING!!</h6></div>'], '']);
18
+ assert.deepStrictEqual(inspect(parser('~~~message/note\n~~~')), [['<section class="message" data-type="note"><h1>Note</h1></section>'], '']);
19
+ assert.deepStrictEqual(inspect(parser('~~~message/note\n\n~~~')), [['<section class="message" data-type="note"><h1>Note</h1></section>'], '']);
20
+ assert.deepStrictEqual(inspect(parser('~~~message/note\na\n~~~')), [['<section class="message" data-type="note"><h1>Note</h1><p>a</p></section>'], '']);
21
+ assert.deepStrictEqual(inspect(parser('~~~message/note\na\n\n- \n~~~')), [['<section class="message" data-type="note"><h1>Note</h1><p>a</p><ul><li></li></ul></section>'], '']);
22
+ assert.deepStrictEqual(inspect(parser('~~~message/note\n# a\n~~~')), [['<section class="message" data-type="note"><h1>Note</h1><p># a</p></section>'], '']);
23
+ assert.deepStrictEqual(inspect(parser('~~~message/caution\n~~~')), [['<section class="message" data-type="caution"><h1>Caution!</h1></section>'], '']);
24
+ assert.deepStrictEqual(inspect(parser('~~~message/warning\n~~~')), [['<section class="message" data-type="warning"><h1>WARNING!!</h1></section>'], '']);
25
25
  });
26
26
 
27
27
  });
@@ -46,8 +46,8 @@ export const message: MessageParser = block(validate('~~~', fmap(
46
46
  }, `${opener}${body}${closer}`)];
47
47
  }
48
48
  return [
49
- html('div', { class: `message`, 'data-type': type }, unshift(
50
- [html('h6', title(type))],
49
+ html('section', { class: `message`, 'data-type': type }, unshift(
50
+ [html('h1', title(type))],
51
51
  [...segment(body)].reduce((acc, seg) => push(acc, eval(content(seg, context), [])), []))),
52
52
  ];
53
53
  })));
@@ -6,14 +6,11 @@ import { push } from 'spica/array';
6
6
 
7
7
  export function* figure(
8
8
  target: ParentNode & Node,
9
- footnotes?: Readonly<{ annotations?: HTMLOListElement; references: HTMLOListElement; }>,
10
- opts: Readonly<{
11
- id?: string;
12
- }> = {},
9
+ footnotes?: { readonly references: HTMLOListElement; },
10
+ opts: { readonly id?: string; } = {},
13
11
  ): Generator<HTMLAnchorElement | undefined, undefined, undefined> {
14
- const refs = new MultiMap<string, HTMLAnchorElement>(push(push(push([],
12
+ const refs = new MultiMap<string, HTMLAnchorElement>(push(push([],
15
13
  target.querySelectorAll('a.label:not(.disabled)[data-label]')),
16
- footnotes?.annotations?.querySelectorAll('a.label:not(.disabled)') ?? []),
17
14
  footnotes?.references.querySelectorAll('a.label:not(.disabled)') ?? [])
18
15
  .map(el => [el.getAttribute('data-label')!, el]));
19
16
  const labels = new Set<string>();
@@ -6,11 +6,12 @@ import { push } from 'spica/array';
6
6
 
7
7
  export function* footnote(
8
8
  target: ParentNode & Node,
9
- footnotes?: Readonly<{ annotations?: HTMLOListElement; references: HTMLOListElement; }>,
10
- opts: Readonly<{ id?: string; }> = {},
9
+ footnotes?: { readonly annotations?: HTMLOListElement; readonly references: HTMLOListElement; },
10
+ opts: { readonly id?: string; } = {},
11
+ bottom: Node | null = null,
11
12
  ): Generator<HTMLAnchorElement | HTMLLIElement | undefined, undefined, undefined> {
12
- yield* reference(target, footnotes?.references, opts);
13
- yield* annotation(target, footnotes?.annotations, opts);
13
+ yield* reference(target, footnotes?.references, opts, bottom);
14
+ yield* annotation(target, footnotes?.annotations, opts, bottom);
14
15
  return;
15
16
  }
16
17
 
@@ -28,9 +29,9 @@ function build(
28
29
  return function* (
29
30
  target: ParentNode & Node,
30
31
  footnote?: HTMLOListElement,
31
- opts: Readonly<{ id?: string }> = {},
32
+ opts: { readonly id?: string } = {},
33
+ bottom: Node | null = null,
32
34
  ): Generator<HTMLAnchorElement | HTMLLIElement | undefined, undefined, undefined> {
33
- //assert(syntax !== 'annotation' || !footnote);
34
35
  const defs = new Map<string, HTMLLIElement>();
35
36
  const buffer = new MultiMap<string, HTMLElement>();
36
37
  const titles = new Map<string, string>();
@@ -148,7 +149,7 @@ function build(
148
149
  `^${refIndex}`));
149
150
  }
150
151
  if (defs.size > 0 || footnote) {
151
- yield* proc(defs, footnote ?? target.insertBefore(html('ol', { class: `${syntax}s` }), splitters[0] ?? target.querySelector(':scope > :is(#annotations, #references)')));
152
+ yield* proc(defs, footnote ?? target.insertBefore(html('ol', { class: `${syntax}s` }), splitters[0] ?? bottom));
152
153
  }
153
154
  return;
154
155
  }
@@ -1,7 +1,7 @@
1
1
  import Prism from 'prismjs';
2
- import { Collection } from 'spica/collection';
2
+ import { Dict } from 'spica/dict';
3
3
 
4
- export function code(target: HTMLElement, cache?: Collection<string, HTMLElement>): void {
4
+ export function code(target: HTMLElement, cache?: Dict<string, HTMLElement>): void {
5
5
  assert(target.children.length === 0);
6
6
  const source = target.textContent!;
7
7
  Prism.highlightElement(target, false, () =>
@@ -1,8 +1,8 @@
1
1
  import { undefined } from 'spica/global';
2
- import { Collection } from 'spica/collection';
2
+ import { Dict } from 'spica/dict';
3
3
  import { html, define } from 'typed-dom/dom';
4
4
 
5
- export function math(target: HTMLElement, cache?: Collection<string, HTMLElement>): void {
5
+ export function math(target: HTMLElement, cache?: Dict<string, HTMLElement>): void {
6
6
  assert(target.children.length === 0);
7
7
  const source = target.textContent!;
8
8
  queue(target, () => {
@@ -1,8 +1,8 @@
1
1
  import { Object } from 'spica/global';
2
- import { Collection } from 'spica/collection';
2
+ import { Dict } from 'spica/dict';
3
3
  import { define } from 'typed-dom/dom';
4
4
 
5
- export function image(source: HTMLImageElement, url: URL, cache?: Collection<string, HTMLElement>): HTMLImageElement {
5
+ export function image(source: HTMLImageElement, url: URL, cache?: Dict<string, HTMLElement>): HTMLImageElement {
6
6
  if (cache?.has(url.href)) return define(
7
7
  cache.get(url.href)!.cloneNode(true) as HTMLImageElement,
8
8
  Object.fromEntries([...source.attributes]
@@ -5,7 +5,7 @@ import { pdf } from './media/pdf';
5
5
  import { video } from './media/video';
6
6
  import { audio } from './media/audio';
7
7
  import { image } from './media/image';
8
- import { Collection } from 'spica/collection';
8
+ import { Dict } from 'spica/dict';
9
9
  import { ReadonlyURL } from 'spica/url';
10
10
  import { reduce } from 'spica/memoize';
11
11
 
@@ -14,7 +14,7 @@ type MediaOptions = NonNullable<RenderingOptions['media']>;
14
14
  const extend = reduce((opts: MediaOptions): MediaOptions =>
15
15
  ({ twitter, youtube, pdf, video, audio, image, ...opts }));
16
16
 
17
- export function media(base: string, source: HTMLImageElement, opts: MediaOptions, cache?: Collection<string, HTMLElement>): HTMLElement | undefined {
17
+ export function media(base: string, source: HTMLImageElement, opts: MediaOptions, cache?: Dict<string, HTMLElement>): HTMLElement | undefined {
18
18
  assert(source.matches('img:not([src])[data-src]'));
19
19
  opts = extend(opts);
20
20
  const url = new ReadonlyURL(source.getAttribute('data-src')!, base);