neobiz 4.7.2 → 5.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/example/async_components.v.js +88 -0
- package/example/basic_syntax.v.js +86 -22
- package/example/control_flow.v.js +89 -54
- package/example/fromString.v.js +63 -20
- package/example/interact_withDOM.v.js +79 -10
- package/example/loop_and_Array.v.js +94 -46
- package/example/style.v.js +118 -24
- package/f.js +19 -0
- package/index.d.ts +145 -0
- package/index.js +1726 -20
- package/index2.js +859 -0
- package/indexw.js +21 -0
- package/package.json +1 -1
- package/readme.md +518 -534
- package/readme_v4.md +735 -0
- package/example/boolean_attributes.js +0 -17
- package/example/explicit-tag.v..js +0 -16
- package/example/innerText&html.v.js +0 -15
- package/example/multi_tag.v.js +0 -13
- package/example/orderChild.v.js +0 -15
- /package/{browser.js → browser_v4.js} +0 -0
package/index.js
CHANGED
|
@@ -1,20 +1,1726 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
const componentRegistry = new Map();
|
|
2
|
+
const styleRegistry = new Map();
|
|
3
|
+
const directiveRegistry = new Map();
|
|
4
|
+
const renderCache = new Map();
|
|
5
|
+
let objectRenderCache = new WeakMap();
|
|
6
|
+
|
|
7
|
+
const Null = Symbol("@null");
|
|
8
|
+
const SCOPE_KEY = Symbol("@scope");
|
|
9
|
+
|
|
10
|
+
const VOID_ELEMENTS = new Set([
|
|
11
|
+
"area", "base", "br", "col", "embed", "hr", "img", "input",
|
|
12
|
+
"link", "meta", "param", "source", "track", "wbr"
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
const RESERVED_KEYS = new Set([
|
|
16
|
+
"text", "html", "noprefix", "nopAttr", "tag", "bind", "when",
|
|
17
|
+
"else", "elseIf", "switch", "cases", "$head", "each",
|
|
18
|
+
"fallback", "onError", "cache"
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
const defaultOptions = {
|
|
22
|
+
camelCase: false,
|
|
23
|
+
once: false,
|
|
24
|
+
nodoctype: true,
|
|
25
|
+
ignoreTag: false,
|
|
26
|
+
prefixTag: false,
|
|
27
|
+
prefixAttr: false,
|
|
28
|
+
pretty: false,
|
|
29
|
+
indentSize: 2
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
let currentOption = { ...defaultOptions };
|
|
33
|
+
|
|
34
|
+
const toKebabCase = (str) => str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
35
|
+
|
|
36
|
+
const escapeHtml = (val) =>
|
|
37
|
+
String(val)
|
|
38
|
+
.replaceAll("&", "&")
|
|
39
|
+
.replaceAll("<", "<")
|
|
40
|
+
.replaceAll(">", ">")
|
|
41
|
+
.replaceAll('"', """)
|
|
42
|
+
.replaceAll("'", "'");
|
|
43
|
+
|
|
44
|
+
const escapeAttr = (val) =>
|
|
45
|
+
String(val)
|
|
46
|
+
.replaceAll("&", "&")
|
|
47
|
+
.replaceAll("<", "<")
|
|
48
|
+
.replaceAll(">", ">")
|
|
49
|
+
.replaceAll("'", "'");
|
|
50
|
+
|
|
51
|
+
const isPlainObj = (val) =>
|
|
52
|
+
val !== null &&
|
|
53
|
+
typeof val === "object" &&
|
|
54
|
+
!Array.isArray(val) &&
|
|
55
|
+
(Object.getPrototypeOf(val) === null || Object.getPrototypeOf(val) === Object.prototype);
|
|
56
|
+
|
|
57
|
+
const isChildTree = (val) => Array.isArray(val) || isPlainObj(val);
|
|
58
|
+
|
|
59
|
+
const serializeFunctionBody = (fn) => {
|
|
60
|
+
const src = fn.toString().trim();
|
|
61
|
+
const blockMatch = src.match(/^[^{]*\{([\s\S]*)\}$/);
|
|
62
|
+
if (blockMatch) return blockMatch[1].trim();
|
|
63
|
+
const arrowMatch = src.match(/^[^=]*=>\s*([\s\S]*)$/);
|
|
64
|
+
return arrowMatch ? arrowMatch[1].trim() : src;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
function resolveClassList(val) {
|
|
68
|
+
if (!val) return [];
|
|
69
|
+
if (typeof val === "string") return val.split(/\s+/).filter(Boolean);
|
|
70
|
+
if (Array.isArray(val)) return val.flatMap((item) => resolveClassList(item));
|
|
71
|
+
if (isPlainObj(val)) {
|
|
72
|
+
const out = [];
|
|
73
|
+
for (const [k, v] of Object.entries(val)) {
|
|
74
|
+
if (v) out.push(...k.split(/\s+/).filter(Boolean));
|
|
75
|
+
}
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
return [String(val)];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function parseEmmetKey(key) {
|
|
82
|
+
const trimmed = key.trim();
|
|
83
|
+
if (!trimmed || trimmed === "$" || trimmed === "$comment") {
|
|
84
|
+
return { tag: trimmed, id: null, classes: [] };
|
|
85
|
+
}
|
|
86
|
+
const match = trimmed.match(/^([a-zA-Z0-9-]+)?((?:[#.][a-zA-Z0-9_-]+)*)$/);
|
|
87
|
+
if (!match || (!match[1] && !match[2])) {
|
|
88
|
+
return { tag: trimmed, id: null, classes: [] };
|
|
89
|
+
}
|
|
90
|
+
const tag = match[1] || "div";
|
|
91
|
+
let id = null;
|
|
92
|
+
const classes = [];
|
|
93
|
+
const tokens = (match[2] || "").match(/[#.][a-zA-Z0-9_-]+/g) || [];
|
|
94
|
+
for (const tok of tokens) {
|
|
95
|
+
if (tok.startsWith("#")) id = tok.slice(1);
|
|
96
|
+
else if (tok.startsWith(".")) classes.push(tok.slice(1));
|
|
97
|
+
}
|
|
98
|
+
return { tag, id, classes };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function buildBoundEventCode(fn, bindObj) {
|
|
102
|
+
let code = serializeFunctionBody(fn);
|
|
103
|
+
if (bindObj && typeof bindObj === "object" && !Array.isArray(bindObj)) {
|
|
104
|
+
const entries = Object.entries(bindObj).filter(
|
|
105
|
+
([k, v]) => /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(k) && v !== undefined
|
|
106
|
+
);
|
|
107
|
+
if (entries.length > 0) {
|
|
108
|
+
const names = entries.map(([k]) => k).join(", ");
|
|
109
|
+
const payload = Object.fromEntries(entries);
|
|
110
|
+
const json = JSON.stringify(payload)
|
|
111
|
+
.replaceAll("<\/script>", "<\\/script>")
|
|
112
|
+
.replaceAll("'", "\\'");
|
|
113
|
+
code = `const { ${names} } = ${json}; ${code}`;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return code.replaceAll("'", "'");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function resolveCssSelector(rawSelector, parentSelector, scopeAttr) {
|
|
120
|
+
return rawSelector
|
|
121
|
+
.split(",")
|
|
122
|
+
.map((part) => {
|
|
123
|
+
const s = part.trim();
|
|
124
|
+
if (parentSelector) {
|
|
125
|
+
return parentSelector
|
|
126
|
+
.split(",")
|
|
127
|
+
.map((p) => {
|
|
128
|
+
const parent = p.trim();
|
|
129
|
+
if (s.includes("&")) return s.replaceAll("&", parent);
|
|
130
|
+
if (!scopeAttr) return `${parent} ${s}`;
|
|
131
|
+
if (s === "self" || s === ":host") return `${parent} ${scopeAttr}`;
|
|
132
|
+
const pseudoIdx = s.indexOf(":");
|
|
133
|
+
return pseudoIdx > 0
|
|
134
|
+
? `${parent} ${s.slice(0, pseudoIdx)}${scopeAttr}${s.slice(pseudoIdx)}`
|
|
135
|
+
: `${parent} ${s}${scopeAttr}`;
|
|
136
|
+
})
|
|
137
|
+
.join(", ");
|
|
138
|
+
}
|
|
139
|
+
if (!scopeAttr) return s;
|
|
140
|
+
if (s === "self" || s === ":host") return scopeAttr;
|
|
141
|
+
const pseudoIdx = s.indexOf(":");
|
|
142
|
+
return pseudoIdx > 0
|
|
143
|
+
? `${s.slice(0, pseudoIdx)}${scopeAttr}${s.slice(pseudoIdx)}`
|
|
144
|
+
: `${s}${scopeAttr}`;
|
|
145
|
+
})
|
|
146
|
+
.join(", ");
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function compileCss(obj, inline = false, parentSelector = "", scopeAttr = "") {
|
|
150
|
+
if (inline) {
|
|
151
|
+
return Object.entries(obj)
|
|
152
|
+
.filter(([, v]) => v !== undefined && v !== null && typeof v !== "object")
|
|
153
|
+
.map(([k, v]) => `${toKebabCase(k)}:${v};`)
|
|
154
|
+
.join("");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const decls = [];
|
|
158
|
+
const nested = [];
|
|
159
|
+
|
|
160
|
+
for (const [key, val] of Object.entries(obj)) {
|
|
161
|
+
if (val === undefined || val === null) continue;
|
|
162
|
+
if (typeof val === "object") {
|
|
163
|
+
if (key.startsWith("@")) {
|
|
164
|
+
const inner = parentSelector
|
|
165
|
+
? compileCss({ [parentSelector]: val }, false, "", "")
|
|
166
|
+
: compileCss(val, false, "", scopeAttr);
|
|
167
|
+
nested.push(`${key}{${inner}}`);
|
|
168
|
+
} else {
|
|
169
|
+
const nextSelector = resolveCssSelector(key, parentSelector, scopeAttr);
|
|
170
|
+
nested.push(compileCss(val, false, nextSelector, scopeAttr));
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
decls.push(`${toKebabCase(key)}:${val};`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const parts = [];
|
|
178
|
+
if (parentSelector && decls.length > 0) {
|
|
179
|
+
parts.push(`${parentSelector}{${decls.join("")}}`);
|
|
180
|
+
} else if (!parentSelector && decls.length > 0) {
|
|
181
|
+
parts.push(decls.join(""));
|
|
182
|
+
}
|
|
183
|
+
if (nested.length > 0) parts.push(...nested.filter(Boolean));
|
|
184
|
+
return parts.join(parentSelector ? "" : "\n");
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function compileScopedCss(styleObj, scopeId) {
|
|
188
|
+
return compileCss(styleObj, false, "", `[data-nb-s="${scopeId}"]`);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function collectHeadAssets(headVal, headMap) {
|
|
192
|
+
const entries = Array.isArray(headVal) ? headVal : [headVal];
|
|
193
|
+
for (const entry of entries) {
|
|
194
|
+
if (!entry || typeof entry !== "object") continue;
|
|
195
|
+
for (const [key, rawVal] of Object.entries(entry)) {
|
|
196
|
+
const items = Array.isArray(rawVal) ? rawVal : [rawVal];
|
|
197
|
+
const parsed = parseEmmetKey(key);
|
|
198
|
+
for (const item of items) {
|
|
199
|
+
if (!item || typeof item !== "object") continue;
|
|
200
|
+
const tag = (item.tag || parsed.tag).toLowerCase();
|
|
201
|
+
const dedupeKey = item.src
|
|
202
|
+
? `${tag}:src:${item.src}`
|
|
203
|
+
: item.href
|
|
204
|
+
? `${tag}:href:${item.href}`
|
|
205
|
+
: item.name
|
|
206
|
+
? `${tag}:name:${item.name}`
|
|
207
|
+
: item.property
|
|
208
|
+
? `${tag}:prop:${item.property}`
|
|
209
|
+
: item.charset
|
|
210
|
+
? `${tag}:charset`
|
|
211
|
+
: `${tag}:inline:${JSON.stringify(item)}`;
|
|
212
|
+
|
|
213
|
+
if (headMap.has(dedupeKey)) continue;
|
|
214
|
+
|
|
215
|
+
let priority = 2;
|
|
216
|
+
if (tag === "meta" || (tag === "link" && /preconnect|preload|dns-prefetch/.test(item.rel || ""))) {
|
|
217
|
+
priority = 1;
|
|
218
|
+
} else if (tag === "link" || tag === "style") {
|
|
219
|
+
priority = 2;
|
|
220
|
+
} else if (tag === "script") {
|
|
221
|
+
priority = item.defer || item.async || item.type === "module" ? 4 : 3;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
headMap.set(dedupeKey, { priority, node: { [key]: item } });
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function interpolateLoopTokens(str, item, index) {
|
|
231
|
+
if (!str.includes("$item") && !str.includes("$index")) return str;
|
|
232
|
+
return str
|
|
233
|
+
.replaceAll("$index", String(index))
|
|
234
|
+
.replace(/\$item(?:\.([a-zA-Z0-9_$.]+))?/g, (_, path) => {
|
|
235
|
+
if (!path) return item != null ? String(item) : "";
|
|
236
|
+
const val = path.split(".").reduce((acc, part) => acc?.[part], item);
|
|
237
|
+
return val != null ? String(val) : "";
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function resolveLoopNode(node, item, index) {
|
|
242
|
+
if (typeof node === "function") return node(item, index);
|
|
243
|
+
if (typeof node === "string") return interpolateLoopTokens(node, item, index);
|
|
244
|
+
if (Array.isArray(node)) return node.map((el) => resolveLoopNode(el, item, index));
|
|
245
|
+
if (node !== null && typeof node === "object" && node !== Null) {
|
|
246
|
+
const out = {};
|
|
247
|
+
if (node[SCOPE_KEY]) out[SCOPE_KEY] = node[SCOPE_KEY];
|
|
248
|
+
for (const [k, v] of Object.entries(node)) {
|
|
249
|
+
if (k === "each") continue;
|
|
250
|
+
const isEventFn = typeof v === "function" && k.toLowerCase().startsWith("on");
|
|
251
|
+
out[k] = isEventFn ? v : resolveLoopNode(v, item, index);
|
|
252
|
+
}
|
|
253
|
+
return out;
|
|
254
|
+
}
|
|
255
|
+
return node;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function expandEachItems(node) {
|
|
259
|
+
const src = node.each;
|
|
260
|
+
const list =
|
|
261
|
+
typeof src === "number" && src >= 0
|
|
262
|
+
? Array.from({ length: Math.floor(src) }, (_, i) => i)
|
|
263
|
+
: Array.isArray(src)
|
|
264
|
+
? src
|
|
265
|
+
: [];
|
|
266
|
+
return list.map((item, idx) => resolveLoopNode(node, item, idx));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function resolveSwitchBranch(node, isFragment) {
|
|
270
|
+
if (!("switch" in node) || !isPlainObj(node.cases)) return { matched: false, node };
|
|
271
|
+
const branch = Object.hasOwn(node.cases, node.switch)
|
|
272
|
+
? node.cases[node.switch]
|
|
273
|
+
: node.cases.default;
|
|
274
|
+
if (isFragment) {
|
|
275
|
+
return { matched: true, node: branch ?? null };
|
|
276
|
+
}
|
|
277
|
+
if (branch === false || branch === null) {
|
|
278
|
+
return { matched: true, node: null };
|
|
279
|
+
}
|
|
280
|
+
const rest = {};
|
|
281
|
+
if (node[SCOPE_KEY]) rest[SCOPE_KEY] = node[SCOPE_KEY];
|
|
282
|
+
for (const [k, v] of Object.entries(node)) {
|
|
283
|
+
if (k !== "switch" && k !== "cases") rest[k] = v;
|
|
284
|
+
}
|
|
285
|
+
if (isPlainObj(branch)) {
|
|
286
|
+
Object.assign(rest, branch);
|
|
287
|
+
if (branch[SCOPE_KEY]) rest[SCOPE_KEY] = branch[SCOPE_KEY];
|
|
288
|
+
}
|
|
289
|
+
return { matched: true, node: rest };
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function splitRespectingBrackets(str, delimiter) {
|
|
293
|
+
const parts = [];
|
|
294
|
+
let buf = "";
|
|
295
|
+
let bracketDepth = 0;
|
|
296
|
+
let parenDepth = 0;
|
|
297
|
+
let quote = null;
|
|
298
|
+
|
|
299
|
+
for (let i = 0; i < str.length; i++) {
|
|
300
|
+
const ch = str[i];
|
|
301
|
+
if (quote) {
|
|
302
|
+
buf += ch;
|
|
303
|
+
if (ch === quote && str[i - 1] !== "\\") quote = null;
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
if (ch === '"' || ch === "'") {
|
|
307
|
+
quote = ch;
|
|
308
|
+
buf += ch;
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
if (ch === "[") bracketDepth++;
|
|
312
|
+
else if (ch === "]" && bracketDepth > 0) bracketDepth--;
|
|
313
|
+
else if (ch === "(") parenDepth++;
|
|
314
|
+
else if (ch === ")" && parenDepth > 0) parenDepth--;
|
|
315
|
+
|
|
316
|
+
if (bracketDepth === 0 && parenDepth === 0 && ch === delimiter) {
|
|
317
|
+
parts.push(buf);
|
|
318
|
+
buf = "";
|
|
319
|
+
} else {
|
|
320
|
+
buf += ch;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (buf) parts.push(buf);
|
|
324
|
+
return parts;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function tokenizeSelectorChain(chainStr) {
|
|
328
|
+
const tokens = [];
|
|
329
|
+
let buf = "";
|
|
330
|
+
let bracketDepth = 0;
|
|
331
|
+
let parenDepth = 0;
|
|
332
|
+
let quote = null;
|
|
333
|
+
|
|
334
|
+
const flush = () => {
|
|
335
|
+
const t = buf.trim();
|
|
336
|
+
if (t) tokens.push(t);
|
|
337
|
+
buf = "";
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
for (let i = 0; i < chainStr.length; i++) {
|
|
341
|
+
const ch = chainStr[i];
|
|
342
|
+
if (quote) {
|
|
343
|
+
buf += ch;
|
|
344
|
+
if (ch === quote && chainStr[i - 1] !== "\\") quote = null;
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
if (ch === '"' || ch === "'") {
|
|
348
|
+
quote = ch;
|
|
349
|
+
buf += ch;
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
if (ch === "[") {
|
|
353
|
+
bracketDepth++;
|
|
354
|
+
buf += ch;
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
if (ch === "]") {
|
|
358
|
+
if (bracketDepth > 0) bracketDepth--;
|
|
359
|
+
buf += ch;
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
if (ch === "(") {
|
|
363
|
+
parenDepth++;
|
|
364
|
+
buf += ch;
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
if (ch === ")") {
|
|
368
|
+
if (parenDepth > 0) parenDepth--;
|
|
369
|
+
buf += ch;
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
if (bracketDepth === 0 && parenDepth === 0) {
|
|
373
|
+
if (ch === ">") {
|
|
374
|
+
flush();
|
|
375
|
+
tokens.push(">");
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
if (/\s/.test(ch)) {
|
|
379
|
+
flush();
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
buf += ch;
|
|
384
|
+
}
|
|
385
|
+
flush();
|
|
386
|
+
return tokens;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function parseSelectorSegment(segStr) {
|
|
390
|
+
let s = segStr.trim();
|
|
391
|
+
const attrs = [];
|
|
392
|
+
const pseudos = [];
|
|
393
|
+
|
|
394
|
+
s = s.replace(/\[([^\]]+)\]/g, (_, inner) => {
|
|
395
|
+
const m = inner.trim().match(/^([a-zA-Z0-9_-]+)(?:\s*([\^$*]?=)\s*(?:"([^"]*)"|'([^']*)'|([^\s]+)))?$/);
|
|
396
|
+
if (m) {
|
|
397
|
+
attrs.push({
|
|
398
|
+
name: m[1],
|
|
399
|
+
op: m[2] || null,
|
|
400
|
+
val: m[3] ?? m[4] ?? m[5] ?? null
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
return "";
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
let idx;
|
|
407
|
+
while ((idx = s.indexOf(":")) !== -1) {
|
|
408
|
+
const rest = s.slice(idx);
|
|
409
|
+
if (rest.startsWith(":not(")) {
|
|
410
|
+
let depth = 0;
|
|
411
|
+
let end = -1;
|
|
412
|
+
for (let i = 4; i < rest.length; i++) {
|
|
413
|
+
if (rest[i] === "(") depth++;
|
|
414
|
+
else if (rest[i] === ")") {
|
|
415
|
+
depth--;
|
|
416
|
+
if (depth === 0) {
|
|
417
|
+
end = i;
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
if (end !== -1) {
|
|
423
|
+
const innerSel = rest.slice(5, end).trim();
|
|
424
|
+
pseudos.push({ type: "not", spec: parseSelectorSegment(innerSel) });
|
|
425
|
+
s = s.slice(0, idx) + rest.slice(end + 1);
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
const pm = rest.match(/^:([a-zA-Z0-9_-]+)/);
|
|
430
|
+
if (pm) {
|
|
431
|
+
pseudos.push({ type: pm[1] });
|
|
432
|
+
s = s.slice(0, idx) + rest.slice(pm[0].length);
|
|
433
|
+
} else {
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
let base;
|
|
439
|
+
if (!s || s === "*") {
|
|
440
|
+
base = { tag: null, id: null, classes: [] };
|
|
441
|
+
} else {
|
|
442
|
+
base = parseEmmetKey(s);
|
|
443
|
+
if (/^[#.]/.test(s)) base.tag = null;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
return { ...base, attrs, pseudos };
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function parseSelectorList(selector) {
|
|
450
|
+
return splitRespectingBrackets(String(selector), ",")
|
|
451
|
+
.map((part) => part.trim())
|
|
452
|
+
.filter(Boolean)
|
|
453
|
+
.map((part) => {
|
|
454
|
+
const tokens = tokenizeSelectorChain(part);
|
|
455
|
+
const chain = [];
|
|
456
|
+
let pendingComb = null;
|
|
457
|
+
for (const tok of tokens) {
|
|
458
|
+
if (tok === ">") {
|
|
459
|
+
pendingComb = ">";
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
chain.push({ comb: pendingComb, spec: parseSelectorSegment(tok) });
|
|
463
|
+
pendingComb = " ";
|
|
464
|
+
}
|
|
465
|
+
return chain;
|
|
466
|
+
})
|
|
467
|
+
.filter((chain) => chain.length > 0);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function getNodeAttr(key, node, attrName) {
|
|
471
|
+
const emmet = parseEmmetKey(key);
|
|
472
|
+
if (attrName === "id") return node.id ?? emmet.id ?? undefined;
|
|
473
|
+
if (attrName === "class") {
|
|
474
|
+
const merged = [...emmet.classes, ...resolveClassList(node.class)];
|
|
475
|
+
return merged.length > 0 ? merged.join(" ") : undefined;
|
|
476
|
+
}
|
|
477
|
+
return node[attrName];
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
function hasNodeChildren(node) {
|
|
481
|
+
for (const [k, v] of Object.entries(node)) {
|
|
482
|
+
if (v === undefined || v === null || v === false) continue;
|
|
483
|
+
if (k === "text" || k === "html") {
|
|
484
|
+
if (isChildTree(v) || String(v).length > 0) return true;
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
if (k === "$comment" || k === "$head" || RESERVED_KEYS.has(k)) continue;
|
|
488
|
+
if (typeof v === "object" && v !== Null) return true;
|
|
489
|
+
}
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function matchNodeSelector(key, node, spec, meta = null) {
|
|
494
|
+
const emmet = parseEmmetKey(key);
|
|
495
|
+
const nodeTag = (node.tag || emmet.tag).toLowerCase();
|
|
496
|
+
if (spec.tag && nodeTag !== spec.tag.toLowerCase()) return false;
|
|
497
|
+
|
|
498
|
+
const nodeId = node.id ?? emmet.id;
|
|
499
|
+
if (spec.id && nodeId !== spec.id) return false;
|
|
500
|
+
|
|
501
|
+
if (spec.classes.length > 0) {
|
|
502
|
+
const classSet = new Set([...emmet.classes, ...resolveClassList(node.class)]);
|
|
503
|
+
for (const cls of spec.classes) {
|
|
504
|
+
if (!classSet.has(cls)) return false;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
if (spec.attrs && spec.attrs.length > 0) {
|
|
509
|
+
for (const attr of spec.attrs) {
|
|
510
|
+
const actual = getNodeAttr(key, node, attr.name);
|
|
511
|
+
if (actual === undefined || actual === null || actual === false) return false;
|
|
512
|
+
if (attr.op) {
|
|
513
|
+
const strVal = actual === Null || actual === true ? "" : String(actual);
|
|
514
|
+
if (attr.op === "=" && strVal !== attr.val) return false;
|
|
515
|
+
if (attr.op === "^=" && !strVal.startsWith(attr.val)) return false;
|
|
516
|
+
if (attr.op === "$=" && !strVal.endsWith(attr.val)) return false;
|
|
517
|
+
if (attr.op === "*=" && !strVal.includes(attr.val)) return false;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
if (spec.pseudos && spec.pseudos.length > 0) {
|
|
523
|
+
for (const pseudo of spec.pseudos) {
|
|
524
|
+
if (pseudo.type === "first-child" && (!meta || meta.index !== 0)) return false;
|
|
525
|
+
if (pseudo.type === "last-child" && (!meta || meta.index !== meta.count - 1)) return false;
|
|
526
|
+
if (pseudo.type === "empty" && hasNodeChildren(node)) return false;
|
|
527
|
+
if (pseudo.type === "not" && matchNodeSelector(key, node, pseudo.spec, meta)) return false;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
return true;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
function matchSelectorChain(key, node, ancestors, chain, meta) {
|
|
535
|
+
if (!matchNodeSelector(key, node, chain[chain.length - 1].spec, meta)) return false;
|
|
536
|
+
let ancIdx = ancestors.length - 1;
|
|
537
|
+
for (let i = chain.length - 2; i >= 0; i--) {
|
|
538
|
+
const comb = chain[i + 1].comb;
|
|
539
|
+
const spec = chain[i].spec;
|
|
540
|
+
if (comb === ">") {
|
|
541
|
+
if (ancIdx < 0 || !matchNodeSelector(ancestors[ancIdx].key, ancestors[ancIdx].node, spec, ancestors[ancIdx].meta)) {
|
|
542
|
+
return false;
|
|
543
|
+
}
|
|
544
|
+
ancIdx--;
|
|
545
|
+
} else {
|
|
546
|
+
while (
|
|
547
|
+
ancIdx >= 0 &&
|
|
548
|
+
!matchNodeSelector(ancestors[ancIdx].key, ancestors[ancIdx].node, spec, ancestors[ancIdx].meta)
|
|
549
|
+
) {
|
|
550
|
+
ancIdx--;
|
|
551
|
+
}
|
|
552
|
+
if (ancIdx < 0) return false;
|
|
553
|
+
ancIdx--;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return true;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
function isQueryableChildKey(key, val) {
|
|
560
|
+
if (key === "$comment" || key === "$head") return false;
|
|
561
|
+
if (key === "style" && isPlainObj(val)) return false;
|
|
562
|
+
if (RESERVED_KEYS.has(key)) {
|
|
563
|
+
return (key === "html" || key === "text") && isChildTree(val);
|
|
564
|
+
}
|
|
565
|
+
return true;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
function queryTree(root, selector, callback) {
|
|
569
|
+
const chains = parseSelectorList(selector);
|
|
570
|
+
if (chains.length === 0) return;
|
|
571
|
+
|
|
572
|
+
const matched = new Set();
|
|
573
|
+
|
|
574
|
+
const walk = (obj, ancestors) => {
|
|
575
|
+
if (!obj || typeof obj !== "object") return;
|
|
576
|
+
if (Array.isArray(obj)) {
|
|
577
|
+
for (const item of obj) walk(item, ancestors);
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
const childNodes = [];
|
|
582
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
583
|
+
if (!isQueryableChildKey(k, v)) continue;
|
|
584
|
+
const isFrag = k.trim() === "$";
|
|
585
|
+
if (Array.isArray(v)) {
|
|
586
|
+
for (const item of v) {
|
|
587
|
+
if (Array.isArray(item)) {
|
|
588
|
+
walk(item, ancestors);
|
|
589
|
+
} else if (item && typeof item === "object" && item !== Null) {
|
|
590
|
+
childNodes.push({ key: k, node: item, isFrag });
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
} else if (v && typeof v === "object" && v !== Null) {
|
|
594
|
+
childNodes.push({ key: k, node: v, isFrag });
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
const realChildren = childNodes.filter((c) => !c.isFrag);
|
|
599
|
+
let realIdx = 0;
|
|
600
|
+
|
|
601
|
+
for (const entry of childNodes) {
|
|
602
|
+
if (entry.isFrag) {
|
|
603
|
+
walk(entry.node, ancestors);
|
|
604
|
+
} else {
|
|
605
|
+
const meta = { index: realIdx++, count: realChildren.length };
|
|
606
|
+
if (
|
|
607
|
+
!matched.has(entry.node) &&
|
|
608
|
+
chains.some((chain) => matchSelectorChain(entry.key, entry.node, ancestors, chain, meta))
|
|
609
|
+
) {
|
|
610
|
+
matched.add(entry.node);
|
|
611
|
+
callback(entry.node);
|
|
612
|
+
}
|
|
613
|
+
walk(entry.node, [...ancestors, { key: entry.key, node: entry.node, meta }]);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
walk(root, []);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
function applyAsyncFallback(node, err) {
|
|
622
|
+
if (typeof node.onError === "function") node.onError(err);
|
|
623
|
+
if (!("fallback" in node)) throw err;
|
|
624
|
+
const fb = typeof node.fallback === "function" ? node.fallback(err) : node.fallback;
|
|
625
|
+
if (isPlainObj(node) && !("$comment" in node)) {
|
|
626
|
+
const out = {};
|
|
627
|
+
if (node[SCOPE_KEY]) out[SCOPE_KEY] = node[SCOPE_KEY];
|
|
628
|
+
for (const k of ["tag", "id", "class"]) {
|
|
629
|
+
if (k in node) out[k] = node[k];
|
|
630
|
+
}
|
|
631
|
+
if (isPlainObj(fb)) {
|
|
632
|
+
Object.assign(out, fb);
|
|
633
|
+
if (fb[SCOPE_KEY]) out[SCOPE_KEY] = fb[SCOPE_KEY];
|
|
634
|
+
return out;
|
|
635
|
+
}
|
|
636
|
+
if (fb != null && fb !== false) {
|
|
637
|
+
out.$ = fb;
|
|
638
|
+
return out;
|
|
639
|
+
}
|
|
640
|
+
return { when: false };
|
|
641
|
+
}
|
|
642
|
+
return fb;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
async function resolveAsyncTree(node) {
|
|
646
|
+
if (node instanceof Promise) return resolveAsyncTree(await node);
|
|
647
|
+
if (typeof node === "function") return node;
|
|
648
|
+
if (Array.isArray(node)) {
|
|
649
|
+
const resolved = await Promise.all(node.map((item) => resolveAsyncTree(item)));
|
|
650
|
+
if (node[SCOPE_KEY]) resolved[SCOPE_KEY] = node[SCOPE_KEY];
|
|
651
|
+
return resolved;
|
|
652
|
+
}
|
|
653
|
+
if (node !== null && typeof node === "object" && node !== Null) {
|
|
654
|
+
const hasBoundary = "fallback" in node || "onError" in node;
|
|
655
|
+
try {
|
|
656
|
+
const entries = await Promise.all(
|
|
657
|
+
Object.entries(node).map(async ([k, v]) => {
|
|
658
|
+
if (k === "fallback" || k === "onError") return [k, v];
|
|
659
|
+
return [k, await resolveAsyncTree(v)];
|
|
660
|
+
})
|
|
661
|
+
);
|
|
662
|
+
const out = Object.fromEntries(entries);
|
|
663
|
+
if (node[SCOPE_KEY]) out[SCOPE_KEY] = node[SCOPE_KEY];
|
|
664
|
+
return out;
|
|
665
|
+
} catch (err) {
|
|
666
|
+
if (hasBoundary) {
|
|
667
|
+
return resolveAsyncTree(applyAsyncFallback(node, err));
|
|
668
|
+
}
|
|
669
|
+
throw err;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
return node;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
function htmlToNeobiz(htmlStr) {
|
|
676
|
+
const trimmed = String(htmlStr).trim();
|
|
677
|
+
if (!trimmed) return {};
|
|
678
|
+
const tokens = trimmed.match(/<!--[\s\S]*?-->|<\/?[^>]+>|[^<]+/g) || [];
|
|
679
|
+
const root = { children: [] };
|
|
680
|
+
const stack = [root];
|
|
681
|
+
|
|
682
|
+
for (const raw of tokens) {
|
|
683
|
+
const tok = raw.trim();
|
|
684
|
+
if (!tok) continue;
|
|
685
|
+
const current = stack[stack.length - 1];
|
|
686
|
+
if (tok.startsWith("<!--") && tok.endsWith("-->")) {
|
|
687
|
+
current.children.push({ isComment: true, content: tok.slice(4, -3).trim() });
|
|
688
|
+
} else if (tok.startsWith("</")) {
|
|
689
|
+
if (stack.length > 1) stack.pop();
|
|
690
|
+
} else if (tok.startsWith("<")) {
|
|
691
|
+
const selfClosing = tok.endsWith("/>");
|
|
692
|
+
const tagMatch = tok.match(/^<([a-zA-Z0-9-]+)/);
|
|
693
|
+
if (!tagMatch) continue;
|
|
694
|
+
const tag = tagMatch[1].toLowerCase();
|
|
695
|
+
const attrPart = tok.slice(tagMatch[0].length, selfClosing ? -2 : -1).trim();
|
|
696
|
+
const obj = {};
|
|
697
|
+
const attrRegex = /([a-zA-Z0-9-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g;
|
|
698
|
+
let m;
|
|
699
|
+
while ((m = attrRegex.exec(attrPart)) !== null) {
|
|
700
|
+
const [, name, dq, sq, bare] = m;
|
|
701
|
+
const val = dq ?? sq ?? bare;
|
|
702
|
+
obj[name] = val === undefined ? Null : val;
|
|
703
|
+
}
|
|
704
|
+
const elNode = { tag, obj, children: [] };
|
|
705
|
+
current.children.push(elNode);
|
|
706
|
+
if (!selfClosing && !VOID_ELEMENTS.has(tag)) stack.push(elNode);
|
|
707
|
+
} else {
|
|
708
|
+
current.children.push({ isText: true, content: tok });
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
function buildObj(node) {
|
|
713
|
+
const out = { ...node.obj };
|
|
714
|
+
const tagCounts = new Map();
|
|
715
|
+
for (const child of node.children) {
|
|
716
|
+
if (child.isComment) {
|
|
717
|
+
out.$comment = child.content;
|
|
718
|
+
continue;
|
|
719
|
+
}
|
|
720
|
+
if (child.isText) {
|
|
721
|
+
out.text = out.text ? `${out.text} ${child.content}` : child.content;
|
|
722
|
+
continue;
|
|
723
|
+
}
|
|
724
|
+
const childObj = buildObj(child);
|
|
725
|
+
const count = tagCounts.get(child.tag) || 0;
|
|
726
|
+
tagCounts.set(child.tag, count + 1);
|
|
727
|
+
out[count === 0 ? child.tag : `${child.tag}${" ".repeat(count)}`] = childObj;
|
|
728
|
+
}
|
|
729
|
+
return out;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
const result = {};
|
|
733
|
+
const rootCounts = new Map();
|
|
734
|
+
for (const child of root.children) {
|
|
735
|
+
if (!child.isText && !child.isComment) {
|
|
736
|
+
const count = rootCounts.get(child.tag) || 0;
|
|
737
|
+
rootCounts.set(child.tag, count + 1);
|
|
738
|
+
result[count === 0 ? child.tag : `${child.tag}${" ".repeat(count)}`] = buildObj(child);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
return result;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
function getCacheEntry(node, opts) {
|
|
745
|
+
if (!("cache" in node) || !node.cache) return null;
|
|
746
|
+
const optsSig = `${opts.camelCase}:${opts.ignoreTag}:${opts.prefixTag}:${opts.prefixAttr}:${opts.pretty}:${opts.indentSize}`;
|
|
747
|
+
if (node.cache === true) {
|
|
748
|
+
const map = objectRenderCache.get(node);
|
|
749
|
+
return map ? map.get(optsSig) ?? null : null;
|
|
750
|
+
}
|
|
751
|
+
return renderCache.get(`${String(node.cache)}:${optsSig}`) ?? null;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
function setCacheEntry(node, opts, entry) {
|
|
755
|
+
if (!("cache" in node) || !node.cache) return;
|
|
756
|
+
const optsSig = `${opts.camelCase}:${opts.ignoreTag}:${opts.prefixTag}:${opts.prefixAttr}:${opts.pretty}:${opts.indentSize}`;
|
|
757
|
+
if (node.cache === true) {
|
|
758
|
+
let map = objectRenderCache.get(node);
|
|
759
|
+
if (!map) {
|
|
760
|
+
map = new Map();
|
|
761
|
+
objectRenderCache.set(node, map);
|
|
762
|
+
}
|
|
763
|
+
map.set(optsSig, entry);
|
|
764
|
+
} else {
|
|
765
|
+
renderCache.set(`${String(node.cache)}:${optsSig}`, entry);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
function replayCachedContext(entry, ctx) {
|
|
770
|
+
for (const sc of entry.scopes) ctx.usedScopes.add(sc);
|
|
771
|
+
for (const [k, v] of entry.headAssets) {
|
|
772
|
+
if (!ctx.headAssets.has(k)) ctx.headAssets.set(k, v);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
function compileSingleElement(rawKey, nodeVal, opts, ctx, depth, inheritedScope) {
|
|
777
|
+
const indent = opts.pretty ? " ".repeat(depth * opts.indentSize) : "";
|
|
778
|
+
const nl = opts.pretty ? "\n" : "";
|
|
779
|
+
|
|
780
|
+
const cached = getCacheEntry(nodeVal, opts);
|
|
781
|
+
if (cached) {
|
|
782
|
+
replayCachedContext(cached, ctx);
|
|
783
|
+
return cached.html;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
const localCtx = "cache" in nodeVal && nodeVal.cache
|
|
787
|
+
? { usedScopes: new Set(), headAssets: new Map() }
|
|
788
|
+
: ctx;
|
|
789
|
+
|
|
790
|
+
const activeScope = nodeVal[SCOPE_KEY] ?? inheritedScope;
|
|
791
|
+
if (activeScope) localCtx.usedScopes.add(activeScope);
|
|
792
|
+
|
|
793
|
+
const childOpts = {
|
|
794
|
+
...opts,
|
|
795
|
+
prefixTag: !nodeVal.noprefix && opts.prefixTag,
|
|
796
|
+
prefixAttr: !nodeVal.nopAttr && opts.prefixAttr
|
|
797
|
+
};
|
|
798
|
+
|
|
799
|
+
const parsed = parseEmmetKey(rawKey);
|
|
800
|
+
let tagName = parsed.tag;
|
|
801
|
+
if (!childOpts.ignoreTag && nodeVal.tag) tagName = nodeVal.tag;
|
|
802
|
+
if (childOpts.camelCase) tagName = toKebabCase(tagName);
|
|
803
|
+
|
|
804
|
+
const fullTag = `${childOpts.prefixTag || ""}${tagName}`;
|
|
805
|
+
const attrs = [];
|
|
806
|
+
const children = [];
|
|
807
|
+
let hasChildElements = false;
|
|
808
|
+
|
|
809
|
+
if (activeScope && tagName !== "style" && tagName !== "script") {
|
|
810
|
+
attrs.push(` data-nb-s='${escapeAttr(activeScope)}'`);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
const resolvedId = nodeVal.id ?? parsed.id;
|
|
814
|
+
const resolvedClasses = [...parsed.classes, ...resolveClassList(nodeVal.class)];
|
|
815
|
+
|
|
816
|
+
if (resolvedId) {
|
|
817
|
+
const idAttr = `${childOpts.prefixAttr || ""}id`;
|
|
818
|
+
attrs.push(` ${idAttr}='${escapeAttr(resolvedId)}'`);
|
|
819
|
+
}
|
|
820
|
+
if (resolvedClasses.length > 0) {
|
|
821
|
+
const clsAttr = `${childOpts.prefixAttr || ""}class`;
|
|
822
|
+
attrs.push(` ${clsAttr}='${escapeAttr(resolvedClasses.join(" "))}'`);
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
let prevWhenMatched = null;
|
|
826
|
+
let innerScope = activeScope;
|
|
827
|
+
|
|
828
|
+
for (const [propKey, propVal] of Object.entries(nodeVal)) {
|
|
829
|
+
if (propVal === undefined || propVal === false || propVal === null) continue;
|
|
830
|
+
if (propKey === "id" || propKey === "class") continue;
|
|
831
|
+
if (propKey === "$head") {
|
|
832
|
+
collectHeadAssets(propVal, localCtx.headAssets);
|
|
833
|
+
continue;
|
|
834
|
+
}
|
|
835
|
+
if (directiveRegistry.has(propKey)) {
|
|
836
|
+
directiveRegistry.get(propKey)(propVal, {
|
|
837
|
+
attrs,
|
|
838
|
+
children,
|
|
839
|
+
tagName: fullTag,
|
|
840
|
+
node: nodeVal,
|
|
841
|
+
escapeHtml
|
|
842
|
+
});
|
|
843
|
+
continue;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
if (propKey === "text" || propKey === "html") {
|
|
847
|
+
if (isChildTree(propVal)) {
|
|
848
|
+
hasChildElements = true;
|
|
849
|
+
children.push(compileNode({ [propKey]: propVal }, childOpts, localCtx, depth + 1, innerScope));
|
|
850
|
+
} else {
|
|
851
|
+
const content =
|
|
852
|
+
propKey === "text"
|
|
853
|
+
? escapeHtml(propVal)
|
|
854
|
+
: typeof propVal === "function"
|
|
855
|
+
? serializeFunctionBody(propVal)
|
|
856
|
+
: String(propVal);
|
|
857
|
+
children.push(content);
|
|
858
|
+
}
|
|
859
|
+
continue;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
if (propKey === "style" && isPlainObj(propVal)) {
|
|
863
|
+
const cssStr = compileCss(propVal, true);
|
|
864
|
+
if (cssStr) {
|
|
865
|
+
const attrName = `${childOpts.prefixAttr || ""}style`;
|
|
866
|
+
attrs.push(` ${attrName}='${escapeAttr(cssStr)}'`);
|
|
867
|
+
}
|
|
868
|
+
continue;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
if (RESERVED_KEYS.has(propKey)) continue;
|
|
872
|
+
|
|
873
|
+
if (propVal === Null || propVal === true) {
|
|
874
|
+
const attrName = `${childOpts.prefixAttr || ""}${childOpts.camelCase ? toKebabCase(propKey) : propKey}`;
|
|
875
|
+
attrs.push(` ${attrName}`);
|
|
876
|
+
continue;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
if (typeof propVal === "function") {
|
|
880
|
+
const attrName = childOpts.camelCase ? toKebabCase(propKey) : propKey;
|
|
881
|
+
const fnCode = buildBoundEventCode(propVal, nodeVal.bind);
|
|
882
|
+
attrs.push(` ${attrName}='${fnCode}'`);
|
|
883
|
+
continue;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
if (typeof propVal === "object") {
|
|
887
|
+
const childOut = compileEntry(propKey, propVal, childOpts, localCtx, depth + 1, innerScope, (matched) => {
|
|
888
|
+
prevWhenMatched = matched;
|
|
889
|
+
}, prevWhenMatched);
|
|
890
|
+
if (childOut !== null) {
|
|
891
|
+
if (childOut !== "") {
|
|
892
|
+
hasChildElements = true;
|
|
893
|
+
children.push(childOut);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
continue;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
const attrName = `${childOpts.prefixAttr || ""}${childOpts.camelCase ? toKebabCase(propKey) : propKey}`;
|
|
900
|
+
attrs.push(` ${attrName}='${escapeAttr(propVal)}'`);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
const isHead = tagName.toLowerCase() === "head";
|
|
904
|
+
const headSlot = isHead ? "__NB_HEAD_SLOT__" : "";
|
|
905
|
+
let html;
|
|
906
|
+
|
|
907
|
+
if (VOID_ELEMENTS.has(tagName.toLowerCase())) {
|
|
908
|
+
html = `${indent}<${fullTag}${attrs.join("")}/>`;
|
|
909
|
+
} else if ((hasChildElements || isHead) && opts.pretty) {
|
|
910
|
+
const inner = children.length > 0 ? `${nl}${children.join(nl)}` : "";
|
|
911
|
+
html = `${indent}<${fullTag}${attrs.join("")}>${inner}${headSlot}${nl}${indent}</${fullTag}>`;
|
|
912
|
+
} else {
|
|
913
|
+
html = `${indent}<${fullTag}${attrs.join("")}>${children.join("")}${headSlot}</${fullTag}>`;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
if (localCtx !== ctx) {
|
|
917
|
+
const cacheEntry = {
|
|
918
|
+
html,
|
|
919
|
+
scopes: [...localCtx.usedScopes],
|
|
920
|
+
headAssets: [...localCtx.headAssets.entries()]
|
|
921
|
+
};
|
|
922
|
+
setCacheEntry(nodeVal, opts, cacheEntry);
|
|
923
|
+
replayCachedContext(cacheEntry, ctx);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
return html;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
function compileEntry(key, val, opts, ctx, depth, inheritedScope, setPrevWhen, prevWhenMatched) {
|
|
930
|
+
const indent = opts.pretty ? " ".repeat(depth * opts.indentSize) : "";
|
|
931
|
+
|
|
932
|
+
if (val === null || val === undefined || val === false) {
|
|
933
|
+
setPrevWhen(null);
|
|
934
|
+
return null;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
if (key.trim() === "$comment") {
|
|
938
|
+
const safe = String(val).replaceAll("--", "- -");
|
|
939
|
+
const keep = safe.startsWith("!");
|
|
940
|
+
return opts.pretty || keep ? `${indent}<!-- ${safe} -->` : null;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
if (key.trim() === "$head") {
|
|
944
|
+
collectHeadAssets(val, ctx.headAssets);
|
|
945
|
+
return null;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
if (key.trim() === "$") {
|
|
949
|
+
if (!Array.isArray(val) && typeof val === "object") {
|
|
950
|
+
if ("when" in val) {
|
|
951
|
+
const cond = Boolean(val.when);
|
|
952
|
+
setPrevWhen(cond);
|
|
953
|
+
if (!cond) return null;
|
|
954
|
+
} else if ("elseIf" in val) {
|
|
955
|
+
if (prevWhenMatched === true) return null;
|
|
956
|
+
const cond = Boolean(val.elseIf);
|
|
957
|
+
setPrevWhen(cond);
|
|
958
|
+
if (!cond) return null;
|
|
959
|
+
} else if ("else" in val) {
|
|
960
|
+
if (prevWhenMatched !== false || !val.else) {
|
|
961
|
+
setPrevWhen(null);
|
|
962
|
+
return null;
|
|
963
|
+
}
|
|
964
|
+
setPrevWhen(null);
|
|
965
|
+
} else {
|
|
966
|
+
setPrevWhen(null);
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
if ("switch" in val && isPlainObj(val.cases)) {
|
|
970
|
+
const { node: branch } = resolveSwitchBranch(val, true);
|
|
971
|
+
return branch ? compileNode(branch, opts, ctx, depth, inheritedScope) : null;
|
|
972
|
+
}
|
|
973
|
+
if ("each" in val) {
|
|
974
|
+
const items = expandEachItems(val);
|
|
975
|
+
return items.map((item) => compileNode(item, opts, ctx, depth, inheritedScope)).filter(Boolean).join(opts.pretty ? "\n" : "");
|
|
976
|
+
}
|
|
977
|
+
} else {
|
|
978
|
+
setPrevWhen(null);
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
const list = Array.isArray(val) ? val : [val];
|
|
982
|
+
const parts = list.map((item) => compileNode(item, opts, ctx, depth, inheritedScope)).filter(Boolean);
|
|
983
|
+
return parts.join(opts.pretty ? "\n" : "");
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
if (Array.isArray(val)) {
|
|
987
|
+
setPrevWhen(null);
|
|
988
|
+
const parts = val
|
|
989
|
+
.map((item) => compileNode({ [key]: item }, opts, ctx, depth, inheritedScope))
|
|
990
|
+
.filter(Boolean);
|
|
991
|
+
return parts.join(opts.pretty ? "\n" : "");
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
if (typeof val !== "object") {
|
|
995
|
+
setPrevWhen(null);
|
|
996
|
+
return null;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
if ("when" in val) {
|
|
1000
|
+
const cond = Boolean(val.when);
|
|
1001
|
+
setPrevWhen(cond);
|
|
1002
|
+
if (!cond) return null;
|
|
1003
|
+
} else if ("elseIf" in val) {
|
|
1004
|
+
if (prevWhenMatched === true) return null;
|
|
1005
|
+
const cond = Boolean(val.elseIf);
|
|
1006
|
+
setPrevWhen(cond);
|
|
1007
|
+
if (!cond) return null;
|
|
1008
|
+
} else if ("else" in val) {
|
|
1009
|
+
if (prevWhenMatched !== false || !val.else) {
|
|
1010
|
+
setPrevWhen(null);
|
|
1011
|
+
return null;
|
|
1012
|
+
}
|
|
1013
|
+
setPrevWhen(null);
|
|
1014
|
+
} else {
|
|
1015
|
+
setPrevWhen(null);
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
if ("each" in val) {
|
|
1019
|
+
const items = expandEachItems(val);
|
|
1020
|
+
const parts = items
|
|
1021
|
+
.map((item) => compileNode({ [key]: item }, opts, ctx, depth, inheritedScope))
|
|
1022
|
+
.filter(Boolean);
|
|
1023
|
+
return parts.join(opts.pretty ? "\n" : "");
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
if ("switch" in val && isPlainObj(val.cases)) {
|
|
1027
|
+
const { node: branchNode } = resolveSwitchBranch(val, false);
|
|
1028
|
+
if (!branchNode) return null;
|
|
1029
|
+
return compileSingleElement(key, branchNode, opts, ctx, depth, inheritedScope);
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
return compileSingleElement(key, val, opts, ctx, depth, inheritedScope);
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
function compileNode(node, opts, ctx, depth = 0, inheritedScope = null) {
|
|
1036
|
+
if (node == null || typeof node !== "object") return "";
|
|
1037
|
+
const activeScope = node[SCOPE_KEY] ?? inheritedScope;
|
|
1038
|
+
if (activeScope) ctx.usedScopes.add(activeScope);
|
|
1039
|
+
|
|
1040
|
+
const nl = opts.pretty ? "\n" : "";
|
|
1041
|
+
const out = [];
|
|
1042
|
+
let prevWhenMatched = null;
|
|
1043
|
+
|
|
1044
|
+
for (const [k, v] of Object.entries(node)) {
|
|
1045
|
+
const res = compileEntry(
|
|
1046
|
+
k,
|
|
1047
|
+
v,
|
|
1048
|
+
opts,
|
|
1049
|
+
ctx,
|
|
1050
|
+
depth,
|
|
1051
|
+
activeScope,
|
|
1052
|
+
(matched) => { prevWhenMatched = matched; },
|
|
1053
|
+
prevWhenMatched
|
|
1054
|
+
);
|
|
1055
|
+
if (res !== null && res !== "") out.push(res);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
return out.join(nl);
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
function buildHeadAndStyles(ctx, opts, hasHeadSlot) {
|
|
1062
|
+
const nl = opts.pretty ? "\n" : "";
|
|
1063
|
+
const headDepth = hasHeadSlot ? 2 : 0;
|
|
1064
|
+
const headItems = [...ctx.headAssets.values()]
|
|
1065
|
+
.sort((a, b) => a.priority - b.priority)
|
|
1066
|
+
.map((asset) => compileNode(asset.node, opts, ctx, headDepth, null));
|
|
1067
|
+
|
|
1068
|
+
const styleRules = [];
|
|
1069
|
+
for (const scopeName of ctx.usedScopes) {
|
|
1070
|
+
if (styleRegistry.has(scopeName)) {
|
|
1071
|
+
styleRules.push(compileScopedCss(styleRegistry.get(scopeName), scopeName));
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
const styleIndent = opts.pretty && hasHeadSlot ? " ".repeat(2 * opts.indentSize) : "";
|
|
1075
|
+
const styleTag = styleRules.length > 0 ? `${styleIndent}<style>${styleRules.join(nl)}</style>` : "";
|
|
1076
|
+
|
|
1077
|
+
return { headItems, styleTag };
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
function renderEngine(root, overrideOpts = null) {
|
|
1081
|
+
const opts = overrideOpts ? { ...currentOption, ...overrideOpts } : { ...currentOption };
|
|
1082
|
+
if (!overrideOpts && currentOption.once) {
|
|
1083
|
+
currentOption = { ...defaultOptions };
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
const ctx = { usedScopes: new Set(), headAssets: new Map() };
|
|
1087
|
+
const nl = opts.pretty ? "\n" : "";
|
|
1088
|
+
const doctype = opts.nodoctype ? "" : `<!DOCTYPE html>${nl}`;
|
|
1089
|
+
|
|
1090
|
+
let bodyHtml = Array.isArray(root)
|
|
1091
|
+
? root.map((item) => compileNode(item, opts, ctx, 0, null)).filter(Boolean).join(nl)
|
|
1092
|
+
: compileNode(root, opts, ctx, 0, null);
|
|
1093
|
+
|
|
1094
|
+
const hasHeadSlot = bodyHtml.includes("__NB_HEAD_SLOT__");
|
|
1095
|
+
const { headItems, styleTag } = buildHeadAndStyles(ctx, opts, hasHeadSlot);
|
|
1096
|
+
|
|
1097
|
+
if (hasHeadSlot) {
|
|
1098
|
+
const slotParts = [...headItems, ...(styleTag ? [styleTag] : [])];
|
|
1099
|
+
const slotStr = slotParts.length > 0 ? `${nl}${slotParts.join(nl)}` : "";
|
|
1100
|
+
bodyHtml = bodyHtml.replace("__NB_HEAD_SLOT__", slotStr).replaceAll("__NB_HEAD_SLOT__", "");
|
|
1101
|
+
return `${doctype}${bodyHtml}`;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
const headPrefix = headItems.length > 0 ? `${headItems.join(nl)}${nl}` : "";
|
|
1105
|
+
const styleSuffix = styleTag ? `${nl}${styleTag}` : "";
|
|
1106
|
+
return `${doctype}${headPrefix}${bodyHtml}${styleSuffix}`;
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
async function* compileNodeStream(node, opts, ctx, depth = 0, inheritedScope = null) {
|
|
1110
|
+
if (node instanceof Promise) {
|
|
1111
|
+
const resolved = await node;
|
|
1112
|
+
yield* compileNodeStream(resolved, opts, ctx, depth, inheritedScope);
|
|
1113
|
+
return;
|
|
1114
|
+
}
|
|
1115
|
+
if (node == null || typeof node !== "object") return;
|
|
1116
|
+
|
|
1117
|
+
if (Array.isArray(node)) {
|
|
1118
|
+
const nl = opts.pretty ? "\n" : "";
|
|
1119
|
+
let first = true;
|
|
1120
|
+
for (const item of node) {
|
|
1121
|
+
if (!first && nl) yield nl;
|
|
1122
|
+
first = false;
|
|
1123
|
+
yield* compileNodeStream(item, opts, ctx, depth, inheritedScope);
|
|
1124
|
+
}
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
const activeScope = node[SCOPE_KEY] ?? inheritedScope;
|
|
1129
|
+
if (activeScope) ctx.usedScopes.add(activeScope);
|
|
1130
|
+
|
|
1131
|
+
const hasPromiseChild = Object.values(node).some(
|
|
1132
|
+
(v) => v instanceof Promise || (v && typeof v === "object" && hasNestedPromise(v))
|
|
1133
|
+
);
|
|
1134
|
+
|
|
1135
|
+
if (!hasPromiseChild) {
|
|
1136
|
+
const chunk = compileNode(node, opts, ctx, depth, activeScope);
|
|
1137
|
+
for (const sc of ctx.usedScopes) {
|
|
1138
|
+
if (!ctx.emittedScopes.has(sc) && styleRegistry.has(sc)) {
|
|
1139
|
+
ctx.emittedScopes.add(sc);
|
|
1140
|
+
yield `<style>${compileScopedCss(styleRegistry.get(sc), sc)}</style>`;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
if (chunk) yield chunk;
|
|
1144
|
+
return;
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
const hasBoundary = "fallback" in node || "onError" in node;
|
|
1148
|
+
try {
|
|
1149
|
+
const nl = opts.pretty ? "\n" : "";
|
|
1150
|
+
const entries = Object.entries(node);
|
|
1151
|
+
let emittedAny = false;
|
|
1152
|
+
|
|
1153
|
+
for (const [k, v] of entries) {
|
|
1154
|
+
if (k === "fallback" || k === "onError") continue;
|
|
1155
|
+
if (v instanceof Promise) {
|
|
1156
|
+
const resolved = await v;
|
|
1157
|
+
if (emittedAny && nl) yield nl;
|
|
1158
|
+
yield* compileNodeStream({ [k]: resolved }, opts, ctx, depth, activeScope);
|
|
1159
|
+
emittedAny = true;
|
|
1160
|
+
} else if (v && typeof v === "object" && hasNestedPromise(v)) {
|
|
1161
|
+
if (k.trim() === "$" || Array.isArray(v)) {
|
|
1162
|
+
if (emittedAny && nl) yield nl;
|
|
1163
|
+
yield* compileNodeStream(v, opts, ctx, depth, activeScope);
|
|
1164
|
+
emittedAny = true;
|
|
1165
|
+
} else {
|
|
1166
|
+
const indent = opts.pretty ? " ".repeat(depth * opts.indentSize) : "";
|
|
1167
|
+
const parsed = parseEmmetKey(k);
|
|
1168
|
+
const tagName = !opts.ignoreTag && v.tag ? v.tag : parsed.tag;
|
|
1169
|
+
const finalTag = `${!v.noprefix && opts.prefixTag ? opts.prefixTag : ""}${opts.camelCase ? toKebabCase(tagName) : tagName}`;
|
|
1170
|
+
|
|
1171
|
+
const headerObj = {};
|
|
1172
|
+
if (v[SCOPE_KEY]) headerObj[SCOPE_KEY] = v[SCOPE_KEY];
|
|
1173
|
+
for (const [ck, cv] of Object.entries(v)) {
|
|
1174
|
+
if (ck === "fallback" || ck === "onError") continue;
|
|
1175
|
+
if (!(cv instanceof Promise) && !(cv && typeof cv === "object" && hasNestedPromise(cv))) {
|
|
1176
|
+
headerObj[ck] = cv;
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
const shellHtml = compileSingleElement(k, headerObj, opts, ctx, depth, activeScope);
|
|
1180
|
+
const closeTag = `</${finalTag}>`;
|
|
1181
|
+
const closeIdx = shellHtml.lastIndexOf(closeTag);
|
|
1182
|
+
|
|
1183
|
+
for (const sc of ctx.usedScopes) {
|
|
1184
|
+
if (!ctx.emittedScopes.has(sc) && styleRegistry.has(sc)) {
|
|
1185
|
+
ctx.emittedScopes.add(sc);
|
|
1186
|
+
yield `<style>${compileScopedCss(styleRegistry.get(sc), sc)}</style>`;
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
if (closeIdx !== -1 && !VOID_ELEMENTS.has(finalTag.toLowerCase())) {
|
|
1191
|
+
yield shellHtml.slice(0, closeIdx);
|
|
1192
|
+
for (const [ck, cv] of Object.entries(v)) {
|
|
1193
|
+
if (ck === "fallback" || ck === "onError") continue;
|
|
1194
|
+
if (cv instanceof Promise || (cv && typeof cv === "object" && hasNestedPromise(cv))) {
|
|
1195
|
+
const resolved = cv instanceof Promise ? await cv : cv;
|
|
1196
|
+
if (ck === "$" || Array.isArray(resolved)) {
|
|
1197
|
+
yield* compileNodeStream(resolved, opts, ctx, depth + 1, v[SCOPE_KEY] ?? activeScope);
|
|
1198
|
+
} else {
|
|
1199
|
+
yield* compileNodeStream({ [ck]: resolved }, opts, ctx, depth + 1, v[SCOPE_KEY] ?? activeScope);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
yield `${indent}${closeTag}`;
|
|
1204
|
+
} else {
|
|
1205
|
+
yield shellHtml;
|
|
1206
|
+
}
|
|
1207
|
+
emittedAny = true;
|
|
1208
|
+
}
|
|
1209
|
+
} else {
|
|
1210
|
+
const chunk = compileNode({ [k]: v }, opts, ctx, depth, activeScope);
|
|
1211
|
+
for (const sc of ctx.usedScopes) {
|
|
1212
|
+
if (!ctx.emittedScopes.has(sc) && styleRegistry.has(sc)) {
|
|
1213
|
+
ctx.emittedScopes.add(sc);
|
|
1214
|
+
yield `<style>${compileScopedCss(styleRegistry.get(sc), sc)}</style>`;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
if (chunk) {
|
|
1218
|
+
if (emittedAny && nl) yield nl;
|
|
1219
|
+
yield chunk;
|
|
1220
|
+
emittedAny = true;
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
} catch (err) {
|
|
1225
|
+
if (hasBoundary) {
|
|
1226
|
+
const fbNode = applyAsyncFallback(node, err);
|
|
1227
|
+
yield* compileNodeStream(fbNode, opts, ctx, depth, inheritedScope);
|
|
1228
|
+
} else {
|
|
1229
|
+
throw err;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
function hasNestedPromise(val) {
|
|
1235
|
+
if (val instanceof Promise) return true;
|
|
1236
|
+
if (!val || typeof val !== "object") return false;
|
|
1237
|
+
if (Array.isArray(val)) return val.some(hasNestedPromise);
|
|
1238
|
+
return Object.values(val).some(hasNestedPromise);
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
function renderStreamEngine(root, overrideOpts = null) {
|
|
1242
|
+
const opts = overrideOpts ? { ...currentOption, ...overrideOpts } : { ...currentOption };
|
|
1243
|
+
if (!overrideOpts && currentOption.once) {
|
|
1244
|
+
currentOption = { ...defaultOptions };
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
return new ReadableStream({
|
|
1248
|
+
async start(controller) {
|
|
1249
|
+
try {
|
|
1250
|
+
const ctx = { usedScopes: new Set(), emittedScopes: new Set(), headAssets: new Map() };
|
|
1251
|
+
const nl = opts.pretty ? "\n" : "";
|
|
1252
|
+
if (!opts.nodoctype) controller.enqueue(`<!DOCTYPE html>${nl}`);
|
|
1253
|
+
|
|
1254
|
+
const roots = Array.isArray(root) ? root : [root];
|
|
1255
|
+
let first = true;
|
|
1256
|
+
for (const item of roots) {
|
|
1257
|
+
for await (const chunk of compileNodeStream(item, opts, ctx, 0, null)) {
|
|
1258
|
+
if (!chunk) continue;
|
|
1259
|
+
let out = chunk;
|
|
1260
|
+
if (out.includes("__NB_HEAD_SLOT__")) {
|
|
1261
|
+
const { headItems } = buildHeadAndStyles(ctx, opts, true);
|
|
1262
|
+
const slotStr = headItems.length > 0 ? `${nl}${headItems.join(nl)}` : "";
|
|
1263
|
+
out = out.replace("__NB_HEAD_SLOT__", slotStr).replaceAll("__NB_HEAD_SLOT__", "");
|
|
1264
|
+
}
|
|
1265
|
+
if (!first && nl) controller.enqueue(nl);
|
|
1266
|
+
first = false;
|
|
1267
|
+
controller.enqueue(out);
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
controller.close();
|
|
1271
|
+
} catch (err) {
|
|
1272
|
+
controller.error(err);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
function injectMountHeadAssets(ctx) {
|
|
1279
|
+
if (typeof document === "undefined" || !document.head) return;
|
|
1280
|
+
const sorted = [...ctx.headAssets.entries()].sort((a, b) => a[1].priority - b[1].priority);
|
|
1281
|
+
for (const [dedupeKey, asset] of sorted) {
|
|
1282
|
+
if (document.head.querySelector(`[data-nb-head="${dedupeKey.replaceAll('"', '\\"')}"]`)) continue;
|
|
1283
|
+
const html = compileNode(asset.node, { ...defaultOptions, nodoctype: true }, { usedScopes: new Set(), headAssets: new Map() }, 0, null);
|
|
1284
|
+
const tpl = document.createElement("template");
|
|
1285
|
+
tpl.innerHTML = html;
|
|
1286
|
+
for (const child of tpl.content.children) {
|
|
1287
|
+
child.setAttribute("data-nb-head", dedupeKey);
|
|
1288
|
+
document.head.appendChild(child);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
for (const scopeName of ctx.usedScopes) {
|
|
1292
|
+
if (!styleRegistry.has(scopeName)) continue;
|
|
1293
|
+
if (document.head.querySelector(`style[data-nb-style="${scopeName}"]`)) continue;
|
|
1294
|
+
const styleEl = document.createElement("style");
|
|
1295
|
+
styleEl.setAttribute("data-nb-style", scopeName);
|
|
1296
|
+
styleEl.textContent = compileScopedCss(styleRegistry.get(scopeName), scopeName);
|
|
1297
|
+
document.head.appendChild(styleEl);
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
function mountNodeToDom(node, opts, ctx, inheritedScope = null) {
|
|
1302
|
+
const frag = document.createDocumentFragment();
|
|
1303
|
+
if (node == null || typeof node !== "object") return frag;
|
|
1304
|
+
|
|
1305
|
+
const activeScope = node[SCOPE_KEY] ?? inheritedScope;
|
|
1306
|
+
if (activeScope) ctx.usedScopes.add(activeScope);
|
|
1307
|
+
|
|
1308
|
+
let prevWhenMatched = null;
|
|
1309
|
+
|
|
1310
|
+
const appendEntry = (key, val) => {
|
|
1311
|
+
if (val === null || val === undefined || val === false) {
|
|
1312
|
+
prevWhenMatched = null;
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
if (key.trim() === "$comment") {
|
|
1316
|
+
frag.appendChild(document.createComment(` ${String(val).replaceAll("--", "- -")} `));
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
if (key.trim() === "$head") {
|
|
1320
|
+
collectHeadAssets(val, ctx.headAssets);
|
|
1321
|
+
return;
|
|
1322
|
+
}
|
|
1323
|
+
if (key.trim() === "$") {
|
|
1324
|
+
if (!Array.isArray(val) && typeof val === "object") {
|
|
1325
|
+
if ("when" in val) {
|
|
1326
|
+
prevWhenMatched = Boolean(val.when);
|
|
1327
|
+
if (!prevWhenMatched) return;
|
|
1328
|
+
} else if ("elseIf" in val) {
|
|
1329
|
+
if (prevWhenMatched === true) return;
|
|
1330
|
+
prevWhenMatched = Boolean(val.elseIf);
|
|
1331
|
+
if (!prevWhenMatched) return;
|
|
1332
|
+
} else if ("else" in val) {
|
|
1333
|
+
if (prevWhenMatched !== false || !val.else) {
|
|
1334
|
+
prevWhenMatched = null;
|
|
1335
|
+
return;
|
|
1336
|
+
}
|
|
1337
|
+
prevWhenMatched = null;
|
|
1338
|
+
} else {
|
|
1339
|
+
prevWhenMatched = null;
|
|
1340
|
+
}
|
|
1341
|
+
if ("switch" in val && isPlainObj(val.cases)) {
|
|
1342
|
+
const { node: branch } = resolveSwitchBranch(val, true);
|
|
1343
|
+
if (branch) frag.appendChild(mountNodeToDom(branch, opts, ctx, activeScope));
|
|
1344
|
+
return;
|
|
1345
|
+
}
|
|
1346
|
+
if ("each" in val) {
|
|
1347
|
+
for (const item of expandEachItems(val)) {
|
|
1348
|
+
frag.appendChild(mountNodeToDom(item, opts, ctx, activeScope));
|
|
1349
|
+
}
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1352
|
+
} else {
|
|
1353
|
+
prevWhenMatched = null;
|
|
1354
|
+
}
|
|
1355
|
+
const list = Array.isArray(val) ? val : [val];
|
|
1356
|
+
for (const item of list) frag.appendChild(mountNodeToDom(item, opts, ctx, activeScope));
|
|
1357
|
+
return;
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
if (Array.isArray(val)) {
|
|
1361
|
+
prevWhenMatched = null;
|
|
1362
|
+
for (const item of val) appendEntry(key, item);
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
if (typeof val !== "object") {
|
|
1367
|
+
prevWhenMatched = null;
|
|
1368
|
+
return;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
if ("when" in val) {
|
|
1372
|
+
prevWhenMatched = Boolean(val.when);
|
|
1373
|
+
if (!prevWhenMatched) return;
|
|
1374
|
+
} else if ("elseIf" in val) {
|
|
1375
|
+
if (prevWhenMatched === true) return;
|
|
1376
|
+
prevWhenMatched = Boolean(val.elseIf);
|
|
1377
|
+
if (!prevWhenMatched) return;
|
|
1378
|
+
} else if ("else" in val) {
|
|
1379
|
+
if (prevWhenMatched !== false || !val.else) {
|
|
1380
|
+
prevWhenMatched = null;
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
prevWhenMatched = null;
|
|
1384
|
+
} else {
|
|
1385
|
+
prevWhenMatched = null;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
if ("each" in val) {
|
|
1389
|
+
for (const item of expandEachItems(val)) {
|
|
1390
|
+
appendEntry(key, item);
|
|
1391
|
+
}
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
let targetVal = val;
|
|
1396
|
+
if ("switch" in val && isPlainObj(val.cases)) {
|
|
1397
|
+
const { node: branchNode } = resolveSwitchBranch(val, false);
|
|
1398
|
+
if (!branchNode) return;
|
|
1399
|
+
targetVal = branchNode;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
const nodeScope = targetVal[SCOPE_KEY] ?? activeScope;
|
|
1403
|
+
if (nodeScope) ctx.usedScopes.add(nodeScope);
|
|
1404
|
+
|
|
1405
|
+
const childOpts = {
|
|
1406
|
+
...opts,
|
|
1407
|
+
prefixTag: !targetVal.noprefix && opts.prefixTag,
|
|
1408
|
+
prefixAttr: !targetVal.nopAttr && opts.prefixAttr
|
|
1409
|
+
};
|
|
1410
|
+
|
|
1411
|
+
const parsed = parseEmmetKey(key);
|
|
1412
|
+
let tagName = parsed.tag;
|
|
1413
|
+
if (!childOpts.ignoreTag && targetVal.tag) tagName = targetVal.tag;
|
|
1414
|
+
if (childOpts.camelCase) tagName = toKebabCase(tagName);
|
|
1415
|
+
const fullTag = `${childOpts.prefixTag || ""}${tagName}`;
|
|
1416
|
+
|
|
1417
|
+
const el = document.createElement(fullTag);
|
|
1418
|
+
|
|
1419
|
+
if (nodeScope && tagName !== "style" && tagName !== "script") {
|
|
1420
|
+
el.setAttribute("data-nb-s", nodeScope);
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
const resolvedId = targetVal.id ?? parsed.id;
|
|
1424
|
+
if (resolvedId) el.setAttribute(`${childOpts.prefixAttr || ""}id`, String(resolvedId));
|
|
1425
|
+
|
|
1426
|
+
const resolvedClasses = [...parsed.classes, ...resolveClassList(targetVal.class)];
|
|
1427
|
+
if (resolvedClasses.length > 0) {
|
|
1428
|
+
el.setAttribute(`${childOpts.prefixAttr || ""}class`, resolvedClasses.join(" "));
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
for (const [pk, pv] of Object.entries(targetVal)) {
|
|
1432
|
+
if (pv === undefined || pv === false || pv === null) continue;
|
|
1433
|
+
if (pk === "id" || pk === "class") continue;
|
|
1434
|
+
if (pk === "$head") {
|
|
1435
|
+
collectHeadAssets(pv, ctx.headAssets);
|
|
1436
|
+
continue;
|
|
1437
|
+
}
|
|
1438
|
+
if (directiveRegistry.has(pk)) {
|
|
1439
|
+
const dAttrs = [];
|
|
1440
|
+
const dChildren = [];
|
|
1441
|
+
directiveRegistry.get(pk)(pv, {
|
|
1442
|
+
attrs: dAttrs,
|
|
1443
|
+
children: dChildren,
|
|
1444
|
+
tagName: fullTag,
|
|
1445
|
+
node: targetVal,
|
|
1446
|
+
element: el,
|
|
1447
|
+
escapeHtml
|
|
1448
|
+
});
|
|
1449
|
+
if (dAttrs.length > 0) {
|
|
1450
|
+
const tpl = document.createElement("template");
|
|
1451
|
+
tpl.innerHTML = `<div ${dAttrs.join(" ")}></div>`;
|
|
1452
|
+
const tmpEl = tpl.content.firstElementChild;
|
|
1453
|
+
if (tmpEl) {
|
|
1454
|
+
for (const a of tmpEl.attributes) el.setAttribute(a.name, a.value);
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
for (const ch of dChildren) el.insertAdjacentHTML("beforeend", ch);
|
|
1458
|
+
continue;
|
|
1459
|
+
}
|
|
1460
|
+
if (pk === "text" || pk === "html") {
|
|
1461
|
+
if (isChildTree(pv)) {
|
|
1462
|
+
el.appendChild(mountNodeToDom({ [pk]: pv }, childOpts, ctx, nodeScope));
|
|
1463
|
+
} else if (pk === "text") {
|
|
1464
|
+
el.appendChild(document.createTextNode(String(pv)));
|
|
1465
|
+
} else {
|
|
1466
|
+
const raw = typeof pv === "function" ? serializeFunctionBody(pv) : String(pv);
|
|
1467
|
+
el.insertAdjacentHTML("beforeend", raw);
|
|
1468
|
+
}
|
|
1469
|
+
continue;
|
|
1470
|
+
}
|
|
1471
|
+
if (pk === "style" && isPlainObj(pv)) {
|
|
1472
|
+
const cssStr = compileCss(pv, true);
|
|
1473
|
+
if (cssStr) el.setAttribute(`${childOpts.prefixAttr || ""}style`, cssStr);
|
|
1474
|
+
continue;
|
|
1475
|
+
}
|
|
1476
|
+
if (RESERVED_KEYS.has(pk)) continue;
|
|
1477
|
+
if (pv === Null || pv === true) {
|
|
1478
|
+
el.setAttribute(`${childOpts.prefixAttr || ""}${childOpts.camelCase ? toKebabCase(pk) : pk}`, "");
|
|
1479
|
+
continue;
|
|
1480
|
+
}
|
|
1481
|
+
if (typeof pv === "function") {
|
|
1482
|
+
if (pk.toLowerCase().startsWith("on")) {
|
|
1483
|
+
el.addEventListener(pk.slice(2).toLowerCase(), pv);
|
|
1484
|
+
} else {
|
|
1485
|
+
el.setAttribute(pk, buildBoundEventCode(pv, targetVal.bind));
|
|
1486
|
+
}
|
|
1487
|
+
continue;
|
|
1488
|
+
}
|
|
1489
|
+
if (typeof pv === "object") {
|
|
1490
|
+
el.appendChild(mountNodeToDom({ [pk]: pv }, childOpts, ctx, nodeScope));
|
|
1491
|
+
continue;
|
|
1492
|
+
}
|
|
1493
|
+
el.setAttribute(`${childOpts.prefixAttr || ""}${childOpts.camelCase ? toKebabCase(pk) : pk}`, String(pv));
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
frag.appendChild(el);
|
|
1497
|
+
};
|
|
1498
|
+
|
|
1499
|
+
for (const [k, v] of Object.entries(node)) {
|
|
1500
|
+
appendEntry(k, v);
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
return frag;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
function mountEngine(node, target) {
|
|
1507
|
+
if (typeof document === "undefined") {
|
|
1508
|
+
throw new Error("mount() requires a browser DOM environment");
|
|
1509
|
+
}
|
|
1510
|
+
const el = typeof target === "string" ? document.querySelector(target) : target;
|
|
1511
|
+
if (!el || typeof el.appendChild !== "function") {
|
|
1512
|
+
throw new Error("mount() target must be a valid Element or selector");
|
|
1513
|
+
}
|
|
1514
|
+
const opts = { ...currentOption, nodoctype: true };
|
|
1515
|
+
const ctx = { usedScopes: new Set(), headAssets: new Map() };
|
|
1516
|
+
const items = Array.isArray(node) ? node : [node];
|
|
1517
|
+
el.innerHTML = "";
|
|
1518
|
+
for (const item of items) {
|
|
1519
|
+
el.appendChild(mountNodeToDom(item, opts, ctx, null));
|
|
1520
|
+
}
|
|
1521
|
+
injectMountHeadAssets(ctx);
|
|
1522
|
+
return el;
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
const clearCache = (key) => {
|
|
1526
|
+
if (key === undefined) {
|
|
1527
|
+
renderCache.clear();
|
|
1528
|
+
objectRenderCache = new WeakMap();
|
|
1529
|
+
} else {
|
|
1530
|
+
const prefix = `${String(key)}:`;
|
|
1531
|
+
for (const k of renderCache.keys()) {
|
|
1532
|
+
if (k.startsWith(prefix)) renderCache.delete(k);
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
};
|
|
1536
|
+
|
|
1537
|
+
const renderOption = (opt) => {
|
|
1538
|
+
currentOption = { ...defaultOptions, ...opt };
|
|
1539
|
+
};
|
|
1540
|
+
|
|
1541
|
+
const addDirective = (name, fn) => {
|
|
1542
|
+
if (typeof fn === "function") directiveRegistry.set(name, fn);
|
|
1543
|
+
};
|
|
1544
|
+
|
|
1545
|
+
const removeDirective = (name) => {
|
|
1546
|
+
directiveRegistry.delete(name);
|
|
1547
|
+
};
|
|
1548
|
+
|
|
1549
|
+
const loadComponent = (name) => componentRegistry.get(name) ?? null;
|
|
1550
|
+
|
|
1551
|
+
Object.defineProperties(Object.prototype, {
|
|
1552
|
+
Null: { value: Null },
|
|
1553
|
+
renderOption: { value: renderOption },
|
|
1554
|
+
addDirective: { value: addDirective },
|
|
1555
|
+
removeDirective: { value: removeDirective },
|
|
1556
|
+
clearCache: { value: clearCache },
|
|
1557
|
+
regStyle: {
|
|
1558
|
+
value(name) {
|
|
1559
|
+
styleRegistry.set(name, this);
|
|
1560
|
+
return this;
|
|
1561
|
+
}
|
|
1562
|
+
},
|
|
1563
|
+
scope: {
|
|
1564
|
+
value(name) {
|
|
1565
|
+
this[SCOPE_KEY] = name;
|
|
1566
|
+
return this;
|
|
1567
|
+
}
|
|
1568
|
+
},
|
|
1569
|
+
query: {
|
|
1570
|
+
value(selector, callback) {
|
|
1571
|
+
if (typeof callback === "function") queryTree(this, selector, callback);
|
|
1572
|
+
return this;
|
|
1573
|
+
}
|
|
1574
|
+
},
|
|
1575
|
+
_render: {
|
|
1576
|
+
get() {
|
|
1577
|
+
return renderEngine(this);
|
|
1578
|
+
}
|
|
1579
|
+
},
|
|
1580
|
+
_renderAsync: {
|
|
1581
|
+
get() {
|
|
1582
|
+
return (async () => renderEngine(await resolveAsyncTree(this)))();
|
|
1583
|
+
}
|
|
1584
|
+
},
|
|
1585
|
+
_renderStream: {
|
|
1586
|
+
get() {
|
|
1587
|
+
return renderStreamEngine(this);
|
|
1588
|
+
}
|
|
1589
|
+
},
|
|
1590
|
+
mount: {
|
|
1591
|
+
value(target) {
|
|
1592
|
+
mountEngine(this, target);
|
|
1593
|
+
return this;
|
|
1594
|
+
}
|
|
1595
|
+
},
|
|
1596
|
+
reg: {
|
|
1597
|
+
value(name) {
|
|
1598
|
+
if (!componentRegistry.has(name)) componentRegistry.set(name, this);
|
|
1599
|
+
return this;
|
|
1600
|
+
}
|
|
1601
|
+
},
|
|
1602
|
+
regm: {
|
|
1603
|
+
value(name) {
|
|
1604
|
+
if (componentRegistry.has(name)) componentRegistry.set(name, this);
|
|
1605
|
+
return this;
|
|
1606
|
+
}
|
|
1607
|
+
},
|
|
1608
|
+
unreg: {
|
|
1609
|
+
value(name) {
|
|
1610
|
+
componentRegistry.delete(name);
|
|
1611
|
+
}
|
|
1612
|
+
},
|
|
1613
|
+
load: { value: loadComponent },
|
|
1614
|
+
css: {
|
|
1615
|
+
get() {
|
|
1616
|
+
return { text: compileCss(this, false) };
|
|
1617
|
+
}
|
|
1618
|
+
},
|
|
1619
|
+
cssText: {
|
|
1620
|
+
get() {
|
|
1621
|
+
return compileCss(this, true);
|
|
1622
|
+
}
|
|
1623
|
+
},
|
|
1624
|
+
alter: {
|
|
1625
|
+
value(callback) {
|
|
1626
|
+
callback(this);
|
|
1627
|
+
return this;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
});
|
|
1631
|
+
|
|
1632
|
+
Object.defineProperty(String.prototype, "repulse", {
|
|
1633
|
+
get() {
|
|
1634
|
+
return htmlToNeobiz(this);
|
|
1635
|
+
}
|
|
1636
|
+
});
|
|
1637
|
+
|
|
1638
|
+
Object.defineProperty(Array.prototype, "range", {
|
|
1639
|
+
value: (len, start = 0) => Array.from({ length: len }, (_, i) => start + i)
|
|
1640
|
+
});
|
|
1641
|
+
|
|
1642
|
+
if (typeof Element !== "undefined" && typeof Document !== "undefined") {
|
|
1643
|
+
const domQueryDescriptor = {
|
|
1644
|
+
value(selector, callback) {
|
|
1645
|
+
if (typeof callback === "function") {
|
|
1646
|
+
this.querySelectorAll(selector).forEach((el) => callback(el));
|
|
1647
|
+
}
|
|
1648
|
+
return this;
|
|
1649
|
+
}
|
|
1650
|
+
};
|
|
1651
|
+
Object.defineProperty(Document.prototype, "query", domQueryDescriptor);
|
|
1652
|
+
Object.defineProperty(Element.prototype, "query", domQueryDescriptor);
|
|
1653
|
+
Object.defineProperties(Element.prototype, {
|
|
1654
|
+
htmlObj: {
|
|
1655
|
+
set(obj) {
|
|
1656
|
+
this.innerHTML = renderEngine(obj, { nodoctype: true });
|
|
1657
|
+
}
|
|
1658
|
+
},
|
|
1659
|
+
appendObj: {
|
|
1660
|
+
value(obj) {
|
|
1661
|
+
this.insertAdjacentHTML("beforeend", renderEngine(obj, { nodoctype: true }));
|
|
1662
|
+
return this;
|
|
1663
|
+
}
|
|
1664
|
+
},
|
|
1665
|
+
mountObj: {
|
|
1666
|
+
value(obj) {
|
|
1667
|
+
return mountEngine(obj, this);
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
});
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
const Neobiz = {
|
|
1674
|
+
Null,
|
|
1675
|
+
renderOption,
|
|
1676
|
+
render: (node, opts) => renderEngine(node, opts),
|
|
1677
|
+
renderAsync: async (node, opts) => renderEngine(await resolveAsyncTree(node), opts),
|
|
1678
|
+
renderStream: (node, opts) => renderStreamEngine(node, opts),
|
|
1679
|
+
query: (node, selector, callback) => {
|
|
1680
|
+
if (typeof callback === "function") queryTree(node, selector, callback);
|
|
1681
|
+
return node;
|
|
1682
|
+
},
|
|
1683
|
+
repulse: (html) => htmlToNeobiz(html),
|
|
1684
|
+
addDirective,
|
|
1685
|
+
removeDirective,
|
|
1686
|
+
clearCache,
|
|
1687
|
+
regStyle: (name, styleObj) => (styleRegistry.set(name, styleObj), styleObj),
|
|
1688
|
+
scope: (node, name) => ((node[SCOPE_KEY] = name), node),
|
|
1689
|
+
reg: (name, obj) => (componentRegistry.has(name) || componentRegistry.set(name, obj), obj),
|
|
1690
|
+
regm: (name, obj) => (componentRegistry.has(name) && componentRegistry.set(name, obj), obj),
|
|
1691
|
+
unreg: (name) => componentRegistry.delete(name),
|
|
1692
|
+
load: loadComponent,
|
|
1693
|
+
css: (styleObj) => ({ text: compileCss(styleObj, false) }),
|
|
1694
|
+
cssText: (styleObj) => compileCss(styleObj, true),
|
|
1695
|
+
alter: (obj, cb) => (cb(obj), obj),
|
|
1696
|
+
mount: (node, target) => mountEngine(node, target)
|
|
1697
|
+
};
|
|
1698
|
+
|
|
1699
|
+
if (typeof globalThis !== "undefined") {
|
|
1700
|
+
globalThis.Neobiz = Neobiz;
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
if (typeof module === "object" && module && module.exports) {
|
|
1704
|
+
module.exports = {
|
|
1705
|
+
Null,
|
|
1706
|
+
renderOption,
|
|
1707
|
+
render: Neobiz.render,
|
|
1708
|
+
renderAsync: Neobiz.renderAsync,
|
|
1709
|
+
renderStream: Neobiz.renderStream,
|
|
1710
|
+
query: Neobiz.query,
|
|
1711
|
+
repulse: Neobiz.repulse,
|
|
1712
|
+
addDirective,
|
|
1713
|
+
removeDirective,
|
|
1714
|
+
clearCache,
|
|
1715
|
+
regStyle: Neobiz.regStyle,
|
|
1716
|
+
scope: Neobiz.scope,
|
|
1717
|
+
reg: Neobiz.reg,
|
|
1718
|
+
regm: Neobiz.regm,
|
|
1719
|
+
unreg: Neobiz.unreg,
|
|
1720
|
+
load: loadComponent,
|
|
1721
|
+
css: Neobiz.css,
|
|
1722
|
+
cssText: Neobiz.cssText,
|
|
1723
|
+
alter: Neobiz.alter,
|
|
1724
|
+
mount: Neobiz.mount
|
|
1725
|
+
};
|
|
1726
|
+
}
|