~evanj/wigly

039e362720ca2fd39ce7cf9f29fd201f189bc7f4 — Evan M Jones 2 years ago 00379f5
0.4.2
5 files changed, 27 insertions(+), 9 deletions(-)

M .npmignore
M package-lock.json
M package.json
M src/main.js
M test/main.js
M .npmignore => .npmignore +2 -2
@@ 1,6 1,6 @@
assets
example
src
test
.gitignore
.cache
\ No newline at end of file
.cache
.webpack.config.js
\ No newline at end of file

M package-lock.json => package-lock.json +17 -1
@@ 1,6 1,6 @@
{
  "name": "wigly",
  "version": "0.4.0",
  "version": "0.4.1",
  "lockfileVersion": 1,
  "requires": true,
  "dependencies": {


@@ 739,6 739,16 @@
        "regexpu-core": "^4.1.3"
      }
    },
    "@babel/polyfill": {
      "version": "7.0.0",
      "resolved": "https://registry.npmjs.org/@babel/polyfill/-/polyfill-7.0.0.tgz",
      "integrity": "sha512-dnrMRkyyr74CRelJwvgnnSUDh2ge2NCTyHVwpOdvRMHtJUyxLtMAfhBN3s64pY41zdw0kgiLPh6S20eb1NcX6Q==",
      "dev": true,
      "requires": {
        "core-js": "^2.5.7",
        "regenerator-runtime": "^0.11.1"
      }
    },
    "@babel/preset-env": {
      "version": "7.1.6",
      "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.1.6.tgz",


@@ 6680,6 6690,12 @@
        "regenerate": "^1.4.0"
      }
    },
    "regenerator-runtime": {
      "version": "0.11.1",
      "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
      "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==",
      "dev": true
    },
    "regenerator-transform": {
      "version": "0.13.3",
      "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.13.3.tgz",

M package.json => package.json +2 -1
@@ 1,6 1,6 @@
{
  "name": "wigly",
  "version": "0.4.0",
  "version": "0.4.2",
  "main": "dist/wigly.es5.js",
  "module": "src/main.js",
  "scripts": {


@@ 13,6 13,7 @@
  },
  "devDependencies": {
    "@babel/plugin-transform-react-jsx": "^7.1.6",
    "@babel/polyfill": "^7.0.0",
    "@babel/preset-env": "^7.1.6",
    "ava": "^1.0.0-rc.1",
    "babel-loader": "^8.0.4",

M src/main.js => src/main.js +4 -4
@@ 25,7 25,7 @@ export let h = (f, props, ...children) => {
  return {
    ...createElement(f, props, ...children),
    args: { f: orig, props, children },
    internal: { effects: [], effectCount: 0, state: [], stateCount: 0, node: null }
    internal: { effects: [], effectCount: 0, state: [], stateCount: 0, node: null, active: false }
  };
};



@@ 66,8 66,6 @@ let transform = async (spec, cb) => {
      internal: {
        ...spec.internal,
        update: () => {
          spec.internal.stateCount = 0;
          spec.internal.effectCount = 0;
          transform(spec, next => {
            if (spec.internal.node.parentElement) {
              vdom = patch(vdom, next, spec.internal.node.parentElement);


@@ 81,6 79,7 @@ let transform = async (spec, cb) => {
  register();

  let runEffects = async () => {
    if (!spec.internal.active) return;
    for (let key in spec.internal.effects) {
      let { f, args, last, cleanup } = spec.internal.effects[key];
      if (typeof last === "undefined" || args.length === 0 || last.join() !== args.join()) {


@@ 103,7 102,6 @@ let transform = async (spec, cb) => {
  let promises = [];
  for (let key in vdom.children) {
    let child = vdom.children[key];

    promises.push(
      new Promise(resolve => {
        transform(child, childVDOM => {


@@ 118,6 116,7 @@ let transform = async (spec, cb) => {
    vdom.props = {
      ...vdom.props,
      oncreate: el => {
        spec.internal.active = true;
        spec.internal.node = el;
        runEffects();
      },


@@ 126,6 125,7 @@ let transform = async (spec, cb) => {
        runEffects();
      },
      ondestroy: () => {
        spec.internal.active = false;
        for (let key in spec.internal.effects) {
          let { cleanup } = spec.internal.effects[key];
          if (cleanup) cleanup();

M test/main.js => test/main.js +2 -1
@@ 1,7 1,8 @@
require("browser-env")();
require("@babel/polyfill");

let test = require("ava");
let { h, render, state, effect } = require("../dist/wigly.es6");
let { h, render, state, effect } = require("../dist/wigly.es5");

let sleep = (t = 1) => new Promise(r => setTimeout(r, t));