@schukai/monster 5.0.0 → 5.0.1
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 +17 -0
- package/README.md +8 -0
- package/documentation/migrations/monster-5-options.md +90 -0
- package/package.json +1 -1
- package/source/types/version.mjs +1 -1
- package/test/cases/packaging.mjs +60 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,9 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
## [5.0.1] - 2026-10-11
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **docs:** ship Monster 5 migration guide ([#597](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/597))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
## [5.0.0] - 2026-10-10
|
|
6
14
|
|
|
15
|
+
### Breaking Changes
|
|
7
16
|
|
|
17
|
+
- **custom-element:** `getOption()`, `setOption()` and `setOptions()` now throw
|
|
18
|
+
`OptionsNotInitializedError` while `defaults` or `customization` are being
|
|
19
|
+
evaluated ([#596](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/596)).
|
|
20
|
+
Keep both getters and their helpers declarative. Use `initMethodSymbol` for
|
|
21
|
+
initialized constructor options and `assembleMethodSymbol` after late
|
|
22
|
+
attributes or script configuration have been applied. Monster 5 deliberately
|
|
23
|
+
provides no compatibility switch, early fallback or write queue. See the
|
|
24
|
+
[Monster 5 options migration guide](documentation/migrations/monster-5-options.md).
|
|
8
25
|
|
|
9
26
|
## [4.154.12] - 2026-10-10
|
|
10
27
|
|
package/README.md
CHANGED
|
@@ -25,6 +25,14 @@ For certain functions, additional [polyfills](#polyfill) may be required.
|
|
|
25
25
|
|
|
26
26
|
To access our documentation and examples, visit [monsterjs.org/](https://monsterjs.org/).
|
|
27
27
|
|
|
28
|
+
### Migrating to Monster 5
|
|
29
|
+
|
|
30
|
+
Monster 5 makes the custom-element option lifecycle strict. Option access is
|
|
31
|
+
not available while `defaults` or `customization` are being evaluated. See the
|
|
32
|
+
[Monster 5 options migration guide](documentation/migrations/monster-5-options.md)
|
|
33
|
+
for the lifecycle contract, migration examples and the correct use of
|
|
34
|
+
`initMethodSymbol` and `assembleMethodSymbol`.
|
|
35
|
+
|
|
28
36
|
## Installation
|
|
29
37
|
|
|
30
38
|
Install Monster using npm, Yarn, or pnpm:
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Monster 5: initialized options
|
|
2
|
+
|
|
3
|
+
`CustomElement.getOption()`, `setOption()` and `setOptions()` require an initialized
|
|
4
|
+
option observer. Calls made while the constructor evaluates `defaults` or
|
|
5
|
+
`customization` throw `OptionsNotInitializedError`. The error is exported from
|
|
6
|
+
`source/dom/customelement.mjs` and the main Monster entry point; its `method` and
|
|
7
|
+
`component` properties identify the attempted operation and class.
|
|
8
|
+
|
|
9
|
+
Monster 4.154.10 restored a fallback for early reads. Monster 5 removes that
|
|
10
|
+
fallback. There is no compatibility switch, dependency injection setting or
|
|
11
|
+
queue for early writes. Normal fallback values for missing initialized options
|
|
12
|
+
continue to work, as do `false`, `0`, `""` and `null`.
|
|
13
|
+
|
|
14
|
+
## Lifecycle
|
|
15
|
+
|
|
16
|
+
1. The constructor reads `defaults`, applies available `data-monster-option-*`
|
|
17
|
+
attributes and applies `customization` (evaluated once).
|
|
18
|
+
2. It creates the option observer, then calls `initMethodSymbol`. All three
|
|
19
|
+
option methods are now usable. Derived instance fields are not initialized
|
|
20
|
+
yet: this hook runs inside the base constructor.
|
|
21
|
+
3. On first connection, option attributes are read again. The base assembly
|
|
22
|
+
merges `data-monster-options`, then the script selected by
|
|
23
|
+
`data-monster-options-selector`, before rendering and connecting updaters.
|
|
24
|
+
4. Runtime setters notify observers. `setOptions()` merges without resetting
|
|
25
|
+
defaults. Reconnection rebinds the existing DOM and updater snapshot; it does
|
|
26
|
+
not repeat assembly or reload the JSON/script configuration.
|
|
27
|
+
|
|
28
|
+
Available attributes depend on the creation path. In particular,
|
|
29
|
+
`document.createElement()` cannot see attributes the caller will set later.
|
|
30
|
+
An initialized API is therefore not a promise that all configuration sources
|
|
31
|
+
have already been applied. Existing attribute conversion and precedence remain
|
|
32
|
+
unchanged, including the attribute reread on connection.
|
|
33
|
+
|
|
34
|
+
## Migration
|
|
35
|
+
|
|
36
|
+
This creates a circular dependency and is no longer supported:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
get defaults() {
|
|
40
|
+
return { ...super.defaults, title: this.getOption("labels.title", "Details") };
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Define initial values without reading the options under construction:
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
get defaults() {
|
|
48
|
+
return {
|
|
49
|
+
...super.defaults,
|
|
50
|
+
labels: { title: "Details" },
|
|
51
|
+
templates: {
|
|
52
|
+
main: '<h2 data-monster-replace="path:labels.title"></h2>',
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Updater-bound markup reads the assembled configuration and follows subsequent
|
|
59
|
+
changes. For imperative work that needs JSON/script options, use the existing
|
|
60
|
+
assembly hook after its `super` call:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
[assembleMethodSymbol]() {
|
|
64
|
+
super[assembleMethodSymbol]();
|
|
65
|
+
this.configureFromResource(this.getOption("resourceConfig"));
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
At that point the base template has already rendered. Do not move template
|
|
71
|
+
configuration after rendering and expect it to rebuild automatically. Prefer a
|
|
72
|
+
static template with updater bindings, or update the rendered component through
|
|
73
|
+
its established API. Do not permanently cache IDs or context keys from
|
|
74
|
+
constructor-time fallbacks.
|
|
75
|
+
|
|
76
|
+
Work needing only constructor configuration can use `initMethodSymbol` after
|
|
77
|
+
its `super` call. Callbacks stored in defaults may read options when invoked
|
|
78
|
+
later; the restriction concerns execution during initialization, not where a
|
|
79
|
+
callback is declared. The same rule applies to helpers called by either getter.
|
|
80
|
+
|
|
81
|
+
Consumer subclasses must migrate before adopting Monster 5. Other option
|
|
82
|
+
classes, including the deprecated `BaseWithOptions`, are outside this change.
|
|
83
|
+
|
|
84
|
+
## Verification
|
|
85
|
+
|
|
86
|
+
Issue #596 adds API lifecycle tests, a local AST call-graph check, and browser
|
|
87
|
+
construction/assembly coverage for the registered component catalog. The static
|
|
88
|
+
check resolves direct calls, local helpers and methods; it is not a proof about
|
|
89
|
+
imported or dynamically selected functions. Browser coverage complements it.
|
|
90
|
+
Existing form, updater, datatable and reconnect suites remain release gates.
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.6"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","exports":{".":"./source/monster.mjs","./CHANGELOG.md":"./CHANGELOG.md","./LICENSE":"./LICENSE","./README.md":"./README.md","./package.json":"./package.json","./source/*":"./source/*","./test/*":"./test/*"},"files":["source","test/cases","test/util","CHANGELOG.md"],"homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"sideEffects":["./source/monster.mjs","./source/components/**","./source/i18n/**","./test/**"],"type":"module","version":"5.0.
|
|
1
|
+
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.6"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","exports":{".":"./source/monster.mjs","./CHANGELOG.md":"./CHANGELOG.md","./LICENSE":"./LICENSE","./README.md":"./README.md","./documentation/migrations/monster-5-options.md":"./documentation/migrations/monster-5-options.md","./package.json":"./package.json","./source/*":"./source/*","./test/*":"./test/*"},"files":["source","test/cases","test/util","documentation/migrations/monster-5-options.md","CHANGELOG.md"],"homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"sideEffects":["./source/monster.mjs","./source/components/**","./source/i18n/**","./test/**"],"type":"module","version":"5.0.1"}
|
package/source/types/version.mjs
CHANGED
package/test/cases/packaging.mjs
CHANGED
|
@@ -27,6 +27,10 @@ function readBuildNix() {
|
|
|
27
27
|
return readFileSync(join(projectRoot, "nix/scripts/build.nix"), "utf8");
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
function readProjectFile(path) {
|
|
31
|
+
return readFileSync(join(projectRoot, path), "utf8");
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
describe("Packaging issue #577", function () {
|
|
31
35
|
describe("exports map", function () {
|
|
32
36
|
it("should resolve every literal export target to an existing file", function () {
|
|
@@ -161,6 +165,62 @@ describe("Packaging issue #577", function () {
|
|
|
161
165
|
).to.be.true;
|
|
162
166
|
}
|
|
163
167
|
});
|
|
168
|
+
|
|
169
|
+
it("should ship and export the Monster 5 migration guide", function () {
|
|
170
|
+
const migrationPath = "documentation/migrations/monster-5-options.md";
|
|
171
|
+
const pkg = readPackageJson();
|
|
172
|
+
const buildNix = readBuildNix();
|
|
173
|
+
|
|
174
|
+
expect(pkg.files).to.include(migrationPath);
|
|
175
|
+
expect(pkg.exports[`./${migrationPath}`]).to.equal(`./${migrationPath}`);
|
|
176
|
+
expect(existsSync(join(projectRoot, migrationPath))).to.be.true;
|
|
177
|
+
expect(buildNix).to.include(migrationPath);
|
|
178
|
+
expect(buildNix).to.include(`package/${migrationPath}`);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
describe("Monster 5 migration contract", function () {
|
|
183
|
+
it("should document the strict lifecycle and migration phases", function () {
|
|
184
|
+
const guide = readProjectFile(
|
|
185
|
+
"documentation/migrations/monster-5-options.md",
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
for (const contract of [
|
|
189
|
+
"OptionsNotInitializedError",
|
|
190
|
+
"getOption()",
|
|
191
|
+
"setOption()",
|
|
192
|
+
"setOptions()",
|
|
193
|
+
"defaults",
|
|
194
|
+
"customization",
|
|
195
|
+
"document.createElement()",
|
|
196
|
+
"initMethodSymbol",
|
|
197
|
+
"assembleMethodSymbol",
|
|
198
|
+
"There is no compatibility switch",
|
|
199
|
+
]) {
|
|
200
|
+
expect(guide, `migration guide is missing ${contract}`).to.include(
|
|
201
|
+
contract,
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it("should describe the breaking change in the 5.0.0 changelog", function () {
|
|
207
|
+
const changelog = readProjectFile("CHANGELOG.md");
|
|
208
|
+
const release = changelog
|
|
209
|
+
.split("## [5.0.0]")[1]
|
|
210
|
+
.split("## [4.154.12]")[0];
|
|
211
|
+
|
|
212
|
+
for (const contract of [
|
|
213
|
+
"### Breaking Changes",
|
|
214
|
+
"OptionsNotInitializedError",
|
|
215
|
+
"initMethodSymbol",
|
|
216
|
+
"assembleMethodSymbol",
|
|
217
|
+
"documentation/migrations/monster-5-options.md",
|
|
218
|
+
]) {
|
|
219
|
+
expect(release, `5.0.0 changelog is missing ${contract}`).to.include(
|
|
220
|
+
contract,
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
164
224
|
});
|
|
165
225
|
|
|
166
226
|
describe("generated barrel", function () {
|