# Source Map JS
[](https://www.npmjs.com/package/source-map-js)
Difference between original [source-map](https://github.com/mozilla/source-map):
> TL,DR: it's fork of original source-map@0.6, but with perfomance optimizations.
This journey starts from [source-map@0.7.0](https://github.com/mozilla/source-map/blob/master/CHANGELOG.md#070). Some part of it was rewritten to Rust and WASM and API became async.
It's still a major block for many libraries like PostCSS or Sass for example because they need to migrate the whole API to the async way. This is the reason why 0.6.1 has 2x more downloads than 0.7.3 while it's faster several times.

More important that WASM version has some optimizations in JS code too. This is why [community asked to create branch for 0.6 version](https://github.com/mozilla/source-map/issues/324) and port these optimizations but, sadly, the answer was «no». A bit later I discovered [the issue](https://github.com/mozilla/source-map/issues/370) created by [Ben Rothman (@benthemonkey)](https://github.com/benthemonkey) with no response at all.
[Roman Dvornov (@lahmatiy)](https://github.com/lahmatiy) wrote a [serveral posts](https://t.me/gorshochekvarit/76) (russian, only, sorry) about source-map library in his own Telegram channel. He mentioned the article [«Maybe you don't need Rust and WASM to speed up your JS»](https://mrale.ph/blog/2018/02/03/maybe-you-dont-need-rust-to-speed-up-your-js.html) written by [Vyacheslav Egorov (@mraleph)](https://github.com/mraleph). This article contains optimizations and hacks that lead to almost the same performance compare to WASM implementation.
I decided to fork the original source-map and port these optimizations from the article and several others PR from the original source-map.
---------
This is a library to generate and consume the source map format
[described here][format].
[format]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
## Use with Node
$ npm install source-map-js
<!-- ## Use on the Web
<script src="https://raw.githubusercontent.com/mozilla/source-map/master/dist/source-map.min.js" defer></script> -->
--------------------------------------------------------------------------------
<!-- `npm run toc` to regenerate the Table of Contents -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
## Table of Contents
- [Examples](#examples)
- [Consuming a source map](#consuming-a-source-map)
- [Generating a source map](#generating-a-source-map)
- [With SourceNode (high level API)](#with-sourcenode-high-level-api)
- [With SourceMapGenerator (low level API)](#with-sourcemapgenerator-low-level-api)
- [API](#api)
- [SourceMapConsumer](#sourcemapconsumer)
- [new SourceMapConsumer(rawSourceMap)](#new-sourcemapconsumerrawsourcemap)
- [SourceMapConsumer.prototype.computeColumnSpans()](#sourcemapconsumerprototypecomputecolumnspans)
- [SourceMapConsumer.prototype.originalPositionFor(generatedPosition)](#sourcemapconsumerprototypeoriginalpositionforgeneratedposition)
- [SourceMapConsumer.prototype.generatedPositionFor(originalPosition)](#sourcemapconsumerprototypegeneratedpositionfororiginalposition)
- [SourceMapConsumer.prototype.allGeneratedPositionsFor(originalPosition)](#sourcemapconsumerprototypeallgeneratedpositionsfororiginalposition)
- [SourceMapConsumer.prototype.hasContentsOfAllSources()](#sourcemapconsumerprototypehascontentsofallsources)
- [SourceMapConsumer.prototype.sourceContentFor(source[, returnNullOnMissing])](#sourcemapconsumerprototypesourcecontentforsource-returnnullonmissing)
- [SourceMapConsumer.prototype.eachMapping(callback, context, order)](#sourcemapconsumerprototypeeachmappingcallback-context-order)
- [SourceMapGenerator](#sourcemapgenerator)
- [new SourceMapGenerator([startOfSourceMap])](#new-sourcemapgeneratorstartofsourcemap)
- [SourceMapGenerator.fromSourceMap(sourceMapConsumer)](#sourcemapgeneratorfromsourcemapsourcemapconsumer)
- [SourceMapGenerator.prototype.addMapping(mapping)](#sourcemapgeneratorprototypeaddmappingmapping)
- [SourceMapGenerator.prototype.setSourceContent(sourceFile, sourceContent)](#sourcemapgeneratorprototypesetsourcecontentsourcefile-sourcecontent)
- [SourceMapGenerator.prototype.applySourceMap(sourceMapConsumer[, sourceFile[, sourceMapPath]])](#sourcemapgeneratorprototypeapplysourcemapsourcemapconsumer-sourcefile-sourcemappath)
- [SourceMapGenerator.prototype.toString()](#sourcemapgeneratorprototypetostring)
- [SourceNode](#sourcenode)
- [new SourceNode([line, column, source[, chunk[, name]]])](#new-sourcenodeline-column-source-chunk-name)
- [SourceNode.fromStringWithSourceMap(code, sourceMapConsumer[, relativePath])](#sourcenodefromstringwithsourcemapcode-sourcemapconsumer-relativepath)
- [SourceNode.prototype.add(chunk)](#sourcenodeprototypeaddchunk)
- [SourceNode.prototype.prepend(chunk)](#sourcenodeprototypeprependchunk)
- [SourceNode.prototype.setSourceContent(sourceFile, sourceContent)](#sourcenodeprototypesetsourcecontentsourcefile-sourcecontent)
- [SourceNode.prototype.walk(fn)](#sourcenodeprototypewalkfn)
- [SourceNode.prototype.walkSourceContents(fn)](#sourcenodeprototypewalksourcecontentsfn)
- [SourceNode.prototype.join(sep)](#sourcenodeprototypejoinsep)
- [SourceNode.prototype.replaceRight(pattern, replacement)](#sourcenodeprototypereplacerightpattern-replacement)
- [SourceNode.prototype.toString()](#sourcenodeprototypetostring)
- [SourceNode.prototype.toStringWithSourceMap([startOfSourceMap])](#sourcenodeprototypetostringwithsourcemapstartofsourcemap)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## Examples
### Consuming a source map
```js
var rawSourceMap = {
version: 3,
file: 'min.js',
names: ['bar', 'baz', 'n'],
sources: ['one.js', 'two.js'],
sourceRoot: 'http://example.com/www/js/',
mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA'
};
var smc = new SourceMapConsumer(rawSourceMap);
console.log(smc.sources);
// [ 'http://example.com/www/js/one.js',
// 'http://example.com/www/js/two.js' ]
console.log(smc.originalPositionFor({
line: 2,
column: 28
}));
// { source: 'http://example.com/www/js/two.js',
// line: 2,
// column: 10,
// name: 'n' }
console.log(smc.generatedPositionFor({
source: 'http://example.com/www/js/two.js',
line: 2,
column: 10
}));
// { line: 2, column: 28 }
smc.eachMapping(function (m) {
// ...
});
```
### Generating a source map
In depth guide:
[**Compiling to JavaScript, and Debugging with Source Maps**](https://hacks.mozilla.org/2013/05/compiling-to-javascript-and-debugging-with-source-maps/)
#### With SourceNode (high level API)
```js
function compile(ast) {
switch (ast.type) {
case 'BinaryExpression':
return new SourceNode(
ast.location.line,
ast.location.column,
ast.location.source,
[compile(ast.left), " + ", compile(ast.right)]
);
case 'Literal':
return new SourceNode(
ast.location.line,
ast.location.column,
ast.location.source,
String(ast.value)
);
// ...
default:
throw new Error("Bad AST");
}
}
var ast = parse("40 + 2", "add.js");
console.log(compile(ast).toStringWithSourceMap({
file: 'add.js'
}));
// { code: '40 + 2',
// map: [object SourceMapGenerator] }
```
#### With SourceMapGenerator (low level API)
```js
var map = new SourceMapGenerator({
file: "source-mapped.js"
});
map.addMapping({
generated: {
line: 10,
column: 35
},
source: "foo.js",
original: {
line: 33,
column: 2
},
name: "christopher"
});
console.log(map.toString());
// '{"version":3,"file":"source-mapped.js","sources"
Ue5+Vue3像素流,保姆级教程

在本“Ue5+Vue3像素流,保姆级教程”中,我们将深入探讨如何将 Unreal Engine 5(Ue5)与 Vue.js 3(Vue3)相结合,利用像素流技术来创建交互式、高性能的Web应用。这个教程旨在为初学者提供一个详尽的指南,帮助他们掌握这两款强大的工具的集成使用。
Unreal Engine 5 是 Epic Games 推出的最新版本的游戏引擎,以其高度真实感的渲染和强大的物理模拟能力闻名。它引入了 Nanite 技术,这是一种虚拟微多边形几何系统,可以即时加载高分辨率的3D资产,以及Lumen全局光照系统,提供更加逼真的光影效果。
Vue.js 3 是一款流行的前端JavaScript框架,用于构建用户界面。它的新版本带来了性能优化,更简洁的API,以及Composition API,使得代码组织更加灵活,提高了可维护性。
像素流是一种技术,允许将Unreal Engine生成的高质量图像实时流式传输到Web浏览器,使得用户可以在不安装游戏引擎的情况下体验3D内容。这大大拓宽了Unreal Engine的应用范围,使其不仅限于游戏开发,还可以应用于虚拟现实、建筑可视化、产品演示等领域。
在这个保姆级教程中,你将学习以下关键知识点:
1. **Vue3基础**:理解Vue3的组件系统、响应式数据绑定、生命周期钩子、模板语法等基础知识。
2. **Unreal Engine 5入门**:学习创建项目、设置场景、导入模型、应用材质和光照。
3. **Nanite和Lumen实战**:了解如何利用Nanite技术处理3D资产,以及如何设置和调整Lumen全局光照。
4. **像素流设置**:配置Unreal Engine进行像素流,包括设置服务器和客户端,优化流媒体性能。
5. **Vue3与Ue5集成**:学习如何使用WebGL插件或Three.js库将Unreal Engine的渲染输出与Vue3应用相连接。
6. **交互功能实现**:通过WebSocket或其他通信协议,实现Vue3中的事件监听和对Unreal Engine场景的实时控制。
7. **性能优化**:探讨如何在Web环境下优化Unreal Engine的性能,减少延迟,提高用户体验。
8. **部署与发布**:学习如何将完成的项目部署到Web服务器,让用户能够在线体验。
通过这个教程,你不仅可以掌握Unreal Engine 5和Vue.js 3的结合使用,还能了解到如何将高端的3D渲染技术应用于Web环境,创造出令人惊叹的互动体验。无论是游戏开发者、设计师还是Web开发者,都将从中受益匪浅。文件“ue5_web1”可能是这个教程的第一部分,包含了初始的项目设置和基础概念介绍,是开始学习旅程的重要起点。

不曾听闻
- 粉丝: 62
最新资源
- 基于stm32的自行车转向刹车灯-生本科学位论文(1).doc
- 电气自动化在电气工程中的实现与应用分析(1).docx
- 互联网+下影响南昌本土零售企业发展因素研究(1).docx
- “计算机是人”双向隐喻的产生及其局限(1).docx
- 互联网+背景下农村留守儿童家庭教育探究(1).docx
- 书店管理系统数据库课程设计概要(1).doc
- 基于电子商务时代企业财务管理对策研究.docx
- 大学电子商务自荐信5篇(1).docx
- 基于android手机通讯录的设计与实现学士学位论文(2)(1).doc
- 扩频通信概述(1).ppt
- WAP网站商业计划书(1).docx
- 微课的信息化资源开发与应用研究(1).docx
- 物联网环境下的企业管理-(1).pptx
- 重庆市信息化工程项目验收实施细则(1).doc
- 理学数据库系统概论(1).pptx
- 2022年互联网公司年终工作总结(1).docx