libaribhtml5 0.1.9 → 0.1.10
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/dist/sdk/arib-vfs-sw.js +56 -8
- package/dist/sdk/libaribhtml5.js +6 -6
- package/dist/sdk/libaribhtml5.mjs +296 -286
- package/dist/types/runtime/external-media-hole.d.ts +1 -1
- package/docs/browser-iframe-compositing.md +2 -0
- package/package.json +1 -1
- package/docs/receiver-compatibility-roadmap.md +0 -300
package/dist/sdk/arib-vfs-sw.js
CHANGED
|
@@ -11,6 +11,61 @@
|
|
|
11
11
|
const basePath = normalizeBasePath(scopePath);
|
|
12
12
|
return `<script>
|
|
13
13
|
(function installAribHtml5Runtime(attempt) {
|
|
14
|
+
var broadcastType = 'video/x-arib2-broadcast'
|
|
15
|
+
var scheduledObjects = new WeakSet()
|
|
16
|
+
function replaceBroadcastObject(object) {
|
|
17
|
+
if (!object || object.nodeType !== 1 ||
|
|
18
|
+
String(object.getAttribute('type') || '').trim().toLowerCase() !== broadcastType) return
|
|
19
|
+
// Keep broadcaster object/video sizing rules; a div loses them and collapses to zero height.
|
|
20
|
+
// This source-less element is only the slot; the host's existing video keeps playing.
|
|
21
|
+
var replacement = document.createElement('video')
|
|
22
|
+
for (var index = 0; index < object.attributes.length; index += 1) {
|
|
23
|
+
var attribute = object.attributes[index]
|
|
24
|
+
if (attribute.name.toLowerCase() === 'type') continue
|
|
25
|
+
replacement.setAttribute(attribute.name, attribute.value)
|
|
26
|
+
}
|
|
27
|
+
replacement.setAttribute('data-arib-object', broadcastType)
|
|
28
|
+
while (object.firstChild) replacement.appendChild(object.firstChild)
|
|
29
|
+
object.replaceWith(replacement)
|
|
30
|
+
}
|
|
31
|
+
function scanBroadcastObjects(root) {
|
|
32
|
+
if (!root) return
|
|
33
|
+
if (root.nodeType === 1 && root.matches && root.matches('object')) {
|
|
34
|
+
scheduleBroadcastObject(root)
|
|
35
|
+
}
|
|
36
|
+
if (!root.querySelectorAll) return
|
|
37
|
+
var objects = root.querySelectorAll('object')
|
|
38
|
+
for (var index = 0; index < objects.length; index += 1) {
|
|
39
|
+
scheduleBroadcastObject(objects[index])
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function scheduleBroadcastObject(object) {
|
|
43
|
+
if (!object || scheduledObjects.has(object)) return
|
|
44
|
+
scheduledObjects.add(object)
|
|
45
|
+
setTimeout(function () {
|
|
46
|
+
scheduledObjects.delete(object)
|
|
47
|
+
replaceBroadcastObject(object)
|
|
48
|
+
}, 0)
|
|
49
|
+
}
|
|
50
|
+
function observeBroadcastObjects() {
|
|
51
|
+
scanBroadcastObjects(document)
|
|
52
|
+
if (!document.documentElement) {
|
|
53
|
+
queueMicrotask(observeBroadcastObjects)
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
var observer = new MutationObserver(function (records) {
|
|
57
|
+
for (var recordIndex = 0; recordIndex < records.length; recordIndex += 1) {
|
|
58
|
+
var record = records[recordIndex]
|
|
59
|
+
for (var nodeIndex = 0; nodeIndex < record.addedNodes.length; nodeIndex += 1) {
|
|
60
|
+
scanBroadcastObjects(record.addedNodes[nodeIndex])
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
observer.observe(document.documentElement, { childList: true, subtree: true })
|
|
65
|
+
}
|
|
66
|
+
if (typeof document !== 'undefined' && typeof MutationObserver === 'function') {
|
|
67
|
+
observeBroadcastObjects()
|
|
68
|
+
}
|
|
14
69
|
var install
|
|
15
70
|
try {
|
|
16
71
|
install = parent && parent.__ARIB_HTML5_INSTALL__
|
|
@@ -56,14 +111,7 @@
|
|
|
56
111
|
return `/${base.replace(/^\/+|\/+$/g, "")}/`;
|
|
57
112
|
}
|
|
58
113
|
function rewriteBroadcastObjectMarkup(source) {
|
|
59
|
-
return source
|
|
60
|
-
const broadcast = /\btype\s*=\s*(?:["']video\/x-arib2-broadcast["']|video\/x-arib2-broadcast)(?:\s|\/?>)/i.test(tag);
|
|
61
|
-
if (!broadcast) return tag;
|
|
62
|
-
return tag.replace(
|
|
63
|
-
/\s+type\s*=\s*(?:["']video\/x-arib2-broadcast["']|video\/x-arib2-broadcast)/i,
|
|
64
|
-
' data-arib-type="video/x-arib2-broadcast"'
|
|
65
|
-
).replace(/\s+data\s*=\s*(["'])(.*?)\1/i, " data-arib-data=$1$2$1");
|
|
66
|
-
});
|
|
114
|
+
return source;
|
|
67
115
|
}
|
|
68
116
|
function receiverPath(path, base, scope) {
|
|
69
117
|
if (path.startsWith(scope)) return path;
|