├── .editorconfig ├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── main.yml ├── .gitignore ├── .npmignore ├── .vscode ├── launch.json └── settings.json ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── dist ├── dom.js ├── feature.js ├── global.js ├── index.js ├── nodejs-dom.js ├── nodejs-feature.js ├── nodejs-global.js ├── nodejs-pal-builder.js ├── nodejs-platform.js ├── observer.js ├── performance.js ├── platform.js └── types │ ├── dom.d.ts │ ├── feature.d.ts │ ├── global.d.ts │ ├── index.d.ts │ ├── nodejs-dom.d.ts │ ├── nodejs-feature.d.ts │ ├── nodejs-global.d.ts │ ├── nodejs-pal-builder.d.ts │ ├── nodejs-platform.d.ts │ ├── observer.d.ts │ ├── performance.d.ts │ └── platform.d.ts ├── doc ├── CHANGELOG.md ├── MAINTAINER.md └── api.json ├── package-lock.json ├── package.json ├── src ├── dom.ts ├── feature.ts ├── global.ts ├── index.ts ├── nodejs-dom.ts ├── nodejs-feature.ts ├── nodejs-global.ts ├── nodejs-pal-builder.ts ├── nodejs-platform.ts ├── observer.ts ├── performance.ts └── platform.ts ├── test ├── nodejs-dom.spec.ts ├── nodejs-pal-builder.spec.ts ├── nodejs-platform.spec.ts └── support │ └── jasmine.json ├── tsconfig.build.json ├── tsconfig.json └── tsfmt.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | indent_style = space 9 | indent_size = 2 10 | end_of_line = lf 11 | charset = utf-8 12 | trim_trailing_whitespace = false 13 | insert_final_newline = false 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | 18 | # 2 space indentation 19 | [**.*] 20 | indent_style = space 21 | indent_size = 2 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 19 | **I'm submitting a bug report** 20 | **I'm submitting a feature request** 21 | 22 | * **Library Version:** 23 | major.minor.patch-pre 24 | 25 | 26 | **Please tell us about your environment:** 27 | * **Operating System:** 28 | OSX 10.x|Linux (distro)|Windows [7|8|8.1|10] 29 | 30 | * **Node Version:** 31 | 6.2.0 32 | 36 | 37 | * **NPM Version:** 38 | 3.8.9 39 | 43 | 44 | * **JSPM OR Webpack AND Version** 45 | JSPM 0.16.32 | webpack 2.1.0-beta.17 46 | 52 | 53 | * **Browser:** 54 | all | Chrome XX | Firefox XX | Edge XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView 55 | 56 | * **Language:** 57 | all | TypeScript X.X | ESNext 58 | 59 | 60 | **Current behavior:** 61 | 62 | 63 | **Expected/desired behavior:** 64 | 71 | 72 | 73 | * **What is the expected behavior?** 74 | 75 | 76 | * **What is the motivation / use case for changing the behavior?** 77 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Make sure you check the following: 2 | * [ ] unless trivial, a corresponding issue exists for this PR (reference it) 3 | * [ ] if this PR fixes the issue, then include `fix #` and the issue number 4 | * [ ] if this PR adds a feature, then you've included tests in `spec/` 5 | * [ ] you've ran `gulp test` and it passes the lint and spec 6 | * [ ] you've prepended the PR description i.e. (chore):, (feat):, (fix): -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: main 2 | on: [push] 3 | 4 | jobs: 5 | 6 | ci: 7 | timeout-minutes: 10 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | - uses: actions/setup-node@v1 12 | with: 13 | node-version: 16 14 | - run: npm ci 15 | - run: npm run cut-release 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | jspm_packages 3 | .idea 4 | .DS_STORE 5 | build/reports 6 | spec/*.js 7 | spec/*.map 8 | .npmrc 9 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | .github 3 | .idea 4 | *.map 5 | doc/ 6 | spec/ 7 | build/ 8 | src/ 9 | .editorconfig 10 | circle.yml 11 | CONTRIBUTING.md 12 | gulpfile.js 13 | ISSUE_TEMPLATE.md 14 | tsconfig.json 15 | tsfmt.json 16 | tslint.json 17 | 18 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Launch Tests", 6 | "type": "node", 7 | "request": "launch", 8 | "program": "${workspaceRoot}/node_modules/gulp/bin/gulp.js", 9 | "stopOnEntry": false, 10 | "args": [ 11 | "dev:debug" 12 | ], 13 | "cwd": "${workspaceRoot}", 14 | "preLaunchTask": "dev:pre-debug", 15 | "internalConsoleOptions": "openOnSessionStart", 16 | "runtimeExecutable": null, 17 | "runtimeArgs": [ 18 | "--nolazy" 19 | ], 20 | "env": { 21 | "NODE_ENV": "development" 22 | }, 23 | "externalConsole": false, 24 | "sourceMaps": true, 25 | "outDir": "${workspaceRoot}/dist" 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "files.exclude": { 4 | "**/*.map":true, 5 | "**/*.js": { 6 | "when": "$(basename).ts" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We'd love for you to contribute and to make this project even better than it is today! If this interests you, please begin by reading [our contributing guidelines](https://github.com/DurandalProject/about/blob/master/CONTRIBUTING.md). The contributing document will provide you with all the information you need to get started. Once you have read that, you will need to also [sign our CLA](http://goo.gl/forms/dI8QDDSyKR) before we can accept a Pull Request from you. More information on the process is included in the [contributor's guide](https://github.com/DurandalProject/about/blob/master/CONTRIBUTING.md). 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2010 - 2018 Blue Spire Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | Aurelia 4 | 5 |

