elegance-js 2.0.19 → 2.1.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/dist/global.d.ts CHANGED
@@ -15,6 +15,7 @@ declare global {
15
15
  id: number;
16
16
  bind?: number;
17
17
  }>;
18
+ /** User defined object attributes. Mostly unused, use at your own risk. */
18
19
  var __SERVER_CURRENT_OBJECT_ATTRIBUTES__: Array<ObjectAttribute<any>>;
19
20
  var __SERVER_CURRENT_LOADHOOKS__: Array<any>;
20
21
  var __SERVER_CURRENT_LAYOUTS__: Map<string, number>;
@@ -44,6 +45,21 @@ declare global {
44
45
  type PageProps = {
45
46
  pageName: string;
46
47
  };
48
+ /** Internal use only. */
49
+ type PageInformation = {
50
+ isDynamic: boolean;
51
+ filePath: string;
52
+ };
53
+ /** Internal use only. */
54
+ type LayoutInformation = {
55
+ isDynamic: boolean;
56
+ filePath: string;
57
+ };
58
+ type Pathname = string;
59
+ /** Modules that are shipped to the browser. */
60
+ type ShippedModules = {
61
+ [key: string]: string;
62
+ };
47
63
  type Page = (AnyBuiltElement) | ((props: PageProps) => AnyBuiltElement | Promise<AnyBuiltElement>);
48
64
  type Metadata = (() => (AnyBuiltElement)) | (() => Promise<AnyBuiltElement>);
49
65
  type ObjectAttribute<T> = T extends ObjectAttributeType.STATE ? {
@@ -284,10 +300,6 @@ declare global {
284
300
  onTransitionEnd?: EleganceEventListener;
285
301
  onToggle?: EleganceEventListener;
286
302
  }
287
- /** Generated client-page data. Contains things like loadHooks, state, etc. */
288
- var pd: Record<string, any>;
289
- /** Generated layout-data. Contains things like loadHooks, state, etc.*/
290
- var ld: Record<string, any>;
291
303
  var client: {
292
304
  navigateLocally: (target: string, pushState?: boolean) => any;
293
305
  fetchPage: (targetURL: URL) => Promise<Document | void>;
@@ -310,7 +322,8 @@ declare global {
310
322
  id: number;
311
323
  bind?: string;
312
324
  }[]) => [ClientSubject["value"]];
313
- observe: (subject: ClientSubject, observer: (value: any) => any, subject_key: string) => void;
325
+ observe: (subject: ClientSubject, observer: (value: any) => any, key: string) => void;
326
+ unobserve: (subject: ClientSubject, key: string) => void;
314
327
  destroy: (subject: ClientSubject) => void;
315
328
  };
316
329
  }
package/dist/index.mjs CHANGED
@@ -87,7 +87,6 @@ var reactiveMap = function(template, deps) {
87
87
  const attributes = [];
88
88
  const currentlyWatched = [];
89
89
  const createElements = () => {
90
- const state3 = pd[client.currentPage].stateManager;
91
90
  for (let i = 0; i < value.length; i += 1) {
92
91
  const htmlElement = client.renderRecursively(templateFn2.value(value[i], i, ...deps2), attributes);
93
92
  htmlElement.setAttribute("map-id", subject2.id.toString());
@@ -100,7 +99,7 @@ var reactiveMap = function(template, deps) {
100
99
  case 2 /* OBSERVER */: {
101
100
  const { field, subjects, updateCallback } = attribute;
102
101
  for (const reference of subjects) {
103
- const subject3 = state3.get(reference.id, reference.bind);
102
+ const subject3 = state2.get(reference.id, reference.bind);
104
103
  const updateFunction = (value2) => {
105
104
  values[subject3.id] = value2;
106
105
  try {
@@ -113,7 +112,7 @@ var reactiveMap = function(template, deps) {
113
112
  }
114
113
  };
115
114
  updateFunction(subject3.value);
116
- state3.observe(subject3, updateFunction, elementKey);
115
+ state2.observe(subject3, updateFunction, elementKey);
117
116
  currentlyWatched.push({
118
117
  key: elementKey,
119
118
  subject: subject3
@@ -141,10 +140,8 @@ var reactiveMap = function(template, deps) {
141
140
  for (const el2 of list) {
142
141
  el2.remove();
143
142
  }
144
- const pageData = pd[client.currentPage];
145
- const state3 = pageData.stateManager;
146
143
  for (const watched of currentlyWatched) {
147
- state3.unobserve(watched.subject, watched.key);
144
+ state2.unobserve(watched.subject, watched.key);
148
145
  }
149
146
  currentlyWatched.splice(0, currentlyWatched.length);
150
147
  };
@@ -185,6 +182,10 @@ var initializeState = () => globalThis.__SERVER_CURRENT_STATE__ = [];
185
182
  var getState = () => {
186
183
  return globalThis.__SERVER_CURRENT_STATE__;
187
184
  };
185
+ var initializeObjectAttributes = () => globalThis.__SERVER_CURRENT_OBJECT_ATTRIBUTES__ = [];
186
+ var getObjectAttributes = () => {
187
+ return globalThis.__SERVER_CURRENT_OBJECT_ATTRIBUTES__;
188
+ };
188
189
 
189
190
  // src/server/observe.ts
190
191
  var observe = (refs, update) => {
@@ -203,7 +204,9 @@ export {
203
204
  createLoadHook,
204
205
  eventListener,
205
206
  getLoadHooks,
207
+ getObjectAttributes,
206
208
  getState,
209
+ initializeObjectAttributes,
207
210
  initializeState,
208
211
  loadHook,
209
212
  observe,
@@ -1 +1,6 @@
1
+ export declare const PAGE_MAP: Map<string, PageInformation>;
2
+ export declare const LAYOUT_MAP: Map<string, LayoutInformation>;
1
3
  export declare const processPageElements: (element: Child, objectAttributes: Array<any>, recursionLevel: number, stack?: any[]) => Child;
4
+ export declare const buildDynamicPage: (DIST_DIR: string, directory: string, pageInfo: PageInformation) => Promise<{
5
+ resultHTML: any;
6
+ }>;