Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Base64 VLQ概要
Search
rchaser53
June 15, 2017
Programming
2
1.4k
Base64 VLQ概要
rchaser53
June 15, 2017
Tweet
Share
More Decks by rchaser53
See All by rchaser53
LLVM IR入門
rchaser53
4
2.5k
pitch loaderについて
rchaser53
1
490
Rustからwasmを生成してみた話
rchaser53
1
710
sourcemap規格概要
rchaser53
1
1.1k
TypeScript+React入門
rchaser53
1
780
Other Decks in Programming
See All in Programming
Open source software: how to live long and go far
gaelvaroquaux
0
640
sappoRo.R #12 初心者セッション
kosugitti
0
260
メンテが命: PHPフレームワークのコンテナ化とアップグレード戦略
shunta27
0
120
Immutable ActiveRecord
megane42
0
140
Multi Step Form, Decentralized Autonomous Organization
pumpkiinbell
1
750
Java Webフレームワークの現状 / java web framework at burikaigi
kishida
9
2.2k
Unity Android XR入門
sakutama_11
0
160
ARA Ansible for the teams
kksat
0
150
苦しいTiDBへの移行を乗り越えて快適な運用を目指す
leveragestech
0
640
昭和の職場からアジャイルの世界へ
kumagoro95
1
380
Grafana Cloudとソラカメ
devoc
0
170
SwiftUI Viewの責務分離
elmetal
PRO
1
240
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
244
12k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.1k
Music & Morning Musume
bryan
46
6.3k
Automating Front-end Workflow
addyosmani
1368
200k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.5k
The Cult of Friendly URLs
andyhume
78
6.2k
Building Adaptive Systems
keathley
40
2.4k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
A better future with KSS
kneath
238
17k
How to train your dragon (web standard)
notwaldorf
91
5.8k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3k
Transcript
Base64 VLQ概要 @rChaser53
概要 ・sourcemapのmappingsで用いられている ・相対的に位置や情報を示すことで情報を圧縮している ・少ない文字数で-2 ~ 2 -1の値まで表現できる 32 32
使用箇所 TypeScript出力のsourcemap 可読性のため改行している
使用箇所
AAGA,OAAO,CAAC...
AAGA,OAAO,CAAC... 正直これだけではよく分からない まずは数字に変換する必要がある
ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789+/ 使用する文字はBase64で使用する文字 「A」=0、 「/」=63とし 「/」に向かい1ずつ数字が大きくなる Gなら6、aなら26になる
011011 b = 27 これを6bitの2進数に変換する
011011 Continuous Bit Value Bit Sign Bit b = 27
bitには役割が存在する
1の場合、次の文字のValue Bitを左に5bitシフトし この文字列のValue Bitとの和を取る(後述) 011011 Continuous Bit Value Bit Sign
Bit b = 27
この4桁の数値で基本となる数値の値を算出する 011011 Continuous Bit Value Bit Sign Bit b =
27
1の場合、マイナスになる 0の場合、プラスになる 011011 Continuous Bit Value Bit Sign Bit b
= 27
011011 Continuous Bit: 0 => 演算不要! Value Bit: 1101 =>
13 Sign Bit: 1 => -1 b = 27 結果 -13
i = 34 =100010 次 iG G = 6 =000110
100010 Continuous Bit: 1 Value Bit: 0001 Sign Bit: 0
i = 34 000110 G = 6 Value Bit: 0011
100010 Continuous Bit: 1 Value Bit: 0001 Sign Bit: 0
i = 34 次の文字のValue Bit(0011)を左に5bitシフトし 000110 G = 6 Value Bit: 0011 0011 << 5 => 1100000
100010 Continuous Bit: 1 Value Bit: 0001 Sign Bit: 0
i = 34 この文字列のValue Bit(0001)との和を取る 1100000 + 0001 = 1100001 => 97 G = 6 Value Bit: 0011 000110
100010 Continuous Bit: 1 Value Bit: 0001 Sign Bit: 0
i = 34 Sign Bitは0のため符号は「+」のまま 従ってiG = 97 G = 6 Value Bit: 0011 000110
つまり先ほどの文字列は AAGA,OAAO,CAAC...
こうなる AAGA,OAAO,CAAC... 0030,7007,1001...
・カンマ区切りでセクションを構成する ・1文字1文字に意味がある ・初期位置は列、行、index全て0 ・以降は相対的な情報を示す ・;は改行を意味する ・必要となる情報によって セクションのサイズは変動する(1 or 4, 5)
(AAGA,OAAO,CAAC…) 0030,7007,1001...
5文字のケースを元に説明する 各文字は以下の情報を示している 1.変換後の列番号 2.変換前のファイル名のindex (sourcemapのsectionsのindex) 3.変換前のファイルの行番号 4.変換前のファイルの列番号 5.変換後の単語のindex (sourcemapのnamesのindex) 使用箇所
1文字の場合は ここまで 4文字の場合は ここまで
sources: ["../src/sourcemapTest.ts"] names: [], mappings: "AACA,IAAM,SAAS,...” 1.変換後の列番号 0 => 0
2.変換前のファイル名のindex 0 => 0 (sourcemapのsectionsのindex) 3.変換前のファイルの行番号 0 => 1 4.変換前のファイルの列番号 0 => 0 5.変換後の単語のindex 0 => 0 (sourcemapのnamesのindex) 例えば以下のようなsourcemapの構成だったら… AACA = 0010
sources: ["../src/sourcemapTest.ts"] names: [], mappings: "AACA,IAAM,SAAS,...” 1.変換後の列番号 0 => 4
2.変換前のファイル名のindex 0 => 0 (sourcemapのsectionsのindex) 3.変換前のファイルの行番号 1 => 1 4.変換前のファイルの列番号 0 => 6 5.変換後の単語のindex 0 => 0 (sourcemapのnamesのindex) 例えば以下のようなsourcemapの構成だったら… IAAM = 4006
sources: ["../src/sourcemapTest.ts"] names: [], mappings: "AACA,IAAM,SAAS,...” 1.変換後の列番号 4 => 13
2.変換前のファイル名のindex 0 => 0 (sourcemapのsectionsのindex) 3.変換前のファイルの行番号 1 => 1 4.変換前のファイルの列番号 6 => 15 5.変換後の単語のindex 0 => 0 (sourcemapのnamesのindex) 例えば以下のようなsourcemapの構成だったら… SAAS = 9009
ちなみに何を変換したか? sources: ["../src/sourcemapTest.ts"] names: [], mappings: "AACA,IAAM,SAAS,...” var tempValue =
123; type TempType = number; const tempValue: TempType = 123; JavaScript TypeScript sourcemap
Base64 VLQ参考リンク ・MS社の人の独自研究 規則性が知りたければここ フォーマットの変遷の考察が本当に面白い ・BASE64のcoder/decoder 圧縮や難読化がされてないのでソースが楽に読める 説明がわからんコードを見せろという方はここ ・変換前後のsourcemap対応図が非常にわかりやすい
ご静聴ありがとうございました