kress95/elm-html-convert/1.0.0

NOTE: the latest version is 1.0.2

Renamed to chrisfls/elm-html-convert. That is where the repository lives now. It has not been published as a package under the new name.

Versions published as kress95/elm-html-convert still install under that name. 3 versions of 3 come from the new location (see their notes).

Rerouted (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/chrisfls/elm-html-convert.

What we checked: The repo moved to github.com/chrisfls/elm-html-convert. Rebuilt with git archive from commit f241b9e12494 of https://github.com/chrisfls/elm-html-convert (zip prefix kress95-elm-html-convert-f241b9e/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 610447b59e9bd116515bd4be84e5352949e89ff8.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/kress95/elm-html-convert/zipball/1.0.0/

elm-html-convert

This is a hack ported from elm-test that allows converting Html msg to Value and String.

WARNING: I didn't test this package yet.

Post-processing

This library requires post-processing, expanded-elm can automize that for you.

where:

var $kress95$elm_html_convert$Html$Convert$toValue = function (_v0) {
	return $elm$json$Json$Encode$string('You thought it was a JSON value, but it was me, Dio!');
};

replace with:

/*

import Elm.Kernel.Json exposing (wrap)

*/

// NOTE: this is duplicating constants also defined in Test.Internal.KernelConstants
//       so if you make any changes here, be sure to synchronize them there!
var virtualDomKernelConstants = {
  nodeTypeTagger: 4,
  nodeTypeThunk: 5,
  kids: "e",
  refs: "l",
  thunk: "m",
  node: "k",
  value: "a",
};

function forceThunks(vNode) {
  if (typeof vNode !== "undefined" && vNode.$ === "#2") {
    // This is a tuple (the kids : List (String, Html) field of a Keyed node); recurse into the right side of the tuple
    vNode.b = forceThunks(vNode.b);
  }
  if (
    typeof vNode !== "undefined" &&
    vNode.$ === virtualDomKernelConstants.nodeTypeThunk &&
    !vNode[virtualDomKernelConstants.node]
  ) {
    // This is a lazy node; evaluate it
    var args = vNode[virtualDomKernelConstants.thunk];
    vNode[virtualDomKernelConstants.node] =
      vNode[virtualDomKernelConstants.thunk].apply(args);
    // And then recurse into the evaluated node
    vNode[virtualDomKernelConstants.node] = forceThunks(
      vNode[virtualDomKernelConstants.node],
    );
  }
  if (
    typeof vNode !== "undefined" &&
    vNode.$ === virtualDomKernelConstants.nodeTypeTagger
  ) {
    // This is an Html.map; recurse into the node it is wrapping
    vNode[virtualDomKernelConstants.node] = forceThunks(
      vNode[virtualDomKernelConstants.node],
    );
  }
  if (
    typeof vNode !== "undefined" &&
    typeof vNode[virtualDomKernelConstants.kids] !== "undefined"
  ) {
    // This is something with children (either a node with kids : List Html, or keyed with kids : List (String, Html));
    // recurse into the children
    vNode[virtualDomKernelConstants.kids] =
      vNode[virtualDomKernelConstants.kids].map(forceThunks);
  }
  return vNode;
}

function _HtmlAsJson_toJson(html) {
  return _Json_wrap(forceThunks(html));
}

function _HtmlAsJson_eventHandler(event) {
  return event[virtualDomKernelConstants.value];
}

function _HtmlAsJson_taggerFunction(tagger) {
  return tagger.a;
}

function _HtmlAsJson_attributeToJson(attribute) {
  return _Json_wrap(attribute);
}

var $kress95$elm_html_convert$Html$Convert$toValue = _HtmlAsJson_toJson;