blockly 9.2.0 → 9.2.1
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/blockly.min.js +13 -11
- package/blockly_compressed.js +13 -11
- package/blockly_compressed.js.map +1 -1
- package/core/utils/xml.d.ts +44 -2
- package/core.js +1 -5
- package/package.json +1 -1
package/core/utils/xml.d.ts
CHANGED
|
@@ -3,6 +3,45 @@
|
|
|
3
3
|
* Copyright 2018 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* Injected dependencies. By default these are just (and have the
|
|
8
|
+
* same types as) the corresponding DOM Window properties, but the
|
|
9
|
+
* Node.js wrapper for Blockly (see scripts/package/node/core.js)
|
|
10
|
+
* calls injectDependencies to supply implementations from the jsdom
|
|
11
|
+
* package instead.
|
|
12
|
+
*/
|
|
13
|
+
declare let DOMParser: {
|
|
14
|
+
new (): DOMParser;
|
|
15
|
+
prototype: DOMParser;
|
|
16
|
+
}, XMLSerializer: {
|
|
17
|
+
new (): XMLSerializer;
|
|
18
|
+
prototype: XMLSerializer;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Inject implementations of document, DOMParser and/or XMLSerializer
|
|
22
|
+
* to use instead of the default ones.
|
|
23
|
+
*
|
|
24
|
+
* Used by the Node.js wrapper for Blockly (see
|
|
25
|
+
* scripts/package/node/core.js) to supply implementations from the
|
|
26
|
+
* jsdom package instead.
|
|
27
|
+
*
|
|
28
|
+
* While they may be set individually, it is normally the case that
|
|
29
|
+
* all three will be sourced from the same JSDOM instance. They MUST
|
|
30
|
+
* at least come from the same copy of the jsdom package. (Typically
|
|
31
|
+
* this is hard to avoid satsifying this requirement, but it can be
|
|
32
|
+
* inadvertently violated by using webpack to build multiple bundles
|
|
33
|
+
* containing Blockly and jsdom, and then loading more than one into
|
|
34
|
+
* the same JavaScript runtime. See
|
|
35
|
+
* https://github.com/google/blockly-samples/pull/1452#issuecomment-1364442135
|
|
36
|
+
* for an example of how this happened.)
|
|
37
|
+
*
|
|
38
|
+
* @param dependencies Options object containing dependencies to set.
|
|
39
|
+
*/
|
|
40
|
+
export declare function injectDependencies(dependencies: {
|
|
41
|
+
document?: Document;
|
|
42
|
+
DOMParser?: typeof DOMParser;
|
|
43
|
+
XMLSerializer?: typeof XMLSerializer;
|
|
44
|
+
}): void;
|
|
6
45
|
/**
|
|
7
46
|
* Namespace for Blockly's XML.
|
|
8
47
|
*
|
|
@@ -13,16 +52,18 @@ export declare const NAME_SPACE = "https://developers.google.com/blockly/xml";
|
|
|
13
52
|
* Get the document object to use for XML serialization.
|
|
14
53
|
*
|
|
15
54
|
* @returns The document object.
|
|
55
|
+
* @deprecated No longer provided by Blockly.
|
|
16
56
|
* @alias Blockly.utils.xml.getDocument
|
|
17
57
|
*/
|
|
18
58
|
export declare function getDocument(): Document;
|
|
19
59
|
/**
|
|
20
60
|
* Get the document object to use for XML serialization.
|
|
21
61
|
*
|
|
22
|
-
* @param
|
|
62
|
+
* @param xmlDocument The document object to use.
|
|
63
|
+
* @deprecated No longer provided by Blockly.
|
|
23
64
|
* @alias Blockly.utils.xml.setDocument
|
|
24
65
|
*/
|
|
25
|
-
export declare function setDocument(
|
|
66
|
+
export declare function setDocument(xmlDocument: Document): void;
|
|
26
67
|
/**
|
|
27
68
|
* Create DOM element for XML.
|
|
28
69
|
*
|
|
@@ -57,4 +98,5 @@ export declare function textToDomDocument(text: string): Document;
|
|
|
57
98
|
* @alias Blockly.utils.xml.domToText
|
|
58
99
|
*/
|
|
59
100
|
export declare function domToText(dom: Node): string;
|
|
101
|
+
export {};
|
|
60
102
|
//# sourceMappingURL=xml.d.ts.map
|
package/core.js
CHANGED
|
@@ -20,11 +20,7 @@
|
|
|
20
20
|
if (typeof globalThis.document !== 'object') {
|
|
21
21
|
const {JSDOM} = require('jsdom');
|
|
22
22
|
const {window} = new JSDOM(`<!DOCTYPE html>`);
|
|
23
|
-
|
|
24
|
-
globalThis.XMLSerializer = window.XMLSerializer;
|
|
25
|
-
const xmlDocument = Blockly.utils.xml.textToDomDocument(
|
|
26
|
-
`<xml xmlns="${Blockly.utils.xml.NAME_SPACE}"></xml>`);
|
|
27
|
-
Blockly.utils.xml.setDocument(xmlDocument);
|
|
23
|
+
Blockly.utils.xml.injectDependencies(window);
|
|
28
24
|
}
|
|
29
25
|
|
|
30
26
|
module.exports = Blockly;
|