jinrai 1.1.2 → 1.1.4
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/front.config.json +2 -1
- package/index.ts +4 -1
- package/lib/bin/bin.js +123 -59
- package/lib/index.d.ts +3 -1
- package/lib/index.js +3 -1
- package/lib/src/bin/agent/agent.d.ts +2 -0
- package/lib/src/bin/agent/agent.js +4 -0
- package/lib/src/bin/playwright/pageCollector.d.ts +2 -0
- package/lib/src/bin/playwright/pageTestCollector.d.ts +6 -0
- package/lib/src/bin/playwright/templates.d.ts +6 -1
- package/lib/src/bin/routes/Parser.d.ts +25 -2
- package/lib/src/bin/routes/Parser.js +5 -0
- package/lib/src/bin/routes/getRoutes.d.ts +1 -0
- package/lib/src/front/server/useIsServer.d.ts +1 -0
- package/lib/src/front/server/useIsServer.js +7 -0
- package/lib/src/front/server-state/DataProxy.d.ts +2 -1
- package/lib/src/front/server-state/DataProxy.js +122 -60
- package/lib/src/front/server-state/SSR.d.ts +3 -0
- package/lib/src/front/server-state/SSR.js +18 -3
- package/lib/src/front/server-state/orig.d.ts +2 -0
- package/lib/src/front/server-state/{real.js → orig.js} +18 -3
- package/lib/src/front/server-state/serverStates.d.ts +3 -1
- package/lib/src/front/server-state/serverStates.js +24 -17
- package/lib/src/front/server-state/testState.d.ts +3 -0
- package/lib/src/front/server-state/testState.js +14 -0
- package/lib/src/front/server-state/useServerState.d.ts +1 -1
- package/lib/src/front/server-state/useServerState.js +5 -9
- package/lib/src/front/translate/TranslateConfig.d.ts +21 -0
- package/lib/src/front/translate/TranslateConfig.js +108 -0
- package/lib/src/front/url/JinraiContext.d.ts +1 -0
- package/lib/src/front/url/JinraiContext.js +1 -0
- package/lib/src/front/url/adapter/def.js +1 -1
- package/lib/src/front/url/adapter/rrd6.js +2 -2
- package/lib/src/front/url/adapter/rrd7.js +2 -2
- package/lib/src/front/url/params/useParamsIndex.js +2 -1
- package/lib/src/front/url/search/useSearch.js +4 -4
- package/lib/src/front/url/search/useSearchValue.d.ts +11 -5
- package/lib/src/front/url/search/useSearchValue.js +13 -8
- package/lib/src/front/wrapper/Custom.d.ts +3 -3
- package/lib/src/front/wrapper/Custom.js +18 -1
- package/lib/vite/plugin.js +26 -154
- package/package.json +9 -1
- package/rollup.config.mjs +2 -1
- package/src/bin/agent/agent.ts +2 -0
- package/src/bin/build/build.ts +23 -10
- package/src/bin/playwright/pageCollector.ts +8 -6
- package/src/bin/playwright/pageTestCollector.ts +15 -0
- package/src/bin/playwright/templates.ts +16 -5
- package/src/bin/routes/Parser.ts +100 -32
- package/src/bin/routes/getRoutes.ts +5 -1
- package/src/front/server/useIsServer.ts +5 -0
- package/src/front/server-state/DataProxy.ts +140 -61
- package/src/front/server-state/SSR.ts +22 -2
- package/src/front/server-state/{real.ts → orig.ts} +19 -2
- package/src/front/server-state/serverStates.ts +33 -18
- package/src/front/server-state/testState.ts +15 -0
- package/src/front/server-state/useServerState.ts +6 -11
- package/src/front/translate/TranslateConfig.tsx +153 -0
- package/src/front/url/JinraiContext.tsx +2 -0
- package/src/front/url/adapter/def.tsx +1 -1
- package/src/front/url/adapter/rrd6.tsx +2 -3
- package/src/front/url/adapter/rrd7.tsx +2 -2
- package/src/front/url/search/useSearch.ts +3 -4
- package/src/front/url/search/useSearchValue.ts +25 -13
- package/src/front/wrapper/Custom.tsx +28 -4
- package/tests/data-proxy/create-dataproxy.test.ts +116 -0
- package/tests/{custom.test.ts → parse/custom.test.ts} +2 -2
- package/tests/{parse.test.ts → parse/parse.test.ts} +7 -7
- package/tsconfig.types.json +1 -0
- package/vite/plugin.ts +40 -22
- package/lib/src/front/server-state/real.d.ts +0 -1
- /package/tests/{content → parse/content}/1.html +0 -0
- /package/tests/{content → parse/content}/1_result.json +0 -0
- /package/tests/{content → parse/content}/2.html +0 -0
- /package/tests/{content → parse/content}/2_result.json +0 -0
- /package/tests/{content → parse/content}/3.html +0 -0
- /package/tests/{content → parse/content}/3_result.json +0 -0
- /package/tests/{content → parse/content}/4.html +0 -0
- /package/tests/{content → parse/content}/4_result.json +0 -0
- /package/tests/{content → parse/content}/custom.html +0 -0
- /package/tests/{content → parse/content}/custom.json +0 -0
- /package/tests/{content → parse/content}/index.html +0 -0
- /package/tests/{content → parse/content}/index.json +0 -0
- /package/tests/{content → parse/content}/index_with_templates.json +0 -0
- /package/tests/{content → parse/content}/templates.json +0 -0
package/front.config.json
CHANGED
package/index.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export type { ServerKey } from "./src/front/server-state/useServerState"
|
|
2
2
|
|
|
3
3
|
export { useServerState } from "./src/front/server-state/useServerState"
|
|
4
|
-
export {
|
|
4
|
+
export { orig, original } from "./src/front/server-state/orig"
|
|
5
5
|
export { useParamsIndex } from "./src/front/url/params/useParamsIndex"
|
|
6
6
|
export { useSearchValue, useSearchArray } from "./src/front/url/search/useSearchValue"
|
|
7
7
|
export { useSearch } from "./src/front/url/search/useSearch"
|
|
8
8
|
export { Custom } from "./src/front/wrapper/Custom"
|
|
9
|
+
|
|
10
|
+
export { stringifyInput } from "./src/front/server-state/SSR"
|
|
11
|
+
export {useIsServer} from "./src/front/server/useIsServer"
|
package/lib/bin/bin.js
CHANGED
|
@@ -28,15 +28,19 @@ const normalizeHtmlWhitespace = (html) => {
|
|
|
28
28
|
.trim();
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
const SPLIT = "@#UNIQ_SPLITTER#@";
|
|
31
32
|
class Parser {
|
|
32
33
|
options;
|
|
33
34
|
openVar = "{{";
|
|
34
35
|
createVar = "}}";
|
|
36
|
+
openTVar = "{!";
|
|
37
|
+
createTVar = "!}";
|
|
35
38
|
createArray = "</loopwrapper";
|
|
36
39
|
createCustom = "</custom";
|
|
37
40
|
deepUp = "<loopwrapper";
|
|
38
41
|
deepUp2 = "<custom";
|
|
39
42
|
templates = {};
|
|
43
|
+
custom = [];
|
|
40
44
|
constructor(options) {
|
|
41
45
|
this.options = options;
|
|
42
46
|
}
|
|
@@ -49,43 +53,62 @@ class Parser {
|
|
|
49
53
|
let match;
|
|
50
54
|
let deep = 0;
|
|
51
55
|
let lastIndex = 0;
|
|
52
|
-
|
|
56
|
+
let translate = false;
|
|
57
|
+
const tagPattern = new RegExp(`(<loopwrapper(\\s+[^>]*)?>|</loopwrapper>|\{\{|\}\}|\{\!|\!\}|<custom(\\s+[^>]*)?>|</custom>)`, "gi");
|
|
53
58
|
while ((match = tagPattern.exec(content)) !== null) {
|
|
54
59
|
const currentTag = match[0];
|
|
55
60
|
const value = content.substring(lastIndex, match.index);
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
if (translate) {
|
|
62
|
+
if (currentTag.startsWith(this.createTVar)) {
|
|
63
|
+
translate = false;
|
|
64
|
+
this.createTranslate(tree, value);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
59
67
|
continue;
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
else if (currentTag.startsWith(this.deepUp)) {
|
|
63
|
-
deep++;
|
|
64
|
-
if (deep > 1)
|
|
65
|
-
continue;
|
|
66
|
-
this.createElement(tree, value);
|
|
67
|
-
}
|
|
68
|
-
else if (currentTag.startsWith(this.createCustom)) {
|
|
69
|
-
deep--;
|
|
70
|
-
if (deep != 0)
|
|
71
|
-
continue;
|
|
72
|
-
this.createCustomElement(tree, value);
|
|
73
|
-
}
|
|
74
|
-
else if (currentTag.startsWith(this.deepUp2)) {
|
|
75
|
-
deep++;
|
|
76
|
-
if (deep > 1)
|
|
77
|
-
continue;
|
|
78
|
-
this.createElement(tree, value);
|
|
79
|
-
}
|
|
80
|
-
else if (currentTag == this.createVar) {
|
|
81
|
-
if (deep != 0)
|
|
82
|
-
continue;
|
|
83
|
-
this.createElement(tree, value, true);
|
|
68
|
+
}
|
|
84
69
|
}
|
|
85
70
|
else {
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
|
|
71
|
+
if (currentTag.startsWith(this.createArray)) {
|
|
72
|
+
deep--;
|
|
73
|
+
if (deep > 0)
|
|
74
|
+
continue;
|
|
75
|
+
this.createElement(tree, value);
|
|
76
|
+
}
|
|
77
|
+
else if (currentTag.startsWith(this.deepUp)) {
|
|
78
|
+
deep++;
|
|
79
|
+
if (deep > 1)
|
|
80
|
+
continue;
|
|
81
|
+
this.createElement(tree, value);
|
|
82
|
+
}
|
|
83
|
+
else if (currentTag.startsWith(this.createCustom)) {
|
|
84
|
+
deep--;
|
|
85
|
+
if (deep != 0)
|
|
86
|
+
continue;
|
|
87
|
+
this.createCustomElement(tree, value);
|
|
88
|
+
}
|
|
89
|
+
else if (currentTag.startsWith(this.deepUp2)) {
|
|
90
|
+
deep++;
|
|
91
|
+
if (deep > 1)
|
|
92
|
+
continue;
|
|
93
|
+
this.createElement(tree, value);
|
|
94
|
+
}
|
|
95
|
+
else if (currentTag.startsWith(this.openTVar)) {
|
|
96
|
+
////////////// >>>>
|
|
97
|
+
if (deep != 0)
|
|
98
|
+
continue;
|
|
99
|
+
translate = true;
|
|
100
|
+
this.createElement(tree, value);
|
|
101
|
+
}
|
|
102
|
+
else if (currentTag == this.createVar) {
|
|
103
|
+
if (deep != 0)
|
|
104
|
+
continue;
|
|
105
|
+
this.createElement(tree, value, true);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
if (deep != 0)
|
|
109
|
+
continue;
|
|
110
|
+
this.createElement(tree, value);
|
|
111
|
+
}
|
|
89
112
|
}
|
|
90
113
|
lastIndex = match.index + currentTag.length;
|
|
91
114
|
}
|
|
@@ -95,20 +118,43 @@ class Parser {
|
|
|
95
118
|
}
|
|
96
119
|
}
|
|
97
120
|
createCustomElement(parent, value) {
|
|
98
|
-
const [
|
|
99
|
-
|
|
121
|
+
const [customProps, exampleProps, children] = value.split(SPLIT);
|
|
122
|
+
const custom = JSON.parse(customProps);
|
|
123
|
+
if (this.custom.find(itm => itm.name == custom.name) == undefined) {
|
|
124
|
+
this.custom.push({
|
|
125
|
+
name: custom.name,
|
|
126
|
+
html: children,
|
|
127
|
+
props: exampleProps,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
100
130
|
parent.push({
|
|
101
131
|
type: "custom",
|
|
102
|
-
name,
|
|
103
|
-
props:
|
|
132
|
+
name: custom.name,
|
|
133
|
+
props: custom.props,
|
|
104
134
|
});
|
|
105
135
|
}
|
|
106
|
-
|
|
107
|
-
|
|
136
|
+
createVarible(parent, value) {
|
|
137
|
+
return parent.push({
|
|
138
|
+
type: "value",
|
|
139
|
+
key: value,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
createTranslate(parent, value) {
|
|
143
|
+
if (value.startsWith("{{") && value.endsWith("}}")) {
|
|
108
144
|
return parent.push({
|
|
109
|
-
type: "
|
|
110
|
-
|
|
145
|
+
type: "tvalue",
|
|
146
|
+
value: value.slice(2, -2),
|
|
111
147
|
});
|
|
148
|
+
}
|
|
149
|
+
return parent.push({
|
|
150
|
+
type: "t",
|
|
151
|
+
text: value,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
createElement(parent, value, isVarible) {
|
|
155
|
+
if (isVarible) {
|
|
156
|
+
return this.createVarible(parent, value);
|
|
157
|
+
}
|
|
112
158
|
if (value.trimStart().startsWith("ArrayDataKey=")) {
|
|
113
159
|
const [key, ...val] = value.trimStart().substring(13).split("|");
|
|
114
160
|
value = val.join("|");
|
|
@@ -139,7 +185,10 @@ const getRoutesAndTemplates = (pages, normalize = true, templates = true) => {
|
|
|
139
185
|
const parser = new Parser({ normalize, templates });
|
|
140
186
|
for (const [id, template] of pages.entries()) {
|
|
141
187
|
const content = parser.parse(template.root);
|
|
142
|
-
const mask = template.mask
|
|
188
|
+
const mask = template.mask
|
|
189
|
+
.replaceAll("/", "\\/")
|
|
190
|
+
.replace(/{(.*?)}/, ".+?")
|
|
191
|
+
.replace("\/*", "\/?.*");
|
|
143
192
|
routes.push({
|
|
144
193
|
id,
|
|
145
194
|
content,
|
|
@@ -150,6 +199,7 @@ const getRoutesAndTemplates = (pages, normalize = true, templates = true) => {
|
|
|
150
199
|
return {
|
|
151
200
|
routes,
|
|
152
201
|
templates: parser.templates,
|
|
202
|
+
customComponents: parser.custom,
|
|
153
203
|
};
|
|
154
204
|
};
|
|
155
205
|
|
|
@@ -193,34 +243,39 @@ class Task {
|
|
|
193
243
|
}
|
|
194
244
|
|
|
195
245
|
const pageCollector = async (page) => {
|
|
196
|
-
const state = await page.evaluate(() => {
|
|
246
|
+
const [state, lang] = await page.evaluate(() => {
|
|
197
247
|
const state = Object.fromEntries(window.$exportServerStates);
|
|
198
|
-
|
|
199
|
-
return state;
|
|
248
|
+
const lang = window.$langDefaultConfig;
|
|
249
|
+
return [state, lang];
|
|
200
250
|
});
|
|
201
|
-
console.log("CLIENT", state);
|
|
202
251
|
const root = await page.locator("#root").innerHTML();
|
|
203
|
-
return { root, state };
|
|
252
|
+
return { root, state, lang };
|
|
204
253
|
};
|
|
205
254
|
|
|
255
|
+
const JinraiAgent = "____JINRAI_AGENT____";
|
|
256
|
+
|
|
206
257
|
const getRawPageData = async (url, pages, test = false, debug = false) => {
|
|
207
258
|
const task = new Task();
|
|
208
259
|
task.next("Router analysis", "yellow", spinners.dotsCircle);
|
|
209
260
|
const result = [];
|
|
261
|
+
let defaultLang = undefined;
|
|
210
262
|
const browser = await chromium.launch({ headless: !debug, devtools: true, channel: "chrome" });
|
|
211
263
|
// const test_browser = await chromium.launch({ headless: true, channel: "chrome" })
|
|
212
264
|
const context = await browser.newContext({
|
|
213
|
-
userAgent:
|
|
265
|
+
userAgent: JinraiAgent,
|
|
214
266
|
locale: "ru-RU",
|
|
215
267
|
});
|
|
216
268
|
for await (const [id, mask] of pages.entries()) {
|
|
217
269
|
task.next(mask, "yellow", spinners.dotsCircle, 1);
|
|
218
270
|
const page = await context.newPage();
|
|
219
|
-
const path = mask.replaceAll("{", "").replaceAll("}", "");
|
|
271
|
+
const path = mask.replaceAll("{", "").replaceAll("}", "").replace("\/*", "");
|
|
220
272
|
await page.goto(url + path);
|
|
221
273
|
await page.waitForLoadState("networkidle");
|
|
222
274
|
await page.waitForTimeout(1000);
|
|
223
|
-
const { state, root } = await pageCollector(page);
|
|
275
|
+
const { state, root, lang } = await pageCollector(page);
|
|
276
|
+
if (defaultLang == undefined) {
|
|
277
|
+
defaultLang = lang;
|
|
278
|
+
}
|
|
224
279
|
// if (debug) console.log({ input })
|
|
225
280
|
let testRoot = undefined;
|
|
226
281
|
// if (test) {
|
|
@@ -245,7 +300,7 @@ const getRawPageData = async (url, pages, test = false, debug = false) => {
|
|
|
245
300
|
await browser.close();
|
|
246
301
|
// await test_browser.close()
|
|
247
302
|
task.success();
|
|
248
|
-
return result;
|
|
303
|
+
return { pages: result, lang: defaultLang };
|
|
249
304
|
};
|
|
250
305
|
|
|
251
306
|
const vitePreview = async () => {
|
|
@@ -266,15 +321,16 @@ const runBuild = async (options) => {
|
|
|
266
321
|
const config = await getUserConfig(configName);
|
|
267
322
|
task.success();
|
|
268
323
|
const [serverUrl, close] = await vitePreview();
|
|
269
|
-
const pages = await getRawPageData(serverUrl, config.pages, config.test, options.debug);
|
|
324
|
+
const { pages, lang } = await getRawPageData(serverUrl, config.pages, config.test, options.debug);
|
|
325
|
+
console.log({ lang });
|
|
270
326
|
close();
|
|
271
327
|
const outputcashe = path.join(config.dist ?? "dist", ".cached");
|
|
272
328
|
task.do("Format");
|
|
273
|
-
const { routes, templates } = getRoutesAndTemplates(pages);
|
|
329
|
+
const { routes, templates, customComponents } = getRoutesAndTemplates(pages);
|
|
274
330
|
task.next(`Export: (${templates.length})`);
|
|
275
331
|
await mkdir(outputcashe, { recursive: true });
|
|
276
332
|
console.log("dev");
|
|
277
|
-
const exportConfig = { routes, proxy: config.proxy, meta: config.meta };
|
|
333
|
+
const exportConfig = { routes, proxy: config.proxy, meta: config.meta, lang };
|
|
278
334
|
await writeFile(path.join(outputcashe, "config.json"), JSON.stringify(exportConfig, null, 2));
|
|
279
335
|
// await writeFile(
|
|
280
336
|
// path.join(outputcashe, "index.html"),
|
|
@@ -283,15 +339,23 @@ const runBuild = async (options) => {
|
|
|
283
339
|
for await (const [template, name] of Object.entries(templates)) {
|
|
284
340
|
await writeFile(path.join(outputcashe, `${name}.html`), template);
|
|
285
341
|
}
|
|
286
|
-
if (
|
|
287
|
-
task.next(`
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
await writeFile(path.join(outputcashe, `test_${page.id}.html`), normalizeHtmlWhitespace(page.test));
|
|
342
|
+
if (customComponents.length) {
|
|
343
|
+
task.next(`Custom`);
|
|
344
|
+
await mkdir(path.join(outputcashe, "custom"), { recursive: true });
|
|
345
|
+
for await (const component of customComponents) {
|
|
346
|
+
await writeFile(path.join(outputcashe, "custom", `${component.name}.html`), component.html);
|
|
347
|
+
await writeFile(path.join(outputcashe, "custom", `${component.name}.json`), component.props);
|
|
293
348
|
}
|
|
294
349
|
}
|
|
350
|
+
// if (config.test) {
|
|
351
|
+
// task.next(`Tests`)
|
|
352
|
+
// for await (const page of pages) {
|
|
353
|
+
// if (!page.test) {
|
|
354
|
+
// continue
|
|
355
|
+
// }
|
|
356
|
+
// await writeFile(path.join(outputcashe, `test_${page.id}.html`), normalizeHtmlWhitespace(page.test))
|
|
357
|
+
// }
|
|
358
|
+
// }
|
|
295
359
|
task.success();
|
|
296
360
|
};
|
|
297
361
|
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export type { ServerKey } from "./src/front/server-state/useServerState";
|
|
2
2
|
export { useServerState } from "./src/front/server-state/useServerState";
|
|
3
|
-
export {
|
|
3
|
+
export { orig, original } from "./src/front/server-state/orig";
|
|
4
4
|
export { useParamsIndex } from "./src/front/url/params/useParamsIndex";
|
|
5
5
|
export { useSearchValue, useSearchArray } from "./src/front/url/search/useSearchValue";
|
|
6
6
|
export { useSearch } from "./src/front/url/search/useSearch";
|
|
7
7
|
export { Custom } from "./src/front/wrapper/Custom";
|
|
8
|
+
export { stringifyInput } from "./src/front/server-state/SSR";
|
|
9
|
+
export { useIsServer } from "./src/front/server/useIsServer";
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { useServerState } from './src/front/server-state/useServerState.js';
|
|
2
|
-
export {
|
|
2
|
+
export { orig, original } from './src/front/server-state/orig.js';
|
|
3
3
|
export { useParamsIndex } from './src/front/url/params/useParamsIndex.js';
|
|
4
4
|
export { useSearchArray, useSearchValue } from './src/front/url/search/useSearchValue.js';
|
|
5
5
|
export { useSearch } from './src/front/url/search/useSearch.js';
|
|
6
6
|
export { Custom } from './src/front/wrapper/Custom.js';
|
|
7
|
+
export { stringifyInput } from './src/front/server-state/SSR.js';
|
|
8
|
+
export { useIsServer } from './src/front/server/useIsServer.js';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Page } from "playwright";
|
|
2
2
|
import { ServerStateMap } from "../../front/server-state/useServerState";
|
|
3
|
+
import { DefaultLangType } from "../../front/translate/TranslateConfig";
|
|
3
4
|
export declare const pageCollector: (page: Page) => Promise<{
|
|
4
5
|
state: ServerStateMap;
|
|
5
6
|
root: string;
|
|
7
|
+
lang: DefaultLangType;
|
|
6
8
|
}>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ServerValue } from "../../front/server-state/serverStates";
|
|
2
|
+
import { DefaultLangType } from "../../front/translate/TranslateConfig";
|
|
2
3
|
export interface PageData {
|
|
3
4
|
id: number;
|
|
4
5
|
mask: string;
|
|
@@ -6,4 +7,8 @@ export interface PageData {
|
|
|
6
7
|
state: Record<string, ServerValue>;
|
|
7
8
|
test?: string;
|
|
8
9
|
}
|
|
9
|
-
export
|
|
10
|
+
export interface Pages {
|
|
11
|
+
pages: PageData[];
|
|
12
|
+
lang?: DefaultLangType;
|
|
13
|
+
}
|
|
14
|
+
export declare const getRawPageData: (url: string, pages: string[], test?: boolean, debug?: boolean) => Promise<Pages>;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
export declare const SPLIT = "@#UNIQ_SPLITTER#@";
|
|
2
|
+
interface CustomElement {
|
|
3
|
+
name: string;
|
|
4
|
+
props: object;
|
|
5
|
+
}
|
|
1
6
|
interface ParserOptions {
|
|
2
7
|
templates?: boolean;
|
|
3
8
|
normalize?: boolean;
|
|
4
9
|
}
|
|
5
|
-
export type Element = ArrayElement | HtmlElement | ValueElement | CustomElement;
|
|
10
|
+
export type Element = ArrayElement | HtmlElement | ValueElement | CustomElement | TranslateText | TValueElement;
|
|
6
11
|
interface ArrayElement {
|
|
7
12
|
type: "array";
|
|
8
13
|
key: string;
|
|
@@ -16,24 +21,42 @@ interface ValueElement {
|
|
|
16
21
|
type: "value";
|
|
17
22
|
key: string;
|
|
18
23
|
}
|
|
24
|
+
interface TValueElement {
|
|
25
|
+
type: "tvalue";
|
|
26
|
+
value: string;
|
|
27
|
+
}
|
|
28
|
+
interface TranslateText {
|
|
29
|
+
type: "t";
|
|
30
|
+
text: string;
|
|
31
|
+
}
|
|
19
32
|
interface CustomElement {
|
|
20
33
|
type: "custom";
|
|
21
34
|
name: string;
|
|
22
|
-
props:
|
|
35
|
+
props: object;
|
|
36
|
+
}
|
|
37
|
+
export interface CustomExample {
|
|
38
|
+
name: string;
|
|
39
|
+
html: string;
|
|
40
|
+
props: any;
|
|
23
41
|
}
|
|
24
42
|
export declare class Parser {
|
|
25
43
|
options?: ParserOptions;
|
|
26
44
|
openVar: string;
|
|
27
45
|
createVar: string;
|
|
46
|
+
openTVar: string;
|
|
47
|
+
createTVar: string;
|
|
28
48
|
createArray: string;
|
|
29
49
|
createCustom: string;
|
|
30
50
|
deepUp: string;
|
|
31
51
|
deepUp2: string;
|
|
32
52
|
templates: Record<string, string>;
|
|
53
|
+
custom: CustomExample[];
|
|
33
54
|
constructor(options?: ParserOptions);
|
|
34
55
|
parse(content: string): Element[];
|
|
35
56
|
handle(content: string, tree: Element[]): void;
|
|
36
57
|
createCustomElement(parent: Element[], value: string): void;
|
|
58
|
+
createVarible(parent: Element[], value: string): number;
|
|
59
|
+
createTranslate(parent: Element[], value: string): number;
|
|
37
60
|
createElement(parent: Element[], value: string, isVarible?: boolean): number;
|
|
38
61
|
createTemplate(html: string): string;
|
|
39
62
|
}
|
|
@@ -10,5 +10,6 @@ interface Route {
|
|
|
10
10
|
export declare const getRoutesAndTemplates: (pages: PageData[], normalize?: boolean, templates?: boolean) => {
|
|
11
11
|
routes: Route[];
|
|
12
12
|
templates: Record<string, string>;
|
|
13
|
+
customComponents: import("./Parser").CustomExample[];
|
|
13
14
|
};
|
|
14
15
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useIsServer: () => boolean;
|
|
@@ -4,5 +4,6 @@ export interface DataProxy {
|
|
|
4
4
|
getValue: () => any;
|
|
5
5
|
}
|
|
6
6
|
export declare const sources: Map<string, any>;
|
|
7
|
-
|
|
7
|
+
type WithDataProxy<T> = T & DataProxy;
|
|
8
|
+
declare function createDataProxy<T>(data: T, path?: string): WithDataProxy<T>;
|
|
8
9
|
export default createDataProxy;
|