本文整理汇总了TypeScript中@core/feature/modules/exports.Module类的典型用法代码示例。如果您正苦于以下问题:TypeScript Module类的具体用法?TypeScript Module怎么用?TypeScript Module使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Module类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: get
function get(fn, path, ctr) {
path = path_resolveUrl(path, Module.resolveLocation(ctr));
var dfr = Cache[path];
if (dfr !== void 0) {
return dfr;
}
dfr = new class_Dfr();
fn(path, dfr.pipeCallback());
return dfr;
}
开发者ID:atmajs,项目名称:MaskJS,代码行数:11,代码来源:file.ts
示例2: UTest
import { mask_config } from '@core/api/config'
import { renderer_render, renderer_renderAsync } from '@core/renderer/exports'
import '@core/feature/methods/exports'
import { Module } from '@core/feature/modules/exports'
UTest({
$teardown () {
mask_config('getScript', null);
Module.clearCache();
},
'should get instance from define args' () {
class Foo {
load () { }
};
mask_config('getScript', async path => {
return new Foo();
});
var template = `
import * as IFoo from 'Foo.js';
define FooCompo (foo: IFoo) {
function onRenderStart () {
this.emitOut('fooSignal', foo);
}
}
FooCompo;
`;
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:di.spec.ts
示例3: UTest
import { mask_config } from '@core/api/config';
import { Module } from '@core/feature/modules/exports';
import { renderer_renderAsync } from '@core/renderer/exports';
import { listeners_on, listeners_off } from '@core/util/listeners';
UTest({
$before () {
// use default module loader
mask_config('modules', 'default');
Module.cfg('moduleResolution', 'node');
},
$after () {
Module.cfg('moduleResolution', 'classic');
listeners_off('error');
},
async 'should load default file in node_modules' () {
let dom = await renderer_renderAsync(`
import Foo from '/test/tmpl/npm/foo.mask';
Foo;
`);
return UTest.domtest(dom, `
find ('h4') > text ('EmptyPackage');
`);
},
async 'should fail loading' () {
var errors = [];
listeners_on('error', assert.await((error) => errors.push(error)));
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:npm.spec.ts
示例4: UTest
import { mask_config } from '@core/api/config';
import { Module } from '@core/feature/modules/exports';
import { renderer_renderAsync } from '@core/renderer/exports';
UTest({
$teardown () {
mask_config('getFile', null);
mask_config('getScript', null);
},
async 'should load script' () {
var Foo = {
get name () { return 'FooTest' }
};
Module
.cfg('prefixes.services', '/src/services/{0}.js')
.cfg('ext.script', 'js')
;
mask_config('getScript', assert.await(async path => {
has_(path, '/src/services/FooService.js');
return Foo;
}));
let dom = await renderer_renderAsync(`
import * as Foo from '@services/FooService';
h3 > '~[Foo.name]'
`);
return UTest.domtest(dom, `
find('h3') > text FooTest;
`);
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:prefixes.spec.ts
示例5: mask_config
mask_config('getFile', assert.await(async path => {
has_(path, 'controls/Foo.mask');
var template = 'define Foo { h3 > "FooTest" }';
return template;
}));
let dom = await renderer_renderAsync(`
import Foo from controls is mask;
Foo;
`);
return UTest.domtest(dom, `
find('h3') > text FooTest;
`);
},
async 'should load script' () {
Module.cfg('ext.script', 'es6');
mask_config('getScript', assert.await(async path => {
has_(path, 'services/Foo.es6');
var service = {
getName () { return 'FooServiceTest' }
};
return service;
}));
let dom = await renderer_renderAsync(`
import Foo from services;
h5 > '~[Foo.getName()]';
`);
return UTest.domtest(dom, `
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:ns.spec.ts
示例6: mask_config
import { renderer_render } from '@core/renderer/exports';
import { Module } from '@core/feature/modules/exports'
import '@core/statements/exports'
// use default module loader
mask_config('modules', 'default');
UTest({
'getting dependencies': {
'should get javascript and style dependencies' () {
var template = `
import X from '/foo.js';
import from 'bar.css';
`;
var path = '/mask/test.mask';
return Module
.getDependencies(template, path)
.done(list => deepEq_(list, {
mask: [],
data: [],
script: [ '/foo.js' ],
style: [ '/mask/bar.css' ]
})
);
},
'should get mask dependencies' () {
var template = `
div {
import X from '/test/tmpl/modules/nest';
}
`;
var path = '/mask/test.mask';
开发者ID:atmajs,项目名称:MaskJS,代码行数:32,代码来源:build.spec.ts
示例7: UTest
import { renderer_renderAsync } from '@core/renderer/exports';
import { Module } from '@core/feature/modules/exports'
UTest({
async 'Should load module' () {
Module.registerModuleType('data', 'myJson', {
async load_ () {
return { foo: 'fox' };
}
})
var template = `
import * as Test from 'any' as myJson;
h4 > '~Test.foo'
`;
var dom = await renderer_renderAsync(template);
await UTest.domtest(dom, `
find ('h4') > text fox;
`)
}
})
开发者ID:atmajs,项目名称:MaskJS,代码行数:23,代码来源:custom.spec.ts
注:本文中的@core/feature/modules/exports.Module类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论