├── .gitignore ├── LICENSE ├── README.md ├── assemblyscript-wasm-package ├── .babelrc ├── README.md ├── demo.html ├── package.json ├── pkg │ ├── README.md │ ├── assets │ │ ├── index.d.ts │ │ ├── index.wasm │ │ └── index.wasm.map │ ├── dist-node │ │ └── index.js │ ├── dist-src │ │ └── index.js │ ├── dist-types │ │ └── index.d.ts │ ├── dist-web │ │ └── index.js │ └── package.json ├── src │ ├── config.ts │ ├── imports.js │ └── index.ts └── tsconfig.json ├── reason-ocaml-package ├── .merlin ├── README.md ├── bsconfig.json ├── package.json ├── pkg │ ├── README.md │ ├── dist-node │ │ └── index.js │ ├── dist-src │ │ └── index.js │ ├── dist-web │ │ └── index.js │ └── package.json └── src │ ├── demos.bs.js │ ├── demos.ml │ └── index.ml ├── simple-cli ├── README.md ├── package.json ├── pkg │ ├── README.md │ ├── dist-node │ │ ├── index.bin.js │ │ └── index.js │ ├── dist-src │ │ └── index.js │ └── package.json └── src │ ├── __tests__ │ └── Greeter.test.js │ ├── index.d.ts │ └── index.js ├── simple-package ├── README.md ├── package.json ├── pkg │ ├── README.md │ ├── dist-node │ │ └── index.js │ ├── dist-src │ │ └── index.js │ ├── dist-types │ │ └── index.d.ts │ ├── dist-web │ │ └── index.js │ └── package.json └── src │ ├── __tests__ │ └── Greeter.test.js │ └── index.js └── typescript-package ├── README.md ├── package.json ├── pkg ├── README.md ├── dist-node │ └── index.js ├── dist-src │ ├── foo.js │ └── index.js ├── dist-types │ ├── foo.d.ts │ └── index.d.ts ├── dist-web │ └── index.js └── package.json ├── src ├── __tests__ │ └── index.test.ts ├── foo.ts └── index.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | local 4 | 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | 24 | # nyc test coverage 25 | .nyc_output 26 | 27 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 28 | .grunt 29 | 30 | # Bower dependency directory (https://bower.io/) 31 | bower_components 32 | 33 | # node-waf configuration 34 | .lock-wscript 35 | 36 | # Compiled binary addons (https://nodejs.org/api/addons.html) 37 | build/Release 38 | 39 | # Dependency directories 40 | web_modules/ 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # Optional npm cache directory 48 | .npm 49 | 50 | # Optional eslint cache 51 | .eslintcache 52 | 53 | # Optional REPL history 54 | .node_repl_history 55 | 56 | # Output of 'npm pack' 57 | *.tgz 58 | 59 | # Yarn Integrity file 60 | .yarn-integrity 61 | 62 | # dotenv environment variables file 63 | .env 64 | 65 | # next.js build output 66 | .next 67 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 pikapkg 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # examples 2 | Example Pika packages & projects 3 | -------------------------------------------------------------------------------- /assemblyscript-wasm-package/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | ["@babel/plugin-proposal-decorators", {"legacy": true}] 4 | ] 5 | } -------------------------------------------------------------------------------- /assemblyscript-wasm-package/README.md: -------------------------------------------------------------------------------- 1 | # assemblyscript-wasm-package 2 | 3 | Uses [AssemblyScript](https://github.com/AssemblyScript/assemblyscript) to compile TypeScript into WASM, with JavaScript bindings. 4 | 5 | ## Build 6 | 7 | ``` 8 | npm i 9 | pack build 10 | ``` 11 | 12 | ## Demo 13 | 14 | Build the package, and then run `demo.html` in the browser to see a Game of Life demo. -------------------------------------------------------------------------------- /assemblyscript-wasm-package/demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Conway's Game of Life - AssemblyScript 5 | 6 | 7 | 16 | 17 | 18 |

19 | Conway's Game of Life in 20 | AssemblyScript 21 | ( source ) 22 |