6 | 7 | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 8 | [![npm Version](https://img.shields.io/npm/v/aurelia-templating-resources.svg)](https://www.npmjs.com/package/aurelia-templating-resources) 9 | ![ci](https://github.com/aurelia/templating-resources/actions/workflows/main.yml/badge.svg) 10 | [![Discourse status](https://img.shields.io/discourse/https/meta.discourse.org/status.svg)](https://discourse.aurelia.io) 11 | [![Twitter](https://img.shields.io/twitter/follow/aureliaeffect.svg?style=social&label=Follow)](https://twitter.com/intent/follow?screen_name=aureliaeffect) 12 | [![Discord Chat](https://img.shields.io/discord/448698263508615178.svg)](https://discord.gg/RBtyM6u) 13 | 14 | # aurelia-pal-nodejs 15 | 16 | This library is part of the [Aurelia](http://www.aurelia.io/) platform and contains the node-specific implementation of the platform abstraction layer. 17 | 18 | > To keep up to date on [Aurelia](http://www.aurelia.io/), please visit and subscribe to [the official blog](http://blog.aurelia.io/) and [our email list](http://eepurl.com/ces50j). We also invite you to [follow us on twitter](https://twitter.com/aureliaeffect). If you have questions look around our [Discourse forums](https://discourse.aurelia.io/), chat in our [community on Discord](https://discord.gg/RBtyM6u) or use [stack overflow](http://stackoverflow.com/search?q=aurelia). Documentation can be found [in our developer hub](http://aurelia.io/docs). 19 | 20 | ## Platform Support 21 | 22 | This library can be used in **NodeJS**. 23 | 24 | # Building The Code 25 | 26 | To build the code, follow these steps. 27 | 28 | 1. Ensure that [NodeJS](http://nodejs.org/) is installed. This provides the platform on which the build tooling runs. 29 | 2. From the project folder, execute the following command: 30 | 31 | ```shell 32 | npm install 33 | ``` 34 | 3. To test the code, run: 35 | 36 | ```shell 37 | npm test 38 | ``` 39 | 4. To build the code, run: 40 | 41 | ```shell 42 | npm run build 43 | ``` 44 | 5. You will find the compiled code in the `dist` folder in CommonJS module format. 45 | 46 | # Acknowledgement 47 | 48 | This software used a snippet borrowed from [browser-env](https://github.com/lukechilds/browser-env). 49 | -------------------------------------------------------------------------------- /dist/dom.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /dist/feature.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /dist/global.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.reset = exports.globalize = exports.initialize = exports.ensurePerformance = void 0; 4 | const aurelia_pal_1 = require("aurelia-pal"); 5 | const nodejs_pal_builder_1 = require("./nodejs-pal-builder"); 6 | var nodejs_pal_builder_2 = require("./nodejs-pal-builder"); 7 | Object.defineProperty(exports, "ensurePerformance", { enumerable: true, get: function () { return nodejs_pal_builder_2.ensurePerformance; } }); 8 | function initialize() { 9 | if (aurelia_pal_1.isInitialized) { 10 | return; 11 | } 12 | let pal = (0, nodejs_pal_builder_1.buildPal)(); 13 | (0, aurelia_pal_1.initializePAL)((platform, feature, dom) => { 14 | Object.assign(platform, pal.platform); 15 | Object.setPrototypeOf(platform, pal.platform.constructor.prototype); 16 | Object.assign(dom, pal.dom); 17 | Object.setPrototypeOf(dom, pal.dom.constructor.prototype); 18 | Object.assign(feature, pal.feature); 19 | Object.setPrototypeOf(feature, pal.feature.constructor.prototype); 20 | (function (global) { 21 | global.console = global.console || {}; 22 | let con = global.console; 23 | let prop; 24 | let method; 25 | let empty = {}; 26 | let dummy = function () { }; 27 | let properties = 'memory'.split(','); 28 | let methods = ('assert,clear,count,debug,dir,dirxml,error,exception,group,' + 29 | 'groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,' + 30 | 'show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn').split(','); 31 | while (prop = properties.pop()) 32 | if (!con[prop]) 33 | con[prop] = empty; 34 | while (method = methods.pop()) 35 | if (!con[method]) 36 | con[method] = dummy; 37 | })(platform.global); 38 | if (platform.global.console && typeof console.log === 'object') { 39 | if (typeof console['debug'] === 'undefined') { 40 | console['debug'] = this.bind(console['log'], console); 41 | } 42 | ['log', 'info', 'warn', 'error', 'assert', 'dir', 'clear', 'profile', 'profileEnd'].forEach(function (method) { 43 | console[method] = this.bind(console[method], console); 44 | }, Function.prototype.call); 45 | } 46 | Object.defineProperty(dom, 'title', { 47 | get: function () { 48 | return pal.global.document.title; 49 | }, 50 | set: function (value) { 51 | pal.global.document.title = value; 52 | } 53 | }); 54 | Object.defineProperty(dom, 'activeElement', { 55 | get: function () { 56 | return pal.global.document.activeElement; 57 | } 58 | }); 59 | Object.defineProperty(platform, 'XMLHttpRequest', { 60 | get: function () { 61 | return pal.global.XMLHttpRequest; 62 | } 63 | }); 64 | }); 65 | } 66 | exports.initialize = initialize; 67 | function createBrowserGlobals() { 68 | Object.getOwnPropertyNames(aurelia_pal_1.PLATFORM.global) 69 | .filter(prop => typeof global[prop] === 'undefined' && prop !== 'undefined') 70 | .forEach(prop => global[prop] = aurelia_pal_1.PLATFORM.global[prop]); 71 | } 72 | function globalize() { 73 | initialize(); 74 | createBrowserGlobals(); 75 | global.System = { 76 | import(moduleId) { 77 | try { 78 | return Promise.resolve(require(moduleId)); 79 | } 80 | catch (e) { 81 | return Promise.reject(e); 82 | } 83 | } 84 | }; 85 | global.PAL = { 86 | DOM: aurelia_pal_1.DOM, PLATFORM: aurelia_pal_1.PLATFORM, FEATURE: aurelia_pal_1.FEATURE 87 | }; 88 | return global; 89 | } 90 | exports.globalize = globalize; 91 | function reset(window) { 92 | if (window) { 93 | window.close(); 94 | } 95 | } 96 | exports.reset = reset; 97 | -------------------------------------------------------------------------------- /dist/nodejs-dom.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.NodeJsDom = void 0; 4 | class NodeJsDom { 5 | constructor(global) { 6 | this.global = global; 7 | this.boundary = 'aurelia-dom-boundary'; 8 | this.title = ""; 9 | this.activeElement = null; 10 | this.Element = global.Element; 11 | this.NodeList = global.NodeList; 12 | this.SVGElement = global.SVGElement || class SVGElement extends global.Element { 13 | }; 14 | } 15 | addEventListener(eventName, callback, capture) { 16 | return this.global.document.addEventListener(eventName, callback, capture); 17 | } 18 | removeEventListener(eventName, callback, capture) { 19 | return this.global.document.removeEventListener(eventName, callback, capture); 20 | } 21 | createElement(tagName) { 22 | return this.global.document.createElement(tagName); 23 | } 24 | createAttribute(name) { 25 | return this.global.document.createAttribute(name); 26 | } 27 | createTextNode(text) { 28 | return this.global.document.createTextNode(text); 29 | } 30 | createComment(text) { 31 | return this.global.document.createComment(text); 32 | } 33 | createDocumentFragment() { 34 | return this.global.document.createDocumentFragment(); 35 | } 36 | createTemplateElement() { 37 | return this.global.document.createElement('template'); 38 | } 39 | createMutationObserver(callback) { 40 | return new (this.global.window.MutationObserver)(callback); 41 | } 42 | createCustomEvent(eventType, options) { 43 | return new this.global.CustomEvent(eventType, options); 44 | } 45 | dispatchEvent(evt) { 46 | this.global.window.dispatchEvent(evt); 47 | } 48 | getComputedStyle(element) { 49 | return this.global.window.getComputedStyle(element); 50 | } 51 | getElementById(id) { 52 | return this.global.document.getElementById(id); 53 | } 54 | querySelector(query) { 55 | return this.global.document.querySelector(query); 56 | } 57 | querySelectorAll(query) { 58 | return this.global.document.querySelectorAll(query); 59 | } 60 | nextElementSibling(element) { 61 | return element.nextElementSibling; 62 | } 63 | createTemplateFromMarkup(markup) { 64 | let parser = this.global.document.createElement('div'); 65 | parser.innerHTML = markup; 66 | let temp = parser.firstElementChild; 67 | if (!temp || temp.nodeName !== 'TEMPLATE') { 68 | throw new Error('Template markup must be wrapped in a