apply-clients 3.2.36 → 3.2.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-android/static/15.js +2 -2
- package/dist-android/static/23.js +2 -2
- package/index.html +1 -1
- package/package.json +5 -5
- package/src/AndroidApp.vue +10 -9
- package/src/android-bootstrap/fonts/glyphicons-halflings-regular.eot +0 -0
- package/src/android-bootstrap/fonts/glyphicons-halflings-regular.svg +288 -0
- package/src/android-bootstrap/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/src/android-bootstrap/fonts/glyphicons-halflings-regular.woff +0 -0
- package/src/android-bootstrap/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/src/android-bootstrap/less/.csscomb.json +304 -0
- package/src/android-bootstrap/less/.csslintrc +19 -0
- package/src/android-bootstrap/less/alerts.less +73 -0
- package/src/android-bootstrap/less/badges.less +66 -0
- package/src/android-bootstrap/less/bootstrap.less +56 -0
- package/src/android-bootstrap/less/breadcrumbs.less +26 -0
- package/src/android-bootstrap/less/button-groups.less +247 -0
- package/src/android-bootstrap/less/buttons.less +173 -0
- package/src/android-bootstrap/less/carousel.less +269 -0
- package/src/android-bootstrap/less/close.less +34 -0
- package/src/android-bootstrap/less/code.less +69 -0
- package/src/android-bootstrap/less/component-animations.less +33 -0
- package/src/android-bootstrap/less/dropdowns.less +216 -0
- package/src/android-bootstrap/less/forms.less +626 -0
- package/src/android-bootstrap/less/glyphicons.less +305 -0
- package/src/android-bootstrap/less/grid.less +84 -0
- package/src/android-bootstrap/less/input-groups.less +167 -0
- package/src/android-bootstrap/less/jumbotron.less +52 -0
- package/src/android-bootstrap/less/labels.less +64 -0
- package/src/android-bootstrap/less/list-group.less +141 -0
- package/src/android-bootstrap/less/media.less +66 -0
- package/src/android-bootstrap/less/mixins/alerts.less +14 -0
- package/src/android-bootstrap/less/mixins/background-variant.less +9 -0
- package/src/android-bootstrap/less/mixins/border-radius.less +18 -0
- package/src/android-bootstrap/less/mixins/buttons.less +69 -0
- package/src/android-bootstrap/less/mixins/center-block.less +7 -0
- package/src/android-bootstrap/less/mixins/clearfix.less +22 -0
- package/src/android-bootstrap/less/mixins/forms.less +90 -0
- package/src/android-bootstrap/less/mixins/gradients.less +59 -0
- package/src/android-bootstrap/less/mixins/grid-framework.less +92 -0
- package/src/android-bootstrap/less/mixins/grid.less +122 -0
- package/src/android-bootstrap/less/mixins/hide-text.less +21 -0
- package/src/android-bootstrap/less/mixins/image.less +33 -0
- package/src/android-bootstrap/less/mixins/labels.less +12 -0
- package/src/android-bootstrap/less/mixins/list-group.less +30 -0
- package/src/android-bootstrap/less/mixins/nav-divider.less +10 -0
- package/src/android-bootstrap/less/mixins/nav-vertical-align.less +9 -0
- package/src/android-bootstrap/less/mixins/opacity.less +8 -0
- package/src/android-bootstrap/less/mixins/pagination.less +24 -0
- package/src/android-bootstrap/less/mixins/panels.less +24 -0
- package/src/android-bootstrap/less/mixins/progress-bar.less +10 -0
- package/src/android-bootstrap/less/mixins/reset-filter.less +8 -0
- package/src/android-bootstrap/less/mixins/reset-text.less +18 -0
- package/src/android-bootstrap/less/mixins/resize.less +6 -0
- package/src/android-bootstrap/less/mixins/responsive-visibility.less +15 -0
- package/src/android-bootstrap/less/mixins/size.less +10 -0
- package/src/android-bootstrap/less/mixins/tab-focus.less +9 -0
- package/src/android-bootstrap/less/mixins/table-row.less +44 -0
- package/src/android-bootstrap/less/mixins/text-emphasis.less +9 -0
- package/src/android-bootstrap/less/mixins/text-overflow.less +8 -0
- package/src/android-bootstrap/less/mixins/vendor-prefixes.less +227 -0
- package/src/android-bootstrap/less/mixins.less +40 -0
- package/src/android-bootstrap/less/modals.less +151 -0
- package/src/android-bootstrap/less/navbar.less +660 -0
- package/src/android-bootstrap/less/navs.less +302 -0
- package/src/android-bootstrap/less/normalize.less +424 -0
- package/src/android-bootstrap/less/pager.less +76 -0
- package/src/android-bootstrap/less/pagination.less +89 -0
- package/src/android-bootstrap/less/panels.less +274 -0
- package/src/android-bootstrap/less/popovers.less +131 -0
- package/src/android-bootstrap/less/print.less +101 -0
- package/src/android-bootstrap/less/progress-bars.less +87 -0
- package/src/android-bootstrap/less/responsive-embed.less +35 -0
- package/src/android-bootstrap/less/responsive-utilities.less +194 -0
- package/src/android-bootstrap/less/scaffolding.less +161 -0
- package/src/android-bootstrap/less/tables.less +262 -0
- package/src/android-bootstrap/less/theme.less +291 -0
- package/src/android-bootstrap/less/thumbnails.less +36 -0
- package/src/android-bootstrap/less/tooltip.less +102 -0
- package/src/android-bootstrap/less/type.less +303 -0
- package/src/android-bootstrap/less/utilities.less +55 -0
- package/src/android-bootstrap/less/variables.less +896 -0
- package/src/android-bootstrap/less/wells.less +29 -0
- package/src/apply.js +143 -25
- package/src/applyAndroid.js +5 -3
- package/src/components/Util.js +5 -5
- package/src/components/app_apply/AppServiceView.vue +2 -2
- package/src/components/app_apply/Process/AppExplorationUser.vue +200 -310
- package/src/components/app_apply/Process/AppProgressReport.vue +84 -0
- package/src/components/app_apply/Process/AppServiceControl.vue +215 -4
- package/src/components/app_apply/ProgressReport/ProgressReportDetail.vue +64 -0
- package/src/components/app_apply/ProgressReport/ProgressReportList.vue +209 -0
- package/src/components/app_apply/Supervisory/AppProcessSupervisory.vue +12 -129
- package/src/components/image/tubiao.png +0 -0
- package/src/components/product/{ApplyCharge → Apply/ApplyCharge}/ApplyChargeList.vue +4 -8
- package/src/components/product/{ApplyCharge → Apply/ApplyCharge}/ApplyChargeSearch.vue +2 -4
- package/src/components/product/{Function → Apply/Function}/InstallFunction.vue +4 -4
- package/src/components/product/{Function → Apply/Function}/InstallInfoSelect.vue +12 -16
- package/src/components/product/{Function → Apply/Function}/Service/FunctionServiceControl.vue +0 -1
- package/src/components/product/{Function → Apply/Function}/StopApplyCrrdList.vue +0 -0
- package/src/components/product/{Function → Apply/Function}/functions/ApplyRecordCancel.vue +1 -1
- package/src/components/product/{Function → Apply/Function}/functions/StopInstall.vue +11 -25
- package/src/components/product/{Process → Apply/Process}/ExplorationSelect.vue +5 -8
- package/src/components/product/{Process → Apply/Process}/ExplorationUser.vue +3 -4
- package/src/components/product/Apply/Process/Processes/InstallationDetails.vue +478 -0
- package/src/components/product/{Process → Apply/Process}/Processes/addressAndUserinfoManagement.vue +3 -8
- package/src/components/product/{Process → Apply/Process}/Processes/chargeManagement.vue +11 -51
- package/src/components/product/{Process → Apply/Process}/Processes/supplementalAgreement.vue +1 -1
- package/src/components/product/{Process → Apply/Process}/Service/ServiceControl.vue +11 -75
- package/src/components/product/{Process → Apply/Process}/ShowBackReason.vue +0 -0
- package/src/components/product/{Supervisory → Apply/Supervisory}/Service/SupervisoryServiceControl.vue +0 -5
- package/src/components/product/{Supervisory → Apply/Supervisory}/SupervisoryControl.vue +43 -22
- package/src/components/product/{Supervisory → Apply/Supervisory}/SupervisoryList.vue +15 -13
- package/src/components/product/{Supervisory → Apply/Supervisory}/SupervisoryhCart.vue +1 -1
- package/src/components/product/Ledger/ContractManagement/OtherContract/OtherContract.vue +156 -0
- package/src/components/product/Ledger/ContractManagement/OtherContract/OtherContractInformation.vue +429 -0
- package/src/components/product/Ledger/ContractManagement/OtherContract/OtherContractList.vue +267 -0
- package/src/components/product/Ledger/ContractManagement/PurchaseContract/PurchaseContract.vue +138 -0
- package/src/components/product/Ledger/ContractManagement/PurchaseContract/PurchaseContractInformation.vue +715 -0
- package/src/components/product/Ledger/ContractManagement/PurchaseContract/PurchaseContractList.vue +304 -0
- package/src/components/product/Ledger/ContractManagement/RepairContract/RepairContract.vue +119 -0
- package/src/components/product/Ledger/ContractManagement/RepairContract/RepairContractInformation.vue +286 -0
- package/src/components/product/Ledger/ContractManagement/RepairContract/RepairContractList.vue +258 -0
- package/src/components/product/Ledger/FacilityManagement/EmployRecord/EmployRecord.vue +24 -0
- package/src/components/product/Ledger/FacilityManagement/EmployRecord/EmployRecordList.vue +218 -0
- package/src/components/product/Ledger/FacilityManagement/FacilityInventory/FacilityEmployRecord.vue +124 -0
- package/src/components/product/Ledger/FacilityManagement/FacilityInventory/FacilityInventory.vue +307 -0
- package/src/components/product/Ledger/FacilityManagement/FacilityInventory/FacilityInventoryInformation.vue +583 -0
- package/src/components/product/Ledger/FacilityManagement/FacilityInventory/FacilityInventoryList.vue +285 -0
- package/src/components/product/Ledger/FacilityManagement/FacilityInventory/FacilityServiceRecord.vue +113 -0
- package/src/components/product/Ledger/FacilityManagement/FacilityInventory/addFacilityInformation.vue +406 -0
- package/src/components/product/Ledger/FacilityManagement/FacilityInventory/addoldFacilityInformation.vue +326 -0
- package/src/components/product/Ledger/FacilityManagement/ScrapRecord/ScrapRecord.vue +24 -0
- package/src/components/product/Ledger/FacilityManagement/ScrapRecord/ScrapRecordList.vue +157 -0
- package/src/components/product/Ledger/FacilityManagement/ServiceRecord/ServiceRecord.vue +24 -0
- package/src/components/product/Ledger/FacilityManagement/ServiceRecord/ServiceRecordList.vue +168 -0
- package/src/components/product/Ledger/FileDownload/FileDownload.vue +42 -0
- package/src/components/product/Ledger/Function/InstallFunction.vue +118 -0
- package/src/components/product/Ledger/Function/InstallInfoSelect.vue +299 -0
- package/src/components/product/Ledger/Function/Service/FunctionServiceControl.vue +220 -0
- package/src/components/product/Ledger/Function/functions/PauseInstall.vue +92 -0
- package/src/components/product/Ledger/ImportApply/ImportApply.vue +68 -0
- package/src/components/product/Ledger/MaterialManagement/DeliveryRecord/DeliveryRecord.vue +24 -0
- package/src/components/product/Ledger/MaterialManagement/DeliveryRecord/DeliveryRecordList.vue +281 -0
- package/src/components/product/Ledger/MaterialManagement/InventoryInformation/InventoryInformation.vue +313 -0
- package/src/components/product/Ledger/MaterialManagement/InventoryInformation/InventoryInformationList.vue +250 -0
- package/src/components/product/Ledger/MaterialManagement/InventoryInformation/MaterialDeliveryRecord.vue +110 -0
- package/src/components/product/Ledger/MaterialManagement/InventoryInformation/MaterialEarlyWarning.vue +194 -0
- package/src/components/product/Ledger/MaterialManagement/InventoryInformation/MaterialInformation.vue +186 -0
- package/src/components/product/Ledger/MaterialManagement/InventoryInformation/MaterialOutStock.vue +438 -0
- package/src/components/product/Ledger/MaterialManagement/InventoryInformation/MaterialOutboundOrder.vue +457 -0
- package/src/components/product/Ledger/MaterialManagement/InventoryInformation/MaterialWarehousingRecord.vue +110 -0
- package/src/components/product/Ledger/MaterialManagement/InventoryInformation/PurchaseMaterial.vue +425 -0
- package/src/components/product/Ledger/MaterialManagement/InventoryInformation/PurchaseOrder.vue +481 -0
- package/src/components/product/Ledger/MaterialManagement/InventoryInformation/ReturnMaterial.vue +321 -0
- package/src/components/product/Ledger/MaterialManagement/OutboundOrder/OutboundOrder.vue +86 -0
- package/src/components/product/Ledger/MaterialManagement/OutboundOrder/OutboundOrderInformation.vue +327 -0
- package/src/components/product/Ledger/MaterialManagement/OutboundOrder/OutboundOrderList.vue +304 -0
- package/src/components/product/Ledger/MaterialManagement/OutboundOrder/PrintMaterialBill.vue +139 -0
- package/src/components/product/Ledger/MaterialManagement/PurchaseRecords/PrintPurchaseOrder.vue +157 -0
- package/src/components/product/Ledger/MaterialManagement/PurchaseRecords/PurchaseRecords.vue +73 -0
- package/src/components/product/Ledger/MaterialManagement/PurchaseRecords/PurchaseRecordsInformation.vue +268 -0
- package/src/components/product/Ledger/MaterialManagement/PurchaseRecords/PurchaseRecordsList.vue +261 -0
- package/src/components/product/Ledger/MaterialManagement/WarehousingRecord/WarehousingRecord.vue +24 -0
- package/src/components/product/Ledger/MaterialManagement/WarehousingRecord/WarehousingRecordList.vue +275 -0
- package/src/components/product/Ledger/Process/ProcessBusiness.vue +155 -0
- package/src/components/product/Ledger/Process/ProcessSelect.vue +340 -0
- package/src/components/product/Ledger/Process/Processes/ExhibitionPicture.vue +27 -0
- package/src/components/product/Ledger/Process/Processes/ProgressReport.vue +236 -0
- package/src/components/product/Ledger/Process/Processes/ProjectMaterialList.vue +77 -0
- package/src/components/product/Ledger/Process/Processes/QinhuaMaterialList.vue +72 -0
- package/src/components/product/Ledger/Process/Service/ServiceControl.vue +639 -0
- package/src/components/product/Ledger/QinhuaMaterial/PickingRecord/PickingInformation.vue +316 -0
- package/src/components/product/Ledger/QinhuaMaterial/PickingRecord/PickingRecord.vue +67 -0
- package/src/components/product/Ledger/QinhuaMaterial/PickingRecord/PickingRecordList.vue +194 -0
- package/src/components/product/Ledger/QinhuaMaterial/SeasoningRecord/SeasoningInformation.vue +385 -0
- package/src/components/product/Ledger/QinhuaMaterial/SeasoningRecord/SeasoningRecord.vue +70 -0
- package/src/components/product/Ledger/QinhuaMaterial/SeasoningRecord/SeasoningRecordList.vue +208 -0
- package/src/components/product/Ledger/Stop/StopApply.vue +103 -0
- package/src/components/product/Ledger/Stop/StopApplyList.vue +241 -0
- package/src/components/product/Ledger/Supervisory/ProcessSupervisory.vue +163 -0
- package/src/components/product/Ledger/Supervisory/Service/RenWuDan.vue +78 -0
- package/src/components/product/Ledger/Supervisory/Service/SupervisoryServiceControl.vue +606 -0
- package/src/components/product/Ledger/Supervisory/SupervisoryCart.vue +102 -0
- package/src/components/product/Ledger/Supervisory/SupervisoryList.vue +387 -0
- package/src/components/product/ServiceView.vue +376 -374
- package/src/components/product/VueUtils/ApplyUpload.vue +1 -3
- package/src/expandcssAndroid.less +534 -0
- package/src/main.js +2 -0
- package/static/Functions.js +91 -0
- package/static/Jsons.js +784 -0
- package/static/ManageHomePic//346/244/255/345/234/2064.png +0 -0
- package/static/ManagementControl/echarts10.png +0 -0
- package/static/ManagementControl/echarts11.png +0 -0
- package/static/ManagementControl/echarts12.png +0 -0
- package/static/ManagementControl/echarts13.png +0 -0
- package/static/ManagementControl/echarts14.png +0 -0
- package/static/ManagementControl/echarts15.png +0 -0
- package/static/ManagementControl/echarts16.png +0 -0
- package/static/ManagementControl/echarts17.png +0 -0
- package/static/ManagementControl/echarts18.png +0 -0
- package/static/ManagementControl/echarts4.png +0 -0
- package/static/ManagementControl/echarts5.png +0 -0
- package/static/ManagementControl/echarts51.png +0 -0
- package/static/ManagementControl/echarts6.png +0 -0
- package/static/ManagementControl/echarts7.png +0 -0
- package/static/ManagementControl/echarts71.png +0 -0
- package/static/ManagementControl/echarts8.png +0 -0
- package/static/ManagementControl//345/233/276/345/261/20211/346/213/267/350/264/235.png +0 -0
- package/static/ManagementControl//347/237/251/345/275/2425/346/213/267/350/264/2353.png +0 -0
- package/static/ManagementControl//347/237/251/345/275/2425/346/213/267/350/264/2355.png +0 -0
- package/static/ManagementControl//347/237/251/345/275/2425/346/213/267/350/264/2356.png +0 -0
- package/static/class.js +97 -0
- package/static/images/lefticon//346/226/207/344/273/266/346/250/241/345/235/227.png +0 -0
- package/static/init.js +135 -0
- package/static/jcwx.jpg +0 -0
- package/static/lefticon//345/215/241/346/234/215/345/212/241/347/256/241/347/220/206.png +0 -0
- package/static/lefticon//345/221/274/345/217/253/347/263/273/347/273/237.png +0 -0
- package/static/lefticon//345/224/256/346/260/224/346/224/266/350/264/271.png +0 -0
- package/static/lefticon//345/233/276/345/261/2023/346/213/267/350/264/2354.png +0 -0
- package/static/lefticon//345/233/276/345/261/202577.png +0 -0
- package/static/lefticon//345/233/276/345/261/2028/346/213/267/350/264/23513.png +0 -0
- package/static/lefticon//345/256/211/346/243/200/346/237/245/347/234/213.png +0 -0
- package/static/lefticon//345/256/211/346/243/200/350/256/241/345/210/222.png +0 -0
- package/static/lefticon//345/276/256/344/277/241/346/234/215/345/212/241.png +0 -0
- package/static/lefticon//346/212/245/345/273/272/347/263/273/347/273/237.png +0 -0
- package/static/lefticon//346/212/245/350/241/250/346/237/245/350/257/242.png +0 -0
- package/static/lefticon//346/227/245/345/270/270/347/256/241/347/220/206.png +0 -0
- package/static/lefticon//346/234/272/350/241/250/347/256/241/347/220/206.png +0 -0
- package/static/lefticon//346/237/245/350/257/242/345/210/227/350/241/250.png +0 -0
- package/static/lefticon//346/241/243/346/241/210/347/256/241/347/220/206.png +0 -0
- package/static/lefticon//347/211/251/350/201/224/347/275/221/350/241/250.png +0 -0
- package/static/lefticon//347/237/251/345/275/2421183.png +0 -0
- package/static/lefticon//347/263/273/347/273/237/347/256/241/347/220/206.png +0 -0
- package/static/lefticon//347/263/273/347/273/237/350/256/276/347/275/256.png +0 -0
- package/static/lefticon//347/273/217/350/220/245/347/256/241/346/216/247.png +0 -0
- package/static/lefticon//347/273/274/345/220/210/344/270/232/345/212/241.png +0 -0
- package/static/lefticon//347/273/274/345/220/210/346/237/245/350/257/242.png +0 -0
- package/static/lefticon//350/217/234/345/215/225/344/274/270/347/274/251.png +0 -0
- package/static/lefticon//351/200/200/345/207/272/347/263/273/347/273/237.png +0 -0
- package/static/loginbg1.jpg +0 -0
- package/static/loginbg_jincheng.jpg +0 -0
- package/static/loginbgmain.jpg +0 -0
- package/static/mainicon/adddevice.png +0 -0
- package/static/mainicon/addmeter.png +0 -0
- package/static/mainicon/bank.png +0 -0
- package/static/mainicon/biaopan.png +0 -0
- package/static/mainicon/cad.jpg +0 -0
- package/static/mainicon/chaobiaoyuan.png +0 -0
- package/static/mainicon/danganguanli.png +0 -0
- package/static/mainicon/deletedevice.png +0 -0
- package/static/mainicon/excel.jpg +0 -0
- package/static/mainicon/huizong.png +0 -0
- package/static/mainicon/jibiaoguanli.png +0 -0
- package/static/mainicon/jibiaoguanli2.png +0 -0
- package/static/mainicon/jiezhang.png +0 -0
- package/static/mainicon/loginbg.jpg +0 -0
- package/static/mainicon/shouqishoufei.png +0 -0
- package/static/mainicon/treeopen.png +0 -0
- package/static/mainicon/treeout.png +0 -0
- package/static/mainicon/treeset.png +0 -0
- package/static/mainicon/word.jpg +0 -0
- package/static/mainicon/wulianwang.png +0 -0
- package/static/mainicon/yingyechaxun.png +0 -0
- package/static/mainicon/zongheyewu.png +0 -0
- package/static/newStyle/loginbg-liaoyuan.gif +0 -0
- package/static/newStyle/loginbg.gif +0 -0
- package/static/newStyle/loginbg1366.gif +0 -0
- package/static/newStyle/loginbg_1.gif +0 -0
- package/static/newStyle/searchin.png +0 -0
- package/static/newStyle/searchout.png +0 -0
- package/static/newStyle//350/261/252/344/275/263/347/207/203/346/260/224.png +0 -0
- package/static/newStyle.7z +0 -0
- package/static/newStyle.zip +0 -0
- package/static/refresh.png +0 -0
- package/static/static.zip +0 -0
- package/static/tools.js +246 -0
- package/static/treeclose.png +0 -0
- package/static/wasm_exec.js +591 -0
- package/src/components/app_apply/Process/Processes/AppInstallationDetails.vue +0 -456
- package/src/components/product/ApplyCharge/ApplyChargeReport.vue +0 -107
- package/src/components/product/Process/Processes/InstallationDetails.vue +0 -515
- package/src/components/product/Process/Processes/printCharge.vue +0 -133
- package/src/components/product/Test.vue +0 -36
- package/src/components/product/VueUtils/ToolsPage.vue +0 -51
- package/src/components/product/VueUtils/Tree.vue +0 -330
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
// Copyright 2018 The Go Authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style
|
|
3
|
+
// license that can be found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
(() => {
|
|
6
|
+
// Map multiple JavaScript environments to a single common API,
|
|
7
|
+
// preferring web standards over Node.js API.
|
|
8
|
+
//
|
|
9
|
+
// Environments considered:
|
|
10
|
+
// - Browsers
|
|
11
|
+
// - Node.js
|
|
12
|
+
// - Electron
|
|
13
|
+
// - Parcel
|
|
14
|
+
|
|
15
|
+
if (typeof global !== "undefined") {
|
|
16
|
+
// global already exists
|
|
17
|
+
} else if (typeof window !== "undefined") {
|
|
18
|
+
window.global = window;
|
|
19
|
+
} else if (typeof self !== "undefined") {
|
|
20
|
+
self.global = self;
|
|
21
|
+
} else {
|
|
22
|
+
throw new Error("cannot export Go (neither global, window nor self is defined)");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!global.require && typeof require !== "undefined") {
|
|
26
|
+
global.require = require;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!global.fs && global.require) {
|
|
30
|
+
global.fs = require("fs");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const enosys = () => {
|
|
34
|
+
const err = new Error("not implemented");
|
|
35
|
+
err.code = "ENOSYS";
|
|
36
|
+
return err;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (!global.fs) {
|
|
40
|
+
let outputBuf = "";
|
|
41
|
+
global.fs = {
|
|
42
|
+
constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 }, // unused
|
|
43
|
+
writeSync(fd, buf) {
|
|
44
|
+
outputBuf += decoder.decode(buf);
|
|
45
|
+
const nl = outputBuf.lastIndexOf("\n");
|
|
46
|
+
if (nl != -1) {
|
|
47
|
+
console.log(outputBuf.substr(0, nl));
|
|
48
|
+
outputBuf = outputBuf.substr(nl + 1);
|
|
49
|
+
}
|
|
50
|
+
return buf.length;
|
|
51
|
+
},
|
|
52
|
+
write(fd, buf, offset, length, position, callback) {
|
|
53
|
+
if (offset !== 0 || length !== buf.length || position !== null) {
|
|
54
|
+
callback(enosys());
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const n = this.writeSync(fd, buf);
|
|
58
|
+
callback(null, n);
|
|
59
|
+
},
|
|
60
|
+
chmod(path, mode, callback) { callback(enosys()); },
|
|
61
|
+
chown(path, uid, gid, callback) { callback(enosys()); },
|
|
62
|
+
close(fd, callback) { callback(enosys()); },
|
|
63
|
+
fchmod(fd, mode, callback) { callback(enosys()); },
|
|
64
|
+
fchown(fd, uid, gid, callback) { callback(enosys()); },
|
|
65
|
+
fstat(fd, callback) { callback(enosys()); },
|
|
66
|
+
fsync(fd, callback) { callback(null); },
|
|
67
|
+
ftruncate(fd, length, callback) { callback(enosys()); },
|
|
68
|
+
lchown(path, uid, gid, callback) { callback(enosys()); },
|
|
69
|
+
link(path, link, callback) { callback(enosys()); },
|
|
70
|
+
lstat(path, callback) { callback(enosys()); },
|
|
71
|
+
mkdir(path, perm, callback) { callback(enosys()); },
|
|
72
|
+
open(path, flags, mode, callback) { callback(enosys()); },
|
|
73
|
+
read(fd, buffer, offset, length, position, callback) { callback(enosys()); },
|
|
74
|
+
readdir(path, callback) { callback(enosys()); },
|
|
75
|
+
readlink(path, callback) { callback(enosys()); },
|
|
76
|
+
rename(from, to, callback) { callback(enosys()); },
|
|
77
|
+
rmdir(path, callback) { callback(enosys()); },
|
|
78
|
+
stat(path, callback) { callback(enosys()); },
|
|
79
|
+
symlink(path, link, callback) { callback(enosys()); },
|
|
80
|
+
truncate(path, length, callback) { callback(enosys()); },
|
|
81
|
+
unlink(path, callback) { callback(enosys()); },
|
|
82
|
+
utimes(path, atime, mtime, callback) { callback(enosys()); },
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!global.process) {
|
|
87
|
+
global.process = {
|
|
88
|
+
getuid() { return -1; },
|
|
89
|
+
getgid() { return -1; },
|
|
90
|
+
geteuid() { return -1; },
|
|
91
|
+
getegid() { return -1; },
|
|
92
|
+
getgroups() { throw enosys(); },
|
|
93
|
+
pid: -1,
|
|
94
|
+
ppid: -1,
|
|
95
|
+
umask() { throw enosys(); },
|
|
96
|
+
cwd() { throw enosys(); },
|
|
97
|
+
chdir() { throw enosys(); },
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!global.crypto) {
|
|
102
|
+
const nodeCrypto = require("crypto");
|
|
103
|
+
global.crypto = {
|
|
104
|
+
getRandomValues(b) {
|
|
105
|
+
nodeCrypto.randomFillSync(b);
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!global.performance) {
|
|
111
|
+
global.performance = {
|
|
112
|
+
now() {
|
|
113
|
+
const [sec, nsec] = process.hrtime();
|
|
114
|
+
return sec * 1000 + nsec / 1000000;
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (!global.TextEncoder) {
|
|
120
|
+
global.TextEncoder = require("util").TextEncoder;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (!global.TextDecoder) {
|
|
124
|
+
global.TextDecoder = require("util").TextDecoder;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// End of polyfills for common API.
|
|
128
|
+
|
|
129
|
+
const encoder = new TextEncoder("utf-8");
|
|
130
|
+
const decoder = new TextDecoder("utf-8");
|
|
131
|
+
|
|
132
|
+
global.Go = class {
|
|
133
|
+
constructor() {
|
|
134
|
+
this.argv = ["js"];
|
|
135
|
+
this.env = {};
|
|
136
|
+
this.exit = (code) => {
|
|
137
|
+
if (code !== 0) {
|
|
138
|
+
console.warn("exit code:", code);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
this._exitPromise = new Promise((resolve) => {
|
|
142
|
+
this._resolveExitPromise = resolve;
|
|
143
|
+
});
|
|
144
|
+
this._pendingEvent = null;
|
|
145
|
+
this._scheduledTimeouts = new Map();
|
|
146
|
+
this._nextCallbackTimeoutID = 1;
|
|
147
|
+
|
|
148
|
+
const setInt64 = (addr, v) => {
|
|
149
|
+
this.mem.setUint32(addr + 0, v, true);
|
|
150
|
+
this.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const getInt64 = (addr) => {
|
|
154
|
+
const low = this.mem.getUint32(addr + 0, true);
|
|
155
|
+
const high = this.mem.getInt32(addr + 4, true);
|
|
156
|
+
return low + high * 4294967296;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const loadValue = (addr) => {
|
|
160
|
+
const f = this.mem.getFloat64(addr, true);
|
|
161
|
+
if (f === 0) {
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
if (!isNaN(f)) {
|
|
165
|
+
return f;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const id = this.mem.getUint32(addr, true);
|
|
169
|
+
return this._values[id];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const storeValue = (addr, v) => {
|
|
173
|
+
const nanHead = 0x7FF80000;
|
|
174
|
+
|
|
175
|
+
if (typeof v === "number") {
|
|
176
|
+
if (isNaN(v)) {
|
|
177
|
+
this.mem.setUint32(addr + 4, nanHead, true);
|
|
178
|
+
this.mem.setUint32(addr, 0, true);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (v === 0) {
|
|
182
|
+
this.mem.setUint32(addr + 4, nanHead, true);
|
|
183
|
+
this.mem.setUint32(addr, 1, true);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
this.mem.setFloat64(addr, v, true);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
switch (v) {
|
|
191
|
+
case undefined:
|
|
192
|
+
this.mem.setFloat64(addr, 0, true);
|
|
193
|
+
return;
|
|
194
|
+
case null:
|
|
195
|
+
this.mem.setUint32(addr + 4, nanHead, true);
|
|
196
|
+
this.mem.setUint32(addr, 2, true);
|
|
197
|
+
return;
|
|
198
|
+
case true:
|
|
199
|
+
this.mem.setUint32(addr + 4, nanHead, true);
|
|
200
|
+
this.mem.setUint32(addr, 3, true);
|
|
201
|
+
return;
|
|
202
|
+
case false:
|
|
203
|
+
this.mem.setUint32(addr + 4, nanHead, true);
|
|
204
|
+
this.mem.setUint32(addr, 4, true);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
let id = this._ids.get(v);
|
|
209
|
+
if (id === undefined) {
|
|
210
|
+
id = this._idPool.pop();
|
|
211
|
+
if (id === undefined) {
|
|
212
|
+
id = this._values.length;
|
|
213
|
+
}
|
|
214
|
+
this._values[id] = v;
|
|
215
|
+
this._goRefCounts[id] = 0;
|
|
216
|
+
this._ids.set(v, id);
|
|
217
|
+
}
|
|
218
|
+
this._goRefCounts[id]++;
|
|
219
|
+
let typeFlag = 1;
|
|
220
|
+
switch (typeof v) {
|
|
221
|
+
case "string":
|
|
222
|
+
typeFlag = 2;
|
|
223
|
+
break;
|
|
224
|
+
case "symbol":
|
|
225
|
+
typeFlag = 3;
|
|
226
|
+
break;
|
|
227
|
+
case "function":
|
|
228
|
+
typeFlag = 4;
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
this.mem.setUint32(addr + 4, nanHead | typeFlag, true);
|
|
232
|
+
this.mem.setUint32(addr, id, true);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const loadSlice = (addr) => {
|
|
236
|
+
const array = getInt64(addr + 0);
|
|
237
|
+
const len = getInt64(addr + 8);
|
|
238
|
+
return new Uint8Array(this._inst.exports.mem.buffer, array, len);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const loadSliceOfValues = (addr) => {
|
|
242
|
+
const array = getInt64(addr + 0);
|
|
243
|
+
const len = getInt64(addr + 8);
|
|
244
|
+
const a = new Array(len);
|
|
245
|
+
for (let i = 0; i < len; i++) {
|
|
246
|
+
a[i] = loadValue(array + i * 8);
|
|
247
|
+
}
|
|
248
|
+
return a;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const loadString = (addr) => {
|
|
252
|
+
const saddr = getInt64(addr + 0);
|
|
253
|
+
const len = getInt64(addr + 8);
|
|
254
|
+
return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const timeOrigin = Date.now() - performance.now();
|
|
258
|
+
this.importObject = {
|
|
259
|
+
go: {
|
|
260
|
+
// Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)
|
|
261
|
+
// may synchronously trigger a Go event handler. This makes Go code get executed in the middle of the imported
|
|
262
|
+
// function. A goroutine can switch to a new stack if the current stack is too small (see morestack function).
|
|
263
|
+
// This changes the SP, thus we have to update the SP used by the imported function.
|
|
264
|
+
|
|
265
|
+
// func wasmExit(code int32)
|
|
266
|
+
"runtime.wasmExit": (sp) => {
|
|
267
|
+
const code = this.mem.getInt32(sp + 8, true);
|
|
268
|
+
this.exited = true;
|
|
269
|
+
delete this._inst;
|
|
270
|
+
delete this._values;
|
|
271
|
+
delete this._goRefCounts;
|
|
272
|
+
delete this._ids;
|
|
273
|
+
delete this._idPool;
|
|
274
|
+
this.exit(code);
|
|
275
|
+
},
|
|
276
|
+
|
|
277
|
+
// func wasmWrite(fd uintptr, p unsafe.Pointer, n int32)
|
|
278
|
+
"runtime.wasmWrite": (sp) => {
|
|
279
|
+
const fd = getInt64(sp + 8);
|
|
280
|
+
const p = getInt64(sp + 16);
|
|
281
|
+
const n = this.mem.getInt32(sp + 24, true);
|
|
282
|
+
fs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));
|
|
283
|
+
},
|
|
284
|
+
|
|
285
|
+
// func resetMemoryDataView()
|
|
286
|
+
"runtime.resetMemoryDataView": (sp) => {
|
|
287
|
+
this.mem = new DataView(this._inst.exports.mem.buffer);
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
// func nanotime1() int64
|
|
291
|
+
"runtime.nanotime1": (sp) => {
|
|
292
|
+
setInt64(sp + 8, (timeOrigin + performance.now()) * 1000000);
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
// func walltime1() (sec int64, nsec int32)
|
|
296
|
+
"runtime.walltime1": (sp) => {
|
|
297
|
+
const msec = (new Date).getTime();
|
|
298
|
+
setInt64(sp + 8, msec / 1000);
|
|
299
|
+
this.mem.setInt32(sp + 16, (msec % 1000) * 1000000, true);
|
|
300
|
+
},
|
|
301
|
+
|
|
302
|
+
// func scheduleTimeoutEvent(delay int64) int32
|
|
303
|
+
"runtime.scheduleTimeoutEvent": (sp) => {
|
|
304
|
+
const id = this._nextCallbackTimeoutID;
|
|
305
|
+
this._nextCallbackTimeoutID++;
|
|
306
|
+
this._scheduledTimeouts.set(id, setTimeout(
|
|
307
|
+
() => {
|
|
308
|
+
this._resume();
|
|
309
|
+
while (this._scheduledTimeouts.has(id)) {
|
|
310
|
+
// for some reason Go failed to register the timeout event, log and try again
|
|
311
|
+
// (temporary workaround for https://github.com/golang/go/issues/28975)
|
|
312
|
+
console.warn("scheduleTimeoutEvent: missed timeout event");
|
|
313
|
+
this._resume();
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
getInt64(sp + 8) + 1, // setTimeout has been seen to fire up to 1 millisecond early
|
|
317
|
+
));
|
|
318
|
+
this.mem.setInt32(sp + 16, id, true);
|
|
319
|
+
},
|
|
320
|
+
|
|
321
|
+
// func clearTimeoutEvent(id int32)
|
|
322
|
+
"runtime.clearTimeoutEvent": (sp) => {
|
|
323
|
+
const id = this.mem.getInt32(sp + 8, true);
|
|
324
|
+
clearTimeout(this._scheduledTimeouts.get(id));
|
|
325
|
+
this._scheduledTimeouts.delete(id);
|
|
326
|
+
},
|
|
327
|
+
|
|
328
|
+
// func getRandomData(r []byte)
|
|
329
|
+
"runtime.getRandomData": (sp) => {
|
|
330
|
+
crypto.getRandomValues(loadSlice(sp + 8));
|
|
331
|
+
},
|
|
332
|
+
|
|
333
|
+
// func finalizeRef(v ref)
|
|
334
|
+
"syscall/js.finalizeRef": (sp) => {
|
|
335
|
+
const id = this.mem.getUint32(sp + 8, true);
|
|
336
|
+
this._goRefCounts[id]--;
|
|
337
|
+
if (this._goRefCounts[id] === 0) {
|
|
338
|
+
const v = this._values[id];
|
|
339
|
+
this._values[id] = null;
|
|
340
|
+
this._ids.delete(v);
|
|
341
|
+
this._idPool.push(id);
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
|
|
345
|
+
// func stringVal(value string) ref
|
|
346
|
+
"syscall/js.stringVal": (sp) => {
|
|
347
|
+
storeValue(sp + 24, loadString(sp + 8));
|
|
348
|
+
},
|
|
349
|
+
|
|
350
|
+
// func valueGet(v ref, p string) ref
|
|
351
|
+
"syscall/js.valueGet": (sp) => {
|
|
352
|
+
const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));
|
|
353
|
+
sp = this._inst.exports.getsp(); // see comment above
|
|
354
|
+
storeValue(sp + 32, result);
|
|
355
|
+
},
|
|
356
|
+
|
|
357
|
+
// func valueSet(v ref, p string, x ref)
|
|
358
|
+
"syscall/js.valueSet": (sp) => {
|
|
359
|
+
Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));
|
|
360
|
+
},
|
|
361
|
+
|
|
362
|
+
// func valueDelete(v ref, p string)
|
|
363
|
+
"syscall/js.valueDelete": (sp) => {
|
|
364
|
+
Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));
|
|
365
|
+
},
|
|
366
|
+
|
|
367
|
+
// func valueIndex(v ref, i int) ref
|
|
368
|
+
"syscall/js.valueIndex": (sp) => {
|
|
369
|
+
storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));
|
|
370
|
+
},
|
|
371
|
+
|
|
372
|
+
// valueSetIndex(v ref, i int, x ref)
|
|
373
|
+
"syscall/js.valueSetIndex": (sp) => {
|
|
374
|
+
Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));
|
|
375
|
+
},
|
|
376
|
+
|
|
377
|
+
// func valueCall(v ref, m string, args []ref) (ref, bool)
|
|
378
|
+
"syscall/js.valueCall": (sp) => {
|
|
379
|
+
try {
|
|
380
|
+
const v = loadValue(sp + 8);
|
|
381
|
+
const m = Reflect.get(v, loadString(sp + 16));
|
|
382
|
+
const args = loadSliceOfValues(sp + 32);
|
|
383
|
+
const result = Reflect.apply(m, v, args);
|
|
384
|
+
sp = this._inst.exports.getsp(); // see comment above
|
|
385
|
+
storeValue(sp + 56, result);
|
|
386
|
+
this.mem.setUint8(sp + 64, 1);
|
|
387
|
+
} catch (err) {
|
|
388
|
+
storeValue(sp + 56, err);
|
|
389
|
+
this.mem.setUint8(sp + 64, 0);
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
|
|
393
|
+
// func valueInvoke(v ref, args []ref) (ref, bool)
|
|
394
|
+
"syscall/js.valueInvoke": (sp) => {
|
|
395
|
+
try {
|
|
396
|
+
const v = loadValue(sp + 8);
|
|
397
|
+
const args = loadSliceOfValues(sp + 16);
|
|
398
|
+
const result = Reflect.apply(v, undefined, args);
|
|
399
|
+
sp = this._inst.exports.getsp(); // see comment above
|
|
400
|
+
storeValue(sp + 40, result);
|
|
401
|
+
this.mem.setUint8(sp + 48, 1);
|
|
402
|
+
} catch (err) {
|
|
403
|
+
storeValue(sp + 40, err);
|
|
404
|
+
this.mem.setUint8(sp + 48, 0);
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
|
|
408
|
+
// func valueNew(v ref, args []ref) (ref, bool)
|
|
409
|
+
"syscall/js.valueNew": (sp) => {
|
|
410
|
+
try {
|
|
411
|
+
const v = loadValue(sp + 8);
|
|
412
|
+
const args = loadSliceOfValues(sp + 16);
|
|
413
|
+
const result = Reflect.construct(v, args);
|
|
414
|
+
sp = this._inst.exports.getsp(); // see comment above
|
|
415
|
+
storeValue(sp + 40, result);
|
|
416
|
+
this.mem.setUint8(sp + 48, 1);
|
|
417
|
+
} catch (err) {
|
|
418
|
+
storeValue(sp + 40, err);
|
|
419
|
+
this.mem.setUint8(sp + 48, 0);
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
|
|
423
|
+
// func valueLength(v ref) int
|
|
424
|
+
"syscall/js.valueLength": (sp) => {
|
|
425
|
+
setInt64(sp + 16, parseInt(loadValue(sp + 8).length));
|
|
426
|
+
},
|
|
427
|
+
|
|
428
|
+
// valuePrepareString(v ref) (ref, int)
|
|
429
|
+
"syscall/js.valuePrepareString": (sp) => {
|
|
430
|
+
const str = encoder.encode(String(loadValue(sp + 8)));
|
|
431
|
+
storeValue(sp + 16, str);
|
|
432
|
+
setInt64(sp + 24, str.length);
|
|
433
|
+
},
|
|
434
|
+
|
|
435
|
+
// valueLoadString(v ref, b []byte)
|
|
436
|
+
"syscall/js.valueLoadString": (sp) => {
|
|
437
|
+
const str = loadValue(sp + 8);
|
|
438
|
+
loadSlice(sp + 16).set(str);
|
|
439
|
+
},
|
|
440
|
+
|
|
441
|
+
// func valueInstanceOf(v ref, t ref) bool
|
|
442
|
+
"syscall/js.valueInstanceOf": (sp) => {
|
|
443
|
+
this.mem.setUint8(sp + 24, loadValue(sp + 8) instanceof loadValue(sp + 16));
|
|
444
|
+
},
|
|
445
|
+
|
|
446
|
+
// func copyBytesToGo(dst []byte, src ref) (int, bool)
|
|
447
|
+
"syscall/js.copyBytesToGo": (sp) => {
|
|
448
|
+
const dst = loadSlice(sp + 8);
|
|
449
|
+
const src = loadValue(sp + 32);
|
|
450
|
+
if (!(src instanceof Uint8Array)) {
|
|
451
|
+
this.mem.setUint8(sp + 48, 0);
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
const toCopy = src.subarray(0, dst.length);
|
|
455
|
+
dst.set(toCopy);
|
|
456
|
+
setInt64(sp + 40, toCopy.length);
|
|
457
|
+
this.mem.setUint8(sp + 48, 1);
|
|
458
|
+
},
|
|
459
|
+
|
|
460
|
+
// func copyBytesToJS(dst ref, src []byte) (int, bool)
|
|
461
|
+
"syscall/js.copyBytesToJS": (sp) => {
|
|
462
|
+
const dst = loadValue(sp + 8);
|
|
463
|
+
const src = loadSlice(sp + 16);
|
|
464
|
+
if (!(dst instanceof Uint8Array)) {
|
|
465
|
+
this.mem.setUint8(sp + 48, 0);
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
const toCopy = src.subarray(0, dst.length);
|
|
469
|
+
dst.set(toCopy);
|
|
470
|
+
setInt64(sp + 40, toCopy.length);
|
|
471
|
+
this.mem.setUint8(sp + 48, 1);
|
|
472
|
+
},
|
|
473
|
+
|
|
474
|
+
"debug": (value) => {
|
|
475
|
+
console.log(value);
|
|
476
|
+
},
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
async run(instance) {
|
|
482
|
+
this._inst = instance;
|
|
483
|
+
this.mem = new DataView(this._inst.exports.mem.buffer);
|
|
484
|
+
this._values = [ // JS values that Go currently has references to, indexed by reference id
|
|
485
|
+
NaN,
|
|
486
|
+
0,
|
|
487
|
+
null,
|
|
488
|
+
true,
|
|
489
|
+
false,
|
|
490
|
+
global,
|
|
491
|
+
this,
|
|
492
|
+
];
|
|
493
|
+
this._goRefCounts = []; // number of references that Go has to a JS value, indexed by reference id
|
|
494
|
+
this._ids = new Map(); // mapping from JS values to reference ids
|
|
495
|
+
this._idPool = []; // unused ids that have been garbage collected
|
|
496
|
+
this.exited = false; // whether the Go program has exited
|
|
497
|
+
|
|
498
|
+
// Pass command line arguments and environment variables to WebAssembly by writing them to the linear memory.
|
|
499
|
+
let offset = 4096;
|
|
500
|
+
|
|
501
|
+
const strPtr = (str) => {
|
|
502
|
+
const ptr = offset;
|
|
503
|
+
const bytes = encoder.encode(str + "\0");
|
|
504
|
+
new Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes);
|
|
505
|
+
offset += bytes.length;
|
|
506
|
+
if (offset % 8 !== 0) {
|
|
507
|
+
offset += 8 - (offset % 8);
|
|
508
|
+
}
|
|
509
|
+
return ptr;
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
const argc = this.argv.length;
|
|
513
|
+
|
|
514
|
+
const argvPtrs = [];
|
|
515
|
+
this.argv.forEach((arg) => {
|
|
516
|
+
argvPtrs.push(strPtr(arg));
|
|
517
|
+
});
|
|
518
|
+
argvPtrs.push(0);
|
|
519
|
+
|
|
520
|
+
const keys = Object.keys(this.env).sort();
|
|
521
|
+
keys.forEach((key) => {
|
|
522
|
+
argvPtrs.push(strPtr(`${key}=${this.env[key]}`));
|
|
523
|
+
});
|
|
524
|
+
argvPtrs.push(0);
|
|
525
|
+
|
|
526
|
+
const argv = offset;
|
|
527
|
+
argvPtrs.forEach((ptr) => {
|
|
528
|
+
this.mem.setUint32(offset, ptr, true);
|
|
529
|
+
this.mem.setUint32(offset + 4, 0, true);
|
|
530
|
+
offset += 8;
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
this._inst.exports.run(argc, argv);
|
|
534
|
+
if (this.exited) {
|
|
535
|
+
this._resolveExitPromise();
|
|
536
|
+
}
|
|
537
|
+
await this._exitPromise;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
_resume() {
|
|
541
|
+
if (this.exited) {
|
|
542
|
+
throw new Error("Go program has already exited");
|
|
543
|
+
}
|
|
544
|
+
this._inst.exports.resume();
|
|
545
|
+
if (this.exited) {
|
|
546
|
+
this._resolveExitPromise();
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
_makeFuncWrapper(id) {
|
|
551
|
+
const go = this;
|
|
552
|
+
return function () {
|
|
553
|
+
const event = { id: id, this: this, args: arguments };
|
|
554
|
+
go._pendingEvent = event;
|
|
555
|
+
go._resume();
|
|
556
|
+
return event.result;
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
if (
|
|
562
|
+
global.require &&
|
|
563
|
+
global.require.main === module &&
|
|
564
|
+
global.process &&
|
|
565
|
+
global.process.versions &&
|
|
566
|
+
!global.process.versions.electron
|
|
567
|
+
) {
|
|
568
|
+
if (process.argv.length < 3) {
|
|
569
|
+
console.error("usage: go_js_wasm_exec [wasm binary] [arguments]");
|
|
570
|
+
process.exit(1);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
const go = new Go();
|
|
574
|
+
go.argv = process.argv.slice(2);
|
|
575
|
+
go.env = Object.assign({ TMPDIR: require("os").tmpdir() }, process.env);
|
|
576
|
+
go.exit = process.exit;
|
|
577
|
+
WebAssembly.instantiate(fs.readFileSync(process.argv[2]), go.importObject).then((result) => {
|
|
578
|
+
process.on("exit", (code) => { // Node.js exits if no event handler is pending
|
|
579
|
+
if (code === 0 && !go.exited) {
|
|
580
|
+
// deadlock, make Go print error and stack traces
|
|
581
|
+
go._pendingEvent = { id: 0 };
|
|
582
|
+
go._resume();
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
return go.run(result.instance);
|
|
586
|
+
}).catch((err) => {
|
|
587
|
+
console.error(err);
|
|
588
|
+
process.exit(1);
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
})();
|