mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Move package to scripts/package (#4045)
This commit is contained in:
77
scripts/package/README.md
Normal file
77
scripts/package/README.md
Normal file
@@ -0,0 +1,77 @@
|
||||
# Blockly
|
||||
|
||||
Google's Blockly is a web-based, visual programming editor. Users can drag
|
||||
blocks together to build programs. All code is free and open source.
|
||||
|
||||
The source for this module is in the [Blockly repo](http://github.com/google/blockly).
|
||||
|
||||
## Installation
|
||||
|
||||
You can install this package either via ``npm`` or ``unpkg``.
|
||||
|
||||
### npm
|
||||
```bash
|
||||
npm install blockly
|
||||
```
|
||||
|
||||
### unpkg
|
||||
```html
|
||||
<script src="https://unpkg.com/blockly/blockly.min.js"></script>
|
||||
```
|
||||
|
||||
## Example Usage
|
||||
|
||||
```js
|
||||
import Blockly from 'blockly';
|
||||
Blockly.inject('blocklyDiv', {
|
||||
...
|
||||
})
|
||||
```
|
||||
|
||||
## Samples
|
||||
|
||||
For samples on how to integrate Blockly into your project, view the list of samples at [blockly-samples](https://github.com/google/blockly-samples).
|
||||
|
||||
|
||||
### Importing Blockly
|
||||
|
||||
When you import Blockly with ``import * as Blockly from 'blockly';`` you'll get the default modules:
|
||||
Blockly core, Blockly built-in blocks, the JavaScript generator and the English lang files.
|
||||
|
||||
If you need more flexibility, you'll want to define your imports more carefully:
|
||||
|
||||
#### Blockly Core
|
||||
|
||||
```js
|
||||
import * as Blockly from 'blockly/core';
|
||||
```
|
||||
|
||||
#### Blockly built in blocks
|
||||
|
||||
```js
|
||||
import 'blockly/blocks';
|
||||
```
|
||||
|
||||
#### Blockly Generators
|
||||
If your application needs to generate code from the Blockly blocks, you'll want to include a generator.
|
||||
|
||||
```js
|
||||
import 'blockly/python';
|
||||
```
|
||||
to include the Python generator, you can also import ``blockly/javascript``, ``blockly/php``, ``blockly/dart`` and ``blockly/lua``.
|
||||
|
||||
#### Blockly Languages
|
||||
|
||||
```js
|
||||
import * as Fr from 'blockly/msg/fr';
|
||||
Blockly.setLocale(Fr);
|
||||
```
|
||||
|
||||
To import the French lang files. Once you've imported the specific lang module, you'll also want to set the locale in Blockly.
|
||||
|
||||
For a full list of supported Blockly locales, see: [https://github.com/google/blockly/tree/master/msg/js](https://github.com/google/blockly/tree/master/msg/js)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
Apache 2.0
|
||||
12
scripts/package/blockly.js
Normal file
12
scripts/package/blockly.js
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Blockly module.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
'use strict';
|
||||
14
scripts/package/blocks.js
Normal file
14
scripts/package/blocks.js
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Blockly Blocks module.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
'use strict';
|
||||
|
||||
Blockly.Blocks = {};
|
||||
21
scripts/package/browser/core.js
Normal file
21
scripts/package/browser/core.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Blockly core module for the browser. It includes blockly.js
|
||||
* and adds a helper method for setting the locale.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
'use strict';
|
||||
|
||||
// Add a helper method to set the Blockly locale.
|
||||
Blockly.setLocale = function (locale) {
|
||||
Blockly.Msg = Blockly.Msg || {};
|
||||
Object.keys(locale).forEach(function (k) {
|
||||
Blockly.Msg[k] = locale[k];
|
||||
});
|
||||
};
|
||||
24
scripts/package/browser/index.js
Normal file
24
scripts/package/browser/index.js
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Blockly module for the browser. This includes Blockly core
|
||||
* and built in blocks, the JavaScript code generator and the English block
|
||||
* localization files.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
'use strict';
|
||||
|
||||
// Include the EN Locale by default.
|
||||
Blockly.setLocale(En);
|
||||
|
||||
Blockly.Blocks = Blockly.Blocks || {};
|
||||
Object.keys(BlocklyBlocks).forEach(function (k) {
|
||||
Blockly.Blocks[k] = BlocklyBlocks[k];
|
||||
});
|
||||
|
||||
Blockly.JavaScript = BlocklyJS;
|
||||
14
scripts/package/dart.js
Normal file
14
scripts/package/dart.js
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Dart Generator module.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
'use strict';
|
||||
|
||||
Blockly.Dart = BlocklyDart;
|
||||
12
scripts/package/index.js
Normal file
12
scripts/package/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Blockly module.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
'use strict';
|
||||
14
scripts/package/javascript.js
Normal file
14
scripts/package/javascript.js
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview JavaScript Generator module.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
'use strict';
|
||||
|
||||
Blockly.JavaScript = BlocklyJavaScript;
|
||||
14
scripts/package/lua.js
Normal file
14
scripts/package/lua.js
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Lua Generator module.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
'use strict';
|
||||
|
||||
Blockly.Lua = BlocklyLua;
|
||||
33
scripts/package/node/core.js
Normal file
33
scripts/package/node/core.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Blockly core module for Node. It includes blockly-node.js
|
||||
* and adds a helper method for setting the locale.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
'use strict';
|
||||
|
||||
// Add a helper method to set the Blockly locale.
|
||||
Blockly.setLocale = function (locale) {
|
||||
Blockly.Msg = Blockly.Msg || {};
|
||||
Object.keys(locale).forEach(function (k) {
|
||||
Blockly.Msg[k] = locale[k];
|
||||
});
|
||||
};
|
||||
|
||||
// Override textToDomDocument and provide Node.js alternatives to DOMParser and
|
||||
// XMLSerializer.
|
||||
if (typeof Blockly.utils.global.document !== 'object') {
|
||||
Blockly.utils.global.DOMParser = require("jsdom/lib/jsdom/living").DOMParser;
|
||||
Blockly.utils.global.XMLSerializer = require("jsdom/lib/jsdom/living").XMLSerializer;
|
||||
var doc = Blockly.utils.xml.textToDomDocument(
|
||||
'<xml xmlns="https://developers.google.com/blockly/xml"></xml>');
|
||||
Blockly.utils.xml.document = function() {
|
||||
return doc;
|
||||
};
|
||||
}
|
||||
31
scripts/package/node/index.js
Normal file
31
scripts/package/node/index.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Blockly module for Node. It includes Blockly core,
|
||||
* built-in blocks, all the generators and the English locale.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
'use strict';
|
||||
|
||||
// Include the EN Locale by default.
|
||||
Blockly.setLocale(En);
|
||||
|
||||
Blockly.Blocks = Blockly.Blocks || {};
|
||||
Object.keys(BlocklyBlocks).forEach(function (k) {
|
||||
Blockly.Blocks[k] = BlocklyBlocks[k];
|
||||
});
|
||||
|
||||
Blockly.JavaScript = BlocklyJS;
|
||||
|
||||
Blockly.Python = BlocklyPython;
|
||||
|
||||
Blockly.Lua = BlocklyLua;
|
||||
|
||||
Blockly.PHP = BlocklyPHP;
|
||||
|
||||
Blockly.Dart = BlocklyDart;
|
||||
14
scripts/package/php.js
Normal file
14
scripts/package/php.js
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview PHP Generator module.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
'use strict';
|
||||
|
||||
Blockly.PHP = BlocklyPHP;
|
||||
14
scripts/package/python.js
Normal file
14
scripts/package/python.js
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2020 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Python Generator module.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
'use strict';
|
||||
|
||||
Blockly.Python = BlocklyPython;
|
||||
5
scripts/package/templates/node.template
Normal file
5
scripts/package/templates/node.template
Normal file
@@ -0,0 +1,5 @@
|
||||
/* eslint-disable */
|
||||
(function (<%= param %>){
|
||||
<%= contents %>
|
||||
module.exports = <%= exports %>;
|
||||
})(<%= cjs %>);
|
||||
13
scripts/package/templates/umd.template
Normal file
13
scripts/package/templates/umd.template
Normal file
@@ -0,0 +1,13 @@
|
||||
/* eslint-disable */
|
||||
;(function(root, factory) {
|
||||
if (typeof define === 'function' && define.amd) { // AMD
|
||||
define(<%= amd %>, factory);
|
||||
} else if (typeof exports === 'object') { // Node.js
|
||||
module.exports = factory(<%= cjs %>);
|
||||
} else { // Browser
|
||||
root.<%= namespace %> = factory(<%= global %>);
|
||||
}
|
||||
}(this, function(<%= param %>) {
|
||||
<%= contents %>
|
||||
return <%= exports %>;
|
||||
}));
|
||||
Reference in New Issue
Block a user