@jisan901/fs-browser 1.0.0 → 1.0.1
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/README.md +19 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# fs-browser
|
|
1
|
+
# @jisan901/fs-browser
|
|
2
2
|
|
|
3
3
|
Browser-compatible filesystem API with Vite plugin support. Write Node.js-style fs code that works in the browser!
|
|
4
4
|
|
|
@@ -14,7 +14,7 @@ Browser-compatible filesystem API with Vite plugin support. Write Node.js-style
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
npm install fs-browser
|
|
17
|
+
npm install @jisan901/fs-browser
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
## Quick Start
|
|
@@ -26,7 +26,7 @@ npm install fs-browser
|
|
|
26
26
|
```javascript
|
|
27
27
|
// vite.config.js
|
|
28
28
|
import { defineConfig } from 'vite';
|
|
29
|
-
import fsPlugin from 'fs-browser/plugin';
|
|
29
|
+
import fsPlugin from '@jisan901/fs-browser/plugin';
|
|
30
30
|
|
|
31
31
|
export default defineConfig({
|
|
32
32
|
plugins: [
|
|
@@ -41,7 +41,7 @@ export default defineConfig({
|
|
|
41
41
|
**2. Use in Browser Code**
|
|
42
42
|
|
|
43
43
|
```javascript
|
|
44
|
-
import { readFile, writeFile, mkdir } from 'fs-browser';
|
|
44
|
+
import { readFile, writeFile, mkdir } from '@jisan901/fs-browser';
|
|
45
45
|
|
|
46
46
|
// Write a file
|
|
47
47
|
await writeFile('hello.txt', 'Hello World!');
|
|
@@ -115,7 +115,7 @@ withfs ./dist --host --open
|
|
|
115
115
|
|
|
116
116
|
## Development with Other Frameworks
|
|
117
117
|
|
|
118
|
-
While
|
|
118
|
+
While `@jisan901/fs-browser` includes a Vite plugin, you can use it with any framework or development setup by running the `withfs` server separately.
|
|
119
119
|
|
|
120
120
|
### React (Create React App, Next.js)
|
|
121
121
|
|
|
@@ -138,7 +138,7 @@ npm start
|
|
|
138
138
|
|
|
139
139
|
```javascript
|
|
140
140
|
// App.js
|
|
141
|
-
import { readFile, writeFile } from 'fs-browser';
|
|
141
|
+
import { readFile, writeFile } from '@jisan901/fs-browser';
|
|
142
142
|
|
|
143
143
|
function App() {
|
|
144
144
|
const handleSave = async () => {
|
|
@@ -153,7 +153,7 @@ function App() {
|
|
|
153
153
|
|
|
154
154
|
```javascript
|
|
155
155
|
// lib/fs.js
|
|
156
|
-
import fs from 'fs-browser';
|
|
156
|
+
import fs from '@jisan901/fs-browser';
|
|
157
157
|
|
|
158
158
|
export default fs.configure({
|
|
159
159
|
apiBase: 'http://localhost:5001/api/fs'
|
|
@@ -202,7 +202,7 @@ npm run serve
|
|
|
202
202
|
```vue
|
|
203
203
|
<!-- App.vue -->
|
|
204
204
|
<script setup>
|
|
205
|
-
import { readFile, writeFile } from 'fs-browser';
|
|
205
|
+
import { readFile, writeFile } from '@jisan901/fs-browser';
|
|
206
206
|
|
|
207
207
|
const saveFile = async () => {
|
|
208
208
|
await writeFile('vue-data.json', { framework: 'Vue' });
|
|
@@ -218,7 +218,7 @@ const saveFile = async () => {
|
|
|
218
218
|
|
|
219
219
|
```javascript
|
|
220
220
|
// composables/useFs.js
|
|
221
|
-
import fs from 'fs-browser';
|
|
221
|
+
import fs from '@jisan901/fs-browser';
|
|
222
222
|
|
|
223
223
|
export const useFs = () => {
|
|
224
224
|
return fs.configure({
|
|
@@ -274,7 +274,7 @@ ng serve
|
|
|
274
274
|
|
|
275
275
|
```typescript
|
|
276
276
|
// app.component.ts
|
|
277
|
-
import { readFile, writeFile } from 'fs-browser';
|
|
277
|
+
import { readFile, writeFile } from '@jisan901/fs-browser';
|
|
278
278
|
|
|
279
279
|
export class AppComponent {
|
|
280
280
|
async saveFile() {
|
|
@@ -315,7 +315,7 @@ npm run dev
|
|
|
315
315
|
```svelte
|
|
316
316
|
<!-- +page.svelte -->
|
|
317
317
|
<script>
|
|
318
|
-
import { readFile, writeFile } from 'fs-browser';
|
|
318
|
+
import { readFile, writeFile } from '@jisan901/fs-browser';
|
|
319
319
|
|
|
320
320
|
async function saveFile() {
|
|
321
321
|
await writeFile('svelte-data.txt', 'Hello SvelteKit!');
|
|
@@ -360,7 +360,7 @@ npm run dev
|
|
|
360
360
|
// src/pages/index.astro
|
|
361
361
|
---
|
|
362
362
|
<script>
|
|
363
|
-
import { writeFile } from 'fs-browser';
|
|
363
|
+
import { writeFile } from '@jisan901/fs-browser';
|
|
364
364
|
|
|
365
365
|
document.querySelector('#save')?.addEventListener('click', async () => {
|
|
366
366
|
await writeFile('astro-data.json', { framework: 'Astro' });
|
|
@@ -378,7 +378,7 @@ npm run dev
|
|
|
378
378
|
<!DOCTYPE html>
|
|
379
379
|
<html>
|
|
380
380
|
<head>
|
|
381
|
-
<title
|
|
381
|
+
<title>@jisan901/fs-browser Demo</title>
|
|
382
382
|
</head>
|
|
383
383
|
<body>
|
|
384
384
|
<button id="save">Save File</button>
|
|
@@ -386,7 +386,7 @@ npm run dev
|
|
|
386
386
|
<pre id="output"></pre>
|
|
387
387
|
|
|
388
388
|
<script type="module">
|
|
389
|
-
import fs from 'https://cdn.jsdelivr.net/npm/fs-browser/src/index.js';
|
|
389
|
+
import fs from 'https://cdn.jsdelivr.net/npm/@jisan901/fs-browser/src/index.js';
|
|
390
390
|
|
|
391
391
|
// Configure to point to your fs server
|
|
392
392
|
const myFs = fs.configure({
|
|
@@ -448,7 +448,7 @@ npx parcel index.html
|
|
|
448
448
|
|
|
449
449
|
```javascript
|
|
450
450
|
// Configure in your JS
|
|
451
|
-
import { configure } from 'fs-browser';
|
|
451
|
+
import { configure } from '@jisan901/fs-browser';
|
|
452
452
|
|
|
453
453
|
configure({ apiBase: 'http://localhost:5001/api/fs' });
|
|
454
454
|
```
|
|
@@ -493,7 +493,7 @@ Set API base via environment variables:
|
|
|
493
493
|
|
|
494
494
|
```javascript
|
|
495
495
|
// config/fs.js
|
|
496
|
-
import fs from 'fs-browser';
|
|
496
|
+
import fs from '@jisan901/fs-browser';
|
|
497
497
|
|
|
498
498
|
const API_BASE = import.meta.env.VITE_FS_API_BASE ||
|
|
499
499
|
process.env.REACT_APP_FS_API_BASE ||
|
|
@@ -517,8 +517,8 @@ FROM node:18
|
|
|
517
517
|
|
|
518
518
|
WORKDIR /app
|
|
519
519
|
|
|
520
|
-
# Install fs-browser globally
|
|
521
|
-
RUN npm install -g fs-browser
|
|
520
|
+
# Install @jisan901/fs-browser globally
|
|
521
|
+
RUN npm install -g @jisan901/fs-browser
|
|
522
522
|
|
|
523
523
|
# Copy your built frontend
|
|
524
524
|
COPY ./dist ./dist
|
|
@@ -584,7 +584,7 @@ services:
|
|
|
584
584
|
Full TypeScript definitions included:
|
|
585
585
|
|
|
586
586
|
```typescript
|
|
587
|
-
import { readFile, writeFile, Stats, Dirent } from 'fs-browser';
|
|
587
|
+
import { readFile, writeFile, Stats, Dirent } from '@jisan901/fs-browser';
|
|
588
588
|
|
|
589
589
|
const content: string = await readFile('test.txt', 'utf8');
|
|
590
590
|
const stats: Stats = await stat('test.txt');
|