Comparing version 0.8.8 to 0.8.9
@@ -43,6 +43,8 @@ function _define_property(obj, key, value) { | ||
_define_property(this, "page", void 0); | ||
_define_property(this, "_base_name", void 0); | ||
_define_property(this, "isLayout", void 0); | ||
this.page = page; | ||
this._base_name = "Layout"; | ||
this.isLayout = true; | ||
} | ||
} |
@@ -18,3 +18,3 @@ function _define_property(obj, key, value) { | ||
static createAndHydrate(element) { | ||
const dataEl = $(element).next("script.__RUNE_DATA__.".concat(this.name)); | ||
const dataEl = $(element).next("script.__RUNE_DATA__.".concat(this.name, '[data-rune-base-name="Page"]')); | ||
if (dataEl === null) { | ||
@@ -32,4 +32,6 @@ throw new Error("No __RUNE_DATA__ script found"); | ||
_define_property(this, "sharedData", void 0); | ||
_define_property(this, "_base_name", void 0); | ||
this.sharedData = sharedData; | ||
this._base_name = "Page"; | ||
} | ||
} |
@@ -143,3 +143,3 @@ function _define_property(obj, key, value) { | ||
static createAndHydrate(element) { | ||
const dataEl = $(element).next("script.__RUNE_DATA__.".concat(this.name)); | ||
const dataEl = $(element).next("script.__RUNE_DATA__.".concat(this.name, '[data-rune-base-name="View"]')); | ||
if (dataEl === null) { | ||
@@ -156,2 +156,3 @@ throw new Error("No __RUNE_DATA__ script found"); | ||
super(...args); | ||
_define_property(this, "_base_name", "View"); | ||
_define_property(this, "subViewsFromTemplate", []); | ||
@@ -158,0 +159,0 @@ _define_property(this, "ignoreRefreshOnlySubViewFromParent", false); |
@@ -84,3 +84,3 @@ function _define_property(obj, key, value) { | ||
html = startTag.includes('class="') ? html.replace('class="', "".concat(runeDataset, ' class="').concat(className, " ")) : startTag.includes("class='") ? html.replace("class='", "".concat(runeDataset, " class='").concat(className, " ")) : html.replace("<".concat(startTagName), "<".concat(startTagName, " ").concat(runeDataset, ' class="').concat(className, '"')); | ||
return isSSR ? html.replace(html, "".concat(html, '<script class="__RUNE_DATA__ ').concat(this, '" type="application/json">').concat(_htmlEscapeJsonString(JSON.stringify({ | ||
return isSSR ? html.replace(html, "".concat(html, '<script class="__RUNE_DATA__ ').concat(this, '" type="application/json" data-rune-base-name="').concat(this._base_name, '">').concat(_htmlEscapeJsonString(JSON.stringify({ | ||
data: this.data, | ||
@@ -130,2 +130,3 @@ args: this._args, | ||
_define_property(this, "key", ""); | ||
_define_property(this, "_base_name", "VirtualView"); | ||
_define_property(this, "_data", void 0); | ||
@@ -132,0 +133,0 @@ _define_property(this, "_args", void 0); |
@@ -5,2 +5,3 @@ import { VirtualView } from './VirtualView'; | ||
page: Page<object>; | ||
protected _base_name: string; | ||
readonly isLayout: boolean; | ||
@@ -7,0 +8,0 @@ constructor(data: T, page: Page<object>); |
@@ -53,6 +53,8 @@ "use strict"; | ||
_define_property(this, "page", void 0); | ||
_define_property(this, "_base_name", void 0); | ||
_define_property(this, "isLayout", void 0); | ||
this.page = page; | ||
this._base_name = "Layout"; | ||
this.isLayout = true; | ||
} | ||
} |
import { View } from './View'; | ||
export declare class Page<T extends object> extends View<T> { | ||
sharedData?: Record<string, any> | undefined; | ||
protected _base_name: string; | ||
constructor(data: T, sharedData?: Record<string, any> | undefined, ...args: any[]); | ||
static createAndHydrate(element: HTMLElement): Page<any>; | ||
} |
@@ -28,3 +28,3 @@ "use strict"; | ||
static createAndHydrate(element) { | ||
const dataEl = (0, _$Element.$)(element).next("script.__RUNE_DATA__.".concat(this.name)); | ||
const dataEl = (0, _$Element.$)(element).next("script.__RUNE_DATA__.".concat(this.name, '[data-rune-base-name="Page"]')); | ||
if (dataEl === null) { | ||
@@ -42,4 +42,6 @@ throw new Error("No __RUNE_DATA__ script found"); | ||
_define_property(this, "sharedData", void 0); | ||
_define_property(this, "_base_name", void 0); | ||
this.sharedData = sharedData; | ||
this._base_name = "Page"; | ||
} | ||
} |
import { VirtualView } from './VirtualView'; | ||
import { type Enable } from './Enable'; | ||
export declare class View<T extends object = object> extends VirtualView<T> { | ||
protected _base_name: string; | ||
subViewsFromTemplate: View<T>[]; | ||
@@ -5,0 +6,0 @@ ignoreRefreshOnlySubViewFromParent: boolean; |
@@ -153,3 +153,3 @@ "use strict"; | ||
static createAndHydrate(element) { | ||
const dataEl = (0, _$Element.$)(element).next("script.__RUNE_DATA__.".concat(this.name)); | ||
const dataEl = (0, _$Element.$)(element).next("script.__RUNE_DATA__.".concat(this.name, '[data-rune-base-name="View"]')); | ||
if (dataEl === null) { | ||
@@ -166,2 +166,3 @@ throw new Error("No __RUNE_DATA__ script found"); | ||
super(...args); | ||
_define_property(this, "_base_name", "View"); | ||
_define_property(this, "subViewsFromTemplate", []); | ||
@@ -168,0 +169,0 @@ _define_property(this, "ignoreRefreshOnlySubViewFromParent", false); |
import { Base } from './Base'; | ||
export declare class VirtualView<T extends object> extends Base { | ||
key: string; | ||
protected _base_name: string; | ||
private readonly _data; | ||
@@ -5,0 +6,0 @@ readonly _args: any[]; |
@@ -114,3 +114,3 @@ "use strict"; | ||
html = startTag.includes('class="') ? html.replace('class="', "".concat(runeDataset, ' class="').concat(className, " ")) : startTag.includes("class='") ? html.replace("class='", "".concat(runeDataset, " class='").concat(className, " ")) : html.replace("<".concat(startTagName), "<".concat(startTagName, " ").concat(runeDataset, ' class="').concat(className, '"')); | ||
return isSSR ? html.replace(html, "".concat(html, '<script class="__RUNE_DATA__ ').concat(this, '" type="application/json">').concat((0, _htmlEscapeJsonString._htmlEscapeJsonString)(JSON.stringify({ | ||
return isSSR ? html.replace(html, "".concat(html, '<script class="__RUNE_DATA__ ').concat(this, '" type="application/json" data-rune-base-name="').concat(this._base_name, '">').concat((0, _htmlEscapeJsonString._htmlEscapeJsonString)(JSON.stringify({ | ||
data: this.data, | ||
@@ -160,2 +160,3 @@ args: this._args, | ||
_define_property(this, "key", ""); | ||
_define_property(this, "_base_name", "VirtualView"); | ||
_define_property(this, "_data", void 0); | ||
@@ -162,0 +163,0 @@ _define_property(this, "_args", void 0); |
{ | ||
"name": "rune-ts", | ||
"version": "0.8.8", | ||
"version": "0.8.9", | ||
"description": "Rune Core Library", | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -5,2 +5,3 @@ import { html, VirtualView } from './VirtualView'; | ||
export class Layout<T extends object> extends VirtualView<T> { | ||
protected override _base_name = 'Layout'; | ||
override readonly isLayout: boolean = true; | ||
@@ -7,0 +8,0 @@ |
@@ -5,2 +5,4 @@ import { View } from './View'; | ||
export class Page<T extends object> extends View<T> { | ||
protected override _base_name = 'Page'; | ||
constructor( | ||
@@ -15,3 +17,3 @@ data: T, | ||
static override createAndHydrate(element: HTMLElement) { | ||
const dataEl = $(element).next(`script.__RUNE_DATA__.${this.name}`); | ||
const dataEl = $(element).next(`script.__RUNE_DATA__.${this.name}[data-rune-base-name="Page"]`); | ||
if (dataEl === null) { | ||
@@ -18,0 +20,0 @@ throw new Error('No __RUNE_DATA__ script found'); |
@@ -54,3 +54,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
getPage(currentView: VirtualView<object>): Page<object> | undefined { | ||
let page: View<object> | undefined; | ||
let page: Page<object> | undefined; | ||
if (currentView) { | ||
@@ -62,3 +62,3 @@ page = this._getPageByParentView(currentView); | ||
if (element) { | ||
page = this.getUnknownView(element); | ||
page = this.getUnknownView(element) as Page<object> | undefined; | ||
} | ||
@@ -65,0 +65,0 @@ } |
@@ -9,2 +9,3 @@ import { rune } from './rune'; | ||
export class View<T extends object = object> extends VirtualView<T> { | ||
protected override _base_name = 'View'; | ||
override subViewsFromTemplate: View<T>[] = []; | ||
@@ -186,3 +187,3 @@ ignoreRefreshOnlySubViewFromParent = false; | ||
static createAndHydrate(element: HTMLElement) { | ||
const dataEl = $(element).next(`script.__RUNE_DATA__.${this.name}`); | ||
const dataEl = $(element).next(`script.__RUNE_DATA__.${this.name}[data-rune-base-name="View"]`); | ||
if (dataEl === null) { | ||
@@ -189,0 +190,0 @@ throw new Error('No __RUNE_DATA__ script found'); |
@@ -9,2 +9,3 @@ import { _escape } from './lib/_escape'; | ||
key = ''; | ||
protected _base_name = 'VirtualView'; | ||
private readonly _data: T; | ||
@@ -70,3 +71,3 @@ readonly _args: any[]; | ||
html, | ||
`${html}<script class="__RUNE_DATA__ ${this}" type="application/json">${_htmlEscapeJsonString( | ||
`${html}<script class="__RUNE_DATA__ ${this}" type="application/json" data-rune-base-name="${this._base_name}">${_htmlEscapeJsonString( | ||
JSON.stringify({ | ||
@@ -73,0 +74,0 @@ data: this.data, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
294025
5326