@kamen/create-webapp 1.0.22 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/index.js +23 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @kamen/create-webapp <a href="https://npmjs.com/package/@kamen/create-webapp"><img src="https://img.shields.io/npm/v/@kamen/create-webapp" alt="npm package"></a>
1
+ # @kamen/create-webapp [![npm](https://img.shields.io/npm/v/@kamen/create-webapp)](https://npmjs.com/package/@kamen/create-webapp) [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@kamen/create-webapp/badge?style=rounded)](https://www.jsdelivr.com/package/npm/@kamen/create-webapp)
2
2
 
3
3
  ## Project Scaffolding (wip)
4
4
 
package/index.js CHANGED
@@ -175,4 +175,27 @@ export function createResourceStyle(code, container = document.head) {
175
175
  */
176
176
  export function createResourceIframe(code, container = document.body) {
177
177
  return createResourceTag(code, 'iframe', 'src', 'text/html', container);
178
+ }
179
+
180
+ /**
181
+ * @param {number} [version=2]
182
+ * @param {Node} [root=document]
183
+ * @param {string} [hook='__VUE_DEVTOOLS_GLOBAL_HOOK__']
184
+ * @returns {Element|string}
185
+ */
186
+ export function findVue(version = 2, root = document, hook = '__VUE_DEVTOOLS_GLOBAL_HOOK__') {
187
+ let element;
188
+ const property = version === 2 ? '__vue__' : '__vue_app__';
189
+ const treeWalker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT);
190
+
191
+ while (element = treeWalker.nextNode())
192
+ if (property in element) {
193
+ const {[property]: app} = element;
194
+ const {config} = version === 2 ? app.constructor : app;
195
+ config.devtools = true;
196
+ if (hook in window) window[hook].Vue = app.constructor;
197
+ return app;
198
+ }
199
+
200
+ return 'Vue mountpoint not found';
178
201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kamen/create-webapp",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "npm init @kamen/webapp",
5
5
  "homepage": "https://www.npmjs.com/package/@kamen/create-webapp",
6
6
  "license": "GPL-2.0-only",