@comunica/actor-rdf-parse-html 4.4.2-alpha.49.0 → 5.0.0

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/README.md CHANGED
@@ -24,7 +24,7 @@ After installing, this package can be added to your engine's configuration as fo
24
24
  {
25
25
  "@context": [
26
26
  ...
27
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html/^4.0.0/components/context.jsonld"
27
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html/^5.0.0/components/context.jsonld"
28
28
  ],
29
29
  "actors": [
30
30
  ...
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "@context": [
3
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html/^4.0.0/components/context.jsonld",
4
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^4.0.0/components/context.jsonld",
5
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-rdf-parse-html/^4.0.0/components/context.jsonld",
6
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-rdf-parse/^4.0.0/components/context.jsonld"
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html/^5.0.0/components/context.jsonld",
4
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^5.0.0/components/context.jsonld",
5
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-rdf-parse-html/^5.0.0/components/context.jsonld",
6
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-rdf-parse/^5.0.0/components/context.jsonld"
7
7
  ],
8
8
  "@id": "npmd:@comunica/actor-rdf-parse-html",
9
9
  "components": [
@@ -48,7 +48,7 @@
48
48
  ]
49
49
  },
50
50
  "default": {
51
- "@id": "npmd:@comunica/bus-rdf-parse-html/^4.0.0/components/ActorRdfParseHtml.jsonld#ActorRdfParseHtml_default_bus"
51
+ "@id": "npmd:@comunica/bus-rdf-parse-html/^5.0.0/components/ActorRdfParseHtml.jsonld#ActorRdfParseHtml_default_bus"
52
52
  },
53
53
  "comment": "The RDF Parse HTML bus for fetching HTML listeners"
54
54
  },
@@ -109,37 +109,37 @@
109
109
  "genericTypeInstances": [
110
110
  {
111
111
  "@type": "ParameterRangeGenericTypeReference",
112
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
112
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
113
113
  },
114
114
  {
115
115
  "@type": "ParameterRangeGenericTypeReference",
116
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
116
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
117
117
  },
118
118
  {
119
119
  "@type": "ParameterRangeGenericTypeReference",
120
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
120
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
121
121
  },
122
122
  {
123
123
  "@type": "ParameterRangeGenericTypeReference",
124
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
124
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
125
125
  }
126
126
  ]
127
127
  },
128
128
  {
129
129
  "@type": "ParameterRangeGenericTypeReference",
130
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
130
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
131
131
  },
132
132
  {
133
133
  "@type": "ParameterRangeGenericTypeReference",
134
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
134
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
135
135
  },
136
136
  {
137
137
  "@type": "ParameterRangeGenericTypeReference",
138
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
138
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
139
139
  },
140
140
  {
141
141
  "@type": "ParameterRangeGenericTypeReference",
142
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
142
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
143
143
  }
144
144
  ]
145
145
  },
@@ -176,19 +176,19 @@
176
176
  "genericTypeInstances": [
177
177
  {
178
178
  "@type": "ParameterRangeGenericTypeReference",
179
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
179
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
180
180
  },
181
181
  {
182
182
  "@type": "ParameterRangeGenericTypeReference",
183
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
183
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
184
184
  },
185
185
  {
186
186
  "@type": "ParameterRangeGenericTypeReference",
187
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
187
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
188
188
  },
189
189
  {
190
190
  "@type": "ParameterRangeGenericTypeReference",
191
- "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
191
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
192
192
  }
193
193
  ]
194
194
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "@context": [
3
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html/^4.0.0/components/context.jsonld"
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html/^5.0.0/components/context.jsonld"
4
4
  ],
5
5
  "@id": "npmd:@comunica/actor-rdf-parse-html",
6
6
  "@type": "Module",
@@ -3,7 +3,7 @@
3
3
  "https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^6.0.0/components/context.jsonld",
