{"_id":"@microsoft/powerappsplayersdk","_rev":"74-4e781b74644bc229779fb437a8f1446d","name":"@microsoft/powerappsplayersdk","dist-tags":{"latest":"0.3.0","beta":"0.3.0"},"versions":{"0.3.0":{"name":"@microsoft/powerappsplayersdk","version":"0.3.0","keywords":["PowerApps","Canvas Apps","Player Sdk"],"author":{"name":"Microsoft"},"license":"See License in LICENSE","_id":"@microsoft/powerappsplayersdk@0.3.0","maintainers":[{"name":"microsoft","email":"npmjs@microsoft.com"}],"dist":{"shasum":"3161826fa3c32797e874ca61b6427782e3c70230","tarball":"https://registry.npmjs.org/@microsoft/powerappsplayersdk/-/powerappsplayersdk-0.3.0.tgz","fileCount":65,"integrity":"sha512-0vv4tIrjjQT6M8+1dvaKiYRb1nx4xwo7UQhiY6eq99IwAMYUgQFCaCLrbh8YuRwwUTXVnt8sH8etVOm8Ztk6lg==","signatures":[{"sig":"MEUCIEpJxXte4MRXFcC5JO+2xuqD3vOKN3Y8oSAyjz7AHcR5AiEA6YnwXvh4vWZNeZ9HcsuAyLkazBOUFqTbIKRn/DQodpc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1178239,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdY/zrCRA9TVsSAnZWagAAenYP/2gToUEosSnCctHMBD+a\nEW4E3u3y2I2GffyNT5nLkiF6zmfB87a9+nyPbhfS96fQgIu0aKMXA4qqGiX9\nLHnM8AiAYh2GyPP95vEA3QcS06ihBfVRWIXJ0A1MQoMuOnB7yKujbG9imyn2\nFg+HPO5b3TI70nT4/6y7w0qn/zlICYSu6k8hp67E4zXPimPlGkjzWVFBugt/\n1AhdOL5LbvLCNG4RucxwbctViWPKNa2iN1u8H/Dwto3KWTgg4ybqg0R/RgTa\nZM8F3ET/eDvDdnTDo/c00W9F4DXj7s38LgVrH2NR+O7HgzBUFZIwYejkoMq6\nU6xLPLrIi+mXiPudSLc8SdAvESiRPgQ8zosmE7sUPALyUaEaFkGMX1NpWhZD\nhcNgat6ugpz1UtzV0XHIWgdB21Wn55jZCVd3PyOW8AA2mG3ylMzfeAmgJ8uo\nUF6VdHOLbGnbgfWUVm4Ny+WvKAd2uGGUnlzkTa3zCbnNEjZLp1O/1JvKlt4/\nFgtn5gejMBz/V7AEA4LaRCwr3ZYSpej95iJJ52rXqwBl6UoZl5LsQn2bgrf9\na2DgrXSRfqwbBRXFmb0OIl17ZfwYS+CPGzoU00ua5KaVAo828YEaU5To3Lba\nP5ZlFL3LZQbyIOeB3o+nE50bYQLycL0MS1iKoeKddRGcV592DkeoPyg2Ep0k\nG8pG\r\n=jwjy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./PowerAppsPlayerSdk/powerappsplayersdk-min.js","types":"./PowerAppsPlayerSdk/index.d.ts","scripts":{"pack":"npm pack","test":"jest","build":"..\\common\\typescriptBuild \"--relative_path=src\\PowerAppsPlayerSdk\"","clean":"rimraf out drop"},"_npmUser":{"name":"microsoft","email":"npmjs@microsoft.com"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","_npmVersion":"6.1.0","description":"Allows users to programmatically embed a canvas app in their experiences.","directories":{},"_nodeVersion":"10.16.0","dependencies":{"@microsoft/applicationinsights-web":"^2.1.1"},"_hasShrinkwrap":false,"devDependencies":{"npm":"^6.9.0","chai":"^4.2.0","gulp":"4.0.0","jest":"^24.8.0","yargs":"^13.1.0","rimraf":"^2.6.3","tslint":"5.11.0","ts-jest":"^24.0.0","typescript":"^3.5.3","@babel/core":"^7.4.5","@types/chai":"^4.1.7","@types/jest":"^24.0.6","@types/node":"^12.0.7","gulp-tslint":"^8.1.4","babel-loader":"^8.0.6","gulp-uglify-es":"^1.0.4","webpack-stream":"^5.2.1","gulp-typescript":"^5.0.1","jest-junit-reporter":"^1.1.0"},"_npmOperationalInternal":{"tmp":"tmp/powerappsplayersdk_0.3.0_1566833898470_0.8986700220150572","host":"s3://npm-registry-packages"}}},"time":{"created":"2019-08-26T15:38:18.470Z","modified":"2026-07-16T15:47:23.818Z","0.3.0":"2019-08-26T15:38:18.658Z"},"author":{"name":"Microsoft"},"license":"See License in LICENSE","keywords":["PowerApps","Canvas Apps","Player Sdk"],"description":"Allows users to programmatically embed a canvas app in their experiences.","maintainers":[{"email":"npmjs@microsoft.com","name":"microsoft1es"},{"email":"microsoft-oss-publishing@microsoft.com","name":"microsoft-oss-releases"},{"email":"powerapps-cli-npm@microsoft.com","name":"powerapps-admin"}],"readme":"# Project\r\n@microsoft/powerappsplayersdk\r\n\r\n## Note\r\n- This is a preview feature.\r\n- Preview features aren’t meant for production use and may have restricted functionality.\r\n- These features are available before an official release so that customers can get early access and provide feedback.\r\n- Microsoft doesn't provide support for this preview feature. Microsoft Technical Support won’t be able to help you with issues or questions.\r\n\r\n\r\n### Description\r\nThe Player SDK enables developers to:\r\n- Embed an app by App Id\r\n- Embed an app by Logical name, Environment Id and Tenant Id. \r\n- Set data on the app \r\n- Register host methods that can be called in the App.\r\n  \r\n  (Schema for the methods and data can be set using PowerApps Authoring SDK.)\r\n- Subscribe to events from Player (like App created, App loaded and App Errored) \r\n\r\n### Installation\r\n```\r\nnpm install @microsoft/powerappsplayersdk\r\n```\r\n\r\n### Usage\r\nFor samples please visit: [Samples](http://aka.ms/powerappsembeddingsamples)\r\n\r\n#### Import module into your project\r\n```\r\nimport * as PowerAppPlayerSdk from \"@microsoft/powerappsplayersdk\";\r\n```\r\n\r\n#### Initialize the SDK\r\n```\r\nconst sdkInitializer: PowerAppsPlayerSdk.SdkInitializer = { \r\n    hostName: “DemoApp” \r\n} \r\nawait PowerAppsPlayerSdk.initAsync(sdkInitializer); \r\n```\r\n\r\n#### Play a PowerApp by AppId\r\nHow to get AppId\r\n\r\nIf you are using @microsoft/powerappsauthoringsdk, app Id is returned in appSaved and appPublished event.\r\nElse in powerapps.com, on the Apps tab, click or tap the ellipsis(…), then Details- copy the App ID (GUID). \r\n```\r\nconst options: PowerAppsPlayerSdk.PlayerOptions = { \r\n    externalCorrelationId: PowerAppsPlayerSdk.initializeCv(),\r\n    parentContainerId: <ParentContainerId e.g. an Id for a div element>\r\n}\r\n\r\nconst player: PowerAppsPlayerSdk.Player = PowerAppsPlayerSdk.Player.initPlayerByAppId(options, <appId>);\r\nplayer.renderApp();\r\n```\r\n\r\n#### Play a PowerApp by Logical Name\r\nHow to get LogicalName, EnvironmentId, TenantId \r\n- If using the @microsoft/powerappsauthoringsdk, these values will be returned in appSaved and appPublished events (only when the application is created within a solution).\r\n\r\nLogicalName \r\n   1. Go to powerapps.com.\r\n   2. Click on the Solutions link in the left-hand side navigation \r\n   3. Open the solution in which the App was added or created. Copy the “Name”.\r\n\r\n\r\nEnvironment Id \r\n   1. Go to powerapps.com.\r\n   2. From top-right corner select the environment in which you application exists.\r\n   3. Copy the id (GUID) after environments portion in URL.\r\n\r\nTenant Id\r\n   1. Go to powerapps.com.\r\n   2. Click on the Apps tab, click or tap the ellipses(...), then Details.\r\n   3. In the Web Link section, copy the GUID after 'tenantid='.\r\n```\r\nconst options: PowerAppsPlayerSdk.PlayerOptions = {\r\n    externalCorrelationId: PowerAppsPlayerSdk.initializeCv(),\r\n    parentContainerId: <ParentContainerId e.g. an Id for a Div element>\r\n}\r\nconst player: PowerAppsPlayerSdk.Player = PowerAppsPlayerSdk.Player.initPlayerByAppId(options, <logicalName>, <environmentId>, <tenantId>);\r\nplayer.renderApp(); \r\n```\r\n\r\n#### Set data on the application\r\nThe data should conform to the schema that was provided when the app was authored.\r\nFor more information see 'MakerSession::setDataAsync' method on @microsoft/powerappsauthoringsdk.\r\n```\r\npublic setData(data: PowerAppsData): void; \r\n```\r\n\r\n#### Register a host callback\r\nSchema for the callback is set during authoring time using the 'MakerSession::setHostMethodDefinitionAsync' method on @microsoft/powerappsauthoringsdk.\r\n```\r\npublic registerHostFunction(name: string, func: Function) :void;\r\n```\r\n\r\n#### onAppLoaded event\r\nEvent is triggered when App is successfully loaded. The onAppLoaded event is of type EventHook<PlayerInfo>. Which means when the event is raised, it has a single parameter which conforms to the PlayerInfo interface which provides the appId.\r\n```\r\nfunction onAppLoaded(playerInfo: PowerAppsPlayerSdk.PlayerInfo) { \r\n    Console.log(“User loaded an application with id: “ + playerInfo.appId); \r\n} \r\n// Subscribe to app load event \r\nplayer.onAppLoaded.subscribe(onAppLoaded);\r\n```\r\n\r\n#### onAppUnload event\r\nEvent is triggered when the App is closed. This can happen before load is fired. For e.g. It happens when user does not agree to consent dialog. The onAppUnload event is of type EventHook<PlayerInfo>.\r\n```\r\nfunction onAppUnload(playerInfo: PowerAppsPlayerSdk.PlayerInfo) { \r\n    Console.log(“App with id: “ + playerInfo.appId + “ Unloaded”); \r\n} \r\n// Subscribe to app unload event \r\nplayer.onAppUnload.subscribe(onAppUnload);\r\n```\r\n\r\n#### onAppError event\r\nEvent is triggered when the App when does not load due to an error. The onAppError event is of type EventHook< PlayerInfo>.\r\n```\r\nfunction onAppError(playerInfo: PowerAppsPlayerSdk.PlayerInfo) { \r\n    Console.log(“App with id: “ + playerInfo.appId + “ errored”); \r\n}\r\n// Subscribe to app error event \r\nplayer.onAppError.subscribe(onAppError);\r\n```\r\n\r\n#### Dispose a Player instance\r\nThis will stop the app rendering and unsubscribe from all the events.\r\n```\r\nplayer.dispose();\r\n```\r\n\r\n## License\r\nSee the [LICENSE](LICENSE) file for details\r\n","readmeFilename":"readme.md"}