aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2023-01-22 14:53:29 +0100
committerMatěj Cepl <mcepl@cepl.eu>2023-01-22 14:53:50 +0100
commit70c89f78a105ef2f8123fa8abd124e21e5a10b80 (patch)
treee030ef87edb66c9d5731c1c31aa11078740b89cb
parent97e4ca0d7d24f5df5c331d9fba963e12368ddd84 (diff)
downloadhesla-70c89f78a105ef2f8123fa8abd124e21e5a10b80.tar.gz
Switch from amd to native ES2015 ECMAScript modules.
-rw-r--r--Makefile4
-rw-r--r--config.ts8
-rw-r--r--hesla.ts2
-rw-r--r--hesla.webapp2
-rw-r--r--require.d.ts330
l---------require.js1
-rw-r--r--sworker.js2
-rw-r--r--templates/base.html2
8 files changed, 8 insertions, 343 deletions
diff --git a/Makefile b/Makefile
index 0ab1ca9..cb8b139 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,10 @@
-FILES=hesla.js hesla.js.map require.js config.js config.js.map \
+FILES=hesla.js hesla.js.map config.js config.js.map \
activePage.js activePage.js.map favicon-*.png a*.png lamb-of-God.svg sworker.js \
index_de.html index.html screen.css site.webmanifest favicon.ico \
google9815148f4ac1407f.html config.ts hesla.ts activePage.ts
%.js: %.ts
- tsc --sourceMap --allowJs true --checkJs true --module amd --target es2015 $<
+ tsc --sourceMap --allowJs true --checkJs true --module es2015 --target es2015 $<
all: index.html index_de.html config.js activePage.js hesla.js
diff --git a/config.ts b/config.ts
index a65dfa8..55de94e 100644
--- a/config.ts
+++ b/config.ts
@@ -1,7 +1,3 @@
-/// <reference path="require.d.ts" />
+import { Hesla } from "./hesla.js";
-import { Hesla } from "hesla";
-
-require([], () => {
- var thisHesla = new Hesla();
-});
+var thisHesla = new Hesla();
diff --git a/hesla.ts b/hesla.ts
index 05e7f2f..473f194 100644
--- a/hesla.ts
+++ b/hesla.ts
@@ -1,4 +1,4 @@
-import {ActivePage} from "activePage";
+import {ActivePage} from "./activePage.js";
function toISODateString(date) {
function pad(n) {
diff --git a/hesla.webapp b/hesla.webapp
index 45f5bd2..6084995 100644
--- a/hesla.webapp
+++ b/hesla.webapp
@@ -1,5 +1,5 @@
{
- "version": "0.4.3",
+ "version": "0.5.0",
"name": "Hesla",
"description": "Display today's Hesla (Losungen, Watchwords) from Bible.",
"display": "standalone",
diff --git a/require.d.ts b/require.d.ts
deleted file mode 100644
index 5ac6d30..0000000
--- a/require.d.ts
+++ /dev/null
@@ -1,330 +0,0 @@
-// Type definitions for RequireJS 2.1.8
-// Project: http://requirejs.org/
-// Definitions by: Josh Baldwin <https://github.com/jbaldwin/>
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-/*
-require-2.1.8.d.ts may be freely distributed under the MIT license.
-
-Copyright (c) 2013 Josh Baldwin https://github.com/jbaldwin/require.d.ts
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-interface RequireError extends Error {
-
- /**
- * The error ID that maps to an ID on a web page.
- **/
- requireType: string;
-
- /**
- * Required modules.
- **/
- requireModules: string[];
-
- /**
- * The original error, if there is one (might be null).
- **/
- originalError: Error;
-}
-
-interface RequireShim {
-
- /**
- * List of dependencies.
- **/
- deps?: string[];
-
- /**
- * Name the module will be exported as.
- **/
- exports?: string;
-
- /**
- * Initialize function with all dependcies passed in,
- * if the function returns a value then that value is used
- * as the module export value instead of the object
- * found via the 'exports' string.
- * @param dependencies
- * @return
- **/
- init?: (...dependencies: any[]) => any;
-}
-
-interface RequireConfig {
-
- // The root path to use for all module lookups.
- baseUrl?: string;
-
- // Path mappings for module names not found directly under
- // baseUrl.
- paths?: { [key: string]: any; };
-
- // Dictionary of Shim's.
- // does not cover case of key->string[]
- shim?: { [key: string]: RequireShim; };
-
- /**
- * For the given module prefix, instead of loading the
- * module with the given ID, substitude a different
- * module ID.
- *
- * @example
- * requirejs.config({
- * map: {
- * 'some/newmodule': {
- * 'foo': 'foo1.2'
- * },
- * 'some/oldmodule': {
- * 'foo': 'foo1.0'
- * }
- * }
- * });
- **/
- map?: {
- [id: string]: {
- [id: string]: string;
- };
- };
-
- /**
- * AMD configurations, use module.config() to access in
- * define() functions
- **/
- config?: { [id: string]: {}; };
-
- /**
- * Configures loading modules from CommonJS packages.
- **/
- packages?: {};
-
- /**
- * The number of seconds to wait before giving up on loading
- * a script. The default is 7 seconds.
- **/
- waitSeconds?: number;
-
- /**
- * A name to give to a loading context. This allows require.js
- * to load multiple versions of modules in a page, as long as
- * each top-level require call specifies a unique context string.
- **/
- context?: string;
-
- /**
- * An array of dependencies to load.
- **/
- deps?: string[];
-
- /**
- * A function to pass to require that should be require after
- * deps have been loaded.
- * @param modules
- **/
- callback?: (...modules: any[]) => void;
-
- /**
- * If set to true, an error will be thrown if a script loads
- * that does not call define() or have shim exports string
- * value that can be checked.
- **/
- enforceDefine?: boolean;
-
- /**
- * If set to true, document.createElementNS() will be used
- * to create script elements.
- **/
- xhtml?: boolean;
-
- /**
- * Extra query string arguments appended to URLs that RequireJS
- * uses to fetch resources. Most useful to cachce bust when
- * the browser or server is not configured correcty.
- *
- * @example
- * urlArgs: "bust= + (new Date()).getTime()
- **/
- urlArgs?: string;
-
- /**
- * Specify the value for the type="" attribute used for script
- * tags inserted into the document by RequireJS. Default is
- * "text/javascript". To use Firefox's JavasScript 1.8
- * features, use "text/javascript;version=1.8".
- **/
- scriptType?: string;
-
-}
-
-// todo: not sure what to do with this guy
-interface RequireModule {
-
- /**
- *
- **/
- config(): {};
-
-}
-
-/**
-*
-**/
-interface RequireMap {
-
- /**
- *
- **/
- prefix: string;
-
- /**
- *
- **/
- name: string;
-
- /**
- *
- **/
- parentMap: RequireMap;
-
- /**
- *
- **/
- url: string;
-
- /**
- *
- **/
- originalName: string;
-
- /**
- *
- **/
- fullName: string;
-}
-
-interface Require {
-
- /**
- * Configure require.js
- **/
- config(config: RequireConfig): Require;
-
- /**
- * CommonJS require call
- * @param module Module to load
- * @return The loaded module
- */
- (module: string): any;
-
- /**
- * Start the main app logic.
- * Callback is optional.
- * Can alternatively use deps and callback.
- * @param modules Required modules to load.
- **/
- (modules: string[]): void;
-
- /**
- * @see Require()
- * @param ready Called when required modules are ready.
- **/
- (modules: string[], ready: Function): void;
-
- /**
- * @see http://requirejs.org/docs/api.html#errbacks
- * @param ready Called when required modules are ready.
- **/
- (modules: string[], ready: Function, errback: Function): void;
-
- /**
- * Generate URLs from require module
- * @param module Module to URL
- * @return URL string
- **/
- toUrl(module: string): string;
-
- /**
- * On Error override
- * @param err
- **/
- onError(err: RequireError, errback?: (err: RequireError) => void): void;
-
- /**
- * Undefine a module
- * @param module Module to undefine.
- **/
- undef(module: string): void;
-
- /**
- * Semi-private function, overload in special instance of undef()
- **/
- onResourceLoad(context: Object, map: RequireMap, depArray: RequireMap[]): void;
-}
-
-interface RequireDefine {
-
- /**
- * Define Simple Name/Value Pairs
- * @param config Dictionary of Named/Value pairs for the config.
- **/
- (config: { [key: string]: any; }): void;
-
- /**
- * Define function.
- * @param func: The function module.
- **/
- (func: () => any): void;
-
- /**
- * Define function with dependencies.
- * @param deps List of dependencies module IDs.
- * @param ready Callback function when the dependencies are loaded.
- * callback param deps module dependencies
- * callback return module definition
- **/
- (deps: string[], ready: Function): void;
-
- /**
- * Define module with simplified CommonJS wrapper.
- * @param ready
- * callback require requirejs instance
- * callback exports exports object
- * callback module module
- * callback return module definition
- **/
- (ready: (require: Require, exports: { [key: string]: any; }, module: RequireModule) => any): void;
-
- /**
- * Define a module with a name and dependencies.
- * @param name The name of the module.
- * @param deps List of dependencies module IDs.
- * @param ready Callback function when the dependencies are loaded.
- * callback deps module dependencies
- * callback return module definition
- **/
- (name: string, deps: string[], ready: Function): void;
-}
-
-// Ambient declarations for 'require' and 'define'
-declare var requirejs: Require;
-declare var require: Require;
-declare var define: RequireDefine;
diff --git a/require.js b/require.js
deleted file mode 120000
index 42d8353..0000000
--- a/require.js
+++ /dev/null
@@ -1 +0,0 @@
-../../../2014/projekty/zalmy/require.js \ No newline at end of file
diff --git a/sworker.js b/sworker.js
index 9ef7f56..3402c4e 100644
--- a/sworker.js
+++ b/sworker.js
@@ -1,4 +1,4 @@
-var VERSION = 'v59 - 2023-01-22';
+var VERSION = 'v60 - 2023-01-22';
var toCache = [
'/',
'activePage.js',
diff --git a/templates/base.html b/templates/base.html
index 5018bbe..a3b2091 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -22,7 +22,7 @@
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<title>{{ title }}</title>
- <script data-main="config" type="text/javascript" src="require.js" defer></script>
+ <script src="config.js" type="module" defer></script>
<style>
div#installButton {
display: none;