@comunica/actor-rdf-parse-html-script 1.21.1 → 2.0.1-alpha.6.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/LICENSE.txt +22 -0
- package/README.md +6 -15
- package/components/ActorRdfParseHtmlScript.jsonld +171 -0
- package/components/components.jsonld +5 -3
- package/components/context.jsonld +45 -5
- package/lib/ActorRdfParseHtmlScript.d.ts +12 -6
- package/lib/HtmlScriptListener.d.ts +6 -7
- package/lib/HtmlScriptListener.js +14 -10
- package/lib/index.d.ts +1 -0
- package/{index.js → lib/index.js} +1 -1
- package/package.json +15 -37
- package/components/Actor/RdfParse/HtmlScript.jsonld +0 -45
- package/index.d.ts +0 -1
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2017–now Ruben Taelman, Joachim Van Herwegen
|
|
4
|
+
Comunica Association and Ghent University – imec, Belgium
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -23,24 +23,15 @@ After installing, this package can be added to your engine's configuration as fo
|
|
|
23
23
|
{
|
|
24
24
|
"@context": [
|
|
25
25
|
...
|
|
26
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html-script/^
|
|
26
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html-script/^2.0.0/components/context.jsonld"
|
|
27
27
|
],
|
|
28
28
|
"actors": [
|
|
29
29
|
...
|
|
30
30
|
{
|
|
31
|
-
"@id": "
|
|
31
|
+
"@id": "urn:comunica:default:rdf-parse-html/actors#script",
|
|
32
32
|
"@type": "ActorRdfParseHtmlScript",
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
"@type": "MediatorCombineUnion",
|
|
36
|
-
"cc:Mediator/bus": { "@id": "cbrp:Bus/RdfParse" },
|
|
37
|
-
"cmcu:Mediator/CombineUnion/field": "mediaTypes"
|
|
38
|
-
},
|
|
39
|
-
"carphs:mediatorRdfParseHandle": {
|
|
40
|
-
"@id": "config-sets:rdf-parsers.json#mediatorRdfParseHandle",
|
|
41
|
-
"@type": "MediatorRace",
|
|
42
|
-
"cc:Mediator/bus": { "@id": "cbrp:Bus/RdfParse" }
|
|
43
|
-
}
|
|
33
|
+
"mediatorRdfParseMediatypes": { "@id": "urn:comunica:default:rdf-parse/mediators#mediaType" },
|
|
34
|
+
"mediatorRdfParseHandle": { "@id": "urn:comunica:default:rdf-parse/mediators#parse" }
|
|
44
35
|
}
|
|
45
36
|
]
|
|
46
37
|
}
|
|
@@ -48,5 +39,5 @@ After installing, this package can be added to your engine's configuration as fo
|
|
|
48
39
|
|
|
49
40
|
### Config Parameters
|
|
50
41
|
|
|
51
|
-
* `
|
|
52
|
-
* `
|
|
42
|
+
* `mediatorRdfParseMediatypes`: A mediator over the [RDF Parse bus](https://github.com/comunica/comunica/tree/master/packages/bus-rdf-parse) for collecting media types.
|
|
43
|
+
* `mediatorRdfParseHandle`: A mediator over the [RDF Parse bus](https://github.com/comunica/comunica/tree/master/packages/bus-rdf-parse) for actual parsing.
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
{
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html-script/^2.0.0/components/context.jsonld",
|
|
4
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^2.0.0/components/context.jsonld",
|
|
5
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-rdf-parse-html/^2.0.0/components/context.jsonld"
|
|
6
|
+
],
|
|
7
|
+
"@id": "npmd:@comunica/actor-rdf-parse-html-script",
|
|
8
|
+
"components": [
|
|
9
|
+
{
|
|
10
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript",
|
|
11
|
+
"@type": "Class",
|
|
12
|
+
"requireElement": "ActorRdfParseHtmlScript",
|
|
13
|
+
"extends": [
|
|
14
|
+
"cbrph:components/ActorRdfParseHtml.jsonld#ActorRdfParseHtml"
|
|
15
|
+
],
|
|
16
|
+
"comment": "A HTML script RDF Parse actor that listens on the 'rdf-parse' bus. It is able to extract and parse any RDF serialization from script tags in HTML files and announce the presence of them by media type.",
|
|
17
|
+
"parameters": [
|
|
18
|
+
{
|
|
19
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_mediatorRdfParseMediatypes",
|
|
20
|
+
"range": "cc:components/Mediator.jsonld#Mediator",
|
|
21
|
+
"comment": "The RDF Parse mediator for collecting media types"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_mediatorRdfParseHandle",
|
|
25
|
+
"range": "cc:components/Mediator.jsonld#Mediator",
|
|
26
|
+
"comment": "The RDF Parse mediator for handling parsing"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_name",
|
|
30
|
+
"range": "xsd:string",
|
|
31
|
+
"default": {
|
|
32
|
+
"@id": "rdf:subject"
|
|
33
|
+
},
|
|
34
|
+
"comment": "The name for this actor."
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_bus",
|
|
38
|
+
"range": {
|
|
39
|
+
"@type": "ParameterRangeGenericComponent",
|
|
40
|
+
"component": "cc:components/Bus.jsonld#Bus",
|
|
41
|
+
"genericTypeInstances": [
|
|
42
|
+
{
|
|
43
|
+
"@type": "ParameterRangeGenericComponent",
|
|
44
|
+
"component": "cc:components/Actor.jsonld#Actor",
|
|
45
|
+
"genericTypeInstances": [
|
|
46
|
+
{
|
|
47
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
48
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
52
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
56
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
62
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
66
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
70
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"default": {
|
|
75
|
+
"@id": "cbrph:components/ActorRdfParseHtml.jsonld#ActorRdfParseHtml_default_bus",
|
|
76
|
+
"@type": "cc:components/Bus.jsonld#Bus"
|
|
77
|
+
},
|
|
78
|
+
"comment": "The bus this actor subscribes to."
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_beforeActors",
|
|
82
|
+
"range": {
|
|
83
|
+
"@type": "ParameterRangeUnion",
|
|
84
|
+
"parameterRangeElements": [
|
|
85
|
+
{
|
|
86
|
+
"@type": "ParameterRangeArray",
|
|
87
|
+
"parameterRangeValue": {
|
|
88
|
+
"@type": "ParameterRangeGenericComponent",
|
|
89
|
+
"component": "cc:components/Actor.jsonld#Actor",
|
|
90
|
+
"genericTypeInstances": [
|
|
91
|
+
{
|
|
92
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
93
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
97
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
101
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"@type": "ParameterRangeUndefined"
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
"comment": "Actor that must be registered in the bus before this actor."
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
"memberKeys": [
|
|
115
|
+
"mediatorRdfParseMediatypes",
|
|
116
|
+
"mediatorRdfParseHandle",
|
|
117
|
+
"constructor",
|
|
118
|
+
"test",
|
|
119
|
+
"run"
|
|
120
|
+
],
|
|
121
|
+
"constructorArguments": [
|
|
122
|
+
{
|
|
123
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args__constructorArgument",
|
|
124
|
+
"fields": [
|
|
125
|
+
{
|
|
126
|
+
"keyRaw": "mediatorRdfParseMediatypes",
|
|
127
|
+
"value": {
|
|
128
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_mediatorRdfParseMediatypes"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"keyRaw": "mediatorRdfParseHandle",
|
|
133
|
+
"value": {
|
|
134
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_mediatorRdfParseHandle"
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"keyRaw": "name",
|
|
139
|
+
"value": {
|
|
140
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_name"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"keyRaw": "bus",
|
|
145
|
+
"value": {
|
|
146
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_bus"
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"keyRaw": "beforeActors",
|
|
151
|
+
"value": {
|
|
152
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_beforeActors"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#IActorRdfParseHtmlScriptArgs",
|
|
161
|
+
"@type": "AbstractClass",
|
|
162
|
+
"requireElement": "IActorRdfParseHtmlScriptArgs",
|
|
163
|
+
"parameters": [],
|
|
164
|
+
"memberKeys": [
|
|
165
|
+
"mediatorRdfParseMediatypes",
|
|
166
|
+
"mediatorRdfParseHandle"
|
|
167
|
+
],
|
|
168
|
+
"constructorArguments": []
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"@context":
|
|
2
|
+
"@context": [
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html-script/^2.0.0/components/context.jsonld"
|
|
4
|
+
],
|
|
3
5
|
"@id": "npmd:@comunica/actor-rdf-parse-html-script",
|
|
4
6
|
"@type": "Module",
|
|
5
7
|
"requireName": "@comunica/actor-rdf-parse-html-script",
|
|
6
8
|
"import": [
|
|
7
|
-
"
|
|
9
|
+
"carphs:components/ActorRdfParseHtmlScript.jsonld"
|
|
8
10
|
]
|
|
9
|
-
}
|
|
11
|
+
}
|
|
@@ -3,10 +3,50 @@
|
|
|
3
3
|
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^4.0.0/components/context.jsonld",
|
|
4
4
|
{
|
|
5
5
|
"npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
|
|
6
|
-
"carphs": "npmd:@comunica/actor-rdf-parse-html-script/",
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
"carphs": "npmd:@comunica/actor-rdf-parse-html-script/^2.0.0/",
|
|
7
|
+
"ActorRdfParseHtmlScript": {
|
|
8
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript",
|
|
9
|
+
"@prefix": true,
|
|
10
|
+
"@context": {
|
|
11
|
+
"args_mediatorRdfParseMediatypes": {
|
|
12
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_mediatorRdfParseMediatypes"
|
|
13
|
+
},
|
|
14
|
+
"args_mediatorRdfParseHandle": {
|
|
15
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_mediatorRdfParseHandle"
|
|
16
|
+
},
|
|
17
|
+
"args_name": {
|
|
18
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_name"
|
|
19
|
+
},
|
|
20
|
+
"args_bus": {
|
|
21
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_bus"
|
|
22
|
+
},
|
|
23
|
+
"args_beforeActors": {
|
|
24
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_beforeActors",
|
|
25
|
+
"@container": "@list"
|
|
26
|
+
},
|
|
27
|
+
"mediatorRdfParseMediatypes": {
|
|
28
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_mediatorRdfParseMediatypes"
|
|
29
|
+
},
|
|
30
|
+
"mediatorRdfParseHandle": {
|
|
31
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_mediatorRdfParseHandle"
|
|
32
|
+
},
|
|
33
|
+
"name": {
|
|
34
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_name"
|
|
35
|
+
},
|
|
36
|
+
"bus": {
|
|
37
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_bus"
|
|
38
|
+
},
|
|
39
|
+
"beforeActors": {
|
|
40
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#ActorRdfParseHtmlScript_args_beforeActors",
|
|
41
|
+
"@container": "@list"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"IActorRdfParseHtmlScriptArgs": {
|
|
46
|
+
"@id": "carphs:components/ActorRdfParseHtmlScript.jsonld#IActorRdfParseHtmlScriptArgs",
|
|
47
|
+
"@prefix": true,
|
|
48
|
+
"@context": {}
|
|
49
|
+
}
|
|
10
50
|
}
|
|
11
51
|
]
|
|
12
|
-
}
|
|
52
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { IActionRdfParseHtml, IActorRdfParseHtmlOutput } from '@comunica/bus-rdf-parse-html';
|
|
1
|
+
import type { MediatorRdfParseHandle, MediatorRdfParseMediaTypes } from '@comunica/bus-rdf-parse';
|
|
2
|
+
import type { IActionRdfParseHtml, IActorRdfParseHtmlOutput, IActorRdfParseHtmlArgs } from '@comunica/bus-rdf-parse-html';
|
|
3
3
|
import { ActorRdfParseHtml } from '@comunica/bus-rdf-parse-html';
|
|
4
|
-
import type {
|
|
4
|
+
import type { IActorTest } from '@comunica/core';
|
|
5
5
|
/**
|
|
6
6
|
* A HTML script RDF Parse actor that listens on the 'rdf-parse' bus.
|
|
7
7
|
*
|
|
@@ -15,7 +15,13 @@ export declare class ActorRdfParseHtmlScript extends ActorRdfParseHtml {
|
|
|
15
15
|
test(action: IActionRdfParseHtml): Promise<IActorTest>;
|
|
16
16
|
run(action: IActionRdfParseHtml): Promise<IActorRdfParseHtmlOutput>;
|
|
17
17
|
}
|
|
18
|
-
export interface IActorRdfParseHtmlScriptArgs extends
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
export interface IActorRdfParseHtmlScriptArgs extends IActorRdfParseHtmlArgs {
|
|
19
|
+
/**
|
|
20
|
+
* The RDF Parse mediator for collecting media types
|
|
21
|
+
*/
|
|
22
|
+
mediatorRdfParseMediatypes: MediatorRdfParseMediaTypes;
|
|
23
|
+
/**
|
|
24
|
+
* The RDF Parse mediator for handling parsing
|
|
25
|
+
*/
|
|
26
|
+
mediatorRdfParseHandle: MediatorRdfParseHandle;
|
|
21
27
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MediatorRdfParseHandle } from '@comunica/bus-rdf-parse';
|
|
2
2
|
import type { IHtmlParseListener } from '@comunica/bus-rdf-parse-html';
|
|
3
|
-
import type {
|
|
4
|
-
import
|
|
5
|
-
import type * as RDF from 'rdf-js';
|
|
3
|
+
import type { IActionContext } from '@comunica/types';
|
|
4
|
+
import type * as RDF from '@rdfjs/types';
|
|
6
5
|
/**
|
|
7
|
-
* An HTML parse listeners that detects <script> data blocks with known RDF media
|
|
6
|
+
* An HTML parse listeners that detects <script> data blocks with known RDF media types,
|
|
8
7
|
* parses them, and outputs the resulting quads.
|
|
9
8
|
*/
|
|
10
9
|
export declare class HtmlScriptListener implements IHtmlParseListener {
|
|
@@ -24,7 +23,7 @@ export declare class HtmlScriptListener implements IHtmlParseListener {
|
|
|
24
23
|
private endBarrier;
|
|
25
24
|
private passedScripts;
|
|
26
25
|
private isFinalJsonLdProcessing;
|
|
27
|
-
constructor(mediatorRdfParseHandle:
|
|
26
|
+
constructor(mediatorRdfParseHandle: MediatorRdfParseHandle, cbQuad: (quad: RDF.Quad) => void, cbError: (error: Error) => void, cbEnd: () => void, supportedTypes: Record<string, number>, context: IActionContext, baseIRI: string, headers: Headers | undefined);
|
|
28
27
|
static newErrorCoded(message: string, code: string): Error;
|
|
29
28
|
onEnd(): void;
|
|
30
29
|
onTagClose(): void;
|
|
@@ -37,7 +36,7 @@ export declare class HtmlScriptListener implements IHtmlParseListener {
|
|
|
37
36
|
* As such, we have to buffer all JSON-LD until the end of HTML processing,
|
|
38
37
|
* and encapsulate all found contents in an array.
|
|
39
38
|
*
|
|
40
|
-
* @param mediaType A media type.
|
|
39
|
+
* @param mediaType A: IActionRdfParseHtml media type.
|
|
41
40
|
*/
|
|
42
41
|
requiresCustomJsonLdHandling(mediaType: string): boolean;
|
|
43
42
|
}
|
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HtmlScriptListener = void 0;
|
|
4
4
|
const stream_1 = require("stream");
|
|
5
|
-
const
|
|
5
|
+
const context_entries_1 = require("@comunica/context-entries");
|
|
6
6
|
const relative_to_absolute_iri_1 = require("relative-to-absolute-iri");
|
|
7
7
|
/**
|
|
8
|
-
* An HTML parse listeners that detects <script> data blocks with known RDF media
|
|
8
|
+
* An HTML parse listeners that detects <script> data blocks with known RDF media types,
|
|
9
9
|
* parses them, and outputs the resulting quads.
|
|
10
10
|
*/
|
|
11
11
|
class HtmlScriptListener {
|
|
12
12
|
constructor(mediatorRdfParseHandle, cbQuad, cbError, cbEnd, supportedTypes, context, baseIRI, headers) {
|
|
13
|
-
var _a;
|
|
14
13
|
this.textChunksJsonLd = [];
|
|
15
14
|
this.endBarrier = 1;
|
|
16
15
|
this.passedScripts = 0;
|
|
@@ -20,11 +19,11 @@ class HtmlScriptListener {
|
|
|
20
19
|
this.cbError = cbError;
|
|
21
20
|
this.cbEnd = cbEnd;
|
|
22
21
|
this.supportedTypes = supportedTypes;
|
|
23
|
-
this.context =
|
|
24
|
-
.set(
|
|
22
|
+
this.context = context
|
|
23
|
+
.set(context_entries_1.KeysRdfParseHtmlScript.processingHtmlScript, true);
|
|
25
24
|
this.baseIRI = baseIRI;
|
|
26
25
|
this.headers = headers;
|
|
27
|
-
this.onlyFirstScript =
|
|
26
|
+
this.onlyFirstScript = context.get(context_entries_1.KeysRdfParseHtmlScript.extractAllScripts) === false;
|
|
28
27
|
const fragmentPos = this.baseIRI.indexOf('#');
|
|
29
28
|
this.targetScriptId = fragmentPos > 0 ? this.baseIRI.slice(fragmentPos + 1, this.baseIRI.length) : null;
|
|
30
29
|
}
|
|
@@ -75,13 +74,18 @@ class HtmlScriptListener {
|
|
|
75
74
|
// Send all collected text to parser
|
|
76
75
|
const parseAction = {
|
|
77
76
|
context: this.context,
|
|
78
|
-
handle: {
|
|
77
|
+
handle: {
|
|
78
|
+
metadata: { baseIRI: this.baseIRI },
|
|
79
|
+
data: textStream,
|
|
80
|
+
headers: this.headers,
|
|
81
|
+
context: this.context,
|
|
82
|
+
},
|
|
79
83
|
handleMediaType: this.handleMediaType,
|
|
80
84
|
};
|
|
81
85
|
this.mediatorRdfParseHandle.mediate(parseAction)
|
|
82
86
|
.then(({ handle }) => {
|
|
83
87
|
// Initialize text parsing
|
|
84
|
-
handle.
|
|
88
|
+
handle.data
|
|
85
89
|
.on('error', error => this.cbError(HtmlScriptListener
|
|
86
90
|
.newErrorCoded(error.message, 'invalid script element')))
|
|
87
91
|
.on('data', this.cbQuad)
|
|
@@ -111,7 +115,7 @@ class HtmlScriptListener {
|
|
|
111
115
|
onTagOpen(name, attributes) {
|
|
112
116
|
// Take into account baseIRI overrides
|
|
113
117
|
if (name === 'base' && attributes.href) {
|
|
114
|
-
this.baseIRI = relative_to_absolute_iri_1.resolve(attributes.href, this.baseIRI);
|
|
118
|
+
this.baseIRI = (0, relative_to_absolute_iri_1.resolve)(attributes.href, this.baseIRI);
|
|
115
119
|
}
|
|
116
120
|
// Only handle script tags with a parseable content type
|
|
117
121
|
// If targetScriptId is defined, only extract from script with that id
|
|
@@ -154,7 +158,7 @@ class HtmlScriptListener {
|
|
|
154
158
|
* As such, we have to buffer all JSON-LD until the end of HTML processing,
|
|
155
159
|
* and encapsulate all found contents in an array.
|
|
156
160
|
*
|
|
157
|
-
* @param mediaType A media type.
|
|
161
|
+
* @param mediaType A: IActionRdfParseHtml media type.
|
|
158
162
|
*/
|
|
159
163
|
requiresCustomJsonLdHandling(mediaType) {
|
|
160
164
|
return !this.onlyFirstScript && !this.targetScriptId && mediaType === 'application/ld+json';
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ActorRdfParseHtmlScript';
|
|
@@ -10,5 +10,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./
|
|
13
|
+
__exportStar(require("./ActorRdfParseHtmlScript"), exports);
|
|
14
14
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/actor-rdf-parse-html-script",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.0.1-alpha.6.0",
|
|
4
4
|
"description": "A html-script rdf-parse actor",
|
|
5
5
|
"lsd:module": true,
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"typings": "index",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"typings": "lib/index",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/comunica/comunica.git",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
|
+
"sideEffects": false,
|
|
16
17
|
"keywords": [
|
|
17
18
|
"comunica",
|
|
18
19
|
"actor",
|
|
@@ -27,43 +28,20 @@
|
|
|
27
28
|
"files": [
|
|
28
29
|
"components",
|
|
29
30
|
"lib/**/*.d.ts",
|
|
30
|
-
"lib/**/*.js"
|
|
31
|
-
"index.d.ts",
|
|
32
|
-
"index.js"
|
|
31
|
+
"lib/**/*.js"
|
|
33
32
|
],
|
|
34
33
|
"dependencies": {
|
|
35
|
-
"@comunica/bus-rdf-parse
|
|
36
|
-
"@
|
|
34
|
+
"@comunica/bus-rdf-parse": "2.0.1-alpha.6.0",
|
|
35
|
+
"@comunica/bus-rdf-parse-html": "2.0.1-alpha.6.0",
|
|
36
|
+
"@comunica/context-entries": "2.0.1-alpha.6.0",
|
|
37
|
+
"@comunica/core": "2.0.1-alpha.6.0",
|
|
38
|
+
"@rdfjs/types": "*",
|
|
37
39
|
"relative-to-absolute-iri": "^1.0.5"
|
|
38
40
|
},
|
|
39
|
-
"peerDependencies": {
|
|
40
|
-
"@comunica/bus-rdf-parse": "^1.4.0",
|
|
41
|
-
"@comunica/core": "^1.4.0"
|
|
42
|
-
},
|
|
43
|
-
"devDependencies": {
|
|
44
|
-
"@comunica/bus-rdf-parse": "^1.21.1",
|
|
45
|
-
"@comunica/core": "^1.21.1"
|
|
46
|
-
},
|
|
47
|
-
"jest": {
|
|
48
|
-
"globals": {
|
|
49
|
-
"ts-jest": {
|
|
50
|
-
"tsConfig": "../../tsconfig.json"
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
"transform": {
|
|
54
|
-
"^.+\\.ts$": "ts-jest"
|
|
55
|
-
},
|
|
56
|
-
"testRegex": "(/test/.*|(\\.|/)(test|spec))\\.ts$",
|
|
57
|
-
"moduleFileExtensions": [
|
|
58
|
-
"ts",
|
|
59
|
-
"js"
|
|
60
|
-
],
|
|
61
|
-
"collectCoverage": true
|
|
62
|
-
},
|
|
63
41
|
"scripts": {
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"build": "
|
|
67
|
-
|
|
68
|
-
|
|
42
|
+
"build": "npm run build:ts && npm run build:components",
|
|
43
|
+
"build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
|
|
44
|
+
"build:components": "componentsjs-generator"
|
|
45
|
+
},
|
|
46
|
+
"gitHead": "bbf46a068e635256495a40e784a4691b22e88bd3"
|
|
69
47
|
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-rdf-parse-html-script/^1.0.0/components/context.jsonld",
|
|
4
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-rdf-parse-html/^1.0.0/components/context.jsonld"
|
|
5
|
-
],
|
|
6
|
-
"@id": "npmd:@comunica/actor-rdf-parse-html-script",
|
|
7
|
-
"components": [
|
|
8
|
-
{
|
|
9
|
-
"@id": "carphs:Actor/RdfParse/HtmlScript",
|
|
10
|
-
"@type": "Class",
|
|
11
|
-
"extends": "cbrph:Actor/RdfParseHtml",
|
|
12
|
-
"requireElement": "ActorRdfParseHtmlScript",
|
|
13
|
-
"comment": "An HTML actor that listens on the 'rdf-parse' bus.",
|
|
14
|
-
"parameters": [
|
|
15
|
-
{
|
|
16
|
-
"@id": "carphs:mediatorRdfParseMediatypes",
|
|
17
|
-
"comment": "The RDF Parse mediator for collecting media types",
|
|
18
|
-
"required": true,
|
|
19
|
-
"unique": true
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"@id": "carphs:mediatorRdfParseHandle",
|
|
23
|
-
"comment": "The RDF Parse mediator for handling parsing",
|
|
24
|
-
"required": true,
|
|
25
|
-
"unique": true
|
|
26
|
-
}
|
|
27
|
-
],
|
|
28
|
-
"constructorArguments": [
|
|
29
|
-
{
|
|
30
|
-
"extends": "cbrph:Actor/RdfParseHtml/constructorArgumentsObject",
|
|
31
|
-
"fields": [
|
|
32
|
-
{
|
|
33
|
-
"keyRaw": "mediatorRdfParseMediatypes",
|
|
34
|
-
"value": "carphs:mediatorRdfParseMediatypes"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"keyRaw": "mediatorRdfParseHandle",
|
|
38
|
-
"value": "carphs:mediatorRdfParseHandle"
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
}
|
|
44
|
-
]
|
|
45
|
-
}
|
package/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lib/ActorRdfParseHtmlScript';
|