mirror of
https://github.com/google/blockly.git
synced 2026-01-10 10:27:08 +01:00
Cherry pick npm distribution change to develop (#2785)
This commit is contained in:
77
package/README.md
Normal file
77
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/js``, ``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
|
||||
32
package/browser/core.js
Normal file
32
package/browser/core.js
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @license
|
||||
* Visual Blocks Editor
|
||||
*
|
||||
* Copyright 2019 Google Inc.
|
||||
* https://developers.google.com/blockly/
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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 = Object.assign(Blockly.Msg || {}, locale);
|
||||
};
|
||||
35
package/browser/index.js
Normal file
35
package/browser/index.js
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @license
|
||||
* Visual Blocks Editor
|
||||
*
|
||||
* Copyright 2019 Google Inc.
|
||||
* https://developers.google.com/blockly/
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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 = Object.assign(Blockly.Blocks, BlocklyBlocks);
|
||||
|
||||
Blockly.JavaScript = BlocklyJS;
|
||||
26
package/index.js
Normal file
26
package/index.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @license
|
||||
* Visual Blocks Editor
|
||||
*
|
||||
* Copyright 2019 Google Inc.
|
||||
* https://developers.google.com/blockly/
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Blockly module.
|
||||
*/
|
||||
|
||||
/* eslint-disable */
|
||||
'use strict';
|
||||
32
package/node/core.js
Normal file
32
package/node/core.js
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @license
|
||||
* Visual Blocks Editor
|
||||
*
|
||||
* Copyright 2019 Google Inc.
|
||||
* https://developers.google.com/blockly/
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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 = Object.assign(Blockly.Msg || {}, locale);
|
||||
};
|
||||
42
package/node/index.js
Normal file
42
package/node/index.js
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @license
|
||||
* Visual Blocks Editor
|
||||
*
|
||||
* Copyright 2019 Google Inc.
|
||||
* https://developers.google.com/blockly/
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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 = Object.assign(Blockly.Blocks, BlocklyBlocks);
|
||||
|
||||
Blockly.JavaScript = BlocklyJS;
|
||||
|
||||
Blockly.Python = BlocklyPython;
|
||||
|
||||
Blockly.Lua = BlocklyLua;
|
||||
|
||||
Blockly.PHP = BlocklyPHP;
|
||||
|
||||
Blockly.Dart = BlocklyDart;
|
||||
5
package/templates/node.template
Normal file
5
package/templates/node.template
Normal file
@@ -0,0 +1,5 @@
|
||||
/* eslint-disable */
|
||||
(function (<%= param %>){
|
||||
<%= contents %>
|
||||
module.exports = <%= exports %>;
|
||||
})(<%= cjs %>);
|
||||
13
package/templates/umd.template
Normal file
13
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