From 213cf7be43ab7b7855597de03ee68967f0d195df Mon Sep 17 00:00:00 2001 From: Jake Archibald Date: Thu, 23 Sep 2021 16:33:24 +0100 Subject: [PATCH] Core: Document `disableWorkerMessageHandler` (#3088) Co-authored-by: Michael Schmidt --- components/prism-core.js | 21 +++++++++ docs/Prism.hooks.html | 8 ++-- docs/Prism.html | 99 ++++++++++++++++++++++++++++++++++++--- docs/Prism.languages.html | 8 ++-- docs/Token.html | 10 ++-- docs/global.html | 12 ++--- docs/index.html | 2 +- docs/prism-core.js.html | 23 ++++++++- prism.js | 21 +++++++++ 9 files changed, 177 insertions(+), 27 deletions(-) diff --git a/components/prism-core.js b/components/prism-core.js index cf77da513b..65145e1431 100644 --- a/components/prism-core.js +++ b/components/prism-core.js @@ -49,6 +49,27 @@ var Prism = (function (_self) { * @public */ manual: _self.Prism && _self.Prism.manual, + /** + * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses + * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your + * own worker, you don't want it to do this. + * + * By setting this value to `true`, Prism will not add its own listeners to the worker. + * + * You obviously have to change this value before Prism executes. To do this, you can add an + * empty Prism object into the global scope before loading the Prism script like this: + * + * ```js + * window.Prism = window.Prism || {}; + * Prism.disableWorkerMessageHandler = true; + * // Load Prism's script + * ``` + * + * @default false + * @type {boolean} + * @memberof Prism + * @public + */ disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler, /** diff --git a/docs/Prism.hooks.html b/docs/Prism.hooks.html index 49fa666188..5b37950723 100644 --- a/docs/Prism.hooks.html +++ b/docs/Prism.hooks.html @@ -36,7 +36,7 @@ -

Home

PrismJS

GitHub

Classes

Namespaces

Global

+

Home

PrismJS

GitHub

Classes

Namespaces

Global

@@ -73,7 +73,7 @@

Source:
@@ -152,7 +152,7 @@

(static) addSource:
@@ -314,7 +314,7 @@

(static) runSource:
diff --git a/docs/Prism.html b/docs/Prism.html index 325c6b5443..0ed222d5df 100644 --- a/docs/Prism.html +++ b/docs/Prism.html @@ -36,7 +36,7 @@ -

Home

PrismJS

GitHub

Classes

Namespaces

Global

+

Home

PrismJS

GitHub

Classes

Namespaces

Global

@@ -155,6 +155,93 @@

Members

+

(static) disableWorkerMessageHandler :boolean

+ + + + + +
+ + +
Source:
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Default Value:
+
    +
  • false
  • +
+ + + + + + + +
+ + + + + +
+

By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses +addEventListener to communicate with its parent instance. However, if you're using Prism manually in your +own worker, you don't want it to do this.

+

By setting this value to true, Prism will not add its own listeners to the worker.

+

You obviously have to change this value before Prism executes. To do this, you can add an +empty Prism object into the global scope before loading the Prism script like this:

+
window.Prism = window.Prism || {};
+Prism.disableWorkerMessageHandler = true;
+// Load Prism's script
+
+
+ + + +
Type:
+
    +
  • + +boolean + + +
  • +
+ + + + + + + +

(static) manual :boolean

@@ -263,7 +350,7 @@

(static) hi
Source:
@@ -480,7 +567,7 @@

(static) Source:
@@ -676,7 +763,7 @@

(static) <
Source:
@@ -911,7 +998,7 @@

(static) Source:
@@ -1157,7 +1244,7 @@

(static) tok
Source:
diff --git a/docs/Prism.languages.html b/docs/Prism.languages.html index 34d849cbc9..9c63cbdc98 100644 --- a/docs/Prism.languages.html +++ b/docs/Prism.languages.html @@ -36,7 +36,7 @@ -

Home

PrismJS

GitHub

Classes

Namespaces

Global

+

Home

PrismJS

GitHub

Classes

Namespaces

Global

@@ -73,7 +73,7 @@

Source:
@@ -154,7 +154,7 @@

(static) exten
Source:
@@ -354,7 +354,7 @@

(static) Source:
diff --git a/docs/Token.html b/docs/Token.html index 427442bd3a..e92d7e6ef1 100644 --- a/docs/Token.html +++ b/docs/Token.html @@ -36,7 +36,7 @@ -

Home

PrismJS

GitHub

Classes

Namespaces

Global

+

Home

PrismJS

GitHub

Classes

Namespaces

Global

@@ -80,7 +80,7 @@

new TokenSource:
@@ -364,7 +364,7 @@

aliasSource:
@@ -447,7 +447,7 @@

contentSource:
@@ -524,7 +524,7 @@

typeSource:
diff --git a/docs/global.html b/docs/global.html index 550ab58aa3..387c0688e0 100644 --- a/docs/global.html +++ b/docs/global.html @@ -36,7 +36,7 @@ -

Home

PrismJS

GitHub

Classes

Namespaces

Global

+

Home

PrismJS

GitHub

Classes

Namespaces

Global

@@ -143,7 +143,7 @@

Grammar

Source:
@@ -274,7 +274,7 @@

GrammarToken

Source:
@@ -559,7 +559,7 @@

High
Source:
@@ -713,7 +713,7 @@

HookCallb
Source:
@@ -859,7 +859,7 @@

TokenStream

Source:
diff --git a/docs/index.html b/docs/index.html index 23c5e5bf18..fe4f203c73 100644 --- a/docs/index.html +++ b/docs/index.html @@ -36,7 +36,7 @@ -

Home

PrismJS

GitHub

Classes

Namespaces

Global

+

Home

PrismJS

GitHub

Classes

Namespaces

Global

diff --git a/docs/prism-core.js.html b/docs/prism-core.js.html index 6d6654abc3..1eef1d09ad 100644 --- a/docs/prism-core.js.html +++ b/docs/prism-core.js.html @@ -36,7 +36,7 @@ -

Home

PrismJS

GitHub

Classes

Namespaces

Global

+

Home

PrismJS

GitHub

Classes

Namespaces

Global

@@ -102,6 +102,27 @@

prism-core.js

* @public */ manual: _self.Prism && _self.Prism.manual, + /** + * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses + * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your + * own worker, you don't want it to do this. + * + * By setting this value to `true`, Prism will not add its own listeners to the worker. + * + * You obviously have to change this value before Prism executes. To do this, you can add an + * empty Prism object into the global scope before loading the Prism script like this: + * + * ```js + * window.Prism = window.Prism || {}; + * Prism.disableWorkerMessageHandler = true; + * // Load Prism's script + * ``` + * + * @default false + * @type {boolean} + * @memberof Prism + * @public + */ disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler, /** diff --git a/prism.js b/prism.js index 6a72563cec..cde32af75a 100644 --- a/prism.js +++ b/prism.js @@ -54,6 +54,27 @@ var Prism = (function (_self) { * @public */ manual: _self.Prism && _self.Prism.manual, + /** + * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses + * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your + * own worker, you don't want it to do this. + * + * By setting this value to `true`, Prism will not add its own listeners to the worker. + * + * You obviously have to change this value before Prism executes. To do this, you can add an + * empty Prism object into the global scope before loading the Prism script like this: + * + * ```js + * window.Prism = window.Prism || {}; + * Prism.disableWorkerMessageHandler = true; + * // Load Prism's script + * ``` + * + * @default false + * @type {boolean} + * @memberof Prism + * @public + */ disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler, /**