rip-lang 3.13.135 → 3.13.136
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 +1 -1
- package/docs/dist/rip.js +379 -548
- package/docs/dist/rip.min.js +173 -181
- package/docs/dist/rip.min.js.br +0 -0
- package/package.json +1 -1
- package/src/compiler.js +2 -245
- package/src/typecheck.js +53 -0
package/docs/dist/rip.js
CHANGED
|
@@ -7658,15 +7658,6 @@ if (typeof globalThis !== 'undefined') {
|
|
|
7658
7658
|
else
|
|
7659
7659
|
body.push(stmt);
|
|
7660
7660
|
}
|
|
7661
|
-
let prevInlinePending = this._inlineVarsPending;
|
|
7662
|
-
let programInlineVars = new Set;
|
|
7663
|
-
if (this.programVars.size > 0 && body.length > 0) {
|
|
7664
|
-
let classified = this.classifyVarsForInlining(body, this.programVars);
|
|
7665
|
-
programInlineVars = classified.inlineVars;
|
|
7666
|
-
programInlineVars.delete("_");
|
|
7667
|
-
if (programInlineVars.size > 0)
|
|
7668
|
-
this._inlineVarsPending = new Set(programInlineVars);
|
|
7669
|
-
}
|
|
7670
7661
|
let blockStmts = ["def", "class", "if", "for-in", "for-of", "for-as", "while", "loop", "switch", "try"];
|
|
7671
7662
|
let stmtEntries = body.map((stmt, index) => {
|
|
7672
7663
|
let isSingle = body.length === 1 && imports.length === 0;
|
|
@@ -7694,7 +7685,6 @@ if (typeof globalThis !== 'undefined') {
|
|
|
7694
7685
|
});
|
|
7695
7686
|
let statementsCode = stmtEntries.map((e) => e.code).join(`
|
|
7696
7687
|
`);
|
|
7697
|
-
this._inlineVarsPending = prevInlinePending;
|
|
7698
7688
|
let needsBlank = false;
|
|
7699
7689
|
if (imports.length > 0) {
|
|
7700
7690
|
code += imports.map((s) => this.addSemicolon(s, this.emit(s, "statement"))).join(`
|
|
@@ -7706,7 +7696,7 @@ if (typeof globalThis !== 'undefined') {
|
|
|
7706
7696
|
if (hasUnderscore)
|
|
7707
7697
|
this.programVars.delete("_");
|
|
7708
7698
|
if (this.programVars.size > 0) {
|
|
7709
|
-
let vars = Array.from(this.programVars).
|
|
7699
|
+
let vars = Array.from(this.programVars).sort().join(", ");
|
|
7710
7700
|
if (vars) {
|
|
7711
7701
|
if (needsBlank)
|
|
7712
7702
|
code += `
|
|
@@ -7911,18 +7901,6 @@ function _setDataSection() {
|
|
|
7911
7901
|
return `(() => { const __v = ${exprCode}; if (!__v) ${ctrlCode}; return (${targetCode2} = __v); })()`;
|
|
7912
7902
|
return `(() => { const __v = ${exprCode}; if (__v) ${ctrlCode}; return (${targetCode2} = __v); })()`;
|
|
7913
7903
|
}
|
|
7914
|
-
let tgtName = typeof target === "string" ? target : target instanceof String ? str(target) : null;
|
|
7915
|
-
if (tgtName && context === "statement" && this._inlineVarsPending?.delete(tgtName)) {
|
|
7916
|
-
let ind = this.indent();
|
|
7917
|
-
if (ctrlOp === "??")
|
|
7918
|
-
return `let ${targetCode2} = ${exprCode};
|
|
7919
|
-
${ind}if (${targetCode2} == null) ${ctrlCode}`;
|
|
7920
|
-
if (ctrlOp === "||")
|
|
7921
|
-
return `let ${targetCode2} = ${exprCode};
|
|
7922
|
-
${ind}if (!${targetCode2}) ${ctrlCode}`;
|
|
7923
|
-
return `let ${targetCode2} = ${exprCode};
|
|
7924
|
-
${ind}if (${targetCode2}) ${ctrlCode}`;
|
|
7925
|
-
}
|
|
7926
7904
|
if (ctrlOp === "??")
|
|
7927
7905
|
return `if ((${targetCode2} = ${exprCode}) == null) ${ctrlCode}`;
|
|
7928
7906
|
if (ctrlOp === "||")
|
|
@@ -7968,10 +7946,6 @@ ${ind}if (${targetCode2}) ${ctrlCode}`;
|
|
|
7968
7946
|
let unwrapped = Array.isArray(wrappedValue) && wrappedValue.length === 1 ? wrappedValue[0] : wrappedValue;
|
|
7969
7947
|
let fullValue = [binOp, left, unwrapped];
|
|
7970
7948
|
let t = this.emit(target, "value"), c = this.emit(condition, "value"), v = this.emit(fullValue, "value");
|
|
7971
|
-
let tgtName = typeof target === "string" ? target : target instanceof String ? str(target) : null;
|
|
7972
|
-
if (tgtName && this._inlineVarsPending?.delete(tgtName))
|
|
7973
|
-
return `let ${t};
|
|
7974
|
-
${this.indent()}if (${c}) ${t} = ${v}`;
|
|
7975
7949
|
return `if (${c}) ${t} = ${v}`;
|
|
7976
7950
|
}
|
|
7977
7951
|
}
|
|
@@ -7983,10 +7957,6 @@ ${this.indent()}if (${c}) ${t} = ${v}`;
|
|
|
7983
7957
|
let t = this.emit(target, "value");
|
|
7984
7958
|
let condCode = this.unwrapLogical(this.emit(condition, "value"));
|
|
7985
7959
|
let v = this.emit(unwrapped, "value");
|
|
7986
|
-
let tgtName = typeof target === "string" ? target : target instanceof String ? str(target) : null;
|
|
7987
|
-
if (tgtName && this._inlineVarsPending?.delete(tgtName))
|
|
7988
|
-
return `let ${t};
|
|
7989
|
-
${this.indent()}if (${condCode}) ${t} = ${v}`;
|
|
7990
7960
|
return `if (${condCode}) ${t} = ${v}`;
|
|
7991
7961
|
}
|
|
7992
7962
|
}
|
|
@@ -8010,10 +7980,6 @@ ${this.indent()}if (${condCode}) ${t} = ${v}`;
|
|
|
8010
7980
|
let isObjLit = this.is(value, "object");
|
|
8011
7981
|
if (!isObjLit)
|
|
8012
7982
|
valueCode = this.unwrap(valueCode);
|
|
8013
|
-
let targetName = typeof target === "string" ? target : target instanceof String ? str(target) : null;
|
|
8014
|
-
if (head === "=" && targetName && context === "statement" && this._inlineVarsPending?.delete(targetName)) {
|
|
8015
|
-
return `let ${targetCode} = ${valueCode}`;
|
|
8016
|
-
}
|
|
8017
7983
|
let needsParensVal = context === "value";
|
|
8018
7984
|
let needsParensObj = context === "statement" && this.is(target, "object");
|
|
8019
7985
|
if (needsParensVal || needsParensObj)
|
|
@@ -9428,20 +9394,11 @@ export default ${expr[1]}`;
|
|
|
9428
9394
|
statements = [...extr, ...statements];
|
|
9429
9395
|
this.restMiddleParam = null;
|
|
9430
9396
|
}
|
|
9431
|
-
let prevInlinePending = this._inlineVarsPending;
|
|
9432
|
-
let inlineVars = new Set;
|
|
9433
|
-
if (newVars.size > 0 && statements.length > 0) {
|
|
9434
|
-
let classified = this.classifyVarsForInlining(statements, newVars);
|
|
9435
|
-
inlineVars = classified.inlineVars;
|
|
9436
|
-
if (inlineVars.size > 0)
|
|
9437
|
-
this._inlineVarsPending = new Set(inlineVars);
|
|
9438
|
-
}
|
|
9439
9397
|
this.indentLevel++;
|
|
9440
9398
|
let code = `{
|
|
9441
9399
|
`;
|
|
9442
|
-
|
|
9443
|
-
|
|
9444
|
-
code += this.indent() + `let ${Array.from(hoistVars).sort().join(", ")};
|
|
9400
|
+
if (newVars.size > 0)
|
|
9401
|
+
code += this.indent() + `let ${Array.from(newVars).sort().join(", ")};
|
|
9445
9402
|
`;
|
|
9446
9403
|
let firstIsSuper = autoAssignments.length > 0 && statements.length > 0 && Array.isArray(statements[0]) && statements[0][0] === "super";
|
|
9447
9404
|
let genStatements = (stmts) => {
|
|
@@ -9469,9 +9426,6 @@ export default ${expr[1]}`;
|
|
|
9469
9426
|
if (typeof target === "string" && Array.isArray(value)) {
|
|
9470
9427
|
let vh = value[0];
|
|
9471
9428
|
if (vh === "comprehension" || vh === "for-in") {
|
|
9472
|
-
if (this._inlineVarsPending?.delete(target))
|
|
9473
|
-
code += this.indent() + `let ${target};
|
|
9474
|
-
`;
|
|
9475
9429
|
this.comprehensionTarget = target;
|
|
9476
9430
|
code += this.emit(value, "value");
|
|
9477
9431
|
this.comprehensionTarget = null;
|
|
@@ -9480,15 +9434,6 @@ export default ${expr[1]}`;
|
|
|
9480
9434
|
return;
|
|
9481
9435
|
}
|
|
9482
9436
|
}
|
|
9483
|
-
if ((typeof target === "string" || target instanceof String) && this._inlineVarsPending?.has(str(target))) {
|
|
9484
|
-
this._inlineVarsPending.delete(str(target));
|
|
9485
|
-
let assignCode = this.emit(stmt, "statement");
|
|
9486
|
-
code += this.indent() + "let " + this.addSemicolon(stmt, assignCode) + `
|
|
9487
|
-
`;
|
|
9488
|
-
code += this.indent() + `return ${str(target)};
|
|
9489
|
-
`;
|
|
9490
|
-
return;
|
|
9491
|
-
}
|
|
9492
9437
|
}
|
|
9493
9438
|
let needsReturn = !isConstructor && !sideEffectOnly && isLast && !noRetStmts.includes(h) && !loopStmts.includes(h) && !this.hasExplicitControlFlow(stmt);
|
|
9494
9439
|
let ctx = needsReturn ? "value" : "statement";
|
|
@@ -9525,7 +9470,6 @@ export default ${expr[1]}`;
|
|
|
9525
9470
|
code += this.indent() + `return;
|
|
9526
9471
|
`;
|
|
9527
9472
|
}
|
|
9528
|
-
this._inlineVarsPending = prevInlinePending;
|
|
9529
9473
|
this.indentLevel--;
|
|
9530
9474
|
code += this.indent() + "}";
|
|
9531
9475
|
this.scopeStack.pop();
|
|
@@ -10281,220 +10225,6 @@ ${this.indent()}}`;
|
|
|
10281
10225
|
return sexpr.some((item) => this.containsYield(item));
|
|
10282
10226
|
return false;
|
|
10283
10227
|
}
|
|
10284
|
-
referencesVar(sexpr, varName) {
|
|
10285
|
-
if (!sexpr)
|
|
10286
|
-
return false;
|
|
10287
|
-
if (sexpr instanceof String)
|
|
10288
|
-
return str(sexpr) === varName;
|
|
10289
|
-
if (typeof sexpr === "string")
|
|
10290
|
-
return sexpr === varName;
|
|
10291
|
-
if (!Array.isArray(sexpr))
|
|
10292
|
-
return false;
|
|
10293
|
-
let h = sexpr[0];
|
|
10294
|
-
let hs = typeof h === "string" ? h : h instanceof String ? str(h) : null;
|
|
10295
|
-
if (hs === "def" || hs === "->" || hs === "=>" || hs === "effect")
|
|
10296
|
-
return false;
|
|
10297
|
-
if (hs === "." || hs === "?.")
|
|
10298
|
-
return this.referencesVar(sexpr[1], varName);
|
|
10299
|
-
if (hs === "object") {
|
|
10300
|
-
for (let i = 1;i < sexpr.length; i++) {
|
|
10301
|
-
let pair = sexpr[i];
|
|
10302
|
-
if (Array.isArray(pair)) {
|
|
10303
|
-
if (this.is(pair, "...")) {
|
|
10304
|
-
if (this.referencesVar(pair[1], varName))
|
|
10305
|
-
return true;
|
|
10306
|
-
} else if (pair.length >= 2) {
|
|
10307
|
-
if (this.referencesVar(pair[pair.length - 1], varName))
|
|
10308
|
-
return true;
|
|
10309
|
-
}
|
|
10310
|
-
} else {
|
|
10311
|
-
if (this.referencesVar(pair, varName))
|
|
10312
|
-
return true;
|
|
10313
|
-
}
|
|
10314
|
-
}
|
|
10315
|
-
return false;
|
|
10316
|
-
}
|
|
10317
|
-
return sexpr.some((item) => this.referencesVar(item, varName));
|
|
10318
|
-
}
|
|
10319
|
-
firstRefIsAssignment(sexpr, varName) {
|
|
10320
|
-
let result = null;
|
|
10321
|
-
let isVar = (n) => (n instanceof String ? str(n) : n) === varName;
|
|
10322
|
-
let walk = (node, inValue) => {
|
|
10323
|
-
if (result !== null)
|
|
10324
|
-
return;
|
|
10325
|
-
if (!node)
|
|
10326
|
-
return;
|
|
10327
|
-
if (!Array.isArray(node)) {
|
|
10328
|
-
if (isVar(node))
|
|
10329
|
-
result = "read";
|
|
10330
|
-
return;
|
|
10331
|
-
}
|
|
10332
|
-
let h = node[0];
|
|
10333
|
-
let hs = typeof h === "string" ? h : h instanceof String ? str(h) : null;
|
|
10334
|
-
if (hs === "def" || hs === "->" || hs === "=>" || hs === "effect")
|
|
10335
|
-
return;
|
|
10336
|
-
if (hs === "=" && (typeof node[1] === "string" || node[1] instanceof String) && str(node[1]) === varName) {
|
|
10337
|
-
if (inValue) {
|
|
10338
|
-
result = "read";
|
|
10339
|
-
return;
|
|
10340
|
-
}
|
|
10341
|
-
result = this.referencesVar(node[2], varName) ? "read" : "write";
|
|
10342
|
-
return;
|
|
10343
|
-
}
|
|
10344
|
-
if (CodeEmitter.ASSIGNMENT_OPS.has(hs) && hs !== "=" && (typeof node[1] === "string" || node[1] instanceof String) && str(node[1]) === varName) {
|
|
10345
|
-
result = "read";
|
|
10346
|
-
return;
|
|
10347
|
-
}
|
|
10348
|
-
if (hs === "." || hs === "?.") {
|
|
10349
|
-
walk(node[1], inValue);
|
|
10350
|
-
return;
|
|
10351
|
-
}
|
|
10352
|
-
if (hs === "object") {
|
|
10353
|
-
for (let i = 1;i < node.length; i++) {
|
|
10354
|
-
let pair = node[i];
|
|
10355
|
-
if (Array.isArray(pair)) {
|
|
10356
|
-
if (this.is(pair, "..."))
|
|
10357
|
-
walk(pair[1], true);
|
|
10358
|
-
else if (pair.length >= 2)
|
|
10359
|
-
walk(pair[pair.length - 1], true);
|
|
10360
|
-
} else
|
|
10361
|
-
walk(pair, true);
|
|
10362
|
-
}
|
|
10363
|
-
return;
|
|
10364
|
-
}
|
|
10365
|
-
if (hs === "block") {
|
|
10366
|
-
for (let i = 1;i < node.length; i++)
|
|
10367
|
-
walk(node[i], false);
|
|
10368
|
-
return;
|
|
10369
|
-
}
|
|
10370
|
-
if (hs === "if") {
|
|
10371
|
-
walk(node[1], true);
|
|
10372
|
-
for (let i = 2;i < node.length; i++)
|
|
10373
|
-
walk(node[i], inValue);
|
|
10374
|
-
return;
|
|
10375
|
-
}
|
|
10376
|
-
if (hs === "for-in" || hs === "for-of" || hs === "for-as") {
|
|
10377
|
-
walk(node[2], true);
|
|
10378
|
-
if (node.length > 3)
|
|
10379
|
-
walk(node[node.length - 1], false);
|
|
10380
|
-
return;
|
|
10381
|
-
}
|
|
10382
|
-
if (hs === "while") {
|
|
10383
|
-
walk(node[1], true);
|
|
10384
|
-
walk(node[2], false);
|
|
10385
|
-
return;
|
|
10386
|
-
}
|
|
10387
|
-
if (hs === "try") {
|
|
10388
|
-
for (let i = 1;i < node.length; i++)
|
|
10389
|
-
walk(node[i], false);
|
|
10390
|
-
return;
|
|
10391
|
-
}
|
|
10392
|
-
if (CodeEmitter.ASSIGNMENT_OPS.has(hs)) {
|
|
10393
|
-
walk(node[2], true);
|
|
10394
|
-
return;
|
|
10395
|
-
}
|
|
10396
|
-
for (let i = 0;i < node.length; i++)
|
|
10397
|
-
walk(node[i], true);
|
|
10398
|
-
};
|
|
10399
|
-
walk(sexpr, false);
|
|
10400
|
-
return result === "write";
|
|
10401
|
-
}
|
|
10402
|
-
allRefsInSingleBlock(sexpr, varName) {
|
|
10403
|
-
if (!Array.isArray(sexpr))
|
|
10404
|
-
return false;
|
|
10405
|
-
let h = sexpr[0];
|
|
10406
|
-
let hs = typeof h === "string" ? h : h instanceof String ? str(h) : null;
|
|
10407
|
-
if (hs === "if") {
|
|
10408
|
-
if (this.referencesVar(sexpr[1], varName))
|
|
10409
|
-
return false;
|
|
10410
|
-
let branchCount = 0;
|
|
10411
|
-
let refBranch = null;
|
|
10412
|
-
for (let i = 2;i < sexpr.length; i++) {
|
|
10413
|
-
if (this.referencesVar(sexpr[i], varName)) {
|
|
10414
|
-
branchCount++;
|
|
10415
|
-
refBranch = sexpr[i];
|
|
10416
|
-
}
|
|
10417
|
-
}
|
|
10418
|
-
if (branchCount !== 1)
|
|
10419
|
-
return false;
|
|
10420
|
-
return this.allRefsInSingleBlock(refBranch, varName);
|
|
10421
|
-
}
|
|
10422
|
-
if (hs === "block") {
|
|
10423
|
-
let childCount = 0;
|
|
10424
|
-
let refChild = null;
|
|
10425
|
-
for (let i = 1;i < sexpr.length; i++) {
|
|
10426
|
-
if (this.referencesVar(sexpr[i], varName)) {
|
|
10427
|
-
childCount++;
|
|
10428
|
-
refChild = sexpr[i];
|
|
10429
|
-
}
|
|
10430
|
-
}
|
|
10431
|
-
if (childCount !== 1)
|
|
10432
|
-
return false;
|
|
10433
|
-
if (Array.isArray(refChild) && refChild[0] === "=" && (typeof refChild[1] === "string" || refChild[1] instanceof String) && str(refChild[1]) === varName)
|
|
10434
|
-
return true;
|
|
10435
|
-
return this.allRefsInSingleBlock(refChild, varName);
|
|
10436
|
-
}
|
|
10437
|
-
if (hs === "for-in" || hs === "for-of" || hs === "for-as") {
|
|
10438
|
-
if (this.referencesVar(sexpr[2], varName))
|
|
10439
|
-
return false;
|
|
10440
|
-
return true;
|
|
10441
|
-
}
|
|
10442
|
-
if (hs === "while") {
|
|
10443
|
-
if (this.referencesVar(sexpr[1], varName))
|
|
10444
|
-
return false;
|
|
10445
|
-
return true;
|
|
10446
|
-
}
|
|
10447
|
-
if (hs === "try")
|
|
10448
|
-
return true;
|
|
10449
|
-
return false;
|
|
10450
|
-
}
|
|
10451
|
-
classifyVarsForInlining(statements, vars) {
|
|
10452
|
-
if (vars.size === 0)
|
|
10453
|
-
return { inlineVars: new Set, hoistVars: new Set(vars) };
|
|
10454
|
-
let typedVars = new Set;
|
|
10455
|
-
let findTypedAssigns = (node) => {
|
|
10456
|
-
if (!Array.isArray(node))
|
|
10457
|
-
return;
|
|
10458
|
-
if (node[0] === "=" && node[1] instanceof String && node[1].type && vars.has(str(node[1]))) {
|
|
10459
|
-
typedVars.add(str(node[1]));
|
|
10460
|
-
}
|
|
10461
|
-
for (let i = 1;i < node.length; i++)
|
|
10462
|
-
findTypedAssigns(node[i]);
|
|
10463
|
-
};
|
|
10464
|
-
for (let stmt of statements)
|
|
10465
|
-
findTypedAssigns(stmt);
|
|
10466
|
-
let varStmts = new Map;
|
|
10467
|
-
for (let v of vars)
|
|
10468
|
-
varStmts.set(v, []);
|
|
10469
|
-
for (let i = 0;i < statements.length; i++) {
|
|
10470
|
-
for (let v of vars) {
|
|
10471
|
-
if (this.referencesVar(statements[i], v))
|
|
10472
|
-
varStmts.get(v).push(i);
|
|
10473
|
-
}
|
|
10474
|
-
}
|
|
10475
|
-
let inlineVars = new Set, hoistVars = new Set;
|
|
10476
|
-
for (let [v, indices] of varStmts) {
|
|
10477
|
-
if (indices.length === 0) {
|
|
10478
|
-
hoistVars.add(v);
|
|
10479
|
-
continue;
|
|
10480
|
-
}
|
|
10481
|
-
if (typedVars.has(v)) {
|
|
10482
|
-
hoistVars.add(v);
|
|
10483
|
-
continue;
|
|
10484
|
-
}
|
|
10485
|
-
let firstIdx = indices[0];
|
|
10486
|
-
let firstStmt = statements[firstIdx];
|
|
10487
|
-
let isDirectAssign = Array.isArray(firstStmt) && firstStmt[0] === "=" && (typeof firstStmt[1] === "string" || firstStmt[1] instanceof String) && str(firstStmt[1]) === v && !this.referencesVar(firstStmt[2], v);
|
|
10488
|
-
if (isDirectAssign) {
|
|
10489
|
-
inlineVars.add(v);
|
|
10490
|
-
} else if (indices.length === 1 && !this.is(firstStmt, "switch") && this.allRefsInSingleBlock(firstStmt, v) && this.firstRefIsAssignment(firstStmt, v)) {
|
|
10491
|
-
inlineVars.add(v);
|
|
10492
|
-
} else {
|
|
10493
|
-
hoistVars.add(v);
|
|
10494
|
-
}
|
|
10495
|
-
}
|
|
10496
|
-
return { inlineVars, hoistVars };
|
|
10497
|
-
}
|
|
10498
10228
|
extractMemberName(mk) {
|
|
10499
10229
|
if (this.is(mk, ".") && mk[1] === "this")
|
|
10500
10230
|
return mk[2];
|
|
@@ -10947,8 +10677,8 @@ globalThis.zip ??= (...a) => a[0].map((_, i) => a.map(b => b[i]));
|
|
|
10947
10677
|
return new CodeEmitter({}).getComponentRuntime();
|
|
10948
10678
|
}
|
|
10949
10679
|
// src/browser.js
|
|
10950
|
-
var VERSION = "3.13.
|
|
10951
|
-
var BUILD_DATE = "2026-04-10@10:
|
|
10680
|
+
var VERSION = "3.13.136";
|
|
10681
|
+
var BUILD_DATE = "2026-04-10@10:36:35GMT";
|
|
10952
10682
|
if (typeof globalThis !== "undefined") {
|
|
10953
10683
|
if (!globalThis.__rip)
|
|
10954
10684
|
new Function(getReactiveRuntime())();
|
|
@@ -11240,12 +10970,56 @@ ${indented}`);
|
|
|
11240
10970
|
createRenderer: () => createRenderer,
|
|
11241
10971
|
createComponents: () => createComponents
|
|
11242
10972
|
});
|
|
10973
|
+
var PATH_RE;
|
|
10974
|
+
var PERSISTED;
|
|
10975
|
+
var PROXIES;
|
|
10976
|
+
var RAW;
|
|
10977
|
+
var SIGNALS;
|
|
10978
|
+
var STASH;
|
|
11243
10979
|
var __batch;
|
|
11244
10980
|
var __effect;
|
|
11245
10981
|
var __state;
|
|
10982
|
+
var _ariaBindDialog;
|
|
10983
|
+
var _ariaBindPopover;
|
|
10984
|
+
var _ariaHasAnchor;
|
|
10985
|
+
var _ariaListNav;
|
|
10986
|
+
var _ariaLockScroll;
|
|
10987
|
+
var _ariaModalStack;
|
|
10988
|
+
var _ariaNAV;
|
|
10989
|
+
var _ariaPopupDismiss;
|
|
10990
|
+
var _ariaPopupGuard;
|
|
10991
|
+
var _ariaPosition;
|
|
10992
|
+
var _ariaPositionBelow;
|
|
10993
|
+
var _ariaRovingNav;
|
|
10994
|
+
var _ariaTrapFocus;
|
|
10995
|
+
var _ariaUnlockScroll;
|
|
10996
|
+
var _ariaWireAria;
|
|
10997
|
+
var _keysVersion;
|
|
10998
|
+
var _proxy;
|
|
10999
|
+
var _toFn;
|
|
11000
|
+
var _writeVersion;
|
|
11001
|
+
var arraysEqual;
|
|
11002
|
+
var buildComponentMap;
|
|
11003
|
+
var buildRoutes;
|
|
11004
|
+
var compileAndImport;
|
|
11005
|
+
var connectWatch;
|
|
11006
|
+
var fileToComponentName;
|
|
11007
|
+
var fileToPattern;
|
|
11008
|
+
var findAllComponents;
|
|
11009
|
+
var findComponent;
|
|
11246
11010
|
var getContext;
|
|
11011
|
+
var getLayoutChain;
|
|
11012
|
+
var getSignal;
|
|
11247
11013
|
var hasContext;
|
|
11014
|
+
var keysSignal;
|
|
11015
|
+
var makeProxy;
|
|
11016
|
+
var matchRoute;
|
|
11017
|
+
var patternToRegex;
|
|
11248
11018
|
var setContext;
|
|
11019
|
+
var stashGet;
|
|
11020
|
+
var stashSet;
|
|
11021
|
+
var walk;
|
|
11022
|
+
var wrapDeep;
|
|
11249
11023
|
globalThis.abort ??= (msg) => {
|
|
11250
11024
|
if (msg)
|
|
11251
11025
|
console.error(msg);
|
|
@@ -11275,42 +11049,46 @@ ${indented}`);
|
|
|
11275
11049
|
globalThis.zip ??= (...a) => a[0].map((_, i) => a.map((b) => b[i]));
|
|
11276
11050
|
({ __state, __effect, __batch } = globalThis.__rip);
|
|
11277
11051
|
({ setContext, getContext, hasContext } = globalThis.__ripComponent || {});
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
|
|
11052
|
+
STASH = Symbol("stash");
|
|
11053
|
+
SIGNALS = Symbol("signals");
|
|
11054
|
+
RAW = Symbol("raw");
|
|
11055
|
+
PERSISTED = Symbol("persisted");
|
|
11056
|
+
PROXIES = new WeakMap;
|
|
11057
|
+
_keysVersion = 0;
|
|
11058
|
+
_writeVersion = __state(0);
|
|
11059
|
+
getSignal = function(target, prop) {
|
|
11060
|
+
let sig;
|
|
11286
11061
|
if (!target[SIGNALS]) {
|
|
11287
11062
|
Object.defineProperty(target, SIGNALS, { value: new Map, enumerable: false });
|
|
11288
11063
|
}
|
|
11289
|
-
|
|
11064
|
+
sig = target[SIGNALS].get(prop);
|
|
11290
11065
|
if (!sig) {
|
|
11291
11066
|
sig = __state(target[prop]);
|
|
11292
11067
|
target[SIGNALS].set(prop, sig);
|
|
11293
11068
|
}
|
|
11294
11069
|
return sig;
|
|
11295
11070
|
};
|
|
11296
|
-
|
|
11071
|
+
keysSignal = function(target) {
|
|
11297
11072
|
return getSignal(target, Symbol.for("keys"));
|
|
11298
11073
|
};
|
|
11299
|
-
|
|
11074
|
+
wrapDeep = function(value) {
|
|
11075
|
+
let existing;
|
|
11300
11076
|
if (!(value != null && typeof value === "object"))
|
|
11301
11077
|
return value;
|
|
11302
11078
|
if (value[STASH])
|
|
11303
11079
|
return value;
|
|
11304
11080
|
if (value instanceof Date || value instanceof RegExp || value instanceof Map || value instanceof Set || value instanceof Promise)
|
|
11305
11081
|
return value;
|
|
11306
|
-
|
|
11082
|
+
existing = PROXIES.get(value);
|
|
11307
11083
|
if (existing)
|
|
11308
11084
|
return existing;
|
|
11309
11085
|
return makeProxy(value);
|
|
11310
11086
|
};
|
|
11311
|
-
|
|
11312
|
-
let proxy
|
|
11313
|
-
|
|
11087
|
+
makeProxy = function(target) {
|
|
11088
|
+
let handler, proxy;
|
|
11089
|
+
proxy = null;
|
|
11090
|
+
handler = { get: function(target2, prop) {
|
|
11091
|
+
let sig, val;
|
|
11314
11092
|
if (prop === STASH)
|
|
11315
11093
|
return true;
|
|
11316
11094
|
if (prop === RAW)
|
|
@@ -11329,14 +11107,15 @@ ${indented}`);
|
|
|
11329
11107
|
return function(path, val2) {
|
|
11330
11108
|
return stashSet(proxy, path, val2);
|
|
11331
11109
|
};
|
|
11332
|
-
|
|
11333
|
-
|
|
11110
|
+
sig = getSignal(target2, prop);
|
|
11111
|
+
val = sig.value;
|
|
11334
11112
|
if (val != null && typeof val === "object")
|
|
11335
11113
|
return wrapDeep(val);
|
|
11336
11114
|
return val;
|
|
11337
11115
|
}, set: function(target2, prop, value) {
|
|
11338
|
-
let old
|
|
11339
|
-
|
|
11116
|
+
let old, r;
|
|
11117
|
+
old = target2[prop];
|
|
11118
|
+
r = value?.[RAW] ? value[RAW] : value;
|
|
11340
11119
|
if (r === old)
|
|
11341
11120
|
return true;
|
|
11342
11121
|
target2[prop] = r;
|
|
@@ -11349,8 +11128,9 @@ ${indented}`);
|
|
|
11349
11128
|
_writeVersion.value++;
|
|
11350
11129
|
return true;
|
|
11351
11130
|
}, deleteProperty: function(target2, prop) {
|
|
11131
|
+
let sig;
|
|
11352
11132
|
delete target2[prop];
|
|
11353
|
-
|
|
11133
|
+
sig = target2[SIGNALS]?.get(prop);
|
|
11354
11134
|
if (sig != null)
|
|
11355
11135
|
sig.value = undefined;
|
|
11356
11136
|
keysSignal(target2).value = ++_keysVersion;
|
|
@@ -11363,15 +11143,16 @@ ${indented}`);
|
|
|
11363
11143
|
PROXIES.set(target, proxy);
|
|
11364
11144
|
return proxy;
|
|
11365
11145
|
};
|
|
11366
|
-
|
|
11367
|
-
|
|
11368
|
-
let
|
|
11146
|
+
PATH_RE = /([./][^./\[\s]+|\[[-+]?\d+\]|\[(?:"[^"]+"|'[^']+')\])/;
|
|
11147
|
+
walk = function(path) {
|
|
11148
|
+
let chr, i, list, part, result;
|
|
11149
|
+
list = ("." + path).split(PATH_RE);
|
|
11369
11150
|
list.shift();
|
|
11370
|
-
|
|
11371
|
-
|
|
11151
|
+
result = [];
|
|
11152
|
+
i = 0;
|
|
11372
11153
|
while (i < list.length) {
|
|
11373
|
-
|
|
11374
|
-
|
|
11154
|
+
part = list[i];
|
|
11155
|
+
chr = part[0];
|
|
11375
11156
|
if (chr === "." || chr === "/") {
|
|
11376
11157
|
result.push(part.slice(1));
|
|
11377
11158
|
} else if (chr === "[") {
|
|
@@ -11385,9 +11166,10 @@ ${indented}`);
|
|
|
11385
11166
|
}
|
|
11386
11167
|
return result;
|
|
11387
11168
|
};
|
|
11388
|
-
|
|
11389
|
-
let segs
|
|
11390
|
-
|
|
11169
|
+
stashGet = function(proxy, path) {
|
|
11170
|
+
let obj, segs;
|
|
11171
|
+
segs = walk(path);
|
|
11172
|
+
obj = proxy;
|
|
11391
11173
|
for (const seg of segs) {
|
|
11392
11174
|
if (!(obj != null))
|
|
11393
11175
|
return;
|
|
@@ -11395,9 +11177,10 @@ ${indented}`);
|
|
|
11395
11177
|
}
|
|
11396
11178
|
return obj;
|
|
11397
11179
|
};
|
|
11398
|
-
|
|
11399
|
-
let segs
|
|
11400
|
-
|
|
11180
|
+
stashSet = function(proxy, path, value) {
|
|
11181
|
+
let obj, segs;
|
|
11182
|
+
segs = walk(path);
|
|
11183
|
+
obj = proxy;
|
|
11401
11184
|
for (let i = 0;i < segs.length; i++) {
|
|
11402
11185
|
const seg = segs[i];
|
|
11403
11186
|
if (i === segs.length - 1) {
|
|
@@ -11420,23 +11203,24 @@ ${indented}`);
|
|
|
11420
11203
|
return obj?.[STASH] === true;
|
|
11421
11204
|
};
|
|
11422
11205
|
var persistStash = function(app, opts = {}) {
|
|
11423
|
-
let
|
|
11206
|
+
let _save, saved, savedData, storage, storageKey, target;
|
|
11207
|
+
target = raw(app) || app;
|
|
11424
11208
|
if (target[PERSISTED])
|
|
11425
11209
|
return;
|
|
11426
11210
|
target[PERSISTED] = true;
|
|
11427
|
-
|
|
11428
|
-
|
|
11211
|
+
storage = opts.local ? localStorage : sessionStorage;
|
|
11212
|
+
storageKey = opts.key || "__rip_app";
|
|
11429
11213
|
try {
|
|
11430
|
-
|
|
11214
|
+
saved = storage.getItem(storageKey);
|
|
11431
11215
|
if (saved) {
|
|
11432
|
-
|
|
11216
|
+
savedData = JSON.parse(saved);
|
|
11433
11217
|
for (const k in savedData) {
|
|
11434
11218
|
const v = savedData[k];
|
|
11435
11219
|
app.data[k] = v;
|
|
11436
11220
|
}
|
|
11437
11221
|
}
|
|
11438
11222
|
} catch {}
|
|
11439
|
-
|
|
11223
|
+
_save = function() {
|
|
11440
11224
|
return (() => {
|
|
11441
11225
|
try {
|
|
11442
11226
|
return storage.setItem(storageKey, JSON.stringify(raw(app.data)));
|
|
@@ -11446,8 +11230,9 @@ ${indented}`);
|
|
|
11446
11230
|
})();
|
|
11447
11231
|
};
|
|
11448
11232
|
__effect(function() {
|
|
11233
|
+
let t;
|
|
11449
11234
|
_writeVersion.value;
|
|
11450
|
-
|
|
11235
|
+
t = setTimeout(_save, 2000);
|
|
11451
11236
|
return function() {
|
|
11452
11237
|
return clearTimeout(t);
|
|
11453
11238
|
};
|
|
@@ -11455,15 +11240,17 @@ ${indented}`);
|
|
|
11455
11240
|
return window.addEventListener("beforeunload", _save);
|
|
11456
11241
|
};
|
|
11457
11242
|
var createResource = function(fn, opts = {}) {
|
|
11458
|
-
let _data
|
|
11459
|
-
|
|
11460
|
-
|
|
11461
|
-
|
|
11243
|
+
let _data, _error, _loading, load, resource;
|
|
11244
|
+
_data = __state(opts.initial || null);
|
|
11245
|
+
_loading = __state(false);
|
|
11246
|
+
_error = __state(null);
|
|
11247
|
+
load = async function() {
|
|
11248
|
+
let result;
|
|
11462
11249
|
_loading.value = true;
|
|
11463
11250
|
_error.value = null;
|
|
11464
11251
|
return await (async () => {
|
|
11465
11252
|
try {
|
|
11466
|
-
|
|
11253
|
+
result = await fn();
|
|
11467
11254
|
return _data.value = result;
|
|
11468
11255
|
} catch (err) {
|
|
11469
11256
|
return _error.value = err;
|
|
@@ -11472,7 +11259,7 @@ ${indented}`);
|
|
|
11472
11259
|
}
|
|
11473
11260
|
})();
|
|
11474
11261
|
};
|
|
11475
|
-
|
|
11262
|
+
resource = { data: undefined, loading: undefined, error: undefined, refetch: load };
|
|
11476
11263
|
Object.defineProperty(resource, "data", { get: function() {
|
|
11477
11264
|
return _data.value;
|
|
11478
11265
|
} });
|
|
@@ -11486,13 +11273,14 @@ ${indented}`);
|
|
|
11486
11273
|
load();
|
|
11487
11274
|
return resource;
|
|
11488
11275
|
};
|
|
11489
|
-
|
|
11276
|
+
_toFn = function(source) {
|
|
11490
11277
|
return typeof source === "function" ? source : function() {
|
|
11491
11278
|
return source.value;
|
|
11492
11279
|
};
|
|
11493
11280
|
};
|
|
11494
|
-
|
|
11495
|
-
let obj
|
|
11281
|
+
_proxy = function(out, source) {
|
|
11282
|
+
let obj;
|
|
11283
|
+
obj = { read: function() {
|
|
11496
11284
|
return out.read();
|
|
11497
11285
|
} };
|
|
11498
11286
|
Object.defineProperty(obj, "value", { get: function() {
|
|
@@ -11503,11 +11291,13 @@ ${indented}`);
|
|
|
11503
11291
|
return obj;
|
|
11504
11292
|
};
|
|
11505
11293
|
var delay = function(ms, source) {
|
|
11506
|
-
let fn
|
|
11507
|
-
|
|
11294
|
+
let fn, out;
|
|
11295
|
+
fn = _toFn(source);
|
|
11296
|
+
out = __state(!!fn());
|
|
11508
11297
|
__effect(function() {
|
|
11298
|
+
let t;
|
|
11509
11299
|
if (fn()) {
|
|
11510
|
-
|
|
11300
|
+
t = setTimeout(function() {
|
|
11511
11301
|
return out.value = true;
|
|
11512
11302
|
}, ms);
|
|
11513
11303
|
return function() {
|
|
@@ -11520,11 +11310,13 @@ ${indented}`);
|
|
|
11520
11310
|
return typeof source !== "function" ? _proxy(out, source) : out;
|
|
11521
11311
|
};
|
|
11522
11312
|
var debounce = function(ms, source) {
|
|
11523
|
-
let fn
|
|
11524
|
-
|
|
11313
|
+
let fn, out;
|
|
11314
|
+
fn = _toFn(source);
|
|
11315
|
+
out = __state(fn());
|
|
11525
11316
|
__effect(function() {
|
|
11526
|
-
let val
|
|
11527
|
-
|
|
11317
|
+
let t, val;
|
|
11318
|
+
val = fn();
|
|
11319
|
+
t = setTimeout(function() {
|
|
11528
11320
|
return out.value = val;
|
|
11529
11321
|
}, ms);
|
|
11530
11322
|
return function() {
|
|
@@ -11534,18 +11326,20 @@ ${indented}`);
|
|
|
11534
11326
|
return typeof source !== "function" ? _proxy(out, source) : out;
|
|
11535
11327
|
};
|
|
11536
11328
|
var throttle = function(ms, source) {
|
|
11537
|
-
let fn
|
|
11538
|
-
|
|
11539
|
-
|
|
11329
|
+
let fn, last, out;
|
|
11330
|
+
fn = _toFn(source);
|
|
11331
|
+
out = __state(fn());
|
|
11332
|
+
last = 0;
|
|
11540
11333
|
__effect(function() {
|
|
11541
|
-
let
|
|
11542
|
-
|
|
11543
|
-
|
|
11334
|
+
let now, remaining, t, val;
|
|
11335
|
+
val = fn();
|
|
11336
|
+
now = Date.now();
|
|
11337
|
+
remaining = ms - (now - last);
|
|
11544
11338
|
if (remaining <= 0) {
|
|
11545
11339
|
out.value = val;
|
|
11546
11340
|
return last = now;
|
|
11547
11341
|
} else {
|
|
11548
|
-
|
|
11342
|
+
t = setTimeout(function() {
|
|
11549
11343
|
out.value = fn();
|
|
11550
11344
|
return last = Date.now();
|
|
11551
11345
|
}, remaining);
|
|
@@ -11557,13 +11351,15 @@ ${indented}`);
|
|
|
11557
11351
|
return typeof source !== "function" ? _proxy(out, source) : out;
|
|
11558
11352
|
};
|
|
11559
11353
|
var hold = function(ms, source) {
|
|
11560
|
-
let fn
|
|
11561
|
-
|
|
11354
|
+
let fn, out;
|
|
11355
|
+
fn = _toFn(source);
|
|
11356
|
+
out = __state(!!fn());
|
|
11562
11357
|
__effect(function() {
|
|
11358
|
+
let t;
|
|
11563
11359
|
if (fn()) {
|
|
11564
11360
|
return out.value = true;
|
|
11565
11361
|
} else {
|
|
11566
|
-
|
|
11362
|
+
t = setTimeout(function() {
|
|
11567
11363
|
return out.value = false;
|
|
11568
11364
|
}, ms);
|
|
11569
11365
|
return function() {
|
|
@@ -11574,10 +11370,11 @@ ${indented}`);
|
|
|
11574
11370
|
return typeof source !== "function" ? _proxy(out, source) : out;
|
|
11575
11371
|
};
|
|
11576
11372
|
var createComponents = function() {
|
|
11577
|
-
let files
|
|
11578
|
-
|
|
11579
|
-
|
|
11580
|
-
|
|
11373
|
+
let compiled, files, notify, watchers;
|
|
11374
|
+
files = new Map;
|
|
11375
|
+
watchers = [];
|
|
11376
|
+
compiled = new Map;
|
|
11377
|
+
notify = function(event, path) {
|
|
11581
11378
|
for (const watcher of watchers) {
|
|
11582
11379
|
watcher(event, path);
|
|
11583
11380
|
}
|
|
@@ -11585,7 +11382,8 @@ ${indented}`);
|
|
|
11585
11382
|
return { read: function(path) {
|
|
11586
11383
|
return files.get(path);
|
|
11587
11384
|
}, write: function(path, content) {
|
|
11588
|
-
let isNew
|
|
11385
|
+
let isNew;
|
|
11386
|
+
isNew = !files.has(path);
|
|
11589
11387
|
files.set(path, content);
|
|
11590
11388
|
compiled.delete(path);
|
|
11591
11389
|
return notify(isNew ? "create" : "change", path);
|
|
@@ -11598,11 +11396,12 @@ ${indented}`);
|
|
|
11598
11396
|
}, size: function() {
|
|
11599
11397
|
return files.size;
|
|
11600
11398
|
}, list: function(dir = "") {
|
|
11601
|
-
let
|
|
11602
|
-
|
|
11399
|
+
let prefix, rest, result;
|
|
11400
|
+
result = [];
|
|
11401
|
+
prefix = dir ? dir + "/" : "";
|
|
11603
11402
|
for (const [path] of files) {
|
|
11604
11403
|
if (path.startsWith(prefix)) {
|
|
11605
|
-
|
|
11404
|
+
rest = path.slice(prefix.length);
|
|
11606
11405
|
if (rest.includes("/"))
|
|
11607
11406
|
continue;
|
|
11608
11407
|
result.push(path);
|
|
@@ -11610,8 +11409,9 @@ ${indented}`);
|
|
|
11610
11409
|
}
|
|
11611
11410
|
return result;
|
|
11612
11411
|
}, listAll: function(dir = "") {
|
|
11613
|
-
let result
|
|
11614
|
-
|
|
11412
|
+
let prefix, result;
|
|
11413
|
+
result = [];
|
|
11414
|
+
prefix = dir ? dir + "/" : "";
|
|
11615
11415
|
for (const [path] of files) {
|
|
11616
11416
|
if (path.startsWith(prefix))
|
|
11617
11417
|
result.push(path);
|
|
@@ -11633,8 +11433,9 @@ ${indented}`);
|
|
|
11633
11433
|
return compiled.set(path, result);
|
|
11634
11434
|
} };
|
|
11635
11435
|
};
|
|
11636
|
-
|
|
11637
|
-
let pattern
|
|
11436
|
+
fileToPattern = function(rel) {
|
|
11437
|
+
let pattern;
|
|
11438
|
+
pattern = rel.replace(/\.rip$/, "");
|
|
11638
11439
|
pattern = pattern.replace(/\[\.\.\.(\w+)\]/g, "*$1");
|
|
11639
11440
|
pattern = pattern.replace(/\[(\w+)\]/g, ":$1");
|
|
11640
11441
|
if (pattern === "index")
|
|
@@ -11642,9 +11443,10 @@ ${indented}`);
|
|
|
11642
11443
|
pattern = pattern.replace(/\/index$/, "");
|
|
11643
11444
|
return "/" + pattern;
|
|
11644
11445
|
};
|
|
11645
|
-
|
|
11646
|
-
let names
|
|
11647
|
-
|
|
11446
|
+
patternToRegex = function(pattern) {
|
|
11447
|
+
let names, str2;
|
|
11448
|
+
names = [];
|
|
11449
|
+
str2 = pattern.replace(/\*(\w+)/g, function(_, name) {
|
|
11648
11450
|
names.push(name);
|
|
11649
11451
|
return "(.+)";
|
|
11650
11452
|
}).replace(/:(\w+)/g, function(_, name) {
|
|
@@ -11653,11 +11455,12 @@ ${indented}`);
|
|
|
11653
11455
|
});
|
|
11654
11456
|
return { regex: new RegExp("^" + str2 + "$"), names };
|
|
11655
11457
|
};
|
|
11656
|
-
|
|
11458
|
+
matchRoute = function(path, routes) {
|
|
11459
|
+
let match, params;
|
|
11657
11460
|
for (const route of routes) {
|
|
11658
|
-
|
|
11461
|
+
match = path.match(route.regex.regex);
|
|
11659
11462
|
if (match) {
|
|
11660
|
-
|
|
11463
|
+
params = {};
|
|
11661
11464
|
for (let i = 0;i < route.regex.names.length; i++) {
|
|
11662
11465
|
const name = route.regex.names[i];
|
|
11663
11466
|
params[name] = decodeURIComponent(match[i + 1]);
|
|
@@ -11667,36 +11470,38 @@ ${indented}`);
|
|
|
11667
11470
|
}
|
|
11668
11471
|
return null;
|
|
11669
11472
|
};
|
|
11670
|
-
|
|
11671
|
-
let routes
|
|
11672
|
-
|
|
11673
|
-
|
|
11473
|
+
buildRoutes = function(components, root = "components") {
|
|
11474
|
+
let allFiles, dir, layouts, name, regex, rel, routes, segs, urlPattern;
|
|
11475
|
+
routes = [];
|
|
11476
|
+
layouts = new Map;
|
|
11477
|
+
allFiles = components.listAll(root);
|
|
11674
11478
|
for (const filePath of allFiles) {
|
|
11675
|
-
|
|
11479
|
+
rel = filePath.slice(root.length + 1);
|
|
11676
11480
|
if (!rel.endsWith(".rip"))
|
|
11677
11481
|
continue;
|
|
11678
|
-
|
|
11482
|
+
name = rel.split("/").pop();
|
|
11679
11483
|
if (name === "_layout.rip") {
|
|
11680
|
-
|
|
11484
|
+
dir = rel === "_layout.rip" ? "" : rel.slice(0, -"/_layout.rip".length);
|
|
11681
11485
|
layouts.set(dir, filePath);
|
|
11682
11486
|
continue;
|
|
11683
11487
|
}
|
|
11684
11488
|
if (name.startsWith("_"))
|
|
11685
11489
|
continue;
|
|
11686
|
-
|
|
11490
|
+
segs = rel.split("/");
|
|
11687
11491
|
if (segs.length > 1 && segs.some(function(s, i) {
|
|
11688
11492
|
return i < segs.length - 1 && s.startsWith("_");
|
|
11689
11493
|
}))
|
|
11690
11494
|
continue;
|
|
11691
|
-
|
|
11692
|
-
|
|
11495
|
+
urlPattern = fileToPattern(rel);
|
|
11496
|
+
regex = patternToRegex(urlPattern);
|
|
11693
11497
|
routes.push({ pattern: urlPattern, regex, file: filePath, rel });
|
|
11694
11498
|
}
|
|
11695
11499
|
routes.sort(function(a, b) {
|
|
11696
|
-
let aDyn
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11500
|
+
let aCatch, aDyn, bCatch, bDyn;
|
|
11501
|
+
aDyn = (a.pattern.match(/:/g) || []).length;
|
|
11502
|
+
bDyn = (b.pattern.match(/:/g) || []).length;
|
|
11503
|
+
aCatch = a.pattern.includes("*") ? 1 : 0;
|
|
11504
|
+
bCatch = b.pattern.includes("*") ? 1 : 0;
|
|
11700
11505
|
if (aCatch !== bCatch)
|
|
11701
11506
|
return aCatch - bCatch;
|
|
11702
11507
|
if (aDyn !== bDyn)
|
|
@@ -11705,11 +11510,12 @@ ${indented}`);
|
|
|
11705
11510
|
});
|
|
11706
11511
|
return { routes, layouts };
|
|
11707
11512
|
};
|
|
11708
|
-
|
|
11709
|
-
let chain
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
|
|
11513
|
+
getLayoutChain = function(routeFile, root, layouts) {
|
|
11514
|
+
let chain, dir, rel, segments;
|
|
11515
|
+
chain = [];
|
|
11516
|
+
rel = routeFile.slice(root.length + 1);
|
|
11517
|
+
segments = rel.split("/");
|
|
11518
|
+
dir = "";
|
|
11713
11519
|
if (layouts.has(""))
|
|
11714
11520
|
chain.push(layouts.get(""));
|
|
11715
11521
|
for (let i = 0;i < segments.length; i++) {
|
|
@@ -11723,17 +11529,18 @@ ${indented}`);
|
|
|
11723
11529
|
return chain;
|
|
11724
11530
|
};
|
|
11725
11531
|
var createRouter = function(components, opts = {}) {
|
|
11726
|
-
let
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
|
|
11532
|
+
let _hash, _layouts, _navigating, _params, _path, _query, _route, addBase, base, hashMode, navCallbacks, onClick, onError, onPopState, readUrl, resolve, root, router, stripBase, tree, writeUrl;
|
|
11533
|
+
root = opts.root || "components";
|
|
11534
|
+
base = opts.base || "";
|
|
11535
|
+
hashMode = opts.hash || false;
|
|
11536
|
+
onError = opts.onError || null;
|
|
11537
|
+
stripBase = function(url) {
|
|
11731
11538
|
return base && url.startsWith(base) ? url.slice(base.length) || "/" : url;
|
|
11732
11539
|
};
|
|
11733
|
-
|
|
11540
|
+
addBase = function(path) {
|
|
11734
11541
|
return base ? base + path : path;
|
|
11735
11542
|
};
|
|
11736
|
-
|
|
11543
|
+
readUrl = function() {
|
|
11737
11544
|
let h;
|
|
11738
11545
|
if (hashMode) {
|
|
11739
11546
|
h = location.hash.slice(1);
|
|
@@ -11744,30 +11551,31 @@ ${indented}`);
|
|
|
11744
11551
|
return location.pathname + location.search + location.hash;
|
|
11745
11552
|
}
|
|
11746
11553
|
};
|
|
11747
|
-
|
|
11554
|
+
writeUrl = function(path) {
|
|
11748
11555
|
return hashMode ? path === "/" ? location.pathname : "#" + path.slice(1) : addBase(path);
|
|
11749
11556
|
};
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11758
|
-
|
|
11557
|
+
_path = __state(stripBase(hashMode ? readUrl() : location.pathname));
|
|
11558
|
+
_params = __state({});
|
|
11559
|
+
_route = __state(null);
|
|
11560
|
+
_layouts = __state([]);
|
|
11561
|
+
_query = __state({});
|
|
11562
|
+
_hash = __state("");
|
|
11563
|
+
_navigating = delay(100, __state(false));
|
|
11564
|
+
tree = buildRoutes(components, root);
|
|
11565
|
+
navCallbacks = new Set;
|
|
11759
11566
|
components.watch(function(event, path) {
|
|
11760
11567
|
if (!path.startsWith(root + "/"))
|
|
11761
11568
|
return;
|
|
11762
11569
|
return tree = buildRoutes(components, root);
|
|
11763
11570
|
});
|
|
11764
|
-
|
|
11765
|
-
let rawPath
|
|
11766
|
-
|
|
11571
|
+
resolve = function(url) {
|
|
11572
|
+
let hash, path, queryStr, rawPath, result;
|
|
11573
|
+
rawPath = url.split("?")[0].split("#")[0];
|
|
11574
|
+
path = stripBase(rawPath);
|
|
11767
11575
|
path = path[0] === "/" ? path : "/" + path;
|
|
11768
|
-
|
|
11769
|
-
|
|
11770
|
-
|
|
11576
|
+
queryStr = url.split("?")[1]?.split("#")[0] || "";
|
|
11577
|
+
hash = url.includes("#") ? url.split("#")[1] : "";
|
|
11578
|
+
result = matchRoute(path, tree.routes);
|
|
11771
11579
|
if (result) {
|
|
11772
11580
|
__batch(function() {
|
|
11773
11581
|
_path.value = path;
|
|
@@ -11786,32 +11594,33 @@ ${indented}`);
|
|
|
11786
11594
|
onError({ status: 404, path });
|
|
11787
11595
|
return false;
|
|
11788
11596
|
};
|
|
11789
|
-
|
|
11597
|
+
onPopState = function() {
|
|
11790
11598
|
return resolve(readUrl());
|
|
11791
11599
|
};
|
|
11792
11600
|
if (typeof window !== "undefined")
|
|
11793
11601
|
window.addEventListener("popstate", onPopState);
|
|
11794
|
-
|
|
11602
|
+
onClick = function(e) {
|
|
11603
|
+
let dest, target, url;
|
|
11795
11604
|
if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey)
|
|
11796
11605
|
return;
|
|
11797
|
-
|
|
11606
|
+
target = e.target;
|
|
11798
11607
|
while (target && target.tagName !== "A") {
|
|
11799
11608
|
target = target.parentElement;
|
|
11800
11609
|
}
|
|
11801
11610
|
if (!target?.href)
|
|
11802
11611
|
return;
|
|
11803
|
-
|
|
11612
|
+
url = new URL(target.href, location.origin);
|
|
11804
11613
|
if (url.origin !== location.origin)
|
|
11805
11614
|
return;
|
|
11806
11615
|
if (target.target === "_blank" || target.hasAttribute("data-external"))
|
|
11807
11616
|
return;
|
|
11808
11617
|
e.preventDefault();
|
|
11809
|
-
|
|
11618
|
+
dest = hashMode && url.hash ? url.hash.slice(1) || "/" : url.pathname + url.search + url.hash;
|
|
11810
11619
|
return router.push(dest);
|
|
11811
11620
|
};
|
|
11812
11621
|
if (typeof document !== "undefined")
|
|
11813
11622
|
document.addEventListener("click", onClick);
|
|
11814
|
-
|
|
11623
|
+
router = { push: function(url) {
|
|
11815
11624
|
return resolve(url) ? history.pushState(null, "", writeUrl(_path.read())) : undefined;
|
|
11816
11625
|
}, replace: function(url) {
|
|
11817
11626
|
return resolve(url) ? history.replaceState(null, "", writeUrl(_path.read())) : undefined;
|
|
@@ -11867,7 +11676,7 @@ ${indented}`);
|
|
|
11867
11676
|
} });
|
|
11868
11677
|
return router;
|
|
11869
11678
|
};
|
|
11870
|
-
|
|
11679
|
+
arraysEqual = function(a, b) {
|
|
11871
11680
|
if (a.length !== b.length)
|
|
11872
11681
|
return false;
|
|
11873
11682
|
for (let i = 0;i < a.length; i++) {
|
|
@@ -11877,7 +11686,7 @@ ${indented}`);
|
|
|
11877
11686
|
}
|
|
11878
11687
|
return true;
|
|
11879
11688
|
};
|
|
11880
|
-
|
|
11689
|
+
findComponent = function(mod) {
|
|
11881
11690
|
for (const key in mod) {
|
|
11882
11691
|
const val = mod[key];
|
|
11883
11692
|
if (typeof val === "function" && (val.prototype?.mount || val.prototype?._create))
|
|
@@ -11885,8 +11694,9 @@ ${indented}`);
|
|
|
11885
11694
|
}
|
|
11886
11695
|
return typeof mod.default === "function" ? mod.default : undefined;
|
|
11887
11696
|
};
|
|
11888
|
-
|
|
11889
|
-
let result
|
|
11697
|
+
findAllComponents = function(mod) {
|
|
11698
|
+
let result;
|
|
11699
|
+
result = {};
|
|
11890
11700
|
for (const key in mod) {
|
|
11891
11701
|
const val = mod[key];
|
|
11892
11702
|
if (typeof val === "function" && (val.prototype?.mount || val.prototype?._create)) {
|
|
@@ -11895,21 +11705,23 @@ ${indented}`);
|
|
|
11895
11705
|
}
|
|
11896
11706
|
return result;
|
|
11897
11707
|
};
|
|
11898
|
-
|
|
11899
|
-
let name
|
|
11708
|
+
fileToComponentName = function(filePath) {
|
|
11709
|
+
let name;
|
|
11710
|
+
name = filePath.split("/").pop().replace(/\.rip$/, "");
|
|
11900
11711
|
return name.replace(/(^|[-_])([a-z])/g, function(_, sep, ch) {
|
|
11901
11712
|
return ch.toUpperCase();
|
|
11902
11713
|
});
|
|
11903
11714
|
};
|
|
11904
|
-
|
|
11905
|
-
let map
|
|
11715
|
+
buildComponentMap = function(components, root = "components") {
|
|
11716
|
+
let fileName, map, name;
|
|
11717
|
+
map = {};
|
|
11906
11718
|
for (const path of components.listAll(root)) {
|
|
11907
11719
|
if (!path.endsWith(".rip"))
|
|
11908
11720
|
continue;
|
|
11909
|
-
|
|
11721
|
+
fileName = path.split("/").pop();
|
|
11910
11722
|
if (fileName.startsWith("_"))
|
|
11911
11723
|
continue;
|
|
11912
|
-
|
|
11724
|
+
name = fileToComponentName(path);
|
|
11913
11725
|
if (map[name]) {
|
|
11914
11726
|
console.warn(`[Rip] Component name collision: ${name} (${map[name]} vs ${path})`);
|
|
11915
11727
|
}
|
|
@@ -11917,23 +11729,23 @@ ${indented}`);
|
|
|
11917
11729
|
}
|
|
11918
11730
|
return map;
|
|
11919
11731
|
};
|
|
11920
|
-
|
|
11921
|
-
let cached, found, names, needed, preamble;
|
|
11732
|
+
compileAndImport = async function(source, compile2, components = null, path = null, resolver = null) {
|
|
11733
|
+
let blob, cached, depMod, depSource, found, header, js, mod, names, needed, preamble, url;
|
|
11922
11734
|
if (components && path) {
|
|
11923
11735
|
cached = components.getCompiled(path);
|
|
11924
11736
|
if (cached)
|
|
11925
11737
|
return cached;
|
|
11926
11738
|
}
|
|
11927
|
-
|
|
11739
|
+
js = compile2(source);
|
|
11928
11740
|
if (resolver) {
|
|
11929
11741
|
needed = {};
|
|
11930
11742
|
for (const name in resolver.map) {
|
|
11931
11743
|
const depPath = resolver.map[name];
|
|
11932
11744
|
if (depPath !== path && js.includes(`new ${name}(`)) {
|
|
11933
11745
|
if (!resolver.classes[name]) {
|
|
11934
|
-
|
|
11746
|
+
depSource = components.read(depPath);
|
|
11935
11747
|
if (depSource) {
|
|
11936
|
-
|
|
11748
|
+
depMod = await compileAndImport(depSource, compile2, components, depPath, resolver);
|
|
11937
11749
|
found = findAllComponents(depMod);
|
|
11938
11750
|
for (const k in found) {
|
|
11939
11751
|
const v = found[k];
|
|
@@ -11952,11 +11764,11 @@ ${indented}`);
|
|
|
11952
11764
|
js = preamble + js;
|
|
11953
11765
|
}
|
|
11954
11766
|
}
|
|
11955
|
-
|
|
11767
|
+
header = path ? `// ${path}
|
|
11956
11768
|
` : "";
|
|
11957
|
-
|
|
11958
|
-
|
|
11959
|
-
|
|
11769
|
+
blob = new Blob([header + js], { type: "application/javascript" });
|
|
11770
|
+
url = URL.createObjectURL(blob);
|
|
11771
|
+
mod = await import(url);
|
|
11960
11772
|
if (resolver) {
|
|
11961
11773
|
found = findAllComponents(mod);
|
|
11962
11774
|
for (const k in found) {
|
|
@@ -11969,26 +11781,26 @@ ${indented}`);
|
|
|
11969
11781
|
return mod;
|
|
11970
11782
|
};
|
|
11971
11783
|
var createRenderer = function(opts = {}) {
|
|
11972
|
-
let app, compile2, components, onError, resolver, router, target;
|
|
11784
|
+
let app, cacheComponent, compile2, componentCache, components, container, currentComponent, currentLayouts, currentParams, currentRoute, disposeEffect, generation, layoutInstances, maxCacheSize, mountPoint, mountRoute, onError, renderer, resolver, router, target, unmount;
|
|
11973
11785
|
({ router, app, components, resolver, compile: compile2, target, onError } = opts);
|
|
11974
|
-
|
|
11786
|
+
container = typeof target === "string" ? document.querySelector(target) : target || document.getElementById("app");
|
|
11975
11787
|
if (!container) {
|
|
11976
11788
|
container = document.createElement("div");
|
|
11977
11789
|
container.id = "app";
|
|
11978
11790
|
document.body.appendChild(container);
|
|
11979
11791
|
}
|
|
11980
11792
|
container.style.opacity = "0";
|
|
11981
|
-
|
|
11982
|
-
|
|
11983
|
-
|
|
11984
|
-
|
|
11985
|
-
|
|
11986
|
-
|
|
11987
|
-
|
|
11988
|
-
|
|
11989
|
-
|
|
11990
|
-
|
|
11991
|
-
|
|
11793
|
+
currentComponent = null;
|
|
11794
|
+
currentRoute = null;
|
|
11795
|
+
currentParams = null;
|
|
11796
|
+
currentLayouts = [];
|
|
11797
|
+
layoutInstances = [];
|
|
11798
|
+
mountPoint = container;
|
|
11799
|
+
generation = 0;
|
|
11800
|
+
disposeEffect = null;
|
|
11801
|
+
componentCache = new Map;
|
|
11802
|
+
maxCacheSize = opts.cacheSize || 10;
|
|
11803
|
+
cacheComponent = function() {
|
|
11992
11804
|
let evicted, oldest;
|
|
11993
11805
|
if (currentComponent && currentRoute) {
|
|
11994
11806
|
if (currentComponent.beforeUnmount)
|
|
@@ -12005,7 +11817,7 @@ ${indented}`);
|
|
|
12005
11817
|
return currentRoute = null;
|
|
12006
11818
|
}
|
|
12007
11819
|
};
|
|
12008
|
-
|
|
11820
|
+
unmount = function() {
|
|
12009
11821
|
cacheComponent();
|
|
12010
11822
|
for (let _i = layoutInstances.length - 1;_i >= 0; _i--) {
|
|
12011
11823
|
const inst = layoutInstances[_i];
|
|
@@ -12027,8 +11839,8 @@ ${indented}`);
|
|
|
12027
11839
|
return componentCache.delete(path);
|
|
12028
11840
|
}
|
|
12029
11841
|
});
|
|
12030
|
-
|
|
12031
|
-
let layoutFiles, params, query, route;
|
|
11842
|
+
mountRoute = async function(info) {
|
|
11843
|
+
let Component, LayoutClass, cached, gen2, handled, inst, instance, layoutFiles, layoutMod, layoutSource, layoutsChanged, mod, mp, oldTarget, pageWrapper, params, pre, query, route, slot, source, wrapper;
|
|
12032
11844
|
({ route, params, layouts: layoutFiles, query } = info);
|
|
12033
11845
|
if (!route)
|
|
12034
11846
|
return;
|
|
@@ -12036,61 +11848,61 @@ ${indented}`);
|
|
|
12036
11848
|
return;
|
|
12037
11849
|
}
|
|
12038
11850
|
currentParams = params;
|
|
12039
|
-
|
|
11851
|
+
gen2 = ++generation;
|
|
12040
11852
|
router.navigating = true;
|
|
12041
11853
|
return await (async () => {
|
|
12042
11854
|
try {
|
|
12043
|
-
|
|
11855
|
+
source = components.read(route.file);
|
|
12044
11856
|
if (!source) {
|
|
12045
11857
|
if (onError)
|
|
12046
11858
|
onError({ status: 404, message: `File not found: ${route.file}` });
|
|
12047
11859
|
router.navigating = false;
|
|
12048
11860
|
return;
|
|
12049
11861
|
}
|
|
12050
|
-
|
|
11862
|
+
mod = await compileAndImport(source, compile2, components, route.file, resolver);
|
|
12051
11863
|
if (gen2 !== generation) {
|
|
12052
11864
|
router.navigating = false;
|
|
12053
11865
|
return;
|
|
12054
11866
|
}
|
|
12055
|
-
|
|
11867
|
+
Component = findComponent(mod);
|
|
12056
11868
|
if (!Component) {
|
|
12057
11869
|
if (onError)
|
|
12058
11870
|
onError({ status: 500, message: `No component found in ${route.file}` });
|
|
12059
11871
|
router.navigating = false;
|
|
12060
11872
|
return;
|
|
12061
11873
|
}
|
|
12062
|
-
|
|
12063
|
-
|
|
11874
|
+
layoutsChanged = !arraysEqual(layoutFiles, currentLayouts);
|
|
11875
|
+
oldTarget = currentComponent?._target;
|
|
12064
11876
|
if (layoutsChanged) {
|
|
12065
11877
|
unmount();
|
|
12066
11878
|
} else {
|
|
12067
11879
|
cacheComponent();
|
|
12068
11880
|
}
|
|
12069
|
-
|
|
11881
|
+
mp = layoutsChanged ? container : mountPoint;
|
|
12070
11882
|
if (layoutsChanged && layoutFiles.length > 0) {
|
|
12071
11883
|
container.innerHTML = "";
|
|
12072
11884
|
mp = container;
|
|
12073
11885
|
for (const layoutFile of layoutFiles) {
|
|
12074
|
-
|
|
11886
|
+
layoutSource = components.read(layoutFile);
|
|
12075
11887
|
if (!layoutSource)
|
|
12076
11888
|
continue;
|
|
12077
|
-
|
|
11889
|
+
layoutMod = await compileAndImport(layoutSource, compile2, components, layoutFile, resolver);
|
|
12078
11890
|
if (gen2 !== generation) {
|
|
12079
11891
|
router.navigating = false;
|
|
12080
11892
|
return;
|
|
12081
11893
|
}
|
|
12082
|
-
|
|
11894
|
+
LayoutClass = findComponent(layoutMod);
|
|
12083
11895
|
if (!LayoutClass)
|
|
12084
11896
|
continue;
|
|
12085
|
-
|
|
11897
|
+
inst = new LayoutClass({ app, params, router });
|
|
12086
11898
|
if (inst.beforeMount)
|
|
12087
11899
|
inst.beforeMount();
|
|
12088
|
-
|
|
11900
|
+
wrapper = document.createElement("div");
|
|
12089
11901
|
wrapper.setAttribute("data-layout", layoutFile);
|
|
12090
11902
|
mp.appendChild(wrapper);
|
|
12091
11903
|
inst.mount(wrapper);
|
|
12092
11904
|
layoutInstances.push(inst);
|
|
12093
|
-
|
|
11905
|
+
slot = wrapper.querySelector("#content") || wrapper;
|
|
12094
11906
|
mp = slot;
|
|
12095
11907
|
}
|
|
12096
11908
|
currentLayouts = [...layoutFiles];
|
|
@@ -12100,7 +11912,7 @@ ${indented}`);
|
|
|
12100
11912
|
currentLayouts = [];
|
|
12101
11913
|
mountPoint = container;
|
|
12102
11914
|
}
|
|
12103
|
-
|
|
11915
|
+
cached = componentCache.get(route.file);
|
|
12104
11916
|
if (cached) {
|
|
12105
11917
|
componentCache.delete(route.file);
|
|
12106
11918
|
mp.appendChild(cached._target);
|
|
@@ -12115,10 +11927,10 @@ ${indented}`);
|
|
|
12115
11927
|
if (cached.load)
|
|
12116
11928
|
await cached.load(params, query);
|
|
12117
11929
|
} else {
|
|
12118
|
-
|
|
11930
|
+
pageWrapper = document.createElement("div");
|
|
12119
11931
|
pageWrapper.setAttribute("data-component", route.file);
|
|
12120
11932
|
mp.appendChild(pageWrapper);
|
|
12121
|
-
|
|
11933
|
+
instance = new Component({ app, params, query, router });
|
|
12122
11934
|
if (instance.beforeMount)
|
|
12123
11935
|
instance.beforeMount();
|
|
12124
11936
|
instance.mount(pageWrapper);
|
|
@@ -12141,12 +11953,12 @@ ${indented}`);
|
|
|
12141
11953
|
console.error(`Renderer: error mounting ${route.file}:`, err);
|
|
12142
11954
|
if (onError)
|
|
12143
11955
|
onError({ status: 500, message: err.message, error: err });
|
|
12144
|
-
|
|
11956
|
+
handled = false;
|
|
12145
11957
|
for (let _i = layoutInstances.length - 1;_i >= 0; _i--) {
|
|
12146
|
-
const
|
|
12147
|
-
if (
|
|
11958
|
+
const inst2 = layoutInstances[_i];
|
|
11959
|
+
if (inst2.onError) {
|
|
12148
11960
|
try {
|
|
12149
|
-
|
|
11961
|
+
inst2.onError(err);
|
|
12150
11962
|
handled = true;
|
|
12151
11963
|
break;
|
|
12152
11964
|
} catch (boundaryErr) {
|
|
@@ -12156,7 +11968,7 @@ ${indented}`);
|
|
|
12156
11968
|
}
|
|
12157
11969
|
return (() => {
|
|
12158
11970
|
if (!handled) {
|
|
12159
|
-
|
|
11971
|
+
pre = document.createElement("pre");
|
|
12160
11972
|
pre.style.cssText = "color:red;padding:1em";
|
|
12161
11973
|
pre.textContent = err.stack || err.message;
|
|
12162
11974
|
container.innerHTML = "";
|
|
@@ -12166,9 +11978,10 @@ ${indented}`);
|
|
|
12166
11978
|
}
|
|
12167
11979
|
})();
|
|
12168
11980
|
};
|
|
12169
|
-
|
|
11981
|
+
renderer = { start: function() {
|
|
12170
11982
|
disposeEffect = __effect(function() {
|
|
12171
|
-
let current
|
|
11983
|
+
let current;
|
|
11984
|
+
current = router.current;
|
|
12172
11985
|
return current.route ? mountRoute(current) : undefined;
|
|
12173
11986
|
});
|
|
12174
11987
|
router.init();
|
|
@@ -12181,16 +11994,19 @@ ${indented}`);
|
|
|
12181
11994
|
}
|
|
12182
11995
|
return container.innerHTML = "";
|
|
12183
11996
|
}, remount: function() {
|
|
12184
|
-
let current
|
|
11997
|
+
let current;
|
|
11998
|
+
current = router.current;
|
|
12185
11999
|
return current.route ? mountRoute(current) : undefined;
|
|
12186
12000
|
}, cache: componentCache };
|
|
12187
12001
|
return renderer;
|
|
12188
12002
|
};
|
|
12189
|
-
|
|
12190
|
-
let
|
|
12191
|
-
|
|
12192
|
-
|
|
12193
|
-
|
|
12003
|
+
connectWatch = function(url) {
|
|
12004
|
+
let connect, maxDelay, retryDelay;
|
|
12005
|
+
retryDelay = 1000;
|
|
12006
|
+
maxDelay = 30000;
|
|
12007
|
+
connect = function() {
|
|
12008
|
+
let es;
|
|
12009
|
+
es = new EventSource(url);
|
|
12194
12010
|
es.addEventListener("connected", function() {
|
|
12195
12011
|
retryDelay = 1000;
|
|
12196
12012
|
return console.log("[Rip] Hot reload connected");
|
|
@@ -12215,17 +12031,17 @@ ${indented}`);
|
|
|
12215
12031
|
return connect();
|
|
12216
12032
|
};
|
|
12217
12033
|
var launch = async function(appBase = "", opts = {}) {
|
|
12218
|
-
let bundle, cached, el, etag, etagKey, headers, res;
|
|
12034
|
+
let app, appComponents, bundle, cached, classesKey, compile2, el, etag, etagKey, hash, headers, persist, renderer, res, resolver, router, target;
|
|
12219
12035
|
globalThis.__ripLaunched = true;
|
|
12220
12036
|
if (typeof appBase === "object") {
|
|
12221
12037
|
opts = appBase;
|
|
12222
12038
|
appBase = "";
|
|
12223
12039
|
}
|
|
12224
12040
|
appBase = appBase.replace(/\/+$/, "");
|
|
12225
|
-
|
|
12226
|
-
|
|
12227
|
-
|
|
12228
|
-
|
|
12041
|
+
target = opts.target || "#app";
|
|
12042
|
+
compile2 = opts.compile || null;
|
|
12043
|
+
persist = opts.persist || false;
|
|
12044
|
+
hash = opts.hash || false;
|
|
12229
12045
|
if (!compile2) {
|
|
12230
12046
|
compile2 = globalThis?.compileToJS || null;
|
|
12231
12047
|
}
|
|
@@ -12258,7 +12074,7 @@ ${indented}`);
|
|
|
12258
12074
|
} else {
|
|
12259
12075
|
throw new Error("launch: no bundle or bundleUrl provided");
|
|
12260
12076
|
}
|
|
12261
|
-
|
|
12077
|
+
app = stash({ components: {}, routes: {}, data: {} });
|
|
12262
12078
|
globalThis.__ripApp = app;
|
|
12263
12079
|
if (bundle.data)
|
|
12264
12080
|
app.data = bundle.data;
|
|
@@ -12268,19 +12084,19 @@ ${indented}`);
|
|
|
12268
12084
|
if (persist && typeof sessionStorage !== "undefined") {
|
|
12269
12085
|
persistStash(app, { local: persist === "local", key: `__rip_${appBase}` });
|
|
12270
12086
|
}
|
|
12271
|
-
|
|
12087
|
+
appComponents = createComponents();
|
|
12272
12088
|
if (bundle.components)
|
|
12273
12089
|
appComponents.load(bundle.components);
|
|
12274
|
-
|
|
12275
|
-
|
|
12090
|
+
classesKey = `__rip_${appBase.replace(/\//g, "_") || "app"}`;
|
|
12091
|
+
resolver = { map: buildComponentMap(appComponents), classes: {}, key: classesKey };
|
|
12276
12092
|
if (typeof globalThis !== "undefined")
|
|
12277
12093
|
globalThis[classesKey] = resolver.classes;
|
|
12278
12094
|
if (app.data.title && typeof document !== "undefined")
|
|
12279
12095
|
document.title = app.data.title;
|
|
12280
|
-
|
|
12096
|
+
router = createRouter(appComponents, { root: "components", base: appBase, hash, onError: function(err) {
|
|
12281
12097
|
return console.error(`[Rip] Error ${err.status}: ${err.message || err.path}`);
|
|
12282
12098
|
} });
|
|
12283
|
-
|
|
12099
|
+
renderer = createRenderer({ router, app, components: appComponents, resolver, compile: compile2, target, onError: function(err) {
|
|
12284
12100
|
return console.error(`[Rip] ${err.message}`, err.error);
|
|
12285
12101
|
} });
|
|
12286
12102
|
renderer.start();
|
|
@@ -12293,7 +12109,7 @@ ${indented}`);
|
|
|
12293
12109
|
}
|
|
12294
12110
|
return { app, components: appComponents, router, renderer };
|
|
12295
12111
|
};
|
|
12296
|
-
|
|
12112
|
+
_ariaNAV = function(e, fn) {
|
|
12297
12113
|
if (!fn)
|
|
12298
12114
|
return;
|
|
12299
12115
|
e.preventDefault();
|
|
@@ -12307,7 +12123,7 @@ ${indented}`);
|
|
|
12307
12123
|
}, true);
|
|
12308
12124
|
globalThis.__ariaFocusTrackerBound = true;
|
|
12309
12125
|
}
|
|
12310
|
-
|
|
12126
|
+
_ariaListNav = function(e, h) {
|
|
12311
12127
|
if (e.isComposing)
|
|
12312
12128
|
return;
|
|
12313
12129
|
return (() => {
|
|
@@ -12334,18 +12150,19 @@ ${indented}`);
|
|
|
12334
12150
|
}
|
|
12335
12151
|
})();
|
|
12336
12152
|
};
|
|
12337
|
-
|
|
12153
|
+
_ariaPopupDismiss = function(open, popup, close, els = [], repos = null) {
|
|
12154
|
+
let get, onDown, onScroll;
|
|
12338
12155
|
if (!open)
|
|
12339
12156
|
return;
|
|
12340
|
-
|
|
12157
|
+
get = function(x) {
|
|
12341
12158
|
return typeof x === "function" ? x() : x;
|
|
12342
12159
|
};
|
|
12343
|
-
|
|
12160
|
+
onDown = (e) => {
|
|
12344
12161
|
return ![get(popup), ...els.map(get)].some(function(el) {
|
|
12345
12162
|
return el?.contains(e.target);
|
|
12346
12163
|
}) ? close() : undefined;
|
|
12347
12164
|
};
|
|
12348
|
-
|
|
12165
|
+
onScroll = (e) => {
|
|
12349
12166
|
if (get(popup)?.contains(e.target))
|
|
12350
12167
|
return;
|
|
12351
12168
|
return repos ? repos() : close();
|
|
@@ -12357,35 +12174,37 @@ ${indented}`);
|
|
|
12357
12174
|
return window.removeEventListener("scroll", onScroll, true);
|
|
12358
12175
|
};
|
|
12359
12176
|
};
|
|
12360
|
-
|
|
12361
|
-
let blockedUntil
|
|
12177
|
+
_ariaPopupGuard = function(delay2 = 250) {
|
|
12178
|
+
let blockedUntil;
|
|
12179
|
+
blockedUntil = 0;
|
|
12362
12180
|
return { block: function(ms = delay2) {
|
|
12363
12181
|
return blockedUntil = Date.now() + ms;
|
|
12364
12182
|
}, canOpen: function() {
|
|
12365
12183
|
return Date.now() >= blockedUntil;
|
|
12366
12184
|
} };
|
|
12367
12185
|
};
|
|
12368
|
-
|
|
12369
|
-
let opts, src;
|
|
12370
|
-
|
|
12186
|
+
_ariaBindPopover = function(open, popover, setOpen, source = null) {
|
|
12187
|
+
let currentFocus, desired, el, get, onToggle, opts, restoreEl, restoreFocus, shown, src, syncState;
|
|
12188
|
+
get = function(x) {
|
|
12371
12189
|
return typeof x === "function" ? x() : x;
|
|
12372
12190
|
};
|
|
12373
|
-
|
|
12374
|
-
let active
|
|
12191
|
+
currentFocus = function() {
|
|
12192
|
+
let active, last;
|
|
12193
|
+
active = document.activeElement;
|
|
12375
12194
|
if (active && active !== document.body)
|
|
12376
12195
|
return active;
|
|
12377
|
-
|
|
12196
|
+
last = globalThis.__ariaLastFocusedEl;
|
|
12378
12197
|
if (last?.isConnected !== false)
|
|
12379
12198
|
return last;
|
|
12380
12199
|
return null;
|
|
12381
12200
|
};
|
|
12382
|
-
|
|
12201
|
+
el = get(popover);
|
|
12383
12202
|
if (!el)
|
|
12384
12203
|
return;
|
|
12385
12204
|
if (!Object.hasOwn(HTMLElement.prototype, "togglePopover"))
|
|
12386
12205
|
return;
|
|
12387
|
-
|
|
12388
|
-
|
|
12206
|
+
restoreEl = null;
|
|
12207
|
+
syncState = function(isOpen) {
|
|
12389
12208
|
if (isOpen) {
|
|
12390
12209
|
el.hidden = false;
|
|
12391
12210
|
try {
|
|
@@ -12400,12 +12219,13 @@ ${indented}`);
|
|
|
12400
12219
|
return el.hidden = true;
|
|
12401
12220
|
}
|
|
12402
12221
|
};
|
|
12403
|
-
|
|
12404
|
-
let target
|
|
12222
|
+
restoreFocus = function() {
|
|
12223
|
+
let focusAttempt, target;
|
|
12224
|
+
target = restoreEl;
|
|
12405
12225
|
restoreEl = null;
|
|
12406
12226
|
if (!target?.focus)
|
|
12407
12227
|
return;
|
|
12408
|
-
|
|
12228
|
+
focusAttempt = function(tries = 6) {
|
|
12409
12229
|
if (!(target.isConnected !== false))
|
|
12410
12230
|
return;
|
|
12411
12231
|
try {
|
|
@@ -12423,8 +12243,9 @@ ${indented}`);
|
|
|
12423
12243
|
return focusAttempt();
|
|
12424
12244
|
});
|
|
12425
12245
|
};
|
|
12426
|
-
|
|
12427
|
-
let isOpen
|
|
12246
|
+
onToggle = function(e) {
|
|
12247
|
+
let isOpen;
|
|
12248
|
+
isOpen = e.newState === "open";
|
|
12428
12249
|
if (isOpen) {
|
|
12429
12250
|
restoreEl = get(source) || currentFocus();
|
|
12430
12251
|
syncState(true);
|
|
@@ -12435,8 +12256,8 @@ ${indented}`);
|
|
|
12435
12256
|
return setOpen?.(isOpen);
|
|
12436
12257
|
};
|
|
12437
12258
|
el.addEventListener("toggle", onToggle);
|
|
12438
|
-
|
|
12439
|
-
|
|
12259
|
+
shown = el.matches(":popover-open");
|
|
12260
|
+
desired = !!open;
|
|
12440
12261
|
if (shown !== desired) {
|
|
12441
12262
|
src = get(source);
|
|
12442
12263
|
if (desired) {
|
|
@@ -12454,24 +12275,26 @@ ${indented}`);
|
|
|
12454
12275
|
return el.removeEventListener("toggle", onToggle);
|
|
12455
12276
|
};
|
|
12456
12277
|
};
|
|
12457
|
-
|
|
12458
|
-
let get
|
|
12278
|
+
_ariaBindDialog = function(open, dialog, setOpen, dismissable = true) {
|
|
12279
|
+
let currentFocus, el, get, onCancel, onClose, restoreEl, restoreFocus, syncState;
|
|
12280
|
+
get = function(x) {
|
|
12459
12281
|
return typeof x === "function" ? x() : x;
|
|
12460
12282
|
};
|
|
12461
|
-
|
|
12462
|
-
let active
|
|
12283
|
+
currentFocus = function() {
|
|
12284
|
+
let active, last;
|
|
12285
|
+
active = document.activeElement;
|
|
12463
12286
|
if (active && active !== document.body)
|
|
12464
12287
|
return active;
|
|
12465
|
-
|
|
12288
|
+
last = globalThis.__ariaLastFocusedEl;
|
|
12466
12289
|
if (last?.isConnected !== false)
|
|
12467
12290
|
return last;
|
|
12468
12291
|
return null;
|
|
12469
12292
|
};
|
|
12470
|
-
|
|
12293
|
+
el = get(dialog);
|
|
12471
12294
|
if (!el?.showModal)
|
|
12472
12295
|
return;
|
|
12473
|
-
|
|
12474
|
-
|
|
12296
|
+
restoreEl = null;
|
|
12297
|
+
syncState = function(isOpen) {
|
|
12475
12298
|
if (isOpen) {
|
|
12476
12299
|
el.hidden = false;
|
|
12477
12300
|
try {
|
|
@@ -12486,12 +12309,13 @@ ${indented}`);
|
|
|
12486
12309
|
return el.hidden = true;
|
|
12487
12310
|
}
|
|
12488
12311
|
};
|
|
12489
|
-
|
|
12490
|
-
let target
|
|
12312
|
+
restoreFocus = function() {
|
|
12313
|
+
let focusAttempt, target;
|
|
12314
|
+
target = restoreEl;
|
|
12491
12315
|
restoreEl = null;
|
|
12492
12316
|
if (!target?.focus)
|
|
12493
12317
|
return;
|
|
12494
|
-
|
|
12318
|
+
focusAttempt = function(tries = 6) {
|
|
12495
12319
|
if (!(target.isConnected !== false))
|
|
12496
12320
|
return;
|
|
12497
12321
|
try {
|
|
@@ -12509,14 +12333,14 @@ ${indented}`);
|
|
|
12509
12333
|
return focusAttempt();
|
|
12510
12334
|
});
|
|
12511
12335
|
};
|
|
12512
|
-
|
|
12336
|
+
onCancel = function(e) {
|
|
12513
12337
|
if (!dismissable) {
|
|
12514
12338
|
e.preventDefault();
|
|
12515
12339
|
return;
|
|
12516
12340
|
}
|
|
12517
12341
|
return setOpen?.(false);
|
|
12518
12342
|
};
|
|
12519
|
-
|
|
12343
|
+
onClose = function() {
|
|
12520
12344
|
setOpen?.(false);
|
|
12521
12345
|
syncState(false);
|
|
12522
12346
|
return restoreFocus();
|
|
@@ -12540,11 +12364,12 @@ ${indented}`);
|
|
|
12540
12364
|
return el.removeEventListener("close", onClose);
|
|
12541
12365
|
};
|
|
12542
12366
|
};
|
|
12543
|
-
|
|
12367
|
+
_ariaRovingNav = function(e, h, orientation = "vertical") {
|
|
12368
|
+
let horz, vert;
|
|
12544
12369
|
if (e.isComposing)
|
|
12545
12370
|
return;
|
|
12546
|
-
|
|
12547
|
-
|
|
12371
|
+
vert = orientation !== "horizontal";
|
|
12372
|
+
horz = orientation !== "vertical";
|
|
12548
12373
|
return (() => {
|
|
12549
12374
|
switch (e.key) {
|
|
12550
12375
|
case "ArrowDown":
|
|
@@ -12571,15 +12396,16 @@ ${indented}`);
|
|
|
12571
12396
|
}
|
|
12572
12397
|
})();
|
|
12573
12398
|
};
|
|
12574
|
-
|
|
12399
|
+
_ariaPositionBelow = function(trigger, popup, gap = 4, setVisible = true) {
|
|
12400
|
+
let fl, tr;
|
|
12575
12401
|
if (!(trigger && popup))
|
|
12576
12402
|
return;
|
|
12577
|
-
|
|
12403
|
+
tr = trigger.getBoundingClientRect();
|
|
12578
12404
|
popup.style.position = "fixed";
|
|
12579
12405
|
popup.style.left = `${tr.left}px`;
|
|
12580
12406
|
popup.style.top = `${tr.bottom + gap}px`;
|
|
12581
12407
|
popup.style.minWidth = `${tr.width}px`;
|
|
12582
|
-
|
|
12408
|
+
fl = popup.getBoundingClientRect();
|
|
12583
12409
|
if (fl.bottom > window.innerHeight)
|
|
12584
12410
|
popup.style.top = `${tr.top - fl.height - gap}px`;
|
|
12585
12411
|
if (fl.right > window.innerWidth)
|
|
@@ -12587,17 +12413,19 @@ ${indented}`);
|
|
|
12587
12413
|
return setVisible ? popup.style.visibility = "visible" : undefined;
|
|
12588
12414
|
};
|
|
12589
12415
|
var _FOCUSABLE = 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])';
|
|
12590
|
-
|
|
12591
|
-
let handler
|
|
12416
|
+
_ariaTrapFocus = function(panel) {
|
|
12417
|
+
let handler;
|
|
12418
|
+
handler = function(e) {
|
|
12419
|
+
let first, last, list;
|
|
12592
12420
|
if (!(e.key === "Tab"))
|
|
12593
12421
|
return;
|
|
12594
|
-
|
|
12422
|
+
list = Array.from(panel.querySelectorAll(_FOCUSABLE)).filter(function(f) {
|
|
12595
12423
|
return f.offsetParent !== null;
|
|
12596
12424
|
});
|
|
12597
12425
|
if (!list.length)
|
|
12598
12426
|
return;
|
|
12599
|
-
|
|
12600
|
-
|
|
12427
|
+
first = list[0];
|
|
12428
|
+
last = list[list.length - 1];
|
|
12601
12429
|
return e.shiftKey ? document.activeElement === first ? (e.preventDefault(), last.focus()) : undefined : document.activeElement === last ? (e.preventDefault(), first.focus()) : undefined;
|
|
12602
12430
|
};
|
|
12603
12431
|
panel.addEventListener("keydown", handler);
|
|
@@ -12605,23 +12433,25 @@ ${indented}`);
|
|
|
12605
12433
|
return panel.removeEventListener("keydown", handler);
|
|
12606
12434
|
};
|
|
12607
12435
|
};
|
|
12608
|
-
|
|
12436
|
+
_ariaWireAria = function(panel, id) {
|
|
12437
|
+
let desc, heading;
|
|
12609
12438
|
if (!panel)
|
|
12610
12439
|
return;
|
|
12611
|
-
|
|
12440
|
+
heading = panel.querySelector("h1,h2,h3,h4,h5,h6");
|
|
12612
12441
|
if (heading) {
|
|
12613
12442
|
heading.id ??= `${id}-title`;
|
|
12614
12443
|
panel.setAttribute("aria-labelledby", heading.id);
|
|
12615
12444
|
}
|
|
12616
|
-
|
|
12445
|
+
desc = panel.querySelector("p");
|
|
12617
12446
|
if (desc) {
|
|
12618
12447
|
desc.id ??= `${id}-desc`;
|
|
12619
12448
|
return panel.setAttribute("aria-describedby", desc.id);
|
|
12620
12449
|
}
|
|
12621
12450
|
};
|
|
12622
|
-
|
|
12623
|
-
|
|
12624
|
-
let scrollY
|
|
12451
|
+
_ariaModalStack = [];
|
|
12452
|
+
_ariaLockScroll = function(instance) {
|
|
12453
|
+
let scrollY;
|
|
12454
|
+
scrollY = window.scrollY;
|
|
12625
12455
|
_ariaModalStack.push({ instance, scrollY });
|
|
12626
12456
|
if (_ariaModalStack.length === 1) {
|
|
12627
12457
|
document.body.style.position = "fixed";
|
|
@@ -12629,9 +12459,9 @@ ${indented}`);
|
|
|
12629
12459
|
return document.body.style.width = "100%";
|
|
12630
12460
|
}
|
|
12631
12461
|
};
|
|
12632
|
-
|
|
12633
|
-
let scrollY;
|
|
12634
|
-
|
|
12462
|
+
_ariaUnlockScroll = function(instance) {
|
|
12463
|
+
let idx, scrollY;
|
|
12464
|
+
idx = _ariaModalStack.findIndex(function(m) {
|
|
12635
12465
|
return m.instance === instance;
|
|
12636
12466
|
});
|
|
12637
12467
|
if (idx < 0)
|
|
@@ -12644,18 +12474,19 @@ ${indented}`);
|
|
|
12644
12474
|
return window.scrollTo(0, scrollY);
|
|
12645
12475
|
}
|
|
12646
12476
|
};
|
|
12647
|
-
|
|
12477
|
+
_ariaHasAnchor = function() {
|
|
12478
|
+
let anchor, floating, rect;
|
|
12648
12479
|
return (() => {
|
|
12649
12480
|
try {
|
|
12650
12481
|
if (!document?.createElement)
|
|
12651
12482
|
return false;
|
|
12652
|
-
|
|
12653
|
-
|
|
12483
|
+
anchor = document.createElement("div");
|
|
12484
|
+
floating = document.createElement("div");
|
|
12654
12485
|
anchor.style.cssText = "position:fixed;top:100px;left:100px;width:10px;height:10px;anchor-name:--probe";
|
|
12655
12486
|
floating.style.cssText = "position:fixed;inset:auto;margin:0;position-anchor:--probe;position-area:bottom start;width:10px;height:10px";
|
|
12656
12487
|
document.body.appendChild(anchor);
|
|
12657
12488
|
document.body.appendChild(floating);
|
|
12658
|
-
|
|
12489
|
+
rect = floating.getBoundingClientRect();
|
|
12659
12490
|
anchor.remove();
|
|
12660
12491
|
floating.remove();
|
|
12661
12492
|
return rect.top > 50;
|
|
@@ -12664,13 +12495,13 @@ ${indented}`);
|
|
|
12664
12495
|
}
|
|
12665
12496
|
})();
|
|
12666
12497
|
}();
|
|
12667
|
-
|
|
12668
|
-
let align, name, rect, side;
|
|
12498
|
+
_ariaPosition = function(trigger, floating, opts = {}) {
|
|
12499
|
+
let align, matchWidth, name, offset, placement, rect, side;
|
|
12669
12500
|
if (!(trigger && floating))
|
|
12670
12501
|
return;
|
|
12671
|
-
|
|
12672
|
-
|
|
12673
|
-
|
|
12502
|
+
placement = opts.placement ?? "bottom start";
|
|
12503
|
+
offset = opts.offset ?? 4;
|
|
12504
|
+
matchWidth = opts.matchWidth ?? false;
|
|
12674
12505
|
if (_ariaHasAnchor) {
|
|
12675
12506
|
name = `--anchor-${floating.id || Math.random().toString(36).slice(2, 8)}`;
|
|
12676
12507
|
trigger.style.anchorName = name;
|