Skip to content

Commit

Permalink
[stable8.5] cherry-pick all kiosk commits (#9743)
Browse files Browse the repository at this point in the history
* Add `--no-webapps` gulp option (#9622)

* Add `--no-webapps' gulp option

* Fix function declaration inconsistency

* docs

* Move kiosk project to pxt repo (#9624)

* Move kiosk to pxt repo

* sync latest kiosk changes from arcade repo

* Move kiosk config files to arcade docs

* kiosk updates

* update GameDataUrl

* comment missing icon resources

* disable eslint, for now

* fix code scan warning

* Include kiosk build in npm package contents (#9631)

* Sync kiosk changes (#9645)

* Restore absolute url on kiosk qr code (#9660)

* Add prettier to kiosk (#9667)

* kiosk: increase gamepad polling frequency (#9668)

* Kiosk navigation improvements (#9669)

* Navigation improvements

* add return types

* sound effect tweak

* Add switch sound to Adding Game screen

* New UI effects for Kiosk, authored in Arcade (#9671)

* New UI effects authored in Arcade

* Update readme

* Clarify readme

* Moving kiosk sfx to arcade repo (#9672)

* Remove unused components from kiosk (#9678)

* disable app insights correlation headers (#9679)

* load pxtlib into kiosk (#9680)

* Made a few small navigation improvements (#9686)

* Kiosk: Use pxt.tickEvent (#9687)

* Kiosk: Use pxt.tickEvent

* remove localhost special case

* Refactor kiosk state management (#9689)

* kiosk: refactor add game polling (#9691)

* kiosk: refactor add game polling

* show toast on game delete

* poll for games even while playing a game

* Kiosk: Remove direct dom manipulation (#9692)

* Remove direct dom manipulation

* tweak adding game css

* prettier

* Removed unneeded css attribute

* update readme

* Remove unwanted memo dependency

* Kiosk: Support event-based navigation (#9700)

* Kiosk: Support event-based navigation

* remove unused packages

* Add spacer to add game layout to keep it centered at wide resolutions

* Restore link border on scan qr page

* Shortened background transition time

* Better focus trapping. Fix tab nav on ScanQR page.

* pr feedback

* prettier

* lf all the strings (#9710)

* kiosk: support gamepad dpad for navigation (#9712)

* Identify kiosk uwp app in telemetry (#9714)

* kiosk: setup react-common dependency (#9717)

* react-common: support for button children (#9719)

* kiosk: use button control from react common (#9720)

* css fix for "press start" label on safari (#9722)

* kiosk: download targetconfig.json at startup (#9723)

* kiosk: download targetconfig.json at startup

* update cli crowdin thing

* Update cli/cli.ts

Co-authored-by: Joey Wunderlich <[email protected]>

---------

Co-authored-by: Joey Wunderlich <[email protected]>

* Add `--noauth` option to `pxt serve` (#9725)

* kiosk: persist built game js in local storage (#9726)

* kiosk: persist built game js in local storage

* better null check

* kiosk: fixes for carousel touch nav, storage exceptions (#9731)

Pushing this through in time for testing today.

* fixes for carousel touch nav, storage exceptions

* don't save compiled js in local storage.

* Log gamepad type to telemetry (#9739)

* support setting color of "loading" text in run.html (#9738)

* fix for shoebox controller (#9737)

* kiosk: remap esc to the controller's back button (#9735)

* kiosk: fix for skipped letters when entering high score (#9734)

* kiosk: fix for skipping letters when entering high score

* whitespace

* kiosk: store built js in indexeddb, not local storage (#9736)

* kiosk: map controller Y to escapebutton functionality (#9741)

---------

Co-authored-by: Joey Wunderlich <[email protected]>
  • Loading branch information
eanders-ms and jwunderl authored Oct 24, 2023
1 parent a5cd145 commit 8607876
Show file tree
Hide file tree
Showing 111 changed files with 15,642 additions and 7,656 deletions.
44 changes: 12 additions & 32 deletions cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,12 @@ ${gcards.map(gcard => `[${gcard.name}](${gcard.url})`).join(',\n')}
if (game.subtitle) targetStrings[`{id:game-subtitle}${game.subtitle}`] = game.subtitle;
}

const kioskGames = targetConfig?.kiosk?.games;
for (const game of (kioskGames ?? [])) {
if (game.name) targetStrings[`{id:game-name}${game.name}`] = game.name;
if (game.description) targetStrings[`{id:game-description}${game.description}`] = game.description;
}

const approvedRepoLib = targetConfig?.packages?.approvedRepoLib;
for (const [extension, repoData] of Object.entries(approvedRepoLib ?? {})) {
for (const tag of (repoData.tags ?? [])) {
Expand Down Expand Up @@ -2075,10 +2081,8 @@ async function buildSemanticUIAsync(parsed?: commandParser.ParsedCommand) {
// This is just to support the local skillmap/cra-app serve for development
nodeutil.cp("built/web/react-common-skillmap.css", "node_modules/pxt-core/skillmap/public/blb");
nodeutil.cp("built/web/react-common-authcode.css", "node_modules/pxt-core/authcode/public/blb");
nodeutil.cp("built/web/react-common-multiplayer.css", "node_modules/pxt-core/multiplayer/public/blb");
nodeutil.cp("built/web/semantic.css", "node_modules/pxt-core/skillmap/public/blb");
nodeutil.cp("built/web/semantic.css", "node_modules/pxt-core/authcode/public/blb");
nodeutil.cp("built/web/semantic.css", "node_modules/pxt-core/multiplayer/public/blb");
}
}

Expand Down Expand Up @@ -2165,18 +2169,6 @@ function buildAuthcodeAsync(parsed: commandParser.ParsedCommand) {
return buildReactAppAsync("authcode", parsed, { copyAssets: false });
}

function buildMultiplayerAsync(parsed: commandParser.ParsedCommand) {
return buildReactAppAsync(
"multiplayer",
parsed,
{
copyAssets: false,
includePxtSim: true,
expandedPxtTarget: true
}
);
}

function updateDefaultProjects(cfg: pxt.TargetBundle) {
let defaultProjects = [
pxt.BLOCKS_PROJECT_NAME,
Expand Down Expand Up @@ -2835,7 +2827,8 @@ export function serveAsync(parsed: commandParser.ParsedCommand) {
wsPort: parsed.flags["wsport"] as number || 0,
hostname: parsed.flags["hostname"] as string || "",
browser: parsed.flags["browser"] as string,
serial: !parsed.flags["noSerial"] && !globalConfig.noSerial
serial: !parsed.flags["noSerial"] && !globalConfig.noSerial,
noauth: parsed.flags["noauth"] as boolean || false,
}))
}

Expand Down Expand Up @@ -6899,6 +6892,10 @@ ${pxt.crowdin.KEY_VARIABLE} - crowdin key
aliases: ["w"],
type: "number",
argument: "wsport"
},
noauth: {
description: "disable localtoken-based authentication",
aliases: ["na"],
}
}
}, serveAsync);
Expand Down Expand Up @@ -7073,23 +7070,6 @@ ${pxt.crowdin.KEY_VARIABLE} - crowdin key
}
}, buildAuthcodeAsync);

p.defineCommand({
name: "buildmultiplayer",
aliases: ["multiplayer", "mp"],
advanced: true,
help: "Serves the multiplayer webapp",
flags: {
serve: {
description: "Serve the multiplayer app locally after building (npm start)"
},
docs: {
description: "Path to local docs folder to copy into multiplayer",
type: "string",
argument: "docs"
}
}
}, buildMultiplayerAsync)

advancedCommand("augmentdocs", "test markdown docs replacements", augmnetDocsAsync, "<temlate.md> <doc.md>");

advancedCommand("crowdin", "upload, download, clean, stats files to/from crowdin", pc => crowdin.execCrowdinAsync.apply(undefined, pc.args), "<cmd> <path> [output]")
Expand Down
8 changes: 5 additions & 3 deletions cli/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ let localHexCacheDir = path.join("built", "hexcache");
let serveOptions: ServeOptions;

const webappNames = [
"kiosk"
// TODO: Add other webapp names here: "multiplayer", "skillmap", "authcode"
"kiosk",
"multiplayer"
// TODO: Add other webapp names here: "skillmap", "authcode"
];

function setupDocfilesdirs() {
Expand Down Expand Up @@ -806,6 +807,7 @@ export interface ServeOptions {
hostname?: string;
wsPort?: number;
serial?: boolean;
noauth?: boolean;
}

// can use http://localhost:3232/streams/nnngzlzxslfu for testing
Expand Down Expand Up @@ -1087,7 +1089,7 @@ export function serveAsync(options: ServeOptions) {
})
}

if (!isAuthorizedLocalRequest(req)) {
if (!options.noauth && !isAuthorizedLocalRequest(req)) {
error(403);
return null;
}
Expand Down
1 change: 1 addition & 0 deletions docfiles/apptracking.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
disableAjaxTracking: true,
overridePageViewDuration: false,
disableExceptionTracking: true,
disableCorrelationHeaders: true,
disableCookiesUsage: !isProduction,
isStorageUseDisabled: !isProduction,
url: "/blb/ai.2.min.js"
Expand Down
14 changes: 11 additions & 3 deletions docfiles/pxtweb/cookieCompliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ namespace pxt {
telemetryItem.properties["stage"] = (pxtConfig.relprefix || "/--").replace(/[^a-z]/ig, '')

const userAgent = navigator.userAgent.toLowerCase();
const userAgentRegexResult = /\belectron\/(\d+\.\d+\.\d+.*?)(?: |$)/i.exec(userAgent); // Example navigator.userAgent: "Mozilla/5.0 Chrome/61.0.3163.100 Electron/2.0.0 Safari/537.36"
if (userAgentRegexResult) {
const electronRegexResult = /\belectron\/(\d+\.\d+\.\d+.*?)(?: |$)/i.exec(userAgent); // Example navigator.userAgent: "Mozilla/5.0 Chrome/61.0.3163.100 Electron/2.0.0 Safari/537.36"
if (electronRegexResult) {
telemetryItem.properties["Electron"] = 1;
telemetryItem.properties["ElectronVersion"] = userAgentRegexResult[1];
telemetryItem.properties["ElectronVersion"] = electronRegexResult[1];
}

const pxtElectron = (window as any).pxtElectron;
Expand All @@ -231,6 +231,14 @@ namespace pxt {
telemetryItem.properties["PxtElectronIsProd"] = pxtElectron.versions.isProd;
}

// Kiosk UWP info is appended to the user agent by the makecode-dotnet-apps/arcade-kiosk UWP app
const kioskUwpRegexResult = /\((MakeCode Arcade Kiosk UWP)\/([\S]+)\/([\S]+)\)/i.exec(userAgent); // Example navigator.userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.2045.60 (MakeCode Arcade Kiosk UWP/0.1.41.0/Windows.Xbox)"
if (kioskUwpRegexResult) {
telemetryItem.properties["KioskUwp"] = 1;
telemetryItem.properties["KioskUwpVersion"] = kioskUwpRegexResult[2];
telemetryItem.properties["KioskUwpPlatform"] = kioskUwpRegexResult[3];
}

// "cookie" does not actually correspond to whether or not we drop the cookie because we recently
// switched to immediately dropping it rather than waiting. Instead, we maintain the legacy behavior
// of only setting it to true for production sites where interactive consent has been obtained
Expand Down
14 changes: 11 additions & 3 deletions docfiles/tracking.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
if (typeof Windows !== "undefined")
telemetryItem.properties["WindowsApp"] = 1;
var userAgent = navigator.userAgent.toLowerCase();
var userAgentRegexResult = /\belectron\/(\d+\.\d+\.\d+.*?)(?: |$)/i.exec(userAgent); // Example navigator.userAgent: "Mozilla/5.0 Chrome/61.0.3163.100 Electron/2.0.0 Safari/537.36"
if (userAgentRegexResult) {
var electronRegexResult = /\belectron\/(\d+\.\d+\.\d+.*?)(?: |$)/i.exec(userAgent); // Example navigator.userAgent: "Mozilla/5.0 Chrome/61.0.3163.100 Electron/2.0.0 Safari/537.36"
if (electronRegexResult) {
telemetryItem.properties["Electron"] = 1;
telemetryItem.properties["ElectronVersion"] = userAgentRegexResult[1];
telemetryItem.properties["ElectronVersion"] = electronRegexResult[1];
}
if (typeof pxtElectron !== "undefined") {
telemetryItem.properties["PxtElectron"] = 1;
Expand All @@ -56,6 +56,13 @@
telemetryItem.properties["PxtTargetVersion"] = pxtElectron.versions.pxtTargetVersion;
telemetryItem.properties["PxtElectronIsProd"] = pxtElectron.versions.isProd;
}
// Kiosk UWP info is appended to the user agent by the makecode-dotnet-apps/arcade-kiosk UWP app
var kioskUwpRegexResult = /\((MakeCode Arcade Kiosk UWP)\/([\S]+)\/([\S]+)\)/i.exec(userAgent); // Example navigator.userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.2045.60 (MakeCode Arcade Kiosk UWP/0.1.41.0/Windows.Xbox)"
if (kioskUwpRegexResult) {
telemetryItem.properties["KioskUwp"] = 1;
telemetryItem.properties["KioskUwpVersion"] = kioskUwpRegexResult[2];
telemetryItem.properties["KioskUwpPlatform"] = kioskUwpRegexResult[3];
}
return true;
});
},
Expand All @@ -64,6 +71,7 @@
disableAjaxTracking: true,
overridePageViewDuration: false,
disableExceptionTracking: true,
disableCorrelationHeaders: true,
disableCookiesUsage: !isProduction,
isStorageUseDisabled: !isProduction,
url: "/doccdn/ai.2.min.js"
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ const maybeBuildWebapps = () => {
const lintWithEslint = () => Promise.all(
["cli", "pxtblocks", "pxteditor", "pxtlib", "pxtcompiler",
"pxtpy", "pxtrunner", "pxtsim", "webapp",
"docfiles/pxtweb", "skillmap", "authcode", "multiplayer", "docs/static/streamer"].map(dirname =>
"docfiles/pxtweb", "skillmap", "authcode", "multiplayer"/*, "kiosk"*/, "docs/static/streamer"].map(dirname =>
exec(`node node_modules/eslint/bin/eslint.js -c .eslintrc.js --ext .ts,.tsx ./${dirname}/`, true)))
.then(() => console.log("linted"))
const lint = lintWithEslint
Expand Down
6 changes: 6 additions & 0 deletions kiosk/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
"parserOptions": {
"project": "kiosk/tsconfig.json",
},
"ignorePatterns": ["tests/**/*.spec.ts", "public/**/*", "build/**/*"]
}
5 changes: 5 additions & 0 deletions kiosk/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"arrowParens": "avoid",
"semi": true,
"tabWidth": 4
}
32 changes: 32 additions & 0 deletions kiosk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,35 @@ Debug and step through Kiosk code using the browser dev tools (F12 to open).

Follow the "Test in staging environment" instructions, but get your auth token from `https://makecode.com/oauth/gettoken`.


## Authoring UI sound effects

1. Open the "Kiosk Audio Effects" project in Arcade: https://makecode.com/_K6AfE6AWd9xV
- Click on the provided link to open the MakeCode Arcade project in your web browser.

2. Tweak or add the desired sound:
- Within the MakeCode Arcade project, modify or add the sound effect you want.

3. Play the sound in the editor a few times while capturing the audio:
- Install a Chrome extension called "Chrome Audio Capturer" from this link: [Link to Chrome Audio Capturer](https://github.com/arblast/Chrome-Audio-Capturer)
- Use the extension to capture the audio of the sound effect by playing it within the MakeCode editor.

4. In a sound file editor, clip out the sound effect and export it as .ogg:
- Download the captured audio file.
- Open a sound file editor (such as Audacity or Adobe Audition).
- Import the downloaded audio file.
- Edit and clip out the specific sound effect you want.
- Run a high-pass filter to reduce volume of low-end frequencies.
- Export the edited audio as an .ogg file.

5. Save the .ogg file to /pxt/docs/kiosk-data/sfx:
- Navigate to the specified directory (/pxt/docs/kiosk-data/sfx) in your file system.
- Save the edited .ogg sound effect file in this directory.

6. If it's a new effect, add it to Services/SoundEffectService.ts:
- If the sound effect you added or modified is new and hasn't been used before, you may need to update the code in the `Services/SoundEffectService.ts` file to include the new sound effect.

7. Re-share the above project and update the URL in Step 1:
- Share the MakeCode Arcade project with the updated sound effect, ensuring is it not saved as a Persistent Share.
- Update the URL in Step 1 of these instructions to reflect the new project URL.

8 changes: 3 additions & 5 deletions kiosk/config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { aliasWebpack } = require("react-app-alias");
const { aliasWebpack } = require("react-app-alias-ex");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = function (config, env) {
Expand All @@ -8,6 +9,7 @@ module.exports = function (config, env) {
...aliasFn(config),
plugins: [
...config.plugins.filter((p) => !(p instanceof HtmlWebpackPlugin)),
new NodePolyfillPlugin(),
new HtmlWebpackPlugin(
Object.assign(
{},
Expand All @@ -34,10 +36,6 @@ module.exports = function (config, env) {
)
),
],
module: {
...config.module,
rules: config.module.rules.filter(el => !(el.use && el.use.some(item => !!(item.options && item.options.eslintPath)))),
}
};
return config;
};
Loading

0 comments on commit 8607876

Please sign in to comment.