Skip to content

Commit

Permalink
switch to esm
Browse files Browse the repository at this point in the history
  • Loading branch information
xriss committed Jan 6, 2024
1 parent b2c74ea commit 044d4e3
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 71 deletions.
23 changes: 12 additions & 11 deletions code/js/arss.js
Expand Up @@ -6,19 +6,20 @@ See https://github.com/xriss/arss for full notice.
*/

const arss=exports

const stringify = require('json-stable-stringify')
let arss={}
export default arss

const jxml = require('./jxml.js')
const db = require('./db_idb.js')
const hoard = require('./hoard.js')
const feeds = require('./feeds.js')
const items = require('./items.js')
const gist = require('./gist.js')
const display = require('./display.js')
import { configure } from 'safe-stable-stringify'
const stringify = configure({})
import jxml from "./jxml.js"
import db from "./db_idb.js"
import hoard from "./hoard.js"
import feeds from "./feeds.js"
import items from "./items.js"
import gist from "./gist.js"
import display from "./display.js"


function getQueryVariable(variable) {
return ret
}
Expand Down
15 changes: 11 additions & 4 deletions code/js/cmd.js
Expand Up @@ -7,11 +7,18 @@ See https://github.com/xriss/arss for full notice.
*/

const cmd=exports;
let cmd={}
export default cmd

const pfs=require("fs").promises

const jml=require("./jxml.js")
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)


import { promises as pfs } from "fs"
import * as jml from "./jxml.js"


