Skip to content

Commit efa17fc

Browse files
authored
Add initial @nx.js/ns package (#172)
1 parent 2d7bf99 commit efa17fc

File tree

10 files changed

+106
-21
lines changed

10 files changed

+106
-21
lines changed

.changeset/blue-sheep-report.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@nx.js/install-title": patch
3+
---
4+
5+
Use `@nx.js/ns` package

.changeset/heavy-beers-beam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@nx.js/ns": major
3+
---
4+
5+
Add initial `@nx.js/ns` package

packages/install-title/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"dependencies": {
2323
"@nx.js/constants": "^0.4.0",
2424
"@nx.js/ncm": "^1.2.0",
25+
"@nx.js/ns": "^0.0.0",
2526
"@nx.js/util": "^1.1.0",
2627
"@tootallnate/nsp": "^0.0.2"
2728
},

packages/install-title/src/index.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ import {
1616
NcmPackagedContentInfo,
1717
NcmApplicationMetaExtendedHeader,
1818
} from '@nx.js/ncm';
19-
import { parseNsp, type FileEntry } from '@tootallnate/nsp';
2019
import {
2120
NsApplicationRecordType,
2221
nsDeleteApplicationRecord,
2322
nsInvalidateApplicationControlCache,
2423
nsListApplicationRecordContentMeta,
2524
nsPushApplicationRecord,
26-
} from './ipc/ns';
25+
} from '@nx.js/ns';
26+
import { parseNsp, type FileEntry } from '@tootallnate/nsp';
2727
import { esImportTicket } from './ipc/es';
2828
import { PackagedContentMetaHeader } from './types';
2929

@@ -140,7 +140,7 @@ class ContentStoragePlaceholderWriteStream extends WritableStream<Uint8Array> {
140140
const placeholderId = contentStorage.generatePlaceHolderId();
141141
try {
142142
contentStorage.deletePlaceHolder(placeholderId);
143-
} catch {}
143+
} catch { }
144144
contentStorage.createPlaceHolder(contentId, placeholderId, BigInt(size));
145145

146146
super({
@@ -153,7 +153,7 @@ class ContentStoragePlaceholderWriteStream extends WritableStream<Uint8Array> {
153153
console.debug(`Finished writing ${this.#offset} bytes`);
154154
try {
155155
contentStorage.delete(contentId);
156-
} catch {}
156+
} catch { }
157157
contentStorage.register(contentId, placeholderId);
158158
},
159159
});
@@ -304,9 +304,9 @@ async function installContentMetaRecords(
304304

305305
const contentMetaData = new Uint8Array(
306306
NcmContentMetaHeader.sizeof +
307-
extendedHeaderSize +
308-
contentInfos.length * NcmContentInfo.sizeof +
309-
extendedDataSize,
307+
extendedHeaderSize +
308+
contentInfos.length * NcmContentInfo.sizeof +
309+
extendedDataSize,
310310
);
311311

312312
// write header
@@ -357,13 +357,13 @@ async function installContentMetaRecords(
357357
new Uint8Array(
358358
cnmtData,
359359
PackagedContentMetaHeader.sizeof +
360-
extendedHeaderSize +
361-
contentInfos.length * NcmContentInfo.sizeof,
360+
extendedHeaderSize +
361+
contentInfos.length * NcmContentInfo.sizeof,
362362
extendedDataSize,
363363
),
364364
NcmContentMetaHeader.sizeof +
365-
extendedHeaderSize +
366-
contentInfos.length * NcmContentInfo.sizeof,
365+
extendedHeaderSize +
366+
contentInfos.length * NcmContentInfo.sizeof,
367367
);
368368
}
369369

@@ -426,7 +426,7 @@ async function pushApplicationRecord(
426426

427427
try {
428428
nsDeleteApplicationRecord(titleId);
429-
} catch {}
429+
} catch { }
430430

431431
nsPushApplicationRecord(
432432
titleId,

packages/ns/package.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "@nx.js/ns",
3+
"version": "0.0.0",
4+
"description": "`ns` service IPC wrapper for nx.js",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/TooTallNate/nx.js.git",
8+
"directory": "packages/ns"
9+
},
10+
"homepage": "https://nxjs.n8.io/ns",
11+
"main": "dist/index.js",
12+
"scripts": {
13+
"build": "tsc",
14+
"docs": "typedoc && ../../type-aliases-meta.sh"
15+
},
16+
"files": [
17+
"dist"
18+
],
19+
"publishConfig": {
20+
"access": "public"
21+
},
22+
"dependencies": {
23+
"@nx.js/constants": "^0.4.0"
24+
},
25+
"devDependencies": {
26+
"@nx.js/runtime": "workspace:*"
27+
},
28+
"keywords": [
29+
"nx.js",
30+
"switch",
31+
"ns"
32+
],
33+
"author": "Nathan Rajlich <[email protected]>",
34+
"license": "MIT"
35+
}

packages/install-title/src/ipc/ns.ts renamed to packages/ns/src/index.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
// Ported from `tinwoo/nx/ipc/ns_ext.c`
22
import { SfBufferAttr } from '@nx.js/constants';
3-
import { NcmStorageId } from '@nx.js/ncm';
3+
import { NsApplicationRecordType } from './types';
44

5-
export enum NsApplicationRecordType {
6-
// installed
7-
Installed = 0x3,
8-
// application is gamecard, but gamecard isn't insterted
9-
GamecardMissing = 0x5,
10-
// archived
11-
Archived = 0xb,
12-
}
5+
export * from './types';
136

147
const nsAm2 = new Switch.Service('ns:am2');
158
const nsAppManSrv = new Switch.Service();

packages/ns/src/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export enum NsApplicationRecordType {
2+
// installed
3+
Installed = 0x3,
4+
// application is gamecard, but gamecard isn't insterted
5+
GamecardMissing = 0x5,
6+
// archived
7+
Archived = 0xb,
8+
}

packages/ns/tsconfig.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"outDir": "dist",
4+
"target": "es2022",
5+
"declaration": true,
6+
"sourceMap": true,
7+
"moduleResolution": "Bundler",
8+
"forceConsistentCasingInFileNames": true,
9+
"strict": true,
10+
"skipLibCheck": true,
11+
"types": [
12+
"@nx.js/runtime"
13+
]
14+
},
15+
"include": [
16+
"src/**/*.ts"
17+
]
18+
}

packages/ns/typedoc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "https://typedoc.org/schema.json",
3+
"extends": ["../../typedoc.json"],
4+
"name": "@nx.js/ns",
5+
"entryPoints": ["./src/index.ts"],
6+
"out": "docs"
7+
}

pnpm-lock.yaml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)