Last change
on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | /*
|
---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | "use strict";
|
---|
| 6 |
|
---|
| 7 | const RuntimeGlobals = require("../RuntimeGlobals");
|
---|
| 8 | const RuntimeModule = require("../RuntimeModule");
|
---|
| 9 | const Template = require("../Template");
|
---|
| 10 |
|
---|
| 11 | class AMDDefineRuntimeModule extends RuntimeModule {
|
---|
| 12 | constructor() {
|
---|
| 13 | super("amd define");
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | /**
|
---|
| 17 | * @returns {string} runtime code
|
---|
| 18 | */
|
---|
| 19 | generate() {
|
---|
| 20 | return Template.asString([
|
---|
| 21 | `${RuntimeGlobals.amdDefine} = function () {`,
|
---|
| 22 | Template.indent("throw new Error('define cannot be used indirect');"),
|
---|
| 23 | "};"
|
---|
| 24 | ]);
|
---|
| 25 | }
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | class AMDOptionsRuntimeModule extends RuntimeModule {
|
---|
| 29 | /**
|
---|
| 30 | * @param {Record<string, boolean | number | string>} options the AMD options
|
---|
| 31 | */
|
---|
| 32 | constructor(options) {
|
---|
| 33 | super("amd options");
|
---|
| 34 | this.options = options;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | /**
|
---|
| 38 | * @returns {string} runtime code
|
---|
| 39 | */
|
---|
| 40 | generate() {
|
---|
| 41 | return Template.asString([
|
---|
| 42 | `${RuntimeGlobals.amdOptions} = ${JSON.stringify(this.options)};`
|
---|
| 43 | ]);
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | exports.AMDDefineRuntimeModule = AMDDefineRuntimeModule;
|
---|
| 48 | exports.AMDOptionsRuntimeModule = AMDOptionsRuntimeModule;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.