4
4
  {
5
5
  "npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
6
- "carph": "npmd:@comunica/actor-rdf-parse-html/^4.0.0/",
6
+ "carph": "npmd:@comunica/actor-rdf-parse-html/^5.0.0/",
7
7
  "ActorRdfParseHtml": {
8
8
  "@id": "carph:components/ActorRdfParseHtml.jsonld#ActorRdfParseHtml",
9
9
  "@prefix": true,
@@ -26,7 +26,7 @@ export declare class ActorRdfParseHtml extends ActorRdfParseFixedMediaTypes {
26
26
  export interface IActorRdfParseHtmlArgs extends IActorRdfParseFixedMediaTypesArgs {
27
27
  /**
28
28
  * The RDF Parse HTML bus for fetching HTML listeners
29
- * @default {<npmd:@comunica/bus-rdf-parse-html/^4.0.0/components/ActorRdfParseHtml.jsonld#ActorRdfParseHtml_default_bus>}
29
+ * @default {<npmd:@comunica/bus-rdf-parse-html/^5.0.0/components/ActorRdfParseHtml.jsonld#ActorRdfParseHtml_default_bus>}
30
30
  */
31
31
  busRdfParseHtml: Bus<Actor<IActionRdfParseHtml, IActorTest, IActorRdfParseHtmlOutput, undefined>, IActionRdfParseHtml, IActorTest, IActorRdfParseHtmlOutput>;
32
32
  }
@@ -9,6 +9,7 @@ const readable_stream_1 = require("readable-stream");
9
9
  * It creates an HTML parser, and delegates its events via the bus-rdf-parse-html bus to other HTML parsing actors.
10
10
  */
11
11
  class ActorRdfParseHtml extends bus_rdf_parse_1.ActorRdfParseFixedMediaTypes {
12
+ busRdfParseHtml;
12
13
  /**
13
14
  * @param args -
14
15
  * \ @defaultNested {{
@@ -22,6 +23,7 @@ class ActorRdfParseHtml extends bus_rdf_parse_1.ActorRdfParseFixedMediaTypes {
22
23
  */
23
24
  constructor(args) {
24
25
  super(args);
26
+ this.busRdfParseHtml = args.busRdfParseHtml;
25
27
  }
26
28
  async runHandle(action, mediaType, context) {
27
29
  const data = new readable_stream_1.Readable({ objectMode: true });
@@ -1 +1 @@
1
- {"version":3,"file":"ActorRdfParseHtml.js","sourceRoot":"","sources":["Actor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import type { IActionRdfParse, IActorRdfParseFixedMediaTypesArgs, IActorRdfParseOutput } from '@comunica/bus-rdf-parse';\nimport {\n ActorRdfParseFixedMediaTypes,\n} from '@comunica/bus-rdf-parse';\nimport type {\n IActionRdfParseHtml,\n IActorRdfParseHtmlOutput,\n IHtmlParseListener,\n} from '@comunica/bus-rdf-parse-html';\nimport type { Actor, Bus, IActorTest } from '@comunica/core';\nimport type { IActionContext } from '@comunica/types';\nimport type * as RDF from '@rdfjs/types';\nimport { Parser } from 'htmlparser2';\nimport { Readable } from 'readable-stream';\n\n/**\n * A comunica HTML RDF Parse Actor.\n * It creates an HTML parser, and delegates its events via the bus-rdf-parse-html bus to other HTML parsing actors.\n */\nexport class ActorRdfParseHtml extends ActorRdfParseFixedMediaTypes {\n private readonly busRdfParseHtml: Bus<Actor<\n IActionRdfParseHtml,\n IActorTest,\n IActorRdfParseHtmlOutput,\n undefined\n >, IActionRdfParseHtml, IActorTest, IActorRdfParseHtmlOutput>;\n\n /**\n * @param args -\n * \\ @defaultNested {{\n * \"text/html\": 1.0,\n * \"application/xhtml+xml\": 0.9\n * }} mediaTypePriorities\n * \\ @defaultNested {{\n * \"text/html\": \"http://www.w3.org/ns/formats/HTML\",\n * \"application/xhtml+xml\": \"http://www.w3.org/ns/formats/HTML\"\n * }} mediaTypeFormats\n */\n public constructor(args: IActorRdfParseHtmlArgs) {\n super(args);\n }\n\n public async runHandle(action: IActionRdfParse, mediaType: string, context: IActionContext):\n Promise<IActorRdfParseOutput> {\n const data = new Readable({ objectMode: true });\n data._read = () => {\n // Do nothing\n };\n\n let maxSize = 0;\n\n // Create callbacks action\n let endBarrier = 1;\n function error(subError: unknown): void {\n data.emit('error', subError);\n }\n function end(): void {\n if (--endBarrier === 0) {\n data.push(null);\n }\n }\n const htmlAction: IActionRdfParseHtml = {\n baseIRI: action.metadata?.baseIRI ?? '',\n context,\n emit: (quad: RDF.Quad) => {\n maxSize--;\n data.push(quad);\n },\n end,\n error,\n headers: action.headers,\n };\n\n try {\n const outputs = await Promise.all(this.busRdfParseHtml.publish(htmlAction));\n endBarrier += outputs.length;\n\n const htmlParseListeners: IHtmlParseListener[] = [];\n for (const output of outputs) {\n // eslint-disable-next-line unicorn/no-useless-undefined\n const { htmlParseListener } = await output.actor.run(htmlAction, undefined);\n htmlParseListeners.push(htmlParseListener);\n }\n\n // Create parser\n const parser = new Parser({\n onclosetag() {\n try {\n for (const htmlParseListener of htmlParseListeners) {\n htmlParseListener.onTagClose();\n }\n } catch (error_: unknown) {\n error(error_);\n }\n },\n onend() {\n try {\n for (const htmlParseListener of htmlParseListeners) {\n htmlParseListener.onEnd();\n }\n } catch (error_: unknown) {\n error(error_);\n }\n end();\n },\n onopentag(name: string, attributes: Record<string, string>) {\n try {\n for (const htmlParseListener of htmlParseListeners) {\n htmlParseListener.onTagOpen(name, attributes);\n }\n } catch (error_: unknown) {\n error(error_);\n }\n },\n ontext(text: string) {\n try {\n for (const htmlParseListener of htmlParseListeners) {\n htmlParseListener.onText(text);\n }\n } catch (error_: unknown) {\n error(error_);\n }\n },\n }, {\n decodeEntities: true,\n recognizeSelfClosing: true,\n xmlMode: false,\n });\n\n const read = data._read = (size: number) => {\n maxSize = Math.max(size, maxSize);\n // eslint-disable-next-line no-unmodified-loop-condition\n while (maxSize > 0) {\n const item = action.data.read();\n if (item === null) {\n action.data.once('readable', () => read(0));\n return;\n }\n parser.write(item.toString());\n }\n };\n\n action.data\n .on('error', error)\n .on('end', () => parser.end());\n } catch (e) {\n setTimeout(() => {\n data.emit('error', e);\n });\n }\n\n return { data };\n }\n}\n\nexport interface IActorRdfParseHtmlArgs extends IActorRdfParseFixedMediaTypesArgs {\n /* eslint-disable max-len */\n /**\n * The RDF Parse HTML bus for fetching HTML listeners\n * @default {<npmd:@comunica/bus-rdf-parse-html/^4.0.0/components/ActorRdfParseHtml.jsonld#ActorRdfParseHtml_default_bus>}\n */\n busRdfParseHtml: Bus<Actor<IActionRdfParseHtml, IActorTest, IActorRdfParseHtmlOutput, undefined>, IActionRdfParseHtml, IActorTest, IActorRdfParseHtmlOutput>;\n /* eslint-enable max-len */\n}\n"]}
1
+ {"version":3,"file":"ActorRdfParseHtml.js","sourceRoot":"","sources":["ActorRdfParseHtml.ts"],"names":[],"mappings":";;;AACA,2DAEiC;AASjC,6CAAqC;AACrC,qDAA2C;AAE3C;;;GAGG;AACH,MAAa,iBAAkB,SAAQ,4CAA4B;IAChD,eAAe,CAK8B;IAE9D;;;;;;;;;;OAUG;IACH,YAAmB,IAA4B;QAC7C,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;IAC9C,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,MAAuB,EAAE,SAAiB,EAAE,OAAuB;QAExF,MAAM,IAAI,GAAG,IAAI,0BAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,KAAK,GAAG,GAAG,EAAE;YAChB,aAAa;QACf,CAAC,CAAC;QAEF,IAAI,OAAO,GAAG,CAAC,CAAC;QAEhB,0BAA0B;QAC1B,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,SAAS,KAAK,CAAC,QAAiB;YAC9B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC/B,CAAC;QACD,SAAS,GAAG;YACV,IAAI,EAAE,UAAU,KAAK,CAAC,EAAE,CAAC;gBACvB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;QACD,MAAM,UAAU,GAAwB;YACtC,OAAO,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,IAAI,EAAE;YACvC,OAAO;YACP,IAAI,EAAE,CAAC,IAAc,EAAE,EAAE;gBACvB,OAAO,EAAE,CAAC;gBACV,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClB,CAAC;YACD,GAAG;YACH,KAAK;YACL,OAA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AE,CAAC;YACX,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACxB,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,CAAC;IAClB,CAAC;CACF;AAvID,8CAuIC","sourcesContent":["import type { IActionRdfParse, IActorRdfParseFixedMediaTypesArgs, IActorRdfParseOutput } from '@comunica/bus-rdf-parse';\nimport {\n ActorRdfParseFixedMediaTypes,\n} from '@comunica/bus-rdf-parse';\nimport type {\n IActionRdfParseHtml,\n IActorRdfParseHtmlOutput,\n IHtmlParseListener,\n} from '@comunica/bus-rdf-parse-html';\nimport type { Actor, Bus, IActorTest } from '@comunica/core';\nimport type { IActionContext } from '@comunica/types';\nimport type * as RDF from '@rdfjs/types';\nimport { Parser } from 'htmlparser2';\nimport { Readable } from 'readable-stream';\n\n/**\n * A comunica HTML RDF Parse Actor.\n * It creates an HTML parser, and delegates its events via the bus-rdf-parse-html bus to other HTML parsing actors.\n */\nexport class ActorRdfParseHtml extends ActorRdfParseFixedMediaTypes {\n private readonly busRdfParseHtml: Bus<Actor<\n IActionRdfParseHtml,\n IActorTest,\n IActorRdfParseHtmlOutput,\n undefined\n >, IActionRdfParseHtml, IActorTest, IActorRdfParseHtmlOutput>;\n\n /**\n * @param args -\n * \\ @defaultNested {{\n * \"text/html\": 1.0,\n * \"application/xhtml+xml\": 0.9\n * }} mediaTypePriorities\n * \\ @defaultNested {{\n * \"text/html\": \"http://www.w3.org/ns/formats/HTML\",\n * \"application/xhtml+xml\": \"http://www.w3.org/ns/formats/HTML\"\n * }} mediaTypeFormats\n */\n public constructor(args: IActorRdfParseHtmlArgs) {\n super(args);\n this.busRdfParseHtml = args.busRdfParseHtml;\n }\n\n public async runHandle(action: IActionRdfParse, mediaType: string, context: IActionContext):\n Promise<IActorRdfParseOutput> {\n const data = new Readable({ objectMode: true });\n data._read = () => {\n // Do nothing\n };\n\n let maxSize = 0;\n\n // Create callbacks action\n let endBarrier = 1;\n function error(subError: unknown): void {\n data.emit('error', subError);\n }\n function end(): void {\n if (--endBarrier === 0) {\n data.push(null);\n }\n }\n const htmlAction: IActionRdfParseHtml = {\n baseIRI: action.metadata?.baseIRI ?? '',\n context,\n emit: (quad: RDF.Quad) => {\n maxSize--;\n data.push(quad);\n },\n end,\n error,\n headers: action.headers,\n };\n\n try {\n const outputs = await Promise.all(this.busRdfParseHtml.publish(htmlAction));\n endBarrier += outputs.length;\n\n const htmlParseListeners: IHtmlParseListener[] = [];\n for (const output of outputs) {\n // eslint-disable-next-line unicorn/no-useless-undefined\n const { htmlParseListener } = await output.actor.run(htmlAction, undefined);\n htmlParseListeners.push(htmlParseListener);\n }\n\n // Create parser\n const parser = new Parser({\n onclosetag() {\n try {\n for (const htmlParseListener of htmlParseListeners) {\n htmlParseListener.onTagClose();\n }\n } catch (error_: unknown) {\n error(error_);\n }\n },\n onend() {\n try {\n for (const htmlParseListener of htmlParseListeners) {\n htmlParseListener.onEnd();\n }\n } catch (error_: unknown) {\n error(error_);\n }\n end();\n },\n onopentag(name: string, attributes: Record<string, string>) {\n try {\n for (const htmlParseListener of htmlParseListeners) {\n htmlParseListener.onTagOpen(name, attributes);\n }\n } catch (error_: unknown) {\n error(error_);\n }\n },\n ontext(text: string) {\n try {\n for (const htmlParseListener of htmlParseListeners) {\n htmlParseListener.onText(text);\n }\n } catch (error_: unknown) {\n error(error_);\n }\n },\n }, {\n decodeEntities: true,\n recognizeSelfClosing: true,\n xmlMode: false,\n });\n\n const read = data._read = (size: number) => {\n maxSize = Math.max(size, maxSize);\n // eslint-disable-next-line no-unmodified-loop-condition\n while (maxSize > 0) {\n const item = action.data.read();\n if (item === null) {\n action.data.once('readable', () => read(0));\n return;\n }\n parser.write(item.toString());\n }\n };\n\n action.data\n .on('error', error)\n .on('end', () => parser.end());\n } catch (e) {\n setTimeout(() => {\n data.emit('error', e);\n });\n }\n\n return { data };\n }\n}\n\nexport interface IActorRdfParseHtmlArgs extends IActorRdfParseFixedMediaTypesArgs {\n /* eslint-disable max-len */\n /**\n * The RDF Parse HTML bus for fetching HTML listeners\n * @default {<npmd:@comunica/bus-rdf-parse-html/^5.0.0/components/ActorRdfParseHtml.jsonld#ActorRdfParseHtml_default_bus>}\n */\n busRdfParseHtml: Bus<Actor<IActionRdfParseHtml, IActorTest, IActorRdfParseHtmlOutput, undefined>, IActionRdfParseHtml, IActorTest, IActorRdfParseHtmlOutput>;\n /* eslint-enable max-len */\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comunica/actor-rdf-parse-html",
3
- "version": "4.4.2-alpha.49.0",
3
+ "version": "5.0.0",
4
4
  "description": "A html rdf-parse actor",
5
5
  "lsd:module": true,
6
6
  "license": "MIT",
@@ -41,13 +41,13 @@
41
41
  "build:components": "componentsjs-generator"
42
42
  },
43
43
  "dependencies": {
44
- "@comunica/bus-rdf-parse": "4.4.2-alpha.49.0",
45
- "@comunica/bus-rdf-parse-html": "4.4.2-alpha.49.0",
46
- "@comunica/core": "4.4.2-alpha.49.0",
47
- "@comunica/types": "4.4.2-alpha.49.0",
44
+ "@comunica/bus-rdf-parse": "^5.0.0",
45
+ "@comunica/bus-rdf-parse-html": "^5.0.0",
46
+ "@comunica/core": "^5.0.0",
47
+ "@comunica/types": "^5.0.0",
48
48
  "@rdfjs/types": "*",
49
49
  "htmlparser2": "^10.0.0",
50
- "readable-stream": "^4.5.2"
50
+ "readable-stream": "^4.7.0"
51
51
  },
52
- "gitHead": "ef6f96cfd8faf7c37955bb7e0fe9f6fc6a994bdf"
52
+ "gitHead": "0b1756fdb9bef014133432489627c1bd71779bd0"
53
53
  }