Skip to content

Commit

Permalink
merging master
Browse files Browse the repository at this point in the history
  • Loading branch information
jwunderl committed Sep 13, 2024
2 parents 214a6a9 + 8e0daec commit a6054af
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 66 deletions.
19 changes: 16 additions & 3 deletions cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3030,6 +3030,7 @@ class SnippetHost implements pxt.Host {
class Host
implements pxt.Host {
fileOverrides: Map<string> = {}
queue = new pxt.Util.PromiseQueue();

resolve(module: pxt.Package, filename: string) {
//pxt.debug(`resolving ${module.level}:${module.id} -- ${filename} in ${path.resolve(".")}`)
Expand Down Expand Up @@ -3165,10 +3166,22 @@ class Host
if (useCompileServiceDocker) {
return build.compileWithLocalCompileService(extInfo);
}
return this.queue.enqueue("getHexInfoAsync", async () => {
const prevVariant = pxt.appTargetVariant;

setBuildEngine()
return build.buildHexAsync(build.thisBuild, mainPkg, extInfo, forceBuild)
.then(() => build.thisBuild.patchHexInfo(extInfo))
if (extInfo.appVariant && extInfo.appVariant !== prevVariant) {
pxt.setAppTargetVariant(extInfo.appVariant, { temporary: true });
}
setBuildEngine()
await build.buildHexAsync(build.thisBuild, mainPkg, extInfo, forceBuild)
const res = build.thisBuild.patchHexInfo(extInfo);

if (extInfo.appVariant && extInfo.appVariant !== prevVariant) {
pxt.setAppTargetVariant(prevVariant);
}

return res;
});
}

cacheStoreAsync(id: string, val: string): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions cli/prepYotta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const os = require("os");
const path = require("path");
const fs = require("fs");

const token = process.env["GH_ACCESS_TOKEN"];
if (process.env["GH_ACCESS_TOKEN"]) {
const token = process.env["GITHUB_ACCESS_TOKEN"];
if (process.env["GITHUB_ACCESS_TOKEN"]) {
console.log("Writing .netrc and .yotta/config.json")
const home = os.homedir();

Expand Down
80 changes: 51 additions & 29 deletions pxtblocks/importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,14 @@ function promoteShadow(shadow: Element) {
shadow.remove();
return undefined;
}
const newBlock = createBlockFromShadow(shadow);
shadow.parentElement.appendChild(newBlock);
shadow.remove();

return newBlock;
};

function createBlockFromShadow(shadow: Element) {
const newBlock = Blockly.utils.xml.createElement("block");

for (const attr of shadow.getAttributeNames()) {
Expand All @@ -392,45 +400,59 @@ function promoteShadow(shadow: Element) {
newBlock.appendChild(child.cloneNode(true));
}

shadow.parentElement.appendChild(newBlock);
shadow.remove();

return newBlock;
};
}

export function patchShadows(root: Element, inShadow: boolean) {
if (root.tagName === "shadow") {
const type = root.getAttribute("type");
let shouldPatch = false;

switch (type) {
case "variables_get_reporter":
case "argument_reporter_boolean":
case "argument_reporter_number":
case "argument_reporter_string":
case "argument_reporter_array":
case "argument_reporter_custom":
shouldPatch = true;
break;
if (root.parentElement?.tagName === "xml") {
console.warn(`Shadow block of type '${root.getAttribute("type")}' found at top level. Converting to non-shadow block`);
pxt.tickEvent(`blocks.import.topLevelShadow`, { blockId: root.getAttribute("type") });

const newBlock = createBlockFromShadow(root);
root.parentElement.insertBefore(newBlock, root);
root.remove();
root = newBlock;

const mutation = getDirectChildren(root, "mutation")[0];
if (mutation?.hasAttribute("dupliacteondrag")) {
mutation.removeAttribute("dupliacteondrag");
}
}
else {
const type = root.getAttribute("type");
let shouldPatch = false;

switch (type) {
case "variables_get_reporter":
case "argument_reporter_boolean":
case "argument_reporter_number":
case "argument_reporter_string":
case "argument_reporter_array":
case "argument_reporter_custom":
shouldPatch = true;
break;
}

if (shouldPatch) {
root = promoteShadow(root)
if (!root) return;
let mutation = getDirectChildren(root, "mutation")[0];
if (shouldPatch) {
root = promoteShadow(root)
if (!root) return;
let mutation = getDirectChildren(root, "mutation")[0];

if (mutation) {
mutation.setAttribute("duplicateondrag", "true");
if (mutation) {
mutation.setAttribute("duplicateondrag", "true");
}
else {
mutation = Blockly.utils.xml.createElement("mutation");
mutation.setAttribute("duplicateondrag", "true");
root.appendChild(mutation);
}
}
else {
mutation = Blockly.utils.xml.createElement("mutation");
mutation.setAttribute("duplicateondrag", "true");
root.appendChild(mutation);
else if (type === "variables_get" || hasNonShadowChild(root)) {
root = promoteShadow(root);
}
}
else if (type === "variables_get" || hasNonShadowChild(root)) {
root = promoteShadow(root);
}

}

if (!root) return;
Expand Down
2 changes: 2 additions & 0 deletions pxtlib/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,8 @@ namespace pxt {
}
}

einfo.appVariant = variant;

const inf = target.isNative ? await this.host().getHexInfoAsync(einfo) : null

einfo = U.flatClone(einfo)
Expand Down
10 changes: 6 additions & 4 deletions teachertool/src/components/CatalogOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,28 @@ interface CatalogItemLabelProps {
recentlyAdded: boolean;
}
const CatalogItemLabel: React.FC<CatalogItemLabelProps> = ({ catalogCriteria, isMaxed, recentlyAdded }) => {
const showRecentlyAddedIndicator = recentlyAdded && !isMaxed;
return (
<div className={css["catalog-item-label"]}>
<div className={css["action-indicators"]}>
{isMaxed ? (
<span>{Strings.Max}</span>
<i
className="fas fa-check"
title={Strings.MaxReached}
/>
) : (
<>
<i
className={classList(
"fas fa-check",
css["recently-added-indicator"],
showRecentlyAddedIndicator ? undefined : css["hide-indicator"]
recentlyAdded ? undefined : css["hide-indicator"]
)}
title={lf("Added!")}
/>
<i
className={classList(
"fas fa-plus",
showRecentlyAddedIndicator ? css["hide-indicator"] : undefined
recentlyAdded ? css["hide-indicator"] : undefined
)}
title={Strings.AddToChecklist}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

.segment-container {
display: flex;
flex-wrap: wrap;
flex-direction: row;
align-items: flex-start;
justify-content: flex-start;
Expand Down Expand Up @@ -158,7 +159,8 @@
.criteria-description {
color: var(--pxt-page-foreground-light);
margin-top: 0.2rem;
width: -webkit-fill-available;
width: 100%; // For non-webkit browsers
width: -webkit-fill-available; // Webkit browsers

&.for-print {
font-style: italic;
Expand Down
11 changes: 7 additions & 4 deletions teachertool/src/components/styling/EvalResultDisplay.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
gap: 0.5rem;
align-items: center;
justify-content: flex-start;
width: -webkit-fill-available;
width: 100%; // For non-webkit browsers
width: -webkit-fill-available; // Webkit browsers
padding: 0.5rem;
}

Expand All @@ -89,7 +90,8 @@
flex-direction: column;
align-items: center;
justify-content: flex-start;
width: -webkit-fill-available;
width: 100%; // For non-webkit browsers
width: -webkit-fill-available; // Webkit browsers
min-height: 9rem;
gap: 0.5rem;

Expand Down Expand Up @@ -163,7 +165,8 @@
.separator {
border-bottom: solid 1px var(--pxt-content-accent);
margin-top: 0.5rem;
width: -webkit-fill-available;
width: 100%; // For non-webkit browsers
width: -webkit-fill-available; // Webkit browsers
}

.result-details {
Expand Down Expand Up @@ -302,4 +305,4 @@
display: flex;
flex-direction: column;
margin-top: 0.5rem;
}
}
2 changes: 1 addition & 1 deletion teachertool/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export namespace Strings {
export const Continue = lf("Continue");
export const Loading = lf("Loading...");
export const Close = lf("Close");
export const Max = lf("Max");
export const AddToChecklist = lf("Add to Checklist");
export const SelectCriteriaDescription = lf("Select the criteria you'd like to include");
export const Checklist = lf("Checklist");
Expand All @@ -53,6 +52,7 @@ export namespace Strings {
export const EvaluationComplete = lf("Evaluation complete");
export const UnableToEvaluatePartial = lf("Unable to evaluate some criteria");
export const GiveFeedback = lf("Give Feedback");
export const MaxReached = lf("Maximum count reached for this item");
}

export namespace Ticks {
Expand Down
1 change: 0 additions & 1 deletion teachertool/src/services/backendRequests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Strings } from "../constants";
import { stateAndDispatch } from "../state";
import { ErrorCode } from "../types/errorCode";
import { logError } from "./loggingService";
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/blocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,8 @@ export class Editor extends toolboxeditor.ToolboxEditor {
minScale: .2,
scaleSpeed: 1.5,
startScale: pxt.BrowserUtils.isMobile() ? 0.7 : 0.9,
pinch: true
pinch: true,
wheel: true
},
rtl: Util.isUserLanguageRtl()
};
Expand Down
3 changes: 3 additions & 0 deletions webapp/src/fileworkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export function setApiAsync(f: (path: string, data?: any) => Promise<any>) {
function getAsync(h: Header) {
return apiAsync("pkg/" + h.path)
.then((resp: pxt.FsPkg) => {
if (!resp.files) {
return undefined;
}
let r: pxt.workspace.File = {
header: h,
text: {},
Expand Down
46 changes: 26 additions & 20 deletions webapp/src/timeMachine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,14 @@ export const TimeMachine = (props: TimeMachineProps) => {
"controller",
"skillsMap",
"noproject",
"nocookiebanner"
"nocookiebanner",
];

const localToken = pxt.storage.getLocal("local_token");
if (localToken) {
queryParams.push(`local_token=${localToken}`);
}

if (pxt.appTarget?.appTheme.timeMachineQueryParams) {
queryParams = queryParams.concat(pxt.appTarget.appTheme.timeMachineQueryParams);
}
Expand Down Expand Up @@ -362,21 +367,31 @@ function formatTime(time: number) {
}

function formatDate(time: number) {
const oneDay = 1000 * 60 * 60 * 24;

const now = new Date();
const nowYear = now.getFullYear();
const nowMonth = now.getMonth();
const nowDay = now.getDate();

const date = new Date(time);
const year = date.getFullYear();
const month = date.getMonth();
const day = date.getDate();
const today = new Date(nowYear, nowMonth, nowDay);
const yesterday = new Date(today.getTime() - oneDay);
const oneWeekAgo = new Date(today.getTime() - oneDay * 7);

const diff = Date.now() - time;
const oneDay = 1000 * 60 * 60 * 24;
const editTime = new Date(time);
const editDay = new Date(editTime.getFullYear(), editTime.getMonth(), editTime.getDate());

if (year !== nowYear) {
return date.toLocaleDateString(
if (time >= today.getTime()) {
return lf("Today");
}
else if (time >= yesterday.getTime()) {
return lf("Yesterday")
}
else if (time >= oneWeekAgo.getTime()) {
return lf("{0} days ago", Math.floor((today.getTime() - editDay.getTime()) / oneDay));
}
else if (editDay.getFullYear() !== today.getFullYear()) {
return editTime.toLocaleDateString(
pxt.U.userLanguage(),
{
year: "numeric",
Expand All @@ -385,17 +400,8 @@ function formatDate(time: number) {
}
);
}
else if (nowMonth === month && nowDay === day) {
return lf("Today");
}
else if (diff < oneDay * 2) {
return lf("Yesterday")
}
else if (diff < oneDay * 8) {
return lf("{0} days ago", Math.floor(diff / oneDay))
}
else {
return date.toLocaleDateString(
return editTime.toLocaleDateString(
pxt.U.userLanguage(),
{
month: "short",
Expand Down Expand Up @@ -439,7 +445,7 @@ function getTimelineEntries(history: HistoryFile): TimelineEntry[] {

const createTimeEntry = (timestamp: number, kind: "snapshot" | "diff" | "share") => {
const date = new Date(timestamp);
const key = new Date(date.getFullYear(), date.getMonth(), date.getDay()).getTime();
const key = new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();

if (!buckets[key]) {
buckets[key] = [];
Expand Down

0 comments on commit a6054af

Please sign in to comment.