Move package to scripts/package (#4045)

This commit is contained in:
Sam El-Husseini
2020-07-14 16:31:53 -07:00
committed by GitHub
parent 55e6f8000e
commit 25821c888d
17 changed files with 19 additions and 20 deletions

77
scripts/package/README.md Normal file
View 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

View 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
View 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 = {};

View 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];
});
};

View 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
View 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
View File

@@ -0,0 +1,12 @@
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Blockly module.
*/
/* eslint-disable */
'use strict';

View 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
View 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;

View 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;
};
}

View 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
View 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
View 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;

View File

@@ -0,0 +1,5 @@
/* eslint-disable */
(function (<%= param %>){
<%= contents %>
module.exports = <%= exports %>;
})(<%= cjs %>);

View 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 %>;
}));