From 3beed860530abd4548cf1abc91f734585f9a4a1a Mon Sep 17 00:00:00 2001 From: SheetJS Date: Fri, 26 Aug 2022 20:15:07 -0400 Subject: [PATCH] cap --- docz/docs/03-demos/02-mobile.md | 184 ++++++++++++++++++++++++++++++++ docz/docs/03-demos/14-svelte.md | 4 + 2 files changed, 188 insertions(+) diff --git a/docz/docs/03-demos/02-mobile.md b/docz/docs/03-demos/02-mobile.md index a924cdb..2be4064 100644 --- a/docz/docs/03-demos/02-mobile.md +++ b/docz/docs/03-demos/02-mobile.md @@ -1517,4 +1517,188 @@ curl -o src/app/home/home.page.ts -L https://docs.sheetjs.com/ionic/home.page.ts npx @ionic/cli cordova emulate ios ``` + + +## CapacitorJS + +:::note + +This demo was tested on an Intel Mac on 2022 August 26 with Svelte. + +The iOS simulator runs iOS 15.5 on an iPhone 13 Pro Max. + +::: + +:::warning Telemetry + +Before starting this demo, manually disable telemetry. On Linux and MacOS: + +```bash +npx @capacitor/cli telemetry off +``` + +To verify telemetry was disabled: + +```bash +npx @capacitor/cli telemetry +``` + +::: + +### Integration Details + +This example uses Svelte, but the same principles apply to other frameworks. + +#### Reading data + +The standard HTML5 File Input element logic works in CapacitorJS: + +```html + + +
+ + +
{@html html}
+
+``` + +#### Writing data + +`@capacitor/fileysstem` can write Base64 strings: + +```html + + +
+ +
{@html html}
+
+``` + +### Demo + +
Complete Example (click to show) + +0) Disable telemetry as noted in the warning. + +Follow the [React Native demo](#demo) to ensure iOS and Android sims are ready. + + +1) Create a new Svelte project: + +```bash +npm create vite@latest sheetjs-cap -- --template svelte +cd sheetjs-cap +``` + +2) Install dependencies: + +```bash +npm i --save https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz +npm i --save @capacitor/core @capacitor/cli @capacitor/ios @capacitor/filesystem +``` + +3) Create CapacitorJS structure: + +```bash +npx cap init sheetjs-cap com.sheetjs.cap --web-dir=dist +npx cap add ios +``` + +4) Replace the contents of `src/App.svelte` with the following: + +```html title="src/App.svelte" + + +
+

SheetJS × CapacitorJS { version }

+ + +
{@html html}
+
+``` + +5) Test the app: + +```bash +npm run build; npx cap sync; npx cap run ios +``` + +There are 3 steps: build the Svelte app, sync with CapacitorJS, and run sim. +This sequence must be run every time to ensure changes are propagated. +
\ No newline at end of file diff --git a/docz/docs/03-demos/14-svelte.md b/docz/docs/03-demos/14-svelte.md index a40892f..421b973 100644 --- a/docz/docs/03-demos/14-svelte.md +++ b/docz/docs/03-demos/14-svelte.md @@ -7,6 +7,10 @@ title: Svelte This demo tries to cover common Svelte data flow ideas and strategies. Svelte familiarity is assumed. +Other demos cover general React deployments, including: + +- [iOS applications powered by CapacitorJS](./mobile#capacitorjs) + ## Installation