regor 1.7.0 → 1.7.2
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/README.md +3 -2
- package/dist/regor.d.ts +24 -0
- package/dist/regor.es2015.cjs.js +141 -121
- package/dist/regor.es2015.cjs.prod.js +3 -3
- package/dist/regor.es2015.esm.js +141 -121
- package/dist/regor.es2015.esm.prod.js +3 -3
- package/dist/regor.es2015.iife.js +141 -121
- package/dist/regor.es2015.iife.prod.js +3 -3
- package/dist/regor.es2019.cjs.js +141 -121
- package/dist/regor.es2019.cjs.prod.js +3 -3
- package/dist/regor.es2019.esm.js +141 -121
- package/dist/regor.es2019.esm.prod.js +3 -3
- package/dist/regor.es2019.iife.js +141 -121
- package/dist/regor.es2019.iife.prod.js +3 -3
- package/dist/regor.es2022.cjs.js +140 -120
- package/dist/regor.es2022.cjs.prod.js +3 -3
- package/dist/regor.es2022.esm.js +140 -120
- package/dist/regor.es2022.esm.prod.js +3 -3
- package/dist/regor.es2022.iife.js +140 -120
- package/dist/regor.es2022.iife.prod.js +3 -3
- package/package.json +1 -1
package/dist/regor.es2019.cjs.js
CHANGED
|
@@ -32,6 +32,7 @@ __export(index_exports, {
|
|
|
32
32
|
computeRef: () => computeRef,
|
|
33
33
|
computed: () => computed,
|
|
34
34
|
createApp: () => createApp,
|
|
35
|
+
cref: () => cref,
|
|
35
36
|
defineComponent: () => defineComponent,
|
|
36
37
|
drainUnbind: () => drainUnbind,
|
|
37
38
|
endBatch: () => endBatch,
|
|
@@ -1193,6 +1194,132 @@ var isScope = (value) => {
|
|
|
1193
1194
|
return scopeSymbol2 in value;
|
|
1194
1195
|
};
|
|
1195
1196
|
|
|
1197
|
+
// src/reactivity/unref.ts
|
|
1198
|
+
var unref = (value) => {
|
|
1199
|
+
const anyValue = value;
|
|
1200
|
+
return anyValue != null && anyValue[srefSymbol] > 0 ? anyValue() : anyValue;
|
|
1201
|
+
};
|
|
1202
|
+
|
|
1203
|
+
// src/directives/attr.ts
|
|
1204
|
+
var xlinkNS = "http://www.w3.org/1999/xlink";
|
|
1205
|
+
var booleanAttributes = {
|
|
1206
|
+
itemscope: 2,
|
|
1207
|
+
allowfullscreen: 2,
|
|
1208
|
+
formnovalidate: 2,
|
|
1209
|
+
ismap: 2,
|
|
1210
|
+
nomodule: 2,
|
|
1211
|
+
novalidate: 2,
|
|
1212
|
+
readonly: 2,
|
|
1213
|
+
async: 1,
|
|
1214
|
+
autofocus: 1,
|
|
1215
|
+
autoplay: 1,
|
|
1216
|
+
controls: 1,
|
|
1217
|
+
default: 1,
|
|
1218
|
+
defer: 1,
|
|
1219
|
+
disabled: 1,
|
|
1220
|
+
hidden: 1,
|
|
1221
|
+
inert: 1,
|
|
1222
|
+
loop: 1,
|
|
1223
|
+
open: 1,
|
|
1224
|
+
required: 1,
|
|
1225
|
+
reversed: 1,
|
|
1226
|
+
scoped: 1,
|
|
1227
|
+
seamless: 1,
|
|
1228
|
+
checked: 1,
|
|
1229
|
+
muted: 1,
|
|
1230
|
+
multiple: 1,
|
|
1231
|
+
selected: 1
|
|
1232
|
+
};
|
|
1233
|
+
var updateAttr = (el, values, previousValues, option, previousOption, flags) => {
|
|
1234
|
+
var _a;
|
|
1235
|
+
if (option) {
|
|
1236
|
+
option = unref(option);
|
|
1237
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
1238
|
+
patchAttr(
|
|
1239
|
+
el,
|
|
1240
|
+
option,
|
|
1241
|
+
unref(values[0]),
|
|
1242
|
+
unref(previousOption)
|
|
1243
|
+
);
|
|
1244
|
+
return;
|
|
1245
|
+
}
|
|
1246
|
+
const len = values.length;
|
|
1247
|
+
for (let i = 0; i < len; ++i) {
|
|
1248
|
+
const next = values[i];
|
|
1249
|
+
if (isArray(next)) {
|
|
1250
|
+
const previousKey = unref((_a = previousValues == null ? void 0 : previousValues[i]) == null ? void 0 : _a[0]);
|
|
1251
|
+
const key = unref(next[0]);
|
|
1252
|
+
const value = unref(next[1]);
|
|
1253
|
+
patchAttr(el, key, value, previousKey);
|
|
1254
|
+
} else if (isObject(next)) {
|
|
1255
|
+
for (const item of Object.entries(next)) {
|
|
1256
|
+
const key = item[0];
|
|
1257
|
+
const value = unref(item[1]);
|
|
1258
|
+
const p = unref(previousValues == null ? void 0 : previousValues[i]);
|
|
1259
|
+
const previousKey = p && key in p ? key : void 0;
|
|
1260
|
+
patchAttr(el, key, value, previousKey);
|
|
1261
|
+
}
|
|
1262
|
+
} else {
|
|
1263
|
+
const previousKey = unref(previousValues == null ? void 0 : previousValues[i]);
|
|
1264
|
+
const key = unref(values[i++]);
|
|
1265
|
+
const value = unref(values[i]);
|
|
1266
|
+
patchAttr(el, key, value, previousKey);
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
};
|
|
1270
|
+
var attrDirective = {
|
|
1271
|
+
mount: () => ({
|
|
1272
|
+
update: ({ el, values, previousValues, option, previousOption, flags }) => {
|
|
1273
|
+
updateAttr(
|
|
1274
|
+
el,
|
|
1275
|
+
values,
|
|
1276
|
+
previousValues,
|
|
1277
|
+
option,
|
|
1278
|
+
previousOption,
|
|
1279
|
+
flags
|
|
1280
|
+
);
|
|
1281
|
+
}
|
|
1282
|
+
})
|
|
1283
|
+
};
|
|
1284
|
+
var patchAttr = (el, key, value, previousKey) => {
|
|
1285
|
+
if (previousKey && previousKey !== key) {
|
|
1286
|
+
el.removeAttribute(previousKey);
|
|
1287
|
+
}
|
|
1288
|
+
if (isNullOrUndefined(key)) {
|
|
1289
|
+
warning(3 /* KeyIsEmpty */, "r-bind", el);
|
|
1290
|
+
return;
|
|
1291
|
+
}
|
|
1292
|
+
if (!isString(key)) {
|
|
1293
|
+
warning(
|
|
1294
|
+
6 /* ErrorLog */,
|
|
1295
|
+
`Attribute key is not string at ${el.outerHTML}`,
|
|
1296
|
+
key
|
|
1297
|
+
);
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
if (key.startsWith("xlink:")) {
|
|
1301
|
+
if (isNullOrUndefined(value)) {
|
|
1302
|
+
el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
|
1303
|
+
} else {
|
|
1304
|
+
el.setAttributeNS(xlinkNS, key, value);
|
|
1305
|
+
}
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
if (isNullOrUndefined(value)) {
|
|
1309
|
+
el.removeAttribute(key);
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
if (key in booleanAttributes) {
|
|
1313
|
+
if (toBoolean(value)) {
|
|
1314
|
+
el.setAttribute(key, "");
|
|
1315
|
+
} else {
|
|
1316
|
+
el.removeAttribute(key);
|
|
1317
|
+
}
|
|
1318
|
+
return;
|
|
1319
|
+
}
|
|
1320
|
+
el.setAttribute(key, value);
|
|
1321
|
+
};
|
|
1322
|
+
|
|
1196
1323
|
// src/directives/context.ts
|
|
1197
1324
|
var contextDirective = {
|
|
1198
1325
|
collectRefObj: true,
|
|
@@ -1931,10 +2058,11 @@ var ComponentBinder = class {
|
|
|
1931
2058
|
} else if (attrName === ":style" || attrName === bindStyleName) {
|
|
1932
2059
|
mergeBinding(":style", bindStyleName, value);
|
|
1933
2060
|
} else {
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
2061
|
+
const normalizedName = normalizeAttributeName(
|
|
2062
|
+
attrName,
|
|
2063
|
+
binder.__config
|
|
1937
2064
|
);
|
|
2065
|
+
patchAttr(inheritor, normalizedName, value);
|
|
1938
2066
|
}
|
|
1939
2067
|
};
|
|
1940
2068
|
for (const { name, value } of inheritedPropAttrs) {
|
|
@@ -2276,12 +2404,6 @@ var DynamicBinder = class {
|
|
|
2276
2404
|
}
|
|
2277
2405
|
};
|
|
2278
2406
|
|
|
2279
|
-
// src/reactivity/unref.ts
|
|
2280
|
-
var unref = (value) => {
|
|
2281
|
-
const anyValue = value;
|
|
2282
|
-
return anyValue != null && anyValue[srefSymbol] > 0 ? anyValue() : anyValue;
|
|
2283
|
-
};
|
|
2284
|
-
|
|
2285
2407
|
// src/directives/html.ts
|
|
2286
2408
|
var updateHtml = (el, values) => {
|
|
2287
2409
|
const [value, replacer] = values;
|
|
@@ -3231,116 +3353,6 @@ var Binder = class {
|
|
|
3231
3353
|
}
|
|
3232
3354
|
};
|
|
3233
3355
|
|
|
3234
|
-
// src/directives/attr.ts
|
|
3235
|
-
var xlinkNS = "http://www.w3.org/1999/xlink";
|
|
3236
|
-
var booleanAttributes = {
|
|
3237
|
-
itemscope: 2,
|
|
3238
|
-
allowfullscreen: 2,
|
|
3239
|
-
formnovalidate: 2,
|
|
3240
|
-
ismap: 2,
|
|
3241
|
-
nomodule: 2,
|
|
3242
|
-
novalidate: 2,
|
|
3243
|
-
readonly: 2,
|
|
3244
|
-
async: 1,
|
|
3245
|
-
autofocus: 1,
|
|
3246
|
-
autoplay: 1,
|
|
3247
|
-
controls: 1,
|
|
3248
|
-
default: 1,
|
|
3249
|
-
defer: 1,
|
|
3250
|
-
disabled: 1,
|
|
3251
|
-
hidden: 1,
|
|
3252
|
-
inert: 1,
|
|
3253
|
-
loop: 1,
|
|
3254
|
-
open: 1,
|
|
3255
|
-
required: 1,
|
|
3256
|
-
reversed: 1,
|
|
3257
|
-
scoped: 1,
|
|
3258
|
-
seamless: 1,
|
|
3259
|
-
checked: 1,
|
|
3260
|
-
muted: 1,
|
|
3261
|
-
multiple: 1,
|
|
3262
|
-
selected: 1
|
|
3263
|
-
};
|
|
3264
|
-
function includeBooleanAttr(value) {
|
|
3265
|
-
return !!value || value === "";
|
|
3266
|
-
}
|
|
3267
|
-
var updateAttr = (el, values, previousValues, option, previousOption, flags) => {
|
|
3268
|
-
var _a;
|
|
3269
|
-
if (option) {
|
|
3270
|
-
if (flags && flags.includes("camel")) option = camelize(option);
|
|
3271
|
-
patchAttribute(el, option, values[0], previousOption);
|
|
3272
|
-
return;
|
|
3273
|
-
}
|
|
3274
|
-
const len = values.length;
|
|
3275
|
-
for (let i = 0; i < len; ++i) {
|
|
3276
|
-
const next = values[i];
|
|
3277
|
-
if (isArray(next)) {
|
|
3278
|
-
const previousKey = (_a = previousValues == null ? void 0 : previousValues[i]) == null ? void 0 : _a[0];
|
|
3279
|
-
const key = next[0];
|
|
3280
|
-
const value = next[1];
|
|
3281
|
-
patchAttribute(el, key, value, previousKey);
|
|
3282
|
-
} else if (isObject(next)) {
|
|
3283
|
-
for (const item of Object.entries(next)) {
|
|
3284
|
-
const key = item[0];
|
|
3285
|
-
const value = item[1];
|
|
3286
|
-
const p = previousValues == null ? void 0 : previousValues[i];
|
|
3287
|
-
const previousKey = p && key in p ? key : void 0;
|
|
3288
|
-
patchAttribute(el, key, value, previousKey);
|
|
3289
|
-
}
|
|
3290
|
-
} else {
|
|
3291
|
-
const previousKey = previousValues == null ? void 0 : previousValues[i];
|
|
3292
|
-
const key = values[i++];
|
|
3293
|
-
const value = values[i];
|
|
3294
|
-
patchAttribute(el, key, value, previousKey);
|
|
3295
|
-
}
|
|
3296
|
-
}
|
|
3297
|
-
};
|
|
3298
|
-
var attrDirective = {
|
|
3299
|
-
mount: () => ({
|
|
3300
|
-
update: ({ el, values, previousValues, option, previousOption, flags }) => {
|
|
3301
|
-
updateAttr(
|
|
3302
|
-
el,
|
|
3303
|
-
values,
|
|
3304
|
-
previousValues,
|
|
3305
|
-
option,
|
|
3306
|
-
previousOption,
|
|
3307
|
-
flags
|
|
3308
|
-
);
|
|
3309
|
-
}
|
|
3310
|
-
})
|
|
3311
|
-
};
|
|
3312
|
-
var patchAttribute = (el, key, value, previousKey) => {
|
|
3313
|
-
if (previousKey && previousKey !== key) {
|
|
3314
|
-
el.removeAttribute(previousKey);
|
|
3315
|
-
}
|
|
3316
|
-
if (isNullOrUndefined(key)) {
|
|
3317
|
-
warning(3 /* KeyIsEmpty */, "r-bind", el);
|
|
3318
|
-
return;
|
|
3319
|
-
}
|
|
3320
|
-
if (!isString(key)) {
|
|
3321
|
-
warning(
|
|
3322
|
-
6 /* ErrorLog */,
|
|
3323
|
-
`Attribute key is not string at ${el.outerHTML}`,
|
|
3324
|
-
key
|
|
3325
|
-
);
|
|
3326
|
-
return;
|
|
3327
|
-
}
|
|
3328
|
-
if (key.startsWith("xlink:")) {
|
|
3329
|
-
if (isNullOrUndefined(value)) {
|
|
3330
|
-
el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
|
3331
|
-
} else {
|
|
3332
|
-
el.setAttributeNS(xlinkNS, key, value);
|
|
3333
|
-
}
|
|
3334
|
-
return;
|
|
3335
|
-
}
|
|
3336
|
-
const isBoolean2 = key in booleanAttributes;
|
|
3337
|
-
if (isNullOrUndefined(value) || isBoolean2 && !includeBooleanAttr(value)) {
|
|
3338
|
-
el.removeAttribute(key);
|
|
3339
|
-
} else {
|
|
3340
|
-
el.setAttribute(key, isBoolean2 ? "" : value);
|
|
3341
|
-
}
|
|
3342
|
-
};
|
|
3343
|
-
|
|
3344
3356
|
// src/directives/class.ts
|
|
3345
3357
|
var updateClass = (el, values, previousValues) => {
|
|
3346
3358
|
const len = values.length;
|
|
@@ -3987,7 +3999,7 @@ var propDirective = {
|
|
|
3987
3999
|
}
|
|
3988
4000
|
})
|
|
3989
4001
|
};
|
|
3990
|
-
function
|
|
4002
|
+
function includeBooleanAttr(value) {
|
|
3991
4003
|
return !!value || value === "";
|
|
3992
4004
|
}
|
|
3993
4005
|
var patchProp = (el, key, value) => {
|
|
@@ -4019,7 +4031,7 @@ var patchProp = (el, key, value) => {
|
|
|
4019
4031
|
if (value === "" || value == null) {
|
|
4020
4032
|
const type = typeof el[key];
|
|
4021
4033
|
if (type === "boolean") {
|
|
4022
|
-
value =
|
|
4034
|
+
value = includeBooleanAttr(value);
|
|
4023
4035
|
} else if (value == null && type === "string") {
|
|
4024
4036
|
value = "";
|
|
4025
4037
|
needRemove = true;
|
|
@@ -4185,6 +4197,8 @@ var flatten = (reference) => {
|
|
|
4185
4197
|
var flattenContent = (value, weakMap = /* @__PURE__ */ new WeakMap()) => {
|
|
4186
4198
|
if (!value) return value;
|
|
4187
4199
|
if (!isObject(value)) return value;
|
|
4200
|
+
if (value instanceof Node || value instanceof Date || value instanceof RegExp || value instanceof Promise || value instanceof Error)
|
|
4201
|
+
return value;
|
|
4188
4202
|
if (isArray(value)) {
|
|
4189
4203
|
return value.map(flatten);
|
|
4190
4204
|
}
|
|
@@ -4273,6 +4287,11 @@ function ref(value) {
|
|
|
4273
4287
|
return result;
|
|
4274
4288
|
}
|
|
4275
4289
|
|
|
4290
|
+
// src/reactivity/cref.ts
|
|
4291
|
+
function cref(value) {
|
|
4292
|
+
return ref(flatten(value));
|
|
4293
|
+
}
|
|
4294
|
+
|
|
4276
4295
|
// src/app/RegorConfig.ts
|
|
4277
4296
|
var _RegorConfig = class _RegorConfig {
|
|
4278
4297
|
constructor(globalContext) {
|
|
@@ -4333,6 +4352,7 @@ var _RegorConfig = class _RegorConfig {
|
|
|
4333
4352
|
obj[key] = global[key];
|
|
4334
4353
|
}
|
|
4335
4354
|
obj.ref = ref;
|
|
4355
|
+
obj.cref = cref;
|
|
4336
4356
|
obj.sref = sref;
|
|
4337
4357
|
obj.flatten = flatten;
|
|
4338
4358
|
return obj;
|