sibujs 4.7.0 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.cjs +45 -4
- package/dist/browser.d.cts +23 -0
- package/dist/browser.d.ts +23 -0
- package/dist/browser.js +6 -5
- package/dist/build.cjs +513 -78
- package/dist/build.d.cts +22 -8
- package/dist/build.d.ts +22 -8
- package/dist/build.js +68 -21
- package/dist/cdn.dev.global.js +15 -13
- package/dist/cdn.full.dev.global.js +15 -13
- package/dist/cdn.full.global.js +14 -12
- package/dist/cdn.global.js +14 -12
- package/dist/chunk-3ACAAQIN.js +224 -0
- package/dist/{chunk-DKXRACVN.js → chunk-44MTL7ED.js} +6 -6
- package/dist/{chunk-3QWBSL5R.js → chunk-4WMSTZ7J.js} +8 -5
- package/dist/{chunk-H3SRKIYX.js → chunk-62BDYGAG.js} +8 -0
- package/dist/{chunk-BSY63EM6.js → chunk-C5PEWEGH.js} +20 -5
- package/dist/{chunk-BC2SECJD.js → chunk-C7AA2CZX.js} +1 -1
- package/dist/{chunk-SLM3IA34.js → chunk-CZPRSWSS.js} +1 -1
- package/dist/{chunk-FQRUXCEE.js → chunk-DSID757X.js} +1 -1
- package/dist/{chunk-ZVL7TY4K.js → chunk-EGUQLBHE.js} +22 -8
- package/dist/{chunk-2INLLLMZ.js → chunk-EXXSN3BW.js} +202 -26
- package/dist/{chunk-HURREPU2.js → chunk-FC6KCJSA.js} +87 -150
- package/dist/{chunk-Z3OHK6QT.js → chunk-GSGNX35Q.js} +5 -5
- package/dist/{chunk-XYV3EDB7.js → chunk-J3YQ457H.js} +37 -20
- package/dist/{chunk-VZSG24LS.js → chunk-JUTFX2RM.js} +18 -10
- package/dist/{chunk-RUSSKG6G.js → chunk-KJ3UKABJ.js} +1 -1
- package/dist/{chunk-UNWRJRKC.js → chunk-LI4W3U6C.js} +1 -1
- package/dist/{chunk-FNJXNGYZ.js → chunk-O6TRVMJI.js} +58 -6
- package/dist/{chunk-7LUJQAOJ.js → chunk-Q5J2LVKH.js} +1 -1
- package/dist/{chunk-4AWA2PVD.js → chunk-QGMSESDD.js} +10 -5
- package/dist/{chunk-XZR4PXRE.js → chunk-RGLPEBDE.js} +13 -10
- package/dist/{chunk-JWKYU5GV.js → chunk-TQQUN4WR.js} +1 -1
- package/dist/{chunk-WOLJZUFQ.js → chunk-UCNP3HVM.js} +12 -8
- package/dist/{chunk-WEQ3DMVL.js → chunk-V3LHZSU5.js} +1 -1
- package/dist/{chunk-UOL2ECCS.js → chunk-VWT3VXPL.js} +18 -12
- package/dist/{chunk-2BPG2XDA.js → chunk-ZVLHNEEL.js} +17 -35
- package/dist/{customElement-MmInOW1U.d.ts → customElement-pYDKUzWl.d.cts} +11 -3
- package/dist/{customElement-MmInOW1U.d.cts → customElement-pYDKUzWl.d.ts} +11 -3
- package/dist/data.cjs +9 -2
- package/dist/data.js +6 -6
- package/dist/devtools.cjs +1 -1
- package/dist/devtools.js +5 -5
- package/dist/ecosystem.cjs +400 -37
- package/dist/ecosystem.js +9 -8
- package/dist/extras.cjs +621 -252
- package/dist/extras.d.cts +2 -2
- package/dist/extras.d.ts +2 -2
- package/dist/extras.js +24 -23
- package/dist/index.cjs +464 -70
- package/dist/index.d.cts +28 -2
- package/dist/index.d.ts +28 -2
- package/dist/index.js +16 -12
- package/dist/motion.cjs +1 -1
- package/dist/motion.js +3 -3
- package/dist/patterns.cjs +10 -7
- package/dist/patterns.js +6 -6
- package/dist/performance.cjs +31 -2
- package/dist/performance.d.cts +12 -2
- package/dist/performance.d.ts +12 -2
- package/dist/performance.js +8 -6
- package/dist/plugins.cjs +558 -231
- package/dist/plugins.d.cts +8 -3
- package/dist/plugins.d.ts +8 -3
- package/dist/plugins.js +22 -28
- package/dist/{ssr-XOTUASDO.js → ssr-5OWAH3U2.js} +4 -2
- package/dist/{ssr-Bli9XRW5.d.ts → ssr-C8hgIAw7.d.cts} +6 -0
- package/dist/{ssr-Bli9XRW5.d.cts → ssr-C8hgIAw7.d.ts} +6 -0
- package/dist/ssr.cjs +457 -131
- package/dist/ssr.d.cts +55 -5
- package/dist/ssr.d.ts +55 -5
- package/dist/ssr.js +11 -9
- package/dist/testing.cjs +3 -3
- package/dist/testing.js +4 -4
- package/dist/ui.cjs +608 -240
- package/dist/ui.d.cts +1 -1
- package/dist/ui.d.ts +1 -1
- package/dist/ui.js +9 -8
- package/dist/widgets.cjs +1 -1
- package/dist/widgets.js +7 -7
- package/package.json +5 -4
package/dist/build.d.cts
CHANGED
|
@@ -48,9 +48,11 @@ interface SibuVitePluginOptions {
|
|
|
48
48
|
*/
|
|
49
49
|
staticOptimize?: boolean;
|
|
50
50
|
/**
|
|
51
|
-
* Compile `html` tagged templates (imported from sibujs)
|
|
52
|
-
*
|
|
53
|
-
*
|
|
51
|
+
* Compile `html` tagged templates (imported from sibujs) at build time.
|
|
52
|
+
* Default: true in production builds. Most templates become direct DOM
|
|
53
|
+
* construction; the rest are parsed at build time and rendered by the
|
|
54
|
+
* runtime's own executor, so no template is parsed in the browser (the sole
|
|
55
|
+
* exception is a template consisting of one invalid escape sequence).
|
|
54
56
|
*/
|
|
55
57
|
compileTemplates?: boolean;
|
|
56
58
|
}
|
|
@@ -97,12 +99,24 @@ declare function createViteConfig(options?: {
|
|
|
97
99
|
*/
|
|
98
100
|
interface SibuWebpackPluginOptions {
|
|
99
101
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
102
|
+
* NOT applied by the plugin — pure annotations under webpack need a loader
|
|
103
|
+
* rule, and webpack loaders must be resolvable module files. Setting this to
|
|
104
|
+
* `true` logs how to add the one-line loader instead of silently doing
|
|
105
|
+
* nothing:
|
|
106
|
+
*
|
|
107
|
+
* ```js
|
|
108
|
+
* // sibu-pure-loader.cjs
|
|
109
|
+
* module.exports = require("sibujs/build").createPureAnnotationsLoader();
|
|
110
|
+
*
|
|
111
|
+
* // webpack.config.js
|
|
112
|
+
* module: {
|
|
113
|
+
* rules: [{ test: /\.[cm]?[jt]sx?$/, exclude: /node_modules/, use: "./sibu-pure-loader.cjs" }],
|
|
114
|
+
* }
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* The rule this plugin used to push named a loader that does not exist
|
|
103
118
|
* (`__sibu_inline_loader__`), which failed every build with the default
|
|
104
|
-
* options
|
|
105
|
-
* `createPureAnnotationsLoader()(source)`.
|
|
119
|
+
* options; the option is kept so existing configs keep compiling.
|
|
106
120
|
*/
|
|
107
121
|
pureAnnotations?: boolean;
|
|
108
122
|
/**
|
package/dist/build.d.ts
CHANGED
|
@@ -48,9 +48,11 @@ interface SibuVitePluginOptions {
|
|
|
48
48
|
*/
|
|
49
49
|
staticOptimize?: boolean;
|
|
50
50
|
/**
|
|
51
|
-
* Compile `html` tagged templates (imported from sibujs)
|
|
52
|
-
*
|
|
53
|
-
*
|
|
51
|
+
* Compile `html` tagged templates (imported from sibujs) at build time.
|
|
52
|
+
* Default: true in production builds. Most templates become direct DOM
|
|
53
|
+
* construction; the rest are parsed at build time and rendered by the
|
|
54
|
+
* runtime's own executor, so no template is parsed in the browser (the sole
|
|
55
|
+
* exception is a template consisting of one invalid escape sequence).
|
|
54
56
|
*/
|
|
55
57
|
compileTemplates?: boolean;
|
|
56
58
|
}
|
|
@@ -97,12 +99,24 @@ declare function createViteConfig(options?: {
|
|
|
97
99
|
*/
|
|
98
100
|
interface SibuWebpackPluginOptions {
|
|
99
101
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
102
|
+
* NOT applied by the plugin — pure annotations under webpack need a loader
|
|
103
|
+
* rule, and webpack loaders must be resolvable module files. Setting this to
|
|
104
|
+
* `true` logs how to add the one-line loader instead of silently doing
|
|
105
|
+
* nothing:
|
|
106
|
+
*
|
|
107
|
+
* ```js
|
|
108
|
+
* // sibu-pure-loader.cjs
|
|
109
|
+
* module.exports = require("sibujs/build").createPureAnnotationsLoader();
|
|
110
|
+
*
|
|
111
|
+
* // webpack.config.js
|
|
112
|
+
* module: {
|
|
113
|
+
* rules: [{ test: /\.[cm]?[jt]sx?$/, exclude: /node_modules/, use: "./sibu-pure-loader.cjs" }],
|
|
114
|
+
* }
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* The rule this plugin used to push named a loader that does not exist
|
|
103
118
|
* (`__sibu_inline_loader__`), which failed every build with the default
|
|
104
|
-
* options
|
|
105
|
-
* `createPureAnnotationsLoader()(source)`.
|
|
119
|
+
* options; the option is kept so existing configs keep compiling.
|
|
106
120
|
*/
|
|
107
121
|
pureAnnotations?: boolean;
|
|
108
122
|
/**
|
package/dist/build.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
index_exports
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-J3YQ457H.js";
|
|
4
|
+
import "./chunk-Q5J2LVKH.js";
|
|
5
|
+
import "./chunk-FC6KCJSA.js";
|
|
6
|
+
import "./chunk-CZPRSWSS.js";
|
|
7
|
+
import "./chunk-C7AA2CZX.js";
|
|
8
|
+
import "./chunk-62BDYGAG.js";
|
|
9
|
+
import "./chunk-VWT3VXPL.js";
|
|
10
|
+
import "./chunk-O6TRVMJI.js";
|
|
11
|
+
import "./chunk-3ACAAQIN.js";
|
|
12
|
+
import "./chunk-KJ3UKABJ.js";
|
|
13
|
+
import "./chunk-7ZHH77QA.js";
|
|
14
|
+
import "./chunk-V3LHZSU5.js";
|
|
11
15
|
import {
|
|
12
16
|
isEventHandlerAttr,
|
|
13
17
|
isHtmlContentAttribute,
|
|
14
18
|
isUrlAttribute
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-7ZHH77QA.js";
|
|
17
|
-
import "./chunk-WEQ3DMVL.js";
|
|
19
|
+
} from "./chunk-EXXSN3BW.js";
|
|
18
20
|
import "./chunk-7XHATCIH.js";
|
|
19
21
|
import "./chunk-5HZXGZ6T.js";
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-DSID757X.js";
|
|
23
|
+
import "./chunk-TQQUN4WR.js";
|
|
22
24
|
import "./chunk-NYNYSPK7.js";
|
|
23
25
|
|
|
24
26
|
// src/build/sourceEdit.ts
|
|
@@ -1174,6 +1176,11 @@ function generateBody(roots, h) {
|
|
|
1174
1176
|
const q = jsStringLiteral;
|
|
1175
1177
|
const P = h.prefix;
|
|
1176
1178
|
function genElement(el) {
|
|
1179
|
+
const tag = el.tag.toLowerCase();
|
|
1180
|
+
if (tag === "meta" || tag === "link") return null;
|
|
1181
|
+
for (const attr of el.attrs) {
|
|
1182
|
+
if ((attr.t === 0 || attr.t === 4) && attr.name.toLowerCase() === "srcdoc") return null;
|
|
1183
|
+
}
|
|
1177
1184
|
const v = `e${n++}`;
|
|
1178
1185
|
h.tags.add(el.tag);
|
|
1179
1186
|
if (el.svg) h.svg = true;
|
|
@@ -1265,6 +1272,9 @@ function helperSource(h) {
|
|
|
1265
1272
|
out.push(
|
|
1266
1273
|
`function ${P}on(el, name, handler) {
|
|
1267
1274
|
if (typeof handler === "function") el.addEventListener(name, handler);
|
|
1275
|
+
else if (typeof __SIBU_DEV__ !== "undefined" && __SIBU_DEV__) {
|
|
1276
|
+
console.warn(\`[SibuJS] html: on:\${name} handler is not a function (got \${typeof handler}). Event listener was not attached.\`);
|
|
1277
|
+
}
|
|
1268
1278
|
}`
|
|
1269
1279
|
);
|
|
1270
1280
|
}
|
|
@@ -1272,7 +1282,10 @@ function helperSource(h) {
|
|
|
1272
1282
|
out.push(
|
|
1273
1283
|
`function ${P}child(el, value) {
|
|
1274
1284
|
if (typeof value === "function") {
|
|
1275
|
-
|
|
1285
|
+
const frag = ${P}Fragment([value]);
|
|
1286
|
+
const ph = frag.firstChild;
|
|
1287
|
+
el.appendChild(frag);
|
|
1288
|
+
${P}registerDisposer(el, () => ${P}dispose(ph));
|
|
1276
1289
|
} else if (value instanceof Node) {
|
|
1277
1290
|
el.appendChild(value);
|
|
1278
1291
|
} else if (Array.isArray(value)) {
|
|
@@ -1292,13 +1305,22 @@ function helperSource(h) {
|
|
|
1292
1305
|
function importSource(h) {
|
|
1293
1306
|
const P = h.prefix;
|
|
1294
1307
|
const core = [];
|
|
1295
|
-
if (h.used.has("child")) core.push(`Fragment as ${P}Fragment`);
|
|
1296
|
-
if (h.used.has("attr")) core.push(`registerDisposer as ${P}registerDisposer`);
|
|
1308
|
+
if (h.used.has("child")) core.push(`Fragment as ${P}Fragment`, `dispose as ${P}dispose`);
|
|
1309
|
+
if (h.used.has("attr") || h.used.has("child")) core.push(`registerDisposer as ${P}registerDisposer`);
|
|
1310
|
+
if (h.used.has("run")) core.push(`__renderParsedTemplate as ${P}run`);
|
|
1297
1311
|
const lines = [];
|
|
1298
1312
|
if (core.length > 0) lines.push(`import { ${core.join(", ")} } from "sibujs";`);
|
|
1299
1313
|
if (h.used.has("attr")) lines.push(`import { bindAttrs as ${P}bindAttrs } from "sibujs/ui";`);
|
|
1300
1314
|
return lines.join("\n");
|
|
1301
1315
|
}
|
|
1316
|
+
function collectTags(children, h) {
|
|
1317
|
+
for (const child of children) {
|
|
1318
|
+
if (child.t !== 0) continue;
|
|
1319
|
+
h.tags.add(child.el.tag);
|
|
1320
|
+
if (child.el.svg) h.svg = true;
|
|
1321
|
+
collectTags(child.el.children, h);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1302
1324
|
function planHtmlTemplates(code) {
|
|
1303
1325
|
const plan = {
|
|
1304
1326
|
edits: [],
|
|
@@ -1326,24 +1348,44 @@ function planHtmlTemplates(code) {
|
|
|
1326
1348
|
const strings = [];
|
|
1327
1349
|
for (const qs of tmpl.quasis) {
|
|
1328
1350
|
const cooked = cookEscapes(code.slice(qs.start, qs.end));
|
|
1329
|
-
if (cooked === null)
|
|
1351
|
+
if (cooked === null) {
|
|
1352
|
+
if (tmpl.quasis.length === 1) return null;
|
|
1353
|
+
strings.push("undefined");
|
|
1354
|
+
continue;
|
|
1355
|
+
}
|
|
1330
1356
|
strings.push(cooked);
|
|
1331
1357
|
}
|
|
1358
|
+
const name = `${h.prefix}t${functions.length}`;
|
|
1359
|
+
const params = tmpl.exprs.map((_, i) => `v${i}`).join(", ");
|
|
1332
1360
|
let roots;
|
|
1333
1361
|
try {
|
|
1334
1362
|
roots = parseTemplate(strings);
|
|
1335
1363
|
} catch (err) {
|
|
1336
|
-
if (err instanceof RuntimeParseError)
|
|
1364
|
+
if (err instanceof RuntimeParseError) {
|
|
1365
|
+
const message = `html: dynamic \${...} expressions are not allowed inside <${err.message}> (raw-text context). Build the content separately and append it as a Node.`;
|
|
1366
|
+
functions.push(`function ${name}(${params}) {
|
|
1367
|
+
throw new Error(${jsStringLiteral(message)});
|
|
1368
|
+
}`);
|
|
1369
|
+
return name;
|
|
1370
|
+
}
|
|
1337
1371
|
throw err;
|
|
1338
1372
|
}
|
|
1339
1373
|
const scratch = { prefix: h.prefix, used: /* @__PURE__ */ new Set(), tags: /* @__PURE__ */ new Set(), svg: false };
|
|
1340
1374
|
const body = generateBody(roots, scratch);
|
|
1341
|
-
if (body === null)
|
|
1375
|
+
if (body === null) {
|
|
1376
|
+
const tree = JSON.stringify(roots).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
1377
|
+
h.used.add("run");
|
|
1378
|
+
collectTags(roots, h);
|
|
1379
|
+
functions.push(
|
|
1380
|
+
`function ${name}(${params}) {
|
|
1381
|
+
return ${h.prefix}run(${name}.tree || (${name}.tree = ${tree}), [${params}]);
|
|
1382
|
+
}`
|
|
1383
|
+
);
|
|
1384
|
+
return name;
|
|
1385
|
+
}
|
|
1342
1386
|
for (const u of scratch.used) h.used.add(u);
|
|
1343
1387
|
for (const t of scratch.tags) h.tags.add(t);
|
|
1344
1388
|
if (scratch.svg) h.svg = true;
|
|
1345
|
-
const name = `${h.prefix}t${functions.length}`;
|
|
1346
|
-
const params = tmpl.exprs.map((_, i) => `v${i}`).join(", ");
|
|
1347
1389
|
functions.push(`function ${name}(${params}) {
|
|
1348
1390
|
${body}
|
|
1349
1391
|
}`);
|
|
@@ -1621,6 +1663,11 @@ function sibuWebpackPlugin(options = {}) {
|
|
|
1621
1663
|
return {
|
|
1622
1664
|
name: "SibuWebpackPlugin",
|
|
1623
1665
|
apply(compiler) {
|
|
1666
|
+
if (options.pureAnnotations === true) {
|
|
1667
|
+
console.warn(
|
|
1668
|
+
'[SibuWebpackPlugin] `pureAnnotations` is not applied by the plugin: webpack needs a loader file. Create sibu-pure-loader.cjs containing `module.exports = require("sibujs/build").createPureAnnotationsLoader();` and add a module rule `{ test: /\\.[cm]?[jt]sx?$/, exclude: /node_modules/, use: "./sibu-pure-loader.cjs" }`.'
|
|
1669
|
+
);
|
|
1670
|
+
}
|
|
1624
1671
|
compiler.hooks?.compilation?.tap("SibuWebpackPlugin", (compilation) => {
|
|
1625
1672
|
const comp = compilation;
|
|
1626
1673
|
if (comp.hooks?.optimizeModules) {
|