marko 5.16.1 → 5.17.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. package/dist/runtime/RenderResult.js +13 -11
  2. package/dist/runtime/RenderResult.js.map +1 -1
  3. package/dist/runtime/components/Component.js +2 -2
  4. package/dist/runtime/components/Component.js.map +1 -1
  5. package/dist/runtime/components/ComponentsContext.js +2 -2
  6. package/dist/runtime/components/ComponentsContext.js.map +1 -1
  7. package/dist/runtime/components/event-delegation.js +8 -8
  8. package/dist/runtime/components/event-delegation.js.map +1 -1
  9. package/dist/runtime/components/init-components/index-browser.js +22 -24
  10. package/dist/runtime/components/init-components/index-browser.js.map +1 -1
  11. package/dist/runtime/components/registry/index-browser.js +2 -2
  12. package/dist/runtime/components/registry/index-browser.js.map +1 -1
  13. package/dist/runtime/components/util/index-browser.js +4 -3
  14. package/dist/runtime/components/util/index-browser.js.map +1 -1
  15. package/dist/runtime/html/AsyncStream.js +8 -10
  16. package/dist/runtime/html/AsyncStream.js.map +1 -1
  17. package/dist/runtime/vdom/AsyncVDOMBuilder.js +65 -70
  18. package/dist/runtime/vdom/AsyncVDOMBuilder.js.map +1 -1
  19. package/dist/runtime/vdom/VComponent.js +3 -3
  20. package/dist/runtime/vdom/VDocumentFragment.js +7 -7
  21. package/dist/runtime/vdom/VDocumentFragment.js.map +1 -1
  22. package/dist/runtime/vdom/VElement.js +42 -39
  23. package/dist/runtime/vdom/VElement.js.map +1 -1
  24. package/dist/runtime/vdom/VFragment.js +5 -5
  25. package/dist/runtime/vdom/VNode.js +31 -31
  26. package/dist/runtime/vdom/VText.js +8 -8
  27. package/dist/runtime/vdom/VText.js.map +1 -1
  28. package/dist/runtime/vdom/hot-reload.js +5 -5
  29. package/dist/runtime/vdom/hot-reload.js.map +1 -1
  30. package/dist/runtime/vdom/morphdom/fragment.js +3 -3
  31. package/dist/runtime/vdom/morphdom/helpers.js +1 -1
  32. package/dist/runtime/vdom/morphdom/index.js +30 -30
  33. package/dist/runtime/vdom/morphdom/index.js.map +1 -1
  34. package/dist/runtime/vdom/morphdom/specialElHandlers.js +6 -6
  35. package/dist/runtime/vdom/preserve-attrs.js +1 -1
  36. package/dist/runtime/vdom/vdom.js +10 -12
  37. package/dist/runtime/vdom/vdom.js.map +1 -1
  38. package/package.json +4 -4
  39. package/src/runtime/RenderResult.js +13 -11
  40. package/src/runtime/components/Component.js +5 -5
  41. package/src/runtime/components/ComponentsContext.js +2 -2
  42. package/src/runtime/components/event-delegation.js +6 -6
  43. package/src/runtime/components/init-components/index-browser.js +23 -25
  44. package/src/runtime/components/registry/index-browser.js +3 -3
  45. package/src/runtime/components/util/index-browser.js +8 -7
  46. package/src/runtime/html/AsyncStream.js +8 -10
  47. package/src/runtime/vdom/AsyncVDOMBuilder.js +9 -14
  48. package/src/runtime/vdom/VDocumentFragment.js +2 -2
  49. package/src/runtime/vdom/VElement.js +5 -2
  50. package/src/runtime/vdom/VText.js +2 -2
  51. package/src/runtime/vdom/hot-reload.js +1 -1
  52. package/src/runtime/vdom/morphdom/index.js +4 -4
  53. package/src/runtime/vdom/vdom.js +2 -4
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/runtime/components/init-components/index-browser.js"],"names":["warp10Finalize","require","eventDelegation","win","window","defaultDocument","document","createFragmentNode","componentsUtil","componentLookup","addComponentRootToKeyedElements","ComponentDef","registry","domData","keyedElementsByComponentId","componentsByDOMNode","serverComponentRootNodes","serverRenderedMeta","DEFAULT_RUNTIME_ID","FLAG_WILL_RERENDER_IN_BROWSER","deferredDefs","indexServerComponentBoundaries","node","runtimeId","stack","componentId","ownerId","ownerComponent","keyedElements","nextSibling","runtimeLength","length","firstChild","nodeType","commentValue","nodeValue","slice","firstChar","push","endNode","startNode","pop","rootNode","parentNode","substring","parts","split","key","removeChild","markoKey","getAttribute","markoProps","separatorIndex","indexOf","Object","keys","forEach","invokeComponentEventHandler","component","targetMethodName","args","method","Error","apply","addEventListenerHelper","el","eventType","isOnce","listener","eventListener","event","removeEventListener","addEventListener","remove","addDOMEventListeners","extraArgs","handles","removeListener","concat","initComponent","componentDef","doc","isExisting","domEvents","eventListenerHandles","domEventArgs","eventEl","initClientRendered","componentDefs","len","i","trackComponent","initServerRendered","renderedComponents","type","globalKey","fakeArray","r","renderedComponent","isFromSerializedGlobals","prefix","p","meta","isLast","l","g","t","w","map","typeName","tryHydrateComponent","reverse","tryInvoke","rawDef","mount","hydrateComponentAndGetMount","undefined","id","renderResult","set","afterInsert","fn","exports"],"mappings":"AAAA;;AAEA,IAAIA,cAAc,GAAGC,OAAO,CAAC,iBAAD,CAA5B;AACA,IAAIC,eAAe,GAAGD,OAAO,CAAC,qBAAD,CAA7B;AACA,IAAIE,GAAG,GAAGC,MAAV;AACA,IAAIC,eAAe,GAAGC,QAAtB;AACA,IAAIC,kBAAkB;AACpBN,OAAO,CAAC,8BAAD,CAAP,IADF;AAEA,IAAIO,cAAc,GAAGP,OAAO,CAAC,SAAD,CAA5B;AACA,IAAIQ,eAAe,GAAGD,cAAc,GAApC;AACA,IAAIE,+BAA+B;AACjCF,cAAc,IADhB;AAEA,IAAIG,YAAY,GAAGV,OAAO,CAAC,iBAAD,CAA1B;AACA,IAAIW,QAAQ,GAAGX,OAAO,CAAC,aAAD,CAAtB;AACA,IAAIY,OAAO,GAAGZ,OAAO,CAAC,aAAD,CAArB;AACA,IAAIa,0BAA0B,GAAGD,OAAO,GAAxC;AACA,IAAIE,mBAAmB,GAAGF,OAAO,GAAjC;AACA,IAAIG,wBAAwB,GAAG,EAA/B;AACA,IAAIC,kBAAkB,GAAG,EAAzB;;AAEA,IAAIC,kBAAkB,GAAG,GAAzB;AACA,IAAIC,6BAA6B,GAAG,CAApC;AACA;;AAEA,IAAIC,YAAJ;;AAEA,SAASC,8BAAT,CAAwCC,IAAxC,EAA8CC,SAA9C,EAAyDC,KAAzD,EAAgE;AAC9D,MAAIC,WAAJ;AACA,MAAIC,OAAJ;AACA,MAAIC,cAAJ;AACA,MAAIC,aAAJ;AACA,MAAIC,WAAJ;AACA,MAAI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gCnC,kBAAhC;AACAmC,OAAO,IAAP,GAAgC9B,kBAAhC;AACA8B,OAAO,IAAP,GAAiCZ,mBAAjC","sourcesContent":["\"use strict\";\nvar complain = \"MARKO_DEBUG\" && require(\"complain\");\nvar warp10Finalize = require(\"warp10/finalize\");\nvar eventDelegation = require(\"../event-delegation\");\nvar win = window;\nvar defaultDocument = document;\nvar createFragmentNode =\n require(\"../../vdom/morphdom/fragment\").___createFragmentNode;\nvar componentsUtil = require(\"../util\");\nvar componentLookup = componentsUtil.___componentLookup;\nvar addComponentRootToKeyedElements =\n componentsUtil.___addComponentRootToKeyedElements;\nvar ComponentDef = require(\"../ComponentDef\");\nvar registry = require(\"../registry\");\nvar domData = require(\"../dom-data\");\nvar keyedElementsByComponentId = domData.___ssrKeyedElementsByComponentId;\nvar componentsByDOMNode = domData.___componentByDOMNode;\nvar serverComponentRootNodes = {};\nvar serverRenderedMeta = {};\n\nvar DEFAULT_RUNTIME_ID = \"M\";\nvar FLAG_WILL_RERENDER_IN_BROWSER = 1;\n// var FLAG_HAS_RENDER_BODY = 2;\n\nvar deferredDefs;\n\nfunction indexServerComponentBoundaries(node, runtimeId, stack) {\n var componentId;\n var ownerId;\n var ownerComponent;\n var keyedElements;\n var nextSibling;\n var runtimeLength = runtimeId.length;\n stack = stack || [];\n\n node = node.firstChild;\n while (node) {\n nextSibling = node.nextSibling;\n if (node.nodeType === 8) {\n // Comment node\n var commentValue = node.nodeValue;\n if (commentValue.slice(0, runtimeLength) === runtimeId) {\n var firstChar = commentValue[runtimeLength];\n\n if (firstChar === \"^\" || firstChar === \"#\") {\n stack.push(node);\n } else if (firstChar === \"/\") {\n var endNode = node;\n var startNode = stack.pop();\n var rootNode;\n\n if (startNode.parentNode === endNode.parentNode) {\n rootNode = createFragmentNode(startNode.nextSibling, endNode);\n } else {\n rootNode = createFragmentNode(\n endNode.parentNode.firstChild,\n endNode\n );\n }\n\n componentId = startNode.nodeValue.substring(runtimeLength + 1);\n firstChar = startNode.nodeValue[runtimeLength];\n\n if (firstChar === \"^\") {\n var parts = componentId.split(/ /g);\n var key = parts[2];\n ownerId = parts[1];\n componentId = parts[0];\n if ((ownerComponent = componentLookup[ownerId])) {\n keyedElements = ownerComponent.___keyedElements;\n } else {\n keyedElements =\n keyedElementsByComponentId[ownerId] ||\n (keyedElementsByComponentId[ownerId] = {});\n }\n addComponentRootToKeyedElements(\n keyedElements,\n key,\n rootNode,\n componentId\n );\n }\n\n serverComponentRootNodes[componentId] = rootNode;\n\n startNode.parentNode.removeChild(startNode);\n endNode.parentNode.removeChild(endNode);\n }\n }\n } else if (node.nodeType === 1) {\n // HTML element node\n var markoKey = node.getAttribute(\"data-marko-key\");\n var markoProps = componentsUtil.___getMarkoPropsFromEl(node);\n if (markoKey) {\n var separatorIndex = markoKey.indexOf(\" \");\n ownerId = markoKey.substring(separatorIndex + 1);\n markoKey = markoKey.substring(0, separatorIndex);\n if ((ownerComponent = componentLookup[ownerId])) {\n keyedElements = ownerComponent.___keyedElements;\n } else {\n keyedElements =\n keyedElementsByComponentId[ownerId] ||\n (keyedElementsByComponentId[ownerId] = {});\n }\n keyedElements[markoKey] = node;\n }\n if (markoProps) {\n Object.keys(markoProps).forEach(function (key) {\n if (key.slice(0, 2) === \"on\") {\n eventDelegation.___addDelegatedEventHandler(key.slice(2));\n }\n });\n }\n indexServerComponentBoundaries(node, runtimeId, stack);\n }\n\n node = nextSibling;\n }\n}\n\nfunction invokeComponentEventHandler(component, targetMethodName, args) {\n var method = component[targetMethodName];\n if (!method) {\n throw Error(\"Method not found: \" + targetMethodName);\n }\n\n method.apply(component, args);\n}\n\nfunction addEventListenerHelper(el, eventType, isOnce, listener) {\n var eventListener = listener;\n if (isOnce) {\n eventListener = function (event) {\n listener(event);\n el.removeEventListener(eventType, eventListener);\n };\n }\n\n el.addEventListener(eventType, eventListener, false);\n\n return function remove() {\n el.removeEventListener(eventType, eventListener);\n };\n}\n\nfunction addDOMEventListeners(\n component,\n el,\n eventType,\n targetMethodName,\n isOnce,\n extraArgs,\n handles\n) {\n var removeListener = addEventListenerHelper(\n el,\n eventType,\n isOnce,\n function (event) {\n var args = [event, el];\n if (extraArgs) {\n args = extraArgs.concat(args);\n }\n\n invokeComponentEventHandler(component, targetMethodName, args);\n }\n );\n handles.push(removeListener);\n}\n\nfunction initComponent(componentDef, doc) {\n var component = componentDef.___component;\n\n component.___reset();\n component.___document = doc;\n\n var isExisting = componentDef.___isExisting;\n\n if (isExisting) {\n component.___removeDOMEventListeners();\n }\n\n var domEvents = componentDef.___domEvents;\n if (domEvents) {\n var eventListenerHandles = [];\n\n domEvents.forEach(function (domEventArgs) {\n // The event mapping is for a direct DOM event (not a custom event and not for bubblign dom events)\n\n var eventType = domEventArgs[0];\n var targetMethodName = domEventArgs[1];\n var eventEl = component.___keyedElements[domEventArgs[2]];\n var isOnce = domEventArgs[3];\n var extraArgs = domEventArgs[4];\n\n addDOMEventListeners(\n component,\n eventEl,\n eventType,\n targetMethodName,\n isOnce,\n extraArgs,\n eventListenerHandles\n );\n });\n\n if (eventListenerHandles.length) {\n component.___domEventListenerHandles = eventListenerHandles;\n }\n }\n\n if (component.___mounted) {\n component.___emitUpdate();\n } else {\n component.___mounted = true;\n component.___emitMount();\n }\n}\n\n/**\n * This method is used to initialized components associated with UI components\n * rendered in the browser. While rendering UI components a \"components context\"\n * is added to the rendering context to keep up with which components are rendered.\n * When ready, the components can then be initialized by walking the component tree\n * in the components context (nested components are initialized before ancestor components).\n * @param {Array<marko-components/lib/ComponentDef>} componentDefs An array of ComponentDef instances\n */\nfunction initClientRendered(componentDefs, doc) {\n // Ensure that event handlers to handle delegating events are\n // always attached before initializing any components\n eventDelegation.___init(doc);\n\n doc = doc || defaultDocument;\n var len = componentDefs.length;\n var componentDef;\n var i;\n\n for (i = len; i--; ) {\n componentDef = componentDefs[i];\n trackComponent(componentDef);\n }\n\n for (i = len; i--; ) {\n componentDef = componentDefs[i];\n initComponent(componentDef, doc);\n }\n}\n\n/**\n * This method initializes all components that were rendered on the server by iterating over all\n * of the component IDs.\n */\nfunction initServerRendered(renderedComponents, doc) {\n var type = typeof renderedComponents;\n var globalKey = \"$\";\n var runtimeId;\n\n if (type !== \"object\") {\n if (type === \"string\") {\n runtimeId = renderedComponents;\n globalKey += runtimeId + \"_C\";\n } else {\n globalKey += (runtimeId = DEFAULT_RUNTIME_ID) + \"C\";\n }\n\n renderedComponents = win[globalKey];\n\n // eslint-disable-next-line no-constant-condition\n if (\"MARKO_DEBUG\") {\n if (\n renderedComponents &&\n renderedComponents.i !== undefined &&\n renderedComponents.i !== componentsUtil.___runtimeId\n ) {\n console.warn(\n \"Multiple instances of Marko have attached to the same runtime id. This could mean that more than one copy of Marko is loaded on the page, or that the script containing Marko has executed more than once.\"\n );\n }\n }\n\n var fakeArray = (win[globalKey] = {\n r: runtimeId,\n concat: initServerRendered\n });\n\n // eslint-disable-next-line no-constant-condition\n if (\"MARKO_DEBUG\") {\n fakeArray.i = componentsUtil.___runtimeId;\n }\n\n if (renderedComponents && renderedComponents.forEach) {\n renderedComponents.forEach(function (renderedComponent) {\n fakeArray.concat(renderedComponent);\n });\n }\n\n return fakeArray;\n }\n\n var isFromSerializedGlobals = this.concat === initServerRendered;\n renderedComponents = warp10Finalize(renderedComponents);\n\n if (isFromSerializedGlobals) {\n runtimeId = this.r;\n doc = defaultDocument;\n } else {\n runtimeId = renderedComponents.r || DEFAULT_RUNTIME_ID;\n doc = doc || defaultDocument;\n\n // eslint-disable-next-line no-constant-condition\n if (\"MARKO_DEBUG\") {\n complain(\n \"Passing serialized data to `require('marko/components).init` is deprecated. Instead set '$global.runtimeId' and provide the 'runtimeId' option to your Marko bundler plugin.\"\n );\n }\n }\n\n // eslint-disable-next-line no-constant-condition\n if (\"MARKO_DEBUG\") {\n if (doc !== defaultDocument) {\n complain(\n \"Passing a document other than the current document to `require('marko/components).init` is deprecated.\"\n );\n }\n }\n\n var prefix = renderedComponents.p || \"\";\n var meta = serverRenderedMeta[prefix];\n var isLast = renderedComponents.l;\n\n if (meta) {\n if (isLast) {\n delete serverRenderedMeta[prefix];\n }\n } else {\n meta = {};\n\n if (!isLast) {\n serverRenderedMeta[prefix] = meta;\n }\n }\n\n // Ensure that event handlers to handle delegating events are\n // always attached before initializing any components\n indexServerComponentBoundaries(doc, runtimeId);\n eventDelegation.___init(doc);\n\n if (renderedComponents.g) {\n meta.___globals = renderedComponents.g;\n }\n\n if (renderedComponents.t) {\n meta.___types = meta.___types\n ? meta.___types.concat(renderedComponents.t)\n : renderedComponents.t;\n }\n\n // hydrate components top down (leaf nodes last)\n // and return an array of functions to mount these components\n (renderedComponents.w || [])\n .map(function (componentDef) {\n var typeName = meta.___types[componentDef[1]];\n\n return registry.___isRegistered(typeName)\n ? tryHydrateComponent(componentDef, meta, doc, runtimeId)\n : registry.___addPendingDef(\n componentDef,\n typeName,\n meta,\n doc,\n runtimeId\n );\n })\n .reverse()\n .forEach(tryInvoke);\n\n return this;\n}\n\nfunction tryHydrateComponent(rawDef, meta, doc, runtimeId) {\n var componentDef = ComponentDef.___deserialize(\n rawDef,\n meta.___types,\n meta.___globals,\n registry\n );\n var mount = hydrateComponentAndGetMount(componentDef, doc);\n\n if (!mount) {\n // hydrateComponentAndGetMount will return false if there is not rootNode\n // for the component. If this is the case, we'll wait until the\n // DOM has fully loaded to attempt to init the component again.\n if (deferredDefs) {\n deferredDefs.push(componentDef);\n } else {\n deferredDefs = [componentDef];\n doc.addEventListener(\"DOMContentLoaded\", function () {\n indexServerComponentBoundaries(doc, runtimeId);\n deferredDefs\n .map(function (componentDef) {\n return hydrateComponentAndGetMount(componentDef, doc);\n })\n .reverse()\n .forEach(tryInvoke);\n deferredDefs = undefined;\n });\n }\n }\n\n return mount;\n}\n\nfunction hydrateComponentAndGetMount(componentDef, doc) {\n var componentId = componentDef.id;\n var component = componentDef.___component;\n var rootNode = serverComponentRootNodes[componentId];\n var renderResult;\n\n if (rootNode) {\n delete serverComponentRootNodes[componentId];\n\n component.___rootNode = rootNode;\n componentsByDOMNode.set(rootNode, component);\n\n if (componentDef.___flags & FLAG_WILL_RERENDER_IN_BROWSER) {\n component.___document = doc;\n renderResult = component.___rerender(component.___input, true);\n trackComponent(componentDef);\n return function mount() {\n renderResult.afterInsert(doc);\n };\n } else {\n trackComponent(componentDef);\n }\n\n return function mount() {\n initComponent(componentDef, doc);\n };\n }\n}\n\nfunction trackComponent(componentDef) {\n var component = componentDef.___component;\n if (component) {\n componentLookup[component.id] = component;\n }\n}\n\nfunction tryInvoke(fn) {\n if (fn) fn();\n}\n\nexports.___initClientRendered = initClientRendered;\nexports.___initServerRendered = initServerRendered;\nexports.___tryHydrateComponent = tryHydrateComponent;\n"],"file":"index-browser.js"}
1
+ {"version":3,"sources":["../../../../src/runtime/components/init-components/index-browser.js"],"names":["warp10Finalize","require","eventDelegation","win","window","createFragmentNode","componentsUtil","componentLookup","addComponentRootToKeyedElements","ComponentDef","registry","domData","keyedElementsByComponentId","componentsByDOMNode","serverComponentRootNodes","serverRenderedMeta","DEFAULT_RUNTIME_ID","FLAG_WILL_RERENDER_IN_BROWSER","deferredDefs","indexServerComponentBoundaries","node","runtimeId","stack","componentId","ownerId","ownerComponent","keyedElements","nextSibling","runtimeLength","length","firstChild","nodeType","commentValue","nodeValue","slice","firstChar","push","endNode","startNode","pop","rootNode","parentNode","substring","parts","split","key","removeChild","markoKey","getAttribute","markoProps","separatorIndex","indexOf","Object","keys","forEach","invokeComponentEventHandler","component","targetMethodName","args","method","Error","apply","addEventListenerHelper","el","eventType","isOnce","listener","eventListener","event","removeEventListener","addEventListener","remove","addDOMEventListeners","extraArgs","handles","removeListener","concat","initComponent","componentDef","host","isExisting","domEvents","eventListenerHandles","domEventArgs","eventEl","initClientRendered","componentDefs","document","len","i","trackComponent","initServerRendered","renderedComponents","type","globalKey","fakeArray","r","renderedComponent","isFromSerializedGlobals","prefix","p","meta","isLast","l","g","t","w","map","typeName","tryHydrateComponent","reverse","tryInvoke","rawDef","mount","hydrateComponentAndGetMount","undefined","id","ren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EA,MAAI7E,QAAJ,EAAc;AACZ,WAAO1B,wBAAwB,CAACS,WAAD,CAA/B;;AAEAiC,IAAAA,SAAS,GAAT,GAAwBhB,QAAxB;AACA3B,IAAAA,mBAAmB,CAACyG,GAApB,CAAwB9E,QAAxB,EAAkCgB,SAAlC;;AAEA,QAAIsB,YAAY,IAAZ,GAAwB7D,6BAA5B,EAA2D;AACzDuC,MAAAA,SAAS,GAAT,GAAoBuB,IAApB;AACAsC,MAAAA,YAAY,GAAG7D,SAAS,IAAT,CAAsBA,SAAS,GAA/B,EAA0C,IAA1C,CAAf;AACAkC,MAAAA,cAAc,CAACZ,YAAD,CAAd;AACA,aAAO,SAASmC,KAAT,GAAiB;AACtBI,QAAAA,YAAY,CAACE,WAAb,CAAyBxC,IAAzB;AACD,OAFD;AAGD,KAPD,MAOO;AACLW,MAAAA,cAAc,CAACZ,YAAD,CAAd;AACD;;AAED,WAAO,SAASmC,KAAT,GAAiB;AACtBpC,MAAAA,aAAa,CAACC,YAAD,EAAeC,IAAf,CAAb;AACD,KAFD;AAGD;AACF;;AAED,SAASW,cAAT,CAAwBZ,YAAxB,EAAsC;AACpC,MAAItB,SAAS,GAAGsB,YAAY,GAA5B;AACA,MAAItB,SAAJ,EAAe;AACbjD,IAAAA,eAAe,CAACiD,SAAS,CAAC4D,EAAX,CAAf,GAAgC5D,SAAhC;AACD;AACF;;AAED,SAASuD,SAAT,CAAmBS,EAAnB,EAAuB;AACrB,MAAIA,EAAJ,EAAQA,EAAE;AACX;;AAEDC,OAAO,IAAP,GAAgCpC,kBAAhC;AACAoC,OAAO,IAAP,GAAgC9B,kBAAhC;AACA8B,OAAO,IAAP,GAAiCZ,mBAAjC","sourcesContent":["\"use strict\";\nvar complain = \"MARKO_DEBUG\" && require(\"complain\");\nvar warp10Finalize = require(\"warp10/finalize\");\nvar eventDelegation = require(\"../event-delegation\");\nvar win = window;\nvar createFragmentNode =\n require(\"../../vdom/morphdom/fragment\").___createFragmentNode;\nvar componentsUtil = require(\"../util\");\nvar componentLookup = componentsUtil.___componentLookup;\nvar addComponentRootToKeyedElements =\n componentsUtil.___addComponentRootToKeyedElements;\nvar ComponentDef = require(\"../ComponentDef\");\nvar registry = require(\"../registry\");\nvar domData = require(\"../dom-data\");\nvar keyedElementsByComponentId = domData.___ssrKeyedElementsByComponentId;\nvar componentsByDOMNode = domData.___componentByDOMNode;\nvar serverComponentRootNodes = {};\nvar serverRenderedMeta = {};\n\nvar DEFAULT_RUNTIME_ID = \"M\";\nvar FLAG_WILL_RERENDER_IN_BROWSER = 1;\n// var FLAG_HAS_RENDER_BODY = 2;\n\nvar deferredDefs;\n\nfunction indexServerComponentBoundaries(node, runtimeId, stack) {\n var componentId;\n var ownerId;\n var ownerComponent;\n var keyedElements;\n var nextSibling;\n var runtimeLength = runtimeId.length;\n stack = stack || [];\n\n node = node.firstChild;\n while (node) {\n nextSibling = node.nextSibling;\n if (node.nodeType === 8) {\n // Comment node\n var commentValue = node.nodeValue;\n if (commentValue.slice(0, runtimeLength) === runtimeId) {\n var firstChar = commentValue[runtimeLength];\n\n if (firstChar === \"^\" || firstChar === \"#\") {\n stack.push(node);\n } else if (firstChar === \"/\") {\n var endNode = node;\n var startNode = stack.pop();\n var rootNode;\n\n if (startNode.parentNode === endNode.parentNode) {\n rootNode = createFragmentNode(startNode.nextSibling, endNode);\n } else {\n rootNode = createFragmentNode(\n endNode.parentNode.firstChild,\n endNode\n );\n }\n\n componentId = startNode.nodeValue.substring(runtimeLength + 1);\n firstChar = startNode.nodeValue[runtimeLength];\n\n if (firstChar === \"^\") {\n var parts = componentId.split(/ /g);\n var key = parts[2];\n ownerId = parts[1];\n componentId = parts[0];\n if ((ownerComponent = componentLookup[ownerId])) {\n keyedElements = ownerComponent.___keyedElements;\n } else {\n keyedElements =\n keyedElementsByComponentId[ownerId] ||\n (keyedElementsByComponentId[ownerId] = {});\n }\n addComponentRootToKeyedElements(\n keyedElements,\n key,\n rootNode,\n componentId\n );\n }\n\n serverComponentRootNodes[componentId] = rootNode;\n\n startNode.parentNode.removeChild(startNode);\n endNode.parentNode.removeChild(endNode);\n }\n }\n } else if (node.nodeType === 1) {\n // HTML element node\n var markoKey = node.getAttribute(\"data-marko-key\");\n var markoProps = componentsUtil.___getMarkoPropsFromEl(node);\n if (markoKey) {\n var separatorIndex = markoKey.indexOf(\" \");\n ownerId = markoKey.substring(separatorIndex + 1);\n markoKey = markoKey.substring(0, separatorIndex);\n if ((ownerComponent = componentLookup[ownerId])) {\n keyedElements = ownerComponent.___keyedElements;\n } else {\n keyedElements =\n keyedElementsByComponentId[ownerId] ||\n (keyedElementsByComponentId[ownerId] = {});\n }\n keyedElements[markoKey] = node;\n }\n if (markoProps) {\n Object.keys(markoProps).forEach(function (key) {\n if (key.slice(0, 2) === \"on\") {\n eventDelegation.___addDelegatedEventHandler(key.slice(2));\n }\n });\n }\n indexServerComponentBoundaries(node, runtimeId, stack);\n }\n\n node = nextSibling;\n }\n}\n\nfunction invokeComponentEventHandler(component, targetMethodName, args) {\n var method = component[targetMethodName];\n if (!method) {\n throw Error(\"Method not found: \" + targetMethodName);\n }\n\n method.apply(component, args);\n}\n\nfunction addEventListenerHelper(el, eventType, isOnce, listener) {\n var eventListener = listener;\n if (isOnce) {\n eventListener = function (event) {\n listener(event);\n el.removeEventListener(eventType, eventListener);\n };\n }\n\n el.addEventListener(eventType, eventListener, false);\n\n return function remove() {\n el.removeEventListener(eventType, eventListener);\n };\n}\n\nfunction addDOMEventListeners(\n component,\n el,\n eventType,\n targetMethodName,\n isOnce,\n extraArgs,\n handles\n) {\n var removeListener = addEventListenerHelper(\n el,\n eventType,\n isOnce,\n function (event) {\n var args = [event, el];\n if (extraArgs) {\n args = extraArgs.concat(args);\n }\n\n invokeComponentEventHandler(component, targetMethodName, args);\n }\n );\n handles.push(removeListener);\n}\n\nfunction initComponent(componentDef, host) {\n var component = componentDef.___component;\n\n component.___reset();\n component.___host = host;\n\n var isExisting = componentDef.___isExisting;\n\n if (isExisting) {\n component.___removeDOMEventListeners();\n }\n\n var domEvents = componentDef.___domEvents;\n if (domEvents) {\n var eventListenerHandles = [];\n\n domEvents.forEach(function (domEventArgs) {\n // The event mapping is for a direct DOM event (not a custom event and not for bubblign dom events)\n\n var eventType = domEventArgs[0];\n var targetMethodName = domEventArgs[1];\n var eventEl = component.___keyedElements[domEventArgs[2]];\n var isOnce = domEventArgs[3];\n var extraArgs = domEventArgs[4];\n\n addDOMEventListeners(\n component,\n eventEl,\n eventType,\n targetMethodName,\n isOnce,\n extraArgs,\n eventListenerHandles\n );\n });\n\n if (eventListenerHandles.length) {\n component.___domEventListenerHandles = eventListenerHandles;\n }\n }\n\n if (component.___mounted) {\n component.___emitUpdate();\n } else {\n component.___mounted = true;\n component.___emitMount();\n }\n}\n\n/**\n * This method is used to initialized components associated with UI components\n * rendered in the browser. While rendering UI components a \"components context\"\n * is added to the rendering context to keep up with which components are rendered.\n * When ready, the components can then be initialized by walking the component tree\n * in the components context (nested components are initialized before ancestor components).\n * @param {Array<marko-components/lib/ComponentDef>} componentDefs An array of ComponentDef instances\n */\nfunction initClientRendered(componentDefs, host) {\n if (!host) host = document;\n // Ensure that event handlers to handle delegating events are\n // always attached before initializing any components\n eventDelegation.___init(host);\n var len = componentDefs.length;\n var componentDef;\n var i;\n\n for (i = len; i--; ) {\n componentDef = componentDefs[i];\n trackComponent(componentDef);\n }\n\n for (i = len; i--; ) {\n componentDef = componentDefs[i];\n initComponent(componentDef, host);\n }\n}\n\n/**\n * This method initializes all components that were rendered on the server by iterating over all\n * of the component IDs.\n */\nfunction initServerRendered(renderedComponents, host) {\n var type = typeof renderedComponents;\n var globalKey = \"$\";\n var runtimeId;\n\n if (type !== \"object\") {\n if (type === \"string\") {\n runtimeId = renderedComponents;\n globalKey += runtimeId + \"_C\";\n } else {\n globalKey += (runtimeId = DEFAULT_RUNTIME_ID) + \"C\";\n }\n\n renderedComponents = win[globalKey];\n\n // eslint-disable-next-line no-constant-condition\n if (\"MARKO_DEBUG\") {\n if (\n renderedComponents &&\n renderedComponents.i !== undefined &&\n renderedComponents.i !== componentsUtil.___runtimeId\n ) {\n console.warn(\n \"Multiple instances of Marko have attached to the same runtime id. This could mean that more than one copy of Marko is loaded on the page, or that the script containing Marko has executed more than once.\"\n );\n }\n }\n\n var fakeArray = (win[globalKey] = {\n r: runtimeId,\n concat: initServerRendered\n });\n\n // eslint-disable-next-line no-constant-condition\n if (\"MARKO_DEBUG\") {\n fakeArray.i = componentsUtil.___runtimeId;\n }\n\n if (renderedComponents && renderedComponents.forEach) {\n renderedComponents.forEach(function (renderedComponent) {\n fakeArray.concat(renderedComponent);\n });\n }\n\n return fakeArray;\n }\n\n var isFromSerializedGlobals = this.concat === initServerRendered;\n renderedComponents = warp10Finalize(renderedComponents);\n\n if (isFromSerializedGlobals) {\n runtimeId = this.r;\n host = document;\n } else {\n runtimeId = renderedComponents.r || DEFAULT_RUNTIME_ID;\n if (!host) host = document;\n\n // eslint-disable-next-line no-constant-condition\n if (\"MARKO_DEBUG\") {\n complain(\n \"Passing serialized data to `require('marko/components).init` is deprecated. Instead set '$global.runtimeId' and provide the 'runtimeId' option to your Marko bundler plugin.\"\n );\n }\n }\n\n // eslint-disable-next-line no-constant-condition\n if (\"MARKO_DEBUG\") {\n if (host !== document) {\n complain(\n \"Passing a document other than the current document to `require('marko/components).init` is deprecated.\"\n );\n }\n }\n\n var prefix = renderedComponents.p || \"\";\n var meta = serverRenderedMeta[prefix];\n var isLast = renderedComponents.l;\n\n if (meta) {\n if (isLast) {\n delete serverRenderedMeta[prefix];\n }\n } else {\n meta = {};\n\n if (!isLast) {\n serverRenderedMeta[prefix] = meta;\n }\n }\n\n // Ensure that event handlers to handle delegating events are\n // always attached before initializing any components\n indexServerComponentBoundaries(host, runtimeId);\n eventDelegation.___init(host);\n\n if (renderedComponents.g) {\n meta.___globals = renderedComponents.g;\n }\n\n if (renderedComponents.t) {\n meta.___types = meta.___types\n ? meta.___types.concat(renderedComponents.t)\n : renderedComponents.t;\n }\n\n // hydrate components top down (leaf nodes last)\n // and return an array of functions to mount these components\n (renderedComponents.w || [])\n .map(function (componentDef) {\n var typeName = meta.___types[componentDef[1]];\n\n return registry.___isRegistered(typeName)\n ? tryHydrateComponent(componentDef, meta, host, runtimeId)\n : registry.___addPendingDef(\n componentDef,\n typeName,\n meta,\n host,\n runtimeId\n );\n })\n .reverse()\n .forEach(tryInvoke);\n\n return this;\n}\n\nfunction tryHydrateComponent(rawDef, meta, host, runtimeId) {\n var componentDef = ComponentDef.___deserialize(\n rawDef,\n meta.___types,\n meta.___globals,\n registry\n );\n var mount = hydrateComponentAndGetMount(componentDef, host);\n\n if (!mount) {\n // hydrateComponentAndGetMount will return false if there is not rootNode\n // for the component. If this is the case, we'll wait until the\n // DOM has fully loaded to attempt to init the component again.\n if (deferredDefs) {\n deferredDefs.push(componentDef);\n } else {\n deferredDefs = [componentDef];\n document.addEventListener(\"DOMContentLoaded\", function () {\n indexServerComponentBoundaries(host, runtimeId);\n deferredDefs\n .map(function (componentDef) {\n return hydrateComponentAndGetMount(componentDef, host);\n })\n .reverse()\n .forEach(tryInvoke);\n deferredDefs = undefined;\n });\n }\n }\n\n return mount;\n}\n\nfunction hydrateComponentAndGetMount(componentDef, host) {\n var componentId = componentDef.id;\n var component = componentDef.___component;\n var rootNode = serverComponentRootNodes[componentId];\n var renderResult;\n\n if (rootNode) {\n delete serverComponentRootNodes[componentId];\n\n component.___rootNode = rootNode;\n componentsByDOMNode.set(rootNode, component);\n\n if (componentDef.___flags & FLAG_WILL_RERENDER_IN_BROWSER) {\n component.___host = host;\n renderResult = component.___rerender(component.___input, true);\n trackComponent(componentDef);\n return function mount() {\n renderResult.afterInsert(host);\n };\n } else {\n trackComponent(componentDef);\n }\n\n return function mount() {\n initComponent(componentDef, host);\n };\n }\n}\n\nfunction trackComponent(componentDef) {\n var component = componentDef.___component;\n if (component) {\n componentLookup[component.id] = component;\n }\n}\n\nfunction tryInvoke(fn) {\n if (fn) fn();\n}\n\nexports.___initClientRendered = initClientRendered;\nexports.___initServerRendered = initServerRendered;\nexports.___tryHydrateComponent = tryHydrateComponent;\n"],"file":"index-browser.js"}
@@ -35,7 +35,7 @@ function register(type, def) {
35
35
  return type;
36
36
  }
37
37
 
38
- function addPendingDef(def, type, meta, doc, runtimeId) {
38
+ function addPendingDef(def, type, meta, host, runtimeId) {
39
39
  if (!pendingDefs) {
40
40
  pendingDefs = {};
41
41
 
@@ -54,7 +54,7 @@ function addPendingDef(def, type, meta, doc, runtimeId) {
54
54
  (pendingDefs[type] = pendingDefs[type] || []).push([
55
55
  def,
56
56
  meta,
57
- doc,
57
+ host,
58
58
  runtimeId]);
59
59
 
60
60
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/runtime/components/registry/index-browser.js"],"names":["queueMicrotask","require","defineComponent","initComponents","registered","loaded","componentTypes","pendingDefs","register","type","def","pendingForType","forEach","args","addPendingDef","meta","doc","runtimeId","push","isRegistered","Boolean","load","typeName","target","Error","getComponentClass","ComponentClass","Component","renderer","prototype","createComponent","id","exports","r"],"mappings":";AACA,IAAIA,cAAc,GAAGC,OAAO,CAAC,sBAAD,CAA5B;AACA,IAAIC,eAAe,GAAGD,OAAO,CAAC,oBAAD,CAA7B;AACA,IAAIE,cAAc,GAAGF,OAAO,CAAC,oBAAD,CAA5B;AACAA,OAAO,CAAC,UAAD,CAAP;;AAEA,IAAIG,UAAU,GAAG,EAAjB;AACA,IAAIC,MAAM,GAAG,EAAb;AACA,IAAIC,cAAc,GAAG,EAArB;AACA,IAAIC,WAAJ;;AAEA,SAASC,QAAT,CAAkBC,IAAlB,EAAwBC,GAAxB,EAA6B;AAC3B,MAAIC,cAAJ;AACA,MAAIJ,WAAJ,EAAiB;AACfI,IAAAA,cAAc,GAAGJ,WAAW,CAACE,IAAD,CAA5B;AACD;AACDL,EAAAA,UAAU,CAACK,IAAD,CAAV,GAAmBC,GAAnB;AACA,SAAOL,MAAM,CAACI,IAAD,CAAb;AACA,SAAOH,cAAc,CAACG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3B,CAAX;AACD;;AAEDjB,IAAAA,MAAM,CAACiB,QAAD,CAAN,GAAmBC,MAAnB;AACD;;AAED,SAAOA,MAAP;AACD;;AAED,SAASE,iBAAT,CAA2BH,QAA3B,EAAqC;AACnC,MAAII,cAAc,GAAGpB,cAAc,CAACgB,QAAD,CAAnC;;AAEA,MAAII,cAAJ,EAAoB;AAClB,WAAOA,cAAP;AACD;;AAEDA,EAAAA,cAAc,GAAGL,IAAI,CAACC,QAAD,CAArB;;AAEAI,EAAAA,cAAc,GAAGA,cAAc,CAACC,SAAf,IAA4BD,cAA7C;;AAEA,MAAI,CAACA,cAAc,GAAnB,EAAoC;AAClCA,IAAAA,cAAc,GAAGxB,eAAe,CAACwB,cAAD,EAAiBA,cAAc,CAACE,QAAhC,CAAhC;AACD;;AAED;AACAF,EAAAA,cAAc,CAACG,SAAf,OAAmCP,QAAnC;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BAhB,EAAAA,cAAc,CAACgB,QAAD,CAAd,GAA2BI,cAA3B;;AAEA,SAAOA,cAAP;AACD;;AAED,SAASI,eAAT,CAAyBR,QAAzB,EAAmCS,EAAnC,EAAuC;AACrC,MAAIL,cAAc,GAAGD,iBAAiB,CAACH,QAAD,CAAtC;AACA,SAAO,IAAII,cAAJ,CAAmBK,EAAnB,CAAP;AACD;;AAEDC,OAAO,CAACC,CAAR,GAAYzB,QAAZ;AACAwB,OAAO,IAAP,GAA+BP,iBAA/B;AACAO,OAAO,IAAP,GAA6BF,eAA7B;AACAE,OAAO,IAAP,GAA0Bb,YAA1B;AACAa,OAAO,IAAP,GAA2BlB,aAA3B","sourcesContent":["var complain = \"MARKO_DEBUG\" && require(\"complain\");\nvar queueMicrotask = require(\"../../queueMicrotask\");\nvar defineComponent = require(\"../defineComponent\");\nvar initComponents = require(\"../init-components\");\nrequire(\"../entry\");\n\nvar registered = {};\nvar loaded = {};\nvar componentTypes = {};\nvar pendingDefs;\n\nfunction register(type, def) {\n var pendingForType;\n if (pendingDefs) {\n pendingForType = pendingDefs[type];\n }\n registered[type] = def;\n delete loaded[type];\n delete componentTypes[type];\n\n if (pendingForType) {\n delete pendingDefs[type];\n queueMicrotask(function () {\n pendingForType.forEach(function (args) {\n initComponents.___tryHydrateComponent(\n args[0],\n args[1],\n args[2],\n args[3]\n )();\n });\n });\n }\n\n return type;\n}\n\nfunction addPendingDef(def, type, meta, doc, runtimeId) {\n if (!pendingDefs) {\n pendingDefs = {};\n\n // eslint-disable-next-line no-constant-condition\n if (\"MARKO_DEBUG\") {\n doc.addEventListener(\"load\", function () {\n var pendingComponentIds = Object.keys(pendingDefs);\n if (pendingComponentIds.length) {\n complain(\n \"Marko templates were never loaded for: \" + pendingComponentIds\n );\n }\n });\n }\n }\n (pendingDefs[type] = pendingDefs[type] || []).push([\n def,\n meta,\n doc,\n runtimeId\n ]);\n}\n\nfunction isRegistered(type) {\n return Boolean(registered[type]);\n}\n\nfunction load(typeName) {\n var target = loaded[typeName];\n if (!target) {\n target = registered[typeName];\n\n if (target) {\n target = target();\n }\n\n if (!target) {\n throw Error(\"Component not found: \" + typeName);\n }\n\n loaded[typeName] = target;\n }\n\n return target;\n}\n\nfunction getComponentClass(typeName) {\n var ComponentClass = componentTypes[typeName];\n\n if (ComponentClass) {\n return ComponentClass;\n }\n\n ComponentClass = load(typeName);\n\n ComponentClass = ComponentClass.Component || ComponentClass;\n\n if (!ComponentClass.___isComponent) {\n ComponentClass = defineComponent(ComponentClass, ComponentClass.renderer);\n }\n\n // Make the component \"type\" accessible on each component instance\n ComponentClass.prototype.___type = typeName;\n\n // eslint-disable-next-line no-constant-condition\n if (\"MARKO_DEBUG\") {\n var classNameMatch =\n /\\/([^/]+?)(?:\\/index|\\/template|)(?:\\.marko|\\.component(?:-browser)?|)$/.exec(\n typeName\n );\n var className = classNameMatch ? classNameMatch[1] : \"AnonymousComponent\";\n className = className.replace(/-(.)/g, function (g) {\n return g[1].toUpperCase();\n });\n className = className\n .replace(/\\$\\d+\\.\\d+\\.\\d+$/, \"\")\n .replace(/^[^a-z$_]/i, \"_$&\")\n .replace(/[^0-9a-z$_]+/gi, \"_\");\n className = className[0].toUpperCase() + className.slice(1);\n // eslint-disable-next-line no-unused-vars\n try {\n var OldComponentClass = ComponentClass;\n eval(\n \"ComponentClass = function \" +\n className +\n \"(id, doc) { OldComponentClass.call(this, id, doc); }\"\n );\n ComponentClass.prototype = OldComponentClass.prototype;\n } catch (e) {\n /** ignore error */\n }\n }\n\n componentTypes[typeName] = ComponentClass;\n\n return ComponentClass;\n}\n\nfunction createComponent(typeName, id) {\n var ComponentClass = getComponentClass(typeName);\n return new ComponentClass(id);\n}\n\nexports.r = register;\nexports.___getComponentClass = getComponentClass;\nexports.___createComponent = createComponent;\nexports.___isRegistered = isRegistered;\nexports.___addPendingDef = addPendingDef;\n"],"file":"index-browser.js"}
1
+ {"version":3,"sources":["../../../../src/runtime/components/registry/index-browser.js"],"names":["queueMicrotask","require","defineComponent","initComponents","registered","loaded","componentTypes","pendingDefs","register","type","def","pendingForType","forEach","args","addPendingDef","meta","host","runtimeId","push","isRegistered","Boolean","load","typeName","target","Error","getComponentClass","ComponentClass","Component","renderer","prototype","createComponent","id","exports","r"],"mappings":";AACA,IAAIA,cAAc,GAAGC,OAAO,CAAC,sBAAD,CAA5B;AACA,IAAIC,eAAe,GAAGD,OAAO,CAAC,oBAAD,CAA7B;AACA,IAAIE,cAAc,GAAGF,OAAO,CAAC,oBAAD,CAA5B;AACAA,OAAO,CAAC,UAAD,CAAP;;AAEA,IAAIG,UAAU,GAAG,EAAjB;AACA,IAAIC,MAAM,GAAG,EAAb;AACA,IAAIC,cAAc,GAAG,EAArB;AACA,IAAIC,WAAJ;;AAEA,SAASC,QAAT,CAAkBC,IAAlB,EAAwBC,GAAxB,EAA6B;AAC3B,MAAIC,cAAJ;AACA,MAAIJ,WAAJ,EAAiB;AACfI,IAAAA,cAAc,GAAGJ,WAAW,CAACE,IAAD,CAA5B;AACD;AACDL,EAAAA,UAA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AM,GAAGA,MAAM,EAAf;AACD;;AAED,QAAI,CAACA,MAAL,EAAa;AACX,YAAMC,KAAK,CAAC,0BAA0BF,QAA3B,CAAX;AACD;;AAEDjB,IAAAA,MAAM,CAACiB,QAAD,CAAN,GAAmBC,MAAnB;AACD;;AAED,SAAOA,MAAP;AACD;;AAED,SAASE,iBAAT,CAA2BH,QAA3B,EAAqC;AACnC,MAAII,cAAc,GAAGpB,cAAc,CAACgB,QAAD,CAAnC;;AAEA,MAAII,cAAJ,EAAoB;AAClB,WAAOA,cAAP;AACD;;AAEDA,EAAAA,cAAc,GAAGL,IAAI,CAACC,QAAD,CAArB;;AAEAI,EAAAA,cAAc,GAAGA,cAAc,CAACC,SAAf,IAA4BD,cAA7C;;AAEA,MAAI,CAACA,cAAc,GAAnB,EAAoC;AAClCA,IAAAA,cAAc,GAAGxB,eAAe,CAACwB,cAAD,EAAiBA,cAAc,CAACE,QAAhC,CAAhC;AACD;;AAED;AACAF,EAAAA,cAAc,CAACG,SAAf,OAAmCP,QAAnC;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BAhB,EAAAA,cAAc,CAACgB,QAAD,CAAd,GAA2BI,cAA3B;;AAEA,SAAOA,cAAP;AACD;;AAED,SAASI,eAAT,CAAyBR,QAAzB,EAAmCS,EAAnC,EAAuC;AACrC,MAAIL,cAAc,GAAGD,iBAAiB,CAACH,QAAD,CAAtC;AACA,SAAO,IAAII,cAAJ,CAAmBK,EAAnB,CAAP;AACD;;AAEDC,OAAO,CAACC,CAAR,GAAYzB,QAAZ;AACAwB,OAAO,IAAP,GAA+BP,iBAA/B;AACAO,OAAO,IAAP,GAA6BF,eAA7B;AACAE,OAAO,IAAP,GAA0Bb,YAA1B;AACAa,OAAO,IAAP,GAA2BlB,aAA3B","sourcesContent":["var complain = \"MARKO_DEBUG\" && require(\"complain\");\nvar queueMicrotask = require(\"../../queueMicrotask\");\nvar defineComponent = require(\"../defineComponent\");\nvar initComponents = require(\"../init-components\");\nrequire(\"../entry\");\n\nvar registered = {};\nvar loaded = {};\nvar componentTypes = {};\nvar pendingDefs;\n\nfunction register(type, def) {\n var pendingForType;\n if (pendingDefs) {\n pendingForType = pendingDefs[type];\n }\n registered[type] = def;\n delete loaded[type];\n delete componentTypes[type];\n\n if (pendingForType) {\n delete pendingDefs[type];\n queueMicrotask(function () {\n pendingForType.forEach(function (args) {\n initComponents.___tryHydrateComponent(\n args[0],\n args[1],\n args[2],\n args[3]\n )();\n });\n });\n }\n\n return type;\n}\n\nfunction addPendingDef(def, type, meta, host, runtimeId) {\n if (!pendingDefs) {\n pendingDefs = {};\n\n // eslint-disable-next-line no-constant-condition\n if (\"MARKO_DEBUG\") {\n document.addEventListener(\"load\", function () {\n var pendingComponentIds = Object.keys(pendingDefs);\n if (pendingComponentIds.length) {\n complain(\n \"Marko templates were never loaded for: \" + pendingComponentIds\n );\n }\n });\n }\n }\n (pendingDefs[type] = pendingDefs[type] || []).push([\n def,\n meta,\n host,\n runtimeId\n ]);\n}\n\nfunction isRegistered(type) {\n return Boolean(registered[type]);\n}\n\nfunction load(typeName) {\n var target = loaded[typeName];\n if (!target) {\n target = registered[typeName];\n\n if (target) {\n target = target();\n }\n\n if (!target) {\n throw Error(\"Component not found: \" + typeName);\n }\n\n loaded[typeName] = target;\n }\n\n return target;\n}\n\nfunction getComponentClass(typeName) {\n var ComponentClass = componentTypes[typeName];\n\n if (ComponentClass) {\n return ComponentClass;\n }\n\n ComponentClass = load(typeName);\n\n ComponentClass = ComponentClass.Component || ComponentClass;\n\n if (!ComponentClass.___isComponent) {\n ComponentClass = defineComponent(ComponentClass, ComponentClass.renderer);\n }\n\n // Make the component \"type\" accessible on each component instance\n ComponentClass.prototype.___type = typeName;\n\n // eslint-disable-next-line no-constant-condition\n if (\"MARKO_DEBUG\") {\n var classNameMatch =\n /\\/([^/]+?)(?:\\/index|\\/template|)(?:\\.marko|\\.component(?:-browser)?|)$/.exec(\n typeName\n );\n var className = classNameMatch ? classNameMatch[1] : \"AnonymousComponent\";\n className = className.replace(/-(.)/g, function (g) {\n return g[1].toUpperCase();\n });\n className = className\n .replace(/\\$\\d+\\.\\d+\\.\\d+$/, \"\")\n .replace(/^[^a-z$_]/i, \"_$&\")\n .replace(/[^0-9a-z$_]+/gi, \"_\");\n className = className[0].toUpperCase() + className.slice(1);\n // eslint-disable-next-line no-unused-vars\n try {\n var OldComponentClass = ComponentClass;\n eval(\n \"ComponentClass = function \" +\n className +\n \"(id, doc) { OldComponentClass.call(this, id, doc); }\"\n );\n ComponentClass.prototype = OldComponentClass.prototype;\n } catch (e) {\n /** ignore error */\n }\n }\n\n componentTypes[typeName] = ComponentClass;\n\n return ComponentClass;\n}\n\nfunction createComponent(typeName, id) {\n var ComponentClass = getComponentClass(typeName);\n return new ComponentClass(id);\n}\n\nexports.r = register;\nexports.___getComponentClass = getComponentClass;\nexports.___createComponent = createComponent;\nexports.___isRegistered = isRegistered;\nexports.___addPendingDef = addPendingDef;\n"],"file":"index-browser.js"}
@@ -8,12 +8,13 @@ var runtimeId = markoUID.i++;
8
8
 
9
9
  var componentLookup = {};
10
10
 
11
- var defaultDocument = document;
12
11
  var EMPTY_OBJECT = {};
13
12
 
14
- function getComponentForEl(el, doc) {
13
+ function getComponentForEl(el, host) {
15
14
  var node =
16
- typeof el == "string" ? (doc || defaultDocument).getElementById(el) : el;
15
+ typeof el == "string" ?
16
+ ((host ? host.ownerDocument : host) || document).getElementById(el) :
17
+ el;
17
18
  var component;
18
19
  var vElement;
19
20
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/runtime/components/util/index-browser.js"],"names":["domData","require","componentsByDOMNode","keysByDOMNode","vElementsByDOMNode","vPropsByDOMNode","markoUID","window","$MUID","i","runtimeId","componentLookup","defaultDocument","document","EMPTY_OBJECT","getComponentForEl","el","doc","node","getElementById","component","vElement","fragment","endNode","startNode","get","previousSibling","parentNode","destroyComponentForNode","componentToDestroy","id","destroyNodeRecursive","nodeType","key","test","curChild","firstChild","nextSibling","nextComponentId","nextComponentIdProvider","attachBubblingEvent","componentDef","handlerMethodName","isOnce","extraArgs","componentId","getMarkoPropsFromEl","virtualProps","getAttribute","set","JSON","parse","normalizeComponentKey","parentId","replace","addComponentRootToKeyedElements","keyedElements","rootNode","repeatedElementsForKey","exports"],"mappings":"aAAA,IAAIA,OAAO,GAAGC,OAAO,CAAC,aAAD,CAArB;AACA,IAAIC,mBAAmB,GAAGF,OAAO,GAAjC;AACA,IAAIG,aAAa,GAAGH,OAAO,IAA3B;AACA,IAAII,kBAAkB,GAAGJ,OAAO,IAAhC;AACA,IAAIK,eAAe,GAAGL,OAAO,IAA7B;AACA,IAAIM,QAAQ,GAAGC,MAAM,CAACC,KAAP,KAAiBD,MAAM,CAACC,KAAP,GAAe,EAAEC,CAAC,EAAE,CAAL,EAAhC,CAAf;AACA,IAAIC,SAAS,GAAGJ,QAAQ,CAACG,CAAT,EAAhB;;AAEA,IAAIE,eAAe,GAAG,EAAtB;;AAEA,IAAIC,eAAe,GAAGC,QAAtB;AACA,IAAIC,YAAY,GAAG,EAAnB;;AAEA,SAASC,iBAAT,CAA2BC,EAA3B,EAA+BC,GAA/B,EAAoC;AAClC,MAAIC,IAAI;AACN,SAAOF,EAAP,IAAa,QAAb,GAAwB,CAACC,GAAG,IAAIL,eAAR,EAAyBO,cAAzB,CAAwCH,EAAxC,CAAxB,GAAsEA,EADxE;AAEA,MAAII,SAAJ;AACA,MAAIC,QAAJ;;AAEA,SAAOH,IAAP,EAAa;AACX,QAAIA,IAAI,CAACI,QAAT,EAAmB;AACjB,UAAIJ,IAAI,CAACI,QAAL,CAAcC,OAAd,KAA0BL,IAA9B,EAAoC;AAClCA,QAAAA,IAAI,GAAGA,IAAI,CAACI,QAAL,CAAcE,SAArB;AACD,OAFD,MAEO;AACLN,QAAAA,IAAI,GAAGA,IAAI,CAACI,QAAZ;AACAF,QAAAA,SAAS,GAAGlB,mBAAmB,CAACuB,GAApB,CAAwBP,IAAxB,CAAZ;AACD;AACF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X,CAAH,GAA8BjC,YAF5D;;AAID;AACF;;AAED,SAAOiC,YAAP;AACD;;AAED,SAASK,qBAAT,CAA+BnB,GAA/B,EAAoCoB,QAApC,EAA8C;AAC5C,MAAIpB,GAAG,CAAC,CAAD,CAAH,KAAW,GAAf,EAAoB;AAClBA,IAAAA,GAAG,GAAGA,GAAG,CAACqB,OAAJ,CAAY,MAAMD,QAAN,GAAiB,GAA7B,EAAkC,EAAlC,CAAN;AACD;AACD,SAAOpB,GAAP;AACD;;AAED,SAASsB,+BAAT;AACEC,aADF;AAEEvB,GAFF;AAGEwB,QAHF;AAIEZ,WAJF;AAKE;AACA,MAAI,QAAQX,IAAR,CAAaD,GAAb,CAAJ,EAAuB;AACrB,QAAIyB,sBAAsB,GAAIF,aAAa,CAACvB,GAAD,CAAb;AAC5BuB,IAAAA,aAAa,CAACvB,GAAD,CAAb,IAAsB,EADxB;AAEAyB,IAAAA,sBAAsB,CAACb,WAAD,CAAtB,GAAsCY,QAAtC;AACD,GAJD,MAIO;AACLD,IAAAA,aAAa,CAACvB,GAAD,CAAb,GAAqBwB,QAArB;AACD;AACF;;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BAE,OAAO,IAAP,GAAuBjD,SAAvB;AACAiD,OAAO,GAAP,GAA6BhD,eAA7B;AACAgD,OAAO,IAAP,GAA+B5C,iBAA/B;AACA4C,OAAO,IAAP,GAAqC/B,uBAArC;AACA+B,OAAO,GAAP,GAAkC5B,oBAAlC;AACA4B,OAAO,IAAP,GAAqCpB,uBAArC;AACAoB,OAAO,IAAP,GAAiCnB,mBAAjC;AACAmB,OAAO,IAAP,GAAiCb,mBAAjC;AACAa,OAAO,IAAP,GAA6CJ,+BAA7C;AACAI,OAAO,IAAP,GAAmCP,qBAAnC","sourcesContent":["var domData = require(\"../dom-data\");\nvar componentsByDOMNode = domData.___componentByDOMNode;\nvar keysByDOMNode = domData.___keyByDOMNode;\nvar vElementsByDOMNode = domData.___vElementByDOMNode;\nvar vPropsByDOMNode = domData.___vPropsByDOMNode;\nvar markoUID = window.$MUID || (window.$MUID = { i: 0 });\nvar runtimeId = markoUID.i++;\n\nvar componentLookup = {};\n\nvar defaultDocument = document;\nvar EMPTY_OBJECT = {};\n\nfunction getComponentForEl(el, doc) {\n var node =\n typeof el == \"string\" ? (doc || defaultDocument).getElementById(el) : el;\n var component;\n var vElement;\n\n while (node) {\n if (node.fragment) {\n if (node.fragment.endNode === node) {\n node = node.fragment.startNode;\n } else {\n node = node.fragment;\n component = componentsByDOMNode.get(node);\n }\n } else if ((vElement = vElementsByDOMNode.get(node))) {\n component = vElement.___ownerComponent;\n }\n\n if (component) {\n return component;\n }\n\n node = node.previousSibling || node.parentNode;\n }\n}\n\nfunction destroyComponentForNode(node) {\n var componentToDestroy = componentsByDOMNode.get(node.fragment || node);\n if (componentToDestroy) {\n componentToDestroy.___destroyShallow();\n delete componentLookup[componentToDestroy.id];\n }\n}\nfunction destroyNodeRecursive(node, component) {\n destroyComponentForNode(node);\n if (node.nodeType === 1 || node.nodeType === 12) {\n var key;\n\n if (component && (key = keysByDOMNode.get(node))) {\n if (node === component.___keyedElements[key]) {\n if (componentsByDOMNode.get(node) && /\\[\\]$/.test(key)) {\n delete component.___keyedElements[key][\n componentsByDOMNode.get(node).id\n ];\n } else {\n delete component.___keyedElements[key];\n }\n }\n }\n\n var curChild = node.firstChild;\n while (curChild && curChild !== node.endNode) {\n destroyNodeRecursive(curChild, component);\n curChild = curChild.nextSibling;\n }\n }\n}\n\nfunction nextComponentId() {\n // Each component will get an ID that is unique across all loaded\n // marko runtimes. This allows multiple instances of marko to be\n // loaded in the same window and they should all place nice\n // together\n return \"c\" + markoUID.i++;\n}\n\nfunction nextComponentIdProvider() {\n return nextComponentId;\n}\n\nfunction attachBubblingEvent(\n componentDef,\n handlerMethodName,\n isOnce,\n extraArgs\n) {\n if (handlerMethodName) {\n var componentId = componentDef.id;\n if (extraArgs) {\n return [handlerMethodName, componentId, isOnce, extraArgs];\n } else {\n return [handlerMethodName, componentId, isOnce];\n }\n }\n}\n\nfunction getMarkoPropsFromEl(el) {\n var vElement = vElementsByDOMNode.get(el);\n var virtualProps;\n\n if (vElement) {\n virtualProps = vElement.___properties;\n } else {\n virtualProps = vPropsByDOMNode.get(el);\n if (!virtualProps) {\n virtualProps = el.getAttribute(\"data-marko\");\n vPropsByDOMNode.set(\n el,\n (virtualProps = virtualProps ? JSON.parse(virtualProps) : EMPTY_OBJECT)\n );\n }\n }\n\n return virtualProps;\n}\n\nfunction normalizeComponentKey(key, parentId) {\n if (key[0] === \"#\") {\n key = key.replace(\"#\" + parentId + \"-\", \"\");\n }\n return key;\n}\n\nfunction addComponentRootToKeyedElements(\n keyedElements,\n key,\n rootNode,\n componentId\n) {\n if (/\\[\\]$/.test(key)) {\n var repeatedElementsForKey = (keyedElements[key] =\n keyedElements[key] || {});\n repeatedElementsForKey[componentId] = rootNode;\n } else {\n keyedElements[key] = rootNode;\n }\n}\n\n// eslint-disable-next-line no-constant-condition\nif (\"MARKO_DEBUG\") {\n var warnNodeRemoved = function (event) {\n var fragment = event.target.fragment;\n if (fragment) {\n var baseError = new Error(\n \"Fragment boundary marker removed. This will cause an error when the fragment is updated.\"\n );\n fragment.___markersRemovedError = function (message) {\n var error = new Error(message + \" Boundary markers missing.\");\n\n baseError.stack = baseError.stack.replace(/.*warnNodeRemoved.*\\n/, \"\");\n\n // eslint-disable-next-line no-console\n console.warn(baseError);\n return error;\n };\n }\n };\n exports.___startDOMManipulationWarning = function () {\n document.addEventListener(\"DOMNodeRemoved\", warnNodeRemoved);\n };\n exports.___stopDOMManipulationWarning = function () {\n document.removeEventListener(\"DOMNodeRemoved\", warnNodeRemoved);\n };\n}\n\nexports.___runtimeId = runtimeId;\nexports.___componentLookup = componentLookup;\nexports.___getComponentForEl = getComponentForEl;\nexports.___destroyComponentForNode = destroyComponentForNode;\nexports.___destroyNodeRecursive = destroyNodeRecursive;\nexports.___nextComponentIdProvider = nextComponentIdProvider;\nexports.___attachBubblingEvent = attachBubblingEvent;\nexports.___getMarkoPropsFromEl = getMarkoPropsFromEl;\nexports.___addComponentRootToKeyedElements = addComponentRootToKeyedElements;\nexports.___normalizeComponentKey = normalizeComponentKey;\n"],"file":"index-browser.js"}
1
+ {"version":3,"sources":["../../../../src/runtime/components/util/index-browser.js"],"names":["domData","require","componentsByDOMNode","keysByDOMNode","vElementsByDOMNode","vPropsByDOMNode","markoUID","window","$MUID","i","runtimeId","componentLookup","EMPTY_OBJECT","getComponentForEl","el","host","node","ownerDocument","document","getElementById","component","vElement","fragment","endNode","startNode","get","previousSibling","parentNode","destroyComponentForNode","componentToDestroy","id","destroyNodeRecursive","nodeType","key","test","curChild","firstChild","nextSibling","nextComponentId","nextComponentIdProvider","attachBubblingEvent","componentDef","handlerMethodName","isOnce","extraArgs","componentId","getMarkoPropsFromEl","virtualProps","getAttribute","set","JSON","parse","normalizeComponentKey","parentId","replace","addComponentRootToKeyedElements","keyedElements","rootNode","repeatedElementsForKey","exports"],"mappings":"aAAA,IAAIA,OAAO,GAAGC,OAAO,CAAC,aAAD,CAArB;AACA,IAAIC,mBAAmB,GAAGF,OAAO,GAAjC;AACA,IAAIG,aAAa,GAAGH,OAAO,IAA3B;AACA,IAAII,kBAAkB,GAAGJ,OAAO,IAAhC;AACA,IAAIK,eAAe,GAAGL,OAAO,IAA7B;AACA,IAAIM,QAAQ,GAAGC,MAAM,CAACC,KAAP,KAAiBD,MAAM,CAACC,KAAP,GAAe,EAAEC,CAAC,EAAE,CAAL,EAAhC,CAAf;AACA,IAAIC,SAAS,GAAGJ,QAAQ,CAACG,CAAT,EAAhB;;AAEA,IAAIE,eAAe,GAAG,EAAtB;;AAEA,IAAIC,YAAY,GAAG,EAAnB;;AAEA,SAASC,iBAAT,CAA2BC,EAA3B,EAA+BC,IAA/B,EAAqC;AACnC,MAAIC,IAAI;AACN,SAAOF,EAAP,IAAa,QAAb;AACI,GAAC,CAACC,IAAI,GAAGA,IAAI,CAACE,aAAR,GAAwBF,I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OAAO,GAAP,GAA6BhD,eAA7B;AACAgD,OAAO,IAAP,GAA+B9C,iBAA/B;AACA8C,OAAO,IAAP,GAAqC/B,uBAArC;AACA+B,OAAO,GAAP,GAAkC5B,oBAAlC;AACA4B,OAAO,IAAP,GAAqCpB,uBAArC;AACAoB,OAAO,IAAP,GAAiCnB,mBAAjC;AACAmB,OAAO,IAAP,GAAiCb,mBAAjC;AACAa,OAAO,IAAP,GAA6CJ,+BAA7C;AACAI,OAAO,IAAP,GAAmCP,qBAAnC","sourcesContent":["var domData = require(\"../dom-data\");\nvar componentsByDOMNode = domData.___componentByDOMNode;\nvar keysByDOMNode = domData.___keyByDOMNode;\nvar vElementsByDOMNode = domData.___vElementByDOMNode;\nvar vPropsByDOMNode = domData.___vPropsByDOMNode;\nvar markoUID = window.$MUID || (window.$MUID = { i: 0 });\nvar runtimeId = markoUID.i++;\n\nvar componentLookup = {};\n\nvar EMPTY_OBJECT = {};\n\nfunction getComponentForEl(el, host) {\n var node =\n typeof el == \"string\"\n ? ((host ? host.ownerDocument : host) || document).getElementById(el)\n : el;\n var component;\n var vElement;\n\n while (node) {\n if (node.fragment) {\n if (node.fragment.endNode === node) {\n node = node.fragment.startNode;\n } else {\n node = node.fragment;\n component = componentsByDOMNode.get(node);\n }\n } else if ((vElement = vElementsByDOMNode.get(node))) {\n component = vElement.___ownerComponent;\n }\n\n if (component) {\n return component;\n }\n\n node = node.previousSibling || node.parentNode;\n }\n}\n\nfunction destroyComponentForNode(node) {\n var componentToDestroy = componentsByDOMNode.get(node.fragment || node);\n if (componentToDestroy) {\n componentToDestroy.___destroyShallow();\n delete componentLookup[componentToDestroy.id];\n }\n}\nfunction destroyNodeRecursive(node, component) {\n destroyComponentForNode(node);\n if (node.nodeType === 1 || node.nodeType === 12) {\n var key;\n\n if (component && (key = keysByDOMNode.get(node))) {\n if (node === component.___keyedElements[key]) {\n if (componentsByDOMNode.get(node) && /\\[\\]$/.test(key)) {\n delete component.___keyedElements[key][\n componentsByDOMNode.get(node).id\n ];\n } else {\n delete component.___keyedElements[key];\n }\n }\n }\n\n var curChild = node.firstChild;\n while (curChild && curChild !== node.endNode) {\n destroyNodeRecursive(curChild, component);\n curChild = curChild.nextSibling;\n }\n }\n}\n\nfunction nextComponentId() {\n // Each component will get an ID that is unique across all loaded\n // marko runtimes. This allows multiple instances of marko to be\n // loaded in the same window and they should all place nice\n // together\n return \"c\" + markoUID.i++;\n}\n\nfunction nextComponentIdProvider() {\n return nextComponentId;\n}\n\nfunction attachBubblingEvent(\n componentDef,\n handlerMethodName,\n isOnce,\n extraArgs\n) {\n if (handlerMethodName) {\n var componentId = componentDef.id;\n if (extraArgs) {\n return [handlerMethodName, componentId, isOnce, extraArgs];\n } else {\n return [handlerMethodName, componentId, isOnce];\n }\n }\n}\n\nfunction getMarkoPropsFromEl(el) {\n var vElement = vElementsByDOMNode.get(el);\n var virtualProps;\n\n if (vElement) {\n virtualProps = vElement.___properties;\n } else {\n virtualProps = vPropsByDOMNode.get(el);\n if (!virtualProps) {\n virtualProps = el.getAttribute(\"data-marko\");\n vPropsByDOMNode.set(\n el,\n (virtualProps = virtualProps ? JSON.parse(virtualProps) : EMPTY_OBJECT)\n );\n }\n }\n\n return virtualProps;\n}\n\nfunction normalizeComponentKey(key, parentId) {\n if (key[0] === \"#\") {\n key = key.replace(\"#\" + parentId + \"-\", \"\");\n }\n return key;\n}\n\nfunction addComponentRootToKeyedElements(\n keyedElements,\n key,\n rootNode,\n componentId\n) {\n if (/\\[\\]$/.test(key)) {\n var repeatedElementsForKey = (keyedElements[key] =\n keyedElements[key] || {});\n repeatedElementsForKey[componentId] = rootNode;\n } else {\n keyedElements[key] = rootNode;\n }\n}\n\n// eslint-disable-next-line no-constant-condition\nif (\"MARKO_DEBUG\") {\n var warnNodeRemoved = function (event) {\n var fragment = event.target.fragment;\n if (fragment) {\n var baseError = new Error(\n \"Fragment boundary marker removed. This will cause an error when the fragment is updated.\"\n );\n fragment.___markersRemovedError = function (message) {\n var error = new Error(message + \" Boundary markers missing.\");\n\n baseError.stack = baseError.stack.replace(/.*warnNodeRemoved.*\\n/, \"\");\n\n // eslint-disable-next-line no-console\n console.warn(baseError);\n return error;\n };\n }\n };\n exports.___startDOMManipulationWarning = function (host) {\n host.addEventListener(\"DOMNodeRemoved\", warnNodeRemoved);\n };\n exports.___stopDOMManipulationWarning = function (host) {\n host.removeEventListener(\"DOMNodeRemoved\", warnNodeRemoved);\n };\n}\n\nexports.___runtimeId = runtimeId;\nexports.___componentLookup = componentLookup;\nexports.___getComponentForEl = getComponentForEl;\nexports.___destroyComponentForNode = destroyComponentForNode;\nexports.___destroyNodeRecursive = destroyNodeRecursive;\nexports.___nextComponentIdProvider = nextComponentIdProvider;\nexports.___attachBubblingEvent = attachBubblingEvent;\nexports.___getMarkoPropsFromEl = getMarkoPropsFromEl;\nexports.___addComponentRootToKeyedElements = addComponentRootToKeyedElements;\nexports.___normalizeComponentKey = normalizeComponentKey;\n"],"file":"index-browser.js"}
@@ -2,7 +2,6 @@
2
2
  var EventEmitter = require("events-light");
3
3
  var StringWriter = require("./StringWriter");
4
4
  var BufferedWriter = require("./BufferedWriter");
5
- var defaultDocument = typeof document != "undefined" && document;
6
5
  var RenderResult = require("../RenderResult");
7
6
  var attrsHelper = require("./helpers/attrs");
8
7
  var markoAttr = require("./helpers/data-marko");
@@ -115,7 +114,7 @@ AsyncStream.enableAsyncStackTrace = function () {
115
114
 
116
115
  var proto = AsyncStream.prototype = {
117
116
  constructor: AsyncStream,
118
- X_: defaultDocument,
117
+ X_: typeof window === "object" && document,
119
118
  aP_: true,
120
119
 
121
120
  sync: function () {
@@ -603,17 +602,16 @@ var proto = AsyncStream.prototype = {
603
602
  }
604
603
  },
605
604
 
606
- A_: function (doc) {
605
+ A_: function (host) {
607
606
  var node = this._node;
608
- var nextEl;
609
- var fragment;
610
- var html = this.B_();
611
-
612
- if (!doc) {
613
- doc = this.X_;
614
- }
615
607
 
616
608
  if (!node) {
609
+ var nextEl;
610
+ var fragment;
611
+ var html = this.B_();
612
+ if (!host) host = this.X_;
613
+ var doc = host.ownerDocument || host;
614
+
617
615
  if (html) {
618
616
  node = parseHTML(html);
619
617
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/html/AsyncStream.js"],"names":["EventEmitter","require","StringWriter","BufferedWriter","defaultDocument","document","RenderResult","attrsHelper","markoAttr","escapeXmlHelper","parseHTML","escapeXmlOrNullish","x","escapeXmlString","selfClosingTags","noop","voidWriter","write","script","merge","clear","get","toString","State","root","stream","writer","events","finished","escapeEndingComment","text","replace","AsyncStream","global","parentOut","Error","finalGlobal","attributes","originalStream","state","_state","on","runtimeId","_ended","_remaining","_lastCount","_last","undefined","_parentOut","data","_sync","_stack","name","_timeoutId","_node","_elStack","DEFAULT_TIMEOUT","INCLUDE_STACK","process","env","NODE_ENV","enableAsyncStackTrace","proto","prototype","constructor","sync","isSync","str","getOutput","_result","beginAsync","options","currentWriter","newWriter","newStream","next","timeout","last","getNonMarkoStack","setTimeout","error","emit","out","_doFinish","end","remaining","_flushNext","_emitLast","timeoutId","clearTimeout","_handleChildDone","childOut","nextWriter","nextStream","event","callback","onLast","once","lastArray","push","i","length","lastCallback","type","arg","arguments","apply","removeListener","prependListener","pipe","e","stack","JSON","stringify","message","flush","scheduleFlush","createOut","newOut","bind","tagName","elementAttrs","key","componentDef","props","voidElements","indexOf","svgElements","element","openTagOnly","beginElement","endElement","pop","comment","bf","component","preserve","ef","doc","node","nextEl","fragment","html","nextSibling","createDocumentFragment","appendChild","then","fn","fnErr","promise","Promise","resolve","reject","result","catch","c","customEvents","w","module","exports","split","slice","filter","line","test","join"],"mappings":"AAAA;AACA,IAAIA,YAAY,GAAGC,OAAO,CAAC,cAAD,CAA1B;AACA,IAAIC,YAAY,GAAGD,OAAO,CAAC,gBAAD,CAA1B;AACA,IAAIE,cAAc,GAAGF,OAAO,CAAC,kBAAD,CAA5B;AACA,IAAIG,eAAe,GAAG,OAAOC,QAAP,IAAmB,WAAnB,I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,KAA1B,EAAiC;AAC/B,SAAOA,KAAK,CAAC+B,KAAN;AACJzF,EAAAA,QADI;AAEJ0I,EAAAA,KAFI,CAEE,IAFF;AAGJC,EAAAA,KAHI,CAGE,CAHF;AAIJC,EAAAA,MAJI,CAIG,CAAAC,IAAI,KAAI,CAAC,0BAA0BC,IAA1B,CAA+BD,IAA/B,CAJZ;AAKJE,EAAAA,IALI,CAKC,IALD,CAAP;AAMD","sourcesContent":["\"use strict\";\nvar EventEmitter = require(\"events-light\");\nvar StringWriter = require(\"./StringWriter\");\nvar BufferedWriter = require(\"./BufferedWriter\");\nvar defaultDocument = typeof document != \"undefined\" && document;\nvar RenderResult = require(\"../RenderResult\");\nvar attrsHelper = require(\"./helpers/attrs\");\nvar markoAttr = require(\"./helpers/data-marko\");\nvar escapeXmlHelper = require(\"./helpers/escape-xml\");\nvar parseHTML = require(\"../vdom/parse-html\");\nvar escapeXmlOrNullish = escapeXmlHelper.x;\nvar escapeXmlString = escapeXmlHelper.___escapeXML;\nvar selfClosingTags = require(\"self-closing-tags\");\n\nfunction noop() {}\n\nvar voidWriter = {\n write: noop,\n script: noop,\n merge: noop,\n clear: noop,\n get: function () {\n return [];\n },\n toString: function () {\n return \"\";\n }\n};\n\nfunction State(root, stream, writer, events) {\n this.root = root;\n this.stream = stream;\n this.writer = writer;\n this.events = events;\n\n this.finished = false;\n}\n\nfunction escapeEndingComment(text) {\n return text.replace(/-->/g, \"--&gt;\");\n}\n\nfunction AsyncStream(global, writer, parentOut) {\n if (parentOut === null) {\n throw new Error(\"illegal state\");\n }\n var finalGlobal = (this.attributes = global || {});\n var originalStream;\n var state;\n\n if (parentOut) {\n state = parentOut._state;\n originalStream = state.stream;\n } else {\n var events = (finalGlobal.events /* deprecated */ =\n writer && writer.on ? writer : new EventEmitter());\n\n if (writer) {\n originalStream = writer;\n writer = new BufferedWriter(writer);\n } else {\n writer = originalStream = new StringWriter();\n }\n\n state = new State(this, originalStream, writer, events);\n writer.state = state;\n }\n\n finalGlobal.runtimeId = finalGlobal.runtimeId || \"M\";\n this.global = finalGlobal;\n this.stream = originalStream;\n this._state = state;\n\n this._ended = false;\n this._remaining = 1;\n this._lastCount = 0;\n this._last = undefined; // Array\n this._parentOut = parentOut;\n\n this.data = {};\n this.writer = writer;\n writer.stream = this;\n\n this._sync = false;\n this._stack = undefined;\n this.name = undefined;\n this._timeoutId = undefined;\n\n this._node = undefined;\n\n this._elStack = undefined; // Array\n\n this.___components = null; // ComponentsContext\n\n this.___assignedComponentDef = null;\n this.___assignedKey = null;\n this.___assignedCustomEvents = null;\n this.___isLast = false;\n}\n\nAsyncStream.DEFAULT_TIMEOUT = 10000;\n\n/**\n * If set to `true`, AsyncStream errors will include the full stack trace\n */\nAsyncStream.INCLUDE_STACK =\n typeof process !== \"undefined\" &&\n (!process.env.NODE_ENV ||\n process.env.NODE_ENV === \"development\" ||\n process.env.NODE_ENV === \"dev\");\n\nAsyncStream.enableAsyncStackTrace = function () {\n AsyncStream.INCLUDE_STACK = true;\n};\n\nvar proto = (AsyncStream.prototype = {\n constructor: AsyncStream,\n ___document: defaultDocument,\n ___isOut: true,\n\n sync: function () {\n this._sync = true;\n },\n\n isSync: function () {\n return this._sync === true;\n },\n\n write: function (str) {\n if (str != null) {\n this.writer.write(str.toString());\n }\n return this;\n },\n\n script: function (str) {\n if (str != null) {\n this.writer.script(str.toString());\n }\n return this;\n },\n\n ___getOutput: function () {\n return this._state.writer.toString();\n },\n\n /**\n * Legacy...\n */\n getOutput: function () {\n return this.___getOutput();\n },\n\n toString: function () {\n return this._state.writer.toString();\n },\n\n ___getResult: function () {\n this._result = this._result || new RenderResult(this);\n return this._result;\n },\n\n beginAsync: function (options) {\n if (this._sync) {\n throw new Error(\"beginAsync() not allowed when using renderSync()\");\n }\n\n var state = this._state;\n\n var currentWriter = this.writer;\n\n /* ┏━━━━━┓ this\n ┃ WAS ┃ ↓↑\n ┗━━━━━┛ prevWriter → currentWriter → nextWriter */\n\n var newWriter = new StringWriter();\n var newStream = new AsyncStream(this.global, currentWriter, this);\n newWriter.state = state;\n\n this.writer = newWriter;\n newWriter.stream = this;\n\n newWriter.next = currentWriter.next;\n currentWriter.next = newWriter;\n\n /* ┏━━━━━┓ newStream this\n ┃ NOW ┃ ↓↑ ↓↑\n ┗━━━━━┛ prevWriter → currentWriter → newWriter → nextWriter */\n\n var timeout;\n var name;\n\n this._remaining++;\n\n if (options != null) {\n if (typeof options === \"number\") {\n timeout = options;\n } else {\n timeout = options.timeout;\n\n if (options.last === true) {\n if (timeout == null) {\n // Don't assign a timeout to last flush fragments\n // unless it is explicitly given a timeout\n timeout = 0;\n }\n\n this._lastCount++;\n newStream.___isLast = true;\n }\n\n name = options.name;\n }\n }\n\n if (timeout == null) {\n timeout = AsyncStream.DEFAULT_TIMEOUT;\n }\n\n newStream._stack = AsyncStream.INCLUDE_STACK\n ? getNonMarkoStack(new Error())\n : null;\n newStream.name = name;\n\n if (timeout > 0) {\n newStream._timeoutId = setTimeout(function () {\n newStream.error(\n new Error(\n \"Async fragment \" +\n (name ? \"(\" + name + \") \" : \"\") +\n \"timed out after \" +\n timeout +\n \"ms\"\n )\n );\n }, timeout);\n }\n\n state.events.emit(\"beginAsync\", {\n out: newStream,\n parentOut: this\n });\n\n return newStream;\n },\n\n _doFinish: function () {\n var state = this._state;\n\n state.finished = true;\n\n if (state.writer.end) {\n state.writer.end();\n } else {\n state.events.emit(\"finish\", this.___getResult());\n }\n },\n\n end: function (data) {\n if (this._ended === true) {\n return;\n }\n\n this._ended = true;\n\n var remaining = --this._remaining;\n\n if (data != null) {\n this.write(data);\n }\n\n var currentWriter = this.writer;\n\n /* ┏━━━━━┓ this nextStream\n ┃ WAS ┃ ↓↑ ↓↑\n ┗━━━━━┛ currentWriter → nextWriter → futureWriter */\n\n // Prevent any more writes to the current steam\n this.writer = voidWriter;\n currentWriter.stream = null;\n\n // Flush the contents of nextWriter to the currentWriter\n this._flushNext(currentWriter);\n\n /* ┏━━━━━┓ this ╵ nextStream\n ┃ ┃ ↓ ╵ ↓↑\n ┃ NOW ┃ voidWriter ╵ currentWriter → futureWriter\n ┃ ┃ ──────────────┴────────────────────────────────\n ┗━━━━━┛ Flushed & garbage collected: nextWriter */\n\n var parentOut = this._parentOut;\n\n if (parentOut === undefined) {\n if (remaining === 0) {\n this._doFinish();\n } else if (remaining - this._lastCount === 0) {\n this._emitLast();\n }\n } else {\n var timeoutId = this._timeoutId;\n\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n\n if (remaining === 0) {\n parentOut._handleChildDone(this);\n } else if (remaining - this._lastCount === 0) {\n this._emitLast();\n }\n }\n\n return this;\n },\n\n _handleChildDone: function (childOut) {\n var remaining = --this._remaining;\n\n if (remaining === 0) {\n var parentOut = this._parentOut;\n if (parentOut === undefined) {\n this._doFinish();\n } else {\n parentOut._handleChildDone(this);\n }\n } else {\n if (childOut.___isLast) {\n this._lastCount--;\n }\n\n if (remaining - this._lastCount === 0) {\n this._emitLast();\n }\n }\n },\n\n _flushNext: function (currentWriter) {\n // It is possible that currentWriter is the\n // last writer in the chain, so let's make\n // sure there is a nextWriter to flush.\n var nextWriter = currentWriter.next;\n if (nextWriter) {\n // Flush the contents of nextWriter\n // to the currentWriter\n currentWriter.merge(nextWriter);\n\n // Remove nextWriter from the chain.\n // It has been flushed and can now be\n // garbage collected.\n currentWriter.next = nextWriter.next;\n\n // It's possible that nextWriter is the last\n // writer in the chain and its stream already\n // ended, so let's make sure nextStream exists.\n var nextStream = nextWriter.stream;\n if (nextStream) {\n // Point the nextStream to currentWriter\n nextStream.writer = currentWriter;\n currentWriter.stream = nextStream;\n }\n }\n },\n\n on: function (event, callback) {\n var state = this._state;\n\n if (event === \"finish\" && state.finished === true) {\n callback(this.___getResult());\n } else if (event === \"last\") {\n this.onLast(callback);\n } else {\n state.events.on(event, callback);\n }\n\n return this;\n },\n\n once: function (event, callback) {\n var state = this._state;\n\n if (event === \"finish\" && state.finished === true) {\n callback(this.___getResult());\n } else if (event === \"last\") {\n this.onLast(callback);\n } else {\n state.events.once(event, callback);\n }\n\n return this;\n },\n\n onLast: function (callback) {\n var lastArray = this._last;\n\n if (lastArray === undefined) {\n this._last = [callback];\n } else {\n lastArray.push(callback);\n }\n\n return this;\n },\n\n _emitLast: function () {\n if (this._last) {\n var i = 0;\n var lastArray = this._last;\n this._last = undefined;\n (function next() {\n if (i === lastArray.length) {\n return;\n }\n var lastCallback = lastArray[i++];\n lastCallback(next);\n\n if (lastCallback.length === 0) {\n next();\n }\n })();\n }\n },\n\n emit: function (type, arg) {\n var events = this._state.events;\n switch (arguments.length) {\n case 1:\n events.emit(type);\n break;\n case 2:\n events.emit(type, arg);\n break;\n default:\n events.emit.apply(events, arguments);\n break;\n }\n return this;\n },\n\n removeListener: function () {\n var events = this._state.events;\n events.removeListener.apply(events, arguments);\n return this;\n },\n\n prependListener: function () {\n var events = this._state.events;\n events.prependListener.apply(events, arguments);\n return this;\n },\n\n pipe: function (stream) {\n this._state.stream.pipe(stream);\n return this;\n },\n\n error: function (e) {\n var name = this.name;\n var stack = this._stack;\n\n if (!(e instanceof Error)) {\n e = new Error(JSON.stringify(e));\n }\n\n if (name || stack) {\n e.message +=\n \"\\nRendered by\" +\n (name ? \" \" + name : \"\") +\n (stack ? \":\\n\" + stack : \"\");\n }\n try {\n this.emit(\"error\", e);\n } finally {\n // If there is no listener for the error event then it will\n // throw a new here. In order to ensure that the async fragment\n // is still properly ended we need to put the end() in a `finally`\n // block\n this.end();\n }\n\n return this;\n },\n\n flush: function () {\n var state = this._state;\n\n if (!state.finished) {\n var writer = state.writer;\n if (writer && writer.scheduleFlush) {\n writer.scheduleFlush();\n }\n }\n return this;\n },\n\n createOut: function () {\n var newOut = new AsyncStream(this.global);\n // Forward error events to the parent out.\n newOut.on(\"error\", this.emit.bind(this, \"error\"));\n this._state.events.emit(\"beginDetachedAsync\", {\n out: newOut,\n parentOut: this\n });\n return newOut;\n },\n\n ___elementDynamic: function (\n tagName,\n elementAttrs,\n key,\n componentDef,\n props\n ) {\n var str =\n \"<\" +\n tagName +\n markoAttr(this, componentDef, props, key) +\n attrsHelper(elementAttrs);\n\n if (selfClosingTags.voidElements.indexOf(tagName) !== -1) {\n str += \">\";\n } else if (selfClosingTags.svgElements.indexOf(tagName) !== -1) {\n str += \"/>\";\n } else {\n str += \"></\" + tagName + \">\";\n }\n\n this.write(str);\n },\n\n element: function (tagName, elementAttrs, openTagOnly) {\n var str = \"<\" + tagName + attrsHelper(elementAttrs) + \">\";\n\n if (openTagOnly !== true) {\n str += \"</\" + tagName + \">\";\n }\n\n this.write(str);\n },\n\n ___beginElementDynamic: function (\n name,\n elementAttrs,\n key,\n componentDef,\n props\n ) {\n var str =\n \"<\" +\n name +\n markoAttr(this, componentDef, props, key) +\n attrsHelper(elementAttrs) +\n \">\";\n\n this.write(str);\n\n if (this._elStack) {\n this._elStack.push(name);\n } else {\n this._elStack = [name];\n }\n },\n\n beginElement: function (name, elementAttrs) {\n var str = \"<\" + name + attrsHelper(elementAttrs) + \">\";\n\n this.write(str);\n\n if (this._elStack) {\n this._elStack.push(name);\n } else {\n this._elStack = [name];\n }\n },\n\n endElement: function () {\n var tagName = this._elStack.pop();\n this.write(\"</\" + tagName + \">\");\n },\n\n comment: function (str) {\n this.write(\"<!--\" + escapeEndingComment(str) + \"-->\");\n },\n\n text: function (str) {\n this.write(escapeXmlOrNullish(str));\n },\n\n bf: function (key, component, preserve) {\n if (preserve) {\n this.write(\"<!--F#\" + escapeXmlString(key) + \"-->\");\n }\n if (this._elStack) {\n this._elStack.push(preserve);\n } else {\n this._elStack = [preserve];\n }\n },\n\n ef: function () {\n var preserve = this._elStack.pop();\n if (preserve) {\n this.write(\"<!--F/-->\");\n }\n },\n\n ___getNode: function (doc) {\n var node = this._node;\n var nextEl;\n var fragment;\n var html = this.___getOutput();\n\n if (!doc) {\n doc = this.___document;\n }\n\n if (!node) {\n if (html) {\n node = parseHTML(html);\n\n if (node && node.nextSibling) {\n // If there are multiple nodes, turn it into a document fragment.\n fragment = doc.createDocumentFragment();\n\n do {\n nextEl = node.nextSibling;\n fragment.appendChild(node);\n } while ((node = nextEl));\n\n node = fragment;\n }\n }\n\n // if HTML is empty use empty document fragment (so that we're returning a valid DOM node)\n this._node = node || doc.createDocumentFragment();\n }\n return node;\n },\n\n then: function (fn, fnErr) {\n var out = this;\n var promise = new Promise(function (resolve, reject) {\n out.on(\"error\", reject);\n out.on(\"finish\", function (result) {\n resolve(result);\n });\n });\n\n return Promise.resolve(promise).then(fn, fnErr);\n },\n\n catch: function (fnErr) {\n return this.then(undefined, fnErr);\n },\n\n c: function (componentDef, key, customEvents) {\n this.___assignedComponentDef = componentDef;\n this.___assignedKey = key;\n this.___assignedCustomEvents = customEvents;\n }\n});\n\n// alias:\nproto.w = proto.write;\nproto.___endElement = proto.endElement;\n\nmodule.exports = AsyncStream;\n\nfunction getNonMarkoStack(error) {\n return error.stack\n .toString()\n .split(\"\\n\")\n .slice(1)\n .filter(line => !/\\/node_modules\\/marko\\//.test(line))\n .join(\"\\n\");\n}\n"],"file":"AsyncStream.js"}
1
+ {"version":3,"sources":["../../../src/runtime/html/AsyncStream.js"],"names":["EventEmitter","require","StringWriter","BufferedWriter","RenderResult","attrsHelper","markoAttr","escapeXmlHelper","parseHTML","escapeXmlOrNullish","x","escapeXmlString","selfClosingTags","noop","voidWriter","write","script","merge","clear","get","toString","State","root","stream","writer","events","finished","escapeEndingComment","text","replace","AsyncStream","global","parentOut","Error","finalGlobal","attributes","originalStream","state","_state","on","runtimeId","_ended","_remaining","_lastCount","_last","undefined","_parentOut","data","_sync","_stack","name","_timeoutId","_node","_elStack","DEFAULT_TIMEOUT","INCLUDE_STACK","process","env","NODE_ENV","enableAsyncStackTrace","proto","prototype","constructor","window","document","sync","isSync","str","getOutput","_result","beginAsync","options","currentWriter","newWriter","newStream","next","timeout","last","getNonMarkoStack","setTimeout","error","emit","out","_doFinish","end","remaining","_flushNext","_emitLast","timeoutId","clearTimeout","_handleChildDone","childOut","nextWriter","nextStream","event","callback","onLast","once","lastArray","push","i","length","lastCallback","type","arg","arguments","apply","removeListener","prependListener","pipe","e","stack","JSON","stringify","message","flush","scheduleFlush","createOut","newOut","bind","tagName","elementAttrs","key","componentDef","props","voidElements","indexOf","svgElements","element","openTagOnly","beginElement","endElement","pop","comment","bf","component","preserve","ef","host","node","nextEl","fragment","html","doc","ownerDocument","nextSibling","createDocumentFragment","appendChild","then","fn","fnErr","promise","Promise","resolve","reject","result","catch","c","customEvents","w","module","exports","split","slice","filter","line","test","join"],"mappings":"AAAA;AACA,IAAIA,YAAY,GAAGC,OAAO,CAAC,cAAD,CAA1B;AACA,IAAIC,YAAY,GAAGD,OAAO,CAAC,gBAAD,CAA1B;AACA,IAAIE,cAAc,GAAGF,OAAO,CAAC,kBAAD,CAA5B;AACA,IAAIG,YAAY,GAAGH,OAAO,CAAC,iBAAD,CAA1B;AACA,IAAII,WAAW,GAAGJ,OAAO,CAAC,iBAAD,CAAzB;AACA,IAAIK,SAAS,GAAGL,OAAO,CAAC,sBAAD,CAAvB;AACA,IAAIM,eAAe,GAAGN,OAAO,CAAC,sBAAD,CAA7B;AACA,IAAIO,SAAS,GAAGP,OAAO,CAAC,oBAAD,CAAvB;AACA,IAAIQ,kBAAkB,GAAGF,eAAe,CAACG,CAAzC;AACA,IAAIC,eAAe,GAAGJ,eAAe,IAArC;AACA,IAAIK,eAAe,GAAGX,OAAO,CAAC,mBAAD,CAA7B;;AAEA,SAASY,IAAT,GAAgB,CAAE;;AAElB,IAAIC,UAAU,GAAG;AACfC,EAAAA,KAAK,EAAEF,IADQ;AAEfG,EAAAA,MAAM,EAAEH,IAFO;AAGfI,EAAAA,KAAK,EAAEJ,IAHQ;AAIfK,EAAAA,KAAK,EAAEL,IAJQ;AAKfM,EAAAA,GAAG,EAAE,YAAY;AACf,WAAO,EAAP;AACD,GAPc;AAQfC,EAAAA,QAAQ,EAAE,YAAY;AACpB,WAAO,EAAP;AACD,GAVc,EAAjB;;;AAaA,SAASC,KAAT,CA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yBH,IAAzB,CAA8BC,EAA9B,EAAkCC,KAAlC,CAAP;AACD,GAphBkC;;AAshBnCM,EAAAA,KAAK,EAAE,UAAUN,KAAV,EAAiB;AACtB,WAAO,KAAKF,IAAL,CAAUvG,SAAV,EAAqByG,KAArB,CAAP;AACD,GAxhBkC;;AA0hBnCO,EAAAA,CAAC,EAAE,UAAUlC,YAAV,EAAwBD,GAAxB,EAA6BoC,YAA7B,EAA2C;AAC5C,cAA+BnC,YAA/B;AACA,cAAsBD,GAAtB;AACA,eAA+BoC,YAA/B;AACD,GA9hBkC,EAArC;;;AAiiBA;AACAlG,KAAK,CAACmG,CAAN,GAAUnG,KAAK,CAAC7C,KAAhB;AACA6C,KAAK,IAAL,GAAsBA,KAAK,CAACuE,UAA5B;;AAEA6B,MAAM,CAACC,OAAP,GAAiBnI,WAAjB;;AAEA,SAASgD,gBAAT,CAA0BE,KAA1B,EAAiC;AAC/B,SAAOA,KAAK,CAAC+B,KAAN;AACJ3F,EAAAA,QADI;AAEJ8I,EAAAA,KAFI,CAEE,IAFF;AAGJC,EAAAA,KAHI,CAGE,CAHF;AAIJC,EAAAA,MAJI,CAIG,CAAAC,IAAI,KAAI,CAAC,0BAA0BC,IAA1B,CAA+BD,IAA/B,CAJZ;AAKJE,EAAAA,IALI,CAKC,IALD,CAAP;AAMD","sourcesContent":["\"use strict\";\nvar EventEmitter = require(\"events-light\");\nvar StringWriter = require(\"./StringWriter\");\nvar BufferedWriter = require(\"./BufferedWriter\");\nvar RenderResult = require(\"../RenderResult\");\nvar attrsHelper = require(\"./helpers/attrs\");\nvar markoAttr = require(\"./helpers/data-marko\");\nvar escapeXmlHelper = require(\"./helpers/escape-xml\");\nvar parseHTML = require(\"../vdom/parse-html\");\nvar escapeXmlOrNullish = escapeXmlHelper.x;\nvar escapeXmlString = escapeXmlHelper.___escapeXML;\nvar selfClosingTags = require(\"self-closing-tags\");\n\nfunction noop() {}\n\nvar voidWriter = {\n write: noop,\n script: noop,\n merge: noop,\n clear: noop,\n get: function () {\n return [];\n },\n toString: function () {\n return \"\";\n }\n};\n\nfunction State(root, stream, writer, events) {\n this.root = root;\n this.stream = stream;\n this.writer = writer;\n this.events = events;\n\n this.finished = false;\n}\n\nfunction escapeEndingComment(text) {\n return text.replace(/-->/g, \"--&gt;\");\n}\n\nfunction AsyncStream(global, writer, parentOut) {\n if (parentOut === null) {\n throw new Error(\"illegal state\");\n }\n var finalGlobal = (this.attributes = global || {});\n var originalStream;\n var state;\n\n if (parentOut) {\n state = parentOut._state;\n originalStream = state.stream;\n } else {\n var events = (finalGlobal.events /* deprecated */ =\n writer && writer.on ? writer : new EventEmitter());\n\n if (writer) {\n originalStream = writer;\n writer = new BufferedWriter(writer);\n } else {\n writer = originalStream = new StringWriter();\n }\n\n state = new State(this, originalStream, writer, events);\n writer.state = state;\n }\n\n finalGlobal.runtimeId = finalGlobal.runtimeId || \"M\";\n this.global = finalGlobal;\n this.stream = originalStream;\n this._state = state;\n\n this._ended = false;\n this._remaining = 1;\n this._lastCount = 0;\n this._last = undefined; // Array\n this._parentOut = parentOut;\n\n this.data = {};\n this.writer = writer;\n writer.stream = this;\n\n this._sync = false;\n this._stack = undefined;\n this.name = undefined;\n this._timeoutId = undefined;\n\n this._node = undefined;\n\n this._elStack = undefined; // Array\n\n this.___components = null; // ComponentsContext\n\n this.___assignedComponentDef = null;\n this.___assignedKey = null;\n this.___assignedCustomEvents = null;\n this.___isLast = false;\n}\n\nAsyncStream.DEFAULT_TIMEOUT = 10000;\n\n/**\n * If set to `true`, AsyncStream errors will include the full stack trace\n */\nAsyncStream.INCLUDE_STACK =\n typeof process !== \"undefined\" &&\n (!process.env.NODE_ENV ||\n process.env.NODE_ENV === \"development\" ||\n process.env.NODE_ENV === \"dev\");\n\nAsyncStream.enableAsyncStackTrace = function () {\n AsyncStream.INCLUDE_STACK = true;\n};\n\nvar proto = (AsyncStream.prototype = {\n constructor: AsyncStream,\n ___host: typeof window === \"object\" && document,\n ___isOut: true,\n\n sync: function () {\n this._sync = true;\n },\n\n isSync: function () {\n return this._sync === true;\n },\n\n write: function (str) {\n if (str != null) {\n this.writer.write(str.toString());\n }\n return this;\n },\n\n script: function (str) {\n if (str != null) {\n this.writer.script(str.toString());\n }\n return this;\n },\n\n ___getOutput: function () {\n return this._state.writer.toString();\n },\n\n /**\n * Legacy...\n */\n getOutput: function () {\n return this.___getOutput();\n },\n\n toString: function () {\n return this._state.writer.toString();\n },\n\n ___getResult: function () {\n this._result = this._result || new RenderResult(this);\n return this._result;\n },\n\n beginAsync: function (options) {\n if (this._sync) {\n throw new Error(\"beginAsync() not allowed when using renderSync()\");\n }\n\n var state = this._state;\n\n var currentWriter = this.writer;\n\n /* ┏━━━━━┓ this\n ┃ WAS ┃ ↓↑\n ┗━━━━━┛ prevWriter → currentWriter → nextWriter */\n\n var newWriter = new StringWriter();\n var newStream = new AsyncStream(this.global, currentWriter, this);\n newWriter.state = state;\n\n this.writer = newWriter;\n newWriter.stream = this;\n\n newWriter.next = currentWriter.next;\n currentWriter.next = newWriter;\n\n /* ┏━━━━━┓ newStream this\n ┃ NOW ┃ ↓↑ ↓↑\n ┗━━━━━┛ prevWriter → currentWriter → newWriter → nextWriter */\n\n var timeout;\n var name;\n\n this._remaining++;\n\n if (options != null) {\n if (typeof options === \"number\") {\n timeout = options;\n } else {\n timeout = options.timeout;\n\n if (options.last === true) {\n if (timeout == null) {\n // Don't assign a timeout to last flush fragments\n // unless it is explicitly given a timeout\n timeout = 0;\n }\n\n this._lastCount++;\n newStream.___isLast = true;\n }\n\n name = options.name;\n }\n }\n\n if (timeout == null) {\n timeout = AsyncStream.DEFAULT_TIMEOUT;\n }\n\n newStream._stack = AsyncStream.INCLUDE_STACK\n ? getNonMarkoStack(new Error())\n : null;\n newStream.name = name;\n\n if (timeout > 0) {\n newStream._timeoutId = setTimeout(function () {\n newStream.error(\n new Error(\n \"Async fragment \" +\n (name ? \"(\" + name + \") \" : \"\") +\n \"timed out after \" +\n timeout +\n \"ms\"\n )\n );\n }, timeout);\n }\n\n state.events.emit(\"beginAsync\", {\n out: newStream,\n parentOut: this\n });\n\n return newStream;\n },\n\n _doFinish: function () {\n var state = this._state;\n\n state.finished = true;\n\n if (state.writer.end) {\n state.writer.end();\n } else {\n state.events.emit(\"finish\", this.___getResult());\n }\n },\n\n end: function (data) {\n if (this._ended === true) {\n return;\n }\n\n this._ended = true;\n\n var remaining = --this._remaining;\n\n if (data != null) {\n this.write(data);\n }\n\n var currentWriter = this.writer;\n\n /* ┏━━━━━┓ this nextStream\n ┃ WAS ┃ ↓↑ ↓↑\n ┗━━━━━┛ currentWriter → nextWriter → futureWriter */\n\n // Prevent any more writes to the current steam\n this.writer = voidWriter;\n currentWriter.stream = null;\n\n // Flush the contents of nextWriter to the currentWriter\n this._flushNext(currentWriter);\n\n /* ┏━━━━━┓ this ╵ nextStream\n ┃ ┃ ↓ ╵ ↓↑\n ┃ NOW ┃ voidWriter ╵ currentWriter → futureWriter\n ┃ ┃ ──────────────┴────────────────────────────────\n ┗━━━━━┛ Flushed & garbage collected: nextWriter */\n\n var parentOut = this._parentOut;\n\n if (parentOut === undefined) {\n if (remaining === 0) {\n this._doFinish();\n } else if (remaining - this._lastCount === 0) {\n this._emitLast();\n }\n } else {\n var timeoutId = this._timeoutId;\n\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n\n if (remaining === 0) {\n parentOut._handleChildDone(this);\n } else if (remaining - this._lastCount === 0) {\n this._emitLast();\n }\n }\n\n return this;\n },\n\n _handleChildDone: function (childOut) {\n var remaining = --this._remaining;\n\n if (remaining === 0) {\n var parentOut = this._parentOut;\n if (parentOut === undefined) {\n this._doFinish();\n } else {\n parentOut._handleChildDone(this);\n }\n } else {\n if (childOut.___isLast) {\n this._lastCount--;\n }\n\n if (remaining - this._lastCount === 0) {\n this._emitLast();\n }\n }\n },\n\n _flushNext: function (currentWriter) {\n // It is possible that currentWriter is the\n // last writer in the chain, so let's make\n // sure there is a nextWriter to flush.\n var nextWriter = currentWriter.next;\n if (nextWriter) {\n // Flush the contents of nextWriter\n // to the currentWriter\n currentWriter.merge(nextWriter);\n\n // Remove nextWriter from the chain.\n // It has been flushed and can now be\n // garbage collected.\n currentWriter.next = nextWriter.next;\n\n // It's possible that nextWriter is the last\n // writer in the chain and its stream already\n // ended, so let's make sure nextStream exists.\n var nextStream = nextWriter.stream;\n if (nextStream) {\n // Point the nextStream to currentWriter\n nextStream.writer = currentWriter;\n currentWriter.stream = nextStream;\n }\n }\n },\n\n on: function (event, callback) {\n var state = this._state;\n\n if (event === \"finish\" && state.finished === true) {\n callback(this.___getResult());\n } else if (event === \"last\") {\n this.onLast(callback);\n } else {\n state.events.on(event, callback);\n }\n\n return this;\n },\n\n once: function (event, callback) {\n var state = this._state;\n\n if (event === \"finish\" && state.finished === true) {\n callback(this.___getResult());\n } else if (event === \"last\") {\n this.onLast(callback);\n } else {\n state.events.once(event, callback);\n }\n\n return this;\n },\n\n onLast: function (callback) {\n var lastArray = this._last;\n\n if (lastArray === undefined) {\n this._last = [callback];\n } else {\n lastArray.push(callback);\n }\n\n return this;\n },\n\n _emitLast: function () {\n if (this._last) {\n var i = 0;\n var lastArray = this._last;\n this._last = undefined;\n (function next() {\n if (i === lastArray.length) {\n return;\n }\n var lastCallback = lastArray[i++];\n lastCallback(next);\n\n if (lastCallback.length === 0) {\n next();\n }\n })();\n }\n },\n\n emit: function (type, arg) {\n var events = this._state.events;\n switch (arguments.length) {\n case 1:\n events.emit(type);\n break;\n case 2:\n events.emit(type, arg);\n break;\n default:\n events.emit.apply(events, arguments);\n break;\n }\n return this;\n },\n\n removeListener: function () {\n var events = this._state.events;\n events.removeListener.apply(events, arguments);\n return this;\n },\n\n prependListener: function () {\n var events = this._state.events;\n events.prependListener.apply(events, arguments);\n return this;\n },\n\n pipe: function (stream) {\n this._state.stream.pipe(stream);\n return this;\n },\n\n error: function (e) {\n var name = this.name;\n var stack = this._stack;\n\n if (!(e instanceof Error)) {\n e = new Error(JSON.stringify(e));\n }\n\n if (name || stack) {\n e.message +=\n \"\\nRendered by\" +\n (name ? \" \" + name : \"\") +\n (stack ? \":\\n\" + stack : \"\");\n }\n try {\n this.emit(\"error\", e);\n } finally {\n // If there is no listener for the error event then it will\n // throw a new here. In order to ensure that the async fragment\n // is still properly ended we need to put the end() in a `finally`\n // block\n this.end();\n }\n\n return this;\n },\n\n flush: function () {\n var state = this._state;\n\n if (!state.finished) {\n var writer = state.writer;\n if (writer && writer.scheduleFlush) {\n writer.scheduleFlush();\n }\n }\n return this;\n },\n\n createOut: function () {\n var newOut = new AsyncStream(this.global);\n // Forward error events to the parent out.\n newOut.on(\"error\", this.emit.bind(this, \"error\"));\n this._state.events.emit(\"beginDetachedAsync\", {\n out: newOut,\n parentOut: this\n });\n return newOut;\n },\n\n ___elementDynamic: function (\n tagName,\n elementAttrs,\n key,\n componentDef,\n props\n ) {\n var str =\n \"<\" +\n tagName +\n markoAttr(this, componentDef, props, key) +\n attrsHelper(elementAttrs);\n\n if (selfClosingTags.voidElements.indexOf(tagName) !== -1) {\n str += \">\";\n } else if (selfClosingTags.svgElements.indexOf(tagName) !== -1) {\n str += \"/>\";\n } else {\n str += \"></\" + tagName + \">\";\n }\n\n this.write(str);\n },\n\n element: function (tagName, elementAttrs, openTagOnly) {\n var str = \"<\" + tagName + attrsHelper(elementAttrs) + \">\";\n\n if (openTagOnly !== true) {\n str += \"</\" + tagName + \">\";\n }\n\n this.write(str);\n },\n\n ___beginElementDynamic: function (\n name,\n elementAttrs,\n key,\n componentDef,\n props\n ) {\n var str =\n \"<\" +\n name +\n markoAttr(this, componentDef, props, key) +\n attrsHelper(elementAttrs) +\n \">\";\n\n this.write(str);\n\n if (this._elStack) {\n this._elStack.push(name);\n } else {\n this._elStack = [name];\n }\n },\n\n beginElement: function (name, elementAttrs) {\n var str = \"<\" + name + attrsHelper(elementAttrs) + \">\";\n\n this.write(str);\n\n if (this._elStack) {\n this._elStack.push(name);\n } else {\n this._elStack = [name];\n }\n },\n\n endElement: function () {\n var tagName = this._elStack.pop();\n this.write(\"</\" + tagName + \">\");\n },\n\n comment: function (str) {\n this.write(\"<!--\" + escapeEndingComment(str) + \"-->\");\n },\n\n text: function (str) {\n this.write(escapeXmlOrNullish(str));\n },\n\n bf: function (key, component, preserve) {\n if (preserve) {\n this.write(\"<!--F#\" + escapeXmlString(key) + \"-->\");\n }\n if (this._elStack) {\n this._elStack.push(preserve);\n } else {\n this._elStack = [preserve];\n }\n },\n\n ef: function () {\n var preserve = this._elStack.pop();\n if (preserve) {\n this.write(\"<!--F/-->\");\n }\n },\n\n ___getNode: function (host) {\n var node = this._node;\n\n if (!node) {\n var nextEl;\n var fragment;\n var html = this.___getOutput();\n if (!host) host = this.___host;\n var doc = host.ownerDocument || host;\n\n if (html) {\n node = parseHTML(html);\n\n if (node && node.nextSibling) {\n // If there are multiple nodes, turn it into a document fragment.\n fragment = doc.createDocumentFragment();\n\n do {\n nextEl = node.nextSibling;\n fragment.appendChild(node);\n } while ((node = nextEl));\n\n node = fragment;\n }\n }\n\n // if HTML is empty use empty document fragment (so that we're returning a valid DOM node)\n this._node = node || doc.createDocumentFragment();\n }\n return node;\n },\n\n then: function (fn, fnErr) {\n var out = this;\n var promise = new Promise(function (resolve, reject) {\n out.on(\"error\", reject);\n out.on(\"finish\", function (result) {\n resolve(result);\n });\n });\n\n return Promise.resolve(promise).then(fn, fnErr);\n },\n\n catch: function (fnErr) {\n return this.then(undefined, fnErr);\n },\n\n c: function (componentDef, key, customEvents) {\n this.___assignedComponentDef = componentDef;\n this.___assignedKey = key;\n this.___assignedCustomEvents = customEvents;\n }\n});\n\n// alias:\nproto.w = proto.write;\nproto.___endElement = proto.endElement;\n\nmodule.exports = AsyncStream;\n\nfunction getNonMarkoStack(error) {\n return error.stack\n .toString()\n .split(\"\\n\")\n .slice(1)\n .filter(line => !/\\/node_modules\\/marko\\//.test(line))\n .join(\"\\n\");\n}\n"],"file":"AsyncStream.js"}