mosaic-headless 1.32.1 → 1.33.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/README.md +2 -2
- package/SKILL.md +36 -19
- package/assets/templates/platforms/claude-ai.json +1 -1
- package/assets/templates/platforms/claude-code.json +1 -1
- package/assets/templates/platforms/codex-cli.json +1 -1
- package/assets/templates/platforms/copilot.json +1 -1
- package/assets/templates/platforms/gemini-cli.json +1 -1
- package/data/data-class-hierarchy.csv +51 -51
- package/data/default-children.csv +14 -14
- package/data/dynamic-variables.csv +5 -4
- package/data/interaction-types.csv +14 -14
- package/data/node-properties.csv +108 -108
- package/data/node-types.csv +54 -54
- package/data/placement-rules.csv +55 -55
- package/data/pluggables.csv +130 -106
- package/data/style-properties.csv +1 -1
- package/data/style-states.csv +36 -36
- package/data/variants.csv +1 -0
- package/package.json +1 -1
- package/references/data-model.md +11 -5
- package/references/design-system.md +43 -8
- package/references/dialog-and-triggers.md +5 -0
- package/references/dynamic-content.md +16 -2
- package/references/placement.md +9 -2
- package/references/styling.md +3 -1
- package/references/templates-and-conditions.md +47 -11
- package/references/upgrading.md +74 -1
- package/references/vs-elementor-gutenberg.md +6 -4
- package/tools/build_page.py +15 -7
- package/tools/extract_default_children.py +5 -4
- package/tools/extract_node_types.py +64 -7
- package/tools/extract_placement.py +18 -7
|
@@ -22,9 +22,10 @@ import sys
|
|
|
22
22
|
|
|
23
23
|
# parent::__construct($nodeFactoryManager, 'slug', <label expr>) -- may span lines
|
|
24
24
|
RE_CTOR = re.compile(
|
|
25
|
-
r"parent::__construct\s*\(\s*\$\w+\s*,\s*'
|
|
25
|
+
r"parent::__construct\s*\(\s*\$\w+\s*,\s*('[^']+'|self::\w+|static::\w+)\s*,\s*(.*?)\)\s*;",
|
|
26
26
|
re.S,
|
|
27
27
|
)
|
|
28
|
+
RE_CONST = re.compile(r"const\s+(\w+)\s*=\s*'([^']+)'\s*;")
|
|
28
29
|
RE_CLASS = re.compile(r"^\s*(?:final\s+)?(abstract\s+)?class\s+(\w+)\s+extends\s+(\w+)", re.M)
|
|
29
30
|
RE_METHOD_BOOL = re.compile(r"function\s+(\w+)\s*\([^)]*\)\s*:\s*bool\s*\{\s*return\s+(true|false)\s*;", re.S)
|
|
30
31
|
RE_ALIAS = re.compile(r"function\s+getAliasTypes\s*\([^)]*\)\s*:\s*array\s*\{\s*return\s*\[(.*?)\]", re.S)
|
|
@@ -51,6 +52,47 @@ def rel(path, root):
|
|
|
51
52
|
return os.path.relpath(path, root).replace(os.sep, "/")
|
|
52
53
|
|
|
53
54
|
|
|
55
|
+
def ctor_of(src):
|
|
56
|
+
"""(slug, label expr) of a factory's own constructor, or None.
|
|
57
|
+
|
|
58
|
+
Since 1.0.11 the slug of a Pro-only element (modal, popover, code) is a class
|
|
59
|
+
constant on a shared `*TypeFactoryAbstract` - the Free build registers a locked
|
|
60
|
+
stand-in from the same abstract - so `self::TYPE` is resolved here."""
|
|
61
|
+
m = RE_CTOR.search(src)
|
|
62
|
+
if not m:
|
|
63
|
+
return None
|
|
64
|
+
slug = m.group(1)
|
|
65
|
+
if slug.startswith("'"):
|
|
66
|
+
return slug.strip("'"), m.group(2)
|
|
67
|
+
consts = dict(RE_CONST.findall(src))
|
|
68
|
+
name = slug.split("::", 1)[1]
|
|
69
|
+
return (consts[name], m.group(2)) if name in consts else None
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def factory_slugs(node_root, suffixes=("TypeFactory.php", "MResourceFactory.php")):
|
|
73
|
+
"""Concrete factory class name -> type slug, a slug inherited from the abstract
|
|
74
|
+
when the factory has no constructor of its own. The other extractors share this
|
|
75
|
+
so the three tables cannot disagree about which types exist."""
|
|
76
|
+
inherited = {}
|
|
77
|
+
for path in walk(node_root, ("TypeFactoryAbstract.php",)):
|
|
78
|
+
src = read(path)
|
|
79
|
+
cls = RE_CLASS.search(src)
|
|
80
|
+
c = ctor_of(src)
|
|
81
|
+
if cls and c:
|
|
82
|
+
inherited[cls.group(2)] = c[0]
|
|
83
|
+
out = {}
|
|
84
|
+
for path in walk(node_root, suffixes):
|
|
85
|
+
src = read(path)
|
|
86
|
+
cls = RE_CLASS.search(src)
|
|
87
|
+
if not cls:
|
|
88
|
+
continue
|
|
89
|
+
c = ctor_of(src)
|
|
90
|
+
slug = c[0] if c else inherited.get(cls.group(3))
|
|
91
|
+
if slug:
|
|
92
|
+
out[cls.group(2)] = slug
|
|
93
|
+
return out
|
|
94
|
+
|
|
95
|
+
|
|
54
96
|
def walk(root, suffixes):
|
|
55
97
|
for dirpath, _dirs, files in os.walk(root):
|
|
56
98
|
for fn in files:
|
|
@@ -68,6 +110,18 @@ def extract(plugin_root, out_dir):
|
|
|
68
110
|
if not os.path.isdir(node_root):
|
|
69
111
|
sys.exit("no Mosaic/NodeTypes under %s" % plugin_root)
|
|
70
112
|
|
|
113
|
+
# A concrete factory with no constructor of its own takes its slug from the
|
|
114
|
+
# abstract it extends (1.0.11 split modal / popover / code this way).
|
|
115
|
+
inherited_ctor = {}
|
|
116
|
+
abstract_src = {}
|
|
117
|
+
for path in walk(node_root, ("TypeFactoryAbstract.php",)):
|
|
118
|
+
src = read(path)
|
|
119
|
+
cls = RE_CLASS.search(src)
|
|
120
|
+
c = ctor_of(src)
|
|
121
|
+
if cls and c:
|
|
122
|
+
inherited_ctor[cls.group(2)] = c
|
|
123
|
+
abstract_src[cls.group(2)] = src
|
|
124
|
+
|
|
71
125
|
types = []
|
|
72
126
|
# `*MResourceFactory.php` as well as `*TypeFactory.php`: two node types -
|
|
73
127
|
# `fieldset-legend` and `fieldset-content` - are declared only by the former,
|
|
@@ -78,7 +132,7 @@ def extract(plugin_root, out_dir):
|
|
|
78
132
|
for path in sorted(walk(node_root, ("TypeFactory.php", "MResourceFactory.php"))):
|
|
79
133
|
src = read(path)
|
|
80
134
|
cls = RE_CLASS.search(src)
|
|
81
|
-
ctor =
|
|
135
|
+
ctor = ctor_of(src) or (inherited_ctor.get(cls.group(3)) if cls else None)
|
|
82
136
|
if not ctor:
|
|
83
137
|
continue # abstract factory with no own slug
|
|
84
138
|
relpath = rel(path, plugin_root)
|
|
@@ -100,14 +154,17 @@ def extract(plugin_root, out_dir):
|
|
|
100
154
|
sibling)))
|
|
101
155
|
data_extends = dcls.group(3) if dcls else ""
|
|
102
156
|
break
|
|
103
|
-
|
|
104
|
-
|
|
157
|
+
# isLink / canBeParentFor / aliases / default variant may sit on that abstract too
|
|
158
|
+
base = abstract_src.get(cls.group(3), "") if cls else ""
|
|
159
|
+
bools = dict(RE_METHOD_BOOL.findall(base))
|
|
160
|
+
bools.update(RE_METHOD_BOOL.findall(src))
|
|
161
|
+
alias = RE_ALIAS.search(src) or RE_ALIAS.search(base)
|
|
105
162
|
aliases = re.findall(r"'([^']+)'", alias.group(1)) if alias else []
|
|
106
|
-
dflt = RE_DEFAULT_CLASS.search(src)
|
|
163
|
+
dflt = RE_DEFAULT_CLASS.search(src) or RE_DEFAULT_CLASS.search(base)
|
|
107
164
|
types.append(
|
|
108
165
|
{
|
|
109
|
-
"type": ctor
|
|
110
|
-
"label": php_label(ctor
|
|
166
|
+
"type": ctor[0],
|
|
167
|
+
"label": php_label(ctor[1]),
|
|
111
168
|
"class": cls.group(2) if cls else "",
|
|
112
169
|
"extends": cls.group(3) if cls else "",
|
|
113
170
|
"abstract": "yes" if (cls and cls.group(1)) else "no",
|
|
@@ -32,6 +32,8 @@ import os
|
|
|
32
32
|
import re
|
|
33
33
|
import sys
|
|
34
34
|
|
|
35
|
+
from extract_node_types import factory_slugs
|
|
36
|
+
|
|
35
37
|
RE_CLASS = re.compile(r"^\s*(?:final\s+)?(?:abstract\s+)?class\s+(\w+)\s+extends\s+(\w+)", re.M)
|
|
36
38
|
RE_CAN_BE_PARENT = re.compile(
|
|
37
39
|
r"function\s+canBeParentFor\s*\([^)]*\)\s*:\s*bool\s*\{(.*?)\n \}", re.S
|
|
@@ -68,16 +70,16 @@ def extract(plugin_root, out_dir):
|
|
|
68
70
|
sys.exit("no Mosaic/NodeTypes under %s" % plugin_root)
|
|
69
71
|
|
|
70
72
|
# factory class name -> type slug, so instanceof targets can be named as types
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
# Abstracts are read as sources too: since 1.0.11 a Pro-only type (modal,
|
|
74
|
+
# popover, code) keeps its canBeParentFor on a shared `*TypeFactoryAbstract`.
|
|
75
|
+
class_to_type, sources = factory_slugs(node_root), {}
|
|
76
|
+
for path in walk(node_root, ("TypeFactory.php", "MResourceFactory.php",
|
|
77
|
+
"TypeFactoryAbstract.php")):
|
|
73
78
|
src = read(path)
|
|
74
79
|
cls = RE_CLASS.search(src)
|
|
75
80
|
if not cls:
|
|
76
81
|
continue
|
|
77
82
|
sources[cls.group(1)] = (path, src, cls.group(2))
|
|
78
|
-
ctor = RE_CTOR.search(src)
|
|
79
|
-
if ctor:
|
|
80
|
-
class_to_type[cls.group(1)] = ctor.group(1)
|
|
81
83
|
|
|
82
84
|
def resolve(cls_name):
|
|
83
85
|
"""A factory may inherit canBeParentFor from an abstract ancestor."""
|
|
@@ -95,7 +97,12 @@ def extract(plugin_root, out_dir):
|
|
|
95
97
|
for cls_name, slug in sorted(class_to_type.items(), key=lambda kv: kv[1]):
|
|
96
98
|
body, defined_in = resolve(cls_name)
|
|
97
99
|
path, src, _parent = sources[cls_name]
|
|
98
|
-
|
|
100
|
+
# canBeNestedChildFor may sit on the abstract as well (modal-overlay, 1.0.11)
|
|
101
|
+
nsrc, c = src, cls_name
|
|
102
|
+
while "function canBeNestedChildFor" not in nsrc and sources.get(c, (0, 0, ""))[2] in sources:
|
|
103
|
+
c = sources[c][2]
|
|
104
|
+
nsrc = sources[c][1]
|
|
105
|
+
nested = "yes" if "function canBeNestedChildFor" in nsrc else ""
|
|
99
106
|
# `yes` alone says a runtime ancestry rule exists and not what it wants.
|
|
100
107
|
# These methods walk the parent chain looking for one MResource class -
|
|
101
108
|
# `radio-input` wants a `ChoiceElementMResource` above it - and that is
|
|
@@ -104,10 +111,14 @@ def extract(plugin_root, out_dir):
|
|
|
104
111
|
if nested:
|
|
105
112
|
mbody = re.search(
|
|
106
113
|
r"function\s+canBeNestedChildFor\s*\([^)]*\)\s*:\s*bool\s*\{(.*?)\n \}",
|
|
107
|
-
|
|
114
|
+
nsrc, re.S)
|
|
108
115
|
if mbody:
|
|
109
116
|
for cls in re.findall(r"instanceof\s+(\w+)ElementMResource\b", mbody.group(1)):
|
|
110
117
|
nested_under.append(cls)
|
|
118
|
+
# 1.0.11 also compares type slugs: `getType() === ModalElementTypeFactoryAbstract::TYPE`
|
|
119
|
+
for cls in re.findall(r"getType\(\)\s*===\s*(\w+)ElementTypeFactory(?:Abstract)?::TYPE", mbody.group(1)):
|
|
120
|
+
if cls not in nested_under:
|
|
121
|
+
nested_under.append(cls)
|
|
111
122
|
|
|
112
123
|
if body is None:
|
|
113
124
|
rule, allowed = "none", [] # inherited default on the abstract base
|