@wordpress/block-library 8.13.0 → 8.14.0
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.
- package/CHANGELOG.md +2 -0
- package/build/archives/index.js +5 -1
- package/build/archives/index.js.map +1 -1
- package/build/audio/index.js +5 -1
- package/build/audio/index.js.map +1 -1
- package/build/avatar/index.js +1 -1
- package/build/block/edit.js +1 -1
- package/build/block/edit.js.map +1 -1
- package/build/block/edit.native.js +6 -9
- package/build/block/edit.native.js.map +1 -1
- package/build/buttons/edit.js +5 -1
- package/build/buttons/edit.js.map +1 -1
- package/build/categories/index.js +5 -1
- package/build/categories/index.js.map +1 -1
- package/build/code/index.js +5 -1
- package/build/code/index.js.map +1 -1
- package/build/column/index.js +1 -0
- package/build/column/index.js.map +1 -1
- package/build/comments/index.js +1 -0
- package/build/comments/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +2 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/index.js +1 -0
- package/build/cover/index.js.map +1 -1
- package/build/details/index.js +5 -1
- package/build/details/index.js.map +1 -1
- package/build/embed/util.js +9 -8
- package/build/embed/util.js.map +1 -1
- package/build/file/index.js +2 -1
- package/build/file/index.js.map +1 -1
- package/build/file/view.js +15 -1
- package/build/file/view.js.map +1 -1
- package/build/gallery/index.js +3 -1
- package/build/gallery/index.js.map +1 -1
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/index.js +5 -1
- package/build/heading/index.js.map +1 -1
- package/build/heading/transforms.js +5 -1
- package/build/heading/transforms.js.map +1 -1
- package/build/image/deprecated.js +453 -175
- package/build/image/deprecated.js.map +1 -1
- package/build/image/edit.js +0 -4
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +96 -43
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +6 -0
- package/build/image/index.js.map +1 -1
- package/build/image/save.js +8 -1
- package/build/image/save.js.map +1 -1
- package/build/image/utils.js +18 -0
- package/build/image/utils.js.map +1 -1
- package/build/image/{interactivity.js → view-interactivity.js} +86 -44
- package/build/image/view-interactivity.js.map +1 -0
- package/build/index.js +12 -3
- package/build/index.js.map +1 -1
- package/build/list/index.js +5 -1
- package/build/list/index.js.map +1 -1
- package/build/list-item/utils.js +6 -1
- package/build/list-item/utils.js.map +1 -1
- package/build/media-text/index.js +1 -0
- package/build/media-text/index.js.map +1 -1
- package/build/missing/edit.js +22 -8
- package/build/missing/edit.js.map +1 -1
- package/build/navigation/edit/index.js +1 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +0 -1
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build/navigation/index.js +3 -2
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/view.js +174 -50
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/edit.js +0 -11
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/link-ui.js +12 -2
- package/build/navigation-link/link-ui.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +3 -3
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/page-list/edit.js +34 -39
- package/build/page-list/edit.js.map +1 -1
- package/build/page-list/use-convert-to-navigation-links.js +2 -15
- package/build/page-list/use-convert-to-navigation-links.js.map +1 -1
- package/build/paragraph/index.js +1 -0
- package/build/paragraph/index.js.map +1 -1
- package/build/paragraph/transforms.js +1 -0
- package/build/paragraph/transforms.js.map +1 -1
- package/build/post-comments-form/index.js +1 -0
- package/build/post-comments-form/index.js.map +1 -1
- package/build/post-navigation-link/index.js +1 -0
- package/build/post-navigation-link/index.js.map +1 -1
- package/build/post-time-to-read/index.js +5 -1
- package/build/post-time-to-read/index.js.map +1 -1
- package/build/query-pagination-numbers/index.js +1 -1
- package/build/quote/index.js +1 -0
- package/build/quote/index.js.map +1 -1
- package/build/site-logo/index.js +5 -1
- package/build/site-logo/index.js.map +1 -1
- package/build/site-tagline/icon.js +1 -1
- package/build/site-tagline/icon.js.map +1 -1
- package/build/site-tagline/index.js +5 -1
- package/build/site-tagline/index.js.map +1 -1
- package/build/site-title/index.js +5 -1
- package/build/site-title/index.js.map +1 -1
- package/build/social-links/index.js +3 -1
- package/build/social-links/index.js.map +1 -1
- package/build/table/index.js +5 -1
- package/build/table/index.js.map +1 -1
- package/build/term-description/index.js +1 -0
- package/build/term-description/index.js.map +1 -1
- package/build/verse/index.js +5 -1
- package/build/verse/index.js.map +1 -1
- package/build/video/deprecated.js +5 -1
- package/build/video/deprecated.js.map +1 -1
- package/build/video/index.js +5 -1
- package/build/video/index.js.map +1 -1
- package/build-module/archives/index.js +5 -1
- package/build-module/archives/index.js.map +1 -1
- package/build-module/audio/index.js +5 -1
- package/build-module/audio/index.js.map +1 -1
- package/build-module/avatar/index.js +1 -1
- package/build-module/block/edit.js +1 -1
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/edit.native.js +7 -9
- package/build-module/block/edit.native.js.map +1 -1
- package/build-module/buttons/edit.js +5 -1
- package/build-module/buttons/edit.js.map +1 -1
- package/build-module/categories/index.js +5 -1
- package/build-module/categories/index.js.map +1 -1
- package/build-module/code/index.js +5 -1
- package/build-module/code/index.js.map +1 -1
- package/build-module/column/index.js +1 -0
- package/build-module/column/index.js.map +1 -1
- package/build-module/comments/index.js +1 -0
- package/build-module/comments/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +2 -1
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/index.js +1 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/details/index.js +5 -1
- package/build-module/details/index.js.map +1 -1
- package/build-module/embed/util.js +6 -6
- package/build-module/embed/util.js.map +1 -1
- package/build-module/file/index.js +2 -1
- package/build-module/file/index.js.map +1 -1
- package/build-module/file/view.js +15 -2
- package/build-module/file/view.js.map +1 -1
- package/build-module/gallery/index.js +3 -1
- package/build-module/gallery/index.js.map +1 -1
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/index.js +5 -1
- package/build-module/heading/index.js.map +1 -1
- package/build-module/heading/transforms.js +5 -1
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/image/deprecated.js +454 -176
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/edit.js +0 -4
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +96 -46
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +6 -0
- package/build-module/image/index.js.map +1 -1
- package/build-module/image/save.js +8 -1
- package/build-module/image/save.js.map +1 -1
- package/build-module/image/utils.js +16 -0
- package/build-module/image/utils.js.map +1 -1
- package/build-module/image/{interactivity.js → view-interactivity.js} +86 -44
- package/build-module/image/view-interactivity.js.map +1 -0
- package/build-module/index.js +12 -3
- package/build-module/index.js.map +1 -1
- package/build-module/list/index.js +5 -1
- package/build-module/list/index.js.map +1 -1
- package/build-module/list-item/utils.js +6 -1
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/media-text/index.js +1 -0
- package/build-module/media-text/index.js.map +1 -1
- package/build-module/missing/edit.js +22 -8
- package/build-module/missing/edit.js.map +1 -1
- package/build-module/navigation/edit/index.js +1 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +0 -1
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build-module/navigation/index.js +3 -2
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/view.js +173 -50
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/edit.js +1 -12
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/link-ui.js +13 -3
- package/build-module/navigation-link/link-ui.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +3 -3
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/page-list/edit.js +34 -39
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/page-list/use-convert-to-navigation-links.js +3 -16
- package/build-module/page-list/use-convert-to-navigation-links.js.map +1 -1
- package/build-module/paragraph/index.js +1 -0
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/paragraph/transforms.js +1 -0
- package/build-module/paragraph/transforms.js.map +1 -1
- package/build-module/post-comments-form/index.js +1 -0
- package/build-module/post-comments-form/index.js.map +1 -1
- package/build-module/post-navigation-link/index.js +1 -0
- package/build-module/post-navigation-link/index.js.map +1 -1
- package/build-module/post-time-to-read/index.js +5 -1
- package/build-module/post-time-to-read/index.js.map +1 -1
- package/build-module/query-pagination-numbers/index.js +1 -1
- package/build-module/quote/index.js +1 -0
- package/build-module/quote/index.js.map +1 -1
- package/build-module/site-logo/index.js +5 -1
- package/build-module/site-logo/index.js.map +1 -1
- package/build-module/site-tagline/icon.js +1 -1
- package/build-module/site-tagline/icon.js.map +1 -1
- package/build-module/site-tagline/index.js +5 -1
- package/build-module/site-tagline/index.js.map +1 -1
- package/build-module/site-title/index.js +5 -1
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/social-links/index.js +3 -1
- package/build-module/social-links/index.js.map +1 -1
- package/build-module/table/index.js +5 -1
- package/build-module/table/index.js.map +1 -1
- package/build-module/term-description/index.js +1 -0
- package/build-module/term-description/index.js.map +1 -1
- package/build-module/verse/index.js +5 -1
- package/build-module/verse/index.js.map +1 -1
- package/build-module/video/deprecated.js +5 -1
- package/build-module/video/deprecated.js.map +1 -1
- package/build-module/video/index.js +5 -1
- package/build-module/video/index.js.map +1 -1
- package/build-style/footnotes/style-rtl.css +2 -2
- package/build-style/footnotes/style.css +2 -2
- package/build-style/image/style-rtl.css +16 -2
- package/build-style/image/style.css +16 -2
- package/build-style/style-rtl.css +18 -4
- package/build-style/style.css +18 -4
- package/package.json +33 -38
- package/src/archives/block.json +5 -1
- package/src/audio/block.json +5 -1
- package/src/avatar/block.json +1 -1
- package/src/block/edit.js +2 -2
- package/src/block/edit.native.js +8 -12
- package/src/block/test/edit.native.js +4 -4
- package/src/buttons/edit.js +2 -2
- package/src/categories/block.json +5 -1
- package/src/code/block.json +5 -1
- package/src/column/block.json +1 -0
- package/src/comments/block.json +1 -0
- package/src/cover/block.json +1 -0
- package/src/cover/edit/inspector-controls.js +1 -0
- package/src/details/block.json +5 -1
- package/src/embed/util.js +4 -6
- package/src/file/block.json +2 -1
- package/src/file/index.php +0 -17
- package/src/file/view.js +14 -5
- package/src/footnotes/index.php +11 -9
- package/src/footnotes/style.scss +2 -2
- package/src/gallery/block.json +3 -1
- package/src/group/block.json +1 -0
- package/src/heading/block.json +5 -1
- package/src/heading/test/index.native.js +18 -0
- package/src/image/block.json +6 -0
- package/src/image/deprecated.js +597 -320
- package/src/image/edit.js +0 -4
- package/src/image/image.js +131 -62
- package/src/image/save.js +9 -1
- package/src/image/style.scss +15 -2
- package/src/image/utils.js +16 -0
- package/src/image/{interactivity.js → view-interactivity.js} +99 -50
- package/src/index.js +18 -1
- package/src/latest-posts/index.php +1 -1
- package/src/list/block.json +5 -1
- package/src/media-text/block.json +1 -0
- package/src/missing/edit.js +31 -11
- package/src/navigation/block.json +3 -2
- package/src/navigation/edit/index.js +1 -2
- package/src/navigation/edit/menu-inspector-controls.js +0 -1
- package/src/navigation/index.php +39 -30
- package/src/navigation/view.js +189 -67
- package/src/navigation-link/edit.js +1 -15
- package/src/navigation-link/link-ui.js +14 -2
- package/src/navigation-submenu/index.php +2 -12
- package/src/page-list/convert-to-links-modal.js +3 -3
- package/src/page-list/edit.js +65 -62
- package/src/page-list/use-convert-to-navigation-links.js +3 -20
- package/src/paragraph/block.json +1 -0
- package/src/post-comments-form/block.json +1 -0
- package/src/post-navigation-link/block.json +1 -0
- package/src/post-time-to-read/block.json +5 -1
- package/src/query-pagination-numbers/block.json +1 -1
- package/src/quote/block.json +1 -0
- package/src/site-logo/block.json +5 -1
- package/src/site-tagline/block.json +5 -1
- package/src/site-tagline/icon.js +1 -1
- package/src/site-title/block.json +5 -1
- package/src/social-links/block.json +3 -1
- package/src/table/block.json +5 -1
- package/src/term-description/block.json +1 -0
- package/src/verse/block.json +5 -1
- package/src/video/block.json +5 -1
- package/build/file/interactivity.js +0 -19
- package/build/file/interactivity.js.map +0 -1
- package/build/heading/heading-level-icon.js +0 -61
- package/build/heading/heading-level-icon.js.map +0 -1
- package/build/image/interactivity.js.map +0 -1
- package/build/navigation/interactivity.js +0 -167
- package/build/navigation/interactivity.js.map +0 -1
- package/build/navigation/view-modal.js +0 -64
- package/build/navigation/view-modal.js.map +0 -1
- package/build/utils/interactivity/constants.js +0 -9
- package/build/utils/interactivity/constants.js.map +0 -1
- package/build/utils/interactivity/directives.js +0 -222
- package/build/utils/interactivity/directives.js.map +0 -1
- package/build/utils/interactivity/hooks.js +0 -159
- package/build/utils/interactivity/hooks.js.map +0 -1
- package/build/utils/interactivity/hydration.js +0 -34
- package/build/utils/interactivity/hydration.js.map +0 -1
- package/build/utils/interactivity/index.js +0 -32
- package/build/utils/interactivity/index.js.map +0 -1
- package/build/utils/interactivity/portals.js +0 -108
- package/build/utils/interactivity/portals.js.map +0 -1
- package/build/utils/interactivity/store.js +0 -66
- package/build/utils/interactivity/store.js.map +0 -1
- package/build/utils/interactivity/utils.js +0 -87
- package/build/utils/interactivity/utils.js.map +0 -1
- package/build/utils/interactivity/vdom.js +0 -119
- package/build/utils/interactivity/vdom.js.map +0 -1
- package/build-module/file/interactivity.js +0 -15
- package/build-module/file/interactivity.js.map +0 -1
- package/build-module/heading/heading-level-icon.js +0 -53
- package/build-module/heading/heading-level-icon.js.map +0 -1
- package/build-module/image/interactivity.js.map +0 -1
- package/build-module/navigation/interactivity.js +0 -164
- package/build-module/navigation/interactivity.js.map +0 -1
- package/build-module/navigation/view-modal.js +0 -58
- package/build-module/navigation/view-modal.js.map +0 -1
- package/build-module/utils/interactivity/constants.js +0 -2
- package/build-module/utils/interactivity/constants.js.map +0 -1
- package/build-module/utils/interactivity/directives.js +0 -209
- package/build-module/utils/interactivity/directives.js.map +0 -1
- package/build-module/utils/interactivity/hooks.js +0 -145
- package/build-module/utils/interactivity/hooks.js.map +0 -1
- package/build-module/utils/interactivity/hydration.js +0 -21
- package/build-module/utils/interactivity/hydration.js.map +0 -1
- package/build-module/utils/interactivity/index.js +0 -15
- package/build-module/utils/interactivity/index.js.map +0 -1
- package/build-module/utils/interactivity/portals.js +0 -100
- package/build-module/utils/interactivity/portals.js.map +0 -1
- package/build-module/utils/interactivity/store.js +0 -55
- package/build-module/utils/interactivity/store.js.map +0 -1
- package/build-module/utils/interactivity/utils.js +0 -75
- package/build-module/utils/interactivity/utils.js.map +0 -1
- package/build-module/utils/interactivity/vdom.js +0 -107
- package/build-module/utils/interactivity/vdom.js.map +0 -1
- package/src/file/interactivity.js +0 -15
- package/src/heading/heading-level-icon.js +0 -48
- package/src/navigation/interactivity.js +0 -169
- package/src/navigation/view-modal.js +0 -78
- package/src/utils/interactivity/constants.js +0 -1
- package/src/utils/interactivity/directives.js +0 -200
- package/src/utils/interactivity/hooks.js +0 -145
- package/src/utils/interactivity/hydration.js +0 -22
- package/src/utils/interactivity/index.js +0 -15
- package/src/utils/interactivity/portals.js +0 -98
- package/src/utils/interactivity/store.js +0 -45
- package/src/utils/interactivity/utils.js +0 -66
- package/src/utils/interactivity/vdom.js +0 -111
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.directive = void 0;
|
|
7
|
-
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
|
-
var _preact = require("preact");
|
|
11
|
-
|
|
12
|
-
var _hooks = require("preact/hooks");
|
|
13
|
-
|
|
14
|
-
var _store = require("./store");
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* External dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Internal dependencies
|
|
22
|
-
*/
|
|
23
|
-
// Main context.
|
|
24
|
-
const context = (0, _preact.createContext)({}); // WordPress Directives.
|
|
25
|
-
|
|
26
|
-
const directiveMap = {};
|
|
27
|
-
const directivePriorities = {};
|
|
28
|
-
|
|
29
|
-
const directive = (name, cb, {
|
|
30
|
-
priority = 10
|
|
31
|
-
} = {}) => {
|
|
32
|
-
directiveMap[name] = cb;
|
|
33
|
-
directivePriorities[name] = priority;
|
|
34
|
-
}; // Resolve the path to some property of the store object.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
exports.directive = directive;
|
|
38
|
-
|
|
39
|
-
const resolve = (path, ctx) => {
|
|
40
|
-
let current = { ..._store.rawStore,
|
|
41
|
-
context: ctx
|
|
42
|
-
};
|
|
43
|
-
path.split('.').forEach(p => current = current[p]);
|
|
44
|
-
return current;
|
|
45
|
-
}; // Generate the evaluate function.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const getEvaluate = ({
|
|
49
|
-
ref
|
|
50
|
-
} = {}) => (path, extraArgs = {}) => {
|
|
51
|
-
// If path starts with !, remove it and save a flag.
|
|
52
|
-
const hasNegationOperator = path[0] === '!' && !!(path = path.slice(1));
|
|
53
|
-
const value = resolve(path, extraArgs.context);
|
|
54
|
-
const returnValue = typeof value === 'function' ? value({
|
|
55
|
-
ref: ref.current,
|
|
56
|
-
..._store.rawStore,
|
|
57
|
-
...extraArgs
|
|
58
|
-
}) : value;
|
|
59
|
-
return hasNegationOperator ? !returnValue : returnValue;
|
|
60
|
-
}; // Separate directives by priority. The resulting array contains objects
|
|
61
|
-
// of directives grouped by same priority, and sorted in ascending order.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const usePriorityLevels = directives => (0, _hooks.useMemo)(() => {
|
|
65
|
-
const byPriority = Object.entries(directives).reduce((acc, [name, values]) => {
|
|
66
|
-
const priority = directivePriorities[name];
|
|
67
|
-
if (!acc[priority]) acc[priority] = {};
|
|
68
|
-
acc[priority][name] = values;
|
|
69
|
-
return acc;
|
|
70
|
-
}, {});
|
|
71
|
-
return Object.entries(byPriority).sort(([p1], [p2]) => p1 - p2).map(([, obj]) => obj);
|
|
72
|
-
}, [directives]); // Directive wrapper.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const Directive = ({
|
|
76
|
-
type,
|
|
77
|
-
directives,
|
|
78
|
-
props: originalProps
|
|
79
|
-
}) => {
|
|
80
|
-
const ref = (0, _hooks.useRef)(null);
|
|
81
|
-
const element = (0, _preact.h)(type, { ...originalProps,
|
|
82
|
-
ref
|
|
83
|
-
});
|
|
84
|
-
const evaluate = (0, _hooks.useMemo)(() => getEvaluate({
|
|
85
|
-
ref
|
|
86
|
-
}), []); // Add wrappers recursively for each priority level.
|
|
87
|
-
|
|
88
|
-
const byPriorityLevel = usePriorityLevels(directives);
|
|
89
|
-
return (0, _element.createElement)(RecursivePriorityLevel, {
|
|
90
|
-
directives: byPriorityLevel,
|
|
91
|
-
element: element,
|
|
92
|
-
evaluate: evaluate,
|
|
93
|
-
originalProps: originalProps
|
|
94
|
-
});
|
|
95
|
-
}; // Priority level wrapper.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const RecursivePriorityLevel = ({
|
|
99
|
-
directives: [directives, ...rest],
|
|
100
|
-
element,
|
|
101
|
-
evaluate,
|
|
102
|
-
originalProps
|
|
103
|
-
}) => {
|
|
104
|
-
// This element needs to be a fresh copy so we are not modifying an already
|
|
105
|
-
// rendered element with Preact's internal properties initialized. This
|
|
106
|
-
// prevents an error with changes in `element.props.children` not being
|
|
107
|
-
// reflected in `element.__k`.
|
|
108
|
-
element = (0, _preact.cloneElement)(element); // Recursively render the wrapper for the next priority level.
|
|
109
|
-
//
|
|
110
|
-
// Note that, even though we're instantiating a vnode with a
|
|
111
|
-
// `RecursivePriorityLevel` here, its render function will not be executed
|
|
112
|
-
// just yet. Actually, it will be delayed until the current render function
|
|
113
|
-
// has finished. That ensures directives in the current priorty level have
|
|
114
|
-
// run (and thus modified the passed `element`) before the next level.
|
|
115
|
-
|
|
116
|
-
const children = rest.length > 0 ? (0, _element.createElement)(RecursivePriorityLevel, {
|
|
117
|
-
directives: rest,
|
|
118
|
-
element: element,
|
|
119
|
-
evaluate: evaluate,
|
|
120
|
-
originalProps: originalProps
|
|
121
|
-
}) : element;
|
|
122
|
-
const props = { ...originalProps,
|
|
123
|
-
children
|
|
124
|
-
};
|
|
125
|
-
const directiveArgs = {
|
|
126
|
-
directives,
|
|
127
|
-
props,
|
|
128
|
-
element,
|
|
129
|
-
context,
|
|
130
|
-
evaluate
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
for (const d in directives) {
|
|
134
|
-
const wrapper = directiveMap[d]?.(directiveArgs);
|
|
135
|
-
if (wrapper !== undefined) props.children = wrapper;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return props.children;
|
|
139
|
-
}; // Preact Options Hook called each time a vnode is created.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const old = _preact.options.vnode;
|
|
143
|
-
|
|
144
|
-
_preact.options.vnode = vnode => {
|
|
145
|
-
if (vnode.props.__directives) {
|
|
146
|
-
const props = vnode.props;
|
|
147
|
-
const directives = props.__directives;
|
|
148
|
-
delete props.__directives;
|
|
149
|
-
vnode.props = {
|
|
150
|
-
type: vnode.type,
|
|
151
|
-
directives,
|
|
152
|
-
props
|
|
153
|
-
};
|
|
154
|
-
vnode.type = Directive;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
if (old) old(vnode);
|
|
158
|
-
};
|
|
159
|
-
//# sourceMappingURL=hooks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/hooks.js"],"names":["context","directiveMap","directivePriorities","directive","name","cb","priority","resolve","path","ctx","current","store","split","forEach","p","getEvaluate","ref","extraArgs","hasNegationOperator","slice","value","returnValue","usePriorityLevels","directives","byPriority","Object","entries","reduce","acc","values","sort","p1","p2","map","obj","Directive","type","props","originalProps","element","evaluate","byPriorityLevel","RecursivePriorityLevel","rest","children","length","directiveArgs","d","wrapper","undefined","old","options","vnode","__directives"],"mappings":"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","sourcesContent":["/**\n * External dependencies\n */\nimport { h, options, createContext, cloneElement } from 'preact';\nimport { useRef, useMemo } from 'preact/hooks';\n/**\n * Internal dependencies\n */\nimport { rawStore as store } from './store';\n\n// Main context.\nconst context = createContext( {} );\n\n// WordPress Directives.\nconst directiveMap = {};\nconst directivePriorities = {};\nexport const directive = ( name, cb, { priority = 10 } = {} ) => {\n\tdirectiveMap[ name ] = cb;\n\tdirectivePriorities[ name ] = priority;\n};\n\n// Resolve the path to some property of the store object.\nconst resolve = ( path, ctx ) => {\n\tlet current = { ...store, context: ctx };\n\tpath.split( '.' ).forEach( ( p ) => ( current = current[ p ] ) );\n\treturn current;\n};\n\n// Generate the evaluate function.\nconst getEvaluate =\n\t( { ref } = {} ) =>\n\t( path, extraArgs = {} ) => {\n\t\t// If path starts with !, remove it and save a flag.\n\t\tconst hasNegationOperator =\n\t\t\tpath[ 0 ] === '!' && !! ( path = path.slice( 1 ) );\n\t\tconst value = resolve( path, extraArgs.context );\n\t\tconst returnValue =\n\t\t\ttypeof value === 'function'\n\t\t\t\t? value( {\n\t\t\t\t\t\tref: ref.current,\n\t\t\t\t\t\t...store,\n\t\t\t\t\t\t...extraArgs,\n\t\t\t\t } )\n\t\t\t\t: value;\n\t\treturn hasNegationOperator ? ! returnValue : returnValue;\n\t};\n\n// Separate directives by priority. The resulting array contains objects\n// of directives grouped by same priority, and sorted in ascending order.\nconst usePriorityLevels = ( directives ) =>\n\tuseMemo( () => {\n\t\tconst byPriority = Object.entries( directives ).reduce(\n\t\t\t( acc, [ name, values ] ) => {\n\t\t\t\tconst priority = directivePriorities[ name ];\n\t\t\t\tif ( ! acc[ priority ] ) acc[ priority ] = {};\n\t\t\t\tacc[ priority ][ name ] = values;\n\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\treturn Object.entries( byPriority )\n\t\t\t.sort( ( [ p1 ], [ p2 ] ) => p1 - p2 )\n\t\t\t.map( ( [ , obj ] ) => obj );\n\t}, [ directives ] );\n\n// Directive wrapper.\nconst Directive = ( { type, directives, props: originalProps } ) => {\n\tconst ref = useRef( null );\n\tconst element = h( type, { ...originalProps, ref } );\n\tconst evaluate = useMemo( () => getEvaluate( { ref } ), [] );\n\n\t// Add wrappers recursively for each priority level.\n\tconst byPriorityLevel = usePriorityLevels( directives );\n\treturn (\n\t\t<RecursivePriorityLevel\n\t\t\tdirectives={ byPriorityLevel }\n\t\t\telement={ element }\n\t\t\tevaluate={ evaluate }\n\t\t\toriginalProps={ originalProps }\n\t\t/>\n\t);\n};\n\n// Priority level wrapper.\nconst RecursivePriorityLevel = ( {\n\tdirectives: [ directives, ...rest ],\n\telement,\n\tevaluate,\n\toriginalProps,\n} ) => {\n\t// This element needs to be a fresh copy so we are not modifying an already\n\t// rendered element with Preact's internal properties initialized. This\n\t// prevents an error with changes in `element.props.children` not being\n\t// reflected in `element.__k`.\n\telement = cloneElement( element );\n\n\t// Recursively render the wrapper for the next priority level.\n\t//\n\t// Note that, even though we're instantiating a vnode with a\n\t// `RecursivePriorityLevel` here, its render function will not be executed\n\t// just yet. Actually, it will be delayed until the current render function\n\t// has finished. That ensures directives in the current priorty level have\n\t// run (and thus modified the passed `element`) before the next level.\n\tconst children =\n\t\trest.length > 0 ? (\n\t\t\t<RecursivePriorityLevel\n\t\t\t\tdirectives={ rest }\n\t\t\t\telement={ element }\n\t\t\t\tevaluate={ evaluate }\n\t\t\t\toriginalProps={ originalProps }\n\t\t\t/>\n\t\t) : (\n\t\t\telement\n\t\t);\n\n\tconst props = { ...originalProps, children };\n\tconst directiveArgs = { directives, props, element, context, evaluate };\n\n\tfor ( const d in directives ) {\n\t\tconst wrapper = directiveMap[ d ]?.( directiveArgs );\n\t\tif ( wrapper !== undefined ) props.children = wrapper;\n\t}\n\n\treturn props.children;\n};\n\n// Preact Options Hook called each time a vnode is created.\nconst old = options.vnode;\noptions.vnode = ( vnode ) => {\n\tif ( vnode.props.__directives ) {\n\t\tconst props = vnode.props;\n\t\tconst directives = props.__directives;\n\t\tdelete props.__directives;\n\t\tvnode.props = {\n\t\t\ttype: vnode.type,\n\t\t\tdirectives,\n\t\t\tprops,\n\t\t};\n\t\tvnode.type = Directive;\n\t}\n\n\tif ( old ) old( vnode );\n};\n"]}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.init = void 0;
|
|
7
|
-
|
|
8
|
-
var _preact = require("preact");
|
|
9
|
-
|
|
10
|
-
var _vdom = require("./vdom");
|
|
11
|
-
|
|
12
|
-
var _utils = require("./utils");
|
|
13
|
-
|
|
14
|
-
var _constants = require("./constants");
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* External dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Internal dependencies
|
|
22
|
-
*/
|
|
23
|
-
const init = async () => {
|
|
24
|
-
document.querySelectorAll(`[data-${_constants.directivePrefix}-interactive]`).forEach(node => {
|
|
25
|
-
if (!_vdom.hydratedIslands.has(node)) {
|
|
26
|
-
const fragment = (0, _utils.createRootFragment)(node.parentNode, node);
|
|
27
|
-
const vdom = (0, _vdom.toVdom)(node);
|
|
28
|
-
(0, _preact.hydrate)(vdom, fragment);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
exports.init = init;
|
|
34
|
-
//# sourceMappingURL=hydration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/hydration.js"],"names":["init","document","querySelectorAll","directivePrefix","forEach","node","hydratedIslands","has","fragment","parentNode","vdom"],"mappings":";;;;;;;AAGA;;AAIA;;AACA;;AACA;;AATA;AACA;AACA;;AAEA;AACA;AACA;AAKO,MAAMA,IAAI,GAAG,YAAY;AAC/BC,EAAAA,QAAQ,CACNC,gBADF,CACqB,SAASC,0BAAiB,eAD/C,EAEEC,OAFF,CAEaC,IAAF,IAAY;AACrB,QAAK,CAAEC,sBAAgBC,GAAhB,CAAqBF,IAArB,CAAP,EAAqC;AACpC,YAAMG,QAAQ,GAAG,+BAAoBH,IAAI,CAACI,UAAzB,EAAqCJ,IAArC,CAAjB;AACA,YAAMK,IAAI,GAAG,kBAAQL,IAAR,CAAb;AACA,2BAASK,IAAT,EAAeF,QAAf;AACA;AACD,GARF;AASA,CAVM","sourcesContent":["/**\n * External dependencies\n */\nimport { hydrate } from 'preact';\n/**\n * Internal dependencies\n */\nimport { toVdom, hydratedIslands } from './vdom';\nimport { createRootFragment } from './utils';\nimport { directivePrefix } from './constants';\n\nexport const init = async () => {\n\tdocument\n\t\t.querySelectorAll( `[data-${ directivePrefix }-interactive]` )\n\t\t.forEach( ( node ) => {\n\t\t\tif ( ! hydratedIslands.has( node ) ) {\n\t\t\t\tconst fragment = createRootFragment( node.parentNode, node );\n\t\t\t\tconst vdom = toVdom( node );\n\t\t\t\thydrate( vdom, fragment );\n\t\t\t}\n\t\t} );\n};\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
Object.defineProperty(exports, "store", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function () {
|
|
11
|
-
return _store.store;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
var _directives = _interopRequireDefault(require("./directives"));
|
|
16
|
-
|
|
17
|
-
var _hydration = require("./hydration");
|
|
18
|
-
|
|
19
|
-
var _store = require("./store");
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Internal dependencies
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Initialize the Interactivity API.
|
|
27
|
-
*/
|
|
28
|
-
(0, _directives.default)();
|
|
29
|
-
document.addEventListener('DOMContentLoaded', async () => {
|
|
30
|
-
await (0, _hydration.init)();
|
|
31
|
-
});
|
|
32
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/index.js"],"names":["document","addEventListener"],"mappings":";;;;;;;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AAEAA,QAAQ,CAACC,gBAAT,CAA2B,kBAA3B,EAA+C,YAAY;AAC1D,QAAM,sBAAN;AACA,CAFD","sourcesContent":["/**\n * Internal dependencies\n */\nimport registerDirectives from './directives';\nimport { init } from './hydration';\nexport { store } from './store';\n\n/**\n * Initialize the Interactivity API.\n */\nregisterDirectives();\n\ndocument.addEventListener( 'DOMContentLoaded', async () => {\n\tawait init();\n} );\n"]}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createPortal = createPortal;
|
|
7
|
-
|
|
8
|
-
var _preact = require("preact");
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* External dependencies
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @param {import('../../src/index').RenderableProps<{ context: any }>} props
|
|
16
|
-
*/
|
|
17
|
-
function ContextProvider(props) {
|
|
18
|
-
this.getChildContext = () => props.context;
|
|
19
|
-
|
|
20
|
-
return props.children;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Portal component
|
|
24
|
-
*
|
|
25
|
-
* @this {import('./internal').Component}
|
|
26
|
-
* @param {object | null | undefined} props
|
|
27
|
-
*
|
|
28
|
-
* TODO: use createRoot() instead of fake root
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
function Portal(props) {
|
|
33
|
-
const _this = this;
|
|
34
|
-
|
|
35
|
-
const container = props._container;
|
|
36
|
-
|
|
37
|
-
_this.componentWillUnmount = function () {
|
|
38
|
-
(0, _preact.render)(null, _this._temp);
|
|
39
|
-
_this._temp = null;
|
|
40
|
-
_this._container = null;
|
|
41
|
-
}; // When we change container we should clear our old container and
|
|
42
|
-
// indicate a new mount.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (_this._container && _this._container !== container) {
|
|
46
|
-
_this.componentWillUnmount();
|
|
47
|
-
} // When props.vnode is undefined/false/null we are dealing with some kind of
|
|
48
|
-
// conditional vnode. This should not trigger a render.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (props._vnode) {
|
|
52
|
-
if (!_this._temp) {
|
|
53
|
-
_this._container = container; // Create a fake DOM parent node that manages a subset of `container`'s children:
|
|
54
|
-
|
|
55
|
-
_this._temp = {
|
|
56
|
-
nodeType: 1,
|
|
57
|
-
parentNode: container,
|
|
58
|
-
childNodes: [],
|
|
59
|
-
|
|
60
|
-
appendChild(child) {
|
|
61
|
-
this.childNodes.push(child);
|
|
62
|
-
|
|
63
|
-
_this._container.appendChild(child);
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
insertBefore(child) {
|
|
67
|
-
this.childNodes.push(child);
|
|
68
|
-
|
|
69
|
-
_this._container.appendChild(child);
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
removeChild(child) {
|
|
73
|
-
this.childNodes.splice( // eslint-disable-next-line no-bitwise
|
|
74
|
-
this.childNodes.indexOf(child) >>> 1, 1);
|
|
75
|
-
|
|
76
|
-
_this._container.removeChild(child);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
};
|
|
80
|
-
} // Render our wrapping element into temp.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
(0, _preact.render)((0, _preact.createElement)(ContextProvider, {
|
|
84
|
-
context: _this.context
|
|
85
|
-
}, props._vnode), _this._temp);
|
|
86
|
-
} // When we come from a conditional render, on a mounted
|
|
87
|
-
// portal we should clear the DOM.
|
|
88
|
-
else if (_this._temp) {
|
|
89
|
-
_this.componentWillUnmount();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Create a `Portal` to continue rendering the vnode tree at a different DOM node
|
|
94
|
-
*
|
|
95
|
-
* @param {import('./internal').VNode} vnode The vnode to render
|
|
96
|
-
* @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.
|
|
97
|
-
*/
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
function createPortal(vnode, container) {
|
|
101
|
-
const el = (0, _preact.createElement)(Portal, {
|
|
102
|
-
_vnode: vnode,
|
|
103
|
-
_container: container
|
|
104
|
-
});
|
|
105
|
-
el.containerInfo = container;
|
|
106
|
-
return el;
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=portals.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/portals.js"],"names":["ContextProvider","props","getChildContext","context","children","Portal","_this","container","_container","componentWillUnmount","_temp","_vnode","nodeType","parentNode","childNodes","appendChild","child","push","insertBefore","removeChild","splice","indexOf","createPortal","vnode","el","containerInfo"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,eAAT,CAA0BC,KAA1B,EAAkC;AACjC,OAAKC,eAAL,GAAuB,MAAMD,KAAK,CAACE,OAAnC;;AACA,SAAOF,KAAK,CAACG,QAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,MAAT,CAAiBJ,KAAjB,EAAyB;AACxB,QAAMK,KAAK,GAAG,IAAd;;AACA,QAAMC,SAAS,GAAGN,KAAK,CAACO,UAAxB;;AAEAF,EAAAA,KAAK,CAACG,oBAAN,GAA6B,YAAY;AACxC,wBAAQ,IAAR,EAAcH,KAAK,CAACI,KAApB;AACAJ,IAAAA,KAAK,CAACI,KAAN,GAAc,IAAd;AACAJ,IAAAA,KAAK,CAACE,UAAN,GAAmB,IAAnB;AACA,GAJD,CAJwB,CAUxB;AACA;;;AACA,MAAKF,KAAK,CAACE,UAAN,IAAoBF,KAAK,CAACE,UAAN,KAAqBD,SAA9C,EAA0D;AACzDD,IAAAA,KAAK,CAACG,oBAAN;AACA,GAduB,CAgBxB;AACA;;;AACA,MAAKR,KAAK,CAACU,MAAX,EAAoB;AACnB,QAAK,CAAEL,KAAK,CAACI,KAAb,EAAqB;AACpBJ,MAAAA,KAAK,CAACE,UAAN,GAAmBD,SAAnB,CADoB,CAGpB;;AACAD,MAAAA,KAAK,CAACI,KAAN,GAAc;AACbE,QAAAA,QAAQ,EAAE,CADG;AAEbC,QAAAA,UAAU,EAAEN,SAFC;AAGbO,QAAAA,UAAU,EAAE,EAHC;;AAIbC,QAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,eAAKF,UAAL,CAAgBG,IAAhB,CAAsBD,KAAtB;;AACAV,UAAAA,KAAK,CAACE,UAAN,CAAiBO,WAAjB,CAA8BC,KAA9B;AACA,SAPY;;AAQbE,QAAAA,YAAY,CAAEF,KAAF,EAAU;AACrB,eAAKF,UAAL,CAAgBG,IAAhB,CAAsBD,KAAtB;;AACAV,UAAAA,KAAK,CAACE,UAAN,CAAiBO,WAAjB,CAA8BC,KAA9B;AACA,SAXY;;AAYbG,QAAAA,WAAW,CAAEH,KAAF,EAAU;AACpB,eAAKF,UAAL,CAAgBM,MAAhB,EACC;AACA,eAAKN,UAAL,CAAgBO,OAAhB,CAAyBL,KAAzB,MAAqC,CAFtC,EAGC,CAHD;;AAKAV,UAAAA,KAAK,CAACE,UAAN,CAAiBW,WAAjB,CAA8BH,KAA9B;AACA;;AAnBY,OAAd;AAqBA,KA1BkB,CA4BnB;;;AACA,wBACC,2BACChB,eADD,EAEC;AAAEG,MAAAA,OAAO,EAAEG,KAAK,CAACH;AAAjB,KAFD,EAGCF,KAAK,CAACU,MAHP,CADD,EAMCL,KAAK,CAACI,KANP;AAQA,GArCD,CAsCA;AACA;AAvCA,OAwCK,IAAKJ,KAAK,CAACI,KAAX,EAAmB;AACvBJ,IAAAA,KAAK,CAACG,oBAAN;AACA;AACD;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASa,YAAT,CAAuBC,KAAvB,EAA8BhB,SAA9B,EAA0C;AAChD,QAAMiB,EAAE,GAAG,2BAAenB,MAAf,EAAuB;AACjCM,IAAAA,MAAM,EAAEY,KADyB;AAEjCf,IAAAA,UAAU,EAAED;AAFqB,GAAvB,CAAX;AAIAiB,EAAAA,EAAE,CAACC,aAAH,GAAmBlB,SAAnB;AACA,SAAOiB,EAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { createElement, render } from 'preact';\n\n/**\n * @param {import('../../src/index').RenderableProps<{ context: any }>} props\n */\nfunction ContextProvider( props ) {\n\tthis.getChildContext = () => props.context;\n\treturn props.children;\n}\n\n/**\n * Portal component\n *\n * @this {import('./internal').Component}\n * @param {object | null | undefined} props\n *\n * TODO: use createRoot() instead of fake root\n */\nfunction Portal( props ) {\n\tconst _this = this;\n\tconst container = props._container;\n\n\t_this.componentWillUnmount = function () {\n\t\trender( null, _this._temp );\n\t\t_this._temp = null;\n\t\t_this._container = null;\n\t};\n\n\t// When we change container we should clear our old container and\n\t// indicate a new mount.\n\tif ( _this._container && _this._container !== container ) {\n\t\t_this.componentWillUnmount();\n\t}\n\n\t// When props.vnode is undefined/false/null we are dealing with some kind of\n\t// conditional vnode. This should not trigger a render.\n\tif ( props._vnode ) {\n\t\tif ( ! _this._temp ) {\n\t\t\t_this._container = container;\n\n\t\t\t// Create a fake DOM parent node that manages a subset of `container`'s children:\n\t\t\t_this._temp = {\n\t\t\t\tnodeType: 1,\n\t\t\t\tparentNode: container,\n\t\t\t\tchildNodes: [],\n\t\t\t\tappendChild( child ) {\n\t\t\t\t\tthis.childNodes.push( child );\n\t\t\t\t\t_this._container.appendChild( child );\n\t\t\t\t},\n\t\t\t\tinsertBefore( child ) {\n\t\t\t\t\tthis.childNodes.push( child );\n\t\t\t\t\t_this._container.appendChild( child );\n\t\t\t\t},\n\t\t\t\tremoveChild( child ) {\n\t\t\t\t\tthis.childNodes.splice(\n\t\t\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\t\t\tthis.childNodes.indexOf( child ) >>> 1,\n\t\t\t\t\t\t1\n\t\t\t\t\t);\n\t\t\t\t\t_this._container.removeChild( child );\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\t// Render our wrapping element into temp.\n\t\trender(\n\t\t\tcreateElement(\n\t\t\t\tContextProvider,\n\t\t\t\t{ context: _this.context },\n\t\t\t\tprops._vnode\n\t\t\t),\n\t\t\t_this._temp\n\t\t);\n\t}\n\t// When we come from a conditional render, on a mounted\n\t// portal we should clear the DOM.\n\telse if ( _this._temp ) {\n\t\t_this.componentWillUnmount();\n\t}\n}\n\n/**\n * Create a `Portal` to continue rendering the vnode tree at a different DOM node\n *\n * @param {import('./internal').VNode} vnode The vnode to render\n * @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.\n */\nexport function createPortal( vnode, container ) {\n\tconst el = createElement( Portal, {\n\t\t_vnode: vnode,\n\t\t_container: container,\n\t} );\n\tel.containerInfo = container;\n\treturn el;\n}\n"]}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.store = exports.rawStore = void 0;
|
|
7
|
-
|
|
8
|
-
var _deepsignal = require("deepsignal");
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* External dependencies
|
|
12
|
-
*/
|
|
13
|
-
const isObject = item => item && typeof item === 'object' && !Array.isArray(item);
|
|
14
|
-
|
|
15
|
-
const deepMerge = (target, source) => {
|
|
16
|
-
if (isObject(target) && isObject(source)) {
|
|
17
|
-
for (const key in source) {
|
|
18
|
-
if (isObject(source[key])) {
|
|
19
|
-
if (!target[key]) Object.assign(target, {
|
|
20
|
-
[key]: {}
|
|
21
|
-
});
|
|
22
|
-
deepMerge(target[key], source[key]);
|
|
23
|
-
} else {
|
|
24
|
-
Object.assign(target, {
|
|
25
|
-
[key]: source[key]
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const getSerializedState = () => {
|
|
33
|
-
// TODO: change the store tag ID for a better one.
|
|
34
|
-
const storeTag = document.querySelector(`script[type="application/json"]#store`);
|
|
35
|
-
if (!storeTag) return {};
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
const {
|
|
39
|
-
state
|
|
40
|
-
} = JSON.parse(storeTag.textContent);
|
|
41
|
-
if (isObject(state)) return state;
|
|
42
|
-
throw Error('Parsed state is not an object');
|
|
43
|
-
} catch (e) {
|
|
44
|
-
// eslint-disable-next-line no-console
|
|
45
|
-
console.log(e);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return {};
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const rawState = getSerializedState();
|
|
52
|
-
const rawStore = {
|
|
53
|
-
state: (0, _deepsignal.deepSignal)(rawState)
|
|
54
|
-
};
|
|
55
|
-
exports.rawStore = rawStore;
|
|
56
|
-
|
|
57
|
-
const store = ({
|
|
58
|
-
state,
|
|
59
|
-
...block
|
|
60
|
-
}) => {
|
|
61
|
-
deepMerge(rawStore, block);
|
|
62
|
-
deepMerge(rawState, state);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
exports.store = store;
|
|
66
|
-
//# sourceMappingURL=store.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/store.js"],"names":["isObject","item","Array","isArray","deepMerge","target","source","key","Object","assign","getSerializedState","storeTag","document","querySelector","state","JSON","parse","textContent","Error","e","console","log","rawState","rawStore","store","block"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAKC,IAAF,IAChBA,IAAI,IAAI,OAAOA,IAAP,KAAgB,QAAxB,IAAoC,CAAEC,KAAK,CAACC,OAAN,CAAeF,IAAf,CADvC;;AAGA,MAAMG,SAAS,GAAG,CAAEC,MAAF,EAAUC,MAAV,KAAsB;AACvC,MAAKN,QAAQ,CAAEK,MAAF,CAAR,IAAsBL,QAAQ,CAAEM,MAAF,CAAnC,EAAgD;AAC/C,SAAM,MAAMC,GAAZ,IAAmBD,MAAnB,EAA4B;AAC3B,UAAKN,QAAQ,CAAEM,MAAM,CAAEC,GAAF,CAAR,CAAb,EAAiC;AAChC,YAAK,CAAEF,MAAM,CAAEE,GAAF,CAAb,EAAuBC,MAAM,CAACC,MAAP,CAAeJ,MAAf,EAAuB;AAAE,WAAEE,GAAF,GAAS;AAAX,SAAvB;AACvBH,QAAAA,SAAS,CAAEC,MAAM,CAAEE,GAAF,CAAR,EAAiBD,MAAM,CAAEC,GAAF,CAAvB,CAAT;AACA,OAHD,MAGO;AACNC,QAAAA,MAAM,CAACC,MAAP,CAAeJ,MAAf,EAAuB;AAAE,WAAEE,GAAF,GAASD,MAAM,CAAEC,GAAF;AAAjB,SAAvB;AACA;AACD;AACD;AACD,CAXD;;AAaA,MAAMG,kBAAkB,GAAG,MAAM;AAChC;AACA,QAAMC,QAAQ,GAAGC,QAAQ,CAACC,aAAT,CACf,uCADe,CAAjB;AAGA,MAAK,CAAEF,QAAP,EAAkB,OAAO,EAAP;;AAClB,MAAI;AACH,UAAM;AAAEG,MAAAA;AAAF,QAAYC,IAAI,CAACC,KAAL,CAAYL,QAAQ,CAACM,WAArB,CAAlB;AACA,QAAKjB,QAAQ,CAAEc,KAAF,CAAb,EAAyB,OAAOA,KAAP;AACzB,UAAMI,KAAK,CAAE,+BAAF,CAAX;AACA,GAJD,CAIE,OAAQC,CAAR,EAAY;AACb;AACAC,IAAAA,OAAO,CAACC,GAAR,CAAaF,CAAb;AACA;;AACD,SAAO,EAAP;AACA,CAfD;;AAiBA,MAAMG,QAAQ,GAAGZ,kBAAkB,EAAnC;AACO,MAAMa,QAAQ,GAAG;AAAET,EAAAA,KAAK,EAAE,4BAAYQ,QAAZ;AAAT,CAAjB;;;AAEA,MAAME,KAAK,GAAG,CAAE;AAAEV,EAAAA,KAAF;AAAS,KAAGW;AAAZ,CAAF,KAA2B;AAC/CrB,EAAAA,SAAS,CAAEmB,QAAF,EAAYE,KAAZ,CAAT;AACArB,EAAAA,SAAS,CAAEkB,QAAF,EAAYR,KAAZ,CAAT;AACA,CAHM","sourcesContent":["/**\n * External dependencies\n */\nimport { deepSignal } from 'deepsignal';\n\nconst isObject = ( item ) =>\n\titem && typeof item === 'object' && ! Array.isArray( item );\n\nconst deepMerge = ( target, source ) => {\n\tif ( isObject( target ) && isObject( source ) ) {\n\t\tfor ( const key in source ) {\n\t\t\tif ( isObject( source[ key ] ) ) {\n\t\t\t\tif ( ! target[ key ] ) Object.assign( target, { [ key ]: {} } );\n\t\t\t\tdeepMerge( target[ key ], source[ key ] );\n\t\t\t} else {\n\t\t\t\tObject.assign( target, { [ key ]: source[ key ] } );\n\t\t\t}\n\t\t}\n\t}\n};\n\nconst getSerializedState = () => {\n\t// TODO: change the store tag ID for a better one.\n\tconst storeTag = document.querySelector(\n\t\t`script[type=\"application/json\"]#store`\n\t);\n\tif ( ! storeTag ) return {};\n\ttry {\n\t\tconst { state } = JSON.parse( storeTag.textContent );\n\t\tif ( isObject( state ) ) return state;\n\t\tthrow Error( 'Parsed state is not an object' );\n\t} catch ( e ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.log( e );\n\t}\n\treturn {};\n};\n\nconst rawState = getSerializedState();\nexport const rawStore = { state: deepSignal( rawState ) };\n\nexport const store = ( { state, ...block } ) => {\n\tdeepMerge( rawStore, block );\n\tdeepMerge( rawState, state );\n};\n"]}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createRootFragment = void 0;
|
|
7
|
-
exports.useSignalEffect = useSignalEffect;
|
|
8
|
-
|
|
9
|
-
var _hooks = require("preact/hooks");
|
|
10
|
-
|
|
11
|
-
var _signals = require("@preact/signals");
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* External dependencies
|
|
15
|
-
*/
|
|
16
|
-
function afterNextFrame(callback) {
|
|
17
|
-
const done = () => {
|
|
18
|
-
window.cancelAnimationFrame(raf);
|
|
19
|
-
setTimeout(callback);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const raf = window.requestAnimationFrame(done);
|
|
23
|
-
} // Using the mangled properties:
|
|
24
|
-
// this.c: this._callback
|
|
25
|
-
// this.x: this._compute
|
|
26
|
-
// https://github.com/preactjs/signals/blob/main/mangle.json
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
function createFlusher(compute, notify) {
|
|
30
|
-
let flush;
|
|
31
|
-
const dispose = (0, _signals.effect)(function () {
|
|
32
|
-
flush = this.c.bind(this);
|
|
33
|
-
this.x = compute;
|
|
34
|
-
this.c = notify;
|
|
35
|
-
return compute();
|
|
36
|
-
});
|
|
37
|
-
return {
|
|
38
|
-
flush,
|
|
39
|
-
dispose
|
|
40
|
-
};
|
|
41
|
-
} // Version of `useSignalEffect` with a `useEffect`-like execution. This hook
|
|
42
|
-
// implementation comes from this PR:
|
|
43
|
-
// https://github.com/preactjs/signals/pull/290.
|
|
44
|
-
//
|
|
45
|
-
// We need to include it here in this repo until the mentioned PR is merged.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
function useSignalEffect(cb) {
|
|
49
|
-
const callback = (0, _hooks.useRef)(cb);
|
|
50
|
-
callback.current = cb;
|
|
51
|
-
(0, _hooks.useEffect)(() => {
|
|
52
|
-
const execute = () => callback.current();
|
|
53
|
-
|
|
54
|
-
const notify = () => afterNextFrame(eff.flush);
|
|
55
|
-
|
|
56
|
-
const eff = createFlusher(execute, notify);
|
|
57
|
-
return eff.dispose;
|
|
58
|
-
}, []);
|
|
59
|
-
} // For wrapperless hydration.
|
|
60
|
-
// See https://gist.github.com/developit/f4c67a2ede71dc2fab7f357f39cff28c
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const createRootFragment = (parent, replaceNode) => {
|
|
64
|
-
replaceNode = [].concat(replaceNode);
|
|
65
|
-
const s = replaceNode[replaceNode.length - 1].nextSibling;
|
|
66
|
-
|
|
67
|
-
function insert(c, r) {
|
|
68
|
-
parent.insertBefore(c, r || s);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return parent.__k = {
|
|
72
|
-
nodeType: 1,
|
|
73
|
-
parentNode: parent,
|
|
74
|
-
firstChild: replaceNode[0],
|
|
75
|
-
childNodes: replaceNode,
|
|
76
|
-
insertBefore: insert,
|
|
77
|
-
appendChild: insert,
|
|
78
|
-
|
|
79
|
-
removeChild(c) {
|
|
80
|
-
parent.removeChild(c);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
exports.createRootFragment = createRootFragment;
|
|
87
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/utils/interactivity/utils.js"],"names":["afterNextFrame","callback","done","window","cancelAnimationFrame","raf","setTimeout","requestAnimationFrame","createFlusher","compute","notify","flush","dispose","c","bind","x","useSignalEffect","cb","current","execute","eff","createRootFragment","parent","replaceNode","concat","s","length","nextSibling","insert","r","insertBefore","__k","nodeType","parentNode","firstChild","childNodes","appendChild","removeChild"],"mappings":";;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,SAASA,cAAT,CAAyBC,QAAzB,EAAoC;AACnC,QAAMC,IAAI,GAAG,MAAM;AAClBC,IAAAA,MAAM,CAACC,oBAAP,CAA6BC,GAA7B;AACAC,IAAAA,UAAU,CAAEL,QAAF,CAAV;AACA,GAHD;;AAIA,QAAMI,GAAG,GAAGF,MAAM,CAACI,qBAAP,CAA8BL,IAA9B,CAAZ;AACA,C,CAED;AACA;AACA;AACA;;;AACA,SAASM,aAAT,CAAwBC,OAAxB,EAAiCC,MAAjC,EAA0C;AACzC,MAAIC,KAAJ;AACA,QAAMC,OAAO,GAAG,qBAAQ,YAAY;AACnCD,IAAAA,KAAK,GAAG,KAAKE,CAAL,CAAOC,IAAP,CAAa,IAAb,CAAR;AACA,SAAKC,CAAL,GAASN,OAAT;AACA,SAAKI,CAAL,GAASH,MAAT;AACA,WAAOD,OAAO,EAAd;AACA,GALe,CAAhB;AAMA,SAAO;AAAEE,IAAAA,KAAF;AAASC,IAAAA;AAAT,GAAP;AACA,C,CAED;AACA;AACA;AACA;AACA;;;AACO,SAASI,eAAT,CAA0BC,EAA1B,EAA+B;AACrC,QAAMhB,QAAQ,GAAG,mBAAQgB,EAAR,CAAjB;AACAhB,EAAAA,QAAQ,CAACiB,OAAT,GAAmBD,EAAnB;AAEA,wBAAW,MAAM;AAChB,UAAME,OAAO,GAAG,MAAMlB,QAAQ,CAACiB,OAAT,EAAtB;;AACA,UAAMR,MAAM,GAAG,MAAMV,cAAc,CAAEoB,GAAG,CAACT,KAAN,CAAnC;;AACA,UAAMS,GAAG,GAAGZ,aAAa,CAAEW,OAAF,EAAWT,MAAX,CAAzB;AACA,WAAOU,GAAG,CAACR,OAAX;AACA,GALD,EAKG,EALH;AAMA,C,CAED;AACA;;;AACO,MAAMS,kBAAkB,GAAG,CAAEC,MAAF,EAAUC,WAAV,KAA2B;AAC5DA,EAAAA,WAAW,GAAG,GAAGC,MAAH,CAAWD,WAAX,CAAd;AACA,QAAME,CAAC,GAAGF,WAAW,CAAEA,WAAW,CAACG,MAAZ,GAAqB,CAAvB,CAAX,CAAsCC,WAAhD;;AACA,WAASC,MAAT,CAAiBf,CAAjB,EAAoBgB,CAApB,EAAwB;AACvBP,IAAAA,MAAM,CAACQ,YAAP,CAAqBjB,CAArB,EAAwBgB,CAAC,IAAIJ,CAA7B;AACA;;AACD,SAASH,MAAM,CAACS,GAAP,GAAa;AACrBC,IAAAA,QAAQ,EAAE,CADW;AAErBC,IAAAA,UAAU,EAAEX,MAFS;AAGrBY,IAAAA,UAAU,EAAEX,WAAW,CAAE,CAAF,CAHF;AAIrBY,IAAAA,UAAU,EAAEZ,WAJS;AAKrBO,IAAAA,YAAY,EAAEF,MALO;AAMrBQ,IAAAA,WAAW,EAAER,MANQ;;AAOrBS,IAAAA,WAAW,CAAExB,CAAF,EAAM;AAChBS,MAAAA,MAAM,CAACe,WAAP,CAAoBxB,CAApB;AACA;;AAToB,GAAtB;AAWA,CAjBM","sourcesContent":["/**\n * External dependencies\n */\nimport { useRef, useEffect } from 'preact/hooks';\nimport { effect } from '@preact/signals';\n\nfunction afterNextFrame( callback ) {\n\tconst done = () => {\n\t\twindow.cancelAnimationFrame( raf );\n\t\tsetTimeout( callback );\n\t};\n\tconst raf = window.requestAnimationFrame( done );\n}\n\n// Using the mangled properties:\n// this.c: this._callback\n// this.x: this._compute\n// https://github.com/preactjs/signals/blob/main/mangle.json\nfunction createFlusher( compute, notify ) {\n\tlet flush;\n\tconst dispose = effect( function () {\n\t\tflush = this.c.bind( this );\n\t\tthis.x = compute;\n\t\tthis.c = notify;\n\t\treturn compute();\n\t} );\n\treturn { flush, dispose };\n}\n\n// Version of `useSignalEffect` with a `useEffect`-like execution. This hook\n// implementation comes from this PR:\n// https://github.com/preactjs/signals/pull/290.\n//\n// We need to include it here in this repo until the mentioned PR is merged.\nexport function useSignalEffect( cb ) {\n\tconst callback = useRef( cb );\n\tcallback.current = cb;\n\n\tuseEffect( () => {\n\t\tconst execute = () => callback.current();\n\t\tconst notify = () => afterNextFrame( eff.flush );\n\t\tconst eff = createFlusher( execute, notify );\n\t\treturn eff.dispose;\n\t}, [] );\n}\n\n// For wrapperless hydration.\n// See https://gist.github.com/developit/f4c67a2ede71dc2fab7f357f39cff28c\nexport const createRootFragment = ( parent, replaceNode ) => {\n\treplaceNode = [].concat( replaceNode );\n\tconst s = replaceNode[ replaceNode.length - 1 ].nextSibling;\n\tfunction insert( c, r ) {\n\t\tparent.insertBefore( c, r || s );\n\t}\n\treturn ( parent.__k = {\n\t\tnodeType: 1,\n\t\tparentNode: parent,\n\t\tfirstChild: replaceNode[ 0 ],\n\t\tchildNodes: replaceNode,\n\t\tinsertBefore: insert,\n\t\tappendChild: insert,\n\t\tremoveChild( c ) {\n\t\t\tparent.removeChild( c );\n\t\t},\n\t} );\n};\n"]}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.hydratedIslands = void 0;
|
|
7
|
-
exports.toVdom = toVdom;
|
|
8
|
-
|
|
9
|
-
var _preact = require("preact");
|
|
10
|
-
|
|
11
|
-
var _constants = require("./constants");
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* External dependencies
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Internal dependencies
|
|
19
|
-
*/
|
|
20
|
-
const ignoreAttr = `data-${_constants.directivePrefix}-ignore`;
|
|
21
|
-
const islandAttr = `data-${_constants.directivePrefix}-interactive`;
|
|
22
|
-
const fullPrefix = `data-${_constants.directivePrefix}-`; // Regular expression for directive parsing.
|
|
23
|
-
|
|
24
|
-
const directiveParser = new RegExp(`^data-${_constants.directivePrefix}-` + // ${p} must be a prefix string, like 'wp'.
|
|
25
|
-
// Match alphanumeric characters including hyphen-separated
|
|
26
|
-
// segments. It excludes underscore intentionally to prevent confusion.
|
|
27
|
-
// E.g., "custom-directive".
|
|
28
|
-
'([a-z0-9]+(?:-[a-z0-9]+)*)' + // (Optional) Match '--' followed by any alphanumeric charachters. It
|
|
29
|
-
// excludes underscore intentionally to prevent confusion, but it can
|
|
30
|
-
// contain multiple hyphens. E.g., "--custom-prefix--with-more-info".
|
|
31
|
-
'(?:--([a-z0-9][a-z0-9-]+))?$', 'i' // Case insensitive.
|
|
32
|
-
);
|
|
33
|
-
const hydratedIslands = new WeakSet(); // Recursive function that transforms a DOM tree into vDOM.
|
|
34
|
-
|
|
35
|
-
exports.hydratedIslands = hydratedIslands;
|
|
36
|
-
|
|
37
|
-
function toVdom(root) {
|
|
38
|
-
const treeWalker = document.createTreeWalker(root, 205 // ELEMENT + TEXT + COMMENT + CDATA_SECTION + PROCESSING_INSTRUCTION
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
function walk(node) {
|
|
42
|
-
const {
|
|
43
|
-
attributes,
|
|
44
|
-
nodeType
|
|
45
|
-
} = node;
|
|
46
|
-
if (nodeType === 3) return [node.data];
|
|
47
|
-
|
|
48
|
-
if (nodeType === 4) {
|
|
49
|
-
const next = treeWalker.nextSibling();
|
|
50
|
-
node.replaceWith(new window.Text(node.nodeValue));
|
|
51
|
-
return [node.nodeValue, next];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (nodeType === 8 || nodeType === 7) {
|
|
55
|
-
const next = treeWalker.nextSibling();
|
|
56
|
-
node.remove();
|
|
57
|
-
return [null, next];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const props = {};
|
|
61
|
-
const children = [];
|
|
62
|
-
const directives = {};
|
|
63
|
-
let hasDirectives = false;
|
|
64
|
-
let ignore = false;
|
|
65
|
-
let island = false;
|
|
66
|
-
|
|
67
|
-
for (let i = 0; i < attributes.length; i++) {
|
|
68
|
-
const n = attributes[i].name;
|
|
69
|
-
|
|
70
|
-
if (n[fullPrefix.length] && n.slice(0, fullPrefix.length) === fullPrefix) {
|
|
71
|
-
if (n === ignoreAttr) {
|
|
72
|
-
ignore = true;
|
|
73
|
-
} else if (n === islandAttr) {
|
|
74
|
-
island = true;
|
|
75
|
-
} else {
|
|
76
|
-
hasDirectives = true;
|
|
77
|
-
let val = attributes[i].value;
|
|
78
|
-
|
|
79
|
-
try {
|
|
80
|
-
val = JSON.parse(val);
|
|
81
|
-
} catch (e) {}
|
|
82
|
-
|
|
83
|
-
const [, prefix, suffix] = directiveParser.exec(n);
|
|
84
|
-
directives[prefix] = directives[prefix] || {};
|
|
85
|
-
directives[prefix][suffix || 'default'] = val;
|
|
86
|
-
}
|
|
87
|
-
} else if (n === 'ref') {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
props[n] = attributes[i].value;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (ignore && !island) return [(0, _preact.h)(node.localName, { ...props,
|
|
95
|
-
innerHTML: node.innerHTML,
|
|
96
|
-
__directives: {
|
|
97
|
-
ignore: true
|
|
98
|
-
}
|
|
99
|
-
})];
|
|
100
|
-
if (island) hydratedIslands.add(node);
|
|
101
|
-
if (hasDirectives) props.__directives = directives;
|
|
102
|
-
let child = treeWalker.firstChild();
|
|
103
|
-
|
|
104
|
-
if (child) {
|
|
105
|
-
while (child) {
|
|
106
|
-
const [vnode, nextChild] = walk(child);
|
|
107
|
-
if (vnode) children.push(vnode);
|
|
108
|
-
child = nextChild || treeWalker.nextSibling();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
treeWalker.parentNode();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return [(0, _preact.h)(node.localName, props, children)];
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return walk(treeWalker.currentNode);
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=vdom.js.map
|