23 | 24 |
Might be blurry because MS Edge does not support 'image-rendering: crisp-edges' (yet) :-(
25 | 134 | 135 | -------------------------------------------------------------------------------- /assemblyscript-wasm-package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pika/game-of-life", 3 | "version": "1.0.0", 4 | "license": "MIT", 5 | "@pika/pack": { 6 | "pipeline": [ 7 | ["@pika/plugin-wasm-assemblyscript", {}], 8 | ["@pika/plugin-wasm-bindings", {}] 9 | ] 10 | }, 11 | "dependencies": {}, 12 | "devDependencies": { 13 | "@babel/plugin-proposal-decorators": "^7.2.3", 14 | "@pika/plugin-wasm-assemblyscript": "^0.3.0", 15 | "@pika/plugin-wasm-bindings": "^0.3.0", 16 | "assemblyscript": "github:AssemblyScript/assemblyscript" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /assemblyscript-wasm-package/pkg/README.md: -------------------------------------------------------------------------------- 1 | # assemblyscript-wasm-package 2 | 3 | Uses [AssemblyScript](https://github.com/AssemblyScript/assemblyscript) to compile TypeScript into WASM, with JavaScript bindings. 4 | 5 | ## Build 6 | 7 | ``` 8 | npm i 9 | pack build 10 | ``` 11 | 12 | ## Demo 13 | 14 | Build the package, and then run `demo.html` in the browser to see a Game of Life demo. -------------------------------------------------------------------------------- /assemblyscript-wasm-package/pkg/assets/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module ASModule { 2 | type i8 = number; 3 | type i16 = number; 4 | type i32 = number; 5 | type u8 = number; 6 | type u16 = number; 7 | type u32 = number; 8 | type f32 = number; 9 | type f64 = number; 10 | type bool = any; 11 | function init(width: i32, height: i32): void; 12 | function step(): void; 13 | function fill(x: u32, y: u32, p: f64): void; 14 | } 15 | export default ASModule; 16 | -------------------------------------------------------------------------------- /assemblyscript-wasm-package/pkg/assets/index.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FredKSchott/pika-pack-examples/9f501374340bd547711f8a0f9330c448575076bd/assemblyscript-wasm-package/pkg/assets/index.wasm -------------------------------------------------------------------------------- /assemblyscript-wasm-package/pkg/assets/index.wasm.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["src/index.ts"],"names":[],"mappings":"8MA4BE,IACA,IACA,AAAI,OAGC,AAAQ,MAAb,EAAgB,EAAI,KACb,AAAQ,MAAb,EAAgB,EAAI,KACR,EAAgB,YAAM,EAAW,OAAa,EAAY,SAnBxE,AAAW,AAAC,EAAI,AAAI,SAAU,QAkBL,WADF,iBASb,EAAI,KACJ,EAAI,OAId,EAAgB,EAAI,KACO,EAAI,UACR,EAAI,EAAI,GAAnB,QACL,AAAQ,MAAb,EAAgB,EAAI,KAMlB,AAAqB,AACnB,AANuB,EAAI,sBAMV,GAAK,cAAiB,IAAK,AALzB,EAAI,EAAI,GAAnB,oBAKqD,IAC7D,cAAiB,IAA2B,cAAiB,IAC7D,cAAiB,IAAK,cAAiB,IAAK,cAAiB,MAI/D,AAAI,AADJ,AApD6B,AAAhB,AAAC,AAAI,QAAU,QAqDjB,KAAG,AAER,EAAkB,GAAW,mEAElB,EAAW,WACrB,AAED,EAAkB,mBAAa,EAAY,UAtDrD,AAAW,AAAC,EAAI,AAAI,SAAU,GAOpB,AAAY,EAAK,MAAjB,AADF,AAAS,EAAO,GAAM,aACd,SA2BS,WAHF,kBAiCvB,EAAiB,EAAK,KACpB,AAAI,qBAA8B,EAAY,UADvB,WAGpB,AAAS,MAAd,EAAiB,EAAK,KACpB,AAAI,OApEN,AAAW,AAAC,EAAI,AAAI,SAAU,GAoEM,EAAY,UADvB","sourceRoot":"assemblyscript:///","sourceContents":["// see: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life\n\n// Configuration imported from JS\nimport { BGR_ALIVE, BGR_DEAD, BIT_ROT } from \"./config\";\n\nvar w: i32, h: i32, s: i32;\n\n/** Gets an input pixel in the range [0, s]. */\n@inline\nfunction get(x: u32, y: u32): u32 {\n return load((y * w + x) << 2);\n}\n\n/** Sets an output pixel in the range [s, 2*s]. */\n@inline\nfunction set(x: u32, y: u32, v: u32): void {\n store((s + y * w + x) << 2, v);\n}\n\n/** Sets an output pixel in the range [s, 2*s] while fading it out. */\n@inline\nfunction rot(x: u32, y: u32, v: u32): void {\n var a = max((v >>> 24) - BIT_ROT, 0);\n set(x, y, (a << 24) | (v & 0x00ffffff));\n}\n\n/** Initializes width and height. Called once from JS. */\nexport function init(width: i32, height: i32): void {\n w = width;\n h = height;\n s = width * height;\n\n // Start by filling output with random live cells.\n for (let y = 0; y < h; ++y) {\n for (let x = 0; x < w; ++x) {\n set(x, y, Math.random() > 0.1 ? BGR_DEAD & 0x00ffffff : BGR_ALIVE | 0xff000000);\n }\n }\n}\n\n/** Performs one step. Called about 30 times a second from JS. */\nexport function step(): void {\n var hm1 = h - 1, // h - 1\n wm1 = w - 1; // w - 1\n\n // The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square\n // \"cells\", each of which is in one of two possible states, alive or dead.\n for (let y = 0; y < h; ++y) {\n let ym1 = y == 0 ? hm1 : y - 1,\n yp1 = y == hm1 ? 0 : y + 1;\n for (let x = 0; x < w; ++x) {\n let xm1 = x == 0 ? wm1 : x - 1,\n xp1 = x == wm1 ? 0 : x + 1;\n\n // Every cell interacts with its eight neighbours, which are the cells that are horizontally,\n // vertically, or diagonally adjacent. Least significant bit indicates alive or dead.\n let aliveNeighbors = (\n (get(xm1, ym1) & 1) + (get(x , ym1) & 1) + (get(xp1, ym1) & 1) +\n (get(xm1, y ) & 1) + (get(xp1, y ) & 1) +\n (get(xm1, yp1) & 1) + (get(x , yp1) & 1) + (get(xp1, yp1) & 1)\n );\n\n let self = get(x, y);\n if (self & 1) {\n // A live cell with 2 or 3 live neighbors rots on to the next generation.\n if ((aliveNeighbors & 0b1110) == 0b0010) rot(x, y, self);\n // A live cell with fewer than 2 or more than 3 live neighbors dies.\n else set(x, y, BGR_DEAD | 0xff000000);\n } else {\n // A dead cell with exactly 3 live neighbors becomes a live cell.\n if (aliveNeighbors == 3) set(x, y, BGR_ALIVE | 0xff000000);\n // A dead cell with fewer or more than 3 live neighbors just rots.\n else rot(x, y, self);\n }\n }\n }\n}\n\n/** Fills the row and column indicated by `x` and `y` with random live cells. */\nexport function fill(x: u32, y: u32, p: f64): void {\n for (let ix = 0; ix < w; ++ix) {\n if (Math.random() < p) set(ix, y, BGR_ALIVE | 0xff000000);\n }\n for (let iy = 0; iy < h; ++iy) {\n if (Math.random() < p) set(x, iy, BGR_ALIVE | 0xff000000);\n }\n}"]} -------------------------------------------------------------------------------- /assemblyscript-wasm-package/pkg/dist-node/index.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | exports.default = exports.createWASM = function createWASM(deps = {}) { 4 | const buf = fs.readFileSync(path.join(__dirname, '../assets/index.wasm')); 5 | return WebAssembly.instantiate(buf, deps); 6 | } 7 | -------------------------------------------------------------------------------- /assemblyscript-wasm-package/pkg/dist-src/index.js: -------------------------------------------------------------------------------- 1 | export function createWASM(deps = {}) { 2 | const url = new URL("../assets/index.wasm", import.meta.url); 3 | const input = window.fetch(url); 4 | return WebAssembly.instantiateStreaming(input, deps); 5 | } 6 | export default createWASM; 7 | -------------------------------------------------------------------------------- /assemblyscript-wasm-package/pkg/dist-types/index.d.ts: -------------------------------------------------------------------------------- 1 | declare class WASMInstance { 2 | readonly exports: any; 3 | constructor(module: any, importObject?: any); 4 | } 5 | interface ResultObject {module: any; instance: WASMInstance} 6 | export function createWASM(importObject?: object): Promise; 7 | export default function createWASM(importObject?: object): Promise; 8 | -------------------------------------------------------------------------------- /assemblyscript-wasm-package/pkg/dist-web/index.js: -------------------------------------------------------------------------------- 1 | export function createWASM(deps = {}) { 2 | if (typeof __webpack_require__ !== "undefined") { 3 | return __webpack_require__("../assets/index.wasm"); 4 | } 5 | const url = new URL("../assets/index.wasm", import.meta.url); 6 | const input = window.fetch(url); 7 | return WebAssembly.instantiateStreaming(input, deps); 8 | } 9 | export default createWASM; 10 | -------------------------------------------------------------------------------- /assemblyscript-wasm-package/pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pika/game-of-life", 3 | "description": "Uses [AssemblyScript](https://github.com/AssemblyScript/assemblyscript) to compile TypeScript into WASM, with JavaScript bindings.", 4 | "version": "1.0.0", 5 | "license": "MIT", 6 | "src": "dist-src/index.js", 7 | "web": "dist-web/index.js", 8 | "node": "dist-node/index.js", 9 | "types": "dist-types/index.js", 10 | "pika": true, 11 | "sideEffects": false, 12 | "files": [ 13 | "dist-*/", 14 | "assets/", 15 | "bin/" 16 | ], 17 | "dependencies": {}, 18 | "devDependencies": { 19 | "@babel/plugin-proposal-decorators": "^7.2.3", 20 | "@pika/plugin-wasm-assemblyscript": "^0.3.0", 21 | "@pika/plugin-wasm-bindings": "^0.3.0", 22 | "assemblyscript": "github:AssemblyScript/assemblyscript" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /assemblyscript-wasm-package/src/config.ts: -------------------------------------------------------------------------------- 1 | // On the WASM side, 32-bit color values are modified in ABGR order (alpha, blue, green, red) 2 | // because WASM is little endian. This results in RGBA in memory, which is exactly what the image 3 | // buffer, composed of 8-bit components, expects on the JS side. 4 | export declare const BGR_ALIVE: u32; 5 | export declare const BGR_DEAD: u32; 6 | export declare const BIT_ROT: u32; -------------------------------------------------------------------------------- /assemblyscript-wasm-package/src/imports.js: -------------------------------------------------------------------------------- 1 | function rgb2bgr(rgb) { 2 | return ((rgb >>> 16) & 0xff) | (rgb & 0xff00) | (rgb & 0xff) << 16; 3 | } 4 | 5 | function createImports() { 6 | return { 7 | env: { 8 | memory: new WebAssembly.Memory({initial: 10}), 9 | }, 10 | config: { 11 | BGR_ALIVE : rgb2bgr(0xD392E6) | 1, // little endian, LSB must be set 12 | BGR_DEAD : rgb2bgr(0xA61B85) & ~1, // little endian, LSB must not be set 13 | BIT_ROT : 10 14 | }, 15 | Math 16 | }; 17 | } -------------------------------------------------------------------------------- /assemblyscript-wasm-package/src/index.ts: -------------------------------------------------------------------------------- 1 | // see: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life 2 | 3 | // Configuration imported from JS 4 | import { BGR_ALIVE, BGR_DEAD, BIT_ROT } from "./config"; 5 | 6 | var w: i32, h: i32, s: i32; 7 | 8 | /** Gets an input pixel in the range [0, s]. */ 9 | @inline 10 | function get(x: u32, y: u32): u32 { 11 | return load((y * w + x) << 2); 12 | } 13 | 14 | /** Sets an output pixel in the range [s, 2*s]. */ 15 | @inline 16 | function set(x: u32, y: u32, v: u32): void { 17 | store((s + y * w + x) << 2, v); 18 | } 19 | 20 | /** Sets an output pixel in the range [s, 2*s] while fading it out. */ 21 | @inline 22 | function rot(x: u32, y: u32, v: u32): void { 23 | var a = max((v >>> 24) - BIT_ROT, 0); 24 | set(x, y, (a << 24) | (v & 0x00ffffff)); 25 | } 26 | 27 | /** Initializes width and height. Called once from JS. */ 28 | export function init(width: i32, height: i32): void { 29 | w = width; 30 | h = height; 31 | s = width * height; 32 | 33 | // Start by filling output with random live cells. 34 | for (let y = 0; y < h; ++y) { 35 | for (let x = 0; x < w; ++x) { 36 | set(x, y, Math.random() > 0.1 ? BGR_DEAD & 0x00ffffff : BGR_ALIVE | 0xff000000); 37 | } 38 | } 39 | } 40 | 41 | /** Performs one step. Called about 30 times a second from JS. */ 42 | export function step(): void { 43 | var hm1 = h - 1, // h - 1 44 | wm1 = w - 1; // w - 1 45 | 46 | // The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square 47 | // "cells", each of which is in one of two possible states, alive or dead. 48 | for (let y = 0; y < h; ++y) { 49 | let ym1 = y == 0 ? hm1 : y - 1, 50 | yp1 = y == hm1 ? 0 : y + 1; 51 | for (let x = 0; x < w; ++x) { 52 | let xm1 = x == 0 ? wm1 : x - 1, 53 | xp1 = x == wm1 ? 0 : x + 1; 54 | 55 | // Every cell interacts with its eight neighbours, which are the cells that are horizontally, 56 | // vertically, or diagonally adjacent. Least significant bit indicates alive or dead. 57 | let aliveNeighbors = ( 58 | (get(xm1, ym1) & 1) + (get(x , ym1) & 1) + (get(xp1, ym1) & 1) + 59 | (get(xm1, y ) & 1) + (get(xp1, y ) & 1) + 60 | (get(xm1, yp1) & 1) + (get(x , yp1) & 1) + (get(xp1, yp1) & 1) 61 | ); 62 | 63 | let self = get(x, y); 64 | if (self & 1) { 65 | // A live cell with 2 or 3 live neighbors rots on to the next generation. 66 | if ((aliveNeighbors & 0b1110) == 0b0010) rot(x, y, self); 67 | // A live cell with fewer than 2 or more than 3 live neighbors dies. 68 | else set(x, y, BGR_DEAD | 0xff000000); 69 | } else { 70 | // A dead cell with exactly 3 live neighbors becomes a live cell. 71 | if (aliveNeighbors == 3) set(x, y, BGR_ALIVE | 0xff000000); 72 | // A dead cell with fewer or more than 3 live neighbors just rots. 73 | else rot(x, y, self); 74 | } 75 | } 76 | } 77 | } 78 | 79 | /** Fills the row and column indicated by `x` and `y` with random live cells. */ 80 | export function fill(x: u32, y: u32, p: f64): void { 81 | for (let ix = 0; ix < w; ++ix) { 82 | if (Math.random() < p) set(ix, y, BGR_ALIVE | 0xff000000); 83 | } 84 | for (let iy = 0; iy < h; ++iy) { 85 | if (Math.random() < p) set(x, iy, BGR_ALIVE | 0xff000000); 86 | } 87 | } -------------------------------------------------------------------------------- /assemblyscript-wasm-package/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./node_modules/assemblyscript/std/assembly.json", 3 | "include": [ 4 | "./src/**/*.ts" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /reason-ocaml-package/.merlin: -------------------------------------------------------------------------------- 1 | ####{BSB GENERATED: NO EDIT 2 | FLG -ppx /Users/fks/Code/pika-examples/reason-ocaml-package/node_modules/bs-platform/lib/bsppx.exe 3 | S /Users/fks/Code/pika-examples/reason-ocaml-package/node_modules/bs-platform/lib/ocaml 4 | B /Users/fks/Code/pika-examples/reason-ocaml-package/node_modules/bs-platform/lib/ocaml 5 | FLG -nostdlib -color always 6 | FLG -w -30-40+6+7+27+32..39+44+45+101 7 | S src 8 | B lib/bs/src 9 | ####BSB GENERATED: NO EDIT} 10 | -------------------------------------------------------------------------------- /reason-ocaml-package/README.md: -------------------------------------------------------------------------------- 1 | # reason-ocaml-package 2 | 3 | Uses [BuckleScript](https://bucklescript.github.io/) to compile Reason or OCaml to a JavaScript npm package. 4 | 5 | ``` 6 | npm i 7 | pack build 8 | ``` -------------------------------------------------------------------------------- /reason-ocaml-package/bsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-bs-project", 3 | "version": "0.1.0", 4 | "sources": { 5 | "dir" : "src", 6 | "subdirs" : true 7 | }, 8 | "package-specs": ["es6"], 9 | "suffix": ".bs.js", 10 | "bs-dependencies": [ 11 | // add your bs-dependencies here 12 | ], 13 | "warnings": { 14 | "error" : "+101" 15 | }, 16 | "refmt": 3 17 | } 18 | -------------------------------------------------------------------------------- /reason-ocaml-package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pika/reason-ocaml-package", 3 | "version": "0.1.0", 4 | "license": "MIT", 5 | "private": true, 6 | "@pika/pack": { 7 | "pipeline": [ 8 | ["@pika/plugin-wasm-bucklescript", {}], 9 | ["@pika/plugin-build-node", {}], 10 | ["@pika/plugin-build-web", {}] 11 | ] 12 | }, 13 | "devDependencies": { 14 | "@pika/plugin-wasm-bucklescript": "^0.3.0", 15 | "@pika/plugin-build-node": "^0.3.0", 16 | "@pika/plugin-build-web": "^0.3.0", 17 | "bs-platform": "^4.0.18" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /reason-ocaml-package/pkg/README.md: -------------------------------------------------------------------------------- 1 | # reason-ocaml-package 2 | 3 | Uses [BuckleScript](https://bucklescript.github.io/) to compile Reason or OCaml to a JavaScript npm package. 4 | 5 | ``` 6 | npm i 7 | pack build 8 | ``` -------------------------------------------------------------------------------- /reason-ocaml-package/pkg/dist-node/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // Generated by BUCKLESCRIPT VERSION 4.0.18, PLEASE EDIT WITH CARE 4 | console.log("Hello, BuckleScript"); 5 | /* Not a pure module */ 6 | -------------------------------------------------------------------------------- /reason-ocaml-package/pkg/dist-src/index.js: -------------------------------------------------------------------------------- 1 | // Generated by BUCKLESCRIPT VERSION 4.0.18, PLEASE EDIT WITH CARE 2 | 3 | 4 | console.log("Hello, BuckleScript"); 5 | /* Not a pure module */ 6 | -------------------------------------------------------------------------------- /reason-ocaml-package/pkg/dist-web/index.js: -------------------------------------------------------------------------------- 1 | // Generated by BUCKLESCRIPT VERSION 4.0.18, PLEASE EDIT WITH CARE 2 | console.log("Hello, BuckleScript"); 3 | /* Not a pure module */ 4 | -------------------------------------------------------------------------------- /reason-ocaml-package/pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pika/reason-ocaml-package", 3 | "description": "Uses [BuckleScript](https://bucklescript.github.io/) to compile Reason or OCaml to a JavaScript npm package.", 4 | "version": "0.1.0", 5 | "license": "MIT", 6 | "es2015": "dist-src/index.js", 7 | "main": "dist-node/index.js", 8 | "module": "dist-web/index.js", 9 | "pika": true, 10 | "sideEffects": false, 11 | "files": [ 12 | "dist-*/", 13 | "assets/", 14 | "bin/" 15 | ], 16 | "dependencies": {}, 17 | "devDependencies": { 18 | "@pika/plugin-wasm-bucklescript": "^0.3.0", 19 | "@pika/plugin-build-node": "^0.3.0", 20 | "@pika/plugin-build-web": "^0.3.0", 21 | "bs-platform": "^4.0.18" 22 | }, 23 | "private": true 24 | } 25 | -------------------------------------------------------------------------------- /reason-ocaml-package/src/demos.bs.js: -------------------------------------------------------------------------------- 1 | // Generated by BUCKLESCRIPT VERSION 4.0.18, PLEASE EDIT WITH CARE 2 | 'use strict'; 3 | 4 | 5 | console.log("Hello, BuckleScript"); 6 | 7 | /* Not a pure module */ 8 | -------------------------------------------------------------------------------- /reason-ocaml-package/src/demos.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let () = Js.log "Hello, BuckleScript" -------------------------------------------------------------------------------- /reason-ocaml-package/src/index.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let () = Js.log "Hello, BuckleScript" -------------------------------------------------------------------------------- /simple-cli/README.md: -------------------------------------------------------------------------------- 1 | # simple-cli 2 | 3 | Example of how to build a simple JavaScript library with an additional CLI wrapper provided by `@pika/plugin-simple-bin`. 4 | 5 | ## Build 6 | 7 | ``` 8 | npm i 9 | pack build 10 | ``` -------------------------------------------------------------------------------- /simple-cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pika/simple-cli", 3 | "description": "A simple example Pika CLI package", 4 | "version": "1.0.0", 5 | "scripts": {}, 6 | "license": "MIT", 7 | "repository": { 8 | "type" : "git", 9 | "url" : "https://github.com/@pikapkg/examples.git" 10 | }, 11 | "@pika/pack": { 12 | "pipeline": [ 13 | ["@pika/plugin-standard-pkg", {"exclude": ["__tests__/*"]}], 14 | ["@pika/plugin-build-node"], 15 | ["@pika/plugin-simple-bin", {"bin": "my-example-cli"}] 16 | ] 17 | }, 18 | "dependencies": {}, 19 | "devDependencies": { 20 | "@pika/plugin-standard-pkg": "^0.3.0", 21 | "@pika/plugin-build-node": "^0.3.0", 22 | "@pika/plugin-simple-bin": "^0.3.0" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /simple-cli/pkg/README.md: -------------------------------------------------------------------------------- 1 | # simple-cli 2 | 3 | Example of how to build a simple JavaScript library with an additional CLI wrapper provided by `@pika/plugin-simple-bin`. 4 | 5 | ## Build 6 | 7 | ``` 8 | npm i 9 | pack build 10 | ``` -------------------------------------------------------------------------------- /simple-cli/pkg/dist-node/index.bin.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict'; 3 | 4 | let cli; 5 | try { 6 | cli = require('./index.bundled.js'); 7 | } catch (err) { 8 | // We don't have/need this on legacy builds and dev builds 9 | // If an error happens here, throw it, that means no Node.js distribution exists at all. 10 | cli = require('../'); 11 | } 12 | 13 | if (cli.autoRun) { 14 | return; 15 | } 16 | 17 | const run = cli.run || cli.cli || cli.default; 18 | run(process.argv).catch(function (error) { 19 | console.error(error.stack || error.message || error); 20 | process.exitCode = 1; 21 | }); 22 | -------------------------------------------------------------------------------- /simple-cli/pkg/dist-node/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { value: true }); 4 | 5 | function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { 6 | try { 7 | var info = gen[key](arg); 8 | var value = info.value; 9 | } catch (error) { 10 | reject(error); 11 | return; 12 | } 13 | 14 | if (info.done) { 15 | resolve(value); 16 | } else { 17 | Promise.resolve(value).then(_next, _throw); 18 | } 19 | } 20 | 21 | function _asyncToGenerator(fn) { 22 | return function () { 23 | var self = this, 24 | args = arguments; 25 | return new Promise(function (resolve, reject) { 26 | var gen = fn.apply(self, args); 27 | 28 | function _next(value) { 29 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); 30 | } 31 | 32 | function _throw(err) { 33 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); 34 | } 35 | 36 | _next(undefined); 37 | }); 38 | }; 39 | } 40 | 41 | const Greeter = name => `Hello ${name}, from ${new (typeof URL !== 'undefined' ? URL : require('ur'+'l').URL)((process.browser ? '' : 'file:') + __filename, process.browser && document.baseURI).href}`; 42 | /** 43 | * Will be called by the CLI wrapper provided by @pika/plugin-simple-bin 44 | */ 45 | 46 | function run(_x) { 47 | return _run.apply(this, arguments); 48 | } 49 | 50 | function _run() { 51 | _run = _asyncToGenerator(function* (args) { 52 | console.log(Greeter(args[2])); 53 | }); 54 | return _run.apply(this, arguments); 55 | } 56 | 57 | exports.Greeter = Greeter; 58 | exports.run = run; 59 | -------------------------------------------------------------------------------- /simple-cli/pkg/dist-src/index.js: -------------------------------------------------------------------------------- 1 | export const Greeter = name => `Hello ${name}, from ${import.meta.url}`; 2 | /** 3 | * Will be called by the CLI wrapper provided by @pika/plugin-simple-bin 4 | */ 5 | 6 | export async function run(args) { 7 | console.log(Greeter(args[2])); 8 | } -------------------------------------------------------------------------------- /simple-cli/pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pika/simple-cli", 3 | "description": "A simple example Pika CLI package", 4 | "version": "1.0.0", 5 | "license": "MIT", 6 | "bin": { 7 | "my-example-cli": "dist-node/index.bin.js" 8 | }, 9 | "esnext": "dist-src/index.js", 10 | "main": "dist-node/index.js", 11 | "pika": true, 12 | "sideEffects": false, 13 | "files": [ 14 | "dist-*/", 15 | "assets/", 16 | "bin/" 17 | ], 18 | "dependencies": {}, 19 | "devDependencies": { 20 | "@pika/plugin-standard-pkg": "^0.3.0", 21 | "@pika/plugin-build-node": "^0.3.0", 22 | "@pika/plugin-simple-bin": "^0.3.0" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /simple-cli/src/__tests__/Greeter.test.js: -------------------------------------------------------------------------------- 1 | import { Greeter } from '../index'; 2 | 3 | test('My Greeter', () => { 4 | expect(Greeter('Carl').startsWith('Hello Carl')).toBeTrue(); 5 | }); 6 | -------------------------------------------------------------------------------- /simple-cli/src/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare const Greeter: (name: string) => string; 2 | -------------------------------------------------------------------------------- /simple-cli/src/index.js: -------------------------------------------------------------------------------- 1 | export const Greeter = (name) => `Hello ${name}, from ${import.meta.url}`; 2 | 3 | /** 4 | * Will be called by the CLI wrapper provided by @pika/plugin-simple-bin 5 | */ 6 | export async function run(args) { 7 | console.log(Greeter(args[2])); 8 | } 9 | -------------------------------------------------------------------------------- /simple-package/README.md: -------------------------------------------------------------------------------- 1 | # simple-package 2 | 3 | Example of how to build a simple JavaScript library. 4 | 5 | ## Build 6 | 7 | ``` 8 | npm i 9 | pack build 10 | ``` -------------------------------------------------------------------------------- /simple-package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pikapkg/simple-package", 3 | "description": "A simple example Pika package", 4 | "version": "1.0.0", 5 | "scripts": {}, 6 | "license": "MIT", 7 | "repository": { 8 | "type" : "git", 9 | "url" : "https://github.com/@pikapkg/examples.git" 10 | }, 11 | "@pika/pack": { 12 | "pipeline": [ 13 | ["@pika/plugin-standard-pkg", {"exclude": ["__tests__/*"]}], 14 | ["@pika/plugin-build-node"], 15 | ["@pika/plugin-build-web"], 16 | ["@pika/plugin-build-types"] 17 | ] 18 | }, 19 | "dependencies": {}, 20 | "devDependencies": { 21 | "@pika/plugin-build-node": "^0.3.4", 22 | "@pika/plugin-build-types": "^0.3.4", 23 | "@pika/plugin-build-web": "^0.3.4", 24 | "@pika/plugin-bundle-web": "^0.3.4", 25 | "@pika/plugin-standard-pkg": "^0.3.4", 26 | "@pika/types": "^0.3.4" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /simple-package/pkg/README.md: -------------------------------------------------------------------------------- 1 | # simple-package 2 | 3 | Example of how to build a simple JavaScript library. 4 | 5 | ## Build 6 | 7 | ``` 8 | npm i 9 | pack build 10 | ``` -------------------------------------------------------------------------------- /simple-package/pkg/dist-node/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { value: true }); 4 | 5 | /** 6 | * Greet your friends! 7 | * @param {string} name 8 | */ 9 | const Greeter = name => `Hello ${name}, from ${new (typeof URL !== 'undefined' ? URL : require('ur'+'l').URL)((process.browser ? '' : 'file:') + __filename, process.browser && document.baseURI).href}`; 10 | 11 | exports.Greeter = Greeter; 12 | -------------------------------------------------------------------------------- /simple-package/pkg/dist-src/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Greet your friends! 3 | * @param {string} name 4 | */ 5 | export const Greeter = name => `Hello ${name}, from ${import.meta.url}`; -------------------------------------------------------------------------------- /simple-package/pkg/dist-types/index.d.ts: -------------------------------------------------------------------------------- 1 | export function Greeter(name: any): void; 2 | -------------------------------------------------------------------------------- /simple-package/pkg/dist-web/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Greet your friends! 3 | * @param {string} name 4 | */ 5 | const Greeter = name => `Hello ${name}, from ${import.meta.url}`; 6 | 7 | export { Greeter }; 8 | -------------------------------------------------------------------------------- /simple-package/pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pika/simple-package", 3 | "description": "A simple example Pika package", 4 | "version": "1.0.0", 5 | "license": "MIT", 6 | "esnext": "dist-src/index.js", 7 | "main": "dist-node/index.js", 8 | "module": "dist-web/index.js", 9 | "types": "dist-types/index.d.ts", 10 | "pika": true, 11 | "sideEffects": false, 12 | "files": [ 13 | "dist-*/", 14 | "assets/", 15 | "bin/" 16 | ], 17 | "dependencies": {}, 18 | "devDependencies": { 19 | "@pika/plugin-build-node": "^0.3.4", 20 | "@pika/plugin-build-types": "^0.3.4", 21 | "@pika/plugin-build-web": "^0.3.4", 22 | "@pika/plugin-bundle-web": "^0.3.4", 23 | "@pika/plugin-standard-pkg": "^0.3.4", 24 | "@pika/types": "^0.3.4" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /simple-package/src/__tests__/Greeter.test.js: -------------------------------------------------------------------------------- 1 | import { Greeter } from '../index'; 2 | 3 | test('My Greeter', () => { 4 | expect(Greeter('Carl').startsWith('Hello Carl')).toBeTrue(); 5 | }); 6 | -------------------------------------------------------------------------------- /simple-package/src/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Greet your friends! 3 | * @param {string} name 4 | */ 5 | export const Greeter = (name) => `Hello ${name}, from ${import.meta.url}`; 6 | -------------------------------------------------------------------------------- /typescript-package/README.md: -------------------------------------------------------------------------------- 1 | # typescript-package 2 | 3 | Example of how to build a simple npm package from TypeScript source. 4 | 5 | 6 | ## Build 7 | 8 | ``` 9 | npm i 10 | pack build 11 | ``` -------------------------------------------------------------------------------- /typescript-package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pika/typescript-package", 3 | "description": "A simple example Pika package written in TypeScript", 4 | "version": "1.0.0", 5 | "scripts": {}, 6 | "license": "MIT", 7 | "repository": { 8 | "type" : "git", 9 | "url" : "https://github.com/@pikapkg/examples.git" 10 | }, 11 | "@pika/pack": { 12 | "pipeline": [ 13 | ["@pika/plugin-ts-standard-pkg"], 14 | ["@pika/plugin-build-node"], 15 | ["@pika/plugin-build-web"], 16 | ["@pika/plugin-build-deno"] 17 | ] 18 | }, 19 | "dependencies": {}, 20 | "devDependencies": { 21 | "@pika/plugin-build-node": "^0.3.4", 22 | "@pika/plugin-build-deno": "^0.3.4", 23 | "@pika/plugin-build-web": "^0.3.4", 24 | "@pika/plugin-ts-standard-pkg": "^0.3.4", 25 | "typescript": "^3.4.5" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /typescript-package/pkg/README.md: -------------------------------------------------------------------------------- 1 | # typescript-package 2 | 3 | Example of how to build a simple npm package from TypeScript source. 4 | 5 | 6 | ## Build 7 | 8 | ``` 9 | npm i 10 | pack build 11 | ``` -------------------------------------------------------------------------------- /typescript-package/pkg/dist-node/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { value: true }); 4 | 5 | function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { 6 | try { 7 | var info = gen[key](arg); 8 | var value = info.value; 9 | } catch (error) { 10 | reject(error); 11 | return; 12 | } 13 | 14 | if (info.done) { 15 | resolve(value); 16 | } else { 17 | Promise.resolve(value).then(_next, _throw); 18 | } 19 | } 20 | 21 | function _asyncToGenerator(fn) { 22 | return function () { 23 | var self = this, 24 | args = arguments; 25 | return new Promise(function (resolve, reject) { 26 | var gen = fn.apply(self, args); 27 | 28 | function _next(value) { 29 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); 30 | } 31 | 32 | function _throw(err) { 33 | asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); 34 | } 35 | 36 | _next(undefined); 37 | }); 38 | }; 39 | } 40 | 41 | const greetOutLoudAsync = 42 | /*#__PURE__*/ 43 | function () { 44 | var _ref = _asyncToGenerator(function* (name) { 45 | console.log(`Hello, ${name} (async)`); 46 | }); 47 | 48 | return function greetOutLoudAsync(_x) { 49 | return _ref.apply(this, arguments); 50 | }; 51 | }(); 52 | 53 | const greetOutLoud = name => { 54 | console.log(`Hello, ${name}`); 55 | }; 56 | 57 | exports.greetOutLoud = greetOutLoud; 58 | exports.greetOutLoudAsync = greetOutLoudAsync; 59 | -------------------------------------------------------------------------------- /typescript-package/pkg/dist-src/foo.js: -------------------------------------------------------------------------------- 1 | export const greetOutLoudAsync = (async (name) => { 2 | console.log(`Hello, ${name} (async)`); 3 | }); 4 | -------------------------------------------------------------------------------- /typescript-package/pkg/dist-src/index.js: -------------------------------------------------------------------------------- 1 | export const greetOutLoud = (name) => { 2 | console.log(`Hello, ${name}`); 3 | }; 4 | import { greetOutLoudAsync } from './foo'; 5 | export { greetOutLoudAsync }; 6 | -------------------------------------------------------------------------------- /typescript-package/pkg/dist-types/foo.d.ts: -------------------------------------------------------------------------------- 1 | export declare const greetOutLoudAsync: (name: string) => Promise; 2 | -------------------------------------------------------------------------------- /typescript-package/pkg/dist-types/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare const greetOutLoud: (name: string) => void; 2 | import { greetOutLoudAsync } from './foo'; 3 | export { greetOutLoudAsync }; 4 | -------------------------------------------------------------------------------- /typescript-package/pkg/dist-web/index.js: -------------------------------------------------------------------------------- 1 | const greetOutLoudAsync = async name => { 2 | console.log(`Hello, ${name} (async)`); 3 | }; 4 | 5 | const greetOutLoud = name => { 6 | console.log(`Hello, ${name}`); 7 | }; 8 | 9 | export { greetOutLoud, greetOutLoudAsync }; 10 | -------------------------------------------------------------------------------- /typescript-package/pkg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@pika/typescript-package", 3 | "description": "A simple example Pika package written in TypeScript", 4 | "version": "1.0.0", 5 | "license": "MIT", 6 | "source": "dist-src/index.js", 7 | "types": "dist-types/index.js", 8 | "main": "dist-node/index.js", 9 | "module": "dist-web/index.js", 10 | "deno": "dist-deno/index.ts", 11 | "pika": true, 12 | "sideEffects": false, 13 | "files": [ 14 | "dist-*/", 15 | "assets/", 16 | "bin/" 17 | ], 18 | "dependencies": {}, 19 | "devDependencies": { 20 | "@pika/plugin-build-node": "^0.3.4", 21 | "@pika/plugin-build-deno": "^0.3.4", 22 | "@pika/plugin-build-web": "^0.3.4", 23 | "@pika/plugin-ts-standard-pkg": "^0.3.4", 24 | "typescript": "^3.2.2" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /typescript-package/src/__tests__/index.test.ts: -------------------------------------------------------------------------------- 1 | import { greetOutLoud } from '../index'; 2 | 3 | test('My Greeter', () => { 4 | expect(greetOutLoud).toBeDefined(); 5 | }); 6 | -------------------------------------------------------------------------------- /typescript-package/src/foo.ts: -------------------------------------------------------------------------------- 1 | export const greetOutLoudAsync = (async (name: string) => { 2 | console.log(`Hello, ${name} (async)`); 3 | }); -------------------------------------------------------------------------------- /typescript-package/src/index.ts: -------------------------------------------------------------------------------- 1 | export const greetOutLoud = (name: string) => { 2 | console.log(`Hello, ${name}`); 3 | }; 4 | 5 | import {greetOutLoudAsync} from './foo'; 6 | export {greetOutLoudAsync}; 7 | -------------------------------------------------------------------------------- /typescript-package/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2019", 4 | "module": "esnext", 5 | "strict": true 6 | }, 7 | "include": ["src/index.ts"], 8 | "exclude": ["node_modules", "**/__tests__/*"] 9 | } 10 | --------------------------------------------------------------------------------