\n\t\t\t\x3CCounter />\n\t\t\t\x3CCountAtomScopeProvider userId=\"tom@example.com\">\n\t\t\t\t\x3CCounter />\n\t\t\t\t\x3CCounter />\n\t\t\t\x3C/CountAtomScopeProvider>\n\t\t\x3C/CountAtomScopeProvider>\n\t);\n}\n```\n\n上記の例は `jotai` を使っているが、`bunshi` も使うと以下のように書くことができる。\n\n```tsx:sample.tsx\nimport { atom, useAtom } from \"jotai\";\nimport {\n\tScopeProvider,\n\tcreateScope,\n\tmolecule,\n\tuseMolecule,\n} from \"bunshi/react\";\n\nconst UserScope = createScope(undefined);\nconst countMolecule = molecule((mol, scope) => {\n\tconst userId = scope(UserScope);\n\tconsole.log(\"Creating a new atom for\", userId);\n\treturn atom(0);\n});\n\n// ... Counter unchanged\n\nexport function App() {\n\treturn (\n\t\t\x3CScopeProvider scope={UserScope} value=\"bob@example.com\">\n\t\t\t\x3CCounter />\n\t\t\x3C/ScopeProvider>\n\t);\n}\n```\n\n## まとめ\n\n今回は `bunshi` というライブラリの基本概念からその魅力までを調べた。途中で実装の方を参照することが多々あったが、ほとんどテストされていてドキュメントも充実しているため、理解するのは難しくなかった。\n\n`bunshi` を使って状態管理のベストプラクティスを追求したいと思った。",description:"自分の理解を深めるために調べ尽くす",published:!0,publishedAt:"2024-05-29T22:23:29.51+09:00[Asia/Tokyo]",tags:$R[6]=["state","jotai","bunshi"],title:"bunshiを理解する",_meta:$R[7]={filePath:"01HYDY4ANBK11SCFE0K2K3DV5A/slug.md",fileName:"slug.md",directory:"01HYDY4ANBK11SCFE0K2K3DV5A",extension:"md",path:"01HYDY4ANBK11SCFE0K2K3DV5A/slug"},abstract:"bunshiを理解するはじめにbunshi というライブラリがある。状態管理ライブラリの DI を行うものだ。jotai を使う機会があり、調べを進める中で当時名前を聞いた jotai-molecule が bunshi という名前で良い感じに開発されていて気になったので調べてみる。注意: この記事が書かれた当時の情報であり、最新の情報とは異なる可能性がある。bunshi のバージョンは 2.1.5 である。bunshiの特徴bunshi は次のような特徴を持つ。バンドルサイズが小さいgzip 圧縮されたサイズで 1.18KB しかない。また他のライブラリに依存いていないのも大きな特徴だ。framework agnosticであるbunshi は jotai や zustand、nanostores などの状態管理ライブラリを molecule という概念でラップすることで、状態のスコープ",mdast:$R[8]={children:$R[9]=[$R[10]={children:$R[11]=[$R[12]={children:$R[13]=[$R[14]={position:$R[15]={start:$R[16]={line:3,column:4,offset:18},end:$R[17]={line:3,column:8,offset:22}},type:"text",value:"はじめに"}],id:"はじめに",level:2,plain:"はじめに",position:$R[18]={start:$R[19]={line:3,column:1,offset:15},end:$R[20]={line:3,column:8,offset:22}},type:"heading"},$R[21]={children:$R[22]=[$R[23]={children:$R[24]=[$R[25]={position:$R[26]={start:$R[27]={line:5,column:2,offset:25},end:$R[28]={line:5,column:8,offset:31}},type:"text",value:"bunshi"}],position:$R[29]={start:$R[30]={line:5,column:1,offset:24},end:$R[31]={line:5,column:47,offset:70}},title:void 0,type:"link",url:"https://github.com/saasquatch/bunshi"},$R[32]={position:$R[33]={start:$R[34]={line:5,column:47,offset:70},end:$R[35]={line:5,column:81,offset:104}},type:"text",value:" というライブラリがある。状態管理ライブラリの DI を行うものだ。"}],position:$R[36]={start:$R[37]={line:5,column:1,offset:24},end:$R[38]={line:5,column:81,offset:104}},type:"paragraph"},$R[39]={children:$R[40]=[$R[41]={position:$R[42]={start:$R[43]={line:7,column:1,offset:106},end:$R[44]={line:7,column:8,offset:113}},type:"inlineCode",value:"jotai"},$R[45]={position:$R[46]={start:$R[47]={line:7,column:8,offset:113},end:$R[48]={line:7,column:35,offset:140}},type:"text",value:" を使う機会があり、調べを進める中で当時名前を聞いた "},$R[49]={position:$R[50]={start:$R[51]={line:7,column:35,offset:140},end:$R[52]={line:7,column:51,offset:156}},type:"inlineCode",value:"jotai-molecule"},$R[53]={position:$R[54]={start:$R[55]={line:7,column:51,offset:156},end:$R[56]={line:7,column:54,offset:159}},type:"text",value:" が "},$R[57]={position:$R[58]={start:$R[59]={line:7,column:54,offset:159},end:$R[60]={line:7,column:62,offset:167}},type:"inlineCode",value:"bunshi"},$R[61]={position:$R[62]={start:$R[63]={line:7,column:62,offset:167},end:$R[64]={line:7,column:94,offset:199}},type:"text",value:" という名前で良い感じに開発されていて気になったので調べてみる。"}],position:$R[65]={start:$R[66]={line:7,column:1,offset:106},end:$R[67]={line:7,column:94,offset:199}},type:"paragraph"},$R[68]={children:$R[69]=[$R[70]={position:$R[71]={start:$R[72]={line:9,column:1,offset:201},end:$R[73]={line:9,column:40,offset:240}},type:"text",value:"注意: この記事が書かれた当時の情報であり、最新の情報とは異なる可能性がある。"},$R[74]={position:$R[75]={start:$R[76]={line:9,column:40,offset:240},end:$R[77]={line:9,column:48,offset:248}},type:"inlineCode",value:"bunshi"},$R[78]={position:$R[79]={start:$R[80]={line:9,column:48,offset:248},end:$R[81]={line:9,column:57,offset:257}},type:"text",value:" のバージョンは "},$R[82]={position:$R[83]={start:$R[84]={line:9,column:57,offset:257},end:$R[85]={line:9,column:64,offset:264}},type:"inlineCode",value:"2.1.5"},$R[86]={position:$R[87]={start:$R[88]={line:9,column:64,offset:264},end:$R[89]={line:9,column:69,offset:269}},type:"text",value:" である。"}],position:$R[90]={start:$R[91]={line:9,column:1,offset:201},end:$R[92]={line:9,column:69,offset:269}},type:"paragraph"}],position:$R[93]={end:$R[94]={line:9,column:69,offset:269},start:$R[95]={line:3,column:1,offset:15}},type:"section"},$R[96]={children:$R[97]=[$R[98]={children:$R[99]=[$R[100]={position:$R[101]={start:$R[102]={line:11,column:4,offset:274},end:$R[103]={line:11,column:13,offset:283}},type:"text",value:"bunshiの特徴"}],id:"bunshiの特徴",level:2,plain:"bunshiの特徴",position:$R[104]={start:$R[105]={line:11,column:1,offset:271},end:$R[106]={line:11,column:13,offset:283}},type:"heading"},$R[107]={children:$R[108]=[$R[109]={position:$R[110]={start:$R[111]={line:13,column:1,offset:285},end:$R[112]={line:13,column:9,offset:293}},type:"inlineCode",value:"bunshi"},$R[113]={position:$R[114]={start:$R[115]={line:13,column:9,offset:293},end:$R[116]={line:13,column:22,offset:306}},type:"text",value:" は次のような特徴を持つ。"}],position:$R[117]={start:$R[118]={line:13,column:1,offset:285},end:$R[119]={line:13,column:22,offset:306}},type:"paragraph"},$R[120]={children:$R[121]=[$R[122]={children:$R[123]=[$R[124]={position:$R[125]={start:$R[126]={line:15,column:5,offset:312},end:$R[127]={line:15,column:16,offset:323}},type:"text",value:"バンドルサイズが小さい"}],id:"バンドルサイズが小さい",level:3,plain:"バンドルサイズが小さい",position:$R[128]={start:$R[129]={line:15,column:1,offset:308},end:$R[130]={line:15,column:16,offset:323}},type:"heading"},$R[131]={children:$R[132]=[$R[133]={position:$R[134]={start:$R[135]={line:17,column:1,offset:325},end:$R[136]={line:17,column:54,offset:378}},type:"text",value:"gzip 圧縮されたサイズで 1.18KB しかない。また他のライブラリに依存いていないのも大きな特徴だ。"}],position:$R[137]={start:$R[138]={line:17,column:1,offset:325},end:$R[139]={line:17,column:54,offset:378}},type:"paragraph"}],position:$R[140]={end:$R[141]={line:17,column:54,offset:378},start:$R[142]={line:15,column:1,offset:308}},type:"section"},$R[143]={children:$R[144]=[$R[145]={children:$R[146]=[$R[147]={position:$R[148]={start:$R[149]={line:19,column:5,offset:384},end:$R[150]={line:19,column:26,offset:405}},type:"text",value:"framework agnosticである"}],id:"framework-agnosticである",level:3,plain:"framework agnosticである",position:$R[151]={start:$R[152]={line:19,column:1,offset:380},end:$R[153]={line:19,column:26,offset:405}},type:"heading"},$R[154]={children:$R[155]=[$R[156]={position:$R[157]={start:$R[158]={line:21,column:1,offset:407},end:$R[159]={line:21,column:9,offset:415}},type:"inlineCode",value:"bunshi"},$R[160]={position:$R[161]={start:$R[162]={line:21,column:9,offset:415},end:$R[163]={line:21,column:12,offset:418}},type:"text",value:" は "},$R[164]={position:$R[165]={start:$R[166]={line:21,column:12,offset:418},end:$R[167]={line:21,column:19,offset:425}},type:"inlineCode",value:"jotai"},$R[168]={position:$R[169]={start:$R[170]={line:21,column:19,offset:425},end:$R[171]={line:21,column:22,offset:428}},type:"text",value:" や "},$R[172]={position:$R[173]={start:$R[174]={line:21,column:22,offset:428},end:$R[175]={line:21,column:31,offset:437}},type:"inlineCode",value:"zustand"},$R[176]={position:$R[177]={start:$R[178]={line:21,column:31,offset:437},end:$R[179]={line:21,column:32,offset:438}},type:"text",value:"、"},$R[180]={position:$R[181]={start:$R[182]={line:21,column:32,offset:438},end:$R[183]={line:21,column:44,offset:450}},type:"inlineCode",value:"nanostores"},$R[184]={position:$R[185]={start:$R[186]={line:21,column:44,offset:450},end:$R[187]={line:21,column:59,offset:465}},type:"text",value:" などの状態管理ライブラリを "},$R[188]={position:$R[189]={start:$R[190]={line:21,column:59,offset:465},end:$R[191]={line:21,column:69,offset:475}},type:"inlineCode",value:"molecule"},$R[192]={position:$R[193]={start:$R[194]={line:21,column:69,offset:475},end:$R[195]={line:21,column:109,offset:515}},type:"text",value:" という概念でラップすることで、状態のスコープ管理や依存注入を行うことができる。"}],position:$R[196]={start:$R[197]={line:21,column:1,offset:407},end:$R[198]={line:21,column:109,offset:515}},type:"paragraph"},$R[199]={children:$R[200]=[$R[201]={position:$R[202]={start:$R[203]={line:23,column:1,offset:517},end:$R[204]={line:23,column:11,offset:527}},type:"inlineCode",value:"molecule"},$R[205]={position:$R[206]={start:$R[207]={line:23,column:11,offset:527},end:$R[208]={line:23,column:68,offset:584}},type:"text",value:" の宣言は framework agnostic であるため、ロジックをフレームワークに依存させず書くことができる"},$R[209]={footnoteIndex:0,position:$R[210]={start:$R[211]={line:23,column:68,offset:584},end:$R[212]={line:23,column:72,offset:588}},referenceIndex:1,type:"footnoteReference"},$R[213]={position:$R[214]={start:$R[215]={line:23,column:72,offset:588},end:$R[216]={line:23,column:73,offset:589}},type:"text",value:"。"}],position:$R[217]={start:$R[218]={line:23,column:1,offset:517},end:$R[219]={line:23,column:73,offset:589}},type:"paragraph"}],position:$R[220]={end:$R[221]={line:23,column:73,offset:589},start:$R[222]={line:19,column:1,offset:380}},type:"section"},$R[223]={children:$R[224]=[$R[225]={children:$R[226]=[$R[227]={position:$R[228]={start:$R[229]={line:27,column:5,offset:747},end:$R[230]={line:27,column:20,offset:762}},type:"text",value:"パフォーマンスに配慮されている"}],id:"パフォーマンスに配慮されている",level:3,plain:"パフォーマンスに配慮されている",position:$R[231]={start:$R[232]={line:27,column:1,offset:743},end:$R[233]={line:27,column:20,offset:762}},type:"heading"},$R[234]={children:$R[235]=[$R[236]={position:$R[237]={start:$R[238]={line:29,column:1,offset:764},end:$R[239]={line:29,column:10,offset:773}},type:"inlineCode",value:"WeakMap"},$R[240]={position:$R[241]={start:$R[242]={line:29,column:10,offset:773},end:$R[243]={line:29,column:24,offset:787}},type:"text",value:" を用いたメモリリークの防止"},$R[244]={footnoteIndex:1,position:$R[245]={start:$R[246]={line:29,column:24,offset:787},end:$R[247]={line:29,column:28,offset:791}},referenceIndex:1,type:"footnoteReference"},$R[248]={position:$R[249]={start:$R[250]={line:29,column:28,offset:791},end:$R[251]={line:29,column:66,offset:829}},type:"text",value:"や、不要な再レンダリングを防止するためにフレームワークのインテグレーション("},$R[252]={position:$R[253]={start:$R[254]={line:29,column:66,offset:829},end:$R[255]={line:29,column:73,offset:836}},type:"inlineCode",value:"React"},$R[256]={position:$R[257]={start:$R[258]={line:29,column:73,offset:836},end:$R[259]={line:29,column:75,offset:838}},type:"text",value:", "},$R[260]={position:$R[261]={start:$R[262]={line:29,column:75,offset:838},end:$R[263]={line:29,column:80,offset:843}},type:"inlineCode",value:"Vue"},$R[264]={position:$R[265]={start:$R[266]={line:29,column:80,offset:843},end:$R[267]={line:29,column:93,offset:856}},type:"text",value:")ではメモ化を行っている。"}],position:$R[268]={start:$R[269]={line:29,column:1,offset:764},end:$R[270]={line:29,column:93,offset:856}},type:"paragraph"}],position:$R[271]={end:$R[272]={line:29,column:93,offset:856},start:$R[273]={line:27,column:1,offset:743}},type:"section"}],position:$R[274]={end:$R[275]={line:29,column:93,offset:856},start:$R[276]={line:11,column:1,offset:271}},type:"section"},$R[277]={children:$R[278]=[$R[279]={children:$R[280]=[$R[281]={position:$R[282]={start:$R[283]={line:33,column:4,offset:985},end:$R[284]={line:33,column:15,offset:996}},type:"text",value:"bunshiの基本概念"}],id:"bunshiの基本概念",level:2,plain:"bunshiの基本概念",position:$R[285]={start:$R[286]={line:33,column:1,offset:982},end:$R[287]={line:33,column:15,offset:996}},type:"heading"},$R[288]={children:$R[289]=[$R[290]={position:$R[291]={start:$R[292]={line:35,column:1,offset:998},end:$R[293]={line:35,column:25,offset:1022}},type:"text",value:"bunshi は次の 3 つの概念で構成される。"}],position:$R[294]={start:$R[295]={line:35,column:1,offset:998},end:$R[296]={line:35,column:25,offset:1022}},type:"paragraph"},$R[297]={children:$R[298]=[$R[299]={children:$R[300]=[$R[301]={position:$R[302]={start:$R[303]={line:37,column:5,offset:1028},end:$R[304]={line:37,column:13,offset:1036}},type:"text",value:"molecule"}],id:"molecule",level:3,plain:"molecule",position:$R[305]={start:$R[306]={line:37,column:1,offset:1024},end:$R[307]={line:37,column:13,offset:1036}},type:"heading"},$R[308]={children:$R[309]=[$R[310]={position:$R[311]={start:$R[312]={line:39,column:1,offset:1038},end:$R[313]={line:39,column:11,offset:1048}},type:"inlineCode",value:"molecule"},$R[314]={position:$R[315]={start:$R[316]={line:39,column:11,offset:1048},end:$R[317]={line:39,column:14,offset:1051}},type:"text",value:" は "},$R[318]={position:$R[319]={start:$R[320]={line:39,column:14,offset:1051},end:$R[321]={line:39,column:22,offset:1059}},type:"inlineCode",value:"bunshi"},$R[322]={position:$R[323]={start:$R[324]={line:39,column:22,offset:1059},end:$R[325]={line:39,column:57,offset:1094}},type:"text",value:" の core 的な概念であり、実態は値を返す関数の HoF である。"}],position:$R[326]={start:$R[327]={line:39,column:1,offset:1038},end:$R[328]={line:39,column:57,offset:1094}},type:"paragraph"},$R[329]={children:$R[330]=[$R[331]={position:$R[332]={start:$R[333]={line:41,column:1,offset:1096},end:$R[334]={line:41,column:45,offset:1140}},type:"text",value:"最大の特徴は、関数の実行結果がキャッシュされることである。以下の例は常に同じ乱数を返す。"}],position:$R[335]={start:$R[336]={line:41,column:1,offset:1096},end:$R[337]={line:41,column:45,offset:1140}},type:"paragraph"},$R[338]={filename:"sample.ts ts",lang:"ts",position:$R[339]={start:$R[340]={line:43,column:1,offset:1142},end:$R[341]={line:47,column:4,offset:1258}},type:"code",value:"import { molecule } from \"bunshi\";\n\nexport const RandomMolecule = molecule(() => Math.random());",hast:$R[342]={type:"root",children:$R[343]=[$R[344]={type:"element",tagName:"pre",properties:$R[345]={class:"shiki vitesse-dark",style:"color: #dbd7cacc;",tabindex:"0"},children:$R[346]=[$R[347]={type:"element",tagName:"code",properties:$R[348]={},children:$R[349]=[$R[350]={type:"element",tagName:"span",properties:$R[351]={class:"line"},children:$R[352]=[$R[353]={type:"element",tagName:"span",properties:$R[354]={style:"color:#4D9375"},children:$R[355]=[$R[356]={type:"text",value:"import"}]},$R[357]={type:"element",tagName:"span",properties:$R[358]={style:"color:#666666"},children:$R[359]=[$R[360]={type:"text",value:" {"}]},$R[361]={type:"element",tagName:"span",properties:$R[362]={style:"color:#BD976A"},children:$R[363]=[$R[364]={type:"text",value:" molecule"}]},$R[365]={type:"element",tagName:"span",properties:$R[366]={style:"color:#666666"},children:$R[367]=[$R[368]={type:"text",value:" }"}]},$R[369]={type:"element",tagName:"span",properties:$R[370]={style:"color:#4D9375"},children:$R[371]=[$R[372]={type:"text",value:" from"}]},$R[373]={type:"element",tagName:"span",properties:$R[374]={style:"color:#C98A7D77"},children:$R[375]=[$R[376]={type:"text",value:" \""}]},$R[377]={type:"element",tagName:"span",properties:$R[378]={style:"color:#C98A7D"},children:$R[379]=[$R[380]={type:"text",value:"bunshi"}]},$R[381]={type:"element",tagName:"span",properties:$R[382]={style:"color:#C98A7D77"},children:$R[383]=[$R[384]={type:"text",value:"\""}]},$R[385]={type:"element",tagName:"span",properties:$R[386]={style:"color:#666666"},children:$R[387]=[$R[388]={type:"text",value:";"}]}]},$R[389]={type:"text",value:"\n"},$R[390]={type:"element",tagName:"span",properties:$R[391]={class:"line"},children:$R[392]=[]},$R[393]={type:"text",value:"\n"},$R[394]={type:"element",tagName:"span",properties:$R[395]={class:"line"},children:$R[396]=[$R[397]={type:"element",tagName:"span",properties:$R[398]={style:"color:#4D9375"},children:$R[399]=[$R[400]={type:"text",value:"export"}]},$R[401]={type:"element",tagName:"span",properties:$R[402]={style:"color:#CB7676"},children:$R[403]=[$R[404]={type:"text",value:" const "}]},$R[405]={type:"element",tagName:"span",properties:$R[406]={style:"color:#BD976A"},children:$R[407]=[$R[408]={type:"text",value:"RandomMolecule"}]},$R[409]={type:"element",tagName:"span",properties:$R[410]={style:"color:#666666"},children:$R[411]=[$R[412]={type:"text",value:" ="}]},$R[413]={type:"element",tagName:"span",properties:$R[414]={style:"color:#80A665"},children:$R[415]=[$R[416]={type:"text",value:" molecule"}]},$R[417]={type:"element",tagName:"span",properties:$R[418]={style:"color:#666666"},children:$R[419]=[$R[420]={type:"text",value:"(()"}]},$R[421]={type:"element",tagName:"span",properties:$R[422]={style:"color:#666666"},children:$R[423]=[$R[424]={type:"text",value:" =>"}]},$R[425]={type:"element",tagName:"span",properties:$R[426]={style:"color:#BD976A"},children:$R[427]=[$R[428]={type:"text",value:" Math"}]},$R[429]={type:"element",tagName:"span",properties:$R[430]={style:"color:#666666"},children:$R[431]=[$R[432]={type:"text",value:"."}]},$R[433]={type:"element",tagName:"span",properties:$R[434]={style:"color:#80A665"},children:$R[435]=[$R[436]={type:"text",value:"random"}]},$R[437]={type:"element",tagName:"span",properties:$R[438]={style:"color:#666666"},children:$R[439]=[$R[440]={type:"text",value:"());"}]}]}]}]}]}},$R[441]={children:$R[442]=[$R[443]={position:$R[444]={start:$R[445]={line:49,column:1,offset:1260},end:$R[446]={line:49,column:4,offset:1263}},type:"text",value:"また "},$R[447]={position:$R[448]={start:$R[449]={line:49,column:4,offset:1263},end:$R[450]={line:49,column:14,offset:1273}},type:"inlineCode",value:"molecule"},$R[451]={position:$R[452]={start:$R[453]={line:49,column:14,offset:1273},end:$R[454]={line:49,column:19,offset:1278}},type:"text",value:" は他の "},$R[455]={position:$R[456]={start:$R[457]={line:49,column:19,offset:1278},end:$R[458]={line:49,column:29,offset:1288}},type:"inlineCode",value:"molecule"},$R[459]={position:$R[460]={start:$R[461]={line:49,column:29,offset:1288},end:$R[462]={line:49,column:37,offset:1296}},type:"text",value:" に依存できる。"}],position:$R[463]={start:$R[464]={line:49,column:1,offset:1260},end:$R[465]={line:49,column:37,offset:1296}},type:"paragraph"},$R[466]={filename:"sample.ts ts",lang:"ts",position:$R[467]={start:$R[468]={line:51,column:1,offset:1298},end:$R[469]={line:59,column:4,offset:1579}},type:"code",value:"import { molecule } from \"bunshi\";\n\nexport const RandomMolecule = molecule(() => Math.random());\nexport const UsernameMolecule = molecule(\n\tmol => `You are user ${mol(RandomMolecule)}`,\n);\nexport const IDMolecule = molecule(mol => `ID: ${mol(RandomMolecule)}`);",hast:$R[470]={type:"root",children:$R[471]=[$R[472]={type:"element",tagName:"pre",properties:$R[473]={class:"shiki vitesse-dark",style:"color: #dbd7cacc;",tabindex:"0"},children:$R[474]=[$R[475]={type:"element",tagName:"code",properties:$R[476]={},children:$R[477]=[$R[478]={type:"element",tagName:"span",properties:$R[479]={class:"line"},children:$R[480]=[$R[481]={type:"element",tagName:"span",properties:$R[482]={style:"color:#4D9375"},children:$R[483]=[$R[484]={type:"text",value:"import"}]},$R[485]={type:"element",tagName:"span",properties:$R[486]={style:"color:#666666"},children:$R[487]=[$R[488]={type:"text",value:" {"}]},$R[489]={type:"element",tagName:"span",properties:$R[490]={style:"color:#BD976A"},children:$R[491]=[$R[492]={type:"text",value:" molecule"}]},$R[493]={type:"element",tagName:"span",properties:$R[494]={style:"color:#666666"},children:$R[495]=[$R[496]={type:"text",value:" }"}]},$R[497]={type:"element",tagName:"span",properties:$R[498]={style:"color:#4D9375"},children:$R[499]=[$R[500]={type:"text",value:" from"}]},$R[501]={type:"element",tagName:"span",properties:$R[502]={style:"color:#C98A7D77"},children:$R[503]=[$R[504]={type:"text",value:" \""}]},$R[505]={type:"element",tagName:"span",properties:$R[506]={style:"color:#C98A7D"},children:$R[507]=[$R[508]={type:"text",value:"bunshi"}]},$R[509]={type:"element",tagName:"span",properties:$R[510]={style:"color:#C98A7D77"},children:$R[511]=[$R[512]={type:"text",value:"\""}]},$R[513]={type:"element",tagName:"span",properties:$R[514]={style:"color:#666666"},children:$R[515]=[$R[516]={type:"text",value:";"}]}]},$R[517]={type:"text",value:"\n"},$R[518]={type:"element",tagName:"span",properties:$R[519]={class:"line"},children:$R[520]=[]},$R[521]={type:"text",value:"\n"},$R[522]={type:"element",tagName:"span",properties:$R[523]={class:"line"},children:$R[524]=[$R[525]={type:"element",tagName:"span",properties:$R[526]={style:"color:#4D9375"},children:$R[527]=[$R[528]={type:"text",value:"export"}]},$R[529]={type:"element",tagName:"span",properties:$R[530]={style:"color:#CB7676"},children:$R[531]=[$R[532]={type:"text",value:" const "}]},$R[533]={type:"element",tagName:"span",properties:$R[534]={style:"color:#BD976A"},children:$R[535]=[$R[536]={type:"text",value:"RandomMolecule"}]},$R[537]={type:"element",tagName:"span",properties:$R[538]={style:"color:#666666"},children:$R[539]=[$R[540]={type:"text",value:" ="}]},$R[541]={type:"element",tagName:"span",properties:$R[542]={style:"color:#80A665"},children:$R[543]=[$R[544]={type:"text",value:" molecule"}]},$R[545]={type:"element",tagName:"span",properties:$R[546]={style:"color:#666666"},children:$R[547]=[$R[548]={type:"text",value:"(()"}]},$R[549]={type:"element",tagName:"span",properties:$R[550]={style:"color:#666666"},children:$R[551]=[$R[552]={type:"text",value:" =>"}]},$R[553]={type:"element",tagName:"span",properties:$R[554]={style:"color:#BD976A"},children:$R[555]=[$R[556]={type:"text",value:" Math"}]},$R[557]={type:"element",tagName:"span",properties:$R[558]={style:"color:#666666"},children:$R[559]=[$R[560]={type:"text",value:"."}]},$R[561]={type:"element",tagName:"span",properties:$R[562]={style:"color:#80A665"},children:$R[563]=[$R[564]={type:"text",value:"random"}]},$R[565]={type:"element",tagName:"span",properties:$R[566]={style:"color:#666666"},children:$R[567]=[$R[568]={type:"text",value:"());"}]}]},$R[569]={type:"text",value:"\n"},$R[570]={type:"element",tagName:"span",properties:$R[571]={class:"line"},children:$R[572]=[$R[573]={type:"element",tagName:"span",properties:$R[574]={style:"color:#4D9375"},children:$R[575]=[$R[576]={type:"text",value:"export"}]},$R[577]={type:"element",tagName:"span",properties:$R[578]={style:"color:#CB7676"},children:$R[579]=[$R[580]={type:"text",value:" const "}]},$R[581]={type:"element",tagName:"span",properties:$R[582]={style:"color:#BD976A"},children:$R[583]=[$R[584]={type:"text",value:"UsernameMolecule"}]},$R[585]={type:"element",tagName:"span",properties:$R[586]={style:"color:#666666"},children:$R[587]=[$R[588]={type:"text",value:" ="}]},$R[589]={type:"element",tagName:"span",properties:$R[590]={style:"color:#80A665"},children:$R[591]=[$R[592]={type:"text",value:" molecule"}]},$R[593]={type:"element",tagName:"span",properties:$R[594]={style:"color:#666666"},children:$R[595]=[$R[596]={type:"text",value:"("}]}]},$R[597]={type:"text",value:"\n"},$R[598]={type:"element",tagName:"span",properties:$R[599]={class:"line"},children:$R[600]=[$R[601]={type:"element",tagName:"span",properties:$R[602]={style:"color:#BD976A"},children:$R[603]=[$R[604]={type:"text",value:"\tmol"}]},$R[605]={type:"element",tagName:"span",properties:$R[606]={style:"color:#666666"},children:$R[607]=[$R[608]={type:"text",value:" =>"}]},$R[609]={type:"element",tagName:"span",properties:$R[610]={style:"color:#C98A7D77"},children:$R[611]=[$R[612]={type:"text",value:" `"}]},$R[613]={type:"element",tagName:"span",properties:$R[614]={style:"color:#C98A7D"},children:$R[615]=[$R[616]={type:"text",value:"You are user "}]},$R[617]={type:"element",tagName:"span",properties:$R[618]={style:"color:#4D9375"},children:$R[619]=[$R[620]={type:"text",value:"${"}]},$R[621]={type:"element",tagName:"span",properties:$R[622]={style:"color:#80A665"},children:$R[623]=[$R[624]={type:"text",value:"mol"}]},$R[625]={type:"element",tagName:"span",properties:$R[626]={style:"color:#666666"},children:$R[627]=[$R[628]={type:"text",value:"("}]},$R[629]={type:"element",tagName:"span",properties:$R[630]={style:"color:#C98A7D"},children:$R[631]=[$R[632]={type:"text",value:"RandomMolecule"}]},$R[633]={type:"element",tagName:"span",properties:$R[634]={style:"color:#666666"},children:$R[635]=[$R[636]={type:"text",value:")"}]},$R[637]={type:"element",tagName:"span",properties:$R[638]={style:"color:#4D9375"},children:$R[639]=[$R[640]={type:"text",value:"}"}]},$R[641]={type:"element",tagName:"span",properties:$R[642]={style:"color:#C98A7D77"},children:$R[643]=[$R[644]={type:"text",value:"`"}]},$R[645]={type:"element",tagName:"span",properties:$R[646]={style:"color:#666666"},children:$R[647]=[$R[648]={type:"text",value:","}]}]},$R[649]={type:"text",value:"\n"},$R[650]={type:"element",tagName:"span",properties:$R[651]={class:"line"},children:$R[652]=[$R[653]={type:"element",tagName:"span",properties:$R[654]={style:"color:#666666"},children:$R[655]=[$R[656]={type:"text",value:");"}]}]},$R[657]={type:"text",value:"\n"},$R[658]={type:"element",tagName:"span",properties:$R[659]={class:"line"},children:$R[660]=[$R[661]={type:"element",tagName:"span",properties:$R[662]={style:"color:#4D9375"},children:$R[663]=[$R[664]={type:"text",value:"export"}]},$R[665]={type:"element",tagName:"span",properties:$R[666]={style:"color:#CB7676"},children:$R[667]=[$R[668]={type:"text",value:" const "}]},$R[669]={type:"element",tagName:"span",properties:$R[670]={style:"color:#BD976A"},children:$R[671]=[$R[672]={type:"text",value:"IDMolecule"}]},$R[673]={type:"element",tagName:"span",properties:$R[674]={style:"color:#666666"},children:$R[675]=[$R[676]={type:"text",value:" ="}]},$R[677]={type:"element",tagName:"span",properties:$R[678]={style:"color:#80A665"},children:$R[679]=[$R[680]={type:"text",value:" molecule"}]},$R[681]={type:"element",tagName:"span",properties:$R[682]={style:"color:#666666"},children:$R[683]=[$R[684]={type:"text",value:"("}]},$R[685]={type:"element",tagName:"span",properties:$R[686]={style:"color:#BD976A"},children:$R[687]=[$R[688]={type:"text",value:"mol"}]},$R[689]={type:"element",tagName:"span",properties:$R[690]={style:"color:#666666"},children:$R[691]=[$R[692]={type:"text",value:" =>"}]},$R[693]={type:"element",tagName:"span",properties:$R[694]={style:"color:#C98A7D77"},children:$R[695]=[$R[696]={type:"text",value:" `"}]},$R[697]={type:"element",tagName:"span",properties:$R[698]={style:"color:#C98A7D"},children:$R[699]=[$R[700]={type:"text",value:"ID: "}]},$R[701]={type:"element",tagName:"span",properties:$R[702]={style:"color:#4D9375"},children:$R[703]=[$R[704]={type:"text",value:"${"}]},$R[705]={type:"element",tagName:"span",properties:$R[706]={style:"color:#80A665"},children:$R[707]=[$R[708]={type:"text",value:"mol"}]},$R[709]={type:"element",tagName:"span",properties:$R[710]={style:"color:#666666"},children:$R[711]=[$R[712]={type:"text",value:"("}]},$R[713]={type:"element",tagName:"span",properties:$R[714]={style:"color:#C98A7D"},children:$R[715]=[$R[716]={type:"text",value:"RandomMolecule"}]},$R[717]={type:"element",tagName:"span",properties:$R[718]={style:"color:#666666"},children:$R[719]=[$R[720]={type:"text",value:")"}]},$R[721]={type:"element",tagName:"span",properties:$R[722]={style:"color:#4D9375"},children:$R[723]=[$R[724]={type:"text",value:"}"}]},$R[725]={type:"element",tagName:"span",properties:$R[726]={style:"color:#C98A7D77"},children:$R[727]=[$R[728]={type:"text",value:"`"}]},$R[729]={type:"element",tagName:"span",properties:$R[730]={style:"color:#666666"},children:$R[731]=[$R[732]={type:"text",value:");"}]}]}]}]}]}},$R[733]={children:$R[734]=[$R[735]={position:$R[736]={start:$R[737]={line:61,column:1,offset:1581},end:$R[738]={line:61,column:31,offset:1611}},type:"text",value:"依存は自動で解決されるため、コード保守やテストが容易になる。"}],position:$R[739]={start:$R[740]={line:61,column:1,offset:1581},end:$R[741]={line:61,column:31,offset:1611}},type:"paragraph"},$R[742]={children:$R[743]=[$R[744]={position:$R[745]={start:$R[746]={line:63,column:1,offset:1613},end:$R[747]={line:63,column:9,offset:1621}},type:"text",value:"ロジックなどを "},$R[748]={position:$R[749]={start:$R[750]={line:63,column:9,offset:1621},end:$R[751]={line:63,column:19,offset:1631}},type:"inlineCode",value:"molecule"},$R[752]={position:$R[753]={start:$R[754]={line:63,column:19,offset:1631},end:$R[755]={line:63,column:44,offset:1656}},type:"text",value:" に閉じ込めることでコードは非結合で遅延的となる。"}],position:$R[756]={start:$R[757]={line:63,column:1,offset:1613},end:$R[758]={line:63,column:44,offset:1656}},type:"paragraph"},$R[759]={children:$R[760]=[$R[761]={children:$R[762]=[$R[763]={children:$R[764]=[$R[765]={position:$R[766]={start:$R[767]={line:65,column:3,offset:1660},end:$R[768]={line:65,column:6,offset:1663}},type:"text",value:"非結合"}],position:$R[769]={start:$R[770]={line:65,column:3,offset:1660},end:$R[771]={line:65,column:6,offset:1663}},type:"paragraph"},$R[772]={children:$R[773]=[$R[774]={children:$R[775]=[$R[776]={children:$R[777]=[$R[778]={position:$R[779]={start:$R[780]={line:67,column:5,offset:1669},end:$R[781]={line:67,column:8,offset:1672}},type:"text",value:"ある "},$R[782]={position:$R[783]={start:$R[784]={line:67,column:8,offset:1672},end:$R[785]={line:67,column:18,offset:1682}},type:"inlineCode",value:"molecule"},$R[786]={position:$R[787]={start:$R[788]={line:67,column:18,offset:1682},end:$R[789]={line:67,column:35,offset:1699}},type:"text",value:" をリファクタリングする時、その "},$R[790]={position:$R[791]={start:$R[792]={line:67,column:35,offset:1699},end:$R[793]={line:67,column:45,offset:1709}},type:"inlineCode",value:"molecule"},$R[794]={position:$R[795]={start:$R[796]={line:67,column:45,offset:1709},end:$R[797]={line:67,column:54,offset:1718}},type:"text",value:" に依存する他の "},$R[798]={position:$R[799]={start:$R[800]={line:67,column:54,offset:1718},end:$R[801]={line:67,column:64,offset:1728}},type:"inlineCode",value:"molecule"},$R[802]={position:$R[803]={start:$R[804]={line:67,column:64,offset:1728},end:$R[805]={line:67,column:73,offset:1737}},type:"text",value:" に影響を与えない"}],position:$R[806]={start:$R[807]={line:67,column:5,offset:1669},end:$R[808]={line:67,column:73,offset:1737}},type:"paragraph"}],position:$R[809]={start:$R[810]={line:67,column:3,offset:1667},end:$R[811]={line:67,column:73,offset:1737}},type:"listItem"}],position:$R[812]={start:$R[813]={line:67,column:3,offset:1667},end:$R[814]={line:67,column:73,offset:1737}},type:"unorderedList"}],position:$R[815]={start:$R[816]={line:65,column:1,offset:1658},end:$R[817]={line:67,column:73,offset:1737}},type:"listItem"},$R[818]={children:$R[819]=[$R[820]={children:$R[821]=[$R[822]={position:$R[823]={start:$R[824]={line:69,column:3,offset:1741},end:$R[825]={line:69,column:6,offset:1744}},type:"text",value:"遅延的"}],position:$R[826]={start:$R[827]={line:69,column:3,offset:1741},end:$R[828]={line:69,column:6,offset:1744}},type:"paragraph"},$R[829]={children:$R[830]=[$R[831]={children:$R[832]=[$R[833]={children:$R[834]=[$R[835]={position:$R[836]={start:$R[837]={line:71,column:5,offset:1750},end:$R[838]={line:71,column:15,offset:1760}},type:"inlineCode",value:"molecule"},$R[839]={position:$R[840]={start:$R[841]={line:71,column:15,offset:1760},end:$R[842]={line:71,column:30,offset:1775}},type:"text",value:" は必要になるまで実行されない"}],position:$R[843]={start:$R[844]={line:71,column:5,offset:1750},end:$R[845]={line:71,column:30,offset:1775}},type:"paragraph"}],position:$R[846]={start:$R[847]={line:71,column:3,offset:1748},end:$R[848]={line:71,column:30,offset:1775}},type:"listItem"}],position:$R[849]={start:$R[850]={line:71,column:3,offset:1748},end:$R[851]={line:71,column:30,offset:1775}},type:"unorderedList"}],position:$R[852]={start:$R[853]={line:69,column:1,offset:1739},end:$R[854]={line:71,column:30,offset:1775}},type:"listItem"}],position:$R[855]={start:$R[856]={line:65,column:1,offset:1658},end:$R[857]={line:71,column:30,offset:1775}},type:"unorderedList"}],position:$R[858]={end:$R[859]={line:71,column:30,offset:1775},start:$R[860]={line:37,column:1,offset:1024}},type:"section"},$R[861]={children:$R[862]=[$R[863]={children:$R[864]=[$R[865]={position:$R[866]={start:$R[867]={line:73,column:5,offset:1781},end:$R[868]={line:73,column:10,offset:1786}},type:"text",value:"scope"}],id:"scope",level:3,plain:"scope",position:$R[869]={start:$R[870]={line:73,column:1,offset:1777},end:$R[871]={line:73,column:10,offset:1786}},type:"heading"},$R[872]={children:$R[873]=[$R[874]={position:$R[875]={start:$R[876]={line:75,column:1,offset:1788},end:$R[877]={line:75,column:8,offset:1795}},type:"inlineCode",value:"scope"},$R[878]={position:$R[879]={start:$R[880]={line:75,column:8,offset:1795},end:$R[881]={line:75,column:11,offset:1798}},type:"text",value:" は "},$R[882]={position:$R[883]={start:$R[884]={line:75,column:11,offset:1798},end:$R[885]={line:75,column:21,offset:1808}},type:"inlineCode",value:"molecule"},$R[886]={position:$R[887]={start:$R[888]={line:75,column:21,offset:1808},end:$R[889]={line:75,column:71,offset:1858}},type:"text",value:" を異なるコンポーネントで共通の環境を共有して使うための依存関係のグラフを構築するための概念である。"}],position:$R[890]={start:$R[891]={line:75,column:1,offset:1788},end:$R[892]={line:75,column:71,offset:1858}},type:"paragraph"},$R[893]={children:$R[894]=[$R[895]={position:$R[896]={start:$R[897]={line:77,column:1,offset:1860},end:$R[898]={line:77,column:14,offset:1873}},type:"inlineCode",value:"createScope"},$R[899]={position:$R[900]={start:$R[901]={line:77,column:14,offset:1873},end:$R[902]={line:77,column:22,offset:1881}},type:"text",value:" 関数を使って "},$R[903]={position:$R[904]={start:$R[905]={line:77,column:22,offset:1881},end:$R[906]={line:77,column:29,offset:1888}},type:"inlineCode",value:"scope"},$R[907]={position:$R[908]={start:$R[909]={line:77,column:29,offset:1888},end:$R[910]={line:77,column:36,offset:1895}},type:"text",value:" を作成する。"}],position:$R[911]={start:$R[912]={line:77,column:1,offset:1860},end:$R[913]={line:77,column:36,offset:1895}},type:"paragraph"},$R[914]={filename:"sample.ts ts",lang:"ts",position:$R[915]={start:$R[916]={line:79,column:1,offset:1897},end:$R[917]={line:86,column:4,offset:2054}},type:"code",value:"import { createScope } from \"bunshi\";\n\n/**\n * Scope for a user id\n */\nexport const UserScope = createScope\x3Cstring>(\"alice@example.com\");",hast:$R[918]={type:"root",children:$R[919]=[$R[920]={type:"element",tagName:"pre",properties:$R[921]={class:"shiki vitesse-dark",style:"color: #dbd7cacc;",tabindex:"0"},children:$R[922]=[$R[923]={type:"element",tagName:"code",properties:$R[924]={},children:$R[925]=[$R[926]={type:"element",tagName:"span",properties:$R[927]={class:"line"},children:$R[928]=[$R[929]={type:"element",tagName:"span",properties:$R[930]={style:"color:#4D9375"},children:$R[931]=[$R[932]={type:"text",value:"import"}]},$R[933]={type:"element",tagName:"span",properties:$R[934]={style:"color:#666666"},children:$R[935]=[$R[936]={type:"text",value:" {"}]},$R[937]={type:"element",tagName:"span",properties:$R[938]={style:"color:#BD976A"},children:$R[939]=[$R[940]={type:"text",value:" createScope"}]},$R[941]={type:"element",tagName:"span",properties:$R[942]={style:"color:#666666"},children:$R[943]=[$R[944]={type:"text",value:" }"}]},$R[945]={type:"element",tagName:"span",properties:$R[946]={style:"color:#4D9375"},children:$R[947]=[$R[948]={type:"text",value:" from"}]},$R[949]={type:"element",tagName:"span",properties:$R[950]={style:"color:#C98A7D77"},children:$R[951]=[$R[952]={type:"text",value:" \""}]},$R[953]={type:"element",tagName:"span",properties:$R[954]={style:"color:#C98A7D"},children:$R[955]=[$R[956]={type:"text",value:"bunshi"}]},$R[957]={type:"element",tagName:"span",properties:$R[958]={style:"color:#C98A7D77"},children:$R[959]=[$R[960]={type:"text",value:"\""}]},$R[961]={type:"element",tagName:"span",properties:$R[962]={style:"color:#666666"},children:$R[963]=[$R[964]={type:"text",value:";"}]}]},$R[965]={type:"text",value:"\n"},$R[966]={type:"element",tagName:"span",properties:$R[967]={class:"line"},children:$R[968]=[]},$R[969]={type:"text",value:"\n"},$R[970]={type:"element",tagName:"span",properties:$R[971]={class:"line"},children:$R[972]=[$R[973]={type:"element",tagName:"span",properties:$R[974]={style:"color:#758575DD"},children:$R[975]=[$R[976]={type:"text",value:"/**"}]}]},$R[977]={type:"text",value:"\n"},$R[978]={type:"element",tagName:"span",properties:$R[979]={class:"line"},children:$R[980]=[$R[981]={type:"element",tagName:"span",properties:$R[982]={style:"color:#758575DD"},children:$R[983]=[$R[984]={type:"text",value:" * Scope for a user id"}]}]},$R[985]={type:"text",value:"\n"},$R[986]={type:"element",tagName:"span",properties:$R[987]={class:"line"},children:$R[988]=[$R[989]={type:"element",tagName:"span",properties:$R[990]={style:"color:#758575DD"},children:$R[991]=[$R[992]={type:"text",value:" */"}]}]},$R[993]={type:"text",value:"\n"},$R[994]={type:"element",tagName:"span",properties:$R[995]={class:"line"},children:$R[996]=[$R[997]={type:"element",tagName:"span",properties:$R[998]={style:"color:#4D9375"},children:$R[999]=[$R[1000]={type:"text",value:"export"}]},$R[1001]={type:"element",tagName:"span",properties:$R[1002]={style:"color:#CB7676"},children:$R[1003]=[$R[1004]={type:"text",value:" const "}]},$R[1005]={type:"element",tagName:"span",properties:$R[1006]={style:"color:#BD976A"},children:$R[1007]=[$R[1008]={type:"text",value:"UserScope"}]},$R[1009]={type:"element",tagName:"span",properties:$R[1010]={style:"color:#666666"},children:$R[1011]=[$R[1012]={type:"text",value:" ="}]},$R[1013]={type:"element",tagName:"span",properties:$R[1014]={style:"color:#80A665"},children:$R[1015]=[$R[1016]={type:"text",value:" createScope"}]},$R[1017]={type:"element",tagName:"span",properties:$R[1018]={style:"color:#666666"},children:$R[1019]=[$R[1020]={type:"text",value:"\x3C"}]},$R[1021]={type:"element",tagName:"span",properties:$R[1022]={style:"color:#5DA994"},children:$R[1023]=[$R[1024]={type:"text",value:"string"}]},$R[1025]={type:"element",tagName:"span",properties:$R[1026]={style:"color:#666666"},children:$R[1027]=[$R[1028]={type:"text",value:">("}]},$R[1029]={type:"element",tagName:"span",properties:$R[1030]={style:"color:#C98A7D77"},children:$R[1031]=[$R[1032]={type:"text",value:"\""}]},$R[1033]={type:"element",tagName:"span",properties:$R[1034]={style:"color:#C98A7D"},children:$R[1035]=[$R[1036]={type:"text",value:"alice@example.com"}]},$R[1037]={type:"element",tagName:"span",properties:$R[1038]={style:"color:#C98A7D77"},children:$R[1039]=[$R[1040]={type:"text",value:"\""}]},$R[1041]={type:"element",tagName:"span",properties:$R[1042]={style:"color:#666666"},children:$R[1043]=[$R[1044]={type:"text",value:");"}]}]}]}]}]}},$R[1045]={children:$R[1046]=[$R[1047]={position:$R[1048]={start:$R[1049]={line:88,column:1,offset:2056},end:$R[1050]={line:88,column:6,offset:2061}},type:"text",value:"宣言した "},$R[1051]={position:$R[1052]={start:$R[1053]={line:88,column:6,offset:2061},end:$R[1054]={line:88,column:13,offset:2068}},type:"inlineCode",value:"scope"},$R[1055]={position:$R[1056]={start:$R[1057]={line:88,column:13,offset:2068},end:$R[1058]={line:88,column:47,offset:2102}},type:"text",value:" はフレームワークによって異なる方法でプロバイダーを提供する。私は "},$R[1059]={position:$R[1060]={start:$R[1061]={line:88,column:47,offset:2102},end:$R[1062]={line:88,column:54,offset:2109}},type:"inlineCode",value:"React"},$R[1063]={position:$R[1064]={start:$R[1065]={line:88,column:54,offset:2109},end:$R[1066]={line:88,column:64,offset:2119}},type:"text",value:" を使っているので、"},$R[1067]={position:$R[1068]={start:$R[1069]={line:88,column:64,offset:2119},end:$R[1070]={line:88,column:71,offset:2126}},type:"inlineCode",value:"React"},$R[1071]={position:$R[1072]={start:$R[1073]={line:88,column:71,offset:2126},end:$R[1074]={line:88,column:89,offset:2144}},type:"text",value:" でのプロバイダーの提供方法を示す。"}],position:$R[1075]={start:$R[1076]={line:88,column:1,offset:2056},end:$R[1077]={line:88,column:89,offset:2144}},type:"paragraph"},$R[1078]={filename:"sample.tsx tsx",lang:"tsx",position:$R[1079]={start:$R[1080]={line:90,column:1,offset:2146},end:$R[1081]={line:103,column:4,offset:2438}},type:"code",value:"import { ScopeProvider } from \"bunshi/react\";\nimport type { ReactElement } from \"react\";\n\nimport { UserScope } from \"./scopes\";\n\nexport function App({ children }: Props): ReactElement {\n\treturn (\n\t\t\x3CScopeProvider scope={UserScope}>\n\t\t\t{children}\n\t\t\x3C/ScopeProvider>\n\t);\n}",hast:$R[1082]={type:"root",children:$R[1083]=[$R[1084]={type:"element",tagName:"pre",properties:$R[1085]={class:"shiki vitesse-dark",style:"color: #dbd7cacc;",tabindex:"0"},children:$R[1086]=[$R[1087]={type:"element",tagName:"code",properties:$R[1088]={},children:$R[1089]=[$R[1090]={type:"element",tagName:"span",properties:$R[1091]={class:"line"},children:$R[1092]=[$R[1093]={type:"element",tagName:"span",properties:$R[1094]={style:"color:#4D9375"},children:$R[1095]=[$R[1096]={type:"text",value:"import"}]},$R[1097]={type:"element",tagName:"span",properties:$R[1098]={style:"color:#666666"},children:$R[1099]=[$R[1100]={type:"text",value:" {"}]},$R[1101]={type:"element",tagName:"span",properties:$R[1102]={style:"color:#BD976A"},children:$R[1103]=[$R[1104]={type:"text",value:" ScopeProvider"}]},$R[1105]={type:"element",tagName:"span",properties:$R[1106]={style:"color:#666666"},children:$R[1107]=[$R[1108]={type:"text",value:" }"}]},$R[1109]={type:"element",tagName:"span",properties:$R[1110]={style:"color:#4D9375"},children:$R[1111]=[$R[1112]={type:"text",value:" from"}]},$R[1113]={type:"element",tagName:"span",properties:$R[1114]={style:"color:#C98A7D77"},children:$R[1115]=[$R[1116]={type:"text",value:" \""}]},$R[1117]={type:"element",tagName:"span",properties:$R[1118]={style:"color:#C98A7D"},children:$R[1119]=[$R[1120]={type:"text",value:"bunshi/react"}]},$R[1121]={type:"element",tagName:"span",properties:$R[1122]={style:"color:#C98A7D77"},children:$R[1123]=[$R[1124]={type:"text",value:"\""}]},$R[1125]={type:"element",tagName:"span",properties:$R[1126]={style:"color:#666666"},children:$R[1127]=[$R[1128]={type:"text",value:";"}]}]},$R[1129]={type:"text",value:"\n"},$R[1130]={type:"element",tagName:"span",properties:$R[1131]={class:"line"},children:$R[1132]=[$R[1133]={type:"element",tagName:"span",properties:$R[1134]={style:"color:#4D9375"},children:$R[1135]=[$R[1136]={type:"text",value:"import"}]},$R[1137]={type:"element",tagName:"span",properties:$R[1138]={style:"color:#4D9375"},children:$R[1139]=[$R[1140]={type:"text",value:" type"}]},$R[1141]={type:"element",tagName:"span",properties:$R[1142]={style:"color:#666666"},children:$R[1143]=[$R[1144]={type:"text",value:" {"}]},$R[1145]={type:"element",tagName:"span",properties:$R[1146]={style:"color:#BD976A"},children:$R[1147]=[$R[1148]={type:"text",value:" ReactElement"}]},$R[1149]={type:"element",tagName:"span",properties:$R[1150]={style:"color:#666666"},children:$R[1151]=[$R[1152]={type:"text",value:" }"}]},$R[1153]={type:"element",tagName:"span",properties:$R[1154]={style:"color:#4D9375"},children:$R[1155]=[$R[1156]={type:"text",value:" from"}]},$R[1157]={type:"element",tagName:"span",properties:$R[1158]={style:"color:#C98A7D77"},children:$R[1159]=[$R[1160]={type:"text",value:" \""}]},$R[1161]={type:"element",tagName:"span",properties:$R[1162]={style:"color:#C98A7D"},children:$R[1163]=[$R[1164]={type:"text",value:"react"}]},$R[1165]={type:"element",tagName:"span",properties:$R[1166]={style:"color:#C98A7D77"},children:$R[1167]=[$R[1168]={type:"text",value:"\""}]},$R[1169]={type:"element",tagName:"span",properties:$R[1170]={style:"color:#666666"},children:$R[1171]=[$R[1172]={type:"text",value:";"}]}]},$R[1173]={type:"text",value:"\n"},$R[1174]={type:"element",tagName:"span",properties:$R[1175]={class:"line"},children:$R[1176]=[]},$R[1177]={type:"text",value:"\n"},$R[1178]={type:"element",tagName:"span",properties:$R[1179]={class:"line"},children:$R[1180]=[$R[1181]={type:"element",tagName:"span",properties:$R[1182]={style:"color:#4D9375"},children:$R[1183]=[$R[1184]={type:"text",value:"import"}]},$R[1185]={type:"element",tagName:"span",properties:$R[1186]={style:"color:#666666"},children:$R[1187]=[$R[1188]={type:"text",value:" {"}]},$R[1189]={type:"element",tagName:"span",properties:$R[1190]={style:"color:#BD976A"},children:$R[1191]=[$R[1192]={type:"text",value:" UserScope"}]},$R[1193]={type:"element",tagName:"span",properties:$R[1194]={style:"color:#666666"},children:$R[1195]=[$R[1196]={type:"text",value:" }"}]},$R[1197]={type:"element",tagName:"span",properties:$R[1198]={style:"color:#4D9375"},children:$R[1199]=[$R[1200]={type:"text",value:" from"}]},$R[1201]={type:"element",tagName:"span",properties:$R[1202]={style:"color:#C98A7D77"},children:$R[1203]=[$R[1204]={type:"text",value:" \""}]},$R[1205]={type:"element",tagName:"span",properties:$R[1206]={style:"color:#C98A7D"},children:$R[1207]=[$R[1208]={type:"text",value:"./scopes"}]},$R[1209]={type:"element",tagName:"span",properties:$R[1210]={style:"color:#C98A7D77"},children:$R[1211]=[$R[1212]={type:"text",value:"\""}]},$R[1213]={type:"element",tagName:"span",properties:$R[1214]={style:"color:#666666"},children:$R[1215]=[$R[1216]={type:"text",value:";"}]}]},$R[1217]={type:"text",value:"\n"},$R[1218]={type:"element",tagName:"span",properties:$R[1219]={class:"line"},children:$R[1220]=[]},$R[1221]={type:"text",value:"\n"},$R[1222]={type:"element",tagName:"span",properties:$R[1223]={class:"line"},children:$R[1224]=[$R[1225]={type:"element",tagName:"span",properties:$R[1226]={style:"color:#4D9375"},children:$R[1227]=[$R[1228]={type:"text",value:"export"}]},$R[1229]={type:"element",tagName:"span",properties:$R[1230]={style:"color:#CB7676"},children:$R[1231]=[$R[1232]={type:"text",value:" function"}]},$R[1233]={type:"element",tagName:"span",properties:$R[1234]={style:"color:#80A665"},children:$R[1235]=[$R[1236]={type:"text",value:" App"}]},$R[1237]={type:"element",tagName:"span",properties:$R[1238]={style:"color:#666666"},children:$R[1239]=[$R[1240]={type:"text",value:"({"}]},$R[1241]={type:"element",tagName:"span",properties:$R[1242]={style:"color:#BD976A"},children:$R[1243]=[$R[1244]={type:"text",value:" children"}]},$R[1245]={type:"element",tagName:"span",properties:$R[1246]={style:"color:#666666"},children:$R[1247]=[$R[1248]={type:"text",value:" }: "}]},$R[1249]={type:"element",tagName:"span",properties:$R[1250]={style:"color:#5DA994"},children:$R[1251]=[$R[1252]={type:"text",value:"Props"}]},$R[1253]={type:"element",tagName:"span",properties:$R[1254]={style:"color:#666666"},children:$R[1255]=[$R[1256]={type:"text",value:"):"}]},$R[1257]={type:"element",tagName:"span",properties:$R[1258]={style:"color:#5DA994"},children:$R[1259]=[$R[1260]={type:"text",value:" ReactElement"}]},$R[1261]={type:"element",tagName:"span",properties:$R[1262]={style:"color:#666666"},children:$R[1263]=[$R[1264]={type:"text",value:" {"}]}]},$R[1265]={type:"text",value:"\n"},$R[1266]={type:"element",tagName:"span",properties:$R[1267]={class:"line"},children:$R[1268]=[$R[1269]={type:"element",tagName:"span",properties:$R[1270]={style:"color:#4D9375"},children:$R[1271]=[$R[1272]={type:"text",value:"\treturn"}]},$R[1273]={type:"element",tagName:"span",properties:$R[1274]={style:"color:#666666"},children:$R[1275]=[$R[1276]={type:"text",value:" ("}]}]},$R[1277]={type:"text",value:"\n"},$R[1278]={type:"element",tagName:"span",properties:$R[1279]={class:"line"},children:$R[1280]=[$R[1281]={type:"element",tagName:"span",properties:$R[1282]={style:"color:#666666"},children:$R[1283]=[$R[1284]={type:"text",value:"\t\t\x3C"}]},$R[1285]={type:"element",tagName:"span",properties:$R[1286]={style:"color:#B8A965"},children:$R[1287]=[$R[1288]={type:"text",value:"ScopeProvider"}]},$R[1289]={type:"element",tagName:"span",properties:$R[1290]={style:"color:#BD976A"},children:$R[1291]=[$R[1292]={type:"text",value:" scope"}]},$R[1293]={type:"element",tagName:"span",properties:$R[1294]={style:"color:#666666"},children:$R[1295]=[$R[1296]={type:"text",value:"={"}]},$R[1297]={type:"element",tagName:"span",properties:$R[1298]={style:"color:#BD976A"},children:$R[1299]=[$R[1300]={type:"text",value:"UserScope"}]},$R[1301]={type:"element",tagName:"span",properties:$R[1302]={style:"color:#666666"},children:$R[1303]=[$R[1304]={type:"text",value:"}>"}]}]},$R[1305]={type:"text",value:"\n"},$R[1306]={type:"element",tagName:"span",properties:$R[1307]={class:"line"},children:$R[1308]=[$R[1309]={type:"element",tagName:"span",properties:$R[1310]={style:"color:#666666"},children:$R[1311]=[$R[1312]={type:"text",value:"\t\t\t{"}]},$R[1313]={type:"element",tagName:"span",properties:$R[1314]={style:"color:#BD976A"},children:$R[1315]=[$R[1316]={type:"text",value:"children"}]},$R[1317]={type:"element",tagName:"span",properties:$R[1318]={style:"color:#666666"},children:$R[1319]=[$R[1320]={type:"text",value:"}"}]}]},$R[1321]={type:"text",value:"\n"},$R[1322]={type:"element",tagName:"span",properties:$R[1323]={class:"line"},children:$R[1324]=[$R[1325]={type:"element",tagName:"span",properties:$R[1326]={style:"color:#666666"},children:$R[1327]=[$R[1328]={type:"text",value:"\t\t\x3C/"}]},$R[1329]={type:"element",tagName:"span",properties:$R[1330]={style:"color:#B8A965"},children:$R[1331]=[$R[1332]={type:"text",value:"ScopeProvider"}]},$R[1333]={type:"element",tagName:"span",properties:$R[1334]={style:"color:#666666"},children:$R[1335]=[$R[1336]={type:"text",value:">"}]}]},$R[1337]={type:"text",value:"\n"},$R[1338]={type:"element",tagName:"span",properties:$R[1339]={class:"line"},children:$R[1340]=[$R[1341]={type:"element",tagName:"span",properties:$R[1342]={style:"color:#666666"},children:$R[1343]=[$R[1344]={type:"text",value:"\t);"}]}]},$R[1345]={type:"text",value:"\n"},$R[1346]={type:"element",tagName:"span",properties:$R[1347]={class:"line"},children:$R[1348]=[$R[1349]={type:"element",tagName:"span",properties:$R[1350]={style:"color:#666666"},children:$R[1351]=[$R[1352]={type:"text",value:"}"}]}]}]}]}]}},$R[1353]={children:$R[1354]=[$R[1355]={position:$R[1356]={start:$R[1357]={line:105,column:1,offset:2440},end:$R[1358]={line:105,column:8,offset:2447}},type:"inlineCode",value:"scope"},$R[1359]={position:$R[1360]={start:$R[1361]={line:105,column:8,offset:2447},end:$R[1362]={line:105,column:14,offset:2453}},type:"text",value:" の真価は、"},$R[1363]={position:$R[1364]={start:$R[1365]={line:105,column:14,offset:2453},end:$R[1366]={line:105,column:24,offset:2463}},type:"inlineCode",value:"molecule"},$R[1367]={position:$R[1368]={start:$R[1369]={line:105,column:24,offset:2463},end:$R[1370]={line:105,column:27,offset:2466}},type:"text",value:" を "},$R[1371]={position:$R[1372]={start:$R[1373]={line:105,column:27,offset:2466},end:$R[1374]={line:105,column:34,offset:2473}},type:"inlineCode",value:"scope"},$R[1375]={position:$R[1376]={start:$R[1377]={line:105,column:34,offset:2473},end:$R[1378]={line:105,column:49,offset:2488}},type:"text",value:" に依存させることで発揮する。"}],position:$R[1379]={start:$R[1380]={line:105,column:1,offset:2440},end:$R[1381]={line:105,column:49,offset:2488}},type:"paragraph"},$R[1382]={filename:"sample.ts ts",lang:"ts",position:$R[1383]={start:$R[1384]={line:107,column:1,offset:2490},end:$R[1385]={line:114,column:4,offset:2682}},type:"code",value:"import { molecule } from \"bunshi\";\nimport { UserScope } from \"./scopes\";\n\nexport const UsernameMolecule = molecule(\n\t(_mol, scope) => `You are user ${scope(UserScope)}`,\n);",hast:$R[1386]={type:"root",children:$R[1387]=[$R[1388]={type:"element",tagName:"pre",properties:$R[1389]={class:"shiki vitesse-dark",style:"color: #dbd7cacc;",tabindex:"0"},children:$R[1390]=[$R[1391]={type:"element",tagName:"code",properties:$R[1392]={},children:$R[1393]=[$R[1394]={type:"element",tagName:"span",properties:$R[1395]={class:"line"},children:$R[1396]=[$R[1397]={type:"element",tagName:"span",properties:$R[1398]={style:"color:#4D9375"},children:$R[1399]=[$R[1400]={type:"text",value:"import"}]},$R[1401]={type:"element",tagName:"span",properties:$R[1402]={style:"color:#666666"},children:$R[1403]=[$R[1404]={type:"text",value:" {"}]},$R[1405]={type:"element",tagName:"span",properties:$R[1406]={style:"color:#BD976A"},children:$R[1407]=[$R[1408]={type:"text",value:" molecule"}]},$R[1409]={type:"element",tagName:"span",properties:$R[1410]={style:"color:#666666"},children:$R[1411]=[$R[1412]={type:"text",value:" }"}]},$R[1413]={type:"element",tagName:"span",properties:$R[1414]={style:"color:#4D9375"},children:$R[1415]=[$R[1416]={type:"text",value:" from"}]},$R[1417]={type:"element",tagName:"span",properties:$R[1418]={style:"color:#C98A7D77"},children:$R[1419]=[$R[1420]={type:"text",value:" \""}]},$R[1421]={type:"element",tagName:"span",properties:$R[1422]={style:"color:#C98A7D"},children:$R[1423]=[$R[1424]={type:"text",value:"bunshi"}]},$R[1425]={type:"element",tagName:"span",properties:$R[1426]={style:"color:#C98A7D77"},children:$R[1427]=[$R[1428]={type:"text",value:"\""}]},$R[1429]={type:"element",tagName:"span",properties:$R[1430]={style:"color:#666666"},children:$R[1431]=[$R[1432]={type:"text",value:";"}]}]},$R[1433]={type:"text",value:"\n"},$R[1434]={type:"element",tagName:"span",properties:$R[1435]={class:"line"},children:$R[1436]=[$R[1437]={type:"element",tagName:"span",properties:$R[1438]={style:"color:#4D9375"},children:$R[1439]=[$R[1440]={type:"text",value:"import"}]},$R[1441]={type:"element",tagName:"span",properties:$R[1442]={style:"color:#666666"},children:$R[1443]=[$R[1444]={type:"text",value:" {"}]},$R[1445]={type:"element",tagName:"span",properties:$R[1446]={style:"color:#BD976A"},children:$R[1447]=[$R[1448]={type:"text",value:" UserScope"}]},$R[1449]={type:"element",tagName:"span",properties:$R[1450]={style:"color:#666666"},children:$R[1451]=[$R[1452]={type:"text",value:" }"}]},$R[1453]={type:"element",tagName:"span",properties:$R[1454]={style:"color:#4D9375"},children:$R[1455]=[$R[1456]={type:"text",value:" from"}]},$R[1457]={type:"element",tagName:"span",properties:$R[1458]={style:"color:#C98A7D77"},children:$R[1459]=[$R[1460]={type:"text",value:" \""}]},$R[1461]={type:"element",tagName:"span",properties:$R[1462]={style:"color:#C98A7D"},children:$R[1463]=[$R[1464]={type:"text",value:"./scopes"}]},$R[1465]={type:"element",tagName:"span",properties:$R[1466]={style:"color:#C98A7D77"},children:$R[1467]=[$R[1468]={type:"text",value:"\""}]},$R[1469]={type:"element",tagName:"span",properties:$R[1470]={style:"color:#666666"},children:$R[1471]=[$R[1472]={type:"text",value:";"}]}]},$R[1473]={type:"text",value:"\n"},$R[1474]={type:"element",tagName:"span",properties:$R[1475]={class:"line"},children:$R[1476]=[]},$R[1477]={type:"text",value:"\n"},$R[1478]={type:"element",tagName:"span",properties:$R[1479]={class:"line"},children:$R[1480]=[$R[1481]={type:"element",tagName:"span",properties:$R[1482]={style:"color:#4D9375"},children:$R[1483]=[$R[1484]={type:"text",value:"export"}]},$R[1485]={type:"element",tagName:"span",properties:$R[1486]={style:"color:#CB7676"},children:$R[1487]=[$R[1488]={type:"text",value:" const "}]},$R[1489]={type:"element",tagName:"span",properties:$R[1490]={style:"color:#BD976A"},children:$R[1491]=[$R[1492]={type:"text",value:"UsernameMolecule"}]},$R[1493]={type:"element",tagName:"span",properties:$R[1494]={style:"color:#666666"},children:$R[1495]=[$R[1496]={type:"text",value:" ="}]},$R[1497]={type:"element",tagName:"span",properties:$R[1498]={style:"color:#80A665"},children:$R[1499]=[$R[1500]={type:"text",value:" molecule"}]},$R[1501]={type:"element",tagName:"span",properties:$R[1502]={style:"color:#666666"},children:$R[1503]=[$R[1504]={type:"text",value:"("}]}]},$R[1505]={type:"text",value:"\n"},$R[1506]={type:"element",tagName:"span",properties:$R[1507]={class:"line"},children:$R[1508]=[$R[1509]={type:"element",tagName:"span",properties:$R[1510]={style:"color:#666666"},children:$R[1511]=[$R[1512]={type:"text",value:"\t("}]},$R[1513]={type:"element",tagName:"span",properties:$R[1514]={style:"color:#BD976A"},children:$R[1515]=[$R[1516]={type:"text",value:"_mol"}]},$R[1517]={type:"element",tagName:"span",properties:$R[1518]={style:"color:#666666"},children:$R[1519]=[$R[1520]={type:"text",value:","}]},$R[1521]={type:"element",tagName:"span",properties:$R[1522]={style:"color:#BD976A"},children:$R[1523]=[$R[1524]={type:"text",value:" scope"}]},$R[1525]={type:"element",tagName:"span",properties:$R[1526]={style:"color:#666666"},children:$R[1527]=[$R[1528]={type:"text",value:")"}]},$R[1529]={type:"element",tagName:"span",properties:$R[1530]={style:"color:#666666"},children:$R[1531]=[$R[1532]={type:"text",value:" =>"}]},$R[1533]={type:"element",tagName:"span",properties:$R[1534]={style:"color:#C98A7D77"},children:$R[1535]=[$R[1536]={type:"text",value:" `"}]},$R[1537]={type:"element",tagName:"span",properties:$R[1538]={style:"color:#C98A7D"},children:$R[1539]=[$R[1540]={type:"text",value:"You are user "}]},$R[1541]={type:"element",tagName:"span",properties:$R[1542]={style:"color:#4D9375"},children:$R[1543]=[$R[1544]={type:"text",value:"${"}]},$R[1545]={type:"element",tagName:"span",properties:$R[1546]={style:"color:#80A665"},children:$R[1547]=[$R[1548]={type:"text",value:"scope"}]},$R[1549]={type:"element",tagName:"span",properties:$R[1550]={style:"color:#666666"},children:$R[1551]=[$R[1552]={type:"text",value:"("}]},$R[1553]={type:"element",tagName:"span",properties:$R[1554]={style:"color:#C98A7D"},children:$R[1555]=[$R[1556]={type:"text",value:"UserScope"}]},$R[1557]={type:"element",tagName:"span",properties:$R[1558]={style:"color:#666666"},children:$R[1559]=[$R[1560]={type:"text",value:")"}]},$R[1561]={type:"element",tagName:"span",properties:$R[1562]={style:"color:#4D9375"},children:$R[1563]=[$R[1564]={type:"text",value:"}"}]},$R[1565]={type:"element",tagName:"span",properties:$R[1566]={style:"color:#C98A7D77"},children:$R[1567]=[$R[1568]={type:"text",value:"`"}]},$R[1569]={type:"element",tagName:"span",properties:$R[1570]={style:"color:#666666"},children:$R[1571]=[$R[1572]={type:"text",value:","}]}]},$R[1573]={type:"text",value:"\n"},$R[1574]={type:"element",tagName:"span",properties:$R[1575]={class:"line"},children:$R[1576]=[$R[1577]={type:"element",tagName:"span",properties:$R[1578]={style:"color:#666666"},children:$R[1579]=[$R[1580]={type:"text",value:");"}]}]}]}]}]}},$R[1581]={children:$R[1582]=[$R[1583]={position:$R[1584]={start:$R[1585]={line:116,column:1,offset:2684},end:$R[1586]={line:116,column:8,offset:2691}},type:"inlineCode",value:"scope"},$R[1587]={position:$R[1588]={start:$R[1589]={line:116,column:8,offset:2691},end:$R[1590]={line:116,column:11,offset:2694}},type:"text",value:" を "},$R[1591]={position:$R[1592]={start:$R[1593]={line:116,column:11,offset:2694},end:$R[1594]={line:116,column:21,offset:2704}},type:"inlineCode",value:"molecule"},$R[1595]={position:$R[1596]={start:$R[1597]={line:116,column:21,offset:2704},end:$R[1598]={line:116,column:32,offset:2715}},type:"text",value:" に依存させることで "},$R[1599]={position:$R[1600]={start:$R[1601]={line:116,column:32,offset:2715},end:$R[1602]={line:116,column:42,offset:2725}},type:"inlineCode",value:"molecule"},$R[1603]={position:$R[1604]={start:$R[1605]={line:116,column:42,offset:2725},end:$R[1606]={line:116,column:70,offset:2753}},type:"text",value:" はアプリケーション全体で 1 回実行されるのではなく、"},$R[1607]={position:$R[1608]={start:$R[1609]={line:116,column:70,offset:2753},end:$R[1610]={line:116,column:77,offset:2760}},type:"inlineCode",value:"scope"},$R[1611]={position:$R[1612]={start:$R[1613]={line:116,column:77,offset:2760},end:$R[1614]={line:116,column:98,offset:2781}},type:"text",value:" をマウントするごとに再実行される。また、"},$R[1615]={position:$R[1616]={start:$R[1617]={line:116,column:98,offset:2781},end:$R[1618]={line:116,column:105,offset:2788}},type:"inlineCode",value:"scope"},$R[1619]={position:$R[1620]={start:$R[1621]={line:116,column:105,offset:2788},end:$R[1622]={line:116,column:113,offset:2796}},type:"text",value:" に渡した値は "},$R[1623]={position:$R[1624]={start:$R[1625]={line:116,column:113,offset:2796},end:$R[1626]={line:116,column:120,offset:2803}},type:"inlineCode",value:"scope"},$R[1627]={position:$R[1628]={start:$R[1629]={line:116,column:120,offset:2803},end:$R[1630]={line:116,column:131,offset:2814}},type:"text",value:" プロバイダー内部の "},$R[1631]={position:$R[1632]={start:$R[1633]={line:116,column:131,offset:2814},end:$R[1634]={line:116,column:141,offset:2824}},type:"inlineCode",value:"molecule"},$R[1635]={position:$R[1636]={start:$R[1637]={line:116,column:141,offset:2824},end:$R[1638]={line:116,column:145,offset:2828}},type:"text",value:" から "},$R[1639]={position:$R[1640]={start:$R[1641]={line:116,column:145,offset:2828},end:$R[1642]={line:116,column:154,offset:2837}},type:"inlineCode",value:"scope()"},$R[1643]={position:$R[1644]={start:$R[1645]={line:116,column:154,offset:2837},end:$R[1646]={line:116,column:167,offset:2850}},type:"text",value:" 関数を通じて取得できる。"}],position:$R[1647]={start:$R[1648]={line:116,column:1,offset:2684},end:$R[1649]={line:116,column:167,offset:2850}},type:"paragraph"}],position:$R[1650]={end:$R[1651]={line:116,column:167,offset:2850},start:$R[1652]={line:73,column:1,offset:1777}},type:"section"},$R[1653]={children:$R[1654]=[$R[1655]={children:$R[1656]=[$R[1657]={position:$R[1658]={start:$R[1659]={line:118,column:5,offset:2856},end:$R[1660]={line:118,column:14,offset:2865}},type:"text",value:"lifecycle"}],id:"lifecycle",level:3,plain:"lifecycle",position:$R[1661]={start:$R[1662]={line:118,column:1,offset:2852},end:$R[1663]={line:118,column:14,offset:2865}},type:"heading"},$R[1664]={children:$R[1665]=[$R[1666]={position:$R[1667]={start:$R[1668]={line:120,column:1,offset:2867},end:$R[1669]={line:120,column:11,offset:2877}},type:"inlineCode",value:"molecule"},$R[1670]={position:$R[1671]={start:$R[1672]={line:120,column:11,offset:2877},end:$R[1673]={line:120,column:85,offset:2951}},type:"text",value:" はアプリケーションやスコープに応じて必要なときに実行され使用中であることを示すためマウントされ、必要でなくなったらアンマウントされ GC される。"}],position:$R[1674]={start:$R[1675]={line:120,column:1,offset:2867},end:$R[1676]={line:120,column:85,offset:2951}},type:"paragraph"},$R[1677]={children:$R[1678]=[$R[1679]={position:$R[1680]={start:$R[1681]={line:122,column:1,offset:2953},end:$R[1682]={line:122,column:7,offset:2959}},type:"text",value:"以下の図は "},$R[1683]={children:$R[1684]=[$R[1685]={position:$R[1686]={start:$R[1687]={line:122,column:8,offset:2960},end:$R[1688]={line:122,column:17,offset:2969}},type:"text",value:"公式のドキュメント"}],position:$R[1689]={start:$R[1690]={line:122,column:7,offset:2959},end:$R[1691]={line:122,column:62,offset:3014}},title:void 0,type:"link",url:"https://www.bunshi.org/concepts/lifecycle/"},$R[1692]={position:$R[1693]={start:$R[1694]={line:122,column:62,offset:3014},end:$R[1695]={line:122,column:85,offset:3037}},type:"text",value:" から引用したものである。とてもわかりやすい。"}],position:$R[1696]={start:$R[1697]={line:122,column:1,offset:2953},end:$R[1698]={line:122,column:85,offset:3037}},type:"paragraph"},$R[1699]={children:$R[1700]=[$R[1701]={alt:"bunshiのライフサイクル",position:$R[1702]={start:$R[1703]={line:124,column:1,offset:3039},end:$R[1704]={line:124,column:35,offset:3073}},title:void 0,type:"image",url:"./lifecycle.png",transformed:$R[1705]=[$R[1706]={dim:$R[1707]={h:1800,w:1390},path:"/img/lifecycle-YaSDHDzK-1390x1800.webp"},$R[1708]={dim:$R[1709]={h:1260,w:973},path:"/img/lifecycle-YaSDHDzK-973x1260.webp"},$R[1710]={dim:$R[1711]={h:882,w:681},path:"/img/lifecycle-YaSDHDzK-681x882.webp"},$R[1712]={dim:$R[1713]={h:617,w:477},path:"/img/lifecycle-YaSDHDzK-477x617.webp"},$R[1714]={dim:$R[1715]={h:432,w:334},path:"/img/lifecycle-YaSDHDzK-334x432.webp"}]}],position:$R[1716]={start:$R[1717]={line:124,column:1,offset:3039},end:$R[1718]={line:124,column:35,offset:3073}},type:"paragraph"},$R[1719]={children:$R[1720]=[$R[1721]={position:$R[1722]={start:$R[1723]={line:126,column:1,offset:3075},end:$R[1724]={line:126,column:9,offset:3083}},type:"text",value:"次の例のように "},$R[1725]={position:$R[1726]={start:$R[1727]={line:126,column:9,offset:3083},end:$R[1728]={line:126,column:18,offset:3092}},type:"inlineCode",value:"onMount"},$R[1729]={position:$R[1730]={start:$R[1731]={line:126,column:18,offset:3092},end:$R[1732]={line:126,column:40,offset:3114}},type:"text",value:" 関数とその cleanup 関数を使って "},$R[1733]={position:$R[1734]={start:$R[1735]={line:126,column:40,offset:3114},end:$R[1736]={line:126,column:50,offset:3124}},type:"inlineCode",value:"molecule"},$R[1737]={position:$R[1738]={start:$R[1739]={line:126,column:50,offset:3124},end:$R[1740]={line:126,column:77,offset:3151}},type:"text",value:" のマウントとアンマウント時の処理を行うことができる。"}],position:$R[1741]={start:$R[1742]={line:126,column:1,offset:3075},end:$R[1743]={line:126,column:77,offset:3151}},type:"paragraph"},$R[1744]={filename:"sample.ts ts",lang:"ts",position:$R[1745]={start:$R[1746]={line:128,column:1,offset:3153},end:$R[1747]={line:140,column:4,offset:3436}},type:"code",value:"import { molecule, onMount } from \"bunshi\";\nimport { atom } from \"jotai/vanilla\";\n\nexport const CountMolecule = molecule(() => {\n\tconsole.log(\"Created\");\n\tonMount(() => {\n\t\tconsole.log(\"Mounted\");\n\t\treturn () => console.log(\"Unmounted\");\n\t});\n\treturn atom(0);\n});",hast:$R[1748]={type:"root",children:$R[1749]=[$R[1750]={type:"element",tagName:"pre",properties:$R[1751]={class:"shiki vitesse-dark",style:"color: #dbd7cacc;",tabindex:"0"},children:$R[1752]=[$R[1753]={type:"element",tagName:"code",properties:$R[1754]={},children:$R[1755]=[$R[1756]={type:"element",tagName:"span",properties:$R[1757]={class:"line"},children:$R[1758]=[$R[1759]={type:"element",tagName:"span",properties:$R[1760]={style:"color:#4D9375"},children:$R[1761]=[$R[1762]={type:"text",value:"import"}]},$R[1763]={type:"element",tagName:"span",properties:$R[1764]={style:"color:#666666"},children:$R[1765]=[$R[1766]={type:"text",value:" {"}]},$R[1767]={type:"element",tagName:"span",properties:$R[1768]={style:"color:#BD976A"},children:$R[1769]=[$R[1770]={type:"text",value:" molecule"}]},$R[1771]={type:"element",tagName:"span",properties:$R[1772]={style:"color:#666666"},children:$R[1773]=[$R[1774]={type:"text",value:","}]},$R[1775]={type:"element",tagName:"span",properties:$R[1776]={style:"color:#BD976A"},children:$R[1777]=[$R[1778]={type:"text",value:" onMount"}]},$R[1779]={type:"element",tagName:"span",properties:$R[1780]={style:"color:#666666"},children:$R[1781]=[$R[1782]={type:"text",value:" }"}]},$R[1783]={type:"element",tagName:"span",properties:$R[1784]={style:"color:#4D9375"},children:$R[1785]=[$R[1786]={type:"text",value:" from"}]},$R[1787]={type:"element",tagName:"span",properties:$R[1788]={style:"color:#C98A7D77"},children:$R[1789]=[$R[1790]={type:"text",value:" \""}]},$R[1791]={type:"element",tagName:"span",properties:$R[1792]={style:"color:#C98A7D"},children:$R[1793]=[$R[1794]={type:"text",value:"bunshi"}]},$R[1795]={type:"element",tagName:"span",properties:$R[1796]={style:"color:#C98A7D77"},children:$R[1797]=[$R[1798]={type:"text",value:"\""}]},$R[1799]={type:"element",tagName:"span",properties:$R[1800]={style:"color:#666666"},children:$R[1801]=[$R[1802]={type:"text",value:";"}]}]},$R[1803]={type:"text",value:"\n"},$R[1804]={type:"element",tagName:"span",properties:$R[1805]={class:"line"},children:$R[1806]=[$R[1807]={type:"element",tagName:"span",properties:$R[1808]={style:"color:#4D9375"},children:$R[1809]=[$R[1810]={type:"text",value:"import"}]},$R[1811]={type:"element",tagName:"span",properties:$R[1812]={style:"color:#666666"},children:$R[1813]=[$R[1814]={type:"text",value:" {"}]},$R[1815]={type:"element",tagName:"span",properties:$R[1816]={style:"color:#BD976A"},children:$R[1817]=[$R[1818]={type:"text",value:" atom"}]},$R[1819]={type:"element",tagName:"span",properties:$R[1820]={style:"color:#666666"},children:$R[1821]=[$R[1822]={type:"text",value:" }"}]},$R[1823]={type:"element",tagName:"span",properties:$R[1824]={style:"color:#4D9375"},children:$R[1825]=[$R[1826]={type:"text",value:" from"}]},$R[1827]={type:"element",tagName:"span",properties:$R[1828]={style:"color:#C98A7D77"},children:$R[1829]=[$R[1830]={type:"text",value:" \""}]},$R[1831]={type:"element",tagName:"span",properties:$R[1832]={style:"color:#C98A7D"},children:$R[1833]=[$R[1834]={type:"text",value:"jotai/vanilla"}]},$R[1835]={type:"element",tagName:"span",properties:$R[1836]={style:"color:#C98A7D77"},children:$R[1837]=[$R[1838]={type:"text",value:"\""}]},$R[1839]={type:"element",tagName:"span",properties:$R[1840]={style:"color:#666666"},children:$R[1841]=[$R[1842]={type:"text",value:";"}]}]},$R[1843]={type:"text",value:"\n"},$R[1844]={type:"element",tagName:"span",properties:$R[1845]={class:"line"},children:$R[1846]=[]},$R[1847]={type:"text",value:"\n"},$R[1848]={type:"element",tagName:"span",properties:$R[1849]={class:"line"},children:$R[1850]=[$R[1851]={type:"element",tagName:"span",properties:$R[1852]={style:"color:#4D9375"},children:$R[1853]=[$R[1854]={type:"text",value:"export"}]},$R[1855]={type:"element",tagName:"span",properties:$R[1856]={style:"color:#CB7676"},children:$R[1857]=[$R[1858]={type:"text",value:" const "}]},$R[1859]={type:"element",tagName:"span",properties:$R[1860]={style:"color:#BD976A"},children:$R[1861]=[$R[1862]={type:"text",value:"CountMolecule"}]},$R[1863]={type:"element",tagName:"span",properties:$R[1864]={style:"color:#666666"},children:$R[1865]=[$R[1866]={type:"text",value:" ="}]},$R[1867]={type:"element",tagName:"span",properties:$R[1868]={style:"color:#80A665"},children:$R[1869]=[$R[1870]={type:"text",value:" molecule"}]},$R[1871]={type:"element",tagName:"span",properties:$R[1872]={style:"color:#666666"},children:$R[1873]=[$R[1874]={type:"text",value:"(()"}]},$R[1875]={type:"element",tagName:"span",properties:$R[1876]={style:"color:#666666"},children:$R[1877]=[$R[1878]={type:"text",value:" =>"}]},$R[1879]={type:"element",tagName:"span",properties:$R[1880]={style:"color:#666666"},children:$R[1881]=[$R[1882]={type:"text",value:" {"}]}]},$R[1883]={type:"text",value:"\n"},$R[1884]={type:"element",tagName:"span",properties:$R[1885]={class:"line"},children:$R[1886]=[$R[1887]={type:"element",tagName:"span",properties:$R[1888]={style:"color:#BD976A"},children:$R[1889]=[$R[1890]={type:"text",value:"\tconsole"}]},$R[1891]={type:"element",tagName:"span",properties:$R[1892]={style:"color:#666666"},children:$R[1893]=[$R[1894]={type:"text",value:"."}]},$R[1895]={type:"element",tagName:"span",properties:$R[1896]={style:"color:#80A665"},children:$R[1897]=[$R[1898]={type:"text",value:"log"}]},$R[1899]={type:"element",tagName:"span",properties:$R[1900]={style:"color:#666666"},children:$R[1901]=[$R[1902]={type:"text",value:"("}]},$R[1903]={type:"element",tagName:"span",properties:$R[1904]={style:"color:#C98A7D77"},children:$R[1905]=[$R[1906]={type:"text",value:"\""}]},$R[1907]={type:"element",tagName:"span",properties:$R[1908]={style:"color:#C98A7D"},children:$R[1909]=[$R[1910]={type:"text",value:"Created"}]},$R[1911]={type:"element",tagName:"span",properties:$R[1912]={style:"color:#C98A7D77"},children:$R[1913]=[$R[1914]={type:"text",value:"\""}]},$R[1915]={type:"element",tagName:"span",properties:$R[1916]={style:"color:#666666"},children:$R[1917]=[$R[1918]={type:"text",value:");"}]}]},$R[1919]={type:"text",value:"\n"},$R[1920]={type:"element",tagName:"span",properties:$R[1921]={class:"line"},children:$R[1922]=[$R[1923]={type:"element",tagName:"span",properties:$R[1924]={style:"color:#80A665"},children:$R[1925]=[$R[1926]={type:"text",value:"\tonMount"}]},$R[1927]={type:"element",tagName:"span",properties:$R[1928]={style:"color:#666666"},children:$R[1929]=[$R[1930]={type:"text",value:"(()"}]},$R[1931]={type:"element",tagName:"span",properties:$R[1932]={style:"color:#666666"},children:$R[1933]=[$R[1934]={type:"text",value:" =>"}]},$R[1935]={type:"element",tagName:"span",properties:$R[1936]={style:"color:#666666"},children:$R[1937]=[$R[1938]={type:"text",value:" {"}]}]},$R[1939]={type:"text",value:"\n"},$R[1940]={type:"element",tagName:"span",properties:$R[1941]={class:"line"},children:$R[1942]=[$R[1943]={type:"element",tagName:"span",properties:$R[1944]={style:"color:#BD976A"},children:$R[1945]=[$R[1946]={type:"text",value:"\t\tconsole"}]},$R[1947]={type:"element",tagName:"span",properties:$R[1948]={style:"color:#666666"},children:$R[1949]=[$R[1950]={type:"text",value:"."}]},$R[1951]={type:"element",tagName:"span",properties:$R[1952]={style:"color:#80A665"},children:$R[1953]=[$R[1954]={type:"text",value:"log"}]},$R[1955]={type:"element",tagName:"span",properties:$R[1956]={style:"color:#666666"},children:$R[1957]=[$R[1958]={type:"text",value:"("}]},$R[1959]={type:"element",tagName:"span",properties:$R[1960]={style:"color:#C98A7D77"},children:$R[1961]=[$R[1962]={type:"text",value:"\""}]},$R[1963]={type:"element",tagName:"span",properties:$R[1964]={style:"color:#C98A7D"},children:$R[1965]=[$R[1966]={type:"text",value:"Mounted"}]},$R[1967]={type:"element",tagName:"span",properties:$R[1968]={style:"color:#C98A7D77"},children:$R[1969]=[$R[1970]={type:"text",value:"\""}]},$R[1971]={type:"element",tagName:"span",properties:$R[1972]={style:"color:#666666"},children:$R[1973]=[$R[1974]={type:"text",value:");"}]}]},$R[1975]={type:"text",value:"\n"},$R[1976]={type:"element",tagName:"span",properties:$R[1977]={class:"line"},children:$R[1978]=[$R[1979]={type:"element",tagName:"span",properties:$R[1980]={style:"color:#4D9375"},children:$R[1981]=[$R[1982]={type:"text",value:"\t\treturn"}]},$R[1983]={type:"element",tagName:"span",properties:$R[1984]={style:"color:#666666"},children:$R[1985]=[$R[1986]={type:"text",value:" ()"}]},$R[1987]={type:"element",tagName:"span",properties:$R[1988]={style:"color:#666666"},children:$R[1989]=[$R[1990]={type:"text",value:" =>"}]},$R[1991]={type:"element",tagName:"span",properties:$R[1992]={style:"color:#BD976A"},children:$R[1993]=[$R[1994]={type:"text",value:" console"}]},$R[1995]={type:"element",tagName:"span",properties:$R[1996]={style:"color:#666666"},children:$R[1997]=[$R[1998]={type:"text",value:"."}]},$R[1999]={type:"element",tagName:"span",properties:$R[2000]={style:"color:#80A665"},children:$R[2001]=[$R[2002]={type:"text",value:"log"}]},$R[2003]={type:"element",tagName:"span",properties:$R[2004]={style:"color:#666666"},children:$R[2005]=[$R[2006]={type:"text",value:"("}]},$R[2007]={type:"element",tagName:"span",properties:$R[2008]={style:"color:#C98A7D77"},children:$R[2009]=[$R[2010]={type:"text",value:"\""}]},$R[2011]={type:"element",tagName:"span",properties:$R[2012]={style:"color:#C98A7D"},children:$R[2013]=[$R[2014]={type:"text",value:"Unmounted"}]},$R[2015]={type:"element",tagName:"span",properties:$R[2016]={style:"color:#C98A7D77"},children:$R[2017]=[$R[2018]={type:"text",value:"\""}]},$R[2019]={type:"element",tagName:"span",properties:$R[2020]={style:"color:#666666"},children:$R[2021]=[$R[2022]={type:"text",value:");"}]}]},$R[2023]={type:"text",value:"\n"},$R[2024]={type:"element",tagName:"span",properties:$R[2025]={class:"line"},children:$R[2026]=[$R[2027]={type:"element",tagName:"span",properties:$R[2028]={style:"color:#666666"},children:$R[2029]=[$R[2030]={type:"text",value:"\t});"}]}]},$R[2031]={type:"text",value:"\n"},$R[2032]={type:"element",tagName:"span",properties:$R[2033]={class:"line"},children:$R[2034]=[$R[2035]={type:"element",tagName:"span",properties:$R[2036]={style:"color:#4D9375"},children:$R[2037]=[$R[2038]={type:"text",value:"\treturn"}]},$R[2039]={type:"element",tagName:"span",properties:$R[2040]={style:"color:#80A665"},children:$R[2041]=[$R[2042]={type:"text",value:" atom"}]},$R[2043]={type:"element",tagName:"span",properties:$R[2044]={style:"color:#666666"},children:$R[2045]=[$R[2046]={type:"text",value:"("}]},$R[2047]={type:"element",tagName:"span",properties:$R[2048]={style:"color:#4C9A91"},children:$R[2049]=[$R[2050]={type:"text",value:"0"}]},$R[2051]={type:"element",tagName:"span",properties:$R[2052]={style:"color:#666666"},children:$R[2053]=[$R[2054]={type:"text",value:");"}]}]},$R[2055]={type:"text",value:"\n"},$R[2056]={type:"element",tagName:"span",properties:$R[2057]={class:"line"},children:$R[2058]=[$R[2059]={type:"element",tagName:"span",properties:$R[2060]={style:"color:#666666"},children:$R[2061]=[$R[2062]={type:"text",value:"});"}]}]}]}]}]}},$R[2063]={children:$R[2064]=[$R[2065]={position:$R[2066]={start:$R[2067]={line:142,column:1,offset:3438},end:$R[2068]={line:142,column:25,offset:3462}},type:"text",value:"次にライフサイクルの各ステップについて説明する。"}],position:$R[2069]={start:$R[2070]={line:142,column:1,offset:3438},end:$R[2071]={line:142,column:25,offset:3462}},type:"paragraph"},$R[2072]={children:$R[2073]=[$R[2074]={children:$R[2075]=[$R[2076]={position:$R[2077]={start:$R[2078]={line:144,column:6,offset:3469},end:$R[2079]={line:144,column:13,offset:3476}},type:"text",value:"Created"}],id:"created",level:4,plain:"Created",position:$R[2080]={start:$R[2081]={line:144,column:1,offset:3464},end:$R[2082]={line:144,column:13,offset:3476}},type:"heading"},$R[2083]={children:$R[2084]=[$R[2085]={position:$R[2086]={start:$R[2087]={line:146,column:1,offset:3478},end:$R[2088]={line:146,column:18,offset:3495}},type:"text",value:"アプリケーションが初期化された時、"},$R[2089]={position:$R[2090]={start:$R[2091]={line:146,column:18,offset:3495},end:$R[2092]={line:146,column:25,offset:3502}},type:"inlineCode",value:"scope"},$R[2093]={position:$R[2094]={start:$R[2095]={line:146,column:25,offset:3502},end:$R[2096]={line:146,column:50,offset:3527}},type:"text",value:" を登録したプロバイダーがマウントされた時などに "},$R[2097]={position:$R[2098]={start:$R[2099]={line:146,column:50,offset:3527},end:$R[2100]={line:146,column:60,offset:3537}},type:"inlineCode",value:"molecule"},$R[2101]={position:$R[2102]={start:$R[2103]={line:146,column:60,offset:3537},end:$R[2104]={line:146,column:85,offset:3562}},type:"text",value:" の値は作成され、すべての値は GC 可能になる。"}],position:$R[2105]={start:$R[2106]={line:146,column:1,offset:3478},end:$R[2107]={line:146,column:85,offset:3562}},type:"paragraph"}],position:$R[2108]={end:$R[2109]={line:146,column:85,offset:3562},start:$R[2110]={line:144,column:1,offset:3464}},type:"section"},$R[2111]={children:$R[2112]=[$R[2113]={children:$R[2114]=[$R[2115]={position:$R[2116]={start:$R[2117]={line:148,column:6,offset:3569},end:$R[2118]={line:148,column:13,offset:3576}},type:"text",value:"Mounted"}],id:"mounted",level:4,plain:"Mounted",position:$R[2119]={start:$R[2120]={line:148,column:1,offset:3564},end:$R[2121]={line:148,column:13,offset:3576}},type:"heading"},$R[2122]={children:$R[2123]=[$R[2124]={position:$R[2125]={start:$R[2126]={line:150,column:1,offset:3578},end:$R[2127]={line:150,column:11,offset:3588}},type:"inlineCode",value:"molecule"},$R[2128]={position:$R[2129]={start:$R[2130]={line:150,column:11,offset:3588},end:$R[2131]={line:150,column:34,offset:3611}},type:"text",value:" の値は実行されただけではキャッシュされない。"},$R[2132]={position:$R[2133]={start:$R[2134]={line:150,column:34,offset:3611},end:$R[2135]={line:150,column:41,offset:3618}},type:"inlineCode",value:"React"},$R[2136]={position:$R[2137]={start:$R[2138]={line:150,column:41,offset:3618},end:$R[2139]={line:150,column:44,offset:3621}},type:"text",value:" や "},$R[2140]={position:$R[2141]={start:$R[2142]={line:150,column:44,offset:3621},end:$R[2143]={line:150,column:49,offset:3626}},type:"inlineCode",value:"Vue"},$R[2144]={position:$R[2145]={start:$R[2146]={line:150,column:49,offset:3626},end:$R[2147]={line:150,column:53,offset:3630}},type:"text",value:" では "},$R[2148]={position:$R[2149]={start:$R[2150]={line:150,column:53,offset:3630},end:$R[2151]={line:150,column:66,offset:3643}},type:"inlineCode",value:"useMolecule"},$R[2152]={position:$R[2153]={start:$R[2154]={line:150,column:66,offset:3643},end:$R[2155]={line:150,column:76,offset:3653}},type:"text",value:" フックを使用して "},$R[2156]={position:$R[2157]={start:$R[2158]={line:150,column:76,offset:3653},end:$R[2159]={line:150,column:86,offset:3663}},type:"inlineCode",value:"molecule"},$R[2160]={position:$R[2161]={start:$R[2162]={line:150,column:86,offset:3663},end:$R[2163]={line:150,column:106,offset:3683}},type:"text",value:" をマウントすることでキャッシュされる。"}],position:$R[2164]={start:$R[2165]={line:150,column:1,offset:3578},end:$R[2166]={line:150,column:106,offset:3683}},type:"paragraph"}],position:$R[2167]={end:$R[2168]={line:150,column:106,offset:3683},start:$R[2169]={line:148,column:1,offset:3564}},type:"section"},$R[2170]={children:$R[2171]=[$R[2172]={children:$R[2173]=[$R[2174]={position:$R[2175]={start:$R[2176]={line:152,column:6,offset:3690},end:$R[2177]={line:152,column:15,offset:3699}},type:"text",value:"Unmounted"}],id:"unmounted",level:4,plain:"Unmounted",position:$R[2178]={start:$R[2179]={line:152,column:1,offset:3685},end:$R[2180]={line:152,column:15,offset:3699}},type:"heading"},$R[2181]={children:$R[2182]=[$R[2183]={position:$R[2184]={start:$R[2185]={line:154,column:1,offset:3701},end:$R[2186]={line:154,column:11,offset:3711}},type:"inlineCode",value:"molecule"},$R[2187]={position:$R[2188]={start:$R[2189]={line:154,column:11,offset:3711},end:$R[2190]={line:154,column:25,offset:3725}},type:"text",value:" の値が使用されなくなると、"},$R[2191]={position:$R[2192]={start:$R[2193]={line:154,column:25,offset:3725},end:$R[2194]={line:154,column:35,offset:3735}},type:"inlineCode",value:"molecule"},$R[2195]={position:$R[2196]={start:$R[2197]={line:154,column:35,offset:3735},end:$R[2198]={line:154,column:53,offset:3753}},type:"text",value:" はアンマウントされ、GC される。"},$R[2199]={position:$R[2200]={start:$R[2201]={line:154,column:53,offset:3753},end:$R[2202]={line:154,column:60,offset:3760}},type:"inlineCode",value:"React"},$R[2203]={position:$R[2204]={start:$R[2205]={line:154,column:60,offset:3760},end:$R[2206]={line:154,column:63,offset:3763}},type:"text",value:" や "},$R[2207]={position:$R[2208]={start:$R[2209]={line:154,column:63,offset:3763},end:$R[2210]={line:154,column:68,offset:3768}},type:"inlineCode",value:"Vue"},$R[2211]={position:$R[2212]={start:$R[2213]={line:154,column:68,offset:3768},end:$R[2214]={line:154,column:72,offset:3772}},type:"text",value:" では "},$R[2215]={position:$R[2216]={start:$R[2217]={line:154,column:72,offset:3772},end:$R[2218]={line:154,column:85,offset:3785}},type:"inlineCode",value:"useMolecule"},$R[2219]={position:$R[2220]={start:$R[2221]={line:154,column:85,offset:3785},end:$R[2222]={line:154,column:104,offset:3804}},type:"text",value:" フックで自動的にアンマウントされる。"}],position:$R[2223]={start:$R[2224]={line:154,column:1,offset:3701},end:$R[2225]={line:154,column:104,offset:3804}},type:"paragraph"},$R[2226]={children:$R[2227]=[$R[2228]={position:$R[2229]={start:$R[2230]={line:156,column:1,offset:3806},end:$R[2231]={line:156,column:75,offset:3880}},type:"text",value:"React Strict mode を使用している方は unmount された後に再度 mount されることがあるので、この点に注意が必要である。"},$R[2232]={position:$R[2233]={start:$R[2234]={line:156,column:75,offset:3880},end:$R[2235]={line:156,column:86,offset:3891}},type:"inlineCode",value:"useEffect"},$R[2236]={position:$R[2237]={start:$R[2238]={line:156,column:86,offset:3891},end:$R[2239]={line:156,column:122,offset:3927}},type:"text",value:" などのフックの正当性を確認するために 2 回実行されるのと同じように、"},$R[2240]={position:$R[2241]={start:$R[2242]={line:156,column:122,offset:3927},end:$R[2243]={line:156,column:132,offset:3937}},type:"inlineCode",value:"molecule"},$R[2244]={position:$R[2245]={start:$R[2246]={line:156,column:132,offset:3937},end:$R[2247]={line:156,column:153,offset:3958}},type:"text",value:" も 2 回実行されることがある。この時、"},$R[2248]={position:$R[2249]={start:$R[2250]={line:156,column:153,offset:3958},end:$R[2251]={line:156,column:180,offset:3985}},type:"inlineCode",value:"mount -> unmount -> mount"},$R[2252]={position:$R[2253]={start:$R[2254]={line:156,column:180,offset:3985},end:$R[2255]={line:156,column:191,offset:3996}},type:"text",value:" の順番で実行される。"}],position:$R[2256]={start:$R[2257]={line:156,column:1,offset:3806},end:$R[2258]={line:156,column:191,offset:3996}},type:"paragraph"}],position:$R[2259]={end:$R[2260]={line:156,column:191,offset:3996},start:$R[2261]={line:152,column:1,offset:3685}},type:"section"}],position:$R[2262]={end:$R[2263]={line:156,column:191,offset:3996},start:$R[2264]={line:118,column:1,offset:2852}},type:"section"}],position:$R[2265]={end:$R[2266]={line:156,column:191,offset:3996},start:$R[2267]={line:33,column:1,offset:982}},type:"section"},$R[2268]={children:$R[2269]=[$R[2270]={children:$R[2271]=[$R[2272]={position:$R[2273]={start:$R[2274]={line:158,column:4,offset:4001},end:$R[2275]={line:158,column:19,offset:4016}},type:"text",value:"個人的に面白いと思ったポイント"}],id:"個人的に面白いと思ったポイント",level:2,plain:"個人的に面白いと思ったポイント",position:$R[2276]={start:$R[2277]={line:158,column:1,offset:3998},end:$R[2278]={line:158,column:19,offset:4016}},type:"heading"},$R[2279]={children:$R[2280]=[$R[2281]={position:$R[2282]={start:$R[2283]={line:160,column:1,offset:4018},end:$R[2284]={line:160,column:19,offset:4036}},type:"inlineCode",value:"MoleculeInjector"},$R[2285]={position:$R[2286]={start:$R[2287]={line:160,column:19,offset:4036},end:$R[2288]={line:160,column:26,offset:4043}},type:"text",value:"(を生成する "},$R[2289]={position:$R[2290]={start:$R[2291]={line:160,column:26,offset:4043},end:$R[2292]={line:160,column:42,offset:4059}},type:"inlineCode",value:"createInjector"},$R[2293]={position:$R[2294]={start:$R[2295]={line:160,column:42,offset:4059},end:$R[2296]={line:160,column:45,offset:4062}},type:"text",value:")と "},$R[2297]={position:$R[2298]={start:$R[2299]={line:160,column:45,offset:4062},end:$R[2300]={line:160,column:64,offset:4081}},type:"inlineCode",value:"moleculeInterface"},$R[2301]={position:$R[2302]={start:$R[2303]={line:160,column:64,offset:4081},end:$R[2304]={line:160,column:67,offset:4084}},type:"text",value:" だ。"}],position:$R[2305]={start:$R[2306]={line:160,column:1,offset:4018},end:$R[2307]={line:160,column:67,offset:4084}},type:"paragraph"},$R[2308]={meta:$R[2309]={title:"moleculeInterface",open_graph:$R[2310]={title:"moleculeInterface",type:"article",url:void 0,locale:"en",description:void 0,site_name:"Bunshi"},twitter_card:$R[2311]={card:"summary_large_image",title:"moleculeInterface",description:void 0},favicon:"https://www.bunshi.org/public/favicon.ico"},oembed:void 0,position:$R[2312]={start:$R[2313]={line:162,column:1,offset:4086},end:$R[2314]={line:162,column:80,offset:4165}},src:"https://www.bunshi.org/reference/vanilla/functions/functionmoleculeinterface-1/",type:"embed"},$R[2315]={meta:$R[2316]={title:"MoleculeInjector",open_graph:$R[2317]={title:"MoleculeInjector",type:"article",url:void 0,locale:"en",description:void 0,site_name:"Bunshi"},twitter_card:$R[2318]={card:"summary_large_image",title:"MoleculeInjector",description:void 0},favicon:"https://www.bunshi.org/public/favicon.ico"},oembed:void 0,position:$R[2319]={start:$R[2320]={line:164,column:1,offset:4167},end:$R[2321]={line:164,column:82,offset:4248}},src:"https://www.bunshi.org/reference/vanilla/type-aliases/type-aliasmoleculeinjector/",type:"embed"},$R[2322]={children:$R[2323]=[$R[2324]={position:$R[2325]={start:$R[2326]={line:166,column:1,offset:4250},end:$R[2327]={line:166,column:6,offset:4255}},type:"text",value:"それぞれ "},$R[2328]={position:$R[2329]={start:$R[2330]={line:166,column:6,offset:4255},end:$R[2331]={line:166,column:14,offset:4263}},type:"inlineCode",value:"bunshi"},$R[2332]={position:$R[2333]={start:$R[2334]={line:166,column:14,offset:4263},end:$R[2335]={line:166,column:45,offset:4294}},type:"text",value:" の依存関係のグラフを構築するための DI コンテナと、他の "},$R[2336]={position:$R[2337]={start:$R[2338]={line:166,column:45,offset:4294},end:$R[2339]={line:166,column:55,offset:4304}},type:"inlineCode",value:"molecule"},$R[2340]={position:$R[2341]={start:$R[2342]={line:166,column:55,offset:4304},end:$R[2343]={line:166,column:93,offset:4342}},type:"text",value:" が依存できるための参照を提供するものだ。ドキュメントにある通り、どちらも "},$R[2344]={position:$R[2345]={start:$R[2346]={line:166,column:93,offset:4342},end:$R[2347]={line:166,column:103,offset:4352}},type:"inlineCode",value:"molecule"},$R[2348]={position:$R[2349]={start:$R[2350]={line:166,column:103,offset:4352},end:$R[2351]={line:166,column:106,offset:4355}},type:"text",value:" や "},$R[2352]={position:$R[2353]={start:$R[2354]={line:166,column:106,offset:4355},end:$R[2355]={line:166,column:119,offset:4368}},type:"inlineCode",value:"useMolecule"},$R[2356]={position:$R[2357]={start:$R[2358]={line:166,column:119,offset:4368},end:$R[2359]={line:166,column:168,offset:4417}},type:"text",value:" の裏で使用されておりユーザーがこれらを直接使用するのはテストコードを書く場合やライブラリとして "},$R[2360]={position:$R[2361]={start:$R[2362]={line:166,column:168,offset:4417},end:$R[2363]={line:166,column:178,offset:4427}},type:"inlineCode",value:"molecule"},$R[2364]={position:$R[2365]={start:$R[2366]={line:166,column:178,offset:4427},end:$R[2367]={line:166,column:194,offset:4443}},type:"text",value:" を提供する場合などに限られる。"}],position:$R[2368]={start:$R[2369]={line:166,column:1,offset:4250},end:$R[2370]={line:166,column:194,offset:4443}},type:"paragraph"},$R[2371]={children:$R[2372]=[$R[2373]={position:$R[2374]={start:$R[2375]={line:168,column:1,offset:4445},end:$R[2376]={line:168,column:43,offset:4487}},type:"text",value:"私がこれらの機能を面白いと感じたのは、今まで TS の DI コンテナと言われると、"},$R[2377]={children:$R[2378]=[$R[2379]={position:$R[2380]={start:$R[2381]={line:168,column:44,offset:4488},end:$R[2382]={line:168,column:50,offset:4494}},type:"text",value:"NestJS"}],position:$R[2383]={start:$R[2384]={line:168,column:43,offset:4487},end:$R[2385]={line:168,column:72,offset:4516}},title:void 0,type:"link",url:"https://nestjs.com/"},$R[2386]={position:$R[2387]={start:$R[2388]={line:168,column:72,offset:4516},end:$R[2389]={line:168,column:80,offset:4524}},type:"text",value:" に乗っかるか、"},$R[2390]={children:$R[2391]=[$R[2392]={position:$R[2393]={start:$R[2394]={line:168,column:81,offset:4525},end:$R[2395]={line:168,column:89,offset:4533}},type:"text",value:"TSyringe"}],position:$R[2396]={start:$R[2397]={line:168,column:80,offset:4524},end:$R[2398]={line:168,column:129,offset:4573}},title:void 0,type:"link",url:"https://github.com/microsoft/tsyringe"},$R[2399]={position:$R[2400]={start:$R[2401]={line:168,column:129,offset:4573},end:$R[2402]={line:168,column:259,offset:4703}},type:"text",value:" であった。前者はバックエンドを構築するためのフレームワークなので、そもそもフロントエンド文脈で使うことがない。また TSyringe は DI コンテナとしては良くできている。循環依存やインスタンスを使い捨てるなどができるが、デコレータを使用する必要があり "},$R[2403]={position:$R[2404]={start:$R[2405]={line:168,column:259,offset:4703},end:$R[2406]={line:168,column:277,offset:4721}},type:"inlineCode",value:"reflect-metadata"},$R[2407]={position:$R[2408]={start:$R[2409]={line:168,column:277,offset:4721},end:$R[2410]={line:168,column:286,offset:4730}},type:"text",value:" を使う制約がある"},$R[2411]={footnoteIndex:2,position:$R[2412]={start:$R[2413]={line:168,column:286,offset:4730},end:$R[2414]={line:168,column:290,offset:4734}},referenceIndex:1,type:"footnoteReference"},$R[2415]={position:$R[2416]={start:$R[2417]={line:168,column:290,offset:4734},end:$R[2418]={line:168,column:291,offset:4735}},type:"text",value:"。"}],position:$R[2419]={start:$R[2420]={line:168,column:1,offset:4445},end:$R[2421]={line:168,column:291,offset:4735}},type:"paragraph"},$R[2422]={children:$R[2423]=[$R[2424]={position:$R[2425]={start:$R[2426]={line:170,column:1,offset:4737},end:$R[2427]={line:170,column:5,offset:4741}},type:"text",value:"その点 "},$R[2428]={position:$R[2429]={start:$R[2430]={line:170,column:5,offset:4741},end:$R[2431]={line:170,column:13,offset:4749}},type:"inlineCode",value:"bunshi"},$R[2432]={position:$R[2433]={start:$R[2434]={line:170,column:13,offset:4749},end:$R[2435]={line:170,column:55,offset:4791}},type:"text",value:" はスコープで分けられていて、かつ自動で DI される仕組みをとても気に入っている。"}],position:$R[2436]={start:$R[2437]={line:170,column:1,offset:4737},end:$R[2438]={line:170,column:55,offset:4791}},type:"paragraph"}],position:$R[2439]={end:$R[2440]={line:170,column:55,offset:4791},start:$R[2441]={line:158,column:1,offset:3998}},type:"section"},$R[2442]={children:$R[2443]=[$R[2444]={children:$R[2445]=[$R[2446]={position:$R[2447]={start:$R[2448]={line:174,column:4,offset:4858},end:$R[2449]={line:174,column:12,offset:4866}},type:"text",value:"結局何が嬉しい?"}],id:"結局何が嬉しい",level:2,plain:"結局何が嬉しい?",position:$R[2450]={start:$R[2451]={line:174,column:1,offset:4855},end:$R[2452]={line:174,column:12,offset:4866}},type:"heading"},$R[2453]={children:$R[2454]=[$R[2455]={position:$R[2456]={start:$R[2457]={line:176,column:1,offset:4868},end:$R[2458]={line:176,column:9,offset:4876}},type:"inlineCode",value:"bunshi"},$R[2459]={position:$R[2460]={start:$R[2461]={line:176,column:9,offset:4876},end:$R[2462]={line:176,column:71,offset:4938}},type:"text",value:" を使うことで、ステートのリフトアップやプッシュダウンを容易に実現できる。以下の 2 つの例を見れば一目瞭然であると言える。"}],position:$R[2463]={start:$R[2464]={line:176,column:1,offset:4868},end:$R[2465]={line:176,column:71,offset:4938}},type:"paragraph"},$R[2466]={filename:"sample.tsx tsx",lang:"tsx",position:$R[2467]={start:$R[2468]={line:178,column:1,offset:4940},end:$R[2469]={line:223,column:4,offset:5998}},type:"code",value:"import { atom, useAtom } from \"jotai\";\n\nfunction createAtom(userId: string) {\n\treturn atom(userId === \"bob@example.com\" ? 0 : 1);\n}\n\nconst CountAtomContext = React.createContext(createAtom(\"bob@example.com\"));\nconst useCountAtom = () => useContext(CountAtomContext);\nfunction CountAtomScopeProvider({ children, userId }) {\n\t// Create a new atom for every user Id\n\tconst countAtom = useMemo(() => createAtom(userId), [userId]);\n\treturn (\n\t\t\x3CCountAtomContext.Provider value={countAtom}>\n\t\t\t{children}\n\t\t\x3C/CountAtomContext.Provider>\n\t);\n}\n\nfunction Counter() {\n\tconst countAtom = useCountAtom();\n\tconst [count, setCount] = useAtom(countAtom);\n\treturn (\n\t\t\x3Cdiv>\n\t\t\tcount:\n\t\t\t{\" \"}\n\t\t\t{count}\n\t\t\t{\" \"}\n\t\t\t\x3Cbutton onClick={() => setCount(c => c + 1)}>+1\x3C/button>\n\t\t\x3C/div>\n\t);\n}\n\nexport function App() {\n\treturn (\n\t\t\x3CCountAtomScopeProvider userId=\"bob@example.com\">\n\t\t\t\x3CCounter />\n\t\t\t\x3CCounter />\n\t\t\t\x3CCountAtomScopeProvider userId=\"tom@example.com\">\n\t\t\t\t\x3CCounter />\n\t\t\t\t\x3CCounter />\n\t\t\t\x3C/CountAtomScopeProvider>\n\t\t\x3C/CountAtomScopeProvider>\n\t);\n}",hast:$R[2470]={type:"root",children:$R[2471]=[$R[2472]={type:"element",tagName:"pre",properties:$R[2473]={class:"shiki vitesse-dark",style:"color: #dbd7cacc;",tabindex:"0"},children:$R[2474]=[$R[2475]={type:"element",tagName:"code",properties:$R[2476]={},children:$R[2477]=[$R[2478]={type:"element",tagName:"span",properties:$R[2479]={class:"line"},children:$R[2480]=[$R[2481]={type:"element",tagName:"span",properties:$R[2482]={style:"color:#4D9375"},children:$R[2483]=[$R[2484]={type:"text",value:"import"}]},$R[2485]={type:"element",tagName:"span",properties:$R[2486]={style:"color:#666666"},children:$R[2487]=[$R[2488]={type:"text",value:" {"}]},$R[2489]={type:"element",tagName:"span",properties:$R[2490]={style:"color:#BD976A"},children:$R[2491]=[$R[2492]={type:"text",value:" atom"}]},$R[2493]={type:"element",tagName:"span",properties:$R[2494]={style:"color:#666666"},children:$R[2495]=[$R[2496]={type:"text",value:","}]},$R[2497]={type:"element",tagName:"span",properties:$R[2498]={style:"color:#BD976A"},children:$R[2499]=[$R[2500]={type:"text",value:" useAtom"}]},$R[2501]={type:"element",tagName:"span",properties:$R[2502]={style:"color:#666666"},children:$R[2503]=[$R[2504]={type:"text",value:" }"}]},$R[2505]={type:"element",tagName:"span",properties:$R[2506]={style:"color:#4D9375"},children:$R[2507]=[$R[2508]={type:"text",value:" from"}]},$R[2509]={type:"element",tagName:"span",properties:$R[2510]={style:"color:#C98A7D77"},children:$R[2511]=[$R[2512]={type:"text",value:" \""}]},$R[2513]={type:"element",tagName:"span",properties:$R[2514]={style:"color:#C98A7D"},children:$R[2515]=[$R[2516]={type:"text",value:"jotai"}]},$R[2517]={type:"element",tagName:"span",properties:$R[2518]={style:"color:#C98A7D77"},children:$R[2519]=[$R[2520]={type:"text",value:"\""}]},$R[2521]={type:"element",tagName:"span",properties:$R[2522]={style:"color:#666666"},children:$R[2523]=[$R[2524]={type:"text",value:";"}]}]},$R[2525]={type:"text",value:"\n"},$R[2526]={type:"element",tagName:"span",properties:$R[2527]={class:"line"},children:$R[2528]=[]},$R[2529]={type:"text",value:"\n"},$R[2530]={type:"element",tagName:"span",properties:$R[2531]={class:"line"},children:$R[2532]=[$R[2533]={type:"element",tagName:"span",properties:$R[2534]={style:"color:#CB7676"},children:$R[2535]=[$R[2536]={type:"text",value:"function"}]},$R[2537]={type:"element",tagName:"span",properties:$R[2538]={style:"color:#80A665"},children:$R[2539]=[$R[2540]={type:"text",value:" createAtom"}]},$R[2541]={type:"element",tagName:"span",properties:$R[2542]={style:"color:#666666"},children:$R[2543]=[$R[2544]={type:"text",value:"("}]},$R[2545]={type:"element",tagName:"span",properties:$R[2546]={style:"color:#BD976A"},children:$R[2547]=[$R[2548]={type:"text",value:"userId"}]},$R[2549]={type:"element",tagName:"span",properties:$R[2550]={style:"color:#666666"},children:$R[2551]=[$R[2552]={type:"text",value:": "}]},$R[2553]={type:"element",tagName:"span",properties:$R[2554]={style:"color:#5DA994"},children:$R[2555]=[$R[2556]={type:"text",value:"string"}]},$R[2557]={type:"element",tagName:"span",properties:$R[2558]={style:"color:#666666"},children:$R[2559]=[$R[2560]={type:"text",value:")"}]},$R[2561]={type:"element",tagName:"span",properties:$R[2562]={style:"color:#666666"},children:$R[2563]=[$R[2564]={type:"text",value:" {"}]}]},$R[2565]={type:"text",value:"\n"},$R[2566]={type:"element",tagName:"span",properties:$R[2567]={class:"line"},children:$R[2568]=[$R[2569]={type:"element",tagName:"span",properties:$R[2570]={style:"color:#4D9375"},children:$R[2571]=[$R[2572]={type:"text",value:"\treturn"}]},$R[2573]={type:"element",tagName:"span",properties:$R[2574]={style:"color:#80A665"},children:$R[2575]=[$R[2576]={type:"text",value:" atom"}]},$R[2577]={type:"element",tagName:"span",properties:$R[2578]={style:"color:#666666"},children:$R[2579]=[$R[2580]={type:"text",value:"("}]},$R[2581]={type:"element",tagName:"span",properties:$R[2582]={style:"color:#BD976A"},children:$R[2583]=[$R[2584]={type:"text",value:"userId"}]},$R[2585]={type:"element",tagName:"span",properties:$R[2586]={style:"color:#CB7676"},children:$R[2587]=[$R[2588]={type:"text",value:" ==="}]},$R[2589]={type:"element",tagName:"span",properties:$R[2590]={style:"color:#C98A7D77"},children:$R[2591]=[$R[2592]={type:"text",value:" \""}]},$R[2593]={type:"element",tagName:"span",properties:$R[2594]={style:"color:#C98A7D"},children:$R[2595]=[$R[2596]={type:"text",value:"bob@example.com"}]},$R[2597]={type:"element",tagName:"span",properties:$R[2598]={style:"color:#C98A7D77"},children:$R[2599]=[$R[2600]={type:"text",value:"\""}]},$R[2601]={type:"element",tagName:"span",properties:$R[2602]={style:"color:#CB7676"},children:$R[2603]=[$R[2604]={type:"text",value:" ?"}]},$R[2605]={type:"element",tagName:"span",properties:$R[2606]={style:"color:#4C9A91"},children:$R[2607]=[$R[2608]={type:"text",value:" 0"}]},$R[2609]={type:"element",tagName:"span",properties:$R[2610]={style:"color:#CB7676"},children:$R[2611]=[$R[2612]={type:"text",value:" :"}]},$R[2613]={type:"element",tagName:"span",properties:$R[2614]={style:"color:#4C9A91"},children:$R[2615]=[$R[2616]={type:"text",value:" 1"}]},$R[2617]={type:"element",tagName:"span",properties:$R[2618]={style:"color:#666666"},children:$R[2619]=[$R[2620]={type:"text",value:");"}]}]},$R[2621]={type:"text",value:"\n"},$R[2622]={type:"element",tagName:"span",properties:$R[2623]={class:"line"},children:$R[2624]=[$R[2625]={type:"element",tagName:"span",properties:$R[2626]={style:"color:#666666"},children:$R[2627]=[$R[2628]={type:"text",value:"}"}]}]},$R[2629]={type:"text",value:"\n"},$R[2630]={type:"element",tagName:"span",properties:$R[2631]={class:"line"},children:$R[2632]=[]},$R[2633]={type:"text",value:"\n"},$R[2634]={type:"element",tagName:"span",properties:$R[2635]={class:"line"},children:$R[2636]=[$R[2637]={type:"element",tagName:"span",properties:$R[2638]={style:"color:#CB7676"},children:$R[2639]=[$R[2640]={type:"text",value:"const"}]},$R[2641]={type:"element",tagName:"span",properties:$R[2642]={style:"color:#BD976A"},children:$R[2643]=[$R[2644]={type:"text",value:" CountAtomContext"}]},$R[2645]={type:"element",tagName:"span",properties:$R[2646]={style:"color:#666666"},children:$R[2647]=[$R[2648]={type:"text",value:" ="}]},$R[2649]={type:"element",tagName:"span",properties:$R[2650]={style:"color:#BD976A"},children:$R[2651]=[$R[2652]={type:"text",value:" React"}]},$R[2653]={type:"element",tagName:"span",properties:$R[2654]={style:"color:#666666"},children:$R[2655]=[$R[2656]={type:"text",value:"."}]},$R[2657]={type:"element",tagName:"span",properties:$R[2658]={style:"color:#80A665"},children:$R[2659]=[$R[2660]={type:"text",value:"createContext"}]},$R[2661]={type:"element",tagName:"span",properties:$R[2662]={style:"color:#666666"},children:$R[2663]=[$R[2664]={type:"text",value:"("}]},$R[2665]={type:"element",tagName:"span",properties:$R[2666]={style:"color:#80A665"},children:$R[2667]=[$R[2668]={type:"text",value:"createAtom"}]},$R[2669]={type:"element",tagName:"span",properties:$R[2670]={style:"color:#666666"},children:$R[2671]=[$R[2672]={type:"text",value:"("}]},$R[2673]={type:"element",tagName:"span",properties:$R[2674]={style:"color:#C98A7D77"},children:$R[2675]=[$R[2676]={type:"text",value:"\""}]},$R[2677]={type:"element",tagName:"span",properties:$R[2678]={style:"color:#C98A7D"},children:$R[2679]=[$R[2680]={type:"text",value:"bob@example.com"}]},$R[2681]={type:"element",tagName:"span",properties:$R[2682]={style:"color:#C98A7D77"},children:$R[2683]=[$R[2684]={type:"text",value:"\""}]},$R[2685]={type:"element",tagName:"span",properties:$R[2686]={style:"color:#666666"},children:$R[2687]=[$R[2688]={type:"text",value:"));"}]}]},$R[2689]={type:"text",value:"\n"},$R[2690]={type:"element",tagName:"span",properties:$R[2691]={class:"line"},children:$R[2692]=[$R[2693]={type:"element",tagName:"span",properties:$R[2694]={style:"color:#CB7676"},children:$R[2695]=[$R[2696]={type:"text",value:"const"}]},$R[2697]={type:"element",tagName:"span",properties:$R[2698]={style:"color:#80A665"},children:$R[2699]=[$R[2700]={type:"text",value:" useCountAtom"}]},$R[2701]={type:"element",tagName:"span",properties:$R[2702]={style:"color:#666666"},children:$R[2703]=[$R[2704]={type:"text",value:" ="}]},$R[2705]={type:"element",tagName:"span",properties:$R[2706]={style:"color:#666666"},children:$R[2707]=[$R[2708]={type:"text",value:" ()"}]},$R[2709]={type:"element",tagName:"span",properties:$R[2710]={style:"color:#666666"},children:$R[2711]=[$R[2712]={type:"text",value:" =>"}]},$R[2713]={type:"element",tagName:"span",properties:$R[2714]={style:"color:#80A665"},children:$R[2715]=[$R[2716]={type:"text",value:" useContext"}]},$R[2717]={type:"element",tagName:"span",properties:$R[2718]={style:"color:#666666"},children:$R[2719]=[$R[2720]={type:"text",value:"("}]},$R[2721]={type:"element",tagName:"span",properties:$R[2722]={style:"color:#BD976A"},children:$R[2723]=[$R[2724]={type:"text",value:"CountAtomContext"}]},$R[2725]={type:"element",tagName:"span",properties:$R[2726]={style:"color:#666666"},children:$R[2727]=[$R[2728]={type:"text",value:");"}]}]},$R[2729]={type:"text",value:"\n"},$R[2730]={type:"element",tagName:"span",properties:$R[2731]={class:"line"},children:$R[2732]=[$R[2733]={type:"element",tagName:"span",properties:$R[2734]={style:"color:#CB7676"},children:$R[2735]=[$R[2736]={type:"text",value:"function"}]},$R[2737]={type:"element",tagName:"span",properties:$R[2738]={style:"color:#80A665"},children:$R[2739]=[$R[2740]={type:"text",value:" CountAtomScopeProvider"}]},$R[2741]={type:"element",tagName:"span",properties:$R[2742]={style:"color:#666666"},children:$R[2743]=[$R[2744]={type:"text",value:"({"}]},$R[2745]={type:"element",tagName:"span",properties:$R[2746]={style:"color:#BD976A"},children:$R[2747]=[$R[2748]={type:"text",value:" children"}]},$R[2749]={type:"element",tagName:"span",properties:$R[2750]={style:"color:#666666"},children:$R[2751]=[$R[2752]={type:"text",value:","}]},$R[2753]={type:"element",tagName:"span",properties:$R[2754]={style:"color:#BD976A"},children:$R[2755]=[$R[2756]={type:"text",value:" userId"}]},$R[2757]={type:"element",tagName:"span",properties:$R[2758]={style:"color:#666666"},children:$R[2759]=[$R[2760]={type:"text",value:" })"}]},$R[2761]={type:"element",tagName:"span",properties:$R[2762]={style:"color:#666666"},children:$R[2763]=[$R[2764]={type:"text",value:" {"}]}]},$R[2765]={type:"text",value:"\n"},$R[2766]={type:"element",tagName:"span",properties:$R[2767]={class:"line"},children:$R[2768]=[$R[2769]={type:"element",tagName:"span",properties:$R[2770]={style:"color:#758575DD"},children:$R[2771]=[$R[2772]={type:"text",value:"\t// Create a new atom for every user Id"}]}]},$R[2773]={type:"text",value:"\n"},$R[2774]={type:"element",tagName:"span",properties:$R[2775]={class:"line"},children:$R[2776]=[$R[2777]={type:"element",tagName:"span",properties:$R[2778]={style:"color:#CB7676"},children:$R[2779]=[$R[2780]={type:"text",value:"\tconst"}]},$R[2781]={type:"element",tagName:"span",properties:$R[2782]={style:"color:#BD976A"},children:$R[2783]=[$R[2784]={type:"text",value:" countAtom"}]},$R[2785]={type:"element",tagName:"span",properties:$R[2786]={style:"color:#666666"},children:$R[2787]=[$R[2788]={type:"text",value:" ="}]},$R[2789]={type:"element",tagName:"span",properties:$R[2790]={style:"color:#80A665"},children:$R[2791]=[$R[2792]={type:"text",value:" useMemo"}]},$R[2793]={type:"element",tagName:"span",properties:$R[2794]={style:"color:#666666"},children:$R[2795]=[$R[2796]={type:"text",value:"(()"}]},$R[2797]={type:"element",tagName:"span",properties:$R[2798]={style:"color:#666666"},children:$R[2799]=[$R[2800]={type:"text",value:" =>"}]},$R[2801]={type:"element",tagName:"span",properties:$R[2802]={style:"color:#80A665"},children:$R[2803]=[$R[2804]={type:"text",value:" createAtom"}]},$R[2805]={type:"element",tagName:"span",properties:$R[2806]={style:"color:#666666"},children:$R[2807]=[$R[2808]={type:"text",value:"("}]},$R[2809]={type:"element",tagName:"span",properties:$R[2810]={style:"color:#BD976A"},children:$R[2811]=[$R[2812]={type:"text",value:"userId"}]},$R[2813]={type:"element",tagName:"span",properties:$R[2814]={style:"color:#666666"},children:$R[2815]=[$R[2816]={type:"text",value:"),"}]},$R[2817]={type:"element",tagName:"span",properties:$R[2818]={style:"color:#666666"},children:$R[2819]=[$R[2820]={type:"text",value:" ["}]},$R[2821]={type:"element",tagName:"span",properties:$R[2822]={style:"color:#BD976A"},children:$R[2823]=[$R[2824]={type:"text",value:"userId"}]},$R[2825]={type:"element",tagName:"span",properties:$R[2826]={style:"color:#666666"},children:$R[2827]=[$R[2828]={type:"text",value:"]);"}]}]},$R[2829]={type:"text",value:"\n"},$R[2830]={type:"element",tagName:"span",properties:$R[2831]={class:"line"},children:$R[2832]=[$R[2833]={type:"element",tagName:"span",properties:$R[2834]={style:"color:#4D9375"},children:$R[2835]=[$R[2836]={type:"text",value:"\treturn"}]},$R[2837]={type:"element",tagName:"span",properties:$R[2838]={style:"color:#666666"},children:$R[2839]=[$R[2840]={type:"text",value:" ("}]}]},$R[2841]={type:"text",value:"\n"},$R[2842]={type:"element",tagName:"span",properties:$R[2843]={class:"line"},children:$R[2844]=[$R[2845]={type:"element",tagName:"span",properties:$R[2846]={style:"color:#666666"},children:$R[2847]=[$R[2848]={type:"text",value:"\t\t\x3C"}]},$R[2849]={type:"element",tagName:"span",properties:$R[2850]={style:"color:#B8A965"},children:$R[2851]=[$R[2852]={type:"text",value:"CountAtomContext.Provider"}]},$R[2853]={type:"element",tagName:"span",properties:$R[2854]={style:"color:#BD976A"},children:$R[2855]=[$R[2856]={type:"text",value:" value"}]},$R[2857]={type:"element",tagName:"span",properties:$R[2858]={style:"color:#666666"},children:$R[2859]=[$R[2860]={type:"text",value:"={"}]},$R[2861]={type:"element",tagName:"span",properties:$R[2862]={style:"color:#BD976A"},children:$R[2863]=[$R[2864]={type:"text",value:"countAtom"}]},$R[2865]={type:"element",tagName:"span",properties:$R[2866]={style:"color:#666666"},children:$R[2867]=[$R[2868]={type:"text",value:"}>"}]}]},$R[2869]={type:"text",value:"\n"},$R[2870]={type:"element",tagName:"span",properties:$R[2871]={class:"line"},children:$R[2872]=[$R[2873]={type:"element",tagName:"span",properties:$R[2874]={style:"color:#666666"},children:$R[2875]=[$R[2876]={type:"text",value:"\t\t\t{"}]},$R[2877]={type:"element",tagName:"span",properties:$R[2878]={style:"color:#BD976A"},children:$R[2879]=[$R[2880]={type:"text",value:"children"}]},$R[2881]={type:"element",tagName:"span",properties:$R[2882]={style:"color:#666666"},children:$R[2883]=[$R[2884]={type:"text",value:"}"}]}]},$R[2885]={type:"text",value:"\n"},$R[2886]={type:"element",tagName:"span",properties:$R[2887]={class:"line"},children:$R[2888]=[$R[2889]={type:"element",tagName:"span",properties:$R[2890]={style:"color:#666666"},children:$R[2891]=[$R[2892]={type:"text",value:"\t\t\x3C/"}]},$R[2893]={type:"element",tagName:"span",properties:$R[2894]={style:"color:#B8A965"},children:$R[2895]=[$R[2896]={type:"text",value:"CountAtomContext.Provider"}]},$R[2897]={type:"element",tagName:"span",properties:$R[2898]={style:"color:#666666"},children:$R[2899]=[$R[2900]={type:"text",value:">"}]}]},$R[2901]={type:"text",value:"\n"},$R[2902]={type:"element",tagName:"span",properties:$R[2903]={class:"line"},children:$R[2904]=[$R[2905]={type:"element",tagName:"span",properties:$R[2906]={style:"color:#666666"},children:$R[2907]=[$R[2908]={type:"text",value:"\t);"}]}]},$R[2909]={type:"text",value:"\n"},$R[2910]={type:"element",tagName:"span",properties:$R[2911]={class:"line"},children:$R[2912]=[$R[2913]={type:"element",tagName:"span",properties:$R[2914]={style:"color:#666666"},children:$R[2915]=[$R[2916]={type:"text",value:"}"}]}]},$R[2917]={type:"text",value:"\n"},$R[2918]={type:"element",tagName:"span",properties:$R[2919]={class:"line"},children:$R[2920]=[]},$R[2921]={type:"text",value:"\n"},$R[2922]={type:"element",tagName:"span",properties:$R[2923]={class:"line"},children:$R[2924]=[$R[2925]={type:"element",tagName:"span",properties:$R[2926]={style:"color:#CB7676"},children:$R[2927]=[$R[2928]={type:"text",value:"function"}]},$R[2929]={type:"element",tagName:"span",properties:$R[2930]={style:"color:#80A665"},children:$R[2931]=[$R[2932]={type:"text",value:" Counter"}]},$R[2933]={type:"element",tagName:"span",properties:$R[2934]={style:"color:#666666"},children:$R[2935]=[$R[2936]={type:"text",value:"()"}]},$R[2937]={type:"element",tagName:"span",properties:$R[2938]={style:"color:#666666"},children:$R[2939]=[$R[2940]={type:"text",value:" {"}]}]},$R[2941]={type:"text",value:"\n"},$R[2942]={type:"element",tagName:"span",properties:$R[2943]={class:"line"},children:$R[2944]=[$R[2945]={type:"element",tagName:"span",properties:$R[2946]={style:"color:#CB7676"},children:$R[2947]=[$R[2948]={type:"text",value:"\tconst"}]},$R[2949]={type:"element",tagName:"span",properties:$R[2950]={style:"color:#BD976A"},children:$R[2951]=[$R[2952]={type:"text",value:" countAtom"}]},$R[2953]={type:"element",tagName:"span",properties:$R[2954]={style:"color:#666666"},children:$R[2955]=[$R[2956]={type:"text",value:" ="}]},$R[2957]={type:"element",tagName:"span",properties:$R[2958]={style:"color:#80A665"},children:$R[2959]=[$R[2960]={type:"text",value:" useCountAtom"}]},$R[2961]={type:"element",tagName:"span",properties:$R[2962]={style:"color:#666666"},children:$R[2963]=[$R[2964]={type:"text",value:"();"}]}]},$R[2965]={type:"text",value:"\n"},$R[2966]={type:"element",tagName:"span",properties:$R[2967]={class:"line"},children:$R[2968]=[$R[2969]={type:"element",tagName:"span",properties:$R[2970]={style:"color:#CB7676"},children:$R[2971]=[$R[2972]={type:"text",value:"\tconst"}]},$R[2973]={type:"element",tagName:"span",properties:$R[2974]={style:"color:#666666"},children:$R[2975]=[$R[2976]={type:"text",value:" ["}]},$R[2977]={type:"element",tagName:"span",properties:$R[2978]={style:"color:#BD976A"},children:$R[2979]=[$R[2980]={type:"text",value:"count"}]},$R[2981]={type:"element",tagName:"span",properties:$R[2982]={style:"color:#666666"},children:$R[2983]=[$R[2984]={type:"text",value:","}]},$R[2985]={type:"element",tagName:"span",properties:$R[2986]={style:"color:#BD976A"},children:$R[2987]=[$R[2988]={type:"text",value:" setCount"}]},$R[2989]={type:"element",tagName:"span",properties:$R[2990]={style:"color:#666666"},children:$R[2991]=[$R[2992]={type:"text",value:"]"}]},$R[2993]={type:"element",tagName:"span",properties:$R[2994]={style:"color:#666666"},children:$R[2995]=[$R[2996]={type:"text",value:" ="}]},$R[2997]={type:"element",tagName:"span",properties:$R[2998]={style:"color:#80A665"},children:$R[2999]=[$R[3000]={type:"text",value:" useAtom"}]},$R[3001]={type:"element",tagName:"span",properties:$R[3002]={style:"color:#666666"},children:$R[3003]=[$R[3004]={type:"text",value:"("}]},$R[3005]={type:"element",tagName:"span",properties:$R[3006]={style:"color:#BD976A"},children:$R[3007]=[$R[3008]={type:"text",value:"countAtom"}]},$R[3009]={type:"element",tagName:"span",properties:$R[3010]={style:"color:#666666"},children:$R[3011]=[$R[3012]={type:"text",value:");"}]}]},$R[3013]={type:"text",value:"\n"},$R[3014]={type:"element",tagName:"span",properties:$R[3015]={class:"line"},children:$R[3016]=[$R[3017]={type:"element",tagName:"span",properties:$R[3018]={style:"color:#4D9375"},children:$R[3019]=[$R[3020]={type:"text",value:"\treturn"}]},$R[3021]={type:"element",tagName:"span",properties:$R[3022]={style:"color:#666666"},children:$R[3023]=[$R[3024]={type:"text",value:" ("}]}]},$R[3025]={type:"text",value:"\n"},$R[3026]={type:"element",tagName:"span",properties:$R[3027]={class:"line"},children:$R[3028]=[$R[3029]={type:"element",tagName:"span",properties:$R[3030]={style:"color:#666666"},children:$R[3031]=[$R[3032]={type:"text",value:"\t\t\x3C"}]},$R[3033]={type:"element",tagName:"span",properties:$R[3034]={style:"color:#4D9375"},children:$R[3035]=[$R[3036]={type:"text",value:"div"}]},$R[3037]={type:"element",tagName:"span",properties:$R[3038]={style:"color:#666666"},children:$R[3039]=[$R[3040]={type:"text",value:">"}]}]},$R[3041]={type:"text",value:"\n"},$R[3042]={type:"element",tagName:"span",properties:$R[3043]={class:"line"},children:$R[3044]=[$R[3045]={type:"element",tagName:"span",properties:$R[3046]={style:"color:#DBD7CAEE"},children:$R[3047]=[$R[3048]={type:"text",value:"\t\t\tcount:"}]}]},$R[3049]={type:"text",value:"\n"},$R[3050]={type:"element",tagName:"span",properties:$R[3051]={class:"line"},children:$R[3052]=[$R[3053]={type:"element",tagName:"span",properties:$R[3054]={style:"color:#666666"},children:$R[3055]=[$R[3056]={type:"text",value:"\t\t\t{"}]},$R[3057]={type:"element",tagName:"span",properties:$R[3058]={style:"color:#C98A7D77"},children:$R[3059]=[$R[3060]={type:"text",value:"\""}]},$R[3061]={type:"element",tagName:"span",properties:$R[3062]={style:"color:#C98A7D77"},children:$R[3063]=[$R[3064]={type:"text",value:" \""}]},$R[3065]={type:"element",tagName:"span",properties:$R[3066]={style:"color:#666666"},children:$R[3067]=[$R[3068]={type:"text",value:"}"}]}]},$R[3069]={type:"text",value:"\n"},$R[3070]={type:"element",tagName:"span",properties:$R[3071]={class:"line"},children:$R[3072]=[$R[3073]={type:"element",tagName:"span",properties:$R[3074]={style:"color:#666666"},children:$R[3075]=[$R[3076]={type:"text",value:"\t\t\t{"}]},$R[3077]={type:"element",tagName:"span",properties:$R[3078]={style:"color:#BD976A"},children:$R[3079]=[$R[3080]={type:"text",value:"count"}]},$R[3081]={type:"element",tagName:"span",properties:$R[3082]={style:"color:#666666"},children:$R[3083]=[$R[3084]={type:"text",value:"}"}]}]},$R[3085]={type:"text",value:"\n"},$R[3086]={type:"element",tagName:"span",properties:$R[3087]={class:"line"},children:$R[3088]=[$R[3089]={type:"element",tagName:"span",properties:$R[3090]={style:"color:#666666"},children:$R[3091]=[$R[3092]={type:"text",value:"\t\t\t{"}]},$R[3093]={type:"element",tagName:"span",properties:$R[3094]={style:"color:#C98A7D77"},children:$R[3095]=[$R[3096]={type:"text",value:"\""}]},$R[3097]={type:"element",tagName:"span",properties:$R[3098]={style:"color:#C98A7D77"},children:$R[3099]=[$R[3100]={type:"text",value:" \""}]},$R[3101]={type:"element",tagName:"span",properties:$R[3102]={style:"color:#666666"},children:$R[3103]=[$R[3104]={type:"text",value:"}"}]}]},$R[3105]={type:"text",value:"\n"},$R[3106]={type:"element",tagName:"span",properties:$R[3107]={class:"line"},children:$R[3108]=[$R[3109]={type:"element",tagName:"span",properties:$R[3110]={style:"color:#666666"},children:$R[3111]=[$R[3112]={type:"text",value:"\t\t\t\x3C"}]},$R[3113]={type:"element",tagName:"span",properties:$R[3114]={style:"color:#4D9375"},children:$R[3115]=[$R[3116]={type:"text",value:"button"}]},$R[3117]={type:"element",tagName:"span",properties:$R[3118]={style:"color:#BD976A"},children:$R[3119]=[$R[3120]={type:"text",value:" onClick"}]},$R[3121]={type:"element",tagName:"span",properties:$R[3122]={style:"color:#666666"},children:$R[3123]=[$R[3124]={type:"text",value:"={()"}]},$R[3125]={type:"element",tagName:"span",properties:$R[3126]={style:"color:#666666"},children:$R[3127]=[$R[3128]={type:"text",value:" =>"}]},$R[3129]={type:"element",tagName:"span",properties:$R[3130]={style:"color:#80A665"},children:$R[3131]=[$R[3132]={type:"text",value:" setCount"}]},$R[3133]={type:"element",tagName:"span",properties:$R[3134]={style:"color:#666666"},children:$R[3135]=[$R[3136]={type:"text",value:"("}]},$R[3137]={type:"element",tagName:"span",properties:$R[3138]={style:"color:#BD976A"},children:$R[3139]=[$R[3140]={type:"text",value:"c"}]},$R[3141]={type:"element",tagName:"span",properties:$R[3142]={style:"color:#666666"},children:$R[3143]=[$R[3144]={type:"text",value:" =>"}]},$R[3145]={type:"element",tagName:"span",properties:$R[3146]={style:"color:#BD976A"},children:$R[3147]=[$R[3148]={type:"text",value:" c"}]},$R[3149]={type:"element",tagName:"span",properties:$R[3150]={style:"color:#CB7676"},children:$R[3151]=[$R[3152]={type:"text",value:" +"}]},$R[3153]={type:"element",tagName:"span",properties:$R[3154]={style:"color:#4C9A91"},children:$R[3155]=[$R[3156]={type:"text",value:" 1"}]},$R[3157]={type:"element",tagName:"span",properties:$R[3158]={style:"color:#666666"},children:$R[3159]=[$R[3160]={type:"text",value:")}>"}]},$R[3161]={type:"element",tagName:"span",properties:$R[3162]={style:"color:#DBD7CAEE"},children:$R[3163]=[$R[3164]={type:"text",value:"+1"}]},$R[3165]={type:"element",tagName:"span",properties:$R[3166]={style:"color:#666666"},children:$R[3167]=[$R[3168]={type:"text",value:"\x3C/"}]},$R[3169]={type:"element",tagName:"span",properties:$R[3170]={style:"color:#4D9375"},children:$R[3171]=[$R[3172]={type:"text",value:"button"}]},$R[3173]={type:"element",tagName:"span",properties:$R[3174]={style:"color:#666666"},children:$R[3175]=[$R[3176]={type:"text",value:">"}]}]},$R[3177]={type:"text",value:"\n"},$R[3178]={type:"element",tagName:"span",properties:$R[3179]={class:"line"},children:$R[3180]=[$R[3181]={type:"element",tagName:"span",properties:$R[3182]={style:"color:#666666"},children:$R[3183]=[$R[3184]={type:"text",value:"\t\t\x3C/"}]},$R[3185]={type:"element",tagName:"span",properties:$R[3186]={style:"color:#4D9375"},children:$R[3187]=[$R[3188]={type:"text",value:"div"}]},$R[3189]={type:"element",tagName:"span",properties:$R[3190]={style:"color:#666666"},children:$R[3191]=[$R[3192]={type:"text",value:">"}]}]},$R[3193]={type:"text",value:"\n"},$R[3194]={type:"element",tagName:"span",properties:$R[3195]={class:"line"},children:$R[3196]=[$R[3197]={type:"element",tagName:"span",properties:$R[3198]={style:"color:#666666"},children:$R[3199]=[$R[3200]={type:"text",value:"\t);"}]}]},$R[3201]={type:"text",value:"\n"},$R[3202]={type:"element",tagName:"span",properties:$R[3203]={class:"line"},children:$R[3204]=[$R[3205]={type:"element",tagName:"span",properties:$R[3206]={style:"color:#666666"},children:$R[3207]=[$R[3208]={type:"text",value:"}"}]}]},$R[3209]={type:"text",value:"\n"},$R[3210]={type:"element",tagName:"span",properties:$R[3211]={class:"line"},children:$R[3212]=[]},$R[3213]={type:"text",value:"\n"},$R[3214]={type:"element",tagName:"span",properties:$R[3215]={class:"line"},children:$R[3216]=[$R[3217]={type:"element",tagName:"span",properties:$R[3218]={style:"color:#4D9375"},children:$R[3219]=[$R[3220]={type:"text",value:"export"}]},$R[3221]={type:"element",tagName:"span",properties:$R[3222]={style:"color:#CB7676"},children:$R[3223]=[$R[3224]={type:"text",value:" function"}]},$R[3225]={type:"element",tagName:"span",properties:$R[3226]={style:"color:#80A665"},children:$R[3227]=[$R[3228]={type:"text",value:" App"}]},$R[3229]={type:"element",tagName:"span",properties:$R[3230]={style:"color:#666666"},children:$R[3231]=[$R[3232]={type:"text",value:"()"}]},$R[3233]={type:"element",tagName:"span",properties:$R[3234]={style:"color:#666666"},children:$R[3235]=[$R[3236]={type:"text",value:" {"}]}]},$R[3237]={type:"text",value:"\n"},$R[3238]={type:"element",tagName:"span",properties:$R[3239]={class:"line"},children:$R[3240]=[$R[3241]={type:"element",tagName:"span",properties:$R[3242]={style:"color:#4D9375"},children:$R[3243]=[$R[3244]={type:"text",value:"\treturn"}]},$R[3245]={type:"element",tagName:"span",properties:$R[3246]={style:"color:#666666"},children:$R[3247]=[$R[3248]={type:"text",value:" ("}]}]},$R[3249]={type:"text",value:"\n"},$R[3250]={type:"element",tagName:"span",properties:$R[3251]={class:"line"},children:$R[3252]=[$R[3253]={type:"element",tagName:"span",properties:$R[3254]={style:"color:#666666"},children:$R[3255]=[$R[3256]={type:"text",value:"\t\t\x3C"}]},$R[3257]={type:"element",tagName:"span",properties:$R[3258]={style:"color:#B8A965"},children:$R[3259]=[$R[3260]={type:"text",value:"CountAtomScopeProvider"}]},$R[3261]={type:"element",tagName:"span",properties:$R[3262]={style:"color:#BD976A"},children:$R[3263]=[$R[3264]={type:"text",value:" userId"}]},$R[3265]={type:"element",tagName:"span",properties:$R[3266]={style:"color:#666666"},children:$R[3267]=[$R[3268]={type:"text",value:"="}]},$R[3269]={type:"element",tagName:"span",properties:$R[3270]={style:"color:#C98A7D77"},children:$R[3271]=[$R[3272]={type:"text",value:"\""}]},$R[3273]={type:"element",tagName:"span",properties:$R[3274]={style:"color:#C98A7D"},children:$R[3275]=[$R[3276]={type:"text",value:"bob@example.com"}]},$R[3277]={type:"element",tagName:"span",properties:$R[3278]={style:"color:#C98A7D77"},children:$R[3279]=[$R[3280]={type:"text",value:"\""}]},$R[3281]={type:"element",tagName:"span",properties:$R[3282]={style:"color:#666666"},children:$R[3283]=[$R[3284]={type:"text",value:">"}]}]},$R[3285]={type:"text",value:"\n"},$R[3286]={type:"element",tagName:"span",properties:$R[3287]={class:"line"},children:$R[3288]=[$R[3289]={type:"element",tagName:"span",properties:$R[3290]={style:"color:#666666"},children:$R[3291]=[$R[3292]={type:"text",value:"\t\t\t\x3C"}]},$R[3293]={type:"element",tagName:"span",properties:$R[3294]={style:"color:#B8A965"},children:$R[3295]=[$R[3296]={type:"text",value:"Counter"}]},$R[3297]={type:"element",tagName:"span",properties:$R[3298]={style:"color:#666666"},children:$R[3299]=[$R[3300]={type:"text",value:" />"}]}]},$R[3301]={type:"text",value:"\n"},$R[3302]={type:"element",tagName:"span",properties:$R[3303]={class:"line"},children:$R[3304]=[$R[3305]={type:"element",tagName:"span",properties:$R[3306]={style:"color:#666666"},children:$R[3307]=[$R[3308]={type:"text",value:"\t\t\t\x3C"}]},$R[3309]={type:"element",tagName:"span",properties:$R[3310]={style:"color:#B8A965"},children:$R[3311]=[$R[3312]={type:"text",value:"Counter"}]},$R[3313]={type:"element",tagName:"span",properties:$R[3314]={style:"color:#666666"},children:$R[3315]=[$R[3316]={type:"text",value:" />"}]}]},$R[3317]={type:"text",value:"\n"},$R[3318]={type:"element",tagName:"span",properties:$R[3319]={class:"line"},children:$R[3320]=[$R[3321]={type:"element",tagName:"span",properties:$R[3322]={style:"color:#666666"},children:$R[3323]=[$R[3324]={type:"text",value:"\t\t\t\x3C"}]},$R[3325]={type:"element",tagName:"span",properties:$R[3326]={style:"color:#B8A965"},children:$R[3327]=[$R[3328]={type:"text",value:"CountAtomScopeProvider"}]},$R[3329]={type:"element",tagName:"span",properties:$R[3330]={style:"color:#BD976A"},children:$R[3331]=[$R[3332]={type:"text",value:" userId"}]},$R[3333]={type:"element",tagName:"span",properties:$R[3334]={style:"color:#666666"},children:$R[3335]=[$R[3336]={type:"text",value:"="}]},$R[3337]={type:"element",tagName:"span",properties:$R[3338]={style:"color:#C98A7D77"},children:$R[3339]=[$R[3340]={type:"text",value:"\""}]},$R[3341]={type:"element",tagName:"span",properties:$R[3342]={style:"color:#C98A7D"},children:$R[3343]=[$R[3344]={type:"text",value:"tom@example.com"}]},$R[3345]={type:"element",tagName:"span",properties:$R[3346]={style:"color:#C98A7D77"},children:$R[3347]=[$R[3348]={type:"text",value:"\""}]},$R[3349]={type:"element",tagName:"span",properties:$R[3350]={style:"color:#666666"},children:$R[3351]=[$R[3352]={type:"text",value:">"}]}]},$R[3353]={type:"text",value:"\n"},$R[3354]={type:"element",tagName:"span",properties:$R[3355]={class:"line"},children:$R[3356]=[$R[3357]={type:"element",tagName:"span",properties:$R[3358]={style:"color:#666666"},children:$R[3359]=[$R[3360]={type:"text",value:"\t\t\t\t\x3C"}]},$R[3361]={type:"element",tagName:"span",properties:$R[3362]={style:"color:#B8A965"},children:$R[3363]=[$R[3364]={type:"text",value:"Counter"}]},$R[3365]={type:"element",tagName:"span",properties:$R[3366]={style:"color:#666666"},children:$R[3367]=[$R[3368]={type:"text",value:" />"}]}]},$R[3369]={type:"text",value:"\n"},$R[3370]={type:"element",tagName:"span",properties:$R[3371]={class:"line"},children:$R[3372]=[$R[3373]={type:"element",tagName:"span",properties:$R[3374]={style:"color:#666666"},children:$R[3375]=[$R[3376]={type:"text",value:"\t\t\t\t\x3C"}]},$R[3377]={type:"element",tagName:"span",properties:$R[3378]={style:"color:#B8A965"},children:$R[3379]=[$R[3380]={type:"text",value:"Counter"}]},$R[3381]={type:"element",tagName:"span",properties:$R[3382]={style:"color:#666666"},children:$R[3383]=[$R[3384]={type:"text",value:" />"}]}]},$R[3385]={type:"text",value:"\n"},$R[3386]={type:"element",tagName:"span",properties:$R[3387]={class:"line"},children:$R[3388]=[$R[3389]={type:"element",tagName:"span",properties:$R[3390]={style:"color:#666666"},children:$R[3391]=[$R[3392]={type:"text",value:"\t\t\t\x3C/"}]},$R[3393]={type:"element",tagName:"span",properties:$R[3394]={style:"color:#B8A965"},children:$R[3395]=[$R[3396]={type:"text",value:"CountAtomScopeProvider"}]},$R[3397]={type:"element",tagName:"span",properties:$R[3398]={style:"color:#666666"},children:$R[3399]=[$R[3400]={type:"text",value:">"}]}]},$R[3401]={type:"text",value:"\n"},$R[3402]={type:"element",tagName:"span",properties:$R[3403]={class:"line"},children:$R[3404]=[$R[3405]={type:"element",tagName:"span",properties:$R[3406]={style:"color:#666666"},children:$R[3407]=[$R[3408]={type:"text",value:"\t\t\x3C/"}]},$R[3409]={type:"element",tagName:"span",properties:$R[3410]={style:"color:#B8A965"},children:$R[3411]=[$R[3412]={type:"text",value:"CountAtomScopeProvider"}]},$R[3413]={type:"element",tagName:"span",properties:$R[3414]={style:"color:#666666"},children:$R[3415]=[$R[3416]={type:"text",value:">"}]}]},$R[3417]={type:"text",value:"\n"},$R[3418]={type:"element",tagName:"span",properties:$R[3419]={class:"line"},children:$R[3420]=[$R[3421]={type:"element",tagName:"span",properties:$R[3422]={style:"color:#666666"},children:$R[3423]=[$R[3424]={type:"text",value:"\t);"}]}]},$R[3425]={type:"text",value:"\n"},$R[3426]={type:"element",tagName:"span",properties:$R[3427]={class:"line"},children:$R[3428]=[$R[3429]={type:"element",tagName:"span",properties:$R[3430]={style:"color:#666666"},children:$R[3431]=[$R[3432]={type:"text",value:"}"}]}]}]}]}]}},$R[3433]={children:$R[3434]=[$R[3435]={position:$R[3436]={start:$R[3437]={line:225,column:1,offset:6000},end:$R[3438]={line:225,column:7,offset:6006}},type:"text",value:"上記の例は "},$R[3439]={position:$R[3440]={start:$R[3441]={line:225,column:7,offset:6006},end:$R[3442]={line:225,column:14,offset:6013}},type:"inlineCode",value:"jotai"},$R[3443]={position:$R[3444]={start:$R[3445]={line:225,column:14,offset:6013},end:$R[3446]={line:225,column:23,offset:6022}},type:"text",value:" を使っているが、"},$R[3447]={position:$R[3448]={start:$R[3449]={line:225,column:23,offset:6022},end:$R[3450]={line:225,column:31,offset:6030}},type:"inlineCode",value:"bunshi"},$R[3451]={position:$R[3452]={start:$R[3453]={line:225,column:31,offset:6030},end:$R[3454]={line:225,column:51,offset:6050}},type:"text",value:" も使うと以下のように書くことができる。"}],position:$R[3455]={start:$R[3456]={line:225,column:1,offset:6000},end:$R[3457]={line:225,column:51,offset:6050}},type:"paragraph"},$R[3458]={filename:"sample.tsx tsx",lang:"tsx",position:$R[3459]={start:$R[3460]={line:227,column:1,offset:6052},end:$R[3461]={line:252,column:4,offset:6556}},type:"code",value:"import { atom, useAtom } from \"jotai\";\nimport {\n\tScopeProvider,\n\tcreateScope,\n\tmolecule,\n\tuseMolecule,\n} from \"bunshi/react\";\n\nconst UserScope = createScope(undefined);\nconst countMolecule = molecule((mol, scope) => {\n\tconst userId = scope(UserScope);\n\tconsole.log(\"Creating a new atom for\", userId);\n\treturn atom(0);\n});\n\n// ... Counter unchanged\n\nexport function App() {\n\treturn (\n\t\t\x3CScopeProvider scope={UserScope} value=\"bob@example.com\">\n\t\t\t\x3CCounter />\n\t\t\x3C/ScopeProvider>\n\t);\n}",hast:$R[3462]={type:"root",children:$R[3463]=[$R[3464]={type:"element",tagName:"pre",properties:$R[3465]={class:"shiki vitesse-dark",style:"color: #dbd7cacc;",tabindex:"0"},children:$R[3466]=[$R[3467]={type:"element",tagName:"code",properties:$R[3468]={},children:$R[3469]=[$R[3470]={type:"element",tagName:"span",properties:$R[3471]={class:"line"},children:$R[3472]=[$R[3473]={type:"element",tagName:"span",properties:$R[3474]={style:"color:#4D9375"},children:$R[3475]=[$R[3476]={type:"text",value:"import"}]},$R[3477]={type:"element",tagName:"span",properties:$R[3478]={style:"color:#666666"},children:$R[3479]=[$R[3480]={type:"text",value:" {"}]},$R[3481]={type:"element",tagName:"span",properties:$R[3482]={style:"color:#BD976A"},children:$R[3483]=[$R[3484]={type:"text",value:" atom"}]},$R[3485]={type:"element",tagName:"span",properties:$R[3486]={style:"color:#666666"},children:$R[3487]=[$R[3488]={type:"text",value:","}]},$R[3489]={type:"element",tagName:"span",properties:$R[3490]={style:"color:#BD976A"},children:$R[3491]=[$R[3492]={type:"text",value:" useAtom"}]},$R[3493]={type:"element",tagName:"span",properties:$R[3494]={style:"color:#666666"},children:$R[3495]=[$R[3496]={type:"text",value:" }"}]},$R[3497]={type:"element",tagName:"span",properties:$R[3498]={style:"color:#4D9375"},children:$R[3499]=[$R[3500]={type:"text",value:" from"}]},$R[3501]={type:"element",tagName:"span",properties:$R[3502]={style:"color:#C98A7D77"},children:$R[3503]=[$R[3504]={type:"text",value:" \""}]},$R[3505]={type:"element",tagName:"span",properties:$R[3506]={style:"color:#C98A7D"},children:$R[3507]=[$R[3508]={type:"text",value:"jotai"}]},$R[3509]={type:"element",tagName:"span",properties:$R[3510]={style:"color:#C98A7D77"},children:$R[3511]=[$R[3512]={type:"text",value:"\""}]},$R[3513]={type:"element",tagName:"span",properties:$R[3514]={style:"color:#666666"},children:$R[3515]=[$R[3516]={type:"text",value:";"}]}]},$R[3517]={type:"text",value:"\n"},$R[3518]={type:"element",tagName:"span",properties:$R[3519]={class:"line"},children:$R[3520]=[$R[3521]={type:"element",tagName:"span",properties:$R[3522]={style:"color:#4D9375"},children:$R[3523]=[$R[3524]={type:"text",value:"import"}]},$R[3525]={type:"element",tagName:"span",properties:$R[3526]={style:"color:#666666"},children:$R[3527]=[$R[3528]={type:"text",value:" {"}]}]},$R[3529]={type:"text",value:"\n"},$R[3530]={type:"element",tagName:"span",properties:$R[3531]={class:"line"},children:$R[3532]=[$R[3533]={type:"element",tagName:"span",properties:$R[3534]={style:"color:#BD976A"},children:$R[3535]=[$R[3536]={type:"text",value:"\tScopeProvider"}]},$R[3537]={type:"element",tagName:"span",properties:$R[3538]={style:"color:#666666"},children:$R[3539]=[$R[3540]={type:"text",value:","}]}]},$R[3541]={type:"text",value:"\n"},$R[3542]={type:"element",tagName:"span",properties:$R[3543]={class:"line"},children:$R[3544]=[$R[3545]={type:"element",tagName:"span",properties:$R[3546]={style:"color:#BD976A"},children:$R[3547]=[$R[3548]={type:"text",value:"\tcreateScope"}]},$R[3549]={type:"element",tagName:"span",properties:$R[3550]={style:"color:#666666"},children:$R[3551]=[$R[3552]={type:"text",value:","}]}]},$R[3553]={type:"text",value:"\n"},$R[3554]={type:"element",tagName:"span",properties:$R[3555]={class:"line"},children:$R[3556]=[$R[3557]={type:"element",tagName:"span",properties:$R[3558]={style:"color:#BD976A"},children:$R[3559]=[$R[3560]={type:"text",value:"\tmolecule"}]},$R[3561]={type:"element",tagName:"span",properties:$R[3562]={style:"color:#666666"},children:$R[3563]=[$R[3564]={type:"text",value:","}]}]},$R[3565]={type:"text",value:"\n"},$R[3566]={type:"element",tagName:"span",properties:$R[3567]={class:"line"},children:$R[3568]=[$R[3569]={type:"element",tagName:"span",properties:$R[3570]={style:"color:#BD976A"},children:$R[3571]=[$R[3572]={type:"text",value:"\tuseMolecule"}]},$R[3573]={type:"element",tagName:"span",properties:$R[3574]={style:"color:#666666"},children:$R[3575]=[$R[3576]={type:"text",value:","}]}]},$R[3577]={type:"text",value:"\n"},$R[3578]={type:"element",tagName:"span",properties:$R[3579]={class:"line"},children:$R[3580]=[$R[3581]={type:"element",tagName:"span",properties:$R[3582]={style:"color:#666666"},children:$R[3583]=[$R[3584]={type:"text",value:"}"}]},$R[3585]={type:"element",tagName:"span",properties:$R[3586]={style:"color:#4D9375"},children:$R[3587]=[$R[3588]={type:"text",value:" from"}]},$R[3589]={type:"element",tagName:"span",properties:$R[3590]={style:"color:#C98A7D77"},children:$R[3591]=[$R[3592]={type:"text",value:" \""}]},$R[3593]={type:"element",tagName:"span",properties:$R[3594]={style:"color:#C98A7D"},children:$R[3595]=[$R[3596]={type:"text",value:"bunshi/react"}]},$R[3597]={type:"element",tagName:"span",properties:$R[3598]={style:"color:#C98A7D77"},children:$R[3599]=[$R[3600]={type:"text",value:"\""}]},$R[3601]={type:"element",tagName:"span",properties:$R[3602]={style:"color:#666666"},children:$R[3603]=[$R[3604]={type:"text",value:";"}]}]},$R[3605]={type:"text",value:"\n"},$R[3606]={type:"element",tagName:"span",properties:$R[3607]={class:"line"},children:$R[3608]=[]},$R[3609]={type:"text",value:"\n"},$R[3610]={type:"element",tagName:"span",properties:$R[3611]={class:"line"},children:$R[3612]=[$R[3613]={type:"element",tagName:"span",properties:$R[3614]={style:"color:#CB7676"},children:$R[3615]=[$R[3616]={type:"text",value:"const"}]},$R[3617]={type:"element",tagName:"span",properties:$R[3618]={style:"color:#BD976A"},children:$R[3619]=[$R[3620]={type:"text",value:" UserScope"}]},$R[3621]={type:"element",tagName:"span",properties:$R[3622]={style:"color:#666666"},children:$R[3623]=[$R[3624]={type:"text",value:" ="}]},$R[3625]={type:"element",tagName:"span",properties:$R[3626]={style:"color:#80A665"},children:$R[3627]=[$R[3628]={type:"text",value:" createScope"}]},$R[3629]={type:"element",tagName:"span",properties:$R[3630]={style:"color:#666666"},children:$R[3631]=[$R[3632]={type:"text",value:"("}]},$R[3633]={type:"element",tagName:"span",properties:$R[3634]={style:"color:#CB7676"},children:$R[3635]=[$R[3636]={type:"text",value:"undefined"}]},$R[3637]={type:"element",tagName:"span",properties:$R[3638]={style:"color:#666666"},children:$R[3639]=[$R[3640]={type:"text",value:");"}]}]},$R[3641]={type:"text",value:"\n"},$R[3642]={type:"element",tagName:"span",properties:$R[3643]={class:"line"},children:$R[3644]=[$R[3645]={type:"element",tagName:"span",properties:$R[3646]={style:"color:#CB7676"},children:$R[3647]=[$R[3648]={type:"text",value:"const"}]},$R[3649]={type:"element",tagName:"span",properties:$R[3650]={style:"color:#BD976A"},children:$R[3651]=[$R[3652]={type:"text",value:" countMolecule"}]},$R[3653]={type:"element",tagName:"span",properties:$R[3654]={style:"color:#666666"},children:$R[3655]=[$R[3656]={type:"text",value:" ="}]},$R[3657]={type:"element",tagName:"span",properties:$R[3658]={style:"color:#80A665"},children:$R[3659]=[$R[3660]={type:"text",value:" molecule"}]},$R[3661]={type:"element",tagName:"span",properties:$R[3662]={style:"color:#666666"},children:$R[3663]=[$R[3664]={type:"text",value:"(("}]},$R[3665]={type:"element",tagName:"span",properties:$R[3666]={style:"color:#BD976A"},children:$R[3667]=[$R[3668]={type:"text",value:"mol"}]},$R[3669]={type:"element",tagName:"span",properties:$R[3670]={style:"color:#666666"},children:$R[3671]=[$R[3672]={type:"text",value:","}]},$R[3673]={type:"element",tagName:"span",properties:$R[3674]={style:"color:#BD976A"},children:$R[3675]=[$R[3676]={type:"text",value:" scope"}]},$R[3677]={type:"element",tagName:"span",properties:$R[3678]={style:"color:#666666"},children:$R[3679]=[$R[3680]={type:"text",value:")"}]},$R[3681]={type:"element",tagName:"span",properties:$R[3682]={style:"color:#666666"},children:$R[3683]=[$R[3684]={type:"text",value:" =>"}]},$R[3685]={type:"element",tagName:"span",properties:$R[3686]={style:"color:#666666"},children:$R[3687]=[$R[3688]={type:"text",value:" {"}]}]},$R[3689]={type:"text",value:"\n"},$R[3690]={type:"element",tagName:"span",properties:$R[3691]={class:"line"},children:$R[3692]=[$R[3693]={type:"element",tagName:"span",properties:$R[3694]={style:"color:#CB7676"},children:$R[3695]=[$R[3696]={type:"text",value:"\tconst"}]},$R[3697]={type:"element",tagName:"span",properties:$R[3698]={style:"color:#BD976A"},children:$R[3699]=[$R[3700]={type:"text",value:" userId"}]},$R[3701]={type:"element",tagName:"span",properties:$R[3702]={style:"color:#666666"},children:$R[3703]=[$R[3704]={type:"text",value:" ="}]},$R[3705]={type:"element",tagName:"span",properties:$R[3706]={style:"color:#80A665"},children:$R[3707]=[$R[3708]={type:"text",value:" scope"}]},$R[3709]={type:"element",tagName:"span",properties:$R[3710]={style:"color:#666666"},children:$R[3711]=[$R[3712]={type:"text",value:"("}]},$R[3713]={type:"element",tagName:"span",properties:$R[3714]={style:"color:#BD976A"},children:$R[3715]=[$R[3716]={type:"text",value:"UserScope"}]},$R[3717]={type:"element",tagName:"span",properties:$R[3718]={style:"color:#666666"},children:$R[3719]=[$R[3720]={type:"text",value:");"}]}]},$R[3721]={type:"text",value:"\n"},$R[3722]={type:"element",tagName:"span",properties:$R[3723]={class:"line"},children:$R[3724]=[$R[3725]={type:"element",tagName:"span",properties:$R[3726]={style:"color:#BD976A"},children:$R[3727]=[$R[3728]={type:"text",value:"\tconsole"}]},$R[3729]={type:"element",tagName:"span",properties:$R[3730]={style:"color:#666666"},children:$R[3731]=[$R[3732]={type:"text",value:"."}]},$R[3733]={type:"element",tagName:"span",properties:$R[3734]={style:"color:#80A665"},children:$R[3735]=[$R[3736]={type:"text",value:"log"}]},$R[3737]={type:"element",tagName:"span",properties:$R[3738]={style:"color:#666666"},children:$R[3739]=[$R[3740]={type:"text",value:"("}]},$R[3741]={type:"element",tagName:"span",properties:$R[3742]={style:"color:#C98A7D77"},children:$R[3743]=[$R[3744]={type:"text",value:"\""}]},$R[3745]={type:"element",tagName:"span",properties:$R[3746]={style:"color:#C98A7D"},children:$R[3747]=[$R[3748]={type:"text",value:"Creating a new atom for"}]},$R[3749]={type:"element",tagName:"span",properties:$R[3750]={style:"color:#C98A7D77"},children:$R[3751]=[$R[3752]={type:"text",value:"\""}]},$R[3753]={type:"element",tagName:"span",properties:$R[3754]={style:"color:#666666"},children:$R[3755]=[$R[3756]={type:"text",value:","}]},$R[3757]={type:"element",tagName:"span",properties:$R[3758]={style:"color:#BD976A"},children:$R[3759]=[$R[3760]={type:"text",value:" userId"}]},$R[3761]={type:"element",tagName:"span",properties:$R[3762]={style:"color:#666666"},children:$R[3763]=[$R[3764]={type:"text",value:");"}]}]},$R[3765]={type:"text",value:"\n"},$R[3766]={type:"element",tagName:"span",properties:$R[3767]={class:"line"},children:$R[3768]=[$R[3769]={type:"element",tagName:"span",properties:$R[3770]={style:"color:#4D9375"},children:$R[3771]=[$R[3772]={type:"text",value:"\treturn"}]},$R[3773]={type:"element",tagName:"span",properties:$R[3774]={style:"color:#80A665"},children:$R[3775]=[$R[3776]={type:"text",value:" atom"}]},$R[3777]={type:"element",tagName:"span",properties:$R[3778]={style:"color:#666666"},children:$R[3779]=[$R[3780]={type:"text",value:"("}]},$R[3781]={type:"element",tagName:"span",properties:$R[3782]={style:"color:#4C9A91"},children:$R[3783]=[$R[3784]={type:"text",value:"0"}]},$R[3785]={type:"element",tagName:"span",properties:$R[3786]={style:"color:#666666"},children:$R[3787]=[$R[3788]={type:"text",value:");"}]}]},$R[3789]={type:"text",value:"\n"},$R[3790]={type:"element",tagName:"span",properties:$R[3791]={class:"line"},children:$R[3792]=[$R[3793]={type:"element",tagName:"span",properties:$R[3794]={style:"color:#666666"},children:$R[3795]=[$R[3796]={type:"text",value:"});"}]}]},$R[3797]={type:"text",value:"\n"},$R[3798]={type:"element",tagName:"span",properties:$R[3799]={class:"line"},children:$R[3800]=[]},$R[3801]={type:"text",value:"\n"},$R[3802]={type:"element",tagName:"span",properties:$R[3803]={class:"line"},children:$R[3804]=[$R[3805]={type:"element",tagName:"span",properties:$R[3806]={style:"color:#758575DD"},children:$R[3807]=[$R[3808]={type:"text",value:"// ... Counter unchanged"}]}]},$R[3809]={type:"text",value:"\n"},$R[3810]={type:"element",tagName:"span",properties:$R[3811]={class:"line"},children:$R[3812]=[]},$R[3813]={type:"text",value:"\n"},$R[3814]={type:"element",tagName:"span",properties:$R[3815]={class:"line"},children:$R[3816]=[$R[3817]={type:"element",tagName:"span",properties:$R[3818]={style:"color:#4D9375"},children:$R[3819]=[$R[3820]={type:"text",value:"export"}]},$R[3821]={type:"element",tagName:"span",properties:$R[3822]={style:"color:#CB7676"},children:$R[3823]=[$R[3824]={type:"text",value:" function"}]},$R[3825]={type:"element",tagName:"span",properties:$R[3826]={style:"color:#80A665"},children:$R[3827]=[$R[3828]={type:"text",value:" App"}]},$R[3829]={type:"element",tagName:"span",properties:$R[3830]={style:"color:#666666"},children:$R[3831]=[$R[3832]={type:"text",value:"()"}]},$R[3833]={type:"element",tagName:"span",properties:$R[3834]={style:"color:#666666"},children:$R[3835]=[$R[3836]={type:"text",value:" {"}]}]},$R[3837]={type:"text",value:"\n"},$R[3838]={type:"element",tagName:"span",properties:$R[3839]={class:"line"},children:$R[3840]=[$R[3841]={type:"element",tagName:"span",properties:$R[3842]={style:"color:#4D9375"},children:$R[3843]=[$R[3844]={type:"text",value:"\treturn"}]},$R[3845]={type:"element",tagName:"span",properties:$R[3846]={style:"color:#666666"},children:$R[3847]=[$R[3848]={type:"text",value:" ("}]}]},$R[3849]={type:"text",value:"\n"},$R[3850]={type:"element",tagName:"span",properties:$R[3851]={class:"line"},children:$R[3852]=[$R[3853]={type:"element",tagName:"span",properties:$R[3854]={style:"color:#666666"},children:$R[3855]=[$R[3856]={type:"text",value:"\t\t\x3C"}]},$R[3857]={type:"element",tagName:"span",properties:$R[3858]={style:"color:#B8A965"},children:$R[3859]=[$R[3860]={type:"text",value:"ScopeProvider"}]},$R[3861]={type:"element",tagName:"span",properties:$R[3862]={style:"color:#BD976A"},children:$R[3863]=[$R[3864]={type:"text",value:" scope"}]},$R[3865]={type:"element",tagName:"span",properties:$R[3866]={style:"color:#666666"},children:$R[3867]=[$R[3868]={type:"text",value:"={"}]},$R[3869]={type:"element",tagName:"span",properties:$R[3870]={style:"color:#BD976A"},children:$R[3871]=[$R[3872]={type:"text",value:"UserScope"}]},$R[3873]={type:"element",tagName:"span",properties:$R[3874]={style:"color:#666666"},children:$R[3875]=[$R[3876]={type:"text",value:"}"}]},$R[3877]={type:"element",tagName:"span",properties:$R[3878]={style:"color:#BD976A"},children:$R[3879]=[$R[3880]={type:"text",value:" value"}]},$R[3881]={type:"element",tagName:"span",properties:$R[3882]={style:"color:#666666"},children:$R[3883]=[$R[3884]={type:"text",value:"="}]},$R[3885]={type:"element",tagName:"span",properties:$R[3886]={style:"color:#C98A7D77"},children:$R[3887]=[$R[3888]={type:"text",value:"\""}]},$R[3889]={type:"element",tagName:"span",properties:$R[3890]={style:"color:#C98A7D"},children:$R[3891]=[$R[3892]={type:"text",value:"bob@example.com"}]},$R[3893]={type:"element",tagName:"span",properties:$R[3894]={style:"color:#C98A7D77"},children:$R[3895]=[$R[3896]={type:"text",value:"\""}]},$R[3897]={type:"element",tagName:"span",properties:$R[3898]={style:"color:#666666"},children:$R[3899]=[$R[3900]={type:"text",value:">"}]}]},$R[3901]={type:"text",value:"\n"},$R[3902]={type:"element",tagName:"span",properties:$R[3903]={class:"line"},children:$R[3904]=[$R[3905]={type:"element",tagName:"span",properties:$R[3906]={style:"color:#666666"},children:$R[3907]=[$R[3908]={type:"text",value:"\t\t\t\x3C"}]},$R[3909]={type:"element",tagName:"span",properties:$R[3910]={style:"color:#B8A965"},children:$R[3911]=[$R[3912]={type:"text",value:"Counter"}]},$R[3913]={type:"element",tagName:"span",properties:$R[3914]={style:"color:#666666"},children:$R[3915]=[$R[3916]={type:"text",value:" />"}]}]},$R[3917]={type:"text",value:"\n"},$R[3918]={type:"element",tagName:"span",properties:$R[3919]={class:"line"},children:$R[3920]=[$R[3921]={type:"element",tagName:"span",properties:$R[3922]={style:"color:#666666"},children:$R[3923]=[$R[3924]={type:"text",value:"\t\t\x3C/"}]},$R[3925]={type:"element",tagName:"span",properties:$R[3926]={style:"color:#B8A965"},children:$R[3927]=[$R[3928]={type:"text",value:"ScopeProvider"}]},$R[3929]={type:"element",tagName:"span",properties:$R[3930]={style:"color:#666666"},children:$R[3931]=[$R[3932]={type:"text",value:">"}]}]},$R[3933]={type:"text",value:"\n"},$R[3934]={type:"element",tagName:"span",properties:$R[3935]={class:"line"},children:$R[3936]=[$R[3937]={type:"element",tagName:"span",properties:$R[3938]={style:"color:#666666"},children:$R[3939]=[$R[3940]={type:"text",value:"\t);"}]}]},$R[3941]={type:"text",value:"\n"},$R[3942]={type:"element",tagName:"span",properties:$R[3943]={class:"line"},children:$R[3944]=[$R[3945]={type:"element",tagName:"span",properties:$R[3946]={style:"color:#666666"},children:$R[3947]=[$R[3948]={type:"text",value:"}"}]}]}]}]}]}}],position:$R[3949]={end:$R[3950]={line:252,column:4,offset:6556},start:$R[3951]={line:174,column:1,offset:4855}},type:"section"},$R[3952]={children:$R[3953]=[$R[3954]={children:$R[3955]=[$R[3956]={position:$R[3957]={start:$R[3958]={line:254,column:4,offset:6561},end:$R[3959]={line:254,column:7,offset:6564}},type:"text",value:"まとめ"}],id:"まとめ",level:2,plain:"まとめ",position:$R[3960]={start:$R[3961]={line:254,column:1,offset:6558},end:$R[3962]={line:254,column:7,offset:6564}},type:"heading"},$R[3963]={children:$R[3964]=[$R[3965]={position:$R[3966]={start:$R[3967]={line:256,column:1,offset:6566},end:$R[3968]={line:256,column:5,offset:6570}},type:"text",value:"今回は "},$R[3969]={position:$R[3970]={start:$R[3971]={line:256,column:5,offset:6570},end:$R[3972]={line:256,column:13,offset:6578}},type:"inlineCode",value:"bunshi"},$R[3973]={position:$R[3974]={start:$R[3975]={line:256,column:13,offset:6578},end:$R[3976]={line:256,column:104,offset:6669}},type:"text",value:" というライブラリの基本概念からその魅力までを調べた。途中で実装の方を参照することが多々あったが、ほとんどテストされていてドキュメントも充実しているため、理解するのは難しくなかった。"}],position:$R[3977]={start:$R[3978]={line:256,column:1,offset:6566},end:$R[3979]={line:256,column:104,offset:6669}},type:"paragraph"},$R[3980]={children:$R[3981]=[$R[3982]={position:$R[3983]={start:$R[3984]={line:258,column:1,offset:6671},end:$R[3985]={line:258,column:9,offset:6679}},type:"inlineCode",value:"bunshi"},$R[3986]={position:$R[3987]={start:$R[3988]={line:258,column:9,offset:6679},end:$R[3989]={line:258,column:39,offset:6709}},type:"text",value:" を使って状態管理のベストプラクティスを追求したいと思った。"}],position:$R[3990]={start:$R[3991]={line:258,column:1,offset:6671},end:$R[3992]={line:258,column:39,offset:6709}},type:"paragraph"}],position:$R[3993]={end:$R[3994]={line:258,column:39,offset:6709},start:$R[3995]={line:254,column:1,offset:6558}},type:"section"}],footnotes:$R[3996]=[$R[3997]={children:$R[3998]=[$R[3999]={children:$R[4000]=[$R[4001]={position:$R[4002]={start:$R[4003]={line:25,column:7,offset:597},end:$R[4004]={line:25,column:14,offset:604}},type:"inlineCode",value:"React"},$R[4005]={position:$R[4006]={start:$R[4007]={line:25,column:14,offset:604},end:$R[4008]={line:25,column:17,offset:607}},type:"text",value:" と "},$R[4009]={position:$R[4010]={start:$R[4011]={line:25,column:17,offset:607},end:$R[4012]={line:25,column:22,offset:612}},type:"inlineCode",value:"Vue"},$R[4013]={position:$R[4014]={start:$R[4015]={line:25,column:22,offset:612},end:$R[4016]={line:25,column:52,offset:642}},type:"text",value:" は専用の API が用意されている。詳しくはこちらを参照。"},$R[4017]={children:$R[4018]=[$R[4019]={position:$R[4020]={start:$R[4021]={line:25,column:53,offset:643},end:$R[4022]={line:25,column:58,offset:648}},type:"text",value:"React"}],position:$R[4023]={start:$R[4024]={line:25,column:52,offset:642},end:$R[4025]={line:25,column:103,offset:693}},title:void 0,type:"link",url:"https://www.bunshi.org/integrations/react/"},$R[4026]={position:$R[4027]={start:$R[4028]={line:25,column:103,offset:693},end:$R[4029]={line:25,column:104,offset:694}},type:"text",value:"、"},$R[4030]={children:$R[4031]=[$R[4032]={position:$R[4033]={start:$R[4034]={line:25,column:105,offset:695},end:$R[4035]={line:25,column:108,offset:698}},type:"text",value:"Vue"}],position:$R[4036]={start:$R[4037]={line:25,column:104,offset:694},end:$R[4038]={line:25,column:151,offset:741}},title:void 0,type:"link",url:"https://www.bunshi.org/integrations/vue/"}],position:$R[4039]={start:$R[4040]={line:25,column:7,offset:597},end:$R[4041]={line:25,column:151,offset:741}},type:"paragraph"}],count:1,index:0,position:$R[4042]={start:$R[4043]={line:25,column:1,offset:591},end:$R[4044]={line:25,column:151,offset:741}},type:"footnoteDefinition"},$R[4045]={children:$R[4046]=[$R[4047]={children:$R[4048]=[$R[4049]={children:$R[4050]=[$R[4051]={position:$R[4052]={start:$R[4053]={line:31,column:8,offset:865},end:$R[4054]={line:31,column:20,offset:877}},type:"text",value:"Why WeakMap?"}],position:$R[4055]={start:$R[4056]={line:31,column:7,offset:864},end:$R[4057]={line:31,column:123,offset:980}},title:void 0,type:"link",url:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap#why_weakmap"}],position:$R[4058]={start:$R[4059]={line:31,column:7,offset:864},end:$R[4060]={line:31,column:123,offset:980}},type:"paragraph"}],count:1,index:1,position:$R[4061]={start:$R[4062]={line:31,column:1,offset:858},end:$R[4063]={line:31,column:123,offset:980}},type:"footnoteDefinition"},$R[4064]={children:$R[4065]=[$R[4066]={children:$R[4067]=[$R[4068]={position:$R[4069]={start:$R[4070]={line:172,column:7,offset:4799},end:$R[4071]={line:172,column:25,offset:4817}},type:"inlineCode",value:"reflect-metadata"},$R[4072]={position:$R[4073]={start:$R[4074]={line:172,column:25,offset:4817},end:$R[4075]={line:172,column:61,offset:4853}},type:"text",value:" はバンドルに含めるとサイズが大きくなるため、筆者はあまり使いたくない。"}],position:$R[4076]={start:$R[4077]={line:172,column:7,offset:4799},end:$R[4078]={line:172,column:61,offset:4853}},type:"paragraph"}],count:1,index:2,position:$R[4079]={start:$R[4080]={line:172,column:1,offset:4793},end:$R[4081]={line:172,column:61,offset:4853}},type:"footnoteDefinition"}],title:$R[4082]={children:$R[4083]=[$R[4084]={position:$R[4085]={start:$R[4086]={line:1,column:3,offset:2},end:$R[4087]={line:1,column:14,offset:13}},type:"text",value:"bunshiを理解する"}],id:"bunshiを理解する",level:1,plain:"bunshiを理解する",position:$R[4088]={start:$R[4089]={line:1,column:1,offset:0},end:$R[4090]={line:1,column:14,offset:13}},type:"heading"},toc:$R[4091]=[$R[4092]={children:$R[4093]=[],id:"はじめに",plain:"はじめに",type:"toc"},$R[4094]={children:$R[4095]=[$R[4096]={children:$R[4097]=[],id:"バンドルサイズが小さい",plain:"バンドルサイズが小さい",type:"toc"},$R[4098]={children:$R[4099]=[],id:"framework-agnosticである",plain:"framework agnosticである",type:"toc"},$R[4100]={children:$R[4101]=[],id:"パフォーマンスに配慮されている",plain:"パフォーマンスに配慮されている",type:"toc"}],id:"bunshiの特徴",plain:"bunshiの特徴",type:"toc"},$R[4102]={children:$R[4103]=[$R[4104]={children:$R[4105]=[],id:"molecule",plain:"molecule",type:"toc"},$R[4106]={children:$R[4107]=[],id:"scope",plain:"scope",type:"toc"},$R[4108]={children:$R[4109]=[$R[4110]={children:$R[4111]=[],id:"created",plain:"Created",type:"toc"},$R[4112]={children:$R[4113]=[],id:"mounted",plain:"Mounted",type:"toc"},$R[4114]={children:$R[4115]=[],id:"unmounted",plain:"Unmounted",type:"toc"}],id:"lifecycle",plain:"lifecycle",type:"toc"}],id:"bunshiの基本概念",plain:"bunshiの基本概念",type:"toc"},$R[4116]={children:$R[4117]=[],id:"個人的に面白いと思ったポイント",plain:"個人的に面白いと思ったポイント",type:"toc"},$R[4118]={children:$R[4119]=[],id:"結局何が嬉しい",plain:"結局何が嬉しい?",type:"toc"},$R[4120]={children:$R[4121]=[],id:"まとめ",plain:"まとめ",type:"toc"}],type:"article"}});$R[4122]($R[2],!0);$R[4122]($R[3],$R[5]);$R[4122]($R[4],!0);
bunshiを理解するbunshi というライブラリがある。状態管理ライブラリの DI を行うものだ。
jotai
を使う機会があり、調べを進める中で当時名前を聞いた jotai-molecule
が bunshi
という名前で良い感じに開発されていて気になったので調べてみる。
注意: この記事が書かれた当時の情報であり、最新の情報とは異なる可能性がある。bunshi
のバージョンは 2.1.5
である。
bunshi
は次のような特徴を持つ。
gzip 圧縮されたサイズで 1.18KB しかない。また他のライブラリに依存いていないのも大きな特徴だ。
bunshi
は jotai
や zustand
、nanostores
などの状態管理ライブラリを molecule
という概念でラップすることで、状態のスコープ管理や依存注入を行うことができる。
molecule
の宣言は framework agnostic であるため、ロジックをフレームワークに依存させず書くことができる1。
WeakMap
を用いたメモリリークの防止2や、不要な再レンダリングを防止するためにフレームワークのインテグレーション(React
, Vue
)ではメモ化を行っている。
bunshi は次の 3 つの概念で構成される。
molecule
は bunshi
の core 的な概念であり、実態は値を返す関数の HoF である。
最大の特徴は、関数の実行結果がキャッシュされることである。以下の例は常に同じ乱数を返す。
import { molecule } from "bunshi";
export const RandomMolecule = molecule(() => Math.random());
また molecule
は他の molecule
に依存できる。
import { molecule } from "bunshi";
export const RandomMolecule = molecule(() => Math.random());
export const UsernameMolecule = molecule(
mol => `You are user ${mol(RandomMolecule)}`,
);
export const IDMolecule = molecule(mol => `ID: ${mol(RandomMolecule)}`);
依存は自動で解決されるため、コード保守やテストが容易になる。
ロジックなどを molecule
に閉じ込めることでコードは非結合で遅延的となる。
scope
は molecule
を異なるコンポーネントで共通の環境を共有して使うための依存関係のグラフを構築するための概念である。
createScope
関数を使って scope
を作成する。
import { createScope } from "bunshi";
/**
* Scope for a user id
*/
export const UserScope = createScope<string>("[email protected]");
宣言した scope
はフレームワークによって異なる方法でプロバイダーを提供する。私は React
を使っているので、React
でのプロバイダーの提供方法を示す。
import { ScopeProvider } from "bunshi/react";
import type { ReactElement } from "react";
import { UserScope } from "./scopes";
export function App({ children }: Props): ReactElement {
return (
<ScopeProvider scope={UserScope}>
{children}
</ScopeProvider>
);
}
scope
の真価は、molecule
を scope
に依存させることで発揮する。
import { molecule } from "bunshi";
import { UserScope } from "./scopes";
export const UsernameMolecule = molecule(
(_mol, scope) => `You are user ${scope(UserScope)}`,
);
scope
を molecule
に依存させることで molecule
はアプリケーション全体で 1 回実行されるのではなく、scope
をマウントするごとに再実行される。また、scope
に渡した値は scope
プロバイダー内部の molecule
から scope()
関数を通じて取得できる。
molecule
はアプリケーションやスコープに応じて必要なときに実行され使用中であることを示すためマウントされ、必要でなくなったらアンマウントされ GC される。
以下の図は 公式のドキュメント から引用したものである。とてもわかりやすい。
次の例のように onMount
関数とその cleanup 関数を使って molecule
のマウントとアンマウント時の処理を行うことができる。
import { molecule, onMount } from "bunshi";
import { atom } from "jotai/vanilla";
export const CountMolecule = molecule(() => {
console.log("Created");
onMount(() => {
console.log("Mounted");
return () => console.log("Unmounted");
});
return atom(0);
});
次にライフサイクルの各ステップについて説明する。
アプリケーションが初期化された時、scope
を登録したプロバイダーがマウントされた時などに molecule
の値は作成され、すべての値は GC 可能になる。
molecule
の値は実行されただけではキャッシュされない。React
や Vue
では useMolecule
フックを使用して molecule
をマウントすることでキャッシュされる。
molecule
の値が使用されなくなると、molecule
はアンマウントされ、GC される。React
や Vue
では useMolecule
フックで自動的にアンマウントされる。
React Strict mode を使用している方は unmount された後に再度 mount されることがあるので、この点に注意が必要である。useEffect
などのフックの正当性を確認するために 2 回実行されるのと同じように、molecule
も 2 回実行されることがある。この時、mount -> unmount -> mount
の順番で実行される。
MoleculeInjector
(を生成する createInjector
)と moleculeInterface
だ。
moleculeInterface
MoleculeInjector
それぞれ bunshi
の依存関係のグラフを構築するための DI コンテナと、他の molecule
が依存できるための参照を提供するものだ。ドキュメントにある通り、どちらも molecule
や useMolecule
の裏で使用されておりユーザーがこれらを直接使用するのはテストコードを書く場合やライブラリとして molecule
を提供する場合などに限られる。
私がこれらの機能を面白いと感じたのは、今まで TS の DI コンテナと言われると、NestJS に乗っかるか、TSyringe であった。前者はバックエンドを構築するためのフレームワークなので、そもそもフロントエンド文脈で使うことがない。また TSyringe は DI コンテナとしては良くできている。循環依存やインスタンスを使い捨てるなどができるが、デコレータを使用する必要があり reflect-metadata
を使う制約がある3。
その点 bunshi
はスコープで分けられていて、かつ自動で DI される仕組みをとても気に入っている。
bunshi
を使うことで、ステートのリフトアップやプッシュダウンを容易に実現できる。以下の 2 つの例を見れば一目瞭然であると言える。
import { atom, useAtom } from "jotai";
function createAtom(userId: string) {
return atom(userId === "[email protected]" ? 0 : 1);
}
const CountAtomContext = React.createContext(createAtom("[email protected]"));
const useCountAtom = () => useContext(CountAtomContext);
function CountAtomScopeProvider({ children, userId }) {
// Create a new atom for every user Id
const countAtom = useMemo(() => createAtom(userId), [userId]);
return (
<CountAtomContext.Provider value={countAtom}>
{children}
</CountAtomContext.Provider>
);
}
function Counter() {
const countAtom = useCountAtom();
const [count, setCount] = useAtom(countAtom);
return (
<div>
count:
{" "}
{count}
{" "}
<button onClick={() => setCount(c => c + 1)}>+1</button>
</div>
);
}
export function App() {
return (
<CountAtomScopeProvider userId="[email protected]">
<Counter />
<Counter />
<CountAtomScopeProvider userId="[email protected]">
<Counter />
<Counter />
</CountAtomScopeProvider>
</CountAtomScopeProvider>
);
}
上記の例は jotai
を使っているが、bunshi
も使うと以下のように書くことができる。
import { atom, useAtom } from "jotai";
import {
ScopeProvider,
createScope,
molecule,
useMolecule,
} from "bunshi/react";
const UserScope = createScope(undefined);
const countMolecule = molecule((mol, scope) => {
const userId = scope(UserScope);
console.log("Creating a new atom for", userId);
return atom(0);
});
// ... Counter unchanged
export function App() {
return (
<ScopeProvider scope={UserScope} value="[email protected]">
<Counter />
</ScopeProvider>
);
}
今回は bunshi
というライブラリの基本概念からその魅力までを調べた。途中で実装の方を参照することが多々あったが、ほとんどテストされていてドキュメントも充実しているため、理解するのは難しくなかった。
bunshi
を使って状態管理のベストプラクティスを追求したいと思った。
脚注
React
と Vue
は専用の API が用意されている。詳しくはこちらを参照。React、Vue
↵reflect-metadata
はバンドルに含めるとサイズが大きくなるため、筆者はあまり使いたくない。
↵