elegance-js 2.0.11 → 2.0.13
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/dist/client/client.mjs +19 -7
- package/dist/index.mjs +1 -2
- package/dist/page_compiler.mjs +0 -1
- package/dist/server/state.d.ts +1 -1
- package/dist/server/state.mjs +1 -2
- package/package.json +1 -1
package/dist/client/client.mjs
CHANGED
|
@@ -177,7 +177,7 @@ var sanitizePathname = (pn) => {
|
|
|
177
177
|
return pn.slice(0, -1);
|
|
178
178
|
};
|
|
179
179
|
var currentPage = sanitizePathname(loc.pathname);
|
|
180
|
-
var createStateManager = (subjects) => {
|
|
180
|
+
var createStateManager = (subjects, bindLevel) => {
|
|
181
181
|
const state = {
|
|
182
182
|
subjects: subjects.map((subject) => {
|
|
183
183
|
const s = {
|
|
@@ -199,11 +199,23 @@ var createStateManager = (subjects) => {
|
|
|
199
199
|
destroy: (s) => {
|
|
200
200
|
state.subjects.splice(state.subjects.indexOf(s), 1);
|
|
201
201
|
},
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
202
|
+
get: (id) => {
|
|
203
|
+
const subject = state.subjects.find((s) => s.id === id);
|
|
204
|
+
if (subject) return subject;
|
|
205
|
+
if (bindLevel === 2 /* SCOPED */) return void 0;
|
|
206
|
+
const parts = window.location.pathname.split("/").filter(Boolean);
|
|
207
|
+
const paths = [
|
|
208
|
+
...parts.map((_, i) => "/" + parts.slice(0, i + 1).join("/")),
|
|
209
|
+
"/"
|
|
210
|
+
].reverse();
|
|
211
|
+
for (const item of paths) {
|
|
212
|
+
const sanitized = sanitizePathname(item);
|
|
213
|
+
const data = ld[sanitized];
|
|
214
|
+
if (!data) continue;
|
|
215
|
+
const entry = data.stateManager.get(id);
|
|
216
|
+
if (entry) return entry;
|
|
217
|
+
}
|
|
218
|
+
return void 0;
|
|
207
219
|
},
|
|
208
220
|
/**
|
|
209
221
|
Bind is deprecated, but kept as a paramater to not upset legacy code.
|
|
@@ -228,7 +240,7 @@ var initPageData = (data, currentPage2, previousPage, bindLevel) => {
|
|
|
228
240
|
}
|
|
229
241
|
let state = data?.stateManager;
|
|
230
242
|
if (!state) {
|
|
231
|
-
state = createStateManager(data.state || []);
|
|
243
|
+
state = createStateManager(data.state || [], bindLevel);
|
|
232
244
|
data.stateManager = state;
|
|
233
245
|
}
|
|
234
246
|
for (const subject of state.subjects) {
|
package/dist/index.mjs
CHANGED
|
@@ -57,8 +57,7 @@ var state = (value, options) => {
|
|
|
57
57
|
const serverStateEntry = {
|
|
58
58
|
id: __SERVER_CURRENT_STATE_ID__ += 1,
|
|
59
59
|
value,
|
|
60
|
-
type: 1 /* STATE
|
|
61
|
-
bind: options?.bind
|
|
60
|
+
type: 1 /* STATE */
|
|
62
61
|
};
|
|
63
62
|
globalThis.__SERVER_CURRENT_STATE__.push(serverStateEntry);
|
|
64
63
|
if (Array.isArray(value)) {
|
package/dist/page_compiler.mjs
CHANGED
|
@@ -800,7 +800,6 @@ var buildPages = async (DIST_DIR2) => {
|
|
|
800
800
|
if (isPage == false) {
|
|
801
801
|
continue;
|
|
802
802
|
}
|
|
803
|
-
console.log("building page with", DIST_DIR2, `d: ${directory}`, filePath, name);
|
|
804
803
|
try {
|
|
805
804
|
const hardReloadForPage = await buildPage(DIST_DIR2, directory, filePath, name);
|
|
806
805
|
if (hardReloadForPage) {
|
package/dist/server/state.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ type ClientSubjectGeneric<T> = Omit<ClientSubject, "value"> & {
|
|
|
4
4
|
};
|
|
5
5
|
type Widen<T> = T extends number ? number : T extends string ? string : T extends boolean ? boolean : T extends {} ? T & Record<string, any> : T;
|
|
6
6
|
export declare const state: <U extends number | string | boolean | {} | undefined | null | Array<any>>(value: U, options?: {
|
|
7
|
-
|
|
7
|
+
isGlobal: boolean;
|
|
8
8
|
}) => {
|
|
9
9
|
id: number;
|
|
10
10
|
value: Widen<U>;
|
package/dist/server/state.mjs
CHANGED
|
@@ -28,8 +28,7 @@ var state = (value, options) => {
|
|
|
28
28
|
const serverStateEntry = {
|
|
29
29
|
id: __SERVER_CURRENT_STATE_ID__ += 1,
|
|
30
30
|
value,
|
|
31
|
-
type: 1 /* STATE
|
|
32
|
-
bind: options?.bind
|
|
31
|
+
type: 1 /* STATE */
|
|
33
32
|
};
|
|
34
33
|
globalThis.__SERVER_CURRENT_STATE__.push(serverStateEntry);
|
|
35
34
|
if (Array.isArray(value)) {
|