amotify-ex-spreadsheet 0.0.1 → 0.0.3

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/index.js CHANGED
@@ -1 +1 @@
1
- var m=(e,r,t)=>new Promise((o,l)=>{var c=n=>{try{s(t.next(n))}catch(i){l(i)}},a=n=>{try{s(t.throw(n))}catch(i){l(i)}},s=n=>n.done?o(n.value):Promise.resolve(n.value).then(c,a);s((t=t.apply(e,r)).next())});import d from"@mingoo/jsmin";const h=(e,r)=>new h.fn.SpreadSheet(e,r);h.fn=h.prototype={},d.extend({SpreadSheet:function(e,r){this.ok=!0;try{this.workbook=e,this.fileName=r}catch(t){console.log(t),this.ok=!1}return this},isValid:function(){return this.ok},getWorkbook:function(){return this.workbook},updateFileName:function(e){return this.fileName=e,this},updateMerges:function(e){this.toJson().sheets.forEach((t,o)=>{let l=e[o];const c=this.workbook.getWorksheet(t.sheetName);for(let[a,s]of l)a&&s&&c.mergeCells(a+":"+s)})},updateStyles:function(e){this.toJson().sheets.forEach((t,o)=>{let l=e[o];const c=this.workbook.getWorksheet(t.sheetName);for(let a of l){let{type:s,target:n,values:i}=a,y=d.flatArray(n);for(let[p,f]of Object.entries(i))for(let u of y)c["get"+s.toCapital()](u)[p]=f}})},toJson:function(){let e={fileName:this.fileName,sheets:[]};return this.workbook.eachSheet((r,t)=>{let o={sheetName:r.name,rows:[]};r.eachRow((l,c)=>{let[a,...s]=l.values;o.rows.push(s)}),e.sheets.push(o)}),e},export:function(e){return m(this,null,function*(){e=e||"xlsx";const r=yield this.workbook[e].writeBuffer(),t=new Blob([r],{type:"application/octet-binary"}),o=document.createElement("a");o.href=(global.URL||global.webkitURL).createObjectURL(t),o.download=this.fileName+"."+e,o.click(),o.remove()})}},h),h.fn.SpreadSheet.prototype=h.fn,h.fn.SpreadSheet.prototype.constructor=h;let S="https://cdn.amotify.com/@env/@foreign/exceljs.min.js";const g={readFromFile:e=>m(void 0,null,function*(){if(global.ExcelJS||(yield d.CDNReader(S)),!global.ExcelJS)return;let r=e.type,t=e.name.replace(/\.[^/.]+$/,"");if(r.match(/csv/)){const a=(yield e.text()).split(/[\n\r]+/).map(i=>i.split(/,/)),s=new ExcelJS.Workbook,n=s.addWorksheet("Sheet1");return a.forEach(i=>n.addRow(i)),h(s,t)}const o=new ExcelJS.Workbook,l=(yield e.read("binaryString")).target.result;return h(yield o.xlsx.load(l),t)}),readFromJson:e=>m(void 0,null,function*(){if(global.ExcelJS||(yield d.CDNReader(S)),!global.ExcelJS)return;let{sheets:r,fileName:t=""}=e;t=t||d.uuid.gen();const o=new ExcelJS.Workbook;return r.forEach((l,c)=>{let{sheetName:a,rows:s,merges:n=[],styles:i=[]}=l;a=a||"\u30B7\u30FC\u30C8"+(c+1),o.addWorksheet(a);const y=o.getWorksheet(a);y.addRows(s);for(let[p,f]of n)p&&f&&y.mergeCells(p+":"+f);for(let p of i){let{type:f,target:u,values:k}=p,w=d.flatArray(u);for(let[b,x]of Object.entries(k))for(let v of w)y["get"+f.toCapital()](v)[b]=x}}),h(o,t)})};export{g as SpreadSheet,g as default};
1
+ var u=(e,r,o)=>new Promise((t,l)=>{var h=n=>{try{s(o.next(n))}catch(i){l(i)}},a=n=>{try{s(o.throw(n))}catch(i){l(i)}},s=n=>n.done?t(n.value):Promise.resolve(n.value).then(h,a);s((o=o.apply(e,r)).next())});import m from"@mingoo/jsmin";const g=e=>new Promise((r,o)=>{if(!e)return r(!1);let t=document.createElement("script");t.src=e,t.addEventListener("load",()=>{r(!0)}),m(document.body).append(t)}),c=(e,r)=>new c.fn.SpreadSheet(e,r);c.fn=c.prototype={},m.extend({SpreadSheet:function(e,r){this.ok=!0;try{this.workbook=e,this.fileName=r}catch(o){console.log(o),this.ok=!1}return this},isValid:function(){return this.ok},getWorkbook:function(){return this.workbook},updateFileName:function(e){return this.fileName=e,this},updateMerges:function(e){this.toJson().sheets.forEach((o,t)=>{let l=e[t];const h=this.workbook.getWorksheet(o.sheetName);for(let[a,s]of l)a&&s&&h.mergeCells(a+":"+s)})},updateStyles:function(e){this.toJson().sheets.forEach((o,t)=>{let l=e[t];const h=this.workbook.getWorksheet(o.sheetName);for(let a of l){let{type:s,target:n,values:i}=a,d=m.flatArray(n);for(let[p,f]of Object.entries(i))for(let y of d)h["get"+s.toCapital()](y)[p]=f}})},toJson:function(){let e={fileName:this.fileName,sheets:[]};return this.workbook.eachSheet((r,o)=>{let t={sheetName:r.name,rows:[]};r.eachRow((l,h)=>{let[a,...s]=l.values;t.rows.push(s)}),e.sheets.push(t)}),e},export:function(e){return u(this,null,function*(){e=e||"xlsx";const r=yield this.workbook[e].writeBuffer(),o=new Blob([r],{type:"application/octet-binary"}),t=document.createElement("a");t.href=(global.URL||global.webkitURL).createObjectURL(o),t.download=this.fileName+"."+e,t.click(),t.remove()})}},c),c.fn.SpreadSheet.prototype=c.fn,c.fn.SpreadSheet.prototype.constructor=c;let S="https://cdn.amotify.com/@env/@foreign/exceljs.min.js";const k={readFromFile:e=>u(void 0,null,function*(){if(global.ExcelJS||(yield g(S)),!global.ExcelJS)return;let r=e.type,o=e.name.replace(/\.[^/.]+$/,"");if(r.match(/csv/)){const a=(yield e.text()).split(/[\n\r]+/).map(i=>i.split(/,/)),s=new ExcelJS.Workbook,n=s.addWorksheet("Sheet1");return a.forEach(i=>n.addRow(i)),c(s,o)}const t=new ExcelJS.Workbook,l=(yield e.convert("binaryString")).target.result;return c(yield t.xlsx.load(l),o)}),readFromJson:e=>u(void 0,null,function*(){if(global.ExcelJS||(yield g(S)),!global.ExcelJS)return;let{sheets:r,fileName:o=""}=e;o=o||m.uuid.gen();const t=new ExcelJS.Workbook;return r.forEach((l,h)=>{let{sheetName:a,rows:s,merges:n=[],styles:i=[]}=l;a=a||"\u30B7\u30FC\u30C8"+(h+1),t.addWorksheet(a);const d=t.getWorksheet(a);d.addRows(s);for(let[p,f]of n)p&&f&&d.mergeCells(p+":"+f);for(let p of i){let{type:f,target:y,values:w}=p,b=m.flatArray(y);for(let[x,v]of Object.entries(w))for(let J of b)d["get"+f.toCapital()](J)[x]=v}}),c(t,o)})};export{k as SpreadSheet,k as default};
package/esbuild.ts ADDED
@@ -0,0 +1,17 @@
1
+ import esbuild from 'esbuild'
2
+
3
+ esbuild.build( {
4
+ entryPoints: [
5
+ './src/index.ts'
6
+ ],
7
+ format: 'esm',
8
+ splitting: true,
9
+ minify: true,
10
+ target: [ "ES6" ],
11
+ outbase: './src',
12
+ outdir: './dist',
13
+ platform: 'node',
14
+ external: [],
15
+ } )
16
+
17
+ // npm publish --access=public
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amotify-ex-spreadsheet",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "amotify spreadsheet extension",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,7 +8,7 @@
8
8
  "clean": "rimraf dist",
9
9
  "start": "run-p start:*",
10
10
  "start:clean": "rimraf dist",
11
- "start:esbuild": "nodemon bundler.ts --watch",
11
+ "start:esbuild": "nodemon esbuild.ts --watch",
12
12
  "start:declaration": "npx tsc --declaration --emitDeclarationOnly --skipLibCheck --declarationDir './dist' --watch"
13
13
  },
14
14
  "repository": {
@@ -26,9 +26,9 @@
26
26
  },
27
27
  "homepage": "https://github.com/IkkoKoyama/amotify-ex-spreadsheet#readme",
28
28
  "dependencies": {
29
- "@mingoo/jsmin": "^0.0.21",
29
+ "@mingoo/jsmin": "^0.0.53",
30
30
  "@types/react": "^18.3.1",
31
- "amotify": "^0.1.56",
31
+ "amotify": "^0.2.25",
32
32
  "esbuild": "^0.20.2",
33
33
  "nodemon": "^3.0.1",
34
34
  "npm-run-all": "^4.1.5",