-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
73 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,26 +3,32 @@ name: Publish | |
on: | ||
push: | ||
branches: | ||
- "!*" | ||
- '!*' | ||
tags: | ||
- "v*" | ||
- 'v*' | ||
|
||
permissions: | ||
id-token: write | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
- name: Setup wasm-pack | ||
uses: jetli/[email protected] | ||
- name: Build | ||
run: ./build.sh | ||
run: | | ||
yarn install --frozen-lockfile | ||
./scripts/build.sh | ||
- name: Publish | ||
uses: JS-DevTools/npm-publish@v2 | ||
uses: JS-DevTools/npm-publish@v3 | ||
with: | ||
token: ${{ secrets.NPM_TOKEN }} | ||
package: ./pkg | ||
access: public | ||
provenance: true | ||
- name: Release | ||
uses: marvinpinto/action-automatic-releases@latest | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/target | ||
/Cargo.lock | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "unity-js-tools" | ||
version = "2.0.0" | ||
version = "3.0.0" | ||
edition = "2021" | ||
authors = ["神代綺凛 <[email protected]>"] | ||
license = "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"esm-to-cjs": "^1.2.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
wasm-pack build --release --target nodejs --scope arkntools --out-name index | ||
wasm-pack build --release --target web --out-name index --out-dir pkg/web | ||
node scripts/process.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
wasm-pack build --release --target nodejs --scope arkntools --out-name index | ||
wasm-pack build --release --target web --out-name index --out-dir pkg/web | ||
node scripts/process.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const { readFileSync, writeFileSync } = require('fs'); | ||
const { resolve, join } = require('path'); | ||
const { runTransform } = require('esm-to-cjs'); | ||
|
||
const pkgPath = resolve(__dirname, '../pkg'); | ||
const webPkgPath = resolve(__dirname, '../pkg/web'); | ||
|
||
const wasmBase64 = readFileSync(join(webPkgPath, 'index_bg.wasm')).toString( | ||
'base64' | ||
); | ||
|
||
function base64Decode(input) { | ||
return Uint8Array.from(atob(input), (m) => m.codePointAt(0)).buffer; | ||
} | ||
|
||
const content = | ||
readFileSync(join(webPkgPath, 'index.js')) | ||
.toString() | ||
.replace(/\nasync function __wbg_load\([\s\S]+?\n}/, '') | ||
.replace(/\nasync function __wbg_init\([\s\S]+?\n}/, '') | ||
.replace(/__wbg_init\.[^;]+?;\s+/, '') | ||
.replace('export { initSync }\n', '') | ||
.replace('export default __wbg_init;\n', '') + | ||
`${base64Decode.toString()} | ||
initSync(base64Decode('${wasmBase64}')); | ||
`; | ||
|
||
writeFileSync( | ||
join(pkgPath, 'index.browser.js'), | ||
runTransform(content, { quote: 'single', lenIdentifier: 30 }) | ||
); | ||
|
||
const packageJsonPath = join(pkgPath, 'package.json'); | ||
const packageJson = JSON.parse(readFileSync(packageJsonPath)); | ||
|
||
packageJson.files.push('index.browser.js'); | ||
packageJson.browser = 'index.browser.js'; | ||
|
||
writeFileSync(packageJsonPath, JSON.stringify(packageJson, undefined, 2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
esm-to-cjs@^1.2.1: | ||
version "1.2.1" | ||
resolved "https://registry.yarnpkg.com/esm-to-cjs/-/esm-to-cjs-1.2.1.tgz#4f5a0c347ab73e9330131c4a5d34172386d1c41f" | ||
integrity sha512-5zzepH0eV7F3LOz+p3Hn8iTaszfqVu9ueGcLltcuCz2kNe7Dbu9p2hePzi3xN+0S/m/d0WCC1IjIEP2UoHbmuQ== |