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.3k
Base64 VLQ概要
rchaser53
June 15, 2017
Tweet
Share
More Decks by rchaser53
See All by rchaser53
LLVM IR入門
rchaser53
4
2.2k
pitch loaderについて
rchaser53
1
460
Rustからwasmを生成してみた話
rchaser53
1
670
sourcemap規格概要
rchaser53
1
1k
TypeScript+React入門
rchaser53
1
740
Other Decks in Programming
See All in Programming
How to Break into Reading Open Source
kaspth
2
210
開発を加速する共有Swift Package実践
elmetal
PRO
0
420
長期運用プロダクトの開発速度を維持し続けるためのリファクタリング実践例
wataruss
8
2.7k
状態管理ライブラリZustandの導入から運用まで
k1tikurisu
3
470
Rechartsで楽にゴリゴリにカスタマイズする!
10tera
1
170
エラーレスポンス設計から考える、0→1開発におけるGraphQLへの向き合い方
bicstone
5
1.5k
あなたのアプリ、ログはでてますか?あるいはログをだしてますか? (Funabashi.dev用 軽量版)
uzulla
2
120
watsonx.ai Dojo #2 生成AIを使ったアプリ開発入門編
oniak3ibm
PRO
0
180
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
0
120
僕が思い描くTypeScriptの未来を勝手に先取りする
yukukotani
9
2.4k
Some more adventure of Happy Eyeballs
coe401_
2
190
LangChainの現在とv0.3にむけて
os1ma
4
920
Featured
See All Featured
Six Lessons from altMBA
skipperchong
26
3.4k
Debugging Ruby Performance
tmm1
72
12k
Documentation Writing (for coders)
carmenintech
65
4.3k
Producing Creativity
orderedlist
PRO
340
39k
How STYLIGHT went responsive
nonsquared
93
5.1k
It's Worth the Effort
3n
182
27k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
The Cost Of JavaScript in 2023
addyosmani
42
5.7k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
Building Your Own Lightsaber
phodgson
101
6k
Building an army of robots
kneath
302
42k
In The Pink: A Labor of Love
frogandcode
139
22k
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対応図が非常にわかりやすい
ご静聴ありがとうございました