: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
comObj.addEventListener("message", this._onComObjOnMessage);
on(actionName, handler) {
const ah = this.actionHandler;
throw new Error(`There is already an actionName called "${actionName}"`);
ah[actionName] = handler;
send(actionName, data, transfers) {
this.comObj.postMessage({
sourceName: this.sourceName,
targetName: this.targetName,
sendWithPromise(actionName, data, transfers) {
const callbackId = this.callbackId++;
const capability = Promise.withResolvers();
this.callbackCapabilities[callbackId] = capability;
this.comObj.postMessage({
sourceName: this.sourceName,
targetName: this.targetName,
return capability.promise;
sendWithStream(actionName, data, queueingStrategy, transfers) {
const streamId = this.streamId++,
sourceName = this.sourceName,
targetName = this.targetName,
return new ReadableStream({
const startCapability = Promise.withResolvers();
this.streamControllers[streamId] = {
startCall: startCapability,
desiredSize: controller.desiredSize
return startCapability.promise;
const pullCapability = Promise.withResolvers();
this.streamControllers[streamId].pullCall = pullCapability;
desiredSize: controller.desiredSize
return pullCapability.promise;
assert(reason instanceof Error, "cancel must have a valid reason");
const cancelCapability = Promise.withResolvers();
this.streamControllers[streamId].cancelCall = cancelCapability;
this.streamControllers[streamId].isClosed = true;
stream: StreamKind.CANCEL,
reason: wrapReason(reason)
return cancelCapability.promise;
#createStreamSink(data) {
const streamId = data.streamId,
sourceName = this.sourceName,
targetName = data.sourceName,
action = this.actionHandler[data.action];
enqueue(chunk, size = 1, transfers) {
const lastDesiredSize = this.desiredSize;
this.desiredSize -= size;
if (lastDesiredSize > 0 && this.desiredSize <= 0) {
this.sinkCapability = Promise.withResolvers();
this.ready = this.sinkCapability.promise;
stream: StreamKind.ENQUEUE,
stream: StreamKind.CLOSE,
delete self.streamSinks[streamId];
assert(reason instanceof Error, "error must have a valid reason");
stream: StreamKind.ERROR,
reason: wrapReason(reason)
sinkCapability: Promise.withResolvers(),
desiredSize: data.desiredSize,
streamSink.sinkCapability.resolve();
streamSink.ready = streamSink.sinkCapability.promise;
this.streamSinks[streamId] = streamSink;
new Promise(function (resolve) {
resolve(action(data.data, streamSink));
stream: StreamKind.START_COMPLETE,
stream: StreamKind.START_COMPLETE,
reason: wrapReason(reason)
#processStreamMessage(data) {
const streamId = data.streamId,
sourceName = this.sourceName,
targetName = data.sourceName,
const streamController = this.streamControllers[streamId],
streamSink = this.streamSinks[streamId];
case StreamKind.START_COMPLETE:
streamController.startCall.resolve();
streamController.startCall.reject(wrapReason(data.reason));
case StreamKind.PULL_COMPLETE:
streamController.pullCall.resolve();
streamController.pullCall.reject(wrapReason(data.reason));
stream: StreamKind.PULL_COMPLETE,
if (streamSink.desiredSize <= 0 && data.desiredSize > 0) {
streamSink.sinkCapability.resolve();
streamSink.desiredSize = data.desiredSize;
new Promise(function (resolve) {
resolve(streamSink.onPull?.());
stream: StreamKind.PULL_COMPLETE,
stream: StreamKind.PULL_COMPLETE,
reason: wrapReason(reason)
assert(streamController, "enqueue should have stream controller");
if (streamController.isClosed) {
streamController.controller.enqueue(data.chunk);
assert(streamController, "close should have stream controller");
if (streamController.isClosed) {
streamController.isClosed = true;
streamController.controller.close();
this.#deleteStreamController(streamController, streamId);
assert(streamController, "error should have stream controller");
streamController.controller.error(wrapReason(data.reason));
this.#deleteStreamController(streamController, streamId);
case StreamKind.CANCEL_COMPLETE:
streamController.cancelCall.resolve();
streamController.cancelCall.reject(wrapReason(data.reason));
this.#deleteStreamController(streamController, streamId);
new Promise(function (resolve) {
resolve(streamSink.onCancel?.(wrapReason(data.reason)));
stream: StreamKind.CANCEL_COMPLETE,
stream: StreamKind.CANCEL_COMPLETE,
reason: wrapReason(reason)
streamSink.sinkCapability.reject(wrapReason(data.reason));
streamSink.isCancelled = true;
delete this.streamSinks[streamId];
throw new Error("Unexpected stream case");
async #deleteStreamController(streamController, streamId) {
await Promise.allSettled([streamController.startCall?.promise, streamController.pullCall?.promise, streamController.cancelCall?.promise]);
delete this.streamControllers[streamId];
this.comObj.removeEventListener("message", this._onComObjOnMessage);
;// CONCATENATED MODULE: ./src/display/metadata.js
this.#metadataMap = parsedData;
return this.#metadataMap.get(name) ?? null;
return objectFromMap(this.#metadataMap);
return this.#metadataMap.has(name);
;// CONCATENATED MODULE: ./src/display/optional_content_config.js
const INTERNAL = Symbol("INTERNAL");
class OptionalContentGroup {
constructor(renderingIntent, {
this.#isDisplay = !!(renderingIntent & RenderingIntentFlag.DISPLAY);
this.#isPrint = !!(renderingIntent & RenderingIntentFlag.PRINT);
return view?.viewState !== "OFF";
} else if (this.#isPrint) {
return print?.printState !== "OFF";
_setVisible(internal, visible, userSet = false) {
if (internal !== INTERNAL) {
unreachable("Internal method `_setVisible` called.");
class OptionalContentConfig {
constructor(data, renderingIntent = RenderingIntentFlag.DISPLAY) {
this.renderingIntent = renderingIntent;
this.creator = data.creator;
this.#order = data.order;
for (const group of data.groups) {
this.#groups.set(group.id, new OptionalContentGroup(renderingIntent, group));
if (data.baseState === "OFF") {
for (const group of this.#groups.values()) {
group._setVisible(INTERNAL, false);
for (const on of data.on) {
this.#groups.get(on)._setVisible(INTERNAL, true);
for (const off of data.off) {
this.#groups.get(off)._setVisible(INTERNAL, false);
this.#initialHash = this.getHash();
#evaluateVisibilityExpression(array) {
const length = array.length;
const operator = array[0];
for (let i = 1; i < length; i++) {
const element = array[i];
if (Array.isArray(element)) {
state = this.#evaluateVisibilityExpression(element);
} else if (this.#groups.has(element)) {
state = this.#groups.get(element).visible;
warn(`Optional content group not found: ${element}`);
return operator === "And";
if (this.#groups.size === 0) {
info("Optional content group not defined.");
if (group.type === "OCG") {
if (!this.#groups.has(group.id)) {
warn(`Optional content group not found: ${group.id}`);
return this.#groups.get(group.id).visible;
} else if (group.type === "OCMD") {
return this.#evaluateVisibilityExpression(group.expression);
if (!group.policy || group.policy === "AnyOn") {
for (const id of group.ids) {
if (!this.#groups.has(id)) {
warn(`Optional content group not found: ${id}`);
if (this.#groups.get(id).visible) {
} else if (group.policy === "AllOn") {
for (const id of group.ids) {
if (!this.#groups.has(id)) {
warn(`Optional content group not found: ${id}`);
if (!this.#groups.get(id).visible) {
} else if (group.policy === "AnyOff") {
for (const id of group.ids) {
if (!this.#groups.has(id)) {
warn(`Optional content group not found: ${id}`);
if (!this.#groups.get(id).visible) {
} else if (group.policy === "AllOff") {
for (const id of group.ids) {
if (!this.#groups.has(id)) {
warn(`Optional content group not found: ${id}`);
if (this.#groups.get(id).visible) {