const ls=function(a) { console.log(util.inspect(a,{depth:null})); }
Expand Down Expand Up @@ -46,7 +53,7 @@ Test jxml code.
// if global.argv is set then we are inside another command so do nothing
if(!global.argv)
{
var argv = require('yargs').argv
var argv = {_:process.argv}
global.argv=argv
cmd.parse(argv)
cmd.run(argv)
Expand Down
9 changes: 7 additions & 2 deletions code/js/db_idb.js
Expand Up @@ -6,9 +6,14 @@ See https://github.com/xriss/arss for full notice.
*/

const db=exports
let db={}
export default db


import * as idb from "idb/with-async-ittr"



const idb = require( "idb/with-async-ittr" )

db.name="arss"

Expand Down
23 changes: 12 additions & 11 deletions code/js/display.js
Expand Up @@ -6,19 +6,20 @@ See https://github.com/xriss/arss for full notice.
*/

const display=exports
let display={}
export default display

const arss = require('./arss.js')
const gist = require('./gist.js')
const feeds = require('./feeds.js')
const items = require('./items.js')
const db = require('./db_idb.js')
const jxml = require('./jxml.js')
const hoard = require('./hoard.js')

//const { Readability } = require('@mozilla/readability');
import arss from "./arss.js"
import gist from "./gist.js"
import feeds from "./feeds.js"
import items from "./items.js"
import db from "./db_idb.js"
import jxml from "./jxml.js"
import hoard from "./hoard.js"

import sanihtml from "sanitize-html"

const sanihtml = require('sanitize-html');

display.element=function(html)
{
Expand Down Expand Up @@ -471,7 +472,7 @@ display.empty_feeds=async function(e)

display.add_feed=async function(e)
{
feed_url=window.prompt("URL of feed to add.","");
let feed_url=window.prompt("URL of feed to add.","");
if(feed_url)
{
let feed={}
Expand Down
21 changes: 13 additions & 8 deletions code/js/feeds.js
Expand Up @@ -6,16 +6,20 @@ See https://github.com/xriss/arss for full notice.
*/

const feeds=exports
let feeds={}
export default feeds


const hoard = require('./hoard.js')
const db = require('./db_idb.js')
const jxml = require('./jxml.js')
const items = require('./items.js')
const gist = require('./gist.js')
const display = require('./display.js')
const stringify = require('json-stable-stringify')
import arss from "./arss.js"
import display from "./display.js"
import gist from "./gist.js"
import items from "./items.js"
import db from "./db_idb.js"
import jxml from "./jxml.js"
import hoard from "./hoard.js"

import { configure } from 'safe-stable-stringify'
const stringify = configure({})

feeds.cached={}

Expand Down Expand Up @@ -257,6 +261,7 @@ feeds.fetch=async function(feed)
let before_count=items.add_count

let txt=await hoard.fetch_text(feed.url)
console.log(txt)

try{ feed.rss=jxml.parse_xml(txt,jxml.xmap.rss) }
catch(e){}
Expand Down
11 changes: 5 additions & 6 deletions code/js/gist.js
Expand Up @@ -6,14 +6,13 @@ See https://github.com/xriss/arss for full notice.
*/

const gist=exports
let gist={}
export default gist

//const { GithubGist } = require('@vighnesh153/github-gist');
const { Octokit } = require("@octokit/rest");


const db = require('./db_idb.js')
const arss = require('./arss.js')
import { Octokit } from "@octokit/rest"
import arss from "./arss.js"
import db from "./db_idb.js"

/*
Expand Down
11 changes: 7 additions & 4 deletions code/js/hoard.js
Expand Up @@ -6,11 +6,14 @@ See https://github.com/xriss/arss for full notice.
*/

const hoard=exports
let hoard={}
export default hoard


import arss from "./arss.js"
import db from "./db_idb.js"
import display from "./display.js"

const db = require('./db_idb.js')
const arss = require('./arss.js')
const display = require('./display.js')

hoard.test_probe=async function()
{
Expand Down
16 changes: 10 additions & 6 deletions code/js/items.js
Expand Up @@ -6,14 +6,18 @@ See https://github.com/xriss/arss for full notice.
*/

const items=exports
let items={}
export default items


const hoard = require('./hoard.js')
const db = require('./db_idb.js')
const jxml = require('./jxml.js')
const display = require('./display.js')
const stringify = require('json-stable-stringify')
import hoard from "./hoard.js"
import db from "./db_idb.js"
import jxml from "./jxml.js"
import display from "./display.js"

import { configure } from 'safe-stable-stringify'
const stringify = configure({})




Expand Down
20 changes: 10 additions & 10 deletions code/js/jxml.js
Expand Up @@ -6,7 +6,11 @@ See https://github.com/xriss/arss for full notice.
*/

const jxml=exports
let jxml={}
export default jxml


import * as sax from "sax"


jxml.xmap={}
Expand Down Expand Up @@ -38,7 +42,6 @@ jxml.xmap.atom={
}


const sax=require('sax')

jxml.sanistr=function(s)
{
Expand Down Expand Up @@ -219,11 +222,6 @@ jxml.build_xml=function(data)

data=jxml.expand(data) // fully expand so every sub tag is an array

/*
let stringify = require('json-stable-stringify');
console.log(stringify(data,{space:" "}))
*/

let parse
parse=function(it,paths)
{
Expand Down Expand Up @@ -270,10 +268,12 @@ jxml.build_xml=function(data)
return s
}

/*
jxml.test=async function(argv)
{
let stringify = require('json-stable-stringify');
let pfs=require("fs").promises
import { configure } from 'safe-stable-stringify'
const stringify = configure({})
import { promises as pfs } from 'fs'
argv.input=argv.input || "./plated/source/tmp/subscriptions.opml"
let txt=await pfs.readFile(argv.input,{ encoding: "utf8" })
Expand All @@ -283,4 +283,4 @@ jxml.test=async function(argv)
console.log(jxml.build_xml(ret))
}

*/
19 changes: 16 additions & 3 deletions code/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions code/package.json
@@ -1,7 +1,8 @@
{
"type": "module",
"name": "arss",
"description": "A rss reader.",
"version": "0.0.1",
"version": "0.1.1",
"license": "MIT",
"main": "js/cmd.js",
"browserify": {
Expand All @@ -22,8 +23,8 @@
"buffer": "^6.0.3",
"fs": "^0.0.1-security",
"idb": "^7.1.1",
"json-stable-stringify": "^1.0.2",
"plated": "^0.0.89",
"safe-stable-stringify": "^2.4.3",
"sanitize-html": "^2.10.0",
"sax": "^1.2.4",
"stream-browserify": "^3.0.0"
Expand Down
6 changes: 4 additions & 2 deletions code/webpack.config.js → code/webpack.config.cjs
Expand Up @@ -32,13 +32,15 @@ module.exports = {
maxEntrypointSize: 555555,
maxAssetSize: 555555,
},
experiments: {
outputModule: true,
},
output: {
path: path.resolve(__dirname, '../plated/source/js/'),
filename: 'arss.js',
globalObject: 'this',
library: {
name: 'arss',
type: 'umd',
type: 'module',
},
},
};
Expand Down
4 changes: 2 additions & 2 deletions plated/source/^.html
Expand Up @@ -7,8 +7,8 @@
<meta name="referrer" content="no-referrer"/>
<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><text x='-2' y='14'>🍑</text></svg>" />
<script src="{_root}js/arss.js"></script>
<script>
<script type="module" >
import arss from "{_root}js/arss.js"
arss.setup({})
</script>
{head}
Expand Down

0 comments on commit 044d4e3

Please sign in to comment.